architext 0.0.4 → 0.0.6

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 (84) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/README.md +93 -14
  3. package/README.zh-CN.md +92 -14
  4. package/dist/index.js +53 -39
  5. package/dist/templates/en/briefs/_base.md +53 -13
  6. package/dist/templates/en/briefs/_modules.md +31 -4
  7. package/dist/templates/en/docs/global/error_memory.json +40 -0
  8. package/dist/templates/en/docs/global/map.json +46 -90
  9. package/dist/templates/en/{rules/04_cli_tools.md → docs/global/references/cli_reference.md} +6 -13
  10. package/dist/templates/en/{rules/02_tech_stack.md → docs/global/tech_stack.md} +7 -18
  11. package/dist/templates/en/docs/global/vision.md +1 -1
  12. package/dist/templates/en/docs/prompts/audit.md +80 -94
  13. package/dist/templates/en/docs/prompts/code.md +99 -89
  14. package/dist/templates/en/docs/prompts/edit.md +61 -51
  15. package/dist/templates/en/docs/prompts/fix.md +59 -43
  16. package/dist/templates/en/docs/prompts/help.md +23 -31
  17. package/dist/templates/en/docs/prompts/inherit.md +97 -117
  18. package/dist/templates/en/docs/prompts/map.md +48 -69
  19. package/dist/templates/en/docs/prompts/plan.md +141 -240
  20. package/dist/templates/en/docs/prompts/recover.md +19 -34
  21. package/dist/templates/en/docs/prompts/ref.md +43 -138
  22. package/dist/templates/en/docs/prompts/remove.md +63 -110
  23. package/dist/templates/en/docs/prompts/revise.md +71 -106
  24. package/dist/templates/en/docs/prompts/scope.md +78 -117
  25. package/dist/templates/en/docs/prompts/script.md +102 -0
  26. package/dist/templates/en/docs/prompts/start.md +98 -132
  27. package/dist/templates/en/docs/prompts/ui.md +113 -0
  28. package/dist/templates/en/docs/shared/ui-redlines.md +7 -0
  29. package/dist/templates/en/docs/templates/spec.template.md +1 -1
  30. package/dist/templates/en/docs/templates/ui.template.md +8 -8
  31. package/dist/templates/en/rules/00_system.md +268 -117
  32. package/dist/templates/en/rules/90_custom_rules.md +3 -1
  33. package/dist/templates/en/skills/archi-data-sync/SKILL.md +37 -23
  34. package/dist/templates/en/skills/archi-decompose-roadmap/SKILL.md +138 -240
  35. package/dist/templates/en/skills/archi-design-patterns/SKILL.md +6 -1
  36. package/dist/templates/en/skills/archi-feature-relations/SKILL.md +10 -6
  37. package/dist/templates/en/skills/archi-interview-protocol/SKILL.md +2 -2
  38. package/dist/templates/en/skills/archi-plan-options/SKILL.md +77 -301
  39. package/dist/templates/en/skills/archi-silent-audit/SKILL.md +24 -25
  40. package/dist/templates/en/skills/archi-ui-wireframe/SKILL.md +175 -305
  41. package/dist/templates/icon.svg +16 -0
  42. package/dist/templates/zh/briefs/_base.md +56 -17
  43. package/dist/templates/zh/briefs/_modules.md +28 -1
  44. package/dist/templates/zh/docs/global/error_memory.json +40 -0
  45. package/dist/templates/zh/docs/global/map.json +39 -109
  46. package/dist/templates/zh/{rules/04_cli_tools.md → docs/global/references/cli_reference.md} +0 -7
  47. package/dist/templates/zh/{rules/02_tech_stack.md → docs/global/tech_stack.md} +9 -20
  48. package/dist/templates/zh/docs/global/vision.md +1 -1
  49. package/dist/templates/zh/docs/prompts/audit.md +43 -57
  50. package/dist/templates/zh/docs/prompts/code.md +66 -56
  51. package/dist/templates/zh/docs/prompts/edit.md +52 -42
  52. package/dist/templates/zh/docs/prompts/fix.md +39 -29
  53. package/dist/templates/zh/docs/prompts/help.md +13 -21
  54. package/dist/templates/zh/docs/prompts/inherit.md +67 -86
  55. package/dist/templates/zh/docs/prompts/map.md +28 -50
  56. package/dist/templates/zh/docs/prompts/plan.md +100 -199
  57. package/dist/templates/zh/docs/prompts/recover.md +9 -24
  58. package/dist/templates/zh/docs/prompts/ref.md +11 -106
  59. package/dist/templates/zh/docs/prompts/remove.md +39 -74
  60. package/dist/templates/zh/docs/prompts/revise.md +47 -88
  61. package/dist/templates/zh/docs/prompts/scope.md +52 -91
  62. package/dist/templates/zh/docs/prompts/script.md +102 -0
  63. package/dist/templates/zh/docs/prompts/start.md +75 -110
  64. package/dist/templates/zh/docs/prompts/ui.md +113 -0
  65. package/dist/templates/zh/docs/shared/ui-redlines.md +7 -0
  66. package/dist/templates/zh/docs/templates/spec.template.md +1 -1
  67. package/dist/templates/zh/docs/templates/ui.template.md +8 -8
  68. package/dist/templates/zh/rules/00_system.md +252 -131
  69. package/dist/templates/zh/rules/90_custom_rules.md +2 -1
  70. package/dist/templates/zh/skills/archi-data-sync/SKILL.md +27 -13
  71. package/dist/templates/zh/skills/archi-decompose-roadmap/SKILL.md +133 -235
  72. package/dist/templates/zh/skills/archi-design-patterns/SKILL.md +6 -1
  73. package/dist/templates/zh/skills/archi-feature-relations/SKILL.md +6 -2
  74. package/dist/templates/zh/skills/archi-interview-protocol/SKILL.md +2 -2
  75. package/dist/templates/zh/skills/archi-plan-options/SKILL.md +77 -301
  76. package/dist/templates/zh/skills/archi-silent-audit/SKILL.md +4 -5
  77. package/dist/templates/zh/skills/archi-ui-wireframe/SKILL.md +174 -301
  78. package/package.json +3 -1
  79. package/dist/templates/en/rules/01_workflow.md +0 -93
  80. package/dist/templates/en/rules/03_data_governance.md +0 -102
  81. package/dist/templates/en/rules/99_context_glue.md +0 -53
  82. package/dist/templates/zh/rules/01_workflow.md +0 -94
  83. package/dist/templates/zh/rules/03_data_governance.md +0 -133
  84. package/dist/templates/zh/rules/99_context_glue.md +0 -53
@@ -1,150 +1,136 @@
1
1
  <protocol_audit>
2
- **Trigger**: `/archi.audit [id]`
3
- **Goal**: Independent deep code audit. With `<id>`, audit the task's code implementation; without `<id>`, execute project-level health check. No code modifications output audit report and fix tickets only.
2
+ **Trigger**: `/archi.audit [id]` | Auto-loaded by Workflow Dispatch on natural language trigger
3
+ **Goal**: Independent deep code review. With `<id>` review that task's code implementation; without `<id>` run project-wide health check. Do not modify code; output review report and fix work items only.
4
4
 
5
5
  <meta>
6
6
  <style>Investigative, Thorough, Evidence-Based</style>
7
7
  <language>English</language>
8
8
  <principles>
9
- 1. **Read-Only**: Prohibited from modifying any code files. Audit ≠ Fix.
10
- 2. **Evidence-Based**: Every finding must include file path, line number, and code snippet.
11
- 3. **Actionable Output**: Every issue must include a recommended fix command (`/archi.fix`, `/archi.edit`, etc.).
12
- 4. **Vision Anchored**: Always use `vision.md` as directional baseline to detect deviations.
13
- 5. **Report Persistence**: Audit results must be written to file — task-level → `tasks/<id>_*/audit.md` (overwrite), project-level → `audits/YYYY-MM-DD.md` (date-archived, same-day overwrite).
9
+ 1. **Read-Only**: Do not modify any code files. Review ≠ Fix.
10
+ 2. **Evidence-Based**: Each finding must include file path, line number, code snippet.
11
+ 3. **Actionable Output**: Each issue must include recommended fix command (`/archi.fix`, `/archi.edit`, etc.).
12
+ 4. **Vision Anchored**: Always use `vision.md` as direction anchor; detect drift.
13
+ 5. **Report Persistence**: Review results must be written to file — task-level → `tasks/<id>_*/audit.md` (overwrite); project-level → `audits/YYYY-MM-DD.md` (date archive).
14
+ 6. **IDE-Native First**: Leverage IDE native capabilities to drive execution rhythm; this protocol defines quality standards and checkpoints, not fight IDE planning/execution mechanisms.
14
15
  </principles>
15
16
  </meta>
16
17
 
17
18
  <step_1_resolve>
18
- **Role**: System Analyst
19
19
  **Mode Gate**:
20
20
 
21
21
  | Input | Mode | Next Steps |
22
22
  |:---|:---|:---|
23
- | `/archi.audit <id>` | Task-level deep audit | step_2_task → step_3_report |
24
- | `/archi.audit` | Project-level health check | step_2_project → step_3_report |
23
+ | `/archi.audit <id>` | Task-level deep review | step_2a_task → step_3_report |
24
+ | `/archi.audit` | Project-level health check | step_2b_project → step_3_report |
25
25
 
26
26
  **Task-level — Resolve ID**:
27
- 1. Parse `<id>` from `[[__DOCS_DIR__]]/global/roadmap.json` → Task Name, Slug, status.
28
- 2. **Status Gate** — Only `active` or `done` can be audited:
27
+ 1. Parse `<id>` from roadmap.json → Task Name, Slug, status.
28
+ 2. **Status Gate** — only `active` or `done` may be reviewed:
29
29
 
30
30
  | Status | Handling |
31
31
  |:---|:---|
32
32
  | `active` / `done` | Pass |
33
- | `pending` | Reject — no code to audit, run `/archi.plan` + `/archi.code` first |
34
- | `blocked` | Reject — prerequisites not completed |
35
-
36
- 3. **Load Context**:
37
- - `[[__DOCS_DIR__]]/global/vision.md` — Project directional baseline
38
- - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/spec.md` — Task logic
39
- - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/plan.json` — Task checklist
40
- - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/ui.md` — Task UI scope declaration (if exists)
41
- - [?UI] `[[__DOCS_DIR__]]/global/ui_context.md` — AI screen index (locate corresponding screen IDs)
42
- - [?UI] `[[__DOCS_DIR__]]/global/ui_concept.html` — read-only visual reference (source of visual truth for #10 compliance comparison)
43
- - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/audit.md` — Previous audit report (if exists, for comparison)
44
- - `02_tech_stack.md` — Technical red lines
45
- - [?UI] `[[__DOCS_DIR__]]/global/design_tokens.json`
46
- - [?Data] `[[__DOCS_DIR__]]/global/data_snapshot.json`
47
- 4. Read all code files corresponding to this task.
33
+ | `pending` | Reject — no code to review |
34
+ | `blocked` | Reject — upstream deps incomplete |
35
+
36
+ 3. **Load**: vision.md (direction anchor) + task docs (spec/plan/ui) + prior audit.md (for comparison) + project context (tech_stack/design_tokens/data_snapshot/ui_context/screens/). Read all code files for this task.
48
37
 
49
38
  **Project-level — Load Overview**:
50
- 1. Read `[[__DOCS_DIR__]]/global/vision.md`, `roadmap.json`, `map.json`.
51
- 2. Read `02_tech_stack.md`.
52
- 3. Scan `[[__DOCS_DIR__]]/tasks/` directory structure.
53
- 4. Read project code entry points and key modules.
39
+ 1. Read vision.md, roadmap.json, map.json, tech_stack.md.
40
+ 2. Scan tasks/ directory structure.
41
+ 3. Read project code entry points and key modules.
54
42
 
55
- **Output**: Audit scope and context inventory.
43
+ **Output**: Review scope and context checklist. Enter step_2a_task or step_2b_project.
56
44
  </step_1_resolve>
57
45
 
58
- <step_2_task>
46
+ <step_2a_task>
59
47
  **Role**: Chief Auditor
60
- **Scope**: Task-level deep code audit (execute only for `/archi.audit <id>`).
48
+ **Scope**: Task-level deep code review (only when `/archi.audit <id>`).
61
49
 
62
- Audit dimension by dimension; every finding must include `file:line` + code snippet + severity:
50
+ Review dimension by dimension; each finding must include `file:line` + code snippet + severity:
63
51
 
64
- | # | Dimension | Audit Focus |
52
+ | # | Dimension | Review focus |
65
53
  |:---|:---|:---|
66
- | 1 | **Vision Alignment** | Does the implementation direction conflict with or deviate from `vision.md` |
67
- | 2 | **Spec Completeness** | Does code cover all scenarios and edge cases in `spec.md` |
68
- | 3 | **Plan Truthfulness** | Are tasks marked `done` actually implemented in code (detect false marks) |
69
- | 4 | **Logic Correctness** | Business logic errors, contradictions, missing branches, state machine defects |
70
- | 5 | **Bug Hunting** | Null/undefined, race conditions, resource leaks, infinite loops, off-by-one |
71
- | 6 | **Error Handling** | Swallowed errors, silent failures, error propagation chain integrity, user-visible feedback |
72
- | 7 | **Tech Stack Compliance** | Against `02_tech_stack.md`: forbidden patterns, outdated APIs, hardcoded values |
73
- | 8 | **Security** | Sensitive info leakage, unvalidated input, injection risks, permission checks |
74
- | 9 | **Performance** | Unnecessary full imports/large loops/useless computation/memory leaks/N+1 queries |
75
- | 10 | [?UI] **Design Compliance** | Styles use visual patterns from Tokens; no hardcoded magic values; implementation visually consistent with corresponding screen in `ui_concept.html` |
76
- | 11 | [?Data] **Data Integrity** | Field names/types consistent with `data_snapshot.json` |
77
- | 12 | [?I18n] **I18n Compliance** | No hardcoded strings; must use Key/dictionary references |
78
- | 13 | **Orphan .gitkeep** | Dir has other files but still contains `.gitkeep` must remove |
79
- | 14 | **Spec-Code Drift** | Do code interfaces/types/behaviors match `spec.md`; have manual changes been synced to docs |
80
- | 15 | [?UI] **UI Reference Integrity** | Are `ref: ui_concept.html#S-XX` pointers in `ui.md` still valid; have referenced screens/components been renamed or removed after edit/revise |
81
-
82
- **Output**: Findings list grouped by dimension, each with severity, location, description.
83
- </step_2_task>
84
-
85
- <step_2_project>
54
+ | 1 | **Vision alignment** | Implementation direction conflicts or drift from `vision.md` |
55
+ | 2 | **Spec completeness** | Code covers all scenarios and boundaries in `spec.md` |
56
+ | 3 | **Plan truthfulness** | Tasks marked `done` actually implemented (prevent false completion) |
57
+ | 4 | **Logic correctness** | Business logic errors, contradictions, missing branches, state machine defects |
58
+ | 5 | **Bug hunting** | null/undefined, race conditions, resource leaks, infinite loops, off-by-one |
59
+ | 6 | **Error handling** | Swallowing, silent failure, error propagation chain, user-visible feedback |
60
+ | 7 | **Tech Stack compliance** | Per `tech_stack.md`: forbidden patterns, outdated API, hardcoding |
61
+ | 8 | **Security** | Sensitive info leak, unvalidated input, injection risk, permission checks |
62
+ | 9 | **Performance** | Unnecessary full imports, large loops, dead computation, memory leaks, N+1 queries |
63
+ | 10 | (When this task involves UI) **Design compliance** | Token usage; no hardcoded magic values; visual consistency with `screens/S-XX.html` |
64
+ | 11 | (When this task involves data) **Data consistency** | Field names/types match `data_snapshot.json` |
65
+ | 12 | (i18n projects only) **I18n compliance** | No hardcoded strings; must use Key/dictionary refs |
66
+ | 13 | **Orphan .gitkeep** | `.gitkeep` exists when dir has other files — remove |
67
+ | 14 | **Spec-Code drift** | Interface/type/behavior match `spec.md`; manual changes synced to docs |
68
+ | 15 | (When this task involves UI) **UI ref completeness** | `ui.md` `ref: screens/S-XX.html` pointers still valid |
69
+
70
+ **Output**: Finding list grouped by dimension; each with level, location, description. Enter step_3_report.
71
+ </step_2a_task>
72
+
73
+ <step_2b_project>
86
74
  **Role**: Chief Auditor
87
- **Scope**: Project-level health check (execute only for `/archi.audit` without arguments).
75
+ **Scope**: Project-level health check (only when `/archi.audit` no args).
88
76
 
89
- | # | Check Item | Description |
77
+ | # | Check | Description |
90
78
  |:---|:---|:---|
91
- | 1 | **Vision Drift** | Are `roadmap.json` task directions consistent with `vision.md` |
92
- | 2 | **Architecture Consistency** | `map.json` vs actual directory structure drift or unregistered modules |
93
- | 3 | **Roadmap Health** | Consistency + progress stats + long-term blocked tasks + dependency cycle detection |
94
- | 4 | **Documentation Completeness** | Each Task has spec.md + plan.json; detect orphan directories |
95
- | 5 | **Tech Stack Global Compliance** | Spot-check key entry points and modules for global violations |
96
- | 6 | **Cross-Task Consistency** | Duplicate logic, naming conflicts, interface inconsistencies |
97
- | 7 | **Orphan .gitkeep** | Dir has other files but still contains `.gitkeep` — must remove |
98
-
99
- After scanning, prioritize and recommend Tasks needing deep audit:
100
- - `done` but plan not fully completed
101
- - Large codebase but no tests
102
- - Long-term `active` with no progress
103
-
104
- **Output**: Project health overview + deep audit recommendation list.
105
- </step_2_project>
79
+ | 1 | **Vision drift** | `roadmap.json` task directions align with `vision.md` |
80
+ | 2 | **Architecture consistency** | `map.json` vs actual dir structure; drift or unregistered modules |
81
+ | 3 | **Roadmap health** | Consistency + progress stats + long blocked + dep cycle detection |
82
+ | 4 | **Doc completeness** | Each Task has spec.md + plan.json; orphan directories |
83
+ | 5 | **Tech Stack global compliance** | Spot-check key entry points and modules |
84
+ | 6 | **Cross-Task consistency** | Duplicate logic, naming conflicts, interface inconsistency |
85
+ | 7 | **Orphan .gitkeep** | `.gitkeep` exists when dir has other files |
86
+
87
+ After scan, recommend tasks for deep review (`done` but plan incomplete / large codebase no tests / long `active`).
88
+
89
+ **Output**: Project health overview + deep review recommendation list. Enter step_3_report.
90
+ </step_2b_project>
106
91
 
107
92
  <step_3_report>
108
- **Role**: Report Writer
109
93
  **Action**:
110
94
 
111
95
  **Issue Classification**:
112
96
 
113
97
  | Level | Meaning | Example |
114
98
  |:---|:---|:---|
115
- | `CRITICAL` | Must fix, blocks release | Logic errors, security vulnerabilities, data corruption risk |
116
- | `WARNING` | Should fix, carries risk | Missing error handling, performance hazards, incomplete Spec coverage |
117
- | `INFO` | Suggested improvement | Naming conventions, missing comments, simplifiable code |
99
+ | `CRITICAL` | Must fix, blocks release | Logic error, security hole, data corruption risk |
100
+ | `WARNING` | Should fix, risk exists | Missing error handling, performance hazard, Spec coverage gap |
101
+ | `INFO` | Suggested optimization | Non-standard naming, missing comments, simplifiable code |
118
102
 
119
103
  **Issue Format** (each must include):
120
104
  ```
121
- [LEVEL] file/path:line — Dimension Name
122
- Description: specific issue
105
+ [LEVEL] file:line — Dimension name
106
+ Description: specific problem
123
107
  -> Recommended fix: /archi.fix <ID> <description> or /archi.edit <ID> <description>
124
108
  ```
125
109
 
126
- **Action Routing** (recommend command by issue type):
110
+ **Action Routing**:
127
111
 
128
112
  | Issue Type | Recommended Command |
129
113
  |:---|:---|
130
- | Bug (logic error, edge case miss) | `/archi.fix <ID> <description>` |
131
- | Spec gap (task not fully implemented) | `/archi.edit <ID> <supplement>` |
132
- | Architecture-level issue (global violation) | `/archi.revise <description>` |
133
- | Incomplete task (plan falsely marked done) | `/archi.code <ID>` |
134
- | Minor issue (naming, comments, simplification) | Address in next `/archi.code` |
135
-
136
- **Report Structure**:
137
- 1. Audit summary (mode, scope, date)
138
- 2. Findings list (sorted by severity: CRITICAL WARNING → INFO)
139
- 3. Statistics summary (count per severity level)
140
- 4. Fix ticket summary (directly executable command list)
141
- 5. Next Steps table
114
+ | Bug | `/archi.fix <ID> <description>` |
115
+ | Spec gap | `/archi.edit <ID> <supplement description>` |
116
+ | Architecture-level | `/archi.revise <description>` |
117
+ | Feature incomplete | `/archi.code <ID>` |
118
+ | Minor | Address in next `/archi.code` |
119
+
120
+ **Pre-signoff Checklist** (confirm each item before writing report file):
121
+ (Task-level) All 15 review dimensions covered; inapplicable items marked N/A (not silently skipped)
122
+ (Project-level) All 7 checklist items evaluated
123
+ Each CRITICAL/WARNING finding includes `file:line` + code snippet
124
+ Each finding includes a recommended fix command (/archi.fix / /archi.edit etc.)
125
+ □ Report written to correct file (task-level: tasks/<id>/audit.md; project-level: audits/YYYY-MM-DD.md)
126
+
127
+ **Report Structure**: Review summary → Finding list (CRITICAL → WARNING → INFO) → Stats summary → Fix work items → Next Steps.
142
128
 
143
129
  **Write Report File**:
144
130
  - Task-level → `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/audit.md` (overwrite)
145
- - Project-level → `[[__DOCS_DIR__]]/audits/YYYY-MM-DD.md` (date-archived, same-day overwrite)
131
+ - Project-level → `[[__DOCS_DIR__]]/audits/YYYY-MM-DD.md` (date archive)
146
132
 
147
- **Output**: Complete audit report (output to both conversation and file).
133
+ **Output**: Full review report (to conversation and file).
148
134
  </step_3_report>
149
135
 
150
136
  </protocol_audit>
@@ -1,153 +1,163 @@
1
1
  <protocol_code>
2
- **Trigger**: `/archi.code <id>`
3
- **Goal**: Based on the `tasks/<id>_<Slug>/plan.json` task list, complete task implementation; follow `02_tech_stack.md` ([?UI] also follow `design_tokens.json`); pass build, type check, lint, formatting, test and audit.
2
+ **Trigger**: `/archi.code <id>` | Auto-loaded by Workflow Dispatch on natural language trigger
3
+ **Goal**: Complete feature development per `tasks/<id>_<Slug>/plan.json` task list; follow `tech_stack.md` (UI projects only: also follow `design_tokens.json`); pass build, types, Lint, format, tests and audit.
4
4
 
5
5
  <meta>
6
6
  <style>Deterministic, Type-Safe, SOTA-First</style>
7
7
  <language>English</language>
8
8
  <principles>
9
- 1. **Frontmatter Preservation**: Prohibited from modifying existing files' YAML Frontmatter.
10
- 2. **Follow Conventions**: Use only existing repo libraries and patterns; read before modify.
11
- 3. **Security First**: Prohibit introducing/printing secrets; sensitive info must not be written to disk.
12
- 4. **SOTA Pattern Check**: Reject outdated practices; adopt best practices defined in tech_stack.
9
+ 1. **Frontmatter Preservation**: Do not change existing files' YAML Frontmatter.
10
+ 2. **Follow Conventions**: Use only repo-existing libs and patterns; read before modify.
11
+ 3. **Security First**: Do not introduce/print secrets; sensitive info must not be persisted.
12
+ 4. **SOTA Pattern Check**: Reject outdated patterns; use tech_stack defined best practices.
13
13
  5. **No Commit Policy**: Do not commit without authorization; present changes as patches.
14
- 6. **Static Check First**: Must pass all static checks (Type/Lint/Format).
15
- 7. **Plan Completion Gate**: Verify Plan completion before signing off. All AI-completable tasks must be finished; only "Human Intervention" and "Force Majeure" are exempt.
14
+ 6. **Static Check First**: Must pass all static checks (types/Lint/format).
15
+ 7. **Plan Completion Gate**: Verify Plan completion before finish. All tasks AI can complete must be done; only exempt "manual intervention" and "force majeure".
16
+ 8. **IDE-Native First**: Leverage IDE native capabilities to drive execution rhythm; this protocol defines quality standards and checkpoints, not fight IDE planning/execution mechanisms.
16
17
  </principles>
17
18
  </meta>
18
19
 
19
20
  <step_1_resolve>
20
- **Role**: System Analyst
21
21
  **Action**:
22
- 1. **Resolve ID**: Parse `<id>` → Task Name, Slug, phase/status from `[[__DOCS_DIR__]]/global/roadmap.json`.
23
- 2. **Status Gate** — Only `active` can enter code workflow:
22
+ 1. **Resolve ID**: Parse `<id>` from roadmap.json → Task Name, Slug, phase/status.
23
+ 2. **Status Gate** — only `active` may enter code flow:
24
24
 
25
25
  | Status | Handling |
26
26
  |:---|:---|
27
27
  | `active` | Pass, continue |
28
28
  | `pending` | Reject — prompt to run `/archi.plan <ID>` first |
29
- | `blocked` | Reject — prerequisites not completed |
30
- | `done` | Reject — already completed, use `/archi.edit <ID>` for modifications |
31
-
32
- 3. **Load Context** (Use Roadmap `📁 Slug` to locate):
33
- - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/spec.md` — Logic & Scenarios
34
- - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/ui.md` task UI scope declaration (if exists)
35
- - [?Complex] `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/design.md` — Technical design (if exists): state machine/pipeline/protocol definitions, parameter table, invariants
36
- - [?UI] `[[__DOCS_DIR__]]/global/ui_context.md` — AI screen index (screen IDs / routes / states / navigation graph / shared components)
37
- - [?UI] `[[__DOCS_DIR__]]/global/ui_concept.html` — read-only visual reference (calibrate layout against this during implementation; do not redesign — design is already locked in ui.md)
38
- - `[[__DOCS_DIR__]]/tasks/<id>_<Slug>/plan.json` — Task breakdown (contains `notes` shorthand; must reference during execution)
39
- - `02_tech_stack.md` — Technical Red Lines
40
- - [?UI] `[[__DOCS_DIR__]]/global/design_tokens.json`
41
- - [?Data] `[[__DOCS_DIR__]]/global/data_snapshot.json`
42
- - **Read Refs** (if any): Read `[[__DOCS_DIR__]]/refs/index.json` (if exists); match by tags and spec.md tech domain semantics; load only matched ref files as supplementary context; skip if `refs/` missing or empty.
43
-
44
- **Output**: Atomic list of tasks to implement, marking dependencies and order.
29
+ | `blocked` | Reject — upstream deps incomplete |
30
+ | `done` | Reject — already done; use `/archi.edit <ID>` for changes |
31
+
32
+ 3. **Load**: task docs (spec/ui/design/plan) + project context (tech_stack/design_tokens/data_snapshot/ui_context/screens/) + refs (match by tags; load only matched files).
33
+
34
+ **Output**: Atomic task list to implement with dependencies and order.
45
35
  </step_1_resolve>
46
36
 
47
37
  <step_2_plan>
48
- **Role**: Tech Lead
49
38
  **Action**:
50
- Generate execution blueprint (dynamically adjusted by project type):
51
- - **Phase A (Domain/Data/API)**: Data models/interfaces/validation
52
- - **Phase B (UI/Presentation)**: Component structure/styling (use Design Tokens only); non-UI projects adjust to corresponding presentation layer
53
- - **Phase C (Integration)**: End-to-end wiring (state management, routing, data flow, error handling)
39
+ Generate execution blueprint (adjust by project type):
40
+ - **Phase A (Domain/Data/API)**: Data models / interfaces / validation
41
+ - **Phase B (UI/Presentation)**: Component structure / styles (Design Tokens only); non-UI projects adjust to corresponding presentation layer
42
+ - **Phase C (Integration)**: End-to-end wiring (state, routing, data flow, error handling)
54
43
 
55
- Write completion criteria for each task: static checks passed, tests passed, compliant with tech_stack specs.
44
+ Each task must have completion criteria: static checks pass, tests pass, comply with tech_stack.
56
45
 
57
- **Output**: Implementation-oriented atomic task list (Checkbox).
46
+ **Output**: Atomic task list for implementation (Checkbox).
58
47
  </step_2_plan>
59
48
 
60
49
  <step_3_implement>
61
- **Role**: Senior Engineer
62
50
  **Protocol**:
63
- - **Read First**: Must read target file before modification; follow existing code style.
64
- - **Use Existing Stack**: Use only technologies and libraries declared in `02_tech_stack.md`.
65
- - [?UI] **Design Tokens Only**: Styles strictly use visual patterns defined by Tokens/Presets; prohibited hardcoding magic values (colors, sizes, spacing, etc.).
66
- - **Type-Safe**: Complete type definitions; use the project tech stack's type system to guard boundaries.
67
- - **Code Organization**: Follow the architecture pattern and file placement strategy defined in `02_tech_stack.md`.
68
- - **Comments**: Explain Why, not What; reject nonsense comments.
69
- - **Naming**: Self-documenting names; reject `a`, `b`, `tmp` etc. (except loop variable `i`).
70
- - [?Complex] **Design Adherence**: When `design.md` exists, implementation must strictly follow its state machine/pipeline/protocol definitions; parameters must reference design.md § 3 values (no hardcoding other values); must satisfy all § 4 Invariants (use assert or runtime checks).
71
- - **Error Handling**: Prohibit swallowing errors/silent failures; must properly propagate errors and provide observable feedback to callers (UI: Toast; CLI: Exit Code; API: Status Code + Body).
72
- - **Robustness**: Explicitly handle edge cases (Loading/Error/Empty/Timeout); prohibit writing only Happy Path.
51
+ - **Read First**: Must read target file before modify; follow existing project code style.
52
+ - **Use Existing Stack**: Use only tech and libs declared in `tech_stack.md`.
53
+ - (When this task involves UI) [[INCLUDE: shared/ui-redlines.md]]
54
+ - **Type-Safe**: Complete type definitions; use project type system to guard boundaries.
55
+ - **Code Organization**: Follow `tech_stack.md` architecture and file placement.
56
+ - **Comments**: Explain Why, not What.
57
+ - **Naming**: Self-explanatory names; no meaningless names.
58
+ - Complex tasks only: **Design Adherence**: When `design.md` exists, implementation must strictly follow its state machine/pipeline/protocol; params reference § 3 values; must satisfy all § 4 Invariants.
59
+ - **Error Handling**: No swallowing/silent failure; propagate and give callers observable feedback.
60
+ - **Robustness**: Explicitly handle boundaries (Loading/Error/Empty/Timeout); no Happy Path only.
73
61
  - **SOTA**: Follow tech_stack best practices; reject explicitly forbidden outdated patterns.
74
- - **Scaffold Safety**: Scaffolds in non-empty directories may overwrite files — must generate in new directory and protect `[[__DOCS_DIR__]]/`; delete/overwrite operations must list manifest and confirm first.
75
- - **.gitkeep Cleanup**: Empty dirs may use `.gitkeep` for Git tracking; when adding other files to a dir, must remove that dir's `.gitkeep`.
76
- - **Patch Output**: Output changes as patches, with Code References.
77
- - **Progress Tracking**: After completing each task, immediately update the corresponding task's `done: true` in `plan.json`; prohibited from batch-updating at signoff (progress will be lost if session is interrupted).
62
+ - **Scaffold Safety**: Non-empty dirs must protect `[[__DOCS_DIR__]]/`.
63
+ - **.gitkeep Cleanup**: Remove `.gitkeep` when adding files to dir.
64
+ - **Patch Output**: Output changes as patches with Code Reference.
65
+ - **Progress Tracking**: After each task, update `plan.json` corresponding `done: true` immediately; do not batch at signoff.
78
66
 
79
- **Action**: Implement Phase A/B/C step by step; produce complete, production-quality code (with necessary tests); new files/directories must align with tech_stack.
67
+ **Action**: Implement phase A/B/C item by item; produce complete, production-ready code (including necessary tests).
80
68
  </step_3_implement>
81
69
 
82
70
  <step_4_validate>
83
- **Role**: Validation Engineer
84
- **Action** (Fix and re-run on failure; commands subject to `02_tech_stack.md` Section 5):
71
+ **Action** (on failure fix and re-run; commands per `tech_stack.md` Section 5):
85
72
 
86
- **Automated Check**: Run `[[__DOCS_DIR__]]/scripts/validate` (if exists); otherwise execute the checklist below manually.
73
+ **Automated Check**: Check `scripts/validate`:
74
+ - **Exists** → Must run, results per script output
75
+ - **Not exists** → Execute checklist below
87
76
 
88
- | Phase | Check Item | Requirement |
77
+ > **Scripts Check**: If `scripts/` directory does not exist → Suggest running `/archi.script` to generate automation scripts first.
78
+
79
+ | Phase | Check | Requirement |
89
80
  |:---|:---|:---|
90
- | **Static** | Build | Zero compilation errors |
81
+ | **Static** | Build | Zero compile errors |
91
82
  | | Type Check | Zero type errors |
92
- | | Lint | Zero lint errors (warnings must explain reason) |
93
- | | Format | Compliant with format rules (if failed, auto-fix then re-check) |
94
- | **Test** | Existing Tests | Run existing test suite, all pass; must not break existing tests |
95
- | | New Coverage | Add tests for newly added/modified critical logic; pure styling exempt |
83
+ | | Lint | Zero Lint errors (warnings require reason) |
84
+ | | Format | Compliant (auto-fix then re-check if fail) |
85
+ | **Test** | Existing Tests | All pass; do not break old tests |
86
+ | | New Coverage | Add tests for new/modified critical logic |
96
87
 
97
- **Task Verification (Mandatory)**
88
+ **Task Verification (mandatory)**
98
89
 
99
- > Prohibited from marking complete via code review or automated tests alone; must actually run and verify the target task.
100
- > If dev server is not running, execute `[[__DOCS_DIR__]]/scripts/dev-up` first.
101
- > **Read `notes.Verify` first**: Read the `Verify: [...]` portion at the end of the current task's `notes` field and use that operation as the concrete e2e step. Fall back to the table below only if the `notes` field has no `Verify` entry.
90
+ > Do not mark complete by code review only; must actually run target feature and verify.
91
+ > **Prefer `notes.验证`**: First read current task `notes` end `Verify: [...]` and run e2e; fallback to table by type when no verify field.
102
92
 
103
93
  | Project Type | Verification Action | Pass Criteria |
104
94
  |:---|:---|:---|
105
- | [?Web] | Browser-navigate target task path | Renders correctly, no interaction errors, clean console |
106
- | [?API] | Call new/modified endpoints | Status code and body match spec |
107
- | [?CLI] | Execute target command (normal args + edge cases) | stdout as expected, correct exit code |
108
- | [?Lib] | Run example code or playground to verify exported API | No runtime errors, correct return values |
109
- | [?Mobile] | Emulator/device operate target task | UI renders, interactions respond |
110
- | [?Desktop] | Launch app operate target task | Window renders, task functional |
95
+ | When this task involves UI | Browser: operate target feature path | Render OK, interaction no errors |
96
+ | When this task involves API | Call new/modified endpoint | Status and Body match spec |
97
+ | When this task involves CLI | Execute target command (normal + edge params) | stdout expected, exit code correct |
98
+ | When this task involves lib | Run sample code to verify exported API | No runtime error, return correct |
99
+ | When this task involves mobile | Simulator/device: operate | UI OK, interaction responsive |
100
+ | When this task involves desktop | Launch app and operate | Window OK, feature works |
111
101
 
112
- **Evidence**: Output must include verification results (command output summary / screenshot / error log).
113
- **Fallback**: If verification keeps failing and environment issues suspected → `[[__DOCS_DIR__]]/scripts/dev-reset` → `[[__DOCS_DIR__]]/scripts/dev-up` → retry.
102
+ **Evidence**: Attach verification result (command output summary / screenshot / error log).
103
+ **Fallback**: If verification keeps failing → `scripts/dev-reset` → `scripts/dev-up` → retry.
114
104
 
115
- **Output**: ✅/❌ status and reason for each check; Task Verification evidence.
105
+ **Output**: Each check ✅/❌ status and reason; Task Verification evidence.
116
106
  </step_4_validate>
117
107
 
118
108
  <step_5_verify>
119
109
  **Role**: Independent Reviewer
120
110
 
121
111
  **5A. Code quality review**:
122
- [[SUBAGENT: archi-silent-audit|mode: code-impl, context: Review step_3 implemented code (Tech/SOTA/Security/Performance + conditional dimensions)]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-silent-audit/SKILL.md`, follow mode: code-impl review dimension table item by item)]]
112
+ [[SUBAGENT: archi-silent-audit|mode: code-impl, context: Review step_3 implemented code (Tech/SOTA/Security/Performance + conditional dimensions)]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-silent-audit/SKILL.md`, follow mode: code-impl review dimension table)]]
123
113
 
124
114
  **5B. Linkage check**:
125
- [[SUBAGENT: archi-feature-relations|mode: check, context: Semantically compare this implementation with featureRelations sources]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-feature-relations/SKILL.md`, follow mode: check logic)]]
115
+ [[SUBAGENT: archi-feature-relations|mode: check, context: Compare implemented feature with featureRelations sources semantically]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-feature-relations/SKILL.md`, follow mode: check logic)]]
126
116
 
127
117
  **5C. Data governance sync**:
128
- [[SUBAGENT: archi-data-sync|context: Scan this implementation for new business entities/error codes/Schema; incremental sync per 03_data_governance.md rules]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-data-sync/SKILL.md`, follow its execution protocol)]]
118
+ [[SUBAGENT: archi-data-sync|context: Scan new business entities/error codes/Schema from implementation; incrementally sync per 00_system.md]][[NO-SKILL: (Skill not installed: read `[[__DOCS_DIR__]]/skills/archi-data-sync/SKILL.md` and follow its protocol)]]
129
119
 
130
120
  [[INCLUDE: shared/verify-result-handling.md]]
131
121
  </step_5_verify>
132
122
 
133
123
  <step_6_signoff>
134
- **Terminal Gate** (Do not skip; must complete before output summary):
124
+ **Terminal Gate** (do not skip):
135
125
  | Step | Command | Pass Condition |
136
126
  |:---|:---|:---|
137
- | 1 | `npx archi plan <ID>` | All done or exempt only; not passed return to step_3 |
127
+ | 1 | `npx archi plan <ID>` | All complete or exempt only; if fail do not sign off, return to step_3 |
138
128
  | 2 | `npx archi task <ID> --status done` | Task status updated |
139
- | 3 | `npx archi task --check` | No ERROR-level issues |
140
- | 4 | `npx archi render` | `.md` views generated |
141
-
142
- **Action** (After Gate passes):
143
- 1. Confirm all task `done` marks in `plan.json` are updated (should be done in real-time during step_3; this is a final check).
144
- 2. **Drift Warning**: Compare code changes against `spec.md`'s key checkpoints (interface signatures, return types, key operations in Gherkin scenarios). If code exceeds spec coverage → mark `⚠️ Spec Drift`, suggest running `/archi.edit <ID>` to sync docs.
145
- 3. Output completed task list with patch links (Code Reference).
146
- 4. Provide next step suggestions and Git Commit Suggestion (Conventional Commits).
147
-
148
- **Checkpoint** (Confirm before Output): Terminal Gate all executed
149
-
150
- **Output**: Completion summary with completed tasks, exempt items (if any), Git Commit suggestion, Next Steps table.
129
+ | 3 | Standard check (task --check + render) | No ERROR + views generated |
130
+
131
+ **Action** (after Gate passes):
132
+ 1. Confirm `plan.json` each task `done` flag updated.
133
+ 2. **Drift Warning**: Compare code changes with `spec.md` key points. If beyond spec coverage mark `⚠️ Spec drift`, suggest `/archi.edit <ID>`.
134
+ 3. Output completed task list and patch links.
135
+ 4. Provide next steps.
136
+
137
+ **Pre-signoff Checklist** (confirm each item before Output):
138
+ plan.json every task done flag updated in real-time (not batch-updated at signoff)
139
+ □ Step 4 — Build / type check / Lint / format all passed
140
+ Step 4 Task Verification executed for each project type with Evidence attached
141
+ □ Step 5A Silent Audit — executed, all CRITICAL issues resolved
142
+ □ Step 5B featureRelations check — executed
143
+ - Check if modified files affect other linked files
144
+ □ Step 5C data governance sync — executed:
145
+ - dictionary.json + error_codes.json + env_registry.json — required
146
+ - (UI projects only) design_tokens.json + ui_context.md
147
+ - (Data projects only) data_snapshot.json
148
+ - (API projects only) api_snapshot.json
149
+ - (CLI projects only) command_api.json
150
+ - (Lib projects only) public_api.json
151
+ □ Terminal Gate — npx archi plan <ID> all complete (exempt items only)
152
+
153
+ **Output**: Completion summary with completed tasks, exempt items (if any), Next Steps:
154
+
155
+ | Priority | Action | Notes |
156
+ |:---|:---|:---|
157
+ | (If no scripts/) | `/archi.script` | Generate automation scripts (validate/dev-up/dev-reset) |
158
+ | Recommended | `/archi.audit <ID>` | Independent review of implementation |
159
+ | (If Spec drift) | `/archi.edit <ID>` | Update docs before continuing |
160
+ | (If next pending task) | `/archi.plan <next pending ID>` | Plan the next task |
151
161
  </step_6_signoff>
152
162
 
153
163
  </protocol_code>