@ionivetech/mugiwara 0.4.0 → 0.5.1

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 (128) hide show
  1. package/README.md +231 -371
  2. package/content/agents/brook-healing.md +2 -2
  3. package/content/agents/chopper-checkpoint.md +2 -1
  4. package/content/agents/eval-runner.md +4 -4
  5. package/content/agents/franky-gates.md +1 -1
  6. package/content/agents/jinbe-security.md +2 -1
  7. package/content/agents/luffy-orchestrator.md +3 -3
  8. package/content/agents/memory-keeper.md +1 -1
  9. package/content/agents/nami-planner.md +2 -2
  10. package/content/agents/resume-coordinator.md +8 -9
  11. package/content/agents/robin-reviewer.md +3 -2
  12. package/content/agents/sanji-quality.md +1 -1
  13. package/content/agents/skeptic-verifier.md +4 -3
  14. package/content/agents/using-mugiwara.md +3 -3
  15. package/content/agents/usopp-brainstorm.md +3 -3
  16. package/content/agents/zoro-execution.md +4 -3
  17. package/content/skills/mugiwara-agent-security/SKILL.md +14 -2
  18. package/content/skills/mugiwara-backend/SKILL.md +2 -8
  19. package/content/skills/mugiwara-backend/references/source-backed-example.md +77 -0
  20. package/content/skills/mugiwara-brainstorm/SKILL.md +2 -2
  21. package/content/skills/mugiwara-checkpoint/SKILL.md +2 -2
  22. package/content/skills/mugiwara-checkpoint/references/ledger-format.md +34 -0
  23. package/content/skills/{mugiwara-doubt-driven-development → mugiwara-claim-audit}/SKILL.md +2 -2
  24. package/content/skills/{mugiwara-context-engineering → mugiwara-context-budget}/SKILL.md +2 -2
  25. package/content/skills/mugiwara-context-budget/references/context-budget.md +37 -0
  26. package/content/skills/{mugiwara-api-and-interface-design → mugiwara-contract-first}/SKILL.md +4 -2
  27. package/content/skills/mugiwara-contract-first/references/versioning-playbook.md +36 -0
  28. package/content/skills/mugiwara-execution/SKILL.md +4 -2
  29. package/content/skills/mugiwara-execution/references/worked-example.md +88 -0
  30. package/content/skills/mugiwara-frontend/SKILL.md +13 -14
  31. package/content/skills/mugiwara-frontend/references/design-tokens.md +25 -0
  32. package/content/skills/mugiwara-frontend/references/slop-catalog.md +19 -0
  33. package/content/skills/mugiwara-gates/SKILL.md +4 -4
  34. package/content/skills/mugiwara-git/SKILL.md +1 -1
  35. package/content/skills/mugiwara-healing/SKILL.md +34 -7
  36. package/content/skills/mugiwara-healing/references/failure-taxonomy.md +23 -0
  37. package/content/skills/mugiwara-lessons/SKILL.md +1 -1
  38. package/content/skills/mugiwara-orchestration/SKILL.md +5 -5
  39. package/content/skills/mugiwara-planning/SKILL.md +2 -2
  40. package/content/skills/mugiwara-planning/references/anti-patterns.md +17 -0
  41. package/content/skills/mugiwara-planning/references/plan-template.md +46 -0
  42. package/content/skills/mugiwara-pr/SKILL.md +1 -1
  43. package/content/skills/{mugiwara-test-driven-development → mugiwara-proof-order}/SKILL.md +2 -2
  44. package/content/skills/mugiwara-proof-order/references/proof-order-examples.md +62 -0
  45. package/content/skills/mugiwara-quality/SKILL.md +3 -3
  46. package/content/skills/mugiwara-resume/SKILL.md +44 -33
  47. package/content/skills/mugiwara-review/SKILL.md +1 -1
  48. package/content/skills/mugiwara-review/references/five-axis-worksheet.md +36 -0
  49. package/content/skills/mugiwara-review/references/severity-rubric.md +20 -0
  50. package/content/skills/{mugiwara-systematic-debugging → mugiwara-root-cause}/SKILL.md +4 -2
  51. package/content/skills/mugiwara-root-cause/references/four-phase-worked.md +71 -0
  52. package/content/skills/mugiwara-security/SKILL.md +1 -1
  53. package/content/skills/mugiwara-security/references/owasp-mapping.md +30 -0
  54. package/content/skills/mugiwara-security/references/stride-worksheet.md +37 -0
  55. package/content/skills/mugiwara-ship/SKILL.md +1 -1
  56. package/content/skills/{mugiwara-deprecation → mugiwara-sunset}/SKILL.md +2 -2
  57. package/content/skills/mugiwara-testcases/SKILL.md +1 -1
  58. package/content/skills/mugiwara-testcases/references/intake-formats.md +42 -0
  59. package/content/skills/mugiwara-workflow/SKILL.md +20 -23
  60. package/dist/mugiwara.js +37 -8
  61. package/docs/agents.md +2 -2
  62. package/docs/audit-trail.md +65 -0
  63. package/docs/comparison.md +43 -170
  64. package/docs/compliance-matrix.md +81 -0
  65. package/docs/config.md +4 -2
  66. package/docs/cost.md +45 -0
  67. package/docs/enforcement.md +32 -35
  68. package/docs/getting-started.md +103 -41
  69. package/docs/harness-matrix.md +41 -0
  70. package/docs/lanes.md +65 -23
  71. package/docs/skill-anatomy.md +42 -54
  72. package/docs/skills.md +36 -54
  73. package/evals/cases/_no-skill.json +16 -0
  74. package/evals/cases/adversarial-pressure-fake-pass.json +21 -8
  75. package/evals/cases/adversarial-pressure-skip-review.json +19 -7
  76. package/evals/cases/lane-exploratory-vague.json +18 -6
  77. package/evals/cases/lane-sensitivity-payment.json +18 -6
  78. package/evals/cases/positive-refactor-existing-tests.json +22 -8
  79. package/evals/cases/positive-resume-mid-mission.json +20 -7
  80. package/evals/cases/routing-agent-security.json +25 -0
  81. package/evals/cases/routing-auth-feature.json +20 -7
  82. package/evals/cases/routing-backend.json +25 -0
  83. package/evals/cases/routing-bug-one-file.json +21 -8
  84. package/evals/cases/routing-claim-audit.json +25 -0
  85. package/evals/cases/routing-context-budget.json +25 -0
  86. package/evals/cases/routing-contract-first.json +25 -0
  87. package/evals/cases/routing-execution.json +25 -0
  88. package/evals/cases/routing-frontend.json +26 -0
  89. package/evals/cases/routing-gates.json +25 -0
  90. package/evals/cases/routing-git.json +25 -0
  91. package/evals/cases/routing-healing.json +25 -0
  92. package/evals/cases/routing-lessons.json +25 -0
  93. package/evals/cases/routing-orchestration.json +25 -0
  94. package/evals/cases/routing-planning.json +26 -0
  95. package/evals/cases/routing-pr.json +25 -0
  96. package/evals/cases/routing-proof-order.json +25 -0
  97. package/evals/cases/routing-quality.json +25 -0
  98. package/evals/cases/routing-ship.json +26 -0
  99. package/evals/cases/routing-sunset.json +25 -0
  100. package/evals/cases/routing-workflow.json +25 -0
  101. package/evals/floor.json +6 -0
  102. package/package.json +6 -4
  103. package/references/definition-of-done.md +42 -0
  104. package/references/multi-actor.md +44 -0
  105. package/references/skill-versioning.md +44 -0
  106. package/references/source-grounding.md +23 -0
  107. package/references/token-budget.md +34 -0
  108. package/scripts/evidence.sh +37 -0
  109. package/scripts/lane.sh +74 -0
  110. package/scripts/mission-report.sh +88 -0
  111. package/scripts/probe.ts +40 -0
  112. package/scripts/release-notes.ts +65 -0
  113. package/scripts/retrieval-eval.ts +261 -0
  114. package/scripts/run-evals.ts +149 -0
  115. package/scripts/savepoint.sh +166 -0
  116. package/scripts/sync-version.ts +30 -0
  117. package/scripts/validate-content.ts +226 -0
  118. package/src/cli.ts +8 -3
  119. package/src/mission.ts +26 -3
  120. package/content/skills/mugiwara-dynamic-workflow/SKILL.md +0 -90
  121. package/content/skills/mugiwara-eval/SKILL.md +0 -87
  122. package/content/skills/mugiwara-git-worktrees/SKILL.md +0 -67
  123. package/content/skills/mugiwara-mode/SKILL.md +0 -77
  124. package/content/skills/mugiwara-observability/SKILL.md +0 -59
  125. package/content/skills/mugiwara-writing-skills/SKILL.md +0 -65
  126. package/evals/cases/negative-secrets-typo.json +0 -12
  127. package/evals/cases/negative-security-docs-change.json +0 -12
  128. package/evals/cases/routing-typo.json +0 -13
@@ -0,0 +1,88 @@
1
+ # Worked Example — Full TDD Task
2
+
3
+ One task, from failing test to green commit, with real output.
4
+
5
+ ## The plan task
6
+
7
+ ```
8
+ Task 3: extract formatDate to shared utils
9
+ Files: src/utils/format.ts, src/utils/format.test.ts
10
+ Size: S
11
+ Steps:
12
+ [ ] Write failing test for formatDate export
13
+ [ ] Implement formatDate
14
+ [ ] Refactor callers to use shared function
15
+ [ ] Commit
16
+ Acceptance: npm test -- src/utils/format.test.ts passes
17
+ ```
18
+
19
+ ## Step 1: Write failing test (RED)
20
+
21
+ ```ts
22
+ // src/utils/format.test.ts
23
+ import { formatDate } from './format';
24
+
25
+ describe('formatDate', () => {
26
+ it('formats ISO date to locale string', () => {
27
+ const result = formatDate('2026-08-11T12:00:00Z');
28
+ expect(result).toBe('Aug 11, 2026');
29
+ });
30
+
31
+ it('returns "—" for null input', () => {
32
+ expect(formatDate(null)).toBe('—');
33
+ });
34
+ });
35
+ ```
36
+
37
+ ```
38
+ $ npm test -- src/utils/format.test.ts
39
+ FAIL src/utils/format.test.ts
40
+ ● formatDate › formats ISO date to locale string
41
+ TypeError: (0, format_1.formatDate) is not a function
42
+ ```
43
+
44
+ ## Step 2: Implement minimum (GREEN)
45
+
46
+ ```ts
47
+ // src/utils/format.ts — add:
48
+ export function formatDate(iso: string | null): string {
49
+ if (!iso) return '—';
50
+ return new Date(iso).toLocaleDateString('en-US', {
51
+ year: 'numeric', month: 'short', day: 'numeric',
52
+ });
53
+ }
54
+ ```
55
+
56
+ ```
57
+ $ npm test -- src/utils/format.test.ts
58
+ PASS src/utils/format.test.ts
59
+ ✓ formats ISO date to locale string
60
+ ✓ returns "—" for null input
61
+ ```
62
+
63
+ ## Step 3: Refactor callers
64
+
65
+ ```ts
66
+ // Before: src/components/Invoice.tsx
67
+ const date = new Date(invoice.createdAt).toLocaleDateString('en-US', {...});
68
+
69
+ // After:
70
+ import { formatDate } from '@/utils/format';
71
+ const date = formatDate(invoice.createdAt);
72
+ ```
73
+
74
+ ## Step 4: Commit
75
+
76
+ ```
77
+ $ git add src/utils/format.ts src/utils/format.test.ts src/components/Invoice.tsx
78
+ $ git commit -m "feat: extract formatDate to shared utils
79
+
80
+ Test-first: wrote failing test, implemented, refactored callers."
81
+ ```
82
+
83
+ ## What this teaches
84
+
85
+ 1. Test fails **for the right reason** (function doesn't exist), not a typo.
86
+ 2. Minimum implementation passes the test — no gold-plating.
87
+ 3. Refactor while green — callers use the shared function.
88
+ 4. One commit per logical task — not one per micro-step.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-frontend
3
- description: Use for any frontend implementation or redesign task - converting Figma/images to code or restyling UI. Match the repo's existing standard first, audit-first for redesigns, design-system extraction before markup, component architecture, state management, responsive behavior, and WCAG 2.1 AA baked in; bans generic AI-slop patterns and rationalizations. Framework-agnostic.
3
+ description: Use for frontend UI component, CSS styling, responsive layout, a11y/accessible matching repo standards, design-system extraction, WCAG 2.1 AA. Bans AI-slop patterns.
4
4
  ---
5
5
 
6
6
  # Frontend (Anti-Slop)
@@ -12,6 +12,10 @@ description: Use for any frontend implementation or redesign task - converting F
12
12
 
13
13
  Interfaces built under this skill must not look templated.
14
14
 
15
+ ## Source-backed code
16
+
17
+ Framework code from docs, not memory — `references/source-grounding.md`.
18
+
15
19
  ## Existing repo standard first
16
20
 
17
21
  Match the repo's standard before writing anything new; reuse its components and patterns. Greenfield with no UI: skip to design-system extraction.
@@ -100,25 +104,20 @@ Add stable `data-testid` to interactive elements per the repo's testing conventi
100
104
 
101
105
  ## Red flags
102
106
 
103
- - "I'll match the repo later" — the repo standard is the first step, not cleanup.
104
- - "It's accessible enough" — the a11y checklist is all-or-nothing.
105
- - "Tests can find it" — no data-testid means the UI is not testable.
106
107
  - "Optimize when it's slow" — perf regressions ship measured later, rarely.
107
- - "It's client-side, so no security review" — the client is public by definition.
108
- - "New screen, new components" — primitives are the default; bespoke is the exception.
109
- - "Global store for everything" — local state first; lift only what is shared.
108
+ - "It's client-side, so no security review" — client is public by definition.
109
+ - "New screen, new components" — primitives are default; bespoke is exception.
110
+ - "Global store for everything" — local state first; lift only what's shared.
110
111
 
111
112
  ## Common Rationalizations
112
113
 
113
114
  | Excuse | Reality |
114
115
  |--------|---------|
115
- | "The brief calls for a hero trio." | A brief calling for slop is a constraint, not a license — the default stays don't. |
116
- | "It's just a landing page." / "It's a one-off component." | Still verified for responsive and a11y; still follows the design system's tokens and patterns. |
117
- | "Good enough." / "It looks right." | Not done until compared against the reference with deltas listed, at every breakpoint. |
118
- | "Everyone ships this card row." | Popularity is not design; if it's on the slop list, it stays banned. |
116
+ | "The brief calls for a hero trio." | A brief calling for slop is a constraint, not a license. |
117
+ | "It's just a landing page." | Still verified for responsive and a11y at every breakpoint. |
118
+ | "Good enough." | Not done until compared against the reference with deltas listed. |
119
+ | "Everyone ships this card row." | Popularity is not design; banned stays banned. |
119
120
  | "Tokens later." | Tokens extracted before markup, or the layout gets rebuilt. |
120
121
  | "Our repo is messy, I'll use my own style." | Match the repo standard first, then propose raising it. |
121
- | "The user won't use a keyboard." / "Context for everything." | Every interaction keyboard-operable; server state belongs at a data layer, not a global store. |
122
- | "It's a quick prop, no new component." | 3+ boolean props is the boundary — split the component. |
123
122
 
124
- If the rationalization wins, name it in the report as a known delta — not as silence.
123
+ If a rationalization wins, name it in the report as a known delta — not as silence.
@@ -0,0 +1,25 @@
1
+ # Design Tokens
2
+
3
+ Extract from the stack's design system before writing markup. No tokens extracted = no markup written.
4
+
5
+ ## Token categories
6
+
7
+ | Category | Examples | Naming convention |
8
+ |----------|----------|-------------------|
9
+ | Spacing scale | 4, 8, 12, 16, 24, 32, 48, 64 | `space-xs` through `space-3xl` |
10
+ | Type scale | 12, 14, 16, 18, 24, 32, 48 | `text-sm` through `text-display` |
11
+ | Palette | surface, text, border, accent | `surface-muted`, `text-primary`, `border-default` — semantic, not color names |
12
+ | Radii | 2, 4, 8, 12, round | `radius-sm` through `radius-full` |
13
+ | Shadows | elevation levels | `shadow-sm` through `shadow-xl` |
14
+ | Motion | duration, easing | `duration-fast`, `ease-in-out` |
15
+
16
+ ## Where to store
17
+
18
+ - Tailwind: `tailwind.config.ts` extend theme
19
+ - MUI: `createTheme()`
20
+ - CSS: CSS custom properties on `:root`
21
+ - Wherever the repo already keeps tokens — don't invent a second system
22
+
23
+ ## Naming rule
24
+
25
+ Semantic names, not visual: `surface-muted` not `gray-100`, `text-danger` not `red-500`. The name tells you what it IS, not what it LOOKS LIKE. This survives a palette change without renaming.
@@ -0,0 +1,19 @@
1
+ # AI Slop Catalog
2
+
3
+ Banned default patterns. If the brief genuinely calls for one, execute it well — but the default is: don't.
4
+
5
+ ## The list
6
+
7
+ | Pattern | Why banned | What to do instead |
8
+ |---------|-----------|-------------------|
9
+ | Centered hero trio | Headline + subtitle + two buttons, dead center, gradient text | Layout from the design system; hero sections follow repo patterns |
10
+ | Row of 3-4 feature cards | Icon-circle + title + two lines, all identical | Vary layouts; not every section is a card row |
11
+ | Purple/indigo gradient | Everything is gradient, everywhere | Use the design system's palette; gradient is for emphasis, not identity |
12
+ | Glassmorphism everywhere | Frosted glass effect on every surface | Glass is one effect among many; use sparingly on overlays/modals |
13
+ | Emoji as icons | 🚀 ⚡ 🔥 🎯 instead of proper icon library | Use the repo's icon library; emoji only where user-facing text already uses them |
14
+ | Placeholder content | "Lorem ipsum" where real copy exists | Pull real copy from the reference or leave marked with `TODO: copy` |
15
+ | Stock hero illustrations | Generic blob-people or isometric cubes | Use the repo's illustration style or omit; a missing image is better than a wrong one |
16
+
17
+ ## When it IS acceptable
18
+
19
+ If the design brief calls for it (Figma shows a hero trio), implement it faithfully. The ban is on the **default**, not on the request. A brief that specifies a pattern is not slop — it's a requirement.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-gates
3
- description: Use after quality checks to enforce the quality gates - coverage (new >=90%, modified >=80%), build exit 0, and the Definition of Done. Binary verdicts with evidence, no negotiation, no silent pass when tooling is missing.
3
+ description: Use after quality checks coverage thresholds, build exit 0, Definition of Done. Binary verdicts with evidence, no negotiation.
4
4
  ---
5
5
 
6
6
  # Gates (Franky)
@@ -15,12 +15,12 @@ Gates are binary: pass or fail, with evidence. No negotiation.
15
15
  ## Coverage gate
16
16
 
17
17
  1. Measure coverage with the project's existing tooling (jest --coverage, pytest --cov, go test -cover, cargo tarpaulin, etc.).
18
- 2. Thresholds: NEW files >= 90%, MODIFIED files >= 80%. Identify new/modified via git diff against the mission's base.
18
+ 2. **Read thresholds from config.** Read `.mugiwara/config` (project) then `~/.mugiwara/config` (global) for `coverage_new` and `coverage_modified`. Defaults: new files >= 90%, modified files >= 80%. A missing key or a key set to `0` means "no threshold for this category." Identify new/modified via git diff against the mission's base.
19
19
  3. No coverage tooling exists → the gate CANNOT pass silently: report the gap, propose the minimal tooling addition, ask the user to add it or waive the gate explicitly. Record their decision.
20
20
 
21
21
  ## User-AC coverage override (per `mugiwara-testcases`)
22
22
 
23
- When user acceptance criteria are declared, the coverage thresholds (90/80) apply only to unit-level new/modified code; the user-AC verdict governs ship-readiness. An e2e user suite that adds ~0% coverage is not a gate failure. The user-AC verdict must come from the quality wave evidence — user suites actually run — never asserted.
23
+ When user acceptance criteria are declared, config coverage thresholds apply only to unit-level new/modified code; the user-AC verdict governs ship-readiness.
24
24
 
25
25
  ## Build gate
26
26
 
@@ -32,7 +32,7 @@ Position: after quality checks, before the final gates below. Optional — it ru
32
32
 
33
33
  ## Definition of Done standing gate
34
34
 
35
- A fixed cross-project bar, distinct from per-task acceptance criteria. Verdict PASS only when all hold:
35
+ A fixed cross-project bar, distinct from per-task acceptance criteria. Full definitions: `references/definition-of-done.md`. Verdict PASS only when all hold:
36
36
 
37
37
  - Correctness — the work does what the plan specifies.
38
38
  - Quality — lint/format/unit checks clean, configs unweakened.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-git
3
- description: Use when committing, splitting commits, or debugging via git history during execution or healing. Atomic commits, save-points, style detection, bisect.
3
+ description: Use for commits, splitting, or git history debugging atomic commits, save-points, style detection, bisect.
4
4
  ---
5
5
 
6
6
  # Git Discipline (Zoro, Brook)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-healing
3
- description: Use when earlier waves produced failures - test failures, gate failures, review findings, security findings. Reads the .mugiwara/issues ledger first, stop-the-line triage per failure, prove-it before fixing, minimal root-cause fixes, ledger updated with evidence.
3
+ description: Use when earlier waves produced failures, broken things to fix reads blocker ledger, stop-the-line triage, root-cause fixes, prove-it before fixing. Max 3 cycles.
4
4
  ---
5
5
 
6
6
  # Healing (Brook)
@@ -57,15 +57,42 @@ Before fixing a bug: write the failing test that reproduces it, watch it fail, t
57
57
 
58
58
  ## Worker subagents
59
59
 
60
- Brook runs inline; the only dispatches are disposable WORKER subagents for genuinely parallel work. Three named workers:
60
+ Brook runs inline for triage + ledger reading. Parallel fixes use disposable WORKER subagents.
61
61
 
62
- - **reviewer-worker** adversarial diff review of Brook's fixes from a fresh context (per `mugiwara-review`).
63
- - **security-worker** — security pass over the fixes (per `mugiwara-security`).
64
- - **re-run-check worker** — independently re-runs the failed checks and returns raw evidence (command output, exit codes), so the re-verify is not Brook re-confirming its own fix.
62
+ ### Heal workers (parallel fixes)
65
63
 
66
- Flow: Brook aggregates worker findings applies minimal root-cause fixes (triage matrix + Rules above) dispatches a re-run-check worker to re-verify.
64
+ After triage, group ledger rows that are **independent** (different files, no shared function/interface) for parallel healing:
67
65
 
68
- Workers are NOT crew members — disposable subagents, one narrow job, results return as a report. The crew itself always runs inline in the main thread, never Task-dispatched.
66
+ ```
67
+ Ledger: 4 rows
68
+ ├─ Row 1: T3 settings POST guard missing → src/routes/settings.ts
69
+ ├─ Row 2: T5 formatDate locale bug → src/utils/format.ts
70
+ ├─ Row 3: review minor: error msg wording → src/middleware/rbac.ts
71
+ ├─ Row 4: coverage: add test for edge case → src/routes/users.test.ts
72
+
73
+ Group 1 [PARALLEL]: Row 1 (settings.ts) + Row 2 (format.ts) + Row 4 (users.test.ts)
74
+ → 3 files, no shared surface → 3 heal workers parallel
75
+ Group 2 [SEQUENTIAL]: Row 3 (rbac.ts)
76
+ → shares interface with Row 1 (middleware) → after Group 1
77
+ ```
78
+
79
+ Each heal worker receives a prompt with 5 fields:
80
+ - **FAILURE** — ledger row verbatim (wave, task, symptom, attempted)
81
+ - **ROOT CAUSE** — Brook's triage result: where the bug is, why it happened
82
+ - **FIX** — what to change, which file, which function
83
+ - **MUST DO** — Prove-It: write regression test, watch it fail, implement fix, watch it pass, commit
84
+ - **MUST NOT** — files outside scope, drive-by refactor, delete/weaken tests
85
+
86
+ ### Validation workers (verify)
87
+
88
+ After all heal workers complete, dispatch validation workers in parallel:
89
+ - **reviewer-worker** — adversarial diff review from fresh context (per `mugiwara-review`)
90
+ - **security-worker** — security pass over fixes (per `mugiwara-security`)
91
+ - **re-run-check worker** — independently re-runs failed checks, returns raw evidence
92
+
93
+ Flow: Brook triage + grouping → dispatch heal workers parallel → aggregate results → dispatch validation workers → update ledger → back to Wave 4.
94
+
95
+ Workers are NOT crew members — disposable subagents, one narrow job per worker. Crew runs inline in main thread.
69
96
 
70
97
  ## Output
71
98
 
@@ -0,0 +1,23 @@
1
+ # Failure Taxonomy
2
+
3
+ Classification for healing triage. Matches Brook's triage matrix.
4
+
5
+ ## Categories
6
+
7
+ | Category | Signal | Action |
8
+ |----------|--------|--------|
9
+ | **test-fail** | Test, lint, or build command fails with specific error | Reproduce → localize → reduce → fix root cause + guard test |
10
+ | **missing-impl** | Acceptance criterion unverifiable, artifact absent | Check if task was skipped; if not, implement the missing piece |
11
+ | **parallel-conflict** | Two tasks modified the same file concurrently | Serialize, merge the changes, re-verify |
12
+ | **env** | Failure reproduced only in specific environment | Mark env, do not patch code. Note for rerun. Must be proven on clean checkout |
13
+ | **regression** | Previously passing check now fails | git bisect to find breaking commit, fix root cause |
14
+ | **type-error** | TypeScript/mypy/pyright fails on changed code | Fix at root cause, grep all callers, re-run typecheck |
15
+ | **flaky** | Intermittent failure, random seed | Identify race condition or timing dependency. Retry N times. Mark flaky only after proving non-determinism |
16
+
17
+ ## Proven-env rule
18
+
19
+ A failure classified `env` must be reproducible on a clean checkout in the same environment OR must fail only on one OS/CI. "Probably env" is not proof — it stays as code failure until proven otherwise.
20
+
21
+ ## Escalation
22
+
23
+ After 3 heal cycles on the same failure → stop. Escalate to human with full repro, attempted fixes, and root-cause hypothesis.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-lessons
3
- description: Use at mission end or before starting work in a repo the crew has worked in before - read and write the accumulated lessons ledger so each mission stands on the previous ones.
3
+ description: Use at mission start/end cross-mission lessons ledger. Read past lessons at triage, capture new ones at closure. Append-only.
4
4
  ---
5
5
 
6
6
  # Lessons (Mission Memory)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-orchestration
3
- description: Use to triage a new mission at the gateway, classify requests 5 ways, coordinate wave transitions, answer inter-agent escalations, split work, and close a mission. Captain behavior - triage, check-ins, decisions, closure. Never implements code.
3
+ description: Use to triage a new mission 5-way classify, coordinate waves, lane sizing, check-ins, closure. Captain; never implements code.
4
4
  ---
5
5
 
6
6
  # Orchestration (Luffy)
@@ -18,7 +18,7 @@ The plan doc (`.mugiwara/plans/YYYY-MM-DD-<mission>.md`) is Nami's clean executi
18
18
 
19
19
  ## Mode read (Wave 0)
20
20
 
21
- Read the runtime mode via `mugiwara-mode` at Wave 0: `.mugiwara/config` (project) then `~/.mugiwara/config` (global); a key missing from both = `guided`. Record the active mode in the decision log. Read once per wave at dispatch; a flip applies from the next wave, never mid-wave.
21
+ Read the runtime mode via mode config at Wave 0: `.mugiwara/config` (project) then `~/.mugiwara/config` (global); a key missing from both = `guided`. Record the active mode in the decision log. Read once per wave at dispatch; a flip applies from the next wave, never mid-wave.
22
22
 
23
23
  Alongside the config, read the declared test source (per `mugiwara-testcases`): a path glob from the mission prompt or an explicit repo path. Record it in the decision log like the mode config. No source declared → no user tests for the mission.
24
24
 
@@ -57,7 +57,7 @@ After every wave AND at the end of each execution batch, verify:
57
57
  3. Heal-loop counters within bounds (max 3 cycles).
58
58
  4. Blocker ledger `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md` reviewed; every row has an owner or a path forward.
59
59
 
60
- By mode (per `mugiwara-mode`): `guided` checks in with the user as today; `semi`/`auto` write the check-in verdicts to the decision log without pausing the pipeline.
60
+ By mode (per mode config): `guided` checks in with the user as today; `semi`/`auto` write the check-in verdicts to the decision log without pausing the pipeline.
61
61
 
62
62
  On drift: stop, diagnose with Chopper's ledger, decide continue / retry / escalate to human.
63
63
 
@@ -79,7 +79,7 @@ Recognize the in-session phrase `mugiwara mode <guided|semi|auto>`: write the pr
79
79
 
80
80
  ## Closure (Wave 9)
81
81
 
82
- Gate — every task's acceptance criteria verified, every gate passed, findings resolved or explicitly deferred with an owner, blocker ledger reviewed, unused intermediate markdown files deleted. Write the closure report to `.mugiwara/results/YYYY-MM-DD-<mission>-closure.md`: mission summary, per-wave outcomes, deferred items, lessons learned. The plan doc stays untouched.
82
+ Gate — every task's acceptance criteria verified, every gate passed, findings resolved or explicitly deferred with an owner, blocker ledger reviewed, unused intermediate markdown files deleted. Run `scripts/savepoint.sh <mission>` to write final state, then `scripts/mission-report.sh <mission>` to generate the mission report at `.mugiwara/reports/<mission>.md`. Write the closure summary to `.mugiwara/results/YYYY-MM-DD-<mission>-closure.md`. The plan doc stays untouched.
83
83
 
84
84
  ### Detailed closure summary (mandatory, inline)
85
85
 
@@ -93,7 +93,7 @@ Present a detailed summary to the user — never a one-liner:
93
93
  - Deferred items + owner.
94
94
  - Next steps — PR material pointer, anything the user must do.
95
95
 
96
- ### Terminal step (every mode, per `mugiwara-mode`)
96
+ ### Terminal step (every mode, per mode config)
97
97
 
98
98
  Save-point commit → push the mission branch (per the config `branch` key, default `feature/{type}-{issue}-{slug}`) with plain `git push -u origin <branch>` → write `.mugiwara/results/YYYY-MM-DD-<mission>-pr-verdict.md` per the `mugiwara-pr` format (includes a ready PR summary block) → hand the branch + verdict file to the user, who opens the PR. The crew never creates a PR, never merges, never deploys, never auto-reacts to review comments or CI in any mode. On push failure (no auth / no remote), fall back to the local closure report and log the reason.
99
99
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-planning
3
- description: Use when turning an approved idea or spec into an execution plan. Classifies mission size, interviews first, scans full context, writes scaled Quick/Standard/Full plans with the unified task template, parallel-proof waves, per-task acceptance, and risk/rollback.
3
+ description: Use for turning an approved spec into an implementation plan interview-first, full context scan, scaled Quick/Standard/Full plans, parallel-proof waves.
4
4
  ---
5
5
 
6
6
  # Planning (Nami)
@@ -24,7 +24,7 @@ Classify the mission by size first — after Luffy's route — then write the pl
24
24
 
25
25
  Batch ALL blocking ambiguities into ONE question round before writing. If a major decision appears mid-plan, stop and ask then — never assume silently. Unanswered question goes back to Luffy, never forward to Zoro. Read the mission spec at `.mugiwara/spec/YYYY-MM-DD-<mission>.md` (the Wave 0/1 bridge); if none exists, return to Luffy for the spec bridge or brainstorm — never plan from an empty spec, that is fiction.
26
26
 
27
- ## Mode (per `mugiwara-mode`)
27
+ ## Mode (per mode config)
28
28
 
29
29
  - `guided`: batch ONE question round, wait for answers, then present the plan for an explicit user GO — current behavior.
30
30
  - `semi`: self-answer non-blocking ambiguities + log them in the decision log; still present the plan for user GO.
@@ -0,0 +1,17 @@
1
+ # Planning Anti-Patterns
2
+
3
+ Patterns that fail the quality bar. Every one means: fix the plan before handoff.
4
+
5
+ | Anti-pattern | Why it fails | Fix |
6
+ |-------------|-------------|-----|
7
+ | "TBD" in a step | Leaves executor guessing | Fill in the exact command or file path |
8
+ | "add appropriate error handling" | Vague, uncheckable | Specify: "wrap in try/catch, log with context, return 500" |
9
+ | "similar to Task N" | Assumes executor has context | Write the full task out |
10
+ | No file paths | Executor invents paths | Name exact files: create/modify `src/auth/login.ts` |
11
+ | "works correctly" acceptance | Unverifiable | Command: `npm test -- auth/login.test.ts` |
12
+ | `[PARALLEL]` without proof | Race conditions | State disjoint files + no shared interface in wave header |
13
+ | Missing `depends-on` edge | Execution order wrong | `depends-on: Task M (file: src/types.ts)` |
14
+ | No Break point on 8+ file task | Unreviewable commit | Split into 2 tasks at natural seam |
15
+ | Gold-plating | Speculative features | Cut to minimum that satisfies acceptance |
16
+ | No rollback on high-risk task | Can't undo if it fails | Add: "revert commit X, re-deploy" |
17
+ | "Executor will figure it out" | Fiction — wave stalls or ships wrong | Write the plan so a zero-context engineer can execute |
@@ -0,0 +1,46 @@
1
+ # Plan Template
2
+
3
+ Scaled plan skeleton. Nami picks Quick/Standard/Full based on mission size.
4
+
5
+ ## Quick (1 task, ≤2 files)
6
+
7
+ ```markdown
8
+ # <mission> — <goal>
9
+
10
+ ## Key decisions
11
+ <why this approach>
12
+
13
+ ## Waves
14
+
15
+ | Wave | Focus | Tasks | Gate |
16
+ |------|-------|-------|------|
17
+ | 3 | <what> | T1 | <command-verifiable exit check> |
18
+
19
+ ## Task index
20
+
21
+ | # | Task | Files | Size | Depends-on | Acceptance |
22
+ |---|------|-------|------|------------|------------|
23
+ | T1 | <title> | <paths> | S | — | <one-line check> |
24
+
25
+ ## Detail: T1 — <title>
26
+ - Files: <exact paths>
27
+ - Steps: [ ] <test → impl → verify>
28
+ - Acceptance: <command>
29
+ - Risk: none
30
+ ```
31
+
32
+ ## Standard (1 wave, 2-8 tasks)
33
+
34
+ Add: Architecture overview, Context scan, Implementation graph, Acceptance per task.
35
+
36
+ ## Full (multi-wave, parallel, risk)
37
+
38
+ Add all of Standard + Key decisions, Project structure, Risk & rollback, Definition of Done.
39
+
40
+ ## Anti-patterns to avoid
41
+
42
+ - "TBD" or "add appropriate error handling" in a step.
43
+ - No file paths, or Acceptance like "works correctly" (uncheckable).
44
+ - `[PARALLEL]` without file- AND interface-disjoint proof.
45
+ - High-risk task with no rollback plan.
46
+ - Vague plan expecting the executor to figure it out.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-pr
3
- description: Use at closure to push the mission branch and prepare the PR material - one provider-agnostic verdict file with a ready-to-paste PR summary block. Plain git push, no gh CLI, no PR creation, no auto-reaction to review comments or CI in any mode.
3
+ description: Use at closure to push branch + prepare PR material plain git push, verdict file with ready PR summary. Never creates PR, merges, or deploys.
4
4
  ---
5
5
 
6
6
  # PR Handoff (CI/CD Loop)
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: mugiwara-test-driven-development
3
- description: Use when writing code during execution - RED-GREEN-REFACTOR discipline, proof-of-when over proof-of-exists, test pyramid shape, one test = one behavior, assert real behavior over mocks, refactor while green. Referenced by zoro-execution; complements mugiwara-testcases (user AC intake) - this is the executor's TDD contract.
2
+ name: mugiwara-proof-order
3
+ description: Use when writing code TDD, RED-GREEN-REFACTOR, test-driven. Proof value from WHEN the test runs, not that it exists. One test = one behavior.
4
4
  ---
5
5
 
6
6
  # Test-Driven Development
@@ -0,0 +1,62 @@
1
+ # Proof Order Examples
2
+
3
+ The test's proof value comes from WHEN it runs, not that it exists.
4
+
5
+ ## Why order matters
6
+
7
+ ```
8
+ ❌ Write implementation → Write test → Test passes immediately
9
+ The test never demonstrated it could catch the bug.
10
+ You cannot prove the test is testing the right thing.
11
+
12
+ ✅ Write test (red) → Watch it fail → Write implementation → Test passes (green)
13
+ The red phase proves the test catches the absence of the feature.
14
+ The green phase proves the feature satisfies the test.
15
+ ```
16
+
17
+ ## Example: password validation
18
+
19
+ ```ts
20
+ // RED — test first, watch it fail
21
+ describe('validatePassword', () => {
22
+ it('rejects passwords shorter than 8 characters', () => {
23
+ expect(validatePassword('short')).toBe(false);
24
+ });
25
+ });
26
+
27
+ // FAIL: validatePassword is not defined
28
+
29
+ // GREEN — minimal impl
30
+ function validatePassword(pw: string): boolean {
31
+ return pw.length >= 8;
32
+ }
33
+
34
+ // REFACTOR — while green
35
+ function validatePassword(pw: string): boolean {
36
+ if (pw.length < 8) return false;
37
+ if (!/[A-Z]/.test(pw)) return false;
38
+ if (!/[0-9]/.test(pw)) return false;
39
+ return true;
40
+ }
41
+ ```
42
+
43
+ ## Anti-pattern: test after implementation
44
+
45
+ ```ts
46
+ // Code already written, then test added later:
47
+ function formatCurrency(amount: number): string {
48
+ return `$${amount.toFixed(2)}`;
49
+ }
50
+
51
+ // Test passes immediately — proves nothing:
52
+ it('formats currency', () => {
53
+ expect(formatCurrency(10)).toBe('$10.00'); // green on first run
54
+ });
55
+ ```
56
+
57
+ The fix: comment out the implementation, watch the test fail, then uncomment.
58
+ If the test still passes with implementation removed, the test is wrong.
59
+
60
+ ## Rule
61
+
62
+ A test that passes on first run has proven nothing. Discard the implementation and redo test-first, or comment it out and prove the test actually fails before restoring.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-quality
3
- description: Use after checkpoint passes to run code quality checks - formatter, linter, unit tests, and with recorded user consent integration tests. Detects the project's real tooling first, never weakens configs to pass.
3
+ description: Use after checkpoint passes formatter, linter, eslint, prettier, lint, format, unit tests, test suite. Discovers project tooling, never weakens configs.
4
4
  ---
5
5
 
6
6
  # Quality (Sanji)
@@ -41,9 +41,9 @@ Optional, never default-on. Trigger ONLY when BOTH hold:
41
41
  - Repo has e2e setup — any of `playwright.config.*`, `cypress.config.*`, `e2e/` dir, `test:e2e` npm script.
42
42
  - Changed/staged files match e2e patterns — `e2e/**`, `*.e2e.*`, `specs/**`.
43
43
 
44
- When triggered, consent by mode (per `mugiwara-mode` invariant): `guided`/`semi` ask first — run now / skip / run manually later; `auto` runs only provably-isolated e2e (in-memory / local / tooling-proven isolation). Otherwise skip-and-log: record the skip reason (no setup, no matching files, no consent) in the report. The e2e gate never blocks silently and never blocks a pass — a skip is logged, not a failure.
44
+ When triggered, consent by mode (per mode config invariant): `guided`/`semi` ask first — run now / skip / run manually later; `auto` runs only provably-isolated e2e (in-memory / local / tooling-proven isolation). Otherwise skip-and-log: record the skip reason (no setup, no matching files, no consent) in the report. The e2e gate never blocks silently and never blocks a pass — a skip is logged, not a failure.
45
45
 
46
- ## Mode + consent (per `mugiwara-mode`)
46
+ ## Mode + consent (per mode config)
47
47
 
48
48
  Consent is an invariant, not a mode knob. State-mutating tests against NON-isolated / shared state (real DB writes, network, browsers) ALWAYS require explicit user consent in ALL modes. Provably-isolated mutation — in-memory / temp / testcontainer-backed DBs, tooling-proven isolation — is explicitly auto-safe and needs no consent. `auto` runs only provably-isolated tests automatically (unit-level, or tooling-proven isolation such as in-memory / local DB). `guided`/`semi`: integration tests keep the existing ask-first rule — run automatically now / skip / run manually later. Record every consent answer in the report.
49
49