herdr-orchestra 6.46.0 → 6.47.2

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,32 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.47.2] - 2026-12-02
6
+
7
+ The reviewer is no longer optional in a full run, and it checks security every time. Before, a milestone was reviewed only when the plan said `Review: yes` (the default was no), a full plan could say `Reviewer: none`, and the review prompt mentioned "security" as one word in a list. Example: a milestone that adds `GET /orders/:id` with no check that the order belongs to the logged-in user could land after a green check, unreviewed, when the lead had marked it `Review: no`.
8
+
9
+ ### Changed
10
+ - **Every milestone of a full run is reviewed.** A milestone is reviewed whenever the plan has a reviewer, whatever its `Review:` line says; `Review: no` in a full run gets a warning from `orch sync` naming the milestone. Quick runs are unchanged: no reviewer, unless the developer starts with `quick review:` (then `Review: yes`).
11
+ - **A full plan must name a reviewer.** `orch sync` refuses a bare `Reviewer: none` in a full plan and says how to add one (`orch team <kind>` picks one). Only when the developer asked for no review may the plan say `Reviewer: none (developer: <their reason>)`.
12
+ - **The reviewer checks three security points on every milestone**, and each problem is a blocker: secrets (no API key, token, password or private key in code, config, tests, fixtures or logs), authorization (every new or changed endpoint, action or query checks that the caller may do it: logged in, the right role, only their own data) and input validation (input from users, requests, files or other services is checked before it reaches a database query, a shell command, a file path, HTML or a redirect). Both the pane reviewer's task file and the Pi reviewer subagent have them.
13
+ - The plan playbook, README and docs (planning, plan file, workflow, reviews) say the same.
14
+
15
+ ## [6.47.0] - 2026-11-30
16
+
17
+ 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.
18
+
19
+ 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).
20
+
21
+ ### Changed
22
+ - **`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.
23
+ - **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.
24
+ - **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.
25
+ - **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.
26
+ - **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).
27
+ - **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").
28
+
29
+ ### Fixed
30
+ - `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.
5
31
  ## [6.46.0] - 2026-11-30
6
32
 
7
33
  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.
package/README.md CHANGED
@@ -148,7 +148,7 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
148
148
 
149
149
  **An all-Codex team.** Codex runs every command in its sandbox, which blocks two things orch needs: talking to herdr, and writing the repo's `.git` (branches, worktrees). So orch starts every Codex pane with two settings that open just those (`-c sandbox_workspace_write.network_access=true`, which also allows the internet, and the repo's `.git` as a writable folder). Start your own Codex lead the same way: `orch agents launch codex --role lead --model gpt-6.2-sol@medium` prints the command; `orch lead plan` warns when the pane you run it in is still blocked. A Codex model id can end in a thinking level: `gpt-6.2-sol@low` is Sol on low thinking. The Codex levels are small = `gpt-6-luna@high`, medium = `gpt-6.2-sol@low`, high = `gpt-6.2-sol@medium` (Astra stays blocked), and `orch models` asks Codex itself (`codex debug models`) for its current models, so a newer Sol or Luna is used without anyone editing a file.
150
150
 
151
- 2. **Orchestration plan:** start the plan playbook in the lead's pane (see [Choose your lead](#choose-your-lead)). The lead researches, writes `.orchestrate/plan.md` and shows you the milestones, which coder and model each one goes to, and why. Edit the plan if you like: dependencies, tier, review yes/no, your answers to open questions.
151
+ 2. **Orchestration plan:** start the plan playbook in the lead's pane (see [Choose your lead](#choose-your-lead)). The lead researches, writes `.orchestrate/plan.md` and shows you the milestones, which coder and model each one goes to, and why. Edit the plan if you like: dependencies, tier, your answers to open questions. A full run always has a reviewer and reviews every milestone; besides the spec and your written rules, the reviewer checks secrets, authorization and input validation on each one.
152
152
  3. **Orchestration run:** tell the lead **go** (`/orch-run`). It dispatches the milestones (`orch dispatch M1 M2`), which starts the event manager, and pauses. From here the run looks after itself:
153
153
  - a milestone finishes → the event manager checks and merges it, then wakes the lead, which dispatches what that unlocked;
154
154
  - a coder asks a question → the lead is woken; if the plan or the code already answers it, it answers, otherwise it asks you in its pane. `orch answer M2 "<your answer>"` writes the answer into the plan and the **same coder** carries on with its work; if a criterion can't be met (say an outside API is missing) and you agree to ship the rest, the lead runs `orch answer M2 --defer AC2 "<your words>"`: no fix rounds or stronger-model retries for AC2, and the summary lists it as **not done**, with a follow-up;
@@ -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.46.0
1
+ 6.47.2
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/
@@ -1487,7 +1488,7 @@ def cmd_sync(args):
1487
1488
  errors.append(f"lead {lead[0]!r} is also the Reviewer — the lead never reviews in its own run")
1488
1489
  reg = registry(required=False)
1489
1490
  cat = models_catalog()
1490
- models = {**parse_models(get("workers")), **parse_models(rev), **parse_models(get("lead"))}
1491
+ models = {**parse_models(get("workers")), **(parse_models(rev) if reviewer else {}), **parse_models(get("lead"))}
1491
1492
  unrated = set()
1492
1493
  for name, mid in models.items():
1493
1494
  why = model_denied(cat, mid)
@@ -1734,6 +1735,16 @@ def cmd_sync(args):
1734
1735
  if has_open_questions(by_id[tid]):
1735
1736
  errors.append(f"{tid} has open questions — a quick run needs a clear change; answer them or use "
1736
1737
  f"`Mode: full`")
1738
+ # full runs always have a reviewer: only the developer can drop it, and the plan says why
1739
+ if not quick and reviewer is None and not re.match(r"none\s*\(\s*developer\b[^)]*\w[^)]*\)", rev.strip(), re.I):
1740
+ errors.append("a full run always has a reviewer — add one (`Reviewer: reviewer (<kind>: <model>)`, "
1741
+ "`orch team <kind>` picks one), or, only when the developer asked for no review, write "
1742
+ "`Reviewer: none (developer: <why>)`")
1743
+ if not quick and reviewer is not None:
1744
+ skipped = [tid for tid in enabled if field(by_id[tid], "review", "").lower().startswith("n")]
1745
+ if skipped:
1746
+ warns.append(f"{', '.join(skipped)} say `Review: no` — a full run reviews every milestone, so they are "
1747
+ f"reviewed anyway (only a quick run can skip the review)")
1737
1748
  # hard to undo (`Door: one-way (why)`): always waits for the developer's `orch approve` before it lands
1738
1749
  doors = {}
1739
1750
  for tid in ids:
@@ -1868,6 +1879,8 @@ def cmd_sync(args):
1868
1879
  "lead_wake": old.get("lead_wake"),
1869
1880
  "lead_ready_told": old.get("lead_ready_told"),
1870
1881
  "compact_told": old.get("compact_told") or [],
1882
+ "lead_compact": old.get("lead_compact") if old.get("branch") == branch else None,
1883
+ "lead_rules": old.get("lead_rules") if old.get("branch") == branch else None,
1871
1884
  "tree_task": old.get("tree_task"),
1872
1885
  "workers": {},
1873
1886
  "order": ids,
@@ -1902,7 +1915,8 @@ def cmd_sync(args):
1902
1915
  **o, # keep runtime fields (last_report, review_ok, conflicts, ...)
1903
1916
  "title": t["title"], "deps": deps[tid],
1904
1917
  "prefer": field(t, "prefer", "any").split()[0].lower() if field(t, "prefer", "any") else "any",
1905
- "review": field(t, "review", "no").lower().startswith("y") and reviewer is not None,
1918
+ # full runs: every milestone is reviewed; quick runs only with `Review: yes` (`quick review:`)
1919
+ "review": reviewer is not None and (not quick or field(t, "review", "no").lower().startswith("y")),
1906
1920
  "status": o.get("status", "pending"), "reason": o.get("reason", ""),
1907
1921
  "worker": o.get("worker"), "dir": o.get("dir"), "attempt": o.get("attempt", 0),
1908
1922
  "fix": o.get("fix", 0), "review_round": o.get("review_round", 0),
@@ -2182,7 +2196,7 @@ def stopping_line(st, name, w):
2182
2196
  # so the chat itself only holds what the agent did on its LAST milestone. Before the agent starts a different
2183
2197
  # milestone (and as soon as the milestone it worked on has landed) orch types its tool's compact command
2184
2198
  # (`/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
2199
+ # 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
2200
  # the chat. `orch config compact off` (or ORCH_COMPACT=0) turns it off; `compact = ""` in agents.toml turns it off
2187
2201
  # for one tool.
2188
2202
 
@@ -2241,7 +2255,8 @@ def compact_unsupported(st, name, kind):
2241
2255
 
2242
2256
 
2243
2257
  def compact_agents(st):
2244
- """(name, info dict, holds a job) for every coder and the reviewer. The lead is never compacted."""
2258
+ """(name, info dict, holds a job) for every coder and the reviewer. The lead is compacted only once, after go
2259
+ (tend_lead_compact)."""
2245
2260
  out = [(n, w, bool(w.get("task"))) for n, w in st.get("workers", {}).items()]
2246
2261
  if st.get("reviewer") and st.get("reviewer_info") is not None:
2247
2262
  out.append((st["reviewer"], st["reviewer_info"], bool(st.get("reviewer_busy"))))
@@ -2311,6 +2326,45 @@ def end_compact(st, name, w, note=True):
2311
2326
  return h
2312
2327
 
2313
2328
 
2329
+ # ---------------------------------------------------------------- compacting the lead's chat once, after go
2330
+ # Planning fills the lead's chat: the plan playbook, the files it read, the questions. None of it is needed to run:
2331
+ # the plan is in plan.md and every wake-up (`orch events`) prints what the lead needs. So once per run, when the lead
2332
+ # is idle after go (it dispatched and stopped), the event manager types the lead's compact command into its pane.
2333
+ # Wake-ups wait until it is done. `orch config lead-compact off` (or ORCH_LEAD_COMPACT=0) turns it off.
2334
+
2335
+ def lead_compact_on():
2336
+ env = os.environ.get("ORCH_LEAD_COMPACT")
2337
+ if env in ("0", "1"):
2338
+ return env == "1"
2339
+ return settings_load().get("lead_compact", True) is not False
2340
+
2341
+
2342
+ def lead_compacting(st):
2343
+ """True while the lead's one compact after go is sent and not over: wake-ups wait for it."""
2344
+ lc = st.get("lead_compact") or {}
2345
+ return bool(lc.get("sent")) and not lc.get("done")
2346
+
2347
+
2348
+ # ---------------------------------------------------------------- news-only lead events
2349
+ # MERGED, AUTO-DISPATCHED and ESCALATED leave the lead nothing to decide: they do not wake it on their own. They wait
2350
+ # in the queue and come with the next wake-up that needs the lead (at the latest ALL_DONE). The board, `orch view`
2351
+ # and `orch story` show them at once. `orch config news-wake on` (or ORCH_NEWS_WAKE=1) wakes the lead for them again.
2352
+ NEWS_KINDS = {"merged", "auto-dispatched", "escalated"}
2353
+
2354
+
2355
+ def news_wake_on():
2356
+ env = os.environ.get("ORCH_NEWS_WAKE")
2357
+ if env in ("0", "1"):
2358
+ return env == "1"
2359
+ return settings_load().get("news_wake") is True
2360
+
2361
+
2362
+ def wake_events(st):
2363
+ """The unread events that are worth a wake-up of their own."""
2364
+ un = unread_events(st)
2365
+ return un if news_wake_on() else [e for e in un if e["kind"] not in NEWS_KINDS]
2366
+
2367
+
2314
2368
  def compacting_line(st, name, w):
2315
2369
  h = w.get("compacting") or {}
2316
2370
  return (f"compacting its chat after {h.get('after') or '?'} ({h.get('cmd') or '/compact'}, sent "
@@ -3827,7 +3881,15 @@ def cmd_review(args):
3827
3881
  "Answer two questions, separately, and give every finding the `axis` of the one it answers:\n"
3828
3882
  "1. `spec`: did it build what the task asks, no more and no less? Every acceptance criterion met, nothing "
3829
3883
  "missing, no behaviour the task did not ask for. Correctness, API/contract consistency, UI/UX, security, "
3830
- "edge cases and missing tests belong here."
3884
+ "edge cases and missing tests belong here.\n"
3885
+ " Security, check all three every time, each problem is a `blocker`:\n"
3886
+ " - secrets: no API key, token, password or private key in code, config, tests, fixtures or logs (it "
3887
+ "belongs in an environment variable or the secret store the project already uses);\n"
3888
+ " - authorization: every new or changed endpoint, action or query checks that the caller may do it "
3889
+ "(logged in, the right role, only their own data), not just that the request is well formed;\n"
3890
+ " - input validation: input from users, requests, files or other services is checked before it reaches a "
3891
+ "database query, a shell command, a file path, HTML or a redirect (injection, path traversal, XSS).\n"
3892
+ " When one does not apply (e.g. no new endpoint), there is nothing to report for it."
3831
3893
  + (f" orch saw changes outside the milestone's Likely files: {', '.join(scope)}. Say whether each one was "
3832
3894
  "needed." if scope else "") + "\n"
3833
3895
  "2. `rules`: does it follow the project's own written rules: "
@@ -6655,11 +6717,16 @@ def cmd_events(args):
6655
6717
  if not new and not old and not hold:
6656
6718
  print("Nothing needs you.")
6657
6719
  kinds = list(dict.fromkeys([e["kind"] for e in new + old] + (["ready"] if hold else [])))
6720
+ rules_given = False
6658
6721
  pb = asset("playbooks/run.md") if kinds else None
6659
6722
  if pb: # the playbook's own words for these events: a wake-up never needs
6660
6723
  text = pb.read_text() # `orch lead run` again, even after the lead's context was compacted
6661
6724
  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="")
6725
+ full = not st.get("lead_rules")
6726
+ print(run_playbook_part(text, "rules" if full else "short"), end="")
6727
+ if full and not peek:
6728
+ st["lead_rules"] = now()
6729
+ rules_given = True
6663
6730
  rows = "".join(run_playbook_part(text, k) for k in kinds if k != "all_done")
6664
6731
  if rows:
6665
6732
  print("| Event | What you do |\n|---|---|\n" + rows, end="")
@@ -6677,6 +6744,8 @@ def cmd_events(args):
6677
6744
  st["lead_wake"]["read_ts"] = now() # for the event manager's timing line
6678
6745
  save(st)
6679
6746
  write_story(st)
6747
+ elif rules_given:
6748
+ save(st)
6680
6749
 
6681
6750
 
6682
6751
  def cmd_escalate(args):
@@ -6895,7 +6964,7 @@ def lead_unwoken(st):
6895
6964
  woken because herdr can't find it, or it did not read the wake-ups), with what to do. "" when all is read."""
6896
6965
  if not lead_on(st):
6897
6966
  return ""
6898
- un = unread_events(st)
6967
+ un = wake_events(st)
6899
6968
  if not un:
6900
6969
  return ""
6901
6970
  name, lw = st["lead"]["name"], st.get("lead_wake") or {}
@@ -7001,10 +7070,11 @@ def _autopilot(args):
7001
7070
  s_ = load()
7002
7071
  if not lead_on(s_):
7003
7072
  return
7004
- un = unread_events(s_)
7073
+ un_all = unread_events(s_)
7074
+ un = wake_events(s_)
7005
7075
  lw = s_.get("lead_wake") or {}
7006
7076
  lead = s_["lead"]["name"]
7007
- if not un:
7077
+ if not un_all:
7008
7078
  if lw.get("n") and not lw.get("ack"):
7009
7079
  patch_state(lambda s2: s2.update(lead_wake={**(s2.get("lead_wake") or {}), "ack": True}))
7010
7080
  rt, first = lw.get("read_ts"), lw.get("first_ts") or lw.get("ts")
@@ -7012,6 +7082,10 @@ def _autopilot(args):
7012
7082
  f" (read {max(0, rt - first)}s after the first wake-up, {max(0, rt - lw['oldest'])}s after the "
7013
7083
  f"oldest event; seen here {max(0, now() - rt)}s later)" if rt and first and lw.get("oldest") else ""))
7014
7084
  return
7085
+ if not un:
7086
+ return # news only: it comes with the next wake-up that needs the lead
7087
+ if lead_compacting(s_) and not force:
7088
+ return # the lead is compacting its chat after go: wake it after that
7015
7089
  newest = max(e["id"] for e in un)
7016
7090
  # a wake the lead has not acted on yet covers newer events too: it reads the whole queue when it comes
7017
7091
  same = any(e["id"] <= lw.get("upto", 0) for e in un)
@@ -7036,7 +7110,7 @@ def _autopilot(args):
7036
7110
  f"(if the wake-up text sits in its input box, press Enter), or tell it: run `orch events`. "
7037
7111
  f"{len(un)} event(s) wait for it (`orch events --peek` shows them)", True)
7038
7112
  return
7039
- text = (f"orch: {len(un)} new event(s) in the run on {s_['branch']} need the lead. Run `orch events` and "
7113
+ text = (f"orch: {len(un_all)} new event(s) in the run on {s_['branch']} need the lead. Run `orch events` and "
7040
7114
  f"handle what it prints, then stop.")
7041
7115
  try:
7042
7116
  deliver(s_, lead, text)
@@ -7051,15 +7125,91 @@ def _autopilot(args):
7051
7125
  first_ts = lw.get("first_ts", lw.get("ts")) if n else now()
7052
7126
  patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n + 1, "wait": wait,
7053
7127
  "first_ts": first_ts, "oldest": oldest}))
7054
- what = ", ".join(f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un[:6])
7128
+ what = ", ".join(f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un_all[:6])
7055
7129
  if n:
7056
7130
  say(f"the lead ({lead}) did not pick up its wake-up (" + ("idle again, " if watch else "")
7057
7131
  + 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}")
7132
+ f"({n + 1} of {LEAD_MAX_WAKES}): {len(un_all)} event(s) — {what}")
7059
7133
  else:
7060
- say(f"woke the lead ({lead}): {len(un)} event(s) — {what} (sent; it counts once the lead reads them; "
7134
+ say(f"woke the lead ({lead}): {len(un_all)} event(s) — {what} (sent; it counts once the lead reads them; "
7061
7135
  f"oldest event {max(0, now() - oldest)}s old)")
7062
7136
 
7137
+ def tend_lead_compact():
7138
+ """Once per run, when the lead is idle after go, type its tool's compact command into its pane, so the
7139
+ planning does not ride along on every later call. Wake-ups wait until herdr shows it idle again."""
7140
+ s_ = load()
7141
+ if not lead_on(s_):
7142
+ return
7143
+ lead = s_["lead"]
7144
+ name = lead["name"]
7145
+ lc = s_.get("lead_compact") or {}
7146
+ if lc.get("done"):
7147
+ return
7148
+ if lc.get("sent"):
7149
+ hs = herdr_state(name)
7150
+ busy = hs is not None and busy_word(hs)
7151
+ late = now() - lc["sent"] > COMPACT_MAX_S
7152
+ if not late and (busy or hs is None):
7153
+ if lc.get("idle_since"):
7154
+ patch_state(lambda s2: s2["lead_compact"].update(idle_since=None))
7155
+ return
7156
+ if not late and not lc.get("idle_since"):
7157
+ patch_state(lambda s2: s2["lead_compact"].update(idle_since=now()))
7158
+ return
7159
+ if not late and now() - lc["idle_since"] < COMPACT_SETTLE_S:
7160
+ return
7161
+
7162
+ def done(s2):
7163
+ s2["lead_compact"].update(done=now())
7164
+ s2["lead_rules"] = None # its next wake-up prints the full hard rules again
7165
+ story_note(s2, f"the lead's chat is now a short summary ({lc.get('cmd')}): the plan is in plan.md"
7166
+ if not late else f"the lead was still busy {_fmt_secs(COMPACT_MAX_S)} after "
7167
+ f"{lc.get('cmd')}: orch stopped waiting for its compact", who="event manager")
7168
+ patch_state(done)
7169
+ say(f"COMPACTED the lead ({name}): its chat after planning is now a short summary" if not late else
7170
+ f"the lead ({name}) is still busy {_fmt_secs(COMPACT_MAX_S)} after {lc.get('cmd')}: wake-ups go on")
7171
+ return
7172
+ tasks = s_["tasks"].values()
7173
+ if not any(t.get("go") for t in tasks) or all(t["status"] in ("merged", "skipped") for t in tasks):
7174
+ return # not started yet, or already over: nothing to gain
7175
+ if any(e["kind"] == "all_done" for e in s_.get("lead_events", [])):
7176
+ return
7177
+ if not lead_compact_on() or not watched(s_, name):
7178
+ return
7179
+ cmd, why = compact_command(s_, lead.get("kind"))
7180
+ if not cmd:
7181
+ if not lc.get("told"):
7182
+ def told(s2, why=why):
7183
+ s2["lead_compact"] = {"told": True, "done": now(), "skipped": why}
7184
+ story_note(s2, f"the lead's chat is not compacted after go: {why}", who="event manager")
7185
+ patch_state(told)
7186
+ say(f"the lead's chat is not compacted after go: {why}")
7187
+ return
7188
+ if wake_events(s_):
7189
+ return # it has news to read first; try again when it is idle
7190
+ hs = herdr_state(name)
7191
+ if hs is None or busy_word(hs):
7192
+ if lc.get("idle_seen"):
7193
+ patch_state(lambda s2: s2.update(lead_compact={**(s2.get("lead_compact") or {}), "idle_seen": None}))
7194
+ return
7195
+ if not lc.get("idle_seen"):
7196
+ patch_state(lambda s2: s2.update(lead_compact={**(s2.get("lead_compact") or {}), "idle_seen": now()}))
7197
+ return
7198
+ if now() - lc["idle_seen"] < LEAD_COMPACT_IDLE_S:
7199
+ return
7200
+ try:
7201
+ deliver(s_, name, cmd)
7202
+ except DeliveryError as e:
7203
+ say(f"could not send {cmd} to the lead ({name}): {e} — will retry")
7204
+ return
7205
+
7206
+ def sent(s2):
7207
+ s2["lead_compact"] = {"sent": now(), "cmd": cmd}
7208
+ story_note(s2, f"the lead dispatched and stopped: orch sent it {cmd} so the planning does not ride along "
7209
+ f"on every later call", who="event manager")
7210
+ patch_state(sent)
7211
+ say(f"the lead ({name}) is idle after go: sent {cmd} so its chat after planning becomes a short summary")
7212
+
7063
7213
  def lead_ready():
7064
7214
  """Ready milestones the lead has not dispatched: tell it once per set; start them ourselves after LEAD_WAIT_S."""
7065
7215
  s_ = load()
@@ -7949,6 +8099,7 @@ def _autopilot(args):
7949
8099
  guarded(tid, lambda: dispatch(kind, tid, worker))
7950
8100
  slots -= 1
7951
8101
  lead_ready()
8102
+ tend_lead_compact()
7952
8103
  wake_lead()
7953
8104
 
7954
8105
  # 3. finished or stuck?
@@ -10831,10 +10982,15 @@ USAGE = """usage: orch <command> [args]
10831
10982
  update [--check] [--version vX.Y.Z] install the latest release (or that one) and show what is new
10832
10983
  config [auto-update on|off] this machine's settings: keep orch up to date by itself, or only be told
10833
10984
  config compact on|off a coder or the reviewer gets /compact when its milestone is done (on by default for
10834
- Claude Code, Codex and AGY 1.2.15+; never the lead). ORCH_COMPACT=0|1 overrides it
10835
- lead plan|run print the lead playbook (any agent can lead: "Run `orch lead plan` and follow it")
10836
- lead plan quick|full the rest of the plan playbook: a quick run's rules, or steps 3-10 of the full process
10837
- lead run --section <EVENT|ALL_DONE|rules> one part of the run playbook (orch events prints these for you)
10985
+ Claude Code, Codex and AGY 1.2.15+). ORCH_COMPACT=0|1 overrides it
10986
+ config lead-compact on|off the lead gets /compact once per run, when it is idle after go (on by default).
10987
+ ORCH_LEAD_COMPACT=0|1 overrides it
10988
+ config news-wake on|off MERGED, AUTO-DISPATCHED and ESCALATED wake the lead at once (off by default: they come
10989
+ with its next wake-up). ORCH_NEWS_WAKE=0|1 overrides it
10990
+ lead plan|run print the lead playbook (any agent can lead: "Run `orch lead plan` and follow it");
10991
+ during a run, `lead run` prints only the rules, the developer's part and open events
10992
+ 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
10993
+ lead run --section <EVENT|ALL_DONE|rules|short|developer> one part of the run playbook (orch events prints these)
10838
10994
  lead onboard the setup playbook: set this project up for its agents (rules, skills) with the
10839
10995
  developer's tick; `orch lead plan` points the lead to it when a project needs it
10840
10996
  onboard [--json] [--all] what the project has for its agents: stack, commands, rule files, the skills each
@@ -11097,10 +11253,17 @@ def plan_playbook_part(text, part):
11097
11253
  """The plan playbook in parts, so a quick run doesn't read the whole full process:
11098
11254
  "" = the start (role, preflight, research, quick-or-full, plus the `<!-- start -->` blocks of the full part);
11099
11255
  "quick" = the `<!-- quick: title -->` blocks (rules a quick plan uses, word for word from the full process);
11100
- "full" = steps 3 to 10. start + full is every line of the playbook exactly once."""
11256
+ "full" = steps 3 to 10. start + full + the quick run's own steps (first in "quick") is every line of the
11257
+ playbook exactly once."""
11101
11258
  lines = text.splitlines(keepends=True)
11102
11259
  cut = next((i for i, l in enumerate(lines) if l.strip() == "<!-- full -->"), len(lines))
11103
11260
  head, rest = lines[:cut], lines[cut + 1:]
11261
+ # the quick run's own steps (in the start part, between <!-- quick-run --> marks) go only to a quick run
11262
+ q0 = next((i for i, l in enumerate(head) if l.strip() == "<!-- quick-run -->"), None)
11263
+ q1 = next((i for i, l in enumerate(head) if l.strip() == "<!-- /quick-run -->"), None)
11264
+ quick_steps = []
11265
+ if q0 is not None and q1 is not None and q1 > q0:
11266
+ quick_steps, head = head[q0 + 1:q1], head[:q0] + head[q1 + 1:]
11104
11267
  blocks, out, cur, title = {"start": [], "quick": []}, [], None, ""
11105
11268
  for l in rest:
11106
11269
  m = PB_MARK_RE.match(l.strip())
@@ -11121,7 +11284,8 @@ def plan_playbook_part(text, part):
11121
11284
  if part == "full":
11122
11285
  return "".join(out)
11123
11286
  if part == "quick":
11124
- return "".join(f"## {t}\n{''.join(b)}\n" for t, b in blocks["quick"])
11287
+ return ((f"## A quick run, step by step (the rest of step 2b)\n{''.join(quick_steps)}\n" if quick_steps else "")
11288
+ + "".join(f"## {t}\n{''.join(b)}\n" for t, b in blocks["quick"]))
11125
11289
  return "".join(head) + "".join(f"\n## {t} (from the full process)\n{''.join(b)}" for t, b in blocks["start"])
11126
11290
 
11127
11291
 
@@ -11139,10 +11303,14 @@ def run_playbook_part(text, name):
11139
11303
  secs = re.split(r"(?m)^(?=## )", text)
11140
11304
  if key in ("rules", "hard rules"):
11141
11305
  return next((x for x in secs if x.startswith("## Hard rules")), "")
11306
+ if key in ("short", "rules short"):
11307
+ return next((x for x in secs if x.startswith("## Rules in short")), "")
11308
+ if key in ("developer", "2b"):
11309
+ return next((x for x in secs if x.startswith("## 2b.")), "")
11142
11310
  if key in ("all_done", "all-done", "3"):
11143
11311
  return next((x for x in secs if x.startswith("## 3. ALL_DONE")), "")
11144
11312
  kind = EVENT_ROWS.get(key, key.upper())
11145
- rows = [l for l in text.splitlines() if re.match(rf"^\| `{re.escape(kind)}\b", l)
11313
+ rows = [l for l in text.splitlines() if re.match(rf"^\| (`[A-Z_-]+[^`]*`, )*`{re.escape(kind)}\b", l)
11146
11314
  or (kind == "STOPPED" and l.startswith("| `STOPPED`"))]
11147
11315
  if kind == "STOPPED":
11148
11316
  rows += [l for l in text.splitlines() if l.startswith(("| `orch status` starts with", "**Red baseline.**",
@@ -11150,6 +11318,73 @@ def run_playbook_part(text, name):
11150
11318
  return "\n".join(rows) + ("\n" if rows else "")
11151
11319
 
11152
11320
 
11321
+ RUN_GO_SKIP = ("## Rules in short", "## 2. ", "## 2b.", "## 3. ")
11322
+
11323
+
11324
+ def run_playbook_go(text):
11325
+ """What `orch lead run` prints when the developer says go: the playbook without the parts that `orch events`
11326
+ prints exactly when they are needed (the event table, ALL_DONE) and without the part for the developer's
11327
+ messages during a run (`orch lead run` prints that once a run is going)."""
11328
+ secs = re.split(r"(?m)^(?=## )", text)
11329
+ return ("".join(x for x in secs if not x.startswith(RUN_GO_SKIP))
11330
+ + "\n## Later in the run\nOn a wake-up, `orch events` prints the steps for its events (section 2 of this "
11331
+ "playbook) and, when every milestone has landed, section 3 (ALL_DONE). When the developer writes to you "
11332
+ "during the run, run `orch lead run` again: it prints the part for that. `orch lead run --section "
11333
+ "<EVENT | ALL_DONE | rules>` prints one part again.\n")
11334
+
11335
+
11336
+ def run_going(st):
11337
+ """A run of this plan has started (something was dispatched) and the lead runs it through events."""
11338
+ return bool(st) and lead_on(st) and bool(st.get("tasks")) and (
11339
+ not plan_not_started(st) or any(t.get("go") for t in st["tasks"].values()))
11340
+
11341
+
11342
+ def run_playbook_mid(text, st):
11343
+ """What `orch lead run` prints while a run is going (the developer wrote to the lead): the hard rules, the part
11344
+ for the developer's messages, the steps for every event open now, and ALL_DONE once every milestone landed."""
11345
+ secs = re.split(r"(?m)^(?=## )", text)
11346
+ intro = secs[0] if not secs[0].startswith("## ") else ""
11347
+ evs = [e for e in st.get("lead_events", []) if event_open(st, e)]
11348
+ kinds = list(dict.fromkeys([e["kind"] for e in evs] + (["ready"] if undispatched(st) else [])))
11349
+ done = all(st["tasks"][k]["status"] in ("merged", "skipped") for k in st["order"])
11350
+ out = [f"RUN IN PROGRESS on {st.get('branch')}: the developer's message is input to this run (an answer, an "
11351
+ f"approval, a change of team or model). Section 1 (go) is over: never run `orch start` or dispatch again "
11352
+ f"unless a step below says so.\n\n", intro,
11353
+ run_playbook_part(text, "rules"), next((x for x in secs if x.startswith("## Context budget")), ""),
11354
+ run_playbook_part(text, "developer")]
11355
+ rows = "".join(run_playbook_part(text, k) for k in kinds if k != "all_done")
11356
+ if rows:
11357
+ out.append("## Events open now (from section 2)\n| Event | What you do |\n|---|---|\n" + rows + "\n")
11358
+ if done or "all_done" in kinds:
11359
+ out.append(run_playbook_part(text, "ALL_DONE"))
11360
+ out.append("Any other event: `orch lead run --section <EVENT>` prints its steps; `orch events` lists what is "
11361
+ "open.\n")
11362
+ return "".join(out)
11363
+
11364
+
11365
+ def lead_run_state():
11366
+ """`orch lead run` runs outside the repo commands: the state of this repo's run (binding ROOT, ORCH and STATE to
11367
+ it), or None when there is no run here."""
11368
+ global ROOT, ORCH, STATE
11369
+ with contextlib.suppress(Exception):
11370
+ p = _repo_state_path()
11371
+ if p:
11372
+ ROOT, ORCH, STATE = p.parent.parent, p.parent, p
11373
+ return load()
11374
+ return None
11375
+
11376
+
11377
+ def lead_rules_seen():
11378
+ """The lead was just given the full hard rules (`orch lead run`): its next wake-ups print the short form."""
11379
+ with contextlib.suppress(Exception):
11380
+ if STATE and STATE.exists():
11381
+ with state_lock():
11382
+ s_ = load()
11383
+ if lead_on(s_):
11384
+ s_["lead_rules"] = now()
11385
+ save(s_)
11386
+
11387
+
11153
11388
  def lead_name_here():
11154
11389
  """(state or None, the lead's name) for the repo this runs in: plan.md's `Lead:` first (it is what the developer
11155
11390
  wrote, even before `orch sync`), then the run's state.json, else `lead`. Never fails."""
@@ -11223,7 +11458,14 @@ def cmd_lead(args):
11223
11458
  print(onboard_plan_note(), end="") # a project never set up for its agents: set it up first
11224
11459
  if subagent and sub == "plan":
11225
11460
  print(SUBAGENT_PLAN_NOTE, end="")
11226
- print(plan_playbook_part(pb.read_text(), part) if sub == "plan" else pb.read_text(), end="")
11461
+ if sub == "plan":
11462
+ print(plan_playbook_part(pb.read_text(), part), end="")
11463
+ elif subagent:
11464
+ print(pb.read_text(), end="")
11465
+ else:
11466
+ st = lead_run_state()
11467
+ print(run_playbook_mid(pb.read_text(), st) if run_going(st) else run_playbook_go(pb.read_text()), end="")
11468
+ lead_rules_seen()
11227
11469
  return
11228
11470
  if sub == "onboard":
11229
11471
  pb = asset("playbooks/onboard.md") or die("playbooks/onboard.md not found next to orch or in the install")
@@ -12430,6 +12672,12 @@ and the code around it.
12430
12672
  Answer two questions, separately:
12431
12673
  - `spec`: did it build what the task asks, no more and no less? Every acceptance criterion, correctness, security,
12432
12674
  edge cases, missing tests.
12675
+ - Security, check all three every time; each problem is a BLOCKER:
12676
+ - secrets: no API key, token, password or private key in code, config, tests, fixtures or logs;
12677
+ - authorization: every new or changed endpoint, action or query checks that the caller may do it (logged in, the
12678
+ right role, only their own data);
12679
+ - input validation: input from users, requests, files or other services is checked before it reaches a database
12680
+ query, a shell command, a file path, HTML or a redirect (injection, path traversal, XSS).
12433
12681
  - `rules`: does it follow the project's written rules: the task file's "Project rules" (coding rules file, decisions,
12434
12682
  words), or AGENTS.md / CLAUDE.md? Only written rules count; name the rule it breaks.
12435
12683
  Don't report what the check command (lint, types, tests) already catches.
@@ -13069,7 +13317,7 @@ def cmd_sub(args):
13069
13317
 
13070
13318
 
13071
13319
  def cmd_config(args):
13072
- """orch config -> this machine's settings; orch config auto-update on|off; orch config compact on|off."""
13320
+ """orch config -> this machine's settings; orch config auto-update|compact|lead-compact|news-wake on|off."""
13073
13321
  if args[:1] == ["auto-update"] and args[1:2] and args[1].lower() in ("on", "off"):
13074
13322
  s = settings_load()
13075
13323
  s["auto_update"] = args[1].lower() == "on"
@@ -13086,8 +13334,25 @@ def cmd_config(args):
13086
13334
  "(/compact) when its milestone is done, before it starts another one" if s["compact"] else
13087
13335
  " — orch never compacts an agent's chat; the tools still compact by themselves when the chat is full"))
13088
13336
  return
13337
+ if args[:1] == ["lead-compact"] and args[1:2] and args[1].lower() in ("on", "off"):
13338
+ s = settings_load()
13339
+ s["lead_compact"] = args[1].lower() == "on"
13340
+ settings_save(s)
13341
+ print(f"lead-compact: {args[1].lower()}" + (" — once per run, when the lead is idle after go, it gets its "
13342
+ "tool's compact command (/compact), so the planning does not ride along on every later call"
13343
+ if s["lead_compact"] else " — orch never compacts the lead's chat"))
13344
+ return
13345
+ if args[:1] == ["news-wake"] and args[1:2] and args[1].lower() in ("on", "off"):
13346
+ s = settings_load()
13347
+ s["news_wake"] = args[1].lower() == "on"
13348
+ settings_save(s)
13349
+ print(f"news-wake: {args[1].lower()}" + (" — MERGED, AUTO-DISPATCHED and ESCALATED wake the lead at once"
13350
+ if s["news_wake"] else " — MERGED, AUTO-DISPATCHED and ESCALATED wait for the lead's next wake-up "
13351
+ "(the board, orch view and orch story show them at once)"))
13352
+ return
13089
13353
  if args:
13090
- die("usage: orch config | orch config auto-update on|off | orch config compact on|off")
13354
+ die("usage: orch config | orch config auto-update on|off | orch config compact on|off | "
13355
+ "orch config lead-compact on|off | orch config news-wake on|off")
13091
13356
  s = settings_load()
13092
13357
  env = os.environ.get("ORCH_AUTO_UPDATE")
13093
13358
  print(f"auto-update: {'on' if auto_update_on() else 'off'}"
@@ -13100,6 +13365,14 @@ def cmd_config(args):
13100
13365
  + (f" (ORCH_COMPACT={cenv} overrides the saved setting)" if cenv in ("0", "1") else "")
13101
13366
  + (f" — coders and the reviewer on {', '.join(kinds)} get /compact between milestones; "
13102
13367
  "`orch config compact off` turns it off" if compact_on() and kinds else ""))
13368
+ lenv, nenv = os.environ.get("ORCH_LEAD_COMPACT"), os.environ.get("ORCH_NEWS_WAKE")
13369
+ print(f"lead-compact: {'on' if lead_compact_on() else 'off'}"
13370
+ + (f" (ORCH_LEAD_COMPACT={lenv} overrides the saved setting)" if lenv in ("0", "1") else "")
13371
+ + (" — the lead's chat is compacted once, after go" if lead_compact_on() else ""))
13372
+ print(f"news-wake: {'on' if news_wake_on() else 'off'}"
13373
+ + (f" (ORCH_NEWS_WAKE={nenv} overrides the saved setting)" if nenv in ("0", "1") else "")
13374
+ + (" — MERGED, AUTO-DISPATCHED and ESCALATED wake the lead at once" if news_wake_on() else
13375
+ " — MERGED, AUTO-DISPATCHED and ESCALATED come with the lead's next wake-up"))
13103
13376
  print(f"installed: {installed_version()}" + ("" if release_install() else " (not a release install: no update checks)"))
13104
13377
  lc = int(s.get("last_check") or 0)
13105
13378
  print("last check: " + (time.strftime("%Y-%m-%d %H:%M", time.localtime(lc)) if lc else "never")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.46.0",
3
+ "version": "6.47.2",
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,13 +110,14 @@ 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
115
117
  - Your pane is named `lead` for you: `orch lead plan` did it (look for `NAMED` or `LEAD` at the top of its output). If it printed a rename command instead, run `orch lead whoami`, which shows YOUR pane, and run the rename command it prints. Never prompt your own pane.
116
118
  - Run `herdr agent list` and `orch agents` (which kinds exist here, their roles, and whether herdr can watch them).
117
119
  - **Coders** = the other agent panes the user wants coding (any kind with the `coder` role: claude, codex, amp, opencode, hermes, agy…). Name them `<kind>-1`, `<kind>-2`… with `herdr agent rename`, and always target them by name.
118
- - **Reviewer** = one spare agent the user picks (any kind, including another pane of your own tool), named `reviewer`. If there is none, use `Reviewer: none`.
120
+ - **Reviewer** = one spare agent the user picks (any kind, including another pane of your own tool), named `reviewer`. A full run always has one: if no spare pane is open, `orch team <your kind>` adds a reviewer pane. Only when the developer says they want no review, write `Reviewer: none (developer: <their reason>)`; a bare `Reviewer: none` is refused by `orch sync` (only a quick run may have no reviewer).
119
121
  - **Only you are open?** When `herdr agent list` shows no agent pane besides yours, build the team from your own tool: run `orch team <your kind>` (e.g. `orch team codex`). It picks coders and a reviewer of that tool on the models the catalog allows for it, spread over its tiers, and prints the `Workers:` and `Reviewer:` lines: put them in the plan. Their panes don't exist yet; `orch team up` opens them, each in its own folder and on its model, when the developer says go. Tell the developer in one line, e.g. "Only one agent window is open, so the team is 2 more Codex coders and a Codex reviewer; orch opens their windows when you say go." Use `--coders 1` when the feature is one milestone, `--models a,b` for the models the developer's tool really reaches, or another installed tool if the developer asks (`orch team claude`). Never open more panes than the plan needs.
120
122
  - You are never a coder or the reviewer in your own run. Another pane of the same kind as you is fine.
121
123
  - A pane herdr doesn't recognise as an agent (it isn't in `herdr agent list`) can still work: write it as `name (kind @pane:<pane id>)` in `Workers:`. `orch` then types prompts into that pane and relies only on its done file.
@@ -220,7 +222,7 @@ Budget: <e.g. 3h — optional>
220
222
  Estimate: <how long the whole feature should take, e.g. 1h30m>
221
223
  Lead: lead (<your kind>: <your model>)
222
224
  Workers: claude-1 (claude: sonnet), claude-2 (claude: haiku), codex-1 (codex: gpt-6.2-sol@low)
223
- Reviewer: reviewer (claude: opus) | none
225
+ Reviewer: reviewer (claude: opus) | none (developer: <why>)
224
226
 
225
227
  ## Global instructions
226
228
  <constraints for every milestone, e.g. the developer's "Must not" rules — or "none">
@@ -317,7 +319,7 @@ Rules for every milestone:
317
319
  - **Skills**: the project's skills that fit this milestone (`Skills: frontend-developer, test-driven-development`), by the names `orch onboard skills` prints. orch lists them in the coder's task file with what each is for. Leave the line out when none fits. Never a skill that runs the work itself (its own worktree, merging, helper agents): orch tells coders not to use those in a run, and `orch sync` warns.
318
320
  - **Prefer**: a worker kind or name from `Workers:` when a tool (not a model) suits the work better, otherwise `any`. A preference, not a lock; the tier comes first.
319
321
  - **Model**: never write it yourself. `orch plan model` writes `Model: <model>@<thinking>` when the developer picks a model for a milestone (step 10); it is a lock.
320
- - **Review**: `yes` for UI, API contracts, auth, payments and schema; `no` for mechanical milestones.
322
+ - **Review**: a full run reviews every milestone, whatever this line says (`Review: no` only gets a warning); write `yes`. Only a quick run uses `Review: no`. The reviewer always checks three security points (secrets in code or logs, authorization on every new or changed endpoint or action, validation of input before it reaches a query, shell, path, HTML or redirect); name the risky spots in `Context` so it knows where to look.
321
323
  - **Door**: most changes are easy to undo: if they are wrong, a revert fixes it and nobody is hurt. Write `Door: one-way (why)` only on a milestone that git can't take back once it runs: a migration that changes real data, a public API or event other apps or teams depend on, deleting data, sending emails or messages, charging money, publishing a package. Example: `Door: one-way (adds a column to orders, 2M rows in production)`. Such a milestone always waits for the developer's `orch approve` before it lands, even when no file looks risky, and its coder is asked for proof that it is safe (a dry run on a copy, a rollback test). Never mark everything one-way: the label tells the developer where to look hardest. orch measures how much each milestone could break by itself (risky files, how many milestones build on it, its size); you don't write that.
322
324
  - **ZERO GUESSWORK**: missing business rules, undefined data shapes, and auth or security trade-offs go under **Open questions** with 2–3 concrete options. `orch sync` marks such milestones `needs-answer`, and their dependents wait.
323
325
  - Each section must stand alone: autopilot hands it to the coder (without the lines only orch uses: `Depends on`, `Why separate`, `Prefer`, `Model`, `Tier`, `Needs`, `Model why`, `Estimate`, `Review`, `Parallel`, `Door`, `Side`, `Repo`; `Role` goes at the top as the coder's role, `Skills` in its own block with what each skill is for), together with the global instructions and the reports of merged dependencies.
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.
@@ -31,15 +44,15 @@ A run behaves like a call stack. You **dispatch** work and **pause**. The **even
31
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.