@mu-crew/mu 3.1.0 → 3.2.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/AGENTS.md CHANGED
@@ -55,9 +55,12 @@ mu/
55
55
  │ ├── VISION.md # design pillars
56
56
  │ ├── VOCABULARY.md # canonical terms (single source of truth)
57
57
  │ └── ARCHITECTURE.md # module layout, TUI architecture, key seams
58
+ ├── extension/ # the mu pi extension (built to dist/extension/mu-pi.js)
59
+ │ ├── mu-pi.ts # serves $MU_CTL_SOCK inside a spawned pi (control socket server)
60
+ │ └── delegate.ts # parent-side mu_delegate / mu_delegate_cancel tools (shell out to mu)
58
61
  ├── src/ # all source (root files: SDK + shared infra; one
59
62
  │ # level of subdirs OK for cohesive clusters — see
60
- │ # `src/cli/`, `src/agents/`, `src/tasks/`, `src/mux/`)
63
+ │ # `src/cli/`, `src/agents/`, `src/tasks/`, `src/mux/`, `src/ctl/`)
61
64
  │ ├── db.ts # SQLite schema + openDb (single CREATE-IF-NOT-EXISTS block; v11)
62
65
  │ │ # also owns SYNCED_ENTITIES / PORTABLE_TABLES / MACHINE_LOCAL_TABLES
63
66
  │ ├── mux.ts # multiplexer backend hub (re-exports src/mux/*)
@@ -78,6 +81,9 @@ mu/
78
81
  │ │ ├── kick.ts # reaper events + cleanup of dead agent rows
79
82
  │ │ ├── adopt.ts # adoptAgent: register an existing pane as a managed agent
80
83
  │ │ ├── wait.ts # waitForAgents: block on task-less agents finishing (busy → any other state)
84
+ │ │ ├── transport.ts # send routing: ctl for pi agents, mux paste otherwise, no fallback; expectsCtl
85
+ │ │ ├── abort.ts # abortAgent: stop a pi turn through the control socket
86
+ │ │ ├── delegate.ts # delegateOutcome: one wait result → done / empty / died / timeout / pending
81
87
  │ │ └── errors.ts # typed agent error classes (AgentNotFoundError, AgentDiedOnSpawnError, …)
82
88
  │ ├── tasks.ts # task SDK hub (re-exports src/tasks/*)
83
89
  │ ├── tasks/ # cohesive cluster of task-graph internals
@@ -105,6 +111,8 @@ mu/
105
111
  │ ├── sync.ts # peer status + the ambient flush/ingest hook + --from reader + --repair
106
112
  │ ├── fleet-hazards.ts # mixed-fleet doctor checks (DB inside MU_SYNC_DIR, network mount, case collisions)
107
113
  │ ├── file-lock.ts # generic cross-process advisory lock via atomic fs.mkdir
114
+ │ ├── ctl/ # control socket client: path.ts (ctlSocketPath), protocol.ts (v1, CTL_OPS), client.ts (ctlRequest / ctlProbe)
115
+ │ ├── link.ts # mu link pi: extension shim + skill symlink + inspectLinks for doctor
108
116
  │ ├── logs.ts # typed READER over `ops` + appendLog / emitEvent (the one write path triggers can't cover)
109
117
  │ ├── log-render.ts # the ONE op → prose formatter (renderOp); shared by CLI + TUI
110
118
  │ ├── vcs.ts # VcsBackend hub (re-exports src/vcs/*: jj/sl/git/none impls)
@@ -121,6 +129,9 @@ mu/
121
129
  │ ├── cli/ # one file per verb-namespace; thin wrappers over the SDK
122
130
  │ │ ├── workstream.ts # workstream init / list / destroy
123
131
  │ │ ├── agents.ts # agent spawn / send / read / list / show / close / kick / wait / adopt
132
+ │ │ ├── agents-remote.ts # agent remote-env (prints ssh forward + env; runs nothing)
133
+ │ │ ├── dispatch-hints.ts # dispatch-time Next: hints for pi agents (--fresh / --steer / abort)
134
+ │ │ ├── link.ts # mu link pi (filesystem only; runs outside handle())
124
135
  │ │ ├── tasks.ts # `mu task` hub (re-exports wireTaskCommands / cmdMyNext / cmdMyTasks / unescapeNoteText)
125
136
  │ │ ├── tasks/ # sub-cluster of the `mu task` namespace
126
137
  │ │ │ ├── queries.ts # list / next / owned-by + cmdMyTasks / cmdMyNext (back `mu me tasks` / `mu me next`)
package/README.md CHANGED
@@ -19,7 +19,7 @@ mu task add --title "Design auth" --impact 80 --effort-days 2
19
19
  mu task add --title "Build auth" --impact 80 --effort-days 5 --blocked-by design_auth
20
20
 
21
21
  mu agent spawn worker-1 --workspace
22
- mu agent send worker-1 'Pick up the next ready task and design the auth module.'
22
+ mu agent send worker-1 --fresh 'Pick up the next ready task and design the auth module.'
23
23
  mu # dashboard
24
24
  ```
25
25
 
@@ -48,6 +48,11 @@ on track.
48
48
  agents, tasks, ownership, notes and workspaces. A single
49
49
  append-only **ops log** records every change ever made to them, so
50
50
  panes can die and humans can come back later.
51
+ - **Exact control of pi agents, in pi's own TUI.** mu's pi extension
52
+ serves a per-agent control socket inside each agent's interactive
53
+ pi, so send, state, wait and abort are exact — locally and on
54
+ remote hosts over the agent's own ssh. No screen scraping; the pane
55
+ stays pi's normal TUI, and you can attach and type into it.
51
56
  - **Stay out of the model's way.** Mu coordinates handoffs; it does
52
57
  not choose models, providers, or thinking effort. `--cli <key>`
53
58
  uppercases to `$MU_<KEY>_COMMAND`, so your shell rc owns the agent
@@ -67,9 +72,9 @@ on track.
67
72
  and the activity log, never agent-to-agent messaging.
68
73
  - **Not a verifier.** `task close --evidence "tests pass"` records
69
74
  the claim; mu doesn't run the tests.
70
- - **Not a replacement for [pi-subagents](https://github.com/nicobailon/pi-subagents).**
71
- Mu agents are driveable panes; pi-subagents is for one-shot
72
- focused delegation. See [vs `pi-subagents`](#vs-pi-subagents).
75
+ - **No hidden subagents.** One-shot delegation runs in a visible pane
76
+ you can attach to, steer and keep talking to. See
77
+ [vs hidden subagents](#vs-hidden-subagents).
73
78
  - **Not a hosted service.** Local-first SQLite.
74
79
  - **DB-undoable, not substrate-undoable.** Every change is captured as ops
75
80
  under one group, so `mu undo <group> --yes` reverses exactly that
@@ -99,43 +104,46 @@ case: one helper or background watcher you still want to drive and
99
104
  observe.
100
105
 
101
106
  **Don't use mu for** — tiny direct edits; quick local inspection;
102
- one-shot focused delegation where you only need a returned answer
103
- (use `pi-subagents`); single-context work where durable coordination
104
- adds ceremony.
107
+ single-context work where durable coordination adds ceremony.
108
+
109
+ For one-shot delegation where you only need an answer back, use a
110
+ **delegate**: the `mu_delegate` tool, or `mu agent spawn -w scratch` +
111
+ `send` + `wait --json` from a shell. Installing mu gives you
112
+ `mu_delegate`; it ships in the extension `mu link pi` installs.
105
113
 
106
114
  ---
107
115
 
108
116
  ## Install
109
117
 
110
118
  ```bash
111
- # 1. The CLI, and murmur for agent state on tmux (see below).
112
- npm install -g @mu-crew/mu @mu-crew/murmur
113
- mu --version
114
- murmur init && murmur link pi
115
-
116
- # 2. The skill (teaches your coding agent how to drive mu).
117
- npx skills add mu-crew/mu # auto-detects pi / claude-code / codex / etc.
118
- # Add -g to install globally (~/.<agent>/skills/), -y to skip prompts.
119
+ npm i -g @mu-crew/mu
120
+ mu link pi # pi extension (exact send/state/wait/abort) + the mu skill
121
+ mu doctor
122
+ ```
123
+
124
+ For pi, `mu link pi` replaces `npx skills add`. To drive mu from
125
+ another coding agent (claude-code, codex, ...), install the skill
126
+ instead:
127
+
128
+ ```bash
129
+ npx skills add mu-crew/mu # auto-detects the agent; -g global, -y no prompts
119
130
  ```
120
131
 
121
132
  **Requirements:**
122
133
  - Node 22.12–26 (see `.nvmrc`), matching `engines` in `package.json`.
123
134
  - A terminal multiplexer: tmux ≥ 3.0, or [herdr](https://github.com/herdrdev/herdr)
124
135
  (`mu doctor` reports which one is active). Spawn, send, and read work
125
- on both. Agent state comes from herdr on herdr and from murmur on tmux;
126
- the remaining herdr gaps are listed in
136
+ on both. The remaining herdr gaps are listed in
127
137
  [docs/USAGE_GUIDE.md § 20](docs/USAGE_GUIDE.md#20-multiplexer-backends-tmux-and-herdr).
128
138
  - pi (the agent CLI mu orchestrates)
129
139
  - For `--workspace`: jj, sl, or git on PATH (or `--backend none`)
130
140
 
131
- **Agent state on tmux needs [murmur](https://github.com/mu-crew/murmur),
132
- even on one machine.** mu owns the work; murmur reports what each agent is
133
- doing. mu does not read panes itself, so without murmur every agent's state
134
- is `unknown`, and everything built on state goes quiet: `mu agent wait`
135
- never fires, `mu task wait --stuck-after` / `--on-stall exit` never detects
136
- a worker waiting on you, and spawn skips its readiness check. Tasks, claims,
137
- `mu task wait` on status, workspaces, spawn and send still work. murmur also
138
- provides one attention-sorted list across machines and owns the ssh egress.
141
+ **murmur is optional for pi agents.** mu reads a pi agent's state from
142
+ its control socket. Non-pi CLIs (claude-code, codex) on tmux get state from
143
+ [murmur](https://github.com/mu-crew/murmur); without it their state is
144
+ `unknown`, so `mu agent wait` and stall detection never fire for them.
145
+ On herdr, herdr reports it. murmur also gives you one attention-sorted
146
+ "who needs me" list across machines, tmux badges, and jump-to-pane.
139
147
 
140
148
  ```bash
141
149
  # on every node that runs agents
@@ -148,12 +156,14 @@ murmur peer add dev # an ssh target; identity is discovered
148
156
  murmur peer list # which hosts are reachable, and when last seen
149
157
  ```
150
158
 
151
- mu exports `MU_MANAGED_AGENT`, `MU_AGENT_NAME`, and `MU_WORKSTREAM`
152
- into every pane it spawns. murmur uses them to identify crew agents.
159
+ mu exports `MU_MANAGED_AGENT`, `MU_AGENT_NAME`, `MU_WORKSTREAM` and
160
+ `MU_CTL_SOCK` into every pane it spawns. murmur uses the first three to
161
+ identify crew agents; mu's extension serves the control socket at the last.
153
162
  See murmur's [stable contract](https://github.com/mu-crew/murmur/blob/main/ARCHITECTURE.md#contract).
154
163
 
155
- **Update:** `npm install -g @mu-crew/mu@latest` for the CLI;
156
- `npx skills update mu` for the skill.
164
+ **Update:** `npm install -g @mu-crew/mu@latest`. The `mu link pi` shim and
165
+ skill symlink follow the installed package; restart running pi agents (or
166
+ `/reload`) to load the new extension. With `npx skills`: `npx skills update mu`.
157
167
 
158
168
  **Install from source** (hacking on mu itself):
159
169
 
@@ -161,7 +171,7 @@ See murmur's [stable contract](https://github.com/mu-crew/murmur/blob/main/ARCHI
161
171
  git clone https://github.com/mu-crew/mu
162
172
  cd mu
163
173
  npm install -g . # `prepare` script auto-builds; `mu` lands on $PATH
164
- npx skills add ./skills/mu # local-path source format
174
+ mu link pi # links this checkout's extension + skill
165
175
  ```
166
176
 
167
177
  More install patterns (alias-to-dist for fastest dev iteration) in
@@ -279,12 +289,17 @@ backend: the pane is local, the process is remote.
279
289
 
280
290
  ```bash
281
291
  ssh dev 'git -C ~/repo worktree add ~/ws/worker-1'
292
+ eval "$(mu agent remote-env worker-1 -w big --shell)" # socket forward + env; runs nothing
282
293
  mu agent spawn worker-1 -w big --command \
283
- 'ssh dev -t "cd ~/ws/worker-1 && pi --approve"'
284
- # ... claim and send exactly as for a local agent, then collect:
294
+ "ssh $MU_SSH_ARGS dev -t 'cd ~/ws/worker-1 && $MU_REMOTE_ENV \$SHELL -ilc \"pi --approve\"'"
295
+ # ... claim, send and abort exactly as for a local agent, then collect:
285
296
  git fetch "ssh://dev/~/ws/worker-1" HEAD && git cherry-pick FETCH_HEAD
286
297
  ```
287
298
 
299
+ The ssh forwards the remote pi's control socket to the local path mu
300
+ derives, so send, state and wait are exact without murmur. The host
301
+ needs `mu link pi`.
302
+
288
303
  Local and remote agents mix freely in one workstream. You create the
289
304
  remote workspace yourself (`--workspace` is local-only) and mu keeps
290
305
  no record of it, so read
@@ -294,21 +309,29 @@ covers the traps, including the one where your own agent blocks your
294
309
 
295
310
  ---
296
311
 
297
- ## vs `pi-subagents`
298
-
299
- | | [`pi-subagents`](https://github.com/nicobailon/pi-subagents) | `mu` |
300
- | ------------------------ | -------------------------------------------------------- | ---- |
301
- | Best for | "Send this focused task to a specialist, return a result" | "Keep a driveable agent/persistent crew in a multiplexer" |
302
- | Lifetime | one-shot per task | from off-the-cuff `scratch` helper to long-lived crew |
303
- | Substrate | `pi` subprocess + result files | tmux/herdr panes running pi sessions |
304
- | Built-in task graph | no | yes: parallel-tracks union-find with diamond-merge |
305
- | Drivable from outside pi | no (extension-only) | yes (`mu` is a real CLI) |
306
-
307
- The two play well together. Use `pi-subagents` when you want one
308
- focused answer back. Use mu's reserved `scratch` workstream when you
309
- want a low-ceremony helper you can keep talking to. For coordinated
310
- multi-agent work, graduate from `scratch` to a named workstream + task
311
- DAG. See [docs/USAGE_GUIDE.md](docs/USAGE_GUIDE.md).
312
+ ## vs hidden subagents
313
+
314
+ Most agent tools delegate to a hidden subagent: a child process or
315
+ in-process loop that pi-subagents, pi's example subagent extension,
316
+ and the Claude Code and Codex task tools run out of sight. You get its
317
+ result and lose the rest. A mu **delegate** is an ordinary agent in a
318
+ pane.
319
+
320
+ | | Hidden subagent | mu delegate |
321
+ | --------------------- | --------------------------------------- | ----------- |
322
+ | Visibility | none while it runs | a pane; attach and watch live |
323
+ | Steer mid-run | no | yes: `mu agent send`; stop with `mu agent abort` |
324
+ | Keep talking after it answers | no | yes, with `keep: true` |
325
+ | Transcript | collapses into a result | a normal pi session log |
326
+ | Agent types | usually built in | none; the brief is ad-hoc text |
327
+ | If the work grows | re-brief a new agent | same task DAG and workspaces as any agent |
328
+ | Cost | light | one pane and one pi process each |
329
+
330
+ The cost row is the trade-off. For many tiny calls a hidden subagent is
331
+ lighter. mu bets that for agent work, seeing and steering the agent is
332
+ worth a pane. For coordinated multi-agent work, graduate from
333
+ `scratch` to a named workstream + task DAG. See
334
+ [docs/USAGE_GUIDE.md](docs/USAGE_GUIDE.md).
312
335
 
313
336
  ---
314
337