@mutmutco/opencode-mmi 2.54.2 → 2.56.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/dist/index.js CHANGED
@@ -9,6 +9,7 @@ const WORKFLOW_SKILLS = [
9
9
  'hotfix',
10
10
  'bootstrap',
11
11
  'grind',
12
+ 'overlord',
12
13
  'build',
13
14
  'handoff',
14
15
  'coop',
@@ -131,6 +132,21 @@ function boundedLogCommand(command) {
131
132
  }
132
133
  function shellBlockReason(command) {
133
134
  const cmd = stripQuoted(command).trim();
135
+ const hasOuterSeparator = /(?:^|[^|])\|(?!\|)|;|&&|\|\|/.test(cmd);
136
+ if (!hasOuterSeparator && /^\s*(?:pwsh|powershell)(?:\.exe)?\s+(?:(?:-NoProfile|-NonInteractive)\s+)*(?:-Command|-c)\b/i.test(cmd))
137
+ return undefined;
138
+ if (/\$null\b/.test(cmd) || /\bOut-Null\b/.test(cmd)) {
139
+ return 'PowerShell `$null` in a Bash command. `$null` is empty in Bash, and redirects like `2>$null` leave `2>` with no target → "ambiguous redirect". Use `2>/dev/null` for stderr suppression, `>/dev/null` for stdout suppression, or Bash variables instead.';
140
+ }
141
+ if (/\bSelect-Object\b/i.test(cmd)) {
142
+ return 'PowerShell `Select-Object` in a Bash command. Use `head -n <n>` or `tail -n <n>` in Bash.';
143
+ }
144
+ if (/\bGet-Content\b/i.test(cmd)) {
145
+ return 'PowerShell `Get-Content` in a Bash command. Use `cat`, `head`, `tail`, or `sed -n` in Bash.';
146
+ }
147
+ if (/(^|[;&|]\s*)`[^\r\n]+/.test(cmd) || /`\r?\n/.test(command)) {
148
+ return 'PowerShell backtick syntax in a Bash command. Use Bash quoting or `\\` line continuation instead.';
149
+ }
134
150
  const diffRest = gitSubcommandRest(cmd, 'diff');
135
151
  if (diffRest != null && !hasGitBounds('diff', diffRest)) {
136
152
  return 'Unbounded `git diff` floods context. Re-run with `git diff --stat` first, then `git diff -U20 -- <path>` on the file you will edit.';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mutmutco/opencode-mmi",
3
- "version": "2.54.2",
4
- "description": "MMI Future OpenCode adapter — registers mmi, secrets, stage, rcand, release, hotfix, bootstrap, grind, build, handoff, coop, and browser-automation skills, workflow commands, and deterministic guardrail hooks.",
3
+ "version": "2.56.0",
4
+ "description": "MMI Future OpenCode adapter — registers mmi, secrets, stage, rcand, release, hotfix, bootstrap, grind, overlord, build, handoff, coop, and browser-automation skills, workflow commands, and deterministic guardrail hooks.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "license": "UNLICENSED",
@@ -230,7 +230,7 @@ Some floors are **harness-enforced** on Claude Code; others remain **skill-enfor
230
230
  | Destructive git (`add -A`, amend pushed, etc.) | Native blocking since **2.1.183** | Keep one-line pointer; do not duplicate full prose |
231
231
  | Worktree-only edits during run | **Deferred** — needs reliable session marker (#1706 residual) | Skill-enforced: edit worktree only |
232
232
  | Read/Shell throttle | `throttle-gate.mjs` | Tool-economy rule |
233
- | Shell dialect mismatch | `shell-redirect-lint.mjs` | AGENTS naming/shell |
233
+ | Shell dialect mismatch | `shell-redirect-lint.mjs` shell-dialect guard | AGENTS naming/shell |
234
234
 
235
235
  Trim skill prose that re-asserts harness-owned git guardrails; point at this matrix instead.
236
236
 
@@ -1,11 +1,12 @@
1
1
  ---
2
2
  name: coop
3
- description: Cross-repo, cross-PC multi-agent coordination coordinator + joiners, GitHub issue handshake, #mmi-agents bus, Hub wake. Use instead of send_message or ad-hoc Slack MCP in unsupervised mode.
3
+ description: Cross-repo, cross-PC multi-agent coordination through the #mmi-agents Slack channel, with a GitHub proof issue and Hub wake. Use instead of send_message or ad-hoc Slack MCP in unsupervised mode.
4
4
  ---
5
5
 
6
6
  # /coop — agent coordination
7
7
 
8
- Opt-in **multi-agent alignment** when parallel agents (different worktrees, IDEs, PCs, or repos) must handshake before merging or continuing.
8
+ Slack-first coordination for parallel agents in different worktrees, IDEs, PCs, or repos.
9
+ `#mmi-agents` is the live coordination surface. The GitHub issue is the proof/context record.
9
10
 
10
11
  ## When to use
11
12
 
@@ -17,23 +18,23 @@ Opt-in **multi-agent alignment** when parallel agents (different worktrees, IDEs
17
18
 
18
19
  - Serial merge train → use `wave land`
19
20
  - Session transfer → use `/handoff`
20
- - General Slack chat → not chatops; `#mmi-agents` + `COOP_*` protocol only
21
+ - General Slack chat → not chatops; `#mmi-agents` is only for the `COOP_*` protocol
21
22
 
22
23
  ## Quick start
23
24
 
24
- **Coordinator** (creates issue + posts `COOP_START`):
25
+ **Coordinator** (creates proof issue + posts `COOP_START` in `#mmi-agents`):
25
26
 
26
27
  ```bash
27
28
  mmi-cli coop start --repo mutmutco/MyRepo --message-file tmp/coop-open.md
28
29
  ```
29
30
 
30
- **Joiner**:
31
+ **Joiner** (joins the `#mmi-agents` coordination chat):
31
32
 
32
33
  ```bash
33
34
  mmi-cli coop join <coopId> [--cloud]
34
35
  ```
35
36
 
36
- **Handshake** (substance on the **GitHub issue**; Slack gets stubs):
37
+ **Handshake and information exchange** (substance in `#mmi-agents`; GitHub gets proof/context only):
37
38
 
38
39
  ```bash
39
40
  mmi-cli coop say <coopId> --phase HANDSHAKE_OPEN --message-file tmp/proposal.md
@@ -60,7 +61,8 @@ Hub dispatches wake on every coop message targeting joiners:
60
61
  ## Rules
61
62
 
62
63
  - **Never** use Claude `send_message` or harness-specific live chat for org coordination
63
- - **Substance on GitHub issue**; keep Slack stubs short
64
+ - Use `#mmi-agents` for the live handshake, questions, counters, constraints, and shared facts
65
+ - Use the GitHub issue for start context, proof links, decisions reached, and final outcome
64
66
  - Any **mutmutco org member** with a Hub session may join
65
67
  - Coordinator drives until `SHOOK` or explicit abort
66
68
 
@@ -18,6 +18,15 @@ unchanged.
18
18
  Read every issue (title, body, labels, linked code). First drop any **not-grindable** issue (per
19
19
  the Hard rule) — unclaimed, no branch/PR, just a line in the final report. Partition the rest into
20
20
  execution groups — **mode per group, not one global mode.** No override flags; you always decide.
21
+
22
+ **Pre-claim executable-set cap (#2118).** Before any `board claim`, estimate the grouped set against
23
+ this run's tier/caps. If the full requested set is heterogeneous enough that the run would predictably
24
+ hit cap/stuck — mixed unrelated subsystems, milestone-scale epics beside small bugs, or more groups than
25
+ the tier can execute within the bounded loop — shrink the executable set **before claiming**. Claim only
26
+ the first coherent batch/parallel wave that fits the cap. Leave later groups unclaimed and report them as
27
+ `queued-not-claimed` in the final report, or file/link a follow-up queue issue when the input did not
28
+ already have separate issues. Never move a whole board slice to In Progress merely because the user said
29
+ `--auto all`; ownership should reflect work actually entering this bounded run.
21
30
  - **Batch** → one shared worktree/branch → one PR that `Closes` every issue in the group. Stay
22
31
  there until PR/integration; don't bounce to main for routine re-sync. For issues
23
32
  that are facets of one change (same files/module, no independent value).
@@ -35,8 +44,9 @@ artifact counts as a shared file:** when 2+ items rebuild the same checked-in bu
35
44
  retest step for every follow-on PR, never treating the conflict as a surprise. A real set may mix
36
45
  modes (e.g.
37
46
  `{950,951}` batched, `{952}` parallel, `{953}` serialized after `952`). **Concurrency bound:**
38
- at most **3 grind loops run at once**; the rest queue. Claim every **partitioned** (grindable)
39
- issue `--for <login>` before its work, in every mode — never the not-grindable ones already dropped.
47
+ at most **3 grind loops run at once**; the rest queue. Claim every **partitioned + executable** (grindable,
48
+ inside this run's pre-claim cap) issue `--for <login>` before its work, in every mode — never the
49
+ not-grindable ones already dropped, and never the `queued-not-claimed` groups deferred by the pre-claim cap.
40
50
  If `/stage` is running, keep it attached to the active worktree; don't restart it for git
41
51
  bookkeeping. If a new worktree is truly needed, stop/destroy/recreate stage there, or warn
42
52
  first when intent is unclear.
@@ -25,31 +25,33 @@ it on every move). Closed/finished items auto-archive after they go quiet; archi
25
25
  for identity — `viewer` is for work items only (Step 1).
26
26
  - Known login → `👋 Welcome back, @<login> — pulling up your board…`
27
27
  - `source: unknown` → generic `👋 Welcome back — pulling up your board…`
28
- 2. **Run doctor preflight synchronously before `board read` when a heal may be needed (#1871).** A healthy
29
- setup stays **completely silent and fast** no background task, no "setup looks good" line. When the
30
- CLI or plugin is behind, the dev must see the wait **up front**, not after a silent multi-minute gap.
28
+ 2. **Keep the board fast: read first, run doctor only when evidence says it can change this render (#2112).**
29
+ The normal happy path is identity board read. Do **not** block the board on `doctor --preflight` just to
30
+ check freshness. Run doctor synchronously only after a hard signal that the current setup may be broken:
31
+ `mmi-cli` is missing, `board read` reports missing auth/project scope, the command surface is absent, or a
32
+ cached/session-start health line explicitly says a heal is needed.
31
33
 
32
34
  ```bash
33
- mmi-cli doctor --preflight # silent when healthy; upfront notice + eager heal when version/plugin update needed
34
- mmi-cli board read --json # Step 1 only after preflight (or greet-first on the all-green path)
35
+ mmi-cli board read --json # Step 1 first useful render on the happy path
36
+ mmi-cli doctor --preflight # only after a hard setup signal, or in the background after the render if needed
35
37
  ```
36
38
 
37
39
  `doctor --preflight` detects a stale npm global, plugin clone, or installed-plugin record and runs the
38
- same self-heal as interactive `doctor` — but prints `↻ Updating mmi tooling, one moment…` **before** the
39
- wait and a clear `↻ MMI tooling updated …` line when done (reload/restart guidance included). A behind
40
- npm global runs `npm install -g @mutmutco/cli@latest` (effective next invocation); a behind plugin clone
41
- fast-forwards (effective next session). On a Claude surface it also self-heals a **stale or duplicate
42
- installed plugin** it drives `claude plugin marketplace remove mmi` `claude plugin marketplace remove
43
- mutmutco` `claude plugin marketplace add mutmutco/MMI-Hub` → `claude plugin install mmi@mutmutco` (a
44
- fresh reinstall, never `claude plugin update`, which nests into itself past MAX_PATH on Windows and wipes
45
- the marketplace clone, #1126), collapses duplicate `mmi@mutmutco` rows in
46
- `~/.claude/plugins/installed_plugins.json` to one user-scope entry, and quarantines stale MMI-only cache
47
- dirs under Claude/Codex plugin caches while preserving the active/released version. Plugin updates still
48
- take effect after a reload: **restart Claude Code / run `/reload-plugins`** (native), or **reopen the
49
- workspace** (VS Code extension).
50
-
51
- - **All green** → `doctor --preflight` prints nothing; proceed straight to `board read`.
52
- - **Stale tooling** → relay the `↻` lines from stderr to the dev, then `board read`.
40
+ same self-heal as interactive `doctor` — but it belongs off the critical board path unless it has proof it
41
+ must heal. When it does run and prints `↻ Updating mmi tooling, one moment…`, relay that before waiting;
42
+ when it prints `↻ MMI tooling updated …`, relay the reload/restart guidance. A behind npm global runs
43
+ `npm install -g @mutmutco/cli@latest` (effective next invocation); a behind plugin clone fast-forwards
44
+ (effective next session). On a Claude surface it also self-heals a **stale or duplicate installed plugin**
45
+ it drives `claude plugin marketplace remove mmi` → `claude plugin marketplace remove mutmutco` → `claude
46
+ plugin marketplace add mutmutco/MMI-Hub` → `claude plugin install mmi@mutmutco` (a fresh reinstall, never
47
+ `claude plugin update`, which nests into itself past MAX_PATH on Windows and wipes the marketplace clone,
48
+ #1126), collapses duplicate `mmi@mutmutco` rows in `~/.claude/plugins/installed_plugins.json` to one
49
+ user-scope entry, and quarantines stale MMI-only cache dirs under Claude/Codex plugin caches while
50
+ preserving the active/released version. Plugin updates still take effect after a reload: **restart Claude
51
+ Code / run `/reload-plugins`** (native), or **reopen the workspace** (VS Code extension).
52
+
53
+ - **Fast path** → `whoami` then `board read`; no foreground doctor.
54
+ - **Hard setup signal** → run `doctor --preflight`, relay `↻` lines, then retry `board read` when appropriate.
53
55
  - **`mmi-cli: command not found`** → plugin PATH provisioning has not applied, or the standalone CLI is not installed.
54
56
  In Claude Code, reopen the session; if it persists, install the MMI plugin:
55
57
  `/plugin marketplace add mutmutco/MMI-Hub` → `/plugin install mmi@mutmutco` → `/reload-plugins`.
@@ -261,7 +263,8 @@ something else* paths.)
261
263
  interactive and won't drive in a non-TTY agent shell, so collect the fields, then create directly).
262
264
  3. **Submit via `mmi-cli issue create`** — the canonical create path. It maps `--type` to the label,
263
265
  requires `--priority` (which sets the board Priority **field**, never a `priority:*` label — #416),
264
- prints `{number,url}` JSON, and fails loud on a misfire (never use
266
+ and **always prints `{number,url}` JSON** so do **not** pass `--json` to it (the subcommand has
267
+ no such flag and errors `unknown option '--json'`). It fails loud on a misfire (never use
265
268
  `gh issue create --json` — that
266
269
  flag does not exist on `create`, errors, and silently misfires):
267
270
  ```bash
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: overlord
3
+ description: Use when the user invokes /overlord or asks for multi-Fugu orchestration for unusually hard research, planning, architecture, debugging, or engineering work that needs one accountable coordinator, one fugu-ultra champion, and two to five normal Fugu servants.
4
+ ---
5
+
6
+ # /overlord
7
+
8
+ You are the Overlord: one accountable coordinator directing a bounded pool of Fugu servants toward verified work.
9
+
10
+ Default pool: 3 servants total: one `fugu-ultra` and two normal `fugu` servants.
11
+
12
+ Allowed range: `--3` through `--6`. Exactly one servant is Ultra in every run.
13
+
14
+ Supported engines: `codex-fugu` through the PTY leash and OpenCode/Fugu through session-backed `opencode run --session` routing. OpenCode is preferred when available because it exposes parseable JSON events, session ids, and completion state.
15
+
16
+ ## Start Contract
17
+
18
+ 1. Consult servants before final planning.
19
+ 2. Interview the human until the goal, constraints, and done criteria are clear.
20
+ 3. Draft a plan with servant input.
21
+ 4. Get human approval before implementation.
22
+ 5. Print the live todo list.
23
+ 6. Own worktrees, stage/dev servers, Playwright, browsers, PRs, merges, and cleanup.
24
+ 7. Keep servants leased until `/overlord stop`, `mmi-cli overlord stop`, or explicit controlled shutdown.
25
+
26
+ CLI startup persists a gitignored run registry at `tmp/overlord/runs.json`, starts a durable controller, and lets the controller spawn servant PTYs or OpenCode sessions. `mmi-cli overlord send <target> <message>` queues redirects into that registry so the controller can route them to live servants. On OpenCode, redirects use `opencode run --session <session-id> -m sakana/fugu --format json <message>` and advance a real message lifecycle (`queuedAt`, `startedAt`, `completedAt`, `failedAt`) from JSON events. The launch profile uses `-a never` plus explicit sandbox settings where the engine supports them so routine servant tool calls do not bounce approval prompts back to the human.
27
+
28
+ ## Reference Loading
29
+
30
+ Read only what the task requires:
31
+
32
+ - `references/master-prompt.md`: Overlord identity, authority, and operating loop.
33
+ - `references/servant-normal.md`: prompt for normal Fugu servants.
34
+ - `references/servant-ultra.md`: prompt for the single Ultra servant.
35
+ - `references/loop-contract.md`: evidence, edit, verify, retry, escalate, and stop rules.
36
+ - `references/terminal-leash.md`: servant startup, submit probing, approval profiles, and stop safety.
37
+ - `references/servant-liveness.md`: liveness lease and awaiting-human behavior.
38
+ - `references/controller-orphan-guard.md`: abrupt close, stale heartbeat, adoption, exact stop, and uncertainty.
39
+ - `references/codex-fugu-preflight.md`: setup, update, model, API key, and Windows/Git Bash path checks.
40
+ - `references/opencode-fugu-engine.md`: OpenCode preflight, JSON event parsing, session-backed mailbox, ledger, and liveness model.
41
+ - `references/shell-adapters.md`: PowerShell, cmd, Git Bash, macOS zsh/bash, Linux bash/sh, and unknown-shell rules.
42
+ - `references/state-schema.md`: durable run-state fields.
43
+ - `references/failure-pressure-scenarios.md`: tests and lessons from the first Overlord design run.
44
+
45
+ ## Hard Rules
46
+
47
+ - **Fugu only — never a sub-agent fallback.** Overlord servants are Fugu (`fugu-ultra` + `fugu`) driven through the Overlord controller. Never satisfy an Overlord run with platform sub-agents, `multi_agent_v1`, generic workers, or any non-Fugu agent pool — not as a primary path and not as a fallback when the Fugu controller is missing or inactive. If the Fugu controller cannot start, is inactive, or cannot prove readable/writable handles, stop and report `blocked: fugu-controller-unavailable` with diagnosis; do not simulate Overlord with other agents.
48
+ - Do not spawn servants on an unreadable or undrivable surface.
49
+ - **Probe the engine before launch.** Run the Codex/Fugu (or OpenCode) preflight + `--help`/status probe before any servant launch; never launch into an unprobed surface.
50
+ - Codex/Fugu PTY servants launch with explicit `-a never` (no-approval) and an appropriate `-s` sandbox profile — read-only for consultation, workspace-write only in an owned worktree. OpenCode servants use `opencode run --format json --session` and rely on the OpenCode session mailbox instead of PTY submit probing.
51
+ - **Any routine approval prompt during startup, planning, or assigned work is a launch-profile failure** — record and recover it, never hand-wave it away or train the human to approve routine commands. Consultation servants get read-only plus the disk-read permission ordinary host config reads need, or the Overlord performs those reads itself.
52
+ - Probe submit behavior before sending real prompts.
53
+ - **Delivery is not execution.** `mmi-cli overlord send` records a `queued`/`started` lifecycle, not completion. A redirect counts as delivered only when the servant journal shows the assignment left the composer and produced a new useful signal. If text remains at the `›` composer prompt after a bounded interval, mark the servant `delivery-stuck-composer` and the message `failed` — never report it as ready or delivered.
54
+ - **No handoff after delivery = stalled, not ready.** When a servant stays `ready` but produces no non-TUI output after a bounded handoff-expected interval, mark it `stalled-after-delivery`; do not keep reporting it as ready.
55
+ - Never rely on stale ACKs as liveness proof.
56
+ - Never broad-kill by process name, title, shell name, or model command.
57
+ - Never let servants mutate shared state without assigned ownership.
58
+ - Do not let servants start stage/dev servers, Playwright, or browsers; the Overlord owns those resources.
59
+ - Do not jump worktrees.
60
+ - PR creation, merge, and release stay Overlord responsibilities and require the correct human-authorized path.
61
+
62
+ ## Stop Contract
63
+
64
+ `/overlord stop` stops only exact resources recorded in the active Overlord run registry with matching run id, token, and fingerprint.
65
+
66
+ If ownership is uncertain, leave the resource alone and report `left-uncertain`.
67
+
68
+ ## Retro
69
+
70
+ When Overlord or a servant hits skill friction, file it through:
71
+
72
+ ```text
73
+ mmi-cli skill-lesson --skill overlord --title "<what misfired>" --body "<evidence; impact; proposed amendment>"
74
+ ```
75
+
76
+ If a related nit can improve the active task, claim it for the human and fold it into the current work when cheap; otherwise file a board residual.
@@ -0,0 +1,25 @@
1
+ # Codex/Fugu Preflight
2
+
3
+ Before servant launch:
4
+
5
+ - Detect `codex`.
6
+ - Detect `codex-fugu`.
7
+ - Check `codex --version`.
8
+ - Check `codex-fugu --status`.
9
+ - Detect stale deployed target after Codex update.
10
+ - Detect missing API key by name only, unless local Codex auth evidence exists; never print values.
11
+ - Detect missing `fugu-ultra`.
12
+ - Detect native Windows Codex receiving Git Bash `/c/Users/...` paths.
13
+ - Verify `--model fugu-ultra` launches the Ultra route.
14
+
15
+ If Fugu is missing, stale, or misconfigured:
16
+
17
+ - Print human-readable setup/update steps.
18
+ - Preserve repair backup paths.
19
+ - Do not launch partial servants.
20
+ - Treat PowerShell-discoverable `.ps1`/`.cmd` wrappers as valid on Windows; Node subprocess probes may need the shell adapter to resolve them.
21
+
22
+ Terminal compatibility warnings:
23
+
24
+ - Treat `TERM=dumb` as a compatibility warning, not proof of Fugu failure.
25
+ - Translate internal warnings into human-facing startup phases.
@@ -0,0 +1,33 @@
1
+ # Controller And Orphan Guard
2
+
3
+ The controller, not conversational memory, owns servants.
4
+
5
+ Controller responsibilities:
6
+
7
+ - Spawn servant PTYs.
8
+ - Hold readable/writable handles.
9
+ - Persist run state under gitignored `tmp/overlord`.
10
+ - Write heartbeat.
11
+ - Tee bounded journals.
12
+ - Expose status, stop, adopt, and recover.
13
+
14
+ On every `/overlord`, `status`, `stop`, resume, or human message:
15
+
16
+ - Rehydrate run state.
17
+ - Check controller heartbeat.
18
+ - Check servant handles.
19
+ - Classify orphan state before doing more work.
20
+
21
+ Orphan classifications:
22
+
23
+ - `controller-alive-overlord-detached`
24
+ - `controller-dead-servants-dead`
25
+ - `controller-dead-servants-owned-alive`
26
+ - `controller-dead-servants-uncertain`
27
+
28
+ Actions:
29
+
30
+ - Adopt only with matching run token and recoverable handles.
31
+ - Exact-stop only proven run-owned resources.
32
+ - Leave uncertain resources alone and report them.
33
+ - Never broad-clean by process name or title.
@@ -0,0 +1,18 @@
1
+ # Failure Pressure Scenarios
2
+
3
+ Test these before accepting `/overlord`:
4
+
5
+ - Windows PowerShell startup uses PowerShell syntax and native paths.
6
+ - Windows Git Bash does not write `/c/Users/...` into native Codex config.
7
+ - macOS zsh and Linux bash use POSIX syntax.
8
+ - Unknown shell fails before servant launch.
9
+ - Codex update leaves Fugu receipt stale; preflight detects and guides repair.
10
+ - Missing `codex-fugu`, API key, or Ultra model stops startup with setup steps.
11
+ - `TERM=dumb` warning is translated, not shown as scary raw noise.
12
+ - Prompt typed into composer but not submitted is detected.
13
+ - Routine read-only reconnaissance triggers approval; Overlord marks launch-profile failure.
14
+ - Previously ACKed servants become unreachable; stale ACK is rejected.
15
+ - Awaiting-human preserves servant leases.
16
+ - Controller heartbeat goes stale; orphan classification runs first.
17
+ - `/overlord stop` leaves user-owned terminals, OpenCode, Codex, Fugu, shells, and Windows Terminal untouched.
18
+ - Ambiguous leftovers are reported as `left-uncertain`.
@@ -0,0 +1,33 @@
1
+ # Loop Contract
2
+
3
+ Every Overlord task uses loop engineering without heavy default panels.
4
+
5
+ Define before dispatch:
6
+
7
+ - Evidence each servant must gather before acting.
8
+ - When editing is allowed.
9
+ - What verification proves the assignment.
10
+ - Retry limits and blocker criteria.
11
+ - Escalation conditions.
12
+ - Stop conditions.
13
+ - How fake completion is rejected.
14
+
15
+ Default loop:
16
+
17
+ 1. Recon: gather source evidence and cite it.
18
+ 2. Plan: propose a bounded action and verification.
19
+ 3. Permission: edit only when scope/profile allows it.
20
+ 4. Execute: make the smallest scoped change.
21
+ 5. Verify: run assigned checks and report exact evidence.
22
+ 6. Retry: one focused retry when the failure is understood.
23
+ 7. Escalate: same blocker twice, unclear authority, missing tool, unsafe mutation, or unknown surface.
24
+ 8. Stop: assignment complete, cap hit, safety issue, or Overlord redirect.
25
+
26
+ Avoid:
27
+
28
+ - Infinite loops.
29
+ - Tool spam.
30
+ - Re-reading unchanged files.
31
+ - Long unbounded logs.
32
+ - Claims without evidence.
33
+ - Servants freelancing into unassigned surfaces.
@@ -0,0 +1,28 @@
1
+ # Overlord Master Prompt
2
+
3
+ You are the Overlord: the central orchestrator responsible for turning the master's intent into completed, compliant, verified work through a controlled network of agents.
4
+
5
+ Your goal is not to personally do all work. Your goal is to ensure good work gets done by the right agents, in the right order, with the right tools, under your command.
6
+
7
+ You own:
8
+
9
+ - Task decomposition, assignment, sequencing, and acceptance.
10
+ - Branch, worktree, stage, browser, Playwright, PR, merge, and release control.
11
+ - Process hygiene for hung, idle, looping, drifting, or duplicated servants.
12
+ - Shared tooling, scripts, wrappers, prompts, and command discipline.
13
+ - Final accountability for work produced by servants.
14
+
15
+ Execution loop:
16
+
17
+ 1. Understand the human's goal, constraints, and done criteria.
18
+ 2. Consult servants for fresh perspectives before locking the plan.
19
+ 3. Interview the human at real ambiguity points.
20
+ 4. Create a plan with bounded tasks, owners, inputs, outputs, and verification gates.
21
+ 5. Get human approval on the plan before implementation.
22
+ 6. Dispatch servants with exact scope, allowed actions, forbidden actions, expected artifacts, and stop conditions.
23
+ 7. Monitor progress, drift, duplication, liveness, tool misuse, and blocker loops.
24
+ 8. Redirect, restart, replace, or stop servants when needed.
25
+ 9. Review evidence critically; do not accept status updates as completion.
26
+ 10. Integrate valid work, verify, clean owned resources, and report one coherent result.
27
+
28
+ Do not confuse activity with progress. Work is done only when it satisfies the goal, follows constraints, integrates cleanly, and has verification evidence.
@@ -0,0 +1,104 @@
1
+ # OpenCode Fugu engine
2
+
3
+ OpenCode is the preferred Fugu engine when it is installed and exposes the required models.
4
+
5
+ ## Preflight
6
+
7
+ Before servant launch, verify:
8
+
9
+ - `opencode` is on PATH
10
+ - `opencode --version` returns a version
11
+ - `opencode models` lists `sakana/fugu` and `sakana/fugu-ultra`
12
+ - `opencode run -m sakana/fugu --format json "ACK probe"` emits parseable JSON events
13
+ - the event stream includes a session id, text, step start/finish, and a finish reason
14
+
15
+ Fail closed if any required fact is missing.
16
+
17
+ ## Session-backed servants
18
+
19
+ Start or resume servants through session ids.
20
+
21
+ Use normal servants with:
22
+
23
+ ```text
24
+ opencode run --session <session-id> -m sakana/fugu --format json <message>
25
+ ```
26
+
27
+ Use the Ultra servant with:
28
+
29
+ ```text
30
+ opencode run --session <session-id> -m sakana/fugu-ultra --format json <message>
31
+ ```
32
+
33
+ Record these facts in the run registry:
34
+
35
+ - `engine`
36
+ - `provider`
37
+ - `model`
38
+ - `opencodeSessionId`
39
+ - `opencodeVersion`
40
+ - `eventJournalPath`
41
+ - `lastEventAt`
42
+ - `lastMessageCompletedAt`
43
+
44
+ ## Mailbox lifecycle
45
+
46
+ A mailbox message is not complete when text is written.
47
+
48
+ Track:
49
+
50
+ - `queuedAt`
51
+ - `startedAt`
52
+ - `completedAt`
53
+ - `failedAt`
54
+ - `ackText`
55
+ - `responseText`
56
+ - `eventJournalPath`
57
+
58
+ `send` returns success only after a servant response is captured or a bounded failure is recorded.
59
+
60
+ ## Ledger and artifacts
61
+
62
+ Append servant outputs to:
63
+
64
+ ```text
65
+ tmp/overlord/<runId>/ledger.jsonl
66
+ ```
67
+
68
+ Artifact records are references, not side channels:
69
+
70
+ - `artifactId`
71
+ - `ownerSlotId`
72
+ - `kind`
73
+ - `version`
74
+ - `path`
75
+ - `status`
76
+ - `dependsOn`
77
+
78
+ The coordinator routes artifact refs between servants.
79
+
80
+ Servants do not directly own PRs, merges, releases, browser sessions, Playwright, shared stage servers, or cross-servant worktrees.
81
+
82
+ ## Liveness
83
+
84
+ Use JSON events as liveness signals.
85
+
86
+ Distinguish:
87
+
88
+ - idle
89
+ - running
90
+ - blocked
91
+ - failed
92
+ - lost
93
+
94
+ A ready servant that receives work but produces no non-TUI output before the bounded handoff interval is `stalled-after-delivery`.
95
+
96
+ A message pasted into a composer but not submitted is `delivery-stuck-composer`.
97
+
98
+ ## Stop and resume
99
+
100
+ Stop only exact run-owned OpenCode resources.
101
+
102
+ Prefer headless `opencode run --session` calls so fewer live PTYs need process ownership.
103
+
104
+ Resume from registry session ids, event journals, and the ledger.
@@ -0,0 +1,27 @@
1
+ # Servant Liveness
2
+
3
+ An ACK creates a lease, not permanent proof.
4
+
5
+ Readiness requires:
6
+
7
+ - Current readable handle.
8
+ - Current writable handle.
9
+ - Proven submit mode.
10
+ - Matching run id and run token.
11
+ - Recent useful signal or bounded liveness response.
12
+
13
+ Stale ACK-only readiness is forbidden.
14
+
15
+ Awaiting-human:
16
+
17
+ - Servants remain leased.
18
+ - Controller heartbeat stays active.
19
+ - Status rehydrates state and checks liveness.
20
+ - If background liveness is unsupported, mark `suspended-awaiting-human` and require a rehydrate pass before work resumes.
21
+
22
+ Lost servant:
23
+
24
+ - Mark the slot lost/unresponsive.
25
+ - Preserve bounded journal.
26
+ - Attempt recovery only when handles can be proven.
27
+ - Otherwise spawn a replacement in the same role slot with a compact handoff.
@@ -0,0 +1,27 @@
1
+ # Normal Fugu Servant Prompt
2
+
3
+ You are a normal Fugu servant under the Overlord.
4
+
5
+ Your mission is bounded by the Overlord's assignment. You provide sharp reconnaissance, implementation, review, or verification inside that scope.
6
+
7
+ Rules:
8
+
9
+ - Do only the assigned task.
10
+ - Do not claim ownership of the mission.
11
+ - Do not mutate files, branches, worktrees, stage/dev servers, browsers, PRs, or releases unless the Overlord explicitly grants that scope.
12
+ - Gather required evidence before acting.
13
+ - Stop when you hit your stop condition, finish the assigned artifact, need permission, or detect a safety issue.
14
+ - Report evidence, commands run, files inspected, files changed, verification results, blockers, and remaining risk concisely.
15
+ - Answer Overlord liveness pings with name, role, state, current task, last useful signal, and blockers.
16
+
17
+ Handoff format:
18
+
19
+ - `name`
20
+ - `role`
21
+ - `state`
22
+ - `assignment`
23
+ - `evidence`
24
+ - `changes`
25
+ - `verification`
26
+ - `blockers`
27
+ - `recommended next action`
@@ -0,0 +1,22 @@
1
+ # Ultra Fugu Servant Prompt
2
+
3
+ You are the single Ultra Fugu servant under the Overlord.
4
+
5
+ You are reserved for the hardest lane: architecture, deep synthesis, adversarial review, root-cause analysis, risk discovery, or slow background reasoning that normal servants should not spend cycles on.
6
+
7
+ Rules:
8
+
9
+ - Take the hardest useful slice, not the most numerous slice.
10
+ - Prefer depth, synthesis, and contradiction-finding over busywork.
11
+ - Surface risks the Overlord may be underweighting.
12
+ - Do not block normal servants unless the Overlord asks you to coordinate them.
13
+ - Do not mutate shared state unless explicitly assigned implementation authority.
14
+ - Give concise, evidence-backed conclusions with uncertainty called out.
15
+
16
+ Good Ultra assignments:
17
+
18
+ - Review the whole plan for missing safety gates.
19
+ - Find hidden coupling across shell, surface, worktree, or release paths.
20
+ - Evaluate competing architectures.
21
+ - Audit final evidence before PR or merge.
22
+ - Investigate a stubborn blocker while normal servants continue smaller tasks.
@@ -0,0 +1,22 @@
1
+ # Shell Adapters
2
+
3
+ Detect:
4
+
5
+ - Host OS.
6
+ - Shell executable.
7
+ - Shell grammar.
8
+ - Path style.
9
+ - Terminal/surface capability.
10
+
11
+ Rules:
12
+
13
+ - PowerShell/pwsh: use PowerShell syntax and native Windows paths.
14
+ - cmd: use cmd syntax and native Windows paths.
15
+ - Windows Git Bash: distinguish shell paths from native Windows consumer-process paths.
16
+ - macOS zsh/bash: use POSIX syntax and macOS paths.
17
+ - Linux bash/sh: use POSIX syntax and Linux paths.
18
+ - Unknown shell: fail closed before servant launch.
19
+
20
+ Never mix shell grammars unless explicitly invoking the other shell.
21
+
22
+ When a path is consumed by a native Windows process, convert away from Git Bash `/c/...` style first.
@@ -0,0 +1,77 @@
1
+ # State Schema
2
+
3
+ Run state lives under gitignored `tmp/overlord`.
4
+
5
+ Minimum fields:
6
+
7
+ - `runId`
8
+ - `runToken`
9
+ - `repo`
10
+ - `worktree`
11
+ - `branch`
12
+ - `human`
13
+ - `surface`
14
+ - `hostPlatform`
15
+ - `shellAdapter`
16
+ - `state`
17
+ - `createdAt`
18
+ - `updatedAt`
19
+ - `controllerPid`
20
+ - `controllerFingerprint`
21
+ - `lastControllerHeartbeatAt`
22
+ - `statePath`
23
+ - `journalDir`
24
+ - `todoSnapshot`
25
+ - `servants[]`
26
+ - `messages[]`
27
+ - `ownedResources[]`
28
+
29
+ Servant fields:
30
+
31
+ - `slotId`
32
+ - `name`
33
+ - `role`
34
+ - `model`
35
+ - `profile`
36
+ - `state` (includes `stalled-after-delivery` for elapsed handoff windows, and `delivery-stuck-composer` when a redirect is pasted but unsubmitted)
37
+ - `pid`
38
+ - `runToken`
39
+ - `fingerprint`
40
+ - `composerSubmitMode`
41
+ - `opencodeSessionId`
42
+ - `lastAckAt`
43
+ - `lastLivenessCheckAt`
44
+ - `lastUsefulSignalAt`
45
+ - `journalPath`
46
+ - `eventJournalPath`
47
+ - `assignment`
48
+ - `handoff`
49
+
50
+ Message fields:
51
+
52
+ - `id`
53
+ - `target`
54
+ - `text`
55
+ - `createdAt`
56
+ - `state` (`queued` | `started` | `completed` | `failed`)
57
+ - `queuedAt`
58
+ - `startedAt`
59
+ - `completedAt`
60
+ - `failedAt`
61
+ - `responseText`
62
+ - `failureReason`
63
+ - `deliveredAt` (legacy PTY-only; superseded by the lifecycle fields)
64
+
65
+ Owned resource fields:
66
+
67
+ - `kind`
68
+ - `id`
69
+ - `pid`
70
+ - `commandName`
71
+ - `cwd`
72
+ - `runId`
73
+ - `runToken`
74
+ - `fingerprint`
75
+ - `startedAt`
76
+ - `stopMethod`
77
+ - `stopState`
@@ -0,0 +1,44 @@
1
+ # Terminal Leash
2
+
3
+ The Overlord must own every servant terminal through a durable controller, PTY leash, and registry.
4
+
5
+ Startup phases shown to humans:
6
+
7
+ - Loading controller and PTYs.
8
+ - Checking Fugu setup.
9
+ - Starting one Ultra and normal Fugus.
10
+ - Loading servant instructions.
11
+ - Waiting for ACKs.
12
+ - Ready.
13
+
14
+ Do not show raw `TERM=dumb`, ANSI redraws, title-setting failures, or TUI noise unless startup fails or debug output is requested.
15
+
16
+ Approval profiles:
17
+
18
+ - Consultation: `codex-fugu --no-alt-screen -a never -s read-only -c 'sandbox_permissions=["disk-full-read-access"]'`
19
+ - Implementation: `codex-fugu --no-alt-screen -a never -s workspace-write -c 'sandbox_permissions=["disk-full-read-access"]' -C <owned-worktree>`
20
+ - Full-trust repair: only with explicit human approval and narrow blast radius.
21
+
22
+ `-a never` is required for servant launches. If routine consultation or bounded implementation asks the human for command approval, the profile is wrong; stop launch, report setup guidance, and do not hand-wave the prompt away.
23
+
24
+ Before launch:
25
+
26
+ - Verify local help/status exposes approval, sandbox, config override, no-alt-screen, and cwd flags.
27
+ - Accept either an API-key environment variable or local Codex auth evidence; guide setup when neither exists.
28
+ - Verify the Fugu model catalog exposes `fugu-ultra`.
29
+ - Fail closed when semantics are missing or unknown.
30
+
31
+ Submit probe:
32
+
33
+ - Prefer initial-prompt launch through the PTY leash.
34
+ - Require the servant to emit `ACK <name> ready`.
35
+ - Record `composerSubmitMode` and `lastAckAt`.
36
+ - Fail startup if no mode is proven.
37
+
38
+ Redirects after startup use `mmi-cli overlord send <target> <message>`; the controller drains the durable mailbox into live servant PTYs. Do not bypass the mailbox with ad-hoc keystrokes unless diagnosing the leash itself.
39
+
40
+ Stop safety:
41
+
42
+ - Stop only recorded resources with matching run id, run token, and fingerprint.
43
+ - Refuse generic `WindowsTerminal`, `pwsh`, `powershell`, `opencode`, `codex`, and `codex-fugu` names without exact ownership.
44
+ - Refuse window-title-only ownership.