@gumpwang/agent-workflow 0.3.0 → 0.4.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.
- package/README.md +6 -13
- package/dist/agent-workflow.js +55 -294
- package/docs/contract.md +25 -26
- package/package.json +1 -1
- package/templates/handlers/workspace-provision.sh +24 -6
- package/templates/projects/your-repo/project.yaml +21 -23
- package/templates/prompts/fix.md +1 -1
- package/templates/prompts/implement.md +3 -3
- package/templates/prompts/merge-resume.md +1 -0
- package/templates/prompts/merge.md +10 -0
- package/templates/prompts/review-resume.md +1 -1
- package/templates/prompts/review.md +1 -1
- package/templates/workflows/implement.yaml +1 -1
- package/templates/workflows/merge.yaml +40 -22
- package/templates/workflows/review-loop.yaml +3 -3
- package/templates/handlers/agent-merge.sh +0 -128
- package/templates/prompts/triage-resume.md +0 -1
- package/templates/prompts/triage.md +0 -66
- package/templates/workflows/triage.yaml +0 -44
package/docs/contract.md
CHANGED
|
@@ -13,7 +13,7 @@ config.yaml max_concurrent, registered projects
|
|
|
13
13
|
agents.yaml agent profiles, default_agent
|
|
14
14
|
workflows/<id>.yaml one workflow per file; <id> is the file name
|
|
15
15
|
prompts/ prompt files (template: implement.md, resume.md, review.md, ...)
|
|
16
|
-
handlers/ scripts for run steps and workspace hooks (template:
|
|
16
|
+
handlers/ scripts for run steps and workspace hooks (template: workspace-*.sh)
|
|
17
17
|
state/ global: dispatch.lock, last-run.json, issues.json, logs/deliveries.log
|
|
18
18
|
projects/<name>/project.yaml one project: tracker, root, workspace, state, enabled workflows
|
|
19
19
|
projects/<name>/state/ default state dir: ledger.json, logs/, prompts/, runs/ (written by the engine)
|
|
@@ -23,12 +23,11 @@ projects/<name>/workspace/ default workspace dir: one git worktree per ticke
|
|
|
23
23
|
workflow、prompt 和 handler 由所有项目共用;ledger 和 workspace 按项目分开。全局只有一把锁:`max_concurrent` 统计所有项目的存活 agent。
|
|
24
24
|
|
|
25
25
|
- `agent-workflow init [--home DIR] [--force]` 把包内 `templates/` 复制进 rule set:只补缺失文件,`--force` 覆盖。之后引擎只读 rule set,模板升级不会改变已有 rule set 的行为。
|
|
26
|
-
- `agent-workflow setup-project <name> (--github <owner/repo> | --linear <project-slug>) --root <dir> [--assignee <user>] [--yes]` 登记一个项目:`projects/<name>/project.yaml` 不存在时按模板状态机写一份(启用 `triage, implement, review-loop, merge, teardown`,`tracker.assignee` 与 `inputs.triage.assignee` 都取 `--assignee`,默认 `me`),把项目名加进 `config.yaml` 的 `projects`,校验 rule set,再检查 tracker 缺什么:GitHub 缺的状态 label 和 triage 用的类型 label(`bug`、`documentation`、`duplicate`、`enhancement`、`help wanted`、`invalid`、`question`、`wontfix`,颜色和描述同 GitHub 默认),Linear 团队缺的工作流状态(按状态名定类型;`Triage` 要在团队设置里打开,只提示不创建)。`--yes` 或终端里确认后才创建;没有终端时只列出。已有的 project.yaml 不改,只重新检查 tracker。有需要人补的状态或创建失败时退出码 1。
|
|
27
26
|
- workflow 只从 `$AGENT_WORKFLOW_HOME/workflows/<id>.yaml` 读取,没有内置 workflow,也没有同 id 覆盖的第二层。
|
|
28
27
|
- `${{ rules.dir }}` 是 rule set 根目录。
|
|
29
28
|
- 相对路径按 rule set 根目录解析:
|
|
30
29
|
- `prompt_file`、`resume_prompt_file`:如 `prompts/implement.md`。
|
|
31
|
-
- `run` 以及 `workspace.provision` / `cleanup` 的第一个词:是含 `/` 的相对路径、且不以 `.`、`/`、`~`、`$` 或引号开头时(如 `handlers/
|
|
30
|
+
- `run` 以及 `workspace.provision` / `cleanup` 的第一个词:是含 `/` 的相对路径、且不以 `.`、`/`、`~`、`$` 或引号开头时(如 `handlers/my-step.sh`),引擎把它换成 rule set 里的绝对路径,文件不存在时 `validate` 报 `RUN_NOT_FOUND`。`./x`、`../x` 保持 shell 原义(相对工作目录)。命令的工作目录不变(`run` 为 workspace,workspace 脚本为 `$ROOT`)。
|
|
32
31
|
- `project.yaml` 里的相对 `workspace.path` 和 `state.path` 按项目目录 `projects/<name>/` 解析。
|
|
33
32
|
|
|
34
33
|
## 一轮 reconcile
|
|
@@ -57,7 +56,7 @@ workflow、prompt 和 handler 由所有项目共用;ledger 和 workspace 按
|
|
|
57
56
|
| 匹配 | 按上表处理 | 按上表处理 |
|
|
58
57
|
| 未指派 / 指派给别人 | 忽略 | `release`:停 agent、删除 context,**不**跑 cleanup,worktree 保留 |
|
|
59
58
|
|
|
60
|
-
`on.tracked` 的 workflow 不看指派人:本机的 context 和 worktree 总要由本机收尾。`on.any_assignee` 的 workflow
|
|
59
|
+
`on.tracked` 的 workflow 不看指派人:本机的 context 和 worktree 总要由本机收尾。`on.any_assignee` 的 workflow 也不看指派人,用于处理任何人的工单(例如用户自己写的 triage 一类 workflow)。
|
|
61
60
|
|
|
62
61
|
人工操作:`agent-workflow status`(JSON)、`resolve <ID> retry|accept|skip|cancel`(见下文 Attention)、`forget <ID>`(删除 context;agent 仍在运行时拒绝)。
|
|
63
62
|
|
|
@@ -148,7 +147,8 @@ tracker:
|
|
|
148
147
|
root: ~/dev/web
|
|
149
148
|
attention_state: Blocked
|
|
150
149
|
workspace:
|
|
151
|
-
branch:
|
|
150
|
+
branch: ${{ ticket.branch ?? 'agent/' + ticket.identifier }}
|
|
151
|
+
base: ${{ ticket.base ?? 'main' }}
|
|
152
152
|
provision: handlers/workspace-provision.sh
|
|
153
153
|
cleanup: handlers/workspace-cleanup.sh
|
|
154
154
|
workflows: [implement, review, hotfix, merge, teardown, abandon]
|
|
@@ -201,16 +201,28 @@ role 的 agent 取值顺序:workflow 里的 `roles.<role>.agent` → `default_
|
|
|
201
201
|
|---|---|---|
|
|
202
202
|
| `tracker` | 是 | 见下表 |
|
|
203
203
|
| `root` | 是 | canonical repo,即 `$ROOT` |
|
|
204
|
-
| `attention_state` | 否 | run 需要人处理时把工单转到的状态(如 `
|
|
204
|
+
| `attention_state` | 否 | run 需要人处理时把工单转到的状态(如 `Blocked`)。不能是该项目任何 workflow 的 trigger 状态(`CONFIG_INVALID`),自动进入状态目录。不配则只评论 |
|
|
205
205
|
| `workspace` | 否 | 每个工单一个 workspace。不写时 agent 在 `root` 里工作 |
|
|
206
206
|
| `workspace.path` | 否 | `${{ }}` 模板,默认 `projects/<name>/workspace/${{ ticket.identifier }}`;相对路径按项目目录解析 |
|
|
207
|
-
| `workspace.branch` | 否 | `${{ }}` 模板。不写时 `$WORKSPACE_BRANCH` 为空。`path
|
|
207
|
+
| `workspace.branch` | 否 | `${{ }}` 模板。不写时 `$WORKSPACE_BRANCH` 为空。`path`、`branch`、`base` 只认 `project.*` 与 `ticket.{id,identifier,number,state,blocked_by,branch,base}`(它们会进 shell 和 git) |
|
|
208
|
+
| `workspace.base` | 否 | `${{ }}` 模板:新分支的起点,也是 PR 的目标分支。不写时 `$WORKSPACE_BASE` 为空 |
|
|
208
209
|
| `workspace.provision` / `cleanup` | 否 | shell 脚本,可以用 rule set 里的公共脚本(如 `handlers/workspace-provision.sh`)。provision 在首个 agent turn 前执行(目录不在时再执行),新建的 workspace 在启动失败时回滚;cleanup 在 `close: cleanup` 时执行,失败只告警 |
|
|
209
210
|
| `state.path` | 否 | 项目 state 目录(ledger、交付、agent 日志与 prompt),默认 `projects/<name>/state`;相对路径按项目目录解析。两个项目不能共用 |
|
|
210
211
|
| `workflows` | 是 | 启用的 workflow id(`workflows/<id>.yaml`)。引擎没有默认列表,缺少时 `validate` 报错。顺序决定 GitHub 状态 label 的优先级 |
|
|
211
212
|
| `states.<workflow>` | 否 | 覆盖该 workflow 的 `on.states` |
|
|
212
213
|
| `inputs.<workflow>.<input>` | 否 | workflow 的 input 值 |
|
|
213
214
|
|
|
215
|
+
workspace 在引擎第一次接手工单时算出,之后改工单不会移动它。
|
|
216
|
+
|
|
217
|
+
工单可以在描述里声明分支,各占一整行,名字可以放在反引号里,每个键取第一行:
|
|
218
|
+
|
|
219
|
+
```text
|
|
220
|
+
Branch: docs/payment-retry
|
|
221
|
+
Base: docs/payment-retry
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
`Branch:` 是 `ticket.branch`,表示工单就在这个分支上开发;`Base:` 是 `ticket.base`,表示工单从这个分支切出自己的分支、PR 合回它。没有这一行,或者名字不是只含 `A-Za-z0-9._/-` 的合法 ref 名时,值为 `null`。
|
|
225
|
+
|
|
214
226
|
`tracker`:
|
|
215
227
|
|
|
216
228
|
| 键 | 适用 | 说明 |
|
|
@@ -317,7 +329,7 @@ steps:
|
|
|
317
329
|
state: In Review
|
|
318
330
|
comment: Hotfix ready for review.
|
|
319
331
|
- if: steps.fix.outcome == 'blocked'
|
|
320
|
-
attention: the fixer is blocked; see
|
|
332
|
+
attention: the fixer is blocked; see the latest '## Handoff' comment
|
|
321
333
|
```
|
|
322
334
|
|
|
323
335
|
```yaml
|
|
@@ -423,10 +435,10 @@ agent 在 attention 期间又交了一份完整的交付时,run 自动继续
|
|
|
423
435
|
- 字面量:数字、`'text'`(`''` 转义单引号)、`true`、`false`、`null`
|
|
424
436
|
- 运算符(优先级从低到高):`??`、`||`、`&&`、`== !=`、`< <= > >=`、`+ -`、一元 `! -`;名字可以含 `-`(`inputs.max-rounds`),所以二元减号两侧要有空格
|
|
425
437
|
- 函数:`exists(x)`、`length(x)`、`contains(a, b)`、`startsWith(a, b)`、`endsWith(a, b)`
|
|
426
|
-
- 名字:`inputs.*`、`state.*`、`ticket.{id,identifier,title,description,url,state,number,labels,assignee,blocked_by}`(`blocked_by`:未关闭的阻塞工单数,GitHub 取 issue dependencies,Linear 取 blocks
|
|
438
|
+
- 名字:`inputs.*`、`state.*`、`ticket.{id,identifier,title,description,url,state,number,labels,assignee,blocked_by,branch,base}`(`blocked_by`:未关闭的阻塞工单数,GitHub 取 issue dependencies,Linear 取 blocks 关系;`branch`、`base`:描述里的分支声明,见 `project.yaml`)、`project.{name,root,repo,slug,tracker}`、`workspace.{path,branch,base}`、`rules.dir`、`deliveries.<name>.{path,verdict}`(`<name>` 必须是某个 `expect.delivery`;还没有交付时用 `exists()` 或 `??`)、`steps.<id>.{outcome,outputs}`、`roles.<r>.{agent,session}`、`loop.iteration`(只在 `while` 内)
|
|
427
439
|
- 不存在的名字是错误;可选数据用 `exists()` 或 `??`
|
|
428
440
|
- `prompt_file` / `resume_prompt_file` 的路径里只能用 `project.*`(如 `prompts/implement.${{ project.tracker }}.md`),`validate` 按每个项目检查文件是否存在;文件内容里的 `${{ }}` 同样受检查
|
|
429
|
-
- `run` 和 `working-directory` 里不能插值不可信的文本(`UNSAFE_INTERPOLATION`):`ticket.*` 中 `id`、`identifier`、`number`、`state`、`blocked_by` 以外的字段,`steps.<id>.outputs`、`deliveries.*`,以及由这些值经 `set` 得到的 `state.*`。这类值要经 `env` 传给命令
|
|
441
|
+
- `run` 和 `working-directory` 里不能插值不可信的文本(`UNSAFE_INTERPOLATION`):`ticket.*` 中 `id`、`identifier`、`number`、`state`、`blocked_by`、`branch`、`base` 以外的字段,`steps.<id>.outputs`、`deliveries.*`,以及由这些值经 `set` 得到的 `state.*`。这类值要经 `env` 传给命令
|
|
430
442
|
|
|
431
443
|
`steps.<id>.outcome`:`run` step 取 `$STEP_OUT` 里的 `outcome`,没写时成功为 `success`、失败为 `failure`;agent step 为 `success`,带 `expect` 时为交付的结论(没有 `verdicts` 时为 `success`)、超时 `skip` 为 `timeout`,此时 `outputs` 为 `{verdict, path}`;`if` 跳过或 `resolve skip` 为 `skipped`。`steps.<id>.outputs` 是 `$STEP_OUT` 的整个 JSON 对象(`detail` 字段会写进 dispatch 输出)。
|
|
432
444
|
|
|
@@ -476,7 +488,7 @@ steps:
|
|
|
476
488
|
| `LINEAR_API_KEY` | 仅 Linear |
|
|
477
489
|
| `GH_REPO` / `ISSUE_NUMBER` | 仅 GitHub:`owner/name`(`gh` 也认它)、issue 号 |
|
|
478
490
|
| `ROOT` | `project.yaml` 的 `root` |
|
|
479
|
-
| `WORKSPACE` / `WORKSPACE_ROOT` / `WORKSPACE_BRANCH` | 工单的 workspace
|
|
491
|
+
| `WORKSPACE` / `WORKSPACE_ROOT` / `WORKSPACE_BRANCH` / `WORKSPACE_BASE` | 工单的 workspace、分支与基础分支 |
|
|
480
492
|
| `AGENT_WORKFLOW_HOME` / `AGENT_WORKFLOW_WORKFLOW` / `AGENT_WORKFLOW_RUN` | rule set 根目录(`${{ rules.dir }}` 同值)/ 当前 workflow 文件 / run id |
|
|
481
493
|
| `AGENT_WORKFLOW_DIR` | 引擎包根目录 |
|
|
482
494
|
| `PATH` | 前置了包内 `bin/`,因此 `agent-workflow`(含 `agent-workflow ticket`)可直接调用 |
|
|
@@ -491,24 +503,11 @@ agent 存活判定:pid 存在,且该进程组中保留本次 `SESSION_ID`。
|
|
|
491
503
|
|
|
492
504
|
| workflow | 触发 | 步骤 |
|
|
493
505
|
|---|---|---|
|
|
494
|
-
| `
|
|
495
|
-
| `
|
|
496
|
-
| `merge` | `Merging`(tracked) | `run: handlers/agent-merge.sh`;`returned` → `note`(冲突说明,交给下次 implement);`done` → `close: cleanup` |
|
|
506
|
+
| `implement` | `Todo`, `In Progress` | `wait` 到没有未关闭的阻塞工单(`ticket.blocked_by == 0`),`tracker` 再把工单转到 In Progress,再 `launch: implementer`(`prompts/implement.md`,续跑 `prompts/resume.md`,`max_attempts: 3`),agent 按 harness-stack 的 `implement` skill 工作,交付 `handoff`(`## PR`、`## Verification`、`## Adjacent issues`,结论 `done` / `blocked`)。`done` → `tracker` 转 In Review;`blocked` → attention。agent 不改状态,只用 `agent-workflow ticket` 写 workpad、关联 PR,交付前把 handoff 发成一条 `## Handoff` 评论 |
|
|
507
|
+
| `merge` | `Merging`(tracked) | `launch: merger`(`prompts/merge.md`,续跑 `prompts/merge-resume.md`,`max_attempts: 2`,`timeout-minutes: 90`),agent 按 harness-stack 的 `pr-land` skill 合并:等 checks,按 rebase → merge commit → squash 的顺序选仓库允许的方式,不改代码、不判断该不该合;交付前在工单上发一条 `## Merge` 评论,交付 `land`(`## PR`、`## Merge`,结论 `merged` / `returned` / `blocked`)。`merged` → `tracker` 转完成状态(Linear `Done`,GitHub `Closed`)+ `close: cleanup`;`returned` → `note` + `tracker` 转 In Progress,implement 续跑实现者的 session;`blocked` → attention |
|
|
497
508
|
| `teardown` | `Done`, `Canceled`, `Cancelled`, `Duplicate`, `Closed`(tracked) | `close: cleanup` |
|
|
498
509
|
| `review-loop` | `In Review` | reviewer 按 harness-stack 的 `code-review` skill 只读评审(`prompts/review.md`,续跑 `prompts/review-resume.md`),把评审评论到工单上,交付 `review`(`## Standards`、`## Spec`,结论 `clean` / `issues` / `incomplete`);`issues` 时 `launch: implementer` 续跑实现者的 session,按 `implement` skill 修复(`prompts/fix.md`),再 `message` 复审(`prompts/rereview.md`),最多 `inputs.max-rounds`(默认 3)轮修复;`clean` → 评论并转 Reviewed,仍有问题、评审 `incomplete` 或 implementer `blocked` → attention。要让评审用另一个 agent,在 `workflows/review-loop.yaml` 里写 `roles.reviewer.agent`;不启用时把 `In Review` 写进 `tracker.other_states` |
|
|
499
510
|
|
|
500
|
-
`handlers/agent-merge.sh` 以 `gh pr view` 读到的 PR 状态为准做决定,不只看 `gh pr merge` 的退出码。PR 分支取 `$WORKSPACE_BRANCH`(即 `workspace.branch`);完成状态与返工状态由 `merge.yaml` 通过 `env:` 传入 `$MERGE_DONE_STATE`、`$MERGE_REWORK_STATE`(模板:Linear `Done`、GitHub `Closed`;返工 `In Progress`)。handler 没有内置默认值,缺任一输入即非 0 退出并说明缺哪个。评论和转状态用 `agent-workflow ticket "$ISSUE_IDENTIFIER" …`:
|
|
501
|
-
|
|
502
|
-
| PR 状态 | 结果 |
|
|
503
|
-
|---|---|
|
|
504
|
-
| `MERGED` | 把工单转到 `$MERGE_DONE_STATE`(GitHub 的 `Closed` 即关闭 issue;失败只告警),`done` |
|
|
505
|
-
| `CLOSED` / draft / checks 失败 / `gh pr merge` 后仍未合并 | 非 0 退出(run `failed`,下一轮重试),原因写清 |
|
|
506
|
-
| `mergeable=CONFLICTING` | 在工单下评论冲突原因,转到 `$MERGE_REWORK_STATE`,`returned` |
|
|
507
|
-
| checks 未完成或可合并性未算出 | `pending`;`GH_MERGE_FLAGS` 含 `--auto` 时先排队一次 auto-merge |
|
|
508
|
-
| 其他(可合并) | `gh pr merge $GH_MERGE_FLAGS`(默认 `--squash --delete-branch`),再读一次状态:`MERGED` → `done`,已排队 → `pending`,否则失败 |
|
|
509
|
-
|
|
510
|
-
默认不带 `--auto`:引擎每轮都会重跑 pending 的 step,自己就起到了"checks 通过后再合并"的作用。显式加了 `--auto` 而仓库没开启时,handler 报失败并提示开启 auto-merge 或去掉 `--auto`。
|
|
511
|
-
|
|
512
511
|
## Ledger(项目 state 目录下的 `ledger.json`)
|
|
513
512
|
|
|
514
513
|
每个项目一份,只放该项目的工单;引擎读写时把所有项目的 ledger 合在一起看(工单编号跨项目唯一)。
|
package/package.json
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# workspace-provision.sh — create the ticket's git worktree on its branch.
|
|
3
|
-
# Runs as workspace.provision with $ROOT, $WORKSPACE
|
|
4
|
-
#
|
|
3
|
+
# Runs as workspace.provision with $ROOT, $WORKSPACE, $WORKSPACE_BRANCH and
|
|
4
|
+
# $WORKSPACE_BASE set. Uses the branch when it exists locally or on origin,
|
|
5
|
+
# else branches off origin/$WORKSPACE_BASE (origin/main without a base, or
|
|
6
|
+
# when the base is gone from origin).
|
|
5
7
|
set -euo pipefail
|
|
6
8
|
mkdir -p "$(dirname "$WORKSPACE")"
|
|
7
9
|
git -C "$ROOT" fetch origin
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
[ -e "$WORKSPACE/.git" ] && exit 0
|
|
11
|
+
|
|
12
|
+
# git refuses a second checkout of a branch; say where the first one is.
|
|
13
|
+
holder=$(git -C "$ROOT" worktree list --porcelain | awk -v ref="branch refs/heads/$WORKSPACE_BRANCH" '
|
|
14
|
+
/^worktree / { path = substr($0, 10) }
|
|
15
|
+
$0 == ref { print path; exit }')
|
|
16
|
+
if [ -n "$holder" ]; then
|
|
17
|
+
echo "$WORKSPACE_BRANCH is checked out at $holder; switch that checkout to another branch first" >&2
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
if git -C "$ROOT" show-ref --verify --quiet "refs/heads/$WORKSPACE_BRANCH"; then
|
|
11
22
|
git -C "$ROOT" worktree add "$WORKSPACE" "$WORKSPACE_BRANCH"
|
|
23
|
+
elif git -C "$ROOT" show-ref --verify --quiet "refs/remotes/origin/$WORKSPACE_BRANCH"; then
|
|
24
|
+
git -C "$ROOT" worktree add --track -b "$WORKSPACE_BRANCH" "$WORKSPACE" "origin/$WORKSPACE_BRANCH"
|
|
12
25
|
else
|
|
13
|
-
|
|
26
|
+
base=${WORKSPACE_BASE:-main}
|
|
27
|
+
if ! git -C "$ROOT" show-ref --verify --quiet "refs/remotes/origin/$base"; then
|
|
28
|
+
echo "base branch $base is not on origin; branching off origin/main" >&2
|
|
29
|
+
base=main
|
|
30
|
+
fi
|
|
31
|
+
git -C "$ROOT" worktree add "$WORKSPACE" -b "$WORKSPACE_BRANCH" "origin/$base"
|
|
14
32
|
fi
|
|
@@ -14,17 +14,14 @@ tracker:
|
|
|
14
14
|
# States no workflow starts on that agents may still move a ticket to.
|
|
15
15
|
# With the trigger states of the enabled workflows they are the only
|
|
16
16
|
# states `agent-workflow ticket <ID> state` accepts. Reviewed is where a
|
|
17
|
-
# clean review waits for a human to move the ticket to Merging; Backlog
|
|
18
|
-
#
|
|
19
|
-
|
|
17
|
+
# clean review waits for a human to move the ticket to Merging; Backlog holds
|
|
18
|
+
# published tickets that must not start yet. Tickets get their first state,
|
|
19
|
+
# assignee and labels when they are published (harness-stack's setup-tracker
|
|
20
|
+
# prepares the tracker; to-spec and to-tickets publish), so there is no triage.
|
|
21
|
+
other_states: [Backlog, Reviewed]
|
|
20
22
|
# Workflow state name → this team's spelling, when they differ.
|
|
21
23
|
# state_alias: { Canceled: Cancelled }
|
|
22
24
|
|
|
23
|
-
# New Linear issues are triaged in the team's Triage state (turn on Triage in
|
|
24
|
-
# the team settings). A GitHub project needs no override: an open issue without
|
|
25
|
-
# a state label is in Open.
|
|
26
|
-
states: { triage: [Triage] }
|
|
27
|
-
|
|
28
25
|
# A project whose tickets are GitHub Issues instead. States are labels (Todo,
|
|
29
26
|
# In Progress, In Review, Reviewed, Merging); an open issue without one is
|
|
30
27
|
# Open, a closed issue is Closed; identifiers are <project name>-<issue
|
|
@@ -37,7 +34,7 @@ states: { triage: [Triage] }
|
|
|
37
34
|
# assignee: [your-github-login]
|
|
38
35
|
# # State labels no workflow starts on; changing state swaps them out too.
|
|
39
36
|
# # Open and Closed are always allowed.
|
|
40
|
-
# other_states: [Backlog, Reviewed
|
|
37
|
+
# other_states: [Backlog, Reviewed]
|
|
41
38
|
# GitHub has no Done / Canceled: tear down on a closed issue only.
|
|
42
39
|
# states: { teardown: [Closed] }
|
|
43
40
|
|
|
@@ -47,18 +44,23 @@ root: ~/dev/00/your-repo
|
|
|
47
44
|
# When a run needs a human (the agent is blocked, kept ending without a
|
|
48
45
|
# delivery, …) the ticket gets a comment; with attention_state it also moves
|
|
49
46
|
# to that state. It must be a state no workflow starts on.
|
|
50
|
-
# attention_state:
|
|
47
|
+
# attention_state: Blocked
|
|
51
48
|
|
|
52
49
|
# The per-ticket workspace, a git worktree on branch agent/<identifier>.
|
|
53
|
-
# path (default projects/<name>/workspace/<identifier>) and
|
|
54
|
-
# ${{ }} templates over ticket.* and project.*.
|
|
55
|
-
#
|
|
56
|
-
#
|
|
50
|
+
# path (default projects/<name>/workspace/<identifier>), branch and base are
|
|
51
|
+
# ${{ }} templates over ticket.* and project.*. base is the branch a new
|
|
52
|
+
# workspace branch starts from and its PR targets. A ticket can name them in
|
|
53
|
+
# its description: a `Branch: <name>` line makes the ticket work on that
|
|
54
|
+
# branch, a `Base: <name>` line makes it branch off that one (ticket.branch,
|
|
55
|
+
# ticket.base; null without the line). provision runs before the first agent
|
|
56
|
+
# turn (and again when the directory is missing); cleanup runs when a ticket
|
|
57
|
+
# closes. Both get $ROOT, $WORKSPACE, $WORKSPACE_BRANCH, $WORKSPACE_BASE and
|
|
57
58
|
# $ISSUE_* in the environment; a relative script path like the ones below is a
|
|
58
59
|
# file of the rule set, shared by every project. Without a workspace, agents
|
|
59
60
|
# work in the project root (not recommended).
|
|
60
61
|
workspace:
|
|
61
|
-
branch:
|
|
62
|
+
branch: ${{ ticket.branch ?? 'agent/' + ticket.identifier }}
|
|
63
|
+
base: ${{ ticket.base ?? 'main' }}
|
|
62
64
|
provision: handlers/workspace-provision.sh
|
|
63
65
|
cleanup: handlers/workspace-cleanup.sh
|
|
64
66
|
|
|
@@ -67,17 +69,13 @@ workspace:
|
|
|
67
69
|
# path: ~/somewhere/else
|
|
68
70
|
|
|
69
71
|
# Enabled workflows, in priority order: ids of files in workflows/.
|
|
70
|
-
# triage Open / Triage → Todo, Backlog, Needs Info or closed
|
|
71
72
|
# implement Todo / In Progress → In Review ("implement" Skill)
|
|
72
73
|
# review-loop In Review → Reviewed ("code-review" Skill)
|
|
73
74
|
# a human Reviewed → Merging
|
|
74
75
|
# merge Merging → Done / Closed
|
|
75
76
|
# Without review-loop, In Review waits for a human: add "In Review" to
|
|
76
77
|
# tracker.other_states instead.
|
|
77
|
-
workflows: [
|
|
78
|
-
# Per-workflow input values
|
|
79
|
-
#
|
|
80
|
-
#
|
|
81
|
-
inputs:
|
|
82
|
-
triage: { assignee: me }
|
|
83
|
-
# review-loop: { max-rounds: 2 }
|
|
78
|
+
workflows: [implement, review-loop, merge, teardown]
|
|
79
|
+
# Per-workflow input values, e.g. at most 2 fix rounds in review-loop.
|
|
80
|
+
# inputs:
|
|
81
|
+
# review-loop: { max-rounds: 2 }
|
package/templates/prompts/fix.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
用 "implement" Skill 的修复评审意见模式处理:逐条核实,真问题按根因修复并重新验证,不认同的写明证据;commit、push。进度记录仍是工单上的 `## Workpad` 评论(用 `agent-workflow ticket ${{ ticket.identifier }} comment-update <id> -` 更新)。这一轮重新截的证据同样用 `agent-workflow ticket ${{ ticket.identifier }} upload <文件>...` 上传,写它输出的链接。不要改工单状态。
|
|
4
4
|
|
|
5
|
-
完成后按 prompt 末尾的 Completion 段交付 handoff:`## Verification` 里写清每条意见的处置和本轮验证。做完用 verdict `done`,无法继续用 `blocked`。
|
|
5
|
+
完成后按 prompt 末尾的 Completion 段交付 handoff:`## Verification` 里写清每条意见的处置和本轮验证。做完用 verdict `done`,无法继续用 `blocked`。交付前先用 `agent-workflow ticket ${{ ticket.identifier }} comment -` 把 handoff 正文新发一条评论,标题是 `## Handoff (round ${{ state.round }})`。
|
|
@@ -11,9 +11,9 @@ ${{ ticket.description }}
|
|
|
11
11
|
- **输入**:工单描述,以及 `agent-workflow ticket ${{ ticket.identifier }} comments` 里的澄清和决定。
|
|
12
12
|
- **进度记录**:写在工单上唯一一条以 `## Workpad` 开头的评论里。先在 `comments` 里找,有就复用它的 id,没有就用 `comment -` 按 Skill 的模板新建。之后每次更新都用 `agent-workflow ticket ${{ ticket.identifier }} comment-update <id> -`,最后一次加 `--final`(还有未勾选项时它会拒绝写入)。
|
|
13
13
|
- **证据**:截图、录屏等证据文件用 `agent-workflow ticket ${{ ticket.identifier }} upload <文件>...` 上传,它每个文件输出一行 Markdown(图片是 ``)。把这些行写进 workpad 的 Validation 段和 handoff 的 `## Verification`,不要写本机路径:评审和看工单的人打不开你机器上的文件。
|
|
14
|
-
- **授权**:没人实时回答问题,不要停下来征求许可。可以 commit、push 当前分支、开 PR
|
|
14
|
+
- **授权**:没人实时回答问题,不要停下来征求许可。可以 commit、push 当前分支、开 PR;不能推基础分支、force push、合并或部署。PR 正文第一行写 `Closes ${{ ticket.url }}`,开完 PR 运行 `agent-workflow ticket ${{ ticket.identifier }} attach <pr-url>`。
|
|
15
15
|
- **状态**:不要改工单状态。引擎已经把它转到 In Progress,交付后由引擎转到 In Review。
|
|
16
|
-
- **起点**:cwd 是工单的工作区。启用 per-issue worktree 时分支是 `${{ workspace.branch }}
|
|
17
|
-
- **交付**:按 prompt 末尾的 Completion 段交付 Skill 的 handoff(`## PR`、`## Verification`、`## Adjacent issues`),做完用 verdict `done`,阻塞用 `blocked
|
|
16
|
+
- **起点**:cwd 是工单的工作区。启用 per-issue worktree 时分支是 `${{ workspace.branch }}`,基础分支是 `${{ workspace.base || 'main' }}`:同步用它,PR 也开到它(`gh pr create --base ${{ workspace.base || 'main' }}`)。分支上已经有 open PR 时复用它,不要再开一个。
|
|
17
|
+
- **交付**:按 prompt 末尾的 Completion 段交付 Skill 的 handoff(`## PR`、`## Verification`、`## Adjacent issues`),做完用 verdict `done`,阻塞用 `blocked`。交付前先用 `agent-workflow ticket ${{ ticket.identifier }} comment -` 把 handoff 正文新发一条评论,标题是 `## Handoff`:交付文件在你的机器上,看工单的人只能从这条评论读到它。
|
|
18
18
|
|
|
19
19
|
"implement" Skill 不可用时,按 `blocked` 交付,写明缺少这个 Skill。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
你之前合并 ${{ ticket.identifier }} 的 PR 的会话被中断了。继续用 "pr-land" Skill 完成它,约定和之前一样:先用 `gh pr view ${{ workspace.branch }}` 核对 PR 的当前状态(可能已经合并),不改代码、不 push、不改工单状态,在工单上发一条 `## Merge` 评论,最后按 prompt 末尾的 Completion 段交付。
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
你是一个无人值守的 merger session,负责合并工单 **${{ ticket.identifier }}**(${{ ticket.title }},${{ ticket.url }})的 PR。
|
|
2
|
+
|
|
3
|
+
用 "pr-land" Skill 合并,等待检查、选择合并方式和结论都按 Skill 来。工单已经被转到 Merging,表示改动已获准合并:不要再评审它是否该合并。工单相关的事按下面的约定完成:
|
|
4
|
+
|
|
5
|
+
- **PR**:分支 `${{ workspace.branch }}` 上的 open PR(`gh pr view ${{ workspace.branch }}`),基础分支是 `${{ workspace.base || 'main' }}`。cwd 是工单的工作区。
|
|
6
|
+
- **授权**:可以合并这个 PR、删除它的 head 分支、用 `gh pr update-branch` 更新分支、重跑失败的 job。不能改代码、commit、push、force push、改基础分支或用 `--admin` 绕过保护规则,也不要改工单状态:合并后由引擎转状态。
|
|
7
|
+
- **反馈**:交付前用 `agent-workflow ticket ${{ ticket.identifier }} comment -` 在工单上新发一条评论,标题是 `## Merge`,正文是 Skill 的报告(PR、合并方式、合并后的 commit,或者退回和阻塞的原因)。
|
|
8
|
+
- **交付**:按 prompt 末尾的 Completion 段交付 Skill 的报告(`## PR`、`## Merge`),verdict 用 Skill 的结论:`merged`、`returned` 或 `blocked`。
|
|
9
|
+
|
|
10
|
+
"pr-land" Skill 不可用时,用 verdict `blocked` 交付,写明缺少这个 Skill。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
你之前评审 ${{ ticket.identifier }} 的会话被中断了。继续用 "code-review" Skill 完成评审,约定和之前一样:评审对象是分支 `${{ workspace.branch }}`
|
|
1
|
+
你之前评审 ${{ ticket.identifier }} 的会话被中断了。继续用 "code-review" Skill 完成评审,约定和之前一样:评审对象是分支 `${{ workspace.branch }}` 相对基础分支 `${{ workspace.base || 'main' }}` 的全部改动,只读,评审结果以 `## Code review (round 1)` 评论发到工单上(末行落款 `— reviewer: ${{ roles.reviewer.agent }}`),按 prompt 末尾的 Completion 段交付。
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
用 "code-review" Skill 评审,方法、两轴报告和结论都按 Skill 来。工单相关的事按下面的约定完成:
|
|
4
4
|
|
|
5
|
-
- **评审对象**:cwd 是工单的工作区,分支 `${{ workspace.branch }}
|
|
5
|
+
- **评审对象**:cwd 是工单的工作区,分支 `${{ workspace.branch }}`。固定点是它和基础分支的 merge-base(`git diff origin/${{ workspace.base || 'main' }}...HEAD`)。实现者的交付在 `${{ deliveries.handoff.path }}`,其中的验证是待核实的声明。
|
|
6
6
|
- **Spec**:这个工单。用 `agent-workflow ticket ${{ ticket.identifier }} get` 和 `agent-workflow ticket ${{ ticket.identifier }} comments` 读取描述和讨论,把需求作为文本交给 Skill。
|
|
7
7
|
- **反馈**:评审完成后,用 `agent-workflow ticket ${{ ticket.identifier }} comment -` 在工单上新发一条评论。标题是 `## Code review (round 1)`,正文写评审的 head SHA、结论和两轴报告,最后一行落款 `— reviewer: ${{ roles.reviewer.agent }}`。
|
|
8
8
|
- **只读**:除了这条评论,不改代码、不 commit、不 push、不改工单状态。
|
|
@@ -35,4 +35,4 @@ steps:
|
|
|
35
35
|
tracker:
|
|
36
36
|
state: In Review
|
|
37
37
|
- if: steps.work.outcome == 'blocked'
|
|
38
|
-
attention: "the agent reported it is blocked; see the workpad and
|
|
38
|
+
attention: "the agent reported it is blocked; see the workpad and the latest '## Handoff' comment"
|
|
@@ -1,32 +1,50 @@
|
|
|
1
|
-
# merge —
|
|
1
|
+
# merge — a merger agent lands the PR of the ticket's workspace branch with
|
|
2
|
+
# the "pr-land" Skill (prompts/merge.md). Whoever moved the ticket to Merging
|
|
3
|
+
# already approved the change; the merger does not judge it and does not
|
|
4
|
+
# change code. It delivers a land report:
|
|
2
5
|
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
6
|
+
# merged the PR is merged: the ticket moves to Done (Linear) / is closed
|
|
7
|
+
# (GitHub), and the workspace is cleaned up
|
|
8
|
+
# returned the change needs work (conflict, failing check, requested
|
|
9
|
+
# changes): the ticket moves back to In Progress with a note, so
|
|
10
|
+
# implement continues the implementer's session, then the ticket
|
|
11
|
+
# goes through In Review again
|
|
12
|
+
# blocked a person must act (permission, protection rule, missing approval,
|
|
13
|
+
# checks that do not finish): the run needs attention
|
|
14
|
+
# Paths are relative to the rule set root.
|
|
10
15
|
name: merge
|
|
11
|
-
description:
|
|
16
|
+
description: Land the ticket's PR once it is approved to merge
|
|
12
17
|
on:
|
|
13
18
|
states: [Merging]
|
|
14
19
|
tracked: true
|
|
20
|
+
roles:
|
|
21
|
+
merger:
|
|
22
|
+
max_attempts: 2
|
|
15
23
|
steps:
|
|
16
|
-
- id:
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
- id: land
|
|
25
|
+
launch: merger
|
|
26
|
+
prompt_file: prompts/merge.md
|
|
27
|
+
resume_prompt_file: prompts/merge-resume.md
|
|
28
|
+
timeout-minutes: 90
|
|
29
|
+
expect:
|
|
30
|
+
delivery: land
|
|
31
|
+
sections: ["## PR", "## Merge"]
|
|
32
|
+
verdicts: [merged, returned, blocked]
|
|
33
|
+
- if: steps.land.outcome == 'merged'
|
|
34
|
+
tracker:
|
|
19
35
|
# GitHub has no Done state: a merged ticket's issue is closed.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
state: "${{ project.tracker == 'github' && 'Closed' || 'Done' }}"
|
|
37
|
+
- if: steps.land.outcome == 'merged'
|
|
38
|
+
close: cleanup
|
|
39
|
+
- if: steps.land.outcome == 'returned'
|
|
23
40
|
note: |
|
|
24
41
|
## Merge note
|
|
25
42
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
合并被退回,原因见工单上最新的 `## Merge` 评论。继续用 "implement"
|
|
44
|
+
Skill 处理:需要时把 origin/${{ workspace.base || 'main' }} 合进分支、解决冲突或修复失败的检查,
|
|
45
|
+
重新验证、push,在 workpad 的 Notes 记一行这次处理,然后重新交付。
|
|
46
|
+
- if: steps.land.outcome == 'returned'
|
|
47
|
+
tracker:
|
|
48
|
+
state: In Progress
|
|
49
|
+
- if: steps.land.outcome == 'blocked'
|
|
50
|
+
attention: "the PR cannot land without a person; see the latest '## Merge' comment"
|
|
@@ -71,11 +71,11 @@ steps:
|
|
|
71
71
|
- if: state.review == 'issues'
|
|
72
72
|
set: { round: "${{ state.round + 1 }}" }
|
|
73
73
|
- if: state.review == 'issues' && (deliveries.handoff.verdict ?? '') == 'blocked'
|
|
74
|
-
attention: "the implementer reported it is blocked while fixing review findings; see the workpad and
|
|
74
|
+
attention: "the implementer reported it is blocked while fixing review findings; see the workpad and the latest '## Handoff' comment"
|
|
75
75
|
- if: state.review == 'exhausted'
|
|
76
|
-
attention: "the review still has issues after ${{ state.round }} round(s); see
|
|
76
|
+
attention: "the review still has issues after ${{ state.round }} round(s); see the latest '## Re-review' comment"
|
|
77
77
|
- if: state.review == 'incomplete'
|
|
78
|
-
attention: "the review is incomplete; see
|
|
78
|
+
attention: "the review is incomplete; see the latest '## Code review' or '## Re-review' comment"
|
|
79
79
|
- if: state.review != 'clean'
|
|
80
80
|
attention: "a clean review is required before Reviewed"
|
|
81
81
|
- tracker:
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# agent-merge.sh — the run step of the template merge workflow. Drives the PR
|
|
3
|
-
# of the ticket's workspace branch towards merged and tells the workflow what
|
|
4
|
-
# happened. Every decision is taken from the PR state that GitHub reports, never
|
|
5
|
-
# from the exit code of `gh pr merge` alone.
|
|
6
|
-
#
|
|
7
|
-
# Contract (set by the engine for every run step):
|
|
8
|
-
# $ISSUE_IDENTIFIER e.g. "HAN-66" (Linear) or "widget-12" (GitHub)
|
|
9
|
-
# $ISSUE_STATE tracker state name (e.g. "Merging")
|
|
10
|
-
# $PATH has `agent-workflow`; `agent-workflow ticket` changes
|
|
11
|
-
# the ticket state and writes comments on any tracker
|
|
12
|
-
# $ROOT canonical repo (where gh recognizes the remote)
|
|
13
|
-
# $WORKSPACE_BRANCH the PR head branch (config `workspace.branch`)
|
|
14
|
-
# $STEP_OUT write {"outcome": ..., "detail": ...} here
|
|
15
|
-
# $GH_MERGE_FLAGS optional; defaults to "--squash --delete-branch".
|
|
16
|
-
# Add --auto only if the repository allows auto-merge.
|
|
17
|
-
# Set by the merge workflow through `env:`. There are no defaults: state names
|
|
18
|
-
# belong to the rule set, not to this handler.
|
|
19
|
-
# $MERGE_DONE_STATE issue state after the PR merged
|
|
20
|
-
# $MERGE_REWORK_STATE issue state that hands a conflicting PR back to the agent
|
|
21
|
-
# stdin not used
|
|
22
|
-
#
|
|
23
|
-
# Outcomes:
|
|
24
|
-
# exit 0 + outcome=done PR is merged
|
|
25
|
-
# exit 0 + outcome=pending checks still run or auto-merge is queued; the step runs again next tick
|
|
26
|
-
# exit 0 + outcome=returned PR conflicts; issue moved to $MERGE_REWORK_STATE, the
|
|
27
|
-
# agent resumes next tick and resolves it through its normal flow
|
|
28
|
-
# exit != 0 merge failed; workspace kept, the workflow starts again next tick
|
|
29
|
-
#
|
|
30
|
-
# The engine stops the ticket's agents before this workflow starts.
|
|
31
|
-
|
|
32
|
-
set -euo pipefail
|
|
33
|
-
|
|
34
|
-
: "${ISSUE_IDENTIFIER:?ISSUE_IDENTIFIER required}"
|
|
35
|
-
: "${ROOT:?ROOT required}"
|
|
36
|
-
: "${WORKSPACE_BRANCH:?WORKSPACE_BRANCH required: set workspace.branch in project.yaml}"
|
|
37
|
-
: "${MERGE_DONE_STATE:?MERGE_DONE_STATE required: set it in the env of the merge workflow step}"
|
|
38
|
-
: "${MERGE_REWORK_STATE:?MERGE_REWORK_STATE required: set it in the env of the merge workflow step}"
|
|
39
|
-
|
|
40
|
-
branch="$WORKSPACE_BRANCH"
|
|
41
|
-
read -r -a merge_flags <<< "${GH_MERGE_FLAGS:---squash --delete-branch}"
|
|
42
|
-
tracker() { agent-workflow ticket "$ISSUE_IDENTIFIER" "$@"; }
|
|
43
|
-
done_state="$MERGE_DONE_STATE"
|
|
44
|
-
rework_state="$MERGE_REWORK_STATE"
|
|
45
|
-
canonical_root="${ROOT/#\~/$HOME}"
|
|
46
|
-
|
|
47
|
-
die() { echo "agent-merge: $ISSUE_IDENTIFIER: $*" >&2; exit 1; }
|
|
48
|
-
report() {
|
|
49
|
-
echo "agent-merge: $ISSUE_IDENTIFIER $1: $2"
|
|
50
|
-
if [[ -n "${STEP_OUT:-}" ]]; then
|
|
51
|
-
jq -nc --arg o "$1" --arg d "$2" '{outcome:$o, detail:$d}' > "$STEP_OUT"
|
|
52
|
-
fi
|
|
53
|
-
exit 0
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
[[ -d "$canonical_root" ]] || die "canonical root not found: $canonical_root"
|
|
57
|
-
cd "$canonical_root"
|
|
58
|
-
|
|
59
|
-
pr_fields="number,url,state,isDraft,mergeable,mergeStateStatus,baseRefName,statusCheckRollup,autoMergeRequest"
|
|
60
|
-
view_pr() { gh pr view "$branch" --json "$pr_fields"; }
|
|
61
|
-
|
|
62
|
-
# Mark the issue done after the merge. The merge itself already succeeded, so a
|
|
63
|
-
# tracker error only warns; the run is still finished.
|
|
64
|
-
finish_merged() {
|
|
65
|
-
local url="$1"
|
|
66
|
-
tracker state "$done_state" \
|
|
67
|
-
|| echo "agent-merge: warning: PR merged but could not move $ISSUE_IDENTIFIER to '$done_state'" >&2
|
|
68
|
-
report done "PR $url merged"
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
pr="$(view_pr 2>&1)" || die "cannot read PR for $branch: $pr"
|
|
72
|
-
url="$(jq -r .url <<< "$pr")"
|
|
73
|
-
|
|
74
|
-
case "$(jq -r .state <<< "$pr")" in
|
|
75
|
-
MERGED) finish_merged "$url" ;;
|
|
76
|
-
CLOSED) die "PR $url was closed without merge" ;;
|
|
77
|
-
OPEN) ;;
|
|
78
|
-
*) die "PR $url has unexpected state: $(jq -c .state <<< "$pr")" ;;
|
|
79
|
-
esac
|
|
80
|
-
|
|
81
|
-
[[ "$(jq -r .isDraft <<< "$pr")" != true ]] || die "PR $url is still a draft"
|
|
82
|
-
|
|
83
|
-
if [[ "$(jq -r .mergeable <<< "$pr")" == CONFLICTING ]]; then
|
|
84
|
-
base="$(jq -r .baseRefName <<< "$pr")"
|
|
85
|
-
note="PR $url has merge conflicts with $base. Update the branch with origin/$base, resolve the conflicts, run the validation again, push, and hand the issue off for review again."
|
|
86
|
-
tracker comment "agent-workflow: $note Moved back to '$rework_state'." >/dev/null \
|
|
87
|
-
|| die "PR $url conflicts, and the ticket comment failed"
|
|
88
|
-
tracker state "$rework_state" \
|
|
89
|
-
|| die "PR $url conflicts, and moving the issue to '$rework_state' failed"
|
|
90
|
-
report returned "$note"
|
|
91
|
-
fi
|
|
92
|
-
|
|
93
|
-
# CheckRun: status/conclusion. StatusContext: state.
|
|
94
|
-
failing="$(jq -r '[.statusCheckRollup[]?
|
|
95
|
-
| select((.conclusion // "" | IN("FAILURE", "TIMED_OUT", "CANCELLED", "ACTION_REQUIRED", "STARTUP_FAILURE"))
|
|
96
|
-
or (.state // "" | IN("FAILURE", "ERROR")))
|
|
97
|
-
| (.name // .context)] | join(", ")' <<< "$pr")"
|
|
98
|
-
[[ -z "$failing" ]] || die "PR $url has failing checks: $failing"
|
|
99
|
-
|
|
100
|
-
wants_auto=false
|
|
101
|
-
for f in "${merge_flags[@]}"; do [[ "$f" == --auto ]] && wants_auto=true; done
|
|
102
|
-
auto_queued() { [[ "$(jq -r '.autoMergeRequest != null' <<< "$1")" == true ]]; }
|
|
103
|
-
|
|
104
|
-
pending="$(jq -r '[.statusCheckRollup[]?
|
|
105
|
-
| select((.status // "COMPLETED") != "COMPLETED" or (.state // "" | IN("PENDING", "EXPECTED")))
|
|
106
|
-
| (.name // .context)] | join(", ")' <<< "$pr")"
|
|
107
|
-
if [[ -n "$pending" || "$(jq -r .mergeable <<< "$pr")" == UNKNOWN ]]; then
|
|
108
|
-
# Without --auto the engine itself polls; with --auto queue once, then wait.
|
|
109
|
-
if ! $wants_auto || auto_queued "$pr"; then
|
|
110
|
-
report pending "PR $url waits for checks: ${pending:-mergeability not computed yet}"
|
|
111
|
-
fi
|
|
112
|
-
fi
|
|
113
|
-
|
|
114
|
-
out="$(gh pr merge "$branch" "${merge_flags[@]}" 2>&1)" && rc=0 || rc=$?
|
|
115
|
-
[[ -z "$out" ]] || echo "$out"
|
|
116
|
-
|
|
117
|
-
# gh may exit non-zero after a successful merge (e.g. the local branch is
|
|
118
|
-
# checked out in a worktree), and zero after only queueing. Ask GitHub.
|
|
119
|
-
after="$(view_pr 2>&1)" || die "gh pr merge exited $rc; cannot read PR state afterwards: $after"
|
|
120
|
-
case "$(jq -r .state <<< "$after")" in
|
|
121
|
-
MERGED) finish_merged "$url" ;;
|
|
122
|
-
OPEN) auto_queued "$after" && report pending "PR $url queued for auto-merge" ;;
|
|
123
|
-
esac
|
|
124
|
-
hint=""
|
|
125
|
-
if grep -qi "auto.merge" <<< "$out" && $wants_auto; then
|
|
126
|
-
hint=" (auto-merge is not enabled for this repository: enable it, or remove --auto from GH_MERGE_FLAGS)"
|
|
127
|
-
fi
|
|
128
|
-
die "gh pr merge $branch failed (exit $rc)$hint: $out"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
再判断一次工单 ${{ ticket.identifier }}:它可能刚补充了信息,或者上一次 triage 被中断了。按工单现在的描述和全部评论,用和上次相同的方法重新判断:打标签、需要时指派、发一条新的 `## Triage` 评论(末行落款 `— triager: ${{ roles.triager.agent }}`),不改状态,按 prompt 末尾的 Completion 段交付。
|