herdr-orchestra 6.3.0 → 6.5.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/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.5.0] - 2026-11-22
6
+
7
+ Subagent mode is now set up from inside Pi with one slash command. Before, `/orch-mode subagent` only saved the mode and printed `NEXT run orch setup --mode subagent`, which you had to run in a separate, normal terminal. Now the slash command does that work itself.
8
+
9
+ Example: in Pi you type `/orch-mode subagent`. Pi shows
10
+
11
+ ```
12
+ mode: subagent (saved in ~/.config/herdr-orchestra/config.json)
13
+ WROTE ~/.pi/agent/agents/coder.md (model: the same as the lead)
14
+ WROTE ~/.pi/agent/agents/reviewer.md (model: the same as the lead)
15
+ INSTALLED npm:@tintinweb/pi-subagents: ...
16
+ Done: subagent mode is ready. Plan with /orch-plan as usual.
17
+ ```
18
+
19
+ then reloads itself so the `Agent` tool is there. Type `/orch-plan` next. No terminal needed.
20
+
21
+ ### Changed
22
+ - **`/orch-mode subagent` sets subagent mode up.** It runs `orch setup --mode subagent` (saves the mode, writes the coder and reviewer agent files, runs `pi install npm:@tintinweb/pi-subagents`). When the `orch` command is missing or older than the Pi package, it runs this package's installer with `--mode subagent` instead, which does the same after installing `orch`. When pi-subagents was just installed, Pi reloads by itself (`ctx.reload()`), so there is no restart either. If a step fails (no `pi` on PATH, a model the policy denies), it says what failed and to type `/orch-mode subagent` again after fixing it. `/orch-mode panes` is unchanged.
23
+ - **`/orch-setup --mode subagent`** (or `/orch-setup subagent`) installs `orch` and sets subagent mode up in one go. `/orch-setup` alone still installs `orch` and, when the saved mode is subagent, sets it up too.
24
+ - The terminal stays supported: `orch setup --mode subagent` works as before; its `NEXT` and `INSTALLED` lines now mention the Pi slash command. The subagent playbook tells the lead to point the developer at `/orch-mode subagent` when the `Agent` tool is missing.
25
+
26
+ ## [6.4.0] - 2026-11-21
27
+
28
+ At the end of a run, the things you should try by hand now come to you as a plain numbered list: `orch finish` prints them, and the lead posts them in its chat. Nothing else changes: the lead writes the same "Manual verification checklist" in the summary as before, and orch reads it from there.
29
+
30
+ Example: you run `orch finish` in a terminal. It ends with
31
+
32
+ ```
33
+ MANUAL TESTS: 2 to try by hand before you merge (from the summary's Manual verification checklist):
34
+ 1. Open /settings, click Save → a green "Saved" note appears
35
+ 2. Open /settings on a phone → the form fits the screen
36
+ ```
37
+
38
+ and the lead's chat shows "Try these by hand before you merge:" with the same two lines, next to the PR link.
39
+
40
+ ### Added
41
+ - **Manual tests at `orch finish`.** It reads the summary's "Manual verification checklist" (any heading level, or a bold line) and prints it as a numbered list after the push and PR lines, also with `--no-push`. It says so when the lead wrote `Nothing to check by hand: <why>`, and when the checklist is not written yet. The list is also saved in `.orchestrate/manual-tests.md`.
42
+ - **`orch manual`** prints the same list again, at any time (also while the event manager runs).
43
+ - **`FINISHED` lead event.** With a lead in the run, `orch finish` queues `FINISHED` (pushed or not, the PR link, how many manual tests) and wakes the lead. `orch events` prints the list under it, and the playbook row tells the lead to post it in its chat, numbered and word for word. When the lead ran `orch finish` itself (from its own pane), it is not woken: the output tells it to post the list. In a subagent run the output tells the lead the same.
44
+
45
+ ### Changed
46
+ - **ALL_DONE:** the lead now lists the manual checklist items themselves in its chat (it used to give only how many there are), so you can try them before you run `orch finish`. Same in subagent runs.
5
47
  ## [6.3.0] - 2026-11-21
6
48
 
7
49
  Moving a milestone away from a coder now really stops that coder. Before, `orch set M7 paused` only typed a STOP note into the coder's pane and marked the coder free at once. An agent in the middle of a step (agy, for example) only reads a typed message after that step, so it kept editing files while `orch status` showed it as free, and it could be handed the next milestone.
package/README.md CHANGED
@@ -152,7 +152,7 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
152
152
  You can also start the event manager yourself: `orch autopilot` in a spare terminal. It is the only driver of a run: while it runs, other `orch` commands that would change the run are refused (`orch status`, `orch report`, `orch approve` and the lead's `orch events` / `orch dispatch` / `orch answer` still work).
153
153
  After each wake-up the lead says in its chat what happened and what it did, one plain line per event; `orch story` keeps the whole run as a diary, and `orch plan show` gives the plan as one short card per milestone.
154
154
  4. **If the lead is away** (its pane is closed, or it never reads its events): nothing is lost, the events wait in the queue. Ready work starts by itself after 15 minutes, you get a desktop notification, and `orch events --peek` shows what is open. With `Lead mode: off` in the plan header there is no lead in the run at all: `orch autopilot` dispatches by itself and stops (exit 3) when it needs you.
155
- 5. **When it's done:** read `.orchestrate/summary.md` and do its manual checklist. It holds only what needs your eyes or hands (how the UI looks and behaves, a real device); whatever a command or a look at the code can settle, the run and the lead have already checked and listed with the evidence. Want a change? Tell the lead (for example "the login button should be blue"). It runs `orch fix M1 "the login button should be blue"`: one small follow-up job goes straight to the coder who built M1, with the check and review as before, and no new plan. You can run `orch fix` yourself too. When you are happy, run `orch finish`. It re-runs the check (or reuses it when it already passed on exactly these files; `--recheck` runs it anyway), removes the coders' worktrees and the `../<repo>-wt` folder (a coder folder with changes no milestone has is kept and named), pushes `feature/<name>` and opens a PR into `main` (with `gh`, or prints the compare link).
155
+ 5. **When it's done:** read `.orchestrate/summary.md` and do its manual checklist. It holds only what needs your eyes or hands (how the UI looks and behaves, a real device); whatever a command or a look at the code can settle, the run and the lead have already checked and listed with the evidence. Want a change? Tell the lead (for example "the login button should be blue"). It runs `orch fix M1 "the login button should be blue"`: one small follow-up job goes straight to the coder who built M1, with the check and review as before, and no new plan. You can run `orch fix` yourself too. When you are happy, run `orch finish`. It re-runs the check (or reuses it when it already passed on exactly these files; `--recheck` runs it anyway), removes the coders' worktrees and the `../<repo>-wt` folder (a coder folder with changes no milestone has is kept and named), pushes `feature/<name>` and opens a PR into `main` (with `gh`, or prints the compare link). Last, it prints the manual tests as a numbered list (`orch manual` prints them again), and the lead posts the same list in its chat.
156
156
 
157
157
  ### Git: one branch per run, real commits, one PR
158
158
  Planning touches no git at all. `orch start` creates the plan's `Branch:` (`feature/<slug>`) and that is the only branch a run makes: coders work on detached worktrees, and a milestone's work in progress (under review, parked, waiting for a fix) lives in hidden refs under `refs/orch/`, which `git branch` doesn't list and `git push` doesn't send. Each milestone lands as **one commit whose message says what changed** (the coder's `COMMIT:` line, e.g. `feat(api): add categories endpoint`, with a `Milestone: M2` trailer). `Commits: single` in the plan header squashes the run into one commit at finish.
@@ -265,13 +265,15 @@ Runs have two modes. Nothing changes for anyone who never picks the second one.
265
265
  | `panes` (default) | herdr panes, as described above | the event manager; the lead dispatches and pauses |
266
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
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:
268
+ Switch with `/orch-mode subagent` in Pi; `/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.
269
+
270
+ `/orch-mode subagent` also sets subagent mode up, right there in Pi, with no terminal step: it installs the `orch` command if it is missing or old, writes the coder and reviewer agents, installs pi-subagents, and reloads Pi so the `Agent` tool is ready. It ends with `Done: subagent mode is ready.` `/orch-setup --mode subagent` does the same. From a normal terminal (no Pi open), the same setup is:
269
271
 
270
272
  ```bash
271
273
  orch setup --mode subagent # or: npx herdr-orchestra@latest --mode subagent, or orch team up --mode subagent
272
274
  ```
273
275
 
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.
276
+ Setup 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
277
 
276
278
  ```json
277
279
  {
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.3.0
1
+ 6.5.0
@@ -119,4 +119,4 @@ skills_dirs = ["~/.agents/skills"]
119
119
  skills_reads = ["~/.pi/agent/skills", "~/.agents/skills"]
120
120
  invoke = "/skill:orch-plan <feature>"
121
121
  verified = false
122
- 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`."
122
+ 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-mode subagent` in Pi sets it up (or `orch setup --mode subagent` in a terminal)."
Binary file
package/bin/orch CHANGED
@@ -168,7 +168,7 @@ def state_lock():
168
168
 
169
169
  # usable while autopilot drives: reads, and the lead's requests (the event manager carries them out)
170
170
  LEASE_FREE = {"status", "ready", "pick", "report", "approve", "autopilot", "events", "dispatch", "answer", "defer",
171
- "fix", "team", "resume", "bench", "stop", "doctor", "plan", "story", "check", "free"}
171
+ "fix", "team", "resume", "bench", "stop", "doctor", "plan", "story", "check", "free", "manual"}
172
172
  _LEASE = None
173
173
 
174
174
 
@@ -3260,6 +3260,122 @@ def ai_credited_commits(base):
3260
3260
  return found
3261
3261
 
3262
3262
 
3263
+ # ---------------------------------------------------------------- manual tests: what the developer tries by hand
3264
+ MANUAL_HEAD_RE = re.compile(r"^\s*(#{1,6}\s+|\*\*)\s*manual (verification checklist|tests?\b)", re.I)
3265
+ MANUAL_ITEM_RE = re.compile(r"^(\s*)(?:[-*+]\s+(?:\[[ xX]\]\s*)?|\d+[.)]\s+)(.*\S)\s*$")
3266
+
3267
+
3268
+ def manual_tests(text):
3269
+ """The summary's "Manual verification checklist" (the lead writes it at ALL_DONE): (items, note). items are
3270
+ the things to try by hand, in order (a sub-bullet or a wrapped line stays with its item); note is the lead's
3271
+ `Nothing to check by hand: ...` line when there are none. (None, None): the summary has no such section yet."""
3272
+ lines, start, level = text.splitlines(), None, 0
3273
+ for i, l in enumerate(lines):
3274
+ m = MANUAL_HEAD_RE.match(l)
3275
+ if m:
3276
+ start, level = i + 1, (len(m.group(1).strip()) if m.group(1).strip().startswith("#") else 0)
3277
+ if start is None:
3278
+ return None, None
3279
+ items, note = [], None
3280
+ for l in lines[start:]:
3281
+ h = re.match(r"^(#{1,6})\s", l)
3282
+ if (h and (not level or len(h.group(1)) <= level)) or (not level and l.startswith("**")):
3283
+ break
3284
+ m = MANUAL_ITEM_RE.match(l)
3285
+ if m and not m.group(1):
3286
+ items.append(m.group(2).strip())
3287
+ elif l.strip() and items and (m or l[:1].isspace()):
3288
+ items[-1] += ("; " + m.group(2).strip()) if m else (" " + l.strip())
3289
+ elif re.search(r"nothing to (check|test) by hand", l, re.I) and not note:
3290
+ note = l.strip().strip("-*_ ")
3291
+ return items, note
3292
+
3293
+
3294
+ def manual_block(st=None):
3295
+ """The manual test list for a person, as printed by `orch finish` and `orch manual` (and saved in
3296
+ .orchestrate/manual-tests.md): numbered, word for word from the summary. Returns (lines, count or None)."""
3297
+ summary = ORCH / "summary.md"
3298
+ items, note = manual_tests(summary.read_text()) if summary.exists() else (None, None)
3299
+ if items:
3300
+ out = [f"MANUAL TESTS: {len(items)} to try by hand before you merge (from the summary's Manual "
3301
+ f"verification checklist):"] + [f" {i}. {x}" for i, x in enumerate(items, 1)]
3302
+ elif items is not None:
3303
+ out = ["MANUAL TESTS: none. " + (note or "The lead's Manual verification checklist is empty.")]
3304
+ else:
3305
+ out = ["MANUAL TESTS: not written yet. .orchestrate/summary.md has no \"Manual verification checklist\": "
3306
+ "ask the lead to finish the summary (ALL_DONE), then `orch manual` prints the list."]
3307
+ with contextlib.suppress(OSError):
3308
+ if ORCH.is_dir():
3309
+ (ORCH / "manual-tests.md").write_text(
3310
+ f"# Manual tests: {(st or {}).get('title') or (st or {}).get('branch') or 'this run'}\n\n"
3311
+ "Try these by hand. They come from the Manual verification checklist in summary.md.\n\n"
3312
+ + ("".join(f"{i}. {x}\n" for i, x in enumerate(items, 1)) if items else out[0] + "\n"))
3313
+ return out, (len(items) if items is not None else None)
3314
+
3315
+
3316
+ def cmd_manual(args):
3317
+ """orch manual -> the manual test list from the summary, numbered, for the developer (and the lead's chat)."""
3318
+ st = load() if STATE.exists() else None
3319
+ print("\n".join(manual_block(st)[0]))
3320
+
3321
+
3322
+ def tell_lead_finished(st, outcome, count):
3323
+ """After `orch finish`: queue a FINISHED event for the lead, so it posts the manual test list in its chat. When
3324
+ the lead ran `orch finish` itself (this pane is the lead's), it has the list in front of it: no wake-up."""
3325
+ if not lead_on(st):
3326
+ if run_mode(st) == "subagent":
3327
+ print("LEAD: post the MANUAL TESTS list above in your chat, numbered, word for word.")
3328
+ return
3329
+ text = outcome + ("" if count is None else f"; {count} manual test(s) to try by hand")
3330
+ with state_lock():
3331
+ s_ = load()
3332
+ lead_event(s_, "finished", None, text)
3333
+ save(s_)
3334
+ lead = st["lead"]["name"]
3335
+ pid = os.environ.get("HERDR_PANE_ID")
3336
+ if pid and pid in (st["lead"].get("pane"), agent_pane(lead)):
3337
+ print("LEAD: you ran `orch finish` yourself: post the MANUAL TESTS list above in your chat now, numbered, "
3338
+ "word for word, then run `orch events` to mark FINISHED read.")
3339
+ return
3340
+ try:
3341
+ deliver(st, lead, f"orch: `orch finish` ran on {st['branch']}. Run `orch events` and post the manual test "
3342
+ f"list it prints in your chat, then stop.")
3343
+ print(f"TOLD THE LEAD ({lead}): it posts the manual test list in its chat")
3344
+ except DeliveryError as e:
3345
+ print(f"NOTE could not tell the lead ({lead}): {e} — tell it: run `orch events`")
3346
+
3347
+
3348
+ def finish_push(st, base, title, pr_body, args):
3349
+ """Push the feature branch and open the PR. Returns one line on what happened, for the lead's FINISHED event."""
3350
+ if "--no-push" in args:
3351
+ print(f"NOT PUSHED (--no-push): push {st['branch']} and open a PR into {base} when ready")
3352
+ return f"cleaned up, not pushed (--no-push): {st['branch']} still needs a push and a PR into {base}"
3353
+ remote = git("remote", "get-url", "origin", cwd=ROOT, check=False)
3354
+ if remote.returncode != 0:
3355
+ print(f"NO REMOTE: no `origin` remote — merge {st['branch']} into {base} yourself")
3356
+ return f"no `origin` remote: {st['branch']} is to be merged into {base} by hand"
3357
+ url = remote.stdout.strip()
3358
+ git("push", "-q", "-u", "origin", st["branch"], cwd=ROOT)
3359
+ print(f"PUSHED {st['branch']} to origin")
3360
+ compare = github_compare_url(url, base, st["branch"])
3361
+ if compare and shutil.which("gh"):
3362
+ try:
3363
+ r = subprocess.run(["gh", "pr", "create", "--base", base, "--head", st["branch"], "--title", title,
3364
+ "--body-file", str(pr_body)],
3365
+ cwd=ROOT, text=True, capture_output=True, timeout=120)
3366
+ except (OSError, subprocess.TimeoutExpired) as e:
3367
+ r = subprocess.CompletedProcess([], 1, "", str(e))
3368
+ if r.returncode == 0:
3369
+ pr = r.stdout.strip().splitlines()[-1] if r.stdout.strip() else "created"
3370
+ print(f"PR {pr}")
3371
+ return f"pushed {st['branch']}, PR into {base}: {pr}"
3372
+ print(f"NOTE gh pr create failed: {(r.stdout + r.stderr).strip()}")
3373
+ print(f"OPEN A PR from {st['branch']} into {base}" + (f": {compare}" if compare else "")
3374
+ + f" — title: {title!r}, text: .orchestrate/pr-body.md (use them as they are: add no \"Generated with\" or "
3375
+ f"Co-Authored-By line)")
3376
+ return f"pushed {st['branch']}; the PR into {base} is still to open" + (f": {compare}" if compare else "")
3377
+
3378
+
3263
3379
  def cmd_finish(args):
3264
3380
  """orch finish [--no-push] [--recheck] -> final check (reused when it already passed on exactly these files;
3265
3381
  --recheck runs it anyway), drop hidden refs and worktrees, push the feature branch, open a PR."""
@@ -3311,31 +3427,10 @@ def cmd_finish(args):
3311
3427
  for ref in rescued:
3312
3428
  print(f"KEPT {ref}: unsaved files orch rescued during the run and no milestone used — look with "
3313
3429
  f"`git show --stat {ref}`, delete with `git update-ref -d {ref}`")
3314
- if "--no-push" in args:
3315
- print(f"NOT PUSHED (--no-push): push {st['branch']} and open a PR into {base} when ready")
3316
- return
3317
- remote = git("remote", "get-url", "origin", cwd=ROOT, check=False)
3318
- if remote.returncode != 0:
3319
- print(f"NO REMOTE: no `origin` remote — merge {st['branch']} into {base} yourself")
3320
- return
3321
- url = remote.stdout.strip()
3322
- git("push", "-q", "-u", "origin", st["branch"], cwd=ROOT)
3323
- print(f"PUSHED {st['branch']} to origin")
3324
- compare = github_compare_url(url, base, st["branch"])
3325
- if compare and shutil.which("gh"):
3326
- try:
3327
- r = subprocess.run(["gh", "pr", "create", "--base", base, "--head", st["branch"], "--title", title,
3328
- "--body-file", str(pr_body)],
3329
- cwd=ROOT, text=True, capture_output=True, timeout=120)
3330
- except (OSError, subprocess.TimeoutExpired) as e:
3331
- r = subprocess.CompletedProcess([], 1, "", str(e))
3332
- if r.returncode == 0:
3333
- print(f"PR {r.stdout.strip().splitlines()[-1] if r.stdout.strip() else 'created'}")
3334
- return
3335
- print(f"NOTE gh pr create failed: {(r.stdout + r.stderr).strip()}")
3336
- print(f"OPEN A PR from {st['branch']} into {base}" + (f": {compare}" if compare else "")
3337
- + f" — title: {title!r}, text: .orchestrate/pr-body.md (use them as they are: add no \"Generated with\" or "
3338
- f"Co-Authored-By line)")
3430
+ outcome = finish_push(st, base, title, pr_body, args)
3431
+ lines, count = manual_block(st)
3432
+ print("\n".join(lines))
3433
+ tell_lead_finished(st, outcome, count)
3339
3434
 
3340
3435
 
3341
3436
  # ---------------------------------------------------------------- v4: task files, nudge, autopilot
@@ -3833,6 +3928,9 @@ EVENT_HELP = {
3833
3928
  "any agent it reports LOST.",
3834
3929
  "all_done": "every milestone landed. Finish .orchestrate/summary.md: the steps (section 3, ALL_DONE) are printed below.",
3835
3930
  "stopped": "the event manager stopped. Tell the developer why; they run `orch resume` (or `orch autopilot`).",
3931
+ "finished": "the developer ran `orch finish`. Post the MANUAL TESTS list printed below in your chat, numbered and "
3932
+ "word for word, under \"Try these by hand before you merge\" (or say there is nothing to try by hand). "
3933
+ "Add nothing else to the run.",
3836
3934
  }
3837
3935
 
3838
3936
 
@@ -3875,6 +3973,8 @@ def say_line(st, e):
3875
3973
  return f"Every milestone is done: {text}."
3876
3974
  if k == "stopped":
3877
3975
  return f"The event manager stopped: {text}."
3976
+ if k == "finished":
3977
+ return f"The run is finished: {text}."
3878
3978
  return f"{k} {name}: {text}".strip()
3879
3979
 
3880
3980
 
@@ -3999,6 +4099,8 @@ def cmd_events(args):
3999
4099
  print(head + (f": {e['text']}" if e.get("text") else ""))
4000
4100
  print(" -> " + EVENT_HELP.get(e["kind"], "").format(t=e.get("task") or "<Mn>"))
4001
4101
  print(" SAY: " + say_line(st, e))
4102
+ if e["kind"] == "finished":
4103
+ print("\n".join(" " + x for x in manual_block(st)[0]))
4002
4104
  print(f"EVENTS for the lead — run {st['branch']}: {len(new)} new, {len(old)} still open")
4003
4105
  for e in new:
4004
4106
  show(e)
@@ -6123,11 +6225,11 @@ COMMANDS = {
6123
6225
  "send-job": cmd_send_job, "handoff": cmd_handoff, "needs-fix": cmd_needs_fix, "review-ok": cmd_review_ok,
6124
6226
  "requeue-review": cmd_requeue_review, "finish": cmd_finish, "resend": cmd_resend, "approve": cmd_approve,
6125
6227
  "report": cmd_report, "events": cmd_events, "dispatch": cmd_dispatch, "answer": cmd_answer, "defer": cmd_defer,
6126
- "escalate": cmd_escalate, "fix": cmd_fix, "plan": cmd_plan, "story": cmd_story, "team": cmd_team, "bench": cmd_bench, "stop": cmd_stop,
6228
+ "escalate": cmd_escalate, "fix": cmd_fix, "plan": cmd_plan, "story": cmd_story, "manual": cmd_manual, "team": cmd_team, "bench": cmd_bench, "stop": cmd_stop,
6127
6229
  "free": cmd_free, "doctor": lambda a: cmd_doctor_crash(a), "check": lambda a: cmd_check(a), "sub": lambda a: cmd_sub(a),
6128
6230
  }
6129
6231
  # they lock per step instead of for the whole command (long-running, or they start the event manager after)
6130
- UNLOCKED = {"autopilot", "poll", "merge", "events", "dispatch", "answer", "defer", "fix", "team", "resume", "bench", "stop",
6232
+ UNLOCKED = {"manual", "autopilot", "poll", "merge", "events", "dispatch", "answer", "defer", "fix", "team", "resume", "bench", "stop",
6131
6233
  "doctor", "check", "free"}
6132
6234
 
6133
6235
  USAGE = """usage: orch <command> [args]
@@ -6154,6 +6256,8 @@ USAGE = """usage: orch <command> [args]
6154
6256
  resume after a restart (computer off, herdr closed): name the agents' panes again, save unsaved
6155
6257
  work, re-send the tasks that were in progress and start the event manager
6156
6258
  story the run diary in plain words: each event and what the lead did (.orchestrate/story.md)
6259
+ manual the manual tests: what to try by hand, numbered, from the summary's Manual verification
6260
+ checklist (`orch finish` prints them too, and the lead posts them in its chat)
6157
6261
  plan show the plan for a person: each milestone in plain words, who builds it, how long, the order
6158
6262
  events [--peek] (lead) what you were woken for; reading acknowledges it
6159
6263
  dispatch <Mn>... [--to <worker>] [--tier <tier>] (lead) start or restart milestones; starts the event manager
@@ -6360,7 +6464,7 @@ def plan_playbook_part(text, part):
6360
6464
  EVENT_ROWS = {"ready": "READY", "merged": "MERGED", "paused": "PAUSED", "failed": "FAILED", "held": "HELD",
6361
6465
  "worker-lost": "WORKER-LOST", "herdr-restart": "HERDR-RESTART", "needs-answer": "NEEDS-ANSWER",
6362
6466
  "escalated": "ESCALATED", "auto-dispatched": "AUTO-DISPATCHED", "stopped": "STOPPED",
6363
- "all_done": "ALL_DONE"}
6467
+ "all_done": "ALL_DONE", "finished": "FINISHED"}
6364
6468
 
6365
6469
 
6366
6470
  def run_playbook_part(text, name):
@@ -7346,7 +7450,8 @@ def pi_setup():
7346
7450
  except (OSError, subprocess.TimeoutExpired) as e:
7347
7451
  ok, out = False, str(e)
7348
7452
  if ok:
7349
- print(f"INSTALLED {PI_SUBAGENTS}: restart Pi (or /reload) so it loads the Agent tool")
7453
+ print(f"INSTALLED {PI_SUBAGENTS}: restart Pi (or /reload) so it loads the Agent tool "
7454
+ f"(/orch-mode subagent in Pi reloads it for you)")
7350
7455
  return problems
7351
7456
  print(f"FAILED pi install {PI_SUBAGENTS}:\n" + "\n".join(out.splitlines()[-10:])
7352
7457
  + f"\n run it yourself: pi install {PI_SUBAGENTS}")
@@ -7407,8 +7512,8 @@ def set_mode(mode, hint=True):
7407
7512
  if mode == "subagent" and hint:
7408
7513
  missing = [r for r in ("coder", "reviewer") if not (pi_agents_dir() / f"{r}.md").exists()]
7409
7514
  if missing:
7410
- print(f"NEXT run `orch setup --mode subagent`: it writes the {' and '.join(missing)} agent file(s) "
7411
- f"and installs pi-subagents")
7515
+ print(f"NEXT run `orch setup --mode subagent` (in Pi, `/orch-mode subagent` does it for you): it writes "
7516
+ f"the {' and '.join(missing)} agent file(s) and installs pi-subagents")
7412
7517
 
7413
7518
 
7414
7519
  SUBAGENT_PLAN_NOTE = """SUBAGENT MODE (Pi, one window). This replaces every herdr step below:
@@ -9,9 +9,14 @@
9
9
  // Where the mode comes from: this repo's run (.orchestrate/state.json, `orch_mode`; a run from before 6.2.0 is
10
10
  // panes), else ~/.config/herdr-orchestra/config.json (`mode`), else panes.
11
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";
12
+ // Commands: /orch-mode [panes|subagent] show or switch the mode; `subagent` also sets it up (below)
13
+ // /orch-setup [--mode panes|subagent] install the `orch` command from this package (needed once)
14
+ //
15
+ // Subagent mode is set up from inside Pi, with no terminal step: `/orch-mode subagent` runs
16
+ // `orch setup --mode subagent` (or this package's installer when orch is missing or old), which writes
17
+ // ~/.pi/agent/agents/coder.md and reviewer.md and runs `pi install npm:@tintinweb/pi-subagents`. When that install
18
+ // is new, the command reloads Pi (ctx.reload) so the Agent tool is there at once.
19
+ import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
15
20
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
16
21
  import { homedir } from "node:os";
17
22
  import { dirname, join, resolve } from "node:path";
@@ -20,6 +25,8 @@ import { fileURLToPath } from "node:url";
20
25
  type Mode = "panes" | "subagent";
21
26
  const MODES: Mode[] = ["panes", "subagent"];
22
27
  const STATUS_KEY = "orch";
28
+ /** `orch setup` result lines (bin/orch pi_setup and set_mode). */
29
+ const SETUP_LINE = /^(WROTE|ok |KEPT|REFUSED|NO PI|INSTALL|INSTALLED|FAILED|mode:|mode panes:|this repo|NOT CHANGED|run it yourself)/;
23
30
 
24
31
  function packageRoot(): string {
25
32
  const here = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
@@ -149,8 +156,65 @@ export default function orchMode(pi: ExtensionAPI) {
149
156
  return { systemPrompt: `${event.systemPrompt}\n\n${line}` };
150
157
  });
151
158
 
159
+ /** Lines worth showing from installer / `orch setup` output (both can be long). */
160
+ function keyLines(out: string, extra: RegExp): string {
161
+ return out
162
+ .replace(/\x1b\[[0-9;]*m/g, "")
163
+ .split("\n")
164
+ .map((l) => l.trimEnd())
165
+ .filter((l) => extra.test(l.trim()) || SETUP_LINE.test(l.trim()))
166
+ .slice(-16)
167
+ .join("\n");
168
+ }
169
+
170
+ /** Run the installer (always with install=true; also when orch is missing or older than this package), else
171
+ * `orch setup --mode subagent`; then reload Pi when pi-subagents was just installed. Returns true when Pi is reloading (the caller must return at once). */
172
+ async function setUp(ctx: ExtensionCommandContext, want: Mode | undefined, install: boolean): Promise<boolean> {
173
+ const o = await orchState(pi);
174
+ let r: { stdout: string; stderr: string; code: number };
175
+ let shown: string;
176
+ if (!install && o.state === "ok" && want === "subagent") {
177
+ ctx.ui.notify("Setting up subagent mode: the coder and reviewer agents, and pi-subagents (can take a minute)...", "info");
178
+ r = await pi.exec(o.path!, ["setup", "--mode", "subagent"], { cwd: ctx.cwd, timeout: 600000 });
179
+ shown = keyLines(r.stdout + r.stderr, /^$/);
180
+ } else {
181
+ const installer = join(packageRoot(), "install.sh");
182
+ if (!existsSync(installer)) {
183
+ ctx.ui.notify(`install.sh not found next to this extension (${installer}). Run: npx herdr-orchestra@latest`, "error");
184
+ return false;
185
+ }
186
+ ctx.ui.notify(
187
+ "Installing herdr-orchestra (orch)" + (want === "subagent" ? " and setting up subagent mode" : "") + "...",
188
+ "info",
189
+ );
190
+ // ORCH_TTY=/dev/null: the installer must not read Pi's terminal. An unanswered auto-update question gets the
191
+ // installer's default (on); the output says how to turn it off (`orch config auto-update off`).
192
+ const args = ["ORCH_PACKAGE=1", "ORCH_TTY=/dev/null", "bash", installer, ...(want ? ["--mode", want] : [])];
193
+ r = await pi.exec("env", args, { cwd: ctx.cwd, timeout: 600000 });
194
+ shown = keyLines(r.stdout + r.stderr, /^(==>|warn:|error:)|auto-update|is active/);
195
+ }
196
+ const out = (r.stdout + r.stderr).replace(/\x1b\[[0-9;]*m/g, "");
197
+ // the installer only warns when its `orch setup` step fails, so look at orch's own lines too
198
+ const ok = r.code === 0 && !/^(FAILED|REFUSED|NO PI)\b|orch setup --mode \S+ did not finish/m.test(out);
199
+ mode = (await readMode(pi, ctx.cwd)).mode;
200
+ showStatus(ctx, mode);
201
+ if (want === "subagent" && ok) {
202
+ shown += "\nDone: subagent mode is ready. Plan with /orch-plan as usual.";
203
+ } else if (want === "subagent") {
204
+ shown += "\nSubagent setup is not finished: fix what it says above, then type /orch-mode subagent again.";
205
+ }
206
+ ctx.ui.notify(shown.trim() || (ok ? "Installed." : "The installer failed."), ok ? "info" : "error");
207
+ if (ok && /^INSTALLED\s+npm:@tintinweb\/pi-subagents/m.test(out)) {
208
+ // pi-subagents is new: reload so its Agent tool is loaded now, not after a restart.
209
+ ctx.ui.notify("Reloading Pi so the new Agent tool loads...", "info");
210
+ await ctx.reload();
211
+ return true;
212
+ }
213
+ return false;
214
+ }
215
+
152
216
  pi.registerCommand("orch-mode", {
153
- description: "Show or switch the herdr-orchestra mode: panes (herdr panes) or subagent (one Pi window)",
217
+ description: "Show or switch the herdr-orchestra mode: panes (herdr panes) or subagent (one Pi window, set up for you)",
154
218
  getArgumentCompletions: (prefix: string) =>
155
219
  MODES.filter((m) => m.startsWith(prefix.trim().toLowerCase())).map((m) => ({ value: m, label: m })),
156
220
  handler: async (args, ctx) => {
@@ -167,6 +231,15 @@ export default function orchMode(pi: ExtensionAPI) {
167
231
  ctx.ui.notify(`Unknown mode "${want}". Use /orch-mode panes or /orch-mode subagent.`, "error");
168
232
  return;
169
233
  }
234
+ if (next === "subagent") {
235
+ // `orch setup --mode subagent` saves the mode (and this repo's run, when nothing is in progress) and sets it up
236
+ if (await setUp(ctx, "subagent", false)) return;
237
+ const now = await readMode(pi, ctx.cwd);
238
+ if (now.mode !== next) {
239
+ ctx.ui.notify(`This repo's run stays ${now.mode} (something is in progress). New runs use ${next}.`, "warning");
240
+ }
241
+ return;
242
+ }
170
243
  const o = await orchState(pi);
171
244
  const orch = o.state === "ok" ? o.path : undefined;
172
245
  if (orch) {
@@ -197,28 +270,20 @@ export default function orchMode(pi: ExtensionAPI) {
197
270
  });
198
271
 
199
272
  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");
273
+ description: "Install the herdr-orchestra `orch` command from this package; --mode subagent also sets up its Pi subagents",
274
+ getArgumentCompletions: (prefix: string) =>
275
+ ["--mode panes", "--mode subagent"].filter((m) => m.startsWith(prefix.trim().toLowerCase())).map((m) => ({ value: m, label: m })),
276
+ handler: async (args, ctx) => {
277
+ const words = args.trim().toLowerCase().split(/\s+/).filter(Boolean);
278
+ if (words[0] === "--mode") words.shift();
279
+ const named = words.length ? asMode(words[0]) : undefined;
280
+ if (words.length > 1 || (words.length && !named)) {
281
+ ctx.ui.notify("Usage: /orch-setup [--mode panes|subagent]", "error");
205
282
  return;
206
283
  }
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);
284
+ // No mode named: the saved one (in subagent mode the installer sets the agents up again, which is harmless)
285
+ const want = named ?? ((await readMode(pi, ctx.cwd)).mode === "subagent" ? "subagent" : undefined);
286
+ await setUp(ctx, want, true);
222
287
  },
223
288
  });
224
289
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.3.0",
3
+ "version": "6.5.0",
4
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": {
package/playbooks/run.md CHANGED
@@ -48,6 +48,7 @@ Run `orch events`. It lists the new events, the ones still open, the milestones
48
48
  | `HELD Mn` | 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`, and tell the developer to look and run `orch approve Mn` (or `orch set Mn paused`). |
49
49
  | `NEEDS-ANSWER Mn` | Open questions in the plan: ask the developer, write the answers under "Notes from user", set "Open questions:" to `- none`, `orch sync`, then `orch dispatch Mn`. |
50
50
  | `ESCALATED Mn`, `AUTO-DISPATCHED Mn` | Information: nothing to dispatch. Mention an escalation in the final summary. |
51
+ | `FINISHED` | The developer ran `orch finish`. Post the MANUAL TESTS list that `orch events` prints under it in your chat, numbered and word for word, under "Try these by hand before you merge", plus the PR link from the event when there is one. If it says none, say there is nothing to try by hand and why. Nothing else to do: the run is over. |
51
52
  | `STOPPED` / the event manager is not running | Read the last lines of `.orchestrate/autopilot.log` and tell the developer why (a red baseline, the run's budget, the branch failing its check). Your next `orch dispatch` or `orch answer` starts it again; so does `orch autopilot` in a terminal. |
52
53
  | `orch status` starts with `!! EVENT MANAGER NOT RUNNING`, or the developer says the computer or herdr was restarted | Run `orch resume` once and read what it prints. It leaves the time orch was down out of every time budget, gives the agents' panes their names back, saves unsaved work, sends the tasks in progress to their agents again and starts the event manager. For each `LOST` line, give the developer the exact command it prints (`herdr agent rename <pane> <name>`, or `orch team up` for a pane with no agent in it), then run `orch resume` again. Never fix this with git by hand, and never prompt a coder yourself. |
53
54
  | `ALL_DONE` | Section 3. |
@@ -72,7 +73,7 @@ If you changed plan.md by hand, run `orch sync` (it works once the event manager
72
73
  - **"Design decisions & study notes"** for the developer (include any milestone that needed a stronger model than planned, and what that says about the plan).
73
74
  - **"Checked by the lead"**. Go through every acceptance criterion and every behaviour the feature promised. Whatever can be settled by running a command or by reading the code, YOU settle now, and write one line each with the evidence: the command and its result, or `file:line`. This covers: a criterion "Checked automatically" marks `no evidence recorded` or `NOT met`, "the comment / doc / config says X", "the endpoint returns 400 for Y" (run its test, or read the test that covers it), "the migration adds column Z", "no leftover TODO or debug output". You may run the check command, single tests and read-only commands (`grep`, `git log`, `git diff --stat`), and open the few files you need; you still never edit application code. If a check of yours fails, it is a defect, not a checklist item: tell the developer and offer `orch fix Mn "<what is wrong>"`.
74
75
  - **"Manual verification checklist"**: ONLY what a person must see or do, because no command and no reading of code can settle it. That is: how the UI looks (layout, spacing, colours, dark mode, a small screen), how it behaves in a real browser or on a real device (click-through flows, focus, animation, how fast it feels), and anything that needs an outside account or hardware (a real email arriving, a payment in the provider's test mode, a push notification, a printer). Write each item so the developer can do it without reading code: `- [ ] <where to go and what to do> → <what they should see>`. Test for every item: "could I, or a test, have checked this?" If yes, it does not belong here: check it and move it to "Checked by the lead". Never write "review the code", "read the comments", "confirm the tests pass" or "check the function handles X" as a manual item. If nothing needs a person (a pure backend, CLI or docs change), write `Nothing to check by hand: <one line why>` instead of inventing items.
75
- 3. Tell the developer: "All tasks landed on <branch>. Review .orchestrate/summary.md. I checked <n> things myself; <m> need your eyes; <k> were deferred with your approval and are NOT done (listed as follow-ups) (the manual checklist), or: nothing needs checking by hand. Then run `orch finish`: it re-runs the check (or reuses it when it already passed on exactly these files), removes the worktrees and hidden refs, pushes <branch> and opens a PR into <base> (`orch finish --no-push` to only clean up)." Run `orch finish` yourself only when the developer says so: it pushes. It opens the PR itself when `gh` is installed; if it prints `OPEN A PR`, give the developer the link, and if they ask you to open it, use exactly the title and `.orchestrate/pr-body.md` it names. 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.**
76
+ 3. Tell the developer: "All tasks landed on <branch>. Review .orchestrate/summary.md. I checked <n> things myself; <k> were deferred with your approval and are NOT done (listed as follow-ups). <m> need your eyes:", then the manual checklist items themselves, numbered, one per line (`orch manual` prints them as orch reads them), or: nothing needs checking by hand. Then: "Run `orch finish`: it re-runs the check (or reuses it when it already passed on exactly these files), removes the worktrees and hidden refs, pushes <branch> and opens a PR into <base> (`orch finish --no-push` to only clean up)." Run `orch finish` yourself only when the developer says so: it pushes. It opens the PR itself when `gh` is installed; if it prints `OPEN A PR`, give the developer the link, and if they ask you to open it, use exactly the title and `.orchestrate/pr-body.md` it names. 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. When you ran `orch finish` yourself, post the MANUAL TESTS list it printed in your chat, numbered and word for word, under "Try these by hand before you merge" (when the developer runs it in a terminal, you are woken with `FINISHED` and do the same). **STOP.**
76
77
  4. **The developer asks for a change after the summary** (for example "the login button should be blue"). Do not plan again. Find the milestone that built that part (the summary's Tasks list and Likely files tell you), then run `orch fix Mn "<the change, in the developer's words>"`. It adds one small follow-up milestone to `plan.md`, sends it straight to the coder who built Mn, and starts the event manager; the check and the review (when Mn had one) still run. Name another coder only when the developer asks: `--to <worker>`. Then **STOP**: you are woken with ALL_DONE again, and the new summary keeps the old one in `.orchestrate/summary.prev.md`, so carry your notes and checklist over and add what changed. Never type into a coder's pane yourself.
77
78
 
78
79
  ## Runs without a lead (`Lead mode: off`)
@@ -16,7 +16,7 @@ There is no event manager and there are no herdr panes. You drive one milestone
16
16
  ## 1. Start the run (the developer said go)
17
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
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**.
19
+ 3. Check that the `Agent` tool is available to you. If it is not, tell the developer to type `/orch-mode subagent` in Pi (it sets up the subagents and reloads Pi; outside Pi: `orch setup --mode subagent`, then restart Pi), and **STOP**.
20
20
 
21
21
  ## 2. One milestone
22
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.)
@@ -37,4 +37,5 @@ There is no event manager and there are no herdr panes. You drive one milestone
37
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
38
  - **Reviewer suggestions not applied.**
39
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.**
40
+ 2. Tell the developer: "All milestones are saved on <branch>. Review .orchestrate/summary.md. <m> need your eyes:", then the manual checklist items, numbered, one per line (or: nothing needs checking by hand). 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.**
41
+ 3. **After `orch finish`** (you ran it, or the developer tells you they did): post its MANUAL TESTS list in your chat, numbered and word for word, under "Try these by hand before you merge" (`orch manual` prints it again). If it says none, say there is nothing to try by hand. **STOP.**