@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.
@@ -0,0 +1,498 @@
1
+ import {
2
+ formatValue
3
+ } from "./chunk-ODUIFFPM.js";
4
+
5
+ // src/extract.ts
6
+ import { existsSync } from "fs";
7
+ import { dirname, isAbsolute, join, relative, resolve } from "path";
8
+ import ts from "typescript";
9
+ var UNRESOLVED_ID = "<unresolved>";
10
+ function findTsconfig(from) {
11
+ return ts.findConfigFile(resolve(from), ts.sys.fileExists, "tsconfig.json");
12
+ }
13
+ function readProgramFiles(tsconfigPath) {
14
+ const read = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
15
+ if (read.error) {
16
+ throw new Error(
17
+ `could not read ${tsconfigPath}: ${ts.flattenDiagnosticMessageText(read.error.messageText, " ")}`
18
+ );
19
+ }
20
+ const parsed = ts.parseJsonConfigFileContent(
21
+ read.config,
22
+ ts.sys,
23
+ dirname(tsconfigPath)
24
+ );
25
+ if (parsed.errors.length > 0 && parsed.fileNames.length === 0) {
26
+ throw new Error(
27
+ `could not resolve any files from ${tsconfigPath}: ${parsed.errors.map((error) => ts.flattenDiagnosticMessageText(error.messageText, " ")).join("; ")}`
28
+ );
29
+ }
30
+ return { fileNames: parsed.fileNames, options: parsed.options };
31
+ }
32
+ function calleeName(call) {
33
+ if (ts.isIdentifier(call.expression)) return call.expression.text;
34
+ if (ts.isPropertyAccessExpression(call.expression)) return call.expression.name.text;
35
+ return void 0;
36
+ }
37
+ function propertyName(name) {
38
+ if (ts.isIdentifier(name) || ts.isStringLiteral(name)) return name.text;
39
+ return void 0;
40
+ }
41
+ function propertyOf(object, wanted) {
42
+ for (const property of object.properties) {
43
+ if (ts.isPropertyAssignment(property) && propertyName(property.name) === wanted) {
44
+ return property.initializer;
45
+ }
46
+ }
47
+ return void 0;
48
+ }
49
+ function hasSpread(object) {
50
+ return object.properties.some((property) => ts.isSpreadAssignment(property));
51
+ }
52
+ function literalText(node) {
53
+ if (!node) return void 0;
54
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return node.text;
55
+ if (ts.isParenthesizedExpression(node)) return literalText(node.expression);
56
+ if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.PlusToken) {
57
+ const left = literalText(node.left);
58
+ const right = literalText(node.right);
59
+ if (left !== void 0 && right !== void 0) return left + right;
60
+ }
61
+ return void 0;
62
+ }
63
+ function describeConstruct(node) {
64
+ if (ts.isCallExpression(node)) {
65
+ const callee = calleeName(node);
66
+ return callee ? `built by ${callee}()` : "built by a call expression";
67
+ }
68
+ if (ts.isIdentifier(node)) return `a variable (${node.text}) this extractor could not follow`;
69
+ if (ts.isConditionalExpression(node)) return "a conditional expression";
70
+ if (ts.isTemplateExpression(node)) return "a template with substitutions";
71
+ if (ts.isPropertyAccessExpression(node)) return "a property access";
72
+ return "a non-literal expression";
73
+ }
74
+ function objectLiteralFor(expression, source) {
75
+ if (ts.isObjectLiteralExpression(expression)) return { object: expression };
76
+ if (ts.isIdentifier(expression)) {
77
+ const target = expression.text;
78
+ let found;
79
+ const visit = (node) => {
80
+ if (found) return;
81
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === target && node.initializer && ts.isObjectLiteralExpression(node.initializer)) {
82
+ found = node.initializer;
83
+ return;
84
+ }
85
+ ts.forEachChild(node, visit);
86
+ };
87
+ visit(source);
88
+ if (found) return { object: found };
89
+ return {
90
+ note: `the config is \`${target}\`, which is not a same-module object literal \u2014 the extractor follows one hop only`
91
+ };
92
+ }
93
+ return { note: `the config is ${describeConstruct(expression)}` };
94
+ }
95
+ var GRANULAR_HOOKS = /* @__PURE__ */ new Set(["useAgentAction", "useAgentObservation"]);
96
+ function capabilitiesFromGroup(group, kind, componentType, componentPartial, emit, source) {
97
+ if (!group) return;
98
+ const resolved = objectLiteralFor(group, source);
99
+ if (!resolved.object) {
100
+ emit.push({
101
+ capabilityId: `view:${componentType}.${UNRESOLVED_ID}`,
102
+ kind,
103
+ origin: emit.origin(group),
104
+ resolution: "unresolved",
105
+ note: `\`${kind}s\` on "${componentType}" is not an object literal: ${resolved.note}`
106
+ });
107
+ return;
108
+ }
109
+ for (const property of resolved.object.properties) {
110
+ if (ts.isSpreadAssignment(property)) {
111
+ emit.push({
112
+ capabilityId: `view:${componentType}.${UNRESOLVED_ID}`,
113
+ kind,
114
+ origin: emit.origin(property),
115
+ resolution: "unresolved",
116
+ note: `\`${kind}s\` on "${componentType}" spreads another object, which may contribute capabilities this inventory cannot name`
117
+ });
118
+ continue;
119
+ }
120
+ const name = ts.isPropertyAssignment(property) || ts.isMethodDeclaration(property) ? propertyName(property.name) : ts.isShorthandPropertyAssignment(property) ? property.name.text : void 0;
121
+ if (name === void 0) {
122
+ emit.push({
123
+ capabilityId: `view:${componentType}.${UNRESOLVED_ID}`,
124
+ kind,
125
+ origin: emit.origin(property),
126
+ resolution: "unresolved",
127
+ note: `a capability on "${componentType}" has a computed name`
128
+ });
129
+ continue;
130
+ }
131
+ const capability = {
132
+ capabilityId: `view:${componentType}.${name}`,
133
+ kind,
134
+ origin: emit.origin(property),
135
+ resolution: "static"
136
+ };
137
+ const notes = [];
138
+ if (componentPartial) notes.push(componentPartial);
139
+ const value = ts.isPropertyAssignment(property) ? property.initializer : void 0;
140
+ const definition = value && ts.isCallExpression(value) && value.arguments.length > 0 ? value.arguments[0] : value;
141
+ if (definition && ts.isObjectLiteralExpression(definition)) {
142
+ const description = literalText(propertyOf(definition, "description"));
143
+ if (description !== void 0) capability.description = description;
144
+ else notes.push("description is not a string literal");
145
+ if (kind === "action") {
146
+ const effect = literalText(propertyOf(definition, "effect"));
147
+ if (effect !== void 0) capability.effect = effect;
148
+ else notes.push("effect is not a string literal");
149
+ }
150
+ if (hasSpread(definition)) notes.push("the definition spreads another object");
151
+ } else {
152
+ notes.push(
153
+ value ? `the definition is ${describeConstruct(value)}` : "the definition is not an object literal"
154
+ );
155
+ }
156
+ if (notes.length > 0) {
157
+ capability.resolution = "partial";
158
+ capability.note = notes.join("; ");
159
+ }
160
+ emit.push(capability);
161
+ }
162
+ }
163
+ function visitCall(call, emit, source) {
164
+ const callee = calleeName(call);
165
+ if (callee === void 0) return;
166
+ if (GRANULAR_HOOKS.has(callee)) {
167
+ emit.push({
168
+ capabilityId: UNRESOLVED_ID,
169
+ kind: callee === "useAgentAction" ? "action" : "observation",
170
+ origin: emit.origin(call),
171
+ resolution: "unresolved",
172
+ note: `${callee}() registers against a render-scope link, so its component type is not at this call site`
173
+ });
174
+ return;
175
+ }
176
+ if (callee !== "useAgentComponent" && callee !== "register") return;
177
+ const argument = call.arguments[0];
178
+ if (!argument) return;
179
+ const resolved = objectLiteralFor(argument, source);
180
+ if (!resolved.object) {
181
+ emit.push({
182
+ capabilityId: UNRESOLVED_ID,
183
+ kind: "action",
184
+ origin: emit.origin(call),
185
+ resolution: "unresolved",
186
+ note: `${callee}() call site could not be read: ${resolved.note}`
187
+ });
188
+ return;
189
+ }
190
+ const config = resolved.object;
191
+ const type = literalText(propertyOf(config, "type"));
192
+ if (type === void 0) {
193
+ if (callee === "register" && propertyOf(config, "type") === void 0) return;
194
+ emit.push({
195
+ capabilityId: UNRESOLVED_ID,
196
+ kind: "action",
197
+ origin: emit.origin(call),
198
+ resolution: "unresolved",
199
+ note: `\`type\` is not a string literal, so no capability id on this component can be determined`
200
+ });
201
+ return;
202
+ }
203
+ const componentPartial = hasSpread(config) ? "the component config spreads another object, so some metadata here may be dynamic" : void 0;
204
+ capabilitiesFromGroup(
205
+ propertyOf(config, "observations"),
206
+ "observation",
207
+ type,
208
+ componentPartial,
209
+ emit,
210
+ source
211
+ );
212
+ capabilitiesFromGroup(
213
+ propertyOf(config, "actions"),
214
+ "action",
215
+ type,
216
+ componentPartial,
217
+ emit,
218
+ source
219
+ );
220
+ }
221
+ function extractCapabilities(options) {
222
+ const root = resolve(options.root);
223
+ const tsconfigPath = options.tsconfig ? isAbsolute(options.tsconfig) ? options.tsconfig : join(root, options.tsconfig) : findTsconfig(root);
224
+ if (!tsconfigPath || !existsSync(tsconfigPath)) {
225
+ throw new Error(
226
+ `no tsconfig.json found from ${root} \u2014 \`capabilities\` reads the TypeScript program, so it needs one (pass --tsconfig to point at it)`
227
+ );
228
+ }
229
+ const { fileNames, options: compilerOptions } = readProgramFiles(tsconfigPath);
230
+ const program = ts.createProgram(fileNames, compilerOptions);
231
+ const capabilities = [];
232
+ let filesAnalyzed = 0;
233
+ let filesOutsideRoot = 0;
234
+ for (const source of program.getSourceFiles()) {
235
+ if (source.isDeclarationFile) continue;
236
+ if (source.fileName.includes("/node_modules/")) continue;
237
+ if (!isInside(root, source.fileName)) {
238
+ filesOutsideRoot += 1;
239
+ continue;
240
+ }
241
+ filesAnalyzed += 1;
242
+ const emit = {
243
+ push: (capability) => capabilities.push(capability),
244
+ origin: (node) => ({
245
+ file: relative(root, source.fileName),
246
+ line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1
247
+ })
248
+ };
249
+ const visit = (node) => {
250
+ if (ts.isCallExpression(node)) visitCall(node, emit, source);
251
+ ts.forEachChild(node, visit);
252
+ };
253
+ visit(source);
254
+ }
255
+ capabilities.sort(
256
+ (a, b) => a.capabilityId.localeCompare(b.capabilityId) || a.origin.file.localeCompare(b.origin.file) || a.origin.line - b.origin.line
257
+ );
258
+ return {
259
+ capabilities,
260
+ tsconfig: tsconfigPath,
261
+ root,
262
+ filesAnalyzed,
263
+ filesOutsideRoot,
264
+ domain: "not-analyzed"
265
+ };
266
+ }
267
+ function isInside(root, file) {
268
+ const rel = relative(root, file);
269
+ return rel !== "" && !rel.startsWith("..") && !isAbsolute(rel);
270
+ }
271
+ function authoredIds(inventory) {
272
+ const ids = /* @__PURE__ */ new Set();
273
+ for (const capability of inventory.capabilities) {
274
+ if (capability.resolution === "unresolved") continue;
275
+ if (capability.capabilityId.endsWith(UNRESOLVED_ID)) continue;
276
+ ids.add(capability.capabilityId);
277
+ }
278
+ return ids;
279
+ }
280
+ function unresolved(inventory) {
281
+ return inventory.capabilities.filter((capability) => capability.resolution === "unresolved");
282
+ }
283
+
284
+ // src/render/plain.ts
285
+ var MARK = { expose: "+", disable: "~", hide: "-" };
286
+ function renderRow(row, lines) {
287
+ const tags = row.tags.length > 0 ? ` [${row.tags.join(", ")}]` : "";
288
+ lines.push(` ${MARK[row.outcome]} ${row.name}${tags}`);
289
+ lines.push(` ${row.description}`);
290
+ if (row.reason) lines.push(` reason: ${row.reason}`);
291
+ if (row.policies) {
292
+ if (row.policies.length === 0) {
293
+ lines.push(" policies: none");
294
+ } else {
295
+ for (const policy of row.policies) {
296
+ const vote = policy.discovery ? policy.discovery.decision === "disable" ? `disable \u2014 ${policy.discovery.reason}` : policy.discovery.decision : "no discovery hook";
297
+ const phases = policy.phases.length > 0 ? policy.phases.join("/") : "\u2014";
298
+ const flags = [
299
+ policy.threw ? "THREW" : "",
300
+ policy.confirmationEscalation ? "escalates-confirmation" : ""
301
+ ].filter(Boolean).join(", ");
302
+ lines.push(
303
+ ` policy ${policy.name} (${policy.scope}, ${phases}): ${vote}${flags ? ` [${flags}]` : ""}`
304
+ );
305
+ }
306
+ }
307
+ if (row.availability && !row.availability.available) {
308
+ lines.push(
309
+ ` availability: unavailable${row.availability.reason ? ` \u2014 ${row.availability.reason}` : ""}`
310
+ );
311
+ }
312
+ }
313
+ if (row.schemas) {
314
+ if (row.schemas.input !== void 0) {
315
+ lines.push(` input: ${JSON.stringify(row.schemas.input)}`);
316
+ }
317
+ if (row.schemas.output !== void 0) {
318
+ lines.push(` output: ${JSON.stringify(row.schemas.output)}`);
319
+ }
320
+ }
321
+ }
322
+ function renderCountsPlain(view) {
323
+ return `${view.counts.callable} callable, ${view.counts.disabled} visible-disabled, ${view.counts.hidden} hidden` + (view.rejections.length > 0 ? `, ${view.rejections.length} registration${view.rejections.length === 1 ? "" : "s"} rejected` : "");
324
+ }
325
+ function renderRejections(view, lines) {
326
+ if (view.rejections.length === 0) return;
327
+ lines.push("");
328
+ lines.push(`rejected during mount (${view.rejections.length})`);
329
+ for (const rejection of view.rejections) {
330
+ const why = rejection.reason === "duplicate" ? "duplicate \u2014 an earlier registration holds this key" : "guard \u2014 onRegister rejected this registration";
331
+ lines.push(` ! ${rejection.componentType} (${rejection.instanceId}) ${why}`);
332
+ }
333
+ }
334
+ function renderSurfacePlain(view) {
335
+ const lines = [];
336
+ lines.push(
337
+ `scenario ${view.scenario}${view.route ? ` route ${view.route}` : ""}${view.scope && view.scope.length > 0 ? ` scope ${view.scope.join(" ")}` : ""}`
338
+ );
339
+ lines.push(renderCountsPlain(view));
340
+ renderRejections(view, lines);
341
+ const populated = view.groups.filter((group) => group.rows.length > 0);
342
+ if (populated.length === 0) {
343
+ lines.push("");
344
+ if (view.counts.hidden > 0) {
345
+ lines.push(
346
+ `Nothing is callable here \u2014 all ${view.counts.hidden} registered capabilities were hidden by policy.`
347
+ );
348
+ if (!view.explained) lines.push("Re-run with --explain to see which policy hid them.");
349
+ } else {
350
+ lines.push("Nothing is registered for this scenario \u2014 the agent has no surface here.");
351
+ if (!view.explained) {
352
+ lines.push("Re-run with --explain to see whether a policy hid it.");
353
+ }
354
+ }
355
+ return lines.join("\n");
356
+ }
357
+ for (const group of populated) {
358
+ lines.push("");
359
+ lines.push(`${group.heading} (${group.rows.length})`);
360
+ for (const row of group.rows) renderRow(row, lines);
361
+ }
362
+ return lines.join("\n");
363
+ }
364
+ function renderInventoryPlain(inventory) {
365
+ const lines = [];
366
+ const resolved = inventory.capabilities.filter((c) => c.resolution !== "unresolved");
367
+ const unresolvedEntries = unresolved(inventory);
368
+ const ids = authoredIds(inventory);
369
+ lines.push(
370
+ `${ids.size} authored (upper bound), ${resolved.length} call site${resolved.length === 1 ? "" : "s"} across ${inventory.filesAnalyzed} file${inventory.filesAnalyzed === 1 ? "" : "s"}`
371
+ );
372
+ lines.push("domain: not analyzed \u2014 domain capabilities come from the oRPC router (OQ-1)");
373
+ if (inventory.filesOutsideRoot > 0) {
374
+ lines.push(
375
+ `${inventory.filesOutsideRoot} program file${inventory.filesOutsideRoot === 1 ? "" : "s"} outside the config's directory were not analyzed`
376
+ );
377
+ }
378
+ const byId = [...resolved].sort((a, b) => a.capabilityId.localeCompare(b.capabilityId));
379
+ if (byId.length > 0) {
380
+ lines.push("");
381
+ for (const capability of byId) {
382
+ const mark = capability.resolution === "static" ? " " : "~";
383
+ lines.push(` ${mark} ${capability.capabilityId}`);
384
+ lines.push(` ${capability.origin.file}:${capability.origin.line} [${capability.kind}]`);
385
+ if (capability.description) lines.push(` ${capability.description}`);
386
+ if (capability.note) lines.push(` partial: ${capability.note}`);
387
+ }
388
+ }
389
+ if (unresolvedEntries.length > 0) {
390
+ lines.push("");
391
+ lines.push(`unresolved (${unresolvedEntries.length})`);
392
+ for (const capability of unresolvedEntries) {
393
+ lines.push(` ? ${capability.origin.file}:${capability.origin.line}`);
394
+ lines.push(` ${capability.note ?? "the extractor could not read this call site"}`);
395
+ }
396
+ lines.push("");
397
+ lines.push(
398
+ `${unresolvedEntries.length} call site${unresolvedEntries.length === 1 ? "" : "s"} could not be resolved \u2014 fix them, or re-run with --allow-unresolved to accept the gap`
399
+ );
400
+ }
401
+ return lines.join("\n");
402
+ }
403
+ function renderCoveragePlain(report) {
404
+ const lines = [];
405
+ lines.push(
406
+ `${report.authored} authored (upper bound), ${report.reached} reached across ${report.scenarios.length} scenario${report.scenarios.length === 1 ? "" : "s"} (${report.scenarios.join(", ")})`
407
+ );
408
+ if (report.unreached.length > 0) {
409
+ lines.push("");
410
+ lines.push(`unreached (${report.unreached.length})`);
411
+ for (const entry of report.unreached) {
412
+ lines.push(` ${entry.capabilityId}`);
413
+ lines.push(` ${entry.origin.file}:${entry.origin.line} \u2014 no scenario mounts it`);
414
+ }
415
+ }
416
+ if (report.domainReached.length > 0) {
417
+ lines.push("");
418
+ lines.push(
419
+ `domain (not analyzed) (${report.domainReached.length}) \u2014 reached, and outside this inventory by design`
420
+ );
421
+ for (const id of report.domainReached) lines.push(` ${id}`);
422
+ }
423
+ if (report.undeclared.length > 0) {
424
+ lines.push("");
425
+ lines.push(`undeclared (${report.undeclared.length})`);
426
+ lines.push(" present at runtime with no static origin \u2014 a dynamic registration, or a gap here");
427
+ for (const id of report.undeclared) lines.push(` ${id}`);
428
+ }
429
+ if (report.unresolved.length > 0) {
430
+ lines.push("");
431
+ lines.push(`unresolved (${report.unresolved.length})`);
432
+ for (const capability of report.unresolved) {
433
+ lines.push(` ? ${capability.origin.file}:${capability.origin.line}`);
434
+ lines.push(` ${capability.note ?? "the extractor could not read this call site"}`);
435
+ }
436
+ }
437
+ if (report.allowed.length > 0) {
438
+ lines.push("");
439
+ lines.push(
440
+ `${report.allowed.length} unreached capabilit${report.allowed.length === 1 ? "y is" : "ies are"} allowlisted in ${report.allowlistPath}`
441
+ );
442
+ }
443
+ if (report.staleAllowlist.length > 0) {
444
+ lines.push("");
445
+ lines.push(`stale allowlist entries (${report.staleAllowlist.length})`);
446
+ lines.push(" these are reached now \u2014 delete them so the list cannot silently rot");
447
+ for (const id of report.staleAllowlist) lines.push(` ${id}`);
448
+ }
449
+ lines.push("");
450
+ const verdicts = [];
451
+ if (report.unreached.length > 0) {
452
+ verdicts.push(
453
+ `surface coverage gap in ${report.unreached.length} capabilit${report.unreached.length === 1 ? "y" : "ies"} \u2014 add a scenario, or delete the component`
454
+ );
455
+ }
456
+ if (report.unresolved.length > 0) {
457
+ verdicts.push(
458
+ `${report.unresolved.length} call site${report.unresolved.length === 1 ? "" : "s"} could not be read, so this report is incomplete \u2014 fix them, or accept the gap knowingly`
459
+ );
460
+ }
461
+ if (report.staleAllowlist.length > 0) {
462
+ verdicts.push(
463
+ `${report.staleAllowlist.length} allowlist entr${report.staleAllowlist.length === 1 ? "y is" : "ies are"} stale \u2014 remove them so the list cannot silently rot`
464
+ );
465
+ }
466
+ if (verdicts.length === 0) {
467
+ verdicts.push(
468
+ report.allowed.length > 0 ? "no new surface coverage gaps \u2014 the allowlist still holds the known ones" : "every authored capability is reached by a scenario"
469
+ );
470
+ }
471
+ lines.push(...verdicts);
472
+ return lines.join("\n");
473
+ }
474
+ function renderDiffPlain(scenario, entries) {
475
+ const lines = [`${scenario}: ${entries.length} change${entries.length === 1 ? "" : "s"}`];
476
+ for (const entry of entries) {
477
+ const where = entry.subject ? `${entry.subject} (${entry.path})` : entry.path;
478
+ if (entry.kind === "added") lines.push(` + ${where} ${formatValue(entry.after)}`);
479
+ else if (entry.kind === "removed") lines.push(` - ${where} ${formatValue(entry.before)}`);
480
+ else {
481
+ lines.push(` ~ ${where}`);
482
+ lines.push(` before: ${formatValue(entry.before)}`);
483
+ lines.push(` after: ${formatValue(entry.after)}`);
484
+ }
485
+ }
486
+ return lines.join("\n");
487
+ }
488
+
489
+ export {
490
+ extractCapabilities,
491
+ authoredIds,
492
+ unresolved,
493
+ renderSurfacePlain,
494
+ renderInventoryPlain,
495
+ renderCoveragePlain,
496
+ renderDiffPlain
497
+ };
498
+ //# sourceMappingURL=chunk-4AEQKM2X.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extract.ts","../src/render/plain.ts"],"sourcesContent":["/**\n * The static capability inventory (`AS-COVER-001…003`, D35).\n *\n * `inspect` answers *what can an agent do on this page right now*. It cannot\n * answer *did we author something no scenario ever reaches*, because a surface\n * is a projection of what is mounted: a route no scenario visits registers\n * nothing, so there is nothing to report and nothing to diff. The denominator\n * has to come from somewhere that does not require mounting.\n *\n * It comes from here. A registration call site is far more static than the\n * surface it produces:\n *\n * ```tsx\n * useAgentComponent({\n * type: \"devices.table\", // string literal\n * actions: { sort: action({ … }) }, // capability name is a key\n * });\n * ```\n *\n * `view:devices.table.sort` is fully determined by source text. What is\n * genuinely dynamic — availability, policy outcome, binding — is the\n * *projection*, and none of it is claimed here.\n *\n * ## This creates no exposure path (directive §2.1)\n *\n * No DOM is scanned, nothing is registered, no annotation is suggested. This\n * module *reads the same reviewed registration code* a human reads and counts\n * what is already there. It lives in `@agent-surface/cli` — which no adapter\n * imports and no application ships — and must never be re-exported from\n * `@agent-surface/core`, mirroring `AS-EXPLAIN-004` (`AS-COVER-006`).\n *\n * ## Failure discipline is the substance, not a detail\n *\n * > Better a missing check than a misleading check.\n *\n * A call site this module cannot understand is **reported with its file and\n * line**, never dropped. An inventory that silently omitted the constructs it\n * failed to parse would understate the denominator, and a coverage number built\n * on it would claim completeness it never had.\n */\nimport { existsSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport ts from \"typescript\";\n\n/** Identity could not be recovered from the call site at all. */\nexport const UNRESOLVED_ID = \"<unresolved>\";\n\nexport interface AuthoredCapability {\n /** Canonical id, instance-independent: `view:devices.table.sort`. */\n capabilityId: string;\n kind: \"observation\" | \"action\" | \"procedure\";\n /** Where a human can go and read it. */\n origin: { file: string; line: number };\n /** Literals recovered from the call site; absent when not statically known. */\n description?: string;\n effect?: string;\n /**\n * How much of this call site the extractor understood.\n *\n * `static` — identity and metadata both recovered from literals.\n * `partial` — identity resolved, some metadata dynamic. The common case: a\n * spread `instanceId`, or a description built from a template.\n * `unresolved` — identity NOT resolved. Reported, never dropped.\n */\n resolution: \"static\" | \"partial\" | \"unresolved\";\n /** Present on `partial`/`unresolved`: what defeated the extractor. */\n note?: string;\n}\n\nexport interface CapabilityInventory {\n capabilities: AuthoredCapability[];\n /** Absolute path to the tsconfig whose file list was analyzed. */\n tsconfig: string;\n /** Directory the analysis was rooted at — the surface config's own. */\n root: string;\n /** Files the program actually walked — the inventory's blast radius. */\n filesAnalyzed: number;\n /**\n * Program files skipped for living outside `root` — workspace packages the\n * app's tsconfig aliases in, typically the library's own source. Reported\n * rather than dropped silently: a boundary nobody can see is a boundary\n * nobody can check.\n */\n filesOutsideRoot: number;\n /**\n * The `domain:` plane is deliberately *not* analyzed here. Those capabilities\n * come from the oRPC router, which is already a static export (OQ-1), and\n * reporting zero of them would read as \"there are none\" rather than \"nobody\n * looked\".\n */\n domain: \"not-analyzed\";\n}\n\n/* ── locating the program ─────────────────────────────────────────────── */\n\nexport function findTsconfig(from: string): string | undefined {\n return ts.findConfigFile(resolve(from), ts.sys.fileExists, \"tsconfig.json\");\n}\n\ninterface ProgramFiles {\n fileNames: string[];\n options: ts.CompilerOptions;\n}\n\nfunction readProgramFiles(tsconfigPath: string): ProgramFiles {\n const read = ts.readConfigFile(tsconfigPath, ts.sys.readFile);\n if (read.error) {\n throw new Error(\n `could not read ${tsconfigPath}: ${ts.flattenDiagnosticMessageText(read.error.messageText, \" \")}`,\n );\n }\n const parsed = ts.parseJsonConfigFileContent(\n read.config as object,\n ts.sys,\n dirname(tsconfigPath),\n );\n if (parsed.errors.length > 0 && parsed.fileNames.length === 0) {\n throw new Error(\n `could not resolve any files from ${tsconfigPath}: ${parsed.errors\n .map((error) => ts.flattenDiagnosticMessageText(error.messageText, \" \"))\n .join(\"; \")}`,\n );\n }\n return { fileNames: parsed.fileNames, options: parsed.options };\n}\n\n/* ── small AST helpers ────────────────────────────────────────────────── */\n\nfunction calleeName(call: ts.CallExpression): string | undefined {\n if (ts.isIdentifier(call.expression)) return call.expression.text;\n if (ts.isPropertyAccessExpression(call.expression)) return call.expression.name.text;\n return undefined;\n}\n\nfunction propertyName(name: ts.PropertyName): string | undefined {\n if (ts.isIdentifier(name) || ts.isStringLiteral(name)) return name.text;\n return undefined;\n}\n\nfunction propertyOf(\n object: ts.ObjectLiteralExpression,\n wanted: string,\n): ts.Expression | undefined {\n for (const property of object.properties) {\n if (ts.isPropertyAssignment(property) && propertyName(property.name) === wanted) {\n return property.initializer;\n }\n }\n return undefined;\n}\n\nfunction hasSpread(object: ts.ObjectLiteralExpression): boolean {\n return object.properties.some((property) => ts.isSpreadAssignment(property));\n}\n\nfunction literalText(node: ts.Expression | undefined): string | undefined {\n if (!node) return undefined;\n if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return node.text;\n if (ts.isParenthesizedExpression(node)) return literalText(node.expression);\n // `\"one long \" + \"description split over two lines\"` is as statically known\n // as either half. Descriptions are the provider's cached prompt prefix (D28),\n // so they are long enough that authors wrap them — calling that `partial`\n // would report the codebase's most common formatting choice as a defect.\n if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.PlusToken) {\n const left = literalText(node.left);\n const right = literalText(node.right);\n if (left !== undefined && right !== undefined) return left + right;\n }\n return undefined;\n}\n\n/** A short name for whatever construct defeated us, for the `note`. */\nfunction describeConstruct(node: ts.Expression): string {\n if (ts.isCallExpression(node)) {\n const callee = calleeName(node);\n return callee ? `built by ${callee}()` : \"built by a call expression\";\n }\n if (ts.isIdentifier(node)) return `a variable (${node.text}) this extractor could not follow`;\n if (ts.isConditionalExpression(node)) return \"a conditional expression\";\n if (ts.isTemplateExpression(node)) return \"a template with substitutions\";\n if (ts.isPropertyAccessExpression(node)) return \"a property access\";\n return \"a non-literal expression\";\n}\n\n/**\n * Resolves a config argument to an object literal, following **one hop** to a\n * same-module `const`.\n *\n * One hop is the whole rule. `useAgentComponent(CONFIG)` where `CONFIG` is a\n * module constant is common and cheap; `useAgentComponent(buildConfig(props))`\n * is not resolvable at any depth worth implementing. Stopping at one hop keeps\n * the limit *visible in the output* rather than buried in the implementation —\n * the deeper case is reported as `unresolved` with the construct named, which\n * is the behaviour this module exists to guarantee.\n */\nfunction objectLiteralFor(\n expression: ts.Expression,\n source: ts.SourceFile,\n): { object?: ts.ObjectLiteralExpression; note?: string } {\n if (ts.isObjectLiteralExpression(expression)) return { object: expression };\n\n if (ts.isIdentifier(expression)) {\n const target = expression.text;\n let found: ts.ObjectLiteralExpression | undefined;\n const visit = (node: ts.Node): void => {\n if (found) return;\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === target &&\n node.initializer &&\n ts.isObjectLiteralExpression(node.initializer)\n ) {\n found = node.initializer;\n return;\n }\n ts.forEachChild(node, visit);\n };\n visit(source);\n if (found) return { object: found };\n return {\n note: `the config is \\`${target}\\`, which is not a same-module object literal — the extractor follows one hop only`,\n };\n }\n\n return { note: `the config is ${describeConstruct(expression)}` };\n}\n\n/* ── the extraction itself ────────────────────────────────────────────── */\n\n/** Hooks that register one capability against the enclosing render scope. */\nconst GRANULAR_HOOKS = new Set([\"useAgentAction\", \"useAgentObservation\"]);\n\ninterface Emitter {\n push(capability: AuthoredCapability): void;\n origin(node: ts.Node): { file: string; line: number };\n}\n\nfunction capabilitiesFromGroup(\n group: ts.Expression | undefined,\n kind: \"observation\" | \"action\",\n componentType: string,\n componentPartial: string | undefined,\n emit: Emitter,\n source: ts.SourceFile,\n): void {\n if (!group) return;\n\n const resolved = objectLiteralFor(group, source);\n if (!resolved.object) {\n emit.push({\n capabilityId: `view:${componentType}.${UNRESOLVED_ID}`,\n kind,\n origin: emit.origin(group),\n resolution: \"unresolved\",\n note: `\\`${kind}s\\` on \"${componentType}\" is not an object literal: ${resolved.note}`,\n });\n return;\n }\n\n for (const property of resolved.object.properties) {\n // A spread inside the capability map can add capabilities this extractor\n // cannot name. That is an identity gap, not a metadata gap.\n if (ts.isSpreadAssignment(property)) {\n emit.push({\n capabilityId: `view:${componentType}.${UNRESOLVED_ID}`,\n kind,\n origin: emit.origin(property),\n resolution: \"unresolved\",\n note: `\\`${kind}s\\` on \"${componentType}\" spreads another object, which may contribute capabilities this inventory cannot name`,\n });\n continue;\n }\n\n const name =\n ts.isPropertyAssignment(property) || ts.isMethodDeclaration(property)\n ? propertyName(property.name)\n : ts.isShorthandPropertyAssignment(property)\n ? property.name.text\n : undefined;\n\n if (name === undefined) {\n emit.push({\n capabilityId: `view:${componentType}.${UNRESOLVED_ID}`,\n kind,\n origin: emit.origin(property),\n resolution: \"unresolved\",\n note: `a capability on \"${componentType}\" has a computed name`,\n });\n continue;\n }\n\n // Identity is recovered from the key alone; the value only carries metadata.\n const capability: AuthoredCapability = {\n capabilityId: `view:${componentType}.${name}`,\n kind,\n origin: emit.origin(property),\n resolution: \"static\",\n };\n const notes: string[] = [];\n if (componentPartial) notes.push(componentPartial);\n\n const value = ts.isPropertyAssignment(property) ? property.initializer : undefined;\n const definition =\n value && ts.isCallExpression(value) && value.arguments.length > 0\n ? value.arguments[0]\n : value;\n\n if (definition && ts.isObjectLiteralExpression(definition)) {\n const description = literalText(propertyOf(definition, \"description\"));\n if (description !== undefined) capability.description = description;\n else notes.push(\"description is not a string literal\");\n\n if (kind === \"action\") {\n const effect = literalText(propertyOf(definition, \"effect\"));\n if (effect !== undefined) capability.effect = effect;\n else notes.push(\"effect is not a string literal\");\n }\n if (hasSpread(definition)) notes.push(\"the definition spreads another object\");\n } else {\n notes.push(\n value\n ? `the definition is ${describeConstruct(value)}`\n : \"the definition is not an object literal\",\n );\n }\n\n if (notes.length > 0) {\n capability.resolution = \"partial\";\n capability.note = notes.join(\"; \");\n }\n emit.push(capability);\n }\n}\n\nfunction visitCall(call: ts.CallExpression, emit: Emitter, source: ts.SourceFile): void {\n const callee = calleeName(call);\n if (callee === undefined) return;\n\n if (GRANULAR_HOOKS.has(callee)) {\n // OQ-3: the granular hooks register through a render-scope link rather than\n // one aggregated descriptor, so the component `type` is not at this call\n // site at all. Reporting the call site as unresolved is the honest state\n // until that join key is settled — silently ignoring it would make a\n // codebase that uses them look fully covered.\n emit.push({\n capabilityId: UNRESOLVED_ID,\n kind: callee === \"useAgentAction\" ? \"action\" : \"observation\",\n origin: emit.origin(call),\n resolution: \"unresolved\",\n note: `${callee}() registers against a render-scope link, so its component type is not at this call site`,\n });\n return;\n }\n\n if (callee !== \"useAgentComponent\" && callee !== \"register\") return;\n const argument = call.arguments[0];\n if (!argument) return;\n\n const resolved = objectLiteralFor(argument, source);\n if (!resolved.object) {\n emit.push({\n capabilityId: UNRESOLVED_ID,\n kind: \"action\",\n origin: emit.origin(call),\n resolution: \"unresolved\",\n note: `${callee}() call site could not be read: ${resolved.note}`,\n });\n return;\n }\n\n const config = resolved.object;\n const type = literalText(propertyOf(config, \"type\"));\n if (type === undefined) {\n // `register` is a common method name; only treat it as ours once the call\n // actually looks like a registration. A `type` that exists but is dynamic\n // *is* ours, and is a genuine finding.\n if (callee === \"register\" && propertyOf(config, \"type\") === undefined) return;\n emit.push({\n capabilityId: UNRESOLVED_ID,\n kind: \"action\",\n origin: emit.origin(call),\n resolution: \"unresolved\",\n note: `\\`type\\` is not a string literal, so no capability id on this component can be determined`,\n });\n return;\n }\n\n // A spread at the component level is the documented common case — the\n // conditional `...(props.instance ? { instanceId } : {})`. `instanceId` is not\n // part of a capability id, so identity survives; metadata may not.\n const componentPartial = hasSpread(config)\n ? \"the component config spreads another object, so some metadata here may be dynamic\"\n : undefined;\n\n capabilitiesFromGroup(\n propertyOf(config, \"observations\"),\n \"observation\",\n type,\n componentPartial,\n emit,\n source,\n );\n capabilitiesFromGroup(\n propertyOf(config, \"actions\"),\n \"action\",\n type,\n componentPartial,\n emit,\n source,\n );\n}\n\nexport interface ExtractOptions {\n /** Directory the analysis is rooted at — normally the surface config's dir. */\n root: string;\n /** Explicit tsconfig; found upward from `root` when omitted. */\n tsconfig?: string;\n}\n\n/**\n * Reads the program and returns every capability its registration call sites\n * author. Nothing is executed: no Vite server, no jsdom, no scenarios, no mount.\n */\nexport function extractCapabilities(options: ExtractOptions): CapabilityInventory {\n const root = resolve(options.root);\n const tsconfigPath = options.tsconfig\n ? isAbsolute(options.tsconfig)\n ? options.tsconfig\n : join(root, options.tsconfig)\n : findTsconfig(root);\n\n if (!tsconfigPath || !existsSync(tsconfigPath)) {\n throw new Error(\n `no tsconfig.json found from ${root} — \\`capabilities\\` reads the TypeScript program, ` +\n \"so it needs one (pass --tsconfig to point at it)\",\n );\n }\n\n const { fileNames, options: compilerOptions } = readProgramFiles(tsconfigPath);\n const program = ts.createProgram(fileNames, compilerOptions);\n\n const capabilities: AuthoredCapability[] = [];\n let filesAnalyzed = 0;\n\n let filesOutsideRoot = 0;\n\n for (const source of program.getSourceFiles()) {\n if (source.isDeclarationFile) continue;\n if (source.fileName.includes(\"/node_modules/\")) continue;\n // A tsconfig with workspace path aliases pulls the library's *own* source\n // into the program, where `registry.register(definition)` inside\n // `useAgentComponent` reads as an unresolvable registration call site. It\n // is not one: it is the implementation every real call site goes through.\n // The inventory covers the app the surface config points at, and says so\n // rather than quietly widening or narrowing.\n if (!isInside(root, source.fileName)) {\n filesOutsideRoot += 1;\n continue;\n }\n filesAnalyzed += 1;\n\n const emit: Emitter = {\n push: (capability) => capabilities.push(capability),\n origin: (node) => ({\n file: relative(root, source.fileName),\n line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1,\n }),\n };\n\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node)) visitCall(node, emit, source);\n ts.forEachChild(node, visit);\n };\n visit(source);\n }\n\n capabilities.sort(\n (a, b) =>\n a.capabilityId.localeCompare(b.capabilityId) ||\n a.origin.file.localeCompare(b.origin.file) ||\n a.origin.line - b.origin.line,\n );\n\n return {\n capabilities,\n tsconfig: tsconfigPath,\n root,\n filesAnalyzed,\n filesOutsideRoot,\n domain: \"not-analyzed\",\n };\n}\n\n/** True when `file` lives under `root` — the analyzed boundary. */\nfunction isInside(root: string, file: string): boolean {\n const rel = relative(root, file);\n return rel !== \"\" && !rel.startsWith(\"..\") && !isAbsolute(rel);\n}\n\n/** Distinct capability ids the inventory resolved — the coverage denominator. */\nexport function authoredIds(inventory: CapabilityInventory): Set<string> {\n const ids = new Set<string>();\n for (const capability of inventory.capabilities) {\n if (capability.resolution === \"unresolved\") continue;\n if (capability.capabilityId.endsWith(UNRESOLVED_ID)) continue;\n ids.add(capability.capabilityId);\n }\n return ids;\n}\n\nexport function unresolved(inventory: CapabilityInventory): AuthoredCapability[] {\n return inventory.capabilities.filter((capability) => capability.resolution === \"unresolved\");\n}\n","import type { CapabilityRow, SurfaceView } from \"./model.js\";\nimport type { DiffEntry } from \"../baseline.js\";\nimport { formatValue } from \"../baseline.js\";\nimport { authoredIds, unresolved, type CapabilityInventory } from \"../extract.js\";\nimport type { CoverageReport } from \"../coverage.js\";\n\n/**\n * The no-colour, no-cursor rendering used when stdout is piped or when\n * `--plain`, `CI` or `NO_COLOR` is set. Same view model as the Ink UI, so the\n * two cannot disagree about what the surface contains.\n */\n\nconst MARK = { expose: \"+\", disable: \"~\", hide: \"-\" } as const;\n\nfunction renderRow(row: CapabilityRow, lines: string[]): void {\n const tags = row.tags.length > 0 ? ` [${row.tags.join(\", \")}]` : \"\";\n lines.push(` ${MARK[row.outcome]} ${row.name}${tags}`);\n lines.push(` ${row.description}`);\n if (row.reason) lines.push(` reason: ${row.reason}`);\n\n if (row.policies) {\n if (row.policies.length === 0) {\n lines.push(\" policies: none\");\n } else {\n for (const policy of row.policies) {\n const vote = policy.discovery\n ? policy.discovery.decision === \"disable\"\n ? `disable — ${policy.discovery.reason}`\n : policy.discovery.decision\n : \"no discovery hook\";\n const phases = policy.phases.length > 0 ? policy.phases.join(\"/\") : \"—\";\n const flags = [\n policy.threw ? \"THREW\" : \"\",\n policy.confirmationEscalation ? \"escalates-confirmation\" : \"\",\n ]\n .filter(Boolean)\n .join(\", \");\n lines.push(\n ` policy ${policy.name} (${policy.scope}, ${phases}): ${vote}${\n flags ? ` [${flags}]` : \"\"\n }`,\n );\n }\n }\n if (row.availability && !row.availability.available) {\n lines.push(\n ` availability: unavailable${\n row.availability.reason ? ` — ${row.availability.reason}` : \"\"\n }`,\n );\n }\n }\n\n if (row.schemas) {\n if (row.schemas.input !== undefined) {\n lines.push(` input: ${JSON.stringify(row.schemas.input)}`);\n }\n if (row.schemas.output !== undefined) {\n lines.push(` output: ${JSON.stringify(row.schemas.output)}`);\n }\n }\n}\n\n/**\n * The counts line, and everything it is relative to (`AS-CLI-007`).\n *\n * `hidden` is printed unconditionally. It is computed on every run — the\n * explanation is always collected — and suppressing it outside `--explain`\n * meant a surface with a policy-hidden half rendered as a complete one. The\n * *attribution* still needs `--explain`; only the count moved.\n */\nexport function renderCountsPlain(view: SurfaceView): string {\n return (\n `${view.counts.callable} callable, ${view.counts.disabled} visible-disabled, ` +\n `${view.counts.hidden} hidden` +\n (view.rejections.length > 0\n ? `, ${view.rejections.length} registration${view.rejections.length === 1 ? \"\" : \"s\"} rejected`\n : \"\")\n );\n}\n\nfunction renderRejections(view: SurfaceView, lines: string[]): void {\n if (view.rejections.length === 0) return;\n lines.push(\"\");\n lines.push(`rejected during mount (${view.rejections.length})`);\n for (const rejection of view.rejections) {\n const why =\n rejection.reason === \"duplicate\"\n ? \"duplicate — an earlier registration holds this key\"\n : \"guard — onRegister rejected this registration\";\n lines.push(` ! ${rejection.componentType} (${rejection.instanceId}) ${why}`);\n }\n}\n\nexport function renderSurfacePlain(view: SurfaceView): string {\n const lines: string[] = [];\n lines.push(\n `scenario ${view.scenario}${view.route ? ` route ${view.route}` : \"\"}${\n view.scope && view.scope.length > 0 ? ` scope ${view.scope.join(\" \")}` : \"\"\n }`,\n );\n lines.push(renderCountsPlain(view));\n\n renderRejections(view, lines);\n\n const populated = view.groups.filter((group) => group.rows.length > 0);\n if (populated.length === 0) {\n lines.push(\"\");\n // \"Nothing is registered\" is only true when nothing was hidden. Saying it\n // over a surface a policy emptied sends the reader to the wrong file.\n if (view.counts.hidden > 0) {\n lines.push(\n `Nothing is callable here — all ${view.counts.hidden} registered capabilities were hidden by policy.`,\n );\n if (!view.explained) lines.push(\"Re-run with --explain to see which policy hid them.\");\n } else {\n lines.push(\"Nothing is registered for this scenario — the agent has no surface here.\");\n if (!view.explained) {\n lines.push(\"Re-run with --explain to see whether a policy hid it.\");\n }\n }\n return lines.join(\"\\n\");\n }\n\n for (const group of populated) {\n lines.push(\"\");\n lines.push(`${group.heading} (${group.rows.length})`);\n for (const row of group.rows) renderRow(row, lines);\n }\n return lines.join(\"\\n\");\n}\n\n/**\n * The static inventory (`AS-COVER-001…003`). The summary says \"upper bound\" in\n * so many words: a tsconfig's include globs are wider than what a bundle\n * reaches, so a capability in a component no route renders any more is in here.\n * That is dead code — a different finding, not a false positive — and the\n * reader has to be told which number they are holding.\n */\nexport function renderInventoryPlain(inventory: CapabilityInventory): string {\n const lines: string[] = [];\n const resolved = inventory.capabilities.filter((c) => c.resolution !== \"unresolved\");\n const unresolvedEntries = unresolved(inventory);\n const ids = authoredIds(inventory);\n\n lines.push(\n `${ids.size} authored (upper bound), ${resolved.length} call site${\n resolved.length === 1 ? \"\" : \"s\"\n } across ${inventory.filesAnalyzed} file${inventory.filesAnalyzed === 1 ? \"\" : \"s\"}`,\n );\n lines.push(\"domain: not analyzed — domain capabilities come from the oRPC router (OQ-1)\");\n if (inventory.filesOutsideRoot > 0) {\n // Relative, not absolute: plain output is byte-stable across runs\n // (`AS-CLI-003`), and an absolute path makes it machine-specific the moment\n // two people diff a CI log.\n lines.push(\n `${inventory.filesOutsideRoot} program file${\n inventory.filesOutsideRoot === 1 ? \"\" : \"s\"\n } outside the config's directory were not analyzed`,\n );\n }\n\n const byId = [...resolved].sort((a, b) => a.capabilityId.localeCompare(b.capabilityId));\n if (byId.length > 0) {\n lines.push(\"\");\n for (const capability of byId) {\n const mark = capability.resolution === \"static\" ? \" \" : \"~\";\n lines.push(` ${mark} ${capability.capabilityId}`);\n lines.push(` ${capability.origin.file}:${capability.origin.line} [${capability.kind}]`);\n if (capability.description) lines.push(` ${capability.description}`);\n if (capability.note) lines.push(` partial: ${capability.note}`);\n }\n }\n\n if (unresolvedEntries.length > 0) {\n lines.push(\"\");\n lines.push(`unresolved (${unresolvedEntries.length})`);\n for (const capability of unresolvedEntries) {\n lines.push(` ? ${capability.origin.file}:${capability.origin.line}`);\n lines.push(` ${capability.note ?? \"the extractor could not read this call site\"}`);\n }\n lines.push(\"\");\n lines.push(\n `${unresolvedEntries.length} call site${\n unresolvedEntries.length === 1 ? \"\" : \"s\"\n } could not be resolved — fix them, or re-run with --allow-unresolved to accept the gap`,\n );\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * The coverage report (`AS-COVER-004…005`). `unreached` is the finding this\n * command exists for; the other two buckets are reported rather than buried,\n * for the same reason the inventory reports what it could not parse.\n */\nexport function renderCoveragePlain(report: CoverageReport): string {\n const lines: string[] = [];\n lines.push(\n `${report.authored} authored (upper bound), ${report.reached} reached across ${\n report.scenarios.length\n } scenario${report.scenarios.length === 1 ? \"\" : \"s\"} (${report.scenarios.join(\", \")})`,\n );\n\n if (report.unreached.length > 0) {\n lines.push(\"\");\n lines.push(`unreached (${report.unreached.length})`);\n for (const entry of report.unreached) {\n lines.push(` ${entry.capabilityId}`);\n lines.push(` ${entry.origin.file}:${entry.origin.line} — no scenario mounts it`);\n }\n }\n\n if (report.domainReached.length > 0) {\n lines.push(\"\");\n lines.push(\n `domain (not analyzed) (${report.domainReached.length}) — reached, and outside this inventory by design`,\n );\n for (const id of report.domainReached) lines.push(` ${id}`);\n }\n\n if (report.undeclared.length > 0) {\n lines.push(\"\");\n lines.push(`undeclared (${report.undeclared.length})`);\n lines.push(\" present at runtime with no static origin — a dynamic registration, or a gap here\");\n for (const id of report.undeclared) lines.push(` ${id}`);\n }\n\n if (report.unresolved.length > 0) {\n lines.push(\"\");\n lines.push(`unresolved (${report.unresolved.length})`);\n for (const capability of report.unresolved) {\n lines.push(` ? ${capability.origin.file}:${capability.origin.line}`);\n lines.push(` ${capability.note ?? \"the extractor could not read this call site\"}`);\n }\n }\n\n if (report.allowed.length > 0) {\n lines.push(\"\");\n lines.push(\n `${report.allowed.length} unreached capabilit${\n report.allowed.length === 1 ? \"y is\" : \"ies are\"\n } allowlisted in ${report.allowlistPath}`,\n );\n }\n\n if (report.staleAllowlist.length > 0) {\n lines.push(\"\");\n lines.push(`stale allowlist entries (${report.staleAllowlist.length})`);\n lines.push(\" these are reached now — delete them so the list cannot silently rot\");\n for (const id of report.staleAllowlist) lines.push(` ${id}`);\n }\n\n lines.push(\"\");\n // Each bucket gets its own remedy. \"Add a scenario, or delete the component\"\n // is the right advice for an unreached capability and useless advice for a\n // call site the extractor could not read.\n const verdicts: string[] = [];\n if (report.unreached.length > 0) {\n verdicts.push(\n `surface coverage gap in ${report.unreached.length} capabilit${\n report.unreached.length === 1 ? \"y\" : \"ies\"\n } — add a scenario, or delete the component`,\n );\n }\n if (report.unresolved.length > 0) {\n verdicts.push(\n `${report.unresolved.length} call site${\n report.unresolved.length === 1 ? \"\" : \"s\"\n } could not be read, so this report is incomplete — fix them, or accept the gap knowingly`,\n );\n }\n if (report.staleAllowlist.length > 0) {\n verdicts.push(\n `${report.staleAllowlist.length} allowlist entr${\n report.staleAllowlist.length === 1 ? \"y is\" : \"ies are\"\n } stale — remove them so the list cannot silently rot`,\n );\n }\n if (verdicts.length === 0) {\n verdicts.push(\n report.allowed.length > 0\n ? \"no new surface coverage gaps — the allowlist still holds the known ones\"\n : \"every authored capability is reached by a scenario\",\n );\n }\n lines.push(...verdicts);\n return lines.join(\"\\n\");\n}\n\nexport function renderDiffPlain(scenario: string, entries: DiffEntry[]): string {\n const lines = [`${scenario}: ${entries.length} change${entries.length === 1 ? \"\" : \"s\"}`];\n for (const entry of entries) {\n const where = entry.subject ? `${entry.subject} (${entry.path})` : entry.path;\n if (entry.kind === \"added\") lines.push(` + ${where} ${formatValue(entry.after)}`);\n else if (entry.kind === \"removed\") lines.push(` - ${where} ${formatValue(entry.before)}`);\n else {\n lines.push(` ~ ${where}`);\n lines.push(` before: ${formatValue(entry.before)}`);\n lines.push(` after: ${formatValue(entry.after)}`);\n }\n }\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;AAwCA,SAAS,kBAAkB;AAC3B,SAAS,SAAS,YAAY,MAAM,UAAU,eAAe;AAC7D,OAAO,QAAQ;AAGR,IAAM,gBAAgB;AAkDtB,SAAS,aAAa,MAAkC;AAC7D,SAAO,GAAG,eAAe,QAAQ,IAAI,GAAG,GAAG,IAAI,YAAY,eAAe;AAC5E;AAOA,SAAS,iBAAiB,cAAoC;AAC5D,QAAM,OAAO,GAAG,eAAe,cAAc,GAAG,IAAI,QAAQ;AAC5D,MAAI,KAAK,OAAO;AACd,UAAM,IAAI;AAAA,MACR,kBAAkB,YAAY,KAAK,GAAG,6BAA6B,KAAK,MAAM,aAAa,GAAG,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,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
@@ -0,0 +1,51 @@
1
+ // src/output.ts
2
+ function isPlain(flags) {
3
+ if (flags.json) return true;
4
+ if (flags.plain) return true;
5
+ if (process.env["CI"]) return true;
6
+ if (process.env["NO_COLOR"]) return true;
7
+ if (process.stdout.isTTY !== true) return true;
8
+ return !process.stdout.columns;
9
+ }
10
+ function write(text) {
11
+ process.stdout.write(`${text}
12
+ `);
13
+ }
14
+ function writeError(text) {
15
+ process.stderr.write(`${text}
16
+ `);
17
+ }
18
+ var cached;
19
+ async function loadInk() {
20
+ if (cached !== void 0) return cached;
21
+ try {
22
+ cached = await import("./ink-HBPOQTRS.js");
23
+ } catch {
24
+ cached = null;
25
+ }
26
+ return cached;
27
+ }
28
+ async function paint(element) {
29
+ const { render } = await import("ink");
30
+ const instance = render(element);
31
+ instance.unmount();
32
+ await instance.waitUntilExit();
33
+ }
34
+ async function transient(element) {
35
+ const { render } = await import("ink");
36
+ const instance = render(element);
37
+ return () => {
38
+ instance.clear();
39
+ instance.unmount();
40
+ };
41
+ }
42
+
43
+ export {
44
+ isPlain,
45
+ write,
46
+ writeError,
47
+ loadInk,
48
+ paint,
49
+ transient
50
+ };
51
+ //# sourceMappingURL=chunk-A27Y7ALQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/output.ts"],"sourcesContent":["import type { ReactElement } from \"react\";\n\nexport interface OutputFlags {\n plain?: boolean;\n json?: boolean;\n}\n\n/**\n * Terminal-aware only when there is a terminal. Piped output, `--plain`, `CI`\n * and `NO_COLOR` all fall back to plain text — a CLI whose output changes shape\n * when redirected is unusable in a build log.\n */\nexport function isPlain(flags: OutputFlags): boolean {\n if (flags.json) return true;\n if (flags.plain) return true;\n if (process.env[\"CI\"]) return true;\n if (process.env[\"NO_COLOR\"]) return true;\n if (process.stdout.isTTY !== true) return true;\n // A TTY that cannot report its width (some CI ptys, `script` on macOS) makes\n // Ink lay out at zero columns and emit one character per line. Plain text is\n // the only honest rendering for a terminal whose size is unknown.\n return !process.stdout.columns;\n}\n\nexport function write(text: string): void {\n process.stdout.write(`${text}\\n`);\n}\n\nexport function writeError(text: string): void {\n process.stderr.write(`${text}\\n`);\n}\n\ntype InkModule = typeof import(\"./render/ink.js\");\n\nlet cached: InkModule | null | undefined;\n\n/**\n * Loads the Ink renderer, or returns `null` when it cannot run here.\n *\n * Two reasons this is lazy rather than a top-level import. It keeps `--plain`\n * and `--json` from paying for a terminal UI they never draw — and Ink drives\n * React through `react-reconciler`, which reads React 19 internals, so a host\n * that pins React 18 globally cannot load it at all. Neither is a reason to\n * fail a command that was about to print text.\n */\nexport async function loadInk(): Promise<InkModule | null> {\n if (cached !== undefined) return cached;\n try {\n cached = await import(\"./render/ink.js\");\n } catch {\n cached = null;\n }\n return cached;\n}\n\n/** Paints an Ink element once and returns when the frame has been flushed. */\nexport async function paint(element: ReactElement): Promise<void> {\n const { render } = await import(\"ink\");\n const instance = render(element);\n instance.unmount();\n await instance.waitUntilExit();\n}\n\n/** A live Ink frame (spinner) that is cleared before the real output lands. */\nexport async function transient(element: ReactElement): Promise<() => void> {\n const { render } = await import(\"ink\");\n const instance = render(element);\n return () => {\n instance.clear();\n instance.unmount();\n };\n}\n"],"mappings":";AAYO,SAAS,QAAQ,OAA6B;AACnD,MAAI,MAAM,KAAM,QAAO;AACvB,MAAI,MAAM,MAAO,QAAO;AACxB,MAAI,QAAQ,IAAI,IAAI,EAAG,QAAO;AAC9B,MAAI,QAAQ,IAAI,UAAU,EAAG,QAAO;AACpC,MAAI,QAAQ,OAAO,UAAU,KAAM,QAAO;AAI1C,SAAO,CAAC,QAAQ,OAAO;AACzB;AAEO,SAAS,MAAM,MAAoB;AACxC,UAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAClC;AAEO,SAAS,WAAW,MAAoB;AAC7C,UAAQ,OAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAClC;AAIA,IAAI;AAWJ,eAAsB,UAAqC;AACzD,MAAI,WAAW,OAAW,QAAO;AACjC,MAAI;AACF,aAAS,MAAM,OAAO,mBAAiB;AAAA,EACzC,QAAQ;AACN,aAAS;AAAA,EACX;AACA,SAAO;AACT;AAGA,eAAsB,MAAM,SAAsC;AAChE,QAAM,EAAE,OAAO,IAAI,MAAM,OAAO,KAAK;AACrC,QAAM,WAAW,OAAO,OAAO;AAC/B,WAAS,QAAQ;AACjB,QAAM,SAAS,cAAc;AAC/B;AAGA,eAAsB,UAAU,SAA4C;AAC1E,QAAM,EAAE,OAAO,IAAI,MAAM,OAAO,KAAK;AACrC,QAAM,WAAW,OAAO,OAAO;AAC/B,SAAO,MAAM;AACX,aAAS,MAAM;AACf,aAAS,QAAQ;AAAA,EACnB;AACF;","names":[]}