architext 0.0.2 → 0.0.4

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 (103) hide show
  1. package/CHANGELOG.md +41 -1
  2. package/README.md +10 -5
  3. package/README.zh-CN.md +10 -5
  4. package/dist/index.js +43 -39
  5. package/dist/templates/en/docs/global/api_snapshot.json +24 -0
  6. package/dist/templates/en/docs/global/command_api.json +26 -0
  7. package/dist/templates/en/docs/global/env_registry.json +12 -0
  8. package/dist/templates/en/docs/global/map.json +5 -0
  9. package/dist/templates/en/docs/global/public_api.json +12 -0
  10. package/dist/templates/en/docs/prompts/code.md +21 -28
  11. package/dist/templates/en/docs/prompts/edit.md +18 -9
  12. package/dist/templates/en/docs/prompts/inherit.md +42 -23
  13. package/dist/templates/en/docs/prompts/plan.md +141 -47
  14. package/dist/templates/en/docs/prompts/recover.md +63 -0
  15. package/dist/templates/en/docs/prompts/ref.md +258 -0
  16. package/dist/templates/en/docs/prompts/revise.md +1 -1
  17. package/dist/templates/en/docs/prompts/scope.md +3 -3
  18. package/dist/templates/en/docs/prompts/start.md +9 -15
  19. package/dist/templates/en/docs/shared/verify-result-handling.md +6 -0
  20. package/dist/templates/en/docs/templates/design.template.md +77 -0
  21. package/dist/templates/en/docs/templates/spec.template.md +60 -25
  22. package/dist/templates/en/skills/archi-data-sync/SKILL.md +83 -0
  23. package/dist/templates/en/skills/archi-decompose-roadmap/SKILL.md +178 -132
  24. package/dist/templates/en/skills/archi-design-patterns/SKILL.md +139 -0
  25. package/dist/templates/en/skills/archi-feature-relations/SKILL.md +118 -0
  26. package/dist/templates/en/skills/archi-silent-audit/SKILL.md +118 -0
  27. package/dist/templates/zh/briefs/_base.md +2 -2
  28. package/dist/templates/zh/briefs/_modules.md +2 -2
  29. package/dist/templates/zh/docs/global/api_snapshot.json +24 -0
  30. package/dist/templates/zh/docs/global/command_api.json +26 -0
  31. package/dist/templates/zh/docs/global/data_snapshot.json +0 -1
  32. package/dist/templates/zh/docs/global/design_tokens.json +0 -1
  33. package/dist/templates/zh/docs/global/dictionary.json +1 -1
  34. package/dist/templates/zh/docs/global/env_registry.json +12 -0
  35. package/dist/templates/zh/docs/global/error_codes.json +0 -8
  36. package/dist/templates/zh/docs/global/map.json +28 -3
  37. package/dist/templates/zh/docs/global/public_api.json +12 -0
  38. package/dist/templates/zh/docs/global/vision.md +1 -1
  39. package/dist/templates/zh/docs/prompts/audit.md +8 -8
  40. package/dist/templates/zh/docs/prompts/code.md +33 -40
  41. package/dist/templates/zh/docs/prompts/edit.md +19 -10
  42. package/dist/templates/zh/docs/prompts/fix.md +8 -2
  43. package/dist/templates/zh/docs/prompts/inherit.md +45 -27
  44. package/dist/templates/zh/docs/prompts/map.md +2 -1
  45. package/dist/templates/zh/docs/prompts/plan.md +143 -50
  46. package/dist/templates/zh/docs/prompts/recover.md +63 -0
  47. package/dist/templates/zh/docs/prompts/ref.md +258 -0
  48. package/dist/templates/zh/docs/prompts/remove.md +2 -14
  49. package/dist/templates/zh/docs/prompts/revise.md +12 -4
  50. package/dist/templates/zh/docs/prompts/scope.md +6 -6
  51. package/dist/templates/zh/docs/prompts/start.md +19 -26
  52. package/dist/templates/zh/docs/shared/verify-result-handling.md +6 -0
  53. package/dist/templates/zh/docs/templates/design.template.md +77 -0
  54. package/dist/templates/zh/docs/templates/spec.template.md +60 -25
  55. package/dist/templates/zh/rules/00_system.md +35 -5
  56. package/dist/templates/zh/rules/01_workflow.md +5 -4
  57. package/dist/templates/zh/rules/02_tech_stack.md +7 -6
  58. package/dist/templates/zh/rules/03_data_governance.md +40 -9
  59. package/dist/templates/zh/rules/99_context_glue.md +2 -2
  60. package/dist/templates/zh/skills/archi-data-sync/SKILL.md +83 -0
  61. package/dist/templates/zh/skills/archi-decompose-roadmap/SKILL.md +82 -37
  62. package/dist/templates/zh/skills/archi-design-patterns/SKILL.md +139 -0
  63. package/dist/templates/zh/skills/archi-feature-relations/SKILL.md +118 -0
  64. package/dist/templates/zh/skills/archi-plan-options/SKILL.md +25 -25
  65. package/dist/templates/zh/skills/archi-silent-audit/SKILL.md +118 -0
  66. package/dist/templates/zh/skills/archi-ui-wireframe/SKILL.md +1 -1
  67. package/package.json +2 -2
  68. package/dist/templates/zh-Hant/briefs/_base.md +0 -115
  69. package/dist/templates/zh-Hant/briefs/_modules.md +0 -173
  70. package/dist/templates/zh-Hant/docs/global/data_snapshot.json +0 -31
  71. package/dist/templates/zh-Hant/docs/global/design_tokens.json +0 -135
  72. package/dist/templates/zh-Hant/docs/global/dictionary.json +0 -35
  73. package/dist/templates/zh-Hant/docs/global/error_codes.json +0 -19
  74. package/dist/templates/zh-Hant/docs/global/map.json +0 -94
  75. package/dist/templates/zh-Hant/docs/global/roadmap.json +0 -39
  76. package/dist/templates/zh-Hant/docs/global/vision.md +0 -82
  77. package/dist/templates/zh-Hant/docs/prompts/audit.md +0 -150
  78. package/dist/templates/zh-Hant/docs/prompts/code.md +0 -160
  79. package/dist/templates/zh-Hant/docs/prompts/edit.md +0 -87
  80. package/dist/templates/zh-Hant/docs/prompts/fix.md +0 -86
  81. package/dist/templates/zh-Hant/docs/prompts/help.md +0 -69
  82. package/dist/templates/zh-Hant/docs/prompts/inherit.md +0 -270
  83. package/dist/templates/zh-Hant/docs/prompts/map.md +0 -131
  84. package/dist/templates/zh-Hant/docs/prompts/plan.md +0 -252
  85. package/dist/templates/zh-Hant/docs/prompts/remove.md +0 -162
  86. package/dist/templates/zh-Hant/docs/prompts/revise.md +0 -160
  87. package/dist/templates/zh-Hant/docs/prompts/scope.md +0 -198
  88. package/dist/templates/zh-Hant/docs/prompts/start.md +0 -258
  89. package/dist/templates/zh-Hant/docs/templates/plan.template.json +0 -88
  90. package/dist/templates/zh-Hant/docs/templates/scope-brief.template.md +0 -58
  91. package/dist/templates/zh-Hant/docs/templates/spec.template.md +0 -51
  92. package/dist/templates/zh-Hant/docs/templates/ui.template.md +0 -51
  93. package/dist/templates/zh-Hant/rules/00_system.md +0 -123
  94. package/dist/templates/zh-Hant/rules/01_workflow.md +0 -93
  95. package/dist/templates/zh-Hant/rules/02_tech_stack.md +0 -192
  96. package/dist/templates/zh-Hant/rules/03_data_governance.md +0 -102
  97. package/dist/templates/zh-Hant/rules/04_cli_tools.md +0 -50
  98. package/dist/templates/zh-Hant/rules/90_custom_rules.md +0 -21
  99. package/dist/templates/zh-Hant/rules/99_context_glue.md +0 -53
  100. package/dist/templates/zh-Hant/skills/archi-decompose-roadmap/SKILL.md +0 -293
  101. package/dist/templates/zh-Hant/skills/archi-interview-protocol/SKILL.md +0 -86
  102. package/dist/templates/zh-Hant/skills/archi-plan-options/SKILL.md +0 -364
  103. package/dist/templates/zh-Hant/skills/archi-ui-wireframe/SKILL.md +0 -337
@@ -39,35 +39,55 @@
39
39
  - Execute only when a `ref: tasks/<dep_id>/spec.md#X` reference appears in the current spec/plan; skip if no reference found.
40
40
  - **Stub Compatibility**: If a dependency's Spec-Status is Stub, extract source files from the stub's "Associated Files", read entry files to extract public interfaces/exported types as upstream interface reference.
41
41
  - Avoid re-defining upstream interfaces; ensure integration points are precisely aligned.
42
+ 7. **Read Refs** (if any): Read `[[__DOCS_DIR__]]/refs/index.json` (if exists).
43
+ - Match relevant ref entries by tags and current task description semantics.
44
+ - Load only matched ref files (`[[__DOCS_DIR__]]/refs/{id}.{ext}`); skip unrelated entries.
45
+ - If `refs/index.json` does not exist or refs is empty → skip.
42
46
 
43
47
  **Output**: Present a **Task Context Brief** to the user:
44
48
  ```
45
49
  ### Task Context: [Task Name] ([ID])
46
50
 
51
+ **Task Type**: [Inferred from ID prefix: Infrastructure / Feature / Quality / Edit]
47
52
  **Goal**: [roadmap task's goal; highlight any [User Presets] if present]
48
53
  **Upstream Dependencies**: [completed dependency tasks and their key interfaces/types, or "None"]
49
54
  **Project Features**: [activated UI/Data/CLI/Lib/API tags]
50
55
  **Technical Constraints**: [key red lines from 02_tech_stack.md]
51
56
  **Design Philosophy**: [North Star Metric and design principles from vision.md]
52
57
  **Project Conventions**: [from 02_tech_stack.md §9 — Error Handling: X | Data Flow: X | Auth: X, or "Not set" if absent]
58
+ **External knowledge refs**: [matched ref ids, e.g. `wechat-pay`, `company-sdk`; or "None"]
53
59
  ```
54
60
  Retain full context materials internally, proceed to step_2.
55
61
  </step_1_load>
56
62
 
57
63
  <step_1_5_complexity>
58
64
  **Role**: Product Consultant
59
- **Action**: Assess task complexity to decide whether to run the full step_2 flow:
65
+ **Action**: Detect task type, assess complexity, decide flow path.
60
66
 
61
- **① Granularity hard-limit check (before complexity verdict)**:
67
+ **⓪ Task Type detection (execute first)**:
62
68
 
63
- | Metric | Limit |
64
- |:---|:---|
65
- | Estimated spec.md Scenario count | 6 |
66
- | Estimated plan.json Phase count | ≤ 4 |
69
+ Infer task type from `<ID>` prefix; applies to all subsequent steps:
70
+
71
+ | ID Prefix | Task Type | spec § 2 Primary Dimension | spec § 4 Interface Exports |
72
+ |:---|:---|:---|:---|
73
+ | `INF-` | Infrastructure | Structural (config contracts) | **Required** (downstream infrastructure) |
74
+ | `FEAT-` | Feature | Behavioral (behavior scenarios) | Required when has downstream deps |
75
+ | `POLISH-` | Quality | Quantitative (quality targets) | Usually omit |
76
+ | `EDIT-` | Edit | Inherit from original task | Inherit |
67
77
 
68
- > Estimation method: based on the roadmap task goal and dependency context loaded in step_1, quickly enumerate the core behavior paths. Trigger if over the limit no need for precise calculation.
78
+ > Mixed tasks (e.g. INF task with behavior aspect) may combine dimensions in § 2; use sub-headings to distinguish.
69
79
 
70
- **② Complexity verdict (only after granularity passes)**:
80
+ **① Granularity hard-limit check (by Task Type)**:
81
+
82
+ | Task Type | Acceptance Criteria item cap | plan.json Phase cap |
83
+ |:---|:---|:---|
84
+ | Feature | ≤ 6 Scenarios | ≤ 4 |
85
+ | Infrastructure | ≤ 8 Contracts | ≤ 5 |
86
+ | Quality | ≤ 4 Targets | ≤ 3 |
87
+
88
+ > Estimation method: based on roadmap task goal and dependency context from step_1, quickly enumerate core paths. Trigger if over limit — no precise calculation needed.
89
+
90
+ **② Complexity verdict (after granularity passes)**:
71
91
 
72
92
  | Signal | Verdict | Flow |
73
93
  |:---|:---|:---|
@@ -76,9 +96,21 @@
76
96
 
77
97
  **Simple Mode**:
78
98
  - Skip 5-dimension architecture recommendations and User Confirm Gate
79
- - spec condensed to 1-2 Gherkin scenarios
99
+ - spec condensed to 1-2 Acceptance Criteria items (format by Task Type)
80
100
  - plan condensed to a single Phase
81
101
  - Confirm at signoff (replacing step_2 Gate)
102
+
103
+ **③ Design signal detection (after Standard verdict)**:
104
+
105
+ For Standard tasks, detect whether to generate `design.md` (technical design):
106
+
107
+ | Signal | Verdict |
108
+ |:---|:---|
109
+ | Architecture option's AI- contains complexity warning (e.g. "extremely hard to implement correctly", "state management complex", "connection leak") | **Standard + Design** |
110
+ | Involves custom state machine, non-trivial algorithm, multi-component coordination protocol, retry/recovery strategy | **Standard + Design** |
111
+ | Standard CRUD / config / simple integration | **Standard** (no design.md) |
112
+
113
+ > When Standard + Design: step_2 must output mechanism preview (Part 1.5); step_4 must additionally generate `design.md`.
82
114
  </step_1_5_complexity>
83
115
 
84
116
  <step_2_interview>
@@ -114,9 +146,22 @@
114
146
 
115
147
  #### Part 2: Architecture Recommendations
116
148
 
117
- [[SKILL: Follow `archi-plan-options` Skill's three-step selection logic (Convention Inheritance -> Tag Routing -> Recommend vs. Expand) to generate architecture recommendations across five dimensions.]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-plan-options/SKILL.md` and follow its three-step logic)]]
149
+ [[SKILL: archi-plan-options|Follow the skill's three-step selection logic (Convention Inheritance -> Tag Routing -> Recommend vs. Expand) to generate architecture recommendations across five dimensions.]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-plan-options/SKILL.md` and follow its three-step logic)]]
150
+
151
+ When expanding a Q-table, follow the format in [[SKILL: archi-interview-protocol|the skill's standard output format]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-interview-protocol/SKILL.md` and follow its rules)]].
152
+
153
+ #### Part 1.5: Mechanism Preview [?Complex]
154
+
155
+ Output only when step_1_5 verdict is **Standard + Design**. List core mechanisms needing technical design and intended pattern:
156
+
157
+ ```
158
+ ### Mechanism Preview (will generate design.md)
159
+ | Mechanism | Pattern | Brief |
160
+ |:---|:---|:---|
161
+ | [name] | [State Machine / Pipeline / Decision Matrix / Protocol] | [one-sentence description] |
162
+ ```
118
163
 
119
- When expanding a Q-table, follow the format in [[SKILL: `archi-interview-protocol` Skill's standard output format]][[NO-SKILL: `[[__DOCS_DIR__]]/skills/archi-interview-protocol/SKILL.md`]].
164
+ > User may add/remove mechanisms or change pattern selection here.
120
165
 
121
166
  #### Output Format
122
167
 
@@ -134,6 +179,12 @@
134
179
  | Error Handling | [Convention value] | Project Convention | ref: 02_tech_stack.md §9 |
135
180
  | ... | ... | ... | ... |
136
181
 
182
+ [Only when Standard + Design]:
183
+ ### Mechanism Preview (will generate design.md)
184
+ | Mechanism | Pattern | Brief |
185
+ |:---|:---|:---|
186
+ | ... | ... | ... |
187
+
137
188
  [Only expand option table for dimensions requiring user decision]:
138
189
  **[Q<n>] Question title**
139
190
  > Why user decision is needed (one sentence)
@@ -149,6 +200,7 @@
149
200
  > - Design correction: "Registration doesn't need email verification step"
150
201
  > - Dimension override: "Core Structure=C, Error Handling=B D"
151
202
  > - Question answer: "Q1=B"
203
+ > - Mechanism change: "Remove Pipeline, reconnection doesn't need that complexity"
152
204
  ```
153
205
 
154
206
  **⌨️ INPUT**: Reply **OK** to accept all; or free-text annotations for changes. No fixed format required.
@@ -171,77 +223,119 @@
171
223
 
172
224
  **Action Checklist**:
173
225
  1. **`map.json`**: Register `[[__DOCS_DIR__]]/tasks/<ID>_<Slug>` in `directoryMapping`; define module responsibility and dependencies in `logicalTopology`.
174
- 2. **`dictionary.json`**: Extract **project business** new terms from the proposal to fill `entities`/`verbs`; register new shared tools to `utilities`; register new public components to `components`.
175
- 3. [?Data] **`data_snapshot.json`**: Add/modify Schema based on Core Structure recommendation. Prohibited from writing "TBD"; must write field names and types.
176
- 4. **`error_codes.json`**: Register new **business** error codes based on Error Handling recommendation. Framework script errors are handled by exit code + stderr; prohibited from registration.
177
- 5. **`map.json` featureRelations**: Determine if this task is an "aggregator" — i.e., its core responsibility is to **list, summarize, or dynamically reflect** a class of other tasks (e.g., "list all commands", "aggregate all page entries", "register all routes"). If yes, append one record to `featureRelations`:
178
- ```json
179
- {
180
- "aggregator": "<this task ID or file path>",
181
- "sources": "<one-sentence description of what is aggregated, e.g. 'all CLI command tasks'>",
182
- "evidence": "<basis, e.g. 'spec.md §X states this task dynamically lists all Y-type tasks'>",
183
- "checkNote": "When tasks of this type are added or removed, check whether <aggregator> needs to be updated"
184
- }
185
- ```
186
- If not an aggregator, skip this step.
226
+ 2. **Data governance sync** (`dictionary.json` / `error_codes.json` / `data_snapshot.json` etc.): Per `03_data_governance.md` rules, incrementally sync new business terms, error codes, Schema from the proposal to corresponding global files.
227
+ 3. **`map.json` featureRelations**: [[SUBAGENT: archi-feature-relations|mode: register, context: Determine if this Task is aggregator; if yes, register featureRelations entry]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-feature-relations/SKILL.md`, follow mode: register logic)]]
187
228
 
188
229
  **Output**: Change diffs of above files (brief).
189
230
  </step_3_global_sync>
190
231
 
191
232
  <step_4_generate>
192
233
  **Role**: Doc Engineer
193
- **Input**: Confirmed Unified Proposal (task design + architecture recommendations) + updated global context.
234
+ **Input**: Confirmed Unified Proposal (task design + architecture recommendations) + updated global context + Task Type from step_1_5.
194
235
  **Action**: Generate standard docs under `[[__DOCS_DIR__]]/tasks/<ID>_<Slug>/`.
195
236
 
196
237
  **1. `spec.md`** (Mandatory):
197
238
  - Template: `templates/spec.template.md`.
198
- - Convert confirmed task design and architecture recommendations to Gherkin Scenarios.
199
- - Each Scenario must map to a concrete flow step or exception path from the task design; do not invent scenarios.
200
- - If upstream task, must include explicit Interface/Type definitions.
239
+
240
+ **spec § 2 dimension format by Task Type**:
241
+
242
+ | Task Type | § 2 Primary Dimension | Format requirement |
243
+ |:---|:---|:---|
244
+ | Feature | Behavioral | Gherkin (Given/When/Then); each Scenario maps to concrete flow step or exception path from task design |
245
+ | Infrastructure | Structural | Configuration Contract per config file/service (Path + Key Settings + Constraints + Verify). Key Settings **must state concrete values**; no generic descriptions (e.g. "configure X") |
246
+ | Quality | Quantitative | Quality Target; each optimization goal has Metric + Baseline + Target + Verify |
247
+ | Edit | Inherit from original | Same as original task type |
248
+
249
+ > Mixed tasks use sub-headings in § 2 to distinguish dimensions (e.g. INF task with Behavioral subsection for hotkey behavior).
250
+
251
+ **spec § 4 Interface Exports**: INF tasks **required** (downstream infrastructure must declare exports); FEAT tasks required when has downstream deps.
252
+ **spec § 5 Constraints**: **Required** — extract relevant red lines from vision.md + 02_tech_stack.md.
253
+
254
+ **General rules**:
255
+ - Do not invent Acceptance Criteria; each must correspond to concrete content in task design.
256
+ - If upstream task, must include explicit Interface/Type definitions in § 4.
201
257
 
202
258
  **2. `ui.md`** [?UI]:
203
259
  - Template: `templates/ui.template.md`.
204
260
  - **With `ui_context.md` (primary path)**:
205
- 1. **UI Divergence Check** (required before writing `ui.md`): Compare the confirmed task design from step_2 against the screen inventory in `ui_context.md`:
261
+ 1. **UI Divergence Check** (required before writing `ui.md`): Compare the confirmed task design from step_2 against the screen inventory in `ui_context.md`. [[SKILL: archi-ui-wireframe|Follow the skill protocol to handle UI divergence.]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-ui-wireframe/SKILL.md` and follow its protocol)]]. Criteria and action:
206
262
 
207
263
  | Divergence type | Criteria | Action |
208
264
  |:---|:---|:---|
209
265
  | No divergence | Screen index matches design | Write `ui.md` directly, reference screen ID |
210
- | Minor addition | New state / modal / local area, overall layout unchanged | Call `archi-ui-wireframe` Skill (Plan refinement mode) to update `ui_concept.html` + `ui_context.md`; note `MODIFIED: S-XX` in `ui.md` |
211
- | Structural divergence | Layout restructure, new standalone screen, flow path change | **Pause** — present divergence summary to user, wait for **OK**, then call Skill to update `ui_concept.html` + `ui_context.md`, then write `ui.md` |
266
+ | Minor addition | New state / modal / local area, overall layout unchanged | Call skill (Plan refinement mode) to update `ui_concept.html` + `ui_context.md`; note `MODIFIED: S-XX` in `ui.md` |
267
+ | Structural divergence | Layout restructure, new standalone screen, flow path change | **Pause** — present divergence summary to user, wait for **OK**, then call skill to update `ui_concept.html` + `ui_context.md`, then write `ui.md` |
212
268
 
213
269
  2. After resolving divergence, fill in screen scope and delta components per `ui.template.md`.
214
270
  - **Without `ui_context.md` (fallback path)**: Write full ITP v3.0 component tree, referencing `design_tokens.json` token definitions.
215
271
 
216
- **3. `plan.json`** (Mandatory):
272
+ **3. `design.md`** [?Complex]:
273
+ - Template: `templates/design.template.md`.
274
+ - Generate only when step_1_5 verdict is **Standard + Design**.
275
+ - § 2 Core Mechanisms: Per step_2 confirmed mechanism preview, call [[SKILL: archi-design-patterns|skill's pattern selection guide and standard format to generate mechanism descriptions and run self-checks]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-design-patterns/SKILL.md` and follow its pattern formats and self-check lists)]].
276
+ - § 3 Parameters: All mechanism numeric values must be concrete; no vague descriptions.
277
+ - § 4 Invariants: Each must be testable; must map to plan.json test entries.
278
+ - § 5 Failure Modes: Each failure must have detection + fallback behavior.
279
+ - § 6 Trace Verification: Trace design path from each spec § 2 AC; fix gaps by returning to § 2 or § 5.
280
+
281
+ **4. `plan.json`** (Mandatory):
217
282
  - Template: `templates/plan.template.json`.
218
283
  - Dynamically adjust Phases by project type; ensure each Task's context is self-contained.
219
284
  - Task descriptions explicitly state "Additive Only" + "Respect Unknowns".
220
- - **`decisions`**: Fill per dimension; `choice` supports multi-select (e.g. `A B`, space-separated), custom (`Z: …`); `rationale` must explain reasoning for code phase; do not leave empty.
221
- - **`notes`**: Fill each task's `notes` with: `[scope] · [spec ref] · [key constraints] · Verify: [concrete operation]`; used by `/archi.code` step_4 to locate context and run e2e; do not leave empty.
222
- > Example: `Implement POST /auth/login · spec §3.1 · JWT must not contain password · Verify: curl POST /auth/login returns 200 + token field`
285
+
286
+ **WBS decomposition three principles (must follow when generating plan.json)**:
287
+
288
+ **Principle 1 — Deliverable-oriented**: Each task `title` describes **deliverable** not activity.
289
+ > ✅ Good: `apps/web/tsconfig.json — strict + path aliases`
290
+ > ❌ Bad: `Configure TypeScript`
291
+
292
+ **Principle 2 — 100% coverage**: After generation, verify coverage:
293
+ | Check | Rule |
294
+ |:---|:---|
295
+ | Each spec § 2 Acceptance Criteria item | Must have ≥1 task covering it |
296
+ | Each spec § 4 Interface Export | Must have task responsible for creating/exposing it |
297
+ | Each spec § 5 Constraint | Must be referenced in some task's notes |
298
+ Add tasks until 100% covered.
299
+
300
+ **Principle 3 — Granularity and mutual exclusion**:
301
+ | Signal | Verdict |
302
+ |:---|:---|
303
+ | Task involves ≥3 unrelated files | Too coarse — split |
304
+ | Task title cannot map to concrete output file | Too abstract — concretize |
305
+ | Two tasks modify same file same region | Violates mutual exclusion — merge or redraw boundary |
306
+ | Task notes single sentence with no verification | Insufficient info — supplement |
307
+
308
+ **`decisions` quality standard**:
309
+ - `rationale` **must include implementation guidance**; not only "why choose" but "how to configure after choosing".
310
+ > ✅ Good: `pnpm workspace manages apps/ + packages/; Turborepo pipeline: build→lint→type-check three-level cache; root scripts unified entry`
311
+ > ❌ Bad: `Brief explicitly requires` ← zero implementation guidance
312
+
313
+ **`notes` quality standard**:
314
+ - Format: `[output file path or operation target] · [spec ref] · [key constraints] · Verify: [executable command + expected result]`
315
+ - Used by `/archi.code` step_4 to locate and run e2e; do not leave empty.
316
+ > ✅ Good: `Create apps/web/next.config.ts · spec §2.2 · transpilePackages: ['@repo/ui'], output: 'standalone' · no CSS-in-JS · Verify: pnpm --filter web build succeeds (exit 0)`
317
+ > ❌ Bad: `Configure Next.js · spec §2.2` ← no concrete content, constraints, or verification
318
+ > ❌ Bad: `Create file · spec §2.1 · Verify: check file exists` ← "check file exists" not executable
319
+ > **Red Flag**: notes degenerate to title synonym. Each notes must contain information **not present** in title.
320
+
223
321
  - Run `npx archi render` after generation to produce readable `.md` view.
224
322
  </step_4_generate>
225
323
 
226
- <step_5_audit>
227
- **Role**: Chief Auditor
228
- **Checklist**:
229
- 1. **Design Fidelity**: Do Scenarios fully cover confirmed task design (flow steps and exception paths)?
230
- 2. **Tech Consistency**: Any undeclared tech used?
231
- 3. **Data Integrity**: Do Scenario entities match confirmed core entities?
232
- 4. **Error Handling**: Is Error Handling recommendation covered?
233
- 5. **AX Compliance**: Are Anti-Clobbering and Interface Stability rules followed?
324
+ <step_5_verify>
325
+ **Role**: Independent Reviewer
326
+
327
+ [[SUBAGENT: archi-silent-audit|mode: plan-docs, context: Review step_4 generated docs (spec.md, ui.md, plan.json, design.md)]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-silent-audit/SKILL.md`, follow mode: plan-docs review dimension table item by item)]]
234
328
 
235
- Silently fix issues; mark critical issues with `⚠️ Risk Warning`.
236
- </step_5_audit>
329
+ [[INCLUDE: shared/verify-result-handling.md]]
330
+ </step_5_verify>
237
331
 
238
332
  <step_6_signoff>
239
333
  **Terminal Gate** (Do not skip; must complete before output summary):
240
334
  | Step | Command | Pass Condition |
241
335
  |:---|:---|:---|
242
336
  | 1 | `npx archi task --check` | No ERROR-level issues |
243
- | 2 | `npx archi task <ID> --status active` | Task marked as in-progress |
244
- | 3 | `npx archi render` | `.md` views generated |
337
+ | 2 | `npx archi render` | `.md` views generated |
338
+ | 3 | `npx archi task <ID> --status active` | Task marked as in-progress |
245
339
 
246
340
  **Action** (After Gate passes):
247
341
  1. Output summary.
@@ -0,0 +1,63 @@
1
+ <protocol_recover>
2
+ **Trigger**: `/archi.recover <pack-file>`
3
+ **Goal**: Read the pack file and write all user data (docs, tasks, custom rules) to their corresponding paths in the current project, completing data restore after a framework upgrade.
4
+
5
+ <meta>
6
+ <style>Precise, Efficient, Non-interactive</style>
7
+ <language>English</language>
8
+ <principles>
9
+ 1. **User Data Only**: The pack file contains only user data (`global/`, `tasks/`, `scripts/`, custom rules) — no framework files. Write all entries without filtering.
10
+ 2. **Overwrite Always**: If the target file already exists, overwrite it directly without prompting (in an upgrade scenario, existing files are empty templates and safe to replace).
11
+ 3. **Delta Notation**: Label each written file as `ADDED` or `MODIFIED` in the output.
12
+ 4. **No Partial Write**: If any file write fails, stop immediately and report. Already-written files are not rolled back (idempotent — safe to re-run).
13
+ </principles>
14
+ </meta>
15
+
16
+ <step_1_ingest>
17
+ **Role**: Intelligence Analyst
18
+ **Action**:
19
+ 1. Read the file at the `<pack-file>` path.
20
+ 2. Parse the XML; extract the `path` attribute and CDATA content of each `<file>` element under `<files>`.
21
+
22
+ | Condition | Action |
23
+ |:---|:---|
24
+ | File not found or unreadable | Stop — ask user to verify path; suggest running `archi pack` to regenerate |
25
+ | XML malformed | Stop — note file may be corrupted; suggest re-running `archi pack` |
26
+ | `<files>` is empty | Stop — inform user the pack is empty |
27
+
28
+ **Output**: Internal file list (path + content). Do not output to user.
29
+ </step_1_ingest>
30
+
31
+ <step_2_apply>
32
+ **Role**: Senior Engineer
33
+ **Action**:
34
+ 1. For each `<file>` entry:
35
+ - Use the `path` attribute (relative to project root) as the write target.
36
+ - If the target file exists → overwrite (mark as `MODIFIED`).
37
+ - If the target file does not exist → create (mark as `ADDED`).
38
+ - Write the full CDATA content, preserving original line endings and encoding.
39
+ 2. Note: paths in the pack may contain nested subdirectories (e.g. `tasks/FEAT-001_auth/spec.md`); ensure parent directories exist before writing.
40
+
41
+ **Output**:
42
+ ```
43
+ ADDED .architext/global/vision.md
44
+ ADDED .architext/global/roadmap.json
45
+ ADDED .architext/tasks/FEAT-001_auth/spec.md
46
+ MODIFIED .cursor/rules/90_custom_rules.mdc
47
+ ...
48
+ ```
49
+ </step_2_apply>
50
+
51
+ <step_3_signoff>
52
+ **Action**:
53
+ 1. Output restore summary:
54
+ - Total files written (ADDED and MODIFIED counted separately)
55
+ 2. Next Steps:
56
+
57
+ | Step | Notes |
58
+ |:---|:---|
59
+ | Verify framework state | Run `/archi.help` to check project status and recommended next actions |
60
+ | Clean up pack file | You may delete `<pack-file>` — it is no longer needed |
61
+ </step_3_signoff>
62
+
63
+ </protocol_recover>
@@ -0,0 +1,258 @@
1
+ <protocol_ref>
2
+ **Trigger**: `/archi.ref <sub> [args]`
3
+ **Goal**: Manage external knowledge references (third-party APIs, internal SDKs, business rules, etc.), store them in `refs/` in a structured way, and inject context into `plan`/`code` on demand.
4
+
5
+ **Subcommands**:
6
+ | Subcommand | Format | Purpose |
7
+ |:---|:---|:---|
8
+ | `add` | `/archi.ref add [input]` | Summarize and store external knowledge (core) |
9
+ | `list` | `/archi.ref list` | List all stored references |
10
+ | `update` | `/archi.ref update <id>` | Re-summarize a specified reference |
11
+ | `remove` | `/archi.ref remove <id>` | Remove a specified reference |
12
+
13
+ <meta>
14
+ <style>Analytical, Precise, Context-Aware</style>
15
+ <language>English</language>
16
+ <principles>
17
+ 1. **Summarize, Not Copy**: Do not copy full original content; distill into structured summaries (key interfaces / constraints / examples) for efficient AI use, compression ratio ≥ 50%.
18
+ 2. **Format-Aware**: Choose the most suitable carrier format (`.md` / `.json` / `.yaml`) based on content type, preserving semantic advantages of the original format.
19
+ 3. **Tag-Driven**: Each ref must carry tags for `plan`/`code` to match and inject on demand; no tagless references allowed.
20
+ 4. **Index-First**: All operations must sync with `refs/index.json`; AI loads on demand via index, no full scan.
21
+ </principles>
22
+ </meta>
23
+
24
+ <!-- ─── Format selection rules ─── -->
25
+ <format_selection>
26
+ **Format-Aware rules** (referenced during step_3_store):
27
+
28
+ | Content type | Recommended format | Rationale |
29
+ |:---|:---|:---|
30
+ | Web page / URL / PDF / plain text | `.md` | Structured summary, highest AI read efficiency |
31
+ | OpenAPI / Swagger spec | `.yaml` | Preserve machine-readable structure; do not convert to .md |
32
+ | JSON Schema / config files | `.json` | Original structured data format is optimal |
33
+ | Mixed (with many code examples) | `.md` (with code blocks) | Preserve syntax in code blocks, add explanatory context |
34
+ | User pasted (pure Markdown) | `.md` | Store in same format, may refine |
35
+ </format_selection>
36
+
37
+ <!-- ═══════════════════════════════════════════════ -->
38
+ <!-- ADD subcommand -->
39
+ <!-- ═══════════════════════════════════════════════ -->
40
+
41
+ <sub_add>
42
+
43
+ <step_0_ingest>
44
+ **Role**: Intelligence Analyst
45
+ **Trigger**: `/archi.ref add [input]`
46
+ **Action**: Parse `[input]` to determine input source.
47
+
48
+ | input form | Handling |
49
+ |:---|:---|
50
+ | Local file path (e.g. `./docs/api.yaml`) | Read file content, record `sourceType: local-file` |
51
+ | URL (e.g. `https://...`) | Fetch page content, record `sourceType: url` |
52
+ | Not provided (conversation mode) | Ask user to paste content or provide path/URL, wait for input, record `sourceType: manual` |
53
+
54
+ Check if `[[__DOCS_DIR__]]/refs/index.json` exists:
55
+ - Exists → Read, get existing id list (avoid duplicate names)
56
+ - Not exists → Initialize as `{ "refs": [] }`
57
+
58
+ **Output**: Internal (raw content + sourceType + existing id list), proceed to `<step_1_analyze>`.
59
+ </step_0_ingest>
60
+
61
+ <step_1_analyze>
62
+ **Role**: System Analyst
63
+ **Action**:
64
+ 1. **Content type identification**: Determine which type the raw content belongs to (see `<format_selection>`), decide recommended storage format.
65
+ 2. **Key info extraction**: From content extract:
66
+ - Core interfaces/endpoints/function signatures
67
+ - Parameter list and types (input/output)
68
+ - Important constraints, limits, caveats
69
+ - Auth/authorization (if any)
70
+ - Typical usage examples (≤ 3)
71
+ 3. **Info gap identification**:
72
+ - id naming (infer a candidate, e.g. `wechat-pay`, pending user confirmation)
73
+ - tags (infer from standard tags: `api` / `sdk` / `internal` / `payment` / `auth` / `map` / `notification` / `storage` / custom)
74
+ - Focus areas (if content is large, confirm which interfaces/features user cares about)
75
+
76
+ **Output**: Internal analysis summary, proceed to `<step_2_interview>` (if gaps) or directly `<step_3_store>` (if complete).
77
+ </step_1_analyze>
78
+
79
+ <step_2_interview>
80
+ **Role**: Product Consultant
81
+ **Trigger**: Execute only when id / tags / focus is uncertain.
82
+ **Action**: Ask user questions, max 3 questions, prefer multiple choice.
83
+
84
+ **Output format**:
85
+ ```
86
+ ### Reference info confirmation
87
+
88
+ **Content type**: [identified] → will store as [.md / .yaml / .json]
89
+ **Content summary**: [one-sentence description of raw content]
90
+
91
+ **Q1 — Reference ID** (for file naming and reference):
92
+ [A] [AI-inferred candidate] (recommended)
93
+ [B] Custom
94
+
95
+ **Q2 — Tags** (multi-select):
96
+ [A] api [B] sdk [C] internal [D] payment [E] auth [F] Other: ___
97
+
98
+ (If content is large) **Q3 — Focus**:
99
+ [A] Keep full [B] Keep only [specific interface list] [C] Custom
100
+
101
+ **INPUT**: Q1 answer | Q2 answer | Q3 answer (if any)
102
+ ```
103
+
104
+ **Gate**: Wait for user reply before `<step_3_store>`.
105
+ </step_2_interview>
106
+
107
+ <step_3_store>
108
+ **Role**: Senior Engineer
109
+ **Action**:
110
+ 1. Determine storage params:
111
+ - `id`: User-confirmed value (or AI-inferred)
112
+ - `format`: File extension from `<format_selection>` rules
113
+ - `filename`: `{id}.{format}`
114
+ - `tags`: User-confirmed tags list
115
+
116
+ 2. **Generate ref file content** (by format):
117
+
118
+ **`.md` format skeleton**:
119
+ ```markdown
120
+ ---
121
+ id: {id}
122
+ title: {title}
123
+ tags: [{tags}]
124
+ sourceType: url | local-file | manual
125
+ source: {source path or URL, "manual-input" when manual}
126
+ created: {YYYY-MM-DD}
127
+ updated: {YYYY-MM-DD}
128
+ ---
129
+
130
+ ## Core info
131
+ <!-- Base URL, version, auth, etc. -->
132
+
133
+ ## Key interfaces
134
+ | Interface/Function | Path/Signature | Description |
135
+ |:---|:---|:---|
136
+
137
+ ## Important constraints and caveats
138
+
139
+ ## Examples
140
+ <!-- ≤ 3 most representative examples -->
141
+ ```
142
+
143
+ **`.yaml` format**: Store original OpenAPI/Swagger content (trim redundant example fields in responses, keep schema structure).
144
+
145
+ **`.json` format**: Store original JSON Schema or config (remove comments, keep structure).
146
+
147
+ 3. **Write file**: `[[__DOCS_DIR__]]/refs/{id}.{ext}`
148
+
149
+ 4. **Update index**: Append to `[[__DOCS_DIR__]]/refs/index.json` refs array:
150
+ ```json
151
+ {
152
+ "id": "{id}",
153
+ "title": "{title}",
154
+ "tags": ["{tags}"],
155
+ "format": "{ext}",
156
+ "file": "{id}.{ext}",
157
+ "sourceType": "url | local-file | manual",
158
+ "updatedAt": "{YYYY-MM-DD}"
159
+ }
160
+ ```
161
+
162
+ **Output**:
163
+ ```
164
+ ADDED [[__DOCS_DIR__]]/refs/{id}.{ext}
165
+ MODIFIED [[__DOCS_DIR__]]/refs/index.json
166
+ ```
167
+ </step_3_store>
168
+
169
+ <step_4_signoff_add>
170
+ **Output**: Add summary including:
171
+ - **Reference ID**: `{id}`
172
+ - **Storage format**: `{ext}` — rationale (one sentence)
173
+ - **Tags**: `[tags]`
174
+ - **File path**: `[[__DOCS_DIR__]]/refs/{id}.{ext}`
175
+ - **How to use**:
176
+
177
+ | Scenario | Description |
178
+ |:---|:---|
179
+ | `/archi.plan <ID>` | When planning involves `[tags]`-related features, AI auto-reads this ref |
180
+ | `/archi.code <ID>` | Injected as supplementary context during coding, provides interface signatures and constraint details |
181
+ | Manual reference | Mention "see `refs/{id}`" in conversation |
182
+ </step_4_signoff_add>
183
+
184
+ </sub_add>
185
+
186
+ <!-- ═══════════════════════════════════════════════ -->
187
+ <!-- LIST subcommand -->
188
+ <!-- ═══════════════════════════════════════════════ -->
189
+
190
+ <sub_list>
191
+
192
+ **Role**: System Analyst
193
+ **Trigger**: `/archi.ref list`
194
+ **Action**: Read `[[__DOCS_DIR__]]/refs/index.json`.
195
+
196
+ | Condition | Handling |
197
+ |:---|:---|
198
+ | Index missing / refs empty | Prompt "No references yet, run `/archi.ref add` to add the first" |
199
+ | Normal | Display grouped by tags |
200
+
201
+ **Output**:
202
+ ```
203
+ ### External knowledge references (N total)
204
+
205
+ #### [tag group name]
206
+ | ID | Title | Format | Updated |
207
+ |:---|:---|:---|:---|
208
+ | wechat-pay | WeChat Pay V3 API | .md | 2025-01-15 |
209
+ | openapi-spec | Internal service OpenAPI | .yaml | 2025-01-10 |
210
+ ```
211
+
212
+ </sub_list>
213
+
214
+ <!-- ═══════════════════════════════════════════════ -->
215
+ <!-- UPDATE subcommand -->
216
+ <!-- ═══════════════════════════════════════════════ -->
217
+
218
+ <sub_update>
219
+
220
+ **Role**: Senior Engineer
221
+ **Trigger**: `/archi.ref update <id>`
222
+ **Action**:
223
+ 1. Find `<id>` in `index.json`, get `file` and `sourceType`.
224
+ 2. If `sourceType` is `url` → re-fetch original URL; `local-file` → re-read file; `manual` → prompt user to paste new content.
225
+ 3. Re-run `<step_1_analyze>` + `<step_3_store>` (keep original id/tags/format, only refresh content and `updatedAt`).
226
+
227
+ | Condition | Handling |
228
+ |:---|:---|
229
+ | id not in index.json | Stop — prompt to check id, run `/archi.ref list` to view |
230
+
231
+ </sub_update>
232
+
233
+ <!-- ═══════════════════════════════════════════════ -->
234
+ <!-- REMOVE subcommand -->
235
+ <!-- ═══════════════════════════════════════════════ -->
236
+
237
+ <sub_remove>
238
+
239
+ **Role**: System Administrator
240
+ **Trigger**: `/archi.ref remove <id>`
241
+ **Action**:
242
+ 1. Find and remove `<id>` from `index.json`.
243
+ 2. Delete corresponding `refs/{id}.{ext}` file.
244
+ 3. Update `index.json`.
245
+
246
+ **Output**:
247
+ ```
248
+ REMOVED [[__DOCS_DIR__]]/refs/{id}.{ext}
249
+ MODIFIED [[__DOCS_DIR__]]/refs/index.json
250
+ ```
251
+
252
+ | Condition | Handling |
253
+ |:---|:---|
254
+ | id not found | Stop — prompt to check id, run `/archi.ref list` to view |
255
+
256
+ </sub_remove>
257
+
258
+ </protocol_ref>
@@ -120,7 +120,7 @@
120
120
  **Phase 2 — Cascade Update Task Docs**:
121
121
  For each affected Task, follow `/archi.edit` standards:
122
122
  1. Update `spec.md` (logic/rules that need adjustment due to global changes).
123
- 2. [?UI] Update `ui.md` (scope/interaction adjustments due to global changes); if screen structure is affected, run `archi-ui-wireframe` Skill (incremental update mode) to sync both `ui_concept.html` + `ui_context.md`.
123
+ 2. [?UI] Update `ui.md` (scope/interaction adjustments due to global changes); if screen structure is affected, [[SKILL: archi-ui-wireframe|run skill (incremental update mode) to sync both `ui_concept.html` + `ui_context.md`]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-ui-wireframe/SKILL.md` and follow its protocol)]].
124
124
  3. Append new Phase to `plan.json` `phases`: `Phase X: Global Revision — [Change Topic] (<Date>)`, listing implementation tasks.
125
125
 
126
126
  **Output**: Change summary for each file (global + Task).
@@ -102,14 +102,14 @@
102
102
  **Trigger**: Only when Step 2 identifies "Required" or "Recommended" gaps.
103
103
  **Input**: Step 2 gap list. Max 3 questions.
104
104
 
105
- [[SKILL: Follow `archi-interview-protocol` Skill's core rules and standard output format.]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-interview-protocol/SKILL.md` and follow its rules)]]
105
+ [[SKILL: archi-interview-protocol|Follow the skill's core rules and standard output format.]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-interview-protocol/SKILL.md` and follow its rules)]]
106
106
  </step_2_5_supplementary>
107
107
 
108
108
  <step_3_decompose>
109
109
  **Role**: Chief Architect
110
110
  **Input**: Full Brief + project context + supplementary answers (if any).
111
111
 
112
- **Action**: [[SKILL: Follow the `archi-decompose-roadmap` Skill protocol to generate incremental task data from the Scope Brief task list]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-decompose-roadmap/SKILL.md` and follow its protocol)]]
112
+ **Action**: [[SKILL: archi-decompose-roadmap|Follow the skill protocol to generate incremental task data from the Scope Brief task list.]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-decompose-roadmap/SKILL.md` and follow its protocol)]]
113
113
 
114
114
  **Display format** (convert Skill output into the following format, present to user and await confirmation):
115
115
 
@@ -171,7 +171,7 @@
171
171
 
172
172
  | Priority | Action | Description |
173
173
  |:---|:---|:---|
174
- | [?UI] Recommended | Run `archi-ui-wireframe` Skill (append mode) | Append screens for new tasks to `ui_concept.html`, sync `ui_context.md` |
174
+ | [?UI] Recommended | [[SKILL: archi-ui-wireframe|Run skill (append mode)]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-ui-wireframe/SKILL.md` and follow its protocol)]] | Append screens for new tasks to `ui_concept.html`, sync `ui_context.md` |
175
175
  | 1 | `/archi.plan <first pending task ID>` | Deep planning for the first actionable task |
176
176
  | 2 | Review roadmap | Confirm dependency relationships and priorities |
177
177
  </step_5_signoff>