claude-code-workflow 6.3.22 → 6.3.24
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/agents/issue-plan-agent.md +10 -5
- package/.claude/commands/issue/plan.md +1 -1
- package/.claude/skills/review-code/SKILL.md +170 -0
- package/.claude/skills/review-code/phases/actions/action-collect-context.md +139 -0
- package/.claude/skills/review-code/phases/actions/action-complete.md +115 -0
- package/.claude/skills/review-code/phases/actions/action-deep-review.md +302 -0
- package/.claude/skills/review-code/phases/actions/action-generate-report.md +263 -0
- package/.claude/skills/review-code/phases/actions/action-quick-scan.md +164 -0
- package/.claude/skills/review-code/phases/orchestrator.md +251 -0
- package/.claude/skills/review-code/phases/state-manager.md +752 -0
- package/.claude/skills/review-code/phases/state-schema.md +174 -0
- package/.claude/skills/review-code/specs/issue-classification.md +228 -0
- package/.claude/skills/review-code/specs/quality-standards.md +214 -0
- package/.claude/skills/review-code/specs/review-dimensions.md +337 -0
- package/.claude/skills/review-code/specs/rules/architecture-rules.json +63 -0
- package/.claude/skills/review-code/specs/rules/correctness-rules.json +60 -0
- package/.claude/skills/review-code/specs/rules/index.md +140 -0
- package/.claude/skills/review-code/specs/rules/performance-rules.json +59 -0
- package/.claude/skills/review-code/specs/rules/readability-rules.json +60 -0
- package/.claude/skills/review-code/specs/rules/security-rules.json +58 -0
- package/.claude/skills/review-code/specs/rules/testing-rules.json +59 -0
- package/.claude/skills/review-code/templates/issue-template.md +186 -0
- package/.claude/skills/review-code/templates/review-report.md +173 -0
- package/.claude/skills/skill-generator/SKILL.md +56 -17
- package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +10 -0
- package/.claude/skills/skill-generator/templates/sequential-phase.md +9 -0
- package/.claude/skills/skill-generator/templates/skill-md.md +84 -5
- package/.claude/workflows/cli-templates/schemas/solution-schema.json +3 -3
- package/ccw/src/templates/dashboard-js/views/issue-manager.js +8 -0
- package/package.json +1 -1
- package/.claude/skills/code-reviewer/README.md +0 -340
- package/.claude/skills/code-reviewer/SKILL.md +0 -308
- package/.claude/skills/code-reviewer/phases/01-code-discovery.md +0 -246
- package/.claude/skills/code-reviewer/phases/02-security-analysis.md +0 -442
- package/.claude/skills/code-reviewer/phases/03-best-practices-review.md +0 -36
- package/.claude/skills/code-reviewer/phases/04-report-generation.md +0 -278
- package/.claude/skills/code-reviewer/specs/best-practices-requirements.md +0 -346
- package/.claude/skills/code-reviewer/specs/quality-standards.md +0 -252
- package/.claude/skills/code-reviewer/specs/security-requirements.md +0 -243
- package/.claude/skills/code-reviewer/templates/best-practice-finding.md +0 -234
- package/.claude/skills/code-reviewer/templates/report-template.md +0 -316
- package/.claude/skills/code-reviewer/templates/security-finding.md +0 -161
|
@@ -212,14 +212,14 @@ Write solution JSON to JSONL file (one line per solution):
|
|
|
212
212
|
|
|
213
213
|
**File Format** (JSONL - each line is a complete solution):
|
|
214
214
|
```
|
|
215
|
-
{"id":"SOL-GH-123-
|
|
216
|
-
{"id":"SOL-GH-123-
|
|
215
|
+
{"id":"SOL-GH-123-a7x9","description":"...","approach":"...","analysis":{...},"score":0.85,"tasks":[...]}
|
|
216
|
+
{"id":"SOL-GH-123-b2k4","description":"...","approach":"...","analysis":{...},"score":0.75,"tasks":[...]}
|
|
217
217
|
```
|
|
218
218
|
|
|
219
219
|
**Solution Schema** (must match CLI `Solution` interface):
|
|
220
220
|
```typescript
|
|
221
221
|
{
|
|
222
|
-
id: string; // Format: SOL-{issue-id}-{
|
|
222
|
+
id: string; // Format: SOL-{issue-id}-{uid}
|
|
223
223
|
description?: string;
|
|
224
224
|
approach?: string;
|
|
225
225
|
tasks: SolutionTask[];
|
|
@@ -232,9 +232,14 @@ Write solution JSON to JSONL file (one line per solution):
|
|
|
232
232
|
**Write Operation**:
|
|
233
233
|
```javascript
|
|
234
234
|
// Append solution to JSONL file (one line per solution)
|
|
235
|
-
|
|
235
|
+
// Use 4-char random uid to avoid collisions across multiple plan runs
|
|
236
|
+
const uid = Math.random().toString(36).slice(2, 6); // e.g., "a7x9"
|
|
237
|
+
const solutionId = `SOL-${issueId}-${uid}`;
|
|
236
238
|
const solutionLine = JSON.stringify({ id: solutionId, ...solution });
|
|
237
239
|
|
|
240
|
+
// Bash equivalent for uid generation:
|
|
241
|
+
// uid=$(cat /dev/urandom | tr -dc 'a-z0-9' | head -c 4)
|
|
242
|
+
|
|
238
243
|
// Read existing, append new line, write back
|
|
239
244
|
const filePath = `.workflow/issues/solutions/${issueId}.jsonl`;
|
|
240
245
|
const existing = existsSync(filePath) ? readFileSync(filePath) : '';
|
|
@@ -311,7 +316,7 @@ Each line is a solution JSON containing tasks. Schema: `cat .claude/workflows/cl
|
|
|
311
316
|
6. Evaluate each solution with `analysis` and `score`
|
|
312
317
|
7. Write solutions to `.workflow/issues/solutions/{issue-id}.jsonl` (append mode)
|
|
313
318
|
8. For HIGH complexity: generate 2-3 candidate solutions
|
|
314
|
-
9. **Solution ID format**: `SOL-{issue-id}-{
|
|
319
|
+
9. **Solution ID format**: `SOL-{issue-id}-{uid}` where uid is 4 random alphanumeric chars (e.g., `SOL-GH-123-a7x9`)
|
|
315
320
|
10. **GitHub Reply Task**: If issue has `github_url` or `github_number`, add final task to comment on GitHub issue with completion summary
|
|
316
321
|
|
|
317
322
|
**CONFLICT AVOIDANCE** (for batch processing of similar issues):
|
|
@@ -203,7 +203,7 @@ ${issueList}
|
|
|
203
203
|
7. Single solution → auto-bind; Multiple → return for selection
|
|
204
204
|
|
|
205
205
|
### Rules
|
|
206
|
-
- Solution ID format: SOL-{issue-id}-{
|
|
206
|
+
- Solution ID format: SOL-{issue-id}-{uid} (uid: 4 random alphanumeric chars, e.g., a7x9)
|
|
207
207
|
- Single solution per issue → auto-bind via ccw issue bind
|
|
208
208
|
- Multiple solutions → register only, return pending_selection
|
|
209
209
|
- Tasks must have quantified acceptance.criteria
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-code
|
|
3
|
+
description: Multi-dimensional code review with structured reports. Analyzes correctness, readability, performance, security, testing, and architecture. Triggers on "review code", "code review", "审查代码", "代码审查".
|
|
4
|
+
allowed-tools: Task, AskUserQuestion, Read, Write, Glob, Grep, Bash, mcp__ace-tool__search_context, mcp__ide__getDiagnostics
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Review Code
|
|
8
|
+
|
|
9
|
+
Multi-dimensional code review skill that analyzes code across 6 key dimensions and generates structured review reports with actionable recommendations.
|
|
10
|
+
|
|
11
|
+
## Architecture Overview
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
15
|
+
│ ⚠️ Phase 0: Specification Study (强制前置) │
|
|
16
|
+
│ → 阅读 specs/review-dimensions.md │
|
|
17
|
+
│ → 理解审查维度和问题分类标准 │
|
|
18
|
+
└───────────────┬─────────────────────────────────────────────────┘
|
|
19
|
+
↓
|
|
20
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
21
|
+
│ Orchestrator (状态驱动决策) │
|
|
22
|
+
│ → 读取状态 → 选择审查动作 → 执行 → 更新状态 │
|
|
23
|
+
└───────────────┬─────────────────────────────────────────────────┘
|
|
24
|
+
│
|
|
25
|
+
┌───────────┼───────────┬───────────┬───────────┐
|
|
26
|
+
↓ ↓ ↓ ↓ ↓
|
|
27
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
28
|
+
│ Collect │ │ Quick │ │ Deep │ │ Report │ │Complete │
|
|
29
|
+
│ Context │ │ Scan │ │ Review │ │ Generate│ │ │
|
|
30
|
+
└─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘
|
|
31
|
+
↓ ↓ ↓ ↓
|
|
32
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
33
|
+
│ Review Dimensions │
|
|
34
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
35
|
+
│ │Correctness│ │Readability│ │Performance│ │ Security │ │
|
|
36
|
+
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
|
|
37
|
+
│ ┌──────────┐ ┌──────────┐ │
|
|
38
|
+
│ │ Testing │ │Architecture│ │
|
|
39
|
+
│ └──────────┘ └──────────┘ │
|
|
40
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Key Design Principles
|
|
44
|
+
|
|
45
|
+
1. **多维度审查**: 覆盖正确性、可读性、性能、安全性、测试覆盖、架构一致性六大维度
|
|
46
|
+
2. **分层执行**: 快速扫描识别高风险区域,深入审查聚焦关键问题
|
|
47
|
+
3. **结构化报告**: 按严重程度分类,提供文件位置和修复建议
|
|
48
|
+
4. **状态驱动**: 自主模式,根据审查进度动态选择下一步动作
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## ⚠️ Mandatory Prerequisites (强制前置条件)
|
|
53
|
+
|
|
54
|
+
> **⛔ 禁止跳过**: 在执行任何审查操作之前,**必须**完整阅读以下文档。
|
|
55
|
+
|
|
56
|
+
### 规范文档 (必读)
|
|
57
|
+
|
|
58
|
+
| Document | Purpose | Priority |
|
|
59
|
+
|----------|---------|----------|
|
|
60
|
+
| [specs/review-dimensions.md](specs/review-dimensions.md) | 审查维度定义和检查点 | **P0 - 最高** |
|
|
61
|
+
| [specs/issue-classification.md](specs/issue-classification.md) | 问题分类和严重程度标准 | **P0 - 最高** |
|
|
62
|
+
| [specs/quality-standards.md](specs/quality-standards.md) | 审查质量标准 | P1 |
|
|
63
|
+
|
|
64
|
+
### 模板文件 (生成前必读)
|
|
65
|
+
|
|
66
|
+
| Document | Purpose |
|
|
67
|
+
|----------|---------|
|
|
68
|
+
| [templates/review-report.md](templates/review-report.md) | 审查报告模板 |
|
|
69
|
+
| [templates/issue-template.md](templates/issue-template.md) | 问题记录模板 |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Execution Flow
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
77
|
+
│ Phase 0: Specification Study (强制前置 - 禁止跳过) │
|
|
78
|
+
│ → Read: specs/review-dimensions.md │
|
|
79
|
+
│ → Read: specs/issue-classification.md │
|
|
80
|
+
│ → 理解审查标准和问题分类 │
|
|
81
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
82
|
+
│ Action: collect-context │
|
|
83
|
+
│ → 收集目标文件/目录 │
|
|
84
|
+
│ → 识别技术栈和语言 │
|
|
85
|
+
│ → Output: state.context (files, language, framework) │
|
|
86
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
87
|
+
│ Action: quick-scan │
|
|
88
|
+
│ → 快速扫描整体结构 │
|
|
89
|
+
│ → 识别高风险区域 │
|
|
90
|
+
│ → Output: state.risk_areas, state.scan_summary │
|
|
91
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
92
|
+
│ Action: deep-review (per dimension) │
|
|
93
|
+
│ → 逐维度深入审查 │
|
|
94
|
+
│ → 记录发现的问题 │
|
|
95
|
+
│ → Output: state.findings[] │
|
|
96
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
97
|
+
│ Action: generate-report │
|
|
98
|
+
│ → 汇总所有发现 │
|
|
99
|
+
│ → 生成结构化报告 │
|
|
100
|
+
│ → Output: review-report.md │
|
|
101
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
102
|
+
│ Action: complete │
|
|
103
|
+
│ → 保存最终状态 │
|
|
104
|
+
│ → 输出审查摘要 │
|
|
105
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Directory Setup
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
const timestamp = new Date().toISOString().slice(0,19).replace(/[-:T]/g, '');
|
|
112
|
+
const workDir = `.workflow/.scratchpad/review-code-${timestamp}`;
|
|
113
|
+
|
|
114
|
+
Bash(`mkdir -p "${workDir}"`);
|
|
115
|
+
Bash(`mkdir -p "${workDir}/findings"`);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Output Structure
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
.workflow/.scratchpad/review-code-{timestamp}/
|
|
122
|
+
├── state.json # 审查状态
|
|
123
|
+
├── context.json # 目标上下文
|
|
124
|
+
├── findings/ # 问题发现
|
|
125
|
+
│ ├── correctness.json
|
|
126
|
+
│ ├── readability.json
|
|
127
|
+
│ ├── performance.json
|
|
128
|
+
│ ├── security.json
|
|
129
|
+
│ ├── testing.json
|
|
130
|
+
│ └── architecture.json
|
|
131
|
+
└── review-report.md # 最终审查报告
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Review Dimensions
|
|
135
|
+
|
|
136
|
+
| Dimension | Focus Areas | Key Checks |
|
|
137
|
+
|-----------|-------------|------------|
|
|
138
|
+
| **Correctness** | 逻辑正确性 | 边界条件、错误处理、null 检查 |
|
|
139
|
+
| **Readability** | 代码可读性 | 命名规范、函数长度、注释质量 |
|
|
140
|
+
| **Performance** | 性能效率 | 算法复杂度、I/O 优化、资源使用 |
|
|
141
|
+
| **Security** | 安全性 | 注入风险、敏感信息、权限控制 |
|
|
142
|
+
| **Testing** | 测试覆盖 | 测试充分性、边界覆盖、可维护性 |
|
|
143
|
+
| **Architecture** | 架构一致性 | 设计模式、分层结构、依赖管理 |
|
|
144
|
+
|
|
145
|
+
## Issue Severity Levels
|
|
146
|
+
|
|
147
|
+
| Level | Prefix | Description | Action Required |
|
|
148
|
+
|-------|--------|-------------|-----------------|
|
|
149
|
+
| **Critical** | [C] | 阻塞性问题,必须立即修复 | Must fix before merge |
|
|
150
|
+
| **High** | [H] | 重要问题,需要修复 | Should fix |
|
|
151
|
+
| **Medium** | [M] | 建议改进 | Consider fixing |
|
|
152
|
+
| **Low** | [L] | 可选优化 | Nice to have |
|
|
153
|
+
| **Info** | [I] | 信息性建议 | For reference |
|
|
154
|
+
|
|
155
|
+
## Reference Documents
|
|
156
|
+
|
|
157
|
+
| Document | Purpose |
|
|
158
|
+
|----------|---------|
|
|
159
|
+
| [phases/orchestrator.md](phases/orchestrator.md) | 审查编排器 |
|
|
160
|
+
| [phases/state-schema.md](phases/state-schema.md) | 状态结构定义 |
|
|
161
|
+
| [phases/actions/action-collect-context.md](phases/actions/action-collect-context.md) | 收集上下文 |
|
|
162
|
+
| [phases/actions/action-quick-scan.md](phases/actions/action-quick-scan.md) | 快速扫描 |
|
|
163
|
+
| [phases/actions/action-deep-review.md](phases/actions/action-deep-review.md) | 深入审查 |
|
|
164
|
+
| [phases/actions/action-generate-report.md](phases/actions/action-generate-report.md) | 生成报告 |
|
|
165
|
+
| [phases/actions/action-complete.md](phases/actions/action-complete.md) | 完成审查 |
|
|
166
|
+
| [specs/review-dimensions.md](specs/review-dimensions.md) | 审查维度规范 |
|
|
167
|
+
| [specs/issue-classification.md](specs/issue-classification.md) | 问题分类标准 |
|
|
168
|
+
| [specs/quality-standards.md](specs/quality-standards.md) | 质量标准 |
|
|
169
|
+
| [templates/review-report.md](templates/review-report.md) | 报告模板 |
|
|
170
|
+
| [templates/issue-template.md](templates/issue-template.md) | 问题模板 |
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Action: Collect Context
|
|
2
|
+
|
|
3
|
+
收集审查目标的上下文信息。
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
在开始审查前,收集目标代码的基本信息:
|
|
8
|
+
- 确定审查范围(文件/目录)
|
|
9
|
+
- 识别编程语言和框架
|
|
10
|
+
- 统计代码规模
|
|
11
|
+
|
|
12
|
+
## Preconditions
|
|
13
|
+
|
|
14
|
+
- [ ] state.status === 'pending' || state.context === null
|
|
15
|
+
|
|
16
|
+
## Execution
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
async function execute(state, workDir) {
|
|
20
|
+
// 1. 询问用户审查目标
|
|
21
|
+
const input = await AskUserQuestion({
|
|
22
|
+
questions: [{
|
|
23
|
+
question: "请指定要审查的代码路径:",
|
|
24
|
+
header: "审查目标",
|
|
25
|
+
multiSelect: false,
|
|
26
|
+
options: [
|
|
27
|
+
{ label: "当前目录", description: "审查当前工作目录下的所有代码" },
|
|
28
|
+
{ label: "src/", description: "审查 src/ 目录" },
|
|
29
|
+
{ label: "手动指定", description: "输入自定义路径" }
|
|
30
|
+
]
|
|
31
|
+
}]
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const targetPath = input["审查目标"] === "手动指定"
|
|
35
|
+
? input["其他"]
|
|
36
|
+
: input["审查目标"] === "当前目录" ? "." : "src/";
|
|
37
|
+
|
|
38
|
+
// 2. 收集文件列表
|
|
39
|
+
const files = Glob(`${targetPath}/**/*.{ts,tsx,js,jsx,py,java,go,rs,cpp,c,cs}`);
|
|
40
|
+
|
|
41
|
+
// 3. 检测主要语言
|
|
42
|
+
const languageCounts = {};
|
|
43
|
+
files.forEach(file => {
|
|
44
|
+
const ext = file.split('.').pop();
|
|
45
|
+
const langMap = {
|
|
46
|
+
'ts': 'TypeScript', 'tsx': 'TypeScript',
|
|
47
|
+
'js': 'JavaScript', 'jsx': 'JavaScript',
|
|
48
|
+
'py': 'Python',
|
|
49
|
+
'java': 'Java',
|
|
50
|
+
'go': 'Go',
|
|
51
|
+
'rs': 'Rust',
|
|
52
|
+
'cpp': 'C++', 'c': 'C',
|
|
53
|
+
'cs': 'C#'
|
|
54
|
+
};
|
|
55
|
+
const lang = langMap[ext] || 'Unknown';
|
|
56
|
+
languageCounts[lang] = (languageCounts[lang] || 0) + 1;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const primaryLanguage = Object.entries(languageCounts)
|
|
60
|
+
.sort((a, b) => b[1] - a[1])[0]?.[0] || 'Unknown';
|
|
61
|
+
|
|
62
|
+
// 4. 统计代码行数
|
|
63
|
+
let totalLines = 0;
|
|
64
|
+
for (const file of files.slice(0, 100)) { // 限制前100个文件
|
|
65
|
+
try {
|
|
66
|
+
const content = Read(file);
|
|
67
|
+
totalLines += content.split('\n').length;
|
|
68
|
+
} catch (e) {}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 5. 检测框架
|
|
72
|
+
let framework = null;
|
|
73
|
+
if (files.some(f => f.includes('package.json'))) {
|
|
74
|
+
const pkg = JSON.parse(Read('package.json'));
|
|
75
|
+
if (pkg.dependencies?.react) framework = 'React';
|
|
76
|
+
else if (pkg.dependencies?.vue) framework = 'Vue';
|
|
77
|
+
else if (pkg.dependencies?.angular) framework = 'Angular';
|
|
78
|
+
else if (pkg.dependencies?.express) framework = 'Express';
|
|
79
|
+
else if (pkg.dependencies?.next) framework = 'Next.js';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 6. 构建上下文
|
|
83
|
+
const context = {
|
|
84
|
+
target_path: targetPath,
|
|
85
|
+
files: files.slice(0, 200), // 限制最多200个文件
|
|
86
|
+
language: primaryLanguage,
|
|
87
|
+
framework: framework,
|
|
88
|
+
total_lines: totalLines,
|
|
89
|
+
file_count: files.length
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// 7. 保存上下文
|
|
93
|
+
Write(`${workDir}/context.json`, JSON.stringify(context, null, 2));
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
stateUpdates: {
|
|
97
|
+
status: 'running',
|
|
98
|
+
context: context
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## State Updates
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
return {
|
|
108
|
+
stateUpdates: {
|
|
109
|
+
status: 'running',
|
|
110
|
+
context: {
|
|
111
|
+
target_path: targetPath,
|
|
112
|
+
files: fileList,
|
|
113
|
+
language: primaryLanguage,
|
|
114
|
+
framework: detectedFramework,
|
|
115
|
+
total_lines: totalLines,
|
|
116
|
+
file_count: fileCount
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Output
|
|
123
|
+
|
|
124
|
+
- **File**: `context.json`
|
|
125
|
+
- **Location**: `${workDir}/context.json`
|
|
126
|
+
- **Format**: JSON
|
|
127
|
+
|
|
128
|
+
## Error Handling
|
|
129
|
+
|
|
130
|
+
| Error Type | Recovery |
|
|
131
|
+
|------------|----------|
|
|
132
|
+
| 路径不存在 | 提示用户重新输入 |
|
|
133
|
+
| 无代码文件 | 返回错误,终止审查 |
|
|
134
|
+
| 读取权限问题 | 跳过该文件,记录警告 |
|
|
135
|
+
|
|
136
|
+
## Next Actions
|
|
137
|
+
|
|
138
|
+
- 成功: action-quick-scan
|
|
139
|
+
- 失败: action-abort
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Action: Complete
|
|
2
|
+
|
|
3
|
+
完成审查,保存最终状态。
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
结束代码审查流程:
|
|
8
|
+
- 保存最终状态
|
|
9
|
+
- 输出审查摘要
|
|
10
|
+
- 提供报告路径
|
|
11
|
+
|
|
12
|
+
## Preconditions
|
|
13
|
+
|
|
14
|
+
- [ ] state.status === 'running'
|
|
15
|
+
- [ ] state.report_generated === true
|
|
16
|
+
|
|
17
|
+
## Execution
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
async function execute(state, workDir) {
|
|
21
|
+
// 1. 计算审查时长
|
|
22
|
+
const duration = Date.now() - new Date(state.started_at).getTime();
|
|
23
|
+
const durationMinutes = Math.round(duration / 60000);
|
|
24
|
+
|
|
25
|
+
// 2. 生成最终摘要
|
|
26
|
+
const summary = {
|
|
27
|
+
...state.summary,
|
|
28
|
+
review_duration_ms: duration,
|
|
29
|
+
completed_at: new Date().toISOString()
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// 3. 保存最终状态
|
|
33
|
+
const finalState = {
|
|
34
|
+
...state,
|
|
35
|
+
status: 'completed',
|
|
36
|
+
completed_at: summary.completed_at,
|
|
37
|
+
summary: summary
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
Write(`${workDir}/state.json`, JSON.stringify(finalState, null, 2));
|
|
41
|
+
|
|
42
|
+
// 4. 输出摘要信息
|
|
43
|
+
console.log('========================================');
|
|
44
|
+
console.log(' CODE REVIEW COMPLETED');
|
|
45
|
+
console.log('========================================');
|
|
46
|
+
console.log('');
|
|
47
|
+
console.log(`📁 审查目标: ${state.context.target_path}`);
|
|
48
|
+
console.log(`📄 文件数量: ${state.context.file_count}`);
|
|
49
|
+
console.log(`📝 代码行数: ${state.context.total_lines}`);
|
|
50
|
+
console.log('');
|
|
51
|
+
console.log('--- 问题统计 ---');
|
|
52
|
+
console.log(`🔴 Critical: ${summary.critical}`);
|
|
53
|
+
console.log(`🟠 High: ${summary.high}`);
|
|
54
|
+
console.log(`🟡 Medium: ${summary.medium}`);
|
|
55
|
+
console.log(`🔵 Low: ${summary.low}`);
|
|
56
|
+
console.log(`⚪ Info: ${summary.info}`);
|
|
57
|
+
console.log(`📊 Total: ${summary.total_issues}`);
|
|
58
|
+
console.log('');
|
|
59
|
+
console.log(`⏱️ 审查用时: ${durationMinutes} 分钟`);
|
|
60
|
+
console.log('');
|
|
61
|
+
console.log(`📋 报告位置: ${state.report_path}`);
|
|
62
|
+
console.log('========================================');
|
|
63
|
+
|
|
64
|
+
// 5. 返回状态更新
|
|
65
|
+
return {
|
|
66
|
+
stateUpdates: {
|
|
67
|
+
status: 'completed',
|
|
68
|
+
completed_at: summary.completed_at,
|
|
69
|
+
summary: summary
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## State Updates
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
return {
|
|
79
|
+
stateUpdates: {
|
|
80
|
+
status: 'completed',
|
|
81
|
+
completed_at: new Date().toISOString(),
|
|
82
|
+
summary: {
|
|
83
|
+
total_issues: state.summary.total_issues,
|
|
84
|
+
critical: state.summary.critical,
|
|
85
|
+
high: state.summary.high,
|
|
86
|
+
medium: state.summary.medium,
|
|
87
|
+
low: state.summary.low,
|
|
88
|
+
info: state.summary.info,
|
|
89
|
+
review_duration_ms: duration
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Output
|
|
96
|
+
|
|
97
|
+
- **Console**: 审查完成摘要
|
|
98
|
+
- **State**: 最终状态保存到 `state.json`
|
|
99
|
+
|
|
100
|
+
## Error Handling
|
|
101
|
+
|
|
102
|
+
| Error Type | Recovery |
|
|
103
|
+
|------------|----------|
|
|
104
|
+
| 状态保存失败 | 输出到控制台 |
|
|
105
|
+
|
|
106
|
+
## Next Actions
|
|
107
|
+
|
|
108
|
+
- 无(终止状态)
|
|
109
|
+
|
|
110
|
+
## Post-Completion
|
|
111
|
+
|
|
112
|
+
用户可以:
|
|
113
|
+
1. 查看完整报告: `cat ${workDir}/review-report.md`
|
|
114
|
+
2. 查看问题详情: `cat ${workDir}/findings/*.json`
|
|
115
|
+
3. 导出报告到其他位置
|