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 つのフック公式+ストレート型に基づき、4〜5 個の候補を出力してユーザーに選ばせます。
8 hook formulas + straightforward style for balanced title generation.
frontmatter フィールドには固定の処理ルールが存在:title/slug/summary/description/coverImage を扱い、summary と description は文字数要件を伴う 2 系統を用意します。
| `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 の quotes/emphasis フェーズにおける writeFileSync、「組版修正のみ」パスではユーザーの元ファイルを直接変更)
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…