@ionivetech/mugiwara 0.8.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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/.kimi-plugin/plugin.json +1 -1
- package/README.md +2 -2
- package/content/agents/brook-healing.md +1 -1
- package/content/agents/memory-keeper.md +5 -0
- package/content/agents/usopp-brainstorm.md +3 -2
- package/content/agents/zoro-execution.md +4 -3
- package/content/skills/mugiwara-brainstorm/SKILL.md +5 -3
- package/content/skills/mugiwara-checkpoint/SKILL.md +2 -0
- package/content/skills/mugiwara-execution/SKILL.md +4 -3
- package/content/skills/mugiwara-execution/references/dispatch.md +1 -1
- package/content/skills/mugiwara-gates/SKILL.md +6 -0
- package/content/skills/mugiwara-healing/SKILL.md +5 -1
- package/content/skills/mugiwara-lessons/SKILL.md +3 -0
- package/content/skills/mugiwara-orchestration/SKILL.md +5 -4
- package/content/skills/mugiwara-planning/SKILL.md +2 -0
- package/content/skills/mugiwara-quality/SKILL.md +3 -14
- package/content/skills/mugiwara-quality/references/order-checklist.md +18 -0
- package/content/skills/mugiwara-resume/SKILL.md +3 -14
- package/content/skills/mugiwara-resume/references/resume-protocol.md +16 -0
- package/content/skills/mugiwara-review/SKILL.md +3 -15
- package/content/skills/mugiwara-review/references/red-flags-review.md +17 -0
- package/content/skills/mugiwara-security/SKILL.md +1 -0
- package/content/skills/mugiwara-ship/SKILL.md +2 -0
- package/content/skills/mugiwara-workflow/SKILL.md +10 -7
- package/dist/mugiwara.js +1190 -376
- package/gemini-extension.json +1 -1
- package/hooks/mugiwara-mode-tracker.js +24 -4
- package/hooks/mugiwara-mode-tracker.ts +36 -7
- package/hooks/session-start.js +6 -1
- package/hooks/session-start.ts +8 -1
- package/package.json +2 -2
- package/plugin.json +1 -1
- package/references/cost-governor.md +104 -0
- package/references/wave-banners.md +1 -2
- package/scripts/gate-selftest.ts +84 -21
- package/scripts/savepoint.sh +22 -2
- package/scripts/validate-content.ts +60 -0
- package/scripts/verify-install.ts +20 -0
- package/scripts/write-metrics.ts +73 -0
- package/src/budget.ts +11 -0
- package/src/cli.ts +128 -13
- package/src/config.ts +6 -0
- package/src/continue.ts +29 -0
- package/src/cost.ts +3 -0
- package/src/integrity.ts +64 -15
- package/src/mission.ts +123 -7
- package/src/policy.ts +355 -2
- package/src/provenance.ts +29 -9
- package/src/sign.ts +45 -3
- package/content/skills/mugiwara-workflow/references/adaptive-budget-governor.md +0 -5
- package/content/skills/mugiwara-workflow/references/benchmark-governor.md +0 -53
- package/content/skills/mugiwara-workflow/references/cognitive-output-governor.md +0 -5
- package/content/skills/mugiwara-workflow/references/scope-code-governor.md +0 -14
- package/content/skills/mugiwara-workflow/references/stop-slop-governor.md +0 -14
package/src/sign.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { createPrivateKey, createPublicKey, generateKeyPairSync, sign, verify }
|
|
|
13
13
|
import { homedir } from 'node:os';
|
|
14
14
|
import { join } from 'node:path';
|
|
15
15
|
import { readConfig } from './config.ts';
|
|
16
|
+
import { loadPolicy } from './policy.ts';
|
|
16
17
|
|
|
17
18
|
export function signArgs(reportPath: string, secretKey: string): string[] {
|
|
18
19
|
return ['-Sm', reportPath, '-s', secretKey];
|
|
@@ -192,6 +193,42 @@ export function signReport(projectDir: string, missionDir: string): { ok: boolea
|
|
|
192
193
|
return { ok: true, message: `signed ${report}.mugisig (pure ed25519, key: ${join(dir, 'mugiwara.key')})` };
|
|
193
194
|
}
|
|
194
195
|
|
|
196
|
+
function normalizePubkey(pk: string): string {
|
|
197
|
+
const t = pk.trim();
|
|
198
|
+
return t.startsWith('ed25519:') ? t.slice('ed25519:'.length).trim() : t;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function checkTrust(projectDir: string, signerPubB64: string): { ok: boolean; message?: string } {
|
|
202
|
+
try {
|
|
203
|
+
const policy = loadPolicy(projectDir);
|
|
204
|
+
const att = policy?.attestation;
|
|
205
|
+
if (!att) return { ok: true };
|
|
206
|
+
const trusted = att.trusted_keys ?? [];
|
|
207
|
+
const revoked = att.revoked ?? [];
|
|
208
|
+
const signer = signerPubB64.trim();
|
|
209
|
+
// revoked by pubkey direct match (before trusted check, so revoked is authoritative)
|
|
210
|
+
const directlyRevoked = revoked.some((r) => {
|
|
211
|
+
const rpk = (r as { pubkey?: string }).pubkey;
|
|
212
|
+
if (!rpk) return false;
|
|
213
|
+
return normalizePubkey(rpk) === signer;
|
|
214
|
+
});
|
|
215
|
+
if (directlyRevoked) return { ok: false, message: 'signature valid but signer revoked (pubkey in revoked list)' };
|
|
216
|
+
|
|
217
|
+
if (trusted.length === 0) {
|
|
218
|
+
// No trust list → only signature validity matters; revoked already checked
|
|
219
|
+
return { ok: true };
|
|
220
|
+
}
|
|
221
|
+
const match = trusted.find((e) => normalizePubkey(e.pubkey) === signer);
|
|
222
|
+
if (!match) return { ok: false, message: 'signature valid but signer untrusted (pub not in trusted_keys)' };
|
|
223
|
+
// check revoked by id (revoked id means that trusted id is revoked)
|
|
224
|
+
const revokedById = revoked.some((r) => r.id === match.id);
|
|
225
|
+
if (revokedById) return { ok: false, message: `signature valid but signer revoked (id: ${match.id})` };
|
|
226
|
+
return { ok: true };
|
|
227
|
+
} catch {
|
|
228
|
+
return { ok: true };
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
195
232
|
export function verifyReport(projectDir: string, missionDir: string): { ok: boolean; message: string } {
|
|
196
233
|
const report = join(missionDir, 'report.md');
|
|
197
234
|
const minisig = `${report}.minisig`;
|
|
@@ -208,6 +245,10 @@ export function verifyReport(projectDir: string, missionDir: string): { ok: bool
|
|
|
208
245
|
const pubKey = existsSync(defaultKey('public')) ? defaultKey('public') : null;
|
|
209
246
|
try {
|
|
210
247
|
execFileSync('minisign', verifyArgs(report, pubKey), { cwd: projectDir, stdio: 'pipe' });
|
|
248
|
+
// trust check for pure is not applied to minisig (MVP: pure-only trust).
|
|
249
|
+
// If a .mugisig also exists alongside minisig, still trust-check the pure pub for completeness,
|
|
250
|
+
// but minisig verification already succeeded — treat as ok.
|
|
251
|
+
// For strict attestation, operator should use pure backend when trusted_keys is configured.
|
|
211
252
|
return { ok: true, message: 'signature verifies against report.md (minisig)' };
|
|
212
253
|
} catch {
|
|
213
254
|
return { ok: false, message: 'SIGNATURE INVALID — report.md changed after signing (minisig)' };
|
|
@@ -219,9 +260,10 @@ export function verifyReport(projectDir: string, missionDir: string): { ok: bool
|
|
|
219
260
|
const parsed = JSON.parse(readFileSafe(mugisig) ?? '{}') as PureSig;
|
|
220
261
|
const content = readFileSafe(report);
|
|
221
262
|
if (content === null || parsed.algo !== 'ed25519-pure') return { ok: false, message: 'invalid .mugisig file' };
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
263
|
+
if (!pureVerify(content, parsed)) return { ok: false, message: 'SIGNATURE INVALID — report.md changed after signing (mugisig)' };
|
|
264
|
+
const trust = checkTrust(projectDir, parsed.pub);
|
|
265
|
+
if (!trust.ok) return { ok: false, message: trust.message! };
|
|
266
|
+
return { ok: true, message: 'signature verifies against report.md (mugisig, ed25519-pure)' };
|
|
225
267
|
} catch {
|
|
226
268
|
return { ok: false, message: 'invalid .mugisig file' };
|
|
227
269
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Adaptive Budget & Circuit Breaker (Phase 7)
|
|
2
|
-
|
|
3
|
-
Reserve expected max before expensive stages (Review/Security/Healing); continuously project `current + remaining required + expected conditional + possible healing` (§26); expand budget only with evidence (§27 valid: scope legitimately expanded, security-sensitive path, test surface larger, architecture dependency, legitimate healing; invalid: verbosity/reread/repeat/unnecessary code); respect progressive thresholds (§28: 60%→optimize, 75%→aggressive, 90%→protect, 100%→pause, 150%→warning, 300%→stop); trip breaker when `actual ≥ 2× expected` without progress/scope/evidence (§29, note: double-threshold); flag 5k-zero-progress anomaly (§24, re-consumes slop signal); record every non-ok verdict via `recordBudgetDecision` (§41).
|
|
4
|
-
|
|
5
|
-
Honest boundary: verdicts-not-enforcement; crew acts. No new config; savepoint/lane-base untouched. Report/CLI budget ledger → Phase 8.
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Benchmark & Hardening — Full Checklist (Phase 9)
|
|
2
|
-
|
|
3
|
-
Tracks `scripts/benchmark-governor.ts` harness (deterministic, no network).
|
|
4
|
-
|
|
5
|
-
## Cost suite (§48) — 4 workloads
|
|
6
|
-
- [ ] lean-trivial: projected 8000 + overhead 1000, context ≤20000, evidence ≥1, surface files 2 loc 50
|
|
7
|
-
- [ ] standard-feature: projected 15000 + overhead 1500, context ≤40000, evidence ≥3
|
|
8
|
-
- [ ] large-repo: projected 22000 + overhead 2200, context ≤80000, evidence ≥5, surface 50 files
|
|
9
|
-
- [ ] long-mission: projected 23000 + overhead 2300, context ≤90000, 9 stages projection ≤ budget
|
|
10
|
-
- Check: `measured.tokens ≤ projected + overhead` else fail; `measured.context ≤ max` else fail
|
|
11
|
-
|
|
12
|
-
## Stop-Slop suite (§45) — 12 scenarios detect→classify→intervene
|
|
13
|
-
- [ ] endless-exploration → investigation slop → stop
|
|
14
|
-
- [ ] repeated-reads (3× no evidence) → context slop → stop; with concrete reason → tolerate
|
|
15
|
-
- [ ] repeated-commands (same cmd+evidence fail) → retry slop → stop
|
|
16
|
-
- [ ] repeated-failed-test → retry slop → stop
|
|
17
|
-
- [ ] repeated-reasoning → reasoning slop → stop
|
|
18
|
-
- [ ] unnecessary-abstraction → code slop → stop
|
|
19
|
-
- [ ] unnecessary-dependency → code slop → stop
|
|
20
|
-
- [ ] unrelated-refactor → scope slop → stop
|
|
21
|
-
- [ ] verbose-output → output slop → stop
|
|
22
|
-
- [ ] no-progress-healing (cycle ≥3, 0 fixes) → healing slop → stop
|
|
23
|
-
- [ ] premature-completion → scope slop → escalate
|
|
24
|
-
- [ ] excessive-context (repeated reads + duplicate chars) → context slop → stop
|
|
25
|
-
|
|
26
|
-
## Stress (bench-only, no runtime)
|
|
27
|
-
- [ ] large repository: 50 files within declared scope → pass (scope drift negative)
|
|
28
|
-
- [ ] long mission: 9 stages, projectBudget max ≤ full budget 50000 → pass
|
|
29
|
-
- [ ] runaway: actual 2× expected with no progress/scope/evidence → breaker tripped → fail (measures, not enforces)
|
|
30
|
-
|
|
31
|
-
## Thresholds (ratchet, like retrieval-eval)
|
|
32
|
-
- Thresholds live in `scripts/benchmark-thresholds.json` (or in-script THRESHOLDS const)
|
|
33
|
-
- `tokens > projected + overhead` → harness fails workload
|
|
34
|
-
- `context_chars > context_max` → fail
|
|
35
|
-
- Thresholds only move on explicit fixture update (reviewed diff), never silently
|
|
36
|
-
- `note: thresholds are fixture constants, not config — ratchet like retrieval-eval`
|
|
37
|
-
|
|
38
|
-
## Regression (§49)
|
|
39
|
-
- `checkRegression`: cost down but correctness/evidence/security/quality/scope down → fail
|
|
40
|
-
- Baseline from thresholds `baselines` + workload `expected_*`; measured vs baseline pure comparison
|
|
41
|
-
|
|
42
|
-
## Cross-platform & Determinism
|
|
43
|
-
- Harness pure over explicit fixture inputs, no Date.now/Math.random/network, deterministic on all platforms
|
|
44
|
-
- `scripts/conformance.ts` 12-platform parity proves cross-platform
|
|
45
|
-
|
|
46
|
-
## CI Enforcement
|
|
47
|
-
- `package.json:gate` includes `bun scripts/benchmark-governor.ts` (extend existing gate)
|
|
48
|
-
- `scripts/gate-selftest.ts` tampers thresholds → harness must exit 1 (G3 — gate that cannot fail is not a gate)
|
|
49
|
-
- note: harness measures, does not enforce — no runtime gate
|
|
50
|
-
|
|
51
|
-
## Docs
|
|
52
|
-
- `docs/concepts/cost.md` ## Benchmark & Hardening documents harness/threshold/stress contracts
|
|
53
|
-
- `docs/cost-governor.md` hub links to cost.md for deep contracts
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Cognitive & Output Governor
|
|
2
|
-
|
|
3
|
-
Reasoning stays focused — Question→Evidence→Decision→Action, no speculative architecture/hypothetical requirements/repeated reconsideration/unrelated implementations (§17); investigation terminates when acceptance_mapped+surface_understood+path_established or limits hit without concrete reason (§13); alternatives bounded to evidence-backed options (default 3).
|
|
4
|
-
|
|
5
|
-
Output compressed to mission-focused structure (Decision/Action/Result/Evidence/Blocker, §18), duplicate explanations fingerprinted; every cognitive verdict lands as a `cognitive-governor` trail row in `.mugiwara/missions/<mission>/decisions.md` → `## Cost governor decisions`. savepoint/lane-base/config untouched.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Scope & Code Governor
|
|
2
|
-
|
|
3
|
-
Prefer the smallest correct scope — reuse existing code + local modification
|
|
4
|
-
over new architecture (§14). An abstraction is justified only when used in ≥2
|
|
5
|
-
places or required by contract, never speculatively (§15); a dependency is
|
|
6
|
-
added only with explicit justification (§16); implementations are minimum
|
|
7
|
-
sufficient, never minimum LOC at the expense of verification/quality
|
|
8
|
-
(§15/§38).
|
|
9
|
-
|
|
10
|
-
Code waste (unnecessary helper/abstraction/wrapper/interface/config/
|
|
11
|
-
dependency/generated code/refactor) is named; the change surface is measured;
|
|
12
|
-
every scope verdict lands as a `scope-governor` trail row in
|
|
13
|
-
`.mugiwara/missions/<mission>/decisions.md` → `## Cost governor decisions`.
|
|
14
|
-
savepoint/lane-base/config untouched.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Stop-Slop Governor
|
|
2
|
-
|
|
3
|
-
Slop taxonomy (§21 eight kinds); detection signals (§22: repeated reads/commands,
|
|
4
|
-
token-without-evidence, LOC-without-acceptance, abstraction-without-justification);
|
|
5
|
-
progress measurement (§23: evidence/criteria/tests/code vs cost delta, slop when
|
|
6
|
-
cost grows without progress); work-to-cost anomaly (§24 drop signal); intervention
|
|
7
|
-
rules (§20 tolerate/stop/compress/escalate by severity); six category detectors
|
|
8
|
-
(retry §21.6/§31 same-action-same-evidence-same-failure→STOP, healing §21.7/§32
|
|
9
|
-
no-progress→stop, scope §21.8 out-of-scope-without-acceptance→reject, context
|
|
10
|
-
§21.2 duplicate/irrelevant→discard/compress, investigation §21.1 unbounded-
|
|
11
|
-
exploration→stop, code §21.5 unnecessary abstraction/dependency/boilerplate→
|
|
12
|
-
remove/simplify). Every slop verdict lands as a `slop-governor` trail row in
|
|
13
|
-
`.mugiwara/missions/<mission>/decisions.md` → `## Cost governor decisions`.
|
|
14
|
-
savepoint/lane-base/config untouched.
|