@mu-crew/mu 3.2.1 → 3.4.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.
Files changed (60) hide show
  1. package/AGENTS.md +10 -5
  2. package/README.md +83 -22
  3. package/dist/cli.js +294 -98
  4. package/dist/cli.js.map +1 -1
  5. package/dist/extension/mu-pi.js +346 -85
  6. package/dist/extension/mu-pi.js.map +1 -1
  7. package/dist/index.d.ts +68 -13
  8. package/dist/index.js +159 -71
  9. package/dist/index.js.map +1 -1
  10. package/docs/ARCHITECTURE.md +1 -0
  11. package/docs/VISION.md +3 -1
  12. package/docs/VOCABULARY.md +6 -1
  13. package/docs/architecture/control-socket.md +17 -3
  14. package/docs/architecture/dag.md +3 -3
  15. package/docs/architecture/mux.md +3 -4
  16. package/docs/guide/README.md +5 -0
  17. package/docs/guide/delegate.md +30 -3
  18. package/docs/guide/dispatch.md +11 -4
  19. package/docs/guide/getting-started.md +3 -0
  20. package/docs/guide/recovery.md +3 -1
  21. package/docs/guide/remote.md +1 -1
  22. package/docs/history/CHANGELOG-pre-3.md +1 -1
  23. package/docs/reference/env.md +2 -1
  24. package/docs/reference/naming.md +18 -0
  25. package/docs/specs/2026-09-29-task-substates.md +1 -1
  26. package/docs/specs/2026-10-03-keep-driving-nudge.md +142 -0
  27. package/package.json +2 -1
  28. package/prompts/mu-debug.md +8 -0
  29. package/prompts/mu-refute.md +8 -0
  30. package/prompts/mu-research.md +8 -0
  31. package/prompts/mu-review.md +8 -0
  32. package/prompts/mu-rules-audit.md +8 -0
  33. package/prompts/mu-sweep.md +8 -0
  34. package/prompts/mu-tournament.md +9 -0
  35. package/prompts/mu-until.md +8 -0
  36. package/prompts/ultrathink.md +10 -0
  37. package/skills/mu/SKILL.md +124 -145
  38. package/skills/mu/recipes/adversarial-review.md +91 -0
  39. package/skills/mu/recipes/backlog-triage.md +43 -0
  40. package/skills/mu/recipes/brief.md +53 -0
  41. package/skills/mu/recipes/codemode-driver.md +102 -0
  42. package/skills/mu/recipes/deep-research.md +67 -0
  43. package/skills/mu/recipes/fan-out.md +40 -0
  44. package/skills/mu/recipes/findings.md +103 -0
  45. package/skills/mu/recipes/hypothesis-panel.md +45 -0
  46. package/skills/mu/recipes/long-run.md +20 -0
  47. package/skills/mu/recipes/loop-until-done.md +42 -0
  48. package/skills/mu/recipes/orchestrator-loop.md +98 -0
  49. package/skills/mu/recipes/plan.md +59 -0
  50. package/skills/mu/recipes/recovery.md +28 -0
  51. package/skills/mu/recipes/refute.md +51 -0
  52. package/skills/mu/{REMOTE_WORKERS.md → recipes/remote-workers.md} +7 -2
  53. package/skills/mu/recipes/review-panel.md +62 -0
  54. package/skills/mu/recipes/rules-audit.md +83 -0
  55. package/skills/mu/recipes/tasks-or-calls.md +67 -0
  56. package/skills/mu/recipes/tournament.md +40 -0
  57. package/skills/mu/recipes/ultrathink.md +82 -0
  58. package/skills/mu/recipes/watcher.md +19 -0
  59. package/skills/mu/recipes/waves.md +20 -0
  60. package/skills/mu/recipes/worker.md +26 -0
@@ -0,0 +1,83 @@
1
+ # Rules audit
2
+
3
+ Use when the repo's written rules (`AGENTS.md`, contributing guides,
4
+ style docs) are not being followed, or when the same correction keeps
5
+ coming up in review and is not written down. One agent checking a diff
6
+ against twenty rules skips some; one checker per rule does not.
7
+
8
+ Two modes. **Check** asks "does this change follow our rules?".
9
+ **Mine** asks "which rules are we missing?".
10
+
11
+ Check on someone's PR runs as delegates; check before merging your own
12
+ work, and mine always, run in a workstream. Violations and candidate
13
+ rules are findings: [findings](findings.md) says where they live.
14
+
15
+ ## Check: a change against the rules
16
+
17
+ 1. **List the rules.** A scout (a delegate call) extracts every
18
+ checkable rule from the rule files, one per line with its source,
19
+ into every checker's brief (delegate mode) or the umbrella's note
20
+ (workstream mode):
21
+
22
+ ```text
23
+ RULE: r7 AGENTS.md:52 "Throw typed error classes, not bare Error"
24
+ ```
25
+
26
+ Skip rules no diff can show (team habits, meeting norms). Record the
27
+ count.
28
+ 2. **Pin the target**: the diff, branch, or PR, as in
29
+ [review-panel](review-panel.md) step 1.
30
+ 3. **One checker per rule**, as a [delegate call](tasks-or-calls.md#delegate-call)
31
+ The checker gets one rule and the diff, and records each violation
32
+ as a finding ([findings § Record](findings.md#record); title
33
+ `<severity>: r7 <what>`), or reports `r7: no violations` with what it
34
+ looked at. One rule per checker keeps it from skimming; batch under
35
+ the cap ([orchestrator-loop § Concurrency](orchestrator-loop.md#concurrency)).
36
+ 4. **A skeptic pass** over the flags, also a delegate call: one fresh agent reads each flagged
37
+ line and the rule, and drops false positives (the rule does not
38
+ apply here, the code already complies, the rule has a stated
39
+ exception). In workstream mode, a dropped flag is
40
+ `close --as rejected --why '<reason>'`; a confirmed one is accepted.
41
+ 5. **Report or fix** confirmed violations, as in review-panel step 5.
42
+
43
+ Done when every rule from step 1 has a checker result, and every flag
44
+ is decided.
45
+
46
+ ## Mine: rules you keep stating but never wrote
47
+
48
+ 1. **Collect corrections.** Sources, any that exist: review comments
49
+ on merged PRs, `REJECT` notes from [adversarial-review](adversarial-review.md)
50
+ tasks, and past agent sessions (with a session archive such as
51
+ [museum](https://github.com/mu-crew/museum), search for user turns
52
+ that correct the agent: "no, use", "don't", "we always"). One reader
53
+ (a delegate call) per source batch returns each correction as one
54
+ line:
55
+
56
+ ```text
57
+ CORRECTION: k12 <source ref> "use the shared retry helper instead of a hand-rolled loop"
58
+ ```
59
+
60
+ 2. **Cluster** the corrections in one delegate call: the same lesson in
61
+ different words is one cluster. Keep clusters with at least two
62
+ corrections from different occasions; a one-off is not a rule.
63
+ 3. **One `OPEN/triage` task per candidate rule**, the rule as the
64
+ title and its cluster of corrections in the note.
65
+ 4. **Refute each candidate** with a [delegate call](tasks-or-calls.md#delegate-call): would it have
66
+ prevented the real mistakes in its cluster? Does it contradict an
67
+ existing rule? Is it already enforced by a linter or test (then it
68
+ needs no prose)? Dropped candidates close `--as rejected`.
69
+ 5. **Propose, don't commit.** The candidates left in triage are the
70
+ proposal: write them as a diff to the rule file in the umbrella's
71
+ note, worded per [brief](brief.md) (positive, specific, with the
72
+ reason). A rule change is a human decision: the human accepts or
73
+ rejects each candidate task.
74
+
75
+ Done when every cluster has a verdict and the proposal lists each kept
76
+ rule with the corrections behind it.
77
+
78
+ ## Traps
79
+
80
+ - **A rule a tool can check belongs in the tool.** If a linter, type,
81
+ or test can catch it, propose that instead of prose.
82
+ - **Mined rules overfit.** Two corrections in one week about one file
83
+ may be about that file, not a rule. The refute step asks.
@@ -0,0 +1,67 @@
1
+ # Tasks or calls
2
+
3
+ Use when a recipe step spawns an agent: decide whether that agent's job
4
+ is a **task** in the DAG or a **call** to a delegate. Getting it wrong
5
+ one way loses track of work; the other way, one PR review creates
6
+ hundreds of tasks and a workstream nobody wanted.
7
+
8
+ ## Delegate call
9
+
10
+ A **delegate call** is one `mu_delegate` tool call in pi. Without the
11
+ tool (another harness, a script):
12
+
13
+ ```bash
14
+ mu agent spawn refuter-1 -w scratch
15
+ mu agent send refuter-1 -w scratch --fresh '<brief>'
16
+ mu agent wait refuter-1 -w scratch --json # answer in lastText
17
+ ```
18
+
19
+ - **It starts empty.** The brief carries everything: the finding or
20
+ claim, file paths, the criteria, and the answer line to end with
21
+ (`VERDICT: ...`, `WINNER: ...`). See [brief](brief.md).
22
+ - **Fan out in one turn.** Issue every call for a step together; in pi
23
+ the answers arrive later as follow-up messages. Calling one, waiting,
24
+ then the next runs them in series.
25
+ - **It leaves no task.** Its `scratch` pane stays attachable while it
26
+ runs. `mu_delegate` closes it after a clean finish and keeps it on a
27
+ crash or timeout (`keep: true` always keeps it); the bash form needs
28
+ `mu agent close <name> -w scratch`. You record its verdict on the task
29
+ it judged.
30
+
31
+ ## The rule
32
+
33
+ **A task is a thing the graph tracks. Checking a thing is a call.**
34
+
35
+ | Make it a task | Make it a delegate call |
36
+ | --- | --- |
37
+ | a unit of work that produces commits | refuting a finding |
38
+ | a gate that decides whether work counts (`review_x`) | checking a claim against its source |
39
+ | a finding, claim, or hypothesis that survives into the workstream | judging a pair in a tournament |
40
+ | the umbrella, and each round of a loop | a skeptic or dedupe pass |
41
+ | anything that needs its own workspace | a reader or scout whose output feeds one step |
42
+
43
+ A call writes nothing to mu. Its answer lands on the task it judged:
44
+ the orchestrator records the verdict as a note and a state change
45
+ (`mu task accept`, `close --as rejected --why '<evidence>'`). The graph
46
+ keeps the decision and its evidence without a node per check.
47
+
48
+ ## Examples
49
+
50
+ - A refuter checks 30 findings: 30 delegate calls, 0 new tasks; each
51
+ finding task gets the refuter's evidence and is accepted or closed.
52
+ - A tournament over 16 names: 15 judge delegate calls; the winner goes
53
+ in the umbrella's note.
54
+ - A hypothesis test that reverts commits or forces a race needs a
55
+ workspace: that one is a task.
56
+
57
+ ## Counting
58
+
59
+ Before a wave, count what it will add: units + gates + expected
60
+ findings. If the count is more than a few hundred for one change, the
61
+ steps that only check things are probably tasks by mistake.
62
+
63
+ Run calls within the delegate cap (`MU_DELEGATE_MAX`, default 16; see
64
+ [orchestrator-loop § Concurrency](orchestrator-loop.md#concurrency)).
65
+
66
+ Done when every agent a recipe step spawns is either a task in the DAG
67
+ or a delegate call whose verdict is recorded on a task.
@@ -0,0 +1,40 @@
1
+ # Tournament
2
+
3
+ Use when several answers are possible and the best is a judgement
4
+ call: a design, a name, an API shape, competing fixes, a ranking. Agents
5
+ compete on the same task; judges compare pairs. Comparing two is more
6
+ reliable than scoring one.
7
+
8
+ ## Steps
9
+
10
+ 1. **Write the rubric first**, on the umbrella: what good looks like,
11
+ in a few ranked criteria. Judges apply it; they do not invent one.
12
+ 2. **Generate.** N attempts with the same brief and a different
13
+ approach or model each. Code attempts are tasks, each in its own
14
+ workspace. Ideas (names, plans) are delegate calls; one call can
15
+ generate many candidates.
16
+ 3. **Filter** (when there are many candidates): one delegate call drops
17
+ the ones that fail a hard rubric criterion and merges duplicates. What is left
18
+ enters the bracket.
19
+ 4. **Judge in pairs.** One [delegate call](tasks-or-calls.md#delegate-call) per comparison, a fresh agent
20
+ each, so no judge holds the whole field
21
+ ([tasks-or-calls](tasks-or-calls.md)). The judge sees the two
22
+ candidates and the rubric and ends with `WINNER: <a|b> <reason>`.
23
+ Record each round's results in the umbrella's note; winners meet in
24
+ the next round. A round wider than the cap runs in batches
25
+ ([orchestrator-loop § Concurrency](orchestrator-loop.md#concurrency)).
26
+ 5. **Confirm the winner** with a final check against the rubric, then
27
+ merge it. Free the losing workspaces.
28
+
29
+ Done when one candidate has won every comparison it entered and the
30
+ final check passed.
31
+
32
+ ## Traps
33
+
34
+ - **Position bias.** Judges favour the first candidate shown. For close
35
+ calls, judge the pair twice with the order swapped; a split decision
36
+ goes to a third judge.
37
+ - **Same model, same taste.** Vary the attempt models, and judge with a
38
+ model that made no attempt.
39
+ - **Ranking many items** (tickets by severity): bucket them in parallel,
40
+ then run pairwise comparisons only within and across bucket edges.
@@ -0,0 +1,82 @@
1
+ # Ultrathink
2
+
3
+ Use when a task is too large or too risky for one context: a migration
4
+ across many files, a repo-wide audit, a hard bug, a design with real
5
+ alternatives, any long autonomous run where you will not read every
6
+ line. Ultrathink composes the other recipes. Every unit, gate, finding
7
+ and round is a task in the DAG, so the run is as visible as the code it
8
+ produces; the checks on them are delegate calls whose verdicts land on
9
+ those tasks.
10
+
11
+ It costs many agents and many tokens. For a change one agent can hold
12
+ and check, skip it.
13
+
14
+ ## Steps
15
+
16
+ 1. **Define done.** Write the goal and the stop rule on an umbrella task:
17
+ the command that must pass, the report that must exist, the criteria
18
+ a reviewer will apply. Ask the human now for anything only they can
19
+ decide (scope, budget, external actions); after this step, keep
20
+ driving.
21
+ 2. **Understand before you change.** If the shape of the work is not
22
+ known, run a scout ([delegate call](tasks-or-calls.md#delegate-call))
23
+ or a [fan-out](fan-out.md) of readers first. Their
24
+ output is the unit list and the facts the plan needs, in notes.
25
+ 3. **Pick the shape** for the main phase:
26
+
27
+ | The work is | Recipe |
28
+ | --- | --- |
29
+ | the same change over many units | [fan-out](fan-out.md) |
30
+ | finding problems or checking claims | [refute](refute.md) |
31
+ | a cause to find | [hypothesis-panel](hypothesis-panel.md) |
32
+ | a choice between real alternatives | [tournament](tournament.md) |
33
+ | an unknown amount, until a check passes | [loop-until-done](loop-until-done.md) |
34
+ | a backlog of external items | [backlog-triage](backlog-triage.md) |
35
+ | a question across many sources | [deep-research](deep-research.md) |
36
+ | one change to review from every angle | [review-panel](review-panel.md) |
37
+ | a change against the repo's written rules | [rules-audit](rules-audit.md) |
38
+
39
+ Phases chain: an audit (refute) feeds a fix sweep (fan-out); a
40
+ tournament picks the design a fan-out then implements.
41
+ 4. **Plan the whole phase as tasks** before spawning: every unit,
42
+ blocked into the umbrella, each note written as a
43
+ [brief](brief.md) ([plan](plan.md) for a spec-driven build). Rounds
44
+ of a loop are the one exception: add each when the last closes.
45
+ 5. **Review every unit that ships.** Each commit-producing task gets a
46
+ review task ([adversarial-review](adversarial-review.md)), on a
47
+ different model where you can. Every finding is a triage task,
48
+ refuted before it is accepted ([findings](findings.md)).
49
+ 6. **Run the loop** ([orchestrator-loop](orchestrator-loop.md)): pipeline
50
+ merges, verify each merge, keep workers busy
51
+ ([waves](waves.md) when they share files). Long runs follow
52
+ [long-run](long-run.md). With codemode, a
53
+ [driver](codemode-driver.md) can dispatch a wave.
54
+ 7. **Close against the stop rule**, checked by you on the merged tree,
55
+ not by any worker's note. Then
56
+ `mu task close <umbrella> --if-ready --evidence '...'`.
57
+
58
+ Done when the umbrella is closed, its stop rule holds on the merged
59
+ tree, every shipped unit's latest review task is `CLOSED/done`
60
+ (ACCEPT), and
61
+ `mu task list --substate triage` is empty or only `UNVERIFIED`.
62
+
63
+ ## Budget
64
+
65
+ - Agree a ceiling in step 1 and write it on the umbrella
66
+ ([orchestrator-loop § Concurrency](orchestrator-loop.md#concurrency)).
67
+ - Checks are calls, not tasks ([tasks-or-calls](tasks-or-calls.md)): a
68
+ 50-unit run should add about 50 units, 50 gates and the findings that
69
+ survive, not a task per refuter and judge.
70
+ - The run gets its own workstream, `<project>-ut-<topic>`, torn down
71
+ when the umbrella closes ([recovery](recovery.md) before teardown).
72
+ - Cheap models scout and find (`pi_mini`); the default builds (`pi`);
73
+ strong models review, refute, judge, and synthesize (`pi_big`).
74
+ - Calibrate on a slice: run the phase on a few units, check the result
75
+ and the cost, then fan out the rest.
76
+
77
+ ## What the human sees
78
+
79
+ `mu state` shows every unit, its reviewer, and what is still running.
80
+ `mu task notes <id>` shows why any unit was accepted or rejected. A
81
+ rejected unit stays in the DAG next to its fix. Nothing about the run
82
+ lives only in your context.
@@ -0,0 +1,19 @@
1
+ # Watcher
2
+
3
+ Use when a helper polls something outside mu (a PR, CI, a log) and
4
+ acts on change. Run it in `scratch`, or in the workstream it serves.
5
+
6
+ 1. **Keep last-seen state in a log ledger**, not in the helper's
7
+ context. Write one line per observation:
8
+ `mu log -w scratch --kind pr-state 'pr=1234 sha=abc ci=red'`.
9
+ 2. **Read the last entry before acting:**
10
+ `mu log -w scratch --kind pr-state -n 1 --json`.
11
+ Act only when the new observation differs.
12
+ 3. **Wait with mu, not `sleep`.** `mu agent wait <names...> --first`
13
+ returns when an agent goes busy → idle.
14
+
15
+ The ledger survives a dead or fresh helper: a replacement reads the
16
+ last line and carries on. To act on new items (issues, alerts), see
17
+ [backlog-triage](backlog-triage.md).
18
+
19
+ Done when the watched thing reaches its end state (PR merged, CI green) and the last ledger line says so.
@@ -0,0 +1,20 @@
1
+ # Waves: several workers in one repo
2
+
3
+ Use when two or more workers edit the same repo at once. Every worker
4
+ runs in its own `--workspace`; this recipe decides what each one gets.
5
+
6
+ 1. **Bucket by file cluster, not severity.** Two agents editing one
7
+ file conflict, whatever the priority. Put tasks that share files on
8
+ one track (`mu task block`) so only one agent holds them.
9
+ 2. **Freeze only what conflicts.** Give idle workers tasks that avoid
10
+ the shared files. A blanket freeze idled four of five workers for a
11
+ day.
12
+ 3. **Pipeline the merge.** Cherry-pick each task as it closes and
13
+ verify the merged tree ([orchestrator-loop § Merging](orchestrator-loop.md#merging));
14
+ never wait for the whole wave.
15
+ 4. **Refresh before each dispatch.** `mu workspace refresh <agent>`
16
+ rebases onto main and keeps the agent's context; run it before every
17
+ `--fresh` send, so each unit starts from the latest merge.
18
+
19
+ Done when every task in the wave is `CLOSED/done`, merged, and the
20
+ merged tree passes the gate command.
@@ -0,0 +1,26 @@
1
+ # Worker loop
2
+
3
+ Use when you are the worker: a task was claimed for you, or you were
4
+ told to claim one.
5
+
6
+ `$MU_AGENT_NAME` (injected at spawn) resolves identity; adopted panes
7
+ fall back to the pane title. In a worker pane, bare `mu task claim <id>`
8
+ works. In the unregistered orchestrator pane it errors; use `--self`,
9
+ `--for <worker>`, or `mu agent adopt <pane>`.
10
+
11
+ ```bash
12
+ mu me
13
+ mu me next
14
+ mu task show <id>; mu task notes <id>
15
+ mu task claim <id> --evidence "starting; read notes"
16
+ mu task note <id> "FILES: ...\nDECISION: ...\nVERIFIED: ..."
17
+ mu task close <id> --evidence "tests pass: ..." # LAST action
18
+ ```
19
+
20
+ The note follows the task note contract in SKILL.md. Commit before you
21
+ close: the orchestrator cherry-picks your commits, not your tree. A
22
+ review or audit task records each problem per
23
+ [findings § Record](findings.md#record).
24
+
25
+ Done when the task is closed. Skipping close makes the orchestrator's
26
+ wait hang. Won't do it: `close --as wontfix --why "..."`.