runtime
skill_run 嵌入式 JavaScript 运行时能力矩阵(API、polyfill、限制)。编写或修复 skill_run 脚本前必读。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
skill_run 嵌入式 JavaScript 运行时能力矩阵(API、polyfill、限制)。编写或修复 skill_run 脚本前必读。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this skill.
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, deleting pages, creating new PDFs, and filling PDF forms. If the user mentions a .pdf file or asks to produce one, use this skill.
| name | runtime |
| description | skill_run 嵌入式 JavaScript 运行时能力矩阵(API、polyfill、限制)。编写或修复 skill_run 脚本前必读。 |
引擎:boa_engine(纯 Rust 嵌入式 JS,非 Node/V8)。语言:JavaScript only(无 TypeScript)。无网络、无 npm、无 shell。
async function main() {
// ...
return { ok: true }; // 必须 JSON 可序列化
}
// ❌ 不要在末尾写 main() — 运行时自动调用
// ❌ 不要用 ES module import — 见下方「模块」
自动 normalize(执行前):剥离 require('fs'|'exceljs'|…) 冗余行;常见 import … from '…' 改写成全局/require 等价;无 main 时自动包裹 async function main() { … };移除末尾 main() 调用。
| 方式 | 说明 |
|---|---|
| 全局 | ExcelJS、PptxGenJS、docx、PDFLib(bundle 按需加载后可用) |
require(id) | 白名单:fs、path、exceljs、pptxgenjs、docx、pdf-lib |
import | 不支持 ESM;单行 import 由 normalize 改写,无法识别则报错 |
Bundle 按代码关键字注入(含 pptxgenjs / PptxGenJS / docx / exceljs / pdf-lib)。仅路径字符串 .pptx 不会加载 pptxgenjs。
| API | 说明 |
|---|---|
doc_read(path) | 读文件 → base64 字符串 |
doc_write(path, b64) | 写文件(base64) |
doc_write_bytes(path, Uint8Array) | 写二进制 |
doc_exists(path) | 沙箱内路径是否存在(bool) |
doc_list(path?) | 列目录直接子项 → [{ name, is_dir }, …](默认 ".") |
fs.readFileSync(path, 'utf-8' | 'base64') | 文本或 base64;无 encoding → Buffer 字节 |
fs.writeFileSync(path, data, 'utf-8') | 文本或字节写入 |
fs.existsSync(path) | 同 doc_exists |
fs.readdirSync(path) | 同 doc_list 的 name 数组(无 is_dir 时用 doc_list) |
path.join / dirname / basename | 最小 path shim |
await wb.xlsx.writeFile('out.xlsx')await pptx.writeFile({ fileName: 'deck.pptx' })await docx.Packer.toBase64String(doc) → doc_write('out.docx', b64)setTimeout/setImmediate:无真实延迟(微任务);console.* → doc_log;Buffer、TextEncoder/TextDecoder、btoa/atob、crypto.getRandomValues。
fetch、无任意 npm 包、无 child_processtimeout_secs)ooxml_unpack(省略 out_dir),用返回的 out_dir 拼 XML 路径(自动目录在 .cache/ooxml/ 下,段名为短 hash);列 slide 用 doc_list('<out_dir>/ppt/slides')script_path 或错误 JSON,错误含行列号fs_patch 局部修复(勿 fs_write 整文件重写)skill_run {"path":"<script_path>"} 重跑script.js 在同 session 内跨 turn 保留;error.json 仅在失败时存在,修复成功后删除;用户 cancel turn 时删除 scratch 目录docx 生成:
async function main() {
const { Document, Packer, Paragraph, TextRun } = docx;
const doc = new Document({ sections: [{ children: [new Paragraph({ children: [new TextRun("Hi")] })] }] });
const b64 = await Packer.toBase64String(doc);
doc_write("out.docx", b64);
return { ok: true };
}
OOXML fs 编辑:
async function main() {
const xmlPath = "<out_dir>/word/document.xml";
let xml = fs.readFileSync(xmlPath, "utf-8");
xml = xml.replace("OLD", "NEW");
fs.writeFileSync(xmlPath, xml, "utf-8");
return { ok: true };
}