@dtt_siye/atool 1.3.1 → 1.5.0
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/README.md +97 -214
- package/README.md.atool-backup.20260410_114701 +299 -0
- package/VERSION +1 -1
- package/bin/atool.js +55 -9
- package/hooks/doc-sync-reminder +4 -4
- package/hooks/hooks-cursor.json +20 -0
- package/hooks/hooks.json +21 -1
- package/hooks/pre-commit +191 -0
- package/hooks/prompt-guard +84 -35
- package/hooks/session-start +34 -12
- package/hooks/task-state-tracker +145 -0
- package/install.sh +14 -4
- package/lib/common.sh +36 -23
- package/lib/compute-importance.sh +73 -0
- package/lib/install-cursor.sh +24 -2
- package/lib/install-hooks.sh +64 -0
- package/lib/install-kiro.sh +26 -2
- package/lib/install-skills.sh +5 -2
- package/lib/pre-scan.sh +13 -1
- package/lib/project-init.sh +28 -9
- package/package.json +1 -1
- package/skills/agent-audit/SKILL.md +180 -0
- package/skills/ai-project-architecture/SKILL.md +33 -534
- package/skills/ai-project-architecture/rules/architecture-validation.md +200 -0
- package/skills/ai-project-architecture/rules/compliance-check.md +83 -0
- package/skills/ai-project-architecture/rules/iron-laws.md +188 -0
- package/skills/ai-project-architecture/rules/migration.md +94 -0
- package/skills/ai-project-architecture/rules/refactoring.md +91 -0
- package/skills/ai-project-architecture/rules/testing.md +249 -0
- package/skills/ai-project-architecture/rules/verification.md +111 -0
- package/skills/architecture-guard/SKILL.md +164 -0
- package/skills/architecture-guard/rules/violation-detection.md +90 -0
- package/skills/atool-init/SKILL.md +24 -4
- package/skills/ci-feedback/SKILL.md +165 -0
- package/skills/project-analyze/SKILL.md +129 -19
- package/skills/project-analyze/phases/phase1-setup.md +76 -5
- package/skills/project-analyze/phases/phase2-understand.md +137 -26
- package/skills/project-analyze/phases/phase2.5-refine.md +32 -23
- package/skills/project-analyze/phases/phase3-graph.md +39 -5
- package/skills/project-analyze/phases/phase4-synthesize.md +17 -1
- package/skills/project-analyze/phases/phase5-export.md +42 -4
- package/skills/project-analyze/prompts/understand-agent.md +156 -298
- package/skills/project-analyze/rules/java.md +69 -1
- package/skills/project-query/SKILL.md +91 -200
- package/skills/project-query/rules/aggregate-stats.md +301 -0
- package/skills/project-query/rules/data-lineage.md +228 -0
- package/skills/project-query/rules/impact-analysis.md +218 -0
- package/skills/project-query/rules/neighborhood.md +234 -0
- package/skills/project-query/rules/node-lookup.md +97 -0
- package/skills/project-query/rules/path-query.md +135 -0
- package/skills/software-architecture/SKILL.md +39 -501
- package/skills/software-architecture/rules/concurrency-ha.md +346 -0
- package/skills/software-architecture/rules/ddd.md +450 -0
- package/skills/software-architecture/rules/decision-workflow.md +155 -0
- package/skills/software-architecture/rules/deployment.md +508 -0
- package/skills/software-architecture/rules/styles.md +232 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ci-feedback
|
|
3
|
+
description: "Use after modifying source files to run local build/test and get automated feedback. 在修改源码后使用 — 运行本地构建/测试获取自动化反馈,失败时自动进入调试流程."
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
category: quality
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# CI Feedback — Local Build & Test Automation
|
|
9
|
+
|
|
10
|
+
Automatically runs project build and test commands, parses results, and feeds them back into the AI workflow. Creates a tight feedback loop without requiring CI/CD infrastructure.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
|
|
14
|
+
- After modifying source files (auto-suggested by doc-sync-reminder or task-state-tracker)
|
|
15
|
+
- Before claiming a task complete (invoked by verification-before-completion)
|
|
16
|
+
- When the user says "run the tests" or "check if it builds"
|
|
17
|
+
- When debugging (auto-triggered by systematic-debugging after fix attempts)
|
|
18
|
+
|
|
19
|
+
## How It Works
|
|
20
|
+
|
|
21
|
+
### Step 1: Detect Build Commands
|
|
22
|
+
|
|
23
|
+
Read build/test commands from the project's CLAUDE.md `## Build & Run` section. If not found, auto-detect from project files:
|
|
24
|
+
|
|
25
|
+
| Project File | Build Command | Test Command |
|
|
26
|
+
|-------------|---------------|--------------|
|
|
27
|
+
| `pom.xml` | `mvn compile -q` | `mvn test -q` |
|
|
28
|
+
| `build.gradle` / `build.gradle.kts` | `gradle compileJava` | `gradle test` |
|
|
29
|
+
| `package.json` | `npm run build` | `npm test` |
|
|
30
|
+
| `Cargo.toml` | `cargo build` | `cargo test` |
|
|
31
|
+
| `go.mod` | `go build ./...` | `go test ./...` |
|
|
32
|
+
| `pyproject.toml` / `setup.py` | `python -m compileall .` | `pytest` |
|
|
33
|
+
| `pubspec.yaml` | `flutter build` | `flutter test` |
|
|
34
|
+
| `Makefile` | `make build` | `make test` |
|
|
35
|
+
|
|
36
|
+
### Step 2: Run Build
|
|
37
|
+
|
|
38
|
+
Execute the build command and capture:
|
|
39
|
+
- Exit code (0 = success)
|
|
40
|
+
- stdout (warnings)
|
|
41
|
+
- stderr (errors)
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
Build Result:
|
|
45
|
+
- Status: PASS / FAIL
|
|
46
|
+
- Duration: {time}
|
|
47
|
+
- Warnings: {count} (list if < 10)
|
|
48
|
+
- Errors: {count} (list all)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If build FAILS → go to Step 4 (Auto-debug).
|
|
52
|
+
|
|
53
|
+
### Step 3: Run Tests
|
|
54
|
+
|
|
55
|
+
Execute the test command and capture:
|
|
56
|
+
- Exit code
|
|
57
|
+
- Test summary (passed/failed/skipped)
|
|
58
|
+
- Specific failure details
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
Test Result:
|
|
62
|
+
- Status: PASS / FAIL
|
|
63
|
+
- Tests: {passed} passed, {failed} failed, {skipped} skipped
|
|
64
|
+
- Duration: {time}
|
|
65
|
+
- Failures:
|
|
66
|
+
- {test_name}: {error_message} (file:line)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If tests FAIL → go to Step 4 (Auto-debug).
|
|
70
|
+
|
|
71
|
+
### Step 4: Auto-debug on Failure
|
|
72
|
+
|
|
73
|
+
When build or tests fail:
|
|
74
|
+
|
|
75
|
+
1. **Parse the error output** — extract file paths, line numbers, error messages
|
|
76
|
+
2. **Classify the error**:
|
|
77
|
+
- Compilation error → syntax/type mismatch
|
|
78
|
+
- Test assertion → logic error
|
|
79
|
+
- Missing dependency → configuration error
|
|
80
|
+
- Timeout → performance issue
|
|
81
|
+
3. **Invoke /systematic-debugging workflow**:
|
|
82
|
+
- Identify root cause (NOT symptoms)
|
|
83
|
+
- Propose targeted fix
|
|
84
|
+
- Re-run only the failed tests (if possible)
|
|
85
|
+
4. **Track in task-state.json**:
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"last_build_status": "FAIL",
|
|
89
|
+
"last_build_errors": 2,
|
|
90
|
+
"auto_debug_attempts": 1,
|
|
91
|
+
"pending_actions": ["fix_build_error", "update_docs"]
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Step 5: Update Task State
|
|
96
|
+
|
|
97
|
+
On success, update `.claude/task-state.json`:
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"verification_passed": true,
|
|
101
|
+
"last_build_status": "PASS",
|
|
102
|
+
"last_test_status": "PASS",
|
|
103
|
+
"pending_actions": ["update_docs"]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
On failure, the state tracks retry attempts and remaining errors.
|
|
108
|
+
|
|
109
|
+
## Integration Points
|
|
110
|
+
|
|
111
|
+
### With task-state-tracker
|
|
112
|
+
Reads `.claude/task-state.json` to know which files were modified, then runs targeted tests if the framework supports it.
|
|
113
|
+
|
|
114
|
+
### With verification-before-completion
|
|
115
|
+
`/verification-before-completion` invokes ci-feedback as part of its gate check: "tests pass" is a hard requirement.
|
|
116
|
+
|
|
117
|
+
### With systematic-debugging
|
|
118
|
+
On build/test failure, automatically enters the systematic-debugging workflow rather than blindly retrying.
|
|
119
|
+
|
|
120
|
+
### With architecture-guard
|
|
121
|
+
After a successful build, optionally runs architecture-guard to check for structural violations.
|
|
122
|
+
|
|
123
|
+
## Output Format
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
## CI Feedback Report
|
|
127
|
+
|
|
128
|
+
### Build
|
|
129
|
+
| Metric | Value |
|
|
130
|
+
|--------|-------|
|
|
131
|
+
| Status | PASS |
|
|
132
|
+
| Duration | 3.2s |
|
|
133
|
+
| Warnings | 1 (unused import in UserService.java) |
|
|
134
|
+
|
|
135
|
+
### Tests
|
|
136
|
+
| Metric | Value |
|
|
137
|
+
|--------|-------|
|
|
138
|
+
| Status | PASS |
|
|
139
|
+
| Total | 47 |
|
|
140
|
+
| Passed | 47 |
|
|
141
|
+
| Failed | 0 |
|
|
142
|
+
| Duration | 12.5s |
|
|
143
|
+
|
|
144
|
+
### Summary
|
|
145
|
+
All checks passed. Task state updated.
|
|
146
|
+
Remaining: update docs before completion.
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Retry Strategy
|
|
150
|
+
|
|
151
|
+
When auto-debugging:
|
|
152
|
+
1. Fix the identified root cause
|
|
153
|
+
2. Re-run ONLY the failing tests (if framework supports file-specific tests)
|
|
154
|
+
3. If fix introduces new failures → stop and report to user
|
|
155
|
+
4. Maximum 3 auto-debug cycles before escalating to user
|
|
156
|
+
|
|
157
|
+
## Skill 协作
|
|
158
|
+
|
|
159
|
+
| 协作 Skill | 触发条件 | 交互方式 |
|
|
160
|
+
|-----------|---------|---------|
|
|
161
|
+
| verification-before-completion | Before claiming done | 作为验证步骤执行构建+测试 |
|
|
162
|
+
| systematic-debugging | Build/test failure | 自动进入调试流程 |
|
|
163
|
+
| task-state-tracker | State file available | 读取修改文件列表,更新验证状态 |
|
|
164
|
+
| architecture-guard | Build success | 可选执行架构检查 |
|
|
165
|
+
| {stack}-conventions | Test framework detection | 使用栈级测试命令 |
|
|
@@ -78,10 +78,23 @@ Pipeline 中 AI 与 bash 工具的分工遵循核心原则:**确定性操作
|
|
|
78
78
|
### 6-Phase 架构
|
|
79
79
|
|
|
80
80
|
```
|
|
81
|
-
Phase 1: SETUP → phases/phase1-setup.md (bash
|
|
82
|
-
|
|
81
|
+
Phase 1: SETUP → phases/phase1-setup.md (bash + AI模块聚合, ~30秒)
|
|
82
|
+
├─ 技术栈检测 (bash)
|
|
83
|
+
├─ Pre-scan 语法提取 (bash)
|
|
84
|
+
├─ 模块发现 + 聚合 (AI, rules/{STACK}.md 聚合规则)
|
|
85
|
+
└─ 用户确认分析参数
|
|
86
|
+
|
|
87
|
+
Phase 2: UNDERSTAND → phases/phase2-understand.md (AI sub-agents ≤5并行, 两阶段执行)
|
|
88
|
+
├─ Stage 1: data.json + README.md (结构化提取)
|
|
89
|
+
├─ Stage 1 验证 (bash, data.json 合法性 + README 行数)
|
|
90
|
+
├─ Stage 2: api.md + data-model.md + dev-guide.md + prd.md + test-cases.md
|
|
91
|
+
└─ Stage 2 验证 (bash, 核心文档存在性)
|
|
92
|
+
注: 每个 sub-agent 内部 Stage 1→2 串行, checkpoint 仅在两阶段都验证通过后写入
|
|
93
|
+
|
|
83
94
|
Phase 2.5: REFINE → phases/phase2.5-refine.md (AI sub-agents ≤5并行,串联 requirements-writer + software-architecture Refine Mode)
|
|
84
95
|
Phase 3: GRAPH → phases/phase3-graph.md (bash only, no AI, ~30秒)
|
|
96
|
+
└─ 前置检查: data.json 存在性硬验证, VALID_COUNT=0 时 BLOCKED
|
|
97
|
+
|
|
85
98
|
Phase 4: SYNTHESIZE → phases/phase4-synthesize.md (main agent, 聚合模式)
|
|
86
99
|
Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文件)
|
|
87
100
|
```
|
|
@@ -94,7 +107,10 @@ Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文
|
|
|
94
107
|
4. **Phase 2 并发上限 5 个 sub-agent**,超出部分按 importance 降序分批排队
|
|
95
108
|
5. **Phase 3 bash 调用失败时**:在 state.json 记录 `phase3_graph: "failed"`,继续 Phase 4(跳过图谱相关文档,Phase 4 检查此标记)
|
|
96
109
|
6. **断点续传**:先读 state.json,跳过 `status: "completed"` 的 phase
|
|
97
|
-
7. Phase 2.5
|
|
110
|
+
7. **Phase 2.5 参数识别**(无需 bash 解析,直接在用户消息中匹配):
|
|
111
|
+
- `--skip-refine`:用户消息中包含此字符串 → Phase 2.5 标记为 "skipped",跳过精炼链,直进 Phase 3
|
|
112
|
+
- `--refine-threshold N`:用户消息中包含此模式 → 提取 N 作为 Gate 1/2/3 门禁阈值(默认 70)
|
|
113
|
+
- 例:用户说"分析项目 --skip-refine"→ 立即检测到 --skip-refine 字符串,跳过 Phase 2.5
|
|
98
114
|
|
|
99
115
|
### 状态管理(简化版)
|
|
100
116
|
|
|
@@ -103,7 +119,8 @@ Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文
|
|
|
103
119
|
{
|
|
104
120
|
"version": "5.2.0",
|
|
105
121
|
"project": "...",
|
|
106
|
-
"
|
|
122
|
+
"project_root": "...",
|
|
123
|
+
"stack": "java-spring",
|
|
107
124
|
"depth": "L2",
|
|
108
125
|
"phases": {
|
|
109
126
|
"phase1_setup": "completed",
|
|
@@ -139,7 +156,7 @@ Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文
|
|
|
139
156
|
}
|
|
140
157
|
```
|
|
141
158
|
|
|
142
|
-
status 枚举值:`"pending"` | `"in_progress"` | `"completed"` | `"failed"` | `"skipped"`
|
|
159
|
+
status 枚举值:`"pending"` | `"in_progress"` | `"completed"` | `"failed"` | `"skipped"` | `"blocked"`
|
|
143
160
|
|
|
144
161
|
### HARD GATE — bash Phase 执行验证
|
|
145
162
|
|
|
@@ -186,24 +203,72 @@ Modules processed in importance order, one at a time. Progress line per module.
|
|
|
186
203
|
## State Management & Checkpoint/Resume
|
|
187
204
|
|
|
188
205
|
### Checkpoint Write Timing
|
|
189
|
-
|
|
206
|
+
Phase 2 checkpoint **仅在 Stage 1 + Stage 2 都验证通过后**写入(详见 phase2-understand.md §2.5)。
|
|
207
|
+
Phase 3 checkpoint 在 data.json 前置检查通过且 knowledge-graph.json 生成后写入。
|
|
208
|
+
其他 Phase 完成后立即写入 checkpoint。
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Phase 2 每模块:
|
|
212
|
+
Stage 1 完成 → 验证 data.json → 通过 → Stage 2
|
|
213
|
+
Stage 2 完成 → 验证 5 个核心文档 → 通过 → 写入 checkpoint
|
|
214
|
+
任一阶段失败 → 不写 checkpoint, 标记为 "failed"
|
|
215
|
+
|
|
216
|
+
Phase 3:
|
|
217
|
+
data.json 前置检查失败 → 标记 "blocked", 不继续
|
|
218
|
+
knowledge-graph.json 生成成功 → 标记 "completed"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Resume Flow(断点恢复决策树)
|
|
222
|
+
|
|
223
|
+
**入口**:执行 Phase 1 setup 时自动检测恢复状态
|
|
224
|
+
|
|
190
225
|
```
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
226
|
+
1. 读取 .atool-docs/analysis-state.json(若不存在)
|
|
227
|
+
└─ 启动全新分析(fresh start)
|
|
228
|
+
|
|
229
|
+
2. 存在 state.json
|
|
230
|
+
├─ phases.phase1_setup != "completed"
|
|
231
|
+
│ └─ 执行 Phase 1(重新检测栈 / manifest / importance)
|
|
232
|
+
│
|
|
233
|
+
├─ phases.phase1_setup == "completed"
|
|
234
|
+
│ ├─ 检查 phase2_understand 状态
|
|
235
|
+
│ │ ├─ "pending" → 执行 Phase 2(全部模块)
|
|
236
|
+
│ │ ├─ "in_progress" → 恢复到 Phase 2 中断位置(读 state.module_status,跳过已完成)
|
|
237
|
+
│ │ └─ "completed" → 进入 Phase 2.5
|
|
238
|
+
│ │
|
|
239
|
+
│ ├─ 检查 phase2_5_refine 状态
|
|
240
|
+
│ │ ├─ "pending" / "failed" → 执行 Phase 2.5(全部模块)
|
|
241
|
+
│ │ ├─ "in_progress" → 恢复精炼进度(读 state.refine_status,跳过已通过 Gate 3)
|
|
242
|
+
│ │ └─ "completed" / "skipped" → 进入 Phase 3
|
|
243
|
+
│ │
|
|
244
|
+
│ ├─ 检查 phase3_graph 状态
|
|
245
|
+
│ │ ├─ "pending" → 执行 Phase 3(知识图谱生成)
|
|
246
|
+
│ │ ├─ "blocked" → data.json 缺失, 需回到 Phase 2 重新执行
|
|
247
|
+
│ │ ├─ "in_progress" / "failed" → 重新执行 Phase 3
|
|
248
|
+
│ │ └─ "completed" → 进入 Phase 4
|
|
249
|
+
│ │
|
|
250
|
+
│ ├─ 检查 phase4_synthesize 状态
|
|
251
|
+
│ │ ├─ "pending" → 执行 Phase 4(聚合合成)
|
|
252
|
+
│ │ ├─ "in_progress" / "failed" → 重新执行 Phase 4
|
|
253
|
+
│ │ └─ "completed" → 进入 Phase 5
|
|
254
|
+
│ │
|
|
255
|
+
│ └─ 检查 phase5_export 状态
|
|
256
|
+
│ ├─ "pending" → 执行 Phase 5(最终导出)
|
|
257
|
+
│ ├─ "in_progress" / "failed" → 重新执行 Phase 5
|
|
258
|
+
│ └─ "completed" → 分析完成(可选重新导出)
|
|
195
259
|
```
|
|
196
260
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
261
|
+
**断点恢复的具体判断**(在每个 Phase 入口执行):
|
|
262
|
+
- 若 phase 状态为 "completed" 且无 `--force`,**跳过该 phase**
|
|
263
|
+
- 若 phase 状态为 "in_progress"/"failed",**重新执行该 phase**(覆盖部分输出)
|
|
264
|
+
- 若 phase 状态为 "pending",**首次执行该 phase**
|
|
265
|
+
|
|
266
|
+
**文件变更检测**(Phase 2+ 的可选优化):
|
|
267
|
+
- 计算 project root 下所有源文件的 hash(与 manifest.json 对比)
|
|
268
|
+
- 若有新增/删除/修改的文件,标记对应模块为"需重新分析"
|
|
269
|
+
- 该模块在 Phase 2 中重新派发 sub-agent(即使之前已完成)
|
|
205
270
|
|
|
206
|
-
|
|
271
|
+
详见各 Phase 的前置检查条款(phase1-setup.md → phase5-export.md)
|
|
207
272
|
|
|
208
273
|
### Incremental Document Recovery
|
|
209
274
|
When resuming Phase 5, incrementally update already-generated documents using `<!-- aTool-module-start:{slug} -->` markers. Only regenerate changed modules.
|
|
@@ -274,6 +339,51 @@ When resuming Phase 5, incrementally update already-generated documents using `<
|
|
|
274
339
|
|
|
275
340
|
---
|
|
276
341
|
|
|
342
|
+
## 调试指南(Debug Guide)
|
|
343
|
+
|
|
344
|
+
### 查看当前分析状态
|
|
345
|
+
```bash
|
|
346
|
+
cat .atool-docs/analysis-state.json | jq '.phases'
|
|
347
|
+
# 输出每个 Phase 的状态(completed/in_progress/failed/pending)
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### 强制重新执行某个 Phase
|
|
351
|
+
```bash
|
|
352
|
+
# 删除特定 Phase 的状态
|
|
353
|
+
jq '.phases.{phase_name} = "pending"' .atool-docs/analysis-state.json > .tmp && mv .tmp .atool-docs/analysis-state.json
|
|
354
|
+
|
|
355
|
+
# 示例:重新执行 Phase 2
|
|
356
|
+
jq '.phases.phase2_understand = "pending"' .atool-docs/analysis-state.json > .tmp && mv .tmp .atool-docs/analysis-state.json
|
|
357
|
+
|
|
358
|
+
# 重新触发分析
|
|
359
|
+
# 在对话中说:分析项目 (AI 会检测到 phase2_understand = "pending",重新执行)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### 完全重置分析(回到 Phase 1)
|
|
363
|
+
```bash
|
|
364
|
+
rm -rf .atool-docs/
|
|
365
|
+
# 重新触发分析会从 Phase 1 开始
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### 查看模块分析进度
|
|
369
|
+
```bash
|
|
370
|
+
# 查看每个模块在 Phase 2 的状态
|
|
371
|
+
jq '.module_status' .atool-docs/analysis-state.json
|
|
372
|
+
|
|
373
|
+
# 查看 Phase 2.5 精炼进度
|
|
374
|
+
jq '.refine_status' .atool-docs/analysis-state.json
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
### 诊断常见问题
|
|
378
|
+
| 问题 | 诊断命令 | 解决方案 |
|
|
379
|
+
|------|---------|---------|
|
|
380
|
+
| 没有检测到模块 | `cat .atool-docs/pre-scan/manifest.json \| jq '.modules'` | 检查源文件格式或 detect-stack 规则 |
|
|
381
|
+
| phase3_graph 失败 | `cat .atool-docs/analysis-state.json \| jq '.phases.phase3_graph'` | 运行 `source lib/knowledge-graph.sh; assemble_enhanced_graph` 检查错误 |
|
|
382
|
+
| Sub-agent 无法读文件 | `cat .atool-docs/modules/{name}/data.json` | 检查 Phase 2 初稿是否生成 |
|
|
383
|
+
| 精炼 Gate 失败 | `cat atool-analysis/modules/{name}/prd.md \| wc -l` | PRD 文件小于 30 行,需要扩展初稿 |
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
277
387
|
## Important Notes
|
|
278
388
|
|
|
279
389
|
- Always check `.atool-docs/` before starting; offer incremental update if exists
|
|
@@ -80,7 +80,51 @@
|
|
|
80
80
|
> fi
|
|
81
81
|
> ```
|
|
82
82
|
|
|
83
|
-
### 1.4a
|
|
83
|
+
### 1.4a 模块聚合(关键步骤 — 必须执行)
|
|
84
|
+
|
|
85
|
+
> **背景**:原始发现的模块数量可能过多(如 Maven 多模块项目可能有 50-70 个子模块),需要按 `rules/{STACK}.md` 的聚合规则将子模块聚合为有业务含义的分析单元。
|
|
86
|
+
|
|
87
|
+
**执行方式**:此步骤由 AI 执行(非 bash),因为需要理解模块的业务含义。
|
|
88
|
+
|
|
89
|
+
**聚合流程**:
|
|
90
|
+
|
|
91
|
+
1. 读取 `rules/{STACK}.md` 的「聚合规则」章节
|
|
92
|
+
2. 对 `manifest.json` 中的每个模块,按聚合决策树分类:
|
|
93
|
+
- **业务模块**:保持独立
|
|
94
|
+
- **框架/基础设施模块**:聚合为单个 `framework` 模块
|
|
95
|
+
- **依赖管理模块**(无源码):标记 `skip`
|
|
96
|
+
- **脚手架/模板模块**:标记 `skip`
|
|
97
|
+
3. 生成聚合后的模块列表,每个模块包含:
|
|
98
|
+
- `slug`:模块标识(如 `dtt-module-mall`)
|
|
99
|
+
- `name`:显示名称(如 `商城模块`)
|
|
100
|
+
- `path`:模块根路径
|
|
101
|
+
- `type`:`business` | `framework` | `skip`
|
|
102
|
+
- `sub_modules`:聚合的子模块列表(仅 framework 类型)
|
|
103
|
+
- `importance`:`high` | `medium` | `low`
|
|
104
|
+
4. **写入聚合后的模块列表**到 `analysis-state.json` 的 `modules` 字段
|
|
105
|
+
|
|
106
|
+
> **执行命令(必须通过 Bash 工具)** — 写入聚合结果:
|
|
107
|
+
> ```bash
|
|
108
|
+
> DOCS_DIR="$(pwd)/.atool-docs"
|
|
109
|
+
> # 聚合后的模块列表(AI 生成后通过 jq 写入)
|
|
110
|
+
> # 注意:AGGREGATED_MODULES 变量由 AI 基于聚合规则生成
|
|
111
|
+
> AGGREGATED_MODULES='[
|
|
112
|
+
> {"slug":"dtt-gateway","name":"API网关","path":"dtt-gateway","type":"business","sub_modules":[],"importance":"high"},
|
|
113
|
+
> {"slug":"dtt-framework","name":"框架层","path":"dtt-framework","type":"framework","sub_modules":["dtt-common","dtt-spring-boot-starter-mybatis","dtt-spring-boot-starter-redis"],"importance":"high"},
|
|
114
|
+
> {"slug":"dtt-module-system","name":"系统管理","path":"dtt-module-system","type":"business","sub_modules":[],"importance":"high"}
|
|
115
|
+
> ]'
|
|
116
|
+
> # 上面的 JSON 是示例,实际内容由 AI 根据聚合规则生成
|
|
117
|
+
> # 写入到 manifest.json 的 aggregated_modules 字段
|
|
118
|
+
> jq --argjson modules "$AGGREGATED_MODULES" \
|
|
119
|
+
> '.aggregated_modules = $modules | .aggregated_count = ($modules | length)' \
|
|
120
|
+
> "$DOCS_DIR/pre-scan/manifest.json" > "$DOCS_DIR/pre-scan/manifest.json.tmp" \
|
|
121
|
+
> && mv "$DOCS_DIR/pre-scan/manifest.json.tmp" "$DOCS_DIR/pre-scan/manifest.json"
|
|
122
|
+
> echo "Aggregated: $(jq '.aggregated_count' "$DOCS_DIR/pre-scan/manifest.json") analysis modules (from $(jq '.total_modules' "$DOCS_DIR/pre-scan/manifest.json") raw modules)"
|
|
123
|
+
> ```
|
|
124
|
+
|
|
125
|
+
**聚合结果必须向用户展示并确认**(纳入 §1.5 的预览中)。
|
|
126
|
+
|
|
127
|
+
### 1.4b 扫描已有文档(用户已有的 PRD/README 等)
|
|
84
128
|
|
|
85
129
|
> **执行命令(必须通过 Bash 工具):**
|
|
86
130
|
> ```bash
|
|
@@ -125,7 +169,20 @@
|
|
|
125
169
|
技术栈:{STACK}
|
|
126
170
|
文件数:{FILE_COUNT}(已排除 node_modules/build/.git 等)
|
|
127
171
|
规模等级:{SCALE}
|
|
128
|
-
|
|
172
|
+
原始模块:{RAW_MODULE_COUNT} 个子模块
|
|
173
|
+
聚合后分析模块:{AGGREGATED_COUNT} 个
|
|
174
|
+
|
|
175
|
+
业务模块:
|
|
176
|
+
✅ {slug} — {name} ({file_count} 文件)
|
|
177
|
+
...
|
|
178
|
+
|
|
179
|
+
框架模块:
|
|
180
|
+
📦 {slug} — {name}(聚合 {sub_count} 个子模块)
|
|
181
|
+
...
|
|
182
|
+
|
|
183
|
+
已跳过:
|
|
184
|
+
⏭️ {slug} — {reason}
|
|
185
|
+
...
|
|
129
186
|
|
|
130
187
|
分析深度选项:
|
|
131
188
|
L1 结构扫描 ~5分钟 ~10K tokens 目录树+技术栈识别
|
|
@@ -147,15 +204,16 @@
|
|
|
147
204
|
> STACK="${STACK:-unknown}"
|
|
148
205
|
> SCALE="${SCALE:-MEDIUM}"
|
|
149
206
|
>
|
|
150
|
-
> #
|
|
151
|
-
> MODULES_JSON=$(jq -c '[.modules[].slug]' "$DOCS_DIR/pre-scan/manifest.json" 2>/dev/null || echo '[]')
|
|
207
|
+
> # 优先使用聚合后的模块列表,fallback 为原始模块
|
|
208
|
+
> MODULES_JSON=$(jq -c 'if .aggregated_modules then [.aggregated_modules[] | .slug] else [.modules[].slug] end' "$DOCS_DIR/pre-scan/manifest.json" 2>/dev/null || echo '[]')
|
|
152
209
|
>
|
|
153
210
|
> # 构建 module_status 初始值
|
|
154
211
|
> MODULE_STATUS=$(echo "$MODULES_JSON" | jq -c '[.[] | {key: ., value: {phase2: "pending"}}] | from_entries' 2>/dev/null || echo '{}')
|
|
155
212
|
>
|
|
156
213
|
> cat > "$DOCS_DIR/analysis-state.json" << STATEEOF
|
|
157
214
|
> {
|
|
158
|
-
> "version": "5.
|
|
215
|
+
> "version": "5.2.0",
|
|
216
|
+
> "project": "$(basename "$PROJECT_ROOT")",
|
|
159
217
|
> "project_root": "$PROJECT_ROOT",
|
|
160
218
|
> "stack": "$STACK",
|
|
161
219
|
> "depth": "$DEPTH",
|
|
@@ -164,11 +222,14 @@
|
|
|
164
222
|
> "phases": {
|
|
165
223
|
> "phase1_setup": "completed",
|
|
166
224
|
> "phase2_understand": "pending",
|
|
225
|
+
> "phase2_5_refine": "pending",
|
|
167
226
|
> "phase3_graph": "pending",
|
|
168
227
|
> "phase4_synthesize": "pending",
|
|
169
228
|
> "phase5_export": "pending"
|
|
170
229
|
> },
|
|
171
230
|
> "module_status": $MODULE_STATUS,
|
|
231
|
+
> "refine_status": {},
|
|
232
|
+
> "deliverable_status": {},
|
|
172
233
|
> "updated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
173
234
|
> }
|
|
174
235
|
> STATEEOF
|
|
@@ -180,3 +241,13 @@
|
|
|
180
241
|
- `.atool-docs/pre-scan/manifest.json` 存在(或 warning 已记录)
|
|
181
242
|
- `.atool-docs/analysis-state.json` 已写入且 `phases.phase1_setup = "completed"`
|
|
182
243
|
- 用户已确认分析深度
|
|
244
|
+
|
|
245
|
+
## 故障排查(Troubleshooting)
|
|
246
|
+
|
|
247
|
+
| 症状 | 可能原因 | 解决方案 |
|
|
248
|
+
|------|---------|---------|
|
|
249
|
+
| pre-scan 超时(>2分钟) | 项目过大或网络配置问题 | 检查 PROJECT_ROOT,尝试指定具体子目录 |
|
|
250
|
+
| manifest.json 为空或缺数据 | 源文件识别失败 | 检查 PRESCAN_EXCLUDE_DIRS,确保源文件扩展名被识别 |
|
|
251
|
+
| state.json 初始化失败 | 目录权限问题 | 确保 ~/.atool-docs 目录可写 |
|
|
252
|
+
| detected_stack = "generic" | 技术栈检测失败 | 检查是否存在 package.json/pom.xml/go.mod 等 |
|
|
253
|
+
| 重复执行 Phase 1 | 上次中断或状态不清 | `rm -rf .atool-docs/analysis-state.json` 后重试 |
|