architext 0.0.4 → 0.0.5

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 (56) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/README.md +84 -7
  3. package/README.zh-CN.md +84 -7
  4. package/dist/index.js +38 -38
  5. package/dist/templates/en/briefs/_base.md +44 -11
  6. package/dist/templates/en/briefs/_modules.md +31 -4
  7. package/dist/templates/en/docs/prompts/audit.md +80 -94
  8. package/dist/templates/en/docs/prompts/code.md +87 -89
  9. package/dist/templates/en/docs/prompts/edit.md +47 -51
  10. package/dist/templates/en/docs/prompts/fix.md +49 -42
  11. package/dist/templates/en/docs/prompts/help.md +23 -31
  12. package/dist/templates/en/docs/prompts/inherit.md +91 -116
  13. package/dist/templates/en/docs/prompts/map.md +47 -69
  14. package/dist/templates/en/docs/prompts/plan.md +134 -239
  15. package/dist/templates/en/docs/prompts/recover.md +19 -34
  16. package/dist/templates/en/docs/prompts/ref.md +43 -138
  17. package/dist/templates/en/docs/prompts/remove.md +55 -107
  18. package/dist/templates/en/docs/prompts/revise.md +63 -106
  19. package/dist/templates/en/docs/prompts/scope.md +77 -117
  20. package/dist/templates/en/docs/prompts/start.md +89 -129
  21. package/dist/templates/en/rules/00_system.md +36 -79
  22. package/dist/templates/en/rules/01_workflow.md +59 -57
  23. package/dist/templates/en/rules/03_data_governance.md +46 -42
  24. package/dist/templates/en/skills/archi-data-sync/SKILL.md +12 -12
  25. package/dist/templates/en/skills/archi-decompose-roadmap/SKILL.md +3 -34
  26. package/dist/templates/en/skills/archi-design-patterns/SKILL.md +1 -0
  27. package/dist/templates/en/skills/archi-feature-relations/SKILL.md +4 -4
  28. package/dist/templates/en/skills/archi-interview-protocol/SKILL.md +2 -1
  29. package/dist/templates/en/skills/archi-plan-options/SKILL.md +4 -3
  30. package/dist/templates/en/skills/archi-silent-audit/SKILL.md +20 -20
  31. package/dist/templates/en/skills/archi-ui-wireframe/SKILL.md +315 -270
  32. package/dist/templates/zh/briefs/_base.md +44 -12
  33. package/dist/templates/zh/briefs/_modules.md +27 -0
  34. package/dist/templates/zh/docs/prompts/audit.md +42 -56
  35. package/dist/templates/zh/docs/prompts/code.md +47 -49
  36. package/dist/templates/zh/docs/prompts/edit.md +38 -42
  37. package/dist/templates/zh/docs/prompts/fix.md +30 -29
  38. package/dist/templates/zh/docs/prompts/help.md +13 -21
  39. package/dist/templates/zh/docs/prompts/inherit.md +59 -83
  40. package/dist/templates/zh/docs/prompts/map.md +24 -47
  41. package/dist/templates/zh/docs/prompts/plan.md +92 -197
  42. package/dist/templates/zh/docs/prompts/recover.md +9 -24
  43. package/dist/templates/zh/docs/prompts/ref.md +11 -106
  44. package/dist/templates/zh/docs/prompts/remove.md +31 -71
  45. package/dist/templates/zh/docs/prompts/revise.md +37 -86
  46. package/dist/templates/zh/docs/prompts/scope.md +51 -91
  47. package/dist/templates/zh/docs/prompts/start.md +67 -106
  48. package/dist/templates/zh/rules/00_system.md +18 -91
  49. package/dist/templates/zh/rules/01_workflow.md +60 -59
  50. package/dist/templates/zh/rules/03_data_governance.md +41 -68
  51. package/dist/templates/zh/skills/archi-decompose-roadmap/SKILL.md +2 -33
  52. package/dist/templates/zh/skills/archi-design-patterns/SKILL.md +1 -0
  53. package/dist/templates/zh/skills/archi-interview-protocol/SKILL.md +2 -1
  54. package/dist/templates/zh/skills/archi-plan-options/SKILL.md +1 -0
  55. package/dist/templates/zh/skills/archi-ui-wireframe/SKILL.md +317 -269
  56. package/package.json +1 -1
@@ -1,69 +1,61 @@
1
1
  <protocol_help>
2
2
  **Trigger**: `/archi.help [question]`
3
- **Goal**: Project navigation and contextual Q&A. Analyze current project state to recommend next actions; or answer user questions based on project context.
3
+ **Goal**: Project navigation and context Q&A. Analyze project current state, recommend next actions; or answer user questions based on project context.
4
4
 
5
5
  <meta>
6
6
  <style>Concise, Contextual, Actionable</style>
7
7
  <language>English</language>
8
8
  <principles>
9
- 1. **Context-Aware**: Answer based on real project state. No guessing.
10
- 2. **Actionable Output**: Every output must include an executable next step (specific command + args).
11
- 3. **Minimal Token**: Keep output concise. Don't repeat what the user already knows. Only present conclusions and recommendations.
12
- 4. **No Audit**: No deep auditing (that's `/archi.audit`'s job). Focus on navigation and Q&A.
9
+ 1. **Context-Aware**: Answer based on actual project state; no guessing.
10
+ 2. **Actionable Output**: Every output must include executable next-step suggestions (concrete command + params).
11
+ 3. **Minimal Token**: Concise output; don't restate known info. Present reasoning and suggestions only.
12
+ 4. **No Audit**: Do not do deep audit (that's `/archi.audit`). Focus on navigation and Q&A.
13
13
  </principles>
14
14
  </meta>
15
15
 
16
16
  <step_1_load_context>
17
- **Role**: Project Observer
18
17
  **Action**:
19
- 1. Read `[[__DOCS_DIR__]]/global/roadmap.json` — extract only `id/title/status/deps/tag` fields per task; skip `goal/notes` (navigation and status aggregation do not need these details).
20
- 2. Scan `[[__DOCS_DIR__]]/tasks/` directory — get existing Tasks and their doc completeness (spec.md / ui.md / plan.json).
21
- 3. [?question] If user provided a question, locate relevant files by semantic match (spec / plan / vision / tech_stack / data_snapshot, etc.), read as needed.
18
+ 1. **Load**: roadmap.json (id/title/status/deps/tag only; skip goal/notes).
19
+ 2. **Scan Tasks**: Scan tasks/ — get existing Tasks and doc completeness (has spec.md / ui.md / plan.json).
20
+ 3. [?question] If user provided a question, locate and read relevant files by semantics.
22
21
 
23
22
  **Output**: Internal context (not shown to user).
24
23
  </step_1_load_context>
25
24
 
26
25
  <step_2_route>
27
- **Role**: Router
28
- **Action**: Branch based on input:
26
+ **Action**: Branch by input:
29
27
 
30
28
  | Input | Branch |
31
29
  |:---|:---|
32
30
  | No args | → step_3_navigate (project navigation) |
33
- | Has `[question]` | → step_4_answer (contextual Q&A) |
31
+ | Has `[question]` | → step_4_answer (context Q&A) |
34
32
 
35
33
  </step_2_route>
36
34
 
37
35
  <step_3_navigate>
38
- **Role**: Project Navigator
39
36
  **Action**:
40
37
  1. **Determine project phase**:
41
38
 
42
- | Signal | Phase | Recommendation |
39
+ | Signal | Phase | Suggestion |
43
40
  |:---|:---|:---|
44
41
  | roadmap.json missing | Not initialized | New project → `/archi.start`; existing code → `/archi.inherit` |
45
- | Has roadmap but no Task dirs | Started, not planned | Run `/archi.scope` to plan new tasks |
46
- | Has Legacy stubs (Spec-Status: Stub) | Inherited, not enriched | Run `/archi.edit LEG-xx` to enrich spec |
47
- | Has active tasks with complete plan.json | Ready to code | Run `/archi.code <ID>` |
48
- | Has active tasks but missing spec/plan | Planning incomplete | Run `/archi.plan <ID>` to complete |
49
- | All tasks done | Complete | Run `/archi.scope` to plan new tasks or release |
50
- | Has blocked tasks | Blocked | Show blocking reason and prerequisites |
51
-
52
- 2. **Output format**:
53
- - One-line summary of current state
54
- - Recommended next action (with specific command)
55
- - If multiple paths available, list by priority (max 3)
42
+ | Has roadmap but no tasks/ | Started, not planned | `/archi.scope` to plan new tasks |
43
+ | Has Legacy stub (Spec-Status: Stub) | Inherited, not enriched | `/archi.edit LEG-xx` to enrich spec |
44
+ | Has active task and plan.json complete | Ready to code | `/archi.code <ID>` |
45
+ | Has active task but missing spec/plan | Planning incomplete | `/archi.plan <ID>` to complete |
46
+ | All tasks done | Completed | `/archi.scope` to plan new or release |
47
+ | Has blocked task | Blocked | Show block reason and upstream deps |
48
+
49
+ 2. **Output**: One-line state summary + recommended next step (with command) + optional paths (≤3, by priority).
56
50
  </step_3_navigate>
57
51
 
58
52
  <step_4_answer>
59
- **Role**: Project Advisor
60
53
  **Action**:
61
- 1. Parse `[question]` semantics, locate relevant project files.
62
- 2. Read relevant files, synthesize answer.
63
- 3. If question involves an action (e.g. "how to do X"), include specific command suggestions.
64
- 4. If insufficient info to answer, state what's missing instead of fabricating.
54
+ 1. Parse `[question]` semantics; locate and read relevant project files.
55
+ 2. Answer comprehensively; operational questions must include concrete command suggestions.
56
+ 3. When info insufficient, state what's missing; do not fabricate.
65
57
 
66
- **Output**: Concise answer based on project context + relevant file references.
58
+ **Output**: Concise answer based on project context + relevant file refs.
67
59
  </step_4_answer>
68
60
 
69
61
  </protocol_help>
@@ -1,34 +1,29 @@
1
1
  <protocol_inherit>
2
2
  **Trigger**: `/archi.inherit [brief_path]`
3
3
  **Phase**: Legacy Adoption
4
- **Goal**: Reverse-engineer an existing codebase to generate the Architext document skeleton, bringing the project under framework governance. Optionally provide a Brief to supplement vision/roadmap (for skeleton repos with minimal code).
4
+ **Goal**: Reverse-engineer existing codebase to fill the init-deployed document skeleton (`[[__DOCS_DIR__]]`) with analysis results, bringing project under framework governance. Fills empty placeholders; does not overwrite user's existing content. Optionally provide Brief to supplement vision/roadmap (for skeleton repos with minimal code).
5
5
 
6
6
  <meta>
7
7
  <style>Analytical, Systematic, Evidence-Based</style>
8
8
  <language>English</language>
9
9
  <principles>
10
- 1. **Code-Driven**: Code is the sole source of truth; do not speculate on tasks without evidence.
11
- 2. **AI-Native Perspective**: All analysis from AI Agent perspective. Focus: Context Locality, Type Safety, Module Boundaries.
12
- 3. **User Agency First**: AI analysis must be confirmed by the user. When code interpretation is ambiguous, ask the user; do not decide unilaterally.
13
- 4. **Minimal Token**: Prioritize config files and entry points; avoid scanning every line of code.
10
+ 1. **Code-Driven**: Code is the sole source of truth; no speculation on features without evidence.
11
+ 2. **AI-Native Perspective**: Analysis from AI Agent perspective. Focus: Context Locality, Type Safety, Module Boundaries.
12
+ 3. **User Agency First**: AI analysis must be confirmed by user. When code interpretation is ambiguous, ask user; do not decide unilaterally.
13
+ 4. **Thorough Discovery, Layered Recording**: Read all non-third-party business code (exclude node_modules/vendor/dist and other generated artifacts), no file count limit. Record in three tiers: core modules with detailed flow documentation, shared logic with signatures and dependency relationships, pure utilities with signatures and purpose. Better to over-read than to miss — downstream protocols cannot use code that was not recorded.
14
14
  5. **Option Z Everywhere**: Supplementary questions must include `[Z] Custom`.
15
15
  </principles>
16
16
  </meta>
17
17
 
18
- <step_0_ingest>
18
+ <step_0_recon>
19
19
  **Role**: Intelligence Analyst
20
- **Trigger**: Only when user provides `[brief_path]`. Skip if no argument or path invalid.
21
- **Action**:
22
- 1. Parse `[brief_path]`: if path provided → read that file; if not → look for `project-brief.md` (project root), then `[[__DOCS_DIR__]]/project-brief.md`
23
- 2. If file exists and non-empty: parse Brief sections, extract project identity, core tasks, tech preferences, constraints, supplementary notes (same as start step_0_ingest)
24
- 3. If file missing or empty: skip this step; subsequent steps use code only as input
25
20
 
26
- **Output**: Internal Brief summary (not shown to user), proceed to step_0_recon.
27
- </step_0_ingest>
21
+ **Brief detection** (only when user provides `[brief_path]`):
22
+ 1. Parse `[brief_path]`: if path provided → read that file; if not → search `project-brief.md` (project root), then `[[__DOCS_DIR__]]/project-brief.md`
23
+ 2. If file exists and non-empty: parse Brief sections, extract project identity, core tasks, tech preferences, boundaries, supplementary notes (same as start step_0_ingest)
24
+ 3. If file missing or empty: skip Brief; subsequent steps use code only as input
28
25
 
29
- <step_0_recon>
30
- **Role**: Intelligence Analyst
31
- **Action**:
26
+ **Code reconnaissance**:
32
27
  1. Read project root config files (auto-detect type):
33
28
 
34
29
  | Language/Ecosystem | Config Files |
@@ -41,80 +36,52 @@
41
36
  | Other | Use root directory config files |
42
37
 
43
38
  2. Read README.md (if exists).
44
- 3. Scan directory structure (top-level + core source directories, two levels deep).
45
- 4. Infer project feature tags (UI / Data / CLI / Lib / API — from directory structure, dependencies, and config).
46
- 5. Identify entry points and core modules.
39
+ 3. Scan directory structure (full depth).
40
+ 4. Infer project feature tags (UI / Data / CLI / Lib / API — from directory structure, deps, and config).
41
+ 5. Identify entry points and core modules. Trace import chains from entry points to build a module dependency sketch.
47
42
 
48
43
  **Output**: Internal summary (not shown to user), proceed to step_1.
49
44
  </step_0_recon>
50
45
 
51
46
  <step_1_analysis>
52
- **Role**: System Analyst
53
- **Scan Strategy**: Medium-depth scan — read each module's entry file and core business files, extract main flow chains. Do not traverse every file.
47
+ **Role**: Chief Product Strategist (CPO)
48
+ **Scan strategy**: Deep scan — starting from entry files, follow call chains to read all business files. For large modules (>10 files), prioritize files imported by multiple consumers.
54
49
 
55
50
  **Action**:
56
51
  1. For each identified functional module:
57
- - Read entry file + 1-2 core business files
52
+ - Starting from entry file, follow import/call chains layer by layer until the module's main business logic is covered
58
53
  - Extract main flows (user action → system processing → result)
59
54
  - Record associated file paths
60
55
  2. For shared/infrastructure code (utils, middleware, config):
61
- - Record directory and responsibility only; do not treat as functional modules
56
+ Read all files and record in two tiers:
57
+ - **Medium tier** (business shared logic: auth/validation/error-handling/permission): record responsibility + exported function signatures + dependents
58
+ - **Brief tier** (pure utility functions: format/slugify/logger/helpers): record function name + parameter signature + one-line purpose
59
+ Both tiers write to map.json publicAPI field, ensuring downstream protocols can discover and reuse.
62
60
  3. Extract domain terminology and naming conventions from code.
63
61
 
64
- **Output**: Present structured analysis report to user:
65
- ```
66
- ### Codebase Analysis Report
67
- > **Project**: [Name] | **Type**: [UI/Data/CLI/Lib/API] | **Scale**: ~[file count] files, [dir count] directories
68
-
69
- **Tech Stack**:
70
- | Category | Selection |
71
- |:---|:---|
72
- | Language | ... |
73
- | Framework | ... |
74
- | Build | ... |
75
- | Testing | ... |
76
- | Deployment | ... |
77
-
78
- **Architecture Pattern**: [Inference] — [Evidence]
79
-
80
- **Functional Module Inventory**:
81
- | # | Module | Source Location | Responsibility | Key Flows |
82
- |:---|:---|:---|:---|:---|
83
- | 1 | [Name] | [Path] | [One sentence] | [Flow1], [Flow2] |
84
-
85
- **Shared Infrastructure**:
86
- | Directory | Responsibility |
87
- |:---|:---|
88
- | [Path] | [Description] |
89
-
90
- **Domain Terminology**: [Term list]
91
-
92
- **Uncertain Items** (if any):
93
- - [Ambiguous item]
94
- ```
62
+ **Output**: Output structured analysis report to user — include project overview (name/type/scale), tech stack table (language/framework/build/test/deploy), architecture pattern and evidence, functional module list (module/source location/responsibility/key flows), shared infrastructure (directory/responsibility/key exported interfaces), domain terminology, AI uncertain items (if any).
95
63
 
96
64
  **Gate**: User confirms or corrects. Do not proceed to step_2 without confirmation.
97
65
  </step_1_analysis>
98
66
 
99
67
  <step_2_supplementary>
100
- **Role**: Product Consultant
101
68
  **Trigger**: Only when step_1 has items AI cannot determine. Skip if no ambiguity.
102
69
 
103
70
  **Action**: Ask ambiguous items in multiple-choice format.
104
- - 3-5 options per question + `[Z] Custom`; AI recommendation marked `[Recommended]`.
71
+ - 35 options per question + `[Z] Custom`; AI recommendation marked `[Recommended]`.
105
72
  - Total questions capped at 3.
106
73
 
107
74
  Common ambiguities:
108
75
  - Architecture pattern cannot be confirmed
109
- - Certain directory responsibilities unclear
110
- - Vision info (North Star Metric, design philosophy) cannot be inferred from code
76
+ - Certain directory responsibility unclear
77
+ - Vision info (North Star metric, design philosophy) cannot be inferred from code
111
78
 
112
79
  **Output Format**:
113
80
  ```
114
81
  ### Supplementary Confirmation
115
82
 
116
- **[Q1] Question Title**
117
- > Why this information is needed
83
+ **[Q1] Question title**
84
+ > Why this info is needed
118
85
 
119
86
  | ID | Option | Description |
120
87
  |:---|:---|:---|
@@ -130,45 +97,45 @@
130
97
  <step_3_constitution>
131
98
  **Role**: Chief Architect
132
99
  **Input**: Step 0 Brief parse (if any) + Step 1 analysis report + Step 2 supplements (if any).
133
- **Action**: Generate project document skeleton in one pass. **When Brief provided**: Brief takes precedence for vision/roadmap/tech_stack; code still used for map, LEG-xx, directory structure. **When no Brief**: Code only as input (original logic).
100
+ **Action**: Fill the init-deployed document skeleton in one pass. **With Brief**: Brief takes precedence for vision/roadmap/tech_stack; code still used for map, LEG-xx, directory structure. **Without Brief**: Code only as input (original logic).
134
101
 
135
102
  ### Information Routing Rules
136
103
 
137
- > Rule files (`02_tech_stack`, `90_custom_rules`, etc.) are already injected into context by the IDE — the AI knows their paths; write directly.
104
+ > Rule files (`02_tech_stack`, `90_custom_rules`, etc.) are already injected into context by IDE; AI knows their paths, write directly.
138
105
 
139
- **When Brief provided** (Brief content → target file, same as start):
106
+ **With Brief** (Brief → target file):
140
107
  | Brief content | Target file |
141
108
  |:---|:---|
142
109
  | Project identity, target users, success metrics, references | `[[__DOCS_DIR__]]/global/vision.md` |
143
- | Tech stack, deployment target, third-party libs/services | rule file `02_tech_stack` |
110
+ | Tech stack, deploy target, 3rd-party libs/services | rule file `02_tech_stack` |
144
111
  | Core task list | `[[__DOCS_DIR__]]/global/roadmap.json` (phase-1/2, call archi-decompose-roadmap) |
145
- | Rules/conventions from supplementary notes | rule file `90_custom_rules` |
112
+ | Rules/conventions/preferences from supplementary notes | rule file `90_custom_rules` |
146
113
  | Style/tone (UI only) | `design_tokens.json` aestheticDirection etc. |
147
114
 
148
- **Information from Code** (always applies):
149
- | Information from Code | Target File |
115
+ **From code** (always applies):
116
+ | Source | Target file |
150
117
  |:---|:---|
151
- | README project description, target users, task list | `[[__DOCS_DIR__]]/global/vision.md` |
152
- | Dependency list, config files, code patterns | rule file `02_tech_stack` |
153
- | Directory structure, module dependencies, user journeys | `[[__DOCS_DIR__]]/global/map.json` |
154
- | Domain terminology, abbreviations, naming conventions | `[[__DOCS_DIR__]]/global/dictionary.json` |
155
- | eslint/prettier and existing standards | rule file `90_custom_rules` |
156
- | Error code definitions in code | `[[__DOCS_DIR__]]/global/error_codes.json` |
157
- | [?UI] CSS variables/theme config | `[[__DOCS_DIR__]]/global/design_tokens.json` |
158
- | [?Data] Schema/Migration files | `[[__DOCS_DIR__]]/global/data_snapshot.json` |
118
+ | README description/features | vision.md |
119
+ | Dependencies/config/code patterns | 02_tech_stack |
120
+ | Directory structure/module deps/user journeys | map.json |
121
+ | Domain terminology/naming conventions | dictionary.json |
122
+ | eslint/prettier etc. | 90_custom_rules |
123
+ | Error codes in code | error_codes.json |
124
+ | (UI projects only) CSS variables/theme | design_tokens.json |
125
+ | (Data projects only) Schema/Migration | data_snapshot.json |
159
126
 
160
127
  ### 3.1 Vision (`[[__DOCS_DIR__]]/global/vision.md`)
161
128
  - **With Brief**: Fill from Brief (same as start); code/README as supplement only
162
- - **Without Brief**: Derive from README + project config; mark un-inferrable items `(AI Inferred — user review recommended)`
129
+ - **Without Brief**: Derive from README + project config; mark un-inferrable items `(AI completion — user review suggested)`
163
130
  - Do not retain template placeholders
164
131
 
165
132
  ### 3.2 Tech Stack (rule file `02_tech_stack`)
166
- - **With Brief**: Brief-confirmed items → write directly; Brief blank/"recommend" → AI recommends by project features; code deps/config as supplement
167
- - **Without Brief**: Existing dependencies/config → write directly; visible code conventions → Coding Standards
168
- - Must populate complete Section 1-8
133
+ - **With Brief**: Brief confirmed → write directly; blank/recommend → AI recommends; code deps as supplement
134
+ - **Without Brief**: Existing deps/config → write directly; visible conventions → write to Coding Standards
135
+ - Fill complete Section 1-8
169
136
 
170
137
  ### 3.3 Custom Rules (rule file `90_custom_rules`)
171
- - **With Brief**: Merge Brief supplementary notes + code eslint/prettier etc.
138
+ - **With Brief**: Merge supplementary notes + code eslint/prettier
172
139
  - **Without Brief**: Extract from eslint/prettier/editorconfig; identify team conventions from code patterns
173
140
 
174
141
  ### 3.4 Roadmap (`[[__DOCS_DIR__]]/global/roadmap.json`)
@@ -189,7 +156,7 @@
189
156
  "tasks": [
190
157
  {
191
158
  "id": "LEG-01",
192
- "title": "<Module Name>",
159
+ "title": "<Module name>",
193
160
  "status": "done",
194
161
  "goal": "<One-line summary>. See tasks/LEG-01_<Slug>/spec.md",
195
162
  "deps": [],
@@ -206,9 +173,8 @@
206
173
 
207
174
  **Rules**:
208
175
  - Functional modules → `phase-0: Legacy`, status `done`, tag `Legacy`, ID prefix `LEG-`
209
- - Shared/infrastructure code does not enter roadmap; only goes to map.json directoryMapping
210
- - phase-1/2 remain as empty skeletons
211
- - Dependencies between LEG tasks must be reflected in deps
176
+ - Shared/infrastructure code does not enter roadmap; only map.json directoryMapping
177
+ - Dependencies between LEG tasks must be in deps
212
178
 
213
179
  ### 3.5 Task Stub Specs
214
180
 
@@ -224,66 +190,75 @@
224
190
  [One paragraph description]
225
191
 
226
192
  ## Key Flows
227
- 1. **[Flow Name]**: [A] → [B] → [C]
228
- 2. **[Flow Name]**: [A] → [B] → [C]
193
+ 1. **[Flow name]**: [A] → [B] → [C]
229
194
 
230
195
  ## Associated Files
231
196
  - [Role]: `[Path]`
232
- - [Role]: `[Path]`
233
197
  ```
234
198
 
235
- > Stubs are a starting point, not the final state. Enrich later via `/archi.edit` (auto-triggers the `step_1_5_enrich` flow).
199
+ > Stub is starting point, not final state. Enrich later via `/archi.edit` (auto-triggers `step_1_5_enrich` flow).
236
200
 
237
- ### 3.6 map.json Population
201
+ ### 3.6 map.json population
238
202
  - `directoryMapping`: Each core directory → `{ "path", "layer", "responsibility", "publicAPI" }`
239
203
  - `logicalTopology`: Inter-module dependencies → `{ "from", "to", "type" }` (imports / calls / extends)
240
204
  - `criticalUserJourneys`: Core flows → `{ "name", "steps": ["module → module → ..."] }`
241
- - `featureRelations`: Scan code to identify "aggregator modules" and record them.
242
- **Recognition patterns**: A module that iterates/enumerates/dynamically loads modules of the same type (e.g., `for (const cmd of allCommands)`, `Object.values(registry)`, reading a directory then dynamic import), or is described as "aggregating/listing/registering all X".
243
- Record format: `{ "aggregator": "<ID or file path>", "sources": "<source range description>", "evidence": "<code basis>", "checkNote": "When tasks of this type are added or removed, check whether <aggregator> needs to be updated" }`
205
+ - `featureRelations`: Scan code to identify "aggregator modules" and record.
206
+ **Recognition pattern**: Module that iterates/enumerates/dynamic-loads same-type modules, or described as "aggregating/listing/registering all X".
207
+ Record format: `{ "aggregator", "sources", "evidence", "checkNote" }`
244
208
 
245
- ### 3.7 Other Global Documents (as needed)
209
+ ### 3.7 Other global docs (as needed)
246
210
  - `dictionary.json`: Extract domain terminology from code
247
- - [?UI] `design_tokens.json`: Extract from CSS variables/theme
248
- - [?UI] `ui_concept.html` + `ui_context.md`: **Not generated by this command.** After inherit completes, [[SKILL: archi-ui-wireframe|invoke skill or prompt user to run]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-ui-wireframe/SKILL.md` and prompt user to follow the document)]] to generate the global UI wireframe (Skill generates both files simultaneously).
249
- - [?Data] `data_snapshot.json`: Extract from schema/migration
211
+ - (UI projects only) `design_tokens.json`: Extract from CSS variables/theme
212
+ - (Data projects only) `data_snapshot.json`: Extract from schema/migration
250
213
  - `error_codes.json`: Extract from error definitions in code
251
214
 
252
- **Output**: Write all files, then run `npx archi render`.
215
+ UI projects only: **UI concept design (Adopt mode)**: [[SKILL: archi-ui-wireframe|Invoke skill (adopt mode) to reverse-generate UI concept design from code.]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-ui-wireframe/SKILL.md` and follow its Adopt protocol)]]
216
+ - Read route definitions, page components, layout files from code
217
+ - Read design_tokens.json written in step_3 (containing CSS variables/theme extracted from code)
218
+ - When tokens incomplete, triggers skill's built-in guidance flow
219
+ - Write `ui_concept.html` + `ui_context.md`
220
+ - Output UI concept design summary; await user confirmation or feedback for adjustments
221
+
222
+ **Output**: Write all files, run `npx archi render`. Enter step_4_verify.
253
223
  </step_3_constitution>
254
224
 
255
225
  <step_4_verify>
256
226
  **Role**: Independent Reviewer
257
-
258
227
  [[SUBAGENT: archi-silent-audit|mode: init, context: Review step_3 generated global files (vision, tech_stack, roadmap, map, dictionary, stub specs, etc.)]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-silent-audit/SKILL.md`, follow mode: init review dimension table item by item)]]
259
228
 
260
229
  [[INCLUDE: shared/verify-result-handling.md]]
261
230
  </step_4_verify>
262
231
 
263
232
  <step_5_signoff>
264
- **Terminal Gate** (Do not skip; must complete before output summary):
265
- | Step | Command | Pass Condition |
266
- |:---|:---|:---|
267
- | 1 | `npx archi task --check` | No ERROR-level issues |
268
- | 2 | `npx archi render` | `.md` views generated |
269
-
270
- **Action** (After Gate passes):
271
- 1. Run `npx archi task` to display task overview.
233
+ **Terminal Gate** (do not skip): Standard check (task --check + render).
234
+
235
+ **Pre-signoff Checklist** (confirm each item after Gate passes, before Output):
236
+ vision.md filled (without Brief: inferred content annotated `(AI completion review recommended)`)
237
+ 02_tech_stack.md Sections 1-8 fully filled
238
+ □ roadmap.json — each functional module has a corresponding LEG-xx (status: done, tag: Legacy)
239
+ tasks/LEG-xx_<Slug>/spec.md — each LEG has a corresponding Stub spec (with related file list)
240
+ □ map.json directoryMapping + logicalTopology + criticalUserJourneys + featureRelations all filled
241
+ □ dictionary.json + error_codes.json — extracted from codebase
242
+ □ (UI projects only) design_tokens.json + ui_concept.html + ui_context.md — Adopt mode executed
243
+ □ Step 4 Silent Audit — executed, all CRITICAL issues resolved
244
+
245
+ **Action** (after Checklist confirmed):
246
+ 1. Run `npx archi task` to output task overview.
272
247
  2. Output summary.
273
248
 
274
- **Output**: Reverse-engineering summary containing:
275
- - **Project Overview**: Type, scale, number of core modules
276
- - **Legacy Tasks**: LEG-xx list (ID / Name / Source location)
277
- - **Generated Documents**: File list
278
- - **AI Inferred Items**: Mark confidence level (High/Medium/Low)
249
+ **Output**: Reverse-engineering summary, including:
250
+ - **Project overview**: Type, scale, core module count
251
+ - **Legacy tasks**: LEG-xx list (ID / name / source location)
252
+ - **Generated docs**: File list
253
+ - **AI completions**: Mark confidence (High/Medium/Low)
279
254
  - **Next Steps**:
280
255
 
281
- | Priority | Action | Description |
256
+ | Priority | Action | Notes |
282
257
  |:---|:---|:---|
283
- | 1 | Review vision.md | Confirm AI-inferred vision description is accurate |
284
- | 2 | `/archi.edit LEG-xx` | Enrich core module stubs into full specs (auto-triggers Enrich flow) |
285
- | 3 | `/archi.scope [file_path]` | Plan new tasks/major modules |
286
- | 4 | `/archi.plan <task ID>` | Deep-plan individual tasks |
258
+ | 1 | Review vision.md | Confirm AI-completed vision description |
259
+ | 2 | `/archi.edit LEG-xx` | Enrich core module stubs into full spec (auto-triggers Enrich flow) |
260
+ | 3 | `/archi.scope [file_path]` | Plan new features/major modules |
261
+ | 4 | `/archi.plan <task ID>` | Deep-plan individual task |
287
262
  </step_5_signoff>
288
263
 
289
264
  </protocol_inherit>
@@ -1,131 +1,109 @@
1
1
  <protocol_map>
2
- **Trigger**: `/archi.map`
3
- **Goal**: Scan actual project directory structure, diff against `map.json`, identify additions/stale/changes, and update the architecture map after user confirmation.
2
+ **Trigger**: `/archi.map` | Auto-loaded by Workflow Dispatch on natural language trigger
3
+ **Goal**: Scan project actual directory structure, compare with `map.json`, identify additions/stale/changes; update architecture map after user confirmation.
4
4
 
5
5
  <meta>
6
6
  <style>Systematic, Precise, Architecture-Aware</style>
7
7
  <language>English</language>
8
8
  <principles>
9
- 1. **Scan vs Map**: Actual filesystem is Ground Truth; map.json is the old snapshot.
10
- 2. **Smart Granularity**: Directory-level by default; drill to file-level when a single file carries multiple responsibilities.
11
- 3. **Architecture Inference**: New entry classification must reference existing map patterns + `02_tech_stack.md`.
12
- 4. **Batch Confirm**: Present all changes at once; user confirms in batch.
9
+ 1. **Scan vs Map**: Actual filesystem is Ground Truth; map.json is old snapshot.
10
+ 2. **Smart Granularity**: Directory-level by default; when single file has multiple responsibilities, refine to file-level.
11
+ 3. **Architecture Inference**: New entry layer/location must reference existing map pattern + `02_tech_stack.md`.
12
+ 4. **Batch Confirm**: Show all changes at once; user confirms in batch.
13
+ 5. **IDE-Native First**: Leverage IDE native capabilities to drive execution rhythm; this protocol defines quality standards and checkpoints, not fight IDE planning/execution mechanisms.
13
14
  </principles>
14
15
  </meta>
15
16
 
16
17
  <step_1_scan>
17
- **Role**: Surveyor
18
18
  **Action**:
19
19
  1. **Read Map**: Read `[[__DOCS_DIR__]]/global/map.json` — current architecture map.
20
- 2. **Read Tech Stack**: Read `02_tech_stack.md` — directory conventions, architecture patterns.
20
+ 2. **Read Tech Stack**: Read `02_tech_stack.md` — directory structure conventions, architecture pattern.
21
21
  3. **Scan Directory Tree**: Scan project directory structure.
22
- - **Exclude**: `.git/`, `node_modules/`, `dist/`, `build/`, `[[__DOCS_DIR__]]/`, and paths declared in `.gitignore`.
23
- - **Depth**: Follow granularity patterns of existing map.json entries. If existing entries include file-level → scan to file-level too.
22
+ - **Exclude**: `.git/`, `node_modules/`, `dist/`, `build/`, `[[__DOCS_DIR__]]/`, and paths in `.gitignore`.
23
+ - **Depth**: Follow granularity pattern of existing map.json entries.
24
24
 
25
- **Output**: Internal data (actual tree + existing map structure), not shown to user.
25
+ **Output**: Internal data (actual dir tree + existing map structure); not shown to user.
26
26
  </step_1_scan>
27
27
 
28
28
  <step_2_diff>
29
- **Role**: Diff Analyst
30
- **Action**: Compare actual directory tree against map.json entry by entry, classify into three diff types.
29
+ **Action**: Compare actual dir tree with map.json entry by entry; classify as three diff types.
31
30
 
32
31
  | Diff Type | Criteria | Handling |
33
32
  |:---|:---|:---|
34
- | **New** | Exists on disk but not in map | Classify and register |
35
- | **Stale** | In map but no longer exists on disk | Remove directly |
36
- | **Possible Rename** | Map path missing, but a new path has highly similar structure/content | Flag as rename candidate |
33
+ | **New** | Exists in reality but not in map | Must classify and register |
34
+ | **Stale** | In map but no longer exists | Remove directly |
35
+ | **Suspected Rename** | Map path gone, but new path structure/content highly similar | Mark as rename candidate |
37
36
 
38
- ### File-Level Detection
37
+ ### File-level detection
39
38
 
40
- Quick-scan files in new directories (read exports/declarations) to identify **single-file multi-responsibility** cases:
41
- - A file exporting multiple unrelated classes/functions/modules
42
- - An entry file aggregating multiple sub-module registrations (e.g. route registration, store registration)
43
- - A file serving multiple Tasks
39
+ Quick scan of files in new directories; identify **single file multi-responsibility** → refine granularity to file-level.
44
40
 
45
- When detected drill granularity to file-level, register the file separately in map with its contained responsibilities.
46
-
47
- **Output**: Diff list (internal), proceed to step_3.
41
+ **Output**: Diff list (internal); proceed to step_3.
48
42
  </step_2_diff>
49
43
 
50
44
  <step_3_classify>
51
45
  **Role**: Chief Architect
52
- **Action**: Classify new entries by architectural layer.
46
+ **Action**: Classify new entries by architecture.
53
47
 
54
- ### Classification Strategy
48
+ ### Classification strategy
55
49
 
56
- 1. **Pattern Matching**: Reference existing entries at the same level. If `src/services/auth/` is "Service Layer", then `src/services/payment/` likely is too.
57
- 2. **Tech Stack Conventions**: Directory structure rules defined in `02_tech_stack.md` (e.g. "commands/ is Task Layer").
58
- 3. **Content Inference**: Read file contents (imports, export types) to determine architectural role.
59
- 4. **Uncertain**: Mark as `[?]`, let user specify during confirmation.
50
+ 1. **Pattern match**: Reference same-level existing entries in map.json.
51
+ 2. **Tech Stack conventions**: Directory structure rules in `02_tech_stack.md`.
52
+ 3. **Content inference**: Read file content (imports, exported types).
53
+ 4. **Cannot determine**: Mark `[?]` for user to specify.
60
54
 
61
- For each new entry, populate:
62
- - `path`: Directory or file path
63
- - `layer`: Architectural layer
64
- - `description`: One-line responsibility description
65
- - `[?file-level]` `contains`: List of sub-responsibilities in the file
55
+ For each new entry fill: `path`, `layer`, `description`, `[?file-level] contains`.
66
56
 
67
- **Output**: Classified new entries list (internal), proceed to step_4.
57
+ **Output**: Classified new entries list (internal); proceed to step_4.
68
58
  </step_3_classify>
69
59
 
70
60
  <step_4_propose>
71
- **Role**: Advisor
72
- **Action**: Present the full change manifest to user.
61
+ **Action**: Present full change list to user.
73
62
 
74
63
  **Output**:
75
64
  ```
76
65
  ### Architecture Map Change Proposal
77
66
 
78
67
  **Scan scope**: [project root]
79
- **Current map entries**: N | **After update**: M
68
+ **Current map entries**: N | **After change**: M
80
69
 
81
70
  ---
82
71
 
83
- #### Stale Entries (will remove)
84
- | Path | Original Layer |
72
+ #### Stale entries (to remove)
73
+ | Path | Original layer |
85
74
  |:---|:---|
86
- | src/legacy/old-module/ | Service Layer |
87
75
 
88
- #### New Entries (will register)
76
+ #### New entries (to register)
89
77
  | Path | Layer | Description | Granularity |
90
78
  |:---|:---|:---|:---|
91
- | src/services/payment/ | Service Layer | Payment service module | Directory |
92
- | src/utils/validators.ts | Shared Layer | Form + data + API param validation | File |
93
- | src/routes/api.ts [?] | [to specify] | Aggregates multiple API route registrations | File |
94
79
 
95
- #### Possible Renames
96
- | Original Path | New Path | Confidence |
80
+ #### Suspected renames
81
+ | Original path | New path | Confidence |
97
82
  |:---|:---|:---|
98
- | src/helpers/ | src/utils/ | High (file content match) |
99
83
 
100
84
  ---
101
- > Reply **OK** to confirm all; or specify changes:
102
- > - "src/routes/api.ts belongs to App Layer"
103
- > - "src/helpers/ is not a rename, keep original entry"
104
- > - "add src/config/ as Config Layer"
85
+ > Reply **OK** to confirm all; or specify modifications.
105
86
  ```
106
87
 
107
88
  **Gate**: Proceed to step_5 after user confirms.
108
89
  </step_4_propose>
109
90
 
110
91
  <step_5_apply>
111
- **Role**: System Administrator
112
92
  **Action**:
113
- 1. Update `[[__DOCS_DIR__]]/global/map.json` per confirmed changes:
114
- - Remove stale entries
115
- - Add new entries (with layer, description)
116
- - Handle renames (update path, preserve other metadata)
117
- 2. Update `lastUpdated` field.
118
-
119
- **Terminal Gate** (Do not skip; must complete before output summary):
120
- | Step | Command | Pass Condition |
121
- |:---|:---|:---|
122
- | 1 | `npx archi render` | `.md` views generated |
93
+ 1. Update map.json per confirmed list (remove stale, add new, handle renames).
94
+ 2. Update `lastUpdated`.
95
+
96
+ **Terminal Gate** (do not skip): Standard check (task --check + render).
97
+
98
+ **Pre-signoff Checklist** (confirm each item before Output):
99
+ User explicitly confirmed change list in step_4 (Gate passed before execution)
100
+ Stale entries removed from directoryMapping
101
+ □ New entries correctly classified (path + layer + description all filled)
102
+ Renamed entries explicitly handled (not silently ignored)
103
+ □ lastUpdated updated
104
+ □ Terminal Gate — task --check + render passed
123
105
 
124
- **Output**: Update summary:
125
- - **Removed**: N stale entries
126
- - **Added**: N entries (M file-level)
127
- - **Renamed**: N entries
128
- - **Current map total**: X entries
106
+ **Output**: Update summary — removed N / added N (M file-level) / renamed N / total entries.
129
107
  </step_5_apply>
130
108
 
131
109
  </protocol_map>