@coda-console/review 2.11.0 → 2.13.0

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.
@@ -17,7 +17,7 @@
17
17
  <message id="ready" name="pull_request.ready_for_review" />
18
18
  <message id="edited" name="pull_request.edited" />
19
19
  <message id="closed" name="pull_request.closed" />
20
- <process id="pull-request" name="PR 生命流程" isExecutable="true"
20
+ <process id="pull-request" name="PR 生命流程" isExecutable="true" coda:autoRun="=vars.review.autoRun"
21
21
  coda:key='=lower case(if github.event.pull_request.html_url != null then github.event.pull_request.html_url
22
22
  else if matches(inputs.pr, "^https://github[.]com/[a-z0-9_.-]+/[a-z0-9_.-]+/pull/[1-9][0-9]*$", "i") then inputs.pr else null)'
23
23
  coda:title='PR {{if github.event.coda.heard = null then (if review.pr = null then inputs.pr else review.pr) else "#" + string(github.event.number) + " " + github.event.pull_request.title}}'>
@@ -0,0 +1,312 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- 简易开发(README.md「简易开发」):主 Agent 自己把活干完,你在会话里开启它,流程推送、检查、评审一次,你验收、批准后合并。
3
+ 交上改动:第一张任务交给主 Agent,不叫醒它,随会话的下一条输入告诉它;它把改动提交到自己的分支,答复改动汇报。
4
+ 推送:流程把那个分支的最新提交推到自己的分支 simple/<运行>,开 PR 到目标分支;之后每次修改都推同一个分支、更新同一个 PR。
5
+ 检查:在这个提交上调用项目声明为检查的流程(coda:kind="check"),没通过交回主 Agent。
6
+ 评审:评审方(发起时选的,没选按设置「评审组合」)在只读会话里评审一次;要求修改交回主 Agent,它改,或写明不改的理由。之后只重跑检查,不评第二轮。
7
+ 设备验收(可选):主 Agent 装预览版,你在设备上验收,「不行」交回主 Agent。
8
+ 合并前检查、GitHub 检查都通过后请你批准;合并后按你勾选的部署、发布。BPMN 2.0,由 Coda 执行(docs/workflows.md)。 -->
9
+ <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:coda="https://coda.pub/schema/bpmn/1.0"
10
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="simple-definitions" targetNamespace="https://coda.pub/plugins/review">
11
+ <process id="simple" name="简易开发" isExecutable="true" coda:title="简易开发">
12
+ <extensionElements>
13
+ <coda:input name="branch" label="分支" type="branch" defaultFrom="session.branch" required="true" description="主 Agent 提交改动的分支,默认是会话所在的分支" />
14
+ <coda:input name="reviewer" label="评审方" type="agent" description="不选按插件设置「评审组合」:Claude 写的由 Codex 评,反之亦然" />
15
+ <coda:input name="devices" label="设备验收" type="boolean" default="false" description="改了客户端、要在 Mac 或 iPhone 上验收时打开" />
16
+ <coda:input name="device" label="验收设备" default="" description="测试机设备名,如 duo-testbed;验收期间独占它;留空不占设备" />
17
+ <coda:input name="base" label="目标分支" default="" description="留空用仓库默认分支" />
18
+ </extensionElements>
19
+ <startEvent id="start" />
20
+ <sequenceFlow id="start-report" sourceRef="start" targetRef="report" />
21
+
22
+ <userTask id="report" name="交上改动" coda:wake="false" coda:noteLabel="写给用户的改动汇报">
23
+ <documentation>用户在这个会话里开启了简易开发:你自己把这次的改动做完,流程推送、跑项目检查、请{{if inputs.reviewer = null then "评审方" else " " + inputs.reviewer.agent + " "}}评审一次,用户验收、批准后合并。
24
+ 把改动提交到分支 {{inputs.branch}}(不用推送、不用开 PR),再答复。备注必填,是写给用户的改动汇报,会放在 PR 描述和批准卡最上面。约 8 行以内,只写用户能感知的变化和动到的端,不放实现细节、测试数量、文件清单,不贴代码:
25
+ 做了什么
26
+ - …(3~5 条)
27
+ 需要你知道:…(风险、没做的、顺带改的;没有写「无」)
28
+ 设备验收:{{if inputs.devices then "开启" else "未开启"}}。
29
+ {{if push.feedback = null then "" else push.feedback}}</documentation>
30
+ <extensionElements><coda:choice id="done" name="已提交" primary="true" note="required" /></extensionElements>
31
+ </userTask>
32
+ <sequenceFlow id="report-push" sourceRef="report" targetRef="push" />
33
+
34
+ <!-- 每次交回改动都从这里走:读出分支的最新提交,推到流程的分支。没有新提交、或分支读不到,交回主 Agent。 -->
35
+ <scriptTask id="push" name="推送改动" coda:timeout="5" scriptFormat="bash">
36
+ <extensionElements>
37
+ <coda:env name="BRANCH" value="=inputs.branch" />
38
+ <coda:env name="BASE" value="=inputs.base" />
39
+ <coda:env name="REPORT" value="=report" />
40
+ <coda:output name="route" /><coda:output name="feedback" /><coda:output name="head" /><coda:output name="lane" />
41
+ </extensionElements>
42
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" push</script>
43
+ </scriptTask>
44
+ <sequenceFlow id="push-how" sourceRef="push" targetRef="pushed" />
45
+ <exclusiveGateway id="pushed" name="推上去了吗" default="push-checks" />
46
+ <sequenceFlow id="push-report" sourceRef="pushed" targetRef="report"><conditionExpression xsi:type="tFormalExpression">=push.route = "report"</conditionExpression></sequenceFlow>
47
+ <sequenceFlow id="push-fix" sourceRef="pushed" targetRef="problem"><conditionExpression xsi:type="tFormalExpression">=push.route = "fix"</conditionExpression></sequenceFlow>
48
+ <sequenceFlow id="push-checks" sourceRef="pushed" targetRef="checks" />
49
+
50
+ <serviceTask id="checks" name="项目检查" coda:action="run-workflows" coda:status="跑项目的检查">
51
+ <extensionElements><coda:param name="kind" value="check" /><coda:param name="commit" value="=push.head" /></extensionElements>
52
+ </serviceTask>
53
+ <boundaryEvent id="checks-failed" name="没通过" attachedToRef="checks"><errorEventDefinition /></boundaryEvent>
54
+ <sequenceFlow id="checks-problem" sourceRef="checks-failed" targetRef="checks-feedback" />
55
+ <scriptTask id="checks-feedback" name="交回检查失败" scriptFormat="bash" coda:checkout="false" coda:timeout="5">
56
+ <extensionElements><coda:env name="STEP" value="项目检查" /></extensionElements>
57
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" failed</script>
58
+ </scriptTask>
59
+ <sequenceFlow id="checks-fix" sourceRef="checks-feedback" targetRef="problem" />
60
+ <sequenceFlow id="checks-pr" sourceRef="checks" targetRef="pr" />
61
+
62
+ <scriptTask id="pr" name="开 PR 或更新" coda:timeout="5" scriptFormat="bash">
63
+ <extensionElements>
64
+ <coda:env name="DEVICES" value="=inputs.devices" />
65
+ <coda:output name="url" /><coda:output name="head" /><coda:output name="review" /><coda:output name="device" /><coda:output name="summary" />
66
+ </extensionElements>
67
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" pr</script>
68
+ </scriptTask>
69
+ <sequenceFlow id="pr-next" sourceRef="pr" targetRef="after-pr" />
70
+ <exclusiveGateway id="after-pr" name="接下来" default="pr-premerge" />
71
+ <sequenceFlow id="pr-review" sourceRef="after-pr" targetRef="review"><conditionExpression xsi:type="tFormalExpression">=pr.review = true</conditionExpression></sequenceFlow>
72
+ <sequenceFlow id="pr-device" sourceRef="after-pr" targetRef="acceptance"><conditionExpression xsi:type="tFormalExpression">=pr.device = true</conditionExpression></sequenceFlow>
73
+ <sequenceFlow id="pr-premerge" sourceRef="after-pr" targetRef="premerge" />
74
+
75
+ <!-- 评审只有一轮:评审过的运行,修改后只重跑检查。 -->
76
+ <scriptTask id="review" name="评审" coda:audience="user" coda:timeout="120" coda:status="评审中" scriptFormat="bash">
77
+ <extensionElements>
78
+ <coda:env name="REVIEWER" value="=inputs.reviewer" />
79
+ <coda:env name="REVIEWERS" value="=vars.review.reviewers" />
80
+ <coda:env name="BLOCKING" value="=vars.review.blockingSeverity" />
81
+ <coda:env name="PRINCIPLES" value="=vars.review.principles" />
82
+ <coda:env name="SESSION" value="=github.event.coda.session" />
83
+ <coda:env name="PR" value="=pr.url" />
84
+ <coda:output name="decision" /><coda:output name="passed" /><coda:output name="changes" /><coda:output name="line" />
85
+ <coda:output name="findings" /><coda:output name="report" /><coda:output name="rules" /><coda:output name="files" />
86
+ <coda:output name="pr" /><coda:output name="head" /><coda:output name="base" /><coda:output name="count" /><coda:output name="changesAt" />
87
+ </extensionElements>
88
+ <script>node "${CODA_PLUGIN_PATH}/scripts/review.mjs"</script>
89
+ </scriptTask>
90
+ <sequenceFlow id="reviewed" sourceRef="review" targetRef="reviewed-record" />
91
+ <scriptTask id="reviewed-record" name="记下评审" scriptFormat="bash" coda:checkout="false" coda:timeout="5">
92
+ <extensionElements><coda:env name="REVIEW" value="=review" /></extensionElements>
93
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" reviewed</script>
94
+ </scriptTask>
95
+ <sequenceFlow id="reviewed-verdict" sourceRef="reviewed-record" targetRef="verdict" />
96
+ <exclusiveGateway id="verdict" name="要求修改吗" default="review-passed" />
97
+ <sequenceFlow id="review-changes" sourceRef="verdict" targetRef="answer"><conditionExpression xsi:type="tFormalExpression">=review.changes</conditionExpression></sequenceFlow>
98
+ <sequenceFlow id="review-passed" sourceRef="verdict" targetRef="after-review" />
99
+ <userTask id="answer" name="处理评审意见" coda:noteLabel="改了什么,或不改的理由">
100
+ <documentation>评审方要求修改 PR {{review.pr}},阻塞级别({{vars.review.blockingSeverity}})及以上的问题:
101
+
102
+ {{review.findings}}
103
+
104
+ 评审方依据的规则如下,与交给它的原文相同:
105
+
106
+ {{review.rules}}
107
+
108
+ 请照这些规则独立核实:没有可达的触发路径的、属于规则说不报的、按严重程度的定义其实低于阻塞级别的,都不算成立。
109
+ 成立的就修改,提交到分支 {{inputs.branch}},选「已修改」,备注写改了什么。不改的选「不改」,备注写明理由和依据的规则,会写进 PR 与批准卡,由用户批准时判断。之后只重跑检查,不再评审。</documentation>
110
+ <extensionElements>
111
+ <coda:choice id="fixed" name="已修改" primary="true" />
112
+ <coda:choice id="kept" name="不改" note="required" />
113
+ </extensionElements>
114
+ </userTask>
115
+ <sequenceFlow id="answered" sourceRef="answer" targetRef="answer-how" />
116
+ <exclusiveGateway id="answer-how" name="改了吗" default="answer-push" />
117
+ <sequenceFlow id="answer-kept" sourceRef="answer-how" targetRef="kept-record"><conditionExpression xsi:type="tFormalExpression">=answer.chose.kept</conditionExpression></sequenceFlow>
118
+ <sequenceFlow id="answer-push" sourceRef="answer-how" targetRef="push" />
119
+ <scriptTask id="kept-record" name="记下不改的理由" scriptFormat="bash" coda:checkout="false" coda:timeout="5">
120
+ <extensionElements><coda:env name="ANSWER" value="=answer" /></extensionElements>
121
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" kept</script>
122
+ </scriptTask>
123
+ <sequenceFlow id="kept-pr" sourceRef="kept-record" targetRef="pr" />
124
+ <exclusiveGateway id="after-review" name="设备验收吗" default="review-premerge" />
125
+ <sequenceFlow id="review-device" sourceRef="after-review" targetRef="acceptance"><conditionExpression xsi:type="tFormalExpression">=pr.device = true</conditionExpression></sequenceFlow>
126
+ <sequenceFlow id="review-premerge" sourceRef="after-review" targetRef="premerge" />
127
+
128
+ <subProcess id="acceptance" name="安装与设备验收" coda:optional="true">
129
+ <startEvent id="acceptance-start" />
130
+ <sequenceFlow id="acceptance-enter" sourceRef="acceptance-start" targetRef="device-lock-choice" />
131
+ <exclusiveGateway id="device-lock-choice" name="是否占用验收设备" default="device-lock-skip" />
132
+ <sequenceFlow id="device-lock-needed" sourceRef="device-lock-choice" targetRef="device-lock"><conditionExpression xsi:type="tFormalExpression">=inputs.device != ""</conditionExpression></sequenceFlow>
133
+ <sequenceFlow id="device-lock-skip" sourceRef="device-lock-choice" targetRef="preview" />
134
+ <serviceTask id="device-lock" name="等验收设备" coda:action="hold-group" coda:status="等验收设备 {{inputs.device}}">
135
+ <extensionElements>
136
+ <coda:param name="group" value="device:{{inputs.device}}" />
137
+ <coda:param name="capacity" value="1" />
138
+ </extensionElements>
139
+ </serviceTask>
140
+ <sequenceFlow id="device-lock-acquired" sourceRef="device-lock" targetRef="preview" />
141
+ <userTask id="preview" name="安装预览版" coda:noteLabel="安装结果,或要先改的地方">
142
+ <documentation>要在设备上验收的提交是 {{pr.head}}(PR {{pr.url}})。
143
+ 只装改到的那一端:改了 Mac 用 workflow_run 发起 mac-preview-install,改了 iPhone 发起 ios-preview-install,都传 commit="{{pr.head}}"。等发起的安装都成功后答复「已装好」;有失败先处理,不能把发起当作装好。
144
+ {{if inputs.device = "" then "" else "发起 ios-preview-install 时还要传 device=\"" + inputs.device + "\"。安装运行会借本段占着的设备,不另排队。"}}
145
+ 需要先修改时,修改并提交到分支 {{inputs.branch}},选「已修改」,备注写改了什么。预览只装客户端,不从这个分支部署后端。</documentation>
146
+ <extensionElements>
147
+ <coda:choice id="installed" name="已装好" primary="true" />
148
+ <coda:choice id="changed" name="已修改" note="required" />
149
+ </extensionElements>
150
+ </userTask>
151
+ <sequenceFlow id="preview-how" sourceRef="preview" targetRef="after-preview" />
152
+ <exclusiveGateway id="after-preview" name="装好了吗" default="preview-device" />
153
+ <sequenceFlow id="preview-changed" sourceRef="after-preview" targetRef="acceptance-changed"><conditionExpression xsi:type="tFormalExpression">=preview.chose.changed</conditionExpression></sequenceFlow>
154
+ <sequenceFlow id="preview-device" sourceRef="after-preview" targetRef="device" />
155
+ <userTask id="device" name="设备验收" coda:assignee="user" coda:noteLabel="验收意见">
156
+ <documentation>{{pr.summary}}
157
+
158
+ 提交:{{pr.head}}
159
+ 主 Agent 的安装结果:{{preview.note}}
160
+ {{if inputs.device = "" then "" else "验收期间设备 " + inputs.device + " 一直被本段占着。"}}
161
+ 请在设备上验收。选「不行」写具体意见或附上截图,交回主 Agent 修改,改好后重新安装验收。</documentation>
162
+ <extensionElements><coda:choice id="yes" name="通过" primary="true" /><coda:choice id="no" name="不行" note="required" /></extensionElements>
163
+ </userTask>
164
+ <sequenceFlow id="device-how" sourceRef="device" targetRef="after-device" />
165
+ <exclusiveGateway id="after-device" name="验收结论" default="device-passed" />
166
+ <sequenceFlow id="device-failed" sourceRef="after-device" targetRef="acceptance-failed"><conditionExpression xsi:type="tFormalExpression">=device.chose.no</conditionExpression></sequenceFlow>
167
+ <sequenceFlow id="device-passed" sourceRef="after-device" targetRef="acceptance-passed" />
168
+ <endEvent id="acceptance-changed"><extensionElements><coda:output name="route" value="changed" /></extensionElements></endEvent>
169
+ <endEvent id="acceptance-failed"><extensionElements><coda:output name="route" value="failed" /></extensionElements></endEvent>
170
+ <endEvent id="acceptance-passed"><extensionElements><coda:output name="route" value="passed" /></extensionElements></endEvent>
171
+ </subProcess>
172
+ <sequenceFlow id="acceptance-finished" sourceRef="acceptance" targetRef="accepted" />
173
+ <scriptTask id="accepted" name="记下验收" scriptFormat="bash" coda:checkout="false" coda:timeout="5">
174
+ <extensionElements>
175
+ <coda:env name="ROUTE" value="=acceptance.route" />
176
+ <coda:env name="DEVICE" value="=device" />
177
+ <coda:output name="route" />
178
+ </extensionElements>
179
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" accepted</script>
180
+ </scriptTask>
181
+ <sequenceFlow id="accepted-how" sourceRef="accepted" targetRef="after-acceptance" />
182
+ <exclusiveGateway id="after-acceptance" name="验收段结论" default="acceptance-premerge" />
183
+ <sequenceFlow id="acceptance-push" sourceRef="after-acceptance" targetRef="push"><conditionExpression xsi:type="tFormalExpression">=accepted.route = "push"</conditionExpression></sequenceFlow>
184
+ <sequenceFlow id="acceptance-fix" sourceRef="after-acceptance" targetRef="problem"><conditionExpression xsi:type="tFormalExpression">=accepted.route = "fix"</conditionExpression></sequenceFlow>
185
+ <sequenceFlow id="acceptance-premerge" sourceRef="after-acceptance" targetRef="premerge" />
186
+
187
+ <serviceTask id="premerge" name="合并前检查" coda:action="run-workflows" coda:status="合并前检查">
188
+ <extensionElements><coda:param name="kind" value="premerge" /><coda:param name="commit" value="=pr.head" /></extensionElements>
189
+ </serviceTask>
190
+ <boundaryEvent id="premerge-failed" name="没通过" attachedToRef="premerge"><errorEventDefinition /></boundaryEvent>
191
+ <sequenceFlow id="premerge-problem" sourceRef="premerge-failed" targetRef="premerge-feedback" />
192
+ <scriptTask id="premerge-feedback" name="交回合并前检查失败" scriptFormat="bash" coda:checkout="false" coda:timeout="5">
193
+ <extensionElements><coda:env name="STEP" value="合并前检查" /></extensionElements>
194
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" failed</script>
195
+ </scriptTask>
196
+ <sequenceFlow id="premerge-fix" sourceRef="premerge-feedback" targetRef="problem" />
197
+ <sequenceFlow id="premerge-github" sourceRef="premerge" targetRef="github-checks" />
198
+
199
+ <scriptTask id="github-checks" name="等 GitHub 检查" coda:timeout="60" coda:checkout="false" coda:status="等 GitHub 检查" scriptFormat="bash">
200
+ <extensionElements>
201
+ <coda:env name="URL" value="=pr.url" />
202
+ <coda:env name="EVERY" value="10" />
203
+ <coda:output name="passed" /><coda:output name="lines" />
204
+ </extensionElements>
205
+ <script>node "${CODA_PLUGIN_PATH}/scripts/checks.mjs"</script>
206
+ </scriptTask>
207
+ <sequenceFlow id="github-checked" sourceRef="github-checks" targetRef="github-how" />
208
+ <exclusiveGateway id="github-how" name="都过了吗" default="github-passed" />
209
+ <sequenceFlow id="github-failed" sourceRef="github-how" targetRef="github-feedback"><conditionExpression xsi:type="tFormalExpression">=not(github-checks.passed)</conditionExpression></sequenceFlow>
210
+ <sequenceFlow id="github-passed" sourceRef="github-how" targetRef="kinds" />
211
+ <scriptTask id="github-feedback" name="交回 GitHub 检查失败" scriptFormat="bash" coda:checkout="false" coda:timeout="5">
212
+ <extensionElements><coda:env name="STEP" value="GitHub 检查" /><coda:env name="LINES" value="=github-checks.lines" /></extensionElements>
213
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" failed</script>
214
+ </scriptTask>
215
+ <sequenceFlow id="github-fix" sourceRef="github-feedback" targetRef="problem" />
216
+
217
+ <!-- 评审之外要改的都交给这一张:推送不了、检查没过、设备验收不行、合并冲突。要改的是什么由前一步记下,这里读出;改好提交后答复,从推送重新走。 -->
218
+ <scriptTask id="problem" name="要修改的地方" scriptFormat="bash" coda:checkout="false" coda:timeout="5">
219
+ <extensionElements><coda:output name="text" /></extensionElements>
220
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" problem</script>
221
+ </scriptTask>
222
+ <sequenceFlow id="problem-fix" sourceRef="problem" targetRef="fix" />
223
+ <userTask id="fix" name="修改后答复" coda:noteLabel="改了什么">
224
+ <documentation>{{problem.text}}
225
+
226
+ 修改并提交到分支 {{inputs.branch}},再答复,备注写改了什么。流程会推送、重跑项目检查,更新同一个 PR。</documentation>
227
+ <extensionElements><coda:choice id="done" name="已修改" primary="true" /></extensionElements>
228
+ </userTask>
229
+ <sequenceFlow id="fix-push" sourceRef="fix" targetRef="push" />
230
+
231
+ <serviceTask id="kinds" name="看项目有哪些部署、发布" coda:action="workflow-kinds">
232
+ <extensionElements><coda:param name="commit" value="=pr.head" /></extensionElements>
233
+ </serviceTask>
234
+ <sequenceFlow id="kinds-approve" sourceRef="kinds" targetRef="approve" />
235
+ <userTask id="approve" name="批准合并" coda:assignee="user" coda:status="检查通过:等你批准合并">
236
+ <documentation>{{pr.summary}}
237
+
238
+ - **检查**:项目检查、合并前检查{{if github-checks.lines = null or github-checks.lines = "" then "" else "、GitHub 检查" + github-checks.lines}}
239
+ - **PR**:{{pr.url}}
240
+
241
+ 「合并」以 {{vars.review.mergeMethod}} 方式合并提交 {{pr.head}},随后按勾选部署、发布。「暂不合并」须写明原因,交给主 Agent 跟进。</documentation>
242
+ <extensionElements>
243
+ <coda:choice id="merge" name="合并" primary="true">
244
+ <coda:option default='=list contains(vars.review.mergeOptions, "deploy")' id="deploy" name="部署" detail="调用项目里的部署流程" coda:shown="=kinds.deploy" />
245
+ <coda:option default='=list contains(vars.review.mergeOptions, "preview")' id="preview" name="发布预览版" detail="调用项目里的预览发布流程" coda:shown="=kinds.preview" />
246
+ <coda:option default='=list contains(vars.review.mergeOptions, "release")' id="release" name="发布正式版" detail="调用项目里的正式发布流程" coda:shown="=kinds.release" />
247
+ <coda:option default="true" id="notify" name="全部完成后通知 Agent" detail="合并及所选部署、发布结束后通知" />
248
+ </coda:choice>
249
+ <coda:choice id="stop" name="暂不合并" note="required" />
250
+ </extensionElements>
251
+ </userTask>
252
+ <sequenceFlow id="approve-how" sourceRef="approve" targetRef="approved" />
253
+ <exclusiveGateway id="approved" name="合并吗" default="approved-merge" />
254
+ <sequenceFlow id="approved-stop" sourceRef="approved" targetRef="stopped"><conditionExpression xsi:type="tFormalExpression">=approve.chose.stop</conditionExpression></sequenceFlow>
255
+ <sequenceFlow id="approved-merge" sourceRef="approved" targetRef="approval" />
256
+ <endEvent id="stopped" name="暂不合并" />
257
+ <scriptTask id="approval" name="记下批准" coda:timeout="5" coda:checkout="false" scriptFormat="bash">
258
+ <extensionElements>
259
+ <coda:env name="APPROVED" value="=approve" />
260
+ <coda:output name="at" /><coda:output name="deleteBranch" /><coda:output name="deploy" /><coda:output name="release" />
261
+ <coda:output name="releaseKinds" /><coda:output name="notify" /><coda:output name="what" />
262
+ </extensionElements>
263
+ <script>node "${CODA_PLUGIN_PATH}/scripts/approval.mjs"</script>
264
+ </scriptTask>
265
+ <sequenceFlow id="approval-merge" sourceRef="approval" targetRef="merge" />
266
+ <scriptTask id="merge" name="合并" coda:timeout="10" coda:status="合并中" scriptFormat="bash">
267
+ <extensionElements>
268
+ <coda:env name="METHOD" value="=vars.review.mergeMethod" />
269
+ <coda:env name="BRANCH" value="=inputs.branch" />
270
+ <coda:output name="route" /><coda:output name="commit" />
271
+ </extensionElements>
272
+ <script>node "${CODA_PLUGIN_PATH}/scripts/simple.mjs" merge</script>
273
+ </scriptTask>
274
+ <sequenceFlow id="merge-how" sourceRef="merge" targetRef="merged" />
275
+ <exclusiveGateway id="merged" name="合并了吗" default="merged-deploy" />
276
+ <sequenceFlow id="merge-conflict" sourceRef="merged" targetRef="problem"><conditionExpression xsi:type="tFormalExpression">=merge.route = "conflict"</conditionExpression></sequenceFlow>
277
+ <sequenceFlow id="merged-deploy" sourceRef="merged" targetRef="deploying" />
278
+
279
+ <exclusiveGateway id="deploying" name="部署吗" default="not-deploying" />
280
+ <sequenceFlow id="to-deploy" sourceRef="deploying" targetRef="deploy"><conditionExpression xsi:type="tFormalExpression">=approval.deploy</conditionExpression></sequenceFlow>
281
+ <sequenceFlow id="not-deploying" sourceRef="deploying" targetRef="releasing" />
282
+ <serviceTask id="deploy" name="部署" coda:action="run-workflows" coda:status="部署中">
283
+ <extensionElements><coda:param name="kind" value="deploy" /><coda:param name="commit" value="=merge.commit" /></extensionElements>
284
+ </serviceTask>
285
+ <sequenceFlow id="deployed" sourceRef="deploy" targetRef="releasing" />
286
+ <exclusiveGateway id="releasing" name="发布吗" default="not-releasing" />
287
+ <sequenceFlow id="to-notes" sourceRef="releasing" targetRef="notes"><conditionExpression xsi:type="tFormalExpression">=approval.release</conditionExpression></sequenceFlow>
288
+ <sequenceFlow id="not-releasing" sourceRef="releasing" targetRef="done" />
289
+ <userTask id="notes" name="写更新说明" coda:status="发布:写更新说明" coda:completeLabel="提交并继续发布" coda:rejectLabel="无法提供更新说明" coda:noteLabel="更新说明">
290
+ <documentation>PR {{pr.url}} 已合并,接下来按用户的选择发布。
291
+
292
+ 请写这次发布的更新说明:Markdown,面向用户,写这次改了什么、用户会注意到什么变化,不写内部实现,不超过 2000 字。用 completed 答复,note 里只放更新说明本身。</documentation>
293
+ </userTask>
294
+ <sequenceFlow id="noted" sourceRef="notes" targetRef="publishing" />
295
+ <scriptTask id="publishing" name="整理发布参数" coda:timeout="5" coda:checkout="false" scriptFormat="bash">
296
+ <extensionElements><coda:env name="AGENT" value="=notes" /><coda:output name="inputs" /></extensionElements>
297
+ <script>node "${CODA_PLUGIN_PATH}/scripts/notes.mjs"</script>
298
+ </scriptTask>
299
+ <sequenceFlow id="to-publish" sourceRef="publishing" targetRef="publish" />
300
+ <serviceTask id="publish" name="发布" coda:action="run-workflows" coda:status="发布中">
301
+ <extensionElements>
302
+ <coda:param name="kind" value="=approval.releaseKinds" />
303
+ <coda:param name="commit" value="=merge.commit" />
304
+ <coda:param name="inputs" value="=publishing.inputs" />
305
+ </extensionElements>
306
+ </serviceTask>
307
+ <sequenceFlow id="published" sourceRef="publish" targetRef="done" />
308
+ <endEvent id="done" name="已合并" coda:notify="=approval.notify">
309
+ <extensionElements><coda:output name="pr" value="=pr.url" /><coda:output name="commit" value="=merge.commit" /></extensionElements>
310
+ </endEvent>
311
+ </process>
312
+ </definitions>
package/README.md CHANGED
@@ -8,8 +8,12 @@
8
8
  也可以 `workflow_run pull-request` 手动发起(必填 `pr`:GitHub 返回的完整 PR 地址,可选 `focus`)。已有运行时返回它,沿用原进度、关注点和结果接收会话;草稿中的运行也照旧等标记为可评审。没有运行时只评审一次、不计次数、不进入合并;如果随后 PR 观察发来事件,在同一条运行里接上完整流程。是否接入完整流程按 `github.event.coda.heard` 判断:手动运行尚未收到事件时为空。
9
9
  `pr` 须在创建运行前明确。编号、旧仓库地址或带后缀的链接先用 `gh pr view <编号或链接> --json url --jq .url` 取得 GitHub 返回的地址,再传入;流程不从 origin 猜仓库身份。需要查最近开的 PR 时先用 GitHub 插件的 `github-reported-pr` 找到它,再用 `gh pr view` 确认当前地址。输入不接受编号、末尾斜线、查询参数或片段,避免不同拼写创建不同主键。此版本需要支持 `coda:key` 的 Coda 流程引擎。
10
10
 
11
+ 另有一个由你在会话里开启的「简易开发」(流程 `simple`,见下文),复用这里的评审与合并。
12
+
11
13
  ```
12
14
  .coda/workflows/pull-request.bpmn 流程本身
15
+ .coda/workflows/simple.bpmn 简易开发
16
+ scripts/simple.mjs 简易开发的推送、PR、验收与合并
13
17
  scripts/checks.mjs 等 GitHub 检查
14
18
  scripts/review.mjs 交叉评审:选评审方、开会话、读结论、写 PR 评论
15
19
  scripts/base.mjs 看 base(叠放)
@@ -25,6 +29,7 @@ prompts/principles/ 评审重点,一项一段,按设置取
25
29
 
26
30
  | 设置 | 类型 | 默认 |
27
31
  | --- | --- | --- |
32
+ | `review.autoRun` PR 自动运行 | 开关:会话开的 PR 新建或有新提交时是否自动开始;关掉后只能手动发起。会话或目录在「工作流」里单独设过的按它们的(流程的 `coda:autoRun`);不影响简易开发 | 开 |
28
33
  | `review.reviewers` 评审组合 | 表格:作者匹配 → Agent 组合 | Claude 由 Codex 评审,Codex 由 Claude 评审,Kimi、Grok 由 Codex 评审,OpenCode 由 Claude 评审 |
29
34
  | `review.blockingSeverity` 阻塞级别 | P0–P3 之一 | P2 |
30
35
  | `review.principles` 评审重点 | 多选:`state` 状态与失败、`defense` 多余的防御、`architecture` 架构与腐化、`tests` 测试;勾选的那几段(`prompts/principles/` 下同名文件)放进提示词 | 都选 |
@@ -112,6 +117,29 @@ prompts/principles/ 评审重点,一项一段,按设置取
112
117
  - 正常结束只更新运行与卡片、结清等待,不唤醒 Agent;勾选「全部完成后通知 Agent」则在合并及所选删除分支、部署、发布都结束后回传一次。未处理的失败照常回传;手动发起的评审交回结论。
113
118
  - 流程只按检查、评审结果、PR 状态与你的批准推进,不读取作者会话的忙闲、后台任务或其他运行;合并前要先完成的验证写成检查(第 2 步)或合并前检查(第 5 步)。
114
119
 
120
+ ## 简易开发
121
+
122
+ 主 Agent 自己把活干完时,在会话的流程里开启「简易开发」(`simple`):流程推送、跑检查、评审一次,你验收、批准后合并。比 PR 生命流程轻:只评审一轮,不等 PR 事件。
123
+
124
+ | 输入 | 用途 |
125
+ | --- | --- |
126
+ | `branch` | 「分支」,主 Agent 提交改动的分支,默认是会话所在的分支(`defaultFrom="session.branch"`) |
127
+ | `reviewer` | 「评审方」,一组 Agent 选择(流程参数的 `agent` 类型),表单里用 App 的 Agent 选择器;不选按设置「评审组合」(`review.reviewers`),与 PR 生命流程相同 |
128
+ | `devices` | 「设备验收」,默认关;改了客户端、要在 Mac 或 iPhone 上验收时打开 |
129
+ | `device` | 「验收设备」,如 `duo-testbed`,默认空;验收期间独占这台设备 |
130
+ | `base` | 「目标分支」,留空用仓库默认分支 |
131
+
132
+ 1. **交上改动**:第一张任务交给主 Agent,不叫醒它(`coda:wake="false"`),随你在会话里的下一条消息告诉它:你开启了简易开发、它要做什么。它把改动提交到 `branch`,答复时备注必填,是写给你的改动汇报,放在 PR 描述和批准卡最上面。
133
+ 2. **推送**:流程读出 `branch` 的最新提交,推到运行自己的分支 `simple/<运行 ID>`(主 Agent 的分支不推),开 PR 到目标分支,标题是这次改动的第一个提交的标题;之后每次修改都推同一个分支(强推,主 Agent 可以变基)、更新同一个 PR。分支读不到、没有比目标分支新的提交,或答复「已修改」却没有新提交的,交回主 Agent。
134
+ 3. **检查**:在这个提交上调用项目的 `coda:kind="check"`,没通过交回主 Agent,写明运行,它用 `workflow_status` 读失败的步骤和日志。
135
+ 4. **评审一次**:`reviewer`(或评审组合里的那一行)在只读会话里评审,规则、阻塞级别、评审重点与 PR 生命流程相同,结论也写成 PR 评论。要求修改时交主 Agent「处理评审意见」:改了就提交、选「已修改」;不改选「不改」,必须写明理由,写进 PR 和批准卡,由你批准时判断。之后只重跑检查,不评第二轮。
136
+ 5. **设备验收**(`devices` 打开时):主 Agent 只装改到的那一端(`mac-preview-install`、`ios-preview-install`,传 PR 的提交),你在设备上验收;「不行」必须附言(写意见或附截图),交回主 Agent 修改,改好后重新验收。验收过的提交之后又改了,也要重新验收。
137
+ 6. **合并前检查与 GitHub 检查**:在 PR 的提交上跑一次 `coda:kind="premerge"`,再等 GitHub 上的检查都有结果;没通过交回主 Agent。
138
+ 7. **批准合并**:卡片上是改动汇报、评审结论、不改的理由与检查结果。「合并」按 `review.mergeMethod` 合并这个提交,可勾部署、发布预览版、发布正式版(项目有对应流程时出现,默认按 `review.mergeOptions`)与「全部完成后通知 Agent」(默认勾选);「暂不合并」必须写明原因,交给主 Agent 跟进。合并时删除运行自己的分支;与目标分支冲突时交回主 Agent 合入、解冲突,再重跑检查、重新批准。其余合并失败让这一步失败。
139
+ 8. **部署与发布**:合并后在合并提交上按勾选调用部署;发布前请主 Agent 写更新说明,再调用发布流程。
140
+
141
+ 所有交回主 Agent 修改的(评审意见除外)都是同一张「修改后答复」,写明要改的是什么;答复后从推送重新走。进度存在本次运行的产物 `simple.json` 里。需要支持流程参数 `agent` 类型、`coda:wake` 与 `note="required"` 的 Coda。
142
+
115
143
  ## 改成自己的
116
144
 
117
145
  - **只改评审的措辞**:改 `prompts/review.md`;评审的规则在 `prompts/rules.md`,改了评审方和开 PR 的会话同时生效。
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
  "name": "@coda-console/review",
3
3
  "id": "review",
4
4
  "displayName": "PR 生命流程",
5
- "description": "PR 从检查、评审到批准合并",
5
+ "description": "PR 从检查、评审到批准合并;简易开发",
6
6
  "icon": { "symbol": "checkmark.bubble.fill", "color": "purple" },
7
- "version": "2.11.0",
7
+ "version": "2.13.0",
8
8
  "categories": [
9
9
  "工作流程"
10
10
  ],
@@ -15,6 +15,13 @@
15
15
  "configuration": {
16
16
  "title": "PR 生命流程",
17
17
  "properties": {
18
+ "review.autoRun": {
19
+ "title": "PR 自动运行",
20
+ "type": "boolean",
21
+ "order": 0,
22
+ "default": true,
23
+ "description": "会话开的 PR 新建或有新提交时自动开始 PR 生命流程。关掉后只能手动发起;会话或目录在「工作流」里单独设过的,按它们的。不影响简易开发。"
24
+ },
18
25
  "review.reviewers": {
19
26
  "title": "评审组合",
20
27
  "type": "object",
@@ -16,16 +16,17 @@ const hex = value => /^[0-9a-f]{40,64}$/.test(value ?? '') ? value : null;
16
16
  const git = args => execFileSync('git', args, { encoding: 'utf8', timeout: 30_000, stdio: ['ignore', 'pipe', 'pipe'] }).trim();
17
17
  const tryGit = args => { try { return git(args); } catch { return null; } };
18
18
 
19
- // The most specific row whose levels all equal the session's: `*`, then agent, agent|model, agent|model|effort.
20
- const reviewers = json('REVIEWERS', {}), session = json('SESSION', null);
19
+ // The reviewer chosen for the run (simple.bpmn's `reviewer`), else the most specific row whose levels all equal the
20
+ // session's: `*`, then agent, agent|model, agent|model|effort.
21
+ const reviewers = json('REVIEWERS', {}), session = json('SESSION', null), picked = json('REVIEWER', null);
21
22
  const levels = key => key === '*' ? 0 : key.split('|').length;
22
- const row = Object.keys(reviewers).filter(key => {
23
+ const row = picked ? null : Object.keys(reviewers).filter(key => {
23
24
  if (key === '*') return true;
24
25
  const [agent, model, effort] = key.split('|');
25
26
  return agent === session?.agent && (!model || model === session?.model) && (!effort || effort === session?.effort);
26
27
  }).sort((a, b) => levels(b) - levels(a))[0];
27
- if (!row) fail(`评审组合里没有适用于${session?.agent ? `「${[session.agent, session.model, session.effort].filter(Boolean).join(' · ')}」` : '这个会话'}的一行`);
28
- const reviewer = reviewers[row];
28
+ if (!picked && !row) fail(`评审组合里没有适用于${session?.agent ? `「${[session.agent, session.model, session.effort].filter(Boolean).join(' · ')}」` : '这个会话'}的一行`);
29
+ const reviewer = picked ?? reviewers[row];
29
30
 
30
31
  // What is reviewed: the event's pull request, or the explicit PR used to key this manual run before it started.
31
32
  const event = json('PULL_REQUEST', null), automatic = !!event?.head?.sha;
@@ -132,7 +133,7 @@ const commented = spawnSync('gh', ['pr', 'comment', pr.html_url, '--body', [`###
132
133
  `评审方 ${who},提交 ${head.slice(0, 12)},阻塞级别 ${SEVERITIES[blocking]} 及以上。`, report].join('\n\n')], { encoding: 'utf8' });
133
134
  const note = commented.status === 0 ? '' : `没能在 PR 上留评论:${(commented.stderr || '').trim().split('\n').at(-1) || '未知原因'}`;
134
135
  summary([`## 交叉评审 PR #${Number(pr.number)}:${verdict}`,
135
- `评审方:${who}(评审组合「${row === '*' ? '其他作者' : row.split('|').join(' · ')}」);提交 ${head.slice(0, 12)};阻塞级别 ${SEVERITIES[blocking]} 及以上。`,
136
+ `评审方:${who}(${picked ? '发起时选的' : `评审组合「${row === '*' ? '其他作者' : row.split('|').join(' · ')}」`});提交 ${head.slice(0, 12)};阻塞级别 ${SEVERITIES[blocking]} 及以上。`,
136
137
  report, note, prose].filter(Boolean).join('\n\n'));
137
138
 
138
139
  // For the process: the verdict, what blocks, the rules it was judged by, the change by top-level directory for the
@@ -0,0 +1,104 @@
1
+ // The steps of the simple development flow (../.coda/workflows/simple.bpmn「简易开发」) other than the review itself: what
2
+ // the lead agent hands in is pushed from its branch to the run's own branch and opened as one pull request, updated by every
3
+ // later change. What the run has seen so far — the report, the head pushed, the review, what the user accepted on a device,
4
+ // what the agent is to change next — stays in the run's artifacts, every step's checkout being its own.
5
+ import { execFileSync, spawnSync } from 'node:child_process';
6
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
7
+ import { join } from 'node:path';
8
+ import { json, output } from './step.mjs';
9
+
10
+ const env = process.env, action = process.argv[2];
11
+ const statePath = join(env.CODA_ARTIFACTS, 'simple.json');
12
+ const run = (command, args) => execFileSync(command, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] }).trim();
13
+ const git = (...args) => run('git', args), gh = (...args) => run('gh', args);
14
+ const tryGit = (...args) => { const done = spawnSync('git', args, { encoding: 'utf8' }); return done.status === 0 ? done.stdout.trim() : null; };
15
+ const state = existsSync(statePath) ? JSON.parse(readFileSync(statePath, 'utf8')) : null;
16
+ const save = value => writeFileSync(statePath, JSON.stringify(value));
17
+ // What the agent is asked to change: kept for the next 「修改后答复」 (`problem`).
18
+ const ask = (value, text) => { save({ ...value, feedback: text }); output('feedback', text); };
19
+
20
+ switch (action) {
21
+ case 'push': {
22
+ // The first time, before a pull request: the report the agent wrote, which heads the pull request and the approval card.
23
+ const now = state ?? { base: env.BASE || gh('repo', 'view', '--json', 'defaultBranchRef', '--jq', '.defaultBranchRef.name'),
24
+ lane: `simple/${env.GITHUB_RUN_ID}`, head: '', pr: '', reviewed: false, deviceHead: '' };
25
+ if (!now.pr) now.report = (json('REPORT', {}).note ?? '').trim();
26
+ const back = now.pr ? 'fix' : 'report', branch = env.BRANCH;
27
+ git('fetch', '--quiet', 'origin', now.base);
28
+ const head = tryGit('rev-parse', '--verify', '--quiet', `refs/heads/${branch}^{commit}`);
29
+ if (!head) { ask(now, `读不到分支 ${branch}:请把改动提交到这个分支再答复。`); output('route', back); break; }
30
+ if (git('rev-list', '--count', `FETCH_HEAD..${head}`) === '0') { ask(now, `分支 ${branch} 上没有比 ${now.base} 新的提交:请把改动提交到这个分支再答复。`); output('route', back); break; }
31
+ if (head === now.head) { ask(now, `分支 ${branch} 上没有新的提交(还是 ${head}):请修改并提交后再答复。`); output('route', 'fix'); break; }
32
+ // The run's own branch: force, the agent may have rebased its branch onto the latest target.
33
+ git('push', '--quiet', '--force', '--no-follow-tags', 'origin', `${head}:refs/heads/${now.lane}`);
34
+ // The pull request is titled as the first commit of the change says.
35
+ const title = now.title || git('log', '--reverse', '--format=%s', `FETCH_HEAD..${head}`).split('\n')[0];
36
+ save({ ...now, head, title, feedback: '' });
37
+ output('route', 'checks');
38
+ output('feedback', '');
39
+ output('head', head);
40
+ output('lane', now.lane);
41
+ break;
42
+ }
43
+ case 'failed': {
44
+ const lines = (env.LINES ?? '').trim();
45
+ ask(state, `${env.STEP}没通过,提交 ${state.head}。运行:coda://workflow-runs/${env.GITHUB_RUN_ID},用 workflow_status 查看「${env.STEP}」调用的流程、失败的步骤和日志,查明原因修好。${lines ? `\n${lines}` : ''}`);
46
+ break;
47
+ }
48
+ case 'problem':
49
+ output('text', state.feedback);
50
+ break;
51
+ case 'reviewed': {
52
+ const review = json('REVIEW', {});
53
+ save({ ...state, reviewed: true, review: { line: review.line ?? '', report: review.report ?? '' } });
54
+ break;
55
+ }
56
+ case 'kept':
57
+ save({ ...state, kept: (json('ANSWER', {}).note ?? '').trim() });
58
+ break;
59
+ case 'pr': {
60
+ const summary = [state.report, state.review ? `评审:${state.review.line}` : '', state.kept ? `没有照评审意见改的:\n${state.kept}` : ''].filter(Boolean).join('\n\n');
61
+ const path = join(env.RUNNER_TEMP, 'pr.md');
62
+ writeFileSync(path, [summary, state.review?.report ? `<details><summary>评审意见</summary>\n\n${state.review.report}\n\n</details>` : ''].filter(Boolean).join('\n\n'));
63
+ const pr = state.pr ? (gh('pr', 'edit', state.pr, '--body-file', path), state.pr)
64
+ : gh('pr', 'create', '--base', state.base, '--head', state.lane, '--title', state.title, '--body-file', path);
65
+ save({ ...state, pr });
66
+ output('url', pr);
67
+ output('head', state.head);
68
+ output('review', String(!state.reviewed));
69
+ output('device', String(env.DEVICES === 'true' && state.deviceHead !== state.head));
70
+ output('summary', summary);
71
+ break;
72
+ }
73
+ case 'accepted': {
74
+ // 「已修改」 while installing: what changed is pushed again; 「不行」 on the device: the note and the files go back to the agent.
75
+ if (env.ROUTE === 'changed') { output('route', 'push'); break; }
76
+ if (env.ROUTE === 'failed') {
77
+ const { note = '', attachments = [] } = json('DEVICE', {});
78
+ const files = attachments.length ? `附件:\n${attachments.map(path => `- ${path}`).join('\n')}` : '';
79
+ ask(state, `设备验收不通过(提交 ${state.head}):\n${[note.trim() && note, files].filter(Boolean).join('\n')}`);
80
+ output('route', 'fix');
81
+ break;
82
+ }
83
+ save({ ...state, deviceHead: state.head });
84
+ output('route', 'premerge');
85
+ break;
86
+ }
87
+ case 'merge': {
88
+ // The run's own branch goes with the merge; --repo keeps gh off the local branches of the step's checkout.
89
+ const url = new URL(state.pr), repo = `${url.host}/${url.pathname.split('/').slice(1, 3).join('/')}`;
90
+ const method = ['merge', 'rebase', 'squash'].includes(env.METHOD) ? env.METHOD : 'squash';
91
+ const done = spawnSync('gh', ['pr', 'merge', state.pr, '--repo', repo, `--${method}`, '--match-head-commit', state.head, '--delete-branch'], { encoding: 'utf8' });
92
+ process.stdout.write(done.stdout ?? ''); process.stderr.write(done.stderr ?? '');
93
+ const now = JSON.parse(gh('pr', 'view', state.pr, '--json', 'state,mergeable,mergeCommit'));
94
+ if (now.state === 'MERGED') { output('route', 'merged'); output('commit', now.mergeCommit.oid); break; }
95
+ if (now.state === 'OPEN' && now.mergeable === 'CONFLICTING') {
96
+ ask(state, `PR ${state.pr} 与目标分支 ${state.base} 有冲突,没有合并。把最新的 ${state.base} 合入分支 ${env.BRANCH},解决冲突、跑相关检查后提交;之后重跑项目检查、合并前检查,再请用户批准。`);
97
+ output('route', 'conflict');
98
+ break;
99
+ }
100
+ console.error(`没有合并 ${state.pr}:${(done.stderr || done.stdout || '').trim().split('\n').at(-1) || now.state}`);
101
+ process.exit(done.status || 1);
102
+ }
103
+ default: throw new Error(`未知的简易开发步骤:${action}`);
104
+ }