@coda-console/review 2.8.0 → 2.8.1
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/.coda/workflows/pull-request.bpmn +40 -18
- package/README.md +5 -2
- package/package.json +1 -1
- package/scripts/approval.mjs +16 -0
- package/scripts/merge.mjs +4 -12
|
@@ -325,10 +325,20 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
325
325
|
<boundaryEvent id="not-handled" name="做不了" attachedToRef="handed"><errorEventDefinition /></boundaryEvent>
|
|
326
326
|
<sequenceFlow id="back-to-approve" sourceRef="not-handled" targetRef="approve" />
|
|
327
327
|
|
|
328
|
-
<!--
|
|
328
|
+
<!-- 记下你批准的时刻和合并后要做的事:之后评审再要求修改(review.changesAt 更晚)这次批准才作废;
|
|
329
|
+
合并后的删分支、部署、发布与通知都照这里,不论 Coda 先从合并步骤还是先从 GitHub 得知合并了。 -->
|
|
329
330
|
<scriptTask id="approval" name="记下批准" coda:timeout="5" coda:checkout="false" scriptFormat="bash">
|
|
330
|
-
<extensionElements
|
|
331
|
-
|
|
331
|
+
<extensionElements>
|
|
332
|
+
<coda:env name="APPROVED" value="=approve" />
|
|
333
|
+
<coda:output name="at" />
|
|
334
|
+
<coda:output name="deleteBranch" />
|
|
335
|
+
<coda:output name="deploy" />
|
|
336
|
+
<coda:output name="release" />
|
|
337
|
+
<coda:output name="releaseKinds" />
|
|
338
|
+
<coda:output name="notify" />
|
|
339
|
+
<coda:output name="what" />
|
|
340
|
+
</extensionElements>
|
|
341
|
+
<script>node "${CODA_PLUGIN_PATH}/scripts/approval.mjs"</script>
|
|
332
342
|
</scriptTask>
|
|
333
343
|
<sequenceFlow id="to-premerge" sourceRef="approval" targetRef="premerge" />
|
|
334
344
|
|
|
@@ -340,7 +350,17 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
340
350
|
<coda:param name="commit" value="=reviewing.head" />
|
|
341
351
|
</extensionElements>
|
|
342
352
|
</serviceTask>
|
|
343
|
-
<sequenceFlow id="premerged" sourceRef="premerge" targetRef="
|
|
353
|
+
<sequenceFlow id="premerged" sourceRef="premerge" targetRef="handing" />
|
|
354
|
+
<!-- 记下交给 GitHub 的是哪个提交:合并期间送到的关闭,合进去的是它才是这条运行交出去的合并(「是批准的合并吗」)。
|
|
355
|
+
合并前检查没过、还在等人处理时,这一步没跑过。 -->
|
|
356
|
+
<scriptTask id="handing" name="交给 GitHub" coda:timeout="5" coda:checkout="false" scriptFormat="bash">
|
|
357
|
+
<extensionElements>
|
|
358
|
+
<coda:env name="HEAD" value="=reviewing.head" />
|
|
359
|
+
<coda:output name="head" />
|
|
360
|
+
</extensionElements>
|
|
361
|
+
<script>echo "head=$HEAD" >> "$GITHUB_OUTPUT"</script>
|
|
362
|
+
</scriptTask>
|
|
363
|
+
<sequenceFlow id="handed-over" sourceRef="handing" targetRef="merge" />
|
|
344
364
|
<boundaryEvent id="premerge-broke" name="没通过" attachedToRef="premerge"><errorEventDefinition /></boundaryEvent>
|
|
345
365
|
<sequenceFlow id="premerge-to-fix" sourceRef="premerge-broke" targetRef="fix-premerge" />
|
|
346
366
|
<userTask id="fix-premerge" name="合并前检查没通过:处理后答复" coda:status="合并前检查没通过:开 PR 的会话处理中" coda:completeLabel="已处理,再跑检查" coda:rejectLabel="处理不了">
|
|
@@ -370,15 +390,10 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
370
390
|
<coda:env name="URL" value="=github.event.pull_request.html_url" />
|
|
371
391
|
<coda:env name="HEAD" value="=reviewing.head" />
|
|
372
392
|
<coda:env name="METHOD" value="=vars.review.mergeMethod" />
|
|
373
|
-
<coda:env name="
|
|
393
|
+
<coda:env name="WHAT" value="=approval.what" />
|
|
374
394
|
<coda:output name="merged" />
|
|
375
395
|
<coda:output name="refused" />
|
|
376
396
|
<coda:output name="reason" />
|
|
377
|
-
<coda:output name="deleteBranch" />
|
|
378
|
-
<coda:output name="deploy" />
|
|
379
|
-
<coda:output name="release" />
|
|
380
|
-
<coda:output name="releaseKinds" />
|
|
381
|
-
<coda:output name="notify" />
|
|
382
397
|
</extensionElements>
|
|
383
398
|
<script>node "${CODA_PLUGIN_PATH}/scripts/merge.mjs"</script>
|
|
384
399
|
</scriptTask>
|
|
@@ -428,7 +443,14 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
428
443
|
<boundaryEvent id="rebased-while-merging" name="base 变了" attachedToRef="merging"><messageEventDefinition messageRef="edited" /></boundaryEvent>
|
|
429
444
|
<sequenceFlow id="merging-rebased" sourceRef="rebased-while-merging" targetRef="opening" />
|
|
430
445
|
<boundaryEvent id="closed-while-merging" name="PR 关闭" attachedToRef="merging"><messageEventDefinition messageRef="closed" /></boundaryEvent>
|
|
431
|
-
<sequenceFlow id="merging-ended" sourceRef="closed-while-merging" targetRef="
|
|
446
|
+
<sequenceFlow id="merging-ended" sourceRef="closed-while-merging" targetRef="approved-merged" />
|
|
447
|
+
<!-- 合并步骤把 PR 交给 GitHub 后,GitHub 的关闭可能先于这一步结束送到:合进去的正是「交给 GitHub」记下的那个提交,
|
|
448
|
+
就是你批准、也过了合并前检查的合并,照你的选择接着删分支、部署、发布;否则是别处合并或关闭的。 -->
|
|
449
|
+
<exclusiveGateway id="approved-merged" name="是批准的合并吗" default="not-approved" />
|
|
450
|
+
<sequenceFlow id="as-approved-merged" sourceRef="approved-merged" targetRef="deleting-or-not">
|
|
451
|
+
<conditionExpression xsi:type="tFormalExpression">=github.event.pull_request.merged and github.event.pull_request.head.sha = handing.head</conditionExpression>
|
|
452
|
+
</sequenceFlow>
|
|
453
|
+
<sequenceFlow id="not-approved" sourceRef="approved-merged" targetRef="ended" />
|
|
432
454
|
<sequenceFlow id="to-after-merging" sourceRef="merging" targetRef="after-merging" />
|
|
433
455
|
<exclusiveGateway id="after-merging" name="接下来" default="to-confirming" />
|
|
434
456
|
<sequenceFlow id="merged-to-waiting" sourceRef="after-merging" targetRef="waiting">
|
|
@@ -465,7 +487,7 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
465
487
|
|
|
466
488
|
<exclusiveGateway id="deleting-or-not" name="删除远程分支吗" default="keep-branch" />
|
|
467
489
|
<sequenceFlow id="to-delete-branch" sourceRef="deleting-or-not" targetRef="delete-branch">
|
|
468
|
-
<conditionExpression xsi:type="tFormalExpression">=
|
|
490
|
+
<conditionExpression xsi:type="tFormalExpression">=approval.deleteBranch</conditionExpression>
|
|
469
491
|
</sequenceFlow>
|
|
470
492
|
<sequenceFlow id="keep-branch" sourceRef="deleting-or-not" targetRef="delivering-or-not" />
|
|
471
493
|
<scriptTask id="delete-branch" name="删除远程分支" coda:timeout="5" coda:checkout="false" coda:status="已合并:删除远程分支" scriptFormat="bash">
|
|
@@ -479,10 +501,10 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
479
501
|
|
|
480
502
|
<exclusiveGateway id="delivering-or-not" name="部署或发布吗" default="merged-only" />
|
|
481
503
|
<sequenceFlow id="to-delivering" sourceRef="delivering-or-not" targetRef="delivering">
|
|
482
|
-
<conditionExpression xsi:type="tFormalExpression">=
|
|
504
|
+
<conditionExpression xsi:type="tFormalExpression">=approval.deploy or approval.release</conditionExpression>
|
|
483
505
|
</sequenceFlow>
|
|
484
506
|
<sequenceFlow id="merged-only" sourceRef="delivering-or-not" targetRef="merged-here" />
|
|
485
|
-
<endEvent id="merged-here" coda:status="已合并" coda:notify="=
|
|
507
|
+
<endEvent id="merged-here" coda:status="已合并" coda:notify="=approval.notify" />
|
|
486
508
|
|
|
487
509
|
<!-- 部署与发布:项目自己声明哪些流程是部署(coda:kind="deploy")、预览发布(preview)、正式发布(release),这里在合并提交上调用它们;
|
|
488
510
|
项目没有这一类的流程,这一步直接过去。先部署,再请开 PR 的会话写更新说明、发布。失败时运行失败,交回开 PR 的会话。 -->
|
|
@@ -491,7 +513,7 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
491
513
|
<sequenceFlow id="dl-in" sourceRef="delivering-in" targetRef="deploying" />
|
|
492
514
|
<exclusiveGateway id="deploying" name="部署吗" default="not-deploying" />
|
|
493
515
|
<sequenceFlow id="to-deploy" sourceRef="deploying" targetRef="deploy">
|
|
494
|
-
<conditionExpression xsi:type="tFormalExpression">=
|
|
516
|
+
<conditionExpression xsi:type="tFormalExpression">=approval.deploy</conditionExpression>
|
|
495
517
|
</sequenceFlow>
|
|
496
518
|
<sequenceFlow id="not-deploying" sourceRef="deploying" targetRef="releasing" />
|
|
497
519
|
<serviceTask id="deploy" name="部署" coda:action="run-workflows" coda:status="部署中">
|
|
@@ -503,7 +525,7 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
503
525
|
<sequenceFlow id="deployed" sourceRef="deploy" targetRef="releasing" />
|
|
504
526
|
<exclusiveGateway id="releasing" name="发布吗" default="deploy-only" />
|
|
505
527
|
<sequenceFlow id="to-notes" sourceRef="releasing" targetRef="notes">
|
|
506
|
-
<conditionExpression xsi:type="tFormalExpression">=
|
|
528
|
+
<conditionExpression xsi:type="tFormalExpression">=approval.release</conditionExpression>
|
|
507
529
|
</sequenceFlow>
|
|
508
530
|
<sequenceFlow id="deploy-only" sourceRef="releasing" targetRef="delivered" />
|
|
509
531
|
<endEvent id="delivered" coda:status="已合并并部署" />
|
|
@@ -537,7 +559,7 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
537
559
|
<sequenceFlow id="to-publish" sourceRef="publishing" targetRef="publish" />
|
|
538
560
|
<serviceTask id="publish" name="发布" coda:action="run-workflows" coda:status="发布中">
|
|
539
561
|
<extensionElements>
|
|
540
|
-
<coda:param name="kind" value="=
|
|
562
|
+
<coda:param name="kind" value="=approval.releaseKinds" />
|
|
541
563
|
<coda:param name="commit" value="=github.event.pull_request.merge_commit_sha" />
|
|
542
564
|
<coda:param name="inputs" value="=publishing.inputs" />
|
|
543
565
|
</extensionElements>
|
|
@@ -546,6 +568,6 @@ GitHub 上各项检查用 `gh pr checks {{github.event.pull_request.html_url}}`
|
|
|
546
568
|
<endEvent id="released-end" coda:status="已发布" />
|
|
547
569
|
</subProcess>
|
|
548
570
|
<sequenceFlow id="to-delivered" sourceRef="delivering" targetRef="delivering-done" />
|
|
549
|
-
<endEvent id="delivering-done" coda:notify="=
|
|
571
|
+
<endEvent id="delivering-done" coda:notify="=approval.notify" />
|
|
550
572
|
</process>
|
|
551
573
|
</definitions>
|
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
scripts/checks.mjs 等 GitHub 检查
|
|
14
14
|
scripts/review.mjs 交叉评审:选评审方、开会话、读结论、写 PR 评论
|
|
15
15
|
scripts/base.mjs 看 base(叠放)
|
|
16
|
+
scripts/approval.mjs 记下批准:时刻与合并后要做的事
|
|
16
17
|
scripts/merge.mjs 合并
|
|
17
18
|
scripts/delete-branch.mjs 合并确认后删除远程源分支
|
|
18
19
|
scripts/notes.mjs 发布流程的参数(更新说明与 publish)
|
|
@@ -79,7 +80,7 @@ prompts/principles/ 评审重点,一项一段,按设置取
|
|
|
79
80
|
卡片之前的「看项目有哪些部署、发布」(`workflow-kinds`)查项目在这个提交上有哪几类流程,部署和发布选项只给项目有的那几类(`coda:shown`);
|
|
80
81
|
比如只有部署流程的项目,面板里有「合并后删除远程分支」「部署」和「全部完成后通知 Agent」。没给的那几项按不勾算。需要 Coda 745f85c 及之后。
|
|
81
82
|
另有「让 Agent 处理评审意见」:连同你的备注交给开 PR 的会话「处理你交付的评审意见」,它推送后重新评审、再请你批准,它做不了就回到批准卡;以及「关闭 PR」(`gh pr close`)。
|
|
82
|
-
-
|
|
83
|
+
- 「合并前检查」:你选了合并后,先「记下批准」(`approval.mjs`):批准的时刻,和你勾的删分支、部署、发布、通知(合并后都照它做),再在评审通过的提交上调用项目声明的合并前检查(`coda:kind="premerge"`)并等它们结束;
|
|
83
84
|
项目没有就直接过去。有一个没通过就交给开 PR 的会话「合并前检查没通过:处理后答复」:改动导致的就推送新提交,照常检查、评审,通过后按你这次的选择合并,不再问;
|
|
84
85
|
检查本身出了问题就处理好后答复,再跑一遍。它做不了交给你「合并前检查没通过:等你处理」。合并没成功后重试合并不再跑合并前检查(同一个提交已经通过)。
|
|
85
86
|
需要认识 `premerge` 这一类的 Coda。
|
|
@@ -91,6 +92,8 @@ prompts/principles/ 评审重点,一项一段,按设置取
|
|
|
91
92
|
- 批准在评审再要求修改时作废:「交叉评审」逐次接力输出最近一次要求修改的时刻 `changesAt`,「记下批准」输出你批准的时刻 `at`,
|
|
92
93
|
「按原批准合并吗」只在 `at` 晚于 `changesAt` 时不再问你。
|
|
93
94
|
- 交给 GitHub 后在「等 GitHub 确认」等关闭事件,它带来合并提交;期间有新提交(被移出了合并队列)就从头再来。
|
|
95
|
+
关闭事件也可能在「合并」这一步结束前就到(合并要几秒,GitHub 先说了):合并前,「交给 GitHub」记下要交出去的提交;合进去的正是它,就照你的勾选接着做,和等到确认的一样。
|
|
96
|
+
合并前检查没过、还在等人处理时被别处合并,不算这条运行的合并。
|
|
94
97
|
- 勾选「合并后删除远程分支」时,确认合并后、部署与发布前运行「删除远程分支」(`delete-branch.mjs`)。它从 PR 读取源仓库(包括 fork)与源分支,
|
|
95
98
|
只删除仍指向这次批准合并的提交的远程分支;本地分支与会话工作树保留。分支或源仓库已删除就跳过,有了其他提交、是默认分支或合并目标分支则保留,原因记在步骤摘要。
|
|
96
99
|
删除用 Git 的 `--force-with-lease=<ref>:<sha>`,推送期间分支变动也不会误删。读取或删除失败会让运行失败,处理后可从失败处继续,之后再部署与发布。
|
|
@@ -100,7 +103,7 @@ prompts/principles/ 评审重点,一项一段,按设置取
|
|
|
100
103
|
参数 `notes`(更新说明)与 `publish`(`"true"`)。没声明某个参数的流程不会拿到它;项目没有这一类的流程,这一步直接过去。
|
|
101
104
|
部署或发布失败时运行失败,结果交回开 PR 的会话,由它查明后手动重跑对应的流程。
|
|
102
105
|
|
|
103
|
-
- PR 在 GitHub 网页上合并或关闭(不经这条运行的「等 GitHub
|
|
106
|
+
- PR 在 GitHub 网页上合并或关闭(不经这条运行的「等 GitHub 确认」,也不是上面那种你批准的版本在合并时先送到的关闭),运行随之结束,交出去的任务和卡片撤回,不删除分支、不部署、不发布。
|
|
104
107
|
- 正常结束只更新运行与卡片、结清等待,不唤醒 Agent;勾选「全部完成后通知 Agent」则在合并及所选删除分支、部署、发布都结束后回传一次。未处理的失败照常回传;手动发起的评审交回结论。
|
|
105
108
|
- 流程只按检查、评审结果、PR 状态与你的批准推进,不读取作者会话的忙闲、后台任务或其他运行;合并前要先完成的验证写成检查(第 2 步)或合并前检查(第 5 步)。
|
|
106
109
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "review",
|
|
4
4
|
"displayName": "PR 生命流程",
|
|
5
5
|
"description": "会话开的 PR 从开出来起一条流程:每个新版本先跑项目声明的检查,再请另一家 Agent 评审,要求修改时交给开 PR 的会话处理、有分歧时交给你仲裁;通过后请你批准合并,跑过项目的合并前检查再合并,合并后按你的选择删除远程分支、调用项目的部署和发布流程,PR 合并或关闭时结束。",
|
|
6
|
-
"version": "2.8.
|
|
6
|
+
"version": "2.8.1",
|
|
7
7
|
"categories": ["工作流程"],
|
|
8
8
|
"extensionDependencies": [
|
|
9
9
|
"github"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Records the user's approval to merge (../.coda/workflows/pull-request.bpmn「记下批准」): when (`at`: a review asking for
|
|
2
|
+
// changes later voids it), and what they chose to follow the merge (`deleteBranch`, `deploy`, `release`, `releaseKinds`,
|
|
3
|
+
// `notify`, and `what`, the choice as the merge step says it). Put out here, not by the merge step, so that the process
|
|
4
|
+
// follows the choice however it hears of the merge: after the merge step, or from GitHub while that step still runs.
|
|
5
|
+
import { json, output } from './step.mjs';
|
|
6
|
+
|
|
7
|
+
const options = (json('APPROVED', {}) ?? {}).options ?? {};
|
|
8
|
+
const chosen = id => options[id] === true;
|
|
9
|
+
output('at', Date.now());
|
|
10
|
+
output('deleteBranch', chosen('deleteBranch'));
|
|
11
|
+
output('deploy', chosen('deploy'));
|
|
12
|
+
output('release', chosen('preview') || chosen('release'));
|
|
13
|
+
output('releaseKinds', ['preview', 'release'].filter(chosen).join(','));
|
|
14
|
+
output('notify', chosen('notify'));
|
|
15
|
+
output('what', ['合并', ...[['deleteBranch', '合并后删除远程分支'], ['deploy', '部署'], ['preview', '发布预览版'], ['release', '发布正式版'], ['notify', '全部完成后通知 Agent']]
|
|
16
|
+
.filter(([id]) => chosen(id)).map(([, name]) => name)].join(' · '));
|
package/scripts/merge.mjs
CHANGED
|
@@ -4,23 +4,15 @@
|
|
|
4
4
|
// merge a version pushed later. Only into the repository's default branch, as GitHub has the base now: Coda hears that a
|
|
5
5
|
// base changed only when it next looks, which may be after the user approved. Not merged (based elsewhere, a conflict, a
|
|
6
6
|
// draft, checks not passed) is no failure of the step: it is put out (`refused`, and the `reason`) for the session that
|
|
7
|
-
// opened the pull request to deal with. What the user chose
|
|
8
|
-
//
|
|
7
|
+
// opened the pull request to deal with. What the user chose to follow the merge is put out when they approved
|
|
8
|
+
// (approval.mjs); here it is only said (`WHAT`).
|
|
9
9
|
import { spawnSync } from 'node:child_process';
|
|
10
|
-
import { baseOf,
|
|
10
|
+
import { baseOf, output, summary } from './step.mjs';
|
|
11
11
|
|
|
12
|
-
const approved = json('APPROVED', {}) ?? {};
|
|
13
|
-
const options = approved.options ?? {};
|
|
14
|
-
const chosen = id => options[id] === true;
|
|
15
12
|
const url = process.env.URL, head = process.env.HEAD, method = ['merge', 'rebase', 'squash'].includes(process.env.METHOD) ? process.env.METHOD : 'squash';
|
|
16
13
|
const number = /\/pull\/(\d+)/.exec(url ?? '')?.[1];
|
|
17
14
|
if (!number || !/^[0-9a-f]{40,64}$/.test(head ?? '')) { console.error('不知道要合并哪个 PR 的哪个提交'); process.exit(1); }
|
|
18
|
-
|
|
19
|
-
output('deploy', chosen('deploy'));
|
|
20
|
-
output('release', chosen('preview') || chosen('release'));
|
|
21
|
-
output('releaseKinds', ['preview', 'release'].filter(chosen).join(','));
|
|
22
|
-
output('notify', chosen('notify'));
|
|
23
|
-
const what = ['合并', ...[['deleteBranch', '合并后删除远程分支'], ['deploy', '部署'], ['preview', '发布预览版'], ['release', '发布正式版'], ['notify', '全部完成后通知 Agent']].filter(([id]) => chosen(id)).map(([, name]) => name)].join(' · ');
|
|
15
|
+
const what = process.env.WHAT;
|
|
24
16
|
|
|
25
17
|
const based = await baseOf(url);
|
|
26
18
|
const elsewhere = based.error ?? (based.base !== based.main ? `base 是 ${based.base},不是默认分支 ${based.main};Coda 得知 base 变了后从头再看` : null);
|