@andyqiu/codeforge 0.3.5 → 0.3.8
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/commands/parallel-status.md +56 -0
- package/commands/parallel.md +38 -1
- package/commands/refactor.md +79 -0
- package/commands/review.md +66 -0
- package/commands/tdd.md +91 -0
- package/dist/index.js +1138 -602
- package/package.json +5 -1
- package/workflows/code-review.yaml +66 -0
- package/workflows/refactor.yaml +106 -0
- package/workflows/tdd.yaml +99 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andyqiu/codeforge",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "CodeForge — opencode 的零侵入扩展包",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
39
39
|
"test": "vitest run",
|
|
40
40
|
"test:watch": "vitest",
|
|
41
|
+
"test:coverage": "vitest run --coverage",
|
|
42
|
+
"bench": "node --experimental-strip-types --no-warnings ./scripts/bench-repo-map.mjs",
|
|
43
|
+
"bench:json": "node --experimental-strip-types --no-warnings ./scripts/bench-repo-map.mjs --json",
|
|
41
44
|
"lint": "tsc --noEmit",
|
|
42
45
|
"check:bun": "node ./scripts/check-bun.mjs",
|
|
43
46
|
"install:local": "bash ./install.sh",
|
|
@@ -79,6 +82,7 @@
|
|
|
79
82
|
"@opencode-ai/plugin": "^1.15.0",
|
|
80
83
|
"@opencode-ai/sdk": "^1.15.0",
|
|
81
84
|
"@types/node": "^22.0.0",
|
|
85
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
82
86
|
"husky": "^9.1.7",
|
|
83
87
|
"typescript": "^5.6.0",
|
|
84
88
|
"vitest": "^2.1.0"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# ──────────────────────────────────────────────────────────────
|
|
2
|
+
# code-review.yaml — 审阅别人的 PR / diff(最常用 workflow)
|
|
3
|
+
# trigger: /review
|
|
4
|
+
# 流程:取 diff → planner 出审阅维度 → reviewer 多维度审 → 沉淀
|
|
5
|
+
# 注意:本流程只读,不 stage / apply 任何改动
|
|
6
|
+
# ──────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
name: code-review
|
|
9
|
+
max_loops: 1
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
description: |
|
|
12
|
+
审阅 PR / diff / 本地未提交改动的工作流:
|
|
13
|
+
1. 取 diff(默认 git diff,支持指定 base 分支或 PR URL)
|
|
14
|
+
2. planner 看 diff 内容,列出审阅维度(安全 / 性能 / 可维护性 / 测试 / 风格)
|
|
15
|
+
3. reviewer 按维度逐项审,跑测试,输出 APPROVE / REQUEST_CHANGES / BLOCK
|
|
16
|
+
4. 沉淀关键发现到 KH(gotcha / convention 类)
|
|
17
|
+
|
|
18
|
+
trigger: /review
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: 准备 diff
|
|
22
|
+
agent: reviewer
|
|
23
|
+
description: 取 diff 上下文(git diff / PR)
|
|
24
|
+
actions:
|
|
25
|
+
- tool: smart_search
|
|
26
|
+
args:
|
|
27
|
+
query: "code review checklist ${user_request}"
|
|
28
|
+
limit: 5
|
|
29
|
+
on_error: skip
|
|
30
|
+
on_error: abort
|
|
31
|
+
|
|
32
|
+
- name: 出审阅维度
|
|
33
|
+
agent: planner
|
|
34
|
+
description: 基于 diff 内容 + 项目特点,列出本次审阅必查的维度清单
|
|
35
|
+
inject_context:
|
|
36
|
+
role_hint: 你只列审阅维度,不评审具体代码
|
|
37
|
+
on_error: abort
|
|
38
|
+
|
|
39
|
+
- name: 审阅
|
|
40
|
+
agent: reviewer
|
|
41
|
+
description: 按维度清单逐项审,跑测试,输出 APPROVE/REQUEST_CHANGES/BLOCK
|
|
42
|
+
actions:
|
|
43
|
+
- tool: pending-changes
|
|
44
|
+
args:
|
|
45
|
+
action: list
|
|
46
|
+
status: pending
|
|
47
|
+
on_error: skip
|
|
48
|
+
on_decision:
|
|
49
|
+
APPROVE: continue
|
|
50
|
+
REQUEST_CHANGES: continue # 仍 continue 进入沉淀,REQUEST_CHANGES 是给提交者看的
|
|
51
|
+
BLOCK: abort
|
|
52
|
+
on_error: abort
|
|
53
|
+
|
|
54
|
+
- name: 沉淀
|
|
55
|
+
agent: reviewer
|
|
56
|
+
description: 把发现的 gotcha / convention 沉淀到 KH
|
|
57
|
+
actions:
|
|
58
|
+
- tool: save_chat_insight
|
|
59
|
+
args:
|
|
60
|
+
insight: "${session_summary}"
|
|
61
|
+
category: gotcha
|
|
62
|
+
tags:
|
|
63
|
+
- "trigger:/review"
|
|
64
|
+
- "workflow:code-review"
|
|
65
|
+
on_error: skip
|
|
66
|
+
on_error: skip
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# ──────────────────────────────────────────────────────────────
|
|
2
|
+
# refactor.yaml — 安全重构工作流
|
|
3
|
+
# trigger: /refactor
|
|
4
|
+
# 流程:planner → 补 characterization test → 重构 → 测试仍绿 → apply
|
|
5
|
+
# 参考:Working Effectively with Legacy Code(Michael Feathers)
|
|
6
|
+
# ──────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
name: refactor
|
|
9
|
+
max_loops: 3
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
description: |
|
|
12
|
+
安全重构流程(参考 Working Effectively with Legacy Code):
|
|
13
|
+
1. planner 分析现状、列出重构方案
|
|
14
|
+
2. coder A 阶段:先补 characterization test(描述现状行为,可能很难看)
|
|
15
|
+
3. reviewer 确认 test 覆盖待重构代码的现有行为
|
|
16
|
+
4. coder B 阶段:开始重构,每步必须保证 test 仍绿
|
|
17
|
+
5. reviewer 最终确认:行为不变 + 代码更清晰
|
|
18
|
+
6. apply 落地
|
|
19
|
+
|
|
20
|
+
trigger: /refactor
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: 规划
|
|
24
|
+
agent: planner
|
|
25
|
+
description: 列出重构目标 / 涉及文件 / 拆步计划
|
|
26
|
+
actions:
|
|
27
|
+
- tool: smart_search
|
|
28
|
+
args:
|
|
29
|
+
query: "${user_request} refactor"
|
|
30
|
+
limit: 5
|
|
31
|
+
on_error: skip
|
|
32
|
+
on_error: abort
|
|
33
|
+
|
|
34
|
+
- name: 补特征测试
|
|
35
|
+
agent: coder
|
|
36
|
+
description: 先写 characterization tests,覆盖现状行为(不为重构,只为锁定行为)
|
|
37
|
+
auto_feedback:
|
|
38
|
+
test_cmd: "npm test"
|
|
39
|
+
max_retries: 3
|
|
40
|
+
error_excerpt_lines: 5
|
|
41
|
+
escalate_to: reviewer
|
|
42
|
+
on_error: retry
|
|
43
|
+
max_retries: 1
|
|
44
|
+
|
|
45
|
+
- name: 确认覆盖
|
|
46
|
+
agent: reviewer
|
|
47
|
+
description: 确认 characterization tests 覆盖了所有待重构代码路径
|
|
48
|
+
on_decision:
|
|
49
|
+
APPROVE: continue
|
|
50
|
+
REQUEST_CHANGES:
|
|
51
|
+
action: goto
|
|
52
|
+
target: 补特征测试
|
|
53
|
+
BLOCK: abort
|
|
54
|
+
on_error: abort
|
|
55
|
+
|
|
56
|
+
- name: 重构
|
|
57
|
+
agent: coder
|
|
58
|
+
description: 实施重构,每步必须保证已写的 tests 全绿
|
|
59
|
+
auto_feedback:
|
|
60
|
+
test_cmd: "npm test"
|
|
61
|
+
max_retries: 5
|
|
62
|
+
error_excerpt_lines: 5
|
|
63
|
+
escalate_to: reviewer
|
|
64
|
+
on_error: retry
|
|
65
|
+
max_retries: 1
|
|
66
|
+
|
|
67
|
+
- name: 审阅
|
|
68
|
+
agent: reviewer
|
|
69
|
+
description: 确认行为不变(tests 绿)+ 代码更清晰
|
|
70
|
+
actions:
|
|
71
|
+
- tool: pending-changes
|
|
72
|
+
args:
|
|
73
|
+
action: list
|
|
74
|
+
status: pending
|
|
75
|
+
on_decision:
|
|
76
|
+
APPROVE: continue
|
|
77
|
+
REQUEST_CHANGES:
|
|
78
|
+
action: goto
|
|
79
|
+
target: 重构
|
|
80
|
+
BLOCK: abort
|
|
81
|
+
on_error: abort
|
|
82
|
+
|
|
83
|
+
- name: 落地
|
|
84
|
+
agent: coder
|
|
85
|
+
description: 用户审批通过后 apply 全部 pending
|
|
86
|
+
requires_human_approval: true
|
|
87
|
+
actions:
|
|
88
|
+
- tool: pending-changes
|
|
89
|
+
args:
|
|
90
|
+
action: apply_all
|
|
91
|
+
on_error: abort
|
|
92
|
+
on_error: abort
|
|
93
|
+
|
|
94
|
+
- name: 沉淀
|
|
95
|
+
agent: reviewer
|
|
96
|
+
description: 把这次重构的经验沉淀回 KH
|
|
97
|
+
actions:
|
|
98
|
+
- tool: save_chat_insight
|
|
99
|
+
args:
|
|
100
|
+
insight: "${session_summary}"
|
|
101
|
+
category: workflow
|
|
102
|
+
tags:
|
|
103
|
+
- "trigger:/refactor"
|
|
104
|
+
- "workflow:refactor"
|
|
105
|
+
on_error: skip
|
|
106
|
+
on_error: skip
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# ──────────────────────────────────────────────────────────────
|
|
2
|
+
# tdd.yaml — Test-Driven Development 严格流程
|
|
3
|
+
# trigger: /tdd
|
|
4
|
+
# 流程:拆需求 → RED 测试 → 验证红 → GREEN 实现 → REFACTOR → 审阅 → apply
|
|
5
|
+
# ──────────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
name: tdd
|
|
8
|
+
max_loops: 5
|
|
9
|
+
version: 1.0.0
|
|
10
|
+
description: |
|
|
11
|
+
Test-Driven Development 严格流程:
|
|
12
|
+
1. planner 拆需求成可测的小步骤
|
|
13
|
+
2. 循环 N 次(每个小步骤):
|
|
14
|
+
a. coder 写 RED 测试(必须先红,否则 BLOCK)
|
|
15
|
+
b. coder 写最小实现(必须变绿)
|
|
16
|
+
c. coder refactor(仍绿)
|
|
17
|
+
d. reviewer APPROVE 进下一循环
|
|
18
|
+
3. 全部完成后 apply
|
|
19
|
+
|
|
20
|
+
trigger: /tdd
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: 拆需求
|
|
24
|
+
agent: planner
|
|
25
|
+
description: 把需求拆成可测的小步骤清单
|
|
26
|
+
actions:
|
|
27
|
+
- tool: smart_search
|
|
28
|
+
args:
|
|
29
|
+
query: "${user_request} tdd"
|
|
30
|
+
limit: 5
|
|
31
|
+
on_error: skip
|
|
32
|
+
on_error: abort
|
|
33
|
+
|
|
34
|
+
- name: 写测试-RED
|
|
35
|
+
agent: coder
|
|
36
|
+
description: 先写测试。必须先跑红(无实现→失败),否则 BLOCK
|
|
37
|
+
inject_context:
|
|
38
|
+
role_hint: 你只写测试,不写实现。测试必须先失败再继续
|
|
39
|
+
on_error: retry
|
|
40
|
+
max_retries: 1
|
|
41
|
+
|
|
42
|
+
- name: 验证 RED
|
|
43
|
+
agent: reviewer
|
|
44
|
+
description: 跑 npm test,确认新测试是红的(如果绿了说明测试无效)
|
|
45
|
+
on_decision:
|
|
46
|
+
APPROVE: continue # APPROVE 意味着"测试确实红了"
|
|
47
|
+
REQUEST_CHANGES:
|
|
48
|
+
action: goto
|
|
49
|
+
target: 写测试-RED
|
|
50
|
+
BLOCK: abort
|
|
51
|
+
on_error: abort
|
|
52
|
+
|
|
53
|
+
- name: 最小实现-GREEN
|
|
54
|
+
agent: coder
|
|
55
|
+
description: 写最小实现,让测试变绿。不要超出测试需要
|
|
56
|
+
auto_feedback:
|
|
57
|
+
test_cmd: "npm test"
|
|
58
|
+
max_retries: 5
|
|
59
|
+
error_excerpt_lines: 5
|
|
60
|
+
escalate_to: reviewer
|
|
61
|
+
on_error: retry
|
|
62
|
+
max_retries: 1
|
|
63
|
+
|
|
64
|
+
- name: 重构-REFACTOR
|
|
65
|
+
agent: coder
|
|
66
|
+
description: 测试绿了之后可选 refactor;任何时刻测试必须仍绿
|
|
67
|
+
auto_feedback:
|
|
68
|
+
test_cmd: "npm test"
|
|
69
|
+
max_retries: 3
|
|
70
|
+
error_excerpt_lines: 5
|
|
71
|
+
escalate_to: reviewer
|
|
72
|
+
on_error: skip # refactor 是可选步骤,跳过也行
|
|
73
|
+
|
|
74
|
+
- name: 审阅
|
|
75
|
+
agent: reviewer
|
|
76
|
+
description: 确认 RED→GREEN→REFACTOR 三步全做,测试覆盖核心
|
|
77
|
+
actions:
|
|
78
|
+
- tool: pending-changes
|
|
79
|
+
args:
|
|
80
|
+
action: list
|
|
81
|
+
status: pending
|
|
82
|
+
on_decision:
|
|
83
|
+
APPROVE: continue
|
|
84
|
+
REQUEST_CHANGES:
|
|
85
|
+
action: goto
|
|
86
|
+
target: 写测试-RED
|
|
87
|
+
BLOCK: abort
|
|
88
|
+
on_error: abort
|
|
89
|
+
|
|
90
|
+
- name: 落地
|
|
91
|
+
agent: coder
|
|
92
|
+
description: 用户审批通过后 apply 全部 pending
|
|
93
|
+
requires_human_approval: true
|
|
94
|
+
actions:
|
|
95
|
+
- tool: pending-changes
|
|
96
|
+
args:
|
|
97
|
+
action: apply_all
|
|
98
|
+
on_error: abort
|
|
99
|
+
on_error: abort
|