Git 提交前工作流(編排器 + Pre-Commit Hooks)
Copilot Hooks(寫作時即時修正)定義於 auto-paper/SKILL.md。
Pre-Commit Hooks(本檔,git commit 前最終把關)只報告不自動修改。
觸發:「commit」「推送」「做完了」「收工」「快速 commit」
Step 0: 偵測變更範圍
get_changed_files() 或 git diff --cached --name-only。
論文檔案模式:projects/*/drafts/*, projects/*/concept.md, projects/*/references/*, projects/*/.memory/*
→ 匹配時觸發 Paper Hooks。
通用 Hooks(每次觸發)
| Hook |
條件 |
動作 |
MCP Tools |
| G1 memory-sync |
必要 |
更新 Memory Bank + workspace state |
memory_bank_update_progress, workspace_state_action(action="sync") |
| G2 readme-update |
新功能/API 變更 |
更新 README |
read_file, replace_string_in_file |
| G3 changelog-update |
版本/重要修改 |
更新 CHANGELOG |
同上 |
| G4 roadmap-update |
里程碑完成 |
更新 ROADMAP |
同上 |
| G5 arch-check |
結構性變更 |
檢查架構文檔 |
grep_search, list_dir |
| G6 project-integrity |
SKILL/AGENTS/src 變更 |
專案一致性審計 |
見下方 |
| G7 vsx-integrity |
skills/prompts/vsx 變更 |
VSX Extension 同步 |
見下方 |
| G8 doc-update-reminder |
任何程式/設定變更 |
提醒需更新的文檔 |
scripts/check-doc-updates.py (pre-commit hook) |
| G9 git-status-check |
必要 |
偵測未 commit/未 push(Code-Enforced) |
run_quality_checks(action="writing_hooks", hooks="G9") |
G6 專案一致性審計
| # |
檢查 |
方法 |
失敗 |
| G6.1 |
Tool 數量 |
grep -c "mcp.tool" vs README/ARCHITECTURE |
⚠️ WARN |
| G6.2 |
Skill 數量 |
ls -d .claude/skills/*/ vs AGENTS.md |
⚠️ WARN |
| G6.3 |
Prompt 數量 |
ls .github/prompts/*.prompt.md vs 文檔 |
⚠️ WARN |
| G6.4 |
Hook 工具存在 |
SKILL.md 中 mcp_mdpaper_* → 已註冊 |
❌ FAIL |
| G6.5 |
跨文件數字一致 |
README vs ARCHITECTURE vs AGENTS |
⚠️ WARN |
G7 VSX Extension 同步
| # |
檢查 |
方法 |
失敗 |
| G7.1 |
Skills 同步 |
diff source vs bundled |
⚠️ WARN |
| G7.2 |
Prompts 同步 |
diff source vs bundled |
⚠️ WARN |
| G7.3 |
Chat commands |
package.json chatParticipants |
❌ FAIL |
| G7.4 |
Version semver |
格式驗證 |
❌ FAIL |
| G7.5 |
TypeScript 編譯 |
tsc --noEmit |
⚠️ WARN |
快速修復:cd vscode-extension && ./scripts/build.sh
Paper Hooks(偵測到論文變更時)
| Hook |
檢查 |
MCP Tools |
判定 |
| P1 citation-integrity |
[[wikilinks]] 可解析 |
scan_draft_citations, validate_wikilinks |
0 unresolved = ✅, unknown = ❌ |
| P2 anti-ai-scan |
AI 痕跡用詞 |
read_draft + Agent 掃描 |
0 = ✅, 1-2 = ⚠️, ≥3 = ❌ |
| P3 concept-alignment |
NOVELTY/SELLING POINTS 體現 |
read_draft("concept.md") + drafts |
完整 = ✅, 部分 = ⚠️, NOVELTY 缺 = ❌ |
| P4 word-count |
各 section ±20% |
count_words |
超 50% = ❌ |
| P5 protected-content |
🔒 區塊存在且非空 |
read_draft("concept.md") |
缺失 = ❌ |
| P6 memory-sync |
.memory/ 已更新 |
workspace_state_action(action="sync") |
未更新 = AUTO-FIX |
| P7 reference-integrity |
文獻 metadata 完整 |
list_saved_references, get_reference_details |
非 VERIFIED = ⚠️ |
| P8 methodology |
Methods 可再現 |
read_draft + Agent checklist |
項目 <3 = ❌ |
P2 Anti-AI 禁止詞:In recent years, It is worth noting, plays a crucial role, has garnered significant attention, a comprehensive understanding, This groundbreaking, delve into, shed light on, pave the way, a myriad of
P8 與 Copilot Hook B5 互補:B5 寫作時即時修正,P8 提交時最終確認(safety net)。
Hook 效能追蹤(§23 Self-Improving)
每次執行後記錄 projects/{slug}/.audit/precommit-stats.md:觸發率/通過率/警告率/阻止率。
- 通過率 >95%(5次+)→ 可能太鬆
- 阻止率 >50%(5次+)→ 可能太嚴
- 記錄供 auto-paper Hook D 分析
執行模式
| 模式 |
觸發 |
執行 |
| 標準 |
「準備 commit」 |
Step 0 → G1-G7 → P1-P8(如適用)→ Final |
| 快速 |
「快速 commit」 |
G1 + P1 + P5(如適用)→ Final |
| 開發 |
「commit code」 |
G1-G7(跳過 Paper Hooks)→ Final |
Git 操作
Commit Message 格式:type(scope): description
- Types: feat, fix, docs, refactor, style, test, chore
- Scope: paper, concept, refs, export, core
Skill 依賴
| Hook |
編排 Skill |
工具 |
| G1 |
memory-updater |
memory_bank_update_progress |
| G2-G4 |
readme/changelog/roadmap-updater |
read_file, replace_string_in_file |
| G5 |
ddd-architect |
grep_search, list_dir |
| P1-P4 |
draft-writing |
read_draft, count_words, validate_wikilinks |
| P3,P5,P8 |
concept-development |
read_draft("concept.md") |
| P7 |
reference-management |
list_saved_references, get_reference_details |
1---2name: git-precommit3description: 提交前編排器 + Paper-Aware Pre-Commit Hooks。 LOAD THIS SKILL WHEN: commit、提交、推送、做完了、收工 CAPABILITIES: 記憶同步、文檔更新、Paper 品質把關、Git 操作4---56# Git 提交前工作流(編排器 + Pre-Commit Hooks)78Copilot Hooks(寫作時即時修正)定義於 `auto-paper/SKILL.md`。9Pre-Commit Hooks(本檔,git commit 前最終把關)只報告不自動修改。1011觸發:「commit」「推送」「做完了」「收工」「快速 commit」1213---1415## Step 0: 偵測變更範圍1617`get_changed_files()` 或 `git diff --cached --name-only`。18論文檔案模式:`projects/*/drafts/*`, `projects/*/concept.md`, `projects/*/references/*`, `projects/*/.memory/*`19→ 匹配時觸發 Paper Hooks。2021---2223## 通用 Hooks(每次觸發)2425| Hook | 條件 | 動作 | MCP Tools |26| -------------------------- | ----------------------- | -------------------------------------- | ---------------------------------------------------------------------- |27| **G1** memory-sync | 必要 | 更新 Memory Bank + workspace state | `memory_bank_update_progress`, `workspace_state_action(action="sync")` |28| **G2** readme-update | 新功能/API 變更 | 更新 README | `read_file`, `replace_string_in_file` |29| **G3** changelog-update | 版本/重要修改 | 更新 CHANGELOG | 同上 |30| **G4** roadmap-update | 里程碑完成 | 更新 ROADMAP | 同上 |31| **G5** arch-check | 結構性變更 | 檢查架構文檔 | `grep_search`, `list_dir` |32| **G6** project-integrity | SKILL/AGENTS/src 變更 | 專案一致性審計 | 見下方 |33| **G7** vsx-integrity | skills/prompts/vsx 變更 | VSX Extension 同步 | 見下方 |34| **G8** doc-update-reminder | 任何程式/設定變更 | 提醒需更新的文檔 | `scripts/check-doc-updates.py` (pre-commit hook) |35| **G9** git-status-check | 必要 | 偵測未 commit/未 push(Code-Enforced) | `run_quality_checks(action="writing_hooks", hooks="G9")` |3637### G6 專案一致性審計3839| # | 檢查 | 方法 | 失敗 |40| ---- | -------------- | ------------------------------------------- | ------- |41| G6.1 | Tool 數量 | `grep -c "mcp.tool"` vs README/ARCHITECTURE | ⚠️ WARN |42| G6.2 | Skill 數量 | `ls -d .claude/skills/*/` vs AGENTS.md | ⚠️ WARN |43| G6.3 | Prompt 數量 | `ls .github/prompts/*.prompt.md` vs 文檔 | ⚠️ WARN |44| G6.4 | Hook 工具存在 | SKILL.md 中 `mcp_mdpaper_*` → 已註冊 | ❌ FAIL |45| G6.5 | 跨文件數字一致 | README vs ARCHITECTURE vs AGENTS | ⚠️ WARN |4647### G7 VSX Extension 同步4849| # | 檢查 | 方法 | 失敗 |50| ---- | --------------- | ----------------------------- | ------- |51| G7.1 | Skills 同步 | `diff` source vs bundled | ⚠️ WARN |52| G7.2 | Prompts 同步 | `diff` source vs bundled | ⚠️ WARN |53| G7.3 | Chat commands | package.json chatParticipants | ❌ FAIL |54| G7.4 | Version semver | 格式驗證 | ❌ FAIL |55| G7.5 | TypeScript 編譯 | `tsc --noEmit` | ⚠️ WARN |5657快速修復:`cd vscode-extension && ./scripts/build.sh`5859---6061## Paper Hooks(偵測到論文變更時)6263| Hook | 檢查 | MCP Tools | 判定 |64| -------------------------- | --------------------------- | ------------------------------------------------ | ------------------------------------- |65| **P1** citation-integrity | `[[wikilinks]]` 可解析 | `scan_draft_citations`, `validate_wikilinks` | 0 unresolved = ✅, unknown = ❌ |66| **P2** anti-ai-scan | AI 痕跡用詞 | `read_draft` + Agent 掃描 | 0 = ✅, 1-2 = ⚠️, ≥3 = ❌ |67| **P3** concept-alignment | NOVELTY/SELLING POINTS 體現 | `read_draft("concept.md")` + drafts | 完整 = ✅, 部分 = ⚠️, NOVELTY 缺 = ❌ |68| **P4** word-count | 各 section ±20% | `count_words` | 超 50% = ❌ |69| **P5** protected-content | 🔒 區塊存在且非空 | `read_draft("concept.md")` | 缺失 = ❌ |70| **P6** memory-sync | `.memory/` 已更新 | `workspace_state_action(action="sync")` | 未更新 = AUTO-FIX |71| **P7** reference-integrity | 文獻 metadata 完整 | `list_saved_references`, `get_reference_details` | 非 VERIFIED = ⚠️ |72| **P8** methodology | Methods 可再現 | `read_draft` + Agent checklist | 項目 <3 = ❌ |7374P2 Anti-AI 禁止詞:`In recent years`, `It is worth noting`, `plays a crucial role`, `has garnered significant attention`, `a comprehensive understanding`, `This groundbreaking`, `delve into`, `shed light on`, `pave the way`, `a myriad of`7576P8 與 Copilot Hook B5 互補:B5 寫作時即時修正,P8 提交時最終確認(safety net)。7778---7980## Hook 效能追蹤(§23 Self-Improving)8182每次執行後記錄 `projects/{slug}/.audit/precommit-stats.md`:觸發率/通過率/警告率/阻止率。8384- 通過率 >95%(5次+)→ 可能太鬆85- 阻止率 >50%(5次+)→ 可能太嚴86- 記錄供 auto-paper Hook D 分析8788---8990## 執行模式9192| 模式 | 觸發 | 執行 |93| ---- | --------------- | --------------------------------------- |94| 標準 | 「準備 commit」 | Step 0 → G1-G7 → P1-P8(如適用)→ Final |95| 快速 | 「快速 commit」 | G1 + P1 + P5(如適用)→ Final |96| 開發 | 「commit code」 | G1-G7(跳過 Paper Hooks)→ Final |9798---99100## Git 操作101102Commit Message 格式:`type(scope): description`103104- Types: feat, fix, docs, refactor, style, test, chore105- Scope: paper, concept, refs, export, core106107---108109## Skill 依賴110111| Hook | 編排 Skill | 工具 |112| -------- | -------------------------------- | ------------------------------------------------- |113| G1 | memory-updater | `memory_bank_update_progress` |114| G2-G4 | readme/changelog/roadmap-updater | `read_file`, `replace_string_in_file` |115| G5 | ddd-architect | `grep_search`, `list_dir` |116| P1-P4 | draft-writing | `read_draft`, `count_words`, `validate_wikilinks` |117| P3,P5,P8 | concept-development | `read_draft("concept.md")` |118| P7 | reference-management | `list_saved_references`, `get_reference_details` |