@ionivetech/mugiwara 0.7.0 → 0.8.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 (87) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.cursor-plugin/plugin.json +1 -1
  5. package/.kimi-plugin/plugin.json +1 -1
  6. package/.opencode/mugiwara-helpers.mjs +2 -2
  7. package/README.md +196 -330
  8. package/content/agents/brook-healing.md +1 -1
  9. package/content/agents/franky-gates.md +1 -1
  10. package/content/agents/luffy-orchestrator.md +2 -2
  11. package/content/agents/memory-keeper.md +5 -0
  12. package/content/agents/usopp-brainstorm.md +3 -2
  13. package/content/agents/zoro-execution.md +4 -3
  14. package/content/skills/mugiwara-backend/SKILL.md +52 -43
  15. package/content/skills/mugiwara-brainstorm/SKILL.md +5 -3
  16. package/content/skills/mugiwara-checkpoint/SKILL.md +21 -8
  17. package/content/skills/mugiwara-contract-first/SKILL.md +46 -1
  18. package/content/skills/mugiwara-execution/SKILL.md +34 -33
  19. package/content/skills/mugiwara-execution/references/dispatch.md +1 -1
  20. package/content/skills/mugiwara-execution/references/execution-phase-flows.md +18 -0
  21. package/content/skills/mugiwara-frontend/SKILL.md +44 -44
  22. package/content/skills/mugiwara-gates/SKILL.md +28 -16
  23. package/content/skills/mugiwara-healing/SKILL.md +30 -25
  24. package/content/skills/mugiwara-lessons/SKILL.md +3 -0
  25. package/content/skills/mugiwara-orchestration/SKILL.md +10 -9
  26. package/content/skills/mugiwara-orchestration/references/control-commands.md +14 -0
  27. package/content/skills/mugiwara-planning/SKILL.md +28 -14
  28. package/content/skills/mugiwara-planning/references/large-campaign-subplan.md +41 -0
  29. package/content/skills/mugiwara-planning/references/plan-template.md +22 -0
  30. package/content/skills/mugiwara-quality/SKILL.md +8 -13
  31. package/content/skills/mugiwara-quality/references/order-checklist.md +18 -0
  32. package/content/skills/mugiwara-resume/SKILL.md +3 -9
  33. package/content/skills/mugiwara-resume/references/resume-protocol.md +16 -0
  34. package/content/skills/mugiwara-review/SKILL.md +17 -24
  35. package/content/skills/mugiwara-review/references/red-flags-review.md +17 -0
  36. package/content/skills/mugiwara-security/SKILL.md +47 -35
  37. package/content/skills/mugiwara-ship/SKILL.md +2 -0
  38. package/content/skills/mugiwara-workflow/SKILL.md +13 -13
  39. package/content/skills/mugiwara-workflow/references/large-campaign-subplan.md +29 -0
  40. package/content/skills/mugiwara-workflow/references/workspace-layout.md +6 -3
  41. package/dist/mugiwara.js +1802 -316
  42. package/gemini-extension.json +1 -1
  43. package/hooks/mugiwara-mode-tracker.js +24 -4
  44. package/hooks/mugiwara-mode-tracker.ts +36 -7
  45. package/hooks/pipeline-guard.js +1 -1
  46. package/hooks/pipeline-guard.ts +2 -1
  47. package/hooks/session-start.js +6 -1
  48. package/hooks/session-start.ts +8 -1
  49. package/package.json +2 -2
  50. package/plugin.json +1 -1
  51. package/references/cost-governor.md +104 -0
  52. package/references/multi-actor.md +21 -0
  53. package/references/posture-routing.md +31 -0
  54. package/references/wave-banners.md +1 -2
  55. package/scripts/benchmark-governor.ts +516 -0
  56. package/scripts/benchmark-thresholds.json +47 -0
  57. package/scripts/check-doc-links.ts +8 -2
  58. package/scripts/gate-selftest.ts +104 -21
  59. package/scripts/lib/lane-base.sh +4 -4
  60. package/scripts/retrieval-eval.ts +9 -3
  61. package/scripts/savepoint.sh +41 -2
  62. package/scripts/validate-content.ts +82 -3
  63. package/scripts/verify-install.ts +20 -0
  64. package/scripts/write-metrics.ts +73 -0
  65. package/src/adaptive-budget.ts +178 -0
  66. package/src/args.ts +3 -2
  67. package/src/budget.ts +18 -16
  68. package/src/check-artifacts.ts +45 -0
  69. package/src/cli.ts +221 -8
  70. package/src/cognition.ts +234 -0
  71. package/src/config.ts +113 -0
  72. package/src/context.ts +72 -0
  73. package/src/continue.ts +29 -0
  74. package/src/cost.ts +189 -0
  75. package/src/evidence.ts +160 -0
  76. package/src/installer.ts +2 -16
  77. package/src/integrity.ts +65 -16
  78. package/src/investigation.ts +72 -0
  79. package/src/mission.ts +246 -16
  80. package/src/policy.ts +355 -2
  81. package/src/posture.ts +86 -0
  82. package/src/provenance.ts +29 -9
  83. package/src/reporting.ts +225 -0
  84. package/src/scope.ts +321 -0
  85. package/src/sign.ts +234 -18
  86. package/src/slop.ts +306 -0
  87. package/src/work.ts +273 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mugiwara",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "The Straw Hat crew of AI agents and skills: brainstorm, plan, execute, checkpoint, quality, gates, review, security, healing.",
5
5
  "contextFileName": "GEMINI.md"
6
6
  }
@@ -54,12 +54,22 @@ function applyModeChange(mode) {
54
54
  writeFileSync(tmp, body);
55
55
  renameSync(tmp, file);
56
56
  }
57
+ function isCodexInput(parsed) {
58
+ if (process.env.CODEX_HOME || process.env.CODEX_THREAD_ID)
59
+ return true;
60
+ if (typeof parsed.turn_id === "string")
61
+ return true;
62
+ if (typeof parsed.cwd === "string" && typeof parsed.model === "string")
63
+ return true;
64
+ return false;
65
+ }
57
66
  async function main() {
58
67
  let input = "";
59
68
  for await (const chunk of process.stdin)
60
69
  input += chunk;
61
70
  if (!input.trim()) {
62
- process.stdout.write(JSON.stringify({ prompt: "" }));
71
+ const codexEmpty = !!(process.env.CODEX_HOME || process.env.CODEX_THREAD_ID);
72
+ process.stdout.write(JSON.stringify(codexEmpty ? {} : { prompt: "" }));
63
73
  return;
64
74
  }
65
75
  let parsed;
@@ -68,12 +78,22 @@ async function main() {
68
78
  } catch {
69
79
  parsed = { prompt: input };
70
80
  }
71
- const prompt = parsed.prompt ?? "";
81
+ const prompt = typeof parsed.prompt === "string" ? parsed.prompt : "";
72
82
  const change = parseModeChange(prompt);
73
83
  if (change)
74
84
  applyModeChange(change);
75
- process.stdout.write(JSON.stringify({ prompt }));
85
+ const codex = isCodexInput(parsed);
86
+ if (codex) {
87
+ if (change) {
88
+ process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: `Mugiwara mode changed to ${change}` } }));
89
+ } else {
90
+ process.stdout.write(JSON.stringify({}));
91
+ }
92
+ } else {
93
+ process.stdout.write(JSON.stringify({ prompt }));
94
+ }
76
95
  }
77
96
  main().catch(() => {
78
- process.stdout.write(JSON.stringify({ prompt: "" }));
97
+ const codexFallback = !!(process.env.CODEX_HOME || process.env.CODEX_THREAD_ID);
98
+ process.stdout.write(JSON.stringify(codexFallback ? {} : { prompt: "" }));
79
99
  });
@@ -57,24 +57,53 @@ function applyModeChange(mode: string) {
57
57
  renameSync(tmp, file);
58
58
  }
59
59
 
60
+ // Codex vs Claude: Codex UserPromptSubmit expects {} or {hookSpecificOutput:{hookEventName,additionalContext}}
61
+ // Claude expects {prompt:""} — Codex rejects "prompt" (additionalProperties:false).
62
+ // Detect Codex via env or input shape (turn_id/cwd/model are Codex-only).
63
+ function isCodexInput(parsed: Record<string, unknown>): boolean {
64
+ if (process.env.CODEX_HOME || process.env.CODEX_THREAD_ID) return true;
65
+ if (typeof parsed.turn_id === 'string') return true;
66
+ if (typeof parsed.cwd === 'string' && typeof parsed.model === 'string') return true;
67
+ return false;
68
+ }
69
+
60
70
  // main
61
71
  async function main() {
62
72
  let input = '';
63
73
  for await (const chunk of process.stdin) input += chunk;
64
- if (!input.trim()) { process.stdout.write(JSON.stringify({ prompt: '' })); return; }
74
+ if (!input.trim()) {
75
+ // empty stdin — Codex expects {}, Claude expects {prompt:""}
76
+ // Emit Codex-safe empty ( {} ) — Claude also accepts {} as no-op (prompt passthrough)
77
+ // but to keep Claude behavior, sniff env: if Codex-like env, emit {}, else prompt
78
+ const codexEmpty = !!(process.env.CODEX_HOME || process.env.CODEX_THREAD_ID);
79
+ process.stdout.write(JSON.stringify(codexEmpty ? {} : { prompt: '' }));
80
+ return;
81
+ }
65
82
 
66
- let parsed: { prompt?: string };
67
- try { parsed = JSON.parse(input); } catch { parsed = { prompt: input }; }
68
- const prompt = parsed.prompt ?? '';
83
+ let parsed: Record<string, unknown>;
84
+ try { parsed = JSON.parse(input) as Record<string, unknown>; } catch { parsed = { prompt: input }; }
85
+ const prompt = typeof parsed.prompt === 'string' ? parsed.prompt : '';
69
86
 
70
87
  const change = parseModeChange(prompt);
71
88
  if (change) applyModeChange(change);
72
89
 
73
- // pass-through always return the prompt unchanged
74
- process.stdout.write(JSON.stringify({ prompt }));
90
+ const codex = isCodexInput(parsed);
91
+ if (codex) {
92
+ // Codex schema: additionalProperties:false — "prompt" is invalid. Use hookSpecificOutput or {}.
93
+ if (change) {
94
+ process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: 'UserPromptSubmit', additionalContext: `Mugiwara mode changed to ${change}` } }));
95
+ } else {
96
+ process.stdout.write(JSON.stringify({}));
97
+ }
98
+ } else {
99
+ // Claude: pass-through prompt
100
+ process.stdout.write(JSON.stringify({ prompt }));
101
+ }
75
102
  }
76
103
 
77
104
  main().catch(() => {
78
105
  // silent — hook must never block the conversation
79
- process.stdout.write(JSON.stringify({ prompt: '' }));
106
+ // Codex-safe fallback: {} (valid for both, but Claude prefers prompt however {} is also accepted as no-op)
107
+ const codexFallback = !!(process.env.CODEX_HOME || process.env.CODEX_THREAD_ID);
108
+ process.stdout.write(JSON.stringify(codexFallback ? {} : { prompt: '' }));
80
109
  });
@@ -135,7 +135,7 @@ function planTouched() {
135
135
  if (!existsSync(plan))
136
136
  continue;
137
137
  const at = lstatSync(plan).mtimeMs;
138
- if (at >= sessionStart)
138
+ if (at + 1000 >= sessionStart)
139
139
  return true;
140
140
  }
141
141
  } catch {}
@@ -179,8 +179,9 @@ function planTouched(): boolean {
179
179
  if (!existsSync(plan)) continue;
180
180
  // lstat, not stat: a symlinked plan pointing outside .mugiwara/
181
181
  // must not count as a plan write.
182
+ // 1s tolerance: file mtime can be ~7ms before first_seen due to FS granularity / clock skew
182
183
  const at = lstatSync(plan).mtimeMs;
183
- if (at >= sessionStart) return true;
184
+ if (at + 1000 >= sessionStart) return true;
184
185
  }
185
186
  } catch { /* unreadable — treat as untouched */ }
186
187
  return false;
@@ -104,6 +104,11 @@ if (active.length === 1 && mode === "auto") {
104
104
  ${lines}
105
105
  ` + `Run /mugiwara continue <mission> [member] to resume one explicitly.`;
106
106
  }
107
+ var isCodexSession = !!(process.env.CODEX_HOME || process.env.CODEX_THREAD_ID || process.env.CODEX_HOME_DIR);
107
108
  if (resumeContext) {
108
- console.log(JSON.stringify({ additionalContext: resumeContext }));
109
+ if (isCodexSession) {
110
+ console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: resumeContext } }));
111
+ } else {
112
+ console.log(JSON.stringify({ additionalContext: resumeContext }));
113
+ }
109
114
  }
@@ -131,6 +131,13 @@ if (active.length === 1 && mode === 'auto') {
131
131
 
132
132
  // Silent unless there is in-flight work: a session that never used mugiwara
133
133
  // gets zero injected context.
134
+ // Codex vs Claude: Codex SessionStart expects {hookSpecificOutput:{hookEventName,additionalContext}}
135
+ // Claude expects {additionalContext} — Codex rejects top-level additionalContext (additionalProperties:false).
136
+ const isCodexSession = !!(process.env.CODEX_HOME || process.env.CODEX_THREAD_ID || process.env.CODEX_HOME_DIR);
134
137
  if (resumeContext) {
135
- console.log(JSON.stringify({ additionalContext: resumeContext }));
138
+ if (isCodexSession) {
139
+ console.log(JSON.stringify({ hookSpecificOutput: { hookEventName: 'SessionStart', additionalContext: resumeContext } }));
140
+ } else {
141
+ console.log(JSON.stringify({ additionalContext: resumeContext }));
142
+ }
136
143
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ionivetech/mugiwara",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "The Straw Hat crew of AI agents and skills: brainstorm, plan, execute, checkpoint, quality, gates, review, security, self-healing. Installs into Claude Code, opencode, Copilot, Gemini, Codex, Cursor, Kimi, pi, Windsurf, Cline, Kilo, Antigravity.",
5
5
  "homepage": "https://github.com/ionivetech/mugiwara#readme",
6
6
  "repository": {
@@ -63,7 +63,7 @@
63
63
  "sync-version": "bun scripts/sync-version.ts",
64
64
  "build-hooks": "bun scripts/build-hooks.ts",
65
65
  "build-hooks:check": "bun scripts/build-hooks.ts --check",
66
- "gate": "bun run build-hooks:check && bun run typecheck && bun run test:coverage && bun run build && bun scripts/validate-content.ts --check-manifest --check-docs --check-doc-integrity && bun scripts/lane-base.ts && bun scripts/check-doc-links.ts && bun run verify-pack && bun scripts/run-evals.ts && bun scripts/retrieval-eval.ts && bun scripts/verify-install.ts && bun scripts/conformance.ts && bun run coverage-gate",
66
+ "gate": "bun run build-hooks:check && bun run typecheck && bun run test:coverage && bun run build && bun scripts/write-metrics.ts && bun scripts/validate-content.ts --check-manifest --check-docs --check-doc-integrity --check-readme-metrics && bun scripts/lane-base.ts && bun scripts/check-doc-links.ts && bun run verify-pack && bun scripts/run-evals.ts && bun scripts/retrieval-eval.ts && bun scripts/benchmark-governor.ts && bun scripts/verify-install.ts && bun scripts/conformance.ts && bun run coverage-gate",
67
67
  "verify-pack": "npm pack --dry-run 2>&1 | node -e \"let s='';process.stdin.on('data',d=>s+=d);process.stdin.on('end',()=>{if(!s.includes('ionivetech-mugiwara')){console.error('npm pack failed');process.exit(1)};console.log('npm package clean')})\"",
68
68
  "prepack": "bun run build && bun run sync-version"
69
69
  },
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mugiwara",
3
3
  "description": "The Straw Hat crew of AI agents and skills: brainstorm, plan, execute, checkpoint, quality, gates, review, security, healing.",
4
- "version": "0.7.0",
4
+ "version": "0.8.1",
5
5
  "author": {
6
6
  "name": "ionivetech"
7
7
  },
@@ -0,0 +1,104 @@
1
+ # Cost Governor — Terse & Low-Cost Execution
2
+
3
+ Single source for Work, Scope/Code, Cognitive/Output, Stop-Slop, Adaptive Budget, Benchmark. Verdicts recommended, not enforced; crew acts. Trail rows → `.mugiwara/missions/<mission>/decisions.md` → `## Cost governor decisions`. `savepoint`/`lane-base`/`config` untouched.
4
+
5
+ ## Ladder — before adding code, run top to bottom, stop at first that holds
6
+
7
+ 1. Does this need to exist at all? Speculative need → skip, one line why (YAGNI).
8
+ 2. Already in codebase? Reuse helper/util/pattern nearby → reuse it.
9
+ 3. Stdlib does it? Use it.
10
+ 4. Native platform covers it? `<input type="date">` over picker lib, CSS over JS, DB constraint over app code → native.
11
+ 5. Already-installed dependency solves it? Use it. Never add new dep for a few lines.
12
+ 6. Can it be one line? One line.
13
+ 7. Only then: minimum code that works. No unrequested abstraction (one impl → no interface/factory/config), no boilerplate for later, deletion over addition, fewest files, shortest diff.
14
+
15
+ Each step: grep callers first; fix root cause in shared function, not symptom in caller. One guard in shared path beats guards in every caller.
16
+
17
+ ## Output — terse, deduped
18
+
19
+ Reasoning: Question → Evidence → Decision → Action. No speculative architecture, hypothetical requirements, repeated reconsideration, unrelated implementations. Investigation ends when `acceptance_mapped + surface_understood + path_established` or limits hit with concrete reason (§13). Alternatives ≤3, evidence-backed only.
20
+
21
+ Output: Decision / Action / Result / Evidence / Blocker only, mission-focused. Duplicate explanations fingerprinted and dropped. Every verdict → `cognitive-governor` trail row.
22
+
23
+ ## Scope & code
24
+
25
+ Prefer smallest correct scope — reuse + local modification over new architecture (§14). Abstraction justified only when used in ≥2 places or required by contract, never speculative (§15). Dependency added only with explicit justification (§16). Minimum sufficient implementation, never minimum LOC at expense of verification/quality (§15/§38). Measure change surface. Code waste (unnecessary helper/abstraction/wrapper/interface/config/dependency/generated code/refactor) named. Trail row `scope-governor`.
26
+
27
+ ## Slop — taxonomy, signals, measurement, intervention
28
+
29
+ Taxonomy 8 kinds (§21): investigation, context, reasoning, output, code, retry, healing, scope.
30
+
31
+ Signals (§22): repeated reads/commands, token-without-evidence, LOC-without-acceptance, abstraction-without-justification.
32
+
33
+ Measure (§23): evidence/criteria/tests/code vs cost delta — cost grows without progress → slop. Flag anomaly (§24): 5k tokens zero progress, work-to-cost drop.
34
+
35
+ Intervene (§20): tolerate / stop / compress / escalate by severity.
36
+
37
+ Detectors — six categories:
38
+ - retry §21.6/§31 same-action same-evidence same-failure → STOP
39
+ - healing §21.7/§32 no progress → stop; `heal_cycle ≥ 3` → halt
40
+ - scope §21.8 out-of-scope without acceptance → reject
41
+ - context §21.2 duplicate/irrelevant → discard/compress
42
+ - investigation §21.1 unbounded exploration → stop
43
+ - code §21.5 unnecessary abstraction/dependency/boilerplate → remove/simplify
44
+
45
+ Trail row `slop-governor`.
46
+
47
+ ## Budget — reserve, projection, thresholds, breaker
48
+
49
+ Reserve expected max before expensive stages (Review/Security/Healing). Continuously project `current + remaining required + expected conditional + possible healing` (§26).
50
+
51
+ Expand only with evidence (§27 valid: scope legitimately expanded, security-sensitive path, test surface larger, architecture dependency, legitimate healing; invalid: verbosity/reread/repeat/unnecessary code).
52
+
53
+ Thresholds (§28): 60% → optimize, 75% → aggressive, 90% → protect, 100% → pause, 150% → warning, 300% → stop.
54
+
55
+ Breaker (§29): actual ≥ 2× expected without progress/scope/evidence → trip.
56
+
57
+ Anomaly (§24): flag 5k-zero-progress, re-consumes slop signal.
58
+
59
+ Record every non-ok verdict via `recordBudgetDecision` (§41). Trail row `budget-governor`. Ledger aggregates envelope+events+registry+trail; `mugiwara cost` surfaces ledger (--json); report Cost section renders ledger+avoided+efficiency+trail (§43).
60
+
61
+ ## Benchmark & hardening
62
+
63
+ Tracks `scripts/benchmark-governor.ts` harness (deterministic, no network).
64
+
65
+ Cost suite (§48) — 4 workloads:
66
+ - lean-trivial: projected 8000 + overhead 1000, context ≤20000, evidence ≥1, surface 2 files 50 LOC
67
+ - standard-feature: projected 15000 + overhead 1500, context ≤40000, evidence ≥3
68
+ - large-repo: projected 22000 + overhead 2200, context ≤80000, evidence ≥5, surface 50 files
69
+ - long-mission: projected 23000 + overhead 2300, context ≤90000, 9 stages projection ≤ budget
70
+ Check: `measured.tokens ≤ projected + overhead` else fail; `measured.context ≤ max` else fail
71
+
72
+ Stop-Slop suite (§45) — 12 scenarios detect→classify→intervene:
73
+ - endless-exploration → investigation slop → stop
74
+ - repeated-reads (3× no evidence) → context slop → stop; with concrete reason → tolerate
75
+ - repeated-commands (same cmd+evidence fail) → retry slop → stop
76
+ - repeated-failed-test → retry slop → stop
77
+ - repeated-reasoning → reasoning slop → stop
78
+ - unnecessary-abstraction → code slop → stop
79
+ - unnecessary-dependency → code slop → stop
80
+ - unrelated-refactor → scope slop → stop
81
+ - verbose-output → output slop → stop
82
+ - no-progress-healing (cycle ≥3, 0 fixes) → healing slop → stop
83
+ - premature-completion → scope slop → escalate
84
+ - excessive-context (repeated reads + duplicate chars) → context slop → stop
85
+
86
+ Stress (bench-only, no runtime): large repository 50 files within scope → pass; long mission 9 stages projection ≤ full budget → pass; runaway 2× expected no progress → breaker tripped.
87
+
88
+ Thresholds live in `scripts/benchmark-thresholds.json` (or THRESHOLDS const) — `tokens > projected+overhead` fail, `context > max` fail, only move on explicit fixture update, ratchet like retrieval-eval. Regression (§49): cost down but correctness/evidence/security/quality/scope down → fail. Determinism: harness pure over explicit fixture inputs, no Date.now/Math.random/network. CI: `package.json:gate` includes harness; `gate-selftest` tampers thresholds → harness must exit 1. Harness measures, not enforces.
89
+
90
+ ## Reporting & trail
91
+
92
+ Ledger aggregates envelope+events+registry+trail; `mugiwara cost` surfaces ledger; report Cost section renders ledger+avoided+efficiency+trail (§43). Every verdict lands as trail row in decisions.md.
93
+
94
+ ## Checklist
95
+
96
+ - [ ] ladder run before each code addition, no skipped rung
97
+ - [ ] output Decision/Action/Result/Evidence/Blocker, deduped
98
+ - [ ] scope/code: reuse checked, abstraction & dep justified
99
+ - [ ] slop: taxonomy classified, signals measured, intervention applied
100
+ - [ ] budget: reserved, projected, thresholds respected, breaker armed
101
+ - [ ] benchmark: 4 cost + 12 slop + 3 stress green, thresholds ratcheted
102
+ - [ ] trail rows written for every non-trivial verdict
103
+
104
+ Unchecked boxes are not done.
@@ -64,3 +64,24 @@ clobber each other's resume position.
64
64
  The session-start hook (auto mode) surfaces only the missions owned by your git
65
65
  actor — never another member's. If you hold several in-flight missions it lists
66
66
  them and asks, it never guesses.
67
+
68
+ ## Ownership & interface declarations (Phase D)
69
+
70
+ Each member declares its owned files/interfaces in the shared plan's ownership
71
+ map. A member or worker never receives another member's scope — in `auto` mode
72
+ this is a hard boundary, never silently crossed (the resumed scope is exactly
73
+ the selected `(mission, member)` file).
74
+
75
+ ## Standardized handoff
76
+
77
+ Handoff between members or sequential sub-missions carries: done-criteria,
78
+ branch/base status, dependency status, continuation pointer
79
+ (`continue-<member>.json`), and unresolved blocker references. Never a bare
80
+ "here's where I left off".
81
+
82
+ ## Base drift & collisions
83
+
84
+ Base drift, merge, and interface collisions are **routing/escalation events**,
85
+ never a silent retry or an automatic cross-scope edit. When main has moved past
86
+ the mission base, escalate (rebase check) before continuing; an interface
87
+ collision routes to Luffy, never silently overwrites another member's work.
@@ -0,0 +1,31 @@
1
+ # Posture Routing (Flow 0/2)
2
+
3
+ Posture is independent of control mode. Luffy records it; Nami proposes the
4
+ resolved posture; it is chosen deterministically — never opaque scoring.
5
+
6
+ ## Initial posture (Flow 0)
7
+
8
+ At triage, alongside route + lane + risk, record the initial execution posture +
9
+ rationale + evidence refs. Ordinary work defaults to `inline-sequential` (a
10
+ no-op route — no posture change).
11
+
12
+ Deterministic matrix: `src/posture.ts` `selectPosture(input)` → `{ posture,
13
+ reason, evidence_refs }`. Inputs: lane, risk, independent_tasks, order_dependent,
14
+ context_pressure, team_members, phases, plan_lines, governor verdict.
15
+
16
+ | Trigger | Posture |
17
+ |---------|---------|
18
+ | ordinary / none | `inline-sequential` (default) |
19
+ | ≥2 independent tasks, no shared files/interfaces | `parallel-workers` |
20
+ | context pressure + ordered tasks | `context-relief` |
21
+ | >3 phases or >1500 plan lines | `phase-isolated` |
22
+ | >1 team member | `team-scoped` |
23
+ | governor stop | safe pause (keep inline, emit state + continue) |
24
+
25
+ Governor stop never silently changes mode or crew roles; it pauses and records.
26
+
27
+ ## Plan posture (Flow 2)
28
+
29
+ Nami declares dependencies, write-conflict groups, explicit `[PARALLEL]`
30
+ eligibility (file- AND interface-disjoint), member ownership, phase/sub-plan
31
+ trigger, acceptance evidence. Luffy records the resolved posture.
@@ -53,8 +53,7 @@ their banners appear only when a wave or worker names them.
53
53
 
54
54
  ## Rules
55
55
 
56
- 1. Banner before EVERY flow stage; handoff after it. No flow stage starts without its
57
- banner (orchestration red flag).
56
+ 1. Banner before EVERY flow stage; handoff after it. Main thread emits `===== FLOW N — CREW =====` FIRST line and `→ Flow N+1 — Crew` LAST line even when subagent does work — covers Flow 0 Luffy, 1 Usopp, 2 Nami, 3 Zoro, 4 Chopper, 5 Sanji, 6 Franky, 7 Robin/Jinbe, 8 Brook, 9 Luffy. No flow stage starts without its banner (orchestration red flag).
58
57
  2. The color comes from this table only — never invent a hex mid-mission.
59
58
  3. One form everywhere: equals line `===== <emoji> FLOW N — <CREW> (ROLE) =====` — five `=` per side, the crew emoji from the table leading the line, ANSI-wrapped in terminals, plain in markdown-rendering UIs. When unsure, the plain form is safe everywhere.
60
59
  4. Only the crew table's colors and the two SGR forms above (truecolor,