@dtt_siye/atool 1.4.0 → 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/install.sh +14 -4
- package/lib/install-cursor.sh +22 -0
- package/lib/install-kiro.sh +26 -2
- package/lib/pre-scan.sh +3 -1
- package/lib/project-init.sh +28 -9
- package/package.json +1 -1
- 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/atool-init/SKILL.md +24 -4
- package/skills/project-analyze/SKILL.md +29 -8
- package/skills/project-analyze/phases/phase1-setup.md +61 -4
- package/skills/project-analyze/phases/phase2-understand.md +129 -27
- package/skills/project-analyze/phases/phase3-graph.md +32 -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 +64 -734
- 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,249 @@
|
|
|
1
|
+
# Testing - 测试策略
|
|
2
|
+
|
|
3
|
+
## 测试原则
|
|
4
|
+
|
|
5
|
+
### 1. TDD 必需性
|
|
6
|
+
**test-driven-development 技能是必需的**
|
|
7
|
+
- 写任何新代码前(Red-Green-Refactor)
|
|
8
|
+
- 重构迁移的代码前
|
|
9
|
+
- 为迁移的代码写测试时
|
|
10
|
+
|
|
11
|
+
### 2. 测试覆盖率目标
|
|
12
|
+
```python
|
|
13
|
+
# 目标:100% 覆盖迁移的代码
|
|
14
|
+
# 最小:80% 覆盖率
|
|
15
|
+
# 优先级:
|
|
16
|
+
# 1. 公共接口(100%)
|
|
17
|
+
# 2. 业务逻辑(100%)
|
|
18
|
+
# 3. 工具函数(80%+)
|
|
19
|
+
# 4. 辅助函数(60%+)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 测试阶段
|
|
23
|
+
|
|
24
|
+
### Phase 1: 迁移前测试
|
|
25
|
+
```python
|
|
26
|
+
# 1. 记录现有测试结果
|
|
27
|
+
old_test_results = run_existing_tests()
|
|
28
|
+
|
|
29
|
+
# 2. 基准性能
|
|
30
|
+
old_performance = benchmark_performance()
|
|
31
|
+
|
|
32
|
+
# 3. 验证现有功能
|
|
33
|
+
test_existing_features()
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Phase 2: 迁移中测试
|
|
37
|
+
每个迁移批次后:
|
|
38
|
+
```python
|
|
39
|
+
# 1. 语法检查
|
|
40
|
+
python -m py_compile new_file.py
|
|
41
|
+
|
|
42
|
+
# 2. 基本导入测试
|
|
43
|
+
python -c "from apps.module import function"
|
|
44
|
+
|
|
45
|
+
# 3. 现有测试通过
|
|
46
|
+
pytest tests/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Phase 3: 迁移后测试
|
|
50
|
+
```python
|
|
51
|
+
# 1. 完整测试套件
|
|
52
|
+
pytest tests/ --cov=.
|
|
53
|
+
|
|
54
|
+
# 2. 对比迁移前结果
|
|
55
|
+
compare_test_results(old_test_results, current_test_results)
|
|
56
|
+
|
|
57
|
+
# 3. 性能回归测试
|
|
58
|
+
compare_performance(old_performance, current_performance)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 测试类型
|
|
62
|
+
|
|
63
|
+
### 1. 单元测试
|
|
64
|
+
```python
|
|
65
|
+
# agents/user_agent/services.py
|
|
66
|
+
def test_user_service():
|
|
67
|
+
# Arrange
|
|
68
|
+
user_service = UserService()
|
|
69
|
+
|
|
70
|
+
# Act
|
|
71
|
+
result = user_service.create_user("test@example.com")
|
|
72
|
+
|
|
73
|
+
# Assert
|
|
74
|
+
assert result.id is not None
|
|
75
|
+
assert result.email == "test@example.com"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 2. 集成测试
|
|
79
|
+
```python
|
|
80
|
+
# 测试代理间协作
|
|
81
|
+
def test_user_order_integration():
|
|
82
|
+
# 用户代理创建用户
|
|
83
|
+
user = user_agent.create_user("test@example.com")
|
|
84
|
+
|
|
85
|
+
# 订单代理为用户创建订单
|
|
86
|
+
order = order_agent.create_order(user.id, "product")
|
|
87
|
+
|
|
88
|
+
# 验证关联
|
|
89
|
+
assert order.user_id == user.id
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. 端到端测试
|
|
93
|
+
```python
|
|
94
|
+
def test_complete_user_flow():
|
|
95
|
+
# 模拟用户注册到订单完成
|
|
96
|
+
user = api_client.post("/users", {"email": "test@example.com"})
|
|
97
|
+
order = api_client.post("/orders", {"user_id": user.id})
|
|
98
|
+
|
|
99
|
+
# 验证整个流程
|
|
100
|
+
assert order.status == "completed"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 测试工具配置
|
|
104
|
+
|
|
105
|
+
### 1. pytest 配置
|
|
106
|
+
```python
|
|
107
|
+
# pytest.ini
|
|
108
|
+
[pytest]
|
|
109
|
+
testpaths = tests
|
|
110
|
+
python_files = test_*.py
|
|
111
|
+
python_functions = test_*
|
|
112
|
+
addopts = -v --tb=short --strict-markers
|
|
113
|
+
|
|
114
|
+
markers =
|
|
115
|
+
unit: unit tests
|
|
116
|
+
integration: integration tests
|
|
117
|
+
e2e: end-to-end tests
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 2. Coverage 配置
|
|
121
|
+
```python
|
|
122
|
+
# .coveragerc
|
|
123
|
+
[run]
|
|
124
|
+
source = apps,core,agents
|
|
125
|
+
omit =
|
|
126
|
+
*/tests/*
|
|
127
|
+
*/migrations/*
|
|
128
|
+
*/__pycache__/*
|
|
129
|
+
|
|
130
|
+
[report]
|
|
131
|
+
exclude_lines =
|
|
132
|
+
pragma: no cover
|
|
133
|
+
def __repr__
|
|
134
|
+
raise AssertionError
|
|
135
|
+
raise NotImplementedError
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## 测试数据管理
|
|
139
|
+
|
|
140
|
+
### 1. 固定装置(Fixtures)
|
|
141
|
+
```python
|
|
142
|
+
# conftest.py
|
|
143
|
+
import pytest
|
|
144
|
+
from tests.factories import UserFactory, OrderFactory
|
|
145
|
+
|
|
146
|
+
@pytest.fixture
|
|
147
|
+
def user():
|
|
148
|
+
return UserFactory()
|
|
149
|
+
|
|
150
|
+
@pytest.fixture
|
|
151
|
+
def order(user):
|
|
152
|
+
return OrderFactory(user=user)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 2. Factories
|
|
156
|
+
```python
|
|
157
|
+
# tests/factories.py
|
|
158
|
+
class UserFactory:
|
|
159
|
+
@staticmethod
|
|
160
|
+
def create(**kwargs):
|
|
161
|
+
defaults = {
|
|
162
|
+
"email": "test@example.com",
|
|
163
|
+
"name": "Test User"
|
|
164
|
+
}
|
|
165
|
+
return User.objects.create(**{**defaults, **kwargs})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 测试问题处理
|
|
169
|
+
|
|
170
|
+
### 1. 测试失败时的处理流程
|
|
171
|
+
```python
|
|
172
|
+
def handle_test_failure(test_name, error):
|
|
173
|
+
# 1. 隔离问题
|
|
174
|
+
isolate_issue(test_name)
|
|
175
|
+
|
|
176
|
+
# 2. 确定原因
|
|
177
|
+
cause = determine_cause(error)
|
|
178
|
+
|
|
179
|
+
if cause == "IMPORT_ERROR":
|
|
180
|
+
fix_imports()
|
|
181
|
+
elif cause == "LOGIC_ERROR":
|
|
182
|
+
fix_logic()
|
|
183
|
+
elif cause == "REGRESSION":
|
|
184
|
+
# 回滚迁移
|
|
185
|
+
rollback_migration()
|
|
186
|
+
|
|
187
|
+
# 3. 重新运行测试
|
|
188
|
+
rerun_tests()
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 2. 常见问题及解决方案
|
|
192
|
+
|
|
193
|
+
| 问题 | 原因 | 解决方案 |
|
|
194
|
+
|------|------|---------|
|
|
195
|
+
| ImportError | 导入路径错误 | 检查 new_ 前缀 |
|
|
196
|
+
| AttributeError | 属性不存在 | 检查类/函数名 |
|
|
197
|
+
| AssertionError | 逻辑改变 | 对比迁移前后代码 |
|
|
198
|
+
| KeyError | 配置缺失 | 检查配置文件 |
|
|
199
|
+
|
|
200
|
+
## 测试报告模板
|
|
201
|
+
|
|
202
|
+
```markdown
|
|
203
|
+
# 测试报告: [项目名] 迁移
|
|
204
|
+
|
|
205
|
+
## 概览
|
|
206
|
+
- 总测试数: 150
|
|
207
|
+
- 通过: 145 (96.7%)
|
|
208
|
+
- 失败: 5 (3.3%)
|
|
209
|
+
- 跳过: 0
|
|
210
|
+
|
|
211
|
+
## 失败测试详情
|
|
212
|
+
|
|
213
|
+
### 1. test_user_creation
|
|
214
|
+
**原因**: UserService.create_user() 返回值格式改变
|
|
215
|
+
**状态**: 已修复
|
|
216
|
+
**行动**: 更新断言逻辑
|
|
217
|
+
|
|
218
|
+
### 2. test_payment_processing
|
|
219
|
+
**原因**: PaymentService 类名改变
|
|
220
|
+
**状态**: 已修复
|
|
221
|
+
**行动**: 更新导入语句
|
|
222
|
+
|
|
223
|
+
## 覆盖率分析
|
|
224
|
+
- 总覆盖率: 87%
|
|
225
|
+
- 目标覆盖率: 80%
|
|
226
|
+
- 覆盖率变化: +2%
|
|
227
|
+
|
|
228
|
+
## 性能测试
|
|
229
|
+
- 平均响应时间: 120ms (迁移前: 115ms)
|
|
230
|
+
- 回归: 4.3% (在可接受范围内)
|
|
231
|
+
|
|
232
|
+
## 建议下一步
|
|
233
|
+
1. 修复剩余 5 个测试
|
|
234
|
+
2. 增加边缘情况测试
|
|
235
|
+
3. 考虑性能优化
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 质量关卡
|
|
239
|
+
|
|
240
|
+
### 测试必需调用
|
|
241
|
+
1. **迁移前**: 记录基准
|
|
242
|
+
2. **迁移中**: 每个批次后
|
|
243
|
+
3. **迁移后**: 全面测试
|
|
244
|
+
|
|
245
|
+
### 通过标准
|
|
246
|
+
- 所有现有测试通过
|
|
247
|
+
- 无性能回归(<5%变化)
|
|
248
|
+
- 覆盖率 ≥ 80%
|
|
249
|
+
- 新增测试覆盖所有公共接口
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Code Verification - 代码验证
|
|
2
|
+
|
|
3
|
+
## 执行步骤
|
|
4
|
+
|
|
5
|
+
### 1. 全面代码审查
|
|
6
|
+
- 审查每个迁移的文件
|
|
7
|
+
- 验证无行为变更
|
|
8
|
+
- 检查意外修改
|
|
9
|
+
- 验证所有导入正确
|
|
10
|
+
|
|
11
|
+
### 2. 验证所有导入解析
|
|
12
|
+
```bash
|
|
13
|
+
# 检查每个导入
|
|
14
|
+
python -c "from agents.x.y import z"
|
|
15
|
+
|
|
16
|
+
# 检查循环依赖
|
|
17
|
+
python -c "
|
|
18
|
+
import agents.agent1
|
|
19
|
+
import agents.agent2
|
|
20
|
+
# 无报错表示无循环依赖"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 3. 检查所有交叉引用更新
|
|
24
|
+
- 配置文件
|
|
25
|
+
- 文档
|
|
26
|
+
- 测试文件
|
|
27
|
+
- 脚本和工具
|
|
28
|
+
|
|
29
|
+
### 4. 验证无行为变更
|
|
30
|
+
- 逐行比较功能
|
|
31
|
+
- 运行现有测试并验证相同结果
|
|
32
|
+
- 手动测试关键功能
|
|
33
|
+
- 性能比较(应该相同)
|
|
34
|
+
|
|
35
|
+
### 5. 生成验证报告
|
|
36
|
+
- 列出所有审查的文件
|
|
37
|
+
- 列出所有验证的导入
|
|
38
|
+
- 列出所有更新的引用
|
|
39
|
+
- 记录发现的任何差异(并修复)
|
|
40
|
+
|
|
41
|
+
## 验证检查清单
|
|
42
|
+
|
|
43
|
+
### 文件级检查
|
|
44
|
+
- [ ] 所有迁移文件已审查
|
|
45
|
+
- [ ] 文件内容无意外修改
|
|
46
|
+
- [ ] 函数/类签名无变化
|
|
47
|
+
- [ ] 注释和文档无丢失
|
|
48
|
+
|
|
49
|
+
### 导入检查
|
|
50
|
+
- [ ] 所有导入语句正确
|
|
51
|
+
- [ ] 无循环依赖
|
|
52
|
+
- [ ] 相对 vs 绝对导入正确
|
|
53
|
+
- [ ] 导入链完整
|
|
54
|
+
|
|
55
|
+
### 功能检查
|
|
56
|
+
- [ ] 所有公共接口行为一致
|
|
57
|
+
- [ ] 错误处理逻辑相同
|
|
58
|
+
- [ ] 返回值格式一致
|
|
59
|
+
- [ ] 性能特征相同
|
|
60
|
+
|
|
61
|
+
### 测试验证
|
|
62
|
+
- [ ] 现有测试通过
|
|
63
|
+
- [ ] 测试结果与迁移前相同
|
|
64
|
+
- [ ] 覆盖率无下降
|
|
65
|
+
- [ ] 新增测试(如需要)
|
|
66
|
+
|
|
67
|
+
## 必需技能调用
|
|
68
|
+
|
|
69
|
+
### systematic-debugging(必需)
|
|
70
|
+
- 调用时机:验证完成后
|
|
71
|
+
- 传递内容:所有代码变更、测试结果、遇到的问题
|
|
72
|
+
- 预期输出:根因分析、变更正确性验证
|
|
73
|
+
|
|
74
|
+
### software-architecture
|
|
75
|
+
- 调用时机:最终架构验证
|
|
76
|
+
- 传递内容:最终结构、命名、关注点分离
|
|
77
|
+
- 预期输出:架构合规性确认
|
|
78
|
+
|
|
79
|
+
## 问题修复模板
|
|
80
|
+
|
|
81
|
+
```markdown
|
|
82
|
+
## 发现的问题
|
|
83
|
+
|
|
84
|
+
### 问题描述
|
|
85
|
+
[具体描述发现的问题]
|
|
86
|
+
|
|
87
|
+
### 根因分析
|
|
88
|
+
[为什么会出现这个问题]
|
|
89
|
+
|
|
90
|
+
### 修复方案
|
|
91
|
+
[如何修复]
|
|
92
|
+
|
|
93
|
+
### 验证方法
|
|
94
|
+
[如何验证修复正确]
|
|
95
|
+
|
|
96
|
+
### 修复结果
|
|
97
|
+
[修复后的验证结果]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 通过标准
|
|
101
|
+
|
|
102
|
+
1. **systematic-debugging** 审查通过
|
|
103
|
+
2. 所有验证检查通过
|
|
104
|
+
3. 无行为变更
|
|
105
|
+
4. 所有交叉引用更新
|
|
106
|
+
5. 无未解决问题
|
|
107
|
+
|
|
108
|
+
## 不通过处理
|
|
109
|
+
- 任何检查失败 → 必须修复才能继续
|
|
110
|
+
- systematic-debugging 发现问题 → 必须解决
|
|
111
|
+
- 行为变更 → 必须回滚并重新迁移
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: atool-init
|
|
3
|
-
description: "Initialize a project with aTool - one-step setup: auto-detect global install status, run global install if needed, then generate project-level CLAUDE.md, Cursor rules, Kiro steering. Use when user says /atool-init, initialize project, setup aTool. 触发:初始化项目/配置aTool/init project"
|
|
4
|
-
version: 1.
|
|
3
|
+
description: "Initialize a project with aTool - one-step setup: auto-detect global install status, run global install if needed, then generate project-level CLAUDE.md, Cursor rules, Kiro steering. Use when user says /atool-init, initialize project, setup aTool, or wants to use CLI equivalent 'atool init'. 触发:初始化项目/配置aTool/init project/atool init"
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# aTool Project Initialization (One-Step)
|
|
@@ -11,9 +11,10 @@ One-step project initialization: automatically checks global install status, per
|
|
|
11
11
|
## When to Use
|
|
12
12
|
- User starts a new project and wants AI IDE configuration
|
|
13
13
|
- User asks to set up or configure aTool for their project
|
|
14
|
-
- User says "/atool-init", "initialize project", "setup atool", "init project"
|
|
15
|
-
- User says "初始化项目", "配置aTool", "初始化aTool"
|
|
14
|
+
- User says "/atool-init", "initialize project", "setup atool", "init project", "atool init"
|
|
15
|
+
- User says "初始化项目", "配置aTool", "初始化aTool", "atool 初始化"
|
|
16
16
|
- User wants to generate CLAUDE.md, Cursor rules, or Kiro steering
|
|
17
|
+
- User wants to use the CLI equivalent `atool init` command
|
|
17
18
|
|
|
18
19
|
## Steps
|
|
19
20
|
|
|
@@ -139,3 +140,22 @@ Stack detection signal files:
|
|
|
139
140
|
- If no stack is detected, a generic template is used
|
|
140
141
|
- Global install is only run once (detected by checking staging directories)
|
|
141
142
|
- The install.sh location varies by how aTool was installed (git clone, manual copy, etc.)
|
|
143
|
+
|
|
144
|
+
## CLI Equivalents
|
|
145
|
+
|
|
146
|
+
| Use Case | Command in AI IDE | CLI Command |
|
|
147
|
+
|----------|-------------------|-------------|
|
|
148
|
+
| Initialize current directory | `/atool-init` | `atool init` |
|
|
149
|
+
| Initialize specific directory | `/atool-init for ./my-app` | `atool init ./my-app` |
|
|
150
|
+
| Initialize with specific stack | `/atool-init with React stack` | `atool init --stack react` |
|
|
151
|
+
| Check aTool installation | (Not applicable) | `atool version` |
|
|
152
|
+
| Update aTool | (Not applicable) | `atool update` |
|
|
153
|
+
|
|
154
|
+
## Skill 协作
|
|
155
|
+
|
|
156
|
+
| 协作 Skill | 触发条件 | 交互方式 |
|
|
157
|
+
|-----------|---------|---------|
|
|
158
|
+
| software-architecture | 项目初始化完成后 | 建议运行架构设计指导 |
|
|
159
|
+
| project-analyze | 初始化的项目 | 可运行深度项目分析 |
|
|
160
|
+
| code-review | 项目有代码后 | 可运行代码质量审查 |
|
|
161
|
+
| java-conventions/web-conventions | 对应技术栈项目 | 自动加载对应编码规范 |
|
|
@@ -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
|
```
|
|
@@ -143,7 +156,7 @@ Phase 5: EXPORT → phases/phase5-export.md (bash + AI, export 单文
|
|
|
143
156
|
}
|
|
144
157
|
```
|
|
145
158
|
|
|
146
|
-
status 枚举值:`"pending"` | `"in_progress"` | `"completed"` | `"failed"` | `"skipped"`
|
|
159
|
+
status 枚举值:`"pending"` | `"in_progress"` | `"completed"` | `"failed"` | `"skipped"` | `"blocked"`
|
|
147
160
|
|
|
148
161
|
### HARD GATE — bash Phase 执行验证
|
|
149
162
|
|
|
@@ -190,12 +203,19 @@ Modules processed in importance order, one at a time. Progress line per module.
|
|
|
190
203
|
## State Management & Checkpoint/Resume
|
|
191
204
|
|
|
192
205
|
### Checkpoint Write Timing
|
|
193
|
-
|
|
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
|
+
|
|
194
210
|
```
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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"
|
|
199
219
|
```
|
|
200
220
|
|
|
201
221
|
### Resume Flow(断点恢复决策树)
|
|
@@ -223,6 +243,7 @@ write analysis-state.json
|
|
|
223
243
|
│ │
|
|
224
244
|
│ ├─ 检查 phase3_graph 状态
|
|
225
245
|
│ │ ├─ "pending" → 执行 Phase 3(知识图谱生成)
|
|
246
|
+
│ │ ├─ "blocked" → data.json 缺失, 需回到 Phase 2 重新执行
|
|
226
247
|
│ │ ├─ "in_progress" / "failed" → 重新执行 Phase 3
|
|
227
248
|
│ │ └─ "completed" → 进入 Phase 4
|
|
228
249
|
│ │
|
|
@@ -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,8 +204,8 @@
|
|
|
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 '{}')
|