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.
- package/CHANGELOG.md +55 -1
- package/README.md +93 -14
- package/README.zh-CN.md +92 -14
- package/dist/index.js +53 -39
- package/dist/templates/en/briefs/_base.md +53 -13
- package/dist/templates/en/briefs/_modules.md +31 -4
- package/dist/templates/en/docs/global/error_memory.json +40 -0
- package/dist/templates/en/docs/global/map.json +46 -90
- package/dist/templates/en/{rules/04_cli_tools.md → docs/global/references/cli_reference.md} +6 -13
- package/dist/templates/en/{rules/02_tech_stack.md → docs/global/tech_stack.md} +7 -18
- package/dist/templates/en/docs/global/vision.md +1 -1
- package/dist/templates/en/docs/prompts/audit.md +80 -94
- package/dist/templates/en/docs/prompts/code.md +99 -89
- package/dist/templates/en/docs/prompts/edit.md +61 -51
- package/dist/templates/en/docs/prompts/fix.md +59 -43
- package/dist/templates/en/docs/prompts/help.md +23 -31
- package/dist/templates/en/docs/prompts/inherit.md +97 -117
- package/dist/templates/en/docs/prompts/map.md +48 -69
- package/dist/templates/en/docs/prompts/plan.md +141 -240
- package/dist/templates/en/docs/prompts/recover.md +19 -34
- package/dist/templates/en/docs/prompts/ref.md +43 -138
- package/dist/templates/en/docs/prompts/remove.md +63 -110
- package/dist/templates/en/docs/prompts/revise.md +71 -106
- package/dist/templates/en/docs/prompts/scope.md +78 -117
- package/dist/templates/en/docs/prompts/script.md +102 -0
- package/dist/templates/en/docs/prompts/start.md +98 -132
- package/dist/templates/en/docs/prompts/ui.md +113 -0
- package/dist/templates/en/docs/shared/ui-redlines.md +7 -0
- package/dist/templates/en/docs/templates/spec.template.md +1 -1
- package/dist/templates/en/docs/templates/ui.template.md +8 -8
- package/dist/templates/en/rules/00_system.md +268 -117
- package/dist/templates/en/rules/90_custom_rules.md +3 -1
- package/dist/templates/en/skills/archi-data-sync/SKILL.md +37 -23
- package/dist/templates/en/skills/archi-decompose-roadmap/SKILL.md +138 -240
- package/dist/templates/en/skills/archi-design-patterns/SKILL.md +6 -1
- package/dist/templates/en/skills/archi-feature-relations/SKILL.md +10 -6
- package/dist/templates/en/skills/archi-interview-protocol/SKILL.md +2 -2
- package/dist/templates/en/skills/archi-plan-options/SKILL.md +77 -301
- package/dist/templates/en/skills/archi-silent-audit/SKILL.md +24 -25
- package/dist/templates/en/skills/archi-ui-wireframe/SKILL.md +175 -305
- package/dist/templates/icon.svg +16 -0
- package/dist/templates/zh/briefs/_base.md +56 -17
- package/dist/templates/zh/briefs/_modules.md +28 -1
- package/dist/templates/zh/docs/global/error_memory.json +40 -0
- package/dist/templates/zh/docs/global/map.json +39 -109
- package/dist/templates/zh/{rules/04_cli_tools.md → docs/global/references/cli_reference.md} +0 -7
- package/dist/templates/zh/{rules/02_tech_stack.md → docs/global/tech_stack.md} +9 -20
- package/dist/templates/zh/docs/global/vision.md +1 -1
- package/dist/templates/zh/docs/prompts/audit.md +43 -57
- package/dist/templates/zh/docs/prompts/code.md +66 -56
- package/dist/templates/zh/docs/prompts/edit.md +52 -42
- package/dist/templates/zh/docs/prompts/fix.md +39 -29
- package/dist/templates/zh/docs/prompts/help.md +13 -21
- package/dist/templates/zh/docs/prompts/inherit.md +67 -86
- package/dist/templates/zh/docs/prompts/map.md +28 -50
- package/dist/templates/zh/docs/prompts/plan.md +100 -199
- package/dist/templates/zh/docs/prompts/recover.md +9 -24
- package/dist/templates/zh/docs/prompts/ref.md +11 -106
- package/dist/templates/zh/docs/prompts/remove.md +39 -74
- package/dist/templates/zh/docs/prompts/revise.md +47 -88
- package/dist/templates/zh/docs/prompts/scope.md +52 -91
- package/dist/templates/zh/docs/prompts/script.md +102 -0
- package/dist/templates/zh/docs/prompts/start.md +75 -110
- package/dist/templates/zh/docs/prompts/ui.md +113 -0
- package/dist/templates/zh/docs/shared/ui-redlines.md +7 -0
- package/dist/templates/zh/docs/templates/spec.template.md +1 -1
- package/dist/templates/zh/docs/templates/ui.template.md +8 -8
- package/dist/templates/zh/rules/00_system.md +252 -131
- package/dist/templates/zh/rules/90_custom_rules.md +2 -1
- package/dist/templates/zh/skills/archi-data-sync/SKILL.md +27 -13
- package/dist/templates/zh/skills/archi-decompose-roadmap/SKILL.md +133 -235
- package/dist/templates/zh/skills/archi-design-patterns/SKILL.md +6 -1
- package/dist/templates/zh/skills/archi-feature-relations/SKILL.md +6 -2
- package/dist/templates/zh/skills/archi-interview-protocol/SKILL.md +2 -2
- package/dist/templates/zh/skills/archi-plan-options/SKILL.md +77 -301
- package/dist/templates/zh/skills/archi-silent-audit/SKILL.md +4 -5
- package/dist/templates/zh/skills/archi-ui-wireframe/SKILL.md +174 -301
- package/package.json +3 -1
- package/dist/templates/en/rules/01_workflow.md +0 -93
- package/dist/templates/en/rules/03_data_governance.md +0 -102
- package/dist/templates/en/rules/99_context_glue.md +0 -53
- package/dist/templates/zh/rules/01_workflow.md +0 -94
- package/dist/templates/zh/rules/03_data_governance.md +0 -133
- package/dist/templates/zh/rules/99_context_glue.md +0 -53
|
@@ -1,102 +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 | Type | Read When | Write When |
|
|
15
|
-
|:---|:---|:---|:---|
|
|
16
|
-
| `roadmap.json` | Roadmap | `/archi.plan`, `/archi.code` start | `/archi.start` creates; AI direct edit or `npx archi task` updates status |
|
|
17
|
-
| `map.json` | Architecture Map | When touching code (via context_glue) | `/archi.plan` Step 3 (global sync); `/archi.inherit` Step 3.6; `/archi.map` |
|
|
18
|
-
| `dictionary.json` | Glossary | When generating variable names | `/archi.plan` Step 3; step_5 auto-appends after code/fix |
|
|
19
|
-
| `design_tokens.json` | Design Tokens [?UI] | When generating UI code | `/archi.start` creates; update on design changes |
|
|
20
|
-
| `data_snapshot.json` | Data Snapshot [?Data] | `/archi.plan` Q1 design; `/archi.code` implementation | Plan phase designs Schema; Code phase syncs actual changes |
|
|
21
|
-
| `error_codes.json` | Error Contracts | When writing error handling | `/archi.plan` Step 3; step_5 auto-appends after code/fix |
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 2. General Rules
|
|
26
|
-
|
|
27
|
-
### 2.1 Format Constraints
|
|
28
|
-
|
|
29
|
-
- **JSON Only**: The single source of truth for global data is `.json` files. `.md` views are auto-generated by `npx archi render`; prohibited from editing `.md` views directly.
|
|
30
|
-
- **Schema Stability**: Managed in two tiers:
|
|
31
|
-
- **Tier 1 (Strict)**: `roadmap.json`, `plan.json` — CLI rendering/commands depend on these directly; structure is validated by Zod Schema; prohibited from changing fields arbitrarily.
|
|
32
|
-
- **Tier 2 (Flexible)**: `dictionary.json`, `error_codes.json`, `data_snapshot.json`, `design_tokens.json`, `map.json` — Only top-level keys are validated. If existing fields cannot adequately describe what needs to be recorded, you may freely extend fields (add new keys or new properties in array items) without modifying the CLI.
|
|
33
|
-
- **Valid JSON**: Must ensure valid JSON after writing (no trailing commas, no comments).
|
|
34
|
-
|
|
35
|
-
### 2.2 Read/Write Discipline
|
|
36
|
-
|
|
37
|
-
| Scenario | Rule |
|
|
38
|
-
|:---|:---|
|
|
39
|
-
| Need to consult data | Read `.json` file; prohibited from reading `.md` view (may be stale) |
|
|
40
|
-
| Need to update Roadmap task status | Prefer `npx archi task <ID> --status <s>`; batch updates may edit JSON directly |
|
|
41
|
-
| Need to update other data files | AI directly edits `.json` file |
|
|
42
|
-
| After updates | Run `npx archi render` to regenerate `.md` views |
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## 3. File-Specific Rules
|
|
47
|
-
|
|
48
|
-
### `roadmap.json`
|
|
49
|
-
|
|
50
|
-
- **Structure**: `phases[] → tasks[]`, each task must have `id`, `title`, `status`, `deps`.
|
|
51
|
-
- **Status values**: `pending` | `active` | `done` | `blocked`.
|
|
52
|
-
- **Dependency integrity**: IDs in `deps` must exist in tasks.
|
|
53
|
-
- **Slug rule**: `slug` is used for tasks folder naming, format `Snake_Case`.
|
|
54
|
-
|
|
55
|
-
### `map.json`
|
|
56
|
-
|
|
57
|
-
- **Directory Mapping**: Must reflect the real physical file tree.
|
|
58
|
-
- **Logical Topology**: Must register each Task Module's responsibility.
|
|
59
|
-
- **Feature Relations** (field `featureRelations`): Records linkage relationships between aggregator tasks and their sources. Each entry: `{ aggregator, sources, evidence, checkNote }`. Written by AI during `/archi.plan` (when planning an aggregator task) or `/archi.inherit` (during reverse scanning); no manual maintenance needed.
|
|
60
|
-
- **Self-Correction**: If code references violate the hierarchy defined in topology, must report error and stop generation.
|
|
61
|
-
- **Extensible**: If existing fields cannot adequately describe the project architecture, you may add fields to items (e.g. `tags`, `owner`) or add new top-level keys.
|
|
62
|
-
|
|
63
|
-
### `dictionary.json`
|
|
64
|
-
|
|
65
|
-
- **Naming Authority**: This file is the supreme law of naming.
|
|
66
|
-
- **Boundary**: Only register **project business domain** content. Architext framework concepts (scripts, scaffold, roadmap, plan, etc.) are prohibited from registration.
|
|
67
|
-
- **entities**: Must consult `entities[].codeName` before generating variable names; prohibited from using words in `forbiddenSynonyms`.
|
|
68
|
-
- **verbs**: Business action naming must consult `verbs[].codeName` for project-wide verb consistency.
|
|
69
|
-
- **utilities**: Shared tools (e.g. logger, AppError, fetchClient) must be registered; AI must use registered utilities instead of raw APIs (refer to `replaces` field).
|
|
70
|
-
- **components** [?UI]: Must search existing components before creating new ones; prioritize reuse.
|
|
71
|
-
- **Extensible**: If existing fields cannot adequately describe a term/tool, you may add fields to array items (e.g. `tags`, `scope`, `deprecated`) or add new top-level arrays (e.g. `enums`, `constants`).
|
|
72
|
-
|
|
73
|
-
### `design_tokens.json` [?UI]
|
|
74
|
-
|
|
75
|
-
- **Token Only**: Styles must strictly use Tokens; prohibited from hardcoding Hex/px/rem.
|
|
76
|
-
- **Dark Mode**: Must define both `light` and `dark` values.
|
|
77
|
-
- **Extensible**: If existing Token structure cannot cover project needs (e.g. `motion`, `breakpoints`, `z-index`), you may add new properties freely.
|
|
78
|
-
|
|
79
|
-
### `data_snapshot.json` [?Data]
|
|
80
|
-
|
|
81
|
-
- **Structure**: `models[]` (name, fields, types, constraints) + `relationships[]` (inter-model relations: 1:1/1:N/M:N/self-ref).
|
|
82
|
-
- **Design First**: Plan phase must define model structure and field types; prohibited from writing "TBD"; must be precise to field names and types.
|
|
83
|
-
- **Sync Back**: After Code phase completion, must sync actual changes back to this file.
|
|
84
|
-
- **Extensible**: If existing fields cannot adequately describe data models (e.g. need to record `indexes`, `triggers`, `seedData`), you may add fields to model items or at the top level.
|
|
85
|
-
|
|
86
|
-
### `error_codes.json`
|
|
87
|
-
|
|
88
|
-
- **Boundary**: Only register **project business domain** errors. Framework infrastructure errors (scripts/validate, dev-up, dev-reset, etc.) are handled by scripts themselves via exit code + stderr; prohibited from registration here.
|
|
89
|
-
- **Structure**: `protocolMapping [?API]` (status code → behavior mapping) + `businessErrors` (business error registry).
|
|
90
|
-
- **Code Format**: `ERR_[MODULE]_[REASON]` (e.g. `ERR_AUTH_INVALID_TOKEN`).
|
|
91
|
-
- **statusCode**: Fill per project type (HTTP status / Exit code / leave empty).
|
|
92
|
-
- **Design Before Code**: Must register error codes here before writing error handling code, including `message` and `recovery`.
|
|
93
|
-
- **Extensible**: If existing fields cannot adequately describe error info (e.g. need to record `severity`, `retryable`, `httpBody`), you may add fields to items freely.
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## 4. Plan JSON (`plan.json`)
|
|
98
|
-
|
|
99
|
-
- **Location**: `tasks/<ID>_<Slug>/plan.json`
|
|
100
|
-
- **Checkbox Updates**: AI sets `done` to `true` directly after completing steps during `/archi.code`.
|
|
101
|
-
- **Append Rule**: `/archi.edit` appends new Phases while preserving completed history.
|
|
102
|
-
- **Verification**: Run `npx archi plan <ID>` to verify completion after finishing.
|
|
@@ -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,94 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Command Dispatcher & Workflow Controller. Handles /archi.start, /archi.plan, and mode transitions between Discussion, Planning, and Implementation.
|
|
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
|
-
> | 执行 Terminal Gate 命令前未确认工作目录(见 `04_cli_tools.md`) | 停止 → 先通过 Working Directory Gate |
|
|
18
|
-
|
|
19
|
-
## 1. Explicit Command Routing
|
|
20
|
-
|
|
21
|
-
**Trigger**: 用户输入以 `/archi.` 开头时,立即加载对应协议模板。
|
|
22
|
-
|
|
23
|
-
| Command | Target Template | Action |
|
|
24
|
-
|:---|:---|:---|
|
|
25
|
-
| `/archi.start` | `[[__DOCS_DIR__]]/prompts/start.md` | Load CPO → Project Initiation |
|
|
26
|
-
| `/archi.inherit` | `[[__DOCS_DIR__]]/prompts/inherit.md` | Load Legacy Analyst → Reverse Engineering |
|
|
27
|
-
| `/archi.scope` | `[[__DOCS_DIR__]]/prompts/scope.md` | Load Strategist → Requirement Decomposition |
|
|
28
|
-
| `/archi.plan` | `[[__DOCS_DIR__]]/prompts/plan.md` | Load Planner → Deep Interview |
|
|
29
|
-
| `/archi.edit` | `[[__DOCS_DIR__]]/prompts/edit.md` | Load Editor → Spec Modification |
|
|
30
|
-
| `/archi.revise` | `[[__DOCS_DIR__]]/prompts/revise.md` | Load Chief Architect → Global Revision |
|
|
31
|
-
| `/archi.code` | `[[__DOCS_DIR__]]/prompts/code.md` | Load Developer → Coding & Auditing |
|
|
32
|
-
| `/archi.audit` | `[[__DOCS_DIR__]]/prompts/audit.md` | Load Chief Auditor → Deep Code Audit |
|
|
33
|
-
| `/archi.fix` | `[[__DOCS_DIR__]]/prompts/fix.md` | Load Debugger → Diagnosis |
|
|
34
|
-
| `/archi.map` | `[[__DOCS_DIR__]]/prompts/map.md` | Load Surveyor → Map Refresh |
|
|
35
|
-
| `/archi.remove` | `[[__DOCS_DIR__]]/prompts/remove.md` | Load Surgeon → Task Decommission |
|
|
36
|
-
| `/archi.help` | `[[__DOCS_DIR__]]/prompts/help.md` | Load Manual → Display Guide |
|
|
37
|
-
|
|
38
|
-
> **Protocol Load Gate** (禁跳过,三步须按序完成):
|
|
39
|
-
> 1. **Read** 目标 `.md` 全文 → 文件不存在时停止,输出: `协议文件未找到,中止执行`
|
|
40
|
-
> 2. **Override** — 可覆盖: `<system_role>`, `<thinking_process>`, `<communication_style>`。
|
|
41
|
-
> 不可覆盖: `<core_philosophy>`, `<critical_protocols>`, `<architecture_governance>`。
|
|
42
|
-
> 3. **Execute** `<step_1>` — 禁在步骤 1 完成前执行任何协议内容
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## 2. Natural Language Passthrough
|
|
47
|
-
|
|
48
|
-
**Trigger**: 用户输入非 `/archi.` 指令文本。
|
|
49
|
-
|
|
50
|
-
### 2.1 Intent Detection
|
|
51
|
-
|
|
52
|
-
**Role**: 智能调度员。检测用户意图,按影响级别决定直接执行或引导到命令。
|
|
53
|
-
|
|
54
|
-
**判定标准**: 该修改是否影响已文档化的行为(spec.md 的接口/逻辑/场景、ui.md 的交互/结构、plan.json 的实施步骤)?
|
|
55
|
-
|
|
56
|
-
| 意图类型 | 处理 |
|
|
57
|
-
|:---|:---|
|
|
58
|
-
| 纯对话 / 代码阅读 / 架构讨论 | ✅ 直接回答,利用基底规则增强 |
|
|
59
|
-
| 琐碎修改(typo/注释/格式/日志) | ✅ 直接执行 |
|
|
60
|
-
| 行为变更(逻辑/接口/类型/UI) | 🔀 引导 → `/archi.edit` + `/archi.code` |
|
|
61
|
-
| Bug 修复 | 🔀 引导 → `/archi.fix` |
|
|
62
|
-
| 新增功能 | 🔀 引导 → `/archi.scope` 或 `/archi.plan` |
|
|
63
|
-
| 大规模重构 | 🔀 引导 → `/archi.revise` |
|
|
64
|
-
|
|
65
|
-
### 2.2 Guided Dispatch (引导规范)
|
|
66
|
-
|
|
67
|
-
🔀 引导时须:
|
|
68
|
-
1. 一句话说明为什么需走命令(关联到哪个文档会受影响)
|
|
69
|
-
2. 推荐具体命令 + 参数
|
|
70
|
-
3. 询问用户是否开始
|
|
71
|
-
|
|
72
|
-
> ⛔ **禁**: 先改代码再事后建议走命令。违反此规则须撤销变更并重新引导。
|
|
73
|
-
|
|
74
|
-
### 2.3 未纳管代码
|
|
75
|
-
|
|
76
|
-
修改对象未在 `map.json` 中注册、无对应 Task:
|
|
77
|
-
- **STOP & ASK** — 告知用户该模块未纳管
|
|
78
|
-
- 建议 `/archi.inherit` 或 `/archi.scope` 纳入管理
|
|
79
|
-
- 禁直接修改未纳管代码,须等待用户提供文档路径或完成纳管后再操作
|
|
80
|
-
|
|
81
|
-
### 2.4 基底规则
|
|
82
|
-
|
|
83
|
-
所有场景(含引导和纯对话)均依赖以下基底规则:
|
|
84
|
-
|
|
85
|
-
| Layer | File | Role |
|
|
86
|
-
|:---|:---|:---|
|
|
87
|
-
| Core | `00_system.md` | 身份设定,核心原则 |
|
|
88
|
-
| Tech | `02_tech_stack.md` | 技术红线,编码规范 |
|
|
89
|
-
| Custom | `90_custom_rules.md` | 团队特殊约束 |
|
|
90
|
-
| Context | `99_context_glue.md` | 自动关联上下文文档 |
|
|
91
|
-
|
|
92
|
-
**End of Dispatcher.**
|
|
93
|
-
|
|
94
|
-
> CLI 强制执行规则见 `04_cli_tools.md`。
|
|
@@ -1,133 +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` | 路线图 | `/archi.plan`, `/archi.code` 开始时 | `/archi.start` 创建; AI 直接编辑或 `npx archi task` 更新状态 |
|
|
17
|
-
| `map.json` | 架构地图 | 触碰代码时 (via context_glue) | `/archi.plan` Step 3 (全局同步); `/archi.inherit` Step 3.6; `/archi.map` |
|
|
18
|
-
| `dictionary.json` | 术语字典 | 生成变量名/命名时 | `/archi.plan` Step 3; code/fix 后 step_5 自动追加 |
|
|
19
|
-
| `design_tokens.json` | 设计令牌(仅ui项目) | 生成 UI 代码时 | `/archi.start` 创建; 设计变更时更新 |
|
|
20
|
-
| `data_snapshot.json` | 数据快照(仅data项目) | `/archi.plan` Q1 设计; `/archi.code` 实现时 | Plan 阶段设计 Schema; Code 阶段同步实际变更 |
|
|
21
|
-
| `error_codes.json` | 业务错误码 | 编写错误处理时 | `/archi.plan` Step 3; code/fix 后 step_5 自动追加 |
|
|
22
|
-
| `api_snapshot.json` | API 端点(仅api项目) | 实现/对接 HTTP 端点时 | `/archi.plan` Step 3 注册端点; Code 阶段同步实际路径 |
|
|
23
|
-
| `env_registry.json` | 环境变量(仅api项目) | 引入新配置项时 | Code 阶段引入新 env var 后立即追加 |
|
|
24
|
-
| `command_api.json` | 命令签名(仅cli项目) | 实现/修改 CLI 命令时 | `/archi.plan` Step 3 注册命令; Code 阶段同步实际签名 |
|
|
25
|
-
| `public_api.json` | 公共导出(仅lib项目) | 新增/修改导出 API 时 | `/archi.plan` Step 3 注册导出; Code 阶段同步实际签名 |
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## 2. 通用规则
|
|
30
|
-
|
|
31
|
-
### 2.1 格式约束
|
|
32
|
-
|
|
33
|
-
- **JSON Only**: 全局数据的唯一真理源是 `.json` 文件。`.md` 视图由 `npx archi render` 自动生成,禁直接编辑 `.md` 视图。
|
|
34
|
-
- **Schema Stability**: 分两档管理:
|
|
35
|
-
- **Tier 1 (严格)**: `roadmap.json`, `plan.json` — CLI 渲染/命令直接依赖,结构由 Zod Schema 校验,禁随意变更字段。
|
|
36
|
-
- **Tier 2 (宽松)**: `dictionary.json`, `error_codes.json`, `data_snapshot.json`, `design_tokens.json`, `map.json`, `api_snapshot.json`, `env_registry.json`, `command_api.json`, `public_api.json` — 仅校验顶层 key 存在。若现有字段无法充分描述需记录的内容,可自行扩展字段(添加新 key 或在数组 item 中添加新属性),无需修改 CLI。
|
|
37
|
-
- **Valid JSON**: 写入后须保证合法 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 与其来源的联动关系。每条结构为 `{ aggregator, sources, evidence, checkNote }`;由 AI 在 `/archi.plan`(规划聚合型 Task 时)或 `/archi.inherit`(逆向扫描时)写入,无需用户手动维护。
|
|
64
|
-
- **自我校正**: 若代码引用违反拓扑定义的层级关系,须报错并停止生成。
|
|
65
|
-
- **可扩展**: 若现有字段不足以描述项目架构,可在 item 中自行添加字段(如 `tags`、`owner`),或添加新顶层 key。
|
|
66
|
-
|
|
67
|
-
### `dictionary.json`
|
|
68
|
-
|
|
69
|
-
- **命名权威**: 本文件是命名的最高法律。
|
|
70
|
-
- **Boundary**: 仅注册**项目业务域**内容。Architext 框架自身概念(scripts、scaffold、roadmap、plan 等)禁注册。
|
|
71
|
-
- **entities**: 生成变量名前须查阅 `entities[].codeName`;禁使用 `forbiddenSynonyms` 中的词。
|
|
72
|
-
- **verbs**: 业务动作命名须查阅 `verbs[].codeName`,保持全项目动词一致。
|
|
73
|
-
- **utilities**: 封装的共享工具(如 logger、AppError、fetchClient)须注册;AI 须用已注册工具替代原始 API(参照 `replaces` 字段)。
|
|
74
|
-
- **components** (仅ui项目): 创建新组件前须搜索现有组件,优先复用。
|
|
75
|
-
- **可扩展**: 若现有字段不足以描述某个术语/工具,可在对应数组 item 中自行添加字段(如 `tags`、`scope`、`deprecated`),也可添加新顶层数组(如 `enums`、`constants`)。
|
|
76
|
-
|
|
77
|
-
### `design_tokens.json` (仅ui项目)
|
|
78
|
-
|
|
79
|
-
- **Token Only**: 样式严格使用 Token;禁硬编码 Hex/px/rem。
|
|
80
|
-
- **Dark Mode**: 须同时定义 `light` 和 `dark` 值。
|
|
81
|
-
- **可扩展**: 若现有 Token 结构不足以覆盖项目需求(如 `motion`、`breakpoints`、`z-index`),可自行添加新属性。
|
|
82
|
-
|
|
83
|
-
### `data_snapshot.json` (仅data项目)
|
|
84
|
-
|
|
85
|
-
- **结构**: `models[]`(名称、字段、类型、约束)+ `relationships[]`(模型间关系:1:1/1:N/M:N/self-ref)。
|
|
86
|
-
- **Design First**: Plan 阶段须定义模型结构和字段类型,禁写 "TBD",须精确到字段名与类型。
|
|
87
|
-
- **Sync Back**: Code 阶段完成后,须将实际变更同步回此文件。
|
|
88
|
-
- **可扩展**: 若现有字段不足以描述数据模型(如需记录 `indexes`、`triggers`、`seedData`),可在 model item 或顶层自行添加字段。
|
|
89
|
-
|
|
90
|
-
### `error_codes.json`
|
|
91
|
-
|
|
92
|
-
- **Boundary**: 仅注册**项目业务域**错误。框架基础设施(scripts/validate、dev-up、dev-reset 等)的错误由脚本自身 exit code + stderr 处理,禁注册到此文件。
|
|
93
|
-
- **结构**: `businessErrors`(业务错误注册表)。HTTP 协议状态码映射见 `api_snapshot.json`。
|
|
94
|
-
- **Code Format**: `ERR_[MODULE]_[REASON]` (如 `ERR_AUTH_INVALID_TOKEN`)。
|
|
95
|
-
- **statusCode**: 按项目类型填写(HTTP status / Exit code / 留空)。
|
|
96
|
-
- **Design Before Code**: 编写错误处理代码前须先在此注册错误码,含 `message` 和 `recovery`。
|
|
97
|
-
- **可扩展**: 若现有字段不足以描述错误信息(如需记录 `severity`、`retryable`),可在 item 中自行添加字段。
|
|
98
|
-
|
|
99
|
-
### `api_snapshot.json` (仅api项目)
|
|
100
|
-
|
|
101
|
-
- **结构**: `endpoints[]`(端点注册表)+ `protocolMapping[]`(HTTP 状态码→调用方行为映射)。
|
|
102
|
-
- **Register First**: 规划端点前须先在此注册,禁实现未登记的端点。
|
|
103
|
-
- **owner**: 每个端点须标注归属 Task ID,便于追踪变更来源。
|
|
104
|
-
- **可扩展**: 可在 endpoint item 中追加 `tags`、`deprecated`、`version` 等字段。
|
|
105
|
-
|
|
106
|
-
### `env_registry.json` (仅api项目)
|
|
107
|
-
|
|
108
|
-
- **Register on Introduce**: 代码中每引入一个新的 `process.env.X` 或等价配置读取,须立即在此追加记录。
|
|
109
|
-
- **required**: 必填项标 `true`;有合理默认值的标 `false` 并填写 `default`。
|
|
110
|
-
- **example**: 须提供示例值,禁留空(帮助新成员快速配置环境)。
|
|
111
|
-
- **可扩展**: 可追加 `sensitive`(是否为密钥)、`validValues`(枚举约束)等字段。
|
|
112
|
-
|
|
113
|
-
### `command_api.json` (仅cli项目)
|
|
114
|
-
|
|
115
|
-
- **Register on Introduce**: 每新增或修改 CLI 命令后同步更新此文件。
|
|
116
|
-
- **owner**: 每条命令须标注归属 Task ID。
|
|
117
|
-
- **可扩展**: 可追加 `examples`、`deprecated`、`since` 等字段。
|
|
118
|
-
|
|
119
|
-
### `public_api.json` (仅lib项目)
|
|
120
|
-
|
|
121
|
-
- **Stability First**: 导出 API 一旦标注 `stable`,变更须走 `/archi.edit` 流程,不可随意修改签名。
|
|
122
|
-
- **signature**: 须写完整 TypeScript 签名,禁模糊描述(如"返回用户对象")。
|
|
123
|
-
- **owner**: 每条导出须标注归属 Task ID。
|
|
124
|
-
- **可扩展**: 可追加 `since`、`examples`、`seeAlso` 等字段。
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## 4. Plan JSON (`plan.json`)
|
|
129
|
-
|
|
130
|
-
- **位置**: `tasks/<ID>_<Slug>/plan.json`
|
|
131
|
-
- **Checkbox 更新**: AI 在 `/archi.code` 中完成步骤后直接将 `done` 设为 `true`。
|
|
132
|
-
- **追加规则**: `/archi.edit` 追加新 Phase 时保留已完成历史。
|
|
133
|
-
- **验证**: 完成后运行 `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`,建立代码路径与文档路径的映射;映射关系不明确时才询问用户确认。
|