SuperAPI AI Directory

code-rules

Coding & development

View repository

Updated 10-15 19:17

About this skill

Code Generation Standards

Must comply

  1. Only use var to declare variables
  2. Do not use arrow functions =>
  3. Do not use let、const、class, template literals
  4. The last line of the code must return a string result
  5. The total code length must not exceed 3000 characters

Security Standards

  1. Wrap all document operations in try/catch
  2. Check object existence before operations
  3. Do not delete content outside the selection (unless explicitly required)
  4. Confirm the paragraph count before bulk modifications
  5. Do not modify document properties (author, date, etc.) unless explicitly required

Return Value Standards

// 好的返回值
return "已替换选区文本(原 120 字 → 新 85 字)";
return "已插入 3 行 × 4 列表格";
return "已将全文 28 个段落的字体设为微软雅黑 12pt";

// 差的返回值
return "done";
return undefined; // 忘记返回

Error Handling

var doc = Application.ActiveDocument;
if (!doc) return "无活动文档,请先打开一个文档";

var sel = Application.Selection;
if (!sel.Text || sel.Text.trim().length === 0) {
  return "请先选中要操作的文本";
}

try {
  // ... 操作
  return "操作成功";
} catch (e) {
  return "操作失败: " + (e.message || String(e));
}