herdr-orchestra 6.45.0 → 6.47.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,38 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.47.0] - 2026-11-30
6
+
7
+ The lead reads far less. Most of the playbook text a lead read was text it did not need at that moment: on "go" it got the whole run playbook (22,774 characters), including the event table and the summary steps that `orch events` prints again exactly when they are needed, and it got all of it again on every message the developer sent during a run. Every wake-up repeated the full hard rules. "M1 landed" woke the lead just to write one line. And the whole planning (the plan playbook, every file read while researching) stayed in the lead's chat for the rest of the run, sent again on every call.
8
+
9
+ Example: a 2-milestone run with a question. Before: go = 22,774 characters, each developer message = 22,774 more, 4 wake-ups with ~2,900 characters of rules each, one of them only to say "M5 landed, M4 started". Now: go = 8,654 characters, a developer message mid-run = the rules, the developer's part and the steps for the open events only, later wake-ups print the short rules, the news comes with the next real wake-up, and the lead's chat is compacted once after go. Sizes measured on the playbooks; the token saving of a whole run is still to be measured on a real run (the summary's token rows, 6.34.0).
10
+
11
+ ### Changed
12
+ - **`orch lead run` prints what this moment needs.** At go: the intro, how a run works, the hard rules, the context budget, step 1 and a pointer to the rest (8,654 characters instead of 22,774). During a run (something was dispatched): `RUN IN PROGRESS`, the hard rules, the context budget, the new section 2b (what to do when the developer writes during a run: bench a coder, swap a coder, pick a model, move a milestone, red baseline), the event table rows for the events open now, and ALL_DONE when every milestone has landed. Subagent mode is unchanged. `orch lead run --section short|developer` print the new parts.
13
+ - **Later wake-ups print the hard rules in short.** The first wake-up after the lead was given the rules (by `orch lead run`, or after its compact) prints them in full; later ones print "Rules in short" (2,224 characters instead of 2,915). Rule 4 (permission prompts and approvals) and rule 8 (never push to main) are word for word in both.
14
+ - **News does not wake the lead on its own.** `MERGED`, `AUTO-DISPATCHED` and `ESCALATED` leave the lead nothing to decide: they wait in its queue and come with the next wake-up that needs it (a question, a failure, a held or ready milestone, at the latest ALL_DONE), and the lead gives their SAY lines then. The board, `orch view` and `orch story` show them at once. `orch config news-wake on` (or `ORCH_NEWS_WAKE=1`) wakes the lead for them again.
15
+ - **The lead's chat is compacted once, after go.** When the lead has dispatched and has been idle for 15 seconds (`ORCH_LEAD_COMPACT_IDLE_S`), the event manager types its tool's compact command (`/compact` for Claude Code, Codex, AGY 1.2.15+) into the lead's pane. Wake-ups wait until herdr shows it idle again, and the next one prints the full hard rules. A tool with no compact command is skipped, and `orch story` says why. `orch config lead-compact off` (or `ORCH_LEAD_COMPACT=0`) turns it off. Coders and the reviewer are compacted between milestones as before.
16
+ - **A full plan no longer reads the quick run's own steps.** The quick run's step-by-step and its plan format moved from `orch lead plan` to the start of `orch lead plan quick`, which only a quick run reads (`orch lead plan`: 15,878 characters instead of 19,384).
17
+ - **Shorter skill descriptions.** The orch-plan, orch-run and orch-onboard descriptions, which every agent's tool keeps in its system prompt on every call, are about half as long (1,800 to 900 characters for all four), with every trigger phrase kept ("orch-run", "go", "start the run", "continue the plan", answers during a run, `orch events`, "orch-plan", `quick:`/`full:`, "orch-onboard").
18
+
19
+ ### Fixed
20
+ - `orch lead run --section AUTO-DISPATCHED` (and a wake-up with only that event) found no row, because the row starts with `ESCALATED`. A row that names several events is found for each of them.
21
+ ## [6.46.0] - 2026-11-30
22
+
23
+ The team's panes are readable. `orch team up` used to put every new pane in the lead's tab: the first one to the right of the lead, each next one split down from the one before. With two coders and a reviewer the lead got half the screen and the agents got thin strips, so text was cut off.
24
+
25
+ Example: a Codex lead with codex-1, codex-2 and a reviewer. Before, the lead's tab held all four panes. Now the lead keeps its whole tab, and a new herdr tab `team` holds codex-1 and codex-2 side by side on top and the reviewer full width below.
26
+
27
+ ### Changed
28
+ - **`orch team up` opens the team in a herdr tab of its own, as a grid of equal panes.** The tab is called `team` (`backend team` in a workspace of several repos). Layout: 1 agent full size, 2 side by side, 3 as two on top and the reviewer below, 4 as 2×2. At most 4 go in a tab; more go to `team 2`. orch reads the screen size from `herdr pane layout` and keeps each pane at least 80 columns × 20 rows, so a small screen gets fewer panes per tab. The reviewer always comes last. Sizes are set with `--ratio`, so the panes are equal. The lead's tab is never split.
29
+ - `orch team up --here` splits next to the lead as before. A herdr that can't make tabs gets a `NOTE`, and the panes then open next to the lead.
30
+ - Settings: `ORCH_TEAM_MAX_PER_TAB` (default 4), `ORCH_PANE_MIN_COLS` (80), `ORCH_PANE_MIN_ROWS` (20).
31
+
32
+ ### Added
33
+ - **`orch team tidy [--dry-run]`** moves the coder and reviewer panes that are already open (opened by hand, or next to the lead by an older orch) into the same `team` tab grid with `herdr pane move`. The agents keep running and keep their names, so wake-ups and prompts still reach them. It never moves the lead's pane or the pane it runs in.
34
+
35
+ Not yet tried on a real herdr: tested with the simulated herdr only. The herdr commands it uses (`tab create`, `pane split --ratio`, `pane layout`, `pane move`) were checked against herdr 0.9.5's source and docs.
36
+
5
37
  ## [6.45.0] - 2026-11-30
6
38
 
7
39
  The board stopped showing the wrong run, the board popup key is set up by one command, and the board comes to the Herdr desktop app. A lead planned new work as `.orchestrate/sap-business-one-hana-plan.md` because `plan.md` still held the last, finished run. orch reads only `plan.md`, so the new plan was never loaded: the work got done, but orch never tracked it, and the board kept showing the old run. Separately, `orch view plugin link` linked the popup, but `prefix+a` did nothing: Herdr takes keys only from its own config, and nothing put the key there.
package/README.md CHANGED
@@ -135,7 +135,7 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
135
135
 
136
136
  `orch agents launch <kind> --model <id>` prints the command with the model (`--role reviewer` gives the reviewer's command: for Claude Code its edit tools are off, it only reads the change and writes its review file); `orch models` lists the models and their tiers. Use whatever your installed agents already reach.
137
137
 
138
- **Only one tool installed, or just one window open?** Open only the lead and start the plan playbook. The lead sees it is alone and builds the team from its own tool: `orch team codex` picks coders and a reviewer of that tool on the models the catalog allows, spread over its tiers, and the lead writes them into the plan. When you say go, `orch team up` opens their panes next to the lead, each in its own folder and on its model, and names them. You never type either command yourself (you can: `orch team codex --coders 1`, `orch team up --dry-run`). Each pane is a separate session of the same tool, on your existing login.
138
+ **Only one tool installed, or just one window open?** Open only the lead and start the plan playbook. The lead sees it is alone and builds the team from its own tool: `orch team codex` picks coders and a reviewer of that tool on the models the catalog allows, spread over its tiers, and the lead writes them into the plan. When you say go, `orch team up` opens their panes in a herdr tab of their own called `team`, as a grid of equal panes (2 side by side, 3 as two on top and the reviewer below, 4 as 2×2; a fifth goes to `team 2`, and a small screen gets fewer per tab), each in its own folder and on its model, and names them. The lead keeps its whole tab. `orch team tidy` moves panes that are already open (by hand, or next to the lead) into that grid; `orch team up --here` splits next to the lead as before. You never type either command yourself (you can: `orch team codex --coders 1`, `orch team up --dry-run`). Each pane is a separate session of the same tool, on your existing login.
139
139
 
140
140
  ```
141
141
  you (1 Codex pane) ──► $orch-plan add a login page
@@ -237,7 +237,7 @@ The first `/orch-plan` in a project checks what the project has for its agents:
237
237
 
238
238
  Skip it once and orch won't ask again in that project. `/orch-onboard` runs it by hand. In a run, each milestone gets a `Skills:` line and the coder's task lists those skills. Skills that do orch's job (their own worktree, merging, helper agents) are named as "don't use in this task". Details: [Project setup](https://herdr-orchestra.vercel.app/docs/project-setup/).
239
239
 
240
- The orch-plan and orch-run skills and slash commands are thin wrappers: the playbooks themselves live in `orch` (`orch lead plan`, `orch lead run`), so every agent follows the same, versioned instructions. They are printed in parts so the lead reads only what it needs: `orch lead plan` prints research and the quick-or-full decision, then `orch lead plan quick` (a quick run's rules) or `orch lead plan full` (steps 3 to 10); on a wake-up, `orch events` prints the rules and steps for those events, so the run playbook is read once.
240
+ The orch-plan and orch-run skills and slash commands are thin wrappers: the playbooks themselves live in `orch` (`orch lead plan`, `orch lead run`), so every agent follows the same, versioned instructions. They are printed in parts so the lead reads only what it needs: `orch lead plan` prints research and the quick-or-full decision, then `orch lead plan quick` (a quick run's steps and rules) or `orch lead plan full` (steps 3 to 10). `orch lead run` prints only the start at go, and during a run only the rules, the developer's part and the steps for the open events; on a wake-up, `orch events` prints the rules (in short after the first time) and the steps for those events. News (a milestone landed) waits for the lead's next real wake-up, and the lead's chat is compacted once after go.
241
241
 
242
242
  ### Agent registry
243
243
  `orch agents` shows every known kind: installed or not, roles, whether herdr can watch it, and its launch command. Defaults ship in `agents.default.toml`; add or fix kinds in `~/.config/herdr-orchestra/agents.toml` (merged key by key):
@@ -370,7 +370,9 @@ Three views show a run while it goes; none of them changes it.
370
370
  | Attempts keep getting lost (unreachable, gone, rate-limited) | after 4 (`ORCH_MAX_LOST`) the task fails with the history instead of looping |
371
371
  | Autopilot is killed mid-step | the next run confirms or re-sends an unconfirmed prompt to the same agent, and finishes or undoes a half-done merge |
372
372
  | The computer was off, herdr was closed, or the event manager died | `orch status` says so in its first lines. `orch resume` carries on: the time orch was down is not counted against any task, the agents' panes get their names back, unsaved work is saved and the tasks in progress are sent again (see [After a restart](#after-a-restart)) |
373
- | A coder's or the reviewer's chat keeps growing, milestone after milestone | between milestones, while herdr shows it idle, orch types the tool's `/compact` (Claude Code, Codex, AGY 1.2.15+): its chat becomes a short summary, and `orch story` says so. Never mid-work, never for a fix round of the same milestone, never the lead. `orch config compact off` turns it off |
373
+ | A coder's or the reviewer's chat keeps growing, milestone after milestone | between milestones, while herdr shows it idle, orch types the tool's `/compact` (Claude Code, Codex, AGY 1.2.15+): its chat becomes a short summary, and `orch story` says so. Never mid-work, never for a fix round of the same milestone. `orch config compact off` turns it off |
374
+ | The lead's chat still holds the whole planning (playbook, files it read) during the run | once per run, when the lead is idle after go, orch types its tool's `/compact`: the plan is on disk and every wake-up prints what the lead needs. Wake-ups wait until it is done. `orch config lead-compact off` turns it off |
375
+ | The lead is woken just to say "M1 landed" | `MERGED`, `AUTO-DISPATCHED` and `ESCALATED` are news only: they come with the lead's next real wake-up (at the latest ALL_DONE); the board, `orch view` and `orch story` show them at once. `orch config news-wake on` wakes the lead for them again |
374
376
  | A milestone is paused or moved while its coder still works | orch presses the agent's interrupt key (Esc; set per agent kind as `interrupt_keys` in the registry), then types the STOP note. The coder shows as `stopping M7` in `orch status` and gets no new work until herdr shows it idle; the event manager presses the key again if it keeps going. `orch free <worker>` frees it once you have checked its pane |
375
377
  | A paused coder keeps writing files | whatever it writes anyway is saved into the milestone the next time the milestone or that folder is used. orch never refuses a task because a folder has unsaved files |
376
378
  | plan.md changed while a coder works on that milestone | its task.md is not rewritten mid-work; `orch sync` warns and says how to send the new text (`orch set Mn paused`, then `orch dispatch Mn`) |
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.45.0
1
+ 6.47.0
Binary file
package/bin/orch CHANGED
@@ -45,6 +45,7 @@ HALT_REPEAT_S = float(os.environ.get("ORCH_HALT_REPEAT_S", "90")) # still worki
45
45
  # growing from milestone to milestone. It counts as busy until herdr shows it idle for COMPACT_SETTLE_S
46
46
  COMPACT_SETTLE_S = float(os.environ.get("ORCH_COMPACT_SETTLE_S", "10"))
47
47
  COMPACT_MAX_S = float(os.environ.get("ORCH_COMPACT_MAX_S", "300")) # still working after this: stop waiting for it
48
+ LEAD_COMPACT_IDLE_S = float(os.environ.get("ORCH_LEAD_COMPACT_IDLE_S", "15")) # the lead idle this long after go: /compact it
48
49
  TEAM_CONFIRM_S = float(os.environ.get("ORCH_TEAM_CONFIRM_S", "5")) # `team up` looks again after this: still running?
49
50
  LOG_MAX_B = int(float(os.environ.get("ORCH_LOG_MAX_MB", "2")) * 1024 * 1024) # autopilot.log; one old copy is kept
50
51
  CRASH_KEEP = int(os.environ.get("ORCH_CRASH_KEEP", "20")) # saved agent screens in .orchestrate/crash/
@@ -1868,6 +1869,8 @@ def cmd_sync(args):
1868
1869
  "lead_wake": old.get("lead_wake"),
1869
1870
  "lead_ready_told": old.get("lead_ready_told"),
1870
1871
  "compact_told": old.get("compact_told") or [],
1872
+ "lead_compact": old.get("lead_compact") if old.get("branch") == branch else None,
1873
+ "lead_rules": old.get("lead_rules") if old.get("branch") == branch else None,
1871
1874
  "tree_task": old.get("tree_task"),
1872
1875
  "workers": {},
1873
1876
  "order": ids,
@@ -2182,7 +2185,7 @@ def stopping_line(st, name, w):
2182
2185
  # so the chat itself only holds what the agent did on its LAST milestone. Before the agent starts a different
2183
2186
  # milestone (and as soon as the milestone it worked on has landed) orch types its tool's compact command
2184
2187
  # (`/compact` in Claude Code, Codex and AGY): the tool replaces the long chat with a short summary. Only when herdr
2185
- # shows the agent idle, never while it works, and never the lead. A fix or review round of the SAME milestone keeps
2188
+ # shows the agent idle, never while it works (the lead only once, after go: see below). A fix or review round of the SAME milestone keeps
2186
2189
  # the chat. `orch config compact off` (or ORCH_COMPACT=0) turns it off; `compact = ""` in agents.toml turns it off
2187
2190
  # for one tool.
2188
2191
 
@@ -2241,7 +2244,8 @@ def compact_unsupported(st, name, kind):
2241
2244
 
2242
2245
 
2243
2246
  def compact_agents(st):
2244
- """(name, info dict, holds a job) for every coder and the reviewer. The lead is never compacted."""
2247
+ """(name, info dict, holds a job) for every coder and the reviewer. The lead is compacted only once, after go
2248
+ (tend_lead_compact)."""
2245
2249
  out = [(n, w, bool(w.get("task"))) for n, w in st.get("workers", {}).items()]
2246
2250
  if st.get("reviewer") and st.get("reviewer_info") is not None:
2247
2251
  out.append((st["reviewer"], st["reviewer_info"], bool(st.get("reviewer_busy"))))
@@ -2311,6 +2315,45 @@ def end_compact(st, name, w, note=True):
2311
2315
  return h
2312
2316
 
2313
2317
 
2318
+ # ---------------------------------------------------------------- compacting the lead's chat once, after go
2319
+ # Planning fills the lead's chat: the plan playbook, the files it read, the questions. None of it is needed to run:
2320
+ # the plan is in plan.md and every wake-up (`orch events`) prints what the lead needs. So once per run, when the lead
2321
+ # is idle after go (it dispatched and stopped), the event manager types the lead's compact command into its pane.
2322
+ # Wake-ups wait until it is done. `orch config lead-compact off` (or ORCH_LEAD_COMPACT=0) turns it off.
2323
+
2324
+ def lead_compact_on():
2325
+ env = os.environ.get("ORCH_LEAD_COMPACT")
2326
+ if env in ("0", "1"):
2327
+ return env == "1"
2328
+ return settings_load().get("lead_compact", True) is not False
2329
+
2330
+
2331
+ def lead_compacting(st):
2332
+ """True while the lead's one compact after go is sent and not over: wake-ups wait for it."""
2333
+ lc = st.get("lead_compact") or {}
2334
+ return bool(lc.get("sent")) and not lc.get("done")
2335
+
2336
+
2337
+ # ---------------------------------------------------------------- news-only lead events
2338
+ # MERGED, AUTO-DISPATCHED and ESCALATED leave the lead nothing to decide: they do not wake it on their own. They wait
2339
+ # in the queue and come with the next wake-up that needs the lead (at the latest ALL_DONE). The board, `orch view`
2340
+ # and `orch story` show them at once. `orch config news-wake on` (or ORCH_NEWS_WAKE=1) wakes the lead for them again.
2341
+ NEWS_KINDS = {"merged", "auto-dispatched", "escalated"}
2342
+
2343
+
2344
+ def news_wake_on():
2345
+ env = os.environ.get("ORCH_NEWS_WAKE")
2346
+ if env in ("0", "1"):
2347
+ return env == "1"
2348
+ return settings_load().get("news_wake") is True
2349
+
2350
+
2351
+ def wake_events(st):
2352
+ """The unread events that are worth a wake-up of their own."""
2353
+ un = unread_events(st)
2354
+ return un if news_wake_on() else [e for e in un if e["kind"] not in NEWS_KINDS]
2355
+
2356
+
2314
2357
  def compacting_line(st, name, w):
2315
2358
  h = w.get("compacting") or {}
2316
2359
  return (f"compacting its chat after {h.get('after') or '?'} ({h.get('cmd') or '/compact'}, sent "
@@ -6655,11 +6698,16 @@ def cmd_events(args):
6655
6698
  if not new and not old and not hold:
6656
6699
  print("Nothing needs you.")
6657
6700
  kinds = list(dict.fromkeys([e["kind"] for e in new + old] + (["ready"] if hold else [])))
6701
+ rules_given = False
6658
6702
  pb = asset("playbooks/run.md") if kinds else None
6659
6703
  if pb: # the playbook's own words for these events: a wake-up never needs
6660
6704
  text = pb.read_text() # `orch lead run` again, even after the lead's context was compacted
6661
6705
  print("\nWHAT TO DO (from `orch lead run`; you need no other part of the playbook for these events):")
6662
- print(run_playbook_part(text, "rules"), end="")
6706
+ full = not st.get("lead_rules")
6707
+ print(run_playbook_part(text, "rules" if full else "short"), end="")
6708
+ if full and not peek:
6709
+ st["lead_rules"] = now()
6710
+ rules_given = True
6663
6711
  rows = "".join(run_playbook_part(text, k) for k in kinds if k != "all_done")
6664
6712
  if rows:
6665
6713
  print("| Event | What you do |\n|---|---|\n" + rows, end="")
@@ -6677,6 +6725,8 @@ def cmd_events(args):
6677
6725
  st["lead_wake"]["read_ts"] = now() # for the event manager's timing line
6678
6726
  save(st)
6679
6727
  write_story(st)
6728
+ elif rules_given:
6729
+ save(st)
6680
6730
 
6681
6731
 
6682
6732
  def cmd_escalate(args):
@@ -6895,7 +6945,7 @@ def lead_unwoken(st):
6895
6945
  woken because herdr can't find it, or it did not read the wake-ups), with what to do. "" when all is read."""
6896
6946
  if not lead_on(st):
6897
6947
  return ""
6898
- un = unread_events(st)
6948
+ un = wake_events(st)
6899
6949
  if not un:
6900
6950
  return ""
6901
6951
  name, lw = st["lead"]["name"], st.get("lead_wake") or {}
@@ -7001,10 +7051,11 @@ def _autopilot(args):
7001
7051
  s_ = load()
7002
7052
  if not lead_on(s_):
7003
7053
  return
7004
- un = unread_events(s_)
7054
+ un_all = unread_events(s_)
7055
+ un = wake_events(s_)
7005
7056
  lw = s_.get("lead_wake") or {}
7006
7057
  lead = s_["lead"]["name"]
7007
- if not un:
7058
+ if not un_all:
7008
7059
  if lw.get("n") and not lw.get("ack"):
7009
7060
  patch_state(lambda s2: s2.update(lead_wake={**(s2.get("lead_wake") or {}), "ack": True}))
7010
7061
  rt, first = lw.get("read_ts"), lw.get("first_ts") or lw.get("ts")
@@ -7012,6 +7063,10 @@ def _autopilot(args):
7012
7063
  f" (read {max(0, rt - first)}s after the first wake-up, {max(0, rt - lw['oldest'])}s after the "
7013
7064
  f"oldest event; seen here {max(0, now() - rt)}s later)" if rt and first and lw.get("oldest") else ""))
7014
7065
  return
7066
+ if not un:
7067
+ return # news only: it comes with the next wake-up that needs the lead
7068
+ if lead_compacting(s_) and not force:
7069
+ return # the lead is compacting its chat after go: wake it after that
7015
7070
  newest = max(e["id"] for e in un)
7016
7071
  # a wake the lead has not acted on yet covers newer events too: it reads the whole queue when it comes
7017
7072
  same = any(e["id"] <= lw.get("upto", 0) for e in un)
@@ -7036,7 +7091,7 @@ def _autopilot(args):
7036
7091
  f"(if the wake-up text sits in its input box, press Enter), or tell it: run `orch events`. "
7037
7092
  f"{len(un)} event(s) wait for it (`orch events --peek` shows them)", True)
7038
7093
  return
7039
- text = (f"orch: {len(un)} new event(s) in the run on {s_['branch']} need the lead. Run `orch events` and "
7094
+ text = (f"orch: {len(un_all)} new event(s) in the run on {s_['branch']} need the lead. Run `orch events` and "
7040
7095
  f"handle what it prints, then stop.")
7041
7096
  try:
7042
7097
  deliver(s_, lead, text)
@@ -7051,15 +7106,91 @@ def _autopilot(args):
7051
7106
  first_ts = lw.get("first_ts", lw.get("ts")) if n else now()
7052
7107
  patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n + 1, "wait": wait,
7053
7108
  "first_ts": first_ts, "oldest": oldest}))
7054
- what = ", ".join(f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un[:6])
7109
+ what = ", ".join(f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un_all[:6])
7055
7110
  if n:
7056
7111
  say(f"the lead ({lead}) did not pick up its wake-up (" + ("idle again, " if watch else "")
7057
7112
  + f"events still unread after {now() - lw.get('ts', now())}s) -> sent it again "
7058
- f"({n + 1} of {LEAD_MAX_WAKES}): {len(un)} event(s) — {what}")
7113
+ f"({n + 1} of {LEAD_MAX_WAKES}): {len(un_all)} event(s) — {what}")
7059
7114
  else:
7060
- say(f"woke the lead ({lead}): {len(un)} event(s) — {what} (sent; it counts once the lead reads them; "
7115
+ say(f"woke the lead ({lead}): {len(un_all)} event(s) — {what} (sent; it counts once the lead reads them; "
7061
7116
  f"oldest event {max(0, now() - oldest)}s old)")
7062
7117
 
7118
+ def tend_lead_compact():
7119
+ """Once per run, when the lead is idle after go, type its tool's compact command into its pane, so the
7120
+ planning does not ride along on every later call. Wake-ups wait until herdr shows it idle again."""
7121
+ s_ = load()
7122
+ if not lead_on(s_):
7123
+ return
7124
+ lead = s_["lead"]
7125
+ name = lead["name"]
7126
+ lc = s_.get("lead_compact") or {}
7127
+ if lc.get("done"):
7128
+ return
7129
+ if lc.get("sent"):
7130
+ hs = herdr_state(name)
7131
+ busy = hs is not None and busy_word(hs)
7132
+ late = now() - lc["sent"] > COMPACT_MAX_S
7133
+ if not late and (busy or hs is None):
7134
+ if lc.get("idle_since"):
7135
+ patch_state(lambda s2: s2["lead_compact"].update(idle_since=None))
7136
+ return
7137
+ if not late and not lc.get("idle_since"):
7138
+ patch_state(lambda s2: s2["lead_compact"].update(idle_since=now()))
7139
+ return
7140
+ if not late and now() - lc["idle_since"] < COMPACT_SETTLE_S:
7141
+ return
7142
+
7143
+ def done(s2):
7144
+ s2["lead_compact"].update(done=now())
7145
+ s2["lead_rules"] = None # its next wake-up prints the full hard rules again
7146
+ story_note(s2, f"the lead's chat is now a short summary ({lc.get('cmd')}): the plan is in plan.md"
7147
+ if not late else f"the lead was still busy {_fmt_secs(COMPACT_MAX_S)} after "
7148
+ f"{lc.get('cmd')}: orch stopped waiting for its compact", who="event manager")
7149
+ patch_state(done)
7150
+ say(f"COMPACTED the lead ({name}): its chat after planning is now a short summary" if not late else
7151
+ f"the lead ({name}) is still busy {_fmt_secs(COMPACT_MAX_S)} after {lc.get('cmd')}: wake-ups go on")
7152
+ return
7153
+ tasks = s_["tasks"].values()
7154
+ if not any(t.get("go") for t in tasks) or all(t["status"] in ("merged", "skipped") for t in tasks):
7155
+ return # not started yet, or already over: nothing to gain
7156
+ if any(e["kind"] == "all_done" for e in s_.get("lead_events", [])):
7157
+ return
7158
+ if not lead_compact_on() or not watched(s_, name):
7159
+ return
7160
+ cmd, why = compact_command(s_, lead.get("kind"))
7161
+ if not cmd:
7162
+ if not lc.get("told"):
7163
+ def told(s2, why=why):
7164
+ s2["lead_compact"] = {"told": True, "done": now(), "skipped": why}
7165
+ story_note(s2, f"the lead's chat is not compacted after go: {why}", who="event manager")
7166
+ patch_state(told)
7167
+ say(f"the lead's chat is not compacted after go: {why}")
7168
+ return
7169
+ if wake_events(s_):
7170
+ return # it has news to read first; try again when it is idle
7171
+ hs = herdr_state(name)
7172
+ if hs is None or busy_word(hs):
7173
+ if lc.get("idle_seen"):
7174
+ patch_state(lambda s2: s2.update(lead_compact={**(s2.get("lead_compact") or {}), "idle_seen": None}))
7175
+ return
7176
+ if not lc.get("idle_seen"):
7177
+ patch_state(lambda s2: s2.update(lead_compact={**(s2.get("lead_compact") or {}), "idle_seen": now()}))
7178
+ return
7179
+ if now() - lc["idle_seen"] < LEAD_COMPACT_IDLE_S:
7180
+ return
7181
+ try:
7182
+ deliver(s_, name, cmd)
7183
+ except DeliveryError as e:
7184
+ say(f"could not send {cmd} to the lead ({name}): {e} — will retry")
7185
+ return
7186
+
7187
+ def sent(s2):
7188
+ s2["lead_compact"] = {"sent": now(), "cmd": cmd}
7189
+ story_note(s2, f"the lead dispatched and stopped: orch sent it {cmd} so the planning does not ride along "
7190
+ f"on every later call", who="event manager")
7191
+ patch_state(sent)
7192
+ say(f"the lead ({name}) is idle after go: sent {cmd} so its chat after planning becomes a short summary")
7193
+
7063
7194
  def lead_ready():
7064
7195
  """Ready milestones the lead has not dispatched: tell it once per set; start them ourselves after LEAD_WAIT_S."""
7065
7196
  s_ = load()
@@ -7949,6 +8080,7 @@ def _autopilot(args):
7949
8080
  guarded(tid, lambda: dispatch(kind, tid, worker))
7950
8081
  slots -= 1
7951
8082
  lead_ready()
8083
+ tend_lead_compact()
7952
8084
  wake_lead()
7953
8085
 
7954
8086
  # 3. finished or stuck?
@@ -8578,11 +8710,14 @@ def team_pick(cands, n):
8578
8710
 
8579
8711
  def cmd_team(args):
8580
8712
  """orch team <kind> [--coders N] [--models a,b] [--no-reviewer] -> the plan's team built from one tool.
8581
- orch team up [--dry-run] -> open a herdr pane for every agent in the plan that herdr cannot find."""
8713
+ orch team up [--dry-run] [--here] -> open a herdr pane for every agent in the plan that herdr cannot find.
8714
+ orch team tidy [--dry-run] -> move the open coder/reviewer panes into the team tab grid."""
8582
8715
  if args and args[0] == "up":
8583
8716
  return team_up(args[1:])
8717
+ if args and args[0] == "tidy":
8718
+ return team_tidy(args[1:])
8584
8719
  usage = ("usage: orch team <kind> [--coders N] [--models a,b] [--no-reviewer] [--prefix <name>] | "
8585
- "orch team up [--dry-run]")
8720
+ "orch team up [--dry-run] [--here] | orch team tidy [--dry-run]")
8586
8721
  rest, coders, models, reviewer, prefix = list(args), None, None, True, None
8587
8722
  if "--prefix" in rest:
8588
8723
  i = rest.index("--prefix")
@@ -8672,14 +8807,207 @@ def _herdr_json(cmd):
8672
8807
  return r.returncode == 0, data, out
8673
8808
 
8674
8809
 
8810
+ TEAM_MAX_PER_TAB = max(1, int(os.environ.get("ORCH_TEAM_MAX_PER_TAB", "4")))
8811
+ PANE_MIN_COLS = max(20, int(os.environ.get("ORCH_PANE_MIN_COLS", "80"))) # an agent's screen stays readable at this size
8812
+ PANE_MIN_ROWS = max(8, int(os.environ.get("ORCH_PANE_MIN_ROWS", "20")))
8813
+
8814
+
8815
+ def herdr_screen(pane=None):
8816
+ """(workspace id, width, height) of the tab `pane` sits in (default: the pane this runs in), in terminal cells,
8817
+ from `herdr pane layout`. Nones for what herdr can't tell."""
8818
+ cmd = [HERDR, "pane", "layout"] + (["--pane", pane] if pane else
8819
+ ["--current"] if os.environ.get("HERDR_PANE_ID") else [])
8820
+ ok, data, _ = _herdr_json(cmd)
8821
+ lay = _dicts_with(data, "tab_id") if ok and data is not None else []
8822
+ lay = next((d for d, _ in lay if isinstance(d.get("area"), dict)), None)
8823
+ ws = os.environ.get("HERDR_WORKSPACE_ID") or (lay or {}).get("workspace_id")
8824
+ area = (lay or {}).get("area") or {}
8825
+ w, h = area.get("width"), area.get("height")
8826
+ return ws, (w if isinstance(w, int) and w > 0 else None), (h if isinstance(h, int) and h > 0 else None)
8827
+
8828
+
8829
+ def team_grid(n, width, height):
8830
+ """How many panes go in one team tab, and the rows for n of them: [panes in row 1, row 2, ...]. Every pane gets
8831
+ at least PANE_MIN_COLS x PANE_MIN_ROWS of a screen this size (2 across when the size is unknown), at most
8832
+ TEAM_MAX_PER_TAB per tab, rows as even as they can be (3 -> [2, 1], 4 -> [2, 2])."""
8833
+ cols = max(1, width // PANE_MIN_COLS) if width else 2
8834
+ rows = max(1, height // PANE_MIN_ROWS) if height else 2
8835
+ cap = max(1, min(TEAM_MAX_PER_TAB, cols * rows))
8836
+ n = min(n, cap)
8837
+ r = max(1, -(-n // min(cols, n))) if n else 0
8838
+ return cap, [n // r + (1 if i < n % r else 0) for i in range(r)]
8839
+
8840
+
8841
+ def build_grid(rows, first, split):
8842
+ """Make a grid of equal panes, row by row: first() -> the top-left pane id; split(pane, direction, ratio, slot)
8843
+ -> the pane id for grid slot `slot` (row-major), cut from `pane`. Returns the pane id of every slot, None where
8844
+ herdr refused. herdr's ratio is the share the pane being split keeps, so 1/k for k panes left gives equal sizes."""
8845
+ out = [None] * sum(rows)
8846
+ top = first()
8847
+ if not top:
8848
+ return out
8849
+ starts = [sum(rows[:i]) for i in range(len(rows))]
8850
+ heads, cur = [top], top
8851
+ for i in range(1, len(rows)):
8852
+ cur = split(cur, "down", 1 / (len(rows) - i + 1), starts[i]) if cur else None
8853
+ heads.append(cur)
8854
+ for head, k, s in zip(heads, rows, starts):
8855
+ cur = out[s] = head
8856
+ for j in range(1, k):
8857
+ cur = out[s + j] = split(cur, "right", 1 / (k - j + 1), s + j) if cur else None
8858
+ return out
8859
+
8860
+
8861
+ def team_tab_label(i, st=None):
8862
+ """"team", "team 2", ...; in a workspace of several repos each repo's team gets its own: "backend team"."""
8863
+ base = f"{ROOT.name} team" if (st or {}).get("workspace") and ROOT else "team"
8864
+ return base if i == 0 else f"{base} {i + 1}"
8865
+
8866
+
8867
+ def _new_pane_id(ok, data, out, key="pane"):
8868
+ """The pane id in a herdr answer: .result.<key>.pane_id (pane split: pane, tab create: root_pane), loosely."""
8869
+ if not ok:
8870
+ return None
8871
+ res = (data or {}).get("result") if isinstance(data, dict) else None
8872
+ pid = _find_key((res or {}).get(key), "pane_id") if isinstance(res, dict) else None
8873
+ return pid or (re.search(r'"pane_id"\s*:\s*"([\w:.-]+)"', out or "") or [None, None])[1]
8874
+
8875
+
8876
+ def team_tab_panes(new, dry=False, lead_pane=None, st=None):
8877
+ """Open one pane per (name, folder) in `new`, in new herdr tabs ("team", "team 2", ...) laid out by team_grid.
8878
+ Returns ({name: pane id, None when herdr refused; dry: the command it would run}, {name: why it failed},
8879
+ [tab labels]). When herdr can't make the first tab (an older herdr), returns ({}, {}, []) after a NOTE, and
8880
+ team up opens the panes next to this one as before."""
8881
+ ws, w, h = herdr_screen(lead_pane)
8882
+ cap, _ = team_grid(len(new), w, h)
8883
+ placed, errs, labels = {}, {}, []
8884
+ q = lambda c: " ".join(shlex.quote(str(x)) for x in c)
8885
+ for c, i in enumerate(range(0, len(new), cap)):
8886
+ chunk, label = new[i:i + cap], team_tab_label(c, st)
8887
+ _, rows = team_grid(len(chunk), w, h)
8888
+ tab_cmd = [HERDR, "tab", "create"] + (["--workspace", ws] if ws else []) + \
8889
+ ["--cwd", chunk[0][1], "--label", label, "--no-focus"]
8890
+
8891
+ def first():
8892
+ if dry:
8893
+ placed[chunk[0][0]] = f"new tab: {q(tab_cmd)}"
8894
+ return f"<{chunk[0][0]}>"
8895
+ ok, data, out = _herdr_json(tab_cmd)
8896
+ pid = _new_pane_id(ok, data, out, "root_pane")
8897
+ if not pid:
8898
+ errs[chunk[0][0]] = out.splitlines()[-1] if out else "no output"
8899
+ return pid
8900
+
8901
+ def split(cur, direction, ratio, slot):
8902
+ name, d = chunk[slot]
8903
+ cmd = [HERDR, "pane", "split", cur, "--direction", direction, "--ratio", f"{ratio:.3f}",
8904
+ "--cwd", d, "--no-focus"]
8905
+ if dry:
8906
+ placed[name] = q(cmd)
8907
+ return f"<{name}>"
8908
+ ok, data, out = _herdr_json(cmd)
8909
+ pid = _new_pane_id(ok, data, out)
8910
+ if not pid:
8911
+ errs[name] = out.splitlines()[-1] if out else "no output"
8912
+ return pid
8913
+
8914
+ pids = build_grid(rows, first, split)
8915
+ if c == 0 and not pids[0] and not dry:
8916
+ print(f"NOTE herdr could not open a tab for the team ({errs.get(chunk[0][0])}), so the panes open "
8917
+ f"next to this one")
8918
+ return {}, {}, []
8919
+ if not dry:
8920
+ placed.update({n: p for (n, _), p in zip(chunk, pids)})
8921
+ for (n, _), p in zip(chunk, pids):
8922
+ if not p and n not in errs:
8923
+ errs[n] = "the pane it splits from was not opened"
8924
+ labels.append(label)
8925
+ return placed, errs, labels
8926
+
8927
+
8928
+ def team_tidy(args):
8929
+ """Move the coders' and the reviewer's panes that are open now (opened by hand, or by an older orch next to the
8930
+ lead) into team tabs, as a grid of equal panes, the same layout `orch team up` opens. The agents keep running
8931
+ and keep their names. Never moves the lead's pane or the pane this runs in."""
8932
+ usage = "usage: orch team tidy [--dry-run]"
8933
+ if any(a != "--dry-run" for a in args):
8934
+ die(usage)
8935
+ dry = "--dry-run" in args
8936
+ st = load()
8937
+ if run_mode(st) == "subagent":
8938
+ print("mode subagent: no panes to arrange; the coder and the reviewer are Pi subagents")
8939
+ return
8940
+ names = [(n, w) for n, w in st["workers"].items()]
8941
+ if st.get("reviewer"):
8942
+ names.append((st["reviewer"], st.get("reviewer_info") or {}))
8943
+ lead = (st.get("lead") or {}).get("name")
8944
+ lead_pane = (st.get("lead") or {}).get("pane") or (agent_pane(lead) if lead else None)
8945
+ keep = {lead_pane, os.environ.get("HERDR_PANE_ID")} - {None}
8946
+ panes = []
8947
+ for n, w in names:
8948
+ p = w.get("pane") or agent_pane(n)
8949
+ if not p:
8950
+ print(f"skip {n}: herdr can't find it (`orch team up` opens it)")
8951
+ elif p in keep:
8952
+ print(f"skip {n}: pane {p} is the lead's (or this) pane, it stays where it is")
8953
+ else:
8954
+ panes.append((n, p))
8955
+ if not panes:
8956
+ print("TEAM TIDY: no coder or reviewer pane to arrange")
8957
+ return
8958
+ ws, w, h = herdr_screen(lead_pane)
8959
+ cap, _ = team_grid(len(panes), w, h)
8960
+ q = lambda c: " ".join(shlex.quote(str(x)) for x in c)
8961
+ failed, labels = 0, []
8962
+ for c, i in enumerate(range(0, len(panes), cap)):
8963
+ chunk, label, tab = panes[i:i + cap], team_tab_label(c, st), [None]
8964
+ _, rows = team_grid(len(chunk), w, h)
8965
+
8966
+ def move(cmd, name, old):
8967
+ if dry:
8968
+ print(f"WOULD {name}: {q(cmd)}")
8969
+ return f"<{name}>"
8970
+ ok, data, out = _herdr_json(cmd)
8971
+ res = ((data or {}).get("result") or {}).get("move_result") if ok and isinstance(data, dict) else None
8972
+ pid = _find_key((res or {}).get("pane"), "pane_id") if isinstance(res, dict) else None
8973
+ tab[0] = tab[0] or (_find_key((res or {}).get("pane"), "tab_id") if isinstance(res, dict) else None)
8974
+ if not pid:
8975
+ print(f"FAILED {name}: herdr could not move pane {old} ({out.splitlines()[-1] if out else 'no output'})")
8976
+ return None
8977
+ print(f"MOVED {name}: pane {old} -> tab \"{label}\"" + (f" (now {pid})" if pid != old else ""))
8978
+ return pid
8979
+
8980
+ def first():
8981
+ n, p = chunk[0]
8982
+ return move([HERDR, "pane", "move", p, "--new-tab"] + (["--workspace", ws] if ws else []) +
8983
+ ["--label", label, "--no-focus"], n, p)
8984
+
8985
+ def split(cur, direction, ratio, slot):
8986
+ n, p = chunk[slot]
8987
+ if not dry and not tab[0]:
8988
+ print(f"FAILED {n}: herdr did not say which tab \"{label}\" is, so pane {p} stays where it is")
8989
+ return None
8990
+ return move([HERDR, "pane", "move", p, "--tab", tab[0] or f"<tab {label}>", "--split", direction,
8991
+ "--target-pane", cur, "--ratio", f"{ratio:.3f}", "--no-focus"], n, p)
8992
+
8993
+ failed += sum(1 for x in build_grid(rows, first, split) if not x)
8994
+ labels.append(label)
8995
+ if dry:
8996
+ return
8997
+ print(f"TEAM TIDY: {'done' if not failed else f'{failed} pane(s) not moved — see above'}; the team is in the "
8998
+ f"herdr tab{'s' if len(labels) > 1 else ''} " + ", ".join(f'"{t}"' for t in labels))
8999
+ if failed:
9000
+ sys.exit(3)
9001
+
9002
+
8675
9003
  def team_up(args):
8676
9004
  """Open a pane for every worker and the reviewer in the plan that herdr can't find: split from this pane, cd
8677
9005
  into the agent's folder (its worktree, or the repo), start it on its plan model, and give it its plan name."""
8678
9006
  args = list(args)
8679
- flag = mode_flag(args, "usage: orch team up [--dry-run] [--mode panes|subagent]")
9007
+ flag = mode_flag(args, "usage: orch team up [--dry-run] [--here] [--mode panes|subagent]")
8680
9008
  dry = "--dry-run" in args
8681
9009
  if flag and not dry:
8682
- set_mode(flag, hint=False, agent=mode_target(flag, "usage: orch team up [--dry-run] [--mode panes|subagent]"))
9010
+ set_mode(flag, hint=False, agent=mode_target(flag, "usage: orch team up [--dry-run] [--here] [--mode panes|subagent]"))
8683
9011
  st = load()
8684
9012
  if (flag or run_mode(st)) == "subagent":
8685
9013
  print("mode subagent: no panes to open; the coder and the reviewer are Pi subagents")
@@ -8713,22 +9041,38 @@ def team_up(args):
8713
9041
  print("TEAM UP: every agent in the plan is running")
8714
9042
  return
8715
9043
  failed, last, opened = 0, None, []
9044
+ runnable = []
8716
9045
  for name, w, d in todo:
8717
- kind, model = w.get("kind"), w.get("model")
8718
- v = reg.get(kind)
9046
+ v = reg.get(w.get("kind"))
8719
9047
  if not v:
8720
- print(f"SKIP {name}: kind {kind!r} is not in the agent registry — start it yourself in {d}")
9048
+ print(f"SKIP {name}: kind {w.get('kind')!r} is not in the agent registry — start it yourself in {d}")
8721
9049
  failed += 1
8722
9050
  continue
9051
+ runnable.append((name, w, d, v))
9052
+ # new panes go in a herdr tab of their own ("team"), as a grid of equal panes, so the lead keeps its whole
9053
+ # screen and every agent stays readable; --here (or a herdr that can't make tabs) splits next to this pane
9054
+ new = [(n, d) for n, w, d, v in runnable if not empty.get(n)]
9055
+ placed, errs, tabs = {}, {}, []
9056
+ if new and "--here" not in args:
9057
+ placed, errs, tabs = team_tab_panes(new, dry, lead_pane, st)
9058
+ for name, w, d, v in runnable:
9059
+ kind, model = w.get("kind"), w.get("model")
8723
9060
  cmd = launch_cmd(kind, v, model, strict=False, role="reviewer" if name == st.get("reviewer") else None, cwd=d)
8724
9061
  split = [HERDR, "pane", "split"] + ([last] if last else []) + \
8725
9062
  ["--direction", "down" if last else "right", "--cwd", d, "--no-focus"]
8726
9063
  if dry:
8727
- print(f"WOULD {name}: {' '.join(shlex.quote(x) for x in split)} then herdr pane run <new pane> "
9064
+ how = placed.get(name) or " ".join(shlex.quote(x) for x in split)
9065
+ print(f"WOULD {name}: {how} then herdr pane run <new pane> "
8728
9066
  f"{shlex.quote(cmd)} then herdr agent rename <new pane> {name}")
8729
9067
  continue
8730
9068
  pid = empty.get(name)
8731
- if not pid:
9069
+ if not pid and name in placed:
9070
+ pid = placed[name]
9071
+ if not pid:
9072
+ print(f"FAILED {name}: herdr could not open its pane in the team tab ({errs.get(name) or 'no output'})")
9073
+ failed += 1
9074
+ continue
9075
+ elif not pid:
8732
9076
  ok, data, out = _herdr_json(split)
8733
9077
  try:
8734
9078
  pid = data["result"]["pane"]["pane_id"] if ok else None
@@ -8782,6 +9126,10 @@ def team_up(args):
8782
9126
  + (f" (its last screen is in {short(saved)})" if saved else "") + ", then `orch team up` again")
8783
9127
  log_line(f"{run_tag(st)} QUIT {name}: {w.get('kind')} exited right after `orch team up` started it "
8784
9128
  f"in pane {pid}")
9129
+ if tabs and not dry:
9130
+ print(f"TAB the team is in the herdr tab{'s' if len(tabs) > 1 else ''} " + ", ".join(f'"{t}"' for t in tabs)
9131
+ + ", so the lead keeps its whole screen — switch tabs to watch them (`orch team tidy` moves panes "
9132
+ "opened by hand there too)")
8785
9133
  print("TEAM UP: done — run `orch start` again; every agent should show herdr=found" if not failed else
8786
9134
  f"TEAM UP: {failed} agent(s) not ready — see above, then `orch team up` again")
8787
9135
  if failed:
@@ -10615,10 +10963,15 @@ USAGE = """usage: orch <command> [args]
10615
10963
  update [--check] [--version vX.Y.Z] install the latest release (or that one) and show what is new
10616
10964
  config [auto-update on|off] this machine's settings: keep orch up to date by itself, or only be told
10617
10965
  config compact on|off a coder or the reviewer gets /compact when its milestone is done (on by default for
10618
- Claude Code, Codex and AGY 1.2.15+; never the lead). ORCH_COMPACT=0|1 overrides it
10619
- lead plan|run print the lead playbook (any agent can lead: "Run `orch lead plan` and follow it")
10620
- lead plan quick|full the rest of the plan playbook: a quick run's rules, or steps 3-10 of the full process
10621
- lead run --section <EVENT|ALL_DONE|rules> one part of the run playbook (orch events prints these for you)
10966
+ Claude Code, Codex and AGY 1.2.15+). ORCH_COMPACT=0|1 overrides it
10967
+ config lead-compact on|off the lead gets /compact once per run, when it is idle after go (on by default).
10968
+ ORCH_LEAD_COMPACT=0|1 overrides it
10969
+ config news-wake on|off MERGED, AUTO-DISPATCHED and ESCALATED wake the lead at once (off by default: they come
10970
+ with its next wake-up). ORCH_NEWS_WAKE=0|1 overrides it
10971
+ lead plan|run print the lead playbook (any agent can lead: "Run `orch lead plan` and follow it");
10972
+ during a run, `lead run` prints only the rules, the developer's part and open events
10973
+ lead plan quick|full the rest of the plan playbook: a quick run's steps and rules, or steps 3-10 of the full process
10974
+ lead run --section <EVENT|ALL_DONE|rules|short|developer> one part of the run playbook (orch events prints these)
10622
10975
  lead onboard the setup playbook: set this project up for its agents (rules, skills) with the
10623
10976
  developer's tick; `orch lead plan` points the lead to it when a project needs it
10624
10977
  onboard [--json] [--all] what the project has for its agents: stack, commands, rule files, the skills each
@@ -10636,9 +10989,13 @@ USAGE = """usage: orch <command> [args]
10636
10989
  team <kind> [--coders N] [--models a,b] [--no-reviewer] [--prefix <name>]
10637
10990
  the plan's team built from one installed tool: coders + reviewer on its catalog models
10638
10991
  (named after the repo, e.g. app-codex-1, while another run is going on this machine)
10639
- team up [--dry-run] [--mode panes|subagent]
10640
- open a herdr pane for every agent in the plan herdr can't find, in its folder, and name it
10641
- (subagent mode: no panes; sets up the Pi coder/reviewer subagents instead)
10992
+ team up [--dry-run] [--here] [--mode panes|subagent]
10993
+ open a herdr pane for every agent in the plan herdr can't find, in its folder, and name it,
10994
+ in a herdr tab of their own ("team") as a grid of equal panes (at most 4 a tab, fewer on a
10995
+ small screen; more go to "team 2"), so the lead keeps its whole screen. --here: split
10996
+ next to this pane instead (subagent mode: no panes; sets up the Pi subagents instead)
10997
+ team tidy [--dry-run] move the coder and reviewer panes already open (by hand, or next to the lead) into that
10998
+ team tab grid; they keep running and keep their names. Never moves the lead's pane
10642
10999
  mode [panes|subagent] [--agent <kind>] this agent's mode, or save one: panes (herdr panes, the default for
10643
11000
  every agent) or subagent (one Pi window; Pi only). Saved per agent in
10644
11001
  ~/.config/herdr-orchestra/config.json ("modes": {"pi": "subagent"}); ORCH_MODE=panes|subagent
@@ -10877,10 +11234,17 @@ def plan_playbook_part(text, part):
10877
11234
  """The plan playbook in parts, so a quick run doesn't read the whole full process:
10878
11235
  "" = the start (role, preflight, research, quick-or-full, plus the `<!-- start -->` blocks of the full part);
10879
11236
  "quick" = the `<!-- quick: title -->` blocks (rules a quick plan uses, word for word from the full process);
10880
- "full" = steps 3 to 10. start + full is every line of the playbook exactly once."""
11237
+ "full" = steps 3 to 10. start + full + the quick run's own steps (first in "quick") is every line of the
11238
+ playbook exactly once."""
10881
11239
  lines = text.splitlines(keepends=True)
10882
11240
  cut = next((i for i, l in enumerate(lines) if l.strip() == "<!-- full -->"), len(lines))
10883
11241
  head, rest = lines[:cut], lines[cut + 1:]
11242
+ # the quick run's own steps (in the start part, between <!-- quick-run --> marks) go only to a quick run
11243
+ q0 = next((i for i, l in enumerate(head) if l.strip() == "<!-- quick-run -->"), None)
11244
+ q1 = next((i for i, l in enumerate(head) if l.strip() == "<!-- /quick-run -->"), None)
11245
+ quick_steps = []
11246
+ if q0 is not None and q1 is not None and q1 > q0:
11247
+ quick_steps, head = head[q0 + 1:q1], head[:q0] + head[q1 + 1:]
10884
11248
  blocks, out, cur, title = {"start": [], "quick": []}, [], None, ""
10885
11249
  for l in rest:
10886
11250
  m = PB_MARK_RE.match(l.strip())
@@ -10901,7 +11265,8 @@ def plan_playbook_part(text, part):
10901
11265
  if part == "full":
10902
11266
  return "".join(out)
10903
11267
  if part == "quick":
10904
- return "".join(f"## {t}\n{''.join(b)}\n" for t, b in blocks["quick"])
11268
+ return ((f"## A quick run, step by step (the rest of step 2b)\n{''.join(quick_steps)}\n" if quick_steps else "")
11269
+ + "".join(f"## {t}\n{''.join(b)}\n" for t, b in blocks["quick"]))
10905
11270
  return "".join(head) + "".join(f"\n## {t} (from the full process)\n{''.join(b)}" for t, b in blocks["start"])
10906
11271
 
10907
11272
 
@@ -10919,10 +11284,14 @@ def run_playbook_part(text, name):
10919
11284
  secs = re.split(r"(?m)^(?=## )", text)
10920
11285
  if key in ("rules", "hard rules"):
10921
11286
  return next((x for x in secs if x.startswith("## Hard rules")), "")
11287
+ if key in ("short", "rules short"):
11288
+ return next((x for x in secs if x.startswith("## Rules in short")), "")
11289
+ if key in ("developer", "2b"):
11290
+ return next((x for x in secs if x.startswith("## 2b.")), "")
10922
11291
  if key in ("all_done", "all-done", "3"):
10923
11292
  return next((x for x in secs if x.startswith("## 3. ALL_DONE")), "")
10924
11293
  kind = EVENT_ROWS.get(key, key.upper())
10925
- rows = [l for l in text.splitlines() if re.match(rf"^\| `{re.escape(kind)}\b", l)
11294
+ rows = [l for l in text.splitlines() if re.match(rf"^\| (`[A-Z_-]+[^`]*`, )*`{re.escape(kind)}\b", l)
10926
11295
  or (kind == "STOPPED" and l.startswith("| `STOPPED`"))]
10927
11296
  if kind == "STOPPED":
10928
11297
  rows += [l for l in text.splitlines() if l.startswith(("| `orch status` starts with", "**Red baseline.**",
@@ -10930,6 +11299,73 @@ def run_playbook_part(text, name):
10930
11299
  return "\n".join(rows) + ("\n" if rows else "")
10931
11300
 
10932
11301
 
11302
+ RUN_GO_SKIP = ("## Rules in short", "## 2. ", "## 2b.", "## 3. ")
11303
+
11304
+
11305
+ def run_playbook_go(text):
11306
+ """What `orch lead run` prints when the developer says go: the playbook without the parts that `orch events`
11307
+ prints exactly when they are needed (the event table, ALL_DONE) and without the part for the developer's
11308
+ messages during a run (`orch lead run` prints that once a run is going)."""
11309
+ secs = re.split(r"(?m)^(?=## )", text)
11310
+ return ("".join(x for x in secs if not x.startswith(RUN_GO_SKIP))
11311
+ + "\n## Later in the run\nOn a wake-up, `orch events` prints the steps for its events (section 2 of this "
11312
+ "playbook) and, when every milestone has landed, section 3 (ALL_DONE). When the developer writes to you "
11313
+ "during the run, run `orch lead run` again: it prints the part for that. `orch lead run --section "
11314
+ "<EVENT | ALL_DONE | rules>` prints one part again.\n")
11315
+
11316
+
11317
+ def run_going(st):
11318
+ """A run of this plan has started (something was dispatched) and the lead runs it through events."""
11319
+ return bool(st) and lead_on(st) and bool(st.get("tasks")) and (
11320
+ not plan_not_started(st) or any(t.get("go") for t in st["tasks"].values()))
11321
+
11322
+
11323
+ def run_playbook_mid(text, st):
11324
+ """What `orch lead run` prints while a run is going (the developer wrote to the lead): the hard rules, the part
11325
+ for the developer's messages, the steps for every event open now, and ALL_DONE once every milestone landed."""
11326
+ secs = re.split(r"(?m)^(?=## )", text)
11327
+ intro = secs[0] if not secs[0].startswith("## ") else ""
11328
+ evs = [e for e in st.get("lead_events", []) if event_open(st, e)]
11329
+ kinds = list(dict.fromkeys([e["kind"] for e in evs] + (["ready"] if undispatched(st) else [])))
11330
+ done = all(st["tasks"][k]["status"] in ("merged", "skipped") for k in st["order"])
11331
+ out = [f"RUN IN PROGRESS on {st.get('branch')}: the developer's message is input to this run (an answer, an "
11332
+ f"approval, a change of team or model). Section 1 (go) is over: never run `orch start` or dispatch again "
11333
+ f"unless a step below says so.\n\n", intro,
11334
+ run_playbook_part(text, "rules"), next((x for x in secs if x.startswith("## Context budget")), ""),
11335
+ run_playbook_part(text, "developer")]
11336
+ rows = "".join(run_playbook_part(text, k) for k in kinds if k != "all_done")
11337
+ if rows:
11338
+ out.append("## Events open now (from section 2)\n| Event | What you do |\n|---|---|\n" + rows + "\n")
11339
+ if done or "all_done" in kinds:
11340
+ out.append(run_playbook_part(text, "ALL_DONE"))
11341
+ out.append("Any other event: `orch lead run --section <EVENT>` prints its steps; `orch events` lists what is "
11342
+ "open.\n")
11343
+ return "".join(out)
11344
+
11345
+
11346
+ def lead_run_state():
11347
+ """`orch lead run` runs outside the repo commands: the state of this repo's run (binding ROOT, ORCH and STATE to
11348
+ it), or None when there is no run here."""
11349
+ global ROOT, ORCH, STATE
11350
+ with contextlib.suppress(Exception):
11351
+ p = _repo_state_path()
11352
+ if p:
11353
+ ROOT, ORCH, STATE = p.parent.parent, p.parent, p
11354
+ return load()
11355
+ return None
11356
+
11357
+
11358
+ def lead_rules_seen():
11359
+ """The lead was just given the full hard rules (`orch lead run`): its next wake-ups print the short form."""
11360
+ with contextlib.suppress(Exception):
11361
+ if STATE and STATE.exists():
11362
+ with state_lock():
11363
+ s_ = load()
11364
+ if lead_on(s_):
11365
+ s_["lead_rules"] = now()
11366
+ save(s_)
11367
+
11368
+
10933
11369
  def lead_name_here():
10934
11370
  """(state or None, the lead's name) for the repo this runs in: plan.md's `Lead:` first (it is what the developer
10935
11371
  wrote, even before `orch sync`), then the run's state.json, else `lead`. Never fails."""
@@ -11003,7 +11439,14 @@ def cmd_lead(args):
11003
11439
  print(onboard_plan_note(), end="") # a project never set up for its agents: set it up first
11004
11440
  if subagent and sub == "plan":
11005
11441
  print(SUBAGENT_PLAN_NOTE, end="")
11006
- print(plan_playbook_part(pb.read_text(), part) if sub == "plan" else pb.read_text(), end="")
11442
+ if sub == "plan":
11443
+ print(plan_playbook_part(pb.read_text(), part), end="")
11444
+ elif subagent:
11445
+ print(pb.read_text(), end="")
11446
+ else:
11447
+ st = lead_run_state()
11448
+ print(run_playbook_mid(pb.read_text(), st) if run_going(st) else run_playbook_go(pb.read_text()), end="")
11449
+ lead_rules_seen()
11007
11450
  return
11008
11451
  if sub == "onboard":
11009
11452
  pb = asset("playbooks/onboard.md") or die("playbooks/onboard.md not found next to orch or in the install")
@@ -12849,7 +13292,7 @@ def cmd_sub(args):
12849
13292
 
12850
13293
 
12851
13294
  def cmd_config(args):
12852
- """orch config -> this machine's settings; orch config auto-update on|off; orch config compact on|off."""
13295
+ """orch config -> this machine's settings; orch config auto-update|compact|lead-compact|news-wake on|off."""
12853
13296
  if args[:1] == ["auto-update"] and args[1:2] and args[1].lower() in ("on", "off"):
12854
13297
  s = settings_load()
12855
13298
  s["auto_update"] = args[1].lower() == "on"
@@ -12866,8 +13309,25 @@ def cmd_config(args):
12866
13309
  "(/compact) when its milestone is done, before it starts another one" if s["compact"] else
12867
13310
  " — orch never compacts an agent's chat; the tools still compact by themselves when the chat is full"))
12868
13311
  return
13312
+ if args[:1] == ["lead-compact"] and args[1:2] and args[1].lower() in ("on", "off"):
13313
+ s = settings_load()
13314
+ s["lead_compact"] = args[1].lower() == "on"
13315
+ settings_save(s)
13316
+ print(f"lead-compact: {args[1].lower()}" + (" — once per run, when the lead is idle after go, it gets its "
13317
+ "tool's compact command (/compact), so the planning does not ride along on every later call"
13318
+ if s["lead_compact"] else " — orch never compacts the lead's chat"))
13319
+ return
13320
+ if args[:1] == ["news-wake"] and args[1:2] and args[1].lower() in ("on", "off"):
13321
+ s = settings_load()
13322
+ s["news_wake"] = args[1].lower() == "on"
13323
+ settings_save(s)
13324
+ print(f"news-wake: {args[1].lower()}" + (" — MERGED, AUTO-DISPATCHED and ESCALATED wake the lead at once"
13325
+ if s["news_wake"] else " — MERGED, AUTO-DISPATCHED and ESCALATED wait for the lead's next wake-up "
13326
+ "(the board, orch view and orch story show them at once)"))
13327
+ return
12869
13328
  if args:
12870
- die("usage: orch config | orch config auto-update on|off | orch config compact on|off")
13329
+ die("usage: orch config | orch config auto-update on|off | orch config compact on|off | "
13330
+ "orch config lead-compact on|off | orch config news-wake on|off")
12871
13331
  s = settings_load()
12872
13332
  env = os.environ.get("ORCH_AUTO_UPDATE")
12873
13333
  print(f"auto-update: {'on' if auto_update_on() else 'off'}"
@@ -12880,6 +13340,14 @@ def cmd_config(args):
12880
13340
  + (f" (ORCH_COMPACT={cenv} overrides the saved setting)" if cenv in ("0", "1") else "")
12881
13341
  + (f" — coders and the reviewer on {', '.join(kinds)} get /compact between milestones; "
12882
13342
  "`orch config compact off` turns it off" if compact_on() and kinds else ""))
13343
+ lenv, nenv = os.environ.get("ORCH_LEAD_COMPACT"), os.environ.get("ORCH_NEWS_WAKE")
13344
+ print(f"lead-compact: {'on' if lead_compact_on() else 'off'}"
13345
+ + (f" (ORCH_LEAD_COMPACT={lenv} overrides the saved setting)" if lenv in ("0", "1") else "")
13346
+ + (" — the lead's chat is compacted once, after go" if lead_compact_on() else ""))
13347
+ print(f"news-wake: {'on' if news_wake_on() else 'off'}"
13348
+ + (f" (ORCH_NEWS_WAKE={nenv} overrides the saved setting)" if nenv in ("0", "1") else "")
13349
+ + (" — MERGED, AUTO-DISPATCHED and ESCALATED wake the lead at once" if news_wake_on() else
13350
+ " — MERGED, AUTO-DISPATCHED and ESCALATED come with the lead's next wake-up"))
12883
13351
  print(f"installed: {installed_version()}" + ("" if release_install() else " (not a release install: no update checks)"))
12884
13352
  lc = int(s.get("last_check") or 0)
12885
13353
  print("last check: " + (time.strftime("%Y-%m-%d %H:%M", time.localtime(lc)) if lc else "never")
@@ -12974,7 +13442,7 @@ if __name__ == "__main__":
12974
13442
  "team": cmd_team, "update": cmd_update, "config": cmd_config, "mode": cmd_mode,
12975
13443
  "setup": cmd_setup, "guard": cmd_guard}
12976
13444
  if (len(sys.argv) >= 2 and sys.argv[1] in NO_REPO_COMMANDS # work outside a git repo
12977
- and sys.argv[2:3] != ["up"] and sys.argv[2:3] != ["--crash"]): # (`orch team up` reads the run's state)
13445
+ and sys.argv[2:3] not in (["up"], ["tidy"], ["--crash"])): # (`orch team up|tidy` read the run's state)
12978
13446
  try:
12979
13447
  NO_REPO_COMMANDS[sys.argv[1]](sys.argv[2:])
12980
13448
  sys.stdout.flush()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.45.0",
3
+ "version": "6.47.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": {
@@ -1,6 +1,6 @@
1
1
  ---
2
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."
3
+ description: "Lead a Herdr agent team, step 1 - plan a feature or a small change (start the request with quick: or full: to choose). Use when the user says orch-plan or asks to plan or orchestrate a feature. Does NOT execute until the developer says go."
4
4
  ---
5
5
 
6
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.
package/playbooks/plan.md CHANGED
@@ -68,7 +68,8 @@ If any is false, use the full process: run `orch lead plan full` and follow its
68
68
  - The developer wrote `full:`: plan in full (`orch lead plan full`), even for a small change.
69
69
 
70
70
  **A quick run, step by step** (in place of steps 3 to 10):
71
- - **First run `orch lead plan quick`.** It prints the rules a quick plan uses, word for word from the full process: the split test, the tiers, the estimate, the check command and how to write acceptance criteria and Likely files. Don't run `orch lead plan full` for a quick run.
71
+ - **First run `orch lead plan quick`.** It prints the rest of these steps (team, fields, header, the plan format) and the rules a quick plan uses, word for word from the full process: the split test, the tiers, the estimate, the check command and how to write acceptance criteria and Likely files. Don't run `orch lead plan full` for a quick run.
72
+ <!-- quick-run -->
72
73
  - **Team: one coder, no reviewer.** Your pane is named `lead` already (`orch lead plan` did it; if it printed a rename command, run it). Pick ONE coder pane whose model fits the tier (a free pane of any kind; if only you are open, `orch team <your kind> --coders 1 --no-reviewer`). `Reviewer: none`, unless the developer wrote `quick review:`: then one reviewer pane and `Review: yes`. Why no reviewer: a quick change is small and stays out of risky areas, the check command (lint, types, tests) still has to pass before it lands, and the developer looks at UI changes in the browser anyway; the reviewer is often the slowest step of a small run.
73
74
  - **One milestone** that holds every change in the request, with **one acceptance criterion per change**, so the coder and the summary go through them one by one.
74
75
  - **Fields:** only `Tier`, `Estimate`, `Likely files`, `Goal`, `Acceptance criteria` and the `Context` facts the coder needs to find their way (plus `Skills:` when a project skill fits). Leave out `Feature breakdown`, `Why separate`, `Needs`, `Model why`, `Role`, `Interfaces` (none) and `Prefer` unless one really helps. A backend change gets an acceptance criterion a test can prove (e.g. "GET /orders returns `createdAt` as ISO 8601; a test covers it").
@@ -109,6 +110,7 @@ Open questions:
109
110
  ```
110
111
 
111
112
  Then the run is the same as any run (`orch lead run`): the coder builds it, the check runs, and it lands on the branch; when the check already passed on exactly the files on the branch, the final check and `orch finish` reuse that result instead of running it again. The summary is short (step 3 of `orch lead run`). The risk hold still applies: if the coder's change turns out to touch a migration, CI, secrets, a package or many lines, it is held: the lead may approve a migration file, CI, a package or many lines after reading the change (`orch approve M1 --lead "<why>"`); deleted files and secrets wait for the developer. After it lands, more small changes go straight to the same coder with `orch fix M1 "<change>"`.
113
+ <!-- /quick-run -->
112
114
 
113
115
  <!-- full -->
114
116
  ## 3. Discover the team
package/playbooks/run.md CHANGED
@@ -21,6 +21,19 @@ A run behaves like a call stack. You **dispatch** work and **pause**. The **even
21
21
  8. **Never push to main.** No agent of the run (you, the coders, the reviewer) ever pushes to main, master or the repo's default branch, or merges a PR (`gh pr merge`, a merge on GitHub, `git push origin HEAD:main`, a force push), in any situation, even when the developer tells you to. Refuse in one line and offer the safe way: "I can't push to main, even when asked: that's a hard rule of this setup. The work is on <branch>; `orch finish` pushes that branch and opens a PR, and you merge it yourself." `orch finish` only ever pushes the run's branch. The repo's pre-push guard (`orch guard`) refuses a push to main anyway: never get around it (`--no-verify`, editing or deleting `.git/hooks`, `git config core.hooksPath`).
22
22
  9. **The developer's model choices stay.** A milestone with `Model:` in plan.md ("locked by you" in `orch plan team`) runs only on that model, and the reviewer keeps the model the developer gave it. Change one only when the developer asks: `orch plan model <Mn|reviewer> <model>@<thinking>`.
23
23
 
24
+ ## Rules in short (later wake-ups)
25
+ `orch events` prints these on a wake-up once it has given you the full hard rules in this chat; they are the same rules, shorter. `orch lead run --section rules` prints the full text.
26
+ 0. You decide what and why; coders decide how. A missing fact or constraint goes in the plan, never a how-to.
27
+ 1. You never edit application code: only `orch`, its files and `.orchestrate/plan.md`.
28
+ 2. You never prompt a worker or your own pane: only the event manager sends prompts.
29
+ 3. Never guess: what only the developer can settle goes to them with 2–3 options; answer a coder yourself only when the request, the plan or the code settles it, and say where from.
30
+ 4. Never answer a worker's permission prompt yourself. A held milestone: approve it yourself only when orch says the lead may (`orch approve Mn --lead "<why it is safe>"`, after you read the change). When it says only the developer may (hard to undo, deleted files, secrets files), run `orch approve Mn` only after the developer tells you to in your chat ("approve Mn"), never on your own.
31
+ 5. `orch set` only to `pending`, `paused`, `failed` or `skipped`; never `--force`.
32
+ 6. After a step that ends in **STOP**, stop: no sleep, loop or check back.
33
+ 7. Never end a wake-up silently: one short line per event in your chat, its `SAY:` line and what you did about it.
34
+ 8. **Never push to main.** No agent of the run (you, the coders, the reviewer) ever pushes to main, master or the repo's default branch, or merges a PR (`gh pr merge`, a merge on GitHub, `git push origin HEAD:main`, a force push), in any situation, even when the developer tells you to. Refuse in one line and offer the safe way: "I can't push to main, even when asked: that's a hard rule of this setup. The work is on <branch>; `orch finish` pushes that branch and opens a PR, and you merge it yourself." `orch finish` only ever pushes the run's branch. The repo's pre-push guard (`orch guard`) refuses a push to main anyway: never get around it (`--no-verify`, editing or deleting `.git/hooks`, `git config core.hooksPath`).
35
+ 9. A model the developer chose (`Model:`, "locked by you") stays; change it only when they ask: `orch plan model <Mn|reviewer> <model>@<thinking>`.
36
+
24
37
  ## Context budget (credits scale with how much you read and how many turns you take)
25
38
  - Your memory is `orch events` + `orch status` + files on disk, not this conversation. Never re-read old reports, diffs, plans or this playbook "to refresh": `orch events` prints what each wake-up needs.
26
39
  - Never print whole files or logs into the conversation: logs → `tail -30 .orchestrate/autopilot.log`; reports → the report or result file only (workers keep them short); never open `diff.patch` yourself — that is the reviewer's job.
@@ -28,18 +41,18 @@ A run behaves like a call stack. You **dispatch** work and **pause**. The **even
28
41
 
29
42
  ## 1. Start the run (the developer said go)
30
43
  1. Run `orch sync`. Stop on ERROR; report every WARN.
31
- 2. Run `orch start`. It checks that herdr can wake you: it names your pane `lead` if it is not named yet (`NAMED`), or refuses with `NO LEAD` and the exact `herdr agent rename <pane> lead` command; give that to the developer and stop. `orch dispatch` makes the same check. If a worker or the reviewer shows `herdr=NOT FOUND`, run `orch team up`: it opens a pane for each missing agent next to yours, in its folder (its worktree, or the repo), starts it on its plan model and gives it its plan name. Then run `orch start` again. If team up reports `WAITING` (the new pane shows a first-run question such as "trust this folder" or a sign-in) or `FAILED`, or a worker shows `STALE pane`, tell the developer exactly what to do in which pane (`orch agents launch <kind> --model <id>` gives the start command), and stop. `WARN agent <kind>: …` means a launch flag in the registry is out of date for the installed tool; show it (`orch doctor <kind>` has the detail). Workers shown as `detect:off` are fine.
44
+ 2. Run `orch start`. It checks that herdr can wake you: it names your pane `lead` if it is not named yet (`NAMED`), or refuses with `NO LEAD` and the exact `herdr agent rename <pane> lead` command; give that to the developer and stop. `orch dispatch` makes the same check. If a worker or the reviewer shows `herdr=NOT FOUND`, run `orch team up`: it opens a pane for each missing agent in a herdr tab called `team` (your tab stays whole), in its folder (its worktree, or the repo), starts it on its plan model and gives it its plan name. Then run `orch start` again. If team up reports `WAITING` (the new pane shows a first-run question such as "trust this folder" or a sign-in) or `FAILED`, or a worker shows `STALE pane`, tell the developer exactly what to do in which pane (`orch agents launch <kind> --model <id>` gives the start command), and stop. `WARN agent <kind>: …` means a launch flag in the registry is out of date for the installed tool; show it (`orch doctor <kind>` has the detail). Workers shown as `detect:off` are fine.
32
45
  3. Dispatch every milestone whose dependencies are met: `orch dispatch M1 M2`. It prints who can take each one, and starts the event manager if none is running. If it says it could not start it, ask the developer to run `orch autopilot` in a terminal.
33
46
  - `--to <worker>` gives a milestone to one coder; `--tier high` asks for a stronger model than the plan says. Use them only with a reason, and tell the developer.
34
- 4. Tell the developer in two lines what is running where (milestone → coder and model). **STOP.**
47
+ 4. Tell the developer in two lines what is running where (milestone → coder and model), and that you will compact your chat now. **STOP.** Once you are idle, orch types your tool's compact command (`/compact`) into your chat, once per run, so the planning (the plan playbook, the files you read) does not ride along on every later call. Nothing is lost: the plan is in `.orchestrate/plan.md`, the run is in `orch`'s files, and your next `orch events` gives you the hard rules again. (`orch config lead-compact off` turns it off.)
35
48
 
36
49
  ## 2. When you are woken (`orch events`)
37
- Run `orch events`. It lists the new events, the ones still open, the milestones READY for your dispatch, the workers, and whether the event manager is running. Under `WHAT TO DO` it also prints the hard rules above and the rows of the table below for those events (on ALL_DONE, all of section 3), word for word, so on a wake-up you never need to run `orch lead run` again: not even in a fresh session or after your conversation was compacted. `orch lead run --section <EVENT>` prints one row again. Handle each line, then **STOP**.
50
+ Run `orch events`. It lists the new events, the ones still open, the milestones READY for your dispatch, the workers, and whether the event manager is running. Under `WHAT TO DO` it also prints the hard rules (in full the first time in this chat, then the short form above) and the rows of the table below for those events (on ALL_DONE, all of section 3), word for word, so on a wake-up you never need to run `orch lead run` again: not even in a fresh session or after your conversation was compacted. `orch lead run --section <EVENT>` prints one row again. Handle each line, then **STOP**.
38
51
 
39
52
  | Event | What you do |
40
53
  |---|---|
41
54
  | `READY` | Dispatch them: `orch dispatch <Mn>...`. If you wait too long (15 minutes by default) the event manager starts them itself, so a run never stalls on you. A milestone that a landing unlocked does not come as READY: it starts at once and you get `AUTO-DISPATCHED` (unless the plan says `Auto dispatch: off`). |
42
- | `MERGED Mn` | Nothing, unless it unlocked milestones listed under READY: dispatch those. |
55
+ | `MERGED Mn` | Nothing, unless it unlocked milestones listed under READY: dispatch those. `MERGED`, `AUTO-DISPATCHED` and `ESCALATED` are news only: they do not wake you on their own, they come with your next wake-up (at the latest with ALL_DONE). Give their SAY lines then. (`orch config news-wake on` wakes you for them again.) |
43
56
  | `PAUSED Mn` with a coder's question | If the request, the plan or the code already answers it: `orch answer Mn "<answer> (from: <where>)"`. Otherwise put it to the developer with 2–3 options and STOP; when they answer, `orch answer Mn "<their answer>"`. The answer is written under that milestone's "Notes from user" and the **same coder** carries on from its saved work. |
44
57
  | `PAUSED Mn`: a criterion can't be met (for example an outside API it needs does not exist) | Only the developer can drop part of a milestone. Ask them: build the rest and defer AC<n>, or wait. If they agree, `orch answer Mn --defer AC<n> "<their words>"`. Then a coder that reports AC<n> `met: false` gets no fix round and no escalation for it, the reviewer does not block on it, and the summary lists it as **not done**, with a follow-up. Never defer without the developer's yes, and never by writing it in the plan only: the check reads `--defer`, not prose. |
45
58
  | `PAUSED Mn`: agent stopped twice / over its time budget / blocked / orch error | Look at what the agent shows (`herdr agent read <agent> --source recent-unwrapped --lines 60`) or the error in the log, and tell the developer. Don't work around it by hand. When it is sorted out: `orch dispatch Mn`. |
@@ -55,6 +68,9 @@ Run `orch events`. It lists the new events, the ones still open, the milestones
55
68
  | `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. |
56
69
  | `ALL_DONE` | Section 3. |
57
70
 
71
+ ## 2b. When the developer writes to you during a run
72
+ `orch lead run` prints this part (with the hard rules and the steps for every event that is open now) when you run it while a run is going. Run `orch events` first if it shows unread events; when the developer talks to you and you have not run `orch events` in this turn, run it before you stop.
73
+
58
74
  If you changed plan.md by hand, run `orch sync` (it works once the event manager is idle; `orch answer`, `orch defer` and `orch dispatch` work at any time).
59
75
 
60
76
  **The developer says "stop sending work to <coder>"** (for example, no Claude today): run `orch bench <worker> off "<their reason>"`. It holds until `orch bench <worker> on`, across restarts, `orch sync` and `orch resume`; a usage-limit bench does not. Tell the developer what it still holds (`orch status`). Never try to keep a coder out by remembering it yourself.
@@ -81,4 +97,4 @@ If you changed plan.md by hand, run `orch sync` (it works once the event manager
81
97
  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. If it prints `LOST` and `WAITS` (exit 3), herdr can't find that coder or the reviewer (their panes were reopened and lost their names): tell the developer the exact fix it printed (usually `herdr agent rename <pane> <name>`, or `orch resume`); the fix starts by itself once herdr finds them. 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.
82
98
 
83
99
  ## Runs without a lead (`Lead mode: off`)
84
- The developer runs `orch autopilot` in a terminal. It dispatches by itself and exits 3 when a human is needed. Then you are asked to help: read `orch status` and `tail -30 .orchestrate/autopilot.log`, handle each paused, failed or held milestone as in the table above (`orch set Mn pending` instead of `orch dispatch Mn`), and tell the developer to run `orch autopilot` again.
100
+ The developer runs `orch autopilot` in a terminal. It dispatches by itself and exits 3 when a human is needed. Then you are asked to help: read `orch status` and `tail -30 .orchestrate/autopilot.log`, handle each paused, failed or held milestone as in the event table of section 2 (`orch lead run --section <EVENT>` prints its row; `orch set Mn pending` instead of `orch dispatch Mn`), and tell the developer to run `orch autopilot` again.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: orch-onboard
3
- description: "Set a project up for its AI agents (Claude, Codex, Antigravity, Pi, OpenCode, Amp): finds the stack, commands, rule files and the skills each agent can see, then offers only what is missing (AGENTS.md, short skills about this repo, one folder link so every agent sees the same skills) and writes nothing without the developer's tick, either only on this machine or as a PR. Use when the user says orch-onboard or asks to set up skills or agent rules for a project. /orch-plan starts it by itself when a project needs it."
3
+ description: Set a project up for its AI agents (AGENTS.md, short skills about this repo, one skill folder every agent sees), writing nothing without the developer's tick. Use when the user says orch-onboard or asks to set up skills or agent rules for a project.
4
4
  ---
5
5
 
6
6
  Run `orch lead onboard` (or `~/.local/bin/orch lead onboard` if `orch` is not on PATH) and follow its output exactly.
@@ -1,6 +1,6 @@
1
1
  ---
2
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.
3
+ description: Lead a Herdr agent team, step 1 - plan a feature or a small change (start the request with quick: or full: to choose). Use when the user says orch-plan or asks to plan or orchestrate a feature. Does NOT execute until the developer says go.
4
4
  ---
5
5
 
6
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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: orch-run
3
- description: Orchestrator step 2 for a Herdr multi-agent team. Use when the user says "orch-run", "go", "start the run", "continue the plan", or answers a question during a run (not the questions the lead asks before it writes the plan); and whenever you are told to run `orch events`. The lead dispatches milestones and pauses; the event manager (`orch autopilot`) runs them and wakes the lead for questions, failures, held or ready milestones, and the final summary.
3
+ description: Lead a Herdr agent team, step 2 - run the plan. Use when the user says orch-run, go, start the run or continue the plan, or answers a question during a run (not the questions asked before the plan is written); and whenever you are told to run `orch events`.
4
4
  ---
5
5
 
6
6
  You are the lead. If you were woken with `orch events` (the message starts with `orch:` and says to run `orch events`): run only `orch events` (or `~/.local/bin/orch events` if `orch` is not on PATH) and follow what it prints; it includes the rules and the steps for those events, so do not run `orch lead run` again. Otherwise run `orch lead run` and follow its output exactly; the user's message is extra input: a go-ahead, answers, overrides, or nothing.