@devcxl/opencode-cabbage 0.3.0 → 0.3.2
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/assets/agents/dev-lifecycle.md +14 -8
- package/assets/agents/team/architect.md +31 -0
- package/assets/agents/team/backend.md +34 -0
- package/assets/agents/team/frontend.md +35 -0
- package/assets/agents/team/reviewer.md +36 -1
- package/assets/context/CONTEXT.md +2 -1
- package/assets/skills/flow-design/SKILL.md +11 -1
- package/assets/skills/flow-requirements/SKILL.md +191 -24
- package/assets/skills/flow-review/SKILL.md +11 -0
- package/assets/skills/flow-tasks/SKILL.md +26 -5
- package/dist/flowrun/gate.d.ts +0 -10
- package/dist/flowrun/gate.js +0 -28
- package/dist/flowrun/gate.js.map +1 -1
- package/dist/flowrun/index.d.ts +1 -2
- package/dist/flowrun/index.js +1 -2
- package/dist/flowrun/index.js.map +1 -1
- package/dist/plugin/server.js +0 -54
- package/dist/plugin/server.js.map +1 -1
- package/dist/plugin/skills.js +15 -10
- package/dist/plugin/skills.js.map +1 -1
- package/package.json +1 -1
- package/assets/skills/flow-requirements/references/interview-guide.md +0 -35
- package/dist/flowrun/pr.d.ts +0 -132
- package/dist/flowrun/pr.js +0 -343
- package/dist/flowrun/pr.js.map +0 -1
- package/dist/plugin/flow-pr-tool.d.ts +0 -37
- package/dist/plugin/flow-pr-tool.js +0 -176
- package/dist/plugin/flow-pr-tool.js.map +0 -1
package/dist/flowrun/pr.js
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
let ghExecutor = null;
|
|
2
|
-
export function setGhExecutor(fn) {
|
|
3
|
-
ghExecutor = fn;
|
|
4
|
-
}
|
|
5
|
-
async function gh(args) {
|
|
6
|
-
if (ghExecutor) {
|
|
7
|
-
return ghExecutor(args);
|
|
8
|
-
}
|
|
9
|
-
const mod = await import("../util/gh.js");
|
|
10
|
-
return mod.gh(args);
|
|
11
|
-
}
|
|
12
|
-
// ─── PR 号解析 ───
|
|
13
|
-
function parsePrNumber(stdout) {
|
|
14
|
-
const trimmed = stdout.trim();
|
|
15
|
-
// 纯数字
|
|
16
|
-
if (/^\d+$/.test(trimmed))
|
|
17
|
-
return parseInt(trimmed, 10);
|
|
18
|
-
// URL 格式:https://github.com/owner/repo/pull/123
|
|
19
|
-
const urlMatch = trimmed.match(/\/pull\/(\d+)$/);
|
|
20
|
-
if (urlMatch)
|
|
21
|
-
return parseInt(urlMatch[1], 10);
|
|
22
|
-
// 其他格式尝试提取尾部数字
|
|
23
|
-
const numMatch = trimmed.match(/(\d+)$/);
|
|
24
|
-
if (numMatch)
|
|
25
|
-
return parseInt(numMatch[1], 10);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
// ─── Preflight 检查 ───
|
|
29
|
-
/**
|
|
30
|
-
* 执行 PR 创建前的前置条件检查(无副作用)。
|
|
31
|
-
*
|
|
32
|
-
* 规则:
|
|
33
|
-
* 1. Task 状态为 running
|
|
34
|
-
* 2. committed-head regression.status === "pass"
|
|
35
|
-
* 3. committed-head verification.status === "pass"
|
|
36
|
-
* 4. evidence headSha 与当前 head 一致
|
|
37
|
-
*/
|
|
38
|
-
export function preflightPRCreate(task, currentHeadSha) {
|
|
39
|
-
// 1. Task 状态检查
|
|
40
|
-
if (task.status !== "running") {
|
|
41
|
-
return {
|
|
42
|
-
ok: false,
|
|
43
|
-
code: "TASK_NOT_RUNNING",
|
|
44
|
-
message: `Task "${task.id}" is not running (status: ${task.status})`,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
const { regression, verification } = task.tddEvidence;
|
|
48
|
-
// 2. Regression 状态检查
|
|
49
|
-
if (regression.status !== "pass") {
|
|
50
|
-
return {
|
|
51
|
-
ok: false,
|
|
52
|
-
code: "REGRESSION_NOT_COMPLETE",
|
|
53
|
-
message: `Committed-head regression is not pass (status: ${regression.status})`,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
// 3. Verification 状态检查
|
|
57
|
-
if (verification.status !== "pass") {
|
|
58
|
-
return {
|
|
59
|
-
ok: false,
|
|
60
|
-
code: "VERIFICATION_NOT_COMPLETE",
|
|
61
|
-
message: `Final verification is not pass (status: ${verification.status})`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
// 4. Head SHA 一致性检查
|
|
65
|
-
if (!regression.headSha) {
|
|
66
|
-
return {
|
|
67
|
-
ok: false,
|
|
68
|
-
code: "HEAD_MISMATCH",
|
|
69
|
-
message: "Regression evidence is missing head SHA",
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (regression.headSha !== currentHeadSha) {
|
|
73
|
-
return {
|
|
74
|
-
ok: false,
|
|
75
|
-
code: "HEAD_MISMATCH",
|
|
76
|
-
message: `Evidence head SHA "${regression.headSha}" does not match current head "${currentHeadSha}"`,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return { ok: true };
|
|
80
|
-
}
|
|
81
|
-
// ─── PR 查找 ───
|
|
82
|
-
/**
|
|
83
|
-
* 按 repo + head branch 查询已存在的 open PR。
|
|
84
|
-
*/
|
|
85
|
-
async function findExistingPR(repo, headBranch) {
|
|
86
|
-
try {
|
|
87
|
-
const { stdout } = await gh(`pr list --head "${headBranch}" --repo "${repo}" --state open --json number,url --jq '.[0]'`);
|
|
88
|
-
if (!stdout.trim())
|
|
89
|
-
return null;
|
|
90
|
-
const pr = JSON.parse(stdout);
|
|
91
|
-
if (!pr || typeof pr.number !== "number")
|
|
92
|
-
return null;
|
|
93
|
-
return { number: pr.number, url: pr.url };
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// ─── PR 创建 ───
|
|
100
|
-
/**
|
|
101
|
-
* 创建或复用 PR。
|
|
102
|
-
*
|
|
103
|
-
* 流程:
|
|
104
|
-
* 1. 查询已有 open PR(按 head branch)
|
|
105
|
-
* 2. 已有 → 复用(created: false)
|
|
106
|
-
* 3. 无 → 创建新 PR(created: true)
|
|
107
|
-
*
|
|
108
|
-
* @throws 如果 gh CLI 执行失败
|
|
109
|
-
*/
|
|
110
|
-
export async function createOrReusePR(params) {
|
|
111
|
-
// 1. 查询已有 PR
|
|
112
|
-
const existing = await findExistingPR(params.repo, params.headBranch);
|
|
113
|
-
if (existing) {
|
|
114
|
-
return {
|
|
115
|
-
prNumber: existing.number,
|
|
116
|
-
prUrl: existing.url,
|
|
117
|
-
created: false,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
// 2. 创建新 PR
|
|
121
|
-
const escapedTitle = params.title.replace(/'/g, "'\\''");
|
|
122
|
-
const escapedBody = params.body.replace(/'/g, "'\\''");
|
|
123
|
-
const { stdout } = await gh(`pr create --head "${params.headBranch}" --base "${params.baseBranch}" --title '${escapedTitle}' --body '${escapedBody}'`);
|
|
124
|
-
const prNumber = parsePrNumber(stdout);
|
|
125
|
-
if (prNumber === null) {
|
|
126
|
-
throw new Error(`Failed to parse PR number from gh output: ${stdout}`);
|
|
127
|
-
}
|
|
128
|
-
return {
|
|
129
|
-
prNumber,
|
|
130
|
-
prUrl: stdout.trim(),
|
|
131
|
-
created: true,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
// ─── Rework 流程 ───
|
|
135
|
-
/**
|
|
136
|
-
* 发起 rework。
|
|
137
|
-
*
|
|
138
|
-
* behavior rework:
|
|
139
|
-
* - 声明 affected criterionIds,增加 reworkRevision
|
|
140
|
-
* - 重置 regression 和 verification 为 pending
|
|
141
|
-
* - 旧 cycle 保持不变(不重新绑定)
|
|
142
|
-
*
|
|
143
|
-
* refactor rework:
|
|
144
|
-
* - 不要求 RED,但必须重跑 regression + 审批
|
|
145
|
-
* - 同样增加 reworkRevision,重置 evidence
|
|
146
|
-
*
|
|
147
|
-
* 要求:Task 状态为 reviewing 且已有 PR。
|
|
148
|
-
*/
|
|
149
|
-
export function initiateRework(task, input) {
|
|
150
|
-
if (task.status !== "reviewing") {
|
|
151
|
-
return {
|
|
152
|
-
ok: false,
|
|
153
|
-
code: "TASK_NOT_REVIEWING",
|
|
154
|
-
message: `Task "${task.id}" is not in reviewing status (current: ${task.status})`,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
if (task.prNumber === null) {
|
|
158
|
-
return {
|
|
159
|
-
ok: false,
|
|
160
|
-
code: "NO_PR_EXISTS",
|
|
161
|
-
message: `Task "${task.id}" has no associated PR`,
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
const evidence = task.tddEvidence;
|
|
165
|
-
const newRevision = evidence.reworkRevision + 1;
|
|
166
|
-
const rework = {
|
|
167
|
-
reworkRevision: newRevision,
|
|
168
|
-
kind: input.kind,
|
|
169
|
-
affectedCriterionIds: input.affectedCriterionIds,
|
|
170
|
-
status: "started",
|
|
171
|
-
startHeadSha: input.startHeadSha,
|
|
172
|
-
approval: null,
|
|
173
|
-
};
|
|
174
|
-
const updatedTask = {
|
|
175
|
-
...task,
|
|
176
|
-
tddEvidence: {
|
|
177
|
-
...evidence,
|
|
178
|
-
reworkRevision: newRevision,
|
|
179
|
-
status: "in-progress",
|
|
180
|
-
regression: {
|
|
181
|
-
status: "pending",
|
|
182
|
-
headSha: null,
|
|
183
|
-
treeSha: null,
|
|
184
|
-
reworkRevision: newRevision,
|
|
185
|
-
runs: [],
|
|
186
|
-
},
|
|
187
|
-
verification: {
|
|
188
|
-
status: "pending",
|
|
189
|
-
headSha: null,
|
|
190
|
-
treeSha: null,
|
|
191
|
-
runs: [],
|
|
192
|
-
},
|
|
193
|
-
reworks: [...evidence.reworks, rework],
|
|
194
|
-
updatedAt: new Date().toISOString(),
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
return { ok: true, task: updatedTask };
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* 完成 rework,验证后恢复 Task 为 reviewing。
|
|
201
|
-
*
|
|
202
|
-
* 检查:
|
|
203
|
-
* 1. 当前有激活的 rework(evidence.status === "in-progress")
|
|
204
|
-
* 2. regression 和 verification 均已 pass
|
|
205
|
-
* 3. evidence head SHA 与 committed head 一致
|
|
206
|
-
*/
|
|
207
|
-
export function completeRework(task, input) {
|
|
208
|
-
const evidence = task.tddEvidence;
|
|
209
|
-
// 1. 检查是否有激活的 rework
|
|
210
|
-
if (evidence.status !== "in-progress") {
|
|
211
|
-
return {
|
|
212
|
-
ok: false,
|
|
213
|
-
code: "NO_ACTIVE_REWORK",
|
|
214
|
-
message: `Task "${task.id}" has no active rework (current TDD status: ${evidence.status})`,
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
// 2. 检查 regression
|
|
218
|
-
if (evidence.regression.status !== "pass") {
|
|
219
|
-
return {
|
|
220
|
-
ok: false,
|
|
221
|
-
code: "REGRESSION_NOT_PASS",
|
|
222
|
-
message: `Committed-head regression is not pass (status: ${evidence.regression.status})`,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
// 3. 检查 verification
|
|
226
|
-
if (evidence.verification.status !== "pass") {
|
|
227
|
-
return {
|
|
228
|
-
ok: false,
|
|
229
|
-
code: "VERIFICATION_NOT_PASS",
|
|
230
|
-
message: `Final verification is not pass (status: ${evidence.verification.status})`,
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
// 4. 检查 head SHA 一致性(regression 和 verification 都需检查)
|
|
234
|
-
const regHead = evidence.regression.headSha;
|
|
235
|
-
const verHead = evidence.verification.headSha;
|
|
236
|
-
if (regHead !== input.committedHeadSha) {
|
|
237
|
-
return {
|
|
238
|
-
ok: false,
|
|
239
|
-
code: "HEAD_MISMATCH",
|
|
240
|
-
message: `Regression head SHA "${regHead}" does not match committed head "${input.committedHeadSha}"`,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
if (verHead !== input.committedHeadSha) {
|
|
244
|
-
return {
|
|
245
|
-
ok: false,
|
|
246
|
-
code: "HEAD_MISMATCH",
|
|
247
|
-
message: `Verification head SHA "${verHead}" does not match committed head "${input.committedHeadSha}"`,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
// 更新最后一个 rework 状态为 pass
|
|
251
|
-
const reworks = [...evidence.reworks];
|
|
252
|
-
if (reworks.length > 0) {
|
|
253
|
-
const last = { ...reworks[reworks.length - 1] };
|
|
254
|
-
last.status = "pass";
|
|
255
|
-
reworks[reworks.length - 1] = last;
|
|
256
|
-
}
|
|
257
|
-
const updatedTask = {
|
|
258
|
-
...task,
|
|
259
|
-
status: "reviewing",
|
|
260
|
-
tddEvidence: {
|
|
261
|
-
...evidence,
|
|
262
|
-
status: "pass",
|
|
263
|
-
reworks,
|
|
264
|
-
updatedAt: new Date().toISOString(),
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
return { ok: true, task: updatedTask };
|
|
268
|
-
}
|
|
269
|
-
// ─── Remote head revalidation ───
|
|
270
|
-
/**
|
|
271
|
-
* 查询 remote PR 的 head commit SHA 和 tree SHA。
|
|
272
|
-
*
|
|
273
|
-
* 步骤:
|
|
274
|
-
* 1. `gh pr view --json headRefOid` 获取完整 JSON,自行解析提取 headRefOid
|
|
275
|
-
* 2. `gh api repos/{owner}/{repo}/git/commits/{sha} --jq '.tree.sha'` 获取 tree SHA
|
|
276
|
-
*/
|
|
277
|
-
export async function fetchRemotePRHead(repo, prNumber) {
|
|
278
|
-
// 步骤 1: 查询 PR head SHA
|
|
279
|
-
let prJson;
|
|
280
|
-
try {
|
|
281
|
-
const { stdout } = await gh(`pr view ${prNumber} --repo "${repo}" --json headRefOid`);
|
|
282
|
-
try {
|
|
283
|
-
prJson = JSON.parse(stdout);
|
|
284
|
-
}
|
|
285
|
-
catch {
|
|
286
|
-
return { ok: false, code: "PARSE_ERROR", message: "Failed to parse gh pr view JSON output" };
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
catch (err) {
|
|
290
|
-
return { ok: false, code: "GH_ERROR", message: `Failed to fetch PR head: ${String(err)}` };
|
|
291
|
-
}
|
|
292
|
-
if (!prJson || typeof prJson !== "object") {
|
|
293
|
-
return { ok: false, code: "PARSE_ERROR", message: "gh pr view returned unexpected output" };
|
|
294
|
-
}
|
|
295
|
-
const prData = prJson;
|
|
296
|
-
if (!prData.headRefOid || typeof prData.headRefOid !== "string") {
|
|
297
|
-
return { ok: false, code: "MISSING_HEAD_SHA", message: "Remote PR headRefOid is missing or not a string" };
|
|
298
|
-
}
|
|
299
|
-
const headSha = prData.headRefOid;
|
|
300
|
-
// 步骤 2: 获取 tree SHA
|
|
301
|
-
let treeSha;
|
|
302
|
-
try {
|
|
303
|
-
const { stdout } = await gh(`api repos/${repo}/git/commits/${headSha} --jq '.tree.sha'`);
|
|
304
|
-
treeSha = stdout.trim();
|
|
305
|
-
if (!treeSha) {
|
|
306
|
-
return { ok: false, code: "MISSING_HEAD_SHA", message: "Remote commit tree SHA is empty" };
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
catch (err) {
|
|
310
|
-
return { ok: false, code: "GH_ERROR", message: `Failed to fetch commit tree SHA: ${String(err)}` };
|
|
311
|
-
}
|
|
312
|
-
return { ok: true, head: { headSha, treeSha } };
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* 重新验证 remote head。
|
|
316
|
-
*
|
|
317
|
-
* 比较 task.tddEvidence.verification.treeSha 与 remote tree SHA:
|
|
318
|
-
* - 相同 tree SHA:可以重新绑定 new head(重跑 regression/verification)
|
|
319
|
-
* - 不同 tree SHA:需要先执行 rework
|
|
320
|
-
*/
|
|
321
|
-
export function revalidateRemoteHead(task, remoteHead) {
|
|
322
|
-
const evidenceTreeSha = task.tddEvidence.verification.treeSha;
|
|
323
|
-
if (!evidenceTreeSha) {
|
|
324
|
-
return {
|
|
325
|
-
ok: false,
|
|
326
|
-
action: "rework-needed",
|
|
327
|
-
summary: `No tree SHA in evidence; remote head ${remoteHead.headSha.slice(0, 7)} (tree: ${remoteHead.treeSha.slice(0, 7)}) requires rework`,
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
if (evidenceTreeSha === remoteHead.treeSha) {
|
|
331
|
-
return {
|
|
332
|
-
ok: true,
|
|
333
|
-
action: "revalidate",
|
|
334
|
-
summary: `Remote head ${remoteHead.headSha.slice(0, 7)} tree matches evidence tree ${evidenceTreeSha.slice(0, 7)} — re-run regression and rebind head`,
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
return {
|
|
338
|
-
ok: false,
|
|
339
|
-
action: "rework-needed",
|
|
340
|
-
summary: `Remote head ${remoteHead.headSha.slice(0, 7)} tree changed (was: ${evidenceTreeSha.slice(0, 7)}, now: ${remoteHead.treeSha.slice(0, 7)}) — rework required`,
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
//# sourceMappingURL=pr.js.map
|
package/dist/flowrun/pr.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pr.js","sourceRoot":"","sources":["../../src/flowrun/pr.ts"],"names":[],"mappings":"AA6DA,IAAI,UAAU,GAAgB,IAAI,CAAA;AAElC,MAAM,UAAU,aAAa,CAAC,EAAQ;IACpC,UAAU,GAAG,EAAE,CAAA;AACjB,CAAC;AAED,KAAK,UAAU,EAAE,CAAC,IAAY;IAC5B,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAA;IACzC,OAAO,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;AACrB,CAAC;AAED,iBAAiB;AAEjB,SAAS,aAAa,CAAC,MAAc;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;IAC7B,MAAM;IACN,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACvD,gDAAgD;IAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;I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,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,mBAAmB;SAC5I,CAAA;IACH,CAAC;IAED,IAAI,eAAe,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3C,OAAO;YACL,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,eAAe,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,+BAA+B,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,sCAAsC;SACvJ,CAAA;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,KAAK;QACT,MAAM,EAAE,eAAe;QACvB,OAAO,EAAE,eAAe,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,uBAAuB,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,qBAAqB;KACtK,CAAA;AACH,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { FlowBroker } from "./broker.js";
|
|
2
|
-
export interface FlowPRCreateRequest {
|
|
3
|
-
op: string;
|
|
4
|
-
parentIssueNumber: number;
|
|
5
|
-
taskId?: string;
|
|
6
|
-
currentHeadSha?: string;
|
|
7
|
-
prTitle?: string;
|
|
8
|
-
prBody?: string;
|
|
9
|
-
baseBranch?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface FlowPRCreateResponse {
|
|
12
|
-
ok: boolean;
|
|
13
|
-
conflictPause: boolean;
|
|
14
|
-
persisted: boolean;
|
|
15
|
-
prNumber?: number;
|
|
16
|
-
prUrl?: string;
|
|
17
|
-
created?: boolean;
|
|
18
|
-
taskStatus?: string;
|
|
19
|
-
error?: {
|
|
20
|
-
code: string;
|
|
21
|
-
message: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* 通过 FlowBroker 执行 flow_pr create 操作。
|
|
26
|
-
*
|
|
27
|
-
* 流程:
|
|
28
|
-
* 1. 通过 broker.writeFlowRunWithLock 读取 FlowRun
|
|
29
|
-
* 2. 提取目标 TaskState,执行 preflight
|
|
30
|
-
* 3. 调用 createOrReusePR(幂等:已有 PR 则复用)
|
|
31
|
-
* 4. 写入 prNumber + 初始化 prCheckpoints → task status → "reviewing"
|
|
32
|
-
* 5. 成功时持久化回 Issue(broker 自动处理 revision + 乐观锁)
|
|
33
|
-
* 6. PERSIST_CONFLICT 时设置 conflictPause=true
|
|
34
|
-
*
|
|
35
|
-
* 补偿:GitHub 创建成功但 FlowRun 写入失败 → 重试时通过 head branch 找回同一 PR
|
|
36
|
-
*/
|
|
37
|
-
export declare function handleFlowPrCreateWithBroker(broker: FlowBroker, req: FlowPRCreateRequest): Promise<FlowPRCreateResponse>;
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { preflightPRCreate, createOrReusePR } from "../flowrun/pr.js";
|
|
2
|
-
// ─── 内部辅助 ───
|
|
3
|
-
function initPRCheckpoints(prNumber) {
|
|
4
|
-
return {
|
|
5
|
-
prNumber,
|
|
6
|
-
localChecks: { name: "localChecks", status: "pending", evidence: [] },
|
|
7
|
-
ciChecks: { name: "ciChecks", status: "pending", evidence: [] },
|
|
8
|
-
reviewerApproval: { name: "reviewerApproval", status: "pending", evidence: [] },
|
|
9
|
-
goalVerification: { name: "goalVerification", status: "pending", evidence: [] },
|
|
10
|
-
branchProtection: { name: "branchProtection", status: "pending", evidence: [] },
|
|
11
|
-
mergeResult: { name: "mergeResult", status: "pending", evidence: [] },
|
|
12
|
-
tddCompliance: null,
|
|
13
|
-
verification: null,
|
|
14
|
-
coverage: null,
|
|
15
|
-
qualityContractDigest: null,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
// ─── Broker-aware handler ───
|
|
19
|
-
/**
|
|
20
|
-
* 通过 FlowBroker 执行 flow_pr create 操作。
|
|
21
|
-
*
|
|
22
|
-
* 流程:
|
|
23
|
-
* 1. 通过 broker.writeFlowRunWithLock 读取 FlowRun
|
|
24
|
-
* 2. 提取目标 TaskState,执行 preflight
|
|
25
|
-
* 3. 调用 createOrReusePR(幂等:已有 PR 则复用)
|
|
26
|
-
* 4. 写入 prNumber + 初始化 prCheckpoints → task status → "reviewing"
|
|
27
|
-
* 5. 成功时持久化回 Issue(broker 自动处理 revision + 乐观锁)
|
|
28
|
-
* 6. PERSIST_CONFLICT 时设置 conflictPause=true
|
|
29
|
-
*
|
|
30
|
-
* 补偿:GitHub 创建成功但 FlowRun 写入失败 → 重试时通过 head branch 找回同一 PR
|
|
31
|
-
*/
|
|
32
|
-
export async function handleFlowPrCreateWithBroker(broker, req) {
|
|
33
|
-
const taskId = req.taskId;
|
|
34
|
-
const currentHeadSha = req.currentHeadSha;
|
|
35
|
-
const prTitle = req.prTitle;
|
|
36
|
-
const prBody = req.prBody;
|
|
37
|
-
const baseBranch = req.baseBranch ?? "main";
|
|
38
|
-
if (!taskId) {
|
|
39
|
-
return {
|
|
40
|
-
ok: false,
|
|
41
|
-
conflictPause: false,
|
|
42
|
-
persisted: false,
|
|
43
|
-
error: { code: "POLICY_INVALID", message: "task_id is required for pr-create" },
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if (!currentHeadSha) {
|
|
47
|
-
return {
|
|
48
|
-
ok: false,
|
|
49
|
-
conflictPause: false,
|
|
50
|
-
persisted: false,
|
|
51
|
-
error: { code: "POLICY_INVALID", message: "current_head_sha is required for pr-create" },
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
if (!prTitle) {
|
|
55
|
-
return {
|
|
56
|
-
ok: false,
|
|
57
|
-
conflictPause: false,
|
|
58
|
-
persisted: false,
|
|
59
|
-
error: { code: "POLICY_INVALID", message: "pr_title is required for pr-create" },
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
if (!prBody) {
|
|
63
|
-
return {
|
|
64
|
-
ok: false,
|
|
65
|
-
conflictPause: false,
|
|
66
|
-
persisted: false,
|
|
67
|
-
error: { code: "POLICY_INVALID", message: "pr_body is required for pr-create" },
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// ── 先创建/复用 PR(可能已经存在) ──
|
|
71
|
-
let prResult;
|
|
72
|
-
try {
|
|
73
|
-
// Step 1: 读取 FlowRun 获取 repo + branch 信息
|
|
74
|
-
const { flowRunResult, currentBody } = await (async () => {
|
|
75
|
-
const mod = await import("../flowrun/github.js");
|
|
76
|
-
return mod.readFlowRunWithLock(req.parentIssueNumber);
|
|
77
|
-
})();
|
|
78
|
-
if (!flowRunResult.ok || currentBody === null) {
|
|
79
|
-
return {
|
|
80
|
-
ok: false,
|
|
81
|
-
conflictPause: false,
|
|
82
|
-
persisted: false,
|
|
83
|
-
error: {
|
|
84
|
-
code: "READ_FAILED",
|
|
85
|
-
message: `Failed to read FlowRun from issue #${req.parentIssueNumber}`,
|
|
86
|
-
},
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
const flowRun = flowRunResult.data;
|
|
90
|
-
const task = flowRun.tasks[taskId];
|
|
91
|
-
if (!task) {
|
|
92
|
-
return {
|
|
93
|
-
ok: false,
|
|
94
|
-
conflictPause: false,
|
|
95
|
-
persisted: false,
|
|
96
|
-
error: { code: "TASK_NOT_FOUND", message: `Task "${taskId}" not found in FlowRun` },
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
// Step 2: Preflight 检查(无副作用)
|
|
100
|
-
const preflight = preflightPRCreate(task, currentHeadSha);
|
|
101
|
-
if (!preflight.ok) {
|
|
102
|
-
return {
|
|
103
|
-
ok: false,
|
|
104
|
-
conflictPause: false,
|
|
105
|
-
persisted: false,
|
|
106
|
-
error: preflight,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
// Step 3: 确定 head branch(从 executionBinding)
|
|
110
|
-
const headBranch = task.executionBinding?.branch ?? taskId;
|
|
111
|
-
// Step 4: 创建或复用 PR
|
|
112
|
-
prResult = await createOrReusePR({
|
|
113
|
-
repo: flowRun.repo,
|
|
114
|
-
headBranch,
|
|
115
|
-
baseBranch,
|
|
116
|
-
title: prTitle,
|
|
117
|
-
body: prBody,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
catch (err) {
|
|
121
|
-
return {
|
|
122
|
-
ok: false,
|
|
123
|
-
conflictPause: false,
|
|
124
|
-
persisted: false,
|
|
125
|
-
error: { code: "INTERNAL_ERROR", message: String(err) },
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
// Step 5: 通过 broker 持久化(乐观锁写入)
|
|
129
|
-
const writeResult = await broker.writeFlowRunWithLock(req.parentIssueNumber, (flowRun) => {
|
|
130
|
-
const task = flowRun.tasks[taskId];
|
|
131
|
-
if (!task) {
|
|
132
|
-
return {
|
|
133
|
-
flowRun,
|
|
134
|
-
result: { prNumber: 0, prUrl: "", created: false, taskStatus: "" },
|
|
135
|
-
shouldPersist: false,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
// 写入 prNumber 和 checkpoints
|
|
139
|
-
task.prNumber = prResult.prNumber;
|
|
140
|
-
task.prCheckpoints = initPRCheckpoints(prResult.prNumber);
|
|
141
|
-
task.status = "reviewing";
|
|
142
|
-
return {
|
|
143
|
-
flowRun,
|
|
144
|
-
result: {
|
|
145
|
-
prNumber: prResult.prNumber,
|
|
146
|
-
prUrl: prResult.prUrl,
|
|
147
|
-
created: prResult.created,
|
|
148
|
-
taskStatus: task.status,
|
|
149
|
-
},
|
|
150
|
-
shouldPersist: true,
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
if (!writeResult.ok) {
|
|
154
|
-
// PERSIST_CONFLICT or READ_FAILED
|
|
155
|
-
return {
|
|
156
|
-
ok: false,
|
|
157
|
-
conflictPause: writeResult.code === "PERSIST_CONFLICT",
|
|
158
|
-
persisted: false,
|
|
159
|
-
prNumber: prResult.prNumber, // 补偿信息:PR 已创建,重试时可找回
|
|
160
|
-
error: {
|
|
161
|
-
code: writeResult.code,
|
|
162
|
-
message: writeResult.message,
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
return {
|
|
167
|
-
ok: true,
|
|
168
|
-
conflictPause: false,
|
|
169
|
-
persisted: writeResult.persisted,
|
|
170
|
-
prNumber: writeResult.result.prNumber,
|
|
171
|
-
prUrl: writeResult.result.prUrl,
|
|
172
|
-
created: writeResult.result.created,
|
|
173
|
-
taskStatus: writeResult.result.taskStatus,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
//# sourceMappingURL=flow-pr-tool.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flow-pr-tool.js","sourceRoot":"","sources":["../../src/plugin/flow-pr-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAuB,MAAM,kBAAkB,CAAA;AA6B1F,eAAe;AAEf,SAAS,iBAAiB,CAAC,QAAgB;IACzC,OAAO;QACL,QAAQ;QACR,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrE,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC/D,gBAAgB,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC/E,gBAAgB,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC/E,gBAAgB,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC/E,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EA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