@1agh/maude 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6157,6 +6157,10 @@ export function createHttp(
6157
6157
  }
6158
6158
 
6159
6159
  // Fall-through: serve user repo files (designRoot + everything under repoRoot).
6160
+ // DNS rebinding (Phase 2 gate): a rebound page talks to this port with its own
6161
+ // name in Host, and this lane serves `/.env`, `/.git/config`, `/.ai/**` — the same
6162
+ // loopback-or-vouched-cell check the API routes use (`isTrustedRequestHost`).
6163
+ if (!isTrustedRequestHost(req)) return new Response('Forbidden', { status: 403 });
6160
6164
  const fp = safePathUnderRoot(req.url, ctx.paths.repoRoot);
6161
6165
  if (!fp) return new Response('Forbidden', { status: 403 });
6162
6166
 
@@ -427,6 +427,13 @@ function startServer(port: number): BunServer {
427
427
  status: 403,
428
428
  });
429
429
  }
430
+ // CSWSH (Phase 2 gate): a WS handshake bypasses SOP and every page in the
431
+ // browser sends a loopback Host to ws://localhost, so on a desktop a drive-by
432
+ // site could open this realm-'main' (ungated) socket. Same check as /_ws/acp.
433
+ // Not in a cell: the proxy authenticates and rewrites Host (D4).
434
+ if (!WORKSPACE && !isSameOriginWs(req)) {
435
+ return new Response('collab is same-origin only', { status: 403 });
436
+ }
430
437
  const ok = srv.upgrade(req, {
431
438
  data: {
432
439
  id: crypto.randomUUID(),
@@ -476,6 +483,11 @@ function startServer(port: number): BunServer {
476
483
 
477
484
  // Legacy inspector WS — JSON frames, designer-facing live tab state.
478
485
  if (pathname.startsWith('/_ws')) {
486
+ // CSWSH (Phase 2 gate) — the shell's own socket; a drive-by Origin is refused
487
+ // on a desktop like /_ws/acp and collab above (a cell's proxy vouches instead).
488
+ if (!WORKSPACE && !isSameOriginWs(req)) {
489
+ return new Response('inspector is same-origin only', { status: 403 });
490
+ }
479
491
  const ok = srv.upgrade(req, {
480
492
  data: {
481
493
  id: crypto.randomUUID(),
@@ -631,6 +643,12 @@ function startCanvasServer(
631
643
  if (!isLoopbackHost(req.headers.get('host')) && !vouchedRole) {
632
644
  return new Response('cross-machine collab requires Phase 9 hub deploy', { status: 403 });
633
645
  }
646
+ // CSWSH (Phase 2 gate) — the canvas iframe keeps its own origin
647
+ // (`allow-same-origin`), so only a page ON this canvas origin passes; a drive-by
648
+ // site could otherwise read the Y-doc and write comments/annotations here.
649
+ if (!WORKSPACE && !isSameOriginWs(req)) {
650
+ return new Response('collab is same-origin only', { status: 403 });
651
+ }
634
652
  const ok = srv.upgrade(req, {
635
653
  data: {
636
654
  id: crypto.randomUUID(),
@@ -653,8 +671,12 @@ function startCanvasServer(
653
671
  }
654
672
 
655
673
  // HMR-only socket — canvas iframes listen for `canvas-hmr` here. Carries
656
- // NO privileged inspector feed and ignores inbound messages (ws.ts).
674
+ // NO privileged inspector feed and ignores inbound messages (ws.ts) — but its
675
+ // frames name files (→ collab slugs), so a drive-by Origin is refused too.
657
676
  if (pathname.startsWith('/_ws')) {
677
+ if (!WORKSPACE && !isSameOriginWs(req)) {
678
+ return new Response('canvas socket is same-origin only', { status: 403 });
679
+ }
658
680
  const ok = srv.upgrade(req, {
659
681
  data: {
660
682
  id: crypto.randomUUID(),
package/cli/bin/maude.mjs CHANGED
@@ -20,6 +20,7 @@ const COMMANDS = {
20
20
  'scenario-report': () => import('../commands/scenario-report.mjs'),
21
21
  doctor: () => import('../commands/doctor.mjs'),
22
22
  kg: () => import('../commands/kg.mjs'),
23
+ flow: () => import('../commands/flow.mjs'),
23
24
  help: () => import('../commands/help.mjs'),
24
25
  hub: () => import('../commands/hub.mjs'),
25
26
  harness: () => import('../commands/harness.mjs'),
@@ -0,0 +1,62 @@
1
+ // `maude flow <verb>` — flow plugin helpers. Verbs: usage.
2
+ //
3
+ // maude flow usage [sessionId] [--top N] [--json] [--root <dir>]
4
+ //
5
+ // sessionId defaults to the /flow:run record of this project (~/.claude/flow-runs/). The over-budget flag uses
6
+ // run.budget.agentContextK (or its preset) from .ai/workflows.config.json.
7
+ import { readFileSync } from 'node:fs';
8
+ import { join, resolve } from 'node:path';
9
+ import {
10
+ findTranscript,
11
+ formatUsage,
12
+ resolveBudget,
13
+ runRecordPath,
14
+ sessionUsage,
15
+ } from '../lib/flow-usage.mjs';
16
+
17
+ const readJson = (p) => {
18
+ try {
19
+ return JSON.parse(readFileSync(p, 'utf8'));
20
+ } catch {
21
+ return null;
22
+ }
23
+ };
24
+
25
+ export async function run({ args }) {
26
+ const [verb, ...rest] = args;
27
+ if (verb !== 'usage') {
28
+ process.stderr.write('usage: maude flow usage [sessionId] [--top N] [--json] [--root <dir>]\n');
29
+ process.exitCode = 2;
30
+ return;
31
+ }
32
+ const opt = (name) => {
33
+ const i = rest.indexOf(name);
34
+ return i >= 0 ? rest[i + 1] : undefined;
35
+ };
36
+ const root = resolve(opt('--root') ?? process.env.CLAUDE_PROJECT_DIR ?? process.cwd());
37
+ const valued = new Set(['--top', '--root']);
38
+ const sid =
39
+ rest.find((a, i) => !a.startsWith('--') && !valued.has(rest[i - 1])) ??
40
+ readJson(runRecordPath(root))?.sessionId;
41
+ if (!sid) {
42
+ process.stderr.write(
43
+ 'maude flow usage: no sessionId given and no /flow:run record for this project\n'
44
+ );
45
+ process.exitCode = 1;
46
+ return;
47
+ }
48
+ const path = findTranscript(sid, { root });
49
+ if (!path) {
50
+ // Codex, or a transcript from another machine: report, never fail a gate.
51
+ process.stdout.write(`usage unavailable — no Claude Code transcript for session ${sid}\n`);
52
+ return;
53
+ }
54
+ const budget = resolveBudget(readJson(join(root, '.ai/workflows.config.json')));
55
+ const usage = sessionUsage(path);
56
+ if (rest.includes('--json')) {
57
+ process.stdout.write(`${JSON.stringify({ sessionId: sid, budget, ...usage }, null, 2)}\n`);
58
+ return;
59
+ }
60
+ const top = Number(opt('--top') ?? 25);
61
+ process.stdout.write(`${formatUsage(usage, { top, contextK: budget.agentContextK })}\n`);
62
+ }
@@ -58,7 +58,7 @@ COMMANDS
58
58
  Deterministically generate the mechanical sections of a cross-platform
59
59
  scenario report.md (TL;DR, counter-delta parity, per-step pivot, path
60
60
  listing) from a scenario run directory. The LLM authors only the prose
61
- sections. Used by /flow:scenario + the scenario-runner agent (DDR-061).
61
+ sections. Used by /flow:validate --scenario + the scenario-runner agent (DDR-061).
62
62
 
63
63
  hub serve [--port N] [--data PATH] [--secret HEX] [--insecure-http] [--dev]
64
64
  Start the self-hostable Yjs sync hub (Phase 9). Defaults to port 1234,
@@ -77,6 +77,11 @@ COMMANDS
77
77
  Plugin bin scripts + hooks call this via PATH instead of a relative
78
78
  cli/lib path that the marketplace never copies beside a plugin (DDR-061).
79
79
 
80
+ flow usage [sessionId] [--top N] [--json] [--root <dir>]
81
+ Token spend per agent of one Claude Code session: model, turns, peak
82
+ context, cache read/write. sessionId defaults to the /flow:run marker;
83
+ agents over run.budget.agentContextK are flagged.
84
+
80
85
  doctor [--plugin <name>] [--fix] [--json]
81
86
  Unified workspace health check. Reports missing dependencies, config
82
87
  schema errors, stack drift, and missing quality-gate declarations in
@@ -260,7 +260,7 @@ function printNextSteps(name, claudeMdExists, kgAvailable = false, usedKg = fals
260
260
  );
261
261
  }
262
262
  process.stdout.write(` 4. Create .ai/${name}-prd.md with your product brief.\n`);
263
- process.stdout.write(' 5. /flow:status to see where you are; /flow:plan to start work.\n');
263
+ process.stdout.write(' 5. /flow:run --status to see where you are; /flow:plan to start work.\n');
264
264
  printKgOffer(kgAvailable, usedKg);
265
265
  }
266
266
 
package/cli/lib/cache.mjs CHANGED
@@ -7,7 +7,7 @@
7
7
  // Used by:
8
8
  // - cli/commands/cache.mjs (`maude cache list|clear|inspect|stats`)
9
9
  // - plugins/design/agents/ux-research-agent.md (research/domain + research/project)
10
- // - plugins/flow/skills/codebase-intelligence/SKILL.md (codebase-intelligence)
10
+ // - plugins/flow/commands/init.md --map (codebase-intelligence layer)
11
11
  // - plugins/design/commands/{edit,new}.md (design-context)
12
12
  // - plugins/flow/commands/{done,validate,validate-security}.md (security)
13
13
  // - plugins/flow/commands/validate.md (validate — skip-if-clean)
@@ -488,7 +488,7 @@ function archiveMigratedSources(projectRoot, { dryRun = false, today } = {}) {
488
488
  };
489
489
 
490
490
  // A — decisions + their index. Under an active graph the README index has no
491
- // job left: `maude kg search` answers what it answered, and ddr-keeper no
491
+ // job left: `maude kg search` answers what it answered, and /flow:record-ddr no
492
492
  // longer appends to it.
493
493
  moveInto(join(ai, 'decisions'), join(arch, 'decisions'));
494
494
  // A — log verdicts (gitignored, so the graph is now their only inheritable copy).
@@ -519,7 +519,7 @@ function archiveMigratedSources(projectRoot, { dryRun = false, today } = {}) {
519
519
  }
520
520
  }
521
521
  }
522
- // A stale HANDOFF.md would be read by `/flow:resume` as if it were current,
522
+ // A stale HANDOFF.md would be read by `/flow:run --resume` as if it were current,
523
523
  // and under the graph it never gets refreshed again — the worst kind of stale.
524
524
  const handoff = join(ai, 'state', 'HANDOFF.md');
525
525
  if (existsSync(handoff)) {
@@ -0,0 +1,137 @@
1
+ // `maude flow usage` — token spend per agent of one Claude Code session (generalised from the Maude
2
+ // v2 run's scripts/v2-hooks/v2-usage.mjs). Reads the lead's transcript plus its subagents/ folder
3
+ // and reports, per agent: model, turns, peak context, cache read / write. Read-only; the numbers
4
+ // are the API usage blocks Claude Code already stores. Codex keeps no such transcript, so a missing
5
+ // transcript is reported as "unavailable" and never fails a gate.
6
+ import { createHash } from 'node:crypto';
7
+ import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
8
+ import { homedir } from 'node:os';
9
+ import { join } from 'node:path';
10
+
11
+ export const BUDGET_PRESETS = {
12
+ small: { agentTurns: 80, agentContextK: 150, handbackLines: 40, leadCheckpointPct: 60 },
13
+ default: { agentTurns: 150, agentContextK: 300, handbackLines: 60, leadCheckpointPct: 60 },
14
+ monorepo: { agentTurns: 150, agentContextK: 300, handbackLines: 60, leadCheckpointPct: 50 },
15
+ };
16
+
17
+ /** run.budget from a workflows config object → resolved numbers (preset + overrides). */
18
+ export function resolveBudget(config) {
19
+ const b = config?.run?.budget ?? {};
20
+ const base = BUDGET_PRESETS[b.preset] ?? BUDGET_PRESETS.default;
21
+ const out = { ...base };
22
+ for (const k of Object.keys(base)) if (Number.isFinite(b[k])) out[k] = b[k];
23
+ if (Number.isFinite(b.maxRunTokens)) out.maxRunTokens = b.maxRunTokens;
24
+ return out;
25
+ }
26
+
27
+ /** The /flow:run record of a project — mirrors recordPath() in plugins/flow/hooks/run-hook.mjs. */
28
+ export function runRecordPath(root, env = process.env) {
29
+ let real = root;
30
+ try {
31
+ real = realpathSync(root);
32
+ } catch {}
33
+ const dir = env.FLOW_RUN_HOME || join(homedir(), '.claude', 'flow-runs');
34
+ return join(dir, `${createHash('sha256').update(real).digest('hex').slice(0, 24)}.json`);
35
+ }
36
+
37
+ export const SESSION_ID = /^[A-Za-z0-9-]{1,64}$/;
38
+
39
+ /** Claude Code's project folder name for a cwd. */
40
+ export const projectSlug = (dir) => dir.replace(/[^A-Za-z0-9]/g, '-');
41
+
42
+ /** Per-transcript totals. Assistant messages repeat per content block — count each id once. */
43
+ export function scanTranscript(text) {
44
+ const seen = new Set();
45
+ const s = { model: '?', turns: 0, peak: 0, read: 0, write: 0, out: 0 };
46
+ for (const line of text.split('\n')) {
47
+ let d;
48
+ try {
49
+ d = JSON.parse(line);
50
+ } catch {
51
+ continue;
52
+ }
53
+ const m = d.message;
54
+ if (d.type !== 'assistant' || !m?.usage || seen.has(m.id)) continue;
55
+ seen.add(m.id);
56
+ const u = m.usage;
57
+ if (m.model && m.model !== '<synthetic>') s.model = m.model;
58
+ s.turns++;
59
+ s.read += u.cache_read_input_tokens ?? 0;
60
+ s.write += u.cache_creation_input_tokens ?? 0;
61
+ s.out += u.output_tokens ?? 0;
62
+ s.peak = Math.max(
63
+ s.peak,
64
+ (u.cache_read_input_tokens ?? 0) +
65
+ (u.cache_creation_input_tokens ?? 0) +
66
+ (u.input_tokens ?? 0)
67
+ );
68
+ }
69
+ return s;
70
+ }
71
+
72
+ /** The lead transcript for `sid`: the project folder of `root` first, then every project folder. */
73
+ export function findTranscript(
74
+ sid,
75
+ { root, home = homedir(), configDir = process.env.CLAUDE_CONFIG_DIR } = {}
76
+ ) {
77
+ if (!SESSION_ID.test(sid ?? '')) return null; // a session id is a path segment — no `../`
78
+ const bases = [configDir, join(home, '.claude')].filter(Boolean).map((b) => join(b, 'projects'));
79
+ for (const base of bases) {
80
+ if (!existsSync(base)) continue;
81
+ if (root) {
82
+ const p = join(base, projectSlug(root), `${sid}.jsonl`);
83
+ if (existsSync(p)) return p;
84
+ }
85
+ for (const d of readdirSync(base)) {
86
+ const p = join(base, d, `${sid}.jsonl`);
87
+ if (existsSync(p)) return p;
88
+ }
89
+ }
90
+ return null;
91
+ }
92
+
93
+ /** Lead + per-agent rows for one session, agents sorted by read+write. */
94
+ export function sessionUsage(leadPath) {
95
+ const lead = scanTranscript(readFileSync(leadPath, 'utf8'));
96
+ const sub = join(leadPath.replace(/\.jsonl$/, ''), 'subagents');
97
+ const agents = [];
98
+ if (existsSync(sub)) {
99
+ for (const f of readdirSync(sub).filter((f) => f.endsWith('.jsonl'))) {
100
+ let meta = {};
101
+ try {
102
+ meta = JSON.parse(readFileSync(join(sub, f.replace(/\.jsonl$/, '.meta.json')), 'utf8'));
103
+ } catch {}
104
+ agents.push({
105
+ ...scanTranscript(readFileSync(join(sub, f), 'utf8')),
106
+ type: meta.agentType ?? '?',
107
+ desc: meta.description ?? '',
108
+ });
109
+ }
110
+ }
111
+ agents.sort((a, b) => b.read + b.write - (a.read + a.write));
112
+ return { lead, agents };
113
+ }
114
+
115
+ const M = (n) => `${(n / 1e6).toFixed(1)}M`;
116
+ const K = (n) => `${Math.round(n / 1e3)}k`;
117
+
118
+ /** Text report in the v2-usage layout; agents whose peak passed the budget are flagged. */
119
+ export function formatUsage({ lead, agents }, { top = 25, contextK = 300 } = {}) {
120
+ const lines = [
121
+ `lead ${lead.model} turns=${lead.turns} peak=${K(lead.peak)} read=${M(lead.read)} write=${M(lead.write)}`,
122
+ ];
123
+ const tot = agents.reduce((t, r) => t + r.read + r.write, 0);
124
+ const all = tot + lead.read + lead.write;
125
+ const share = all ? Math.round((tot / all) * 100) : 0;
126
+ lines.push(
127
+ `subagents ${agents.length} read+write=${M(tot)} (lead ${M(lead.read + lead.write)}, agents ${share} %)`,
128
+ ''
129
+ );
130
+ for (const r of agents.slice(0, top)) {
131
+ const flag = r.peak > contextK * 1000 ? ` ! peak>${contextK}k` : '';
132
+ lines.push(
133
+ `${M(r.read + r.write).padStart(7)} ${String(r.turns).padStart(4)}t peak ${K(r.peak).padStart(5)} ${r.model.padEnd(16)} ${r.type.padEnd(16)} ${r.desc.slice(0, 50)}${flag}`
134
+ );
135
+ }
136
+ return lines.join('\n');
137
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1agh/maude",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Marketplace of Claude Code plugins by Michal Dovrtěl: `design` (canvas-first design iteration) + `flow` (generic agentic workflow loop with .ai second brain). Ships the `maude` CLI (with `mdcc` legacy alias) to scaffold workspace, run the design dev server, and manage configs.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,7 +29,7 @@
29
29
  "test:e2e:desktop:git": "pnpm --filter @maude/desktop-e2e e2e:git",
30
30
  "build": "pnpm -r --if-present --filter '!@maude/desktop' '!@maude/desktop-e2e' run build",
31
31
  "build:binary": "bun run apps/studio/build.ts --release",
32
- "test": "node --test --test-reporter=spec cli/**/*.test.mjs && pnpm --filter @maude/hub test && pnpm run test:harness",
32
+ "test": "node --test --test-reporter=spec cli/**/*.test.mjs plugins/flow/hooks/*.test.mjs && pnpm --filter @maude/hub test && pnpm run test:harness",
33
33
  "test:harness": "node --test $(find scripts/dev/sync-e2e -maxdepth 1 -name 'surface-*.test.mjs' ! -name 'surface-source-audit.test.mjs') && bun test scripts/dev/sync-e2e/surface-source-audit.test.mjs",
34
34
  "test:dev-server": "cd apps/studio && bun test --isolate --timeout 20000",
35
35
  "lint": "biome check .",
@@ -58,13 +58,13 @@
58
58
  "test:e2e:desktop:parity:cloud": "pnpm --filter @maude/desktop-e2e e2e:parity:cloud"
59
59
  },
60
60
  "optionalDependencies": {
61
- "@1agh/maude-darwin-arm64": "1.9.0",
62
- "@1agh/maude-darwin-x64": "1.9.0",
63
- "@1agh/maude-linux-arm64": "1.9.0",
64
- "@1agh/maude-linux-arm64-musl": "1.9.0",
65
- "@1agh/maude-linux-x64": "1.9.0",
66
- "@1agh/maude-linux-x64-musl": "1.9.0",
67
- "@1agh/maude-win32-x64": "1.9.0"
61
+ "@1agh/maude-darwin-arm64": "1.10.0",
62
+ "@1agh/maude-darwin-x64": "1.10.0",
63
+ "@1agh/maude-linux-arm64": "1.10.0",
64
+ "@1agh/maude-linux-arm64-musl": "1.10.0",
65
+ "@1agh/maude-linux-x64": "1.10.0",
66
+ "@1agh/maude-linux-x64-musl": "1.10.0",
67
+ "@1agh/maude-win32-x64": "1.10.0"
68
68
  },
69
69
  "files": [
70
70
  "cli",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "scenarioGuide": {
52
52
  "type": "string",
53
- "description": "Repo-owned scenario-testing knowledge/deltas file that flow:scenario reads for overrides — device/platform lifecycle, selector conventions, infra-error classification, platform-specific gotchas. Mirrors `integrations.changelog.releaseGuide`'s generic-skill-plus-repo-knowledge-file shape, but optional: unlike the release guide, flow:scenario runs its documented defaults when this file is absent — no project is required to author one. Scaffolded by `maude init`. Default: `.ai/scenario-guide.md`.",
53
+ "description": "Repo-owned scenario-testing knowledge/deltas file that /flow:validate --scenario reads for overrides — device/platform lifecycle, selector conventions, infra-error classification, platform-specific gotchas. Mirrors `integrations.changelog.releaseGuide`'s generic-skill-plus-repo-knowledge-file shape, but optional: unlike the release guide, flow:scenario runs its documented defaults when this file is absent — no project is required to author one. Scaffolded by `maude init`. Default: `.ai/scenario-guide.md`.",
54
54
  "default": ".ai/scenario-guide.md"
55
55
  }
56
56
  }
@@ -77,12 +77,12 @@
77
77
  },
78
78
  "bundleIdPrefix": {
79
79
  "type": "string",
80
- "description": "Native app bundle ID prefix (e.g. `com.acme.myapp`). Used by `/flow:utils-verify` and `/flow:scenario` when launching native builds. Omit for web-only projects."
80
+ "description": "Native app bundle ID prefix (e.g. `com.acme.myapp`). Used by `/flow:validate --fast` and `/flow:validate --scenario` when launching native builds. Omit for web-only projects."
81
81
  },
82
82
  "stack": {
83
83
  "type": "object",
84
84
  "additionalProperties": false,
85
- "description": "Auto-detected technology stack snapshot. Populated by /flow:init, refreshed by /flow:setup-codebase-map. Flow commands read this for routing decisions (e.g. which test runner to invoke, whether to gate on monorepo workspace builds). Use `unknown` when detection fails — never invent a value.",
85
+ "description": "Auto-detected technology stack snapshot. Populated by /flow:init, refreshed by /flow:init --map. Flow commands read this for routing decisions (e.g. which test runner to invoke, whether to gate on monorepo workspace builds). Use `unknown` when detection fails — never invent a value.",
86
86
  "properties": {
87
87
  "language": {
88
88
  "type": "string",
@@ -207,7 +207,7 @@
207
207
  },
208
208
  "densityMap": {
209
209
  "type": "object",
210
- "description": "Maps each entry in `platforms` to a density preset (`command-center` | `sideline-tool` | `palm-friendly` | `cozy` | `compact` | custom). responsive-rules uses this to flag wrong density per platform.",
210
+ "description": "Maps each entry in `platforms` to a density preset (`command-center` | `sideline-tool` | `palm-friendly` | `cozy` | `compact` | custom). flow:ui-rules uses this to flag wrong density per platform.",
211
211
  "additionalProperties": { "type": "string" },
212
212
  "default": {}
213
213
  },
@@ -305,6 +305,162 @@
305
305
  }
306
306
  }
307
307
  },
308
+ "run": {
309
+ "type": "object",
310
+ "additionalProperties": false,
311
+ "description": "Economy and unattended-run settings for /flow:execute and /flow:run (flow:context-budget skill). Every key is optional; an absent block keeps today's behaviour apart from the preset defaults the skill documents.",
312
+ "properties": {
313
+ "routing": {
314
+ "type": "object",
315
+ "additionalProperties": false,
316
+ "description": "Which tier and effort each role agent runs on. Defaults: worker fast/high, spike deep/high, scout fast/medium, critic fast.",
317
+ "properties": {
318
+ "worker": {
319
+ "type": "object",
320
+ "additionalProperties": false,
321
+ "description": "flow:worker — implements one plan task.",
322
+ "properties": {
323
+ "tier": {
324
+ "type": "string",
325
+ "enum": ["fast", "deep", "inherit"],
326
+ "description": "`fast` = the Sonnet-class model, `deep` = the Opus-class model, `inherit` = the lead's model. A tier, never a dated model id — the plugin maps it to the host alias."
327
+ },
328
+ "effort": {
329
+ "type": "string",
330
+ "enum": ["low", "medium", "high", "xhigh"]
331
+ }
332
+ }
333
+ },
334
+ "spike": {
335
+ "type": "object",
336
+ "additionalProperties": false,
337
+ "description": "flow:spike — resolves an open question.",
338
+ "properties": {
339
+ "tier": {
340
+ "type": "string",
341
+ "enum": ["fast", "deep", "inherit"],
342
+ "description": "`fast` = the Sonnet-class model, `deep` = the Opus-class model, `inherit` = the lead's model. A tier, never a dated model id — the plugin maps it to the host alias."
343
+ },
344
+ "effort": {
345
+ "type": "string",
346
+ "enum": ["low", "medium", "high", "xhigh"]
347
+ }
348
+ }
349
+ },
350
+ "scout": {
351
+ "type": "object",
352
+ "additionalProperties": false,
353
+ "description": "flow:scout — read-only fact finding.",
354
+ "properties": {
355
+ "tier": {
356
+ "type": "string",
357
+ "enum": ["fast", "deep", "inherit"],
358
+ "description": "`fast` = the Sonnet-class model, `deep` = the Opus-class model, `inherit` = the lead's model. A tier, never a dated model id — the plugin maps it to the host alias."
359
+ },
360
+ "effort": {
361
+ "type": "string",
362
+ "enum": ["low", "medium", "high", "xhigh"]
363
+ }
364
+ }
365
+ },
366
+ "critic": {
367
+ "type": "object",
368
+ "additionalProperties": false,
369
+ "description": "Rubric reviewers (design critics, a11y-auditor, scenario-runner, design-system-guard). The security pair always inherits.",
370
+ "properties": {
371
+ "tier": {
372
+ "type": "string",
373
+ "enum": ["fast", "deep", "inherit"],
374
+ "description": "`fast` = the Sonnet-class model, `deep` = the Opus-class model, `inherit` = the lead's model. A tier, never a dated model id — the plugin maps it to the host alias."
375
+ },
376
+ "effort": {
377
+ "type": "string",
378
+ "enum": ["low", "medium", "high", "xhigh"]
379
+ }
380
+ }
381
+ }
382
+ }
383
+ },
384
+ "riskClasses": {
385
+ "type": "array",
386
+ "items": {
387
+ "type": "string",
388
+ "minLength": 1
389
+ },
390
+ "description": "Globs or plan tags (e.g. `auth/**`, `migration`) that send a task's worker to the deep tier."
391
+ },
392
+ "budget": {
393
+ "type": "object",
394
+ "additionalProperties": false,
395
+ "description": "Per-agent context budget. `preset` picks the defaults (see flow:context-budget); explicit keys override it.",
396
+ "properties": {
397
+ "preset": {
398
+ "type": "string",
399
+ "enum": ["small", "default", "monorepo"],
400
+ "default": "default"
401
+ },
402
+ "agentTurns": {
403
+ "type": "integer",
404
+ "minimum": 10
405
+ },
406
+ "agentContextK": {
407
+ "type": "integer",
408
+ "minimum": 50
409
+ },
410
+ "handbackLines": {
411
+ "type": "integer",
412
+ "minimum": 10
413
+ },
414
+ "leadCheckpointPct": {
415
+ "type": "integer",
416
+ "minimum": 20,
417
+ "maximum": 95
418
+ },
419
+ "maxRunTokens": {
420
+ "type": "integer",
421
+ "minimum": 1,
422
+ "description": "/flow:run only: total read+write tokens after which the Stop hook checkpoints and lets the run stop. Absent = no ceiling."
423
+ }
424
+ }
425
+ },
426
+ "largeFileKB": {
427
+ "type": "integer",
428
+ "minimum": 1,
429
+ "default": 64,
430
+ "description": "Files above this size are read by range, never whole."
431
+ },
432
+ "gates": {
433
+ "type": "string",
434
+ "enum": ["per-batch", "per-task"],
435
+ "default": "per-batch",
436
+ "description": "When /flow:execute runs the full `quality` gates: after each batch of related tasks (default) or after every task. Workers always run their focused tests."
437
+ },
438
+ "lane": {
439
+ "type": "string",
440
+ "minLength": 1,
441
+ "description": "Optional wrapper that serialises test suites, invoked as `<lane> -- <command>` (e.g. a script that takes a machine-wide lock). Absent = suites run directly."
442
+ },
443
+ "hooks": {
444
+ "type": "boolean",
445
+ "default": false,
446
+ "description": "/flow:run hooks (SubagentStart rules, SubagentStop Decisions check, Stop gate). OFF by default; every hook is a no-op unless this is true AND /flow:run armed this session (record in ~/.claude/flow-runs/, outside the project). Kill switch for one shell: FLOW_RUN_HOOKS=0."
447
+ },
448
+ "maxStopBlocks": {
449
+ "type": "integer",
450
+ "minimum": 1,
451
+ "maximum": 20,
452
+ "default": 3,
453
+ "description": "/flow:run: identical red done-checks in a row after which the Stop hook writes the waiting file and lets the session stop."
454
+ },
455
+ "expiresHours": {
456
+ "type": "integer",
457
+ "minimum": 1,
458
+ "maximum": 72,
459
+ "default": 24,
460
+ "description": "/flow:run: hours after arming when the run expires and every hook becomes a no-op (clamped to 1–72)."
461
+ }
462
+ }
463
+ },
308
464
  "knowledgeGraph": {
309
465
  "type": "object",
310
466
  "additionalProperties": false,
@@ -380,7 +536,7 @@
380
536
  "type": "string",
381
537
  "enum": ["low", "medium", "high", "critical"],
382
538
  "default": "medium",
383
- "description": "Lowest severity that blocks /flow:validate step 6.5 and /flow:validate-security. Findings below this rate as warnings, not blockers."
539
+ "description": "Lowest severity that blocks /flow:validate step 6.5 and /flow:validate --security. Findings below this rate as warnings, not blockers."
384
540
  },
385
541
  "scope": {
386
542
  "type": "array",
@@ -461,7 +617,7 @@
461
617
  },
462
618
  "qualityScoped": {
463
619
  "type": "object",
464
- "description": "Scoped (changed-files / changed-packages-only) gate variants for the IMPLEMENTATION inner loop (`/flow:utils-verify`, per-task `/flow:execute`, `/flow:bug-fix`). Same flat shape as `quality` — gate name → shell command string, keys mirror `quality` (conventionally `lint`, `format`, `typecheck`, `tests`). During implementation these run INSTEAD of the repo-wide `quality.*` commands; a missing key means the inner loop defers that gate to `/flow:validate` (it never falls back to the repo-wide command). `/flow:validate` and `/flow:done` ignore this block entirely — the full `quality.*` pipeline remains the single outer gate. Monorepo example: `\"lint\": \"turbo run lint --filter='[origin/main]'\"` — note changed-only `[base]`, NOT dependents-inclusive `...[base]`, which selects nearly the whole monorepo whenever a shared package is touched; dependent breakage is `/flow:validate`'s job.",
620
+ "description": "Scoped (changed-files / changed-packages-only) gate variants for the IMPLEMENTATION inner loop (`/flow:validate --fast`, per-task `/flow:execute`, `/flow:bug-fix`). Same flat shape as `quality` — gate name → shell command string, keys mirror `quality` (conventionally `lint`, `format`, `typecheck`, `tests`). During implementation these run INSTEAD of the repo-wide `quality.*` commands; a missing key means the inner loop defers that gate to `/flow:validate` (it never falls back to the repo-wide command). `/flow:validate` and `/flow:done` ignore this block entirely — the full `quality.*` pipeline remains the single outer gate. Monorepo example: `\"lint\": \"turbo run lint --filter='[origin/main]'\"` — note changed-only `[base]`, NOT dependents-inclusive `...[base]`, which selects nearly the whole monorepo whenever a shared package is touched; dependent breakage is `/flow:validate`'s job.",
465
621
  "additionalProperties": {
466
622
  "type": "string",
467
623
  "minLength": 1
@@ -475,7 +631,7 @@
475
631
  "tracker": {
476
632
  "type": "object",
477
633
  "additionalProperties": false,
478
- "description": "Issue / task tracker. Used by /flow:done, /flow:bug-rca, /flow:bug-fix and /flow:status to optionally read, create or update tickets. `orbit` additionally routes /flow:plan (find or create the task), /flow:execute (working-state reports) and /flow:done (close-time artifact push, warn-only) through the `orbit-backend` skill.",
634
+ "description": "Issue / task tracker. Used by /flow:done, /flow:bug-rca, /flow:bug-fix and /flow:run --status to optionally read, create or update tickets. `orbit` additionally routes /flow:plan (find or create the task), /flow:execute (working-state reports) and /flow:done (close-time artifact push, warn-only) through the `orbit-backend` skill.",
479
635
  "properties": {
480
636
  "provider": {
481
637
  "type": "string",
@@ -581,7 +737,7 @@
581
737
  "changelog": {
582
738
  "type": "object",
583
739
  "additionalProperties": false,
584
- "description": "Release-note / changelog tooling. Used by /flow:validate and /flow:done to remind (soft warning) about missing release notes, by /flow:release-changelog to author entries, and by /flow:release to walk the project-owned release runbook. Phase 3 implements the `changesets` provider; other enum values are accepted but treated as no-op until their providers land.",
740
+ "description": "Release-note / changelog tooling. Used by /flow:validate and /flow:done to remind (soft warning) about missing release notes, by /flow:release --changelog to author entries, and by /flow:release to walk the project-owned release runbook. Phase 3 implements the `changesets` provider; other enum values are accepted but treated as no-op until their providers land.",
585
741
  "properties": {
586
742
  "provider": {
587
743
  "type": "string",