herdr-orchestra 6.0.0 → 6.2.1
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/CHANGELOG.md +37 -0
- package/README.md +40 -1
- package/VERSION +1 -1
- package/agents.default.toml +12 -0
- package/bin/orch +394 -6
- package/extensions/orch-mode.ts +224 -0
- package/install.sh +8 -0
- package/package.json +27 -4
- package/pi/README.md +5 -0
- package/pi/skills/orch-plan/SKILL.md +6 -0
- package/playbooks/subagent.md +40 -0
- package/bin/__pycache__/orchcpython-314.pyc +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes. Versions follow [semantic versioning](https://semver.org).
|
|
4
4
|
|
|
5
|
+
## [6.2.1] - 2026-11-21
|
|
6
|
+
|
|
7
|
+
Fixes `/orch-setup` and `/orch-mode` not working in Pi when an older `orch` is already on the machine.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- **Old `orch` next to the new Pi package.** If the `orch` command installed on the machine is older than the Pi package (for example 6.1.0 with package 6.2.0), it does not know `orch mode` or `orch setup`, so `/orch-mode` failed with a bare `usage: orch <command>`. Now Pi says at start-up: `this Pi package is 6.2.0 but the orch command on this machine is 6.1.0 ... Type /orch-setup to update it`. `/orch-mode` still saves your choice (and says the old orch does not know modes yet), and `/orch-setup` installs the matching `orch`, switching the active version to the package's.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- README: `pi install git:github.com/arunnarangali/herdr-orchestra@v6.2.1` is listed as a way to install the Pi package straight from GitHub (works without the npm package).
|
|
14
|
+
|
|
15
|
+
## [6.2.0] - 2026-11-21
|
|
16
|
+
|
|
17
|
+
herdr-orchestra is now a Pi package, and runs can use a second mode: everything in one Pi window, with the coder and the reviewer as Pi subagents. Nothing changes for anyone who doesn't pick it: `panes` stays the default, runs from older versions are panes runs, and Claude Code, Codex, OpenCode, Amp, Hermes and Antigravity see the same skills and commands as before.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- **Pi package.** `pi install npm:herdr-orchestra` gives Pi the `orch-plan` and `orch-run` skills and the `orch-mode` extension. `package.json` has the `pi-package` keyword and a `pi` block; only Pi reads them. The extension shows the mode in Pi's footer (`orch: subagent`), tells Pi the mode on every turn, and adds `/orch-mode [panes|subagent]` and `/orch-setup` (installs the `orch` command from the package, needed once). Pi's YAML reader rejects the `orch-plan` skill's description as written, so Pi loads a copy with the same text in quotes (`pi/skills/orch-plan`); every other agent keeps the original, unchanged, and a test checks the two say the same thing.
|
|
21
|
+
- **Two modes.** `panes` (default): coders and the reviewer in herdr panes, driven by the event manager, as before. `subagent`: one Pi window; the lead starts the `coder` and `reviewer` subagents (the `Agent` tool of `@tintinweb/pi-subagents`), one milestone at a time. `orch mode [panes|subagent]` shows or switches it; the choice is saved in `~/.config/herdr-orchestra/config.json`, and each run keeps the mode it was planned in (`orch_mode` in `.orchestrate/state.json`; a state file without it is a panes run). A run's mode is not switched while a milestone is in progress.
|
|
22
|
+
- **`orch setup [--mode panes|subagent]`**, also `npx herdr-orchestra@latest --mode subagent` and `orch team up --mode subagent`: in subagent mode it writes `~/.pi/agent/agents/coder.md` and `reviewer.md` from the config (model and thinking level; the reviewer cannot edit files) and installs `npm:@tintinweb/pi-subagents`. A denied model is refused; a file you edited yourself is never overwritten. In panes mode it does nothing.
|
|
23
|
+
- **`orch check [Mn]`**: runs the plan's check command in the main folder and prints `CHECK PASS`, or `CHECK FAIL` with the last 30 lines (exit 1). A pass is reused by `orch finish` when the files did not change.
|
|
24
|
+
- **`orch sub next` / `orch sub done Mn`** (subagent mode): the next ready milestone and its task file; save a finished one (orch commits it on the feature branch, holding risky changes for `orch approve` as in panes mode). `orch finish` works the same at the end.
|
|
25
|
+
- **`orch lead run` in subagent mode** prints the new `playbooks/subagent.md` (coder → `orch check` → reviewer → `orch sub done`, then the summary and `orch finish`); `orch lead plan` starts with a short note on the subagent team. The `orch-run` and `orch-plan` skills are unchanged.
|
|
26
|
+
- **`pi` in the agent registry**, so Pi can also be a lead, coder or reviewer in panes mode (herdr detection of Pi is unverified, so orch relies on its done file).
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- In a subagent run, `orch dispatch` and `orch autopilot` refuse with a clear message (there is no event manager), and `orch answer` never starts one.
|
|
30
|
+
|
|
31
|
+
## [6.1.0] - 2026-11-19
|
|
32
|
+
|
|
33
|
+
The website gets a new look: a dark, terminal-style design. Every page keeps the same words, links and features; only the design changed.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- **Terminal-minimal design.** A near-black background, thin 1px lines, square corners, no shadows, and one amber accent colour. Headings, navigation, buttons and labels use a monospace font (JetBrains Mono); explanations stay in Inter. The docs use the same colours and fonts. The site opens in dark mode; light mode is still one click on the theme button.
|
|
37
|
+
- **Diagrams restyled.** The run graph, the event-loop picture and the branch picture use the new colours and square boxes, and animate as before.
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- **"How it works" in four steps, with a live terminal.** On the homepage and the How it works page: the run as four numbered steps (01 plan, 02 say go, 03 run, 04 pull request), a data-flow diagram that lights up the step you are on, and a terminal that replays one run with real `orch` commands and log lines (`orch sync`, `orch plan show`, `orch dispatch`, the event manager's log, a `SAY:` line, `orch finish`). It has Play, Pause, Step and Restart buttons; click a step to jump to it. With reduced motion turned on, the whole log is shown at once.
|
|
41
|
+
|
|
5
42
|
## [6.0.0] - 2026-11-19
|
|
6
43
|
|
|
7
44
|
A major version for a major performance change: how fast work moves from a coder to the reviewer, the branch and the lead. Plans, commands and files work as before; three new defaults change timing (early review, auto dispatch, no repeated branch check), and each can be turned off with one plan line.
|
package/README.md
CHANGED
|
@@ -246,6 +246,45 @@ Full stack: M1 contract (API + types) → M2 backend ∥ M3 UI → M4 integratio
|
|
|
246
246
|
### Review pipelining (worktree mode)
|
|
247
247
|
When a milestone passes its checks it's saved to its hidden ref and the coder is **freed immediately**, so it takes the next ready milestone while the reviewer works. Blockers come back as a **fix job** for the next free coder (preferring the one who built it); fix jobs go before new milestones.
|
|
248
248
|
|
|
249
|
+
### Pi: panes or one window (subagent mode)
|
|
250
|
+
|
|
251
|
+
herdr-orchestra is also a [Pi](https://pi.dev) package:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
pi install npm:herdr-orchestra
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
You can also install it straight from GitHub (same files, no npm needed): `pi install git:github.com/arunnarangali/herdr-orchestra@v6.2.1`.
|
|
258
|
+
|
|
259
|
+
Pi then has the `orch-plan` and `orch-run` skills and two commands. The first time, Pi says the `orch` command is missing (or older than the package): type `/orch-setup` once and it runs this package's installer. Pi may warn once that `orch-plan` / `orch-run` were found twice (the installer also puts them in `~/.agents/skills` for Codex, Amp and OpenCode); it keeps one copy and works.
|
|
260
|
+
|
|
261
|
+
Runs have two modes. Nothing changes for anyone who never picks the second one.
|
|
262
|
+
|
|
263
|
+
| Mode | Where the coder and reviewer run | Who drives the run |
|
|
264
|
+
|---|---|---|
|
|
265
|
+
| `panes` (default) | herdr panes, as described above | the event manager; the lead dispatches and pauses |
|
|
266
|
+
| `subagent` | inside one Pi window, as Pi subagents ([pi-subagents](https://www.npmjs.com/package/@tintinweb/pi-subagents)) | the lead, one milestone at a time |
|
|
267
|
+
|
|
268
|
+
Switch with `/orch-mode subagent` in Pi, or `orch mode subagent` in a terminal; `/orch-mode` alone shows the mode, and Pi's footer shows it too (`orch: subagent`). The choice is saved in `~/.config/herdr-orchestra/config.json`, and a run keeps the mode it was planned in. Set up subagent mode once:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
orch setup --mode subagent # or: npx herdr-orchestra@latest --mode subagent, or orch team up --mode subagent
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
It writes `~/.pi/agent/agents/coder.md` and `reviewer.md` (the reviewer cannot edit files) and installs `npm:@tintinweb/pi-subagents`. Pick their models in the config file; with none, they use the lead's model. A model the policy denies is refused, and a file you edited yourself (without orch's line in it) is left alone.
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"mode": "subagent",
|
|
279
|
+
"subagent": {
|
|
280
|
+
"coder": { "model": "anthropic/claude-sonnet-4-5", "thinking": "medium" },
|
|
281
|
+
"reviewer": { "model": "openai/gpt-5", "thinking": "high" }
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
A subagent run: `/orch-plan` as usual (the plan's team is `Workers: coder (pi)`, `Reviewer: reviewer (pi)`, `Isolation: shared`), say go, and the lead repeats for each milestone: `orch sub next` (the next milestone and its task file) → the `coder` subagent builds it → `orch check Mn` (failures go back to the same coder) → the `reviewer` subagent when the milestone has `Review: yes` → `orch sub done Mn` (orch commits it on the feature branch; risky changes still wait for `orch approve`). At the end you get the summary and run `orch finish`, as always. It is simpler and needs no herdr, but slower than panes mode: no coders in parallel, and the lead spends more tokens.
|
|
287
|
+
|
|
249
288
|
### Modes
|
|
250
289
|
- **worktree**: each coder works in `../<repo>-wt/<name>`, independent tasks run in parallel, and each task is squash-merged when it passes checks and review. Start each coder inside its own worktree.
|
|
251
290
|
- **shared**: everyone works in your folder, one milestone at a time. Two agents in one folder would overwrite each other's files and mix their changes, so this is only safe sequentially. Use it when every milestone depends on the previous one.
|
|
@@ -324,7 +363,7 @@ Every status change is written to `.orchestrate/events.jsonl`, and `orch report
|
|
|
324
363
|
Optional plan header lines: `Lead mode: events | off` (default `events` when the plan has a `Lead:` line) · `Scope: warn | strict` · `Risk hold: on | off` · `Budget: 3h` (autopilot stops when its running time is used up) · `Estimate: 1h30m` (the lead's estimate for the feature) · `Setup inputs: <globs>` (which files mean "run setup again"; default: lockfiles and manifests). Per milestone: `Why separate` (why it is its own milestone; needed when the plan has more than one) · `Tier`, `Needs`, `Model why` (see [Models and tiers](#models-and-tiers)) · `Estimate: 40m` (dispatch to landed if nothing goes wrong) · `Parallel: allow` lets it run next to a milestone that shares its `Likely files`.
|
|
325
364
|
|
|
326
365
|
### Commands
|
|
327
|
-
`orch status` · `orch resume` · `orch report` · `orch approve Mn` · `orch models [show|check <id>]` · `orch events [--peek]` · `orch dispatch Mn... [--to <worker>] [--tier <tier>]` · `orch answer Mn [--defer AC2] "<answer>"` · `orch defer Mn AC2 "<reason>"` · `orch fix Mn "<change>" [--to <worker>]` · `orch doctor [kind]` · `orch ready` · `orch autopilot` · `orch lead plan|run|check|whoami` · `orch agents [launch <kind> [--model <id>]|sync|check]` · `orch handoff Mn` · `orch needs-fix Mn` · `orch set M3 pending` · `orch park M2 paused "why"` · `orch cooldown claude-1 60` · `orch bench claude-1 off|on` · `orch stop [--now]` · `orch doctor --crash` · `orch cleanup` · `orch finish [--no-push]` · `orch version` · `orch update [--check] [--version vX.Y.Z]` · `orch config [auto-update on|off]` · `orch` (full help)
|
|
366
|
+
`orch status` · `orch resume` · `orch report` · `orch approve Mn` · `orch models [show|check <id>]` · `orch events [--peek]` · `orch dispatch Mn... [--to <worker>] [--tier <tier>]` · `orch answer Mn [--defer AC2] "<answer>"` · `orch defer Mn AC2 "<reason>"` · `orch fix Mn "<change>" [--to <worker>]` · `orch doctor [kind]` · `orch ready` · `orch autopilot` · `orch lead plan|run|check|whoami` · `orch agents [launch <kind> [--model <id>]|sync|check]` · `orch handoff Mn` · `orch needs-fix Mn` · `orch set M3 pending` · `orch park M2 paused "why"` · `orch cooldown claude-1 60` · `orch bench claude-1 off|on` · `orch stop [--now]` · `orch doctor --crash` · `orch cleanup` · `orch finish [--no-push]` · `orch version` · `orch update [--check] [--version vX.Y.Z]` · `orch config [auto-update on|off]` · `orch mode [panes|subagent]` · `orch setup [--mode panes|subagent]` · `orch check [Mn]` · `orch sub next|done Mn` · `orch` (full help)
|
|
328
367
|
|
|
329
368
|
Tunables: `ORCH_CODER_BUDGET_MIN` (45) · `ORCH_REVIEW_BUDGET_MIN` (15) · `ORCH_CHECK_TIMEOUT_MIN` (30) · `ORCH_COOLDOWN_MIN` (60) · `ORCH_MAX_TASKS` (unset: no limit) · `ORCH_GONE_COOLDOWN_MIN` (10) · `ORCH_SEND_RETRY_S` (120) · `ORCH_HERDR_TIMEOUT_S` (30) · `ORCH_MAX_LOST` (4) · `ORCH_UNREACHABLE_MIN` (30) · `ORCH_CONFIRM_S` (30) · `ORCH_DOWN_MIN_S` (120: an event manager silent for longer was down, and that time is not counted) · `ORCH_RISK_MAX_LINES` (1500) · `ORCH_LEAD_WAIT_MIN` (15: ready work the lead hasn't dispatched starts by itself) · `ORCH_LEAD_CONFIRM_S` (30: a wake-up the lead did not pick up is sent again, doubling) · `ORCH_LEAD_REWAKE_S` (300) · `ORCH_LEAD_MAX_WAKES` (3) · `ORCH_LEAD_IDLE_MAX_MIN` (720: how long the event manager waits for an answer) · `ORCH_NO_AUTOSTART=1` (the lead's commands never start the event manager)
|
|
330
369
|
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.
|
|
1
|
+
6.2.1
|
package/agents.default.toml
CHANGED
|
@@ -98,3 +98,15 @@ skills_dirs = ["~/.gemini/config/skills"]
|
|
|
98
98
|
invoke = "use the orch-plan skill: <feature>"
|
|
99
99
|
verified = true
|
|
100
100
|
notes = "Antigravity CLI 1.5: --mode accept-edits|auto|plan and --dangerously-skip-permissions. The binary documents ~/.gemini/config/skills/<name>/SKILL.md as the global skills folder."
|
|
101
|
+
|
|
102
|
+
[pi]
|
|
103
|
+
binary = "pi"
|
|
104
|
+
launch = "pi"
|
|
105
|
+
model_flag = "--model"
|
|
106
|
+
herdr_detect = false
|
|
107
|
+
roles = ["lead", "coder", "reviewer"]
|
|
108
|
+
skills_dirs = ["~/.agents/skills"]
|
|
109
|
+
skills_reads = ["~/.pi/agent/skills", "~/.agents/skills"]
|
|
110
|
+
invoke = "/skill:orch-plan <feature>"
|
|
111
|
+
verified = false
|
|
112
|
+
notes = "Pi (pi.dev, npm @earendil-works/pi-coding-agent 1.6): `pi install npm:herdr-orchestra` adds the orch skills and the orch-mode extension (/orch-mode, /orch-setup). Pi also reads ~/.agents/skills, so it may warn once that orch-plan / orch-run are found twice; it keeps the first copy. Docs list `--model`; herdr detection of Pi is unverified, so orch relies on the done file in panes mode. Subagent mode (one Pi window): `orch setup --mode subagent`."
|
package/bin/orch
CHANGED
|
@@ -163,7 +163,7 @@ def state_lock():
|
|
|
163
163
|
|
|
164
164
|
# usable while autopilot drives: reads, and the lead's requests (the event manager carries them out)
|
|
165
165
|
LEASE_FREE = {"status", "ready", "pick", "report", "approve", "autopilot", "events", "dispatch", "answer", "defer",
|
|
166
|
-
"fix", "team", "resume", "bench", "stop", "doctor", "plan", "story"}
|
|
166
|
+
"fix", "team", "resume", "bench", "stop", "doctor", "plan", "story", "check"}
|
|
167
167
|
_LEASE = None
|
|
168
168
|
|
|
169
169
|
|
|
@@ -1274,6 +1274,7 @@ def cmd_sync(args):
|
|
|
1274
1274
|
"title": title_m.group(1) if title_m else branch,
|
|
1275
1275
|
"commits": commits,
|
|
1276
1276
|
"mode": mode,
|
|
1277
|
+
"orch_mode": old.get("orch_mode") or config_mode(), # panes (herdr) or subagent (Pi): kept for the run
|
|
1277
1278
|
"quick_because": quick_because if quick else None,
|
|
1278
1279
|
"green_tree": old.get("green_tree"),
|
|
1279
1280
|
"integration_broken": old.get("integration_broken"),
|
|
@@ -3363,6 +3364,9 @@ def start_manager():
|
|
|
3363
3364
|
detached from this shell, when none is running. Says what happened."""
|
|
3364
3365
|
if driver_alive():
|
|
3365
3366
|
return f"the event manager is running ({driver_line(driver_info())})"
|
|
3367
|
+
with contextlib.suppress(OSError, ValueError):
|
|
3368
|
+
if STATE.exists() and run_mode(json.loads(STATE.read_text())) == "subagent":
|
|
3369
|
+
return "subagent mode: no event manager (the lead drives the run with `orch sub next`)"
|
|
3366
3370
|
if os.environ.get("ORCH_NO_AUTOSTART") == "1":
|
|
3367
3371
|
return "the event manager is NOT running — ask the developer to run `orch autopilot` in a terminal"
|
|
3368
3372
|
_rotate(ORCH / "manager.out", LOG_MAX_B // 2)
|
|
@@ -3404,6 +3408,9 @@ def cmd_dispatch(args):
|
|
|
3404
3408
|
need(args, 1, "dispatch <Mn> [Mn...] [--to <worker>] [--tier small|medium|high]")
|
|
3405
3409
|
with state_lock():
|
|
3406
3410
|
st = load()
|
|
3411
|
+
if run_mode(st) == "subagent":
|
|
3412
|
+
die("this run is in subagent mode: the lead starts milestones with `orch sub next` (no event manager); "
|
|
3413
|
+
"`orch mode panes` switches back while nothing is in progress")
|
|
3407
3414
|
require_lead(st, "orch dispatch")
|
|
3408
3415
|
if opts.get("--to") and opts["--to"] not in st["workers"]:
|
|
3409
3416
|
die(f"unknown worker {opts['--to']!r} — workers: {', '.join(st['workers'])}")
|
|
@@ -4045,6 +4052,9 @@ def cmd_autopilot(args):
|
|
|
4045
4052
|
"""The event manager (see _autopilot). This wrapper records how it ends: every stop writes a last line to
|
|
4046
4053
|
autopilot.log, a Python error writes the traceback, and a manager that was killed without a word (memory guard,
|
|
4047
4054
|
a crash of the whole terminal) is found by the next one, which looks up why in the computer's own log."""
|
|
4055
|
+
with contextlib.suppress(OSError, ValueError):
|
|
4056
|
+
if STATE.exists() and run_mode(json.loads(STATE.read_text())) == "subagent":
|
|
4057
|
+
die("this run is in subagent mode: there is no event manager; the lead drives it with `orch sub next`")
|
|
4048
4058
|
take_lease()
|
|
4049
4059
|
if STATE.exists():
|
|
4050
4060
|
manager_begin()
|
|
@@ -5608,8 +5618,17 @@ def _herdr_json(cmd):
|
|
|
5608
5618
|
def team_up(args):
|
|
5609
5619
|
"""Open a pane for every worker and the reviewer in the plan that herdr can't find: split from this pane, cd
|
|
5610
5620
|
into the agent's folder (its worktree, or the repo), start it on its plan model, and give it its plan name."""
|
|
5621
|
+
args = list(args)
|
|
5622
|
+
flag = mode_flag(args, "usage: orch team up [--dry-run] [--mode panes|subagent]")
|
|
5611
5623
|
dry = "--dry-run" in args
|
|
5624
|
+
if flag and not dry:
|
|
5625
|
+
set_mode(flag, hint=False)
|
|
5612
5626
|
st = load()
|
|
5627
|
+
if (flag or run_mode(st)) == "subagent":
|
|
5628
|
+
print("mode subagent: no panes to open; the coder and the reviewer are Pi subagents")
|
|
5629
|
+
if dry:
|
|
5630
|
+
return
|
|
5631
|
+
sys.exit(1 if pi_setup() else 0)
|
|
5613
5632
|
reg = registry(required=False) or {}
|
|
5614
5633
|
agents = [(n, w, w.get("dir")) for n, w in st["workers"].items()]
|
|
5615
5634
|
if st.get("reviewer"):
|
|
@@ -5923,11 +5942,11 @@ COMMANDS = {
|
|
|
5923
5942
|
"requeue-review": cmd_requeue_review, "finish": cmd_finish, "resend": cmd_resend, "approve": cmd_approve,
|
|
5924
5943
|
"report": cmd_report, "events": cmd_events, "dispatch": cmd_dispatch, "answer": cmd_answer, "defer": cmd_defer,
|
|
5925
5944
|
"escalate": cmd_escalate, "fix": cmd_fix, "plan": cmd_plan, "story": cmd_story, "team": cmd_team, "bench": cmd_bench, "stop": cmd_stop,
|
|
5926
|
-
"doctor": lambda a: cmd_doctor_crash(a),
|
|
5945
|
+
"doctor": lambda a: cmd_doctor_crash(a), "check": lambda a: cmd_check(a), "sub": lambda a: cmd_sub(a),
|
|
5927
5946
|
}
|
|
5928
5947
|
# they lock per step instead of for the whole command (long-running, or they start the event manager after)
|
|
5929
5948
|
UNLOCKED = {"autopilot", "poll", "merge", "events", "dispatch", "answer", "defer", "fix", "team", "resume", "bench", "stop",
|
|
5930
|
-
"doctor"}
|
|
5949
|
+
"doctor", "check"}
|
|
5931
5950
|
|
|
5932
5951
|
USAGE = """usage: orch <command> [args]
|
|
5933
5952
|
version print the installed herdr-orchestra version
|
|
@@ -5940,7 +5959,12 @@ USAGE = """usage: orch <command> [args]
|
|
|
5940
5959
|
lead whoami show the lead's own herdr pane and how to name it `lead`
|
|
5941
5960
|
team <kind> [--coders N] [--models a,b] [--no-reviewer]
|
|
5942
5961
|
the plan's team built from one installed tool: coders + reviewer on its catalog models
|
|
5943
|
-
team up [--dry-run]
|
|
5962
|
+
team up [--dry-run] [--mode panes|subagent]
|
|
5963
|
+
open a herdr pane for every agent in the plan herdr can't find, in its folder, and name it
|
|
5964
|
+
(subagent mode: no panes; sets up the Pi coder/reviewer subagents instead)
|
|
5965
|
+
mode [panes|subagent] which mode runs use: panes (herdr panes, the default) or subagent (one Pi window)
|
|
5966
|
+
setup [--mode panes|subagent] get this machine ready for a mode; subagent: write ~/.pi/agent/agents/coder.md and
|
|
5967
|
+
reviewer.md from ~/.config/herdr-orchestra/config.json and install pi-subagents
|
|
5944
5968
|
agents the agent registry: kinds, installed?, roles, herdr detection, launch commands
|
|
5945
5969
|
agents launch <kind> [--model <id>] print the command that starts <kind> in a pane (auto-approve edits)
|
|
5946
5970
|
models the model catalog: tiers (small / medium / high), ratings, and what policy forbids
|
|
@@ -5951,6 +5975,8 @@ USAGE = """usage: orch <command> [args]
|
|
|
5951
5975
|
plan show the plan for a person: each milestone in plain words, who builds it, how long, the order
|
|
5952
5976
|
events [--peek] (lead) what you were woken for; reading acknowledges it
|
|
5953
5977
|
dispatch <Mn>... [--to <worker>] [--tier <tier>] (lead) start or restart milestones; starts the event manager
|
|
5978
|
+
check [Mn] run the plan's check command in the main folder: CHECK PASS, or CHECK FAIL (exit 1)
|
|
5979
|
+
sub next | sub done <Mn> (lead, subagent mode) the next milestone and its task file | save a finished milestone
|
|
5954
5980
|
answer <Mn> [--defer AC2,AC3] <text> (lead) the developer's answer: into plan.md, and back to the same coder;
|
|
5955
5981
|
--defer records that the developer approved leaving those criteria undone
|
|
5956
5982
|
defer <Mn> <AC2,AC3> <reason> (lead, only with the developer's yes) these criteria stay undone in Mn: no fix
|
|
@@ -6209,9 +6235,15 @@ def cmd_lead(args):
|
|
|
6209
6235
|
print(run_playbook_part(pb.read_text(), args[2] if len(args) > 2 else ""), end="")
|
|
6210
6236
|
return
|
|
6211
6237
|
label = f"{sub} ({part})" if part else sub
|
|
6238
|
+
subagent = current_mode()[0] == "subagent"
|
|
6239
|
+
if subagent and sub == "run":
|
|
6240
|
+
pb = asset("playbooks/subagent.md") or die("playbooks/subagent.md not found next to orch or in the install")
|
|
6241
|
+
label = "run (subagent mode)"
|
|
6212
6242
|
print(f"herdr-orchestra {installed_version()} — lead playbook: {label}\n")
|
|
6213
|
-
if not part:
|
|
6243
|
+
if not part and not subagent:
|
|
6214
6244
|
lead_self_name()
|
|
6245
|
+
if subagent and sub == "plan":
|
|
6246
|
+
print(SUBAGENT_PLAN_NOTE, end="")
|
|
6215
6247
|
print(plan_playbook_part(pb.read_text(), part) if sub == "plan" else pb.read_text(), end="")
|
|
6216
6248
|
return
|
|
6217
6249
|
if sub == "check":
|
|
@@ -6942,6 +6974,361 @@ def cmd_update(args):
|
|
|
6942
6974
|
print(f"Go back any time: orch update --version v{cur}")
|
|
6943
6975
|
|
|
6944
6976
|
|
|
6977
|
+
# ---------------------------------------------------------------- run modes: panes (herdr) or subagent (one Pi window)
|
|
6978
|
+
# `panes` is today's workflow and the default: coders and the reviewer are agents in herdr panes, the event manager
|
|
6979
|
+
# drives them. `subagent` is for Pi (https://pi.dev) with the @tintinweb/pi-subagents extension: the lead stays in one
|
|
6980
|
+
# window and starts the coder and the reviewer as Pi subagents, one milestone at a time. Nothing about panes mode
|
|
6981
|
+
# changes when nobody picks subagent.
|
|
6982
|
+
ORCH_MODES = ("panes", "subagent")
|
|
6983
|
+
PI_SUBAGENTS = "npm:@tintinweb/pi-subagents"
|
|
6984
|
+
PI_AGENT_MARK = "<!-- written by `orch setup` (herdr-orchestra). orch rewrites this file; delete this line to keep your own edits. -->"
|
|
6985
|
+
|
|
6986
|
+
|
|
6987
|
+
def user_config_file():
|
|
6988
|
+
return Path(os.environ.get("ORCH_CONFIG_FILE") or Path.home() / ".config/herdr-orchestra/config.json")
|
|
6989
|
+
|
|
6990
|
+
|
|
6991
|
+
def config_load():
|
|
6992
|
+
try:
|
|
6993
|
+
data = json.loads(user_config_file().read_text())
|
|
6994
|
+
return data if isinstance(data, dict) else {}
|
|
6995
|
+
except (OSError, ValueError):
|
|
6996
|
+
return {}
|
|
6997
|
+
|
|
6998
|
+
|
|
6999
|
+
def config_save(data):
|
|
7000
|
+
p = user_config_file()
|
|
7001
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
7002
|
+
tmp = p.with_suffix(".json.tmp")
|
|
7003
|
+
tmp.write_text(json.dumps(data, indent=2) + "\n")
|
|
7004
|
+
os.replace(tmp, p)
|
|
7005
|
+
|
|
7006
|
+
|
|
7007
|
+
def config_mode():
|
|
7008
|
+
m = str(config_load().get("mode") or "panes").lower()
|
|
7009
|
+
return m if m in ORCH_MODES else "panes"
|
|
7010
|
+
|
|
7011
|
+
|
|
7012
|
+
def run_mode(st):
|
|
7013
|
+
"""A run keeps the mode it was planned in. Runs from before 6.2.0 have no `orch_mode`: they are panes runs."""
|
|
7014
|
+
m = (st or {}).get("orch_mode") or "panes"
|
|
7015
|
+
return m if m in ORCH_MODES else "panes"
|
|
7016
|
+
|
|
7017
|
+
|
|
7018
|
+
def _repo_state_path():
|
|
7019
|
+
""".orchestrate/state.json of the repo this shell is in, or None (outside a repo, or no run yet)."""
|
|
7020
|
+
r = git("rev-parse", "--path-format=absolute", "--git-common-dir", check=False)
|
|
7021
|
+
if r.returncode != 0:
|
|
7022
|
+
return None
|
|
7023
|
+
p = Path(r.stdout.strip()).parent / ".orchestrate" / "state.json"
|
|
7024
|
+
return p if p.exists() else None
|
|
7025
|
+
|
|
7026
|
+
|
|
7027
|
+
def current_mode():
|
|
7028
|
+
"""(mode, where it comes from): this repo's run, else the machine's config, else panes."""
|
|
7029
|
+
with contextlib.suppress(Exception):
|
|
7030
|
+
p = _repo_state_path()
|
|
7031
|
+
if p:
|
|
7032
|
+
return run_mode(json.loads(p.read_text())), "this repo's run"
|
|
7033
|
+
if "mode" in config_load():
|
|
7034
|
+
return config_mode(), short(user_config_file())
|
|
7035
|
+
return "panes", "default"
|
|
7036
|
+
|
|
7037
|
+
|
|
7038
|
+
def mode_flag(args, usage):
|
|
7039
|
+
"""Take `--mode <panes|subagent>` (or `--mode=...`) out of args; returns the mode or None."""
|
|
7040
|
+
for i, a in enumerate(list(args)):
|
|
7041
|
+
if a == "--mode" or a.startswith("--mode="):
|
|
7042
|
+
val = a.split("=", 1)[1] if "=" in a else (args[i + 1] if len(args) > i + 1 else "")
|
|
7043
|
+
del args[i:i + (1 if "=" in a else 2)]
|
|
7044
|
+
val = val.lower()
|
|
7045
|
+
if val not in ORCH_MODES:
|
|
7046
|
+
die(f"--mode must be panes or subagent, got {val!r} — {usage}")
|
|
7047
|
+
return val
|
|
7048
|
+
return None
|
|
7049
|
+
|
|
7050
|
+
|
|
7051
|
+
def pi_bin():
|
|
7052
|
+
return os.environ.get("ORCH_PI") or "pi"
|
|
7053
|
+
|
|
7054
|
+
|
|
7055
|
+
def pi_agents_dir():
|
|
7056
|
+
return Path(os.environ.get("PI_CODING_AGENT_DIR") or Path.home() / ".pi/agent") / "agents"
|
|
7057
|
+
|
|
7058
|
+
|
|
7059
|
+
PI_CODER_BODY = """You are a coder in a herdr-orchestra run. The lead gives you one milestone at a time: the path of its task file
|
|
7060
|
+
is in your prompt. Read it and build what it asks. The task says what and why; you decide how.
|
|
7061
|
+
|
|
7062
|
+
- Work only in this folder, on the branch that is checked out. Never commit, push, stash, reset or switch branches:
|
|
7063
|
+
orch saves your work when the milestone is done.
|
|
7064
|
+
- Never weaken, skip or delete tests to make the check pass.
|
|
7065
|
+
- Before you finish, run the check command named in the task file and fix what fails.
|
|
7066
|
+
- If something only the developer can decide blocks you, stop and reply `QUESTION: <the question>` with 2 or 3
|
|
7067
|
+
concrete options. Don't guess.
|
|
7068
|
+
- When the lead sends you a failing check or review findings, fix exactly those and run the check again.
|
|
7069
|
+
|
|
7070
|
+
End every reply with: the files you changed, the check result (PASS or FAIL), and one line per acceptance criterion:
|
|
7071
|
+
`AC<n>: met|not met - <evidence: a test, a command, or file:line>`.
|
|
7072
|
+
"""
|
|
7073
|
+
|
|
7074
|
+
PI_REVIEWER_BODY = """You are the reviewer in a herdr-orchestra run. The lead sends you one milestone: its task file and what changed.
|
|
7075
|
+
You never edit files. Read the task file, then the change (`git diff HEAD` and `git status --short` for new files),
|
|
7076
|
+
and the code around it.
|
|
7077
|
+
|
|
7078
|
+
Reply with one line per finding, most serious first:
|
|
7079
|
+
- `BLOCKER: <file:line> - <problem> - <why it matters> (AC<n> when it breaks a criterion)` for a bug, a broken or
|
|
7080
|
+
missing acceptance criterion, a missing test for new behaviour, or a security problem.
|
|
7081
|
+
- `SUGGESTION: <file:line> - <idea>` for something nice to have.
|
|
7082
|
+
- `NO FINDINGS` when there is nothing to report.
|
|
7083
|
+
Then one line per acceptance criterion: `AC<n>: met|not met - <evidence>`.
|
|
7084
|
+
"""
|
|
7085
|
+
|
|
7086
|
+
|
|
7087
|
+
def pi_agent_text(role, conf):
|
|
7088
|
+
"""coder.md / reviewer.md for pi-subagents: front matter from the config, then the role's instructions."""
|
|
7089
|
+
model, thinking = (conf or {}).get("model"), (conf or {}).get("thinking")
|
|
7090
|
+
desc = ("herdr-orchestra coder: builds one milestone from its task file" if role == "coder" else
|
|
7091
|
+
"herdr-orchestra reviewer: reviews one milestone, never edits files")
|
|
7092
|
+
fm = [f"name: {role}", f"description: {desc}"]
|
|
7093
|
+
if role == "reviewer":
|
|
7094
|
+
fm.append("tools: read, bash, grep, find, ls")
|
|
7095
|
+
if model:
|
|
7096
|
+
fm.append(f"model: {model}")
|
|
7097
|
+
if thinking:
|
|
7098
|
+
fm.append(f"thinking: {thinking}")
|
|
7099
|
+
fm += ["prompt_mode: append", "skills: false", "run_in_background: false"]
|
|
7100
|
+
body = PI_CODER_BODY if role == "coder" else PI_REVIEWER_BODY
|
|
7101
|
+
return "---\n" + "\n".join(fm) + "\n---\n\n" + PI_AGENT_MARK + "\n\n" + body
|
|
7102
|
+
|
|
7103
|
+
|
|
7104
|
+
def pi_setup():
|
|
7105
|
+
"""Subagent mode: write ~/.pi/agent/agents/coder.md and reviewer.md from the config, and install pi-subagents.
|
|
7106
|
+
Returns the number of problems (0 = ready)."""
|
|
7107
|
+
conf = config_load().get("subagent") or {}
|
|
7108
|
+
if not isinstance(conf, dict):
|
|
7109
|
+
conf = {}
|
|
7110
|
+
cat = models_catalog()
|
|
7111
|
+
problems = 0
|
|
7112
|
+
for role in ("coder", "reviewer"):
|
|
7113
|
+
rc = conf.get(role) if isinstance(conf.get(role), dict) else {}
|
|
7114
|
+
why = model_denied(cat, str(rc.get("model") or "").lower() or None)
|
|
7115
|
+
if why:
|
|
7116
|
+
print(f"REFUSED {role}: model {rc['model']!r} is not allowed in runs (pattern {why!r}) — pick another "
|
|
7117
|
+
f"in {short(user_config_file())}")
|
|
7118
|
+
problems += 1
|
|
7119
|
+
continue
|
|
7120
|
+
p = pi_agents_dir() / f"{role}.md"
|
|
7121
|
+
text = pi_agent_text(role, rc)
|
|
7122
|
+
if p.exists() and PI_AGENT_MARK not in p.read_text():
|
|
7123
|
+
print(f"KEPT {short(p)}: you edited it (no orch line in it), so orch leaves it alone")
|
|
7124
|
+
continue
|
|
7125
|
+
if p.exists() and p.read_text() == text:
|
|
7126
|
+
print(f"ok {short(p)}")
|
|
7127
|
+
continue
|
|
7128
|
+
p.parent.mkdir(parents=True, exist_ok=True)
|
|
7129
|
+
p.write_text(text)
|
|
7130
|
+
print(f"WROTE {short(p)} (model: {rc.get('model') or 'the same as the lead'}"
|
|
7131
|
+
+ (f", thinking: {rc['thinking']}" if rc.get("thinking") else "") + ")")
|
|
7132
|
+
pi = shutil.which(pi_bin())
|
|
7133
|
+
if not pi:
|
|
7134
|
+
print(f"NO PI `{pi_bin()}` is not on PATH. Install Pi (npm install -g @earendil-works/pi-coding-agent), "
|
|
7135
|
+
f"then run `orch setup --mode subagent` again to add pi-subagents")
|
|
7136
|
+
return problems + 1
|
|
7137
|
+
try:
|
|
7138
|
+
listed = subprocess.run([pi, "list"], text=True, capture_output=True, timeout=60)
|
|
7139
|
+
have = "@tintinweb/pi-subagents" in (listed.stdout + listed.stderr)
|
|
7140
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
7141
|
+
have = False
|
|
7142
|
+
if have:
|
|
7143
|
+
print(f"ok {PI_SUBAGENTS} is installed")
|
|
7144
|
+
return problems
|
|
7145
|
+
print(f"INSTALL {PI_SUBAGENTS} (pi install)")
|
|
7146
|
+
try:
|
|
7147
|
+
r = subprocess.run([pi, "install", PI_SUBAGENTS], text=True, capture_output=True, timeout=600)
|
|
7148
|
+
ok = r.returncode == 0
|
|
7149
|
+
out = (r.stdout + r.stderr).strip()
|
|
7150
|
+
except (OSError, subprocess.TimeoutExpired) as e:
|
|
7151
|
+
ok, out = False, str(e)
|
|
7152
|
+
if ok:
|
|
7153
|
+
print(f"INSTALLED {PI_SUBAGENTS}: restart Pi (or /reload) so it loads the Agent tool")
|
|
7154
|
+
return problems
|
|
7155
|
+
print(f"FAILED pi install {PI_SUBAGENTS}:\n" + "\n".join(out.splitlines()[-10:])
|
|
7156
|
+
+ f"\n run it yourself: pi install {PI_SUBAGENTS}")
|
|
7157
|
+
return problems + 1
|
|
7158
|
+
|
|
7159
|
+
|
|
7160
|
+
def cmd_setup(args):
|
|
7161
|
+
"""orch setup [--mode panes|subagent] -> get this machine ready for a mode (and save it with --mode)."""
|
|
7162
|
+
usage = "usage: orch setup [--mode panes|subagent]"
|
|
7163
|
+
args = list(args)
|
|
7164
|
+
flag = mode_flag(args, usage)
|
|
7165
|
+
if args:
|
|
7166
|
+
die(usage)
|
|
7167
|
+
if flag:
|
|
7168
|
+
set_mode(flag, hint=False)
|
|
7169
|
+
mode = flag or current_mode()[0]
|
|
7170
|
+
if mode == "panes":
|
|
7171
|
+
print("mode panes: nothing to set up here. Coders and the reviewer run in herdr panes; `orch team up` opens "
|
|
7172
|
+
"them when a run starts.")
|
|
7173
|
+
return
|
|
7174
|
+
sys.exit(1 if pi_setup() else 0)
|
|
7175
|
+
|
|
7176
|
+
|
|
7177
|
+
def cmd_mode(args):
|
|
7178
|
+
"""orch mode -> which mode is active and where it comes from; orch mode panes|subagent -> switch."""
|
|
7179
|
+
if not args:
|
|
7180
|
+
mode, src = current_mode()
|
|
7181
|
+
print(f"mode: {mode} ({src})")
|
|
7182
|
+
return
|
|
7183
|
+
if len(args) != 1 or args[0].lower() not in ORCH_MODES:
|
|
7184
|
+
die("usage: orch mode [panes|subagent]")
|
|
7185
|
+
set_mode(args[0].lower())
|
|
7186
|
+
|
|
7187
|
+
|
|
7188
|
+
def set_mode(mode, hint=True):
|
|
7189
|
+
"""Save the machine's mode, and switch this repo's run too when nothing in it is in progress."""
|
|
7190
|
+
c = config_load()
|
|
7191
|
+
c["mode"] = mode
|
|
7192
|
+
config_save(c)
|
|
7193
|
+
print(f"mode: {mode} (saved in {short(user_config_file())})")
|
|
7194
|
+
p = None
|
|
7195
|
+
with contextlib.suppress(Exception):
|
|
7196
|
+
p = _repo_state_path()
|
|
7197
|
+
if p:
|
|
7198
|
+
global ROOT, ORCH, STATE
|
|
7199
|
+
ROOT, ORCH, STATE = p.parent.parent, p.parent, p
|
|
7200
|
+
with state_lock():
|
|
7201
|
+
st = load()
|
|
7202
|
+
busy = [k for k, v in st["tasks"].items() if v["status"] in ACTIVE]
|
|
7203
|
+
if run_mode(st) != mode and (driver_alive() or busy):
|
|
7204
|
+
print(f"NOT CHANGED this repo's run stays {run_mode(st)}: "
|
|
7205
|
+
+ (f"{', '.join(busy)} in progress" if busy else "the event manager is running")
|
|
7206
|
+
+ ". Switch when nothing is in progress.")
|
|
7207
|
+
elif run_mode(st) != mode:
|
|
7208
|
+
st["orch_mode"] = mode
|
|
7209
|
+
save(st)
|
|
7210
|
+
print(f"this repo's run: {mode}")
|
|
7211
|
+
if mode == "subagent" and hint:
|
|
7212
|
+
missing = [r for r in ("coder", "reviewer") if not (pi_agents_dir() / f"{r}.md").exists()]
|
|
7213
|
+
if missing:
|
|
7214
|
+
print(f"NEXT run `orch setup --mode subagent`: it writes the {' and '.join(missing)} agent file(s) "
|
|
7215
|
+
f"and installs pi-subagents")
|
|
7216
|
+
|
|
7217
|
+
|
|
7218
|
+
SUBAGENT_PLAN_NOTE = """SUBAGENT MODE (Pi, one window). This replaces every herdr step below:
|
|
7219
|
+
- Skip `orch lead check` and `herdr agent ...`: no panes are used. Skip step 3 (Discover the team) and `orch team`.
|
|
7220
|
+
- Write the team exactly like this in the plan header:
|
|
7221
|
+
Lead: lead (pi)
|
|
7222
|
+
Lead mode: off
|
|
7223
|
+
Workers: coder (pi)
|
|
7224
|
+
Reviewer: reviewer (pi)
|
|
7225
|
+
Isolation: shared
|
|
7226
|
+
`coder` and `reviewer` are the Pi subagents `orch setup --mode subagent` made (~/.pi/agent/agents). They run on
|
|
7227
|
+
the models in ~/.config/herdr-orchestra/config.json, so keep each milestone's Tier and Model why as usual, and
|
|
7228
|
+
ignore `orch sync` WARNs that Workers names no model.
|
|
7229
|
+
- One milestone runs at a time (one folder). Everything else in this playbook applies.
|
|
7230
|
+
|
|
7231
|
+
"""
|
|
7232
|
+
|
|
7233
|
+
|
|
7234
|
+
def subagent_ready_or_die(st):
|
|
7235
|
+
if run_mode(st) != "subagent":
|
|
7236
|
+
die("this run is in panes mode — `orch sub` is for subagent mode (`orch mode subagent`); "
|
|
7237
|
+
"in panes mode use `orch dispatch`")
|
|
7238
|
+
if st["isolation"] != "shared":
|
|
7239
|
+
die("subagent mode works in one folder: put `Isolation: shared` in the plan header, then `orch sync`")
|
|
7240
|
+
if git("rev-parse", "--abbrev-ref", "HEAD", cwd=ROOT).stdout.strip() != st["branch"]:
|
|
7241
|
+
die(f"not on {st['branch']} — run `orch start` first")
|
|
7242
|
+
|
|
7243
|
+
|
|
7244
|
+
def cmd_check(args):
|
|
7245
|
+
"""orch check [Mn] -> run the plan's check command in the main folder: CHECK PASS / CHECK FAIL (exit 1)."""
|
|
7246
|
+
if len(args) > 1:
|
|
7247
|
+
die("usage: orch check [Mn]")
|
|
7248
|
+
st = load()
|
|
7249
|
+
if args:
|
|
7250
|
+
task(st, args[0])
|
|
7251
|
+
if not st.get("check"):
|
|
7252
|
+
print("CHECK NONE: the plan has no `Check command`")
|
|
7253
|
+
return
|
|
7254
|
+
ok, tail, secs = run_check(st, ROOT)
|
|
7255
|
+
if not driver_alive():
|
|
7256
|
+
with state_lock():
|
|
7257
|
+
st = load()
|
|
7258
|
+
note_green(st, ROOT, ok) # `orch finish` reuses a pass on exactly these files
|
|
7259
|
+
save(st)
|
|
7260
|
+
label = f" {args[0]}" if args else ""
|
|
7261
|
+
if ok:
|
|
7262
|
+
print(f"CHECK PASS{label} ({secs}s): {st['check']}")
|
|
7263
|
+
return
|
|
7264
|
+
print(f"CHECK FAIL{label} ({secs}s): {st['check']}\n" + "\n".join(tail.splitlines()[-30:]))
|
|
7265
|
+
sys.exit(1)
|
|
7266
|
+
|
|
7267
|
+
|
|
7268
|
+
def cmd_sub(args):
|
|
7269
|
+
"""orch sub next | done <Mn> -> subagent mode: the next milestone and its task file; save a finished one."""
|
|
7270
|
+
usage = "usage: orch sub next | orch sub done <Mn>"
|
|
7271
|
+
sub = args[0] if args else die(usage)
|
|
7272
|
+
st = load()
|
|
7273
|
+
subagent_ready_or_die(st)
|
|
7274
|
+
coder = next(iter(st["workers"]), None) or die("the plan has no Workers line")
|
|
7275
|
+
if sub == "next":
|
|
7276
|
+
cur = [k for k in st["order"] if st["tasks"][k]["status"] in ("coding", "verifying")]
|
|
7277
|
+
if cur:
|
|
7278
|
+
tid = cur[0]
|
|
7279
|
+
t = st["tasks"][tid]
|
|
7280
|
+
print(f"CURRENT {tid}: {t['title']} (not saved yet: finish it, then `orch sub done {tid}`)")
|
|
7281
|
+
print(f"TASK {Path(t['dir']) / TASK_DIR / tid / 'task.md'}")
|
|
7282
|
+
print(f"REVIEW {'yes' if t.get('review') else 'no'}")
|
|
7283
|
+
return
|
|
7284
|
+
held = [k for k in st["order"] if st["tasks"][k]["status"] == "held"]
|
|
7285
|
+
ready = [k for k in st["order"] if st["tasks"][k]["status"] == "pending" and deps_met(st, st["tasks"][k])]
|
|
7286
|
+
if not ready:
|
|
7287
|
+
left = {k: v["status"] for k, v in st["tasks"].items() if v["status"] not in ("merged", "skipped")}
|
|
7288
|
+
if not left:
|
|
7289
|
+
print(f"ALL_DONE every milestone is saved on {st['branch']}")
|
|
7290
|
+
return
|
|
7291
|
+
if held:
|
|
7292
|
+
print("HELD " + ", ".join(held) + ": risky changes wait for the developer (`orch status` shows why; "
|
|
7293
|
+
"they run `orch approve <Mn>`, then `orch sub done <Mn>`)")
|
|
7294
|
+
print("WAITING " + ", ".join(f"{k} ({s})" for k, s in left.items() if k not in held)
|
|
7295
|
+
+ " — nothing is ready to start")
|
|
7296
|
+
sys.exit(3)
|
|
7297
|
+
tid = ready[0]
|
|
7298
|
+
if is_dirty(ROOT):
|
|
7299
|
+
die("the folder has uncommitted changes that no milestone owns — commit, stash or discard them first")
|
|
7300
|
+
cmd_prepare([tid, coder])
|
|
7301
|
+
cmd_write_task([tid])
|
|
7302
|
+
st = load()
|
|
7303
|
+
t = st["tasks"][tid]
|
|
7304
|
+
print(f"NEXT {tid}: {t['title']}")
|
|
7305
|
+
print(f"TASK {Path(t['dir']) / TASK_DIR / tid / 'task.md'}")
|
|
7306
|
+
print(f"REVIEW {'yes' if t.get('review') else 'no'}")
|
|
7307
|
+
return
|
|
7308
|
+
if sub == "done":
|
|
7309
|
+
need(args, 2, "sub done <Mn>")
|
|
7310
|
+
tid = args[1]
|
|
7311
|
+
t = task(st, tid)
|
|
7312
|
+
if t["status"] == "merged":
|
|
7313
|
+
print(f"MERGED {tid} (already saved)")
|
|
7314
|
+
return
|
|
7315
|
+
if t["status"] == "coding":
|
|
7316
|
+
move(st, tid, "verifying")
|
|
7317
|
+
save(st)
|
|
7318
|
+
elif t["status"] not in ("verifying", "committed"):
|
|
7319
|
+
die(f"{tid} is {t['status']}: only a milestone from `orch sub next` can be saved"
|
|
7320
|
+
+ (" (the developer runs `orch approve` first)" if t["status"] == "held" else ""))
|
|
7321
|
+
story_note(st, f"{tid} saved by the subagent run")
|
|
7322
|
+
save(st)
|
|
7323
|
+
cmd_commit([tid])
|
|
7324
|
+
st = load()
|
|
7325
|
+
left = [k for k, v in st["tasks"].items() if v["status"] not in ("merged", "skipped")]
|
|
7326
|
+
print("ALL_DONE every milestone is saved; write the summary, then the developer runs `orch finish`"
|
|
7327
|
+
if not left else "NEXT run `orch sub next`")
|
|
7328
|
+
return
|
|
7329
|
+
die(usage)
|
|
7330
|
+
|
|
7331
|
+
|
|
6945
7332
|
def cmd_config(args):
|
|
6946
7333
|
"""orch config -> this machine's settings; orch config auto-update on|off."""
|
|
6947
7334
|
if args[:1] == ["auto-update"] and args[1:2] and args[1].lower() in ("on", "off"):
|
|
@@ -7026,7 +7413,8 @@ if __name__ == "__main__":
|
|
|
7026
7413
|
update_notice()
|
|
7027
7414
|
sys.exit(0)
|
|
7028
7415
|
NO_REPO_COMMANDS = {"lead": cmd_lead, "agents": cmd_agents, "doctor": cmd_doctor, "models": cmd_models,
|
|
7029
|
-
"team": cmd_team, "update": cmd_update, "config": cmd_config
|
|
7416
|
+
"team": cmd_team, "update": cmd_update, "config": cmd_config, "mode": cmd_mode,
|
|
7417
|
+
"setup": cmd_setup}
|
|
7030
7418
|
if (len(sys.argv) >= 2 and sys.argv[1] in NO_REPO_COMMANDS # work outside a git repo
|
|
7031
7419
|
and sys.argv[2:3] != ["up"] and sys.argv[2:3] != ["--crash"]): # (`orch team up` reads the run's state)
|
|
7032
7420
|
try:
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// herdr-orchestra for Pi (https://pi.dev): shows which orch mode this window is in and lets you switch it.
|
|
2
|
+
//
|
|
3
|
+
// panes (default) coders and the reviewer run in herdr panes; the lead uses `orch dispatch`
|
|
4
|
+
// subagent one Pi window: the lead starts the coder and the reviewer as Pi subagents (@tintinweb/pi-subagents)
|
|
5
|
+
//
|
|
6
|
+
// Only Pi loads this file (package.json "pi".extensions). Claude Code, Codex, OpenCode and the other agents never
|
|
7
|
+
// read it, and `npx herdr-orchestra` ignores it.
|
|
8
|
+
//
|
|
9
|
+
// Where the mode comes from: this repo's run (.orchestrate/state.json, `orch_mode`; a run from before 6.2.0 is
|
|
10
|
+
// panes), else ~/.config/herdr-orchestra/config.json (`mode`), else panes.
|
|
11
|
+
//
|
|
12
|
+
// Commands: /orch-mode [panes|subagent] show or switch the mode
|
|
13
|
+
// /orch-setup install the `orch` command from this package (needed once)
|
|
14
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import { dirname, join, resolve } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
type Mode = "panes" | "subagent";
|
|
21
|
+
const MODES: Mode[] = ["panes", "subagent"];
|
|
22
|
+
const STATUS_KEY = "orch";
|
|
23
|
+
|
|
24
|
+
function packageRoot(): string {
|
|
25
|
+
const here = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
return resolve(here, "..");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function configFile(): string {
|
|
30
|
+
return process.env.ORCH_CONFIG_FILE || join(homedir(), ".config", "herdr-orchestra", "config.json");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readJson(path: string): Record<string, unknown> | undefined {
|
|
34
|
+
try {
|
|
35
|
+
const data = JSON.parse(readFileSync(path, "utf8"));
|
|
36
|
+
return data && typeof data === "object" && !Array.isArray(data) ? data : undefined;
|
|
37
|
+
} catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function asMode(value: unknown): Mode | undefined {
|
|
43
|
+
return typeof value === "string" && (MODES as string[]).includes(value.toLowerCase())
|
|
44
|
+
? (value.toLowerCase() as Mode)
|
|
45
|
+
: undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** .orchestrate/state.json of the repo that holds cwd (orch keeps it in the main checkout, not in worktrees). */
|
|
49
|
+
async function stateFile(pi: ExtensionAPI, cwd: string): Promise<string | undefined> {
|
|
50
|
+
try {
|
|
51
|
+
const r = await pi.exec("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd, timeout: 5000 });
|
|
52
|
+
if (r.code === 0 && r.stdout.trim()) {
|
|
53
|
+
const p = join(dirname(r.stdout.trim()), ".orchestrate", "state.json");
|
|
54
|
+
return existsSync(p) ? p : undefined;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
// not a git repo, or no git: no run here
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function readMode(pi: ExtensionAPI, cwd: string): Promise<{ mode: Mode; from: string }> {
|
|
63
|
+
const state = await stateFile(pi, cwd);
|
|
64
|
+
if (state) {
|
|
65
|
+
const st = readJson(state);
|
|
66
|
+
if (st) return { mode: asMode(st.orch_mode) ?? "panes", from: "this repo's run" };
|
|
67
|
+
}
|
|
68
|
+
const saved = asMode(readJson(configFile())?.mode);
|
|
69
|
+
return saved ? { mode: saved, from: configFile() } : { mode: "panes", from: "default" };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function saveConfigMode(mode: Mode): void {
|
|
73
|
+
const path = configFile();
|
|
74
|
+
const data = readJson(path) ?? {};
|
|
75
|
+
data.mode = mode;
|
|
76
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
77
|
+
writeFileSync(path + ".tmp", JSON.stringify(data, null, 2) + "\n");
|
|
78
|
+
renameSync(path + ".tmp", path);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function orchCommand(pi: ExtensionAPI): Promise<string | undefined> {
|
|
82
|
+
const r = await pi.exec("sh", ["-c", 'command -v orch || { test -x "$HOME/.local/bin/orch" && echo "$HOME/.local/bin/orch"; }'], {
|
|
83
|
+
timeout: 5000,
|
|
84
|
+
});
|
|
85
|
+
const path = r.stdout.trim().split("\n")[0];
|
|
86
|
+
return r.code === 0 && path ? path : undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function packageVersion(): string | undefined {
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(readFileSync(join(packageRoot(), "package.json"), "utf8")).version;
|
|
92
|
+
} catch {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** "6.1.0" or "6.2.0-dev" -> [6, 1, 0]; undefined when it is not a version. */
|
|
98
|
+
function parseVersion(text: string | undefined): number[] | undefined {
|
|
99
|
+
const m = /(\d+)\.(\d+)\.(\d+)/.exec(text ?? "");
|
|
100
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function olderThan(a: number[], b: number[]): boolean {
|
|
104
|
+
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] < b[i];
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** What orch is on this machine: missing, older than this package (an old install next to a new Pi package, which
|
|
109
|
+
* has no `orch mode` yet), or ok. */
|
|
110
|
+
async function orchState(pi: ExtensionAPI): Promise<{ state: "missing" | "old" | "ok"; path?: string; version?: string }> {
|
|
111
|
+
const path = await orchCommand(pi);
|
|
112
|
+
if (!path) return { state: "missing" };
|
|
113
|
+
const r = await pi.exec(path, ["version"], { timeout: 10000 });
|
|
114
|
+
const have = parseVersion(r.stdout);
|
|
115
|
+
const want = parseVersion(packageVersion());
|
|
116
|
+
const version = have?.join(".");
|
|
117
|
+
if (r.code !== 0 || !have || (want && olderThan(have, want))) return { state: "old", path, version };
|
|
118
|
+
return { state: "ok", path, version };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function showStatus(ctx: ExtensionContext, mode: Mode): void {
|
|
122
|
+
ctx.ui.setStatus(STATUS_KEY, `orch: ${mode}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default function orchMode(pi: ExtensionAPI) {
|
|
126
|
+
let mode: Mode = "panes";
|
|
127
|
+
|
|
128
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
129
|
+
mode = (await readMode(pi, ctx.cwd)).mode;
|
|
130
|
+
showStatus(ctx, mode);
|
|
131
|
+
const o = await orchState(pi);
|
|
132
|
+
if (o.state === "missing") {
|
|
133
|
+
ctx.ui.notify("herdr-orchestra: the `orch` command is not installed yet. Type /orch-setup once to install it.", "warning");
|
|
134
|
+
} else if (o.state === "old") {
|
|
135
|
+
ctx.ui.notify(
|
|
136
|
+
`herdr-orchestra: this Pi package is ${packageVersion() ?? "newer"} but the orch command on this machine is ${o.version ?? "older"}, which does not know the modes. Type /orch-setup to update it.`,
|
|
137
|
+
"warning",
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Pi knows the mode on every turn. Worded for anyone who reads it (a coder subagent loads this extension too).
|
|
143
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
144
|
+
mode = (await readMode(pi, ctx.cwd)).mode;
|
|
145
|
+
const line =
|
|
146
|
+
mode === "subagent"
|
|
147
|
+
? "herdr-orchestra (orch) mode: subagent. When you lead an orch run, the coder and the reviewer are Pi subagents (the Agent tool), not herdr panes; `orch lead run` prints the steps."
|
|
148
|
+
: "herdr-orchestra (orch) mode: panes. When you lead an orch run, coders and the reviewer run in herdr panes; `orch lead run` prints the steps.";
|
|
149
|
+
return { systemPrompt: `${event.systemPrompt}\n\n${line}` };
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
pi.registerCommand("orch-mode", {
|
|
153
|
+
description: "Show or switch the herdr-orchestra mode: panes (herdr panes) or subagent (one Pi window)",
|
|
154
|
+
getArgumentCompletions: (prefix: string) =>
|
|
155
|
+
MODES.filter((m) => m.startsWith(prefix.trim().toLowerCase())).map((m) => ({ value: m, label: m })),
|
|
156
|
+
handler: async (args, ctx) => {
|
|
157
|
+
const want = args.trim().toLowerCase();
|
|
158
|
+
if (!want) {
|
|
159
|
+
const cur = await readMode(pi, ctx.cwd);
|
|
160
|
+
mode = cur.mode;
|
|
161
|
+
showStatus(ctx, mode);
|
|
162
|
+
ctx.ui.notify(`orch mode: ${cur.mode} (${cur.from}). Switch with /orch-mode panes or /orch-mode subagent.`, "info");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const next = asMode(want);
|
|
166
|
+
if (!next) {
|
|
167
|
+
ctx.ui.notify(`Unknown mode "${want}". Use /orch-mode panes or /orch-mode subagent.`, "error");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const o = await orchState(pi);
|
|
171
|
+
const orch = o.state === "ok" ? o.path : undefined;
|
|
172
|
+
if (orch) {
|
|
173
|
+
// `orch mode` saves the machine's default and, when nothing is in progress, this repo's run too
|
|
174
|
+
const r = await pi.exec(orch, ["mode", next], { cwd: ctx.cwd, timeout: 30000 });
|
|
175
|
+
const out = (r.stdout + r.stderr).trim();
|
|
176
|
+
if (r.code !== 0) {
|
|
177
|
+
ctx.ui.notify(out || `orch mode ${next} failed`, "error");
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
ctx.ui.notify(out, "info");
|
|
181
|
+
} else {
|
|
182
|
+
saveConfigMode(next);
|
|
183
|
+
ctx.ui.notify(
|
|
184
|
+
`orch mode: ${next} (saved in ${configFile()}). ` +
|
|
185
|
+
(o.state === "old" ? `The orch command here is ${o.version ?? "older"} and does not know the modes yet: ` : "") +
|
|
186
|
+
"Type /orch-setup to install the orch command.",
|
|
187
|
+
"info",
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const now = await readMode(pi, ctx.cwd);
|
|
191
|
+
mode = now.mode;
|
|
192
|
+
showStatus(ctx, mode);
|
|
193
|
+
if (now.mode !== next) {
|
|
194
|
+
ctx.ui.notify(`This repo's run stays ${now.mode} (${orch ? "something is in progress" : "switch it with /orch-mode after /orch-setup"}). New runs use ${next}.`, "warning");
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
pi.registerCommand("orch-setup", {
|
|
200
|
+
description: "Install the herdr-orchestra `orch` command from this package (and, in subagent mode, its Pi subagents)",
|
|
201
|
+
handler: async (_args, ctx) => {
|
|
202
|
+
const installer = join(packageRoot(), "install.sh");
|
|
203
|
+
if (!existsSync(installer)) {
|
|
204
|
+
ctx.ui.notify(`install.sh not found next to this extension (${installer}). Run: npx herdr-orchestra@latest`, "error");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const cur = await readMode(pi, ctx.cwd);
|
|
208
|
+
ctx.ui.notify("Installing herdr-orchestra (orch)...", "info");
|
|
209
|
+
// ORCH_TTY=/dev/null: the installer must not read Pi's terminal. An unanswered auto-update question gets the
|
|
210
|
+
// installer's default (on); the output says how to turn it off (`orch config auto-update off`).
|
|
211
|
+
const args = ["ORCH_PACKAGE=1", "ORCH_TTY=/dev/null", "bash", installer, ...(cur.mode === "subagent" ? ["--mode", "subagent"] : [])];
|
|
212
|
+
const r = await pi.exec("env", args, { cwd: ctx.cwd, timeout: 600000 });
|
|
213
|
+
const tail = (r.stdout + r.stderr)
|
|
214
|
+
.replace(/\x1b\[[0-9;]*m/g, "")
|
|
215
|
+
.split("\n")
|
|
216
|
+
.filter((l) => /^(==>|warn:|error:)|auto-update|is active/.test(l.trim()))
|
|
217
|
+
.slice(-12)
|
|
218
|
+
.join("\n");
|
|
219
|
+
ctx.ui.notify(tail || (r.code === 0 ? "Installed." : "The installer failed."), r.code === 0 ? "info" : "error");
|
|
220
|
+
mode = (await readMode(pi, ctx.cwd)).mode;
|
|
221
|
+
showStatus(ctx, mode);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
package/install.sh
CHANGED
|
@@ -42,6 +42,8 @@ Options:
|
|
|
42
42
|
--no-herdr-skill don't install/refresh the official herdr skill via npx
|
|
43
43
|
--auto-update keep herdr-orchestra up to date automatically (no question asked)
|
|
44
44
|
--no-auto-update never update by itself (also: ORCH_AUTO_UPDATE=1 or 0)
|
|
45
|
+
--mode <panes|subagent> save the mode runs use (default panes); subagent also sets up Pi's coder and
|
|
46
|
+
reviewer subagents (same as: orch setup --mode subagent)
|
|
45
47
|
-h, --help this help
|
|
46
48
|
EOF
|
|
47
49
|
}
|
|
@@ -57,6 +59,8 @@ while [[ $# -gt 0 ]]; do
|
|
|
57
59
|
--no-herdr-skill) HERDR_SKILL=0; shift;;
|
|
58
60
|
--auto-update) AUTO_UPDATE=1; shift;;
|
|
59
61
|
--no-auto-update) AUTO_UPDATE=0; shift;;
|
|
62
|
+
--mode) MODE_ARG="${2:?--mode needs panes or subagent}"; shift 2;;
|
|
63
|
+
--mode=*) MODE_ARG="${1#*=}"; shift;;
|
|
60
64
|
-h|--help) usage; exit 0;;
|
|
61
65
|
*) die "unknown option: $1 (see --help)";;
|
|
62
66
|
esac
|
|
@@ -266,6 +270,10 @@ fi
|
|
|
266
270
|
|
|
267
271
|
case ":$PATH:" in *":$BIN:"*) ;; *) warn "$BIN is not on your PATH — add: export PATH=\"\$HOME/.local/bin:\$PATH\"";; esac
|
|
268
272
|
|
|
273
|
+
if [[ -n "${MODE_ARG:-}" ]]; then
|
|
274
|
+
"$BIN/orch" setup --mode "$MODE_ARG" || warn "orch setup --mode $MODE_ARG did not finish — run it again after fixing what it says"
|
|
275
|
+
fi
|
|
276
|
+
|
|
269
277
|
say "herdr-orchestra $VER is active"
|
|
270
278
|
cat <<'MSG'
|
|
271
279
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "herdr-orchestra",
|
|
3
|
-
"version": "6.
|
|
4
|
-
"description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp) as one team
|
|
3
|
+
"version": "6.2.1",
|
|
4
|
+
"description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp, Pi) as one team: a lead plans, coders build, a reviewer checks, you get one PR. Runs in Herdr panes, or in one Pi window with subagents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"herdr-orchestra": "npm/cli.js"
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"opencode-commands",
|
|
15
15
|
"claude-commands",
|
|
16
16
|
"playbooks",
|
|
17
|
+
"extensions",
|
|
18
|
+
"pi",
|
|
17
19
|
"agents.default.toml",
|
|
18
20
|
"models.default.toml",
|
|
19
21
|
"VERSION",
|
|
@@ -44,13 +46,34 @@
|
|
|
44
46
|
"amp",
|
|
45
47
|
"llm",
|
|
46
48
|
"cli",
|
|
47
|
-
"developer-tools"
|
|
49
|
+
"developer-tools",
|
|
50
|
+
"pi-package",
|
|
51
|
+
"pi",
|
|
52
|
+
"pi-coding-agent",
|
|
53
|
+
"subagents"
|
|
48
54
|
],
|
|
55
|
+
"pi": {
|
|
56
|
+
"skills": [
|
|
57
|
+
"./pi/skills/orch-plan",
|
|
58
|
+
"./skills/orch-run"
|
|
59
|
+
],
|
|
60
|
+
"extensions": [
|
|
61
|
+
"./extensions/orch-mode.ts"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
49
64
|
"engines": {
|
|
50
65
|
"node": ">=16"
|
|
51
66
|
},
|
|
52
67
|
"publishConfig": {
|
|
53
68
|
"access": "public"
|
|
54
69
|
},
|
|
55
|
-
"author": "arunnarangali (https://github.com/arunnarangali)"
|
|
70
|
+
"author": "arunnarangali (https://github.com/arunnarangali)",
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@earendil-works/pi-coding-agent": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
56
79
|
}
|
package/pi/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Pi-only copies of the orch skills, loaded through package.json `"pi".skills`.
|
|
2
|
+
|
|
3
|
+
`skills/orch-plan/SKILL.md` has a `description:` with `: ` inside it, which strict YAML parsers (Pi's) reject, so
|
|
4
|
+
Pi would skip the skill. This copy has the same text with the description in quotes. Every other agent keeps using
|
|
5
|
+
`skills/orch-plan/SKILL.md`, unchanged. `tests/run.sh` checks that the two say the same thing.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orch-plan
|
|
3
|
+
description: "Orchestrator step 1 for a Herdr multi-agent team (any agent can lead; Claude, Codex, Amp, OpenCode, Hermes or Antigravity coders; optional reviewer). Use when the user asks to plan or orchestrate a feature, or says \"orch-plan\". Research the codebase, then write a dependency-aware plan with as many milestones as the feature needs, written as issues (what and why, never how), each with the model tier it needs (small, medium, high) and why. A small, clear change (UI or backend) gets a short quick-run plan instead: one milestone, one coder, no reviewer; start the request with quick: or full: to choose. Does NOT execute until the developer says go."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Run `orch lead plan` (or `~/.local/bin/orch lead plan` if `orch` is not on PATH) and follow its output exactly. You are the lead. The user's message is the feature request.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
You are the LEAD of a herdr-orchestra run in **subagent mode**: you stay in this one Pi window, and the coder and the reviewer are Pi subagents (the `Agent` tool from pi-subagents). All bookkeeping goes through `orch` (`~/.local/bin/orch` — use the full path if `orch` is not on PATH). Trust its output over your memory: it owns task states, the check, commits and the final PR.
|
|
2
|
+
Extra user input = whatever the user wrote alongside asking you to run this playbook (a go-ahead, answers, overrides, or nothing).
|
|
3
|
+
|
|
4
|
+
## How a run works in subagent mode
|
|
5
|
+
There is no event manager and there are no herdr panes. You drive one milestone at a time, in this folder:
|
|
6
|
+
`orch sub next` → coder subagent → `orch check` → reviewer subagent (when the milestone has `Review: yes`) → `orch sub done` → the next milestone. When every milestone is saved: the summary, then `orch finish` when the developer says so.
|
|
7
|
+
|
|
8
|
+
## Hard rules
|
|
9
|
+
0. **Roles: you decide what and why; the coder decides how.** Your prompts to the coder name the task file, the failing check output or the review findings: problems and goals, never solutions.
|
|
10
|
+
1. You NEVER edit application code yourself. You only run `orch`, read its files, start subagents, and edit `.orchestrate/plan.md` (answers, notes, tiers, the check command).
|
|
11
|
+
2. Never guess. A question only the developer can settle goes to the developer, with 2–3 concrete options. Answer the coder's question yourself only when the feature request, the plan or the code already settles it; say where the answer comes from.
|
|
12
|
+
3. Never approve a held milestone yourself (`orch approve` is the developer's call). Never `git commit`, `git stash` or `git reset` yourself: `orch sub done` saves the work.
|
|
13
|
+
4. Never skip the check, and never ask the coder to weaken or skip tests.
|
|
14
|
+
5. After each milestone, write one short line in your chat in plain words: what landed, what the check and the review said, what starts next. Example: `M1 (Model) is saved on the branch: check PASS, review found nothing. Starting M2 (Endpoint).`
|
|
15
|
+
|
|
16
|
+
## 1. Start the run (the developer said go)
|
|
17
|
+
1. Run `orch sync`. Stop on ERROR; report every WARN except the ones about Workers naming no model (the subagents run on the models in `~/.config/herdr-orchestra/config.json`).
|
|
18
|
+
2. Run `orch start` (it makes or switches to the feature branch).
|
|
19
|
+
3. Check that the `Agent` tool is available to you. If it is not, tell the developer to run `orch setup --mode subagent` and restart Pi, and **STOP**.
|
|
20
|
+
|
|
21
|
+
## 2. One milestone
|
|
22
|
+
1. Run `orch sub next`. It prints `NEXT Mn: <title>`, `TASK <path to task.md>` and `REVIEW yes|no`. (`CURRENT Mn` means a milestone was started and not saved: carry on with it from step 2. `HELD`, `WAITING` or `ALL_DONE`: see below.)
|
|
23
|
+
2. **Coder.** Call the `Agent` tool: `subagent_type: "coder"`, `description: "Mn <short title>"`, `run_in_background: false`, and a prompt like `Build milestone Mn. Read the task file <TASK path> and follow it. The check command is: <check command>. There is no result file or done file in this run: put your report in your reply.`
|
|
24
|
+
- If the coder replies `QUESTION: ...`: answer it from the plan or the code (say where the answer comes from), or ask the developer with 2–3 options and **STOP**. Write the answer under that milestone's "Notes from user" in `.orchestrate/plan.md`, then send it to the same coder with the `Agent` tool's `resume` (its agent id), so it carries on from its work.
|
|
25
|
+
3. **Check.** Run `orch check Mn`. On `CHECK FAIL`, resume the same coder with the failing output (the last lines `orch check` printed) and ask it to fix the cause. Run `orch check Mn` again. At most 3 fix rounds; after that, run `orch set Mn failed "<what keeps failing>"`, explain it to the developer in two lines, and **STOP**.
|
|
26
|
+
4. **Review** (only when `REVIEW yes`). Call the `Agent` tool: `subagent_type: "reviewer"`, `run_in_background: false`, prompt `Review milestone Mn. Task file: <TASK path>. Look at the change with git diff HEAD and git status --short.` Each `BLOCKER:` line goes back to the same coder (resume it with those lines only), then `orch check Mn` again, then one more review. At most 2 review rounds; blockers still left after that: `orch set Mn failed "<the blockers>"`, tell the developer, **STOP**. `SUGGESTION:` lines do not block: keep them for the summary.
|
|
27
|
+
5. **Save.** Run `orch sub done Mn`. `MERGED Mn` means it is committed on the feature branch. `HELD Mn` (exit 7) means risky changes (deleted files, migrations, CI config, secrets files, unlisted dependency changes, a very large diff) wait for the developer: show the reasons from `orch status`, tell them to look and run `orch approve Mn`, and **STOP**; after their approval run `orch sub done Mn` again.
|
|
28
|
+
6. Write your one line in the chat (hard rule 5), and go back to step 1 for the next milestone.
|
|
29
|
+
|
|
30
|
+
`orch sub next` printing `WAITING` means nothing is ready (a milestone is paused, failed or needs an answer): tell the developer which and why (`orch status`), and **STOP**. When it is sorted out, `orch set Mn pending` and carry on.
|
|
31
|
+
|
|
32
|
+
**The developer asks for a change after a milestone was saved** (for example "the login button should be blue"): do not plan again. Add one small follow-up milestone to `.orchestrate/plan.md` (same format, `Depends on: Mn (what it changes)`, the change in the developer's words), run `orch sync`, and run it with section 2. (`orch fix` and `orch dispatch` are for panes mode: they need the event manager.)
|
|
33
|
+
|
|
34
|
+
## 3. ALL_DONE (`orch sub next` or `orch sub done` prints it)
|
|
35
|
+
1. Write `.orchestrate/summary.md` for the developer, short:
|
|
36
|
+
- **Tasks**: one line per milestone, what it does now.
|
|
37
|
+
- **Checked**: the final `orch check` result, each review, and one line per acceptance criterion with its evidence (a test, a command, or `file:line`). Run a command or read the code to settle anything you can.
|
|
38
|
+
- **Reviewer suggestions not applied.**
|
|
39
|
+
- **Manual verification checklist**: ONLY what a person must see or do (how the UI looks, a click-through in a real browser, a real email arriving). For a backend-only change write `Nothing to check by hand: <why>`.
|
|
40
|
+
2. Tell the developer: "All milestones are saved on <branch>. Review .orchestrate/summary.md. Then run `orch finish`: it re-runs the check (or reuses it), pushes <branch> and opens a PR (`orch finish --no-push` to only clean up)." Run `orch finish` yourself only when the developer says so: it pushes. Never add a "Generated with …", `Co-Authored-By` or session line to a commit or a PR of the run: they are the developer's. **STOP.**
|
|
Binary file
|