architext 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE +21 -0
  3. package/README.md +326 -0
  4. package/README.zh-CN.md +326 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +46 -0
  7. package/dist/templates/en/briefs/_base.md +115 -0
  8. package/dist/templates/en/briefs/_modules.md +173 -0
  9. package/dist/templates/en/docs/global/data_snapshot.json +31 -0
  10. package/dist/templates/en/docs/global/design_tokens.json +150 -0
  11. package/dist/templates/en/docs/global/dictionary.json +35 -0
  12. package/dist/templates/en/docs/global/error_codes.json +19 -0
  13. package/dist/templates/en/docs/global/map.json +94 -0
  14. package/dist/templates/en/docs/global/roadmap.json +39 -0
  15. package/dist/templates/en/docs/global/vision.md +82 -0
  16. package/dist/templates/en/docs/prompts/audit.md +150 -0
  17. package/dist/templates/en/docs/prompts/code.md +160 -0
  18. package/dist/templates/en/docs/prompts/edit.md +87 -0
  19. package/dist/templates/en/docs/prompts/fix.md +86 -0
  20. package/dist/templates/en/docs/prompts/help.md +69 -0
  21. package/dist/templates/en/docs/prompts/inherit.md +270 -0
  22. package/dist/templates/en/docs/prompts/map.md +131 -0
  23. package/dist/templates/en/docs/prompts/plan.md +252 -0
  24. package/dist/templates/en/docs/prompts/remove.md +162 -0
  25. package/dist/templates/en/docs/prompts/revise.md +160 -0
  26. package/dist/templates/en/docs/prompts/scope.md +198 -0
  27. package/dist/templates/en/docs/prompts/start.md +258 -0
  28. package/dist/templates/en/docs/templates/plan.template.json +113 -0
  29. package/dist/templates/en/docs/templates/scope-brief.template.md +58 -0
  30. package/dist/templates/en/docs/templates/spec.template.md +51 -0
  31. package/dist/templates/en/docs/templates/ui.template.md +51 -0
  32. package/dist/templates/en/rules/00_system.md +123 -0
  33. package/dist/templates/en/rules/01_workflow.md +93 -0
  34. package/dist/templates/en/rules/02_tech_stack.md +197 -0
  35. package/dist/templates/en/rules/03_data_governance.md +102 -0
  36. package/dist/templates/en/rules/04_cli_tools.md +50 -0
  37. package/dist/templates/en/rules/90_custom_rules.md +22 -0
  38. package/dist/templates/en/rules/99_context_glue.md +53 -0
  39. package/dist/templates/en/skills/archi-decompose-roadmap/SKILL.md +292 -0
  40. package/dist/templates/en/skills/archi-interview-protocol/SKILL.md +86 -0
  41. package/dist/templates/en/skills/archi-plan-options/SKILL.md +364 -0
  42. package/dist/templates/en/skills/archi-ui-wireframe/SKILL.md +342 -0
  43. package/dist/templates/zh/briefs/_base.md +116 -0
  44. package/dist/templates/zh/briefs/_modules.md +173 -0
  45. package/dist/templates/zh/docs/global/data_snapshot.json +31 -0
  46. package/dist/templates/zh/docs/global/design_tokens.json +135 -0
  47. package/dist/templates/zh/docs/global/dictionary.json +35 -0
  48. package/dist/templates/zh/docs/global/error_codes.json +19 -0
  49. package/dist/templates/zh/docs/global/map.json +94 -0
  50. package/dist/templates/zh/docs/global/roadmap.json +39 -0
  51. package/dist/templates/zh/docs/global/vision.md +82 -0
  52. package/dist/templates/zh/docs/prompts/audit.md +150 -0
  53. package/dist/templates/zh/docs/prompts/code.md +160 -0
  54. package/dist/templates/zh/docs/prompts/edit.md +87 -0
  55. package/dist/templates/zh/docs/prompts/fix.md +86 -0
  56. package/dist/templates/zh/docs/prompts/help.md +69 -0
  57. package/dist/templates/zh/docs/prompts/inherit.md +270 -0
  58. package/dist/templates/zh/docs/prompts/map.md +131 -0
  59. package/dist/templates/zh/docs/prompts/plan.md +253 -0
  60. package/dist/templates/zh/docs/prompts/remove.md +162 -0
  61. package/dist/templates/zh/docs/prompts/revise.md +160 -0
  62. package/dist/templates/zh/docs/prompts/scope.md +198 -0
  63. package/dist/templates/zh/docs/prompts/start.md +258 -0
  64. package/dist/templates/zh/docs/templates/plan.template.json +88 -0
  65. package/dist/templates/zh/docs/templates/scope-brief.template.md +58 -0
  66. package/dist/templates/zh/docs/templates/spec.template.md +51 -0
  67. package/dist/templates/zh/docs/templates/ui.template.md +51 -0
  68. package/dist/templates/zh/rules/00_system.md +123 -0
  69. package/dist/templates/zh/rules/01_workflow.md +93 -0
  70. package/dist/templates/zh/rules/02_tech_stack.md +192 -0
  71. package/dist/templates/zh/rules/03_data_governance.md +102 -0
  72. package/dist/templates/zh/rules/04_cli_tools.md +50 -0
  73. package/dist/templates/zh/rules/90_custom_rules.md +21 -0
  74. package/dist/templates/zh/rules/99_context_glue.md +53 -0
  75. package/dist/templates/zh/skills/archi-decompose-roadmap/SKILL.md +293 -0
  76. package/dist/templates/zh/skills/archi-interview-protocol/SKILL.md +86 -0
  77. package/dist/templates/zh/skills/archi-plan-options/SKILL.md +364 -0
  78. package/dist/templates/zh/skills/archi-ui-wireframe/SKILL.md +339 -0
  79. package/dist/templates/zh-Hant/briefs/_base.md +115 -0
  80. package/dist/templates/zh-Hant/briefs/_modules.md +173 -0
  81. package/dist/templates/zh-Hant/docs/global/data_snapshot.json +31 -0
  82. package/dist/templates/zh-Hant/docs/global/design_tokens.json +135 -0
  83. package/dist/templates/zh-Hant/docs/global/dictionary.json +35 -0
  84. package/dist/templates/zh-Hant/docs/global/error_codes.json +19 -0
  85. package/dist/templates/zh-Hant/docs/global/map.json +94 -0
  86. package/dist/templates/zh-Hant/docs/global/roadmap.json +39 -0
  87. package/dist/templates/zh-Hant/docs/global/vision.md +82 -0
  88. package/dist/templates/zh-Hant/docs/prompts/audit.md +150 -0
  89. package/dist/templates/zh-Hant/docs/prompts/code.md +160 -0
  90. package/dist/templates/zh-Hant/docs/prompts/edit.md +87 -0
  91. package/dist/templates/zh-Hant/docs/prompts/fix.md +86 -0
  92. package/dist/templates/zh-Hant/docs/prompts/help.md +69 -0
  93. package/dist/templates/zh-Hant/docs/prompts/inherit.md +270 -0
  94. package/dist/templates/zh-Hant/docs/prompts/map.md +131 -0
  95. package/dist/templates/zh-Hant/docs/prompts/plan.md +252 -0
  96. package/dist/templates/zh-Hant/docs/prompts/remove.md +162 -0
  97. package/dist/templates/zh-Hant/docs/prompts/revise.md +160 -0
  98. package/dist/templates/zh-Hant/docs/prompts/scope.md +198 -0
  99. package/dist/templates/zh-Hant/docs/prompts/start.md +258 -0
  100. package/dist/templates/zh-Hant/docs/templates/plan.template.json +88 -0
  101. package/dist/templates/zh-Hant/docs/templates/scope-brief.template.md +58 -0
  102. package/dist/templates/zh-Hant/docs/templates/spec.template.md +51 -0
  103. package/dist/templates/zh-Hant/docs/templates/ui.template.md +51 -0
  104. package/dist/templates/zh-Hant/rules/00_system.md +123 -0
  105. package/dist/templates/zh-Hant/rules/01_workflow.md +93 -0
  106. package/dist/templates/zh-Hant/rules/02_tech_stack.md +192 -0
  107. package/dist/templates/zh-Hant/rules/03_data_governance.md +102 -0
  108. package/dist/templates/zh-Hant/rules/04_cli_tools.md +50 -0
  109. package/dist/templates/zh-Hant/rules/90_custom_rules.md +21 -0
  110. package/dist/templates/zh-Hant/rules/99_context_glue.md +53 -0
  111. package/dist/templates/zh-Hant/skills/archi-decompose-roadmap/SKILL.md +293 -0
  112. package/dist/templates/zh-Hant/skills/archi-interview-protocol/SKILL.md +86 -0
  113. package/dist/templates/zh-Hant/skills/archi-plan-options/SKILL.md +364 -0
  114. package/dist/templates/zh-Hant/skills/archi-ui-wireframe/SKILL.md +337 -0
  115. package/package.json +85 -0
@@ -0,0 +1,160 @@
1
+ <protocol_code>
2
+ **Trigger**: `/archi.code <id>`
3
+ **Goal**: 基於 `tasks/<id>_<Slug>/plan.json` 任務清單,完成功能開發;遵循 `02_tech_stack.md`([?UI] 同時遵循 `design_tokens.json`);通過建置、型別、Lint、格式化、測試與審計。
4
+
5
+ <meta>
6
+ <style>Deterministic, Type-Safe, SOTA-First</style>
7
+ <language>繁體中文</language>
8
+ <principles>
9
+ 1. **Frontmatter Preservation**: 禁改已有檔案的 YAML Frontmatter。
10
+ 2. **Follow Conventions**: 僅用儲存庫已有庫與模式;先讀後改。
11
+ 3. **Security First**: 禁引入/列印密鑰;敏感資訊不落盤。
12
+ 4. **SOTA Pattern Check**: 拒絕過時寫法;採用 tech_stack 定義的最佳實務。
13
+ 5. **No Commit Policy**: 未經授權不提交;以補丁呈現變更。
14
+ 6. **Static Check First**: 須通過所有靜態檢查(型別/Lint/格式化)。
15
+ 7. **Plan Completion Gate**: 結束前驗證 Plan 完成度。AI 可完成的任務須全部完成,僅豁免「人工介入」和「不可抗力」類。
16
+ </principles>
17
+ </meta>
18
+
19
+ <step_1_resolve>
20
+ **Role**: 系統分析師
21
+ **Action**:
22
+ 1. **Resolve ID**: 從 `[[__DOCS_DIR__]]/global/roadmap.json` 解析 `<id>` → Task Name、Slug、階段/狀態。
23
+ 2. **Status Gate** — 僅 `active` 可進入 code 流程:
24
+
25
+ | 狀態 | 處理 |
26
+ |:---|:---|
27
+ | `active` 🟢 | 通過,繼續 |
28
+ | `pending` ⏳ | 拒絕 — 提示先執行 `/archi.plan <ID>` |
29
+ | `blocked` 🧱 | 拒絕 — 前置依賴未完成 |
30
+ | `done` ✅ | 拒絕 — 已完成,如需修改用 `/archi.edit <ID>` |
31
+
32
+ 3. **Load Context** (用 Roadmap `📁 Slug` 定位):
33
+ - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/spec.md` — 邏輯與場景
34
+ - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/ui.md` — 本任務 UI 範圍聲明(如存在)
35
+ - [?UI] `[[__DOCS_DIR__]]/global/ui_context.md` — AI 畫面索引(畫面 ID/路由/狀態/導覽關係/共享元件)
36
+ - [?UI] `[[__DOCS_DIR__]]/global/ui_concept.html` — 唯讀視覺參考(實作時以此校準布局結構,禁基於此重新設計,設計已在 ui.md 確定)
37
+ - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/plan.json` — 任務拆解(含 `notes` 速記,執行時須參照)
38
+ - `02_tech_stack.md` — 技術紅線
39
+ - [?UI] `[[__DOCS_DIR__]]/global/design_tokens.json`
40
+ - [?Data] `[[__DOCS_DIR__]]/global/data_snapshot.json`
41
+
42
+ **Output**: 待實施任務的原子清單,標註依賴與順序。
43
+ </step_1_resolve>
44
+
45
+ <step_2_plan>
46
+ **Role**: Tech Lead
47
+ **Action**:
48
+ 生成執行藍圖(根據專案型別動態調整):
49
+ - **Phase A (Domain/Data/API)**: 資料模型/介面/校驗
50
+ - **Phase B (UI/Presentation)**: 元件結構/樣式(僅用 Design Token);非 UI 專案調整為對應展示層
51
+ - **Phase C (Integration)**: 端到端串聯(狀態管理、路由、資料流、錯誤處理)
52
+
53
+ 每項任務寫出完成判定標準:靜態檢查通過、測試通過、符合 tech_stack 規範。
54
+
55
+ **Output**: 面向實施的原子任務列表(Checkbox)。
56
+ </step_2_plan>
57
+
58
+ <step_3_implement>
59
+ **Role**: 資深工程師
60
+ **Protocol**:
61
+ - **Read First**: 修改前須讀取目標檔案;遵循專案現有程式碼風格。
62
+ - **Use Existing Stack**: 僅用 `02_tech_stack.md` 宣告的技術與庫。
63
+ - [?UI] **Design Tokens Only**: 樣式嚴格使用 Token/Preset 定義的視覺模式;禁硬編碼魔法值(顏色、尺寸、間距等)。
64
+ - **Type-Safe**: 補齊型別定義;用專案技術棧的型別系統守護邊界。
65
+ - **Code Organization**: 遵循 `02_tech_stack.md` 中定義的架構模式與檔案歸位策略。
66
+ - **Comments**: 解釋 Why 而非 What;拒絕廢話註解。
67
+ - **Naming**: 自解釋命名;拒絕 `a`, `b`, `tmp` 等無意義名(迴圈變數 `i` 除外)。
68
+ - **Error Handling**: 禁吞錯/禁靜默失敗;須正確傳播錯誤並給呼叫方可觀測回饋(UI: Toast;CLI: Exit Code;API: Status Code + Body)。
69
+ - **Robustness**: 顯式處理邊界(Loading/Error/Empty/Timeout);禁只寫 Happy Path。
70
+ - **SOTA**: 遵循 tech_stack 定義的最佳實務;拒絕明確禁止的過時模式。
71
+ - **Scaffold Safety**: 鷹架在非空目錄可能覆蓋檔案 — 須在新目錄生成並保護 `[[__DOCS_DIR__]]/`;刪除/覆蓋操作須先列清單並確認。
72
+ - **.gitkeep Cleanup**: 空目錄可用 `.gitkeep` 占位以便 Git 追蹤;向目錄新增其他檔案時須刪除該目錄下的 `.gitkeep`。
73
+ - **Patch Output**: 以補丁形式輸出變更,附 Code Reference。
74
+ - **Progress Tracking**: 每完成一個 task 後,立即更新 `plan.json` 對應 task 的 `done: true`;禁在 signoff 時批次更新(會話中斷後進度將丟失)。
75
+
76
+ **Action**: 按 Phase A/B/C 逐項實施;每項產出完整、工程化的程式碼(含必要測試);新增檔案/目錄須與 tech_stack 一致。
77
+ </step_3_implement>
78
+
79
+ <step_4_validate>
80
+ **Role**: 驗證工程師
81
+ **Action** (失敗須修復後重跑;命令以 `02_tech_stack.md` Section 5 為準):
82
+
83
+ **Automated Check**: 執行 `[[__DOCS_DIR__]]/scripts/validate`(如存在);否則按以下清單逐項手動執行。
84
+
85
+ | Phase | 檢查項 | 要求 |
86
+ |:---|:---|:---|
87
+ | **Static** | Build | 零編譯錯誤 |
88
+ | | Type Check | 零型別錯誤 |
89
+ | | Lint | 零 Lint 錯誤(警告須說明原因) |
90
+ | | Format | 符合格式規範(失敗則自動修復後重檢) |
91
+ | **Test** | Existing Tests | 執行已有測試套件全部通過;禁因新程式碼破壞舊測試 |
92
+ | | New Coverage | 為新增/修改的關鍵邏輯補充測試;純樣式調整可豁免 |
93
+
94
+ **Task Verification (硬性要求)**
95
+
96
+ > 禁僅通過程式碼審查或自動化測試就標記完成;須實際執行目標功能並驗證。
97
+ > 如 dev server 未啟動,先執行 `[[__DOCS_DIR__]]/scripts/dev-up`。
98
+ > **優先讀取 `notes.驗證`**: 先讀當前 task 的 `notes` 字段末尾 `驗證: [...]` 部分,以其指定操作執行具體 e2e;`notes` 無驗證字段時按下表型別兜底。
99
+
100
+ | 專案型別 | 驗證動作 | 通過標準 |
101
+ |:---|:---|:---|
102
+ | [?Web] | 瀏覽器操作目標功能路徑 | 渲染正常,互動無報錯,主控台無異常 |
103
+ | [?API] | 呼叫新增/修改的 endpoint | 狀態碼與 Body 符合 spec |
104
+ | [?CLI] | 執行目標命令(含正常參數 + 邊界參數) | stdout 符合預期,exit code 正確 |
105
+ | [?Lib] | 執行範例程式碼或 playground 驗證匯出 API | 無執行時錯誤,回傳值正確 |
106
+ | [?Mobile] | 模擬器/真機操作目標功能 | 介面正常,互動響應 |
107
+ | [?Desktop] | 啟動應用操作目標功能 | 視窗正常,功能可用 |
108
+
109
+ **Evidence**: Output 須附驗證結果(命令輸出摘要 / 截圖 / 錯誤日誌)。
110
+ **Fallback**: 驗證持續失敗且懷疑環境問題 → `[[__DOCS_DIR__]]/scripts/dev-reset` → `[[__DOCS_DIR__]]/scripts/dev-up` → 重試。
111
+
112
+ **Output**: 每項檢查 ✅/❌ 狀態與原因;Task Verification 證據。
113
+ </step_4_validate>
114
+
115
+ <step_5_audit>
116
+ **Role**: 首席審計官
117
+ **Checklist**:
118
+ 1. **Tech Consistency**: 與 `02_tech_stack.md` 一致(庫/模式/API 風格)。
119
+ 2. [?UI] **Design Compliance**: 樣式僅用 Token/Preset 視覺模式;無硬編碼魔法值。
120
+ 3. [?Data] **Data Integrity**: 符合 `data_snapshot.json`;欄位名/型別一致。
121
+ 4. **SOTA**: 拒絕過時模式;採用 tech_stack 最佳實務。
122
+ 5. [?UI] **Accessibility**: 含必要無障礙屬性。
123
+ 6. [?I18n] **I18n**: 無硬編碼字串;須用 Key/字典引用。
124
+ 7. **Performance**: 避免不必要大依賴/全量匯入/無用計算/記憶體洩漏。
125
+ 8. **Security**: 無敏感資訊洩露;輸入有校驗。
126
+ 9. **Static Check Zero**: 所有靜態檢查問題已解決。
127
+ 10. **step_4 Gate**: 確認 step_4 所有檢查(Static + Test + Task Verification)已通過。
128
+ 11. **聯動檢查**: 讀取 `[[__DOCS_DIR__]]/global/map.json` 中的 `featureRelations` 陣列,將本次實現的功能與各條 `sources` 欄位做語義對比。命中時輸出提示:`⚠️ 聯動: [aggregator] — [checkNote]`,提醒在當前實現完成後確認聚合方是否需要同步。`featureRelations` 為空則跳過。
129
+ 12. **資料治理**: 本次實現引入新內容時,須直接寫入對應全域索引:
130
+
131
+ | 觸發條件 | 檔案 | 動作 |
132
+ |:---|:---|:---|
133
+ | 新業務實體 · 動作 · 共享工具 | `dictionary.json` | 直接追加寫入 |
134
+ | 新錯誤情境 | `error_codes.json` | 直接追加寫入 |
135
+ | [?Data] Schema 實際變更 | `data_snapshot.json` | 直接同步 |
136
+
137
+ 細節問題可 Auto-Fix 並說明;重大風險標註 `⚠️ Risk` 並提出替代方案。
138
+ </step_5_audit>
139
+
140
+ <step_6_signoff>
141
+ **Terminal Gate** (禁止跳過,須在輸出總結前全部完成):
142
+ | 步驟 | 命令 | 通過條件 |
143
+ |:---|:---|:---|
144
+ | 1 | `npx archi plan <ID>` | 全部完成或僅豁免項;未通過禁簽收,回到 step_3 |
145
+ | 2 | `npx archi task <ID> --status done` | 任務狀態已更新 |
146
+ | 3 | `npx archi task --check` | 無 ERROR 級問題 |
147
+ | 4 | `npx archi render` | `.md` 視圖生成完成 |
148
+
149
+ **Action** (Gate 通過後):
150
+ 1. 確認 `plan.json` 各 task `done` 標記已全部更新(應在 step_3 實時完成,此處做最終校驗)。
151
+ 2. **Drift Warning**: 對比本次程式碼變更與 `spec.md` 的關鍵點位(介面簽名、回傳型別、Gherkin 場景關鍵操作)。如發現程式碼超出 spec 覆蓋範圍 → 標注 `⚠️ Spec 漂移`,建議執行 `/archi.edit <ID>` 同步文件。
152
+ 3. 輸出完成任務清單與補丁連結(Code Reference)。
153
+ 4. 提供下一步建議與 Git Commit Suggestion(Conventional Commits)。
154
+
155
+ **Checkpoint** (Output 前須確認): □ Terminal Gate 全部執行
156
+
157
+ **Output**: 完成摘要,含已完成任務、豁免項(如有)、Git Commit 建議、Next Steps 表格。
158
+ </step_6_signoff>
159
+
160
+ </protocol_code>
@@ -0,0 +1,87 @@
1
+ <protocol_edit>
2
+ **Trigger**: `/archi.edit <id> [context]`
3
+ **Goal**: 基於新需求/修改意見,更新已納管模組的 Spec/UI 文件,並追加開發計畫。
4
+
5
+ <meta>
6
+ <style>Collaborative, Iterative, Traceable</style>
7
+ <language>繁體中文</language>
8
+ <principles>
9
+ 1. **Doc First**: 須先改文件 (Spec/UI),再生成 Plan。禁跳過文件直接改程式碼計畫。
10
+ 2. **Incremental**: 僅追加新 Task 到 Plan,保留已完成歷史(除非需回滾)。
11
+ 3. **Conflict Check**: 檢查新需求是否與 tech_stack / design_tokens 衝突。
12
+ 4. **Frontmatter Preservation**: 禁破壞現有文件 Metadata。
13
+ </principles>
14
+ </meta>
15
+
16
+ <step_1_load>
17
+ **Role**: 產品經理
18
+ **Action**:
19
+ - 讀取 `[[__DOCS_DIR__]]/tasks/<ID>_<Slug>/` 下的 spec.md、ui.md、plan.json。
20
+ - [?UI] 讀取 `[[__DOCS_DIR__]]/global/ui_context.md`(定位本功能對應的畫面範圍及導覽關係)。
21
+ - 檢測 spec.md 中的 `Spec-Status` 欄位:
22
+ - `Full` → 正常流程,進入 step_2。
23
+ - `Stub` → 進入 step_1_5_enrich。
24
+ - [?重大 UX 變更] 快速搜尋同類產品最佳實務。
25
+ </step_1_load>
26
+
27
+ <step_1_5_enrich>
28
+ **Role**: 逆向工程師
29
+ **Trigger**: spec.md 中 `Spec-Status: Stub`(由 `/archi.inherit` 生成的輕量快照)。
30
+
31
+ **Action**:
32
+ 1. 告知使用者:「該功能僅有輕量快照,須先補全完整 spec 才能執行修改。」
33
+ 2. 從 stub 的「關聯檔案」section 提取原始碼路徑。
34
+ 3. 逐一讀取關聯檔案,中度掃描(入口 + 核心邏輯)。
35
+ 4. 基於程式碼分析,將 stub 補全為完整 spec:
36
+ - 保留原有概述和關鍵流程
37
+ - 補充 Gherkin Scenarios(覆蓋正常流程 + 異常路徑)
38
+ - 補充介面/型別定義(如該功能是其他功能的上游)
39
+ 5. 更新 `Spec-Status: Stub → Full`。
40
+ 6. [?UI] 如模組有 UI → 同步生成或更新 `ui.md`(範圍聲明);如須新增畫面,提示使用者執行 `archi-ui-wireframe` Skill(Skill 會同步更新 `ui_concept.html` + `ui_context.md`)。
41
+ 7. 生成 `plan.json`(全部 task 為 done,記錄已實作內容)。
42
+ 8. 向使用者輸出補全後的 spec 摘要。
43
+
44
+ **Gate**: 使用者確認補全內容正確後,繼續 step_2_refine_docs。
45
+ **異常**: 關聯檔案不存在/已移動 → 提示使用者更新路徑。
46
+ </step_1_5_enrich>
47
+
48
+ <step_2_refine_docs>
49
+ **Role**: 需求分析師 & 設計師
50
+ **Action**:
51
+ - 根據 `[context]` 修改 spec.md(邏輯/規則變更)和 ui.md(結構/互動變更)。
52
+ - [?UI 修改] 透過 Skill 同步更新 `ui_concept.html` + `ui_context.md`(Skill 為兩個檔案的唯一寫者):
53
+
54
+ | 變更類型 | 判定標準 | 處理方式 |
55
+ |:---|:---|:---|
56
+ | 無畫面影響 | 僅邏輯/資料變更,無視覺差異 | 僅改 spec.md,`ui_concept.html` / `ui_context.md` 不動 |
57
+ | 輕微 UI 調整 | 新增/修改狀態、彈窗、局部區域,不改整體版面 | 呼叫 Skill(修改畫面模式)更新兩個檔案,輸出 `MODIFIED: S-XX` |
58
+ | 畫面結構變更 | 版面重構、新增獨立畫面、導覽路徑變化 | 呼叫 Skill(修改畫面模式)更新兩個檔案,輸出 `MODIFIED: S-XX`;若已完成 Phase 2 著色,同步重新著色 |
59
+ | 功能縮減 | 畫面/區域整體移除 | 呼叫 Skill(刪除畫面模式)更新兩個檔案,輸出 `REMOVED: S-XX` |
60
+
61
+ - 需求模糊時向使用者提問 (A/B/C/D 選項) 確認細節。
62
+
63
+ **Output**: 更新後的 Spec、UI 文件及 `ui_concept.html` / `ui_context.md` 變更摘要。
64
+ </step_2_refine_docs>
65
+
66
+ <step_3_update_plan>
67
+ **Role**: Tech Lead
68
+ **Action**:
69
+ - 在 `plan.json` 的 `phases` 陣列中追加新 Phase 物件。
70
+ - 列出具體 Tasks (API update, UI tweak, Test update);每項須可驗證。
71
+ - **狀態轉換**: 若當前任務 status=`done`,追加 Phase 後須將狀態重置為 `active`(否則後續 `/archi.code` 將被 Status Gate 拒絕)。
72
+
73
+ **Terminal Gate** (禁止跳過,須在 step_4 輸出前全部完成):
74
+ | 步驟 | 命令 | 通過條件 |
75
+ |:---|:---|:---|
76
+ | 1 | `npx archi render` | `.md` 視圖生成完成 |
77
+ | 2 | [當前 status=done] `npx archi task <ID> --status active` | 任務狀態已重置為 active |
78
+
79
+ **Output**: 追加了新任務的 plan.json;若執行了狀態轉換,輸出 `MODIFIED: roadmap.json <ID>.status done→active`。
80
+ </step_3_update_plan>
81
+
82
+ <step_4_summary>
83
+ **Action** (Gate 須在 step_3 完成):
84
+ **Output**: Task 更新摘要,含 Spec/UI/Plan 變更概要和 Next Steps 表格。推薦執行 `/archi.code <ID>`。
85
+ </step_4_summary>
86
+
87
+ </protocol_edit>
@@ -0,0 +1,86 @@
1
+ <protocol_fix>
2
+ **Trigger**: `/archi.fix [id] <context>`
3
+ **Goal**: 針對 Bug 進行診斷並直接執行修復。若未提供 `[id]`,自動定位相關功能模組。
4
+
5
+ <meta>
6
+ <style>Diagnostic, Surgical, Spec-Compliant</style>
7
+ <language>繁體中文</language>
8
+ <principles>
9
+ 1. **Spec Immutable**: 禁改 `spec.md` / `ui.md`(除非 Bug 本身是檔案錯誤)。
10
+ 2. **Reproduction**: 須先構想複現步驟或測試案例。
11
+ 3. **Root Cause**: 須分析根因,而非修補表面。
12
+ 4. **Test-Driven**: 修復計畫須含新增測試案例。
13
+ 5. **Auto-Discovery**: 若未指定 ID,透過 Context 語意搜尋定位 Task。
14
+ </principles>
15
+ </meta>
16
+
17
+ <step_1_diagnose>
18
+ **Role**: 故障分析師
19
+ **Action**:
20
+ 1. **Resolve Target**:
21
+ - 有 `<id>`: 鎖定 `tasks/<ID>_<Slug>/`。
22
+ - 無 `<id>`: 分析 `[context]` 搜尋最相關模組。
23
+ 唯一匹配 → 自動鎖定 | 多個匹配 → 列出候選詢問 | 無法定位 → 報錯請求指定 ID。
24
+ 2. 讀取目標目錄下所有檔案 (`spec.md`, `ui.md`, `plan.json`) 與相關程式碼。
25
+ 3. 讀取 `02_tech_stack.md`(確保修復方式不違反技術紅線)和 `[[__DOCS_DIR__]]/global/vision.md`(確保修復方向不偏離專案願景)。
26
+ 4. 分析 `[context]`,結合程式碼邏輯定位潛在故障點。
27
+ 5. **Hypothesis**: 提出 1-3 個根因假設。
28
+
29
+ **Output**: 故障診斷報告 (Root Cause Analysis)。
30
+ </step_1_diagnose>
31
+
32
+ <step_2_plan_fix>
33
+ **Role**: Tech Lead
34
+ **Action**:
35
+ - 更新 `[[__DOCS_DIR__]]/tasks/<ID>_<Slug>/plan.json`,在 `phases` 陣列中追加 phase 物件,`name` 為 `Bugfix: <Bug Title>`。
36
+ - Tasks: 1) 建立複現測試(Red) 2) 修復(Green) 3) 迴歸測試。
37
+
38
+ **Terminal Gate** (禁止跳過,須在 step_5 輸出前全部完成):
39
+ | 步驟 | 命令 | 通過條件 |
40
+ |:---|:---|:---|
41
+ | 1 | `npx archi render` | `.md` 視圖生成完成 |
42
+
43
+ **Output**: 追加了修復任務的 plan.json。
44
+ </step_2_plan_fix>
45
+
46
+ <step_3_execute_fix>
47
+ **Role**: 資深工程師 (Surgical Fix — 僅改 Bug,禁擴散)
48
+ **Action**:
49
+ - 根據 Plan 直接修改程式碼。
50
+ - 僅修復 Bug,禁藉機重構或改無關程式碼。
51
+ - 錯誤處理遵循 `code.md` 規範(禁吞錯/禁靜默失敗)。
52
+ </step_3_execute_fix>
53
+
54
+ <step_4_verify>
55
+ **Role**: QA 工程師
56
+ **Terminal Gate** (禁止跳過,須在 step_5 輸出前全部完成):
57
+ | 步驟 | 命令 | 通過條件 |
58
+ |:---|:---|:---|
59
+ | 1 | 運行建置命令 | 建置成功 |
60
+ | 2 | 運行型別檢查 | 零型別錯誤 |
61
+ | 3 | 運行 Lint/Format | 通過 |
62
+ | 4 | 運行測試 | 複現測試 + 迴歸測試通過 |
63
+
64
+ 任何失敗須修復至通過。
65
+ </step_4_verify>
66
+
67
+ <step_4_5_plan_update>
68
+ **Role**: Tech Lead
69
+ **Action**:
70
+ 1. 更新 `plan.json`:將 Bugfix Phase 中已完成的 tasks 的 `done` 設為 `true`。
71
+ 2. [當前 status=`done` 且 Bugfix Phase 全部通過] → 保持 `done` 不變。
72
+ 3. [Bugfix Phase 有未通過項] → 執行 `npx archi task <ID> --status active`;signoff 輸出中標注須重新 `/archi.code` 完成剩餘修復。
73
+
74
+ **Output**: `MODIFIED: plan.json Bugfix Phase done 標記`(如狀態變更,附 `MODIFIED: roadmap.json <ID>.status`)。
75
+ </step_4_5_plan_update>
76
+
77
+ <step_5_summary>
78
+ **Output**: Bug 修復摘要,含 Root Cause 分析、修復內容、新增測試,以及 Next Steps 表格:
79
+
80
+ | 優先級 | 動作 | 說明 |
81
+ |:---|:---|:---|
82
+ | 推薦 | `/archi.audit <ID>` | 重新審查,確認修復完整且無新引入問題 |
83
+ | 可選 | `/archi.code <ID>` | 如有 Bugfix Phase 未完成項,繼續實作 |
84
+ </step_5_summary>
85
+
86
+ </protocol_fix>
@@ -0,0 +1,69 @@
1
+ <protocol_help>
2
+ **Trigger**: `/archi.help [question]`
3
+ **Goal**: 專案導航與上下文問答。分析專案當前狀態,推薦下一步操作;或基於專案上下文回答使用者問題。
4
+
5
+ <meta>
6
+ <style>Concise, Contextual, Actionable</style>
7
+ <language>繁體中文</language>
8
+ <principles>
9
+ 1. **Context-Aware**: 基於專案真實狀態回答,禁憑空猜測。
10
+ 2. **Actionable Output**: 每次輸出須含可執行的下一步建議(具體指令 + 參數)。
11
+ 3. **Minimal Token**: 精簡輸出,不複述使用者已知資訊。僅呈現推理結論與建議。
12
+ 4. **No Audit**: 不做深度審計(那是 `/archi.audit` 的職責)。聚焦導航與問答。
13
+ </principles>
14
+ </meta>
15
+
16
+ <step_1_load_context>
17
+ **Role**: 專案觀察員
18
+ **Action**:
19
+ 1. 讀取 `[[__DOCS_DIR__]]/global/roadmap.json` — 僅提取每個 task 的 `id/title/status/deps/tag` 欄位;`goal/notes` 欄位跳過(導航和狀態聚合不需要這些詳情)。
20
+ 2. 掃描 `[[__DOCS_DIR__]]/tasks/` 目錄 — 取得已有 Task 及其檔案完整度(有無 spec.md / ui.md / plan.json)。
21
+ 3. [?question] 若使用者帶了問題,根據問題語義定位相關檔案(spec / plan / vision / tech_stack / data_snapshot 等),按需讀取。
22
+
23
+ **Output**: 內部上下文(不直接輸出給使用者)。
24
+ </step_1_load_context>
25
+
26
+ <step_2_route>
27
+ **Role**: 路由器
28
+ **Action**: 根據輸入分支:
29
+
30
+ | 輸入 | 分支 |
31
+ |:---|:---|
32
+ | 無參數 | → step_3_navigate(專案導航) |
33
+ | 有 `[question]` | → step_4_answer(上下文問答) |
34
+
35
+ </step_2_route>
36
+
37
+ <step_3_navigate>
38
+ **Role**: 專案導航員
39
+ **Action**:
40
+ 1. **判斷專案階段**:
41
+
42
+ | 訊號 | 階段 | 建議 |
43
+ |:---|:---|:---|
44
+ | roadmap.json 不存在 | 未初始化 | 新專案 → `/archi.start`;已有程式碼 → `/archi.inherit` |
45
+ | 有 roadmap 但無 Task 目錄 | 已啟動,未規劃 | 執行 `/archi.scope` 規劃新任務 |
46
+ | 有 Legacy stub (Spec-Status: Stub) | 已繼承,未補全 | 執行 `/archi.edit LEG-xx` 補全 spec |
47
+ | 有 active 任務且 plan.json 完整 | 可編碼 | 執行 `/archi.code <ID>` |
48
+ | 有 active 任務但缺 spec/plan | 規劃未完成 | 執行 `/archi.plan <ID>` 補全 |
49
+ | 所有任務 done | 已完成 | 執行 `/archi.scope` 規劃新任務或發佈 |
50
+ | 有 blocked 任務 | 存在阻塞 | 提示阻塞原因與前置依賴 |
51
+
52
+ 2. **輸出格式**:
53
+ - 一句話總結當前狀態
54
+ - 推薦的下一步操作(含具體指令)
55
+ - 如有多個可選路徑,列出優先級排序(最多 3 個)
56
+ </step_3_navigate>
57
+
58
+ <step_4_answer>
59
+ **Role**: 專案顧問
60
+ **Action**:
61
+ 1. 解析 `[question]` 語義,定位相關專案檔案。
62
+ 2. 讀取相關檔案,綜合回答。
63
+ 3. 若問題涉及操作(如「怎麼做 X」),回答須包含具體指令建議。
64
+ 4. 若資訊不足以回答,明確告知缺少什麼,而非編造。
65
+
66
+ **Output**: 基於專案上下文的簡潔回答 + 相關檔案引用。
67
+ </step_4_answer>
68
+
69
+ </protocol_help>
@@ -0,0 +1,270 @@
1
+ <protocol_inherit>
2
+ **Trigger**: `/archi.inherit`
3
+ **Phase**: Legacy Adoption
4
+ **Goal**: 逆向分析已有程式碼儲存庫,生成 Architext 文件骨架,將專案納入框架管理。
5
+
6
+ <meta>
7
+ <style>Analytical, Systematic, Evidence-Based</style>
8
+ <language>繁體中文</language>
9
+ <principles>
10
+ 1. **Code-Driven**: 以程式碼為唯一真相源,禁憑空推測功能。
11
+ 2. **AI-Native Perspective**: 分析從 AI Agent 視角撰寫。關注:Context Locality、Type Safety、Module Boundaries。
12
+ 3. **User Agency First**: AI 的分析須經使用者確認。程式碼解讀有歧義時詢問使用者,禁擅自決定。
13
+ 4. **Minimal Token**: 優先讀配置和入口檔案,避免逐行掃描所有程式碼。
14
+ 5. **Option Z Everywhere**: 補充提問須包含 `[Z] 自訂`。
15
+ </principles>
16
+ </meta>
17
+
18
+ <step_0_recon>
19
+ **Role**: 情報分析官
20
+ **Action**:
21
+ 1. 讀取專案根配置檔案(自動識別型別):
22
+
23
+ | 語言/生態 | 配置檔案 |
24
+ |:---|:---|
25
+ | Node.js | package.json, tsconfig.json |
26
+ | Rust | Cargo.toml |
27
+ | Go | go.mod |
28
+ | Python | pyproject.toml, requirements.txt |
29
+ | Java | pom.xml, build.gradle |
30
+ | 其他 | 以根目錄配置檔案為準 |
31
+
32
+ 2. 讀取 README.md(如存在)。
33
+ 3. 掃描目錄結構(頂層 + 核心原始碼目錄兩層深度)。
34
+ 4. 推斷專案特徵標籤(UI / Data / CLI / Lib / API — 由目錄結構、依賴和配置推斷)。
35
+ 5. 識別入口檔案和核心模組。
36
+
37
+ **Output**: 內部摘要(不輸出給使用者),進入 step_1。
38
+ </step_0_recon>
39
+
40
+ <step_1_analysis>
41
+ **Role**: 系統分析師
42
+ **掃描策略**: 中度掃描 — 讀每個模組的入口檔案和核心業務檔案,提取主要流程鏈路。禁逐檔案遍歷。
43
+
44
+ **Action**:
45
+ 1. 對每個識別出的功能模組:
46
+ - 讀入口檔案 + 1-2 個核心業務檔案
47
+ - 提取主要流程(使用者操作 → 系統處理 → 結果)
48
+ - 記錄關聯檔案路徑
49
+ 2. 對共享/基建程式碼(utils, middleware, config):
50
+ - 僅記錄目錄和職責,不作為功能模組
51
+ 3. 從程式碼中提取領域術語和命名慣例。
52
+
53
+ **Output**: 向使用者輸出結構化分析報告:
54
+ ```
55
+ ### 程式碼分析報告
56
+ > **專案**: [名稱] | **型別**: [UI/Data/CLI/Lib/API] | **規模**: ~[檔案數] 檔案, [目錄數] 目錄
57
+
58
+ **技術棧**:
59
+ | 類別 | 選型 |
60
+ |:---|:---|
61
+ | 語言 | ... |
62
+ | 框架 | ... |
63
+ | 建置 | ... |
64
+ | 測試 | ... |
65
+ | 部署 | ... |
66
+
67
+ **架構模式**: [推斷] — [依據]
68
+
69
+ **功能模組清單**:
70
+ | # | 模組 | 原始碼位置 | 職責 | 關鍵流程 |
71
+ |:---|:---|:---|:---|:---|
72
+ | 1 | [名稱] | [路徑] | [一句話] | [流程1], [流程2] |
73
+
74
+ **共享基建**:
75
+ | 目錄 | 職責 |
76
+ |:---|:---|
77
+ | [路徑] | [描述] |
78
+
79
+ **領域術語**: [術語列表]
80
+
81
+ **AI 不確定項** (如有):
82
+ - [歧義項]
83
+ ```
84
+
85
+ **Gate**: 使用者確認或修正。未確認禁進入 step_2。
86
+ </step_1_analysis>
87
+
88
+ <step_2_supplementary>
89
+ **Role**: 產品顧問
90
+ **Trigger**: 僅當 step_1 有 AI 無法確定的項時執行。無歧義則略過。
91
+
92
+ **Action**: 以選擇題形式詢問歧義項。
93
+ - 每題 3-5 選項 + `[Z] 自訂`,AI 推薦項標 `[推薦]`。
94
+ - 總問題數控制在 3 個以內。
95
+
96
+ 常見歧義:
97
+ - 架構模式無法確認
98
+ - 某目錄職責不明確
99
+ - vision 資訊(北極星指標、設計哲學)程式碼中無法推斷
100
+
101
+ **Output Format**:
102
+ ```
103
+ ### 補充確認
104
+
105
+ **[Q1] 問題標題**
106
+ > 為什麼需要這個資訊
107
+
108
+ | ID | 選項 | 說明 |
109
+ |:---|:---|:---|
110
+ | A [推薦] | ... | ... |
111
+ | B | ... | ... |
112
+ | Z | 自訂 | (請描述) |
113
+
114
+ ---
115
+ **INPUT**: `Q1答案 | Q2答案 | ...`
116
+ ```
117
+ </step_2_supplementary>
118
+
119
+ <step_3_constitution>
120
+ **Role**: 首席架構師
121
+ **Input**: Step 1 分析報告 + Step 2 補充(如有)。
122
+ **Action**: 一次性生成專案文件骨架。
123
+
124
+ ### 資訊路由規則
125
+
126
+ > 規則檔案(`02_tech_stack`、`90_custom_rules` 等)已由 IDE 注入當前上下文,AI 已知其路徑,直接寫入即可。
127
+
128
+ | 程式碼中的資訊 | 目標檔案 |
129
+ |:---|:---|
130
+ | README 專案描述、目標使用者、特性列表 | `[[__DOCS_DIR__]]/global/vision.md` |
131
+ | 依賴清單、配置檔案、程式碼模式 | 規則檔案 `02_tech_stack` |
132
+ | 目錄結構、模組依賴、使用者旅程 | `[[__DOCS_DIR__]]/global/map.json` |
133
+ | 領域術語、縮寫、命名慣例 | `[[__DOCS_DIR__]]/global/dictionary.json` |
134
+ | eslint/prettier 等已有規範 | 規則檔案 `90_custom_rules` |
135
+ | 程式碼中的錯誤碼定義 | `[[__DOCS_DIR__]]/global/error_codes.json` |
136
+ | [?UI] CSS 變數/主題配置 | `[[__DOCS_DIR__]]/global/design_tokens.json` |
137
+ | [?Data] Schema/Migration 檔案 | `[[__DOCS_DIR__]]/global/data_snapshot.json` |
138
+
139
+ ### 3.1 Vision (`[[__DOCS_DIR__]]/global/vision.md`)
140
+ - 從 README + 專案配置推導
141
+ - 無法推導的項標註 `(AI 補全 — 建議使用者審查)`
142
+ - 禁保留範本佔位符
143
+
144
+ ### 3.2 Tech Stack (規則檔案 `02_tech_stack`)
145
+ - 已有依賴/配置 → 直接寫入
146
+ - 程式碼中可見的規範(命名、結構) → 寫入 Coding Standards
147
+ - 須填充完整 Section 1-8
148
+
149
+ ### 3.3 Custom Rules (規則檔案 `90_custom_rules`)
150
+ - 從 eslint/prettier/editorconfig 等提取規則
151
+ - 從程式碼模式中識別團隊慣例(如 named export 偏好、async/await 風格)
152
+
153
+ ### 3.4 Roadmap (`[[__DOCS_DIR__]]/global/roadmap.json`)
154
+
155
+ **結構**:
156
+ ```json
157
+ {
158
+ "version": 1,
159
+ "projectStatus": "active",
160
+ "lastUpdated": "<date>",
161
+ "phases": [
162
+ {
163
+ "id": "phase-0",
164
+ "name": "Legacy",
165
+ "tasks": [
166
+ {
167
+ "id": "LEG-01",
168
+ "title": "<模組名>",
169
+ "status": "done",
170
+ "goal": "<一句話摘要>。詳見 tasks/LEG-01_<Slug>/spec.md",
171
+ "deps": [],
172
+ "tag": "Legacy",
173
+ "slug": "<Slug>"
174
+ }
175
+ ]
176
+ },
177
+ { "id": "phase-1", "name": "Infrastructure", "tasks": [] },
178
+ { "id": "phase-2", "name": "Core Features", "tasks": [] }
179
+ ]
180
+ }
181
+ ```
182
+
183
+ **規則**:
184
+ - 功能模組 → `phase-0: Legacy`,status `done`,tag `Legacy`,ID 前綴 `LEG-`
185
+ - 共享/基建程式碼不進 roadmap,僅進 map.json directoryMapping
186
+ - phase-1/2 保留空骨架
187
+ - LEG 間如有依賴關係須在 deps 中體現
188
+
189
+ ### 3.5 Task Stub Specs
190
+
191
+ 為每個 LEG 任務建立 `[[__DOCS_DIR__]]/tasks/LEG-xx_<Slug>/spec.md`:
192
+
193
+ ```markdown
194
+ # LEG-xx: [Title]
195
+
196
+ > **Spec-Status**: Stub
197
+ > **Source**: 逆向分析自 [原始碼路徑]
198
+
199
+ ## 概述
200
+ [一段話描述]
201
+
202
+ ## 關鍵流程
203
+ 1. **[流程名]**: [A] → [B] → [C]
204
+ 2. **[流程名]**: [A] → [B] → [C]
205
+
206
+ ## 關聯檔案
207
+ - [角色]: `[路徑]`
208
+ - [角色]: `[路徑]`
209
+ ```
210
+
211
+ > Stub 是起點,非終態。後續透過 `/archi.edit` 觸發補全(自動進入 `step_1_5_enrich` 流程)。
212
+
213
+ ### 3.6 map.json 填充
214
+ - `directoryMapping`: 每個核心目錄 → `{ "path", "layer", "responsibility", "publicAPI" }`
215
+ - `logicalTopology`: 模組間依賴 → `{ "from", "to", "type" }` (imports / calls / extends)
216
+ - `criticalUserJourneys`: 核心流程 → `{ "name", "steps": ["module → module → ..."] }`
217
+ - `featureRelations`: 掃描程式碼,識別「聚合型模組」並記錄。
218
+ **識別特徵**: 某模組遍歷/枚舉/動態載入同類模組(如 `for (const cmd of allCommands)`、`Object.values(registry)`、讀取目錄後動態 import),或其描述為「彙總/列舉/註冊所有 X」。
219
+ 每條記錄格式: `{ "aggregator": "<ID 或檔案路徑>", "sources": "<來源範圍描述>", "evidence": "<程式碼依據>", "checkNote": "此類功能新增或刪除時,檢查 <aggregator> 是否需要同步" }`
220
+
221
+ ### 3.7 其他全域文件(按需)
222
+ - `dictionary.json`: 從程式碼提取領域術語
223
+ - [?UI] `design_tokens.json`: 從 CSS 變數/主題提取
224
+ - [?UI] `ui_concept.html` + `ui_context.md`: **不由本命令產生**。繼承完成後,提示使用者執行 `archi-ui-wireframe` Skill 產生全域 UI 線框圖(Skill 同時產生兩個檔案)。
225
+ - [?Data] `data_snapshot.json`: 從 schema/migration 提取
226
+ - `error_codes.json`: 從程式碼中的錯誤定義提取
227
+
228
+ **Output**: 寫入所有檔案,執行 `npx archi render`。
229
+ </step_3_constitution>
230
+
231
+ <step_4_audit>
232
+ **Role**: 審計官
233
+ **Checklist**:
234
+ 1. **Vision 對齊**: vision.md 與程式碼實際功能一致?
235
+ 2. **Tech Stack 一致**: 規則檔案 `02_tech_stack` 與 package.json/config 一致?
236
+ 3. **Map 覆蓋**: map.json 覆蓋所有核心目錄?
237
+ 4. **Roadmap 完整**: phase-0 覆蓋所有已識別功能模組?
238
+ 5. **Stub 齊全**: 每個 LEG-xx 都有對應 tasks/ 目錄和 spec.md?
239
+ 6. **Dictionary 無衝突**: 術語無歧義或重複?
240
+
241
+ 如有問題則靜默修正;嚴重問題標記 `Risk Warning`。
242
+ </step_4_audit>
243
+
244
+ <step_5_signoff>
245
+ **Terminal Gate** (禁止跳過,須在輸出總結前全部完成):
246
+ | 步驟 | 命令 | 通過條件 |
247
+ |:---|:---|:---|
248
+ | 1 | `npx archi task --check` | 無 ERROR 級問題 |
249
+ | 2 | `npx archi render` | `.md` 視圖生成完成 |
250
+
251
+ **Action** (Gate 通過後):
252
+ 1. 執行 `npx archi task` 輸出任務概覽。
253
+ 2. 輸出總結。
254
+
255
+ **Output**: 逆向分析摘要,含:
256
+ - **專案概況**: 型別、規模、核心模組數
257
+ - **Legacy 功能**: LEG-xx 列表(ID / 名稱 / 原始碼位置)
258
+ - **已生成文件**: 檔案清單
259
+ - **AI 補全項**: 標註置信度(高/中/低)
260
+ - **Next Steps**:
261
+
262
+ | 優先級 | 動作 | 說明 |
263
+ |:---|:---|:---|
264
+ | 1 | 審查 vision.md | 確認 AI 補全的願景描述是否準確 |
265
+ | 2 | `/archi.edit LEG-xx` | 對核心模組補全完整 spec(自動觸發 Enrich 流程) |
266
+ | 3 | `/archi.scope [file_path]` | 規劃新任務/大模組 |
267
+ | 4 | `/archi.plan <任務ID>` | 對單個任務做深度規劃 |
268
+ </step_5_signoff>
269
+
270
+ </protocol_inherit>