@gumpwang/agent-workflow 0.0.0-stage → 0.1.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,110 @@
1
+ # ─────────────────────────────────────────────────────────────────────────
2
+ # config.yaml — agent-workflow configuration
3
+ #
4
+ # `agent-workflow init` copies this file into the rule set,
5
+ # $AGENT_WORKFLOW_HOME (default ~/.agent-workflow), next to workflows/,
6
+ # prompts/ and handlers/. The engine reads only the rule set: edit these
7
+ # copies freely. Relative prompt_file, resume_prompt_file and run paths in a
8
+ # workflow resolve against this rule set root.
9
+ #
10
+ # This file says which projects exist, how to reach their tracker, which
11
+ # coding agents there are and which workflows each project enables. What a
12
+ # workflow does lives in $AGENT_WORKFLOW_HOME/workflows/<id>.yaml.
13
+ #
14
+ # Check the result with: agent-workflow validate
15
+ # ─────────────────────────────────────────────────────────────────────────
16
+
17
+ # Agents alive at the same time, across all projects. Remove for no limit.
18
+ max_concurrent: 3
19
+
20
+ # When a run needs a human (the agent is blocked, kept ending without a
21
+ # delivery, …) the ticket gets a comment; with attention_state it also moves
22
+ # to that state. It must be a state no workflow starts on; agents may move a
23
+ # ticket there too. Projects may override it.
24
+ # attention_state: In Review
25
+
26
+ # Agent profiles. A workflow role names one (roles.<role>.agent), a project can
27
+ # override it (projects.<name>.roles), and with a single profile every role
28
+ # uses it. The command runs under bash with the prompt on stdin and output
29
+ # appended to $LOG_FILE; it must keep $SESSION_ID on its command line, which is
30
+ # how the engine tells the agent from a recycled pid.
31
+ # With several profiles, roles that name no agent use this one.
32
+ # default_agent: claude
33
+ agents:
34
+ claude:
35
+ # claude: resume_command continues $SESSION_ID. none: every turn is a new session.
36
+ session: claude
37
+ command: |
38
+ claude -p --dangerously-skip-permissions --session-id "$SESSION_ID" --output-format stream-json --verbose
39
+ resume_command: |
40
+ claude -p --dangerously-skip-permissions --resume "$SESSION_ID" --output-format stream-json --verbose
41
+
42
+ # The per-ticket workspace, a git worktree on branch agent/<identifier>.
43
+ # path and branch are ${{ }} templates over ticket.* and project.*. provision
44
+ # runs before the first agent turn (and again when the directory is missing);
45
+ # cleanup runs when a ticket closes. Both get $ROOT, $WORKSPACE,
46
+ # $WORKSPACE_BRANCH and $ISSUE_* in the environment. A project may set its own.
47
+ # Without a workspace, agents work in the project root (not recommended).
48
+ workspace:
49
+ path: ~/.agent-workflow/workspaces/${{ project.name }}/${{ ticket.identifier }}
50
+ branch: agent/${{ ticket.identifier }}
51
+ provision: |
52
+ set -euo pipefail
53
+ mkdir -p "$(dirname "$WORKSPACE")"
54
+ git -C "$ROOT" fetch origin
55
+ if [ -e "$WORKSPACE/.git" ]; then
56
+ :
57
+ elif git -C "$ROOT" show-ref --verify --quiet "refs/heads/$WORKSPACE_BRANCH"; then
58
+ git -C "$ROOT" worktree add "$WORKSPACE" "$WORKSPACE_BRANCH"
59
+ else
60
+ git -C "$ROOT" worktree add "$WORKSPACE" -b "$WORKSPACE_BRANCH" origin/main
61
+ fi
62
+ cleanup: |
63
+ git -C "$ROOT" worktree remove "$WORKSPACE" --force 2>/dev/null || true
64
+ git -C "$ROOT" branch -D "$WORKSPACE_BRANCH" 2>/dev/null || true
65
+ git -C "$ROOT" worktree prune || true
66
+
67
+ # The key is the project name ([A-Za-z0-9_.-]): it shows up in workspace paths,
68
+ # reports and $PROJECT_NAME.
69
+ projects:
70
+ your-repo:
71
+ tracker:
72
+ kind: linear
73
+ # Linear project URL tail, e.g. https://linear.app/<team>/project/<this>.
74
+ slug: your-project-slug-000000000000
75
+ # $VAR reads the environment, then ~/.config/linear/api-key or ~/.linear-api-key.
76
+ api_key: $LINEAR_API_KEY
77
+ # Only tickets assigned to these users (id, email, name or display name;
78
+ # `me` is the key's owner). Remove to dispatch every ticket.
79
+ assignee: me
80
+ # States no workflow starts on that agents may still move a ticket to.
81
+ # With the trigger states of the enabled workflows they are the only
82
+ # states `agent-workflow ticket <ID> state` accepts.
83
+ other_states: ["In Review"]
84
+ # Workflow state name → this team's spelling, when they differ.
85
+ # state_alias: { Canceled: Cancelled }
86
+ # The canonical repo: $ROOT in hooks and steps.
87
+ root: ~/dev/00/your-repo
88
+ # Enabled workflows, in priority order: ids of files in workflows/.
89
+ workflows: [implement, merge, teardown]
90
+
91
+ # A project whose tickets are GitHub Issues. States are labels (Todo,
92
+ # In Progress, In Review, Merging); a closed issue is Closed; identifiers are
93
+ # <project name>-<issue number>, e.g. your-gh-repo-12.
94
+ # your-gh-repo:
95
+ # tracker:
96
+ # kind: github
97
+ # repo: your-org/your-gh-repo
98
+ # assignee: me
99
+ # # State labels no workflow starts on; changing state swaps them out too.
100
+ # # Open and Closed are always allowed.
101
+ # other_states: [Backlog, "In Review"]
102
+ # root: ~/dev/00/your-gh-repo
103
+ # workflows: [implement, merge, teardown]
104
+ # # GitHub has no Done / Canceled: tear down on a closed issue only.
105
+ # states: { teardown: [Closed] }
106
+ # # Per-workflow input values and role → agent overrides. For example, an
107
+ # # implementer / reviewer loop with the reviewer on another agent:
108
+ # # workflows: [review-loop, merge, teardown]
109
+ # # inputs: { review-loop: { max-rounds: 2 } }
110
+ # # roles: { reviewer: { agent: codex } }
@@ -0,0 +1,128 @@
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 config.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"
@@ -0,0 +1,5 @@
1
+ 评审发现了必须修改的问题(第 ${{ state.round }} 轮),评审结果在 `${{ deliveries.review.path }}`。
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`。
@@ -0,0 +1,179 @@
1
+ 你是一个自治运行的 coding agent session,正在处理 ${{ project.tracker }} 工单 **${{ ticket.identifier }}**。
2
+
3
+ ## 工单
4
+
5
+ - 编号:${{ ticket.identifier }}
6
+ - 标题:${{ ticket.title }}
7
+ - URL:${{ ticket.url }}
8
+
9
+ ### 描述
10
+
11
+ ${{ ticket.description }}
12
+
13
+ ---
14
+
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
+ <一句话说明都过了什么;截图链接;实际跑过的命令,每行一条>
173
+
174
+ ## Adjacent issues
175
+ <观察到但没修的问题,每条一句话,或 "none">
176
+ ```
177
+
178
+ - 做完:verdict 用 `done`。引擎收到后把工单转到 In Review。
179
+ - 阻塞(缺密钥/工具、规格冲突无法独立判断):先在 workpad 写清缺什么,再用 verdict `blocked` 交付,正文的 PR 段写 `Blocked at: <step>`。引擎会在工单下评论、标记为需要人处理。**不要**自己改状态,也不要不交付就结束:没有交付时引擎会续跑你的会话。
@@ -0,0 +1,3 @@
1
+ 实现者处理了上一轮的评审意见(第 ${{ state.round }} 轮),交付在 `${{ deliveries.handoff.path }}`。
2
+
3
+ 再评审一次:先核对上一轮每条问题是否已解决(或理由是否成立),再看本轮新增的改动。规则与上一轮相同:只读,只报告有依据、必须修改的问题。没有了用 verdict `clean`,还有用 `issues`。
@@ -0,0 +1 @@
1
+ 你之前处理 ${{ ticket.identifier }} 的会话被中断了。先 `git status` / `git log --oneline -5` 和 `agent-workflow ticket ${{ ticket.identifier }} get` 核对现状,读取 workpad 评论,然后从中断处继续原工作流,直到完成判据全部满足,然后按 prompt 末尾的 Completion 段交付。
@@ -0,0 +1 @@
1
+ 你之前评审 ${{ ticket.identifier }} 的会话被中断了。交付在 `${{ deliveries.handoff.path }}`,评审对象仍是分支 `${{ workspace.branch }}` 上 `git diff origin/main...HEAD` 的全部改动。从中断处继续评审,规则不变:只读,只报告有依据、必须修改的问题。没有了用 verdict `clean`,还有用 `issues`。
@@ -0,0 +1,26 @@
1
+ 你是一个自治运行的 code reviewer session,正在评审工单 **${{ ticket.identifier }}**(${{ ticket.title }})的实现。
2
+
3
+ ## 工单
4
+
5
+ ${{ ticket.description }}
6
+
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` 按严重程度列出。
@@ -0,0 +1,30 @@
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).
3
+ #
4
+ # done the ticket moves to In Review for a human
5
+ # blocked the run needs attention: the ticket gets a comment (and moves to
6
+ # the project's attention_state when it has one)
7
+ # A turn that ends without a delivery is continued with prompts/resume.md and
8
+ # a reminder, at most roles.implementer.max_attempts turns in all, then the
9
+ # run needs attention. Paths are relative to the rule set root.
10
+ name: implement
11
+ description: Hand the ticket to a coding agent until it is ready for review
12
+ on:
13
+ states: [Todo, "In Progress"]
14
+ roles:
15
+ implementer:
16
+ max_attempts: 3
17
+ steps:
18
+ - id: work
19
+ launch: implementer
20
+ prompt_file: prompts/implement.md
21
+ resume_prompt_file: prompts/resume.md
22
+ expect:
23
+ delivery: handoff
24
+ sections: ["## PR", "## Verification", "## Adjacent issues"]
25
+ verdicts: [done, blocked]
26
+ - if: steps.work.outcome == 'done'
27
+ tracker:
28
+ state: In Review
29
+ - if: steps.work.outcome == 'blocked'
30
+ attention: "the agent reported it is blocked; see the workpad and ${{ deliveries.handoff.path }}"
@@ -0,0 +1,27 @@
1
+ # merge — drive the PR of the ticket's workspace branch to merged.
2
+ #
3
+ # handlers/agent-merge.sh decides from the PR state GitHub reports:
4
+ # done PR merged, ticket moved to Done (Linear) / closed (GitHub)
5
+ # pending checks still run or auto-merge is queued: run again next reconcile
6
+ # returned PR conflicts: ticket commented and moved back to In Progress, so
7
+ # implement continues the agent's session with the note below
8
+ # failure (non-zero exit) the run fails and starts again next reconcile
9
+ name: merge
10
+ description: Merge the ticket's PR once checks pass
11
+ on:
12
+ states: [Merging]
13
+ tracked: true
14
+ steps:
15
+ - id: merge
16
+ run: handlers/agent-merge.sh
17
+ env:
18
+ # GitHub has no Done state: a merged ticket's issue is closed.
19
+ MERGE_DONE_STATE: "${{ project.tracker == 'github' && 'Closed' || 'Done' }}"
20
+ MERGE_REWORK_STATE: In Progress
21
+ - if: steps.merge.outcome == 'returned'
22
+ note: |
23
+ ## Merge note
24
+
25
+ ${{ steps.merge.outputs.detail }}
26
+ - if: steps.merge.outcome == 'done'
27
+ close: cleanup
@@ -0,0 +1,66 @@
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 } }
7
+ #
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.
12
+ name: review-loop
13
+ description: Implement, then iterate with a reviewer until the review is clean
14
+ on:
15
+ states: [Todo, "In Progress"]
16
+ inputs:
17
+ max-rounds: { type: number, default: 3, min: 1, max: 10 }
18
+ roles:
19
+ implementer:
20
+ max_attempts: 3
21
+ reviewer:
22
+ max_attempts: 2
23
+ state:
24
+ round: 0
25
+ 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
36
+ launch: reviewer
37
+ prompt_file: prompts/review.md
38
+ resume_prompt_file: prompts/review-resume.md
39
+ expect:
40
+ delivery: review
41
+ sections: ["## Findings"]
42
+ verdicts: [clean, issues]
43
+ - while: deliveries.handoff.verdict == 'done' && (deliveries.review.verdict ?? '') == 'issues' && state.round < inputs.max-rounds
44
+ max-iterations: 10
45
+ steps:
46
+ - set: { round: "${{ state.round + 1 }}" }
47
+ - message: implementer
48
+ prompt_file: prompts/fix.md
49
+ expect:
50
+ delivery: handoff
51
+ sections: ["## PR", "## Verification", "## Adjacent issues"]
52
+ 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'
63
+ attention: "the review still has issues after ${{ state.round }} round(s); see ${{ deliveries.review.path }}"
64
+ - tracker:
65
+ state: In Review
66
+ comment: "Review clean after ${{ state.round }} fix round(s); ready for human review."
@@ -0,0 +1,10 @@
1
+ # teardown — the ticket is finished or dropped: stop its agents, remove the
2
+ # workspace and forget the ticket. GitHub projects usually override the states
3
+ # with `states: { teardown: [Closed] }` in config.yaml.
4
+ name: teardown
5
+ description: Stop agents and clean up when a ticket is finished or dropped
6
+ on:
7
+ states: [Done, Canceled, Cancelled, Duplicate, Closed]
8
+ tracked: true
9
+ steps:
10
+ - close: cleanup