@agent-surface/cli 0.14.0 → 0.16.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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/analysis.ts","../src/render/present.tsx"],"sourcesContent":["/**\n * The two halves of the surface, and the join between them.\n *\n * A presentation surface has two sources of truth, and every command needs\n * some mix of both:\n *\n * - the **catalog** — what this codebase authors. Static: `type` is a string\n * literal, capability names are object keys, so `view:devices.table.sort` is\n * fully determined by source text ([`extract.ts`](./extract.ts)).\n * - the **projection** — what a mounted scenario actually surfaces, after\n * availability, policy and binding have had their say ([`collect.ts`](./collect.ts)).\n *\n * Splitting those across separate commands is what let a green `check` sit on\n * top of a route no scenario visits. So the split lives here, behind a `depth`\n * dial, and the commands compose the same three steps in whatever order their\n * output needs: `inspect` streams and closes with the verdict, `check` collects\n * and leads with it.\n */\nimport { dirname } from \"node:path\";\nimport { matchesScope } from \"@agent-surface/core/explain\";\nimport { baselineDirFor } from \"./baseline.js\";\nimport { UsageError, type Depth } from \"./contract.js\";\nimport type { CollectResult } from \"./collect.js\";\nimport {\n allowlistPathFor,\n buildCoverageReport,\n readAllowlist,\n unreadAllowlistPathFor,\n type CoverageReport,\n} from \"./coverage.js\";\nimport {\n authoredIds,\n extractCapabilities,\n readLiteralConfigScope,\n unresolved,\n type CapabilityInventory,\n} from \"./extract.js\";\nimport { createSurfaceRunner } from \"./load.js\";\n\nexport type { Depth } from \"./contract.js\";\nexport { UsageError } from \"./contract.js\";\n\nexport interface AnalysisOptions {\n configPath: string;\n depth: Depth;\n scenario?: string;\n scope?: string[];\n tsconfig?: string;\n baselineDir?: string;\n}\n\n/**\n * The static half. `undefined` at `--depth runtime`, which is the caller\n * saying it does not want this computed rather than it having failed.\n */\nexport function readInventory(options: AnalysisOptions): CapabilityInventory | undefined {\n if (options.depth === \"runtime\") return undefined;\n return extractCapabilities({\n root: dirname(options.configPath),\n ...(options.tsconfig ? { tsconfig: options.tsconfig } : {}),\n });\n}\n\nexport function staticConfigScope(options: AnalysisOptions): string[] | undefined {\n return options.scope ?? readLiteralConfigScope(options.configPath);\n}\n\n/** A scenario the config declares whose mount threw. Named, never swallowed. */\nexport interface ScenarioFailure {\n scenario: string;\n message: string;\n}\n\n/**\n * Everything knowable once the config has loaded and before the first mount:\n * which scenarios will run, under which scope, against which manifest.\n *\n * Split out so a command can *say* what it is about to measure. The mounts are\n * the slow half — on a real app, seconds of them — and a report that opens with\n * its qualifiers only after they finish spends that time showing nothing and\n * then asks the reader to re-read the numbers above.\n */\nexport interface RuntimePlan {\n /** Scenarios selected for this run, in config order. */\n scenarios: string[];\n /** Every scenario declared by the config, even when one was selected. */\n declaredScenarios: string[];\n baselineDir: string;\n /** CLI scope wins; otherwise the config scope is effective everywhere. */\n scope?: string[];\n /** Authoritative domain capability ids from the configured oRPC manifest. */\n domainCapabilities: string[];\n domainManifestConfigured: boolean;\n}\n\nexport interface RuntimeAnalysis extends RuntimePlan {\n /** The ones that mounted. */\n results: CollectResult[];\n failures: ScenarioFailure[];\n}\n\nexport interface MountHooks {\n /** Called once, after the config loads and before the first mount. */\n onPlan?: (plan: RuntimePlan) => void | Promise<void>;\n /** Called as each scenario finishes, so a command can print as it goes. */\n onEach?: (result: CollectResult) => void | Promise<void>;\n}\n\n/**\n * The runtime half. `undefined` at `--depth static`.\n *\n * `onEach` is awaited as each scenario finishes, so a command can print as it\n * goes instead of after the last mount — a config with ten scenarios is a long\n * time to look at nothing.\n *\n * A scenario that throws is recorded and the run continues. Before this was\n * one command, `capabilities` was the only thing that still worked on an app\n * that would not mount; merging the commands would have thrown that away if a\n * single bad scenario could abort the run.\n */\nexport async function mountScenarios(\n options: AnalysisOptions,\n hooks: MountHooks = {},\n): Promise<RuntimeAnalysis | undefined> {\n if (options.depth === \"static\") return undefined;\n\n const runner = await createSurfaceRunner(options.configPath);\n try {\n if (options.scenario && !runner.scenarioNames.includes(options.scenario)) {\n throw new UsageError(\n `unknown scenario \"${options.scenario}\" — this config defines ` +\n runner.scenarioNames.map((name) => `\"${name}\"`).join(\", \"),\n );\n }\n const scenarios = options.scenario ? [options.scenario] : runner.scenarioNames;\n const effectiveScope = options.scope ?? runner.config.scope;\n const results: CollectResult[] = [];\n const failures: ScenarioFailure[] = [];\n const plan: RuntimePlan = {\n scenarios,\n declaredScenarios: runner.scenarioNames,\n baselineDir: baselineDirFor(\n options.configPath,\n options.baselineDir ?? runner.config.baselineDir,\n ),\n ...(effectiveScope ? { scope: effectiveScope } : {}),\n domainCapabilities: Object.keys(runner.config.manifest?.tools ?? {})\n .map((path) => `domain:${path}`)\n .sort(),\n domainManifestConfigured: runner.config.manifest !== undefined,\n };\n await hooks.onPlan?.(plan);\n\n for (const scenario of scenarios) {\n let result: CollectResult;\n try {\n result = await runner.collect({\n scenario,\n ...(options.scope ? { scope: options.scope } : {}),\n });\n } catch (error) {\n failures.push({\n scenario,\n message: error instanceof Error ? error.message : String(error),\n });\n continue;\n }\n results.push(result);\n await hooks.onEach?.(result);\n }\n\n return { ...plan, results, failures };\n } finally {\n await runner.close();\n }\n}\n\n/**\n * The component type a capability id belongs to: `view:devices.table.sort` →\n * `devices.table`. Capability names are object keys and cannot contain a dot,\n * so the last one is always the boundary; component types can and do.\n */\nfunction componentTypeOf(capabilityId: string): string {\n const withoutPlane = capabilityId.replace(/^(view|domain):/, \"\");\n const dot = withoutPlane.lastIndexOf(\".\");\n return dot === -1 ? withoutPlane : withoutPlane.slice(0, dot);\n}\n\nexport function scopeInventory(\n inventory: CapabilityInventory | undefined,\n scope: string[] | undefined,\n): CapabilityInventory | undefined {\n if (!inventory || !scope) return inventory;\n return {\n ...inventory,\n capabilities: inventory.capabilities.filter(\n (capability) =>\n capability.resolution === \"unresolved\" ||\n matchesScope(componentTypeOf(capability.capabilityId), scope),\n ),\n };\n}\n\nexport function scopeCapabilityIds(ids: string[], scope: string[] | undefined): string[] {\n return scope ? ids.filter((id) => matchesScope(componentTypeOf(id), scope)) : ids;\n}\n\n/**\n * Authored minus reached (`AS-COVER-004…005`).\n *\n * Two ways this returns `undefined`, and neither is \"no gaps\":\n *\n * - a half was not computed, because the depth did not ask for it;\n * - **a scenario failed to mount.** That scenario reached nothing, so every\n * capability it would have surfaced would be reported as one no scenario\n * reaches. A coverage verdict computed over a partial run is precisely the\n * misleading check this package refuses to emit, so there is no verdict\n * until every scenario mounted. The renderer says which of the two it was.\n */\nexport function joinCoverage(\n inventory: CapabilityInventory | undefined,\n runtime: RuntimeAnalysis | undefined,\n options: AnalysisOptions,\n): CoverageReport | undefined {\n if (!inventory || !runtime) return undefined;\n if (runtime.failures.length > 0) return undefined;\n\n // A scope filters the mount, so it has to filter the catalog by the same\n // predicate — core's own, not a second copy of it. Without this, `--scope\n // devices` reported every `app.navigation` capability as unreached, with the\n // words \"no scenario mounts it\" over two that both scenarios mount.\n const effectiveScope = options.scope ?? runtime.scope;\n const inScope = (capabilityId: string): boolean =>\n matchesScope(componentTypeOf(capabilityId), effectiveScope);\n\n const origins = new Map<string, { file: string; line: number }>();\n for (const capability of inventory.capabilities) {\n if (!origins.has(capability.capabilityId)) {\n origins.set(capability.capabilityId, capability.origin);\n }\n }\n\n const authored = new Set([...authoredIds(inventory)].filter(inScope));\n for (const capabilityId of runtime.domainCapabilities) {\n if (inScope(capabilityId)) authored.add(capabilityId);\n if (!origins.has(capabilityId)) {\n origins.set(capabilityId, { file: \"oRPC manifest\", line: 0 });\n }\n }\n const reachedIds = new Set<string>();\n for (const result of runtime.results) {\n for (const capability of result.explanation.capabilities) {\n reachedIds.add(capability.capabilityId);\n }\n }\n\n // The allowlist is a statement about the whole catalog, and a scoped run has\n // only looked at part of it. Judging an out-of-scope entry either way would\n // be wrong in both directions — it is not an unreached capability this run\n // waved through, and it is not a stale entry either, because nothing here\n // reached it.\n const allowlistPath = allowlistPathFor(runtime.baselineDir);\n const wholeAllowlist = readAllowlist(allowlistPath);\n const allowlist = Object.fromEntries(\n Object.entries(wholeAllowlist).filter(([id]) => inScope(id)),\n );\n\n // Not scope-filtered, deliberately: an unread call site has no capability id,\n // so there is no component type to test a scope prefix against. A scoped run\n // simply reports the same unread sites as an unscoped one.\n const unreadAllowlistPath = unreadAllowlistPathFor(runtime.baselineDir);\n\n return buildCoverageReport({\n unreadAllowlist: readAllowlist(unreadAllowlistPath, \"file#reason#site\"),\n unreadAllowlistPath,\n domainAuthoritative: runtime.domainManifestConfigured,\n authored,\n origins,\n reachedIds,\n scenarios: runtime.scenarios,\n ...(effectiveScope ? { scope: effectiveScope } : {}),\n unresolved: unresolved(inventory),\n allowlist,\n allowlistOutOfScope: Object.keys(wholeAllowlist).length - Object.keys(allowlist).length,\n allowlistPath,\n });\n}\n","/**\n * The presenter: one report, one look, whichever command produced it.\n *\n * Every human-facing command builds [`ReportPart`s](./summary.ts) and hands them\n * here. Nothing else in this package decides between the terminal UI and plain\n * text, waits on a spinner, or writes a blank line — which is the point. That\n * choice used to be made at each call site, so `check` and `snapshot` never drew\n * a terminal UI at all, `inspect` printed its static catalog and its mount\n * failures as raw text in the middle of a rendered report, and the same block\n * carried a different text column in each of them.\n *\n * Three invariants it exists to keep:\n *\n * - **One renderer per stream, decided once.** Ink when that stream is a\n * terminal, plain text otherwise (`AS-CLI-003`), for every part of the run.\n * - **One blank line between parts**, on both paths. Ink ends each painted frame\n * with a newline and plain text has to be asked for one, so the callers stop\n * sprinkling `\\n` and getting it wrong in one of the two.\n * - **One label grid.** The text column belongs to the report, not to the block,\n * and it can only ever widen — so `Config`, `Capabilities` and `Coverage` line\n * up whether they were printed a second or a minute apart.\n */\nimport { isPlain, loadInk, paint, transient, write, type OutputFlags } from \"../output.js\";\nimport { renderPartPlain } from \"./plain.js\";\nimport { LABEL_WIDTH, reportGrid, type ReportPart, type ReportStream } from \"./summary.js\";\n\nexport interface Presenter {\n /** Draws parts in order, one blank line between them. */\n emit(...parts: ReportPart[]): Promise<void>;\n /** Names the slow thing currently happening. A no-op in plain mode. */\n wait(label: string): Promise<void>;\n /** Clears any spinner. Called for you before anything is drawn. */\n settle(): void;\n}\n\ntype InkModule = NonNullable<Awaited<ReturnType<typeof loadInk>>>;\n\nclass ReportPresenter implements Presenter {\n /** `null` on a stream rendering plain text — piped, CI, `--plain`, React 18. */\n readonly #out: InkModule | null;\n readonly #err: InkModule | null;\n /** Sticky, and only ever wider: a grid that shrank mid-report is two grids. */\n #labelWidth = LABEL_WIDTH;\n #wrote = false;\n /**\n * Whether the last part was written as plain text. Ink's own frame supplies\n * the blank line after it; plain text has to be asked for one before the next\n * part. Tracking which drew last is what keeps the spacing identical when a\n * drawn report sends a finding to a redirected stderr.\n */\n #plainLast = false;\n #stop: (() => void) | undefined;\n\n constructor(out: InkModule | null, err: InkModule | null) {\n this.#out = out;\n this.#err = err;\n }\n\n async emit(...parts: ReportPart[]): Promise<void> {\n for (const part of parts) await this.#draw(part);\n }\n\n async wait(label: string): Promise<void> {\n this.settle();\n // Nothing transient is ever written in plain mode: `AS-CLI-003` wants\n // byte-stable output, and a spinner is neither.\n const ink = this.#out;\n if (ink) this.#stop = await transient(<ink.Loading label={label} />);\n }\n\n settle(): void {\n this.#stop?.();\n this.#stop = undefined;\n }\n\n async #draw(part: ReportPart): Promise<void> {\n // A spinner is a live frame: anything written under it lands in the region\n // Ink is about to erase.\n this.settle();\n const stream: ReportStream = part.stream ?? \"out\";\n if (part.kind === \"blocks\") {\n this.#labelWidth = Math.max(this.#labelWidth, reportGrid(part.blocks, LABEL_WIDTH).label);\n }\n const separate = this.#wrote && this.#plainLast;\n const ink = stream === \"err\" ? this.#err : this.#out;\n\n if (ink) {\n if (separate) write(\"\", stream);\n await paint(<ink.Part part={part} labelWidth={this.#labelWidth} />, stream);\n } else {\n const text = renderPartPlain(part, this.#labelWidth);\n if (text.length === 0) return;\n write(separate ? `\\n${text}` : text, stream);\n }\n this.#plainLast = ink === null;\n this.#wrote = true;\n }\n}\n\n/**\n * The presenter for this run.\n *\n * `--json` resolves to the plain path and its spinner to nothing, so a command\n * emitting data rather than a report simply has no parts to emit — it never has\n * to ask which renderer it is talking to.\n */\nexport async function createPresenter(flags: OutputFlags): Promise<Presenter> {\n const drawn = !isPlain(flags, \"out\") || !isPlain(flags, \"err\");\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 = drawn ? await loadInk() : null;\n return new ReportPresenter(\n ink && !isPlain(flags, \"out\") ? ink : null,\n ink && !isPlain(flags, \"err\") ? ink : null,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAoCtB,SAAS,cAAc,SAA2D;AACvF,MAAI,QAAQ,UAAU,UAAW,QAAO;AACxC,SAAO,oBAAoB;AAAA,IACzB,MAAM,QAAQ,QAAQ,UAAU;AAAA,IAChC,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,EAC3D,CAAC;AACH;AAEO,SAAS,kBAAkB,SAAgD;AAChF,SAAO,QAAQ,SAAS,uBAAuB,QAAQ,UAAU;AACnE;AAuDA,eAAsB,eACpB,SACA,QAAoB,CAAC,GACiB;AACtC,MAAI,QAAQ,UAAU,SAAU,QAAO;AAEvC,QAAM,SAAS,MAAM,oBAAoB,QAAQ,UAAU;AAC3D,MAAI;AACF,QAAI,QAAQ,YAAY,CAAC,OAAO,cAAc,SAAS,QAAQ,QAAQ,GAAG;AACxE,YAAM,IAAI;AAAA,QACR,qBAAqB,QAAQ,QAAQ,kCACnC,OAAO,cAAc,IAAI,CAAC,SAAS,IAAI,IAAI,GAAG,EAAE,KAAK,IAAI;AAAA,MAC7D;AAAA,IACF;AACA,UAAM,YAAY,QAAQ,WAAW,CAAC,QAAQ,QAAQ,IAAI,OAAO;AACjE,UAAM,iBAAiB,QAAQ,SAAS,OAAO,OAAO;AACtD,UAAM,UAA2B,CAAC;AAClC,UAAM,WAA8B,CAAC;AACrC,UAAM,OAAoB;AAAA,MACxB;AAAA,MACA,mB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AW,QAAQ,KAAK,OAAO,KAAK;AAEhD,QAAI,KAAK;AACP,UAAI,SAAU,OAAM,IAAI,MAAM;AAC9B,YAAM,MAAM,oBAAC,IAAI,MAAJ,EAAS,MAAY,YAAY,KAAK,aAAa,GAAI,MAAM;AAAA,IAC5E,OAAO;AACL,YAAM,OAAO,gBAAgB,MAAM,KAAK,WAAW;AACnD,UAAI,KAAK,WAAW,EAAG;AACvB,YAAM,WAAW;AAAA,EAAK,IAAI,KAAK,MAAM,MAAM;AAAA,IAC7C;AACA,SAAK,aAAa,QAAQ;AAC1B,SAAK,SAAS;AAAA,EAChB;AACF;AASA,eAAsB,gBAAgB,OAAwC;AAC5E,QAAM,QAAQ,CAAC,QAAQ,OAAO,KAAK,KAAK,CAAC,QAAQ,OAAO,KAAK;AAG7D,QAAM,MAAM,QAAQ,MAAM,QAAQ,IAAI;AACtC,SAAO,IAAI;AAAA,IACT,OAAO,CAAC,QAAQ,OAAO,KAAK,IAAI,MAAM;AAAA,IACtC,OAAO,CAAC,QAAQ,OAAO,KAAK,IAAI,MAAM;AAAA,EACxC;AACF;","names":[]}
package/dist/collect.js DELETED
@@ -1,52 +0,0 @@
1
- import {
2
- mountScenario
3
- } from "./chunk-A2G4QLX5.js";
4
-
5
- // src/collect.ts
6
- import { explainSurface } from "@agent-surface/core/explain";
7
- async function collect(config, options) {
8
- const mount = await mountScenario(config, options.scenario, {
9
- ...options.consumer ? { consumer: options.consumer } : {}
10
- });
11
- const scope = options.scope ?? config.scope;
12
- const ctx = {
13
- consumer: mount.consumer,
14
- includeUnavailable: true,
15
- ...scope ? { scope } : {}
16
- };
17
- try {
18
- return {
19
- scenario: options.scenario,
20
- // Inert copies: the live objects are frozen and graph-local, and only
21
- // plain JSON may cross back into the CLI process.
22
- snapshot: jsonify(mount.mounted.registry.snapshot(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 } : {}
29
- };
30
- } finally {
31
- mount.surface.dispose();
32
- }
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
- }
46
- function jsonify(value) {
47
- return JSON.parse(JSON.stringify(value));
48
- }
49
- export {
50
- collect
51
- };
52
- //# sourceMappingURL=collect.js.map
@@ -1 +0,0 @@
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":[]}
@@ -1,60 +0,0 @@
1
- import { ReactElement } from 'react';
2
- import { AgentSurfaceRegistry, AgentConsumer } from '@agent-surface/core';
3
-
4
- /** Structural subset of the authoritative orpc-agent manifest the CLI consumes. */
5
- interface SurfaceDomainManifest {
6
- tools: Record<string, {
7
- description: string;
8
- }>;
9
- }
10
- /** What `mount()` hands back: the app's own registry and its rendered tree. */
11
- interface MountResult<TApp = unknown> {
12
- registry: AgentSurfaceRegistry;
13
- ui: ReactElement;
14
- /**
15
- * Anything else your tests need back — the app wiring, a backend double, a
16
- * router handle. The CLI ignores it entirely; it exists so the same scenario
17
- * can drive `agent-surface inspect` and a Vitest suite without the suite
18
- * having to rebuild the app a second way.
19
- */
20
- app?: TApp;
21
- }
22
- /**
23
- * Scenario properties are whatever your `mount()` needs — a user, a route, a
24
- * feature flag. The CLI never interprets them; it just hands them back, plus
25
- * `scenario` (the key it was listed under).
26
- */
27
- type ScenarioProps = Record<string, unknown>;
28
- interface SurfaceConfig<TScenario extends ScenarioProps = ScenarioProps, TApp = unknown> {
29
- /**
30
- * Build the app the way the app builds itself. This should point at your
31
- * existing composition root, not restate it — whatever `main.tsx` calls.
32
- */
33
- mount(props: TScenario & {
34
- scenario: string;
35
- }): MountResult<TApp> | Promise<MountResult<TApp>>;
36
- /**
37
- * Optional extra settling after mount effects flush, for anything the first
38
- * render kicks off asynchronously (an initial fetch, a router resolve).
39
- * The CLI already flushes React effects and pending microtasks for you.
40
- */
41
- settle?: (mounted: MountResult<TApp>) => void | Promise<void>;
42
- /** Named surfaces to inspect and check. At least one is required. */
43
- scenarios: Record<string, TScenario>;
44
- /** Consumer identity snapshots are computed for. Default `{id:"cli",kind:"test"}`. */
45
- consumer?: AgentConsumer;
46
- /** Component-type prefixes to restrict to, same meaning as `SnapshotContext.scope`. */
47
- scope?: string[];
48
- /** Authoritative domain denominator. Full analysis joins every manifest tool. */
49
- manifest?: SurfaceDomainManifest;
50
- /** Where `snapshot`/`check` keep baselines. Default `.agent-surface`, relative to the config. */
51
- baselineDir?: string;
52
- }
53
- /**
54
- * Identity function that exists purely for type inference — the same shape as
55
- * Vite's `defineConfig`. Your scenario props stay strongly typed inside
56
- * `mount()` without you annotating them.
57
- */
58
- declare function defineSurface<TScenario extends ScenarioProps, TApp = unknown>(config: SurfaceConfig<TScenario, TApp>): SurfaceConfig<TScenario, TApp>;
59
-
60
- export { type MountResult as M, type ScenarioProps as S, type SurfaceConfig as a, defineSurface as d };
@@ -1,164 +0,0 @@
1
- import {
2
- createPresenter
3
- } from "./chunk-YUT4FVQQ.js";
4
- import {
5
- UsageError,
6
- isPlain,
7
- loadInk,
8
- writeError
9
- } from "./chunk-G7Z6PP6C.js";
10
- import {
11
- READING_SOURCE,
12
- authoredIds,
13
- catalogDetailParts,
14
- catalogRows,
15
- displayPath,
16
- extractCapabilities,
17
- findTsconfig
18
- } from "./chunk-LQUL4OIA.js";
19
-
20
- // src/commands/init.tsx
21
- import { existsSync, writeFileSync } from "fs";
22
- import { join } from "path";
23
- import { jsx } from "react/jsx-runtime";
24
- var CONFIG_NAME = "agent-surface.config.tsx";
25
- var ENTRY_CANDIDATES = [
26
- "src/main.tsx",
27
- "src/main.ts",
28
- "src/index.tsx",
29
- "src/App.tsx",
30
- "src/app/App.tsx",
31
- "app/root.tsx"
32
- ];
33
- function scaffold(entry) {
34
- const importPath = entry ? `./${entry.replace(/\.tsx?$/, ".js")}` : "./src/App.js";
35
- return `import { defineSurface } from "@agent-surface/cli";
36
- // TODO: point these at your own composition root \u2014 whatever \`main.tsx\` calls.
37
- // The config should *reuse* how the app builds itself, not restate it.
38
- import { App } from "${importPath}";
39
-
40
- export default defineSurface({
41
- mount: ({ user }) => {
42
- // TODO: build the app the way the app builds itself, and hand back the
43
- // registry it created plus the tree that registers into it.
44
- const app = createApp({ environment: "test", user });
45
- return { registry: app.registry, ui: <App app={app} />, app };
46
- },
47
-
48
- // Named prop bundles. Free-form \u2014 a user, a route, a feature flag; the CLI
49
- // never interprets them. Every scenario you leave out is a surface nothing
50
- // measures, which is what \`--depth full\` reports as unreached.
51
- scenarios: {
52
- default: { user: { id: "u_1", permissions: [] } },
53
- },
54
- });
55
- `;
56
- }
57
- async function runInit(options) {
58
- const configPath = join(options.cwd, CONFIG_NAME);
59
- if (existsSync(configPath)) {
60
- throw new UsageError(
61
- `${displayPath(configPath)} already exists \u2014 edit it, or delete it and re-run`
62
- );
63
- }
64
- const tsconfig = options.tsconfig ?? findTsconfig(options.cwd);
65
- if (!tsconfig) {
66
- throw new UsageError(
67
- `no tsconfig.json found from ${options.cwd} \u2014 agent-surface reads your TypeScript program to find registration call sites, and cannot do that without one`
68
- );
69
- }
70
- const present = await createPresenter(options);
71
- await present.wait(READING_SOURCE);
72
- const inventory = extractCapabilities({ root: options.cwd, tsconfig });
73
- const ids = authoredIds(inventory);
74
- const entry = ENTRY_CANDIDATES.find((candidate) => existsSync(join(options.cwd, candidate)));
75
- const parts = [
76
- {
77
- kind: "blocks",
78
- blocks: [
79
- {
80
- title: "SURFACE INIT",
81
- rows: [
82
- { label: "Tsconfig", text: displayPath(tsconfig) },
83
- { label: "Config", text: `${displayPath(configPath)} \u2014 to be written` }
84
- ]
85
- },
86
- { title: "STATIC CATALOG", rows: catalogRows(inventory) }
87
- ]
88
- },
89
- ...ids.size > 0 ? catalogDetailParts(inventory) : []
90
- ];
91
- if (ids.size === 0) {
92
- parts.push({
93
- kind: "note",
94
- lines: [
95
- "Nothing is annotated yet \u2014 that is the default, and it is the safe one: a capability",
96
- "exists only where someone wrote one. Start with `useAgentComponent` in a component",
97
- "that owns state worth acting on, then re-run this."
98
- ]
99
- });
100
- }
101
- parts.push({
102
- kind: "note",
103
- title: "SCAFFOLD",
104
- lines: [
105
- ` ${displayPath(configPath)}`,
106
- entry ? ` imports ./${entry}, which you will still have to wire into a mount()` : " no app entry found, so the import line is a placeholder you will have to point somewhere"
107
- ]
108
- });
109
- await present.emit(...parts);
110
- if (!options.yes) {
111
- const answered = await ask(options, `Write ${CONFIG_NAME}?`);
112
- if (!answered) {
113
- await present.emit({ kind: "note", lines: ["Nothing written."] });
114
- return 0;
115
- }
116
- }
117
- writeFileSync(configPath, scaffold(entry), "utf8");
118
- await present.emit(
119
- { kind: "note", lines: [`wrote ${displayPath(configPath)}`] },
120
- {
121
- kind: "steps",
122
- title: "NEXT STEPS",
123
- steps: [
124
- "fill in mount() \u2014 it should call your existing composition root",
125
- "`agent-surface inspect` to see what an agent can reach",
126
- "`agent-surface snapshot` to commit the baseline, then `check` in CI"
127
- ]
128
- }
129
- );
130
- return 0;
131
- }
132
- async function ask(options, question) {
133
- if (isPlain(options) || process.stdin.isTTY !== true) {
134
- writeError("");
135
- writeError("stdin is not a terminal, so there is nobody to ask \u2014 re-run with --yes to accept.");
136
- return false;
137
- }
138
- const ink = await loadInk();
139
- if (!ink) {
140
- writeError("");
141
- writeError("no interactive renderer available here \u2014 re-run with --yes to accept.");
142
- return false;
143
- }
144
- const { render } = await import("ink");
145
- return new Promise((resolve) => {
146
- const instance = render(
147
- /* @__PURE__ */ jsx(
148
- ink.Confirm,
149
- {
150
- question,
151
- onAnswer: (yes) => {
152
- instance.clear();
153
- instance.unmount();
154
- resolve(yes);
155
- }
156
- }
157
- )
158
- );
159
- });
160
- }
161
- export {
162
- runInit
163
- };
164
- //# sourceMappingURL=init-64GIHMKV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/init.tsx"],"sourcesContent":["import { existsSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { UsageError } from \"../analysis.js\";\nimport { authoredIds, extractCapabilities, findTsconfig } from \"../extract.js\";\nimport { isPlain, loadInk, writeError } from \"../output.js\";\nimport { createPresenter } from \"../render/present.js\";\nimport {\n catalogDetailParts,\n catalogRows,\n displayPath,\n READING_SOURCE,\n type ReportPart,\n} from \"../render/summary.js\";\n\nexport interface InitOptions {\n cwd: string;\n tsconfig?: string;\n yes?: boolean;\n plain?: boolean;\n}\n\nconst CONFIG_NAME = \"agent-surface.config.tsx\";\n\n/**\n * Where an app is usually assembled. `init` does not *probe* these — it cannot,\n * because a surface config needs a `mount()` that builds the app, and there is\n * no export a tool can import to get one. It names the likeliest file so the\n * scaffold's import line points somewhere real more often than not.\n */\nconst ENTRY_CANDIDATES = [\n \"src/main.tsx\",\n \"src/main.ts\",\n \"src/index.tsx\",\n \"src/App.tsx\",\n \"src/app/App.tsx\",\n \"app/root.tsx\",\n];\n\nfunction scaffold(entry: string | undefined): string {\n const importPath = entry ? `./${entry.replace(/\\.tsx?$/, \".js\")}` : \"./src/App.js\";\n return `import { defineSurface } from \"@agent-surface/cli\";\n// TODO: point these at your own composition root — whatever \\`main.tsx\\` calls.\n// The config should *reuse* how the app builds itself, not restate it.\nimport { App } from \"${importPath}\";\n\nexport default defineSurface({\n mount: ({ user }) => {\n // TODO: build the app the way the app builds itself, and hand back the\n // registry it created plus the tree that registers into it.\n const app = createApp({ environment: \"test\", user });\n return { registry: app.registry, ui: <App app={app} />, app };\n },\n\n // Named prop bundles. Free-form — a user, a route, a feature flag; the CLI\n // never interprets them. Every scenario you leave out is a surface nothing\n // measures, which is what \\`--depth full\\` reports as unreached.\n scenarios: {\n default: { user: { id: \"u_1\", permissions: [] } },\n },\n});\n`;\n}\n\n/**\n * `agent-surface init` — the on-ramp.\n *\n * It reads the codebase first and writes nothing before it has shown you what\n * it found. That order is the whole point: the number it prints is the one\n * every later command is relative to, and a scaffold that appears before the\n * summary asks you to accept a config for a codebase neither of you has looked\n * at yet.\n *\n * It mounts nothing and needs no config to exist — it is `--depth static` with\n * a file write on the end, and it says so in the same blocks `inspect --depth\n * static` uses, so the first report a reader ever sees is the one they will go\n * on seeing.\n */\nexport async function runInit(options: InitOptions): Promise<number> {\n const configPath = join(options.cwd, CONFIG_NAME);\n if (existsSync(configPath)) {\n throw new UsageError(\n `${displayPath(configPath)} already exists — edit it, or delete it and re-run`,\n );\n }\n\n const tsconfig = options.tsconfig ?? findTsconfig(options.cwd);\n if (!tsconfig) {\n throw new UsageError(\n `no tsconfig.json found from ${options.cwd} — agent-surface reads your TypeScript program ` +\n \"to find registration call sites, and cannot do that without one\",\n );\n }\n\n const present = await createPresenter(options);\n await present.wait(READING_SOURCE);\n const inventory = extractCapabilities({ root: options.cwd, tsconfig });\n const ids = authoredIds(inventory);\n const entry = ENTRY_CANDIDATES.find((candidate) => existsSync(join(options.cwd, candidate)));\n\n const parts: ReportPart[] = [\n {\n kind: \"blocks\",\n blocks: [\n {\n title: \"SURFACE INIT\",\n rows: [\n { label: \"Tsconfig\", text: displayPath(tsconfig) },\n { label: \"Config\", text: `${displayPath(configPath)} — to be written` },\n ],\n },\n { title: \"STATIC CATALOG\", rows: catalogRows(inventory) },\n ],\n },\n ...(ids.size > 0 ? catalogDetailParts(inventory) : []),\n ];\n\n if (ids.size === 0) {\n parts.push({\n kind: \"note\",\n lines: [\n \"Nothing is annotated yet — that is the default, and it is the safe one: a capability\",\n \"exists only where someone wrote one. Start with `useAgentComponent` in a component\",\n \"that owns state worth acting on, then re-run this.\",\n ],\n });\n }\n\n parts.push({\n kind: \"note\",\n title: \"SCAFFOLD\",\n lines: [\n ` ${displayPath(configPath)}`,\n entry\n ? ` imports ./${entry}, which you will still have to wire into a mount()`\n : \" no app entry found, so the import line is a placeholder you will have to point somewhere\",\n ],\n });\n await present.emit(...parts);\n\n if (!options.yes) {\n const answered = await ask(options, `Write ${CONFIG_NAME}?`);\n if (!answered) {\n await present.emit({ kind: \"note\", lines: [\"Nothing written.\"] });\n return 0;\n }\n }\n\n writeFileSync(configPath, scaffold(entry), \"utf8\");\n await present.emit(\n { kind: \"note\", lines: [`wrote ${displayPath(configPath)}`] },\n {\n kind: \"steps\",\n title: \"NEXT STEPS\",\n steps: [\n \"fill in mount() — it should call your existing composition root\",\n \"`agent-surface inspect` to see what an agent can reach\",\n \"`agent-surface snapshot` to commit the baseline, then `check` in CI\",\n ],\n },\n );\n return 0;\n}\n\n/**\n * There is no prompt to give when nothing is attached to answer it. Failing\n * with the flag that would have worked beats writing a file the caller never\n * agreed to, and beats hanging on a read that will never return.\n */\nasync function ask(options: InitOptions, question: string): Promise<boolean> {\n if (isPlain(options) || process.stdin.isTTY !== true) {\n writeError(\"\");\n writeError(\"stdin is not a terminal, so there is nobody to ask — re-run with --yes to accept.\");\n return false;\n }\n const ink = await loadInk();\n if (!ink) {\n writeError(\"\");\n writeError(\"no interactive renderer available here — re-run with --yes to accept.\");\n return false;\n }\n const { render } = await import(\"ink\");\n return new Promise<boolean>((resolve) => {\n const instance = render(\n <ink.Confirm\n question={question}\n onAnswer={(yes)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