@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
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-resume
3
- description: Use when a mission is interrupted, context is lost or compacted, or a new session starts mid-mission - rebuild the full picture from .mugiwara/ state and continue from the exact point, never restart.
3
+ description: Use when mission interrupted, context lost, or new session mid-mission rebuild from .mugiwara/state.json, continue never restart.
4
4
  ---
5
5
 
6
6
  # Session Resume (Never Start Over)
@@ -10,47 +10,58 @@ description: Use when a mission is interrupted, context is lost or compacted, or
10
10
  - Fresh mission: no `.mugiwara/` state exists to rebuild from.
11
11
  - No interruption, compaction, or new-session-mid-mission happened.
12
12
 
13
- The host AI can lose context — compaction, a new session, a crash. Disk state under `.mugiwara/` is the single source of truth. Rebuild the picture from disk, continue from the exact point, never restart.
14
-
15
- ## The state contract
16
-
17
- What survives on disk and drives resume:
18
-
19
- | File | Holds |
20
- |------|-------|
21
- | `.mugiwara/plans/YYYY-MM-DD-<mission>.md` | waves, tasks, acceptance criteria (clean plan) |
22
- | `.mugiwara/results/<mission>-todos.md` | checkbox per task, checked = done with evidence |
23
- | `.mugiwara/results/<mission>-trace.md` | every dispatch, outcome |
24
- | `.mugiwara/issues/YYYY-MM-DD-<mission>-blockers.md` | blocker rows with owners / heal state |
25
- | `.mugiwara/logs/YYYY-MM-DD-<mission>.md` | Luffy's decision + check-in log |
26
- | `.mugiwara/config` | current mode (project); `~/.mugiwara/config` = global default; per-mission override rows live in the decision log |
13
+ The host AI can lose context — compaction, new session, crash. Disk state is truth. Rebuild from one file, continue from exact point, never restart.
14
+
15
+ ## State contract
16
+
17
+ Resume reads one file: `.mugiwara/state.json`. All position data is computed at every wave boundary by `scripts/savepoint.sh`.
18
+
19
+ ```json
20
+ {
21
+ "mission": "2026-08-11-invitation-accepted",
22
+ "actor": "farid",
23
+ "branch": "feature/feat-MKR-412",
24
+ "lane": "full",
25
+ "lane_reason": "auth/ path touched",
26
+ "wave": 5,
27
+ "mode": "guided",
28
+ "base_sha": "a3f1c2e",
29
+ "files_touched": 11,
30
+ "loc_delta": 340,
31
+ "sensitive_paths": ["src/auth/invitation.ts"],
32
+ "tasks": { "done": 7, "total": 12 },
33
+ "blockers_open": 1,
34
+ "heal_cycle": 1,
35
+ "tokens_est": 14200,
36
+ "budget": 20000,
37
+ "evidence": [".mugiwara/results/wave4-audit.md"],
38
+ "updated_at": "2026-08-11T12:40:00Z"
39
+ }
40
+ ```
27
41
 
28
42
  ## Resume protocol
29
43
 
30
- Read in this order, then act:
31
-
32
- 1. Plan doc → current wave, remaining tasks.
33
- 2. Todos done/undone (unchecked box = not done, regardless of memory).
34
- 3. Trace last completed step, last outcome.
35
- 4. Blocker ledger → open rows (they have owners / are mid-heal).
36
- 5. Config → the mode. Read `.mugiwara/config` (project) then `~/.mugiwara/config` (global) before re-deriving position; missing = `guided`. If a per-mission override row exists in the decision log (`.mugiwara/logs/YYYY-MM-DD-<mission>.md`), that level wins over the config file for this mission.
37
- 6. Re-derive position: wave N, tasks remaining, open blockers, heal counter, and the resumed mode.
38
- 7. State it in one line: "Resumed: Wave 5, tasks 5.3-5.7 pending, 1 blocker (env), heal counter 1, mode semi." Then CONTINUE — do not re-verify completed waves unless the trace shows a failure.
44
+ 1. Read `.mugiwara/state.json`. If absent, this is a fresh mission — no resume needed.
45
+ 2. Derive position from fields: wave N, tasks done/total, blockers open, heal cycle, mode.
46
+ 3. If `state.json` is stale or corrupted, fall back to legacy files: plan doc → todos trace → blocker ledger → config. Then write a fresh `state.json`.
47
+ 4. State it: "Resumed: Wave 5, 7/12 tasks, 1 blocker, heal cycle 1, mode guided."
48
+ 5. Continue do not re-verify completed waves.
39
49
 
40
50
  ## Rules
41
51
 
42
52
  1. Never trust memory over disk — disk is truth.
43
- 2. Never re-run completed work — the trace proves it.
53
+ 2. Never re-run completed work — state.json proves it.
44
54
  3. Never skip the resume read — guessing position = drift.
45
- 4. If disk state is missing/contradictory escalate to Luffy to reconcile, do not invent state.
55
+ 4. If state.json is absent and no legacy files exist → fresh mission, escalate to Luffy.
46
56
 
47
- ## Writing discipline
57
+ ## Rationalizations
48
58
 
49
- Update todos/trace AFTER every task, not at the end. Resume quality is proportional to log freshness. A stale log makes the next resume guess.
59
+ - "I remember where we were" memory lies after compaction; disk is truth.
60
+ - "Re-running is safer" → wastes the mission; trust state.json.
61
+ - "I'll update state later" → savepoint.sh runs at every wave boundary; state is always current.
50
62
 
51
- ## Rationalizations + red flags
63
+ ## Red flags
52
64
 
53
- - "I remember where we were" memory lies after compaction; disk is truth.
54
- - "Re-running is safer" wastes the mission; trust the trace.
55
- - "I'll update todos later" later never comes; resume breaks.
56
- - Red flags: reading any file out of order, re-doing a wave the trace shows complete, skipping the blocker ledger, inventing state instead of escalating, a resume position stated without citing the files.
65
+ - Resume position stated without citing state.json or legacy files.
66
+ - Re-doing a wave state.json shows complete.
67
+ - Inventing state instead of escalating when files are missing.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-review
3
- description: Use after quality gates pass to review the diff adversarially - doubt-driven review, breaking-change damage map via repo-wide caller mapping first, five-axis review with regression emphasis, sonar smells, severity criteria, dispute hierarchy, docs gaps. Findings to .mugiwara/review/. Max 3 cycles then escalate.
3
+ description: Use after gates pass to review PR diff, code review breaking-change map via caller mapping, five-axis review, severity-tagged findings. Max 3 cycles.
4
4
  ---
5
5
 
6
6
  # Review (Robin)
@@ -0,0 +1,36 @@
1
+ # Five-Axis Review Worksheet
2
+
3
+ One verdict + evidence per axis. No axis passes on assertion.
4
+
5
+ ## Axes
6
+
7
+ | Axis | Question | Evidence required |
8
+ |------|----------|-------------------|
9
+ | Correctness | Does the change break anything that currently works? | Re-run caller tests, verify edge cases |
10
+ | Readability | Can a new team member understand the diff in 5 minutes? | Naming convention check, function length, comment quality |
11
+ | Architecture | Does the change fit the existing system structure? | No parallel patterns, no new abstraction without need |
12
+ | Security | Any security regression or new attack surface? | STRIDE on changed surface, checklist pass |
13
+ | Performance | Any N+1, O(n²), or unbounded resource use introduced? | Profiler output or manual analysis of hot path |
14
+
15
+ ## Example
16
+
17
+ ```
18
+ Axis: Correctness
19
+ Verdict: PASS
20
+ Evidence: npm test -- --shard=1/2 passes (312 tests), caller grep confirms all
21
+ imports of renamed function updated
22
+ ```
23
+
24
+ ```
25
+ Axis: Security
26
+ Verdict: FAIL
27
+ Evidence: New endpoint POST /api/export has no authz middleware. Missing rate
28
+ limit on file generation (DoS risk).
29
+ ```
30
+
31
+ ## Rules
32
+
33
+ - One verdict per axis. "Partial pass" = FAIL.
34
+ - Evidence is command output or file path, never a paraphrase.
35
+ - FAIL on any axis → overall review FAIL → Brook (Wave 8).
36
+ - PASS on all 5 → forward to closure.
@@ -0,0 +1,20 @@
1
+ # Severity Rubric
2
+
3
+ For review findings. Every finding gets a severity backed by criteria.
4
+
5
+ | Severity | Definition | Examples | Action |
6
+ |----------|-----------|----------|--------|
7
+ | **blocker** | public-break with no migration path, wrong behavior shipped, security hole | renamed public API with callers unfixed, authz bypass, data loss | Fix before merge |
8
+ | **major** | internal-break with callers unfixed, missed contract, behavior change outside declared scope | changed function signature, missing error handling, N+1 in hot path | Fix this mission |
9
+ | **minor** | polish, style drift, batched items | inconsistent naming, missing test for edge case, duplicated 3-line helper | May batch with Brook |
10
+
11
+ ## CVSS-style for security
12
+
13
+ | Severity | Exploitability × Impact |
14
+ |----------|------------------------|
15
+ | Critical | Reachable + tooling exists + pre-auth → data loss/auth bypass/RCE |
16
+ | High | Reachable + limited tooling → PII leak, privilege escalation |
17
+ | Medium | Requires auth/conditions → partial exposure |
18
+ | Low | Defense-in-depth gaps, no known exploit path |
19
+
20
+ Security findings are never "minor by default." Every finding gets the matrix.
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: mugiwara-systematic-debugging
3
- description: Use when any agent or worker hits a failure and must debug it - a bug, a test that fails for an unknown reason, a crash, a wrong result, or an unexplained regression. A standalone 4-phase discipline - reproduce, localize, reduce, fix + guard. Stop-the-line on failures, prove-it before fixing, rollback prep before a risky fix.
2
+ name: mugiwara-root-cause
3
+ description: Use for debugging bugs debug, bug, crash, error, recurring, intermittent, track it down. 4-phase: reproduce, localize, reduce, fix+guard. Root cause hunt.
4
4
  ---
5
5
 
6
6
  # Systematic Debugging
@@ -16,6 +16,8 @@ A failure is a stopping event, not a speed bump. Do not guess, do not patch. Wal
16
16
 
17
17
  Any bug, unexplained failure, crash, or regression in code, tests, or config. When the cause is unknown, the fix is not obvious, or the failure is intermittent. Standalone discipline — use it before any fix ships, and escalate when a phase cannot complete.
18
18
 
19
+ Framework code from docs, not memory: `references/source-grounding.md`.
20
+
19
21
  ## Process
20
22
 
21
23
  ### Phase 1 — Reproduce
@@ -0,0 +1,71 @@
1
+ # Four-Phase Debugging — Worked Example
2
+
3
+ A real bug traced end to end through reproduce → localize → reduce → fix + guard.
4
+
5
+ ## The bug report
6
+
7
+ ```
8
+ Title: Users see "null" instead of display name on profile page
9
+ Severity: medium
10
+ Reported: Aug 2026
11
+ ```
12
+
13
+ ## Phase 1 — Reproduce
14
+
15
+ ```bash
16
+ # Create user with no displayName
17
+ $ curl -X POST /api/users -d '{"email":"test@ex.com"}'
18
+ {"id": "u_42", "email": "test@ex.com"}
19
+
20
+ # Fetch profile
21
+ $ curl /api/users/u_42
22
+ {"id": "u_42", "displayName": "null", "email": "test@ex.com"}
23
+ ```
24
+
25
+ Expected: `displayName` should be `null` (JSON null) or omitted, not string `"null"`.
26
+
27
+ ## Phase 2 — Localize
28
+
29
+ ```bash
30
+ $ git grep -n 'displayName' src/
31
+ src/models/user.ts:12: displayName?: string | null;
32
+ src/services/user-profile.ts:34: return user.displayName ?? 'null';
33
+ ```
34
+
35
+ Bug at `src/services/user-profile.ts:34`: `?? 'null'` is the string `"null"`, not the JavaScript `null` value. The default should be `null` or `undefined`.
36
+
37
+ ## Phase 3 — Reduce
38
+
39
+ ```ts
40
+ // Before (broken):
41
+ return user.displayName ?? 'null'; // string "null"!
42
+
43
+ // Minimal reproduction:
44
+ const result = undefined ?? 'null'; // "null" — this is a string
45
+ ```
46
+
47
+ The `??` operator returns the right operand only when the left is `null`/`undefined`. But `'null'` is a truthy string — it's never the `null` value.
48
+
49
+ ## Phase 4 — Fix + Guard
50
+
51
+ ```ts
52
+ // Fix:
53
+ return user.displayName ?? null; // JSON null
54
+
55
+ // Guard test:
56
+ it('returns null for missing displayName, not string "null"', () => {
57
+ const user = { id: 'u_42', email: 'test@ex.com' };
58
+ const profile = buildProfile(user);
59
+ expect(profile.displayName).toBeNull(); // was: toBe('null')
60
+ });
61
+ ```
62
+
63
+ ```
64
+ $ npm test -- user-profile.test.ts
65
+ PASS user-profile.test.ts
66
+ ✓ returns null for missing displayName, not string "null"
67
+ ```
68
+
69
+ ## Lesson
70
+
71
+ String `"null"` ≠ JavaScript `null`. The `??` operator with a string default is almost always a bug. Grep the codebase: `git grep "?? '"` to find similar patterns.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-security
3
- description: Use for the security audit of a diff or system - STRIDE threat model first, OWASP Top 10 mapping, full checklist in order (secrets, injection, authn/authz, data exposure, dependencies, deserialization, crypto), security-regression and cross-cutting impact checks, untrusted-data doctrine, CVSS-style severity. Findings to .mugiwara/review/.
3
+ description: Use for security audit of a diff STRIDE, OWASP Top 10, secrets, injection, authn/authz, authorization, RBAC, roles, permissions, dependency audit. Findings to .mugiwara/review/.
4
4
  ---
5
5
 
6
6
  # Security (Jinbe)
@@ -0,0 +1,30 @@
1
+ # OWASP Top 10 Mapping
2
+
3
+ Required when the project handles payments, health data, or PII.
4
+
5
+ | Code | Category | Review area |
6
+ |------|----------|-------------|
7
+ | A01 | Broken access control | authz gaps, IDOR, missing server-side checks |
8
+ | A02 | Cryptographic failures | PII in transit/at rest, weak crypto, exposed secrets |
9
+ | A03 | Injection | SQL/NoSQL/OS/template injection, unsanitized input to exec/render |
10
+ | A04 | Insecure design | missing threat model, trust-boundary failures |
11
+ | A05 | Misconfiguration | default creds, verbose errors, permissive headers, debug on |
12
+ | A06 | Vulnerable components | dependency audit, known-vuln check, outdated libs |
13
+ | A07 | Authn failures | broken sessions, brute-forceable login, credential reuse |
14
+ | A08 | Integrity | insecure deserialization, supply-chain tamper |
15
+ | A09 | Logging/monitoring | PII in logs, missing audit trail, silent failures |
16
+ | A10 | SSRF | server-side requests to attacker-controlled targets, URL validation |
17
+
18
+ ## How to map
19
+
20
+ For each security check run, record which OWASP category it covers. A handled
21
+ category with no mapping row = documentation gap in the security report.
22
+
23
+ ```
24
+ | OWASP | Check | Verdict |
25
+ |-------|-------|---------|
26
+ | A01 | Authz on /api/admin routes | PASS |
27
+ | A02 | TLS enforced, no hardcoded secrets | PASS |
28
+ | A03 | SQL params in user query handler | PASS |
29
+ | A06 | npm audit: 0 critical/high | PASS |
30
+ ```
@@ -0,0 +1,37 @@
1
+ # STRIDE Worksheet
2
+
3
+ Map every application surface to STRIDE before running security checks.
4
+
5
+ ## Surface inventory
6
+
7
+ List every surface where data, requests, or state cross trust levels:
8
+
9
+ - HTTP endpoints (REST, GraphQL, gRPC)
10
+ - CLI arguments and environment variables
11
+ - File uploads, database reads/writes
12
+ - External API calls, webhooks
13
+ - Rendered output (HTML, JSON, logs)
14
+ - Config files, secret stores
15
+
16
+ ## STRIDE per surface
17
+
18
+ | STRIDE | Ask of each surface |
19
+ |--------|---------------------|
20
+ | Spoofing | Can an identity be forged or impersonated? |
21
+ | Tampering | Can data in transit or at rest be altered undetected? |
22
+ | Repudiation | Can an action occur without a traceable actor? |
23
+ | Info disclosure | Can data leak to an unintended party? |
24
+ | DoS | Can the surface be exhausted or taken down? |
25
+ | Elevation | Can a caller gain privileges beyond their grant? |
26
+
27
+ ## Example
28
+
29
+ | Surface | S | T | R | I | D | E | Notes |
30
+ |---------|---|---|---|---|---|---|-------|
31
+ | POST /api/invite | ✅ | ✅ | — | ⚠️ | — | ✅ | Email exposed in error response |
32
+ | GET /api/users/:id | ✅ | — | — | ⚠️ | — | ✅ | IDOR: no ownership check |
33
+ | config upload | — | ✅ | — | — | — | — | YAML parsing, no schema validation |
34
+
35
+ ✅ = threat present, ⚠️ = partial mitigation, — = not applicable
36
+
37
+ A surface with no STRIDE row is a modeling gap, not a safe surface.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-ship
3
- description: Use at mission end or before any release to run the ship gate - pre-launch checklist, feature flags, staged rollout, mandatory rollback plan. Binary GO/NO-GO verdict with evidence.
3
+ description: Use at mission end pre-launch checklist, feature flags, staged rollout, mandatory rollback plan. Binary GO/NO-GO.
4
4
  ---
5
5
 
6
6
  # Ship Gate (Luffy, Franky)
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: mugiwara-deprecation
3
- description: Use when retiring code, APIs, or features that no longer justify their upkeep, or when steering users off one implementation onto another. Sunset criteria, safe DB migrations, phased cutovers, orphaned code. Every removal needs a plan and a tested way back.
2
+ name: mugiwara-sunset
3
+ description: Use when removing, deleting, deprecating old code, legacy APIs, v1 endpoints keep-or-retire gate, safe DB migrations, phased cutovers. Every removal needs a plan.
4
4
  ---
5
5
 
6
6
  # Deprecation & Migration (Brook)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-testcases
3
- description: Use when a mission declares user-provided test cases or acceptance criteria - intake formats, immutable-gold rule, declarative-AC routing, consent, and failure adjudication. Single home for the ATDD contract; referenced by the quality and gates agents.
3
+ description: Use when mission declares user test cases, e2e, playwright, cypress, integration tests — intake formats, immutable-gold rule, consent, failure adjudication.
4
4
  ---
5
5
 
6
6
  # Test Cases (ATDD Contract)
@@ -0,0 +1,42 @@
1
+ # Test Intake Formats
2
+
3
+ Single home for the ATDD contract. Referenced by `mugiwara-quality` and `mugiwara-gates`.
4
+
5
+ ## Format 1: Executable tests (user test files)
6
+
7
+ ```
8
+ Path: tests/acceptance/invitation-flow.test.ts
9
+ Type: integration
10
+ Commands: npm run test:acceptance -- invitation-flow
11
+ ```
12
+
13
+ Imported as immutable gold. Never edit, never skip. Run failing first, green at end.
14
+
15
+ ## Format 2: Declarative acceptance (Gherkin/markdown AC)
16
+
17
+ ```gherkin
18
+ Feature: Invitation flow
19
+ Scenario: User accepts invitation
20
+ Given an invitation exists for "user@example.com"
21
+ When the user clicks the invitation link
22
+ Then the user is redirected to onboarding
23
+ And the invitation status changes to "accepted"
24
+ ```
25
+
26
+ The crew translates this to a project test file. Write the test, watch it fail, implement, re-run green.
27
+
28
+ ## Format 3: Command-verifiable
29
+
30
+ ```
31
+ Acceptance: curl -X POST /api/invite -d '{"email":"test@ex.com"}' | jq .status
32
+ Expected: "sent"
33
+ ```
34
+
35
+ Run directly. No translation needed.
36
+
37
+ ## Rules
38
+
39
+ - No declared test source → no user tests for the mission.
40
+ - Executable user tests = immutable gold. Change requires user consent + ledger row.
41
+ - Declarative AC tests are model-written → extra Chopper scrutiny (can encode the bug).
42
+ - Cross-cutting user ACs (e2e flow spanning tasks) → plan-level criteria, re-run at checkpoint against whole diff.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: mugiwara-workflow
3
- description: Use at the start of any non-trivial mission to run the Mugiwara crew harness - Luffy triage gateway first, then brainstorm, planning, execution, checkpoint, quality, gates, review, healing, and closure waves.
3
+ description: Use at start of any non-trivial mission Luffy triage gateway, full pipeline: brainstorm/plan/execute/checkpoint/quality/gates/review/heal/closure waves.
4
4
  ---
5
5
 
6
6
  # Mugiwara Workflow
@@ -36,9 +36,11 @@ Every mission creates and works inside `.mugiwara/` at the repo root:
36
36
  ```
37
37
  .mugiwara/
38
38
  ├── config # runtime mode config: mode/branch/commit/pr key=value (gitignored; project overrides global)
39
+ ├── state.json # computed mission state at every wave boundary (scripts/savepoint.sh)
39
40
  ├── spec/ # brainstorm output: YYYY-MM-DD-<mission>.md
40
- ├── plans/ # plan doc: YYYY-MM-DD-<mission>.md — CLEAN, Nami-only, source of truth from Wave 2. No agent names, no log, no closure.
41
+ ├── plans/ # plan doc: YYYY-MM-DD-<mission>.md — CLEAN, Nami-only, source of truth from Wave 2
41
42
  ├── results/ # wave results: audit/quality/gate reports, todos, closure report
43
+ ├── reports/ # human-readable mission reports: YYYY-MM-DD-<mission>.md
42
44
  ├── review/ # review + security findings
43
45
  ├── issues/ # blocker log: YYYY-MM-DD-<mission>-blockers.md
44
46
  └── logs/ # Luffy's decision + check-in log: YYYY-MM-DD-<mission>.md (deleted at cleanup)
@@ -58,7 +60,7 @@ At session start, after context loss, or on any "where were we?" — embody `res
58
60
 
59
61
  Front door: embody `using-mugiwara` inline (the router) — it routes to the right crew member and records the route. For a full triage embody `luffy-orchestrator` inline. NEVER start directly with brainstorming or planning. Luffy classifies every request 5 ways (Trivial / Explicit / Exploratory / Open-ended / Ambiguous) and routes: Trivial and Explicit → Wave 2 directly; Exploratory, Open-ended, and Ambiguous → Wave 1 brainstorm first. Alongside the class, Luffy sizes the mission and picks a lane (0 Direct / 1 Lean / 2 Standard / 3 Full / 4 Spike) — small work skips the pipeline, sensitive work never sneaks through the lean path. The user may summon any crew member directly — Luffy still records the route.
60
62
 
61
- Alongside triage, read the mode config per `mugiwara-mode`: `.mugiwara/config` (project) then `~/.mugiwara/config` (global); a key missing from both = `guided`. Lazy-create the project config on first WRITE only, never auto-create on read.
63
+ Alongside triage, read the mode config per mode config: `.mugiwara/config` (project) then `~/.mugiwara/config` (global); a key missing from both = `guided`. Lazy-create the project config on first WRITE only, never auto-create on read.
62
64
 
63
65
  ## Waves
64
66
 
@@ -69,7 +71,7 @@ Alongside triage, read the mode config per `mugiwara-mode`: `.mugiwara/config` (
69
71
  | 2 Planning | Nami | mugiwara-planning | plan doc: waves/tasks/criteria, parallel markers |
70
72
  | 3 Execution | Zoro | mugiwara-execution | implemented tasks with evidence |
71
73
  | 4 Checkpoint | Chopper | mugiwara-checkpoint | audit report + failure ledger |
72
- | 4.5 Adversarial | Skeptic | mugiwara-dynamic-workflow | findings report + failure ledger |
74
+ | 4.5 Adversarial | Skeptic | mugiwara-claim-audit | findings report + failure ledger |
73
75
  | 5 Quality | Sanji | mugiwara-quality | formatter/linter/test results |
74
76
  | 6 Gates | Franky | mugiwara-gates | coverage + build verdict |
75
77
  | 7 Review | Robin ∥ Jinbe | mugiwara-review + mugiwara-security | severity-tagged findings |
@@ -88,7 +90,7 @@ Never silently work around a blocker. Brook reads this ledger at Wave 8 to decid
88
90
 
89
91
  ## Cleanup
90
92
 
91
- At closure (Wave 9), after the terminal step, run the cleanup procedure in `mugiwara-ship`: delete consumed intermediates — superseded results, review, issues reports, the per-mission decision log in `logs/`, and the consumed spec. Keep the plan doc, the closure report, the PR verdict, `config`, and cross-mission state (`logs/lessons.md`, `backup/`, `manifest.json`). List candidates before deleting.
93
+ At closure (Wave 9), after the terminal step, run cleanup per `mugiwara-ship`: delete consumed intermediates — superseded results, review, issues, the decision log in `logs/`, and consumed spec. Keep the plan doc, closure report, PR verdict, mission report, `config`, `state.json`, and cross-mission state (`logs/lessons.md`, `backup/`, `manifest.json`). List candidates before deleting.
92
94
 
93
95
  ## Rules
94
96
 
@@ -96,29 +98,24 @@ At closure (Wave 9), after the terminal step, run the cleanup procedure in `mugi
96
98
  2. No wave skipped without the reason recorded in the decision log (`.mugiwara/logs/`) — name the wave, owner, and reason at the moment of omission.
97
99
  3. Heal loop is bounded: Wave 8 → Wave 4, max 3 cycles. After that, escalate to the human with full history.
98
100
  4. Any agent may consult Luffy mid-flight (embody `luffy-orchestrator` inline) for decisions and escalations.
99
- 5. Wave 7 runs Robin and Jinbe review passes in parallel — both are inline passes over the same diff, or parallel review subagents for large diffs.
100
- 6. The plan doc (`.mugiwara/plans/YYYY-MM-DD-<mission>.md`) is the single source of truth from Wave 2 onward.
101
- 7. Frontend-touching tasks in Wave 3 must apply `mugiwara-frontend` in the same pass.
102
- 8. One crew member may hold many skills (e.g. Usopp holds `mugiwara-brainstorm` + `mugiwara-frontend`; the crew is 15 members); load the member's skills, embody the role inline.
103
- 9. On session start, context loss, or "where were we?" resume before any wave via `resume-coordinator` (mugiwara-resume); never start over.
104
- 10. The crew never merges and never deploys — push the branch + hand the verdict file to the user, who opens the PR; PR review is the terminal gate in every mode.
101
+ 5. Wave 7 runs Robin and Jinbe in parallel over the same diff.
102
+ 6. The plan doc is the single source of truth from Wave 2 onward.
103
+ 7. Frontend tasks in Wave 3 must apply `mugiwara-frontend`.
104
+ 8. On session start or context loss resume via `resume-coordinator` before any wave; never start over.
105
+ 9. Push branch + hand verdict file to the user, who opens the PR; crew never merges, never deploys.
105
106
 
106
107
  ## Iron Law
107
108
 
108
- EVIDENCE OVER CLAIMS. No wave passes on assertion — the owning agent runs the checks and shows output. A wave that cannot produce evidence is a failed wave.
109
-
110
- ## Verification gate (every completion claim)
111
-
112
- A claim is only as strong as the evidence produced in the same turn that made it. "Done", "passes", and "fixed" each name a command that would prove them — run that command, read its full output, then speak. A result from an earlier run, a guess, or a worker's word for it is not proof; re-run it and diff the work against the tree before reporting. Trust is not a substitute for verification.
109
+ EVIDENCE OVER CLAIMS. No wave passes on assertion — the owning agent runs the checks and shows output. "Done", "passes", and "fixed" must be proved by running the check command in the same turn; no stale results, no guesses, no worker's word for it.
113
110
 
114
111
  ## Red flags
115
112
 
116
- - A wave "passes" on a spoken claim with no command output or file to point at.
113
+ - A wave passes on a spoken claim with no command output.
117
114
  - Heal loop beyond 3 cycles with the same failure still open.
118
- - A wave skipped with no reason recorded in the decision log.
119
- - Execution starts before triage (Wave 0), or planning before brainstorm when triage routed to Wave 1.
120
- - Mission artifacts landing outside `.mugiwara/`.
121
- - Wave order drifts from the table (e.g. quality before checkpoint).
122
- - A blocker worked around silently with no ledger row.
115
+ - Wave skipped with no reason recorded in the decision log.
116
+ - Execution before triage (Wave 0).
117
+ - Mission artifacts outside `.mugiwara/`.
118
+ - Wave order drifts (e.g. quality before checkpoint).
119
+ - Blocker worked around silently with no ledger row.
123
120
 
124
- All mean: stop the pipeline, diagnose with Chopper's ledger, decide continue / retry / escalate.
121
+ All mean: stop, diagnose with Chopper's ledger, decide continue/retry/escalate.
package/dist/mugiwara.js CHANGED
@@ -494,21 +494,45 @@ function writeManifest(file, data) {
494
494
  }
495
495
 
496
496
  // src/mission.ts
497
- import { existsSync as existsSync5, rmSync as rmSync2 } from "node:fs";
497
+ import { existsSync as existsSync5, rmSync as rmSync2, readFileSync as readFileSync4 } from "node:fs";
498
498
  import { join as join7 } from "node:path";
499
- function resetMission(projectDir, keepLogs) {
499
+ function activeActor(projectDir) {
500
+ const stateFile = join7(projectDir, ".mugiwara", "state.json");
501
+ if (!existsSync5(stateFile))
502
+ return null;
503
+ try {
504
+ const state = JSON.parse(readFileSync4(stateFile, "utf8"));
505
+ return state.actor || null;
506
+ } catch {
507
+ return null;
508
+ }
509
+ }
510
+ function resetMission(projectDir, keepLogs, force) {
500
511
  const root = join7(projectDir, ".mugiwara");
501
512
  if (!existsSync5(root))
502
513
  return { removed: [], kept: [] };
514
+ if (!force) {
515
+ const actor = activeActor(projectDir);
516
+ if (actor) {
517
+ return { removed: [], kept: [], blocked: `Active mission for '${actor}'. Use --force to override.` };
518
+ }
519
+ }
503
520
  const removed = [];
504
521
  const kept = [];
505
- for (const dir of ["spec", "plans", "results", "review", "issues"]) {
522
+ for (const dir of ["spec", "plans", "results", "review", "issues", "reports"]) {
506
523
  const p = join7(root, dir);
507
524
  if (existsSync5(p)) {
508
525
  rmSync2(p, { recursive: true, force: true });
509
526
  removed.push(dir);
510
527
  }
511
528
  }
529
+ for (const f of ["state.json"]) {
530
+ const p = join7(root, f);
531
+ if (existsSync5(p)) {
532
+ rmSync2(p);
533
+ removed.push(f);
534
+ }
535
+ }
512
536
  if (!keepLogs) {
513
537
  const p = join7(root, "logs");
514
538
  if (existsSync5(p)) {
@@ -553,13 +577,18 @@ async function run(argv) {
553
577
  }
554
578
  function resetCmd(flags) {
555
579
  const projectDir = resolve(str(flags.project) ?? process.cwd());
556
- const { removed, kept } = resetMission(projectDir, flag(flags.keepLogs));
557
- if (removed.length)
558
- console.log(`removed: ${removed.join(", ")}`);
580
+ const force = flag(flags.force);
581
+ const result = resetMission(projectDir, flag(flags.keepLogs), force);
582
+ if (result.blocked) {
583
+ console.error(`✗ ${result.blocked}`);
584
+ process.exit(1);
585
+ }
586
+ if (result.removed.length)
587
+ console.log(`removed: ${result.removed.join(", ")}`);
559
588
  else
560
589
  console.log("nothing to remove.");
561
- if (kept.length)
562
- console.log(`kept: ${kept.join(", ")}`);
590
+ if (result.kept.length)
591
+ console.log(`kept: ${result.kept.join(", ")}`);
563
592
  }
564
593
  async function resolveOptions(flags) {
565
594
  const interactive = !flag(flags.yes);
package/docs/agents.md CHANGED
@@ -44,8 +44,8 @@ check-ins. The harness stays coherent either way.
44
44
 
45
45
  ## The crew ships whole
46
46
 
47
- Every install gets all 15 agents and all 32 skills. No project-type selection —
47
+ Every install gets all 15 agents and all 26 skills. No project-type selection —
48
48
  the harness routes each task to the right specialist.
49
49
 
50
- See [skills.md](skills.md) for the 32 techniques, or
50
+ See [skills.md](skills.md) for the 26 techniques, or
51
51
  [workflow.md](workflow.md) for the pipeline.