claude-code-workflow 6.3.2 → 6.3.5
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/.claude/CLAUDE.md +9 -1
- package/.claude/commands/{clean.md → workflow/clean.md} +5 -5
- package/.claude/commands/workflow/docs/analyze.md +1467 -0
- package/.claude/commands/workflow/docs/copyright.md +1265 -0
- package/.claude/commands/workflow/lite-plan.md +1 -1
- package/.claude/commands/workflow/tools/conflict-resolution.md +76 -240
- package/.claude/commands/workflow/tools/task-generate-agent.md +81 -8
- package/.claude/skills/_shared/mermaid-utils.md +584 -0
- package/.claude/skills/copyright-docs/SKILL.md +132 -0
- package/.claude/skills/copyright-docs/phases/01-metadata-collection.md +78 -0
- package/.claude/skills/copyright-docs/phases/02-deep-analysis.md +454 -0
- package/.claude/skills/copyright-docs/phases/02.5-consolidation.md +192 -0
- package/.claude/skills/copyright-docs/phases/04-document-assembly.md +261 -0
- package/.claude/skills/copyright-docs/phases/05-compliance-refinement.md +192 -0
- package/.claude/skills/copyright-docs/specs/cpcc-requirements.md +121 -0
- package/.claude/skills/copyright-docs/templates/agent-base.md +200 -0
- package/.claude/skills/project-analyze/SKILL.md +162 -0
- package/.claude/skills/project-analyze/phases/01-requirements-discovery.md +79 -0
- package/.claude/skills/project-analyze/phases/02-project-exploration.md +75 -0
- package/.claude/skills/project-analyze/phases/03-deep-analysis.md +640 -0
- package/.claude/skills/project-analyze/phases/03.5-consolidation.md +208 -0
- package/.claude/skills/project-analyze/phases/04-report-generation.md +217 -0
- package/.claude/skills/project-analyze/phases/05-iterative-refinement.md +124 -0
- package/.claude/skills/project-analyze/specs/quality-standards.md +115 -0
- package/.claude/skills/project-analyze/specs/writing-style.md +152 -0
- package/.claude/workflows/cli-templates/schemas/conflict-resolution-schema.json +79 -65
- package/.claude/workflows/cli-tools-usage.md +515 -516
- package/README.md +11 -1
- package/ccw/dist/cli.d.ts.map +1 -1
- package/ccw/dist/cli.js +7 -1
- package/ccw/dist/cli.js.map +1 -1
- package/ccw/dist/commands/cli.d.ts +1 -1
- package/ccw/dist/commands/cli.d.ts.map +1 -1
- package/ccw/dist/commands/cli.js +116 -14
- package/ccw/dist/commands/cli.js.map +1 -1
- package/ccw/dist/core/routes/cli-routes.js +2 -2
- package/ccw/dist/core/routes/cli-routes.js.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.d.ts +7 -3
- package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.js +31 -17
- package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
- package/ccw/dist/tools/cli-executor.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor.js +19 -7
- package/ccw/dist/tools/cli-executor.js.map +1 -1
- package/ccw/dist/tools/cli-history-store.d.ts +33 -0
- package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
- package/ccw/dist/tools/cli-history-store.js +89 -5
- package/ccw/dist/tools/cli-history-store.js.map +1 -1
- package/ccw/dist/tools/smart-search.d.ts +25 -0
- package/ccw/dist/tools/smart-search.d.ts.map +1 -1
- package/ccw/dist/tools/smart-search.js +121 -17
- package/ccw/dist/tools/smart-search.js.map +1 -1
- package/ccw/src/cli.ts +264 -258
- package/ccw/src/commands/cli.ts +1009 -884
- package/ccw/src/core/routes/cli-routes.ts +3 -3
- package/ccw/src/templates/dashboard-js/components/cli-history.js +40 -13
- package/ccw/src/templates/dashboard-js/components/cli-status.js +26 -2
- package/ccw/src/templates/dashboard-js/views/cli-manager.js +5 -0
- package/ccw/src/templates/dashboard-js/views/history.js +19 -4
- package/ccw/src/tools/claude-cli-tools.ts +37 -20
- package/ccw/src/tools/cli-executor.ts +20 -7
- package/ccw/src/tools/cli-history-store.ts +125 -5
- package/ccw/src/tools/smart-search.ts +157 -16
- package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/config.py +8 -0
- package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/chain_search.py +71 -1
- package/codex-lens/src/codexlens/search/hybrid_search.py +144 -11
- package/codex-lens/src/codexlens/search/ranking.py +540 -274
- package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/chunker.py +55 -10
- package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/global_index.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/dir_index.py +1888 -1850
- package/codex-lens/src/codexlens/storage/global_index.py +365 -0
- package/codex-lens/src/codexlens/storage/index_tree.py +83 -10
- package/package.json +2 -2
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Phase 3.5: Consolidation Agent
|
|
2
|
+
|
|
3
|
+
汇总所有分析 Agent 的产出,生成跨章节综合分析,为 Phase 4 索引报告提供内容。
|
|
4
|
+
|
|
5
|
+
> **写作规范**: [../specs/writing-style.md](../specs/writing-style.md)
|
|
6
|
+
|
|
7
|
+
## 核心职责
|
|
8
|
+
|
|
9
|
+
1. **跨章节综合分析**:生成 synthesis(报告综述)
|
|
10
|
+
2. **章节摘要提取**:生成 section_summaries(索引表格内容)
|
|
11
|
+
3. **质量检查**:识别问题并评分
|
|
12
|
+
4. **建议汇总**:生成 recommendations(优先级排序)
|
|
13
|
+
|
|
14
|
+
## 输入
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
interface ConsolidationInput {
|
|
18
|
+
output_dir: string;
|
|
19
|
+
config: AnalysisConfig;
|
|
20
|
+
agent_summaries: AgentReturn[];
|
|
21
|
+
cross_module_notes: string[];
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 执行
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
Task({
|
|
29
|
+
subagent_type: "cli-explore-agent",
|
|
30
|
+
run_in_background: false,
|
|
31
|
+
prompt: `
|
|
32
|
+
## 规范前置
|
|
33
|
+
首先读取规范文件:
|
|
34
|
+
- Read: ${skillRoot}/specs/quality-standards.md
|
|
35
|
+
- Read: ${skillRoot}/specs/writing-style.md
|
|
36
|
+
严格遵循规范中的质量标准和段落式写作要求。
|
|
37
|
+
|
|
38
|
+
## 任务
|
|
39
|
+
作为汇总 Agent,读取所有章节文件,执行跨章节分析,生成汇总报告和索引内容。
|
|
40
|
+
|
|
41
|
+
## 输入
|
|
42
|
+
- 章节文件: ${outputDir}/sections/section-*.md
|
|
43
|
+
- Agent 摘要: ${JSON.stringify(agent_summaries)}
|
|
44
|
+
- 跨模块备注: ${JSON.stringify(cross_module_notes)}
|
|
45
|
+
- 报告类型: ${config.type}
|
|
46
|
+
|
|
47
|
+
## 核心产出
|
|
48
|
+
|
|
49
|
+
### 1. 综合分析 (synthesis)
|
|
50
|
+
阅读所有章节,用 2-3 段落描述项目全貌:
|
|
51
|
+
- 第一段:项目定位与核心架构特征
|
|
52
|
+
- 第二段:关键设计决策与技术选型
|
|
53
|
+
- 第三段:整体质量评价与显著特点
|
|
54
|
+
|
|
55
|
+
### 2. 章节摘要 (section_summaries)
|
|
56
|
+
为每个章节提取一句话核心发现,用于索引表格。
|
|
57
|
+
|
|
58
|
+
### 3. 架构洞察 (cross_analysis)
|
|
59
|
+
描述章节间的关联性,如:
|
|
60
|
+
- 模块间的依赖关系如何体现在各章节
|
|
61
|
+
- 设计决策如何贯穿多个层面
|
|
62
|
+
- 潜在的一致性或冲突
|
|
63
|
+
|
|
64
|
+
### 4. 建议汇总 (recommendations)
|
|
65
|
+
按优先级整理各章节的建议,段落式描述。
|
|
66
|
+
|
|
67
|
+
## 质量检查维度
|
|
68
|
+
|
|
69
|
+
### 一致性检查
|
|
70
|
+
- 术语一致性:同一概念是否使用相同名称
|
|
71
|
+
- 代码引用:file:line 格式是否正确
|
|
72
|
+
|
|
73
|
+
### 完整性检查
|
|
74
|
+
- 章节覆盖:是否涵盖所有必需章节
|
|
75
|
+
- 内容深度:每章节是否达到 ${config.depth} 级别
|
|
76
|
+
|
|
77
|
+
### 质量检查
|
|
78
|
+
- Mermaid 语法:图表是否可渲染
|
|
79
|
+
- 段落式写作:是否符合写作规范(禁止清单罗列)
|
|
80
|
+
|
|
81
|
+
## 输出文件
|
|
82
|
+
|
|
83
|
+
写入: ${outputDir}/consolidation-summary.md
|
|
84
|
+
|
|
85
|
+
### 文件格式
|
|
86
|
+
|
|
87
|
+
\`\`\`markdown
|
|
88
|
+
# 分析汇总报告
|
|
89
|
+
|
|
90
|
+
## 综合分析
|
|
91
|
+
|
|
92
|
+
[2-3 段落的项目全貌描述,段落式写作]
|
|
93
|
+
|
|
94
|
+
## 章节摘要
|
|
95
|
+
|
|
96
|
+
| 章节 | 文件 | 核心发现 |
|
|
97
|
+
|------|------|----------|
|
|
98
|
+
| 系统概述 | section-overview.md | 一句话描述 |
|
|
99
|
+
| 层次分析 | section-layers.md | 一句话描述 |
|
|
100
|
+
| ... | ... | ... |
|
|
101
|
+
|
|
102
|
+
## 架构洞察
|
|
103
|
+
|
|
104
|
+
[跨章节关联分析,段落式描述]
|
|
105
|
+
|
|
106
|
+
## 建议汇总
|
|
107
|
+
|
|
108
|
+
[优先级排序的建议,段落式描述]
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 质量评估
|
|
113
|
+
|
|
114
|
+
### 评分
|
|
115
|
+
|
|
116
|
+
| 维度 | 得分 | 说明 |
|
|
117
|
+
|------|------|------|
|
|
118
|
+
| 完整性 | 85% | ... |
|
|
119
|
+
| 一致性 | 90% | ... |
|
|
120
|
+
| 深度 | 95% | ... |
|
|
121
|
+
| 可读性 | 88% | ... |
|
|
122
|
+
| 综合 | 89% | ... |
|
|
123
|
+
|
|
124
|
+
### 发现的问题
|
|
125
|
+
|
|
126
|
+
#### 严重问题
|
|
127
|
+
| ID | 类型 | 位置 | 描述 |
|
|
128
|
+
|----|------|------|------|
|
|
129
|
+
| E001 | ... | ... | ... |
|
|
130
|
+
|
|
131
|
+
#### 警告
|
|
132
|
+
| ID | 类型 | 位置 | 描述 |
|
|
133
|
+
|----|------|------|------|
|
|
134
|
+
| W001 | ... | ... | ... |
|
|
135
|
+
|
|
136
|
+
#### 提示
|
|
137
|
+
| ID | 类型 | 位置 | 描述 |
|
|
138
|
+
|----|------|------|------|
|
|
139
|
+
| I001 | ... | ... | ... |
|
|
140
|
+
|
|
141
|
+
### 统计
|
|
142
|
+
|
|
143
|
+
- 章节数: X
|
|
144
|
+
- 图表数: X
|
|
145
|
+
- 总字数: X
|
|
146
|
+
\`\`\`
|
|
147
|
+
|
|
148
|
+
## 返回格式 (JSON)
|
|
149
|
+
|
|
150
|
+
{
|
|
151
|
+
"status": "completed",
|
|
152
|
+
"output_file": "consolidation-summary.md",
|
|
153
|
+
|
|
154
|
+
// Phase 4 索引报告所需
|
|
155
|
+
"synthesis": "2-3 段落的综合分析文本",
|
|
156
|
+
"cross_analysis": "跨章节关联分析文本",
|
|
157
|
+
"recommendations": "优先级排序的建议文本",
|
|
158
|
+
"section_summaries": [
|
|
159
|
+
{"file": "section-overview.md", "title": "系统概述", "summary": "一句话核心发现"},
|
|
160
|
+
{"file": "section-layers.md", "title": "层次分析", "summary": "一句话核心发现"}
|
|
161
|
+
],
|
|
162
|
+
|
|
163
|
+
// 质量信息
|
|
164
|
+
"quality_score": {
|
|
165
|
+
"completeness": 85,
|
|
166
|
+
"consistency": 90,
|
|
167
|
+
"depth": 95,
|
|
168
|
+
"readability": 88,
|
|
169
|
+
"overall": 89
|
|
170
|
+
},
|
|
171
|
+
"issues": {
|
|
172
|
+
"errors": [...],
|
|
173
|
+
"warnings": [...],
|
|
174
|
+
"info": [...]
|
|
175
|
+
},
|
|
176
|
+
"stats": {
|
|
177
|
+
"total_sections": 5,
|
|
178
|
+
"total_diagrams": 8,
|
|
179
|
+
"total_words": 3500
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
`
|
|
183
|
+
})
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 问题分类
|
|
187
|
+
|
|
188
|
+
| 严重级别 | 前缀 | 含义 | 处理方式 |
|
|
189
|
+
|----------|------|------|----------|
|
|
190
|
+
| Error | E | 阻塞报告生成 | 必须修复 |
|
|
191
|
+
| Warning | W | 影响报告质量 | 建议修复 |
|
|
192
|
+
| Info | I | 可改进项 | 可选修复 |
|
|
193
|
+
|
|
194
|
+
## 问题类型
|
|
195
|
+
|
|
196
|
+
| 类型 | 说明 |
|
|
197
|
+
|------|------|
|
|
198
|
+
| missing | 缺失章节 |
|
|
199
|
+
| inconsistency | 术语/描述不一致 |
|
|
200
|
+
| invalid_ref | 无效代码引用 |
|
|
201
|
+
| syntax | Mermaid 语法错误 |
|
|
202
|
+
| shallow | 内容过浅 |
|
|
203
|
+
| list_style | 违反段落式写作规范 |
|
|
204
|
+
|
|
205
|
+
## Output
|
|
206
|
+
|
|
207
|
+
- **文件**: `consolidation-summary.md`(完整汇总报告)
|
|
208
|
+
- **返回**: JSON 包含 Phase 4 所需的所有字段
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Phase 4: Report Generation
|
|
2
|
+
|
|
3
|
+
生成索引式报告,通过 markdown 链接引用章节文件。
|
|
4
|
+
|
|
5
|
+
> **规范参考**: [../specs/quality-standards.md](../specs/quality-standards.md)
|
|
6
|
+
|
|
7
|
+
## 设计原则
|
|
8
|
+
|
|
9
|
+
1. **引用而非嵌入**:主报告通过链接引用章节,不复制内容
|
|
10
|
+
2. **索引 + 综述**:主报告提供导航和高阶分析
|
|
11
|
+
3. **避免重复**:综述来自 consolidation,不重新生成
|
|
12
|
+
4. **独立可读**:各章节文件可单独阅读
|
|
13
|
+
|
|
14
|
+
## 输入
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
interface ReportInput {
|
|
18
|
+
output_dir: string;
|
|
19
|
+
config: AnalysisConfig;
|
|
20
|
+
consolidation: {
|
|
21
|
+
quality_score: QualityScore;
|
|
22
|
+
issues: { errors: Issue[], warnings: Issue[], info: Issue[] };
|
|
23
|
+
stats: Stats;
|
|
24
|
+
synthesis: string; // consolidation agent 的综合分析
|
|
25
|
+
section_summaries: Array<{file: string, summary: string}>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 执行流程
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
// 1. 质量门禁检查
|
|
34
|
+
if (consolidation.issues.errors.length > 0) {
|
|
35
|
+
const response = await AskUserQuestion({
|
|
36
|
+
questions: [{
|
|
37
|
+
question: `发现 ${consolidation.issues.errors.length} 个严重问题,如何处理?`,
|
|
38
|
+
header: "质量检查",
|
|
39
|
+
multiSelect: false,
|
|
40
|
+
options: [
|
|
41
|
+
{label: "查看并修复", description: "显示问题列表,手动修复后重试"},
|
|
42
|
+
{label: "忽略继续", description: "跳过问题检查,继续装配"},
|
|
43
|
+
{label: "终止", description: "停止报告生成"}
|
|
44
|
+
]
|
|
45
|
+
}]
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (response === "查看并修复") {
|
|
49
|
+
return { action: "fix_required", errors: consolidation.issues.errors };
|
|
50
|
+
}
|
|
51
|
+
if (response === "终止") {
|
|
52
|
+
return { action: "abort" };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 2. 生成索引式报告(不读取章节内容)
|
|
57
|
+
const report = generateIndexReport(config, consolidation);
|
|
58
|
+
|
|
59
|
+
// 3. 写入最终文件
|
|
60
|
+
const fileName = `${config.type.toUpperCase()}-REPORT.md`;
|
|
61
|
+
Write(`${outputDir}/${fileName}`, report);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 报告模板
|
|
65
|
+
|
|
66
|
+
### 通用结构
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
# {报告标题}
|
|
70
|
+
|
|
71
|
+
> 生成日期:{date}
|
|
72
|
+
> 分析范围:{scope}
|
|
73
|
+
> 分析深度:{depth}
|
|
74
|
+
> 质量评分:{overall}%
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 报告综述
|
|
79
|
+
|
|
80
|
+
{consolidation.synthesis - 来自汇总 Agent 的跨章节综合分析}
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 章节索引
|
|
85
|
+
|
|
86
|
+
| 章节 | 核心发现 | 详情 |
|
|
87
|
+
|------|----------|------|
|
|
88
|
+
{section_summaries 生成的表格行}
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 架构洞察
|
|
93
|
+
|
|
94
|
+
{从 consolidation 提取的跨模块关联分析}
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 建议与展望
|
|
99
|
+
|
|
100
|
+
{consolidation.recommendations - 优先级排序的综合建议}
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
**附录**
|
|
105
|
+
|
|
106
|
+
- [质量报告](./consolidation-summary.md)
|
|
107
|
+
- [章节文件目录](./sections/)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 报告标题映射
|
|
111
|
+
|
|
112
|
+
| 类型 | 标题 |
|
|
113
|
+
|------|------|
|
|
114
|
+
| architecture | 项目架构设计报告 |
|
|
115
|
+
| design | 项目设计模式报告 |
|
|
116
|
+
| methods | 项目核心方法报告 |
|
|
117
|
+
| comprehensive | 项目综合分析报告 |
|
|
118
|
+
|
|
119
|
+
## 生成函数
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
function generateIndexReport(config, consolidation) {
|
|
123
|
+
const titles = {
|
|
124
|
+
architecture: "项目架构设计报告",
|
|
125
|
+
design: "项目设计模式报告",
|
|
126
|
+
methods: "项目核心方法报告",
|
|
127
|
+
comprehensive: "项目综合分析报告"
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const date = new Date().toLocaleDateString('zh-CN');
|
|
131
|
+
|
|
132
|
+
// 章节索引表格
|
|
133
|
+
const sectionTable = consolidation.section_summaries
|
|
134
|
+
.map(s => `| ${s.title} | ${s.summary} | [查看详情](./sections/${s.file}) |`)
|
|
135
|
+
.join('\n');
|
|
136
|
+
|
|
137
|
+
return `# ${titles[config.type]}
|
|
138
|
+
|
|
139
|
+
> 生成日期:${date}
|
|
140
|
+
> 分析范围:${config.scope}
|
|
141
|
+
> 分析深度:${config.depth}
|
|
142
|
+
> 质量评分:${consolidation.quality_score.overall}%
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 报告综述
|
|
147
|
+
|
|
148
|
+
${consolidation.synthesis}
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 章节索引
|
|
153
|
+
|
|
154
|
+
| 章节 | 核心发现 | 详情 |
|
|
155
|
+
|------|----------|------|
|
|
156
|
+
${sectionTable}
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 架构洞察
|
|
161
|
+
|
|
162
|
+
${consolidation.cross_analysis || '详见各章节分析。'}
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 建议与展望
|
|
167
|
+
|
|
168
|
+
${consolidation.recommendations || '详见质量报告中的改进建议。'}
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
**附录**
|
|
173
|
+
|
|
174
|
+
- [质量报告](./consolidation-summary.md)
|
|
175
|
+
- [章节文件目录](./sections/)
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 输出结构
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
.workflow/.scratchpad/analyze-{timestamp}/
|
|
184
|
+
├── sections/ # 独立章节(Phase 3 产出)
|
|
185
|
+
│ ├── section-overview.md
|
|
186
|
+
│ ├── section-layers.md
|
|
187
|
+
│ └── ...
|
|
188
|
+
├── consolidation-summary.md # 质量报告(Phase 3.5 产出)
|
|
189
|
+
└── {TYPE}-REPORT.md # 索引报告(本阶段产出)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## 与 Phase 3.5 的协作
|
|
193
|
+
|
|
194
|
+
Phase 3.5 consolidation agent 需要提供:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
interface ConsolidationOutput {
|
|
198
|
+
// ... 原有字段
|
|
199
|
+
synthesis: string; // 跨章节综合分析(2-3 段落)
|
|
200
|
+
cross_analysis: string; // 架构级关联洞察
|
|
201
|
+
recommendations: string; // 优先级排序的建议
|
|
202
|
+
section_summaries: Array<{
|
|
203
|
+
file: string; // 文件名
|
|
204
|
+
title: string; // 章节标题
|
|
205
|
+
summary: string; // 一句话核心发现
|
|
206
|
+
}>;
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 关键变更
|
|
211
|
+
|
|
212
|
+
| 原设计 | 新设计 |
|
|
213
|
+
|--------|--------|
|
|
214
|
+
| 读取章节内容并拼接 | 链接引用,不读取内容 |
|
|
215
|
+
| 重新生成 Executive Summary | 直接使用 consolidation.synthesis |
|
|
216
|
+
| 嵌入质量评分表格 | 链接引用 consolidation-summary.md |
|
|
217
|
+
| 主报告包含全部内容 | 主报告仅为索引 + 综述 |
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Phase 5: Iterative Refinement
|
|
2
|
+
|
|
3
|
+
Discovery-driven refinement based on analysis findings.
|
|
4
|
+
|
|
5
|
+
## Execution
|
|
6
|
+
|
|
7
|
+
### Step 1: Extract Discoveries
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
function extractDiscoveries(deepAnalysis) {
|
|
11
|
+
return {
|
|
12
|
+
ambiguities: deepAnalysis.findings.filter(f => f.confidence < 0.7),
|
|
13
|
+
complexityHotspots: deepAnalysis.findings.filter(f => f.complexity === 'high'),
|
|
14
|
+
patternDeviations: deepAnalysis.patterns.filter(p => p.consistency < 0.8),
|
|
15
|
+
unclearDependencies: deepAnalysis.dependencies.filter(d => d.type === 'implicit'),
|
|
16
|
+
potentialIssues: deepAnalysis.recommendations.filter(r => r.priority === 'investigate'),
|
|
17
|
+
depthOpportunities: deepAnalysis.sections.filter(s => s.has_more_detail)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const discoveries = extractDiscoveries(deepAnalysis);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Step 2: Build Dynamic Questions
|
|
25
|
+
|
|
26
|
+
Questions emerge from discoveries, NOT predetermined:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
function buildDynamicQuestions(discoveries, config) {
|
|
30
|
+
const questions = [];
|
|
31
|
+
|
|
32
|
+
if (discoveries.ambiguities.length > 0) {
|
|
33
|
+
questions.push({
|
|
34
|
+
question: `Analysis found ambiguity in "${discoveries.ambiguities[0].area}". Which interpretation is correct?`,
|
|
35
|
+
header: "Clarify",
|
|
36
|
+
options: discoveries.ambiguities[0].interpretations
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (discoveries.complexityHotspots.length > 0) {
|
|
41
|
+
questions.push({
|
|
42
|
+
question: `These areas have high complexity. Which would you like explained?`,
|
|
43
|
+
header: "Deep-Dive",
|
|
44
|
+
multiSelect: true,
|
|
45
|
+
options: discoveries.complexityHotspots.slice(0, 4).map(h => ({
|
|
46
|
+
label: h.name,
|
|
47
|
+
description: h.summary
|
|
48
|
+
}))
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (discoveries.patternDeviations.length > 0) {
|
|
53
|
+
questions.push({
|
|
54
|
+
question: `Found pattern deviations. Should these be highlighted in the report?`,
|
|
55
|
+
header: "Patterns",
|
|
56
|
+
options: [
|
|
57
|
+
{label: "Yes, include analysis", description: "Add section explaining deviations"},
|
|
58
|
+
{label: "No, skip", description: "Omit from report"}
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Always include action question
|
|
64
|
+
questions.push({
|
|
65
|
+
question: "How would you like to proceed?",
|
|
66
|
+
header: "Action",
|
|
67
|
+
options: [
|
|
68
|
+
{label: "Continue refining", description: "Address more discoveries"},
|
|
69
|
+
{label: "Finalize report", description: "Generate final output"},
|
|
70
|
+
{label: "Change scope", description: "Modify analysis scope"}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return questions.slice(0, 4); // Max 4 questions
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Step 3: Apply Refinements
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
if (userAction === "Continue refining") {
|
|
82
|
+
// Apply selected refinements
|
|
83
|
+
for (const selection of userSelections) {
|
|
84
|
+
applyRefinement(selection, deepAnalysis, report);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Save iteration
|
|
88
|
+
Write(`${outputDir}/iterations/iteration-${iterationCount}.json`, {
|
|
89
|
+
timestamp: new Date().toISOString(),
|
|
90
|
+
discoveries: discoveries,
|
|
91
|
+
selections: userSelections,
|
|
92
|
+
changes: appliedChanges
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Loop back to Step 1
|
|
96
|
+
iterationCount++;
|
|
97
|
+
goto Step1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (userAction === "Finalize report") {
|
|
101
|
+
// Proceed to final output
|
|
102
|
+
goto FinalizeReport;
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Step 4: Finalize Report
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
// Add iteration history to report metadata
|
|
110
|
+
const finalReport = {
|
|
111
|
+
...report,
|
|
112
|
+
metadata: {
|
|
113
|
+
iterations: iterationCount,
|
|
114
|
+
refinements_applied: allRefinements,
|
|
115
|
+
final_discoveries: discoveries
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
Write(`${outputDir}/${config.type.toUpperCase()}-REPORT.md`, finalReport);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Output
|
|
123
|
+
|
|
124
|
+
Updated report with refinements, saved iterations to `iterations/` folder.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Quality Standards
|
|
2
|
+
|
|
3
|
+
Quality gates and requirements for project analysis reports.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
| Phase | Usage | Section |
|
|
8
|
+
|-------|-------|---------|
|
|
9
|
+
| Phase 4 | Check report structure before assembly | Report Requirements |
|
|
10
|
+
| Phase 5 | Validate before each iteration | Quality Gates |
|
|
11
|
+
| Phase 5 | Handle failures during refinement | Error Handling |
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Report Requirements
|
|
16
|
+
|
|
17
|
+
**Use in Phase 4**: Ensure report includes all required elements.
|
|
18
|
+
|
|
19
|
+
| Requirement | Check | How to Fix |
|
|
20
|
+
|-------------|-------|------------|
|
|
21
|
+
| Executive Summary | 3-5 key takeaways | Extract from analysis findings |
|
|
22
|
+
| Visual diagrams | Valid Mermaid syntax | Use `../_shared/mermaid-utils.md` |
|
|
23
|
+
| Code references | `file:line` format | Link to actual source locations |
|
|
24
|
+
| Recommendations | Actionable, specific | Derive from analysis insights |
|
|
25
|
+
| Consistent depth | Match user's depth level | Adjust detail per config.depth |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Quality Gates
|
|
30
|
+
|
|
31
|
+
**Use in Phase 5**: Run these checks before asking user questions.
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
function runQualityGates(report, config, diagrams) {
|
|
35
|
+
const gates = [
|
|
36
|
+
{
|
|
37
|
+
name: "focus_areas_covered",
|
|
38
|
+
check: () => config.focus_areas.every(area =>
|
|
39
|
+
report.toLowerCase().includes(area.toLowerCase())
|
|
40
|
+
),
|
|
41
|
+
fix: "Re-analyze missing focus areas"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "diagrams_valid",
|
|
45
|
+
check: () => diagrams.every(d => d.valid),
|
|
46
|
+
fix: "Regenerate failed diagrams with mermaid-utils"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "code_refs_accurate",
|
|
50
|
+
check: () => extractCodeRefs(report).every(ref => fileExists(ref)),
|
|
51
|
+
fix: "Update invalid file references"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "no_placeholders",
|
|
55
|
+
check: () => !report.includes('[TODO]') && !report.includes('[PLACEHOLDER]'),
|
|
56
|
+
fix: "Fill in all placeholder content"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "recommendations_specific",
|
|
60
|
+
check: () => !report.includes('consider') || report.includes('specifically'),
|
|
61
|
+
fix: "Make recommendations project-specific"
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const results = gates.map(g => ({...g, passed: g.check()}));
|
|
66
|
+
const allPassed = results.every(r => r.passed);
|
|
67
|
+
|
|
68
|
+
return { allPassed, results };
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Integration with Phase 5**:
|
|
73
|
+
```javascript
|
|
74
|
+
// In 05-iterative-refinement.md
|
|
75
|
+
const { allPassed, results } = runQualityGates(report, config, diagrams);
|
|
76
|
+
|
|
77
|
+
if (allPassed) {
|
|
78
|
+
// All gates passed → ask user to confirm or finalize
|
|
79
|
+
} else {
|
|
80
|
+
// Gates failed → include failed gates in discovery questions
|
|
81
|
+
const failedGates = results.filter(r => !r.passed);
|
|
82
|
+
discoveries.qualityIssues = failedGates;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Error Handling
|
|
89
|
+
|
|
90
|
+
**Use when**: Encountering errors during any phase.
|
|
91
|
+
|
|
92
|
+
| Error | Detection | Recovery |
|
|
93
|
+
|-------|-----------|----------|
|
|
94
|
+
| CLI timeout | Bash exits with timeout | Reduce scope via `config.scope`, retry |
|
|
95
|
+
| Exploration failure | Agent returns error | Fall back to `Read` + `Grep` directly |
|
|
96
|
+
| User abandons | User selects "cancel" | Save to `iterations/`, allow resume |
|
|
97
|
+
| Invalid scope path | Path doesn't exist | `AskUserQuestion` to correct path |
|
|
98
|
+
| Diagram validation fails | `validateMermaidSyntax` returns issues | Regenerate with stricter escaping |
|
|
99
|
+
|
|
100
|
+
**Recovery Flow**:
|
|
101
|
+
```javascript
|
|
102
|
+
try {
|
|
103
|
+
await executePhase(phase);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
const recovery = ERROR_HANDLERS[error.type];
|
|
106
|
+
if (recovery) {
|
|
107
|
+
await recovery.action(error, config);
|
|
108
|
+
// Retry phase or continue
|
|
109
|
+
} else {
|
|
110
|
+
// Save progress and ask user
|
|
111
|
+
Write(`${outputDir}/error-state.json`, { phase, error, config });
|
|
112
|
+
AskUserQuestion({ question: "遇到错误,如何处理?", ... });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|