1实现原理 · 为什么它能做到
职责二分:内容层面的分析/重构由模型按 SKILL.md 的步骤做(Step 1-5),排版层面的确定性修复交给自带脚本(Step 6)。
Claude performs content analysis and formatting (Steps 1-5), then runs the script for typography fixes (Step 6).
核心纪律是『只调格式、不碰内容』:不改写、不增删、不加评论性内容。
**Core principle**: Only adjust formatting and fix obvious typos. Never add, delete, or rewrite content.
脚本主体是 unified/remark 管线:解析 → 可选 CJK 友好强调修复 → GFM/frontmatter → stringify,然后原地写回文件。
.use(options.emphasis ? remarkCjkFriendly : [])
CJK/英文间距不是自己实现,而是运行时调用 npx autocorrect-node --fix 就地改文件。
const result = spawnSync(npxCmd, ["autocorrect-node", "--fix", filePath], {
可选的引号规范化:把成对 ASCII 双引号与「」替换为全角弯引号。
.replace(/"([^"]+)"/g, "\u201c$1\u201d")
标题生成走可复用公式库:references/title-formulas.md 提供 8 个 hook 公式 + 直白型,输出 4-5 个候选交给用户选。
8 hook formulas + straightforward style for balanced title generation.
frontmatter 字段有固定加工规则:title/slug/summary/description/coverImage,summary 与 description 双版本且长度有指标。
| `summary` | 1 sentence, ~50-80 chars | Concise hook — for feeds, social sharing, SEO meta |
写盘纪律:输出 {filename}-formatted.md,覆盖前先按时间戳备份;分析文档 {original-filename}-analysis.md 作为改稿依据保留。
mv "{filename}-formatted.md" "{filename}-formatted.backup-$(date +%Y%m%d-%H%M%S).md"
2核心能力
3外部依赖
| Kind | Dependency / Endpoint |
|---|---|
| cli | npx autocorrect-node --fix(CJK/英文间距修复) |
| package | remark-cjk-friendly |
| package | remark-parse / remark-stringify / remark-gfm / remark-frontmatter / unified / unist-util-visit / yaml |
| cli | bun(首选运行时;无 bun 时 npx -y bun) |
4管控建议与判定依据
- scripts/: 执行本地脚本或命令: bun {baseDir}/scripts/main.ts <file.md> [--quotes/--no-spacing/--no-emphasi
- 网络端点: 声明外部网络访问: registry.npmjs.org:npx 拉取 autocorrect-node(未在本仓锁定版本);首跑后由 npm 缓存
- 本地工作目录: 文件读写与工件输出: 原地写回被处理的 .md(main.ts 的 writeFileSync,quotes/emphasis 阶段;『仅排版修复』路径直接改用户原文件)
5第二遍独立确认
- [ok] 『模型做内容、脚本做排版』的两段式划分 — SKILL.md Workflow 段逐字:'Claude performs content analysis and formatting (Steps 1-5), then runs the script for typography fixes (Step 6).' 与脚本能力一致(脚本无内容改写逻辑)。
- [ok] 脚本的确定性修复项与默认值 — main.ts DEFAULT_OPTIONS={quotes:false, spacing:true, emphasis:true};--quotes/--no-spacing/--no-emphasis 均有对应分支;与 SKILL.md 选项表一致。
- [ok] npx autocorrect-node 为唯一外部命令调用 — 全目录 grep spawn/exec/npx 仅 autocorrect.ts 命中一处;main.ts 只有 readFileSync/writeFileSync。
- [ok] 外部依赖清单完整性 — package.json 声明 8 个包(remark 生态 + unified + yaml),另加运行时 npx 的 autocorrect-node;全目录无任何 http 端点/API 调用。
- [ok] 无凭证读取 — 目录内 token 扫描 API_KEY/TOKEN/SECRET/.env/keychain 零命中;仅读取 EXTEND.md 偏好(路径在 SKILL.md 明列)。
- [ok] 标题公式库内容与『8 个公式』一致 — references/title-formulas.md 首行 '8 hook formulas + straightforward style for balanced title generation.',表格确为 8 行 hook(Subversive…Empathy)。
- [ok] 『仅排版修复』会原地改用户文件 — SKILL.md 第三条路径写明 'Run typography script on original file in-place / No copy created, modifies original file directly',与 main.ts writeFileSync(filePath…) 行为一致,已列为使用注意。
- [ok] 元数据(license/stars/commit) — git HEAD=1567581c26ec29f4216c6e6835415bf30343b0e3;仓库根 LICENSE=MIT(Copyright (c) 2026 Jim Liu);GitHub API stars=25926、pushed_at=2026-09-10T15:13:43Z。
6结论
6367312d8f2334bb…