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,192 @@
|
|
|
1
|
+
# Phase 2.5: Consolidation Agent
|
|
2
|
+
|
|
3
|
+
汇总所有分析 Agent 的产出,生成设计综述,为 Phase 4 索引文档提供内容。
|
|
4
|
+
|
|
5
|
+
> **规范参考**: [../specs/cpcc-requirements.md](../specs/cpcc-requirements.md)
|
|
6
|
+
|
|
7
|
+
## 核心职责
|
|
8
|
+
|
|
9
|
+
1. **设计综述**:生成 synthesis(软件整体设计思路)
|
|
10
|
+
2. **章节摘要**:生成 section_summaries(导航表格内容)
|
|
11
|
+
3. **跨模块分析**:识别问题和关联
|
|
12
|
+
4. **质量检查**:验证 CPCC 合规性
|
|
13
|
+
|
|
14
|
+
## 输入
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
interface ConsolidationInput {
|
|
18
|
+
output_dir: string;
|
|
19
|
+
agent_summaries: AgentReturn[];
|
|
20
|
+
cross_module_notes: string[];
|
|
21
|
+
metadata: ProjectMetadata;
|
|
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/cpcc-requirements.md
|
|
35
|
+
严格遵循 CPCC 软著申请规范要求。
|
|
36
|
+
|
|
37
|
+
## 任务
|
|
38
|
+
作为汇总 Agent,读取所有章节文件,生成设计综述和跨模块分析报告。
|
|
39
|
+
|
|
40
|
+
## 输入
|
|
41
|
+
- 章节文件: ${outputDir}/sections/section-*.md
|
|
42
|
+
- Agent 摘要: ${JSON.stringify(agent_summaries)}
|
|
43
|
+
- 跨模块备注: ${JSON.stringify(cross_module_notes)}
|
|
44
|
+
- 软件信息: ${JSON.stringify(metadata)}
|
|
45
|
+
|
|
46
|
+
## 核心产出
|
|
47
|
+
|
|
48
|
+
### 1. 设计综述 (synthesis)
|
|
49
|
+
用 2-3 段落描述软件整体设计思路:
|
|
50
|
+
- 第一段:软件定位与核心设计理念
|
|
51
|
+
- 第二段:模块划分与协作机制
|
|
52
|
+
- 第三段:技术选型与设计特点
|
|
53
|
+
|
|
54
|
+
### 2. 章节摘要 (section_summaries)
|
|
55
|
+
为每个章节提取一句话说明,用于导航表格:
|
|
56
|
+
|
|
57
|
+
| 章节 | 文件 | 一句话说明 |
|
|
58
|
+
|------|------|------------|
|
|
59
|
+
| 2. 系统架构设计 | section-2-architecture.md | ... |
|
|
60
|
+
| 3. 功能模块设计 | section-3-functions.md | ... |
|
|
61
|
+
| 4. 核心算法与流程 | section-4-algorithms.md | ... |
|
|
62
|
+
| 5. 数据结构设计 | section-5-data-structures.md | ... |
|
|
63
|
+
| 6. 接口设计 | section-6-interfaces.md | ... |
|
|
64
|
+
| 7. 异常处理设计 | section-7-exceptions.md | ... |
|
|
65
|
+
|
|
66
|
+
### 3. 跨模块分析
|
|
67
|
+
- 一致性:术语、命名规范
|
|
68
|
+
- 完整性:功能-接口对应、异常覆盖
|
|
69
|
+
- 关联性:模块依赖、数据流向
|
|
70
|
+
|
|
71
|
+
## 输出文件
|
|
72
|
+
|
|
73
|
+
写入: ${outputDir}/cross-module-summary.md
|
|
74
|
+
|
|
75
|
+
### 文件格式
|
|
76
|
+
|
|
77
|
+
\`\`\`markdown
|
|
78
|
+
# 跨模块分析报告
|
|
79
|
+
|
|
80
|
+
## 设计综述
|
|
81
|
+
|
|
82
|
+
[2-3 段落的软件设计思路描述]
|
|
83
|
+
|
|
84
|
+
## 章节摘要
|
|
85
|
+
|
|
86
|
+
| 章节 | 文件 | 说明 |
|
|
87
|
+
|------|------|------|
|
|
88
|
+
| 2. 系统架构设计 | section-2-architecture.md | 一句话说明 |
|
|
89
|
+
| ... | ... | ... |
|
|
90
|
+
|
|
91
|
+
## 文档统计
|
|
92
|
+
|
|
93
|
+
| 章节 | 图表数 | 字数 |
|
|
94
|
+
|------|--------|------|
|
|
95
|
+
| ... | ... | ... |
|
|
96
|
+
|
|
97
|
+
## 发现的问题
|
|
98
|
+
|
|
99
|
+
### 严重问题 (必须修复)
|
|
100
|
+
|
|
101
|
+
| ID | 类型 | 位置 | 描述 | 建议 |
|
|
102
|
+
|----|------|------|------|------|
|
|
103
|
+
| E001 | ... | ... | ... | ... |
|
|
104
|
+
|
|
105
|
+
### 警告 (建议修复)
|
|
106
|
+
|
|
107
|
+
| ID | 类型 | 位置 | 描述 | 建议 |
|
|
108
|
+
|----|------|------|------|------|
|
|
109
|
+
| W001 | ... | ... | ... | ... |
|
|
110
|
+
|
|
111
|
+
### 提示 (可选修复)
|
|
112
|
+
|
|
113
|
+
| ID | 类型 | 位置 | 描述 |
|
|
114
|
+
|----|------|------|------|
|
|
115
|
+
| I001 | ... | ... | ... |
|
|
116
|
+
|
|
117
|
+
## 跨模块关联图
|
|
118
|
+
|
|
119
|
+
\`\`\`mermaid
|
|
120
|
+
graph LR
|
|
121
|
+
S2[架构] --> S3[功能]
|
|
122
|
+
S3 --> S4[算法]
|
|
123
|
+
S3 --> S6[接口]
|
|
124
|
+
S5[数据结构] --> S6
|
|
125
|
+
S6 --> S7[异常]
|
|
126
|
+
\`\`\`
|
|
127
|
+
|
|
128
|
+
## 修复建议优先级
|
|
129
|
+
|
|
130
|
+
[按优先级排序的建议,段落式描述]
|
|
131
|
+
\`\`\`
|
|
132
|
+
|
|
133
|
+
## 返回格式 (JSON)
|
|
134
|
+
|
|
135
|
+
{
|
|
136
|
+
"status": "completed",
|
|
137
|
+
"output_file": "cross-module-summary.md",
|
|
138
|
+
|
|
139
|
+
// Phase 4 索引文档所需
|
|
140
|
+
"synthesis": "2-3 段落的设计综述文本",
|
|
141
|
+
"section_summaries": [
|
|
142
|
+
{"file": "section-2-architecture.md", "title": "2. 系统架构设计", "summary": "一句话说明"},
|
|
143
|
+
{"file": "section-3-functions.md", "title": "3. 功能模块设计", "summary": "一句话说明"},
|
|
144
|
+
{"file": "section-4-algorithms.md", "title": "4. 核心算法与流程", "summary": "一句话说明"},
|
|
145
|
+
{"file": "section-5-data-structures.md", "title": "5. 数据结构设计", "summary": "一句话说明"},
|
|
146
|
+
{"file": "section-6-interfaces.md", "title": "6. 接口设计", "summary": "一句话说明"},
|
|
147
|
+
{"file": "section-7-exceptions.md", "title": "7. 异常处理设计", "summary": "一句话说明"}
|
|
148
|
+
],
|
|
149
|
+
|
|
150
|
+
// 质量信息
|
|
151
|
+
"stats": {
|
|
152
|
+
"total_sections": 6,
|
|
153
|
+
"total_diagrams": 8,
|
|
154
|
+
"total_words": 3500
|
|
155
|
+
},
|
|
156
|
+
"issues": {
|
|
157
|
+
"errors": [...],
|
|
158
|
+
"warnings": [...],
|
|
159
|
+
"info": [...]
|
|
160
|
+
},
|
|
161
|
+
"cross_refs": {
|
|
162
|
+
"found": 12,
|
|
163
|
+
"missing": 3
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
`
|
|
167
|
+
})
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## 问题分类
|
|
171
|
+
|
|
172
|
+
| 严重级别 | 前缀 | 含义 | 处理方式 |
|
|
173
|
+
|----------|------|------|----------|
|
|
174
|
+
| Error | E | 阻塞合规检查 | 必须修复 |
|
|
175
|
+
| Warning | W | 影响文档质量 | 建议修复 |
|
|
176
|
+
| Info | I | 可改进项 | 可选修复 |
|
|
177
|
+
|
|
178
|
+
## 问题类型
|
|
179
|
+
|
|
180
|
+
| 类型 | 说明 |
|
|
181
|
+
|------|------|
|
|
182
|
+
| missing | 缺失内容(功能-接口对应、异常覆盖)|
|
|
183
|
+
| inconsistency | 不一致(术语、命名、编号)|
|
|
184
|
+
| circular | 循环依赖 |
|
|
185
|
+
| orphan | 孤立内容(未被引用)|
|
|
186
|
+
| syntax | Mermaid 语法错误 |
|
|
187
|
+
| enhancement | 增强建议 |
|
|
188
|
+
|
|
189
|
+
## Output
|
|
190
|
+
|
|
191
|
+
- **文件**: `cross-module-summary.md`(完整汇总报告)
|
|
192
|
+
- **返回**: JSON 包含 Phase 4 所需的 synthesis 和 section_summaries
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Phase 4: Document Assembly
|
|
2
|
+
|
|
3
|
+
生成索引式文档,通过 markdown 链接引用章节文件。
|
|
4
|
+
|
|
5
|
+
> **规范参考**: [../specs/cpcc-requirements.md](../specs/cpcc-requirements.md)
|
|
6
|
+
|
|
7
|
+
## 设计原则
|
|
8
|
+
|
|
9
|
+
1. **引用而非嵌入**:主文档通过链接引用章节,不复制内容
|
|
10
|
+
2. **索引 + 综述**:主文档提供导航和软件概述
|
|
11
|
+
3. **CPCC 合规**:保持章节编号符合软著申请要求
|
|
12
|
+
4. **独立可读**:各章节文件可单独阅读
|
|
13
|
+
|
|
14
|
+
## 输入
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
interface AssemblyInput {
|
|
18
|
+
output_dir: string;
|
|
19
|
+
metadata: ProjectMetadata;
|
|
20
|
+
consolidation: {
|
|
21
|
+
synthesis: string; // 跨章节综合分析
|
|
22
|
+
section_summaries: Array<{
|
|
23
|
+
file: string;
|
|
24
|
+
title: string;
|
|
25
|
+
summary: string;
|
|
26
|
+
}>;
|
|
27
|
+
issues: { errors: Issue[], warnings: Issue[], info: Issue[] };
|
|
28
|
+
stats: { total_sections: number, total_diagrams: number };
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 执行流程
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
// 1. 检查是否有阻塞性问题
|
|
37
|
+
if (consolidation.issues.errors.length > 0) {
|
|
38
|
+
const response = await AskUserQuestion({
|
|
39
|
+
questions: [{
|
|
40
|
+
question: `发现 ${consolidation.issues.errors.length} 个严重问题,如何处理?`,
|
|
41
|
+
header: "阻塞问题",
|
|
42
|
+
multiSelect: false,
|
|
43
|
+
options: [
|
|
44
|
+
{label: "查看并修复", description: "显示问题列表,手动修复后重试"},
|
|
45
|
+
{label: "忽略继续", description: "跳过问题检查,继续装配"},
|
|
46
|
+
{label: "终止", description: "停止文档生成"}
|
|
47
|
+
]
|
|
48
|
+
}]
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (response === "查看并修复") {
|
|
52
|
+
return { action: "fix_required", errors: consolidation.issues.errors };
|
|
53
|
+
}
|
|
54
|
+
if (response === "终止") {
|
|
55
|
+
return { action: "abort" };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 2. 生成索引式文档(不读取章节内容)
|
|
60
|
+
const doc = generateIndexDocument(metadata, consolidation);
|
|
61
|
+
|
|
62
|
+
// 3. 写入最终文件
|
|
63
|
+
Write(`${outputDir}/${metadata.software_name}-软件设计说明书.md`, doc);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 文档模板
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
<!-- 页眉:{软件名称} - 版本号:{版本号} -->
|
|
70
|
+
|
|
71
|
+
# {软件名称} 软件设计说明书
|
|
72
|
+
|
|
73
|
+
## 文档信息
|
|
74
|
+
|
|
75
|
+
| 项目 | 内容 |
|
|
76
|
+
|------|------|
|
|
77
|
+
| 软件名称 | {software_name} |
|
|
78
|
+
| 版本号 | {version} |
|
|
79
|
+
| 生成日期 | {date} |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 1. 软件概述
|
|
84
|
+
|
|
85
|
+
### 1.1 软件背景与用途
|
|
86
|
+
|
|
87
|
+
[从 metadata 生成的软件背景描述]
|
|
88
|
+
|
|
89
|
+
### 1.2 开发目标与特点
|
|
90
|
+
|
|
91
|
+
[从 metadata 生成的目标和特点]
|
|
92
|
+
|
|
93
|
+
### 1.3 运行环境与技术架构
|
|
94
|
+
|
|
95
|
+
[从 metadata.tech_stack 生成]
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 文档导航
|
|
100
|
+
|
|
101
|
+
{consolidation.synthesis - 软件整体设计思路综述}
|
|
102
|
+
|
|
103
|
+
| 章节 | 说明 | 详情 |
|
|
104
|
+
|------|------|------|
|
|
105
|
+
| 2. 系统架构设计 | {summary} | [查看](./sections/section-2-architecture.md) |
|
|
106
|
+
| 3. 功能模块设计 | {summary} | [查看](./sections/section-3-functions.md) |
|
|
107
|
+
| 4. 核心算法与流程 | {summary} | [查看](./sections/section-4-algorithms.md) |
|
|
108
|
+
| 5. 数据结构设计 | {summary} | [查看](./sections/section-5-data-structures.md) |
|
|
109
|
+
| 6. 接口设计 | {summary} | [查看](./sections/section-6-interfaces.md) |
|
|
110
|
+
| 7. 异常处理设计 | {summary} | [查看](./sections/section-7-exceptions.md) |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 附录
|
|
115
|
+
|
|
116
|
+
- [跨模块分析报告](./cross-module-summary.md)
|
|
117
|
+
- [章节文件目录](./sections/)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
<!-- 页脚:生成时间 {timestamp} -->
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 生成函数
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
function generateIndexDocument(metadata, consolidation) {
|
|
128
|
+
const date = new Date().toLocaleDateString('zh-CN');
|
|
129
|
+
|
|
130
|
+
// 章节导航表格
|
|
131
|
+
const sectionTable = consolidation.section_summaries
|
|
132
|
+
.map(s => `| ${s.title} | ${s.summary} | [查看](./sections/${s.file}) |`)
|
|
133
|
+
.join('\n');
|
|
134
|
+
|
|
135
|
+
return `<!-- 页眉:${metadata.software_name} - 版本号:${metadata.version} -->
|
|
136
|
+
|
|
137
|
+
# ${metadata.software_name} 软件设计说明书
|
|
138
|
+
|
|
139
|
+
## 文档信息
|
|
140
|
+
|
|
141
|
+
| 项目 | 内容 |
|
|
142
|
+
|------|------|
|
|
143
|
+
| 软件名称 | ${metadata.software_name} |
|
|
144
|
+
| 版本号 | ${metadata.version} |
|
|
145
|
+
| 生成日期 | ${date} |
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## 1. 软件概述
|
|
150
|
+
|
|
151
|
+
### 1.1 软件背景与用途
|
|
152
|
+
|
|
153
|
+
${generateBackground(metadata)}
|
|
154
|
+
|
|
155
|
+
### 1.2 开发目标与特点
|
|
156
|
+
|
|
157
|
+
${generateObjectives(metadata)}
|
|
158
|
+
|
|
159
|
+
### 1.3 运行环境与技术架构
|
|
160
|
+
|
|
161
|
+
${generateTechStack(metadata)}
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 设计综述
|
|
166
|
+
|
|
167
|
+
${consolidation.synthesis}
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 文档导航
|
|
172
|
+
|
|
173
|
+
| 章节 | 说明 | 详情 |
|
|
174
|
+
|------|------|------|
|
|
175
|
+
${sectionTable}
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 附录
|
|
180
|
+
|
|
181
|
+
- [跨模块分析报告](./cross-module-summary.md)
|
|
182
|
+
- [章节文件目录](./sections/)
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
<!-- 页脚:生成时间 ${new Date().toISOString()} -->
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function generateBackground(metadata) {
|
|
191
|
+
const categoryDescriptions = {
|
|
192
|
+
"命令行工具 (CLI)": "提供命令行界面,用户通过终端命令与系统交互",
|
|
193
|
+
"后端服务/API": "提供 RESTful/GraphQL API 接口,支持前端或其他服务调用",
|
|
194
|
+
"SDK/库": "提供可复用的代码库,供其他项目集成使用",
|
|
195
|
+
"数据处理系统": "处理数据导入、转换、分析和导出",
|
|
196
|
+
"自动化脚本": "自动执行重复性任务,提高工作效率"
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
return `${metadata.software_name}是一款${metadata.category}软件。${categoryDescriptions[metadata.category] || ''}
|
|
200
|
+
|
|
201
|
+
本软件基于${metadata.tech_stack.language}语言开发,运行于${metadata.tech_stack.runtime}环境,采用${metadata.tech_stack.framework || '原生'}框架实现核心功能。`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function generateObjectives(metadata) {
|
|
205
|
+
return `本软件旨在${metadata.purpose || '解决特定领域的技术问题'}。
|
|
206
|
+
|
|
207
|
+
主要技术特点包括${metadata.tech_stack.framework ? `采用 ${metadata.tech_stack.framework} 框架` : '模块化设计'},具备良好的可扩展性和可维护性。`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function generateTechStack(metadata) {
|
|
211
|
+
return `**运行环境**
|
|
212
|
+
|
|
213
|
+
- 操作系统:${metadata.os || 'Windows/Linux/macOS'}
|
|
214
|
+
- 运行时:${metadata.tech_stack.runtime}
|
|
215
|
+
- 依赖环境:${metadata.tech_stack.dependencies?.join(', ') || '无特殊依赖'}
|
|
216
|
+
|
|
217
|
+
**技术架构**
|
|
218
|
+
|
|
219
|
+
- 架构模式:${metadata.architecture_pattern || '分层架构'}
|
|
220
|
+
- 核心框架:${metadata.tech_stack.framework || '原生实现'}
|
|
221
|
+
- 主要模块:详见第2章系统架构设计`;
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## 输出结构
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
.workflow/.scratchpad/copyright-{timestamp}/
|
|
229
|
+
├── sections/ # 独立章节(Phase 2 产出)
|
|
230
|
+
│ ├── section-2-architecture.md
|
|
231
|
+
│ ├── section-3-functions.md
|
|
232
|
+
│ └── ...
|
|
233
|
+
├── cross-module-summary.md # 跨模块报告(Phase 2.5 产出)
|
|
234
|
+
└── {软件名称}-软件设计说明书.md # 索引文档(本阶段产出)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## 与 Phase 2.5 的协作
|
|
238
|
+
|
|
239
|
+
Phase 2.5 consolidation agent 需要提供:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
interface ConsolidationOutput {
|
|
243
|
+
synthesis: string; // 设计思路综述(2-3 段落)
|
|
244
|
+
section_summaries: Array<{
|
|
245
|
+
file: string; // 文件名
|
|
246
|
+
title: string; // 章节标题(如"2. 系统架构设计")
|
|
247
|
+
summary: string; // 一句话说明
|
|
248
|
+
}>;
|
|
249
|
+
issues: {...};
|
|
250
|
+
stats: {...};
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## 关键变更
|
|
255
|
+
|
|
256
|
+
| 原设计 | 新设计 |
|
|
257
|
+
|--------|--------|
|
|
258
|
+
| 读取章节内容并拼接 | 链接引用,不读取内容 |
|
|
259
|
+
| 嵌入完整章节 | 仅提供导航索引 |
|
|
260
|
+
| 重复生成统计 | 引用 cross-module-summary.md |
|
|
261
|
+
| 大文件 | 精简索引文档 |
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Phase 5: Compliance Review & Iterative Refinement
|
|
2
|
+
|
|
3
|
+
Discovery-driven refinement loop until CPCC compliance is met.
|
|
4
|
+
|
|
5
|
+
## Execution
|
|
6
|
+
|
|
7
|
+
### Step 1: Extract Compliance Issues
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
function extractComplianceIssues(validationResult, deepAnalysis) {
|
|
11
|
+
return {
|
|
12
|
+
// Missing or incomplete sections
|
|
13
|
+
missingSections: validationResult.details
|
|
14
|
+
.filter(d => !d.pass)
|
|
15
|
+
.map(d => ({
|
|
16
|
+
section: d.name,
|
|
17
|
+
severity: 'critical',
|
|
18
|
+
suggestion: `需要补充 ${d.name} 相关内容`
|
|
19
|
+
})),
|
|
20
|
+
|
|
21
|
+
// Features with weak descriptions (< 50 chars)
|
|
22
|
+
weakDescriptions: (deepAnalysis.functions?.feature_list || [])
|
|
23
|
+
.filter(f => !f.description || f.description.length < 50)
|
|
24
|
+
.map(f => ({
|
|
25
|
+
feature: f.name,
|
|
26
|
+
current: f.description || '(无描述)',
|
|
27
|
+
severity: 'warning'
|
|
28
|
+
})),
|
|
29
|
+
|
|
30
|
+
// Complex algorithms without detailed flowcharts
|
|
31
|
+
complexAlgorithms: (deepAnalysis.algorithms?.algorithms || [])
|
|
32
|
+
.filter(a => (a.complexity || 0) > 10 && (a.steps?.length || 0) < 5)
|
|
33
|
+
.map(a => ({
|
|
34
|
+
algorithm: a.name,
|
|
35
|
+
complexity: a.complexity,
|
|
36
|
+
file: a.file,
|
|
37
|
+
severity: 'warning'
|
|
38
|
+
})),
|
|
39
|
+
|
|
40
|
+
// Data relationships without descriptions
|
|
41
|
+
incompleteRelationships: (deepAnalysis.data_structures?.relationships || [])
|
|
42
|
+
.filter(r => !r.description)
|
|
43
|
+
.map(r => ({from: r.from, to: r.to, severity: 'info'})),
|
|
44
|
+
|
|
45
|
+
// Diagram validation issues
|
|
46
|
+
diagramIssues: (deepAnalysis.diagrams?.validation || [])
|
|
47
|
+
.filter(d => !d.valid)
|
|
48
|
+
.map(d => ({file: d.file, issues: d.issues, severity: 'critical'}))
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Step 2: Build Dynamic Questions
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
function buildComplianceQuestions(issues) {
|
|
57
|
+
const questions = [];
|
|
58
|
+
|
|
59
|
+
if (issues.missingSections.length > 0) {
|
|
60
|
+
questions.push({
|
|
61
|
+
question: `发现 ${issues.missingSections.length} 个章节内容不完整,需要补充哪些?`,
|
|
62
|
+
header: "章节补充",
|
|
63
|
+
multiSelect: true,
|
|
64
|
+
options: issues.missingSections.slice(0, 4).map(s => ({
|
|
65
|
+
label: s.section,
|
|
66
|
+
description: s.suggestion
|
|
67
|
+
}))
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (issues.weakDescriptions.length > 0) {
|
|
72
|
+
questions.push({
|
|
73
|
+
question: `以下 ${issues.weakDescriptions.length} 个功能描述过于简短,请选择需要详细说明的:`,
|
|
74
|
+
header: "功能描述",
|
|
75
|
+
multiSelect: true,
|
|
76
|
+
options: issues.weakDescriptions.slice(0, 4).map(f => ({
|
|
77
|
+
label: f.feature,
|
|
78
|
+
description: `当前:${f.current.substring(0, 30)}...`
|
|
79
|
+
}))
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (issues.complexAlgorithms.length > 0) {
|
|
84
|
+
questions.push({
|
|
85
|
+
question: `发现 ${issues.complexAlgorithms.length} 个复杂算法缺少详细流程图,是否生成?`,
|
|
86
|
+
header: "算法详解",
|
|
87
|
+
multiSelect: false,
|
|
88
|
+
options: [
|
|
89
|
+
{label: "全部生成 (推荐)", description: "为所有复杂算法生成含分支/循环的流程图"},
|
|
90
|
+
{label: "仅最复杂的", description: `仅为 ${issues.complexAlgorithms[0]?.algorithm} 生成`},
|
|
91
|
+
{label: "跳过", description: "保持当前简单流程图"}
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
questions.push({
|
|
97
|
+
question: "如何处理当前文档?",
|
|
98
|
+
header: "操作",
|
|
99
|
+
multiSelect: false,
|
|
100
|
+
options: [
|
|
101
|
+
{label: "应用修改并继续", description: "应用上述选择,继续检查"},
|
|
102
|
+
{label: "完成文档", description: "当前文档满足要求,生成最终版本"},
|
|
103
|
+
{label: "重新分析", description: "使用不同配置重新分析代码"}
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return questions.slice(0, 4);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Step 3: Apply Updates
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
async function applyComplianceUpdates(responses, issues, analyses, outputDir) {
|
|
115
|
+
const updates = [];
|
|
116
|
+
|
|
117
|
+
if (responses['章节补充']) {
|
|
118
|
+
for (const section of responses['章节补充']) {
|
|
119
|
+
const sectionAnalysis = await Task({
|
|
120
|
+
subagent_type: "cli-explore-agent",
|
|
121
|
+
prompt: `深入分析 ${section.section} 所需内容...`
|
|
122
|
+
});
|
|
123
|
+
updates.push({type: 'section_supplement', section: section.section, data: sectionAnalysis});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (responses['算法详解'] === '全部生成 (推荐)') {
|
|
128
|
+
for (const algo of issues.complexAlgorithms) {
|
|
129
|
+
const detailedSteps = await analyzeAlgorithmInDepth(algo, analyses);
|
|
130
|
+
const flowchart = generateAlgorithmFlowchart({
|
|
131
|
+
name: algo.algorithm,
|
|
132
|
+
inputs: detailedSteps.inputs,
|
|
133
|
+
outputs: detailedSteps.outputs,
|
|
134
|
+
steps: detailedSteps.steps
|
|
135
|
+
});
|
|
136
|
+
Write(`${outputDir}/diagrams/algorithm-${sanitizeId(algo.algorithm)}-detailed.mmd`, flowchart);
|
|
137
|
+
updates.push({type: 'algorithm_flowchart', algorithm: algo.algorithm});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return updates;
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Step 4: Iteration Loop
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
async function runComplianceLoop(documentPath, analyses, metadata, outputDir) {
|
|
149
|
+
let iteration = 0;
|
|
150
|
+
const maxIterations = 5;
|
|
151
|
+
|
|
152
|
+
while (iteration < maxIterations) {
|
|
153
|
+
iteration++;
|
|
154
|
+
|
|
155
|
+
// Validate current document
|
|
156
|
+
const document = Read(documentPath);
|
|
157
|
+
const validation = validateCPCCCompliance(document, analyses);
|
|
158
|
+
|
|
159
|
+
// Extract issues
|
|
160
|
+
const issues = extractComplianceIssues(validation, analyses);
|
|
161
|
+
const totalIssues = Object.values(issues).flat().length;
|
|
162
|
+
|
|
163
|
+
if (totalIssues === 0) {
|
|
164
|
+
console.log("✅ 所有检查通过,文档符合 CPCC 要求");
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Ask user
|
|
169
|
+
const questions = buildComplianceQuestions(issues);
|
|
170
|
+
const responses = await AskUserQuestion({questions});
|
|
171
|
+
|
|
172
|
+
if (responses['操作'] === '完成文档') break;
|
|
173
|
+
if (responses['操作'] === '重新分析') return {action: 'restart'};
|
|
174
|
+
|
|
175
|
+
// Apply updates
|
|
176
|
+
const updates = await applyComplianceUpdates(responses, issues, analyses, outputDir);
|
|
177
|
+
|
|
178
|
+
// Regenerate document
|
|
179
|
+
const updatedDocument = regenerateDocument(document, updates, analyses);
|
|
180
|
+
Write(documentPath, updatedDocument);
|
|
181
|
+
|
|
182
|
+
// Archive iteration
|
|
183
|
+
Write(`${outputDir}/iterations/v${iteration}.md`, document);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {action: 'finalized', iterations: iteration};
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Output
|
|
191
|
+
|
|
192
|
+
Final compliant document + iteration history in `iterations/`.
|