@dtt_siye/atool 1.3.1 → 1.4.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/VERSION +1 -1
- 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/lib/common.sh +36 -23
- package/lib/compute-importance.sh +73 -0
- package/lib/install-cursor.sh +2 -2
- package/lib/install-hooks.sh +64 -0
- package/lib/install-skills.sh +5 -2
- package/lib/pre-scan.sh +11 -1
- package/package.json +1 -1
- package/skills/agent-audit/SKILL.md +180 -0
- package/skills/architecture-guard/SKILL.md +164 -0
- package/skills/architecture-guard/rules/violation-detection.md +90 -0
- package/skills/ci-feedback/SKILL.md +165 -0
- package/skills/project-analyze/SKILL.md +100 -11
- package/skills/project-analyze/phases/phase1-setup.md +15 -1
- package/skills/project-analyze/phases/phase2-understand.md +10 -1
- package/skills/project-analyze/phases/phase2.5-refine.md +32 -23
- package/skills/project-analyze/phases/phase3-graph.md +7 -1
- package/skills/project-analyze/phases/phase4-synthesize.md +17 -1
- package/skills/project-analyze/phases/phase5-export.md +42 -4
- package/skills/project-query/SKILL.md +681 -120
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Architecture Violation Detection Rules
|
|
2
|
+
|
|
3
|
+
## Dependency Direction Rules
|
|
4
|
+
|
|
5
|
+
### Rule 1: Strict Layer Ordering
|
|
6
|
+
Each layer may only depend on layers below it in the hierarchy. A dependency pointing upward is a violation.
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
ALLOWED: Presentation → Application → Domain → Infrastructure
|
|
10
|
+
VIOLATION: Domain → Application (upward dependency)
|
|
11
|
+
VIOLATION: Infrastructure → Domain (skipping layers or upward)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Rule 2: No Cross-Skip Dependencies
|
|
15
|
+
A layer may not skip intermediate layers unless the intermediate layer has no relevant abstraction.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
ALLOWED: Controller → Repository (if Service is just a pass-through)
|
|
19
|
+
VIOLATION: Page → API (skipping Service layer with business logic)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## API Boundary Rules
|
|
23
|
+
|
|
24
|
+
### Rule 3: No DTO Leakage
|
|
25
|
+
Response/DTO/ViewModel types must NOT appear in Service or Repository layers.
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
VIOLATION: PaymentService.java imports OrderResponse
|
|
29
|
+
VIOLATION: UserRepository.java returns UserDTO instead of UserEntity
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Rule 4: No Domain Logic in Presentation
|
|
33
|
+
Business logic must NOT appear in Controller/Handler/Page layers.
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
VIOLATION: UserController.java contains validation logic (should be in Service)
|
|
37
|
+
VIOLATION: OrderPage.vue contains price calculation (should be in Service)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Circular Dependency Rules
|
|
41
|
+
|
|
42
|
+
### Rule 5: No Import Cycles
|
|
43
|
+
No circular import chains are allowed between modules.
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
VIOLATION: A imports B, B imports C, C imports A
|
|
47
|
+
ALLOWED: A imports B, A imports C, B imports C (DAG)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Rule 6: No Mutual Dependencies
|
|
51
|
+
Two modules must not directly import from each other.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
VIOLATION: UserService imports OrderService, OrderService imports UserService
|
|
55
|
+
FIX: Extract shared logic into a third module or use events
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Module Boundary Rules
|
|
59
|
+
|
|
60
|
+
### Rule 7: Bounded Context Isolation
|
|
61
|
+
Modules from different bounded contexts should not directly import each other's internal types.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
VIOLATION: billing/internal/invoice.go imports shipping/internal/package.go
|
|
65
|
+
ALLOWED: billing/invoice.go imports shipping/api.go (public API)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Rule 8: No God Modules
|
|
69
|
+
A module importing from more than 50% of other modules may be a god module.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
WARNING: CommonUtils imports from 15 out of 20 modules
|
|
73
|
+
FIX: Split into focused utility modules
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Detection Priority
|
|
77
|
+
|
|
78
|
+
1. **Critical** (blocks commit): Circular dependencies, reverse dependencies
|
|
79
|
+
2. **Warning** (should fix): API boundary leaks, cross-module imports
|
|
80
|
+
3. **Info** (consider): God modules, new unknown modules
|
|
81
|
+
|
|
82
|
+
## Output Format
|
|
83
|
+
|
|
84
|
+
Each violation includes:
|
|
85
|
+
- `file`: The file containing the violation
|
|
86
|
+
- `line`: Line number of the problematic import/usage
|
|
87
|
+
- `rule`: Which rule was violated (1-8)
|
|
88
|
+
- `severity`: Critical / Warning / Info
|
|
89
|
+
- `detail`: Human-readable explanation
|
|
90
|
+
- `suggestion`: How to fix
|
|
@@ -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 | 使用栈级测试命令 |
|
|
@@ -94,7 +94,10 @@ Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文
|
|
|
94
94
|
4. **Phase 2 并发上限 5 个 sub-agent**,超出部分按 importance 降序分批排队
|
|
95
95
|
5. **Phase 3 bash 调用失败时**:在 state.json 记录 `phase3_graph: "failed"`,继续 Phase 4(跳过图谱相关文档,Phase 4 检查此标记)
|
|
96
96
|
6. **断点续传**:先读 state.json,跳过 `status: "completed"` 的 phase
|
|
97
|
-
7. Phase 2.5
|
|
97
|
+
7. **Phase 2.5 参数识别**(无需 bash 解析,直接在用户消息中匹配):
|
|
98
|
+
- `--skip-refine`:用户消息中包含此字符串 → Phase 2.5 标记为 "skipped",跳过精炼链,直进 Phase 3
|
|
99
|
+
- `--refine-threshold N`:用户消息中包含此模式 → 提取 N 作为 Gate 1/2/3 门禁阈值(默认 70)
|
|
100
|
+
- 例:用户说"分析项目 --skip-refine"→ 立即检测到 --skip-refine 字符串,跳过 Phase 2.5
|
|
98
101
|
|
|
99
102
|
### 状态管理(简化版)
|
|
100
103
|
|
|
@@ -103,7 +106,8 @@ Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文
|
|
|
103
106
|
{
|
|
104
107
|
"version": "5.2.0",
|
|
105
108
|
"project": "...",
|
|
106
|
-
"
|
|
109
|
+
"project_root": "...",
|
|
110
|
+
"stack": "java-spring",
|
|
107
111
|
"depth": "L2",
|
|
108
112
|
"phases": {
|
|
109
113
|
"phase1_setup": "completed",
|
|
@@ -194,16 +198,56 @@ state.checkpoint = { last_completed_phase, last_completed_module, next_pending_m
|
|
|
194
198
|
write analysis-state.json
|
|
195
199
|
```
|
|
196
200
|
|
|
197
|
-
### Resume Flow
|
|
198
|
-
1. Read `.atool-docs/analysis-state.json`
|
|
199
|
-
2. If no state file → full analysis
|
|
200
|
-
3. If `phases.phase1_setup != "completed"` → execute Phase 1
|
|
201
|
-
4. Detect stale modules (file hash mismatch) → mark for re-analysis
|
|
202
|
-
5. Determine resume point from checkpoint
|
|
203
|
-
6. Execute pending phases, skip completed, rerun stale
|
|
204
|
-
7. Update final state
|
|
201
|
+
### Resume Flow(断点恢复决策树)
|
|
205
202
|
|
|
206
|
-
|
|
203
|
+
**入口**:执行 Phase 1 setup 时自动检测恢复状态
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
1. 读取 .atool-docs/analysis-state.json(若不存在)
|
|
207
|
+
└─ 启动全新分析(fresh start)
|
|
208
|
+
|
|
209
|
+
2. 存在 state.json
|
|
210
|
+
├─ phases.phase1_setup != "completed"
|
|
211
|
+
│ └─ 执行 Phase 1(重新检测栈 / manifest / importance)
|
|
212
|
+
│
|
|
213
|
+
├─ phases.phase1_setup == "completed"
|
|
214
|
+
│ ├─ 检查 phase2_understand 状态
|
|
215
|
+
│ │ ├─ "pending" → 执行 Phase 2(全部模块)
|
|
216
|
+
│ │ ├─ "in_progress" → 恢复到 Phase 2 中断位置(读 state.module_status,跳过已完成)
|
|
217
|
+
│ │ └─ "completed" → 进入 Phase 2.5
|
|
218
|
+
│ │
|
|
219
|
+
│ ├─ 检查 phase2_5_refine 状态
|
|
220
|
+
│ │ ├─ "pending" / "failed" → 执行 Phase 2.5(全部模块)
|
|
221
|
+
│ │ ├─ "in_progress" → 恢复精炼进度(读 state.refine_status,跳过已通过 Gate 3)
|
|
222
|
+
│ │ └─ "completed" / "skipped" → 进入 Phase 3
|
|
223
|
+
│ │
|
|
224
|
+
│ ├─ 检查 phase3_graph 状态
|
|
225
|
+
│ │ ├─ "pending" → 执行 Phase 3(知识图谱生成)
|
|
226
|
+
│ │ ├─ "in_progress" / "failed" → 重新执行 Phase 3
|
|
227
|
+
│ │ └─ "completed" → 进入 Phase 4
|
|
228
|
+
│ │
|
|
229
|
+
│ ├─ 检查 phase4_synthesize 状态
|
|
230
|
+
│ │ ├─ "pending" → 执行 Phase 4(聚合合成)
|
|
231
|
+
│ │ ├─ "in_progress" / "failed" → 重新执行 Phase 4
|
|
232
|
+
│ │ └─ "completed" → 进入 Phase 5
|
|
233
|
+
│ │
|
|
234
|
+
│ └─ 检查 phase5_export 状态
|
|
235
|
+
│ ├─ "pending" → 执行 Phase 5(最终导出)
|
|
236
|
+
│ ├─ "in_progress" / "failed" → 重新执行 Phase 5
|
|
237
|
+
│ └─ "completed" → 分析完成(可选重新导出)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**断点恢复的具体判断**(在每个 Phase 入口执行):
|
|
241
|
+
- 若 phase 状态为 "completed" 且无 `--force`,**跳过该 phase**
|
|
242
|
+
- 若 phase 状态为 "in_progress"/"failed",**重新执行该 phase**(覆盖部分输出)
|
|
243
|
+
- 若 phase 状态为 "pending",**首次执行该 phase**
|
|
244
|
+
|
|
245
|
+
**文件变更检测**(Phase 2+ 的可选优化):
|
|
246
|
+
- 计算 project root 下所有源文件的 hash(与 manifest.json 对比)
|
|
247
|
+
- 若有新增/删除/修改的文件,标记对应模块为"需重新分析"
|
|
248
|
+
- 该模块在 Phase 2 中重新派发 sub-agent(即使之前已完成)
|
|
249
|
+
|
|
250
|
+
详见各 Phase 的前置检查条款(phase1-setup.md → phase5-export.md)
|
|
207
251
|
|
|
208
252
|
### Incremental Document Recovery
|
|
209
253
|
When resuming Phase 5, incrementally update already-generated documents using `<!-- aTool-module-start:{slug} -->` markers. Only regenerate changed modules.
|
|
@@ -274,6 +318,51 @@ When resuming Phase 5, incrementally update already-generated documents using `<
|
|
|
274
318
|
|
|
275
319
|
---
|
|
276
320
|
|
|
321
|
+
## 调试指南(Debug Guide)
|
|
322
|
+
|
|
323
|
+
### 查看当前分析状态
|
|
324
|
+
```bash
|
|
325
|
+
cat .atool-docs/analysis-state.json | jq '.phases'
|
|
326
|
+
# 输出每个 Phase 的状态(completed/in_progress/failed/pending)
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### 强制重新执行某个 Phase
|
|
330
|
+
```bash
|
|
331
|
+
# 删除特定 Phase 的状态
|
|
332
|
+
jq '.phases.{phase_name} = "pending"' .atool-docs/analysis-state.json > .tmp && mv .tmp .atool-docs/analysis-state.json
|
|
333
|
+
|
|
334
|
+
# 示例:重新执行 Phase 2
|
|
335
|
+
jq '.phases.phase2_understand = "pending"' .atool-docs/analysis-state.json > .tmp && mv .tmp .atool-docs/analysis-state.json
|
|
336
|
+
|
|
337
|
+
# 重新触发分析
|
|
338
|
+
# 在对话中说:分析项目 (AI 会检测到 phase2_understand = "pending",重新执行)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### 完全重置分析(回到 Phase 1)
|
|
342
|
+
```bash
|
|
343
|
+
rm -rf .atool-docs/
|
|
344
|
+
# 重新触发分析会从 Phase 1 开始
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### 查看模块分析进度
|
|
348
|
+
```bash
|
|
349
|
+
# 查看每个模块在 Phase 2 的状态
|
|
350
|
+
jq '.module_status' .atool-docs/analysis-state.json
|
|
351
|
+
|
|
352
|
+
# 查看 Phase 2.5 精炼进度
|
|
353
|
+
jq '.refine_status' .atool-docs/analysis-state.json
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### 诊断常见问题
|
|
357
|
+
| 问题 | 诊断命令 | 解决方案 |
|
|
358
|
+
|------|---------|---------|
|
|
359
|
+
| 没有检测到模块 | `cat .atool-docs/pre-scan/manifest.json \| jq '.modules'` | 检查源文件格式或 detect-stack 规则 |
|
|
360
|
+
| phase3_graph 失败 | `cat .atool-docs/analysis-state.json \| jq '.phases.phase3_graph'` | 运行 `source lib/knowledge-graph.sh; assemble_enhanced_graph` 检查错误 |
|
|
361
|
+
| Sub-agent 无法读文件 | `cat .atool-docs/modules/{name}/data.json` | 检查 Phase 2 初稿是否生成 |
|
|
362
|
+
| 精炼 Gate 失败 | `cat atool-analysis/modules/{name}/prd.md \| wc -l` | PRD 文件小于 30 行,需要扩展初稿 |
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
277
366
|
## Important Notes
|
|
278
367
|
|
|
279
368
|
- Always check `.atool-docs/` before starting; offer incremental update if exists
|
|
@@ -155,7 +155,8 @@
|
|
|
155
155
|
>
|
|
156
156
|
> cat > "$DOCS_DIR/analysis-state.json" << STATEEOF
|
|
157
157
|
> {
|
|
158
|
-
> "version": "5.
|
|
158
|
+
> "version": "5.2.0",
|
|
159
|
+
> "project": "$(basename "$PROJECT_ROOT")",
|
|
159
160
|
> "project_root": "$PROJECT_ROOT",
|
|
160
161
|
> "stack": "$STACK",
|
|
161
162
|
> "depth": "$DEPTH",
|
|
@@ -164,11 +165,14 @@
|
|
|
164
165
|
> "phases": {
|
|
165
166
|
> "phase1_setup": "completed",
|
|
166
167
|
> "phase2_understand": "pending",
|
|
168
|
+
> "phase2_5_refine": "pending",
|
|
167
169
|
> "phase3_graph": "pending",
|
|
168
170
|
> "phase4_synthesize": "pending",
|
|
169
171
|
> "phase5_export": "pending"
|
|
170
172
|
> },
|
|
171
173
|
> "module_status": $MODULE_STATUS,
|
|
174
|
+
> "refine_status": {},
|
|
175
|
+
> "deliverable_status": {},
|
|
172
176
|
> "updated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
173
177
|
> }
|
|
174
178
|
> STATEEOF
|
|
@@ -180,3 +184,13 @@
|
|
|
180
184
|
- `.atool-docs/pre-scan/manifest.json` 存在(或 warning 已记录)
|
|
181
185
|
- `.atool-docs/analysis-state.json` 已写入且 `phases.phase1_setup = "completed"`
|
|
182
186
|
- 用户已确认分析深度
|
|
187
|
+
|
|
188
|
+
## 故障排查(Troubleshooting)
|
|
189
|
+
|
|
190
|
+
| 症状 | 可能原因 | 解决方案 |
|
|
191
|
+
|------|---------|---------|
|
|
192
|
+
| pre-scan 超时(>2分钟) | 项目过大或网络配置问题 | 检查 PROJECT_ROOT,尝试指定具体子目录 |
|
|
193
|
+
| manifest.json 为空或缺数据 | 源文件识别失败 | 检查 PRESCAN_EXCLUDE_DIRS,确保源文件扩展名被识别 |
|
|
194
|
+
| state.json 初始化失败 | 目录权限问题 | 确保 ~/.atool-docs 目录可写 |
|
|
195
|
+
| detected_stack = "generic" | 技术栈检测失败 | 检查是否存在 package.json/pom.xml/go.mod 等 |
|
|
196
|
+
| 重复执行 Phase 1 | 上次中断或状态不清 | `rm -rf .atool-docs/analysis-state.json` 后重试 |
|
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
**目标**:每个模块派发 1 个 sub-agent,产出三层文档(业务/技术/数据),直接写入 `atool-analysis/modules/`。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## IDE 适配(执行前检查)
|
|
8
|
+
|
|
9
|
+
- **Claude Code**:使用 Agent 工具批量派发,每批最多 5 个并行,等待全部完成后派发下一批
|
|
10
|
+
- **Cursor/其他**:**顺序执行**,按 importance 降序逐模块处理,每个模块完成后更新 state.json
|
|
11
|
+
- *原因*:Cursor 不支持并行 sub-agent,自动降级为逐个执行
|
|
12
|
+
- *判断方式*:若 Agent 工具不可用或不响应,自动切换到顺序模式
|
|
13
|
+
|
|
14
|
+
---
|
|
6
15
|
|
|
7
16
|
## 前置检查
|
|
8
17
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
## 前置检查
|
|
10
10
|
|
|
11
11
|
1. `analysis-state.json` 中 `phases.phase2_understand == "completed"`
|
|
12
|
-
2. 读取 `
|
|
12
|
+
2. 读取 `stack` 用于 conventions 加载
|
|
13
13
|
3. 如果 `phases.phase2_5_refine == "completed"` 且非 `--force`,跳过本 Phase
|
|
14
14
|
4. 如果 `--skip-refine`,跳过本 Phase
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
# 从 state.json 读取技术栈
|
|
30
|
-
STACK=$(jq -r '.
|
|
30
|
+
STACK=$(jq -r '.stack // "generic"' .atool-docs/analysis-state.json)
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
从对应 conventions SKILL.md 中提取以下章节内容(不加载全文,控制在 ~200 行):
|
|
@@ -94,11 +94,13 @@ MODULES=$(jq -r '.modules | sort_by(-.importance) | .[].name' .atool-docs/pre-sc
|
|
|
94
94
|
{conventions_context}
|
|
95
95
|
|
|
96
96
|
## 精炼规则
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
4
|
|
97
|
+
**必须读取并遵循**:`~/.claude/skills/requirements-writer/SKILL.md` 中的 **Refine Mode(精炼模式)** 章节。该章节定义了标准的 PRD 精炼流程和输出格式。按照其中的精炼规则逐条执行。
|
|
98
|
+
|
|
99
|
+
补充说明(与 Refine Mode 保持一致):
|
|
100
|
+
- 保留初稿 §1-§3 和原 §4 非目标(移至 §6)
|
|
101
|
+
- 补全 §4 数据需求、§5 跨模块依赖、§7 风险与假设、§8 需求追溯矩阵
|
|
102
|
+
- 增强 §2 加 FR-{MOD}-NNN 编号 + Given-When-Then AC + UI 交互表;§3 加 NFR-{MOD}-NNN 编号,标注 [待系统级确认]
|
|
103
|
+
- 输出必须包含完整 8 节结构
|
|
102
104
|
|
|
103
105
|
## 输出
|
|
104
106
|
原地覆盖 atool-analysis/modules/{module_name}/prd.md
|
|
@@ -109,12 +111,13 @@ MODULES=$(jq -r '.modules | sort_by(-.importance) | .[].name' .atool-docs/pre-sc
|
|
|
109
111
|
- 不创建新文件
|
|
110
112
|
```
|
|
111
113
|
|
|
112
|
-
完成后立即写入 checkpoint
|
|
114
|
+
完成后立即写入 checkpoint(使用唯一临时文件避免并发竞争):
|
|
113
115
|
|
|
114
116
|
```bash
|
|
117
|
+
TMP_FILE=".atool-docs/analysis-state.json.tmp.{module_name}"
|
|
115
118
|
jq --arg mod "{module_name}" \
|
|
116
119
|
'.refine_status[$mod].prd_refine = "completed"' \
|
|
117
|
-
.atool-docs/analysis-state.json >
|
|
120
|
+
.atool-docs/analysis-state.json > "$TMP_FILE" && mv "$TMP_FILE" .atool-docs/analysis-state.json
|
|
118
121
|
```
|
|
119
122
|
|
|
120
123
|
---
|
|
@@ -151,10 +154,11 @@ jq --arg mod "{module_name}" \
|
|
|
151
154
|
选择 C 时:`refine_status.{name}.degraded = true, degraded_reason = "PRD coverage {score}% below threshold"`
|
|
152
155
|
|
|
153
156
|
```bash
|
|
154
|
-
# Gate 2
|
|
157
|
+
# Gate 2 通过时写入(使用唯一临时文件)
|
|
158
|
+
TMP_FILE=".atool-docs/analysis-state.json.tmp.{module_name}.gate2"
|
|
155
159
|
jq --arg mod "{module_name}" --argjson score {score} \
|
|
156
160
|
'.refine_status[$mod].prd_coverage = $score | .refine_status[$mod].prd_gate = "passed"' \
|
|
157
|
-
.atool-docs/analysis-state.json >
|
|
161
|
+
.atool-docs/analysis-state.json > "$TMP_FILE" && mv "$TMP_FILE" .atool-docs/analysis-state.json
|
|
158
162
|
```
|
|
159
163
|
|
|
160
164
|
---
|
|
@@ -186,12 +190,14 @@ jq --arg mod "{module_name}" --argjson score {score} \
|
|
|
186
190
|
{conventions_context}
|
|
187
191
|
|
|
188
192
|
## 精炼规则
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
**必须读取并遵循**:`~/.claude/skills/software-architecture/SKILL.md` 中的 **Refine Mode(精炼模式)** 章节。该章节定义了标准的架构设计精炼流程和输出格式。按照其中的精炼规则逐条执行。
|
|
194
|
+
|
|
195
|
+
补充说明(与 Refine Mode 保持一致):
|
|
196
|
+
- 在现有 dev-guide.md 内容末尾追加(不删除原有内容)
|
|
197
|
+
- 追加 B-subset 组件设计(分层表 + 边界 + 依赖方向)
|
|
198
|
+
- 追加 C-subset 数据与交互设计(数据所有权 + 同步/异步边界 + API 契约)
|
|
199
|
+
- 追加至少 1 个 ADR(使用 7 节 ADR 模板:Status/Context/Decision/Options/Consequences/NFR Impact/Related)
|
|
200
|
+
- NFR 对齐:标注 [待系统级确认]
|
|
195
201
|
|
|
196
202
|
## 输出
|
|
197
203
|
原地覆盖 atool-analysis/modules/{module_name}/dev-guide.md
|
|
@@ -203,12 +209,13 @@ jq --arg mod "{module_name}" --argjson score {score} \
|
|
|
203
209
|
- 不生成项目级文档(A/D/E/F)
|
|
204
210
|
```
|
|
205
211
|
|
|
206
|
-
完成后写入 checkpoint
|
|
212
|
+
完成后写入 checkpoint(使用唯一临时文件):
|
|
207
213
|
|
|
208
214
|
```bash
|
|
215
|
+
TMP_FILE=".atool-docs/analysis-state.json.tmp.{module_name}.archrefine"
|
|
209
216
|
jq --arg mod "{module_name}" \
|
|
210
217
|
'.refine_status[$mod].arch_refine = "completed"' \
|
|
211
|
-
.atool-docs/analysis-state.json >
|
|
218
|
+
.atool-docs/analysis-state.json > "$TMP_FILE" && mv "$TMP_FILE" .atool-docs/analysis-state.json
|
|
212
219
|
```
|
|
213
220
|
|
|
214
221
|
---
|
|
@@ -226,17 +233,19 @@ jq --arg mod "{module_name}" \
|
|
|
226
233
|
**失败** → 同 Gate 2 的三选项恢复机制(A 重试 / B 手动 / C 降级)
|
|
227
234
|
|
|
228
235
|
```bash
|
|
229
|
-
# Gate 3
|
|
236
|
+
# Gate 3 通过时写入(使用唯一临时文件)
|
|
237
|
+
TMP_FILE=".atool-docs/analysis-state.json.tmp.{module_name}.gate3"
|
|
230
238
|
jq --arg mod "{module_name}" \
|
|
231
239
|
'.refine_status[$mod].arch_gate = "passed"' \
|
|
232
|
-
.atool-docs/analysis-state.json >
|
|
240
|
+
.atool-docs/analysis-state.json > "$TMP_FILE" && mv "$TMP_FILE" .atool-docs/analysis-state.json
|
|
233
241
|
```
|
|
234
242
|
|
|
235
243
|
### 2.5.5 完成 Checkpoint
|
|
236
244
|
|
|
237
|
-
|
|
245
|
+
每个模块完成全部精炼(或降级)后,写入完整状态(使用唯一临时文件):
|
|
238
246
|
|
|
239
247
|
```bash
|
|
248
|
+
TMP_FILE=".atool-docs/analysis-state.json.tmp.{module_name}.final"
|
|
240
249
|
jq --arg mod "{module_name}" \
|
|
241
250
|
--argjson score {prd_score} \
|
|
242
251
|
--arg conv "{conventions_skill}" \
|
|
@@ -249,7 +258,7 @@ jq --arg mod "{module_name}" \
|
|
|
249
258
|
"conventions_loaded": $conv,
|
|
250
259
|
"degraded": false,
|
|
251
260
|
"degraded_reason": null
|
|
252
|
-
}' .atool-docs/analysis-state.json >
|
|
261
|
+
}' .atool-docs/analysis-state.json > "$TMP_FILE" && mv "$TMP_FILE" .atool-docs/analysis-state.json
|
|
253
262
|
```
|
|
254
263
|
|
|
255
264
|
### 2.5.6 跨 IDE 降级
|
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
**目标**:从 Phase 2 的 data.json 构建知识图谱 + 五维分析。全部通过 bash 库函数执行,禁止 AI 生成。
|
|
4
4
|
|
|
5
|
-
**执行时间目标**:< 30
|
|
5
|
+
**执行时间目标**:< 30秒(大型项目 < 60秒)
|
|
6
|
+
|
|
7
|
+
**性能特点**:
|
|
8
|
+
- Pure bash + jq(无 AI 开销)
|
|
9
|
+
- 线性时间复杂度:O(M*E),M=模块数,E=边数
|
|
10
|
+
- 内存消耗:~50MB per 100 modules(jq slurp)
|
|
11
|
+
- 中断保护:超过 120 秒自动停止,记录为 "failed"
|
|
6
12
|
|
|
7
13
|
## 前置检查
|
|
8
14
|
|
|
@@ -2,10 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
**目标**:以 Phase 2.5 精炼后的模块文档 + 知识图谱为数据源,**聚合**为项目级交付物。Phase 4 不再从零生成模块级内容,而是聚合、补全项目级独有文档、并生成 PROJECT-DELIVERABLE.md 总览入口。
|
|
4
4
|
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## IDE 适配(执行前检查)
|
|
8
|
+
|
|
9
|
+
- **Claude Code**:主 Agent 单条线执行 Phase 4 逻辑(无额外并行)
|
|
10
|
+
- **Cursor/其他**:同 Claude Code(Phase 4 本身是单 Agent,无 sub-agent 并行需求)
|
|
11
|
+
|
|
12
|
+
**注**:Phase 4 与 Phase 2/4 不同,本身不使用 sub-agents,仅为单条线聚合逻辑,故无 IDE 差异。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
5
16
|
## 前置检查
|
|
6
17
|
|
|
7
18
|
1. 确认 `phases.phase2_understand == "completed"`(必须)
|
|
8
|
-
2. 检查 `phases.
|
|
19
|
+
2. 检查 `phases.phase2_5_refine`(必须):
|
|
20
|
+
- `"completed"` → 使用精炼后的 prd.md、dev-guide.md(含 ADR、架构设计)
|
|
21
|
+
- `"skipped"` 或 `"failed"` → **警告用户并询问是否继续**
|
|
22
|
+
- 若继续:使用 Phase 2 初稿(内容可能不完整)
|
|
23
|
+
- 若中止:建议用户重新执行 Phase 2.5
|
|
24
|
+
3. 检查 `phases.phase3_graph`:
|
|
9
25
|
- `"completed"` → 可使用图谱数据生成完整文档
|
|
10
26
|
- `"failed"` → 跳过图谱相关输出(data-flow.mmd、module-dependencies.mmd),其余正常生成
|
|
11
27
|
|