@agent-surface/cli 0.9.0 → 0.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.
@@ -112,56 +112,8 @@ async function createSurfaceRunner(configPath) {
112
112
  }
113
113
  }
114
114
 
115
- // src/output.ts
116
- function isPlain(flags) {
117
- if (flags.json) return true;
118
- if (flags.plain) return true;
119
- if (process.env["CI"]) return true;
120
- if (process.env["NO_COLOR"]) return true;
121
- if (process.stdout.isTTY !== true) return true;
122
- return !process.stdout.columns;
123
- }
124
- function write(text) {
125
- process.stdout.write(`${text}
126
- `);
127
- }
128
- function writeError(text) {
129
- process.stderr.write(`${text}
130
- `);
131
- }
132
- var cached;
133
- async function loadInk() {
134
- if (cached !== void 0) return cached;
135
- try {
136
- cached = await import("./ink-GCWDO4ML.js");
137
- } catch {
138
- cached = null;
139
- }
140
- return cached;
141
- }
142
- async function paint(element) {
143
- const { render } = await import("ink");
144
- const instance = render(element);
145
- instance.unmount();
146
- await instance.waitUntilExit();
147
- }
148
- async function transient(element) {
149
- const { render } = await import("ink");
150
- const instance = render(element);
151
- return () => {
152
- instance.clear();
153
- instance.unmount();
154
- };
155
- }
156
-
157
115
  export {
158
116
  findConfig,
159
- createSurfaceRunner,
160
- isPlain,
161
- write,
162
- writeError,
163
- loadInk,
164
- paint,
165
- transient
117
+ createSurfaceRunner
166
118
  };
167
- //# sourceMappingURL=chunk-S2LM3N6D.js.map
119
+ //# sourceMappingURL=chunk-FYEXHWGG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/load.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { createServer, type ViteDevServer } from \"vite\";\nimport { ViteNodeServer } from \"vite-node/server\";\nimport { ViteNodeRunner } from \"vite-node/client\";\nimport { installSourcemapsSupport } from \"vite-node/source-map\";\nimport type { CollectOptions, CollectResult } from \"./collect.js\";\nimport type { SurfaceConfig } from \"./config.js\";\n\nconst CONFIG_NAMES = [\n \"agent-surface.config.tsx\",\n \"agent-surface.config.ts\",\n \"agent-surface.config.mjs\",\n \"agent-surface.config.js\",\n];\n\n/** Walks up from `from` looking for an `agent-surface.config.*`. */\nexport function findConfig(from: string = process.cwd()): string | undefined {\n let dir = resolve(from);\n for (;;) {\n for (const name of CONFIG_NAMES) {\n const candidate = join(dir, name);\n if (existsSync(candidate)) return candidate;\n }\n const parent = dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n\n/** `dist/collect.js` when installed; `src/collect.ts` when run from source. */\nfunction collectorPath(): string {\n for (const ext of [\"js\", \"ts\"]) {\n const candidate = fileURLToPath(new URL(`./collect.${ext}`, import.meta.url));\n if (existsSync(candidate)) return candidate;\n }\n throw new Error(\"could not locate the agent-surface collector module\");\n}\n\nexport interface SurfaceRunner {\n config: SurfaceConfig;\n scenarioNames: string[];\n collect(options: CollectOptions): Promise<CollectResult>;\n close(): Promise<void>;\n}\n\n/**\n * Boots a Vite dev server on the app's own config, so the config file and the\n * app modules it imports are transformed and resolved exactly as the app\n * resolves them — its aliases, its plugins, its TSX.\n */\nexport async function createSurfaceRunner(configPath: string): Promise<SurfaceRunner> {\n const absoluteConfig = isAbsolute(configPath) ? configPath : resolve(configPath);\n if (!existsSync(absoluteConfig)) {\n throw new Error(`config not found: ${absoluteConfig}`);\n }\n const root = dirname(absoluteConfig);\n\n let server: ViteDevServer;\n try {\n server = await createServer({\n root,\n logLevel: \"error\",\n // `serve` so plugins behave as they do in dev; nothing is ever served.\n server: { middlewareMode: true, watch: null, fs: { strict: false } },\n optimizeDeps: { noDiscovery: true, include: [] },\n resolve: {\n // Both halves of the graph must agree on these. React because two\n // copies break hooks; core because `explainSurface` finds the registry\n // through a Symbol, which is per-module-instance (see collect.ts).\n dedupe: [\n \"react\",\n \"react-dom\",\n \"@agent-surface/core\",\n \"@agent-surface/react\",\n \"@agent-surface/testing\",\n ],\n },\n });\n } catch (error) {\n throw new Error(\n `could not start Vite for ${root}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n\n try {\n await server.pluginContainer.buildStart({});\n } catch {\n // Vite keeps moving this; a plugin that needs buildStart will say so itself.\n }\n\n const nodeServer = new ViteNodeServer(server);\n installSourcemapsSupport({ getSourceMap: (source) => nodeServer.getSourceMap(source) });\n\n const runner = new ViteNodeRunner({\n root: server.config.root,\n base: server.config.base,\n fetchModule: (id) => nodeServer.fetchModule(id),\n resolveId: (id, importer) => nodeServer.resolveId(id, importer),\n });\n\n const close = async (): Promise<void> => {\n await server.close();\n };\n\n try {\n const configModule = (await runner.executeFile(absoluteConfig)) as {\n default?: SurfaceConfig;\n };\n const config = configModule.default;\n if (!config || typeof config.mount !== \"function\") {\n throw new Error(\n `${absoluteConfig} must \\`export default defineSurface({ mount, scenarios })\\``,\n );\n }\n const scenarioNames = Object.keys(config.scenarios ?? {});\n if (scenarioNames.length === 0) {\n throw new Error(`${absoluteConfig} defines no scenarios`);\n }\n\n // Same runner ⇒ same module graph ⇒ the collector shares React and core\n // with the app tree it is about to mount.\n const collector = (await runner.executeFile(collectorPath())) as {\n collect(config: SurfaceConfig, options: CollectOptions): Promise<CollectResult>;\n };\n\n return {\n config,\n scenarioNames,\n collect: async (options) => {\n // Scoped to the mount, never process-wide: `act()` needs it, and Ink\n // renders its own React tree afterwards — with the flag still set,\n // every frame of the CLI's own UI prints React's \"not wrapped in\n // act(...)\" warning at the user.\n const globals = globalThis as Record<string, unknown>;\n const previous = globals[\"IS_REACT_ACT_ENVIRONMENT\"];\n globals[\"IS_REACT_ACT_ENVIRONMENT\"] = true;\n try {\n return await collector.collect(config, options);\n } finally {\n globals[\"IS_REACT_ACT_ENVIRONMENT\"] = previous;\n }\n },\n close,\n };\n } catch (error) {\n await close();\n throw error;\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,YAAY,MAAM,eAAe;AACnD,SAAS,qBAAqB;AAC9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AACA,kBAAQ,0BAA0B,IAAI;AAAA,QACxC;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,UAAM,MAAM;AACZ,UAAM;AAAA,EACR;AACF;","names":[]}
package/dist/collect.js CHANGED
@@ -20,12 +20,29 @@ async function collect(config, options) {
20
20
  // Inert copies: the live objects are frozen and graph-local, and only
21
21
  // plain JSON may cross back into the CLI process.
22
22
  snapshot: jsonify(mount.mounted.registry.snapshot(ctx)),
23
- explanation: jsonify(explainSurface(mount.mounted.registry, ctx))
23
+ explanation: jsonify(explainSurface(mount.mounted.registry, ctx)),
24
+ // The harness subscribes to the registry when it is constructed, which is
25
+ // before the tree renders — so this is the whole mount, not what happened
26
+ // to still be pending when the render finished.
27
+ rejections: rejectionsFrom(mount.surface.events()),
28
+ ...scope ? { scope } : {}
24
29
  };
25
30
  } finally {
26
31
  mount.surface.dispose();
27
32
  }
28
33
  }
34
+ function rejectionsFrom(events) {
35
+ const rejections = [];
36
+ for (const event of events) {
37
+ if (event.type !== "component-rejected") continue;
38
+ rejections.push({
39
+ componentType: event.componentType,
40
+ instanceId: event.instanceId,
41
+ reason: event.reason
42
+ });
43
+ }
44
+ return rejections;
45
+ }
29
46
  function jsonify(value) {
30
47
  return JSON.parse(JSON.stringify(value));
31
48
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/collect.ts"],"sourcesContent":["/**\n * The collector — the *only* module the CLI executes inside the vite-node\n * graph, and the reason that boundary exists.\n *\n * Two things force it:\n *\n * 1. **One React.** The app's component tree resolves React through the app's\n * own Vite config. If the mount ran in the CLI's Node graph instead, a\n * second React copy would render it and every hook would throw.\n *\n * 2. **One `@agent-surface/core`.** `explainSurface()` reaches the registry\n * through a plain `Symbol` seam, and a symbol is only equal to itself within\n * one module instance. Load core twice and the seam silently misses. So the\n * explanation is computed *here*, beside the registry that owns it.\n *\n * Everything crosses back as plain JSON. Nothing live — no registry, no React\n * element, no policy function — escapes into the CLI process.\n */\nimport { explainSurface, type SurfaceExplanation } from \"@agent-surface/core/explain\";\nimport type { AgentConsumer, AgentSurfaceSnapshot, SnapshotContext } from \"@agent-surface/core\";\nimport type { SurfaceConfig } from \"./config.js\";\nimport { mountScenario } from \"./mount.js\";\n\nexport interface CollectOptions {\n scenario: string;\n consumer?: AgentConsumer;\n scope?: string[];\n}\n\nexport interface CollectResult {\n scenario: string;\n snapshot: AgentSurfaceSnapshot;\n explanation: SurfaceExplanation;\n}\n\nexport async function collect(\n config: SurfaceConfig,\n options: CollectOptions,\n): Promise<CollectResult> {\n const mount = await mountScenario(config, options.scenario, {\n ...(options.consumer ? { consumer: options.consumer } : {}),\n });\n const scope = options.scope ?? config.scope;\n const ctx: SnapshotContext = {\n consumer: mount.consumer,\n includeUnavailable: true,\n ...(scope ? { scope } : {}),\n };\n\n try {\n return {\n scenario: options.scenario,\n // Inert copies: the live objects are frozen and graph-local, and only\n // plain JSON may cross back into the CLI process.\n snapshot: jsonify(mount.mounted.registry.snapshot(ctx)),\n explanation: jsonify(explainSurface(mount.mounted.registry, ctx)),\n };\n } finally {\n mount.surface.dispose();\n }\n}\n\nfunction jsonify<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n"],"mappings":";;;;;AAkBA,SAAS,sBAA+C;AAiBxD,eAAsB,QACpB,QACA,SACwB;AACxB,QAAM,QAAQ,MAAM,cAAc,QAAQ,QAAQ,UAAU;AAAA,IAC1D,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,EAC3D,CAAC;AACD,QAAM,QAAQ,QAAQ,SAAS,OAAO;AACtC,QAAM,MAAuB;AAAA,IAC3B,UAAU,MAAM;AAAA,IAChB,oBAAoB;AAAA,IACpB,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;AAAA,EAC3B;AAEA,MAAI;AACF,WAAO;AAAA,MACL,UAAU,QAAQ;AAAA;AAAA;AAAA,MAGlB,UAAU,QAAQ,MAAM,QAAQ,SAAS,SAAS,GAAG,CAAC;AAAA,MACtD,aAAa,QAAQ,eAAe,MAAM,QAAQ,UAAU,GAAG,CAAC;AAAA,IAClE;AAAA,EACF,UAAE;AACA,UAAM,QAAQ,QAAQ;AAAA,EACxB;AACF;AAEA,SAAS,QAAW,OAAa;AAC/B,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;","names":[]}
1
+ {"version":3,"sources":["../src/collect.ts"],"sourcesContent":["/**\n * The collector — the *only* module the CLI executes inside the vite-node\n * graph, and the reason that boundary exists.\n *\n * Two things force it:\n *\n * 1. **One React.** The app's component tree resolves React through the app's\n * own Vite config. If the mount ran in the CLI's Node graph instead, a\n * second React copy would render it and every hook would throw.\n *\n * 2. **One `@agent-surface/core`.** `explainSurface()` reaches the registry\n * through a plain `Symbol` seam, and a symbol is only equal to itself within\n * one module instance. Load core twice and the seam silently misses. So the\n * explanation is computed *here*, beside the registry that owns it.\n *\n * Everything crosses back as plain JSON. Nothing live — no registry, no React\n * element, no policy function — escapes into the CLI process.\n */\nimport { explainSurface, type SurfaceExplanation } from \"@agent-surface/core/explain\";\nimport type {\n AgentConsumer,\n AgentSurfaceEvent,\n AgentSurfaceSnapshot,\n SnapshotContext,\n} from \"@agent-surface/core\";\nimport type { SurfaceConfig } from \"./config.js\";\nimport { mountScenario } from \"./mount.js\";\n\nexport interface CollectOptions {\n scenario: string;\n consumer?: AgentConsumer;\n scope?: string[];\n}\n\n/**\n * A registration the registry refused while the scenario mounted (`AS-CLI-006`).\n *\n * Rejection is the one failure that is invisible everywhere else. The handle is\n * dead, so the capability never reaches the snapshot; the registration never\n * became active, so `explainSurface()` does not iterate it either. The only\n * diagnostic core emits goes through `devError`, which prints nothing unless\n * the app was built with `environment: \"development\"` — and the config shape\n * this CLI documents builds it with `\"test\"`.\n */\nexport interface RegistrationRejection {\n componentType: string;\n instanceId: string;\n reason: \"duplicate\" | \"guard\";\n}\n\nexport interface CollectResult {\n scenario: string;\n snapshot: AgentSurfaceSnapshot;\n explanation: SurfaceExplanation;\n /** Refused during this mount. Empty on a healthy one. */\n rejections: RegistrationRejection[];\n /** The scope the two projections above were computed under, when one was set. */\n scope?: string[];\n}\n\nexport async function collect(\n config: SurfaceConfig,\n options: CollectOptions,\n): Promise<CollectResult> {\n const mount = await mountScenario(config, options.scenario, {\n ...(options.consumer ? { consumer: options.consumer } : {}),\n });\n const scope = options.scope ?? config.scope;\n const ctx: SnapshotContext = {\n consumer: mount.consumer,\n includeUnavailable: true,\n ...(scope ? { scope } : {}),\n };\n\n try {\n return {\n scenario: options.scenario,\n // Inert copies: the live objects are frozen and graph-local, and only\n // plain JSON may cross back into the CLI process.\n snapshot: jsonify(mount.mounted.registry.snapshot(ctx)),\n explanation: jsonify(explainSurface(mount.mounted.registry, ctx)),\n // The harness subscribes to the registry when it is constructed, which is\n // before the tree renders — so this is the whole mount, not what happened\n // to still be pending when the render finished.\n rejections: rejectionsFrom(mount.surface.events()),\n ...(scope ? { scope } : {}),\n };\n } finally {\n mount.surface.dispose();\n }\n}\n\nfunction rejectionsFrom(events: readonly AgentSurfaceEvent[]): RegistrationRejection[] {\n const rejections: RegistrationRejection[] = [];\n for (const event of events) {\n if (event.type !== \"component-rejected\") continue;\n rejections.push({\n componentType: event.componentType,\n instanceId: event.instanceId,\n reason: event.reason,\n });\n }\n return rejections;\n}\n\nfunction jsonify<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n"],"mappings":";;;;;AAkBA,SAAS,sBAA+C;AA0CxD,eAAsB,QACpB,QACA,SACwB;AACxB,QAAM,QAAQ,MAAM,cAAc,QAAQ,QAAQ,UAAU;AAAA,IAC1D,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,EAC3D,CAAC;AACD,QAAM,QAAQ,QAAQ,SAAS,OAAO;AACtC,QAAM,MAAuB;AAAA,IAC3B,UAAU,MAAM;AAAA,IAChB,oBAAoB;AAAA,IACpB,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;AAAA,EAC3B;AAEA,MAAI;AACF,WAAO;AAAA,MACL,UAAU,QAAQ;AAAA;AAAA;AAAA,MAGlB,UAAU,QAAQ,MAAM,QAAQ,SAAS,SAAS,GAAG,CAAC;AAAA,MACtD,aAAa,QAAQ,eAAe,MAAM,QAAQ,UAAU,GAAG,CAAC;AAAA;AAAA;AAAA;AAAA,MAIhE,YAAY,eAAe,MAAM,QAAQ,OAAO,CAAC;AAAA,MACjD,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;AAAA,IAC3B;AAAA,EACF,UAAE;AACA,UAAM,QAAQ,QAAQ;AAAA,EACxB;AACF;AAEA,SAAS,eAAe,QAA+D;AACrF,QAAM,aAAsC,CAAC;AAC7C,aAAW,SAAS,QAAQ;AAC1B,QAAI,MAAM,SAAS,qBAAsB;AACzC,eAAW,KAAK;AAAA,MACd,eAAe,MAAM;AAAA,MACrB,YAAY,MAAM;AAAA,MAClB,QAAQ,MAAM;AAAA,IAChB,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,SAAS,QAAW,OAAa;AAC/B,SAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;AACzC;","names":[]}
@@ -0,0 +1,133 @@
1
+ import {
2
+ authoredIds,
3
+ extractCapabilities,
4
+ renderCoveragePlain,
5
+ unresolved
6
+ } from "./chunk-4AEQKM2X.js";
7
+ import {
8
+ createSurfaceRunner
9
+ } from "./chunk-FYEXHWGG.js";
10
+ import {
11
+ write
12
+ } from "./chunk-A27Y7ALQ.js";
13
+ import {
14
+ baselineDirFor
15
+ } from "./chunk-ODUIFFPM.js";
16
+
17
+ // src/commands/coverage.ts
18
+ import { dirname } from "path";
19
+
20
+ // src/coverage.ts
21
+ import { existsSync, readFileSync } from "fs";
22
+ import { join } from "path";
23
+ var ALLOWLIST_FILE = "coverage-allow.json";
24
+ function allowlistPathFor(baselineDir) {
25
+ return join(baselineDir, ALLOWLIST_FILE);
26
+ }
27
+ function readAllowlist(path) {
28
+ if (!existsSync(path)) return {};
29
+ let parsed;
30
+ try {
31
+ parsed = JSON.parse(readFileSync(path, "utf8"));
32
+ } catch (error) {
33
+ throw new Error(
34
+ `could not parse ${path}: ${error instanceof Error ? error.message : String(error)}`
35
+ );
36
+ }
37
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
38
+ throw new Error(`${path} must be a JSON object of { "capabilityId": "reason" }`);
39
+ }
40
+ const allowlist = {};
41
+ for (const [id, reason] of Object.entries(parsed)) {
42
+ if (typeof reason !== "string" || reason.trim() === "") {
43
+ throw new Error(`${path}: "${id}" needs a non-empty reason string`);
44
+ }
45
+ allowlist[id] = reason;
46
+ }
47
+ return allowlist;
48
+ }
49
+ function buildCoverageReport(input) {
50
+ const unreached = [];
51
+ const allowed = [];
52
+ for (const id of [...input.authored].sort()) {
53
+ if (input.reachedIds.has(id)) continue;
54
+ if (id in input.allowlist) {
55
+ allowed.push(id);
56
+ continue;
57
+ }
58
+ unreached.push({ capabilityId: id, origin: input.origins.get(id) ?? { file: "?", line: 0 } });
59
+ }
60
+ const staleAllowlist = Object.keys(input.allowlist).filter((id) => input.reachedIds.has(id) || !input.authored.has(id)).sort();
61
+ const unaccounted = [...input.reachedIds].filter((id) => !input.authored.has(id)).sort();
62
+ const domainReached = unaccounted.filter((id) => id.startsWith("domain:"));
63
+ const undeclared = unaccounted.filter((id) => !id.startsWith("domain:"));
64
+ return {
65
+ authored: input.authored.size,
66
+ reached: [...input.authored].filter((id) => input.reachedIds.has(id)).length,
67
+ scenarios: input.scenarios,
68
+ unreached,
69
+ undeclared,
70
+ domainReached,
71
+ unresolved: input.unresolved,
72
+ allowed,
73
+ staleAllowlist,
74
+ allowlistPath: input.allowlistPath
75
+ };
76
+ }
77
+ function coverageExitCode(report) {
78
+ if (report.unreached.length > 0) return 1;
79
+ if (report.unresolved.length > 0) return 1;
80
+ if (report.staleAllowlist.length > 0) return 1;
81
+ return 0;
82
+ }
83
+
84
+ // src/commands/coverage.ts
85
+ async function runCoverage(options) {
86
+ const root = dirname(options.configPath);
87
+ const inventory = extractCapabilities({
88
+ root,
89
+ ...options.tsconfig ? { tsconfig: options.tsconfig } : {}
90
+ });
91
+ const authored = authoredIds(inventory);
92
+ const origins = /* @__PURE__ */ new Map();
93
+ for (const capability of inventory.capabilities) {
94
+ if (!origins.has(capability.capabilityId)) origins.set(capability.capabilityId, capability.origin);
95
+ }
96
+ const runner = await createSurfaceRunner(options.configPath);
97
+ try {
98
+ const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;
99
+ const reachedIds = /* @__PURE__ */ new Set();
100
+ for (const scenario of scenarios) {
101
+ const result = await runner.collect({
102
+ scenario,
103
+ ...options.scope ? { scope: options.scope } : {}
104
+ });
105
+ for (const capability of result.explanation.capabilities) {
106
+ reachedIds.add(capability.capabilityId);
107
+ }
108
+ }
109
+ const dir = baselineDirFor(
110
+ options.configPath,
111
+ options.baselineDir ?? runner.config.baselineDir
112
+ );
113
+ const allowlistPath = allowlistPathFor(dir);
114
+ const report = buildCoverageReport({
115
+ authored,
116
+ origins,
117
+ reachedIds,
118
+ scenarios,
119
+ unresolved: unresolved(inventory),
120
+ allowlist: readAllowlist(allowlistPath),
121
+ allowlistPath
122
+ });
123
+ if (options.json) write(JSON.stringify(report, null, 2));
124
+ else write(renderCoveragePlain(report));
125
+ return coverageExitCode(report);
126
+ } finally {
127
+ await runner.close();
128
+ }
129
+ }
130
+ export {
131
+ runCoverage
132
+ };
133
+ //# sourceMappingURL=coverage-HCHLJTDD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/coverage.ts","../src/coverage.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport { createSurfaceRunner } from \"../load.js\";\nimport { baselineDirFor } from \"../baseline.js\";\nimport { authoredIds, extractCapabilities, unresolved } from \"../extract.js\";\nimport {\n allowlistPathFor,\n buildCoverageReport,\n coverageExitCode,\n readAllowlist,\n} from \"../coverage.js\";\nimport { renderCoveragePlain } from \"../render/plain.js\";\nimport { write } from \"../output.js\";\n\nexport interface CoverageOptions {\n configPath: string;\n scenario?: string;\n scope?: string[];\n tsconfig?: string;\n baselineDir?: string;\n json?: boolean;\n plain?: boolean;\n}\n\n/**\n * Joins the two halves: the static inventory (what is authored) against the\n * union of every scenario's explanation (what is reached).\n *\n * The join key is `capabilityId`, which is instance-independent by\n * construction — `instanceId` is not part of it — so two mounted instances of\n * one component collapse onto the one authored entry, which is what a coverage\n * question means.\n */\nexport async function runCoverage(options: CoverageOptions): Promise<number> {\n const root = dirname(options.configPath);\n const inventory = extractCapabilities({\n root,\n ...(options.tsconfig ? { tsconfig: options.tsconfig } : {}),\n });\n\n const authored = authoredIds(inventory);\n const origins = new Map<string, { file: string; line: number }>();\n for (const capability of inventory.capabilities) {\n if (!origins.has(capability.capabilityId)) origins.set(capability.capabilityId, capability.origin);\n }\n\n const runner = await createSurfaceRunner(options.configPath);\n try {\n const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;\n const reachedIds = new Set<string>();\n\n for (const scenario of scenarios) {\n const result = await runner.collect({\n scenario,\n ...(options.scope ? { scope: options.scope } : {}),\n });\n // Reached means present in the *explanation*, not the snapshot — see\n // BuildCoverageInput.reachedIds for why hiding still counts as reaching.\n for (const capability of result.explanation.capabilities) {\n reachedIds.add(capability.capabilityId);\n }\n }\n\n const dir = baselineDirFor(\n options.configPath,\n options.baselineDir ?? runner.config.baselineDir,\n );\n const allowlistPath = allowlistPathFor(dir);\n const report = buildCoverageReport({\n authored,\n origins,\n reachedIds,\n scenarios,\n unresolved: unresolved(inventory),\n allowlist: readAllowlist(allowlistPath),\n allowlistPath,\n });\n\n if (options.json) write(JSON.stringify(report, null, 2));\n else write(renderCoveragePlain(report));\n\n // AS-CLI-002's contract: 0 clean, 1 a gap, 2 usage.\n return coverageExitCode(report);\n } finally {\n await runner.close();\n }\n}\n","/**\n * `coverage` — authored minus reached (`AS-COVER-004…005`, D36).\n *\n * The inventory says what the codebase authors; the scenarios say what a mount\n * surfaces. Neither half alone answers \"which authored capability does no\n * scenario reach\", because that is a set difference no command computed.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AuthoredCapability } from \"./extract.js\";\n\nexport const ALLOWLIST_FILE = \"coverage-allow.json\";\n\n/**\n * A committed list of unreached capabilities a repository has decided not to\n * fix yet, each with a reason. Adoption has to ratchet rather than gate: a\n * codebase turning this on with 200 unreached capabilities cannot fix them in\n * one pull request, and a check that can only be adopted big-bang is a check\n * that never gets adopted.\n */\nexport type CoverageAllowlist = Record<string, string>;\n\nexport function allowlistPathFor(baselineDir: string): string {\n return join(baselineDir, ALLOWLIST_FILE);\n}\n\nexport function readAllowlist(path: string): CoverageAllowlist {\n if (!existsSync(path)) return {};\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(path, \"utf8\"));\n } catch (error) {\n throw new Error(\n `could not parse ${path}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n throw new Error(`${path} must be a JSON object of { \"capabilityId\": \"reason\" }`);\n }\n const allowlist: CoverageAllowlist = {};\n for (const [id, reason] of Object.entries(parsed as Record<string, unknown>)) {\n if (typeof reason !== \"string\" || reason.trim() === \"\") {\n throw new Error(`${path}: \"${id}\" needs a non-empty reason string`);\n }\n allowlist[id] = reason;\n }\n return allowlist;\n}\n\nexport interface UnreachedCapability {\n capabilityId: string;\n origin: { file: string; line: number };\n}\n\nexport interface CoverageReport {\n /** Distinct capability ids the inventory resolved. */\n authored: number;\n /** How many of them at least one scenario surfaced. */\n reached: number;\n scenarios: string[];\n /** Authored, surfaced by no scenario, and not allowlisted — the finding. */\n unreached: UnreachedCapability[];\n /**\n * Present at runtime with no static origin: a dynamic registration, or a gap\n * in the extractor. `view:` only — see `domainReached`.\n */\n undeclared: string[];\n /**\n * `domain:` capabilities a scenario surfaced. Held apart from `undeclared`\n * because the inventory never claimed to analyze that plane: filing them as\n * \"no static origin\" would report the design's own stated boundary as a\n * defect, which is the misleading check this whole command rejects.\n */\n domainReached: string[];\n /** Carried forward from the inventory. */\n unresolved: AuthoredCapability[];\n /** Unreached, but listed in the allowlist. */\n allowed: string[];\n /** Listed in the allowlist and reached anyway — the list has rotted. */\n staleAllowlist: string[];\n allowlistPath: string;\n}\n\nexport interface BuildCoverageInput {\n authored: Set<string>;\n /** First origin seen for each authored id, for the report. */\n origins: Map<string, { file: string; line: number }>;\n /**\n * Every capability id any scenario's *explanation* held.\n *\n * The explanation, not the snapshot. A capability a policy hid **was**\n * reached: a scenario mounted it and the policy made a deliberate decision\n * about it. Classifying those as unreached would flood the report with the\n * library's own correct behaviour — in the example app the `anonymous`\n * scenario alone would contribute eleven false gaps.\n */\n reachedIds: Set<string>;\n scenarios: string[];\n unresolved: AuthoredCapability[];\n allowlist: CoverageAllowlist;\n allowlistPath: string;\n}\n\nexport function buildCoverageReport(input: BuildCoverageInput): CoverageReport {\n const unreached: UnreachedCapability[] = [];\n const allowed: string[] = [];\n\n for (const id of [...input.authored].sort()) {\n if (input.reachedIds.has(id)) continue;\n if (id in input.allowlist) {\n allowed.push(id);\n continue;\n }\n unreached.push({ capabilityId: id, origin: input.origins.get(id) ?? { file: \"?\", line: 0 } });\n }\n\n // An allowlist entry that is no longer unreached fails the command, so the\n // list shrinks and cannot silently rot — the same idiom as the baselines\n // `check` already commits.\n const staleAllowlist = Object.keys(input.allowlist)\n .filter((id) => input.reachedIds.has(id) || !input.authored.has(id))\n .sort();\n\n const unaccounted = [...input.reachedIds].filter((id) => !input.authored.has(id)).sort();\n const domainReached = unaccounted.filter((id) => id.startsWith(\"domain:\"));\n const undeclared = unaccounted.filter((id) => !id.startsWith(\"domain:\"));\n\n return {\n authored: input.authored.size,\n reached: [...input.authored].filter((id) => input.reachedIds.has(id)).length,\n scenarios: input.scenarios,\n unreached,\n undeclared,\n domainReached,\n unresolved: input.unresolved,\n allowed,\n staleAllowlist,\n allowlistPath: input.allowlistPath,\n };\n}\n\n/**\n * `0` clean, `1` a gap.\n *\n * `undeclared` deliberately does not fail (OQ-4): a dynamically registered\n * capability is legitimate, and from the outside it is indistinguishable from\n * an extractor that missed something. Failing on it would punish the honest\n * case to catch the other one. It is reported, loudly, and revisited when a\n * codebase does it deliberately.\n */\nexport function coverageExitCode(report: CoverageReport): number {\n if (report.unreached.length > 0) return 1;\n if (report.unresolved.length > 0) return 1;\n if (report.staleAllowlist.length > 0) return 1;\n return 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,eAAe;;;ACOxB,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AAGd,IAAM,iBAAiB;AAWvB,SAAS,iBAAiB,aAA6B;AAC5D,SAAO,KAAK,aAAa,cAAc;AACzC;AAEO,SAAS,cAAc,MAAiC;AAC7D,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO,CAAC;AAC/B,MAAI;AACJ,MAAI;AACF,aAAS,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;AAAA,EAChD,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,mBAAmB,IAAI,KAAK,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,IACpF;AAAA,EACF;AACA,MAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,GAAG;AAC1E,UAAM,IAAI,MAAM,GAAG,IAAI,wDAAwD;AAAA,EACjF;AACA,QAAM,YAA+B,CAAC;AACtC,aAAW,CAAC,IAAI,MAAM,KAAK,OAAO,QAAQ,MAAiC,GAAG;AAC5E,QAAI,OAAO,WAAW,YAAY,OAAO,KAAK,MAAM,IAAI;AACtD,YAAM,IAAI,MAAM,GAAG,IAAI,MAAM,EAAE,mCAAmC;AAAA,IACpE;AACA,cAAU,EAAE,IAAI;AAAA,EAClB;AACA,SAAO;AACT;AAwDO,SAAS,oBAAoB,OAA2C;AAC7E,QAAM,YAAmC,CAAC;AAC1C,QAAM,UAAoB,CAAC;A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22,10 +22,121 @@ import 'react';
22
22
  * element, no policy function — escapes into the CLI process.
23
23
  */
24
24
 
25
+ /**
26
+ * A registration the registry refused while the scenario mounted (`AS-CLI-006`).
27
+ *
28
+ * Rejection is the one failure that is invisible everywhere else. The handle is
29
+ * dead, so the capability never reaches the snapshot; the registration never
30
+ * became active, so `explainSurface()` does not iterate it either. The only
31
+ * diagnostic core emits goes through `devError`, which prints nothing unless
32
+ * the app was built with `environment: "development"` — and the config shape
33
+ * this CLI documents builds it with `"test"`.
34
+ */
35
+ interface RegistrationRejection {
36
+ componentType: string;
37
+ instanceId: string;
38
+ reason: "duplicate" | "guard";
39
+ }
25
40
  interface CollectResult {
26
41
  scenario: string;
27
42
  snapshot: AgentSurfaceSnapshot;
28
43
  explanation: SurfaceExplanation;
44
+ /** Refused during this mount. Empty on a healthy one. */
45
+ rejections: RegistrationRejection[];
46
+ /** The scope the two projections above were computed under, when one was set. */
47
+ scope?: string[];
48
+ }
49
+
50
+ interface AuthoredCapability {
51
+ /** Canonical id, instance-independent: `view:devices.table.sort`. */
52
+ capabilityId: string;
53
+ kind: "observation" | "action" | "procedure";
54
+ /** Where a human can go and read it. */
55
+ origin: {
56
+ file: string;
57
+ line: number;
58
+ };
59
+ /** Literals recovered from the call site; absent when not statically known. */
60
+ description?: string;
61
+ effect?: string;
62
+ /**
63
+ * How much of this call site the extractor understood.
64
+ *
65
+ * `static` — identity and metadata both recovered from literals.
66
+ * `partial` — identity resolved, some metadata dynamic. The common case: a
67
+ * spread `instanceId`, or a description built from a template.
68
+ * `unresolved` — identity NOT resolved. Reported, never dropped.
69
+ */
70
+ resolution: "static" | "partial" | "unresolved";
71
+ /** Present on `partial`/`unresolved`: what defeated the extractor. */
72
+ note?: string;
73
+ }
74
+ interface CapabilityInventory {
75
+ capabilities: AuthoredCapability[];
76
+ /** Absolute path to the tsconfig whose file list was analyzed. */
77
+ tsconfig: string;
78
+ /** Directory the analysis was rooted at — the surface config's own. */
79
+ root: string;
80
+ /** Files the program actually walked — the inventory's blast radius. */
81
+ filesAnalyzed: number;
82
+ /**
83
+ * Program files skipped for living outside `root` — workspace packages the
84
+ * app's tsconfig aliases in, typically the library's own source. Reported
85
+ * rather than dropped silently: a boundary nobody can see is a boundary
86
+ * nobody can check.
87
+ */
88
+ filesOutsideRoot: number;
89
+ /**
90
+ * The `domain:` plane is deliberately *not* analyzed here. Those capabilities
91
+ * come from the oRPC router, which is already a static export (OQ-1), and
92
+ * reporting zero of them would read as "there are none" rather than "nobody
93
+ * looked".
94
+ */
95
+ domain: "not-analyzed";
96
+ }
97
+
98
+ /**
99
+ * A committed list of unreached capabilities a repository has decided not to
100
+ * fix yet, each with a reason. Adoption has to ratchet rather than gate: a
101
+ * codebase turning this on with 200 unreached capabilities cannot fix them in
102
+ * one pull request, and a check that can only be adopted big-bang is a check
103
+ * that never gets adopted.
104
+ */
105
+ type CoverageAllowlist = Record<string, string>;
106
+ interface UnreachedCapability {
107
+ capabilityId: string;
108
+ origin: {
109
+ file: string;
110
+ line: number;
111
+ };
112
+ }
113
+ interface CoverageReport {
114
+ /** Distinct capability ids the inventory resolved. */
115
+ authored: number;
116
+ /** How many of them at least one scenario surfaced. */
117
+ reached: number;
118
+ scenarios: string[];
119
+ /** Authored, surfaced by no scenario, and not allowlisted — the finding. */
120
+ unreached: UnreachedCapability[];
121
+ /**
122
+ * Present at runtime with no static origin: a dynamic registration, or a gap
123
+ * in the extractor. `view:` only — see `domainReached`.
124
+ */
125
+ undeclared: string[];
126
+ /**
127
+ * `domain:` capabilities a scenario surfaced. Held apart from `undeclared`
128
+ * because the inventory never claimed to analyze that plane: filing them as
129
+ * "no static origin" would report the design's own stated boundary as a
130
+ * defect, which is the misleading check this whole command rejects.
131
+ */
132
+ domainReached: string[];
133
+ /** Carried forward from the inventory. */
134
+ unresolved: AuthoredCapability[];
135
+ /** Unreached, but listed in the allowlist. */
136
+ allowed: string[];
137
+ /** Listed in the allowlist and reached anyway — the list has rotted. */
138
+ staleAllowlist: string[];
139
+ allowlistPath: string;
29
140
  }
30
141
 
31
- export type { CollectResult };
142
+ export type { AuthoredCapability, CapabilityInventory, CollectResult, CoverageAllowlist, CoverageReport, RegistrationRejection };
@@ -65,17 +65,42 @@ function Header({ view }) {
65
65
  return /* @__PURE__ */ jsxs(Box, { children: [
66
66
  /* @__PURE__ */ jsx(Text, { bold: true, children: view.scenario }),
67
67
  view.route ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${view.route}` }) : null,
68
+ view.scope && view.scope.length > 0 ? /* @__PURE__ */ jsx(Text, { color: "cyan", children: ` scope ${view.scope.join(" ")}` }) : null,
68
69
  /* @__PURE__ */ jsx(Text, { dimColor: true, children: " \xB7 " }),
69
70
  /* @__PURE__ */ jsx(Text, { color: "green", children: `${view.counts.callable} callable` }),
70
71
  /* @__PURE__ */ jsx(Text, { dimColor: true, children: ", " }),
71
72
  /* @__PURE__ */ jsx(Text, { color: "yellow", children: `${view.counts.disabled} visible-disabled` }),
72
- view.explained ? /* @__PURE__ */ jsxs(Fragment, { children: [
73
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: ", " }),
74
+ /* @__PURE__ */ jsx(Text, { color: "red", children: `${view.counts.hidden} hidden` }),
75
+ view.rejections.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
73
76
  /* @__PURE__ */ jsx(Text, { dimColor: true, children: ", " }),
74
- /* @__PURE__ */ jsx(Text, { color: "red", children: `${view.counts.hidden} hidden` })
77
+ /* @__PURE__ */ jsx(Text, { color: "magenta", children: `${view.rejections.length} registration${view.rejections.length === 1 ? "" : "s"} rejected` })
75
78
  ] }) : null
76
79
  ] });
77
80
  }
81
+ function Rejections({ view }) {
82
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
83
+ /* @__PURE__ */ jsxs(Box, { children: [
84
+ /* @__PURE__ */ jsx(Text, { backgroundColor: "magenta", color: "black", bold: true, children: " rejected during mount " }),
85
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${view.rejections.length}` })
86
+ ] }),
87
+ view.rejections.map((rejection) => /* @__PURE__ */ jsxs(Box, { children: [
88
+ /* @__PURE__ */ jsx(Text, { color: "magenta", children: " ! " }),
89
+ /* @__PURE__ */ jsx(Text, { bold: true, children: `${rejection.componentType} (${rejection.instanceId})` }),
90
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: rejection.reason === "duplicate" ? " duplicate \u2014 an earlier registration holds this key" : " guard \u2014 onRegister rejected this registration" })
91
+ ] }, `${rejection.componentType}@${rejection.instanceId}-${rejection.reason}`))
92
+ ] });
93
+ }
78
94
  function Empty({ view }) {
95
+ if (view.counts.hidden > 0) {
96
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
97
+ /* @__PURE__ */ jsxs(Text, { dimColor: true, wrap: "wrap", children: [
98
+ `Nothing is callable here \u2014 all ${view.counts.hidden} registered capabilities were hidden by policy. `,
99
+ "The surface is empty by decision, not because nothing was annotated."
100
+ ] }),
101
+ view.explained ? null : /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Re-run with --explain to see which policy hid them." })
102
+ ] });
103
+ }
79
104
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
80
105
  /* @__PURE__ */ jsx(Text, { dimColor: true, wrap: "wrap", children: "Nothing is registered for this scenario \u2014 the agent has no surface here. That is the default: capabilities exist only where they were explicitly annotated." }),
81
106
  view.explained ? null : /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Re-run with --explain to see whether a policy hid it." })
@@ -89,6 +114,7 @@ function Surface({ view }) {
89
114
  ];
90
115
  return /* @__PURE__ */ jsx(Static, { items: blocks, children: (block) => block.group ? /* @__PURE__ */ jsx(Group, { group: block.group }, block.key) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
91
116
  /* @__PURE__ */ jsx(Header, { view }),
117
+ view.rejections.length > 0 ? /* @__PURE__ */ jsx(Rejections, { view }) : null,
92
118
  populated.length === 0 ? /* @__PURE__ */ jsx(Empty, { view }) : null
93
119
  ] }, block.key) });
94
120
  }
@@ -119,4 +145,4 @@ export {
119
145
  Loading,
120
146
  Surface
121
147
  };
122
- //# sourceMappingURL=ink-GCWDO4ML.js.map
148
+ //# sourceMappingURL=ink-HBPOQTRS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/render/ink.tsx"],"sourcesContent":["import type { ReactElement } from \"react\";\nimport { Box, Static, Text } from \"ink\";\nimport Spinner from \"ink-spinner\";\nimport type { CapabilityRow, CapabilityGroup, SurfaceView } from \"./model.js\";\nimport type { DiffEntry } from \"../baseline.js\";\nimport { formatValue } from \"../baseline.js\";\n\nconst OUTCOME = {\n expose: { mark: \"●\", color: \"green\" as const },\n disable: { mark: \"◐\", color: \"yellow\" as const },\n hide: { mark: \"○\", color: \"red\" as const },\n};\n\nexport function Loading({ label }: { label: string }): ReactElement {\n return (\n <Text>\n <Text color=\"cyan\">\n <Spinner type=\"dots\" />\n </Text>\n {` ${label}`}\n </Text>\n );\n}\n\nfunction PolicyLine({\n policy,\n}: {\n policy: NonNullable<CapabilityRow[\"policies\"]>[number];\n}): ReactElement {\n const vote = policy.discovery?.decision;\n const color = vote === \"hide\" ? \"red\" : vote === \"disable\" ? \"yellow\" : \"green\";\n return (\n <Box paddingLeft={6}>\n <Text dimColor>policy </Text>\n <Text bold>{policy.name}</Text>\n <Text dimColor>{` (${policy.scope}${policy.phases.length ? `, ${policy.phases.join(\"/\")}` : \"\"}) `}</Text>\n {vote ? (\n <Text color={color}>\n {vote}\n {policy.discovery?.decision === \"disable\" ? ` — ${policy.discovery.reason}` : \"\"}\n </Text>\n ) : (\n <Text dimColor>no discovery hook</Text>\n )}\n {policy.threw ? <Text color=\"red\" bold>{\" THREW\"}</Text> : null}\n {policy.confirmationEscalation ? (\n <Text color=\"magenta\">{\" escalates-confirmation\"}</Text>\n ) : null}\n </Box>\n );\n}\n\nfunction Capability({ row }: { row: CapabilityRow }): ReactElement {\n const outcome = OUTCOME[row.outcome];\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text color={outcome.color}>{` ${outcome.mark} `}</Text>\n <Text bold>{row.name}</Text>\n {row.tags.length > 0 ? <Text dimColor>{` ${row.tags.join(\" · \")}`}</Text> : null}\n </Box>\n <Box paddingLeft={4}>\n <Text dimColor wrap=\"wrap\">\n {row.description}\n </Text>\n </Box>\n {row.reason ? (\n <Box paddingLeft={4}>\n <Text color=\"yellow\" wrap=\"wrap\">{`⤷ ${row.reason}`}</Text>\n </Box>\n ) : null}\n {row.policies\n ? row.policies.length > 0\n ? row.policies.map((policy, index) => (\n <PolicyLine key={`${policy.name}-${index}`} policy={policy} />\n ))\n : [\n <Box key=\"none\" paddingLeft={6}>\n <Text dimColor>policies: none</Text>\n </Box>,\n ]\n : null}\n {row.policies && row.availability && !row.availability.available ? (\n <Box paddingLeft={6}>\n <Text dimColor>{`availability: unavailable${\n row.availability.reason ? ` — ${row.availability.reason}` : \"\"\n }`}</Text>\n </Box>\n ) : null}\n {row.schemas?.input !== undefined ? (\n <Box paddingLeft={6}>\n <Text dimColor wrap=\"wrap\">{`input: ${JSON.stringify(row.schemas.input)}`}</Text>\n </Box>\n ) : null}\n {row.schemas?.output !== undefined ? (\n <Box paddingLeft={6}>\n <Text dimColor wrap=\"wrap\">{`output: ${JSON.stringify(row.schemas.output)}`}</Text>\n </Box>\n ) : null}\n </Box>\n );\n}\n\nfunction Group({ group }: { group: CapabilityGroup }): ReactElement {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text backgroundColor=\"blueBright\" color=\"black\" bold>{` ${group.heading} `}</Text>\n <Text dimColor>{` ${group.rows.length}`}</Text>\n </Box>\n {group.rows.map((row) => (\n <Capability key={`${row.capabilityId}-${row.name}`} row={row} />\n ))}\n </Box>\n );\n}\n\n/**\n * The header states everything the counts are relative to (`AS-CLI-007`): the\n * scenario, the route, and the scope when one is active — a scope filters both\n * projections, so an unqualified count reads as a claim about the whole surface.\n * `hidden` is unconditional here for the same reason it is in plain text.\n */\nfunction Header({ view }: { view: SurfaceView }): ReactElement {\n return (\n <Box>\n <Text bold>{view.scenario}</Text>\n {view.route ? <Text dimColor>{` ${view.route}`}</Text> : null}\n {view.scope && view.scope.length > 0 ? (\n <Text color=\"cyan\">{` scope ${view.scope.join(\" \")}`}</Text>\n ) : null}\n <Text dimColor>{\" · \"}</Text>\n <Text color=\"green\">{`${view.counts.callable} callable`}</Text>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"yellow\">{`${view.counts.disabled} visible-disabled`}</Text>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"red\">{`${view.counts.hidden} hidden`}</Text>\n {view.rejections.length > 0 ? (\n <>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"magenta\">\n {`${view.rejections.length} registration${\n view.rejections.length === 1 ? \"\" : \"s\"\n } rejected`}\n </Text>\n </>\n ) : null}\n </Box>\n );\n}\n\n/**\n * Rejected registrations (`AS-CLI-006`). A dead handle leaves no trace in either\n * projection, so without this block a copy-pasted component `type` removes a\n * capability and prints nothing anywhere.\n */\nfunction Rejections({ view }: { view: SurfaceView }): ReactElement {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text backgroundColor=\"magenta\" color=\"black\" bold>\n {\" rejected during mount \"}\n </Text>\n <Text dimColor>{` ${view.rejections.length}`}</Text>\n </Box>\n {view.rejections.map((rejection) => (\n <Box key={`${rejection.componentType}@${rejection.instanceId}-${rejection.reason}`}>\n <Text color=\"magenta\">{\" ! \"}</Text>\n <Text bold>{`${rejection.componentType} (${rejection.instanceId})`}</Text>\n <Text dimColor>\n {rejection.reason === \"duplicate\"\n ? \" duplicate — an earlier registration holds this key\"\n : \" guard — onRegister rejected this registration\"}\n </Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nfunction Empty({ view }: { view: SurfaceView }): ReactElement {\n if (view.counts.hidden > 0) {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Text dimColor wrap=\"wrap\">\n {`Nothing is callable here — all ${view.counts.hidden} registered capabilities were hidden by policy. `}\n The surface is empty by decision, not because nothing was annotated.\n </Text>\n {view.explained ? null : (\n <Text dimColor>Re-run with --explain to see which policy hid them.</Text>\n )}\n </Box>\n );\n }\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Text dimColor wrap=\"wrap\">\n Nothing is registered for this scenario — the agent has no surface here. That is the\n default: capabilities exist only where they were explicitly annotated.\n </Text>\n {view.explained ? null : (\n <Text dimColor>Re-run with --explain to see whether a policy hid it.</Text>\n )}\n </Box>\n );\n}\n\ntype Block = { key: string; group?: CapabilityGroup };\n\nexport function Surface({ view }: { view: SurfaceView }): ReactElement {\n const populated = view.groups.filter((group) => group.rows.length > 0);\n\n // Everything goes through <Static>, header included. Ink paints static output\n // once, permanently, above the live frame — and erases the live frame on\n // unmount. A one-shot render that leaves anything outside <Static> therefore\n // prints it and then wipes it, which is exactly what happened to this header.\n const blocks: Block[] = [\n { key: \"__header\" },\n ...populated.map((group) => ({ key: group.heading, group })),\n ];\n\n return (\n <Static items={blocks}>\n {(block) =>\n block.group ? (\n <Group key={block.key} group={block.group} />\n ) : (\n <Box key={block.key} flexDirection=\"column\">\n <Header view={view} />\n {view.rejections.length > 0 ? <Rejections view={view} /> : null}\n {populated.length === 0 ? <Empty view={view} /> : null}\n </Box>\n )\n }\n </Static>\n );\n}\n\nexport function Drift({\n scenario,\n entries,\n}: {\n scenario: string;\n entries: DiffEntry[];\n}): ReactElement {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text backgroundColor=\"yellow\" color=\"black\" bold>{` ${scenario} `}</Text>\n <Text dimColor>{` ${entries.length} change${entries.length === 1 ? \"\" : \"s\"}`}</Text>\n </Box>\n {entries.map((entry) => (\n <Box key={`${entry.kind}-${entry.path}`} flexDirection=\"column\" paddingLeft={2}>\n {entry.subject ? (\n <Text bold>\n {entry.subject}\n <Text dimColor>{` ${entry.path}`}</Text>\n </Text>\n ) : null}\n {entry.kind === \"added\" ? (\n <Text color=\"green\" wrap=\"wrap\">{`+ ${entry.path} ${formatValue(entry.after)}`}</Text>\n ) : entry.kind === \"removed\" ? (\n <Text color=\"red\" wrap=\"wrap\">{`- ${entry.path} ${formatValue(entry.before)}`}</Text>\n ) : (\n <>\n <Text color=\"yellow\">{`~ ${entry.path}`}</Text>\n <Text color=\"red\" wrap=\"wrap\">{` before: ${formatValue(entry.before)}`}</Text>\n <Text color=\"green\" wrap=\"wrap\">{` after: ${formatValue(entry.after)}`}</Text>\n </>\n )}\n </Box>\n ))}\n </Box>\n );\n}\n"],"mappings":";;;;;AACA,SAAS,KAAK,QAAQ,YAAY;AAClC,OAAO,aAAa;AAahB,SA2HI,UAzHA,KAFJ;AARJ,IAAM,UAAU;AAAA,EACd,QAAQ,EAAE,MAAM,UAAK,OAAO,QAAiB;AAAA,EAC7C,SAAS,EAAE,MAAM,UAAK,OAAO,SAAkB;AAAA,EAC/C,MAAM,EAAE,MAAM,UAAK,OAAO,MAAe;AAC3C;AAEO,SAAS,QAAQ,EAAE,MAAM,GAAoC;AAClE,SACE,qBAAC,QACC;AAAA,wBAAC,QAAK,OAAM,QACV,8BAAC,WAAQ,MAAK,QAAO,GACvB;AAAA,IACC,IAAI,KAAK;AAAA,KACZ;AAEJ;AAEA,SAAS,WAAW;AAAA,EAClB;AACF,GAEiB;AACf,QAAM,OAAO,OAAO,WAAW;AAC/B,QAAM,QAAQ,SAAS,SAAS,QAAQ,SAAS,YAAY,WAAW;AACxE,SACE,qBAAC,OAAI,aAAa,GAChB;AAAA,wBAAC,QAAK,UAAQ,MAAC,qBAAO;AAAA,IACtB,oBAAC,QAAK,MAAI,MAAE,iBAAO,MAAK;AAAA,IACxB,oBAAC,QAAK,UAAQ,MAAE,eAAK,OAAO,KAAK,GAAG,OAAO,OAAO,SAAS,KAAK,OAAO,OAAO,KAAK,GAAG,CAAC,KAAK,EAAE,MAAK;AAAA,IAClG,OACC,qBAAC,QAAK,OACH;AAA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I,CAAC,UACZ,qBAAC,OAAwC,eAAc,UAAS,aAAa,GAC1E;AAAA,YAAM,UACL,qBAAC,QAAK,MAAI,MACP;AAAA,cAAM;AAAA,QACP,oBAAC,QAAK,UAAQ,MAAE,eAAK,MAAM,IAAI,IAAG;AAAA,SACpC,IACE;AAAA,MACH,MAAM,SAAS,UACd,oBAAC,QAAK,OAAM,SAAQ,MAAK,QAAQ,eAAK,MAAM,IAAI,KAAK,YAAY,MAAM,KAAK,CAAC,IAAG,IAC9E,MAAM,SAAS,YACjB,oBAAC,QAAK,OAAM,OAAM,MAAK,QAAQ,eAAK,MAAM,IAAI,KAAK,YAAY,MAAM,MAAM,CAAC,IAAG,IAE/E,iCACE;AAAA,4BAAC,QAAK,OAAM,UAAU,eAAK,MAAM,IAAI,IAAG;AAAA,QACxC,oBAAC,QAAK,OAAM,OAAM,MAAK,QAAQ,yBAAe,YAAY,MAAM,MAAM,CAAC,IAAG;AAAA,QAC1E,oBAAC,QAAK,OAAM,SAAQ,MAAK,QAAQ,yBAAe,YAAY,MAAM,KAAK,CAAC,IAAG;AAAA,SAC7E;AAAA,SAhBM,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,EAkBrC,CACD;AAAA,KACH;AAEJ;","names":[]}
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  renderSurfacePlain
3
- } from "./chunk-KZUR4CAU.js";
3
+ } from "./chunk-4AEQKM2X.js";
4
+ import {
5
+ createSurfaceRunner
6
+ } from "./chunk-FYEXHWGG.js";
4
7
  import {
5
- createSurfaceRunner,
6
8
  isPlain,
7
9
  loadInk,
8
10
  paint,
9
11
  transient,
10
12
  write
11
- } from "./chunk-S2LM3N6D.js";
13
+ } from "./chunk-A27Y7ALQ.js";
12
14
  import "./chunk-ODUIFFPM.js";
13
15
 
14
16
  // src/render/model.ts
@@ -135,8 +137,10 @@ function buildView(result, options = {}) {
135
137
  return {
136
138
  scenario: result.scenario,
137
139
  ...snapshot.route?.path ? { route: snapshot.route.path } : {},
140
+ ...result.scope ? { scope: result.scope } : {},
138
141
  groups,
139
142
  counts,
143
+ rejections: result.rejections ?? [],
140
144
  explained: options.explain === true
141
145
  };
142
146
  }
@@ -159,7 +163,12 @@ import { jsx } from "react/jsx-runtime";
159
163
  function jsonFor(result, explain) {
160
164
  return {
161
165
  scenario: result.scenario,
166
+ ...result.scope ? { scope: result.scope } : {},
162
167
  snapshot: result.snapshot,
168
+ // Unconditional, and unconditionally present even when empty (`AS-CLI-006`):
169
+ // a consumer that has to distinguish "no rejections" from "this CLI predates
170
+ // the field" cannot rely on an absent key.
171
+ rejections: result.rejections,
163
172
  ...explain ? { explanation: result.explanation } : {}
164
173
  };
165
174
  }
@@ -201,4 +210,4 @@ ${renderSurfacePlain(view)}`);
201
210
  export {
202
211
  runInspect
203
212
  };
204
- //# sourceMappingURL=inspect-SLYLBZAH.js.map
213
+ //# sourceMappingURL=inspect-NJNB6CAS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/render/model.ts","../src/commands/inspect.tsx"],"sourcesContent":["import type {\n AgentActionDescriptor,\n AgentObservationDescriptor,\n AgentProcedureDescriptor,\n AgentSurfaceSnapshot,\n} from \"@agent-surface/core\";\nimport type { CapabilityExplanation, SurfaceExplanation } from \"@agent-surface/core/explain\";\nimport type { CollectResult, RegistrationRejection } from \"../collect.js\";\n\n/**\n * One view model, two renderers. The Ink UI and the plain-text fallback both\n * consume this, so `--plain` can never drift into showing something different\n * from what a TTY shows.\n */\nexport interface CapabilityRow {\n capabilityId: string;\n /** Leaf name — the group heading already carries the rest of the id. */\n name: string;\n kind: \"observation\" | \"action\" | \"procedure\";\n plane: \"view\" | \"domain\";\n outcome: \"expose\" | \"disable\" | \"hide\";\n description: string;\n reason?: string;\n tags: string[];\n policies?: CapabilityExplanation[\"policies\"];\n availability?: CapabilityExplanation[\"availability\"];\n schemas?: { input?: unknown; output?: unknown };\n}\n\nexport interface CapabilityGroup {\n heading: string;\n rows: CapabilityRow[];\n}\n\nexport interface SurfaceView {\n scenario: string;\n route?: string;\n /**\n * The scope the counts below were computed under (`AS-CLI-007`). A scope\n * filters the snapshot *and* the explanation, so without it on screen the\n * header reads as a statement about the whole surface when it is a statement\n * about one prefix of it.\n */\n scope?: string[];\n groups: CapabilityGroup[];\n counts: { callable: number; disabled: number; hidden: number };\n /** Refused during the mount — absent from both projections (`AS-CLI-006`). */\n rejections: RegistrationRejection[];\n explained: boolean;\n}\n\nexport interface ViewOptions {\n explain?: boolean;\n schemas?: boolean;\n}\n\nfunction leafOf(capabilityId: string): string {\n const withoutPlane = capabilityId.replace(/^(view|domain):/, \"\");\n const dot = withoutPlane.lastIndexOf(\".\");\n return dot === -1 ? withoutPlane : withoutPlane.slice(dot + 1);\n}\n\nfunction observationTags(): string[] {\n return [\"observation\"];\n}\n\nfunction actionTags(action: AgentActionDescriptor): string[] {\n const tags: string[] = [action.effect];\n if (action.idempotent) tags.push(\"idempotent\");\n if (action.reversible) tags.push(\"reversible\");\n if (action.confirmation !== \"never\") tags.push(`confirmation:${action.confirmation}`);\n return tags;\n}\n\nfunction procedureTags(procedure: AgentProcedureDescriptor): string[] {\n const tags: string[] = [procedure.effect];\n if (procedure.confirmation !== \"never\") tags.push(`confirmation:${procedure.confirmation}`);\n for (const field of procedure.boundFields) {\n tags.push(`${field.path} bound${field.locked ? \"+locked\" : \"\"}`);\n }\n return tags;\n}\n\nfunction explanationIndex(explanation: SurfaceExplanation): Map<string, CapabilityExplanation> {\n const index = new Map<string, CapabilityExplanation>();\n for (const capability of explanation.capabilities) {\n // Keyed by id + registration so two instances of one component stay apart.\n index.set(`${capability.capabilityId}\\u0000${capability.registrationId}`, capability);\n }\n return index;\n}\n\nexport function buildView(result: CollectResult, options: ViewOptions = {}): SurfaceView {\n const { snapshot, explanation } = result;\n const index = explanationIndex(explanation);\n const groups: CapabilityGroup[] = [];\n const counts = { callable: 0, disabled: 0, hidden: 0 };\n\n const enrich = (\n row: CapabilityRow,\n capabilityId: string,\n registrationId: string,\n ): CapabilityRow => {\n const explained = index.get(`${capabilityId}\\u0000${registrationId}`);\n if (options.explain && explained) {\n row.policies = explained.policies;\n row.availability = explained.availability;\n }\n return row;\n };\n\n for (const component of snapshot.components) {\n const rows: CapabilityRow[] = [];\n\n for (const observation of component.observations) {\n rows.push(\n enrich(\n rowFor(observation, \"observation\", observationTags(), options, {\n input: undefined,\n output: observation.outputSchema,\n }),\n observation.capabilityId,\n component.registrationId,\n ),\n );\n }\n for (const action of component.actions) {\n rows.push(\n enrich(\n rowFor(action, \"action\", actionTags(action), options, {\n input: action.inputSchema,\n output: action.outputSchema,\n }),\n action.capabilityId,\n component.registrationId,\n ),\n );\n }\n\n groups.push({\n heading:\n component.instanceId === \"default\"\n ? component.type\n : `${component.type}@${component.instanceId}`,\n rows,\n });\n }\n\n if (snapshot.procedures.length > 0) {\n groups.push({\n heading: \"authoritative (domain)\",\n rows: snapshot.procedures.map((procedure) =>\n enrich(\n {\n capabilityId: procedure.procedureId,\n name: procedure.procedureId.replace(/^domain:/, \"\"),\n kind: \"procedure\",\n plane: \"domain\",\n outcome: procedure.available ? \"expose\" : \"disable\",\n description: procedure.description,\n ...(procedure.unavailableReason ? { reason: procedure.unavailableReason } : {}),\n tags: procedureTags(procedure),\n ...(options.schemas\n ? { schemas: { input: procedure.inputSchema, output: procedure.outputSchema } }\n : {}),\n },\n procedure.procedureId,\n procedure.registrationId,\n ),\n ),\n });\n }\n\n // Hidden capabilities exist only in the explanation — that is the whole point\n // of it. They get their own group so nobody mistakes them for callable.\n if (options.explain) {\n const hidden = explanation.capabilities.filter((c) => c.outcome === \"hide\");\n if (hidden.length > 0) {\n groups.push({\n heading: \"hidden by policy (absent from the snapshot)\",\n rows: hidden.map((capability) => ({\n capabilityId: capability.capabilityId,\n name: leafOf(capability.capabilityId),\n kind: capability.kind,\n plane: capability.plane,\n outcome: \"hide\" as const,\n description: capability.description,\n tags: [`${capability.component.type}@${capability.component.instanceId}`],\n policies: capability.policies,\n availability: capability.availability,\n })),\n });\n }\n }\n\n for (const capability of explanation.capabilities) {\n if (capability.outcome === \"expose\") counts.callable += 1;\n else if (capability.outcome === \"disable\") counts.disabled += 1;\n else counts.hidden += 1;\n }\n\n return {\n scenario: result.scenario,\n ...(snapshot.route?.path ? { route: snapshot.route.path } : {}),\n ...(result.scope ? { scope: result.scope } : {}),\n groups,\n counts,\n rejections: result.rejections ?? [],\n explained: options.explain === true,\n };\n}\n\nfunction rowFor(\n descriptor: AgentObservationDescriptor | AgentActionDescriptor,\n kind: \"observation\" | \"action\",\n tags: string[],\n options: ViewOptions,\n schemas: { input?: unknown; output?: unknown },\n): CapabilityRow {\n return {\n capabilityId: descriptor.capabilityId,\n name: descriptor.name,\n kind,\n plane: \"view\",\n outcome: descriptor.available ? \"expose\" : \"disable\",\n description: descriptor.description,\n ...(descriptor.unavailableReason ? { reason: descriptor.unavailableReason } : {}),\n tags,\n ...(options.schemas ? { schemas } : {}),\n };\n}\n","import { createSurfaceRunner } from \"../load.js\";\nimport { buildView } from \"../render/model.js\";\nimport { renderSurfacePlain } from \"../render/plain.js\";\nimport { isPlain, loadInk, paint, transient, write } from \"../output.js\";\nimport type { CollectResult } from \"../collect.js\";\n\nexport interface InspectOptions {\n configPath: string;\n scenario?: string;\n scope?: string[];\n explain?: boolean;\n schemas?: boolean;\n json?: boolean;\n plain?: boolean;\n}\n\nfunction jsonFor(result: CollectResult, explain: boolean): Record<string, unknown> {\n return {\n scenario: result.scenario,\n ...(result.scope ? { scope: result.scope } : {}),\n snapshot: result.snapshot,\n // Unconditional, and unconditionally present even when empty (`AS-CLI-006`):\n // a consumer that has to distinguish \"no rejections\" from \"this CLI predates\n // the field\" cannot rely on an absent key.\n rejections: result.rejections,\n ...(explain ? { explanation: result.explanation } : {}),\n };\n}\n\n/**\n * Renders the live surface. A bare `inspect` covers every scenario the config\n * defines, the same way bare `snapshot` and `check` do — a config lists the\n * contexts worth looking at, and picking one of them by `Object.keys` order\n * made the default silently depend on the order they happened to be written in.\n */\nexport async function runInspect(options: InspectOptions): Promise<number> {\n const runner = await createSurfaceRunner(options.configPath);\n // `null` when Ink cannot run here (React 18 host), which is a fallback to\n // plain text rather than a failed command — see loadInk().\n const ink = isPlain(options) ? null : await loadInk();\n try {\n const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;\n const collected: Array<Record<string, unknown>> = [];\n\n for (const [index, scenario] of scenarios.entries()) {\n const stop = ink\n ? await transient(<ink.Loading label={`mounting ${scenario}…`} />)\n : undefined;\n\n let result;\n try {\n result = await runner.collect({\n scenario,\n ...(options.scope ? { scope: options.scope } : {}),\n });\n } finally {\n stop?.();\n }\n\n // Each scenario is mounted and rendered before the next one is mounted,\n // so a slow config prints as it goes instead of after the last mount.\n // `--json` is the exception: one document, so it has to be complete.\n if (options.json) {\n collected.push(jsonFor(result, options.explain === true));\n continue;\n }\n\n const view = buildView(result, {\n ...(options.explain ? { explain: true } : {}),\n ...(options.schemas ? { schemas: true } : {}),\n });\n\n if (ink) await paint(<ink.Surface view={view} />);\n else write(index === 0 ? renderSurfacePlain(view) : `\\n${renderSurfacePlain(view)}`);\n }\n\n if (options.json) write(JSON.stringify({ scenarios: collected }, null, 2));\n return 0;\n } finally {\n await runner.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwDA,SAAS,OAAO,cAA8B;AAC5C,QAAM,eAAe,aAAa,QAAQ,mBAAmB,EAAE;AAC/D,QAAM,MAAM,aAAa,YAAY,GAAG;AACxC,SAAO,QAAQ,KAAK,eAAe,aAAa,MAAM,MAAM,CAAC;AAC/D;AAEA,SAAS,kBAA4B;AACnC,SAAO,CAAC,aAAa;AACvB;AAEA,SAAS,WAAW,QAAyC;AAC3D,QAAM,OAAiB,CAAC,OAAO,MAAM;AACrC,MAAI,OAAO,WAAY,MAAK,KAAK,YAAY;AAC7C,MAAI,OAAO,WAAY,MAAK,KAAK,YAAY;AAC7C,MAAI,OAAO,iBAAiB,QAAS,MAAK,KAAK,gBAAgB,OAAO,YAAY,EAAE;AAC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M,OAAO,MAAM;AAAA,EACrB;AACF;","names":[]}
@@ -1,7 +1,9 @@
1
1
  import {
2
- createSurfaceRunner,
2
+ createSurfaceRunner
3
+ } from "./chunk-FYEXHWGG.js";
4
+ import {
3
5
  write
4
- } from "./chunk-S2LM3N6D.js";
6
+ } from "./chunk-A27Y7ALQ.js";
5
7
  import {
6
8
  baselineDirFor,
7
9
  baselinePath,
@@ -33,4 +35,4 @@ async function runSnapshot(options) {
33
35
  export {
34
36
  runSnapshot
35
37
  };
36
- //# sourceMappingURL=snapshot-3D55FL63.js.map
38
+ //# sourceMappingURL=snapshot-JQAB73OV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/commands/snapshot.ts"],"sourcesContent":["import { relative } from \"node:path\";\nimport { createSurfaceRunner } from \"../load.js\";\nimport { baselineDirFor, baselinePath, normalize, writeBaseline } from \"../baseline.js\";\nimport { write } from \"../output.js\";\n\nexport interface SnapshotOptions {\n configPath: string;\n scenario?: string;\n scope?: string[];\n baselineDir?: string;\n}\n\n/** Writes (or refreshes) the committed baseline `check` compares against. */\nexport async function runSnapshot(options: SnapshotOptions): Promise<number> {\n const runner = await createSurfaceRunner(options.configPath);\n try {\n const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;\n const dir = baselineDirFor(options.configPath, options.baselineDir ?? runner.config.baselineDir);\n\n for (const scenario of scenarios) {\n const result = await runner.collect({\n scenario,\n ...(options.scope ? { scope: options.scope } : {}),\n });\n const path = baselinePath(dir, scenario);\n writeBaseline(path, normalize(result.snapshot));\n write(`wrote ${relative(process.cwd(), path)}`);\n }\n return 0;\n } finally {\n await runner.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,gBAAgB;AAazB,eAAsB,YAAY,SAA2C;AAC3E,QAAM,SAAS,MAAM,oBAAoB,QAAQ,UAAU;AAC3D,MAAI;AACF,UAAM,YAAY,QAAQ,WAAW,CAAC,QAAQ,QAAQ,IAAI,OAAO;AACjE,UAAM,MAAM,eAAe,QAAQ,YAAY,QAAQ,eAAe,OAAO,OAAO,WAAW;AAE/F,eAAW,YAAY,WAAW;AAChC,YAAM,SAAS,MAAM,OAAO,QAAQ;AAAA,QAClC;AAAA,QACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,MAClD,CAAC;AACD,YAAM,OAAO,aAAa,KAAK,QAAQ;AACvC,oBAAc,MAAM,UAAU,OAAO,QAAQ,CAAC;AAC9C,YAAM,SAAS,SAAS,QAAQ,IAAI,GAAG,IAAI,CAAC,EAAE;AAAA,IAChD;AACA,WAAO;AAAA,EACT,UAAE;AACA,UAAM,OAAO,MAAM;AAAA,EACrB;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/commands/snapshot.ts"],"sourcesContent":["import { relative } from \"node:path\";\nimport { createSurfaceRunner } from \"../load.js\";\nimport { baselineDirFor, baselinePath, normalize, writeBaseline } from \"../baseline.js\";\nimport { write } from \"../output.js\";\n\nexport interface SnapshotOptions {\n configPath: string;\n scenario?: string;\n scope?: string[];\n baselineDir?: string;\n}\n\n/** Writes (or refreshes) the committed baseline `check` compares against. */\nexport async function runSnapshot(options: SnapshotOptions): Promise<number> {\n const runner = await createSurfaceRunner(options.configPath);\n try {\n const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;\n const dir = baselineDirFor(options.configPath, options.baselineDir ?? runner.config.baselineDir);\n\n for (const scenario of scenarios) {\n const result = await runner.collect({\n scenario,\n ...(options.scope ? { scope: options.scope } : {}),\n });\n const path = baselinePath(dir, scenario);\n writeBaseline(path, normalize(result.snapshot));\n write(`wrote ${relative(process.cwd(), path)}`);\n }\n return 0;\n } finally {\n await runner.close();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AAazB,eAAsB,YAAY,SAA2C;AAC3E,QAAM,SAAS,MAAM,oBAAoB,QAAQ,UAAU;AAC3D,MAAI;AACF,UAAM,YAAY,QAAQ,WAAW,CAAC,QAAQ,QAAQ,IAAI,OAAO;AACjE,UAAM,MAAM,eAAe,QAAQ,YAAY,QAAQ,eAAe,OAAO,OAAO,WAAW;AAE/F,eAAW,YAAY,WAAW;AAChC,YAAM,SAAS,MAAM,OAAO,QAAQ;AAAA,QAClC;AAAA,QACA,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,MAClD,CAAC;AACD,YAAM,OAAO,aAAa,KAAK,QAAQ;AACvC,oBAAc,MAAM,UAAU,OAAO,QAAQ,CAAC;AAC9C,YAAM,SAAS,SAAS,QAAQ,IAAI,GAAG,IAAI,CAAC,EAAE;AAAA,IAChD;AACA,WAAO;AAAA,EACT,UAAE;AACA,UAAM,OAAO,MAAM;AAAA,EACrB;AACF;","names":[]}