architext 0.0.5 → 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 (78) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +18 -16
  3. package/README.zh-CN.md +15 -14
  4. package/dist/index.js +43 -29
  5. package/dist/templates/en/briefs/_base.md +13 -6
  6. package/dist/templates/en/briefs/_modules.md +2 -2
  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 +5 -5
  13. package/dist/templates/en/docs/prompts/code.md +23 -11
  14. package/dist/templates/en/docs/prompts/edit.md +21 -7
  15. package/dist/templates/en/docs/prompts/fix.md +11 -2
  16. package/dist/templates/en/docs/prompts/inherit.md +18 -13
  17. package/dist/templates/en/docs/prompts/map.md +4 -3
  18. package/dist/templates/en/docs/prompts/plan.md +11 -5
  19. package/dist/templates/en/docs/prompts/remove.md +13 -8
  20. package/dist/templates/en/docs/prompts/revise.md +10 -2
  21. package/dist/templates/en/docs/prompts/scope.md +4 -3
  22. package/dist/templates/en/docs/prompts/script.md +102 -0
  23. package/dist/templates/en/docs/prompts/start.md +20 -14
  24. package/dist/templates/en/docs/prompts/ui.md +113 -0
  25. package/dist/templates/en/docs/shared/ui-redlines.md +7 -0
  26. package/dist/templates/en/docs/templates/spec.template.md +1 -1
  27. package/dist/templates/en/docs/templates/ui.template.md +8 -8
  28. package/dist/templates/en/rules/00_system.md +245 -51
  29. package/dist/templates/en/rules/90_custom_rules.md +3 -1
  30. package/dist/templates/en/skills/archi-data-sync/SKILL.md +26 -12
  31. package/dist/templates/en/skills/archi-decompose-roadmap/SKILL.md +137 -208
  32. package/dist/templates/en/skills/archi-design-patterns/SKILL.md +6 -2
  33. package/dist/templates/en/skills/archi-feature-relations/SKILL.md +6 -2
  34. package/dist/templates/en/skills/archi-interview-protocol/SKILL.md +1 -2
  35. package/dist/templates/en/skills/archi-plan-options/SKILL.md +77 -302
  36. package/dist/templates/en/skills/archi-silent-audit/SKILL.md +4 -5
  37. package/dist/templates/en/skills/archi-ui-wireframe/SKILL.md +131 -306
  38. package/dist/templates/icon.svg +16 -0
  39. package/dist/templates/zh/briefs/_base.md +17 -10
  40. package/dist/templates/zh/briefs/_modules.md +2 -2
  41. package/dist/templates/zh/docs/global/error_memory.json +40 -0
  42. package/dist/templates/zh/docs/global/map.json +39 -109
  43. package/dist/templates/zh/{rules/04_cli_tools.md → docs/global/references/cli_reference.md} +0 -7
  44. package/dist/templates/zh/{rules/02_tech_stack.md → docs/global/tech_stack.md} +9 -20
  45. package/dist/templates/zh/docs/global/vision.md +1 -1
  46. package/dist/templates/zh/docs/prompts/audit.md +5 -5
  47. package/dist/templates/zh/docs/prompts/code.md +22 -10
  48. package/dist/templates/zh/docs/prompts/edit.md +20 -6
  49. package/dist/templates/zh/docs/prompts/fix.md +10 -1
  50. package/dist/templates/zh/docs/prompts/inherit.md +18 -13
  51. package/dist/templates/zh/docs/prompts/map.md +5 -4
  52. package/dist/templates/zh/docs/prompts/plan.md +11 -5
  53. package/dist/templates/zh/docs/prompts/remove.md +13 -8
  54. package/dist/templates/zh/docs/prompts/revise.md +12 -4
  55. package/dist/templates/zh/docs/prompts/scope.md +4 -3
  56. package/dist/templates/zh/docs/prompts/script.md +102 -0
  57. package/dist/templates/zh/docs/prompts/start.md +19 -15
  58. package/dist/templates/zh/docs/prompts/ui.md +113 -0
  59. package/dist/templates/zh/docs/shared/ui-redlines.md +7 -0
  60. package/dist/templates/zh/docs/templates/spec.template.md +1 -1
  61. package/dist/templates/zh/docs/templates/ui.template.md +8 -8
  62. package/dist/templates/zh/rules/00_system.md +243 -49
  63. package/dist/templates/zh/rules/90_custom_rules.md +2 -1
  64. package/dist/templates/zh/skills/archi-data-sync/SKILL.md +27 -13
  65. package/dist/templates/zh/skills/archi-decompose-roadmap/SKILL.md +133 -204
  66. package/dist/templates/zh/skills/archi-design-patterns/SKILL.md +6 -2
  67. package/dist/templates/zh/skills/archi-feature-relations/SKILL.md +6 -2
  68. package/dist/templates/zh/skills/archi-interview-protocol/SKILL.md +1 -2
  69. package/dist/templates/zh/skills/archi-plan-options/SKILL.md +77 -302
  70. package/dist/templates/zh/skills/archi-silent-audit/SKILL.md +4 -5
  71. package/dist/templates/zh/skills/archi-ui-wireframe/SKILL.md +131 -306
  72. package/package.json +3 -1
  73. package/dist/templates/en/rules/01_workflow.md +0 -95
  74. package/dist/templates/en/rules/03_data_governance.md +0 -106
  75. package/dist/templates/en/rules/99_context_glue.md +0 -53
  76. package/dist/templates/zh/rules/01_workflow.md +0 -95
  77. package/dist/templates/zh/rules/03_data_governance.md +0 -106
  78. package/dist/templates/zh/rules/99_context_glue.md +0 -53
@@ -1,106 +0,0 @@
1
- ---
2
- description: AI collaboration governance rules for JSON data files. Defines read/write specs, update timing & format constraints for global data files.
3
- globs: "**/*.json"
4
- applyTo: "**/*.json"
5
- alwaysApply: true
6
- ---
7
-
8
- # Data Governance Protocol
9
-
10
- > **Role**: Data Steward. Ensure consistency, integrity & traceability of global JSON data files.
11
-
12
- ## 1. Data File Registry
13
-
14
- | File | Read When | Write When |
15
- |:---|:---|:---|
16
- | `roadmap.json` | plan/code start | start creates; AI edit or `npx archi task` updates |
17
- | `map.json` | When touching code (via context_glue) | plan Step 3; inherit Step 3.6; /archi.map |
18
- | `dictionary.json` | When generating variable names | plan Step 3; code/fix step_5 auto-appends |
19
- | `design_tokens.json` [?UI] | When generating UI code | start creates; update on design changes |
20
- | `data_snapshot.json` [?Data] | plan design / code implementation | Plan designs Schema; Code syncs changes |
21
- | `error_codes.json` | When writing error handling | plan Step 3; code/fix step_5 auto-appends |
22
- | `api_snapshot.json` [?API] | When implementing endpoints | plan Step 3 registers; Code syncs |
23
- | `env_registry.json` [?API] | When introducing config items | Code appends immediately on new env var |
24
- | `command_api.json` [?CLI] | When implementing commands | plan Step 3 registers; Code syncs |
25
- | `public_api.json` [?Lib] | When adding/modifying exports | plan Step 3 registers; Code syncs |
26
-
27
- ---
28
-
29
- ## 2. General Rules
30
-
31
- ### 2.1 Format Constraints
32
-
33
- - **JSON Only**: `.json` is the single source of truth. `.md` views are auto-generated by `npx archi render`; forbidden to edit directly.
34
- - **Schema Stability**:
35
- - **Tier 1 (Strict)**: `roadmap.json`, `plan.json` — CLI depends on these; Zod Schema validated; forbidden to change arbitrarily.
36
- - **Tier 2 (Flexible)**: All other files only validate top-level keys. **All Tier 2 files may freely extend fields (new keys / new array item properties) without CLI changes.**
37
- - **Valid JSON**: No trailing commas, no comments.
38
-
39
- ### 2.2 Read/Write Discipline
40
-
41
- | Scenario | Rule |
42
- |:---|:---|
43
- | Consult data | Read `.json`; forbidden to read `.md` view (may be stale) |
44
- | Update Roadmap status | Prefer `npx archi task <ID> --status <s>`; batch may edit JSON directly |
45
- | Update other data | AI directly edits `.json` |
46
- | After updates | Run `npx archi render` to regenerate `.md` views |
47
-
48
- ---
49
-
50
- ## 3. File-Specific Rules
51
-
52
- ### `roadmap.json`
53
-
54
- - **Structure**: `phases[] → tasks[]`, each task must have `id`, `title`, `status`, `deps`.
55
- - **Status values**: `pending` | `active` | `done` | `blocked`.
56
- - **Dependency integrity**: IDs in `deps` must exist in tasks.
57
- - **Slug rule**: `slug` used for tasks folder naming, format `Snake_Case`.
58
-
59
- ### `map.json`
60
-
61
- - **Directory Mapping**: Must reflect real physical file tree.
62
- - **Logical Topology**: Must register each Task Module's responsibility.
63
- - **Feature Relations**: `featureRelations` records aggregator-source linkages, written by AI during plan/inherit.
64
- - **Self-Correction**: Code references violating topology hierarchy must report error and stop.
65
-
66
- ### `dictionary.json`
67
-
68
- - **Naming Authority**: `entities[].codeName` is the supreme law; forbidden to use `forbiddenSynonyms`.
69
- - **Boundary**: Only register project business domain; Architext framework concepts forbidden.
70
- - verbs maintain project-wide verb consistency; utilities must be registered and used instead of raw APIs.
71
- - [?UI]: components — search existing before creating new ones.
72
-
73
- ### `design_tokens.json` [?UI]
74
-
75
- - **Token Only**: Styles must use Tokens; forbidden to hardcode Hex/px/rem.
76
- - **Dark Mode**: Must define both `light` and `dark` values.
77
-
78
- ### `data_snapshot.json` [?Data]
79
-
80
- - **Structure**: `models[]` (name/fields/types/constraints) + `relationships[]` (1:1/1:N/M:N/self-ref).
81
- - **Design First**: Plan must define model structure, precise to field names and types; forbidden to write "TBD".
82
- - **Sync Back**: After Code phase, must sync actual changes back.
83
-
84
- ### `error_codes.json`
85
-
86
- - **Boundary**: Only register project business domain errors; framework infrastructure errors forbidden.
87
- - **Code Format**: `ERR_[MODULE]_[REASON]`.
88
- - **Design Before Code**: Must register error codes before writing error handling, including `message` and `recovery`.
89
-
90
- ### Conditional File Rules
91
-
92
- | File | Core Rules |
93
- |:---|:---|
94
- | `api_snapshot.json` [?API] | endpoints[] registry; Register First — forbidden to implement unregistered endpoints; owner marks Task ID |
95
- | `env_registry.json` [?API] | Register on introduce; required/example mandatory |
96
- | `command_api.json` [?CLI] | Sync on modify; owner marks Task ID |
97
- | `public_api.json` [?Lib] | stable changes require /archi.edit; full TS signature; owner marks Task ID |
98
-
99
- ---
100
-
101
- ## 4. Plan JSON (`plan.json`)
102
-
103
- - **Location**: `tasks/<ID>_<Slug>/plan.json`
104
- - **Checkbox Updates**: AI sets `done` to `true` directly after completing steps during `/archi.code`.
105
- - **Append Rule**: `/archi.edit` appends new Phases while preserving completed history.
106
- - **Verification**: Run `npx archi plan <ID>` to verify completion.
@@ -1,53 +0,0 @@
1
- ---
2
- description: Context Navigation & Document Indexing. Bridges source code to documentation using the Map registry. Essential for locating specs and plans.
3
- globs: **/*
4
- applyTo: **/*
5
- alwaysApply: true
6
- ---
7
-
8
- # Context Glue Protocol
9
-
10
- > **Role**: Context Navigator. Prevent AI amnesia, use Map Look-up to determine the business document corresponding to the current code.
11
-
12
- ## 1. Context Discovery
13
-
14
- When reading or editing code files, must execute the following addressing steps:
15
-
16
- **Step 1: Check Global Map**
17
- - Read `[[__DOCS_DIR__]]/global/map.json`.
18
- - Find the module the current file belongs to in `directoryMapping` / `logicalTopology`.
19
- - Load the Docs Link (Spec/UI/Plan) registered for that module.
20
-
21
- **Step 2: Check Explicit Context**
22
- - Scenario: Newly created file or Map not yet updated.
23
- - Check if user Prompt explicitly specified a document path, if so must load it.
24
-
25
- **Step 3: Fallback**
26
- - Not registered in Map and user did not specify → **STOP & ASK**.
27
- - Prompt: "Spec document for current code not found. Please provide the path, or run `/archi.map` to update the architecture map."
28
-
29
- ---
30
-
31
- ## 2. Mandatory Loading Rules
32
-
33
- | Code Type | Required Context | Source of Truth |
34
- |:---|:---|:---|
35
- | **Business Logic** (Tasks/Entities) | Spec Document | `[[__DOCS_DIR__]]/global/map.json` → Module Entry |
36
- | **UI Components** (Pages/Widgets) [?UI] | UI Document + `[[__DOCS_DIR__]]/global/design_tokens.json` | `[[__DOCS_DIR__]]/global/map.json` + Global Rules |
37
- | **Data Schema** (ORM/SQL/Models) [?Data] | Data Snapshot | `[[__DOCS_DIR__]]/global/data_snapshot.json` |
38
- | **Config / Infra** (Package.json...) | Tech Stack | `02_tech_stack.md` |
39
-
40
- ---
41
-
42
- ## 3. Anti-Hallucination
43
-
44
- - Code is the downstream artifact of documentation.
45
- - Forbidden to guess business logic based on variable names without reading Spec.
46
- - When code is found inconsistent with documentation: do not arbitrarily fix either, must pause and report the inconsistency.
47
-
48
- ---
49
-
50
- ## 4. Maintenance Hook
51
-
52
- - **Trigger**: When creating a new file or new module.
53
- - **Action**: Must automatically update `map.json` to establish mapping between code path and document path; only ask user when the mapping relationship is unclear.
@@ -1,95 +0,0 @@
1
- ---
2
- description: Command Dispatcher & Workflow Controller. Handles /archi.* routing and mode transitions.
3
- globs: **/*
4
- applyTo: **/*
5
- alwaysApply: true
6
- ---
7
-
8
- # Workflow Dispatcher
9
-
10
- > **Role**: 模式切换器。默认"通用架构师"模式,仅检测到显式指令时加载特定协议。
11
-
12
- > ⛔ **STOP CHECK** — 每轮回复前自检:
13
- > | 违规行为 | 正确处理 |
14
- > |:---|:---|
15
- > | 收到 `/archi.*` 却未读协议文件就执行 | 停止 → 先读取协议文件 |
16
- > | 用户请求涉及行为变更却直接改代码 | 停止 → 加载对应协议执行 |
17
- > | 执行 `npx archi` 前未确认工作目录 | 停止 → 先通过 Working Directory Gate(见 `04_cli_tools.md`) |
18
-
19
- ## 1. Explicit Command Routing
20
-
21
- **Trigger**: 用户输入以 `/archi.` 开头时,立即加载对应协议。
22
-
23
- | Command | Target Template |
24
- |:---|:---|
25
- | `/archi.start` | `[[__PROMPTS_PATH__]]/archi.start.md` |
26
- | `/archi.inherit` | `[[__PROMPTS_PATH__]]/archi.inherit.md` |
27
- | `/archi.scope` | `[[__PROMPTS_PATH__]]/archi.scope.md` |
28
- | `/archi.plan` | `[[__PROMPTS_PATH__]]/archi.plan.md` |
29
- | `/archi.edit` | `[[__PROMPTS_PATH__]]/archi.edit.md` |
30
- | `/archi.revise` | `[[__PROMPTS_PATH__]]/archi.revise.md` |
31
- | `/archi.code` | `[[__PROMPTS_PATH__]]/archi.code.md` |
32
- | `/archi.audit` | `[[__PROMPTS_PATH__]]/archi.audit.md` |
33
- | `/archi.fix` | `[[__PROMPTS_PATH__]]/archi.fix.md` |
34
- | `/archi.map` | `[[__PROMPTS_PATH__]]/archi.map.md` |
35
- | `/archi.remove` | `[[__PROMPTS_PATH__]]/archi.remove.md` |
36
- | `/archi.ref` | `[[__PROMPTS_PATH__]]/archi.ref.md` |
37
- | `/archi.recover` | `[[__PROMPTS_PATH__]]/archi.recover.md` |
38
- | `/archi.help` | `[[__PROMPTS_PATH__]]/archi.help.md` |
39
-
40
- > **Protocol Load Gate** (禁跳过,按序完成):
41
- > 1. **Read** 目标 `.md` 全文 → 文件不存在时停止: `协议文件未找到,中止执行`
42
- > 2. **Override** — 可覆盖: `<system_role>`, `<thinking_process>`, `<communication_style>`。不可覆盖: `<core_philosophy>`, `<critical_protocols>`。
43
- > 3. **Execute** `<step_1>` — 禁在步骤 1 完成前执行任何协议内容
44
-
45
- ---
46
-
47
- ## 2. Natural Language Dispatch
48
-
49
- **Trigger**: 用户输入非 `/archi.` 指令且涉及业务变更。
50
-
51
- ### §2.0 不触发协议的场景(直接回答)
52
-
53
- | 意图类型 | 处理 |
54
- |:---|:---|
55
- | 纯对话 / 代码阅读 / 架构讨论 | ✅ 直接回答 |
56
- | 琐碎修改(typo/注释/格式/日志) | ✅ 直接执行 |
57
-
58
- ### §2.1 Pre-flight(涉及业务变更时触发)
59
-
60
- 1. 扫描 `roadmap.json` + `tasks/<ID>_*/` 目录,匹配用户意图对应的任务。
61
- 2. 按下表确定应加载的协议:
62
-
63
- | 检查结果 | 加载协议 | 确认方式 |
64
- |:---|:---|:---|
65
- | roadmap 无匹配任务 | `scope.md` | 告知"我来帮你梳理需求"后直接开始 |
66
- | 有任务·无 spec.md | `plan.md` | 告知"该任务还没规划,我来做"后直接开始 |
67
- | 有 spec+plan·status=active | `code.md` | 直接开始(IDE 原生 plan mode 接管节奏) |
68
- | status=done·用户要修改 | `edit.md` | 告知"我先更新文档再改代码"后开始 |
69
- | 用户描述了异常行为 | `fix.md` | 直接开始诊断 |
70
- | 影响 >1 个任务或全局资产 | `revise.md` | 先输出影响评估,等确认 |
71
-
72
- 3. 加载协议后按 §1 的 **Protocol Load Gate** 执行(读全文 → override → step_1)。
73
-
74
- ### §2.2 链条衔接
75
-
76
- 各协议 Signoff 的 Next Steps 已指向下一个协议。AI 须:
77
- - 主动提示下一步("spec 写好了,要开始实现吗?")
78
- - 用户确认后,直接加载下一个协议继续
79
-
80
- | 衔接 | 串联方式 |
81
- |:---|:---|
82
- | scope → plan | 可连续执行(scope 完成后主动询问"要 plan 第一个任务吗?") |
83
- | plan → code | **须等用户确认**(spec 是最重要的 checkpoint) |
84
- | code → audit | 协议内置(code.md step_5 已有 silent audit) |
85
-
86
- > ⛔ **禁**: 在用户未确认时自动从 plan 串联到 code。
87
-
88
- ### §2.3 IDE 协作
89
-
90
- 利用 IDE 原生能力(plan mode / agent mode / checkpoint)驱动执行节奏。
91
- 协议定义"做什么、检查什么",不对抗 IDE 的规划/执行能力。
92
-
93
- ### §2.4 未纳管代码
94
-
95
- 修改对象未在 `map.json` 中注册、无对应 Task → **STOP & ASK**,提示用户通过 `/archi.inherit` 或 `/archi.scope` 纳管。
@@ -1,106 +0,0 @@
1
- ---
2
- description: JSON 数据文件的 AI 协作治理规则。定义全局数据文件的读写规范、更新时机与格式约束。
3
- globs: "**/*.json"
4
- applyTo: "**/*.json"
5
- alwaysApply: true
6
- ---
7
-
8
- # Data Governance Protocol
9
-
10
- > **Role**: 数据管家。确保全局 JSON 数据文件的一致性、完整性与可追溯性。
11
-
12
- ## 1. 数据文件清单
13
-
14
- | 文件 | 读取时机 | 写入时机 |
15
- |:---|:---|:---|
16
- | `roadmap.json` | plan/code 开始时 | start 创建; AI 编辑或 `npx archi task` 更新 |
17
- | `map.json` | 触碰代码时 (via context_glue) | plan Step 3; inherit Step 3.6; /archi.map |
18
- | `dictionary.json` | 生成变量名/命名时 | plan Step 3; code/fix 后 step_5 自动追加 |
19
- | `design_tokens.json`(仅ui) | 生成 UI 代码时 | start 创建; 设计变更时更新 |
20
- | `data_snapshot.json`(仅data) | plan 设计/code 实现时 | Plan 设计 Schema; Code 同步变更 |
21
- | `error_codes.json` | 编写错误处理时 | plan Step 3; code/fix 后 step_5 自动追加 |
22
- | `api_snapshot.json`(仅api) | 实现/对接端点时 | plan Step 3 注册; Code 同步 |
23
- | `env_registry.json`(仅api) | 引入新配置项时 | Code 引入新 env var 后立即追加 |
24
- | `command_api.json`(仅cli) | 实现/修改命令时 | plan Step 3 注册; Code 同步 |
25
- | `public_api.json`(仅lib) | 新增/修改导出时 | plan Step 3 注册; Code 同步 |
26
-
27
- ---
28
-
29
- ## 2. 通用规则
30
-
31
- ### 2.1 格式约束
32
-
33
- - **JSON Only**: `.json` 是唯一真理源。`.md` 视图由 `npx archi render` 生成,禁直接编辑。
34
- - **Schema Stability**:
35
- - **Tier 1 (严格)**: `roadmap.json`, `plan.json` — CLI 直接依赖,Zod Schema 校验,禁随意变更。
36
- - **Tier 2 (宽松)**: 其余文件仅校验顶层 key。**所有 Tier 2 文件均可自行扩展字段(新 key / 新数组属性),无需改 CLI。**
37
- - **Valid JSON**: 无尾逗号、无注释。
38
-
39
- ### 2.2 读写纪律
40
-
41
- | 场景 | 规则 |
42
- |:---|:---|
43
- | 查阅数据 | 读 `.json`,禁读 `.md` 视图(可能过期) |
44
- | 更新 Roadmap 状态 | 优先 `npx archi task <ID> --status <s>`; 批量时可直接编辑 JSON |
45
- | 更新其他数据 | AI 直接编辑 `.json` |
46
- | 更新后 | 运行 `npx archi render` 重新生成 `.md` 视图 |
47
-
48
- ---
49
-
50
- ## 3. 文件专项规则
51
-
52
- ### `roadmap.json`
53
-
54
- - **结构**: `phases[] → tasks[]`,每个 task 须有 `id`, `title`, `status`, `deps`。
55
- - **Status 值**: `pending` | `active` | `done` | `blocked`。
56
- - **依赖完整性**: `deps` 中引用的 ID 须存在于 tasks 中。
57
- - **Slug 规则**: `slug` 用于 tasks 文件夹命名,格式为 `Snake_Case`。
58
-
59
- ### `map.json`
60
-
61
- - **Directory Mapping**: 须反映真实物理文件树。
62
- - **Logical Topology**: 须注册每个 Task Module 的职责。
63
- - **Feature Relations**: `featureRelations` 记录聚合型 Task 与来源的联动关系,由 AI 在 plan/inherit 时写入。
64
- - **自我校正**: 代码引用违反拓扑层级关系时,须报错并停止。
65
-
66
- ### `dictionary.json`
67
-
68
- - **命名权威**: `entities[].codeName` 是最高法律;禁用 `forbiddenSynonyms` 中的词。
69
- - **Boundary**: 仅注册项目业务域;Architext 框架概念禁注册。
70
- - verbs 保持全项目动词一致;utilities 须注册并用已注册工具替代原始 API。
71
- - 仅ui项目: components 创建前须搜索复用。
72
-
73
- ### `design_tokens.json`(仅ui项目)
74
-
75
- - **Token Only**: 样式严格使用 Token;禁硬编码 Hex/px/rem。
76
- - **Dark Mode**: 须同时定义 `light` 和 `dark` 值。
77
-
78
- ### `data_snapshot.json`(仅data项目)
79
-
80
- - **结构**: `models[]`(名称/字段/类型/约束)+ `relationships[]`(1:1/1:N/M:N/self-ref)。
81
- - **Design First**: Plan 须定义模型结构,精确到字段名与类型,禁写 "TBD"。
82
- - **Sync Back**: Code 完成后须将实际变更同步回此文件。
83
-
84
- ### `error_codes.json`
85
-
86
- - **Boundary**: 仅注册项目业务域错误;框架基础设施错误禁注册。
87
- - **Code Format**: `ERR_[MODULE]_[REASON]`。
88
- - **Design Before Code**: 编写错误处理前须先注册,含 `message` 和 `recovery`。
89
-
90
- ### 条件性文件专项
91
-
92
- | 文件 | 核心规则 |
93
- |:---|:---|
94
- | `api_snapshot.json`(仅api) | endpoints[] 注册; Register First 禁实现未登记端点; owner 标注 Task ID |
95
- | `env_registry.json`(仅api) | 引入即注册; required/example 必填 |
96
- | `command_api.json`(仅cli) | 修改即同步; owner 标注 Task ID |
97
- | `public_api.json`(仅lib) | stable 变更须走 /archi.edit; 完整 TS 签名; owner 标注 Task ID |
98
-
99
- ---
100
-
101
- ## 4. Plan JSON (`plan.json`)
102
-
103
- - **位置**: `tasks/<ID>_<Slug>/plan.json`
104
- - **Checkbox 更新**: AI 在 `/archi.code` 中完成步骤后直接将 `done` 设为 `true`。
105
- - **追加规则**: `/archi.edit` 追加新 Phase 时保留已完成历史。
106
- - **验证**: 完成后运行 `npx archi plan <ID>` 验证完成度。
@@ -1,53 +0,0 @@
1
- ---
2
- description: Context Navigation & Document Indexing. Bridges source code to documentation using the Map registry. Essential for locating specs and plans.
3
- globs: **/*
4
- applyTo: **/*
5
- alwaysApply: true
6
- ---
7
-
8
- # Context Glue Protocol
9
-
10
- > **Role**: 上下文导航仪。防止 AI 失忆,通过查阅地图 (Map Look-up) 确定代码对应的业务文档。
11
-
12
- ## 1. Context Discovery
13
-
14
- 读取或编辑代码文件时,须执行以下寻址步骤:
15
-
16
- **Step 1: Check Global Map**
17
- - 读取 `[[__DOCS_DIR__]]/global/map.json`。
18
- - 在 `directoryMapping` / `logicalTopology` 中查找当前文件所属模块。
19
- - 加载该模块注册的 Docs Link (Spec/UI/Plan)。
20
-
21
- **Step 2: Check Explicit Context**
22
- - 场景: 新创建的文件或 Map 尚未更新。
23
- - 检查用户 Prompt 中是否显式指定了文档路径,如有则须加载。
24
-
25
- **Step 3: Fallback**
26
- - Map 中未注册且用户未指定 → **STOP & ASK**。
27
- - 提示: "未找到当前代码对应的 Spec 文档。请告知路径,或运行 `/archi.map` 更新架构地图。"
28
-
29
- ---
30
-
31
- ## 2. Mandatory Loading Rules
32
-
33
- | 代码类型 | 必读上下文 | 真理来源 |
34
- |:---|:---|:---|
35
- | **Business Logic** (Tasks/Entities) | Spec Document | `[[__DOCS_DIR__]]/global/map.json` → Module Entry |
36
- | **UI Components** (Pages/Widgets)(仅ui项目) | UI Document + `[[__DOCS_DIR__]]/global/design_tokens.json` | `[[__DOCS_DIR__]]/global/map.json` + Global Rules |
37
- | **Data Schema** (ORM/SQL/Models)(仅data项目) | Data Snapshot | `[[__DOCS_DIR__]]/global/data_snapshot.json` |
38
- | **Config / Infra** (Package.json...) | Tech Stack | `02_tech_stack.md` |
39
-
40
- ---
41
-
42
- ## 3. Anti-Hallucination
43
-
44
- - 代码是文档的下游产物。
45
- - 禁在未读取 Spec 的情况下凭变量名猜测业务逻辑。
46
- - 发现代码与文档不符时: 不擅自修复文档或代码,须暂停并报告不一致性。
47
-
48
- ---
49
-
50
- ## 4. Maintenance Hook
51
-
52
- - **Trigger**: 创建新文件或新模块时。
53
- - **Action**: 须自动更新 `map.json`,建立代码路径与文档路径的映射;映射关系不明确时才询问用户确认。