@irythill/orq 0.1.0 → 0.2.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/package.json CHANGED
@@ -1,27 +1,48 @@
1
- {
2
- "name": "@irythill/orq",
3
- "version": "0.1.0",
4
- "description": "Orchestrate coding agents (Claude Code, Codex, OpenCode, Antigravity, Copilot) from one conductor.",
5
- "license": "MIT",
6
- "type": "module",
7
- "bin": { "orq": "dist/cli.js" },
8
- "files": ["dist", "!dist/**/*.test.js", "skills", "templates/workspace.CLAUDE.md"],
9
- "engines": { "node": ">=20" },
10
- "repository": { "type": "git", "url": "git+https://github.com/irythill/orq.git" },
11
- "homepage": "https://github.com/irythill/orq#readme",
12
- "keywords": ["agents", "orchestration", "claude-code", "codex", "opencode", "cli"],
13
- "publishConfig": { "access": "public" },
14
- "scripts": {
15
- "build": "tsc",
16
- "test": "tsc && node --test dist/orq.test.js",
17
- "prepack": "tsc"
18
- },
19
- "dependencies": {
20
- "@napi-rs/keyring": "^2.1.1",
21
- "smol-toml": "^1.9.1"
22
- },
23
- "devDependencies": {
24
- "@types/node": "^24.0.0",
25
- "typescript": "^7.0.2"
26
- }
27
- }
1
+ {
2
+ "name": "@irythill/orq",
3
+ "version": "0.2.0",
4
+ "description": "Orchestrate coding agents (Claude Code, Codex, OpenCode, Antigravity, Copilot) from one conductor.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "orq": "dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "!dist/**/*.test.js",
13
+ "skills",
14
+ "templates/workspace.CLAUDE.md"
15
+ ],
16
+ "engines": {
17
+ "node": ">=20"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/irythill/orq.git"
22
+ },
23
+ "homepage": "https://github.com/irythill/orq#readme",
24
+ "keywords": [
25
+ "agents",
26
+ "orchestration",
27
+ "claude-code",
28
+ "codex",
29
+ "opencode",
30
+ "cli"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "build": "tsc",
37
+ "test": "tsc && node --test dist/orq.test.js",
38
+ "prepack": "tsc"
39
+ },
40
+ "dependencies": {
41
+ "@napi-rs/keyring": "^2.1.1",
42
+ "smol-toml": "^1.9.1"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^24.0.0",
46
+ "typescript": "^7.0.2"
47
+ }
48
+ }
@@ -1,197 +1,229 @@
1
- ---
2
- name: issue
3
- description: Runs a Plane issue end to end by orchestrating coding agents in herdr or any terminal (herdr-agent / orq agent + orq wait) — implementer and cross-vendor reviewer picked by orq pick, tests by herdr-verify / orq verify, comment and status in Plane. Use when the user says "/issue <ID>", "take issue X", "run ABC-123", or asks to check/create issues in the conductor's ecosystem.
4
- ---
5
-
6
- # /issue <ID> — conductor playbook (herdr or any terminal)
7
-
8
- You are the **orchestrator**: you plan, dispatch, follow up and report. **Do not implement anything yourself** (it
9
- burns the conductor's model). Talk to the user in the user's language.
10
-
11
- **Ecosystem configuration:** the **workspace** `CLAUDE.md` (the folder named in your conductor instructions) defines
12
- the repositories and their groups (= herdr workspace, `-g`), **each repo's base branch**, verification commands,
13
- Plane projects (identifier → project_id), default assignee, labels/modules and MCP limitations. Read it before you
14
- start. Below, `$WS` = workspace.
15
- **Inside herdr** (`HERDR_ENV=1`): children open in herdr tabs and their notices reach your pane — the flow below.
16
- **Outside herdr** (any terminal, tmux, any OS): the same flow with these swaps —
17
- - `herdr-agent ...` → `orq agent ...` (same flags; it is the same program). Children run in tmux windows inside tmux,
18
- else in the background (their screen goes to a log; the answer is still `<prefix>.out.md`). No `-T`.
19
- - `herdr-claim` → `orq claim` (set `ORQ_CONDUCTOR_ID` to a fixed name per conductor), `herdr-deps` → `orq deps`.
20
- - **Completion signal:** no line arrives in your pane. After dispatching, run `orq wait <prefix>` **as a background
21
- task** (Claude Code: Bash with `run_in_background`); its exit wakes you and its output is the line
22
- `[ORQ AGENT DONE] <title> status=ok|fail ... answer: <file>` — treat it exactly like `[HERDR-AGENT DONE]`. Several
23
- children in parallel: `orq wait --any <prefix1> <prefix2>` (one wake-up per finish; wait again for the rest).
24
- No background tasks in your harness → run `orq wait` in the foreground; that is the one allowed blocking wait.
25
- - `herdr-verify` → `orq verify`, `herdr-baseline` → `orq baseline` (same flags). They run in a tmux window or in
26
- the background like children, and you wait for them the same way: `orq wait $O/verify-<repo>`.
27
- - Peeking at a child: `<prefix>.log` (not `herdr pane read`).
28
- Issue artifacts (prompts, notes) live in `$WS/.orquestra/<ID>/`.
29
-
30
- ## 1. Read the issue
31
- - **First, claim it:** `herdr-claim -w $WS <ID>`. Exit 1 = another conductor owns it: **stop** and tell the user
32
- (don't read it, don't dispatch anything). Taking it over (e.g. switching accounts) only with the user's OK:
33
- `herdr-claim -w $WS -f <ID>`. Several conductors may share a workspace; `herdr-claim -w $WS -l` lists who has what.
34
- - `mcp__plane__workitem` `retrieve_by_identifier` with `workitem_identifier: "<ID>"`; then `workitem_comment list`.
35
- - Extract: goal, **acceptance criteria**, affected repos, links. No acceptance criteria → write a short proposal and
36
- **ask the user** before dispatching.
37
- - Issue missing assignee, priority, labels or module → **fill them in** following the workspace `CLAUDE.md` "Issue
38
- standard". The same standard applies to any new issue you create.
39
- - Move it to **In Progress** (`workitem update` with the state_id from `state list`).
40
-
41
- ## 2. Classify
42
- One task per repo. Level:
43
- - **simple** — CRUD, UI/text tweak, localized bug, 1–3 files.
44
- - **medium** — business rule, API↔front integration, several files.
45
- - **heavy** — architecture, data migration, hard/concurrency bug, security.
46
-
47
- ## 3. Pick agent and model: always `orq pick`, never by hand
48
- `orq pick` decides agent, model, effort and account (user config + delivery and token history + current quota +
49
- rotation). **Do not choose by preference, by a rule you read elsewhere, or by what worked last time**: run it before
50
- EVERY dispatch (implementation, review, second opinion) and use its output verbatim.
51
- ```bash
52
- orq pick impl --level simple|medium|heavy # → e.g. -a codex -m gpt-6-sol -e low
53
- orq pick review --level <level> --impl-agent <agent that implemented> # → another vendor, e.g. -a opencode -m ...
54
- orq pick opinion # second opinion (e.g. Copilot), see step 5
55
- ```
56
- The output goes straight into `herdr-agent` (`herdr-agent $(orq pick ...) -g ... -t ... -d ... -o ... -- prompt.md`).
57
- - Exit 3 = no candidate (quota exhausted, no agent with that role): **stop and ask the user**.
58
- - Implementer failed review twice (step 6) → pick again without it: `orq pick impl --level <level> --exclude-agent <agent>`.
59
- - `--exclude-agent` never "sticks": every `orq pick` call decides again, with only that dispatch's exclusions.
60
- - The conductor's own model (e.g. Opus) as implementer: only with the user's OK, never through `orq pick`.
61
- - Want to understand a choice? `orq pick ... --explain --no-record` (score of each candidate; not counted in rotation).
62
-
63
- **Every child runs through `herdr-agent`** (agent from `orq pick`): headless (`claude -p` / `codex exec` /
64
- `opencode run` / `agy -p` / `copilot -p`) in a herdr tab (workspace = group `-g`, tab = title) with live output.
65
- When it finishes it writes `<prefix>.done` and sends ONE line `[HERDR-AGENT DONE] <title> status=ok|fail ...` to your
66
- pane; no MCP, and a **4 GB memory cap per agent** (own cgroup: if it blows up, only it dies). NEVER `herdr agent start`
67
- for children (no memory cap, no answer file). **Screen mode (`-T`, or `HERDR_AGENT_TUI=1`):** the tab shows the
68
- agent's own TUI instead of the log; same cap, same files, same signal (end-of-turn hook). The screen stays open after
69
- the turn (it holds memory until the tab closes); `-R` with the tab open types the follow-up into it. Use it when the
70
- user wants to watch. The repo must already be trusted in Codex/Claude (otherwise the TUI stops at the "trust this
71
- folder?" dialog — tell the user, don't approve it for them).
72
-
73
- ## 4. Dispatch the implementer
74
- Write the prompt to `$WS/.orquestra/<ID>/impl-<repo>.md` (short: goal, acceptance criteria, likely files, the repo's
75
- verification commands, "base: origin/<BASE>; don't rebase/merge other branches; local commits, no push; commit
76
- messages following <path of the repo's commit conventions, see step 7>").
77
- Always include:
78
- - **Repo checklist:** copy the repo's "Checklist" column from the workspace `CLAUDE.md`.
79
- - **No tests in the child** (memory rule): "don't run jest/vitest; I run the related tests afterwards".
80
- - **Fresh branch:** "before your final answer: `git fetch origin <BASE> && git rebase origin/<BASE>`; on conflict stop
81
- and report; after the rebase repeat lint/tsc". Codex has no network: for it, you fetch and check in step 5.
82
-
83
- **Base = the repo's base branch from the workspace `CLAUDE.md`, always from the updated remote (`origin/<BASE>`).**
84
- Worktree with `git worktree add` (not `herdr worktree create`: that opens a separate herdr workspace per worktree, and
85
- children are grouped by the repo's `-g`).
86
- ```bash
87
- R=$WS/<repo>; BASE=<repo base>; B=<prefix>plane-<lowercase-id>; WT=$WS/.worktrees/<repo>-plane-<lowercase-id>
88
- O=$WS/.orquestra/<ID>
89
- git -C $R fetch origin $BASE
90
- git -C $R worktree add -b $B $WT origin/$BASE # already exists? reuse $WT, don't recreate it
91
- git -C $WT log -1 --format='%h %s' # check HEAD == origin/$BASE before launching
92
- ```
93
- **Dependencies — NEVER install inside the worktree** (each `node_modules` is ~1 GB and tens of thousands of files;
94
- on a modest disk that saturates I/O and memory and freezes the machine). The worktree uses a **link** to the main
95
- repo's `node_modules`:
96
- ```bash
97
- herdr-deps -r $R -b $BASE -w $WT # link; stale deps → fast-forward + ONE install in $R (per-repo lock across conductors)
98
- ```
99
- Exit 3 = stale deps and `$R` dirty or not on `$BASE` → **ask the user**. If another conductor is installing in the
100
- same repo, the command waits its turn (never install by hand).
101
- In the child's prompt: "node_modules is shared (link): don't run install/add; if you need a new dependency, stop and
102
- tell me".
103
- **Dispatch** (no MCP; memory cap; writes in automatic mode — that is why implementation only happens in a worktree):
104
- ```bash
105
- herdr-agent $(orq pick impl --level <level>) -g <group> -t "<ID> impl <repo>" -d $WT -o $O/impl-<repo> -- $O/impl-<repo>.md
106
- ```
107
- - The Claude account (`-c`) already comes from `orq pick` (the least used one under the limit).
108
- - Full final answer in `$O/impl-<repo>.out.md`; log in `.log`; the agent's session id in `.id`.
109
- - Codex's sandbox has no network: `git fetch` is yours, beforehand (above). Push/PR: yours (step 7).
110
- - `herdr-agent` returns immediately (no need to background it); the child's pane is in `<prefix>.pane`
111
- (`herdr pane read $(cat <prefix>.pane) --source recent` to peek).
112
- - **No baseline in the issue flow:** don't run `herdr-baseline` before dispatching (the base moves with every merge and
113
- the full suite blocks every conductor's test queue). `herdr-verify` checks the base on demand (step 4b).
114
- - **Children start WITHOUT MCP** (Plane is yours; each MCP costs ~150–200 MB per session and `systemd-oomd` kills the
115
- whole herdr server when memory runs out) — `herdr-agent` takes care of it.
116
- - Every child prompt ends with: "Don't try to talk to the conductor or use herdr; finish with your complete final
117
- answer (that is what I read)."
118
- - **Verification in the child: lint and tsc only, one command at a time** (the cap is 4 GB per agent and jest/vitest
119
- blow it; tests are yours, step 4b): use the Verification column of the workspace `CLAUDE.md` and put in the prompt
120
- "verify sequentially, never in parallel or watch mode: (1) lint only the changed files (`git diff --name-only
121
- origin/<BASE>...HEAD`); (2) `NODE_OPTIONS=--max-old-space-size=2048 tsc --noEmit` for the project. Don't run tests".
122
- Full suite only in CI (or a manual `herdr-baseline` if the user asks).
123
- - An issue that changes an API contract: **API first**; consumers afterwards, with the new contract in the prompt.
124
- - **Never block waiting** (`herdr agent wait`, `pane wait-output`, `sleep`, `timeout`): completion arrives as a
125
- `[HERDR-AGENT DONE]` line in your pane. Dispatch, report in one line and end your turn. "Done yet?" = `<prefix>.done`
126
- exists (never `pgrep`).
127
- - Investigation only (no code): "READ ONLY" prompt, in the repo itself, no worktree. `herdr-agent -r` (Claude:
128
- `--permission-mode plan`; the others: throwaway worktree, no editing).
129
-
130
- ## 4b. Tests (yours, not the child's)
131
- Child with `status=ok` → run the tests related to the diff, in their own tab, one at a time on the machine (queue):
132
- `herdr-verify -w $WS -r <repo> -d $WT -b <BASE> -o $O/verify-<repo> -g <group>` → `$O/verify-<repo>.txt` with
133
- **new failures** and pre-existing ones: if any test fails, it runs the same test files on an updated
134
- `origin/<BASE>` (whatever fails there is pre-existing). You get `[HERDR-AGENT DONE] verify ... new=N`.
135
- `new>0` → fix round with the list (step 6), no review. `new=0` → review.
136
- **Mandatory order every round (impl and each fix): child `ok` → verify → review.** Never dispatch the review (or an
137
- "early" fix) while this round's verify is pending, even if it is queued behind another verify: wait for
138
- `[HERDR-AGENT DONE] ... verify ...` and end your turn until then.
139
-
140
- ## 5. Cross review (always another vendor)
141
- ```bash
142
- herdr-agent $(orq pick review --level <level> --impl-agent <who implemented>) -b $BASE \
143
- -g <group> -t "<ID> review <repo>" -d $WT -o $O/review-<repo> -r -i $O/impl-<repo>.md -i $O/verify-<repo>.txt \
144
- -- $O/review-<repo>.md
145
- ```
146
- `-b $BASE` attaches the diff (`origin/$BASE...HEAD`): always use it. The review prompt works for any reviewer and says
147
- "the diff is attached; for context, open files with your file-reading tool; don't run lint, tsc or tests (the results
148
- are in the attached verify)". If the reviewer ends with `status=fail` and no verdict (empty answer, or a
149
- `jetski: ... permission` line), that is not a rejection: run `orq pick review ... --exclude-agent <it>` and redo it.
150
- `--exclude-agent` applies **only to redoing that review**: for the next round's review, run `orq pick review` without
151
- exclusions (the failure may have been a one-off). An agent that failed twice in a row with no verdict →
152
- `orq block <agent> --days 1` and tell the user.
153
- **Second opinion** (`orq pick opinion`, read only, same attachments): only on **heavy** issues or when reviewer and
154
- implementer disagree about a blocker. It never becomes a round by itself: you weigh both answers and decide.
155
- **Before dispatching:** `git -C $R fetch origin $BASE; git -C $WT merge-base --is-ancestor origin/$BASE HEAD` — if it
156
- fails, don't review yet: send a fix "rebase on origin/<BASE> and repeat the checks".
157
- Always **in the same worktree `$WT`**, with the prompt in `$WS/.orquestra/<ID>/review-<repo>.md` = acceptance
158
- criteria + "review only the attached diff; answer APPROVED or a numbered list of problems (blocker/suggestion)".
159
- Fixed review checklist, besides the criteria: (a) identifiers/keys consistent across the touched modules (same concept
160
- = same field); (b) dependency downgrade, override or pin → check the CVE/advisory behind the current version; (c) the
161
- repo checklist.
162
-
163
- ## 6. Loop
164
- Blocking problems → write the list to `$O/fix-<n>.md` and continue the implementer's session (any agent):
165
- `herdr-agent -a <same> [-c <same account>] -g <group> -t "<ID> fix<n> <repo>" -d $WT -o $O/impl-<repo> -R $(cat $O/impl-<repo>.id) -- $O/fix-<n>.md`.
166
- A fix is a continuation: same agent and session, no `orq pick`. Then a new `herdr-verify` (4b) and a new review
167
- (`orq pick review` again). **Maximum: `orq config get policy.max_rounds` rounds**; over it → `orq pick impl
168
- --exclude-agent <it>` only with the user's OK, or stop and report. Non-blocking suggestions go into the comment; they
169
- don't become a round.
170
-
171
- ## 7. Close
172
- **Commit/PR conventions belong to the repo, not to you.** The **implementer, in the worktree** (where the repo's
173
- rules live) commits and writes the PR. Find and cite in the prompt, by path, whatever the repo has:
174
- `.claude/skills/commit-conventions/SKILL.md` or `.agents/skills/commit-conventions/SKILL.md`,
175
- `.github/pull_request_template.md`, `commitlint.config.*`. None of those → plain Conventional Commits.
176
- - Commits: from step 4 on, the prompt says "follow <commit conventions path>". If the review flags a deviation, ask the
177
- implementer for `git commit --amend`/`rebase -i` before the PR.
178
- - PR (**only when the user asks**): you, in `$WT`: `git -C $WT push -u origin <branch>` and `gh pr create` with a body
179
- built **from the repo's `.github/pull_request_template.md`** (every section; `<ID>` where the template asks for the
180
- issue) and the answer in `$O/impl-<repo>.out.md`. Check the opened PR against the template.
181
- - Plane comment (`workitem_comment create`): summary, repo(s), branch, agents and models used (`orq pick` output),
182
- review result, checks that ran.
183
- - **CI after every push:** `gh pr checks <n>` (no `--watch`; if pending, end your turn and check on the next notice).
184
- Red → `gh run view <id> --log-failed | tail -40`: error from the diff → fix round; error already on the base → create
185
- a Plane issue (workspace standard) and tell the user. "Ready to merge" only with green checks or an explained failure
186
- + issue.
187
- - Move it to **In Review** (finished child tabs close by themselves; close any leftover with
188
- `herdr tab list | jq -r '.result.tabs[]|select(.label|startswith("<ID> "))|.tab_id' | xargs -rn1 herdr tab close`)
189
- and **release the issue**: `herdr-claim -w $WS -r <ID>`. The worktree stays until the merge.
190
- - **After the merge** (when the user confirms): `git -C $R fetch origin $BASE; git -C $R cherry origin/$BASE <branch>`
191
- with no `+` lines → `git -C $R worktree remove $WT` and `git -C $R branch -D <branch>`; with `+` lines → ask.
192
- - **Never** push, PR, merge or deploy unless the user asks. Report to the user in 3–5 lines.
193
-
194
- ## Saving tokens
195
- Short prompts (never paste the whole `CLAUDE.md` — the agent reads the repo's own). Reviews judge only the diff, but the prompt must say the reviewer **may open files for context** (cat, rg, git
196
- show — read only): Codex read "review only the diff" as "use only the attached diff" and returned an empty review. Don't re-read
197
- the whole issue at every step. Respect the MCP limitations listed in the workspace `CLAUDE.md`.
1
+ ---
2
+ name: issue
3
+ description: Runs a Plane issue end to end by orchestrating coding agents in herdr or any terminal (herdr-agent / orq agent + orq wait) — implementer and cross-vendor reviewer picked by orq pick, tests by herdr-verify / orq verify, comment and status in Plane. Use when the user says "/issue <ID>", "take issue X", "run ABC-123", or asks to check/create issues in the conductor's ecosystem.
4
+ ---
5
+
6
+ # /issue <ID> — conductor playbook (herdr or any terminal)
7
+
8
+ You are the **orchestrator**: you plan, dispatch, follow up and report. **Do not implement anything yourself** (it
9
+ burns the conductor's model). Talk to the user in the user's language.
10
+
11
+ **Ecosystem configuration:** the **workspace** `CLAUDE.md` (the folder named in your conductor instructions) defines
12
+ the repositories and their groups (= herdr workspace, `-g`), **each repo's base branch**, verification commands,
13
+ Plane projects (identifier → project_id), default assignee, labels/modules and MCP limitations. Read it before you
14
+ start. Below, `$WS` = workspace.
15
+ **Inside herdr** (`HERDR_ENV=1`): children open in herdr tabs and their notices reach your pane — the flow below.
16
+ **Outside herdr** (any terminal, tmux, any OS): the same flow with these swaps —
17
+ - `herdr-agent ...` → `orq agent ...` (same flags; it is the same program). Children run in tmux windows inside tmux,
18
+ else in the background (their screen goes to a log; the answer is still `<prefix>.out.md`). No `-T`.
19
+ - `herdr-claim` → `orq claim` (set `ORQ_CONDUCTOR_ID` to a fixed name per conductor), `herdr-deps` → `orq deps`.
20
+ - **Completion signal:** no line arrives in your pane. After dispatching, run `orq wait <prefix>` **as a background
21
+ task** (Claude Code: Bash with `run_in_background`); its exit wakes you and its output is the line
22
+ `[ORQ AGENT DONE] <title> status=ok|fail ... answer: <file>` — treat it exactly like `[HERDR-AGENT DONE]`. Several
23
+ children in parallel: `orq wait --any <prefix1> <prefix2>` (one wake-up per finish; wait again for the rest).
24
+ No background tasks in your harness → run `orq wait` in the foreground; that is the one allowed blocking wait.
25
+ - `herdr-verify` → `orq verify`, `herdr-baseline` → `orq baseline` (same flags). They run in a tmux window or in
26
+ the background like children, and you wait for them the same way: `orq wait $O/verify-<repo>`.
27
+ - Peeking at a child: `<prefix>.log` (not `herdr pane read`).
28
+ Issue artifacts (prompts, notes) live in `$WS/.orquestra/<ID>/`.
29
+
30
+ ## 1. Read the issue
31
+ - **First, claim it:** `herdr-claim -w $WS <ID>`. Exit 1 = another conductor owns it: **stop** and tell the user
32
+ (don't read it, don't dispatch anything). Taking it over (e.g. switching accounts) only with the user's OK:
33
+ `herdr-claim -w $WS -f <ID>`. Several conductors may share a workspace; `herdr-claim -w $WS -l` lists who has what.
34
+ - `mcp__plane__workitem` `retrieve_by_identifier` with `workitem_identifier: "<ID>"`; then `workitem_comment list`.
35
+ - Extract: goal, **acceptance criteria**, affected repos, links. No acceptance criteria → write a short proposal and
36
+ **ask the user** before dispatching.
37
+ - Issue missing assignee, priority, labels or module → **fill them in** following the workspace `CLAUDE.md` "Issue
38
+ standard". The same standard applies to any new issue you create.
39
+ - Move it to **In Progress** (`workitem update` with the state_id from `state list`).
40
+
41
+ ## 2. Classify
42
+ One task per repo. Level:
43
+ - **simple** — CRUD, UI/text tweak, localized bug, 1–3 files.
44
+ - **medium** — business rule, API↔front integration, several files.
45
+ - **heavy** — architecture, data migration, hard/concurrency bug, security.
46
+
47
+ ## 3. Pick agent and model: always `orq pick`, never by hand
48
+ `orq pick` decides agent, model, effort and account (user config + delivery and token history + current quota +
49
+ rotation). **Do not choose by preference, by a rule you read elsewhere, or by what worked last time**: run it before
50
+ EVERY dispatch (implementation, review, second opinion) and use its output verbatim.
51
+ ```bash
52
+ orq pick impl --level simple|medium|heavy # → e.g. -a codex -m gpt-6-sol -e low
53
+ orq pick review --level <level> --impl-agent <agent that implemented> # → another vendor, e.g. -a opencode -m ...
54
+ orq pick opinion # second opinion (e.g. Copilot), see step 5
55
+ ```
56
+ The output goes straight into `herdr-agent` (`herdr-agent $(orq pick ...) -g ... -t ... -d ... -o ... -- prompt.md`).
57
+ - Exit 3 = no candidate (quota exhausted, no agent with that role): **stop and ask the user**.
58
+ - Implementer failed review twice (step 6) → pick again without it: `orq pick impl --level <level> --exclude-agent <agent>`.
59
+ - `--exclude-agent` never "sticks": every `orq pick` call decides again, with only that dispatch's exclusions.
60
+ - The conductor's own model (e.g. Opus) as implementer: only with the user's OK, never through `orq pick`.
61
+ - Want to understand a choice? `orq pick ... --explain --no-record` (score of each candidate; not counted in rotation).
62
+
63
+ **Every child runs through `herdr-agent`** (agent from `orq pick`): headless (`claude -p` / `codex exec` /
64
+ `opencode run` / `agy -p` / `copilot -p`) in a herdr tab (workspace = group `-g`, tab = title) with live output.
65
+ When it finishes it writes `<prefix>.done` and sends ONE line `[HERDR-AGENT DONE] <title> status=ok|fail ...` to your
66
+ pane; no MCP, and a **4 GB memory cap per agent** (own cgroup: if it blows up, only it dies). NEVER `herdr agent start`
67
+ for children (no memory cap, no answer file). **Screen mode (`-T`, or `HERDR_AGENT_TUI=1`):** the tab shows the
68
+ agent's own TUI instead of the log; same cap, same files, same signal (end-of-turn hook). The screen stays open after
69
+ the turn (it holds memory until the tab closes); `-R` with the tab open types the follow-up into it. Use it when the
70
+ user wants to watch. The repo must already be trusted in Codex/Claude (otherwise the TUI stops at the "trust this
71
+ folder?" dialog — tell the user, don't approve it for them).
72
+
73
+ ## 4. Dispatch the implementer
74
+ Write the prompt to `$WS/.orquestra/<ID>/impl-<repo>.md` (short: goal, acceptance criteria, likely files, the repo's
75
+ verification commands, "base: origin/<BASE>; don't rebase/merge other branches; local commits, no push; commit
76
+ messages following <path of the repo's commit conventions, see step 7>").
77
+ Always include:
78
+ - **Repo checklist:** copy the repo's "Checklist" column from the workspace `CLAUDE.md`.
79
+ - **Decisions:** "end your final answer with a `## Decisions` section, at most 10 lines: what you chose and what you
80
+ ruled out, trade-offs, and what you left out on purpose and why". The reviewer reads it (step 5), so a deliberate
81
+ choice doesn't come back as a blocker.
82
+ - **No tests in the child** (memory rule): "don't run jest/vitest; I run the related tests afterwards".
83
+ - **Fresh branch:** "before your final answer: `git fetch origin <BASE> && git rebase origin/<BASE>`; on conflict stop
84
+ and report; after the rebase repeat lint/tsc". Codex has no network: for it, you fetch and check in step 5.
85
+
86
+ **Base = the repo's base branch from the workspace `CLAUDE.md`, always from the updated remote (`origin/<BASE>`).**
87
+ Worktree with `git worktree add` (not `herdr worktree create`: that opens a separate herdr workspace per worktree, and
88
+ children are grouped by the repo's `-g`).
89
+ ```bash
90
+ R=$WS/<repo>; BASE=<repo base>; B=<prefix>plane-<lowercase-id>; WT=$WS/.worktrees/<repo>-plane-<lowercase-id>
91
+ O=$WS/.orquestra/<ID>
92
+ git -C $R fetch origin $BASE
93
+ git -C $R worktree add -b $B $WT origin/$BASE # already exists? reuse $WT, don't recreate it
94
+ git -C $WT log -1 --format='%h %s' # check HEAD == origin/$BASE before launching
95
+ ```
96
+ **Dependencies — NEVER install inside the worktree** (each `node_modules` is ~1 GB and tens of thousands of files;
97
+ on a modest disk that saturates I/O and memory and freezes the machine). The worktree uses a **link** to the main
98
+ repo's `node_modules`:
99
+ ```bash
100
+ herdr-deps -r $R -b $BASE -w $WT # link; stale deps → fast-forward + ONE install in $R (per-repo lock across conductors)
101
+ ```
102
+ Exit 3 = stale deps and `$R` dirty or not on `$BASE` → **ask the user**. If another conductor is installing in the
103
+ same repo, the command waits its turn (never install by hand).
104
+ In the child's prompt: "node_modules is shared (link): don't run install/add; if you need a new dependency, stop and
105
+ tell me".
106
+ **Dispatch** (no MCP; memory cap; writes in automatic mode — that is why implementation only happens in a worktree):
107
+ ```bash
108
+ orq pick impl --level <level> > $O/impl-<repo>.pick # the fix rounds reuse it (step 6)
109
+ herdr-agent $(cat $O/impl-<repo>.pick) -g <group> -t "<ID> impl <repo>" -d $WT -o $O/impl-<repo> -- $O/impl-<repo>.md
110
+ ```
111
+ - The Claude account (`-c`) already comes from `orq pick` (the least used one under the limit).
112
+ - Full final answer in `$O/impl-<repo>.out.md`; log in `.log`; the agent's session id in `.id`.
113
+ - Codex's sandbox has no network: `git fetch` is yours, beforehand (above). Push/PR: yours (step 7).
114
+ - `herdr-agent` returns immediately (no need to background it); the child's pane is in `<prefix>.pane`
115
+ (`herdr pane read $(cat <prefix>.pane) --source recent` to peek).
116
+ - **No baseline in the issue flow:** don't run `herdr-baseline` before dispatching (the base moves with every merge and
117
+ the full suite blocks every conductor's test queue). `herdr-verify` checks the base on demand (step 4b).
118
+ - **Children start WITHOUT MCP** (Plane is yours; each MCP costs ~150–200 MB per session and `systemd-oomd` kills the
119
+ whole herdr server when memory runs out) — `herdr-agent` takes care of it.
120
+ - Every child prompt ends with: "Don't try to talk to the conductor or use herdr; finish with your complete final
121
+ answer (that is what I read)."
122
+ - **Verification in the child: lint and tsc only, one command at a time** (the cap is 4 GB per agent and jest/vitest
123
+ blow it; tests are yours, step 4b): use the Verification column of the workspace `CLAUDE.md` and put in the prompt
124
+ "verify sequentially, never in parallel or watch mode: (1) lint only the changed files (`git diff --name-only
125
+ origin/<BASE>...HEAD`); (2) `NODE_OPTIONS=--max-old-space-size=2048 tsc --noEmit` for the project. Don't run tests".
126
+ Full suite only in CI (or a manual `herdr-baseline` if the user asks).
127
+ - An issue that changes an API contract: **API first**; consumers afterwards, with the new contract in the prompt.
128
+ - **Never block waiting** (`herdr agent wait`, `pane wait-output`, `sleep`, `timeout`): completion arrives as a
129
+ `[HERDR-AGENT DONE]` line in your pane. Dispatch, report in one line and end your turn. "Done yet?" = `<prefix>.done`
130
+ exists (never `pgrep`).
131
+ - Investigation only (no code): "READ ONLY" prompt, in the repo itself, no worktree. `herdr-agent -r` (Claude:
132
+ `--permission-mode plan`; the others: throwaway worktree, no editing).
133
+
134
+ ## 4b. Tests (yours, not the child's)
135
+ Child with `status=ok` → run the tests related to the diff, in their own tab, one at a time on the machine (queue):
136
+ `herdr-verify -w $WS -r <repo> -d $WT -b <BASE> -o $O/verify-<repo> -g <group>` → `$O/verify-<repo>.txt` with
137
+ **new failures** and pre-existing ones: if any test fails, it runs the same test files on an updated
138
+ `origin/<BASE>` (whatever fails there is pre-existing). You get `[HERDR-AGENT DONE] verify ... new=N`.
139
+ `new>0` → fix round with the list (step 6), no review. `new=0` → review.
140
+ **Pre-existing failures get fixed too.** Any failure — tests listed as "already failing on origin/<BASE>", or a CI job
141
+ (lint, biome, typecheck, shard, regression) failing on the PR or on the base — goes into a fix round on the issue's
142
+ branch (separate `fix:`/`test:` commit naming the issue). Never close, move to In Review or call a PR done while
143
+ something is red, new or old, and never widen a baseline or allowlist to silence it. Only if the fix is large or
144
+ outside the issue's domain: ask the user first (then it ships as its own PR, not as a note).
145
+ **Mandatory order every round (impl and each fix): child `ok` → verify → review.** Never dispatch the review (or an
146
+ "early" fix) while this round's verify is pending, even if it is queued behind another verify: wait for
147
+ `[HERDR-AGENT DONE] ... verify ...` and end your turn until then.
148
+
149
+ ## 5. Cross review (always another vendor)
150
+ ```bash
151
+ orq pick review --level <level> --impl-agent <who implemented> > $O/review-<repo>.pick # round 2+ reuses it
152
+ herdr-agent $(cat $O/review-<repo>.pick) -b $BASE \
153
+ -g <group> -t "<ID> review <repo>" -d $WT -o $O/review-<repo> -r -i $O/impl-<repo>.md -i $O/impl-<repo>.out.md \
154
+ -i $O/verify-<repo>.txt \
155
+ -- $O/review-<repo>.md
156
+ ```
157
+ `-b $BASE` attaches the diff (`origin/$BASE...HEAD`): always use it. The review prompt works for any reviewer and says
158
+ "the diff is attached; for context, open files with your file-reading tool; don't run lint, tsc or tests (the results
159
+ are in the attached verify)". If the reviewer ends with `status=fail` and no verdict (empty answer, or a
160
+ `jetski: ... permission` line), that is not a rejection: run `orq pick review ... --exclude-agent <it>` and redo it.
161
+ `--exclude-agent` applies **only to redoing that review** (save the new pick to `review-<repo>.pick`); the next
162
+ round reuses whoever gave the verdict. An agent that failed twice in a row with no verdict →
163
+ `orq block <agent> --days 1` and tell the user.
164
+ **Second opinion** (`orq pick opinion`, read only, same attachments): only on **heavy** issues or when reviewer and
165
+ implementer disagree about a blocker. It never becomes a round by itself: you weigh both answers and decide.
166
+ **Before dispatching:** `git -C $R fetch origin $BASE; git -C $WT merge-base --is-ancestor origin/$BASE HEAD` — if it
167
+ fails, don't review yet: send a fix "rebase on origin/<BASE> and repeat the checks".
168
+ Always **in the same worktree `$WT`**, with the prompt in `$WS/.orquestra/<ID>/review-<repo>.md` = acceptance
169
+ criteria + "review only the attached diff; answer APPROVED or a numbered list of problems, each tagged `[blocker]` or
170
+ `[suggestion]`. A blocker has `file:line` and a concrete failure (input or state → wrong result, crash, data loss,
171
+ security hole, broken acceptance criterion); style, naming, refactors and 'could be cleaner' are suggestions".
172
+ The implementer's answer (`impl-<repo>.out.md`) is attached for its `## Decisions` section only: the diff is the source
173
+ of truth. The prompt says "a choice listed under Decisions is not a blocker unless it breaks an acceptance criterion or
174
+ is wrong; then say why".
175
+ Fixed review checklist, besides the criteria: (a) identifiers/keys consistent across the touched modules (same concept
176
+ = same field); (b) dependency downgrade, override or pin → check the CVE/advisory behind the current version; (c) the
177
+ repo checklist.
178
+
179
+ ## 6. Loop
180
+ **Only `[blocker]` items open a round.** An item tagged blocker without `file:line` and a concrete failure, or that
181
+ only restates a `## Decisions` choice, counts as a suggestion; when you downgrade one, say why in the Plane comment.
182
+ No blockers left → APPROVED, even with suggestions.
183
+ Blocking problems → write the list (blockers only) to `$O/fix-<n>.md` and continue the implementer's session (any agent):
184
+ `herdr-agent $(orq pick fix --same $O/impl-<repo>.pick) -g <group> -t "<ID> fix<n> <repo>" -d $WT -o $O/impl-<repo> -R $(cat $O/impl-<repo>.id) -- $O/fix-<n>.md`.
185
+ A fix is a continuation: same agent, model, account and session, effort one level up (`--same` reads the implementer's
186
+ pick; never a new `orq pick`, never `-a` alone — without `-m` the session resumes on the CLI's default model, which
187
+ loses the prompt cache and hands the work to a weaker model). `fix-<n>.md` = the numbered blockers + these rules: "fix only
188
+ these items, with the smallest diff that does it; don't refactor, rename or reformat code that isn't in the list; for
189
+ each blocker add or adjust a test that fails without the fix, when the code is testable (say so when it isn't); if an
190
+ item is wrong or conflicts with a criterion, don't fix it: say why"; and it ends with "update the `## Decisions`
191
+ section of your final answer for the whole branch". **Before dispatching the fix:** `git -C $WT rev-parse HEAD > $O/round-<n>.sha`.
192
+ Then a new `herdr-verify` (4b) and the **round review** (step 5 with these changes):
193
+ - Same reviewer as the round before: `$(cat $O/review-<repo>.pick)`. Only if it is over quota, blocked or fails with
194
+ no verdict → a new `orq pick review` (saved to the same file).
195
+ - Extra attachments: `git -C $WT diff $(cat $O/round-<n>.sha)..HEAD > $O/fix-<n>.diff` → `-i $O/fix-<n>.md -i $O/fix-<n>.diff`
196
+ (the full `-b $BASE` diff stays, as context).
197
+ - The prompt asks a closed question: "for each item in fix-<n>.md: RESOLVED or NOT RESOLVED (why); then the fix diff:
198
+ any regression it introduced, as `[blocker]`/`[suggestion]`. Outside the fix diff, report only a blocker you missed
199
+ before that would break production, and say why it wasn't in the first review". Anything else is a suggestion. **Maximum: `orq config get policy.max_rounds` rounds**; over it → `orq pick impl
200
+ --exclude-agent <it> > $O/impl-<repo>.pick` only with the user's OK, or stop and report. Non-blocking suggestions go into the comment; they
201
+ don't become a round.
202
+
203
+ ## 7. Close
204
+ **Commit/PR conventions belong to the repo, not to you.** The **implementer, in the worktree** (where the repo's
205
+ rules live) commits and writes the PR. Find and cite in the prompt, by path, whatever the repo has:
206
+ `.claude/skills/commit-conventions/SKILL.md` or `.agents/skills/commit-conventions/SKILL.md`,
207
+ `.github/pull_request_template.md`, `commitlint.config.*`. None of those → plain Conventional Commits.
208
+ - Commits: from step 4 on, the prompt says "follow <commit conventions path>". If the review flags a deviation, ask the
209
+ implementer for `git commit --amend`/`rebase -i` before the PR.
210
+ - PR (**only when the user asks**): you, in `$WT`: `git -C $WT push -u origin <branch>` and `gh pr create` with a body
211
+ built **from the repo's `.github/pull_request_template.md`** (every section; `<ID>` where the template asks for the
212
+ issue) and the answer in `$O/impl-<repo>.out.md`. Check the opened PR against the template.
213
+ - Plane comment (`workitem_comment create`): summary, repo(s), branch, agents and models used (`orq pick` output),
214
+ review result, checks that ran.
215
+ - **CI after every push:** `gh pr checks <n>` (no `--watch`; if pending, end your turn and check on the next notice).
216
+ Red → `gh run view <id> --log-failed | tail -40`: error from the diff → fix round; error already on the base → create
217
+ a Plane issue (workspace standard) and tell the user. "Ready to merge" only with green checks or an explained failure
218
+ + issue.
219
+ - Move it to **In Review** (finished child tabs close by themselves; close any leftover with
220
+ `herdr tab list | jq -r '.result.tabs[]|select(.label|startswith("<ID> "))|.tab_id' | xargs -rn1 herdr tab close`)
221
+ and **release the issue**: `herdr-claim -w $WS -r <ID>`. The worktree stays until the merge.
222
+ - **After the merge** (when the user confirms): run `orq gc -w $WS` and show the list. If this issue's worktree is
223
+ listed as removable, run `orq gc -w $WS --yes`; anything else → ask the user.
224
+ - **Never** push, PR, merge or deploy unless the user asks. Report to the user in 3–5 lines.
225
+
226
+ ## Saving tokens
227
+ Short prompts (never paste the whole `CLAUDE.md` — the agent reads the repo's own). Reviews judge only the diff, but the prompt must say the reviewer **may open files for context** (cat, rg, git
228
+ show — read only): Codex read "review only the diff" as "use only the attached diff" and returned an empty review. Don't re-read
229
+ the whole issue at every step. Respect the MCP limitations listed in the workspace `CLAUDE.md`.