@gumpwang/agent-workflow 0.1.1 → 0.3.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.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bash
2
+ # workspace-provision.sh — create the ticket's git worktree on its branch.
3
+ # Runs as workspace.provision with $ROOT, $WORKSPACE and $WORKSPACE_BRANCH set.
4
+ # Reuses the branch when it exists, else branches off origin/main.
5
+ set -euo pipefail
6
+ mkdir -p "$(dirname "$WORKSPACE")"
7
+ git -C "$ROOT" fetch origin
8
+ if [ -e "$WORKSPACE/.git" ]; then
9
+ :
10
+ elif git -C "$ROOT" show-ref --verify --quiet "refs/heads/$WORKSPACE_BRANCH"; then
11
+ git -C "$ROOT" worktree add "$WORKSPACE" "$WORKSPACE_BRANCH"
12
+ else
13
+ git -C "$ROOT" worktree add "$WORKSPACE" -b "$WORKSPACE_BRANCH" origin/main
14
+ fi
@@ -0,0 +1,83 @@
1
+ # project.yaml — one project: which tracker, which repo, which workflows.
2
+ # The directory name (projects/<name>/) is the project name; list it under
3
+ # `projects` in config.yaml.
4
+
5
+ tracker:
6
+ kind: linear
7
+ # Linear project URL tail, e.g. https://linear.app/<team>/project/<this>.
8
+ slug: your-project-slug-000000000000
9
+ # $VAR reads the environment, then ~/.config/linear/api-key or ~/.linear-api-key.
10
+ api_key: $LINEAR_API_KEY
11
+ # Only tickets assigned to these users (id, email, name or display name;
12
+ # `me` is the key's owner). Remove to dispatch every ticket.
13
+ assignee: me
14
+ # States no workflow starts on that agents may still move a ticket to.
15
+ # With the trigger states of the enabled workflows they are the only
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 and
18
+ # Needs Info are where triage parks tickets that are not ready.
19
+ other_states: [Backlog, Reviewed, Needs Info]
20
+ # Workflow state name → this team's spelling, when they differ.
21
+ # state_alias: { Canceled: Cancelled }
22
+
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
+ # A project whose tickets are GitHub Issues instead. States are labels (Todo,
29
+ # In Progress, In Review, Reviewed, Merging); an open issue without one is
30
+ # Open, a closed issue is Closed; identifiers are <project name>-<issue
31
+ # number>, e.g. your-repo-12.
32
+ # tracker:
33
+ # kind: github
34
+ # repo: your-org/your-repo
35
+ # # Only issues assigned to one of these GitHub logins. Remove to dispatch
36
+ # # every issue.
37
+ # assignee: [your-github-login]
38
+ # # State labels no workflow starts on; changing state swaps them out too.
39
+ # # Open and Closed are always allowed.
40
+ # other_states: [Backlog, Reviewed, Needs Info]
41
+ # GitHub has no Done / Canceled: tear down on a closed issue only.
42
+ # states: { teardown: [Closed] }
43
+
44
+ # The canonical repo: $ROOT in hooks and steps.
45
+ root: ~/dev/00/your-repo
46
+
47
+ # When a run needs a human (the agent is blocked, kept ending without a
48
+ # delivery, …) the ticket gets a comment; with attention_state it also moves
49
+ # to that state. It must be a state no workflow starts on.
50
+ # attention_state: Needs Human
51
+
52
+ # The per-ticket workspace, a git worktree on branch agent/<identifier>.
53
+ # path (default projects/<name>/workspace/<identifier>) and branch are
54
+ # ${{ }} templates over ticket.* and project.*. provision runs before the
55
+ # first agent turn (and again when the directory is missing); cleanup runs
56
+ # when a ticket closes. Both get $ROOT, $WORKSPACE, $WORKSPACE_BRANCH and
57
+ # $ISSUE_* in the environment; a relative script path like the ones below is a
58
+ # file of the rule set, shared by every project. Without a workspace, agents
59
+ # work in the project root (not recommended).
60
+ workspace:
61
+ branch: agent/${{ ticket.identifier }}
62
+ provision: handlers/workspace-provision.sh
63
+ cleanup: handlers/workspace-cleanup.sh
64
+
65
+ # Ledger, run deliveries and agent logs. Default: projects/<name>/state.
66
+ # state:
67
+ # path: ~/somewhere/else
68
+
69
+ # Enabled workflows, in priority order: ids of files in workflows/.
70
+ # triage Open / Triage → Todo, Backlog, Needs Info or closed
71
+ # implement Todo / In Progress → In Review ("implement" Skill)
72
+ # review-loop In Review → Reviewed ("code-review" Skill)
73
+ # a human Reviewed → Merging
74
+ # merge Merging → Done / Closed
75
+ # Without review-loop, In Review waits for a human: add "In Review" to
76
+ # tracker.other_states instead.
77
+ workflows: [triage, implement, review-loop, merge, teardown]
78
+ # Per-workflow input values: who triage assigns tickets to (it must match
79
+ # tracker.assignee, or implement will not pick them up), and e.g. at most 2
80
+ # fix rounds in review-loop.
81
+ inputs:
82
+ triage: { assignee: me }
83
+ # review-loop: { max-rounds: 2 }
@@ -1,5 +1,5 @@
1
- 评审发现了必须修改的问题(第 ${{ state.round }} 轮),评审结果在 `${{ deliveries.review.path }}`。
1
+ 工单 ${{ ticket.identifier }} 的评审发现了必须修改的问题,评审结果在 `${{ deliveries.review.path }}`,也是工单上最新一条 `## Code review` 或 `## Re-review` 评论。
2
2
 
3
- 1. 读评审结果,逐条处理:确认是真问题就修,不认同的在交付里写明理由。
4
- 2. 每处修改都重新跑相关验证,按原工作流 commit、push,并用 `agent-workflow ticket ${{ ticket.identifier }} comment-update <workpad-id> -` 更新 workpad。
5
- 3. 全部处理完后按 Completion 段交付:`## PR` 写 PR url,`## Verification` 写本轮的验证,`## Adjacent issues` 写本轮看到但没修的问题。做完用 verdict `done`,无法继续用 `blocked`。
3
+ 用 "implement" Skill 的修复评审意见模式处理:逐条核实,真问题按根因修复并重新验证,不认同的写明证据;commit、push。进度记录仍是工单上的 `## Workpad` 评论(用 `agent-workflow ticket ${{ ticket.identifier }} comment-update <id> -` 更新)。这一轮重新截的证据同样用 `agent-workflow ticket ${{ ticket.identifier }} upload <文件>...` 上传,写它输出的链接。不要改工单状态。
4
+
5
+ 完成后按 prompt 末尾的 Completion 段交付 handoff:`## Verification` 里写清每条意见的处置和本轮验证。做完用 verdict `done`,无法继续用 `blocked`。
@@ -1,179 +1,19 @@
1
- 你是一个自治运行的 coding agent session,正在处理 ${{ project.tracker }} 工单 **${{ ticket.identifier }}**。
1
+ 你是一个无人值守的 coding agent session,负责 ${{ project.tracker }} 工单 **${{ ticket.identifier }}**:${{ ticket.title }}(${{ ticket.url }})。
2
2
 
3
- ## 工单
4
-
5
- - 编号:${{ ticket.identifier }}
6
- - 标题:${{ ticket.title }}
7
- - URL:${{ ticket.url }}
8
-
9
- ### 描述
3
+ ### 工单描述
10
4
 
11
5
  ${{ ticket.description }}
12
6
 
13
7
  ---
14
8
 
15
- ## 运行模式
16
-
17
- - 当前以 headless 模式(`-p` + `--dangerously-skip-permissions`)运行,没有人实时盯着,也没法回答你的问题;不要停下来征求许可,直接行动,进度写进 workpad。
18
- - 这是端到端的会话:要么把工单做完,要么遇到**真正的阻塞**(缺密钥/工具、规格冲突无法独立判断)才停。
19
- - 会话可能被中断后由引擎续跑(同一 session)。续跑时以 git 与 workpad 的真实状态为准,不要重复已完成的步骤。
20
- - 你的 cwd 已经在项目工作区。若启用了 per-issue worktree,分支已经是 `${{ workspace.branch }}`;否则保持当前分支,先 `git status` 确认。
21
- - **只用 `agent-workflow ticket` 读写工单**,它在 Linear 和 GitHub 上用法相同。可转的状态只有 `agent-workflow ticket ${{ ticket.identifier }} get` 输出的 `states`。GitHub 上状态是 issue 的 label,`Closed` 即关闭 issue,换状态时旧的状态 label 会一并摘掉;不要用 `gh issue edit` 手工加减状态 label。
22
- - 你**可以也应该**回写工单:开工时转状态、workpad 评论、PR 关联都由你来做。交付之后的状态转移(In Review)由引擎按你的交付结论完成。
23
- 引擎在状态进入 Merging 或终态(Done / Canceled / Closed 等)后停掉仍在运行的 agent 并清理工作区。
24
-
25
- ## 可用工具
26
-
27
- - `agent-workflow ticket` CLI(引擎已把 `agent-workflow` 放进 PATH)。先跑 `agent-workflow help` 看用法。常用:
28
- - `agent-workflow ticket ${{ ticket.identifier }} get` —— 读工单、当前状态和可用状态列表(`states`)。
29
- - `agent-workflow ticket ${{ ticket.identifier }} state "In Progress"` —— 转状态(大小写不敏感;已在该状态时是 no-op)。
30
- - `agent-workflow ticket ${{ ticket.identifier }} comments` —— 列出评论(`id` / `url` / `author` / `body`)。
31
- - `agent-workflow ticket ${{ ticket.identifier }} comment [body|-]` —— 建评论(不给 body 或给 `-` 时读 stdin),输出 `{id, url}` JSON。
32
- - `agent-workflow ticket ${{ ticket.identifier }} comment-update <comment-id> [body|-] [--final]` —— 改已有评论(workpad 用),输出勾选计数 `checked=N unchecked=M`。`--final` 在还有未勾选项时拒绝写入并以退出码 5 结束。
33
- - `agent-workflow ticket ${{ ticket.identifier }} attach <pr-url>` —— 把 PR 挂到 Linear 工单(已关联时直接成功)。GitHub 上是 no-op,PR 靠正文里的 `Closes` 关联。
34
- - `gh` CLI —— 创建/查询 PR 和其他 GitHub 操作。
35
- - `git` —— 版本控制。
36
- - `/screenshot` skill(`scripts/screenshot.sh`)—— 无人值守截图:`window --app <App> --activate` 截单个窗口、`long --app <App>` 滚动截长图、`region x,y,w,h` 截区域、`optimize <img>` 压到适合上传的大小。先跑 `doctor` 确认宿主 App 已有屏幕录制权限。
37
- - `/screen-record` skill(`scripts/record.sh`)—— 无人值守录屏:`wrap -- <命令>` 包住一条命令录前后画面、`run --app <App> --duration S` 定时录、`compress <video> --max 1280 --fps 15` 压缩、`convert --to gif` 转 gif、`frames <video>` 抽关键帧拼图。
38
- - `/s3` skill —— 上传文件到 AWS S3(`put <local> <key>`)并生成限时只读链接(`url <key> --expires <秒>`)。截图等证据都走它,规则见第 4 步。
39
-
40
- ## 工作流
41
-
42
- ### 0. 启动(必做,在开任何编辑前)
43
-
44
- 1. **转状态**:`agent-workflow ticket ${{ ticket.identifier }} state "In Progress"`。已经在 In Progress 时是 no-op,不要因为这一步退出。
45
- 2. **建/复用 workpad 评论**:
46
- - `agent-workflow ticket ${{ ticket.identifier }} get` 看工单,`agent-workflow ticket ${{ ticket.identifier }} comments` 查现有评论。
47
- - 在返回里找 body 以 `## Workpad` 开头的评论。找到就**复用**它的 id;没有就 `agent-workflow ticket ${{ ticket.identifier }} comment -` 用 stdin 喂下面的 workpad 初稿。
48
- - 把 comment id 记在你的 task tool 里,后续每次 milestone 都更新它。**全程只有一条 workpad 评论**,所有进度都更到这条。
49
-
50
- Workpad 初稿模板(首次 `comment` 时用这个,之后 `comment-update` 改):
51
-
52
- ```md
53
- ## Workpad
54
-
55
- ### Plan
56
- - [ ] 1. <计划项>
57
- - [ ] 1.1 <子项>
58
-
59
- ### Acceptance Criteria
60
- - [ ] <验收项>
61
-
62
- ### Validation
63
- - [ ] <跑哪个测试命令>
64
- - [ ] <涉及 UI 时:截图 + 链接;不涉及则删掉本行>
65
-
66
- ### Notes
67
- - <时间戳 + 简短进度>
68
- ```
69
-
70
- ### 1. 理解
71
-
72
- - 先跑 `git status` 与 `git log --oneline -10`,搞清楚起点。
73
- - 重读工单标题和描述,用一句话复述目标。目标不清楚就**停下来报告**,不要猜。
74
- - Bug 类:先**复现**,在改任何代码前抓住失败的命令和输出。
75
- - Feature 类:定位变更要嵌入的现有表面(哪个文件、哪个函数、哪个组件)。
76
-
77
- ### 2. 计划
78
-
79
- - 拟一份 3–8 项的有序任务清单,用你自己的任务工具(TaskCreate)落地——这是**会话内**的工作清单。
80
- - 每一项要是一个**自包含的小切片**(约 ≤100 LOC + 对应验证)。太大就拆。
81
- - 标注**验收标准**:每一片怎么证明 work?具体到命令、测试名、可观察行为。不接受"看上去对"。
82
- - **同时把这份计划 + Acceptance Criteria + Validation 写进 workpad 评论**(`agent-workflow ticket ${{ ticket.identifier }} comment-update`)。Workpad 是给评审/异步观察者看的真相;TaskCreate 列表是给你自己用的工作内存。两者要一致。
83
-
84
- ### 3. 实现(一次一片)
85
-
86
- 每片按以下顺序:
87
-
88
- 1. 做最小必要的代码改动。
89
- 2. 跑这一片的验证(unit test / `tsc --noEmit` / `pnpm build` / 手测命令——按仓库情况选)。
90
- 3. 绿了就 `git add` 涉及的路径,写一条聚焦的 conventional-commit(`feat: ...` / `fix: ...` / `refactor: ...`)。
91
- 4. 把这一项勾掉,进入下一片。
92
-
93
- 每完成一片,立刻 `agent-workflow ticket ${{ ticket.identifier }} comment-update <workpad-id> -` 把那一项在 workpad 里勾掉,Notes 加一行短进度(含时间戳和短 sha)。**不要让 workpad 落后于实际进度**。
94
-
95
- 写 workpad 的规矩(防止把旧稿推上去):
96
- - 正文直接用 heredoc 喂给命令:`agent-workflow ticket ${{ ticket.identifier }} comment-update <workpad-id> - <<'EOF' … EOF`。不要先写到 `/tmp` 之类的共享文件再读:前一步失败时文件不会被重写,推上去的就是旧稿。
97
- - workpad 更新单独一条命令,不要接在别的命令的 `&&` 后面,也不要和状态转移写在同一条命令里。
98
- - 看输出里的 `checked=N unchecked=M` 是否符合预期;不符合就修正后重推。
99
-
100
- 回复人类评论时 @ 评论的作者(`comments` 输出的 `author`),不要 @ 你自己的账号。
101
-
102
- 在工单上写的评论和回复使用工单描述所用的语言(描述是英文就用英文,是中文就用中文)。
103
-
104
- 实现期间的约束:
105
-
106
- - 不要碰本片范围外的文件,不顺手重构。
107
- - 不要加工单没要求的功能("顺便也方便"不是范围内)。
108
- - 路上发现了无关但真实的问题,记一行进最终报告的"adjacent issues",**这次不修**。如果是值得专门跟踪的,在同一个 tracker 里开一个 Backlog 状态的新工单(GitHub 用 `gh issue create --label Backlog`),正文链回 ${{ ticket.url }}。
109
-
110
- ### 4. 整体验证
111
-
112
- - 跑一次仓库的完整测试套件(或最接近的等价物)。
113
- - 改动涉及用户可见/运行时路径,至少端到端用一次,记下使用的命令和输出。
114
- - 任何红的先修掉再继续。**不要推不绿的代码**。
115
- - **改动涉及 UI(页面、组件、样式、桌面/移动端界面等用户可见的视觉变化)时,必须附截图作为验证证据**:
116
- 1. **采集,优先用 `/screenshot` 和 `/screen-record`**(两者都是非交互脚本,不会弹框选)。先跑一次 `screenshot.sh doctor`,exit 2 说明宿主 App 没有屏幕录制权限,按"验证未完成"处理,不要反复重试。
117
- - 静态界面:在真实运行的应用里用 `screenshot.sh window --app <App> --activate --out <file>.png` 截单个窗口(不要截整屏,避免带进无关窗口和终端里的密钥);可滚动的长页面用 `long --app <App>`;浏览器页面可用 `long --url <url>`。覆盖每个受影响的页面/状态,有前后对比价值时也截改动前。
118
- - 交互流程(多步操作、动画、过渡):用 `record.sh wrap --app <App> --post-roll 2 --out <file>.mp4 -- <触发操作的命令>` 或 `run --app <App> --duration <S>` 录下来;要让 reviewer 一眼看完就再跑 `frames <file>.mp4` 把 `contact.png` 一起附上。
119
- - 两个 skill 都不可用(未安装、无图形会话)时退回系统 `screencapture`,仍然只截目标窗口。
120
- 2. **先压缩**:截图用 `screenshot.sh optimize <img>`(长边 ≤ 1568、jpg 80);录屏用 `record.sh compress <video> --max 1280 --fps 15`,短片段也可 `convert --to gif --max 640`。看清 UI 即可,不要传原始 Retina 大图或 60fps 原始录屏。
121
- 3. **上传到 `/s3`**:上传到 `screenshot/` 文件夹,key 形如 `screenshot/${{ ticket.identifier }}/<简短描述>.<ext>`;再用 `url` 子命令生成只读链接,有效期取上限 7 天(`--expires 604800`),保证 review 期间可访问。
122
- 4. 把链接写进 workpad 评论的 Validation 段(每张一行:`- [x] <页面/状态>: <链接>`),图片可直接用 Markdown 图片语法 `![<描述>](<链接>)` 让工单页内联显示。
123
- - 拿不到截图(无法启动应用、缺屏幕录制权限、上传失败等)属于验证未完成:在 workpad 写清原因,不要假装已验证。
124
-
125
- ### 5. 收尾交付
126
-
127
- 1. `git push -u origin HEAD` 推送分支。
128
- 2. 用 `gh pr create` 开 PR(用 `--body-file -` 配合 heredoc 写正文):
129
- - 标题:祈使句,≤ 70 字符,说清做了什么。
130
- - 正文:第一行写 `Closes ${{ ticket.url }}`(把 PR 关联到工单),然后一段简述、你验证过的验收标准、你实际跑过的验证命令;涉及 UI 时附上截图链接。**不要写 "next steps for user"**。
131
- - 开完 PR 跑 `agent-workflow ticket ${{ ticket.identifier }} attach <pr-url>` 把 PR 挂到工单(GitHub 上是 no-op,照样跑即可)。
132
- 下面每一步都是单独一条命令,上一步失败先处理,不要用 `&&` 串成一条。
133
- 3. **最后一次** `agent-workflow ticket ${{ ticket.identifier }} comment-update <workpad-id> - --final <<'EOF' … EOF` 把 workpad 同步到最终状态:所有 Plan / Acceptance / Validation 项都已勾掉,Notes 末尾追加 "handoff: PR=<url>"。命令失败说明还有未勾选项:要么补完,要么按阻塞情形处理,不要去掉 `--final` 硬推。
134
- 4. 第 3 步成功后,按下文"交付内容"交付(verdict `done`),然后结束会话。引擎把状态换成 In Review;In Review 不触发任何 workflow,引擎不会续跑你,worktree 保留供人类 review。
135
- - 之后的链路(不需要你做):
136
- - 人类 approve 后把状态转到 **Merging** → 引擎等 checks 通过后跑 `gh pr merge --squash --delete-branch`,确认已合并后把工单转到 Done(GitHub 上关闭 issue)并清 per-issue worktree。
137
- - PR 有冲突时引擎会在工单下评论、把状态换回 **In Progress** 并续跑你的会话(prompt 末尾带 `## Merge note`):把 origin/main 合进分支、解决冲突、重新验证、push,然后照第 3、4 步重新交付。
138
- - 或人类直接把工单转到终态(Done / Canceled,GitHub 上关闭 issue)→ 引擎只清 worktree(不 merge)。
139
- - 人类要返工就把状态换回 **Todo / In Progress** → 引擎会续跑同一会话(受 max_attempts 限制)。
140
-
141
- ## 完成判据
142
-
143
- 下面 6 条**全部满足**,才算完成:
144
-
145
- - [ ] 计划覆盖工单全部范围,每一项都已勾掉。
146
- - [ ] 最新 commit 上所有验证命令都通过。
147
- - [ ] 涉及 UI 时,截图/录屏已用 `/screenshot` / `/screen-record` 采集并压缩,已上传 `/s3`,链接已写进 workpad(不涉及 UI 则跳过本条)。
148
- - [ ] 分支已 push,PR 已开,正文含 `Closes ${{ ticket.url }}`;Linear 工单已用 `attach` 挂上 PR。
149
- - [ ] Workpad 评论的 Plan / Acceptance / Validation 全部勾完(`comment-update --final` 成功),Notes 反映了真实最终状态。
150
- - [ ] 已按 Completion 段交付(verdict `done`),交付命令没有报问题。
151
-
152
- 无法满足时按下文"交付内容"用 verdict `blocked` 交付,正文写清停在第几步、缺什么信息 / 决策 / 工具、分支当前的状态(已 commit?已 push?做了一半?)。
153
-
154
- ## 红线
155
-
156
- - 不要直接推 `main` / `master`,始终在当前分支工作。
157
- - 不要 `git rebase -i`、不要 force push,永远新建 commit。
158
- - 不要执行破坏性命令(`rm -rf`、`git reset --hard`、删数据库表等),除非工单正文明确授权。
159
- - pre-commit hook 失败时,**修根因**,新建一个 commit。不准 `--no-verify`。
160
- - diff 里看到密钥/凭证,立即停止并报告。
161
- - 不要把工单转到终态(Done / Canceled / Closed),由人类或引擎在合并后完成。
162
-
163
- ## 交付内容
164
-
165
- 结束时按 prompt 末尾 **Completion** 段的命令交付,交付正文是下面这几段 Markdown(每段都要有,没有内容写 "n/a"):
166
-
167
- ```md
168
- ## PR
169
- <PR url;阻塞时写 "Blocked at: <step>">
170
-
171
- ## Verification
172
- <一句话说明都过了什么;截图链接;实际跑过的命令,每行一条>
9
+ 用 "implement" Skill 完成这个工单。Skill 负责怎么做;工单相关的事按下面的约定,由你通过 `agent-workflow ticket ${{ ticket.identifier }} …`(`get`、`comments`、`comment`、`comment-update`、`attach`、`upload`)完成,它在 Linear 和 GitHub 上用法相同。
173
10
 
174
- ## Adjacent issues
175
- <观察到但没修的问题,每条一句话,或 "none">
176
- ```
11
+ - **输入**:工单描述,以及 `agent-workflow ticket ${{ ticket.identifier }} comments` 里的澄清和决定。
12
+ - **进度记录**:写在工单上唯一一条以 `## Workpad` 开头的评论里。先在 `comments` 里找,有就复用它的 id,没有就用 `comment -` 按 Skill 的模板新建。之后每次更新都用 `agent-workflow ticket ${{ ticket.identifier }} comment-update <id> -`,最后一次加 `--final`(还有未勾选项时它会拒绝写入)。
13
+ - **证据**:截图、录屏等证据文件用 `agent-workflow ticket ${{ ticket.identifier }} upload <文件>...` 上传,它每个文件输出一行 Markdown(图片是 `![…](…)`)。把这些行写进 workpad 的 Validation 段和 handoff 的 `## Verification`,不要写本机路径:评审和看工单的人打不开你机器上的文件。
14
+ - **授权**:没人实时回答问题,不要停下来征求许可。可以 commit、push 当前分支、开 PR;不能推 main、force push、合并或部署。PR 正文第一行写 `Closes ${{ ticket.url }}`,开完 PR 运行 `agent-workflow ticket ${{ ticket.identifier }} attach <pr-url>`。
15
+ - **状态**:不要改工单状态。引擎已经把它转到 In Progress,交付后由引擎转到 In Review。
16
+ - **起点**:cwd 是工单的工作区。启用 per-issue worktree 时分支是 `${{ workspace.branch }}`。
17
+ - **交付**:按 prompt 末尾的 Completion 段交付 Skill 的 handoff(`## PR`、`## Verification`、`## Adjacent issues`),做完用 verdict `done`,阻塞用 `blocked`。
177
18
 
178
- - 做完:verdict 用 `done`。引擎收到后把工单转到 In Review。
179
- - 阻塞(缺密钥/工具、规格冲突无法独立判断):先在 workpad 写清缺什么,再用 verdict `blocked` 交付,正文的 PR 段写 `Blocked at: <step>`。引擎会在工单下评论、标记为需要人处理。**不要**自己改状态,也不要不交付就结束:没有交付时引擎会续跑你的会话。
19
+ "implement" Skill 不可用时,按 `blocked` 交付,写明缺少这个 Skill。
@@ -1,3 +1,3 @@
1
- 实现者处理了上一轮的评审意见(第 ${{ state.round }} 轮),交付在 `${{ deliveries.handoff.path }}`。
1
+ 实现者处理了上一轮评审意见(第 ${{ state.round }} 轮修复),交付在 `${{ deliveries.handoff.path }}`。
2
2
 
3
- 再评审一次:先核对上一轮每条问题是否已解决(或理由是否成立),再看本轮新增的改动。规则与上一轮相同:只读,只报告有依据、必须修改的问题。没有了用 verdict `clean`,还有用 `issues`。
3
+ 用 "code-review" Skill 复审:把上一轮的 findings 和实现者对每条的处置作为复审输入,先核实每条是否已解决或理由是否成立,再看本轮新增的改动。约定与上一轮相同:只读,结果在工单上新发一条评论,标题是 `## Re-review (round ${{ state.round + 1 }}, after fix)`,正文先逐条写上一轮意见的结论(已解决 / 未解决 / 理由成立),再写本轮的两轴报告,最后一行落款 `— reviewer: ${{ roles.reviewer.agent }}`。按 prompt 末尾的 Completion 段交付,verdict 用 `clean`、`issues` 或 `incomplete`。
@@ -1 +1 @@
1
- 你之前处理 ${{ ticket.identifier }} 的会话被中断了。先 `git status` / `git log --oneline -5` 和 `agent-workflow ticket ${{ ticket.identifier }} get` 核对现状,读取 workpad 评论,然后从中断处继续原工作流,直到完成判据全部满足,然后按 prompt 末尾的 Completion 段交付。
1
+ 你之前处理 ${{ ticket.identifier }} 的会话被中断了。继续用 "implement" Skill 完成它,约定和之前一样:先用 `git status`、`git log --oneline -5` 和 `agent-workflow ticket ${{ ticket.identifier }} comments` 里的 `## Workpad` 核对实际进度,从中断处继续,不重复已完成的步骤,不改工单状态,最后按 prompt 末尾的 Completion 段交付。
@@ -1 +1 @@
1
- 你之前评审 ${{ ticket.identifier }} 的会话被中断了。交付在 `${{ deliveries.handoff.path }}`,评审对象仍是分支 `${{ workspace.branch }}` 上 `git diff origin/main...HEAD` 的全部改动。从中断处继续评审,规则不变:只读,只报告有依据、必须修改的问题。没有了用 verdict `clean`,还有用 `issues`。
1
+ 你之前评审 ${{ ticket.identifier }} 的会话被中断了。继续用 "code-review" Skill 完成评审,约定和之前一样:评审对象是分支 `${{ workspace.branch }}` 相对默认分支的全部改动,只读,评审结果以 `## Code review (round 1)` 评论发到工单上(末行落款 `— reviewer: ${{ roles.reviewer.agent }}`),按 prompt 末尾的 Completion 段交付。
@@ -1,26 +1,11 @@
1
- 你是一个自治运行的 code reviewer session,正在评审工单 **${{ ticket.identifier }}**(${{ ticket.title }})的实现。
1
+ 你是一个无人值守的 code reviewer session,评审工单 **${{ ticket.identifier }}**(${{ ticket.title }},${{ ticket.url }})的实现。
2
2
 
3
- ## 工单
3
+ 用 "code-review" Skill 评审,方法、两轴报告和结论都按 Skill 来。工单相关的事按下面的约定完成:
4
4
 
5
- ${{ ticket.description }}
5
+ - **评审对象**:cwd 是工单的工作区,分支 `${{ workspace.branch }}`。固定点是它和默认分支的 merge-base(通常是 `git diff origin/main...HEAD`)。实现者的交付在 `${{ deliveries.handoff.path }}`,其中的验证是待核实的声明。
6
+ - **Spec**:这个工单。用 `agent-workflow ticket ${{ ticket.identifier }} get` 和 `agent-workflow ticket ${{ ticket.identifier }} comments` 读取描述和讨论,把需求作为文本交给 Skill。
7
+ - **反馈**:评审完成后,用 `agent-workflow ticket ${{ ticket.identifier }} comment -` 在工单上新发一条评论。标题是 `## Code review (round 1)`,正文写评审的 head SHA、结论和两轴报告,最后一行落款 `— reviewer: ${{ roles.reviewer.agent }}`。
8
+ - **只读**:除了这条评论,不改代码、不 commit、不 push、不改工单状态。
9
+ - **交付**:按 prompt 末尾的 Completion 段交付评审报告(`## Standards`、`## Spec`),verdict 用 Skill 的结论:`clean`、`issues` 或 `incomplete`。
6
10
 
7
- ## 评审对象
8
-
9
- - 你的 cwd 是该工单的工作区,分支 `${{ workspace.branch }}`。实现者已经交付,交付内容在 `${{ deliveries.handoff.path }}`。
10
- - 评审 `git diff origin/main...HEAD` 的全部改动,对照工单描述和交付里的验证说明。
11
- - 需要工单详情或 workpad 时用 `agent-workflow ticket ${{ ticket.identifier }} get` 和 `agent-workflow ticket ${{ ticket.identifier }} comments`。
12
- - **只读**:不要改代码、不要 commit、不要 push、不要改工单状态或评论。你的产出只有交付。
13
-
14
- ## 评审什么
15
-
16
- 1. 正确性:是否满足工单要求;边界、失败路径、并发和回归风险。
17
- 2. 验证:交付里声称跑过的验证是否可信、是否覆盖了改动;必要时自己跑一遍测试。
18
- 3. 可维护性:与周边代码风格一致,没有无关改动和多余抽象。
19
- 4. 安全:输入校验、密钥、注入风险。
20
-
21
- 只报告有依据、值得改的问题,每条写清文件与行号、问题、建议的改法。风格偏好不算问题。
22
-
23
- ## 结论
24
-
25
- - 没有必须修改的问题:verdict `clean`,`## Findings` 写 "none" 或可选建议。
26
- - 有必须修改的问题:verdict `issues`,`## Findings` 按严重程度列出。
11
+ "code-review" Skill 不可用时,用 verdict `incomplete` 交付,写明缺少这个 Skill。
@@ -0,0 +1 @@
1
+ 再判断一次工单 ${{ ticket.identifier }}:它可能刚补充了信息,或者上一次 triage 被中断了。按工单现在的描述和全部评论,用和上次相同的方法重新判断:打标签、需要时指派、发一条新的 `## Triage` 评论(末行落款 `— triager: ${{ roles.triager.agent }}`),不改状态,按 prompt 末尾的 Completion 段交付。
@@ -0,0 +1,66 @@
1
+ 你是一个无人值守的 triage session,负责 ${{ project.tracker }} 上的新工单 **${{ ticket.identifier }}**:${{ ticket.title }}(${{ ticket.url }})。
2
+
3
+ ### 工单描述
4
+
5
+ ${{ ticket.description }}
6
+
7
+ ---
8
+
9
+ 判断这张工单能不能进入开发:它是否成立、是否重复、实现者能否不提问就开工,以及它是哪类工作。只读工单、代码和其他工单;不改代码,不改工单状态,状态由引擎按你的结论转。工单相关的读写都通过 `agent-workflow ticket ${{ ticket.identifier }} …` 完成。
10
+
11
+ ## 1. 读工单
12
+
13
+ 用 `get` 读工单(含 label 和阻塞关系 `blocked_by`),用 `comments` 读全部评论。后面的评论可能回答了描述里没说清的问题,或者改了需求,以最新达成一致的版本为准。读不到工单时,用 verdict `needs-info` 交付并说明原因,不要只凭标题判断。
14
+
15
+ 评论、问题和理由都用工单的语言写。
16
+
17
+ ## 2. 对照仓库核实
18
+
19
+ cwd 是工单的工作区,以默认分支为准:
20
+
21
+ - **缺陷**:找到它描述的代码路径,确认问题现在还在。它可能已经修好,或者说的代码已经不存在。能低成本复现就复现(现有测试、一条命令),否则写明读了什么。
22
+ - **改动或新功能**:找到它该落在哪,确认它还不存在,也不违背已生效的决策(ADR、文档里的不做清单、明确的非目标)。
23
+ - **依赖的文档**:工单引用的术语、ADR、设计说明必须已经在默认分支上。如果链接的是未合并的 PR 或本地路径,就说明还没进默认分支。
24
+
25
+ 每条发现都写明出处:文件和符号、命令和输出,或者文档。
26
+
27
+ ## 3. 查重
28
+
29
+ 用标题和现象里的关键词,搜索同一项目的 open 和 closed 工单(GitHub 上用 `gh issue list --state all --search "<关键词>"`,Linear 上用你能用的 Linear 工具)。只有要的是同一个结果才算重复,同一块代码不算。记下那张工单,以及它是未完成、已完成还是已拒绝。
30
+
31
+ ## 4. 下结论
32
+
33
+ 从上往下,取第一条符合的:
34
+
35
+ | verdict | 什么时候 |
36
+ | --- | --- |
37
+ | `close` | 重复:已有工单要的是同一个结果。无效:不是对这个仓库的请求(垃圾、别的产品的支持问题),或者描述的缺陷在默认分支上不存在,或者要的东西已经全部交付。不做:要的东西被已生效的决策排除,必须引用那条决策,引用不出来就不是不做 |
38
+ | `needs-info` | 实现者开工前必须先提问:期望行为、复现步骤、范围或验收标准缺失或互相矛盾,代码和文档也定不下来 |
39
+ | `backlog` | 成立也清楚,但还不能开工:它是带子工单的 spec,要先做子工单;它太大,一次改动做不完,要先拆分;或者它依赖的文档、决策还没进默认分支 |
40
+ | `ready` | 成立、不重复,实现者不用提问就能开工 |
41
+
42
+ 被其他未关闭的工单阻塞不影响 `ready`:阻塞只决定什么时候开工,开工会等阻塞工单关闭。
43
+
44
+ 证据不足、两边都说得通时,选 `needs-info`,不要关闭:提一个问题只需要作者回一句话,错关一张工单会把需求丢掉。
45
+
46
+ ## 5. 打标签和指派
47
+
48
+ 用 `label add` 打标签:
49
+
50
+ - **类型**,结论是无效时不打。`bug`:现有行为不对;`enhancement`:新行为,或者改变按设计工作的行为;`documentation`:只改文档;`question`:问东西怎么工作,而不是要求改动。
51
+ - **`help wanted`**:工单成立,但需要实现者没有的判断或权限,比如产品决策、凭证、硬件或第三方。
52
+ - **`close` 时**按原因打 `duplicate`、`invalid` 或 `wontfix`。
53
+
54
+ 结论不是 `close` 时,用 `assign ${{ inputs.assignee }}` 指派。
55
+
56
+ ## 6. 评论并交付
57
+
58
+ 用 `comment -` 在工单上发一条评论:
59
+
60
+ - 标题 `## Triage`,接着写结论、类型和理由,理由都带出处。
61
+ - `needs-info`:给作者的问题逐条编号,每条一句话能答。
62
+ - 重复:链接原工单。
63
+ - `backlog`:写明在等什么。
64
+ - 最后一行落款 `— triager: ${{ roles.triager.agent }}`。
65
+
66
+ 然后按 prompt 末尾的 Completion 段交付:`## Verdict` 写结论,`## Labels` 写打上的标签,`## Reasons` 写理由。
@@ -1,7 +1,10 @@
1
- # implement — a coding agent works the ticket end to end: plan, implement,
2
- # verify and open a PR, then delivers a handoff (prompts/implement.md).
1
+ # implement — once no open ticket blocks it, the engine moves the ticket to
2
+ # In Progress, then a coding agent
3
+ # works it end to end with the "implement" Skill: plan, implement,
4
+ # verify and open a PR, keeping the ticket's workpad, then delivers a handoff
5
+ # (prompts/implement.md). The agent never changes the ticket's state.
3
6
  #
4
- # done the ticket moves to In Review for a human
7
+ # done the ticket moves to In Review, where review-loop picks it up
5
8
  # blocked the run needs attention: the ticket gets a comment (and moves to
6
9
  # the project's attention_state when it has one)
7
10
  # A turn that ends without a delivery is continued with prompts/resume.md and
@@ -15,6 +18,11 @@ roles:
15
18
  implementer:
16
19
  max_attempts: 3
17
20
  steps:
21
+ # A ticket that open tickets block stays in Todo until they are closed.
22
+ - name: wait for blocking tickets
23
+ wait: { until: "ticket.blocked_by == 0" }
24
+ - tracker:
25
+ state: In Progress
18
26
  - id: work
19
27
  launch: implementer
20
28
  prompt_file: prompts/implement.md
@@ -4,7 +4,8 @@
4
4
  # done PR merged, ticket moved to Done (Linear) / closed (GitHub)
5
5
  # pending checks still run or auto-merge is queued: run again next reconcile
6
6
  # returned PR conflicts: ticket commented and moved back to In Progress, so
7
- # implement continues the agent's session with the note below
7
+ # implement continues the agent's session with the note below,
8
+ # then the ticket goes through In Review and review-loop again
8
9
  # failure (non-zero exit) the run fails and starts again next reconcile
9
10
  name: merge
10
11
  description: Merge the ticket's PR once checks pass
@@ -23,5 +24,9 @@ steps:
23
24
  ## Merge note
24
25
 
25
26
  ${{ steps.merge.outputs.detail }}
27
+
28
+ PR 和 main 有冲突,工单已转回 In Progress。继续用 "implement"
29
+ Skill 处理:把 origin/main 合进分支、解决冲突、重新验证、push,在 workpad 的
30
+ Notes 记一行这次合并,然后重新交付。
26
31
  - if: steps.merge.outcome == 'done'
27
32
  close: cleanup
@@ -1,66 +1,83 @@
1
- # review-loop — an implementer and a reviewer iterate until the review is
2
- # clean, then the ticket goes to human review. Not enabled by default: put it
3
- # in a project's `workflows` in place of implement, e.g.
4
- # workflows: [review-loop, merge, teardown]
5
- # and bind the reviewer to another agent if you like:
6
- # roles: { reviewer: { agent: codex } }
1
+ # review-loop — a reviewer reviews the delivered change with the
2
+ # "code-review" Skill; the implementer fixes the findings in its
3
+ # own session for a bounded number of rounds. A clean review moves the ticket
4
+ # to Reviewed, where a human decides whether it goes to Merging.
7
5
  #
8
- # implementer delivers a handoff (done | blocked), like implement
9
- # reviewer reviews the branch read-only, delivers review (clean | issues)
10
- # Up to inputs.max-rounds fix + review rounds; still issues after that, or a
11
- # blocked implementer, needs attention. Paths are relative to the rule set root.
6
+ # reviewer reviews the branch read-only, comments the review on the ticket
7
+ # and delivers review (clean | issues | incomplete)
8
+ # implementer the session that implemented the ticket; fixes the findings with
9
+ # the "implement" Skill and delivers a handoff (done | blocked)
10
+ # Up to inputs.max-rounds fix + re-review rounds. Still issues after that, an
11
+ # incomplete review or a blocked implementer needs attention. Bind the
12
+ # reviewer to another agent profile of agents.yaml if you like:
13
+ # reviewer: { agent: codex, max_attempts: 2 }
14
+ # Paths are relative to the rule set root.
12
15
  name: review-loop
13
- description: Implement, then iterate with a reviewer until the review is clean
16
+ description: Review the delivered change and iterate with the implementer until the review is clean
14
17
  on:
15
- states: [Todo, "In Progress"]
18
+ states: [In Review]
16
19
  inputs:
17
20
  max-rounds: { type: number, default: 3, min: 1, max: 10 }
18
21
  roles:
19
- implementer:
20
- max_attempts: 3
21
22
  reviewer:
22
23
  max_attempts: 2
24
+ implementer:
25
+ max_attempts: 3
23
26
  state:
24
27
  round: 0
28
+ review: none
25
29
  steps:
26
- - id: work
27
- launch: implementer
28
- prompt_file: prompts/implement.md
29
- resume_prompt_file: prompts/resume.md
30
- expect:
31
- delivery: handoff
32
- sections: ["## PR", "## Verification", "## Adjacent issues"]
33
- verdicts: [done, blocked]
34
- - if: deliveries.handoff.verdict == 'done'
35
- id: review
30
+ - id: review
36
31
  launch: reviewer
37
32
  prompt_file: prompts/review.md
38
33
  resume_prompt_file: prompts/review-resume.md
39
34
  expect:
40
35
  delivery: review
41
- sections: ["## Findings"]
42
- verdicts: [clean, issues]
43
- - while: deliveries.handoff.verdict == 'done' && (deliveries.review.verdict ?? '') == 'issues' && state.round < inputs.max-rounds
36
+ sections: ["## Standards", "## Spec"]
37
+ verdicts: [clean, issues, incomplete]
38
+ - set: { review: "${{ steps.review.outcome }}" }
39
+ - if: state.review == 'issues'
40
+ set: { round: 1 }
41
+ - if: state.review == 'issues'
42
+ id: fix
43
+ launch: implementer
44
+ prompt_file: prompts/fix.md
45
+ resume_prompt_file: prompts/fix.md
46
+ expect:
47
+ delivery: handoff
48
+ sections: ["## PR", "## Verification", "## Adjacent issues"]
49
+ verdicts: [done, blocked]
50
+ - while: state.review == 'issues' && (deliveries.handoff.verdict ?? '') == 'done'
44
51
  max-iterations: 10
45
52
  steps:
46
- - set: { round: "${{ state.round + 1 }}" }
47
- - message: implementer
53
+ - id: rereview
54
+ message: reviewer
55
+ prompt_file: prompts/rereview.md
56
+ expect:
57
+ delivery: review
58
+ sections: ["## Standards", "## Spec"]
59
+ verdicts: [clean, issues, incomplete]
60
+ - set: { review: "${{ steps.rereview.outcome }}" }
61
+ - if: state.review == 'issues' && state.round >= inputs.max-rounds
62
+ set: { review: exhausted }
63
+ - if: state.review == 'issues'
64
+ id: refix
65
+ message: implementer
48
66
  prompt_file: prompts/fix.md
49
67
  expect:
50
68
  delivery: handoff
51
69
  sections: ["## PR", "## Verification", "## Adjacent issues"]
52
70
  verdicts: [done, blocked]
53
- - if: deliveries.handoff.verdict == 'done'
54
- message: reviewer
55
- prompt_file: prompts/rereview.md
56
- expect:
57
- delivery: review
58
- sections: ["## Findings"]
59
- verdicts: [clean, issues]
60
- - if: deliveries.handoff.verdict == 'blocked'
61
- attention: "the implementer reported it is blocked; see the workpad and ${{ deliveries.handoff.path }}"
62
- - if: (deliveries.review.verdict ?? '') == 'issues'
71
+ - if: state.review == 'issues'
72
+ set: { round: "${{ state.round + 1 }}" }
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 ${{ deliveries.handoff.path }}"
75
+ - if: state.review == 'exhausted'
63
76
  attention: "the review still has issues after ${{ state.round }} round(s); see ${{ deliveries.review.path }}"
77
+ - if: state.review == 'incomplete'
78
+ attention: "the review is incomplete; see ${{ deliveries.review.path }}"
79
+ - if: state.review != 'clean'
80
+ attention: "a clean review is required before Reviewed"
64
81
  - tracker:
65
- state: In Review
66
- comment: "Review clean after ${{ state.round }} fix round(s); ready for human review."
82
+ state: Reviewed
83
+ comment: "Review clean after ${{ state.round }} fix round(s); ready for a human to approve the merge."
@@ -1,6 +1,6 @@
1
1
  # teardown — the ticket is finished or dropped: stop its agents, remove the
2
2
  # workspace and forget the ticket. GitHub projects usually override the states
3
- # with `states: { teardown: [Closed] }` in config.yaml.
3
+ # with `states: { teardown: [Closed] }` in its project.yaml.
4
4
  name: teardown
5
5
  description: Stop agents and clean up when a ticket is finished or dropped
6
6
  on: