@hupan56/wlkj 3.4.2 → 3.4.4
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/package.json +1 -1
- package/templates/qoder/commands/wl-code.md +34 -218
- package/templates/qoder/commands/wl-commit.md +46 -43
- package/templates/qoder/commands/wl-prd.md +87 -371
- package/templates/qoder/commands/wl-prd.md.bak +371 -0
- package/templates/qoder/commands/wl-search.md +41 -220
- package/templates/qoder/commands/wl-task.md +622 -619
- package/templates/qoder/commands/wl-test.md +159 -156
- package/templates/qoder/scripts/protocol/mcp/kg_mcp_server.py +8 -8
package/package.json
CHANGED
|
@@ -1,218 +1,34 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: wl-code
|
|
3
|
-
description: "
|
|
4
|
-
argument-hint: "[
|
|
5
|
-
auto-approve:
|
|
6
|
-
allowed-tools: [Read, Glob, Grep, Bash, Write, Edit]
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# /wl-code -
|
|
10
|
-
|
|
11
|
-
User input: $ARGUMENTS
|
|
12
|
-
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
> 这是 Step 4 自检之后的硬门禁:过→回流;不过→列问题修,重跑;无 Ultra Review→手动 checklist 降级。
|
|
36
|
-
|
|
37
|
-
### 强制流程(Step 4 自检后执行)
|
|
38
|
-
1. 自检 4 项全 ✓ 后,**立即调 Ultra Review Agent**(宿主原生能力)审查本次改动
|
|
39
|
-
2. **分支裁决**:
|
|
40
|
-
- ✅ **过** → 调 `submit_return` 回流 + `learn` 沉淀(见 Step 5 / 学习沉淀段)
|
|
41
|
-
- ❌ **不过** → 列出 Review 指出的问题(边界/性能/安全/规范),逐条修,**重跑 Ultra Review**,不过不回流
|
|
42
|
-
3. **降级**(宿主无 Ultra Review Agent):按下方手动 checklist 逐条过,全 ✓ 视同通过
|
|
43
|
-
|
|
44
|
-
### 手动 checklist 降级(无 Ultra Review 时)
|
|
45
|
-
- [ ] 边界条件:空值/越界/并发/大数量都处理了
|
|
46
|
-
- [ ] 性能:无 N+1 查询、无循环里调 DB、大数据量分页
|
|
47
|
-
- [ ] 安全:入参校验、权限校验、SQL 无拼接注入
|
|
48
|
-
- [ ] 异常路径:Spec 定义的异常场景都有对应处理
|
|
49
|
-
- [ ] 规范:与周围代码风格一致(命名/注释/分层)
|
|
50
|
-
|
|
51
|
-
## Step 1: Spec Gate(强制前置 · 非侵入式)
|
|
52
|
-
|
|
53
|
-
> ⚠️ **核心门禁**:没有 `status: confirmed` 的 spec,**绝不动手写代码**。
|
|
54
|
-
> 本 gate 只在走 `/wl-code` 命令时生效;用户不调 `/wl-code` 时完全无感。
|
|
55
|
-
|
|
56
|
-
### 1.1 定位 spec(确定性检测)
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# 用 paths.find_spec 确定性查找 (查 .qoder/workspace/specs/ + 当前任务目录, 读 status)
|
|
60
|
-
SPEC=$($PY -c "
|
|
61
|
-
import sys, json; sys.path.insert(0,'$R/.qoder/scripts')
|
|
62
|
-
from foundation.bootstrap import setup; setup()
|
|
63
|
-
from foundation.core.paths import find_spec, get_spec_status
|
|
64
|
-
hits = find_spec('$ARGUMENTS') if '$ARGUMENTS' else find_spec()
|
|
65
|
-
if hits:
|
|
66
|
-
# 优先输出 confirmed 的; 都不是 confirmed 就输出第一个(draft)
|
|
67
|
-
confirmed = [h for h in hits if h['status']=='confirmed']
|
|
68
|
-
chosen = confirmed[0] if confirmed else hits[0]
|
|
69
|
-
print(json.dumps(chosen, ensure_ascii=False))
|
|
70
|
-
")
|
|
71
|
-
```
|
|
72
|
-
- 有 `$ARGUMENTS`(REQ-ID)→ `find_spec('REQ-ID')` 查全局 specs/
|
|
73
|
-
- 无参数 → `find_spec()` 读当前任务目录的 spec.md
|
|
74
|
-
|
|
75
|
-
### 1.2 检查 status 字段 → 三分支
|
|
76
|
-
|
|
77
|
-
读 spec 文件契约头的 `status:`:
|
|
78
|
-
|
|
79
|
-
| 情况 | 处理 |
|
|
80
|
-
|------|------|
|
|
81
|
-
| **无 spec** | → 调 **spec-generator** 生成(读 `templates/spec-template.md`,产出 `status: draft`)→ 进入 1.3 确认环节 |
|
|
82
|
-
| **status: draft**(或非 confirmed) | → 展示 spec 全文 + 关键决策点(接口/表结构/异常枚举/AI边界)→ 进入 1.3 确认环节 |
|
|
83
|
-
| **status: confirmed** | ✅ 放行,进入 Step 2 |
|
|
84
|
-
|
|
85
|
-
### 1.3 确认环节(停在写码之前)
|
|
86
|
-
|
|
87
|
-
向用户展示 spec 后,明确询问:
|
|
88
|
-
|
|
89
|
-
> 📋 spec 已就绪(`status: draft`):`{spec路径}`
|
|
90
|
-
> 你可以:① 直接说哪里要改 ② 自己打开文件改后告诉我 ③ 回复「确认」开始写代码
|
|
91
|
-
>
|
|
92
|
-
> **确认前不会写任何代码。**
|
|
93
|
-
|
|
94
|
-
- 用户提修改 → 按反馈改 spec(或重读用户改过的文件)→ 再次展示 → 再问确认
|
|
95
|
-
- 用户回复「确认」→ AI 把 spec 契约头 `status: draft` 改为 `status: confirmed` → **先做 1.4 回填禅道** → 才进入 Step 2
|
|
96
|
-
- ❌ 用户未确认时,**禁止推进到 Step 2,禁止写任何代码**(哪怕催促)
|
|
97
|
-
|
|
98
|
-
> 向后兼容:老 spec 无 `status` 字段 → 视同 `draft`,走确认环节(不直接写码)。
|
|
99
|
-
|
|
100
|
-
### 1.4 确认后回填禅道 task(仅禅道来源的 spec)
|
|
101
|
-
|
|
102
|
-
spec 契约头有 `zentao: task=X` 时,确认后把 spec 摘要回填到该 task(让禅道里能看到开发规格要点):
|
|
103
|
-
|
|
104
|
-
```python
|
|
105
|
-
# 组装摘要:接口清单 + 关键表 + 异常条数 + AC 映射 + 本地 spec 路径(全量太长,只取要点)
|
|
106
|
-
summary = build_spec_digest(spec_path) # 第1章接口表 + 第2章表名 + 第3章异常计数 + 第6章AC映射
|
|
107
|
-
cap.mcp.call("update_task", {"task_id": X, "desc": summary + "\n本地spec: " + spec_path})
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
- **非侵入**:禅道不可达 / spec 无 zentao 字段 → 跳过回填,不阻塞写码(已在 Step 1 拿到 PRD,回填是锦上添花)
|
|
111
|
-
- **失败不阻塞**:update_task 返回 ⚠️(权限/网络)→ 提示用户但继续写码
|
|
112
|
-
- **不重复回填**:契约头已标 `回填=true`(或 task desc 末尾已含本地路径)→ 跳过
|
|
113
|
-
|
|
114
|
-
> panel 也可调同一个 `update_task` 做回填,两边都行(谁先触发都行,不冲突)。
|
|
115
|
-
|
|
116
|
-
## Step 2: Search Related Code(RAG 语义召回,不只关键词)
|
|
117
|
-
|
|
118
|
-
**改代码前用 rag_search 找相关函数/API(语义召回最全),精确符号定位才用 search_code。**
|
|
119
|
-
|
|
120
|
-
```python
|
|
121
|
-
from capability import resolve
|
|
122
|
-
cap = resolve()
|
|
123
|
-
# ⓪ 有 REQ-ID/禅道号时查这需求的历史代码变更(code_changes 按需求号→改过哪些函数/hunk)
|
|
124
|
-
# 看这需求历史改过啥,避免重复改/沿用历史模式。与 code_history(按文件查) 互补。
|
|
125
|
-
if <有 REQ-ID 或禅道号>:
|
|
126
|
-
changes = cap.mcp.call("code_changes", {"project_id": "<项目UUID>", "req_key": "<REQ-ID或XQ/WT号>"})
|
|
127
|
-
# ① rag_search 语义召回:找和需求相关的函数/API/字段(词不必一样,召回最全)
|
|
128
|
-
rag = cap.mcp.call("rag_search", {"query": "<需求关键词或功能描述>", "top_k": 10})
|
|
129
|
-
# ② 需要精确找某个已知符号(如 handleExport)才用 search_code
|
|
130
|
-
precise = cap.mcp.call("search_code", {"keyword": "<精确符号名>"})
|
|
131
|
-
# ③ 影响分析(必跑):改这些符号会影响谁/依赖谁,按项目仓库隔离,避免改一处崩一片
|
|
132
|
-
# project_id 从 mcp_config.json 的 WLKJ_PROJECT_ID 取(绑当前项目)
|
|
133
|
-
# get_impact 返回分层 upstream(谁依赖我→改动影响范围)/downstream(我依赖谁)+byType
|
|
134
|
-
impact = cap.mcp.call("get_impact", {
|
|
135
|
-
"project_id": "<项目UUID>", # mcp_config.json 的 WLKJ_PROJECT_ID
|
|
136
|
-
"entity": "<要改的核心符号: 如 handleExport / C:FlowOperationController>",
|
|
137
|
-
"depth": 2,
|
|
138
|
-
})
|
|
139
|
-
# ③a 改码前风险三件套(get_impact 看影响面 → risk_assessment 看风险等级 → code_history 看历史 → get_confidence 看证据置信)
|
|
140
|
-
# risk_assessment 返回 score/level(7项多证据:影响面/DB写/覆盖缺口/路径置信缺口/缺需求链路/历史不稳定/Agent变更);
|
|
141
|
-
# code_history 返回这文件/函数被哪些需求(XQ/WT)改过、改了什么(反向:代码→需求);
|
|
142
|
-
# get_confidence 返回路径置信度(0-1)+证据路径链。
|
|
143
|
-
# level=high/critical 或 confidence 低 → 先在回复里提示风险再动手。
|
|
144
|
-
risk = cap.mcp.call("risk_assessment", {"project_id": "<项目UUID>", "entity": "<核心符号>", "depth": 2})
|
|
145
|
-
history = cap.mcp.call("code_history", {"project_id": "<项目UUID>", "file_path": "<文件名或路径片段>"})
|
|
146
|
-
conf = cap.mcp.call("get_confidence", {"project_id": "<项目UUID>", "entity": "<核心符号>"})
|
|
147
|
-
# ③c 终极门禁裁决(合成 risk+coverage → block/warn/pass + 保形策略/alpha)
|
|
148
|
-
# gate.decision=block 须拦停问用户(高风险+裸改);warn 可放行带提示;pass 放心改
|
|
149
|
-
gate = cap.mcp.call("gate_check", {"project_id": "<项目UUID>", "entity": "<核心符号>"})
|
|
150
|
-
# 影响面大 / risk level≥high / confidence 低 / gate=block 时,先提示风险再动手(block 须拦停问用户)
|
|
151
|
-
# ③d 影响面大时多层并行审改动风险(宿主支持 Agent 并行 → 派 3 个 subagent 各审一层,合并风险清单):
|
|
152
|
-
# - 前端层:谁调用这个接口/符号?改动会不会破坏调用方?
|
|
153
|
-
# - 后端层:实现逻辑/事务/调用链是否自洽?
|
|
154
|
-
# - DB层:涉及表/字段改动是否波及别处(trace_dataflow 已追全链)?
|
|
155
|
-
# 不支持 Agent 并行 → 上面 risk_assessment 单点结果已够(串行降级)。
|
|
156
|
-
# ③e 门禁前知识新鲜度(改码前看知识层是否过期,过期数据不可信):
|
|
157
|
-
# check_freshness 返回模块 avg_age_days + 是否过期;过期(>threshold)→提示 refresh_knowledge 再动手
|
|
158
|
-
fresh = cap.mcp.call("check_freshness", {"module": "<核心模块>", "threshold_days": 30})
|
|
159
|
-
# fresh.verdict 含"过期" → 提示用户知识层陈旧,建议先 refresh_knowledge(跑构建脚本)再改码
|
|
160
|
-
# ③b 涉及字段改动(加列/改类型/表单字段):追字段全链路(表单→接口→Java字段→DB列),改一处看全链
|
|
161
|
-
if <涉及字段层>:
|
|
162
|
-
cap.mcp.call("trace_dataflow", {"field": "<字段名>"}) # 防"改了DB列没改对应Java字段/前端表单"
|
|
163
|
-
# ④ 涉及数据库改动的,查真表结构(引擎自己的 MySQL MCP,别猜列名)
|
|
164
|
-
if <涉及数据库层>:
|
|
165
|
-
schema = cap.mcp.call("query_schema", {"table": "<表名>"}) # qoder-mysql 工具
|
|
166
|
-
# 真表结构回流平台
|
|
167
|
-
cap.mcp.call("learn", {"project_id":"<项目UUID>","category":"rule",
|
|
168
|
-
"pattern": f"真表结构<表名>: {json.dumps(schema.get('columns',[]),ensure_ascii=False)[:400]}",
|
|
169
|
-
"source":"wlkj/wl-code+mysql"})
|
|
170
|
-
```
|
|
171
|
-
等价 CLI(脚本兜底):
|
|
172
|
-
```bash
|
|
173
|
-
$PY "$R/.qoder/scripts/orchestration/wlkj.py" search <keyword>
|
|
174
|
-
```
|
|
175
|
-
Find existing code that this implementation relates to.
|
|
176
|
-
Read relevant files for context.
|
|
177
|
-
|
|
178
|
-
**接地铁律**:实现时调用的函数名/字段名/API 路径必须来自 rag_search 召回结果(系统里真有的),不编造不存在的 API。改码前用 get_impact 拿分层影响范围(谁依赖我/我依赖谁),影响面大先提示风险再动手,避免改一处崩一片。
|
|
179
|
-
|
|
180
|
-
## Step 3: Implement
|
|
181
|
-
|
|
182
|
-
Follow the spec strictly:
|
|
183
|
-
1. Read spec-coder skill for coding workflow
|
|
184
|
-
2. Implement each requirement from spec
|
|
185
|
-
3. Follow team conventions from data/code/ patterns
|
|
186
|
-
4. Write clean, commented code
|
|
187
|
-
|
|
188
|
-
> **宿主 sub-agent 激活**:QoderWork 支持 sub-agent 时,dispatch 到 **`qoder-coder`** agent(`.qoder/agents/qoder-coder.toml`)——它内置 Spec 契约实现规范(数据层 Entity→Mapper→Service→Controller / 接口层 RESTful+校验+统一返回 / 异常按 Spec),递归守卫不二次 spawn。dispatch prompt 首行传 `Active Spec: <spec路径>`。不支持 sub-agent 时按上面 4 步手动实现。
|
|
189
|
-
|
|
190
|
-
## Step 4: Self-Check
|
|
191
|
-
|
|
192
|
-
After implementation:
|
|
193
|
-
- [ ] All spec requirements covered
|
|
194
|
-
- [ ] No TODO/FIXME left
|
|
195
|
-
- [ ] Code follows project conventions
|
|
196
|
-
- [ ] Error handling in place
|
|
197
|
-
|
|
198
|
-
## Step 5: Report
|
|
199
|
-
|
|
200
|
-
Tell user what was implemented and suggest next:
|
|
201
|
-
- `/wl-test <描述>` — 跑测试验证(改动大时先 `impact_coverage` 圈必跑范围)
|
|
202
|
-
- 验过后 `/wl-commit <message>` — 提交+push+回流平台(自动 record_commit)
|
|
203
|
-
|
|
204
|
-
## 下一步
|
|
205
|
-
- 实现 → `/wl-test` 验证 → `/wl-commit` 提交回流 → `/wl-task finish <REQ-ID>` 收尾(双通飞轮)
|
|
206
|
-
|
|
207
|
-
## 🧠 学习沉淀(改完代码即执行,反哺下次)
|
|
208
|
-
|
|
209
|
-
改代码过程中发现的业务规则/架构约定/踩坑经验,调 learn 写回平台:
|
|
210
|
-
```python
|
|
211
|
-
cap.mcp.call("learn", {
|
|
212
|
-
"project_id": "<项目UUID>",
|
|
213
|
-
"category": "pitfall", # pitfall=踩坑 / rule=业务规则 / decision=架构决策
|
|
214
|
-
"pattern": "<学到的,如:VehicleController 的 save 方法必须先校验驾驶员是否存在>",
|
|
215
|
-
"source": "wlkj/wl-code",
|
|
216
|
-
})
|
|
217
|
-
```
|
|
218
|
-
- 至少写 1 条最有价值的认知。try/except 不阻塞。
|
|
1
|
+
---
|
|
2
|
+
name: wl-code
|
|
3
|
+
description: "改码方案:影响分析+风险评估。MCP工具优先,禁跑本地脚本。"
|
|
4
|
+
argument-hint: "[要改的实体/功能]"
|
|
5
|
+
auto-approve: true
|
|
6
|
+
allowed-tools: [Read, Glob, Grep, Bash, Write, Edit]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# /wl-code - 改码方案
|
|
10
|
+
|
|
11
|
+
User input: $ARGUMENTS
|
|
12
|
+
|
|
13
|
+
## 🚨 MCP工具优先,禁止跑本地脚本
|
|
14
|
+
|
|
15
|
+
| 要什么 | 工具 |
|
|
16
|
+
|---|---|
|
|
17
|
+
| 改XX影响谁 | get_impact |
|
|
18
|
+
| 全上下文 | context_pack |
|
|
19
|
+
| 代码搜索 | search_code |
|
|
20
|
+
| 功能画像 | feature_overview |
|
|
21
|
+
|
|
22
|
+
> QoderWork: mcp__qoder-knowledge-graph__<工具名>
|
|
23
|
+
|
|
24
|
+
## 流程
|
|
25
|
+
|
|
26
|
+
1. 调 get_impact 查影响面(upstream谁依赖我/downstream我依赖谁)
|
|
27
|
+
2. 调 context_pack 取上下文(代码+API+字段)
|
|
28
|
+
3. 输出:改动范围/影响面/风险/必跑测试/改前注意
|
|
29
|
+
|
|
30
|
+
## 🚨 接地铁律
|
|
31
|
+
1. 溯源:引用符号用真实原名
|
|
32
|
+
2. 禁编:不编造未召回实体
|
|
33
|
+
3. 接地:涉及表结构先调search_field
|
|
34
|
+
4. 完整:方案详尽
|
|
@@ -1,46 +1,49 @@
|
|
|
1
|
-
---
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
- [ ]
|
|
39
|
-
- [ ]
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
-
|
|
43
|
-
|
|
1
|
+
---
|
|
2
|
+
n## 🚨 MCP工具优先,禁跑本地脚本
|
|
3
|
+
所有知识查询走 mcp__qoder-knowledge-graph__ 工具(云平台),绝不跑 wlkj.py kg(本地kg空)。
|
|
4
|
+
|
|
5
|
+
name: wl-commit
|
|
6
|
+
description: "代码提交 + push + 同步,带质量门禁。Git commit + push + sync with pre-commit quality gate. "
|
|
7
|
+
argument-hint: "[commit message]"
|
|
8
|
+
auto-approve: false
|
|
9
|
+
allowed-tools: [Read, Glob, Grep, Bash, Write, Edit]
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# /wl-commit - Git Commit + Push + Sync
|
|
13
|
+
|
|
14
|
+
User input: $ARGUMENTS (commit message)
|
|
15
|
+
|
|
16
|
+
## Flow
|
|
17
|
+
1. Check git status for uncommitted changes
|
|
18
|
+
2. Auto-stage changed files
|
|
19
|
+
3. Generate commit message if not provided:
|
|
20
|
+
- Format: [ai-generated] {type}: {description}
|
|
21
|
+
- Types: feat/fix/docs/refactor/test
|
|
22
|
+
4. Ask user to confirm commit message
|
|
23
|
+
5. Commit with message
|
|
24
|
+
6. Pull latest from remote (sync)
|
|
25
|
+
7. Push to remote
|
|
26
|
+
8. 回流平台:提交 + push 后执行回流,把本次 commit 沉淀到平台知识层
|
|
27
|
+
```bash
|
|
28
|
+
R=$(python ~/.qoderwork/repo_root.py 2>/dev/null || python3 ~/.qoderwork/repo_root.py 2>/dev/null) || R=.
|
|
29
|
+
PY=$(python --version >/dev/null 2>&1 && echo python || echo python3)
|
|
30
|
+
$PY "$R/.qoder/scripts/orchestration/wlkj.py" return commit --last
|
|
31
|
+
```
|
|
32
|
+
- 自动取 HEAD commit(sha/message/author/时间)→ POST 平台 `/api/git/commits/record`
|
|
33
|
+
- message 里的 `[#REQ-xxx]` / `[#<禅道号>]` 平台自动解析,建 commit→需求 边
|
|
34
|
+
- 失败只告警不阻塞(回流是增强,主流程 commit 已落地)
|
|
35
|
+
|
|
36
|
+
## Pre-commit Quality Gate
|
|
37
|
+
Before committing, check:
|
|
38
|
+
- [ ] All tests pass (if /wl-test was run)
|
|
39
|
+
- [ ] No TODO/FIXME left in code
|
|
40
|
+
- [ ] Commit tagged [ai-generated] or [ai-assisted]
|
|
41
|
+
- [ ] Commit message 含需求标记 `[#REQ-xxx]` 或 `[#<禅道号>]`(关联平台需求,回流自动建边;多需求 `[#REQ-aaa][#REQ-bbb]`)
|
|
42
|
+
- [ ] Amount fields use BigDecimal (if applicable)
|
|
43
|
+
|
|
44
|
+
## 下一步
|
|
45
|
+
- 提交回流成功后,更新任务状态:`/wl-task finish <REQ-ID>`(标记开发完成,同步禅道)
|
|
46
|
+
- 查看本次提交在需求链路的位置:平台资产中心 → 需求 → 变更史
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
## 🚨 接地铁律(防幻觉/保真)
|