herdr-orchestra 6.0.0 → 6.3.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 +54 -0
- package/README.md +43 -2
- package/VERSION +1 -1
- package/agents.default.toml +22 -0
- package/bin/__pycache__/orchcpython-314.pyc +0 -0
- package/bin/orch +646 -38
- package/extensions/orch-mode.ts +224 -0
- package/install.sh +8 -0
- package/package.json +27 -4
- package/pi/README.md +5 -0
- package/pi/skills/orch-plan/SKILL.md +6 -0
- package/playbooks/run.md +2 -0
- package/playbooks/subagent.md +40 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// herdr-orchestra for Pi (https://pi.dev): shows which orch mode this window is in and lets you switch it.
|
|
2
|
+
//
|
|
3
|
+
// panes (default) coders and the reviewer run in herdr panes; the lead uses `orch dispatch`
|
|
4
|
+
// subagent one Pi window: the lead starts the coder and the reviewer as Pi subagents (@tintinweb/pi-subagents)
|
|
5
|
+
//
|
|
6
|
+
// Only Pi loads this file (package.json "pi".extensions). Claude Code, Codex, OpenCode and the other agents never
|
|
7
|
+
// read it, and `npx herdr-orchestra` ignores it.
|
|
8
|
+
//
|
|
9
|
+
// Where the mode comes from: this repo's run (.orchestrate/state.json, `orch_mode`; a run from before 6.2.0 is
|
|
10
|
+
// panes), else ~/.config/herdr-orchestra/config.json (`mode`), else panes.
|
|
11
|
+
//
|
|
12
|
+
// Commands: /orch-mode [panes|subagent] show or switch the mode
|
|
13
|
+
// /orch-setup install the `orch` command from this package (needed once)
|
|
14
|
+
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
|
+
import { homedir } from "node:os";
|
|
17
|
+
import { dirname, join, resolve } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
19
|
+
|
|
20
|
+
type Mode = "panes" | "subagent";
|
|
21
|
+
const MODES: Mode[] = ["panes", "subagent"];
|
|
22
|
+
const STATUS_KEY = "orch";
|
|
23
|
+
|
|
24
|
+
function packageRoot(): string {
|
|
25
|
+
const here = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
return resolve(here, "..");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function configFile(): string {
|
|
30
|
+
return process.env.ORCH_CONFIG_FILE || join(homedir(), ".config", "herdr-orchestra", "config.json");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function readJson(path: string): Record<string, unknown> | undefined {
|
|
34
|
+
try {
|
|
35
|
+
const data = JSON.parse(readFileSync(path, "utf8"));
|
|
36
|
+
return data && typeof data === "object" && !Array.isArray(data) ? data : undefined;
|
|
37
|
+
} catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function asMode(value: unknown): Mode | undefined {
|
|
43
|
+
return typeof value === "string" && (MODES as string[]).includes(value.toLowerCase())
|
|
44
|
+
? (value.toLowerCase() as Mode)
|
|
45
|
+
: undefined;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** .orchestrate/state.json of the repo that holds cwd (orch keeps it in the main checkout, not in worktrees). */
|
|
49
|
+
async function stateFile(pi: ExtensionAPI, cwd: string): Promise<string | undefined> {
|
|
50
|
+
try {
|
|
51
|
+
const r = await pi.exec("git", ["rev-parse", "--path-format=absolute", "--git-common-dir"], { cwd, timeout: 5000 });
|
|
52
|
+
if (r.code === 0 && r.stdout.trim()) {
|
|
53
|
+
const p = join(dirname(r.stdout.trim()), ".orchestrate", "state.json");
|
|
54
|
+
return existsSync(p) ? p : undefined;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
// not a git repo, or no git: no run here
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function readMode(pi: ExtensionAPI, cwd: string): Promise<{ mode: Mode; from: string }> {
|
|
63
|
+
const state = await stateFile(pi, cwd);
|
|
64
|
+
if (state) {
|
|
65
|
+
const st = readJson(state);
|
|
66
|
+
if (st) return { mode: asMode(st.orch_mode) ?? "panes", from: "this repo's run" };
|
|
67
|
+
}
|
|
68
|
+
const saved = asMode(readJson(configFile())?.mode);
|
|
69
|
+
return saved ? { mode: saved, from: configFile() } : { mode: "panes", from: "default" };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function saveConfigMode(mode: Mode): void {
|
|
73
|
+
const path = configFile();
|
|
74
|
+
const data = readJson(path) ?? {};
|
|
75
|
+
data.mode = mode;
|
|
76
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
77
|
+
writeFileSync(path + ".tmp", JSON.stringify(data, null, 2) + "\n");
|
|
78
|
+
renameSync(path + ".tmp", path);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function orchCommand(pi: ExtensionAPI): Promise<string | undefined> {
|
|
82
|
+
const r = await pi.exec("sh", ["-c", 'command -v orch || { test -x "$HOME/.local/bin/orch" && echo "$HOME/.local/bin/orch"; }'], {
|
|
83
|
+
timeout: 5000,
|
|
84
|
+
});
|
|
85
|
+
const path = r.stdout.trim().split("\n")[0];
|
|
86
|
+
return r.code === 0 && path ? path : undefined;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function packageVersion(): string | undefined {
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(readFileSync(join(packageRoot(), "package.json"), "utf8")).version;
|
|
92
|
+
} catch {
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** "6.1.0" or "6.2.0-dev" -> [6, 1, 0]; undefined when it is not a version. */
|
|
98
|
+
function parseVersion(text: string | undefined): number[] | undefined {
|
|
99
|
+
const m = /(\d+)\.(\d+)\.(\d+)/.exec(text ?? "");
|
|
100
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : undefined;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function olderThan(a: number[], b: number[]): boolean {
|
|
104
|
+
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] < b[i];
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** What orch is on this machine: missing, older than this package (an old install next to a new Pi package, which
|
|
109
|
+
* has no `orch mode` yet), or ok. */
|
|
110
|
+
async function orchState(pi: ExtensionAPI): Promise<{ state: "missing" | "old" | "ok"; path?: string; version?: string }> {
|
|
111
|
+
const path = await orchCommand(pi);
|
|
112
|
+
if (!path) return { state: "missing" };
|
|
113
|
+
const r = await pi.exec(path, ["version"], { timeout: 10000 });
|
|
114
|
+
const have = parseVersion(r.stdout);
|
|
115
|
+
const want = parseVersion(packageVersion());
|
|
116
|
+
const version = have?.join(".");
|
|
117
|
+
if (r.code !== 0 || !have || (want && olderThan(have, want))) return { state: "old", path, version };
|
|
118
|
+
return { state: "ok", path, version };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function showStatus(ctx: ExtensionContext, mode: Mode): void {
|
|
122
|
+
ctx.ui.setStatus(STATUS_KEY, `orch: ${mode}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default function orchMode(pi: ExtensionAPI) {
|
|
126
|
+
let mode: Mode = "panes";
|
|
127
|
+
|
|
128
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
129
|
+
mode = (await readMode(pi, ctx.cwd)).mode;
|
|
130
|
+
showStatus(ctx, mode);
|
|
131
|
+
const o = await orchState(pi);
|
|
132
|
+
if (o.state === "missing") {
|
|
133
|
+
ctx.ui.notify("herdr-orchestra: the `orch` command is not installed yet. Type /orch-setup once to install it.", "warning");
|
|
134
|
+
} else if (o.state === "old") {
|
|
135
|
+
ctx.ui.notify(
|
|
136
|
+
`herdr-orchestra: this Pi package is ${packageVersion() ?? "newer"} but the orch command on this machine is ${o.version ?? "older"}, which does not know the modes. Type /orch-setup to update it.`,
|
|
137
|
+
"warning",
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Pi knows the mode on every turn. Worded for anyone who reads it (a coder subagent loads this extension too).
|
|
143
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
144
|
+
mode = (await readMode(pi, ctx.cwd)).mode;
|
|
145
|
+
const line =
|
|
146
|
+
mode === "subagent"
|
|
147
|
+
? "herdr-orchestra (orch) mode: subagent. When you lead an orch run, the coder and the reviewer are Pi subagents (the Agent tool), not herdr panes; `orch lead run` prints the steps."
|
|
148
|
+
: "herdr-orchestra (orch) mode: panes. When you lead an orch run, coders and the reviewer run in herdr panes; `orch lead run` prints the steps.";
|
|
149
|
+
return { systemPrompt: `${event.systemPrompt}\n\n${line}` };
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
pi.registerCommand("orch-mode", {
|
|
153
|
+
description: "Show or switch the herdr-orchestra mode: panes (herdr panes) or subagent (one Pi window)",
|
|
154
|
+
getArgumentCompletions: (prefix: string) =>
|
|
155
|
+
MODES.filter((m) => m.startsWith(prefix.trim().toLowerCase())).map((m) => ({ value: m, label: m })),
|
|
156
|
+
handler: async (args, ctx) => {
|
|
157
|
+
const want = args.trim().toLowerCase();
|
|
158
|
+
if (!want) {
|
|
159
|
+
const cur = await readMode(pi, ctx.cwd);
|
|
160
|
+
mode = cur.mode;
|
|
161
|
+
showStatus(ctx, mode);
|
|
162
|
+
ctx.ui.notify(`orch mode: ${cur.mode} (${cur.from}). Switch with /orch-mode panes or /orch-mode subagent.`, "info");
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const next = asMode(want);
|
|
166
|
+
if (!next) {
|
|
167
|
+
ctx.ui.notify(`Unknown mode "${want}". Use /orch-mode panes or /orch-mode subagent.`, "error");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const o = await orchState(pi);
|
|
171
|
+
const orch = o.state === "ok" ? o.path : undefined;
|
|
172
|
+
if (orch) {
|
|
173
|
+
// `orch mode` saves the machine's default and, when nothing is in progress, this repo's run too
|
|
174
|
+
const r = await pi.exec(orch, ["mode", next], { cwd: ctx.cwd, timeout: 30000 });
|
|
175
|
+
const out = (r.stdout + r.stderr).trim();
|
|
176
|
+
if (r.code !== 0) {
|
|
177
|
+
ctx.ui.notify(out || `orch mode ${next} failed`, "error");
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
ctx.ui.notify(out, "info");
|
|
181
|
+
} else {
|
|
182
|
+
saveConfigMode(next);
|
|
183
|
+
ctx.ui.notify(
|
|
184
|
+
`orch mode: ${next} (saved in ${configFile()}). ` +
|
|
185
|
+
(o.state === "old" ? `The orch command here is ${o.version ?? "older"} and does not know the modes yet: ` : "") +
|
|
186
|
+
"Type /orch-setup to install the orch command.",
|
|
187
|
+
"info",
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const now = await readMode(pi, ctx.cwd);
|
|
191
|
+
mode = now.mode;
|
|
192
|
+
showStatus(ctx, mode);
|
|
193
|
+
if (now.mode !== next) {
|
|
194
|
+
ctx.ui.notify(`This repo's run stays ${now.mode} (${orch ? "something is in progress" : "switch it with /orch-mode after /orch-setup"}). New runs use ${next}.`, "warning");
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
pi.registerCommand("orch-setup", {
|
|
200
|
+
description: "Install the herdr-orchestra `orch` command from this package (and, in subagent mode, its Pi subagents)",
|
|
201
|
+
handler: async (_args, ctx) => {
|
|
202
|
+
const installer = join(packageRoot(), "install.sh");
|
|
203
|
+
if (!existsSync(installer)) {
|
|
204
|
+
ctx.ui.notify(`install.sh not found next to this extension (${installer}). Run: npx herdr-orchestra@latest`, "error");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const cur = await readMode(pi, ctx.cwd);
|
|
208
|
+
ctx.ui.notify("Installing herdr-orchestra (orch)...", "info");
|
|
209
|
+
// ORCH_TTY=/dev/null: the installer must not read Pi's terminal. An unanswered auto-update question gets the
|
|
210
|
+
// installer's default (on); the output says how to turn it off (`orch config auto-update off`).
|
|
211
|
+
const args = ["ORCH_PACKAGE=1", "ORCH_TTY=/dev/null", "bash", installer, ...(cur.mode === "subagent" ? ["--mode", "subagent"] : [])];
|
|
212
|
+
const r = await pi.exec("env", args, { cwd: ctx.cwd, timeout: 600000 });
|
|
213
|
+
const tail = (r.stdout + r.stderr)
|
|
214
|
+
.replace(/\x1b\[[0-9;]*m/g, "")
|
|
215
|
+
.split("\n")
|
|
216
|
+
.filter((l) => /^(==>|warn:|error:)|auto-update|is active/.test(l.trim()))
|
|
217
|
+
.slice(-12)
|
|
218
|
+
.join("\n");
|
|
219
|
+
ctx.ui.notify(tail || (r.code === 0 ? "Installed." : "The installer failed."), r.code === 0 ? "info" : "error");
|
|
220
|
+
mode = (await readMode(pi, ctx.cwd)).mode;
|
|
221
|
+
showStatus(ctx, mode);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
}
|
package/install.sh
CHANGED
|
@@ -42,6 +42,8 @@ Options:
|
|
|
42
42
|
--no-herdr-skill don't install/refresh the official herdr skill via npx
|
|
43
43
|
--auto-update keep herdr-orchestra up to date automatically (no question asked)
|
|
44
44
|
--no-auto-update never update by itself (also: ORCH_AUTO_UPDATE=1 or 0)
|
|
45
|
+
--mode <panes|subagent> save the mode runs use (default panes); subagent also sets up Pi's coder and
|
|
46
|
+
reviewer subagents (same as: orch setup --mode subagent)
|
|
45
47
|
-h, --help this help
|
|
46
48
|
EOF
|
|
47
49
|
}
|
|
@@ -57,6 +59,8 @@ while [[ $# -gt 0 ]]; do
|
|
|
57
59
|
--no-herdr-skill) HERDR_SKILL=0; shift;;
|
|
58
60
|
--auto-update) AUTO_UPDATE=1; shift;;
|
|
59
61
|
--no-auto-update) AUTO_UPDATE=0; shift;;
|
|
62
|
+
--mode) MODE_ARG="${2:?--mode needs panes or subagent}"; shift 2;;
|
|
63
|
+
--mode=*) MODE_ARG="${1#*=}"; shift;;
|
|
60
64
|
-h|--help) usage; exit 0;;
|
|
61
65
|
*) die "unknown option: $1 (see --help)";;
|
|
62
66
|
esac
|
|
@@ -266,6 +270,10 @@ fi
|
|
|
266
270
|
|
|
267
271
|
case ":$PATH:" in *":$BIN:"*) ;; *) warn "$BIN is not on your PATH — add: export PATH=\"\$HOME/.local/bin:\$PATH\"";; esac
|
|
268
272
|
|
|
273
|
+
if [[ -n "${MODE_ARG:-}" ]]; then
|
|
274
|
+
"$BIN/orch" setup --mode "$MODE_ARG" || warn "orch setup --mode $MODE_ARG did not finish — run it again after fixing what it says"
|
|
275
|
+
fi
|
|
276
|
+
|
|
269
277
|
say "herdr-orchestra $VER is active"
|
|
270
278
|
cat <<'MSG'
|
|
271
279
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "herdr-orchestra",
|
|
3
|
-
"version": "6.
|
|
4
|
-
"description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp) as one team
|
|
3
|
+
"version": "6.3.0",
|
|
4
|
+
"description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp, Pi) as one team: a lead plans, coders build, a reviewer checks, you get one PR. Runs in Herdr panes, or in one Pi window with subagents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"herdr-orchestra": "npm/cli.js"
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"opencode-commands",
|
|
15
15
|
"claude-commands",
|
|
16
16
|
"playbooks",
|
|
17
|
+
"extensions",
|
|
18
|
+
"pi",
|
|
17
19
|
"agents.default.toml",
|
|
18
20
|
"models.default.toml",
|
|
19
21
|
"VERSION",
|
|
@@ -44,13 +46,34 @@
|
|
|
44
46
|
"amp",
|
|
45
47
|
"llm",
|
|
46
48
|
"cli",
|
|
47
|
-
"developer-tools"
|
|
49
|
+
"developer-tools",
|
|
50
|
+
"pi-package",
|
|
51
|
+
"pi",
|
|
52
|
+
"pi-coding-agent",
|
|
53
|
+
"subagents"
|
|
48
54
|
],
|
|
55
|
+
"pi": {
|
|
56
|
+
"skills": [
|
|
57
|
+
"./pi/skills/orch-plan",
|
|
58
|
+
"./skills/orch-run"
|
|
59
|
+
],
|
|
60
|
+
"extensions": [
|
|
61
|
+
"./extensions/orch-mode.ts"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
49
64
|
"engines": {
|
|
50
65
|
"node": ">=16"
|
|
51
66
|
},
|
|
52
67
|
"publishConfig": {
|
|
53
68
|
"access": "public"
|
|
54
69
|
},
|
|
55
|
-
"author": "arunnarangali (https://github.com/arunnarangali)"
|
|
70
|
+
"author": "arunnarangali (https://github.com/arunnarangali)",
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@earendil-works/pi-coding-agent": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
56
79
|
}
|
package/pi/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Pi-only copies of the orch skills, loaded through package.json `"pi".skills`.
|
|
2
|
+
|
|
3
|
+
`skills/orch-plan/SKILL.md` has a `description:` with `: ` inside it, which strict YAML parsers (Pi's) reject, so
|
|
4
|
+
Pi would skip the skill. This copy has the same text with the description in quotes. Every other agent keeps using
|
|
5
|
+
`skills/orch-plan/SKILL.md`, unchanged. `tests/run.sh` checks that the two say the same thing.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: orch-plan
|
|
3
|
+
description: "Orchestrator step 1 for a Herdr multi-agent team (any agent can lead; Claude, Codex, Amp, OpenCode, Hermes or Antigravity coders; optional reviewer). Use when the user asks to plan or orchestrate a feature, or says \"orch-plan\". Research the codebase, then write a dependency-aware plan with as many milestones as the feature needs, written as issues (what and why, never how), each with the model tier it needs (small, medium, high) and why. A small, clear change (UI or backend) gets a short quick-run plan instead: one milestone, one coder, no reviewer; start the request with quick: or full: to choose. Does NOT execute until the developer says go."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Run `orch lead plan` (or `~/.local/bin/orch lead plan` if `orch` is not on PATH) and follow its output exactly. You are the lead. The user's message is the feature request.
|
package/playbooks/run.md
CHANGED
|
@@ -58,6 +58,8 @@ If you changed plan.md by hand, run `orch sync` (it works once the event manager
|
|
|
58
58
|
|
|
59
59
|
**Swap a coder** (for example, AGY instead of OpenCode): `orch stop` (the event manager finishes its current step and exits; nothing is lost), change `Workers:` in plan.md, `orch sync`, `orch team up`, check that `orch status` shows the new worker as `herdr=ok`, then `orch resume`. Never kill the event manager by hand.
|
|
60
60
|
|
|
61
|
+
**Move a milestone to another coder** (for example M7 from rs-agy-1 to rs-claude-1): `orch set M7 paused`, then `orch dispatch M7 --to rs-claude-1`. orch presses the old coder's interrupt key and tells it to stop. Tell the developer it has stopped only when `orch status` no longer shows it as `stopping M7`; until then it may still be editing files, and it gets no new work.
|
|
62
|
+
|
|
61
63
|
**Before `orch dispatch --to <worker>`**, `orch status` must show that worker as `herdr=ok`. dispatch refuses a worker with no agent (`NO AGENT`, `SHELL ONLY`); do what it says (`orch team up`) and try again. If `orch team up` reports `QUIT <worker>`, the agent quit as soon as it started: show the developer the pane and the saved screen it names.
|
|
62
64
|
|
|
63
65
|
**Why did the event manager stop?** `orch doctor --crash` prints the last `STOPPED` / `CRASHED` / `LOST` notes (with the reason found in the computer's own log) and the saved agent screens. Give the developer that reason in one line.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
You are the LEAD of a herdr-orchestra run in **subagent mode**: you stay in this one Pi window, and the coder and the reviewer are Pi subagents (the `Agent` tool from pi-subagents). All bookkeeping goes through `orch` (`~/.local/bin/orch` — use the full path if `orch` is not on PATH). Trust its output over your memory: it owns task states, the check, commits and the final PR.
|
|
2
|
+
Extra user input = whatever the user wrote alongside asking you to run this playbook (a go-ahead, answers, overrides, or nothing).
|
|
3
|
+
|
|
4
|
+
## How a run works in subagent mode
|
|
5
|
+
There is no event manager and there are no herdr panes. You drive one milestone at a time, in this folder:
|
|
6
|
+
`orch sub next` → coder subagent → `orch check` → reviewer subagent (when the milestone has `Review: yes`) → `orch sub done` → the next milestone. When every milestone is saved: the summary, then `orch finish` when the developer says so.
|
|
7
|
+
|
|
8
|
+
## Hard rules
|
|
9
|
+
0. **Roles: you decide what and why; the coder decides how.** Your prompts to the coder name the task file, the failing check output or the review findings: problems and goals, never solutions.
|
|
10
|
+
1. You NEVER edit application code yourself. You only run `orch`, read its files, start subagents, and edit `.orchestrate/plan.md` (answers, notes, tiers, the check command).
|
|
11
|
+
2. Never guess. A question only the developer can settle goes to the developer, with 2–3 concrete options. Answer the coder's question yourself only when the feature request, the plan or the code already settles it; say where the answer comes from.
|
|
12
|
+
3. Never approve a held milestone yourself (`orch approve` is the developer's call). Never `git commit`, `git stash` or `git reset` yourself: `orch sub done` saves the work.
|
|
13
|
+
4. Never skip the check, and never ask the coder to weaken or skip tests.
|
|
14
|
+
5. After each milestone, write one short line in your chat in plain words: what landed, what the check and the review said, what starts next. Example: `M1 (Model) is saved on the branch: check PASS, review found nothing. Starting M2 (Endpoint).`
|
|
15
|
+
|
|
16
|
+
## 1. Start the run (the developer said go)
|
|
17
|
+
1. Run `orch sync`. Stop on ERROR; report every WARN except the ones about Workers naming no model (the subagents run on the models in `~/.config/herdr-orchestra/config.json`).
|
|
18
|
+
2. Run `orch start` (it makes or switches to the feature branch).
|
|
19
|
+
3. Check that the `Agent` tool is available to you. If it is not, tell the developer to run `orch setup --mode subagent` and restart Pi, and **STOP**.
|
|
20
|
+
|
|
21
|
+
## 2. One milestone
|
|
22
|
+
1. Run `orch sub next`. It prints `NEXT Mn: <title>`, `TASK <path to task.md>` and `REVIEW yes|no`. (`CURRENT Mn` means a milestone was started and not saved: carry on with it from step 2. `HELD`, `WAITING` or `ALL_DONE`: see below.)
|
|
23
|
+
2. **Coder.** Call the `Agent` tool: `subagent_type: "coder"`, `description: "Mn <short title>"`, `run_in_background: false`, and a prompt like `Build milestone Mn. Read the task file <TASK path> and follow it. The check command is: <check command>. There is no result file or done file in this run: put your report in your reply.`
|
|
24
|
+
- If the coder replies `QUESTION: ...`: answer it from the plan or the code (say where the answer comes from), or ask the developer with 2–3 options and **STOP**. Write the answer under that milestone's "Notes from user" in `.orchestrate/plan.md`, then send it to the same coder with the `Agent` tool's `resume` (its agent id), so it carries on from its work.
|
|
25
|
+
3. **Check.** Run `orch check Mn`. On `CHECK FAIL`, resume the same coder with the failing output (the last lines `orch check` printed) and ask it to fix the cause. Run `orch check Mn` again. At most 3 fix rounds; after that, run `orch set Mn failed "<what keeps failing>"`, explain it to the developer in two lines, and **STOP**.
|
|
26
|
+
4. **Review** (only when `REVIEW yes`). Call the `Agent` tool: `subagent_type: "reviewer"`, `run_in_background: false`, prompt `Review milestone Mn. Task file: <TASK path>. Look at the change with git diff HEAD and git status --short.` Each `BLOCKER:` line goes back to the same coder (resume it with those lines only), then `orch check Mn` again, then one more review. At most 2 review rounds; blockers still left after that: `orch set Mn failed "<the blockers>"`, tell the developer, **STOP**. `SUGGESTION:` lines do not block: keep them for the summary.
|
|
27
|
+
5. **Save.** Run `orch sub done Mn`. `MERGED Mn` means it is committed on the feature branch. `HELD Mn` (exit 7) means risky changes (deleted files, migrations, CI config, secrets files, unlisted dependency changes, a very large diff) wait for the developer: show the reasons from `orch status`, tell them to look and run `orch approve Mn`, and **STOP**; after their approval run `orch sub done Mn` again.
|
|
28
|
+
6. Write your one line in the chat (hard rule 5), and go back to step 1 for the next milestone.
|
|
29
|
+
|
|
30
|
+
`orch sub next` printing `WAITING` means nothing is ready (a milestone is paused, failed or needs an answer): tell the developer which and why (`orch status`), and **STOP**. When it is sorted out, `orch set Mn pending` and carry on.
|
|
31
|
+
|
|
32
|
+
**The developer asks for a change after a milestone was saved** (for example "the login button should be blue"): do not plan again. Add one small follow-up milestone to `.orchestrate/plan.md` (same format, `Depends on: Mn (what it changes)`, the change in the developer's words), run `orch sync`, and run it with section 2. (`orch fix` and `orch dispatch` are for panes mode: they need the event manager.)
|
|
33
|
+
|
|
34
|
+
## 3. ALL_DONE (`orch sub next` or `orch sub done` prints it)
|
|
35
|
+
1. Write `.orchestrate/summary.md` for the developer, short:
|
|
36
|
+
- **Tasks**: one line per milestone, what it does now.
|
|
37
|
+
- **Checked**: the final `orch check` result, each review, and one line per acceptance criterion with its evidence (a test, a command, or `file:line`). Run a command or read the code to settle anything you can.
|
|
38
|
+
- **Reviewer suggestions not applied.**
|
|
39
|
+
- **Manual verification checklist**: ONLY what a person must see or do (how the UI looks, a click-through in a real browser, a real email arriving). For a backend-only change write `Nothing to check by hand: <why>`.
|
|
40
|
+
2. Tell the developer: "All milestones are saved on <branch>. Review .orchestrate/summary.md. Then run `orch finish`: it re-runs the check (or reuses it), pushes <branch> and opens a PR (`orch finish --no-push` to only clean up)." Run `orch finish` yourself only when the developer says so: it pushes. Never add a "Generated with …", `Co-Authored-By` or session line to a commit or a PR of the run: they are the developer's. **STOP.**
|