@dtt_siye/atool 1.2.1 → 1.3.1

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 (97) hide show
  1. package/VERSION +1 -1
  2. package/hooks/session-start +9 -12
  3. package/lib/export-analysis.sh +100 -0
  4. package/lib/install-kiro.sh +11 -6
  5. package/lib/install-skills.sh +16 -0
  6. package/lib/knowledge-graph.sh +490 -83
  7. package/lib/pre-scan.sh +70 -5
  8. package/package.json +1 -1
  9. package/skills/doc-standards-enforcer/SKILL.md +200 -220
  10. package/skills/doc-standards-enforcer/examples/valid-document-example.md +5 -5
  11. package/skills/doc-standards-enforcer/references/101-standards-summary.md +17 -17
  12. package/skills/project-analyze/SKILL.md +157 -124
  13. package/skills/project-analyze/phases/{phase0-discovery.md → archive/phase0-discovery.md} +6 -2
  14. package/skills/project-analyze/phases/{phase1-inventory.md → archive/phase1-inventory.md} +10 -0
  15. package/skills/project-analyze/phases/{phase2-deep-analysis.md → archive/phase2-deep-analysis.md} +20 -0
  16. package/skills/project-analyze/phases/{phase3-knowledge-graph.md → archive/phase3-knowledge-graph.md} +31 -0
  17. package/skills/project-analyze/phases/{phase3a-multi-dimensional.md → archive/phase3a-multi-dimensional.md} +13 -0
  18. package/skills/project-analyze/phases/{phase5-synthesis.md → archive/phase5-synthesis.md} +20 -0
  19. package/skills/project-analyze/phases/phase1-setup.md +182 -0
  20. package/skills/project-analyze/phases/phase2-understand.md +114 -0
  21. package/skills/project-analyze/phases/phase2.5-refine.md +284 -0
  22. package/skills/project-analyze/phases/phase3-graph.md +77 -0
  23. package/skills/project-analyze/phases/phase4-synthesize.md +241 -0
  24. package/skills/project-analyze/phases/phase5-export.md +207 -0
  25. package/skills/project-analyze/prompts/{deep-analysis-agent.md → archive/deep-analysis-agent.md} +14 -1
  26. package/skills/project-analyze/prompts/understand-agent.md +424 -0
  27. package/skills/project-analyze/rules/android.md +61 -260
  28. package/skills/project-analyze/rules/devops.md +61 -421
  29. package/skills/project-analyze/rules/generic.md +53 -221
  30. package/skills/project-analyze/rules/go.md +60 -275
  31. package/skills/project-analyze/rules/harmony.md +64 -237
  32. package/skills/project-analyze/rules/java.md +47 -485
  33. package/skills/project-analyze/rules/mobile-flutter.md +57 -292
  34. package/skills/project-analyze/rules/mobile-react-native.md +65 -262
  35. package/skills/project-analyze/rules/mobile-swift.md +58 -303
  36. package/skills/project-analyze/rules/python.md +50 -296
  37. package/skills/project-analyze/rules/rust-tauri.md +51 -217
  38. package/skills/project-analyze/rules/rust.md +50 -274
  39. package/skills/project-analyze/rules/web-nextjs.md +61 -335
  40. package/skills/project-analyze/rules/web-react.md +50 -272
  41. package/skills/project-analyze/rules/web-vue.md +58 -352
  42. package/skills/project-analyze/rules/web.md +55 -347
  43. package/skills/requirements-writer/README.md +1 -1
  44. package/skills/requirements-writer/SKILL.md +423 -282
  45. package/skills/requirements-writer/examples/prd-outline-example.md +5 -5
  46. package/skills/requirements-writer/templates/module-prd-template.md +15 -15
  47. package/skills/requirements-writer/templates/prd-outline-template.md +3 -3
  48. package/skills/requirements-writer/templates/user-story-template.md +23 -23
  49. package/skills/software-architecture/SKILL.md +318 -17
  50. package/templates/CLAUDE.md.android +17 -0
  51. package/templates/CLAUDE.md.devops +17 -0
  52. package/templates/CLAUDE.md.generic +17 -0
  53. package/templates/CLAUDE.md.go +17 -0
  54. package/templates/CLAUDE.md.harmony +17 -0
  55. package/templates/CLAUDE.md.java +17 -0
  56. package/templates/CLAUDE.md.mobile-flutter +17 -0
  57. package/templates/CLAUDE.md.mobile-react-native +17 -0
  58. package/templates/CLAUDE.md.mobile-swift +17 -0
  59. package/templates/CLAUDE.md.python +17 -0
  60. package/templates/CLAUDE.md.rust +17 -0
  61. package/templates/CLAUDE.md.rust-tauri +17 -0
  62. package/templates/CLAUDE.md.web +17 -0
  63. package/templates/cursor-rules.android.mdc +17 -0
  64. package/templates/cursor-rules.devops.mdc +17 -0
  65. package/templates/cursor-rules.generic.mdc +17 -0
  66. package/templates/cursor-rules.go.mdc +17 -0
  67. package/templates/cursor-rules.harmony.mdc +17 -0
  68. package/templates/cursor-rules.java.mdc +17 -0
  69. package/templates/cursor-rules.mobile-flutter.mdc +17 -0
  70. package/templates/cursor-rules.mobile-react-native.mdc +17 -0
  71. package/templates/cursor-rules.mobile-swift.mdc +17 -0
  72. package/templates/cursor-rules.python.mdc +17 -0
  73. package/templates/cursor-rules.rust-tauri.mdc +17 -0
  74. package/templates/cursor-rules.rust.mdc +17 -0
  75. package/templates/cursor-rules.web.mdc +17 -0
  76. package/templates/kiro-steering.android.md +6 -0
  77. package/templates/kiro-steering.devops.md +6 -0
  78. package/templates/kiro-steering.generic.md +6 -0
  79. package/templates/kiro-steering.go.md +6 -0
  80. package/templates/kiro-steering.harmony.md +6 -0
  81. package/templates/kiro-steering.java.md +6 -0
  82. package/templates/kiro-steering.mobile-flutter.md +6 -0
  83. package/templates/kiro-steering.mobile-react-native.md +6 -0
  84. package/templates/kiro-steering.mobile-swift.md +6 -0
  85. package/templates/kiro-steering.python.md +6 -0
  86. package/templates/kiro-steering.rust-tauri.md +6 -0
  87. package/templates/kiro-steering.rust.md +6 -0
  88. package/templates/kiro-steering.web.md +6 -0
  89. package/templates/shared/hard-rules.md +21 -0
  90. /package/skills/project-analyze/phases/{phase0.5-prescan.md → archive/phase0.5-prescan.md} +0 -0
  91. /package/skills/project-analyze/phases/{phase2a-l4-analysis.md → archive/phase2a-l4-analysis.md} +0 -0
  92. /package/skills/project-analyze/phases/{phase2b-l5-analysis.md → archive/phase2b-l5-analysis.md} +0 -0
  93. /package/skills/project-analyze/phases/{phase4-code-quality.md → archive/phase4-code-quality.md} +0 -0
  94. /package/skills/project-analyze/phases/{phase6-validation.md → archive/phase6-validation.md} +0 -0
  95. /package/skills/project-analyze/prompts/{code-review-agent.md → archive/code-review-agent.md} +0 -0
  96. /package/skills/project-analyze/prompts/{inventory-agent.md → archive/inventory-agent.md} +0 -0
  97. /package/skills/project-analyze/prompts/{l4-analysis-agent.md → archive/l4-analysis-agent.md} +0 -0
@@ -5,7 +5,7 @@ status: approved
5
5
  owner: PM
6
6
  last_updated: 2026-01-09
7
7
  related_docs:
8
- - ../100-standards/101-documentation-standards.md
8
+ - ../100-governance/101-documentation-standards.md
9
9
  ---
10
10
 
11
11
  # Documentation Standards Quick Reference
@@ -40,15 +40,15 @@ Quick reference guide for the Inspection Agent project's documentation standards
40
40
  ### Hundreds-Based Directories
41
41
  ```
42
42
  docs/
43
- ├── 100-standards/ # Project standards
44
- ├── 200-product/ # Product documentation
43
+ ├── 100-governance/ # Project standards & governance
44
+ ├── 200-business/ # Business & product documentation
45
45
  ├── 300-requirements/ # Requirements
46
- ├── 400-design/ # Design documents
47
- ├── 500-data/ # Data documentation
48
- ├── 600-architecture/ # Architecture
49
- ├── 700-engineering/ # Engineering standards
50
- ├── 800-operations/ # Operations
51
- ├── 900-project-mgmt/ # Project management
46
+ ├── 400-architecture/ # Architecture
47
+ ├── 500-design/ # Design documents (UI/UX)
48
+ ├── 600-data/ # Data documentation
49
+ ├── 800-engineering/ # Engineering standards
50
+ ├── 900-operations/ # Operations
51
+ ├── 950-project/ # Project management
52
52
  └── 990-archive/ # Historical archives
53
53
  ```
54
54
 
@@ -58,13 +58,13 @@ docs/
58
58
  ```
59
59
 
60
60
  ### Examples
61
- - ✓ `100-standards/`
62
- - ✓ `200-product/`
61
+ - ✓ `100-governance/`
62
+ - ✓ `200-business/`
63
63
  - ✓ `300-requirements/`
64
64
 
65
65
  ### File-Directory Matching
66
66
  Files should match their directory's hundreds digit:
67
- - Files in `200-product/` start with `2` (e.g., `201-*.md`)
67
+ - Files in `200-business/` start with `2` (e.g., `201-*.md`)
68
68
  - Files in `300-requirements/` start with `3` (e.g., `301-*.md`)
69
69
 
70
70
  ## Frontmatter Template
@@ -78,7 +78,7 @@ status: draft
78
78
  owner: Your Name
79
79
  last_updated: 2026-01-09
80
80
  related_docs:
81
- - docs/100-standards/101-documentation-standards.md
81
+ - docs/100-governance/101-documentation-standards.md
82
82
  ---
83
83
  ```
84
84
 
@@ -172,7 +172,7 @@ Table tracking all changes.
172
172
  Use relative paths from repository root:
173
173
 
174
174
  ```markdown
175
- See docs/500-data/502-data-dictionary.md (field definitions)
175
+ See docs/600-data/502-data-dictionary.md (field definitions)
176
176
  ```
177
177
 
178
178
  ### Rules
@@ -181,12 +181,12 @@ See docs/500-data/502-data-dictionary.md (field definitions)
181
181
  - **Clear descriptions**: Add parenthetical context
182
182
 
183
183
  ### Good Examples
184
- - ✓ `See docs/500-data/502-data-dictionary.md (field definitions)`
184
+ - ✓ `See docs/600-data/502-data-dictionary.md (field definitions)`
185
185
  - ✓ `As defined in docs/100-standards/106-engineering-standards.md (tech stack)`
186
186
  - ✓ `Refer to docs/300-requirements/310-prd.md (business requirements)`
187
187
 
188
188
  ### Bad Examples
189
- - ✗ `See docs/500-data/502-data-dictionary.md` (no context)
189
+ - ✗ `See docs/600-data/502-data-dictionary.md` (no context)
190
190
  - ✗ `Check the data dictionary` (ambiguous)
191
191
 
192
192
  ## Common Mistakes
@@ -270,7 +270,7 @@ status: draft
270
270
  owner: Your Name
271
271
  last_updated: 2026-01-09
272
272
  related_docs:
273
- - docs/100-standards/101-documentation-standards.md
273
+ - docs/100-governance/101-documentation-standards.md
274
274
  ---
275
275
 
276
276
  ## Purpose
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: project-analyze
3
3
  description: "Deep project analysis v5.0 — 7-phase pipeline with five-dimensional analysis framework, 14 node types, 24 edge types, 5-level granularity zooming, interactive visualization (Cytoscape.js), and query system. 5 depth levels (L1-L5): Discovery → Pre-Scan → Inventory → Deep Analysis → Knowledge Graph → Multi-Dimensional Analysis → Code Quality → Document Synthesis → Validation. Checkpoint/resume, incremental docs, large-module decomposition. Zero-KT standard, Chinese output. 触发:分析项目/生成文档/analyze project/generate docs/project analysis"
4
- version: 5.0.0
4
+ version: 5.2.0
5
5
  ---
6
6
 
7
7
  # Project Analyzer v5.0
@@ -40,83 +40,113 @@ version: 5.0.0
40
40
  | L4 | 函数级分析:L3 + 逐函数调用链追踪 + 性能热点识别 + 安全审计点 + 数据流路径 | 质量审查、性能优化 |
41
41
  | L5 | 跨模块行为推断:L4 + 时序图 + 状态机 + 异常路径追踪 + 数据血缘 | 架构重构、完整技术文档 |
42
42
 
43
- **选择规则**:用户未指定 → 默认 L2;<50 文件 → 建议提升到 L3L3/L4/L5 对所有项目规模可用(通过多批次执行)。**L1 特殊**:Phase 0.5 完全替代 Phase 1(0 AI agents,纯 bash 提取)。
43
+ **选择规则**:用户未指定 → 默认 L2;<50 文件 → 建议提升到 L3。**L1-L5 所有深度对任何项目规模均可用**(L3+ 通过多批次执行)。Phase 1 确认时**必须向用户展示全部 L1-L5 五个选项**。**L1 特殊**:Phase 1 pre-scan 完全替代 Phase 2 AI 分析(0 AI agents,纯 bash 提取)。
44
44
 
45
- ---
46
-
47
- ## Pipeline Controller
48
-
49
- ### Execution Flow
45
+ ### AI 调用设计原则
50
46
 
51
- 1. **Detect IDE** set execution_mode (parallel/sequential/compressed)
52
- 2. **Read `analysis-state.json`** (if exists) → determine resume point (see `phases/phase0-discovery.md` 0.5a)
53
- 3. **Execute Phase 0**: Read `phases/phase0-discovery.md` → detect stack, evaluate scale, compute importance, get user confirmation → write `analysis-state.json`
54
- 4. **Execute Phase 0.5 (Pre-Scan)**: Run `source lib/pre-scan.sh && pre_scan_project "$PROJECT_ROOT" "$PRESCAN_DIR"` → pure bash structural extraction → output `.atool-docs/pre-scan/{module-slug}.json` + `manifest.json` → write checkpoint `phase0_5_prescan = "completed"`
55
- 5. Based on Phase 0 + Phase 0.5 pre-scan data → set depth, scale, module list
56
- 6. **For each phase in pipeline order**:
57
- - Check preconditions in `analysis-state.json`
58
- - If not completed:
59
- - **Read `phases/phase{N}-{name}.md`** for detailed instructions
60
- - Execute phase → write checkpoint to `analysis-state.json`
61
- 6. **Phase 6**: Read `phases/phase6-validation.md` → validate all outputs → write summary
47
+ Pipeline AI bash 工具的分工遵循核心原则:**确定性操作用 bash,语义理解用 AI**。
62
48
 
63
- ### Pipeline Order
64
-
65
- ```
66
- Phase 0 → phases/phase0-discovery.md (always)
67
- Phase 0.5→ phases/phase0.5-prescan.md (always, pure bash, no AI)
68
- Phase 1 → phases/phase1-inventory.md (always; L1 depth: skip, use Phase 0.5 data)
69
- Phase 2 → phases/phase2-deep-analysis.md (skip if Kiro)
70
- Phase 2a → phases/phase2a-l4-analysis.md (only if depth >= L4, skip if Kiro)
71
- Phase 2b → phases/phase2b-l5-analysis.md (only if depth >= L5, skip if Kiro)
72
- Phase 3 → phases/phase3-knowledge-graph.md (always, main agent only)
73
- Phase 3a → phases/phase3a-multi-dimensional.md (always, Kiro: structure only)
74
- Phase 4 → phases/phase4-code-quality.md (skip if Kiro)
75
- Phase 5 → phases/phase5-synthesis.md (always)
76
- Phase 6 → phases/phase6-validation.md (always)
77
- ```
49
+ | Phase | AI 调用 | 方式 | 原因 |
50
+ |-------|---------|------|------|
51
+ | Phase 1 SETUP | 否 | bash 脚本 | 栈检测、文件计数、重要性排序、pre-scan 语法提取 = 确定性操作 |
52
+ | Phase 2 UNDERSTAND | 是 | Sub-agent × N | 核心分析 — 业务逻辑、设计意图、Zero-KT 三层文档 |
53
+ | Phase 3 GRAPH | **否** | bash `knowledge-graph.sh` + `multi-dimensional-analysis.sh` | 图组装 + 五维分析 = 确定性算法 |
54
+ | Phase 4 SYNTHESIZE | 是 | 主 agent + Sub-agent | 项目级文档综合 + Mermaid 图表 + 质量报告 |
55
+ | Phase 5 EXPORT | 否 | bash 脚本 | 文件整理 + 项目注册 = 确定性操作 |
78
56
 
79
- ### IMPORTANT RULE
57
+ **Pre-scan 效率基石**:Phase 1 的 pre-scan 一次 bash 提取(~5秒/150文件)→ Phase 2 所有 AI sub-agent 复用数据。跳过 pre-scan → 每个 AI sub-agent 都要重新全量读取源文件(5-10x token 浪费)。
80
58
 
81
- **Before executing ANY phase, you MUST read the corresponding phase file from `phases/phase{N}-{name}.md`. Do not execute from memory. Each phase file contains critical details not duplicated here.**
59
+ ### 深度等级 AI 使用差异
82
60
 
83
- ### Phase 0.5: Pre-Scan (纯 Bash,无 AI)
61
+ | 维度 | L1 | L2 | L3 | L4 | L5 |
62
+ |------|-----|-----|-----|-----|-----|
63
+ | 执行 Phase | 1→3→5 | 1→2→3→4→5 | 同 L2 | 同 L2(Phase 2 追加 L4 指令) | 同 L2(Phase 2 追加 L5 指令) |
64
+ | AI Sub-agent | **0 个** | Phase 2 + Phase 4 | 同 L2 | 同 L2(更深指令)| 同 L2(最深指令)|
65
+ | 源文件 AI 读取 | 无 | 分层策略* | 同 L2,提取更多细节 | +函数体定向行范围 | +跨模块推断(不重读源文件) |
66
+ | Sub-agent Prompt | N/A | 标准模板 | +L3 追加指令(签名/模式/ADR)| +L4 追加指令(调用链/性能/安全)| +L5 追加指令(时序图/状态机/数据血缘) |
67
+ | 独特产出 | overview + modules(lite) | +quality + diagrams | +实现细节+设计决策 | +调用链分析+性能报告 | +时序图+状态机+数据血缘 |
68
+ | Token 估算 | ~10K | ~50K | ~100K | ~200K | ~350K |
84
69
 
85
- **目标**:使用 grep/awk/jq 秒级提取所有语法元数据,消除 AI 重复读取。
70
+ \* 分层策略:小文件(<100行)用 pre-scan 数据不重读;中文件(100-500行)全文;大文件(>500行)仅读关键行范围
86
71
 
87
- **执行**:
88
- 1. 读取 `analysis-state.json` 获取模块列表和技术栈
89
- 2. 执行 `source lib/pre-scan.sh && pre_scan_project "$PROJECT_ROOT" "$PRESCAN_DIR"`
90
- 3. 输出 `.atool-docs/pre-scan/{module-slug}.json` + `manifest.json`
91
- 4. 写入检查点 `phase0_5_prescan = "completed"`
72
+ **递增原则**:每级深度在上一级基础上通过 sub-agent prompt 追加指令增加分析维度,不重新读取已分析过的文件。L1 完全零 AI(Phase 1 bash 替代 Phase 2),是最快但最浅的扫描。
92
73
 
93
- **支持语言**:Python, Java/Kotlin, TypeScript/JavaScript/Vue/Svelte, Go, Rust, 通用 fallback
94
-
95
- **性能目标**:152 文件/10 模块 < 10 秒(vs AI Phase 1 的 2-4 分钟)
74
+ ---
96
75
 
97
- **增量扫描**:比对文件 MD5 hash,仅重新扫描变更文件。
76
+ ## Pipeline Controller
98
77
 
99
- **降级**:pre-scan 失败时,Phase 1 自动回退到全量 AI 提取(v5.0 行为)。
78
+ ### 6-Phase 架构
100
79
 
101
- 详细指令:`phases/phase0.5-prescan.md`
80
+ ```
81
+ Phase 1: SETUP → phases/phase1-setup.md (bash only, no AI, ~30秒)
82
+ Phase 2: UNDERSTAND → phases/phase2-understand.md (AI sub-agents ≤5并行)
83
+ Phase 2.5: REFINE → phases/phase2.5-refine.md (AI sub-agents ≤5并行,串联 requirements-writer + software-architecture Refine Mode)
84
+ Phase 3: GRAPH → phases/phase3-graph.md (bash only, no AI, ~30秒)
85
+ Phase 4: SYNTHESIZE → phases/phase4-synthesize.md (main agent, 聚合模式)
86
+ Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文件)
87
+ ```
102
88
 
103
- ### Sub-Agent Prompts
89
+ ### 执行规则(硬性)
90
+
91
+ 1. **每个 Phase 开始前必须读取对应的 phase 文件**,不可从记忆执行
92
+ 2. **bash Phase(1/3/5)必须通过 Bash 工具调用**,禁止 AI 模拟执行或用 Write 工具写脚本代替
93
+ 3. **每个 Phase 完成后立即写 `.atool-docs/analysis-state.json`**
94
+ 4. **Phase 2 并发上限 5 个 sub-agent**,超出部分按 importance 降序分批排队
95
+ 5. **Phase 3 bash 调用失败时**:在 state.json 记录 `phase3_graph: "failed"`,继续 Phase 4(跳过图谱相关文档,Phase 4 检查此标记)
96
+ 6. **断点续传**:先读 state.json,跳过 `status: "completed"` 的 phase
97
+ 7. Phase 2.5 在 Phase 2 完成后自动执行;`--skip-refine` 可跳过;`--refine-threshold N` 自定义门禁阈值(默认 70)
98
+
99
+ ### 状态管理(简化版)
100
+
101
+ `analysis-state.json` 最小结构:
102
+ ```jsonc
103
+ {
104
+ "version": "5.2.0",
105
+ "project": "...",
106
+ "detected_stack": "java-spring",
107
+ "depth": "L2",
108
+ "phases": {
109
+ "phase1_setup": "completed",
110
+ "phase2_understand": "in_progress",
111
+ "phase2_5_refine": "pending",
112
+ "phase3_graph": "pending",
113
+ "phase4_synthesize": "pending",
114
+ "phase5_export": "pending"
115
+ },
116
+ "module_status": {
117
+ "{slug}": {
118
+ "phase2": "completed|in_progress|pending",
119
+ "assigned_to": "sub-agent-id"
120
+ }
121
+ },
122
+ "refine_status": {
123
+ "{slug}": {
124
+ "prd_refine": "completed|in_progress|pending",
125
+ "prd_coverage": 82,
126
+ "prd_gate": "passed|failed",
127
+ "arch_refine": "completed|in_progress|pending|skipped",
128
+ "arch_gate": "passed|failed",
129
+ "conventions_loaded": "java-conventions",
130
+ "degraded": false,
131
+ "degraded_reason": null
132
+ }
133
+ },
134
+ "deliverable_status": {
135
+ "project_deliverable_md": "pending",
136
+ "export_single_file": "pending"
137
+ },
138
+ "errors": []
139
+ }
140
+ ```
104
141
 
105
- When dispatching sub-agents for phases 1, 2, 2a, 4:
106
- - Read the prompt template from `prompts/{name}-agent.md`
107
- - Fill in module-specific variables (module name, inventory data, rules content, etc.)
108
- - Dispatch with the filled prompt
142
+ status 枚举值:`"pending"` | `"in_progress"` | `"completed"` | `"failed"` | `"skipped"`
109
143
 
110
- | Phase | Prompt Template | Variables to Fill |
111
- |-------|----------------|-------------------|
112
- | Phase 1 | `prompts/inventory-agent.md` | file_list, module-slug |
113
- | Phase 2 | `prompts/deep-analysis-agent.md` | module_name, inventory_json_content, rules_content, stack, project_name, module_list, depth_specific_instructions |
114
- | Phase 2a | `prompts/l4-analysis-agent.md` | module_name, analysis_json_content, inventory_json_content, file_list |
115
- | Phase 4 | `prompts/code-review-agent.md` | module_name, inventory_json, relevant_graph_subtree, multi_dimensional_context, file_list |
144
+ ### HARD GATE bash Phase 执行验证
116
145
 
117
- ### Batch Dispatch Rule (Hard Limit)
146
+ Phase 1、3、5 执行前在对话中明确声明:
147
+ > "正在通过 Bash 工具执行 Phase N..."
118
148
 
119
- **Maximum 5 concurrent sub-agents at all times.** When modules > 5, dispatch in batches of 5 by importance descending order. Wait for all agents in current batch to complete before dispatching next batch.
149
+ 执行后检查输出文件是否存在以确认成功。不得跳过此验证。
120
150
 
121
151
  ---
122
152
 
@@ -139,23 +169,17 @@ else:
139
169
 
140
170
  | Phase | Claude | Cursor | Kiro | Notes |
141
171
  |-------|--------|--------|------|-------|
142
- | Phase 0 | full | full | full | All IDEs |
143
- | Phase 0.5 | full (bash) | full (bash) | full (bash) | Pure shell, no AI |
144
- | Phase 1 | parallel | sequential | compressed (file counts only) | |
145
- | Phase 2 | parallel | sequential | **skip** | Kiro uses inventory directly |
146
- | Phase 2a | parallel | sequential | **skip** | L4 function-level |
147
- | Phase 2b | parallel+aggregate | sequential | **skip** | L5 cross-module |
148
- | Phase 3 | main agent | main agent | main agent | No sub-agents |
149
- | Phase 3a | 5 dimensions | 5 dimensions | structure only | v5.0 |
150
- | Phase 4 | parallel | sequential | **skip** | |
151
- | Phase 5 | full | full | L1 quality from inventory | |
152
- | Phase 6 | full | full | full | All IDEs |
172
+ | Phase 1 SETUP | full (bash) | full (bash) | full (bash) | Pure shell, no AI |
173
+ | Phase 2 UNDERSTAND | parallel sub-agents | sequential | **skip** | Kiro uses pre-scan data directly |
174
+ | Phase 3 GRAPH | main agent (bash) | main agent (bash) | main agent (bash) | No sub-agents |
175
+ | Phase 4 SYNTHESIZE | parallel sub-agents | sequential | L1 quality from pre-scan | |
176
+ | Phase 5 EXPORT | full (bash) | full (bash) | full (bash) | All IDEs |
153
177
 
154
178
  ### Kiro Compressed Mode
155
- Phase 0.5: full pre-scan (bash, same as all IDEs). Phase 1: file counts + import/export counts only (no signatures). Phase 5: L1 quality docs from pre-scan inventory. No CODE_REVIEW.md.
179
+ Phase 1: full pre-scan (bash, same as all IDEs). Phase 2: skip (use pre-scan data). Phase 4: L1 quality docs from pre-scan data only. No quality/ reports.
156
180
 
157
181
  ### Cursor Sequential Mode
158
- Modules processed in importance order, one at a time. Progress line per module. Phase 3 and 6 execute normally.
182
+ Modules processed in importance order, one at a time. Progress line per module. Phase 3 and 5 execute normally.
159
183
 
160
184
  ---
161
185
 
@@ -173,13 +197,13 @@ write analysis-state.json
173
197
  ### Resume Flow
174
198
  1. Read `.atool-docs/analysis-state.json`
175
199
  2. If no state file → full analysis
176
- 3. If `phase0_5_prescan != "completed"` → execute Phase 0.5
200
+ 3. If `phases.phase1_setup != "completed"` → execute Phase 1
177
201
  4. Detect stale modules (file hash mismatch) → mark for re-analysis
178
202
  5. Determine resume point from checkpoint
179
203
  6. Execute pending phases, skip completed, rerun stale
180
204
  7. Update final state
181
205
 
182
- Detailed resume logic: see `phases/phase0-discovery.md` section 0.5a.
206
+ Detailed resume logic: see `phases/phase1-setup.md`.
183
207
 
184
208
  ### Incremental Document Recovery
185
209
  When resuming Phase 5, incrementally update already-generated documents using `<!-- aTool-module-start:{slug} -->` markers. Only regenerate changed modules.
@@ -188,54 +212,62 @@ When resuming Phase 5, incrementally update already-generated documents using `<
188
212
 
189
213
  ## Output File Summary
190
214
 
191
- ### Final Deliverables (project directory)
192
-
193
- | File | Condition |
194
- |------|-----------|
195
- | `README.md` | always |
196
- | `COMPONENT.md` | always |
197
- | `CODE_REVIEW.md` | L2/L3/L4/L5 |
198
- | `UI_STYLE.md` | UI projects only |
199
- | `CLAUDE.md` | append project rules |
200
- | `.cursor/rules/atool-conventions.mdc` | always |
201
- | `.kiro/steering/atool-conventions.md` | always |
202
- | `docs/` (~15 files) | L2/L3/L4/L5 |
203
-
204
- ### Intermediate Artifacts (.atool-docs/)
205
-
206
- | File | Phase |
207
- |------|-------|
208
- | `analysis-state.json` | Phase 0 |
209
- | `pre-scan/{module-slug}.json` | Phase 0.5 |
210
- | `pre-scan/manifest.json` | Phase 0.5 |
211
- | `inventory/{module-slug}.json` | Phase 1 |
212
- | `modules/{module-slug}/MODULE-DOC.md` | Phase 2 |
213
- | `modules/{module-slug}/analysis.json` | Phase 2 |
214
- | `modules/{module-slug}/references.json` | Phase 2 |
215
- | `modules/{module-slug}/l4-analysis.json` | Phase 2a (L4+) |
216
- | `modules/{module-slug}/l5-analysis.json` | Phase 2b (L5) |
217
- | `cross-module-behavior.json` | Phase 2b (L5) |
218
- | `knowledge-graph.json` | Phase 3 |
219
- | `multi-dimensional-analysis.json` | Phase 3a |
220
- | `query-index.json` | Phase 3a |
221
- | `visualization/index.html` | Phase 3a |
222
- | `code-review/{module-slug}.json` | Phase 4 |
223
-
224
- ### Multi-Project Extra Outputs
225
-
226
- | File | Description |
227
- |------|-------------|
228
- | `.atool-docs/discovery.json` | Project discovery record |
229
- | `.atool-docs/summaries/{name}/summary.md` | Sub-project summary |
230
- | `.atool-docs/cross-project-analysis.md` | Cross-project relations |
215
+ ### 用户交付物(`atool-analysis/`)— 统一入口
216
+
217
+ | 路径 | 内容 | 生成阶段 |
218
+ |------|------|---------|
219
+ | `atool-analysis/manifest.json` | 元数据:分析时间/版本/栈 | Phase 5 |
220
+ | **overview/** | | |
221
+ | `atool-analysis/overview/summary.md` | 业务摘要(非技术人员友好)| Phase 4 |
222
+ | `atool-analysis/overview/architecture.md` | 架构说明 + Mermaid 图 + ADR | Phase 4 |
223
+ | `atool-analysis/overview/tech-stack.md` | 技术栈明细 | Phase 4 |
224
+ | `atool-analysis/overview/getting-started.md` | 新人上手指南(Zero-KT)| Phase 4 |
225
+ | **modules/{name}/** | | |
226
+ | `atool-analysis/modules/{name}/README.md` | 模块业务说明(非技术人员友好)| Phase 2 |
227
+ | `atool-analysis/modules/{name}/api.md` | 接口文档(字段级 Schema + 错误码表 + curl 示例)| Phase 2 |
228
+ | `atool-analysis/modules/{name}/data-model.md` | 数据模型(字段约束 + 枚举 + 级联 + ER 图)| Phase 2 |
229
+ | `atool-analysis/modules/{name}/dev-guide.md` | 开发指引(如何扩展/调试)| Phase 2 |
230
+ | `atool-analysis/modules/{name}/prd.md` | 模块级 PRD(按钮级交互定义 + 验收标准)| Phase 2 |
231
+ | `atool-analysis/modules/{name}/test-cases.md` | 测试用例(功能/边界/安全/集成)| Phase 2 |
232
+ | **quality/** | | |
233
+ | `atool-analysis/quality/code-review.md` | 代码质量(+重构优先级矩阵+迁移路线图+代码对比)| Phase 4 |
234
+ | `atool-analysis/quality/tech-debt.md` | 技术债清单 | Phase 4 |
235
+ | `atool-analysis/quality/recommendations.md` | 改进建议(+impact-vs-effort 矩阵)| Phase 4 |
236
+ | `atool-analysis/quality/security-audit.md` | 安全审计(OWASP Top 10 逐项检查)| Phase 4 |
237
+ | `atool-analysis/quality/performance-baseline.md` | 性能基准(延迟/内存/并发估算)| Phase 4 |
238
+ | **project/** | | |
239
+ | `atool-analysis/project/prd.md` | 项目级 PRD(全局用户流 + 功能矩阵 + 路线图)| Phase 4 |
240
+ | `atool-analysis/project/deployment.md` | 部署文档(环境/配置/检查清单/回滚)| Phase 4 |
241
+ | `atool-analysis/project/testing-strategy.md` | 测试策略(金字塔 + 覆盖率 + 自动化)| Phase 4 |
242
+ | `atool-analysis/project/runbook.md` | 运维手册(故障排查 + 监控 + 告警)| Phase 4 |
243
+ | **diagrams/** | | |
244
+ | `atool-analysis/diagrams/architecture.mmd` | Mermaid 整体架构图 | Phase 4 |
245
+ | `atool-analysis/diagrams/module-dependencies.mmd` | 模块依赖图 | Phase 4 |
246
+ | `atool-analysis/diagrams/data-flow.mmd` | 数据流向图 | Phase 4 |
247
+ | **data/** | | |
248
+ | `atool-analysis/data/knowledge-graph.json` | 完整知识图谱(供 aTool Monitor)| Phase 5 |
249
+ | `atool-analysis/data/modules.json` | 模块列表 + 指标 | Phase 5 |
250
+ | `atool-analysis/data/metrics.json` | 质量指标(五维分析)| Phase 5 |
251
+
252
+ ### 机器内部产物(`.atool-docs/`)— 用户无需关心
253
+
254
+ | 路径 | 内容 |
255
+ |------|------|
256
+ | `.atool-docs/analysis-state.json` | Pipeline 状态 |
257
+ | `.atool-docs/pre-scan/*.json` | bash 语法提取(Phase 1)|
258
+ | `.atool-docs/modules/{name}/data.json` | sub-agent 结构化数据(Phase 2)|
259
+ | `.atool-docs/knowledge-graph.json` | 图谱原始数据(Phase 3)|
260
+ | `.atool-docs/multi-dimensional-analysis.json` | 五维分析数据(Phase 3)|
261
+
262
+ **废弃**:不再生成 `docs/101-*.md`、`docs/201-*.md` 等数字命名文件。原 `README.md`、`COMPONENT.md`、`CODE_REVIEW.md` 等项目根目录文件也不再生成(改为 `atool-analysis/` 内对应文件)。
231
263
 
232
264
  ---
233
265
 
234
266
  ## Error Handling
235
267
 
236
268
  - Analysis state file corrupted → warn user, offer fresh start or manual recovery
237
- - Pre-scan failure → graceful degradation: skip Phase 0.5, Phase 1 falls back to full AI extraction (v5.0 behavior)
238
- - Sub-agent fails mid-analysis → mark module as "failed" in state, continue with next module, report in Phase 6
269
+ - Pre-scan failure → graceful degradation: Phase 2 sub-agents 回退到全量 AI 读取源文件
270
+ - Sub-agent fails mid-analysis → mark module as "failed" in state, continue with next module, report in Phase 5 completion summary
239
271
  - Source file read error → skip file, mark in inventory as "unreadable", continue
240
272
  - Disk space insufficient → warn immediately, offer partial save
241
273
  - Resume with changed state version → auto-migrate v3.0/v4.0 → v5.0 (add missing fields with defaults)
@@ -250,7 +282,7 @@ When resuming Phase 5, incrementally update already-generated documents using `<
250
282
  - Output summary report upon completion (modules, files, deliverables)
251
283
  - Each module document must be immediately readable (Zero-KT standard)
252
284
  - Existing CLAUDE.md: only append project rules section
253
- - docs/: only update aTool-numbered files (101, 201-801), never modify user-created docs
285
+ - `atool-analysis/`: only update files generated by aTool analysis, never modify user-created docs
254
286
  - All inferred content marked `[推断]`
255
287
  - UI wireframes: UI projects only (web/mobile)
256
288
  - **Never fabricate**: only record what is visible in code
@@ -261,10 +293,11 @@ When resuming Phase 5, incrementally update already-generated documents using `<
261
293
 
262
294
  | Collaborating Skill | Trigger Condition | Interaction |
263
295
  |---------------------|-------------------|-------------|
264
- | code-review | Phase 4 eight-dimension review | References rules/ files |
265
- | software-architecture | Phase 3a structural layer violation rate >30% | Suggest running |
266
- | {stack}-conventions | Phase 2 deep analysis | Load stack-level conventions |
267
- | doc-standards-enforcer | Phase 5 document generation | Validate frontmatter format |
296
+ | code-review | Phase 4 quality report generation | References rules/ files |
297
+ | software-architecture | Phase 2.5 Refine Mode 调用;Phase 4 聚合时 layer_violations/total_edges > 30% 建议深度审查 | 精炼模式 + 建议运行 |
298
+ | {stack}-conventions | Phase 2 module analysis | Load stack-level conventions |
299
+ | doc-standards-enforcer | Phase 4 document generation | Validate frontmatter format |
268
300
  | smart-dispatch | LARGE/XLARGE projects | Batch parallel by module |
269
301
  | project-query | Need to query analysis results | User manually invokes /project-query |
270
- | clarify-before-build | Before Phase 0 user confirmation | Requirement clarification (auto-injected) |
302
+ | requirements-writer | Phase 2.5 Refine Mode 调用;Phase 4 PRD 降级模块存在时建议补全 | 精炼模式 + 建议运行 |
303
+ | clarify-before-build | Before Phase 1 user confirmation | Requirement clarification (auto-injected) |
@@ -21,7 +21,7 @@
21
21
 
22
22
  统计源文件数(排除 node_modules, build, .git, vendor, target, dist),按规模选择策略:
23
23
 
24
- | 规模 | 文件数 | 建议深度 | 覆盖率 | 最大 Agent | 多批次 | 说明 |
24
+ | 规模 | 文件数 | 默认深度 | 覆盖率 | 最大 Agent | 多批次 | 说明 |
25
25
  |------|--------|---------|--------|-----------|--------|------|
26
26
  | TINY | 1-50 | L3 | 100% | 5 | 否 | 小项目全量深度分析 |
27
27
  | SMALL | 51-200 | L2 | 100% | 5 | L3+ 自动分批 | 中小项目,L3+ 按模块分批 |
@@ -30,7 +30,9 @@
30
30
  | XLARGE | 1501-5000 | L2 | Top 50% | 5 | L3+ 始终分批 | 核心 L3+,重要 L2,其余 L1 |
31
31
  | MEGA | 5001+ | L2 | 用户选择 | 5 | Wave 策略 | 多波策略,Wave 深度递增 |
32
32
 
33
- **深度覆盖规则**:建议深度为推荐值,用户可在 Phase 0.6 覆盖为任意深度。LARGE/XLARGE 的覆盖率仅影响 L4/L5 深度的模块范围,所有模块至少 L2。
33
+ > **所有项目规模均可使用 L1-L5 任意深度**。上表"默认深度"仅用于回车确认时的默认值,Phase 0.6 必须**始终向用户展示全部 L1-L5 五个选项**。
34
+
35
+ **深度覆盖规则**:上表"默认深度"仅作为回车确认默认值。**用户可在 Phase 0.6 选择 L1-L5 任意深度**。LARGE/XLARGE 的覆盖率仅影响 L4/L5 深度的模块范围,所有模块至少 L2。
34
36
 
35
37
  ### 0.2a 批量派发规则(硬性限制)
36
38
 
@@ -226,6 +228,8 @@ else (中断的分析):
226
228
 
227
229
  ### 0.6 用户确认(必须)
228
230
 
231
+ > **硬性规则:必须向用户展示全部 L1-L5 五个深度选项,不得省略或隐藏任何等级。** 即使项目规模很小,L4 和 L5 也必须出现在选项列表中,让用户做出知情选择。
232
+
229
233
  向用户展示分析计划并获得确认:
230
234
 
231
235
  ```
@@ -10,6 +10,16 @@ Phase 1 现在基于 Phase 0.5 pre-scan 数据工作。AI agent 接收 pre-scan
10
10
 
11
11
  - Phase 0 已完成(`analysis-state.json` 存在,模块列表和 importance 排序已确定)
12
12
 
13
+ ### 前置检查(硬性 — 禁止跳过)
14
+
15
+ 1. 读取 `analysis-state.json`,确认 `phase0_5_prescan.status == "completed"`
16
+ 2. 如果未完成 → **停止 Phase 1**,先执行 Phase 0.5:
17
+ ```bash
18
+ source lib/pre-scan.sh && pre_scan_project "$PROJECT_ROOT" "$PRESCAN_DIR"
19
+ ```
20
+ 3. 读取 `.atool-docs/pre-scan/{module-slug}.json`,确认数据存在
21
+ 4. 如果某个模块的 pre-scan 数据不存在 → 标记 warning,该模块回退到全量 AI 提取
22
+
13
23
  ## 输入数据
14
24
 
15
25
  1. Pre-scan JSON(来自 Phase 0.5)
@@ -6,6 +6,13 @@
6
6
 
7
7
  - Phase 1 已完成(所有 `inventory/{module-slug}.json` 已写入)
8
8
 
9
+ ### 前置检查(硬性)
10
+
11
+ 1. 读取 `analysis-state.json`,确认 `phase1_inventory.status == "completed"`
12
+ 2. 如果未完成 → **停止**,先完成 Phase 1
13
+ 3. 读取 `.atool-docs/inventory/{module-slug}.json`,确认数据存在
14
+ 4. **L1 深度例外**:Phase 1 被跳过(Phase 0.5 替代),此时直接使用 pre-scan 数据
15
+
9
16
  ## 输入数据
10
17
 
11
18
  - Phase 0.5 Pre-Scan 数据:每个文件的 imports/exports/classes/functions/decorators/api_endpoints 已由 grep+awk+jq 提取,AI agent 直接引用,无需重新读取
@@ -15,6 +22,17 @@
15
22
  - 中文件(100-500行):读取全文
16
23
  - 大文件(>500行):仅读取 pre-scan 标记的关键行范围
17
24
 
25
+ ### Pre-scan 降级规则
26
+
27
+ 当 pre-scan 数据或 inventory 数据缺失时(Phase 0.5/1 未执行),sub-agent prompt 必须降级:
28
+
29
+ 1. **pre-scan 数据存在** → 正常三层策略
30
+ 2. **pre-scan 数据缺失** → 全量读取降级:
31
+ - `small_files_list`/`medium_files_list`/`large_files_list` → 全部归入 medium(需全文读取)
32
+ - `prescan_summary_content` → 替换为 `"⚠️ Pre-scan data NOT available. Read ALL source files to extract structural information."`
33
+ - `inventory_semantic_content` → 替换为 `"⚠️ Inventory data NOT available. Extract business context from source files."`
34
+ - 在 sub-agent prompt 末尾追加:`"Pre-scan was skipped. You MUST read all source files first to extract structural info (imports, classes, functions), THEN perform deep analysis."`
35
+
18
36
  ## 详细步骤
19
37
 
20
38
  ### 2.0a 超大模块拆分策略
@@ -84,6 +102,8 @@ else: 按文件扩展名分组
84
102
 
85
103
  ### 2.2b 深度级别指令(追加到 sub-agent prompt 末尾)
86
104
 
105
+ > **硬性规则:必须将对应深度的完整指令内联展开到 `{depth_specific_instructions}` 变量中。禁止用 "执行 L3 分析" 等抽象标签替代具体指令 — sub-agent 不知道 "L3" 意味着什么。**
106
+
87
107
  根据当前分析深度级别,在 sub-agent prompt 模板末尾追加以下指令:
88
108
 
89
109
  #### L1 指令
@@ -9,12 +9,32 @@
9
9
  - Phase 2 已完成(所有 `MODULE-DOC.md` + `analysis.json` 已写入)
10
10
  - Phase 2a(如 depth ≥ L4)和 Phase 2b(如 depth ≥ L5)应已完成
11
11
 
12
+ ### 输入数据检查(硬性 — 禁止跳过)
13
+
14
+ Phase 3 不读取源文件,只处理 JSON 中间产物。开始前必须确认:
15
+
16
+ 1. 读取 `analysis-state.json`,确认 `phase2_deep_analysis.status == "completed"`
17
+ 2. 检查 `.atool-docs/inventory/*.json` 是否存在(Phase 1 输出)
18
+ 3. 检查 `.atool-docs/modules/*/analysis.json` 是否存在(Phase 2 输出)
19
+ 4. 如果以上文件缺失 → **停止 Phase 3**,先完成对应的 Phase 1 或 Phase 2
20
+ 5. **禁止**在缺失中间产物时回退到读取源文件 — 这会导致全量重复读取,违背 pipeline 设计
21
+ 6. 如果 `lib/knowledge-graph.sh` 不存在 → 标记 warning,跳过自动图谱构建,AI 手动从 JSON 数据构建
22
+
12
23
  ## 详细步骤
13
24
 
14
25
  ### 知识图谱构建 (v5.0: 6 步管线)
15
26
 
16
27
  v5.0 使用 `lib/knowledge-graph.sh` 的函数进行构建。**不要手动实现以下算法,全部通过库函数调用。**
17
28
 
29
+ > ⚠️ **硬性指令:必须通过 Bash 工具执行以下命令构建知识图谱。**
30
+ > **禁止用 AI/LLM 直接生成 knowledge-graph.json 内容。**
31
+ > AI 生成的 JSON 格式(如 `modules`/`dependency_edges`)与 `generate-visualization.sh` 期望的 `nodes`/`edges` 格式不兼容,会导致后续可视化、查询和多维分析全部失败。
32
+ >
33
+ > ```bash
34
+ > source lib/knowledge-graph.sh
35
+ > assemble_enhanced_graph "$DOCS_DIR" "$PROJECT_ROOT"
36
+ > ```
37
+
18
38
  1. **节点组装**: 调用 `assemble_enhanced_graph()` — 从 `inventory/*.json` 和 `analysis.json` 读取,支持 14 种节点类型(module, component, function, store, data_entity, api_endpoint, route, config, service, repository, middleware, event, test_suite, layer)
19
39
  2. **边组装**: `assemble_enhanced_graph()` 内部调用 `compute_edge_weights()` — 计算 `base_weight × frequency × confidence`,支持 24 种边类型
20
40
  3. **层确认**: 结合启发式(Phase 0.3a)+ LLM 验证(Phase 2 sub-agent 结果)
@@ -58,6 +78,17 @@ Instability(M) = Ce / (Ca + Ce) // 0=稳定(被依赖), 1=不稳定(依赖
58
78
 
59
79
  写入 `.atool-docs/knowledge-graph.json`:
60
80
 
81
+ **格式校验(硬性 — assemble_enhanced_graph() 完成后必须验证)**:
82
+
83
+ ```bash
84
+ jq '.nodes | length' .atool-docs/knowledge-graph.json # 必须 > 0
85
+ jq '.edges | type' .atool-docs/knowledge-graph.json # 必须是 "array"
86
+ jq '.layers | type' .atool-docs/knowledge-graph.json # 必须是 "object"
87
+ jq '.indexes | type' .atool-docs/knowledge-graph.json # 必须是 "object"
88
+ ```
89
+
90
+ 如果 `nodes` 数组长度为 0 → 说明 `inventory/` 或 `analysis.json` 数据缺失,回到输入数据检查步骤排查。**不要在此情况下用 AI 补充生成节点** — 应修复上游 Phase。
91
+
61
92
  ```json
62
93
  {
63
94
  "version": "5.0",
@@ -6,6 +6,19 @@
6
6
 
7
7
  ## 详细步骤
8
8
 
9
+ > ⚠️ **硬性指令:必须通过 Bash 工具执行以下命令运行五维分析。**
10
+ > **禁止用 AI/LLM 直接生成 multi-dimensional-analysis.json 内容。**
11
+ > AI 生成的格式与后续查询和可视化工具不兼容。
12
+ >
13
+ > ```bash
14
+ > source lib/multi-dimensional-analysis.sh
15
+ > analyze_structural "$DOCS_DIR"
16
+ > analyze_behavioral "$DOCS_DIR"
17
+ > analyze_data "$DOCS_DIR"
18
+ > analyze_quality "$DOCS_DIR"
19
+ > analyze_semantic "$DOCS_DIR"
20
+ > ```
21
+
9
22
  使用 `lib/multi-dimensional-analysis.sh` 执行 5 个独立分析维度:
10
23
 
11
24
  ### 3a.1 结构分析