herdr-orchestra 6.14.0 → 6.17.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,32 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [6.17.0] - 2026-11-26
6
+
7
+ A compact that ended quickly always gets its line in `orch story` now. Nothing else about compacting changed.
8
+
9
+ Example: `claude-1` finishes M1, gets `/compact`, and is idle again before the event manager looks at it. The next job (M5) was sent at once, and the line `claude-1's chat after M1 is now a short summary (/compact)` was never written (about 1 run in 10 in the tests). Now whichever step sees the compact end first writes that line, exactly once.
10
+
11
+ ### Fixed
12
+ - **The "compact is over" line could go missing.** When the next job reached the agent before the event manager noticed the compact had ended, `orch send` / `orch review` dropped the compact silently. Both now write the story line (`<agent>'s chat after Mn is now a short summary`), and the event manager writes it only when it is the one that ends the compact. The work itself was never affected: the agent was idle and got its job.
13
+ - The test for it no longer depends on timing: section 60 checks the story lines, and a new check sends the next job before the event manager looks (it failed on 6.14.0).
14
+
15
+ ## [6.15.0] - 2026-11-26
16
+
17
+ The lead's questions before planning now open in your agent's own question picker, so you click your answers instead of typing `1 a, 2 both, 3 no`. This works in every agent that has a picker, and chat stays the fallback.
18
+
19
+ Example: `/orch-plan add discounts` in Pi shows `Discount on the whole order or on each item?` with `(a) Whole order [Recommended]`, `(b) Each item` and `Custom answer...`. You pick, the answers are saved to `.orchestrate/questions.md`, and the plan follows straight away.
20
+
21
+ ### Added
22
+ - **Native question rule** in the plan playbook (step 2a), for every lead: use your question picker when you have one (Claude Code `AskUserQuestion`, OpenCode `question`, Codex `request_user_input`, Pi `orch_ask`, Antigravity's picker), save questions and answers to `.orchestrate/questions.md`, and go straight on to the plan. If you close the picker, planning pauses and the lead never guesses. With no picker, the lead asks in chat as before. `grill:` is still one question at a time.
23
+ - **Pi: `orch_ask` tool** in orch's Pi package (Pi has no question tool of its own). It shows one picker per question, marks the suggestion `[Recommended]`, offers a custom answer, and saves the file in the main checkout's `.orchestrate/`, also from a worktree. Escape returns `cancelled`, and a Pi with no screen returns `no_ui`. A second round in the same planning is added to the file, and questions from an earlier plan are replaced.
24
+ - **Codex lead with its picker on.** New registry key `lead_flags`, added only to the lead's start command. For Codex it is `-c features.default_mode_request_user_input=true`, which codex-cli 0.172 lists as an "under development" feature. `orch team codex` and `orch agents launch codex --role lead` include it. Coders and the reviewer never get it, because a picker in an unattended pane would wait for nobody.
25
+
26
+ ### Notes
27
+ - The real pickers were not tried by hand in Claude Code, Codex, OpenCode, Antigravity or Pi. The tests drive `orch_ask` with a stand-in for Pi's screen, and the extension type-checks against `@earendil-works/pi-coding-agent` 1.6.1. Antigravity's picker tool name is not documented, so the rule describes the tool instead of naming it.
28
+ - A Codex lead that is already open keeps working as before: it asks in chat. Start it again with `orch agents launch codex --role lead` to get the picker.
29
+ - `.orchestrate/questions.md` is no longer listed as "a plan file orch does not read" in the views and `orch sync` (orch reads it to tell planning from a run).
30
+
5
31
  ## [6.14.0] - 2026-11-26
6
32
 
7
33
  A coder's and the reviewer's chat no longer keeps growing from milestone to milestone. When one is done with a milestone, orch types its tool's `/compact` into its pane while it is idle, so the tool swaps the long chat for a short summary. Every job orch gives an agent is already written down in files (`task.md`, `task.json`, fix and review files), so the next milestone loses nothing it needs.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 6.14.0
1
+ 6.17.0
@@ -10,6 +10,8 @@
10
10
  # out when the tool has none or it is unverified, and choose the model inside the tool
11
11
  # effort_flag the launch option that sets how hard the model thinks, with {effort} where the level goes. A model
12
12
  # id written `<model>@<level>` (e.g. gpt-6.2-sol@low) starts on <model> with this option
13
+ # lead_flags optional: options added only to the LEAD's start command (`orch team <kind>`, `orch agents launch
14
+ # <kind> --role lead`), never to coders or the reviewer, whose panes run unattended
13
15
  # launch_needs parts the launch command must keep for orch to work in that tool; `orch doctor` says when your
14
16
  # own launch drops one. In `launch`, {git_dir} is the repo's .git folder (filled in by orch)
15
17
  # herdr_detect herdr can tell idle / working / blocked for it (false: orch relies on the done file only)
@@ -65,6 +67,9 @@ binary = "codex"
65
67
  # waiting for an approval review.
66
68
  launch = "codex --approve-for-me -c sandbox_workspace_write.network_access=true -c 'sandbox_workspace_write.writable_roots=[\"{git_dir}\"]'"
67
69
  launch_needs = ["sandbox_workspace_write.network_access=true", "sandbox_workspace_write.writable_roots"]
70
+ # The lead only: Codex's question picker (request_user_input) outside Plan mode, so /orch-plan asks its questions
71
+ # in a picker. Coders never get it: a picker in an unattended pane would wait for nobody.
72
+ lead_flags = "-c features.default_mode_request_user_input=true"
68
73
  model_flag = "--model"
69
74
  effort_flag = "-c model_reasoning_effort={effort}"
70
75
  herdr_detect = true
@@ -75,7 +80,7 @@ skills_dirs = ["~/.agents/skills", "~/.codex/skills"]
75
80
  skills_reads = ["~/.agents/skills", "~/.codex/skills"]
76
81
  invoke = "$orch-plan <feature> (or: use the orch-plan skill: <feature>)"
77
82
  verified = true
78
- notes = "codex-cli 0.167: --full-auto is gone; --approve-for-me routes approvals to automatic review in the workspace-write sandbox. Reads ~/.codex/skills and ~/.agents/skills (its docs name ~/.agents/skills as the user folder, and say two skills with the same name both show up, so orch keeps one copy). codex-cli 0.172 (checked with `codex sandbox`): in workspace-write, .git is read-only and connecting to a local socket is refused; sandbox_workspace_write.network_access=true lets the herdr socket through (it also allows the internet) and writable_roots with the repo's .git lets git work. Thinking level: -c model_reasoning_effort=low|medium|high|xhigh|max. `codex debug models` lists the models this Codex has (see [discover.codex] in models.default.toml)."
83
+ notes = "codex-cli 0.167: --full-auto is gone; --approve-for-me routes approvals to automatic review in the workspace-write sandbox. Reads ~/.codex/skills and ~/.agents/skills (its docs name ~/.agents/skills as the user folder, and say two skills with the same name both show up, so orch keeps one copy). codex-cli 0.172 (checked with `codex sandbox`): in workspace-write, .git is read-only and connecting to a local socket is refused; sandbox_workspace_write.network_access=true lets the herdr socket through (it also allows the internet) and writable_roots with the repo's .git lets git work. Thinking level: -c model_reasoning_effort=low|medium|high|xhigh|max. `codex debug models` lists the models this Codex has (see [discover.codex] in models.default.toml). codex-cli 0.172 (checked with `codex features list`): default_mode_request_user_input is an 'under development' feature, off by default; -c features.default_mode_request_user_input=true turns it on (request_user_input is refused in `codex exec`)."
79
84
 
80
85
  [amp]
81
86
  binary = "amp"
Binary file
package/bin/orch CHANGED
@@ -2113,6 +2113,20 @@ def start_compact(st, name, w, cmd, before=None):
2113
2113
  return True
2114
2114
 
2115
2115
 
2116
+ def end_compact(st, name, w, note=True):
2117
+ """The agent's compact is over: forget it, and say so once in `orch story`. Whichever step sees it first calls
2118
+ this: the event manager (herdr shows the agent idle again) or the next job sent to the agent (`orch send`,
2119
+ `orch review`), so the story line never depends on which of the two came first. Returns the record or None."""
2120
+ h = (w or {}).pop("compacting", None)
2121
+ if not h:
2122
+ return None
2123
+ w["ctx"] = None
2124
+ if note:
2125
+ story_note(st, f"{name}'s chat after {h.get('after') or 'its last milestone'} is now a short summary "
2126
+ f"({h.get('cmd') or '/compact'})", who="event manager")
2127
+ return h
2128
+
2129
+
2116
2130
  def compacting_line(st, name, w):
2117
2131
  h = w.get("compacting") or {}
2118
2132
  return (f"compacting its chat after {h.get('after') or '?'} ({h.get('cmd') or '/compact'}, sent "
@@ -2945,8 +2959,8 @@ def cmd_send(args):
2945
2959
  "result": str(d / rel / f"result-{k}.json"), "since": now(), "started": now(), "kind": "coder",
2946
2960
  "prompt": text, "nudges": 0, "file": fname, "delivering": True,
2947
2961
  "model": st["workers"][t["worker"]].get("model"), "tier": st["workers"][t["worker"]].get("tier")}
2962
+ end_compact(st, t["worker"], st["workers"][t["worker"]]) # compacted before this job: say so, once
2948
2963
  st["workers"][t["worker"]]["ctx"] = tid # its chat now holds this milestone (compacted before another)
2949
- st["workers"][t["worker"]].pop("compacting", None)
2950
2964
  save(st)
2951
2965
  try:
2952
2966
  deliver(st, t["worker"], text)
@@ -3120,8 +3134,8 @@ def cmd_review(args):
3120
3134
  t["review_round"] = k
3121
3135
  st["reviewer_busy"] = tid
3122
3136
  if st.get("reviewer_info") is not None:
3137
+ end_compact(st, st["reviewer"], st["reviewer_info"])
3123
3138
  st["reviewer_info"]["ctx"] = tid # its chat now holds this milestone (compacted before another)
3124
- st["reviewer_info"].pop("compacting", None)
3125
3139
  move(st, tid, "reviewing")
3126
3140
  t["wait"] = {"agent": st["reviewer"], "sentinel": str(sentinel), "report": str(rd / f"review-{k}.md"),
3127
3141
  "result": str(rd / f"review-{k}.json"), "since": now(), "started": now(), "kind": "reviewer",
@@ -5886,20 +5900,21 @@ def _autopilot(args):
5886
5900
  late = now() - h.get("ts", 0) > COMPACT_MAX_S
5887
5901
  done = not still_compacting(st_, n, w)
5888
5902
 
5903
+ ended = {}
5904
+
5889
5905
  def upd(s_, n=n, idle=h.get("idle_since"), done=done, late=late, busy=busy):
5890
5906
  a = _agent_of(s_, n)
5891
5907
  if not a or not a.get("compacting"):
5892
- return
5908
+ return # its next job was sent first: that step already said so
5893
5909
  if not done:
5894
5910
  a["compacting"]["idle_since"] = idle
5895
5911
  return
5896
- a.pop("compacting", None)
5897
- a["ctx"] = None
5912
+ ended["yes"] = end_compact(s_, n, a, note=not (late and busy))
5898
5913
  if late and busy:
5899
5914
  story_note(s_, f"{n} was still busy {_fmt_secs(COMPACT_MAX_S)} after {h.get('cmd')}: orch "
5900
5915
  f"stopped waiting for it", who="event manager")
5901
5916
  patch_state(upd)
5902
- if done:
5917
+ if ended:
5903
5918
  say(f"{n} is still working {_fmt_secs(COMPACT_MAX_S)} after {h.get('cmd')}: look at its pane"
5904
5919
  if late and busy else f"COMPACTED {n}: its chat after {h.get('after')} is now a short summary",
5905
5920
  late and busy)
@@ -6722,6 +6737,7 @@ def launch_cmd(kind, v, model=None, strict=True, role=None, cwd=None):
6722
6737
  """The shell command that starts agent `kind` in a pane, on `model` when given. With strict=False a kind
6723
6738
  without a model_flag starts on its default model instead of failing (the caller says so). role="reviewer"
6724
6739
  uses the kind's `review_launch` when it has one: the same tool with its code-editing tools turned off.
6740
+ role="lead" adds the kind's `lead_flags` (Codex: its question picker, so /orch-plan asks in a picker).
6725
6741
  A model `<id>@<level>` on a kind with an `effort_flag` starts <id> with that thinking level. `cwd` is the
6726
6742
  folder the agent will run in ({git_dir} is filled in from it)."""
6727
6743
  cmd = fill_launch((v.get("review_launch") if role == "reviewer" else None) or v.get("launch")
@@ -6743,6 +6759,8 @@ def launch_cmd(kind, v, model=None, strict=True, role=None, cwd=None):
6743
6759
  cmd += f" {v['model_flag']} {shlex.quote(base)}"
6744
6760
  if effort:
6745
6761
  cmd += " " + v["effort_flag"].replace("{effort}", shlex.quote(effort))
6762
+ if role == "lead" and v.get("lead_flags"):
6763
+ cmd += " " + v["lead_flags"]
6746
6764
  return cmd
6747
6765
 
6748
6766
 
@@ -6830,7 +6848,7 @@ def cmd_team(args):
6830
6848
  f"it, and `orch sync` will say so")
6831
6849
  if top and v.get("model_flag") and "lead" in roles:
6832
6850
  print(f"\nYour own lead pane on the strongest level (start it like this, then write `Lead: lead ({kind}: {top})`):"
6833
- f"\n {launch_cmd(kind, v, top, strict=False)}")
6851
+ f"\n {launch_cmd(kind, v, top, strict=False, role='lead')}")
6834
6852
  print(f"\nCheck these are models your {kind} really reaches (`--models a,b` to choose others).")
6835
6853
  print("\nThese panes don't exist yet. After `orch sync` and `orch start`, `orch team up` opens each one in its "
6836
6854
  "own folder, on its model, and names it.")
@@ -7220,7 +7238,8 @@ def view_events(limit=None):
7220
7238
  return out
7221
7239
 
7222
7240
 
7223
- ORCH_OWN_MD = {"plan.md", "summary.md", "summary.prev.md", "story.md", "pr-body.md", "manual-tests.md"}
7241
+ ORCH_OWN_MD = {"plan.md", "summary.md", "summary.prev.md", "story.md", "pr-body.md", "manual-tests.md",
7242
+ "questions.md"} # questions.md: the lead writes it, orch reads it (asked_before_plan)
7224
7243
 
7225
7244
 
7226
7245
  def other_plan_files(newer_than=0):
@@ -8091,7 +8110,7 @@ def sandbox_warnings():
8091
8110
  if out and codex:
8092
8111
  v = (registry(required=False) or {}).get("codex") or {}
8093
8112
  out.append(" Fix: quit this Codex and start it again with orch's command (it opens just those two):\n "
8094
- + launch_cmd("codex", v, None, strict=False, cwd=Path.cwd()) + "\n (`orch agents launch codex "
8113
+ + launch_cmd("codex", v, None, strict=False, role="lead", cwd=Path.cwd()) + "\n (`orch agents launch codex "
8095
8114
  "--role lead --model <id>` adds a model; `orch models` lists them)")
8096
8115
  return out
8097
8116
 
@@ -8621,7 +8640,7 @@ def cmd_agents(args):
8621
8640
  if sub == "launch":
8622
8641
  rest = args[1:]
8623
8642
  model, role = None, None
8624
- use = "usage: orch agents launch <kind> [--model <id>] [--role coder|reviewer]"
8643
+ use = "usage: orch agents launch <kind> [--model <id>] [--role coder|reviewer|lead]"
8625
8644
  if "--model" in rest:
8626
8645
  i = rest.index("--model")
8627
8646
  model = rest[i + 1] if len(rest) > i + 1 else die(use)
@@ -8704,9 +8723,9 @@ def doctor_kind(kind, v, full=True):
8704
8723
  hcmd = v.get("help_cmd") or f"{binary} --help"
8705
8724
  code, help_ = _probe(hcmd)
8706
8725
  flags = []
8707
- for key in ("launch", "review_launch"):
8726
+ for key in ("launch", "review_launch", "lead_flags"):
8708
8727
  try:
8709
- launch = shlex.split(v.get(key) or binary)
8728
+ launch = shlex.split(v.get(key) or binary) if key != "lead_flags" else [binary] + shlex.split(v.get(key) or "")
8710
8729
  except ValueError:
8711
8730
  launch = [binary]
8712
8731
  for f in (tok.split("=")[0] for tok in launch[1:] if tok.startswith("-")):
@@ -12,12 +12,16 @@
12
12
  // Commands: /orch-mode [panes|subagent] show or switch the mode; `subagent` also sets it up (below)
13
13
  // /orch-setup [--mode panes|subagent] install the `orch` command from this package (needed once)
14
14
  //
15
+ // Tool: orch_ask the lead's clickable questions before it writes the plan (/orch-plan
16
+ // step 2a): one picker per question, answers saved in
17
+ // .orchestrate/questions.md. Pi has no question tool of its own.
18
+ //
15
19
  // Subagent mode is set up from inside Pi, with no terminal step: `/orch-mode subagent` runs
16
20
  // `orch setup --mode subagent` (or this package's installer when orch is missing or old), which writes
17
21
  // ~/.pi/agent/agents/coder.md and reviewer.md and runs `pi install npm:@tintinweb/pi-subagents`. When that install
18
22
  // is new, the command reloads Pi (ctx.reload) so the Agent tool is there at once.
19
23
  import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@earendil-works/pi-coding-agent";
20
- import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
24
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
21
25
  import { homedir } from "node:os";
22
26
  import { dirname, join, resolve } from "node:path";
23
27
  import { fileURLToPath } from "node:url";
@@ -66,6 +70,83 @@ async function stateFile(pi: ExtensionAPI, cwd: string): Promise<string | undefi
66
70
  return undefined;
67
71
  }
68
72
 
73
+ /** The main checkout's .orchestrate folder (the same place as stateFile(), also from a worktree); cwd's when no git. */
74
+ async function orchestrateDir(pi: ExtensionAPI, cwd: string): Promise<string> {
75
+ try {
76
+ const r = await pi.exec("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd, timeout: 5000 });
77
+ if (r.code === 0 && r.stdout.trim()) return join(dirname(r.stdout.trim()), ".orchestrate");
78
+ } catch {
79
+ // no git: use cwd
80
+ }
81
+ return join(cwd, ".orchestrate");
82
+ }
83
+
84
+ type AskOption = { key: string; label: string; description?: string; recommended?: boolean };
85
+ type AskQuestion = { id: string; question: string; options: AskOption[]; allow_custom?: boolean };
86
+ type AskParams = { title?: string; questions: AskQuestion[] };
87
+ type AskAnswer = { id: string; question: string; key: string; label: string; custom: boolean };
88
+
89
+ const CUSTOM = "Custom answer...";
90
+
91
+ /** orch_ask's parameters, as plain JSON Schema (Pi validates JSON Schema; no typebox import needed). */
92
+ const ASK_SCHEMA = {
93
+ type: "object",
94
+ properties: {
95
+ title: { type: "string", description: 'Short header, e.g. "Decisions before planning"' },
96
+ questions: {
97
+ type: "array",
98
+ minItems: 1,
99
+ maxItems: 8,
100
+ description: "The decisions only the developer can make, asked one after another",
101
+ items: {
102
+ type: "object",
103
+ properties: {
104
+ id: { type: "string", description: "q1, q2, ..." },
105
+ question: { type: "string", description: "One clear question" },
106
+ options: {
107
+ type: "array",
108
+ minItems: 1,
109
+ maxItems: 6,
110
+ items: {
111
+ type: "object",
112
+ properties: {
113
+ key: { type: "string", description: "a, b, c" },
114
+ label: { type: "string", description: "The choice, in a few words" },
115
+ description: { type: "string", description: "Optional: what it means, from what you found" },
116
+ recommended: { type: "boolean", description: "true on your suggested choice (one per question)" },
117
+ },
118
+ required: ["key", "label"],
119
+ },
120
+ },
121
+ allow_custom: { type: "boolean", description: 'Adds "Custom answer..." (default true)' },
122
+ },
123
+ required: ["id", "question", "options"],
124
+ },
125
+ },
126
+ },
127
+ required: ["questions"],
128
+ } as const;
129
+
130
+ function optionLine(o: AskOption): string {
131
+ return `(${o.key}) ${o.label}${o.recommended ? " [Recommended]" : ""}${o.description ? ` - ${o.description}` : ""}`;
132
+ }
133
+
134
+ /** The questions and answers as markdown for .orchestrate/questions.md (questions with choices, then ## Answers). */
135
+ function questionsMarkdown(p: AskParams, answers: AskAnswer[]): string {
136
+ const lines = [`# ${p.title?.trim() || "Questions before planning"}`, ""];
137
+ p.questions.forEach((q, i) => {
138
+ lines.push(`${i + 1}. ${q.question}`);
139
+ for (const o of q.options) lines.push(` ${optionLine(o)}`);
140
+ });
141
+ lines.push("", "## Answers", "");
142
+ answers.forEach((a, i) => lines.push(`${i + 1}. ${a.custom ? a.label : `(${a.key}) ${a.label}`}`));
143
+ return lines.join("\n") + "\n";
144
+ }
145
+
146
+ function textResult(text: string, details: Record<string, unknown>) {
147
+ return { content: [{ type: "text" as const, text }], details };
148
+ }
149
+
69
150
  async function readMode(pi: ExtensionAPI, cwd: string): Promise<{ mode: Mode; from: string }> {
70
151
  const state = await stateFile(pi, cwd);
71
152
  if (state) {
@@ -153,7 +234,77 @@ export default function orchMode(pi: ExtensionAPI) {
153
234
  mode === "subagent"
154
235
  ? "herdr-orchestra (orch) mode: subagent. When you lead an orch run, the coder and the reviewer are Pi subagents (the Agent tool), not herdr panes; `orch lead run` prints the steps."
155
236
  : "herdr-orchestra (orch) mode: panes. When you lead an orch run, coders and the reviewer run in herdr panes; `orch lead run` prints the steps.";
156
- return { systemPrompt: `${event.systemPrompt}\n\n${line}` };
237
+ const ask =
238
+ "When you lead /orch-plan and need decisions only the developer can make, ask them with the orch_ask tool " +
239
+ "(clickable choices, saved to .orchestrate/questions.md). A coder or reviewer never uses it.";
240
+ return { systemPrompt: `${event.systemPrompt}\n\n${line}\n${ask}` };
241
+ });
242
+
243
+ pi.registerTool({
244
+ name: "orch_ask",
245
+ label: "orch ask",
246
+ description:
247
+ "herdr-orchestra lead only, during /orch-plan (plan playbook step 2a): ask the developer the decisions only " +
248
+ "they can make, as clickable choices, before you write .orchestrate/plan.md. Shows one picker per question, " +
249
+ "saves questions and answers to .orchestrate/questions.md, and returns the answers. status `cancelled`: the " +
250
+ "developer stopped; don't guess, say planning is paused until they answer. status `no_ui`: ask in chat instead. " +
251
+ "Coders and reviewers never use it (a coder reports status `question` in its result file).",
252
+ promptSnippet: "orch_ask: the orch lead's clickable questions for the developer before writing the plan",
253
+ parameters: ASK_SCHEMA as any,
254
+ async execute(_id: string, params: AskParams, _signal: AbortSignal | undefined, _onUpdate: unknown, ctx: ExtensionContext) {
255
+ const qs = Array.isArray(params?.questions) ? params.questions : [];
256
+ if (!qs.length) return textResult("orch_ask needs at least one question.", { status: "error" });
257
+ if (!ctx.hasUI) {
258
+ return textResult(
259
+ "status: no_ui. This Pi has no screen for pickers (print or JSON mode). Write the questions to " +
260
+ ".orchestrate/questions.md and ask them in chat, as plan playbook step 2a says.",
261
+ { status: "no_ui" },
262
+ );
263
+ }
264
+ const answers: AskAnswer[] = [];
265
+ for (let i = 0; i < qs.length; i++) {
266
+ const q = qs[i];
267
+ const opts = Array.isArray(q.options) ? q.options : [];
268
+ const choices = opts.map(optionLine);
269
+ if (q.allow_custom !== false) choices.push(CUSTOM);
270
+ const head = (params.title?.trim() || "Decisions before planning") + (qs.length > 1 ? ` (${i + 1} of ${qs.length})` : "");
271
+ const picked: string | undefined = await ctx.ui.select(`${head}\n${q.question}`, choices);
272
+ let answer: AskAnswer | undefined;
273
+ if (picked === CUSTOM) {
274
+ const typed: string | undefined = await ctx.ui.input(q.question, "Your answer");
275
+ if (typed !== undefined && typed.trim()) answer = { id: q.id, question: q.question, key: "custom", label: typed.trim(), custom: true };
276
+ } else if (picked !== undefined) {
277
+ const o = opts[choices.indexOf(picked)];
278
+ if (o) answer = { id: q.id, question: q.question, key: o.key, label: o.label, custom: false };
279
+ }
280
+ if (!answer) {
281
+ return textResult(
282
+ `status: cancelled at question ${i + 1} of ${qs.length} (${q.id}). The developer stopped answering. ` +
283
+ "Don't guess and don't write the plan: tell them planning is paused until they answer, and ask again " +
284
+ "when they say so. Nothing was saved.",
285
+ { status: "cancelled", at: q.id, answers },
286
+ );
287
+ }
288
+ answers.push(answer);
289
+ }
290
+ const dir = await orchestrateDir(pi, ctx.cwd);
291
+ mkdirSync(dir, { recursive: true });
292
+ const file = join(dir, "questions.md");
293
+ const md = questionsMarkdown(params, answers);
294
+ // The same planning (questions.md newer than plan.md: a second round, or `grill:` one at a time): add to it.
295
+ // Otherwise it is from an earlier plan: start the file again.
296
+ const plan = join(dir, "plan.md");
297
+ const samePlanning =
298
+ existsSync(file) && readFileSync(file, "utf8").trim() !== "" && (!existsSync(plan) || statSync(file).mtimeMs > statSync(plan).mtimeMs);
299
+ if (samePlanning) appendFileSync(file, "\n" + md);
300
+ else writeFileSync(file, md);
301
+ const lines = answers.map((a, i) => `${i + 1}. ${a.id}: ${a.custom ? `custom: ${a.label}` : `(${a.key}) ${a.label}`}`);
302
+ return textResult(
303
+ `status: answered. Saved in ${file}. The developer's answers:\n${lines.join("\n")}\n` +
304
+ "Write each answer into the plan where it applies (plan playbook step 2a), then carry on from step 2b.",
305
+ { status: "answered", file, answers },
306
+ );
307
+ },
157
308
  });
158
309
 
159
310
  /** Lines worth showing from installer / `orch setup` output (both can be long). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "6.14.0",
3
+ "version": "6.17.0",
4
4
  "description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp, Pi) as one team: a lead plans, coders build, a reviewer checks, you get one PR. Runs in Herdr panes, or in one Pi window with subagents.",
5
5
  "license": "MIT",
6
6
  "bin": {
package/playbooks/plan.md CHANGED
@@ -37,16 +37,19 @@ Feature request = the user's message that asked you to run this playbook.
37
37
  A wrong guess in the plan is the most expensive mistake in a run: every coder builds on it. So before you write any plan, settle what only the developer can decide.
38
38
  - From your research, list what the code, the docs and the request do NOT settle: business rules ("can a discount bring the total to zero?"), data shapes nobody has defined, auth or security trade-offs, which of two existing patterns to follow, a change to a decision record. Not questions the code answers: look those up yourself.
39
39
  - **Nothing to ask?** Go straight on to step 2b. Don't invent questions.
40
- - **Something to ask?** Write the questions to `.orchestrate/questions.md` and show the developer the same text, **all in one message**: one line each, numbered, with 2 or 3 concrete choices and your own suggestion and why (from what you found). End with: "Answer by number (for example `1 a, 2 both, 3 no`). I write the plan after your answers; nothing runs until you say go." Then **STOP** and wait.
41
- Example:
40
+ - **Something to ask?** Use the **native question rule**: put all the questions in front of the developer at once, each with 2 or 3 concrete choices and your own suggestion and why (from what you found).
41
+ 1. **You have a question picker: use it.** That is any tool of yours that shows the developer clickable choices and returns their pick: `AskUserQuestion` in Claude Code, `question` in OpenCode, `request_user_input` in Codex (orch starts a Codex lead with it turned on), `orch_ask` in Pi (from orch's Pi package), Antigravity's own picker. Choices `(a)`, `(b)`, `(c)`, your suggestion marked recommended (or labelled `(recommended)`), a custom answer allowed. A picker that takes fewer questions than you have (Claude Code takes 4 at a time): ask in two rounds. When the answers come back, write the questions with their choices and the answers under `## Answers` in `.orchestrate/questions.md` (`orch_ask` saves the file itself), then go straight on: no extra message, no waiting.
42
+ 2. **The developer closed the picker without answering** (Escape, `cancelled`): don't guess and don't plan. Say "Planning is paused until you answer these. Say when you are ready, or answer in chat." and **STOP**.
43
+ 3. **No picker, or it can't show here** (headless, `no_ui`, the tool is refused): write the questions to `.orchestrate/questions.md` and show the developer the same text, **all in one message**: one line each, numbered. End with: "Answer by number (for example `1 a, 2 both, 3 no`). I write the plan after your answers; nothing runs until you say go." Then **STOP** and wait.
44
+ Example (the chat form; a picker shows the same question and choices, one at a time):
42
45
  ```
43
46
  Before I plan, 3 questions:
44
47
  1. Discount on the whole order or on each item? (a) whole order (b) each item. I suggest (a): the cart has no per-item price changes today.
45
48
  2. Percent, fixed amount, or both? I suggest both: the admin screen already has a type dropdown.
46
49
  3. Can a discount bring the total to zero? I suggest no: the payment step refuses a zero total.
47
50
  ```
48
- - The developer started the request with `grill:`: ask **one question at a time** instead, each with your suggestion, until nothing is left that only they can decide. Then go on.
49
- - **When the answers come**, add them under `## Answers` in `.orchestrate/questions.md`, then carry on from step 2b. Write each answer into the plan where it applies: the `Constraints` of the milestones it affects, or `## Global instructions` when it affects all of them (e.g. `Decided by the developer: a discount applies to the whole order, never to one item`). The open questions inside milestones (step 9) are only for what still comes up later.
51
+ - The developer started the request with `grill:`: ask **one question at a time** instead (one picker call per question when you have a picker), each with your suggestion, until nothing is left that only they can decide. Then go on.
52
+ - **When the answers come** (from the picker or in chat), make sure they are under `## Answers` in `.orchestrate/questions.md`, then carry on from step 2b. Write each answer into the plan where it applies: the `Constraints` of the milestones it affects, or `## Global instructions` when it affects all of them (e.g. `Decided by the developer: a discount applies to the whole order, never to one item`). The open questions inside milestones (step 9) are only for what still comes up later.
50
53
  - **New words and decisions get written down.** When the feature brings a new name for something (Discount, not coupon or promo), list it under `## Glossary additions` in the plan (`- **Discount**: money taken off an order total, in paise`), and give the milestone that introduces it an acceptance criterion `docs/glossary.md defines Discount`, with `docs/glossary.md` in its Likely files. A decision that will be hard to change later (money in paise, one discount per order) gets a decision record the same way: `docs/adr/<next number>-<short-name>.md records the decision and why`. The coder writes these files; you never do. Skip both in a repo that keeps no glossary or decision records, unless the developer asks.
51
54
 
52
55
  ## 2b. Quick or full: decide from what you found, not from how the request sounds