@agent-surface/cli 0.13.0 → 0.15.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.
Files changed (38) hide show
  1. package/dist/bin.js +41 -14
  2. package/dist/bin.js.map +1 -1
  3. package/dist/{check-TJIX7NDE.js → check-VWRYNYLN.js} +66 -48
  4. package/dist/check-VWRYNYLN.js.map +1 -0
  5. package/dist/chunk-A5UCBF7D.js +246 -0
  6. package/dist/chunk-A5UCBF7D.js.map +1 -0
  7. package/dist/chunk-GYYWHZPM.js +532 -0
  8. package/dist/chunk-GYYWHZPM.js.map +1 -0
  9. package/dist/chunk-NFK3XWWH.js +1475 -0
  10. package/dist/chunk-NFK3XWWH.js.map +1 -0
  11. package/dist/chunk-Y2LSPEVK.js +61 -0
  12. package/dist/chunk-Y2LSPEVK.js.map +1 -0
  13. package/dist/index.d.ts +3 -2
  14. package/dist/{init-6XV64LK2.js → init-BVZR6CRS.js} +62 -40
  15. package/dist/init-BVZR6CRS.js.map +1 -0
  16. package/dist/{ink-QR7X7TAC.js → ink-ZCQ26EY4.js} +71 -17
  17. package/dist/ink-ZCQ26EY4.js.map +1 -0
  18. package/dist/{inspect-NJ4J3MPP.js → inspect-3YFPCYQJ.js} +88 -104
  19. package/dist/inspect-3YFPCYQJ.js.map +1 -0
  20. package/dist/snapshot-5QKLZKZI.js +130 -0
  21. package/dist/snapshot-5QKLZKZI.js.map +1 -0
  22. package/package.json +4 -4
  23. package/dist/check-TJIX7NDE.js.map +0 -1
  24. package/dist/chunk-3AJ343NA.js +0 -178
  25. package/dist/chunk-3AJ343NA.js.map +0 -1
  26. package/dist/chunk-IALBMW3R.js +0 -278
  27. package/dist/chunk-IALBMW3R.js.map +0 -1
  28. package/dist/chunk-L7GHSC2Z.js +0 -465
  29. package/dist/chunk-L7GHSC2Z.js.map +0 -1
  30. package/dist/chunk-UGCLJ5JX.js +0 -724
  31. package/dist/chunk-UGCLJ5JX.js.map +0 -1
  32. package/dist/chunk-VX6GBEP3.js +0 -539
  33. package/dist/chunk-VX6GBEP3.js.map +0 -1
  34. package/dist/init-6XV64LK2.js.map +0 -1
  35. package/dist/ink-QR7X7TAC.js.map +0 -1
  36. package/dist/inspect-NJ4J3MPP.js.map +0 -1
  37. package/dist/snapshot-ZGTAF2Y5.js +0 -77
  38. package/dist/snapshot-ZGTAF2Y5.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/init.tsx"],"sourcesContent":["import { existsSync, writeFileSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\nimport { UsageError } from \"../analysis.js\";\nimport { authoredIds, extractCapabilities, findTsconfig, unresolved } from \"../extract.js\";\nimport { isPlain, loadInk, write, writeError } from \"../output.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.\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 `${relative(process.cwd(), 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 inventory = extractCapabilities({ root: options.cwd, tsconfig });\n const ids = authoredIds(inventory);\n const unread = unresolved(inventory);\n const components = new Set(\n [...ids].map((id) => id.replace(/^view:/, \"\").split(\".\").slice(0, -1).join(\".\")),\n );\n\n write(`Read ${inventory.filesAnalyzed} file${inventory.filesAnalyzed === 1 ? \"\" : \"s\"} from ${relative(process.cwd(), tsconfig) || \"tsconfig.json\"}`);\n write(\"\");\n write(` authored capabilities ${ids.size}`);\n write(` components ${components.size}`);\n write(` unread call sites ${unread.length}`);\n\n if (ids.size === 0) {\n write(\"\");\n write(\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 } else {\n write(\"\");\n for (const component of [...components].sort()) write(` ${component}`);\n }\n\n const entry = ENTRY_CANDIDATES.find((candidate) => existsSync(join(options.cwd, candidate)));\n write(\"\");\n write(`Write ${relative(process.cwd(), configPath)}?`);\n write(\n entry\n ? ` it will import from ./${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 if (!options.yes) {\n const answered = await ask(options, `Write ${CONFIG_NAME}?`);\n if (!answered) {\n write(\"\");\n write(\"Nothing written.\");\n return 0;\n }\n }\n\n writeFileSync(configPath, scaffold(entry), \"utf8\");\n write(\"\");\n write(`wrote ${relative(process.cwd(), configPath)}`);\n write(\"\");\n write(\"Next:\");\n write(\" 1. fill in mount() — it should call your existing composition root\");\n write(\" 2. `agent-surface inspect` to see what an agent can reach\");\n write(\" 3. `agent-surface snapshot` to commit the baseline, then `check` in CI\");\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) => {\n instance.clear();\n instance.unmount();\n resolve(yes);\n }}\n />,\n );\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,qBAAqB;AAC1C,SAAS,MAAM,gBAAgB;AA4JzB;AAhJN,IAAM,cAAc;AAQpB,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,SAAS,OAAmC;AACnD,QAAM,aAAa,QAAQ,KAAK,MAAM,QAAQ,WAAW,KAAK,CAAC,KAAK;AACpE,SAAO;AAAA;AAAA;AAAA,uBAGc,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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import type { ReactElement } from \"react\";\nimport { Box, Static, Text, useInput } from \"ink\";\nimport Spinner from \"ink-spinner\";\nimport type { CapabilityRow, CapabilityGroup, SurfaceView } from \"./model.js\";\nimport { flatRows } from \"./model.js\";\nimport { riskClause, type FindingSection, type ReportBlock, type ReportRow } from \"./summary.js\";\n\nconst OUTCOME = {\n expose: { mark: \"●\", color: \"green\" as const, state: \"callable\" },\n disable: { mark: \"◐\", color: \"yellow\" as const, state: \"disabled\" },\n hide: { mark: \"○\", color: \"red\" as const, state: \"hidden\" },\n};\n\nconst STATUS_COLOR = {\n PASS: \"green\",\n WARN: \"yellow\",\n FAIL: \"red\",\n ERROR: \"red\",\n} as const;\n\nconst TONE_COLOR = { good: \"green\", warn: \"yellow\", bad: \"red\" } as const;\n\nconst NONE = \"—\";\nconst LABEL_WIDTH = 12;\nconst STATUS_WIDTH = 7;\n\n/**\n * Same column widths as the plain renderer computes, and for the same reason:\n * from the content, never from the terminal. A TTY table that reflows on resize\n * and a piped table that does not would be two different renderings of one view\n * model, which is exactly what this file exists to prevent.\n */\nfunction widthsFor(headers: string[], rows: string[][]): number[] {\n return headers.map((header, column) =>\n Math.max(header.length, ...rows.map((row) => (row[column] ?? \"\").length)),\n );\n}\n\nfunction pad(value: string, width: number): string {\n return value.padEnd(width);\n}\n\n/**\n * `init`'s one question. Enter accepts, because the answer this asks for is the\n * one the summary above it has already made the case for — and because a\n * scaffold is the least destructive thing this package writes.\n */\nexport function Confirm({\n question,\n onAnswer,\n}: {\n question: string;\n onAnswer: (yes: boolean) => void;\n}): ReactElement {\n useInput((input, key) => {\n if (key.return || input.toLowerCase() === \"y\") onAnswer(true);\n else if (key.escape || input.toLowerCase() === \"n\" || (key.ctrl && input === \"c\")) {\n onAnswer(false);\n }\n });\n return (\n <Box marginTop={1}>\n <Text bold>{question}</Text>\n <Text dimColor>{\" (Y/n) \"}</Text>\n </Box>\n );\n}\n\nexport function Loading({ label }: { label: string }): ReactElement {\n return (\n <Text>\n <Text color=\"cyan\">\n <Spinner type=\"dots\" />\n </Text>\n <Text dimColor>{` ${label}…`}</Text>\n </Text>\n );\n}\n\n/** One `label STATUS text` row, coloured by whichever of the two it carries. */\nfunction Row({ row, width, statuses }: { row: ReportRow; width: number; statuses: boolean }): ReactElement {\n return (\n <Box>\n <Text dimColor>{pad(row.label, width)}</Text>\n {statuses ? (\n <Text bold color={row.status ? STATUS_COLOR[row.status] : undefined}>\n {pad(row.status ?? \"\", STATUS_WIDTH)}\n </Text>\n ) : null}\n <Text color={row.tone ? TONE_COLOR[row.tone] : undefined} wrap=\"wrap\">\n {row.text}\n </Text>\n </Box>\n );\n}\n\n/**\n * The labelled blocks a report is built from — the run header, the catalog\n * summary, the closing verdict. Same rows the plain renderer prints, same\n * widths, with the status word and the tone carrying colour on a terminal.\n */\nexport function Report({ blocks }: { blocks: ReportBlock[] }): ReactElement {\n const width = Math.max(\n LABEL_WIDTH,\n ...blocks.flatMap((block) => block.rows.map((row) => row.label.length + 2)),\n );\n const statuses = blocks.some((block) => block.rows.some((row) => row.status));\n // Ink prints a newline of its own after each painted frame, so only the\n // blocks *within* one frame ask for the blank line above them. A margin on\n // the first would double it, which reads as a missing block rather than as\n // breathing room.\n return (\n <Static\n items={blocks.map((block, index) => ({ key: block.title ?? `block-${index}`, block, index }))}\n >\n {({ key, block, index }) => (\n <Box key={key} flexDirection=\"column\" marginTop={index === 0 ? 0 : 1}>\n {block.title ? <Text bold>{block.title}</Text> : null}\n {block.rows.map((row) => (\n <Row key={row.label} row={row} width={width} statuses={statuses} />\n ))}\n </Box>\n )}\n </Static>\n );\n}\n\nfunction Grid({\n headers,\n rows,\n}: {\n headers: string[];\n rows: Array<{ cells: string[]; note?: string }>;\n}): ReactElement {\n const widths = widthsFor(\n headers,\n rows.map((row) => row.cells),\n );\n return (\n <Box flexDirection=\"column\">\n <Box>\n {headers.map((header, column) => (\n <Text key={header} dimColor bold>\n {column === headers.length - 1 ? header : `${pad(header, widths[column]!)} `}\n </Text>\n ))}\n </Box>\n {rows.map((row, index) => (\n <Box key={`${row.cells[0]}-${index}`} flexDirection=\"column\">\n <Box>\n {row.cells.map((cell, column) => (\n <Text key={`${column}`} bold={column === 0}>\n {column === headers.length - 1 ? cell : `${pad(cell, widths[column]!)} `}\n </Text>\n ))}\n </Box>\n {row.note ? (\n <Box paddingLeft={4}>\n <Text dimColor wrap=\"wrap\">{`⤷ ${row.note}`}</Text>\n </Box>\n ) : null}\n </Box>\n ))}\n </Box>\n );\n}\n\nexport function Table({\n title,\n headers,\n rows,\n}: {\n title: string;\n headers: string[];\n rows: Array<{ cells: string[]; note?: string }>;\n}): ReactElement {\n return (\n <Static items={[{ key: title }]}>\n {(block) => (\n <Box key={block.key} flexDirection=\"column\">\n <Text bold>{title}</Text>\n <Grid headers={headers} rows={rows} />\n </Box>\n )}\n </Static>\n );\n}\n\n/**\n * Findings. The heading says what it is, the gloss why it matters, and the hint\n * what to do — printed with the finding rather than left to be inferred.\n */\nexport function Findings({ sections }: { sections: FindingSection[] }): ReactElement {\n return (\n <Static\n items={sections.map((section, index) => ({ key: `${section.title}-${index}`, section, index }))}\n >\n {({ key, section, index }) => (\n <Box key={key} flexDirection=\"column\" marginTop={index === 0 ? 0 : 1}>\n <Box>\n <Text\n backgroundColor={section.tone === \"notice\" ? \"yellow\" : \"red\"}\n color=\"black\"\n bold\n >{` ${section.title} `}</Text>\n <Text dimColor>{` ${section.gloss}${section.count > 0 ? ` ${section.count}` : \"\"}`}</Text>\n </Box>\n {section.headers && section.rows ? (\n <Grid headers={section.headers} rows={section.rows} />\n ) : null}\n {(section.lines ?? []).map((line, index) => (\n <Box key={`${index}`} paddingLeft={2}>\n <Text>{line}</Text>\n </Box>\n ))}\n {section.hint ? (\n <Box paddingLeft={2}>\n <Text color=\"cyan\" wrap=\"wrap\">{`→ ${section.hint}`}</Text>\n </Box>\n ) : null}\n </Box>\n )}\n </Static>\n );\n}\n\nfunction PolicyLine({\n policy,\n}: {\n policy: NonNullable<CapabilityRow[\"policies\"]>[number];\n}): ReactElement {\n const vote = policy.discovery?.decision;\n const color = vote === \"hide\" ? \"red\" : vote === \"disable\" ? \"yellow\" : \"green\";\n return (\n <Box paddingLeft={6}>\n <Text dimColor>policy </Text>\n <Text bold>{policy.name}</Text>\n <Text dimColor>{` (${policy.scope}${policy.phases.length ? `, ${policy.phases.join(\"/\")}` : \"\"}) `}</Text>\n {vote ? (\n <Text color={color}>\n {vote}\n {policy.discovery?.decision === \"disable\" ? ` — ${policy.discovery.reason}` : \"\"}\n </Text>\n ) : (\n <Text dimColor>no discovery hook</Text>\n )}\n {policy.threw ? <Text color=\"red\" bold>{\" THREW\"}</Text> : null}\n {policy.confirmationEscalation ? (\n <Text color=\"magenta\">{\" escalates-confirmation\"}</Text>\n ) : null}\n </Box>\n );\n}\n\nfunction Capability({ row }: { row: CapabilityRow }): ReactElement {\n const outcome = OUTCOME[row.outcome];\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text color={outcome.color}>{` ${outcome.mark} `}</Text>\n <Text bold>{row.name}</Text>\n {row.tags.length > 0 ? <Text dimColor>{` ${row.tags.join(\" · \")}`}</Text> : null}\n </Box>\n <Box paddingLeft={4}>\n <Text dimColor wrap=\"wrap\">\n {row.description}\n </Text>\n </Box>\n {row.reason ? (\n <Box paddingLeft={4}>\n <Text color=\"yellow\" wrap=\"wrap\">{`⤷ ${row.reason}`}</Text>\n </Box>\n ) : null}\n {row.policies\n ? row.policies.length > 0\n ? row.policies.map((policy, index) => (\n <PolicyLine key={`${policy.name}-${index}`} policy={policy} />\n ))\n : [\n <Box key=\"none\" paddingLeft={6}>\n <Text dimColor>policies: none</Text>\n </Box>,\n ]\n : null}\n {row.policies && row.availability && !row.availability.available ? (\n <Box paddingLeft={6}>\n <Text dimColor>{`availability: unavailable${\n row.availability.reason ? ` — ${row.availability.reason}` : \"\"\n }`}</Text>\n </Box>\n ) : null}\n {row.schemas?.input !== undefined ? (\n <Box paddingLeft={6}>\n <Text dimColor wrap=\"wrap\">{`input: ${JSON.stringify(row.schemas.input)}`}</Text>\n </Box>\n ) : null}\n {row.schemas?.output !== undefined ? (\n <Box paddingLeft={6}>\n <Text dimColor wrap=\"wrap\">{`output: ${JSON.stringify(row.schemas.output)}`}</Text>\n </Box>\n ) : null}\n </Box>\n );\n}\n\nfunction Group({ group }: { group: CapabilityGroup }): ReactElement {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text backgroundColor=\"blueBright\" color=\"black\" bold>{` ${group.heading} `}</Text>\n <Text dimColor>{` ${group.rows.length}`}</Text>\n </Box>\n {group.rows.map((row) => (\n <Capability key={`${row.capabilityId}-${row.name}`} row={row} />\n ))}\n </Box>\n );\n}\n\n/**\n * The header states everything the counts are relative to (`AS-CLI-007`): the\n * scenario, the route, and the scope when one is active — a scope filters both\n * projections, so an unqualified count reads as a claim about the whole surface.\n * `hidden` is unconditional here for the same reason it is in plain text.\n */\nfunction Header({ view }: { view: SurfaceView }): ReactElement {\n // What the surface can do, not just how much of it there is: \"one of these\n // deletes a device\" is the part a reader needs before they read anything else.\n const risk = riskClause(flatRows(view));\n return (\n <Box>\n <Text bold>{view.scenario}</Text>\n {view.route ? <Text dimColor>{` ${view.route}`}</Text> : null}\n {view.scope && view.scope.length > 0 ? (\n <Text color=\"cyan\">{` scope ${view.scope.join(\" \")}`}</Text>\n ) : null}\n <Text dimColor>{\" · \"}</Text>\n <Text color=\"green\">{`${view.counts.callable} callable`}</Text>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"yellow\">{`${view.counts.disabled} visible-disabled`}</Text>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"red\">{`${view.counts.hidden} hidden`}</Text>\n {view.rejections.length > 0 ? (\n <>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"magenta\">\n {`${view.rejections.length} registration${\n view.rejections.length === 1 ? \"\" : \"s\"\n } rejected`}\n </Text>\n </>\n ) : null}\n {risk ? (\n <>\n <Text dimColor>{\" · \"}</Text>\n <Text color=\"magenta\">{risk}</Text>\n </>\n ) : null}\n </Box>\n );\n}\n\n/**\n * Rejected registrations (`AS-CLI-006`). A dead handle leaves no trace in either\n * projection, so without this block a copy-pasted component `type` removes a\n * capability and prints nothing anywhere.\n */\nfunction Rejections({ view }: { view: SurfaceView }): ReactElement {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text backgroundColor=\"magenta\" color=\"black\" bold>\n {\" rejected during mount \"}\n </Text>\n <Text dimColor>{` ${view.rejections.length}`}</Text>\n </Box>\n {view.rejections.map((rejection) => (\n <Box key={`${rejection.componentType}@${rejection.instanceId}-${rejection.reason}`}>\n <Text color=\"magenta\">{\" ! \"}</Text>\n <Text bold>{`${rejection.componentType} (${rejection.instanceId})`}</Text>\n <Text dimColor>\n {rejection.reason === \"duplicate\"\n ? \" duplicate — an earlier registration holds this key\"\n : \" guard — onRegister rejected this registration\"}\n </Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nfunction Empty({ view }: { view: SurfaceView }): ReactElement {\n if (view.counts.hidden > 0) {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Text dimColor wrap=\"wrap\">\n {`Nothing is callable here — all ${view.counts.hidden} registered capabilities were hidden by policy. `}\n The surface is empty by decision, not because nothing was annotated.\n </Text>\n {view.explained ? null : (\n <Text dimColor>Re-run with --explain to see which policy hid them.</Text>\n )}\n </Box>\n );\n }\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Text dimColor wrap=\"wrap\">\n Nothing is registered for this scenario — the agent has no surface here. That is the\n default: capabilities exist only where they were explicitly annotated.\n </Text>\n {view.explained ? null : (\n <Text dimColor>Re-run with --explain to see whether a policy hid it.</Text>\n )}\n </Box>\n );\n}\n\nconst HEADERS = [\"CAPABILITY\", \"KIND\", \"EFFECT\", \"STATE\", \"FLAGS\"];\n\nfunction cellsFor(row: CapabilityRow): string[] {\n return [\n row.path,\n row.kind,\n row.effect ?? NONE,\n OUTCOME[row.outcome].state,\n row.flags.length > 0 ? row.flags.join(\" · \") : NONE,\n ];\n}\n\nfunction TableRow({\n row,\n cells,\n widths,\n}: {\n row: CapabilityRow;\n cells: string[];\n widths: number[];\n}): ReactElement {\n const outcome = OUTCOME[row.outcome];\n return (\n <Box flexDirection=\"column\">\n <Box>\n <Text bold>{`${pad(cells[0]!, widths[0]!)} `}</Text>\n <Text dimColor>{`${pad(cells[1]!, widths[1]!)} `}</Text>\n <Text>{`${pad(cells[2]!, widths[2]!)} `}</Text>\n <Text color={outcome.color}>{`${pad(cells[3]!, widths[3]!)} `}</Text>\n <Text dimColor>{cells[4]!}</Text>\n </Box>\n {row.reason ? (\n <Box paddingLeft={4}>\n <Text color=\"yellow\" wrap=\"wrap\">{`⤷ ${row.reason}`}</Text>\n </Box>\n ) : null}\n </Box>\n );\n}\n\n/**\n * One capability per line, aligned — the scanning view, and the default. The\n * grouped paragraphs below stay for `--detail`, `--explain` and `--schemas`,\n * whose payloads (policy chains, JSON Schemas) cannot live in a table cell.\n */\nfunction CapabilityTable({ rows }: { rows: CapabilityRow[] }): ReactElement {\n const cells = rows.map(cellsFor);\n const widths = widthsFor(HEADERS, cells);\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n {HEADERS.map((header, column) => (\n <Text key={header} dimColor bold>\n {column === HEADERS.length - 1 ? header : `${pad(header, widths[column]!)} `}\n </Text>\n ))}\n </Box>\n {rows.map((row, index) => (\n <TableRow\n key={`${row.capabilityId}-${index}`}\n row={row}\n cells={cells[index]!}\n widths={widths}\n />\n ))}\n </Box>\n );\n}\n\ntype Block = { key: string; group?: CapabilityGroup; rows?: CapabilityRow[] };\n\nexport function Surface({\n view,\n detail,\n}: {\n view: SurfaceView;\n detail?: boolean;\n}): ReactElement {\n const populated = view.groups.filter((group) => group.rows.length > 0);\n const rows = flatRows(view);\n\n // Everything goes through <Static>, header included. Ink paints static output\n // once, permanently, above the live frame — and erases the live frame on\n // unmount. A one-shot render that leaves anything outside <Static> therefore\n // prints it and then wipes it, which is exactly what happened to this header.\n const blocks: Block[] = [\n { key: \"__header\" },\n ...(detail\n ? populated.map((group) => ({ key: group.heading, group }))\n : rows.length > 0\n ? [{ key: \"__table\", rows }]\n : []),\n ];\n\n return (\n <Static items={blocks}>\n {(block) =>\n block.group ? (\n <Group key={block.key} group={block.group} />\n ) : block.rows ? (\n <CapabilityTable key={block.key} rows={block.rows} />\n ) : (\n <Box key={block.key} flexDirection=\"column\">\n <Header view={view} />\n {view.rejections.length > 0 ? <Rejections view={view} /> : null}\n {rows.length === 0 ? <Empty view={view} /> : null}\n </Box>\n )\n }\n </Static>\n );\n}\n\n"],"mappings":";;;;;;;AACA,SAAS,KAAK,QAAQ,MAAM,gBAAgB;AAC5C,OAAO,aAAa;AA2DhB,SA0RI,UAzRF,KADF;AAtDJ,IAAM,UAAU;AAAA,EACd,QAAQ,EAAE,MAAM,UAAK,OAAO,SAAkB,OAAO,WAAW;AAAA,EAChE,SAAS,EAAE,MAAM,UAAK,OAAO,UAAmB,OAAO,WAAW;AAAA,EAClE,MAAM,EAAE,MAAM,UAAK,OAAO,OAAgB,OAAO,SAAS;AAC5D;AAEA,IAAM,eAAe;AAAA,EACnB,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAEA,IAAM,aAAa,EAAE,MAAM,SAAS,MAAM,UAAU,KAAK,MAAM;AAE/D,IAAM,OAAO;AACb,IAAM,cAAc;AACpB,IAAM,eAAe;AAQrB,SAAS,UAAU,SAAmB,MAA4B;AAChE,SAAO,QAAQ;AAAA,IAAI,CAAC,QAAQ,WAC1B,KAAK,IAAI,OAAO,QAAQ,GAAG,KAAK,IAAI,CAAC,SAAS,IAAI,MAAM,KAAK,IAAI,MAAM,CAAC;AAAA,EAC1E;AACF;AAEA,SAAS,IAAI,OAAe,OAAuB;AACjD,SAAO,MAAM,OAAO,KAAK;AAC3B;AAOO,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA;AACF,GAGiB;AACf,WAAS,CAAC,OA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ClB;AAAA;AAAA,MAHK,GAAG,IAAI,YAAY,IAAI,KAAK;AAAA,IAInC,CACD;AAAA,KACH;AAEJ;AAIO,SAAS,QAAQ;AAAA,EACtB;AAAA,EACA;AACF,GAGiB;AACf,QAAM,YAAY,KAAK,OAAO,OAAO,CAAC,UAAU,MAAM,KAAK,SAAS,CAAC;AACrE,QAAM,OAAO,SAAS,IAAI;AAM1B,QAAM,SAAkB;AAAA,IACtB,EAAE,KAAK,WAAW;AAAA,IAClB,GAAI,SACA,UAAU,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,SAAS,MAAM,EAAE,IACxD,KAAK,SAAS,IACZ,CAAC,EAAE,KAAK,WAAW,KAAK,CAAC,IACzB,CAAC;AAAA,EACT;AAEA,SACE,oBAAC,UAAO,OAAO,QACZ,WAAC,UACA,MAAM,QACJ,oBAAC,SAAsB,OAAO,MAAM,SAAxB,MAAM,GAAyB,IACzC,MAAM,OACR,oBAAC,mBAAgC,MAAM,MAAM,QAAvB,MAAM,GAAuB,IAEnD,qBAAC,OAAoB,eAAc,UACjC;AAAA,wBAAC,UAAO,MAAY;AAAA,IACnB,KAAK,WAAW,SAAS,IAAI,oBAAC,cAAW,MAAY,IAAK;AAAA,IAC1D,KAAK,WAAW,IAAI,oBAAC,SAAM,MAAY,IAAK;AAAA,OAHrC,MAAM,GAIhB,GAGN;AAEJ;","names":["index"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/inspect.tsx"],"sourcesContent":["import {\n joinCoverage,\n mountScenarios,\n readInventory,\n scopeCapabilityIds,\n scopeInventory,\n staticConfigScope,\n type AnalysisOptions,\n type Depth,\n type RuntimePlan,\n} from \"../analysis.js\";\nimport { buildView, flatRows, type SurfaceView } from \"../render/model.js\";\nimport {\n catalogRows,\n coverageSections,\n neverCallable,\n neverCallableSection,\n runHeaderBlocks,\n scenarioStats,\n scenarioTable,\n surfaceSummaryRows,\n trackReach,\n type CapabilityReach,\n type FindingSection,\n type ReportBlock,\n type ScenarioStats,\n} from \"../render/summary.js\";\nimport {\n renderCatalogDetailPlain,\n renderFailuresPlain,\n renderNoVerdictPlain,\n renderReportPlain,\n renderSectionsPlain,\n renderSurfacePlain,\n renderTablePlain,\n} from \"../render/plain.js\";\nimport { isPlain, loadInk, paint, transient, write, writeError } from \"../output.js\";\nimport {\n coverageReport,\n inventoryReport,\n scenarioReport,\n type ScenarioReport,\n} from \"../report.js\";\n\nexport interface InspectOptions {\n configPath: string;\n depth: Depth;\n scenario?: string;\n scope?: string[];\n tsconfig?: string;\n baselineDir?: string;\n detail?: boolean;\n explain?: boolean;\n schemas?: boolean;\n json?: boolean;\n plain?: boolean;\n}\n\n/**\n * The whole surface: what this codebase authors, what a mount surfaces, and the\n * difference between them.\n *\n * It answers findings, it does not gate on them — exit `0` whatever it reports,\n * because `check` is the gate and a viewer that sometimes fails is a viewer\n * nobody puts in a pipeline. The exception is `2`, which is not a finding: the\n * command could not run at all.\n *\n * The report is read top-down, so it is written top-down: **summaries first,\n * details after.**\n *\n * 1. **The run** — the config, the depth, the scope, the scenarios. All of it is\n * known before the first mount, and the mounts are the slow half, so it\n * prints immediately rather than making a reader wait to learn what is being\n * measured.\n * 2. **The summary** — reach, what is callable, what the surface can do, the\n * verdict. The answer, before anything it was derived from.\n * 3. **One row per scenario**, for a config with more than one.\n * 4. **The findings** — unreached, never callable, unread call sites — each with\n * what to do about it.\n * 5. **The details** — the static catalog, then each scenario's own table.\n *\n * That order costs the streaming this command used to do: the summary is a\n * statement about every scenario, so it cannot be written until every scenario\n * has mounted. A terminal is told what it is waiting for instead — the header\n * is already on screen and a spinner names the scenario being mounted — and\n * `check`, whose output has always been a report, works the same way.\n */\nexport async function runInspect(options: InspectOptions): Promise<number> {\n const analysis: AnalysisOptions = {\n configPath: options.configPath,\n depth: options.depth,\n ...(options.scenario ? { scenario: options.scenario } : {}),\n ...(options.scope ? { scope: options.scope } : {}),\n ...(options.tsconfig ? { tsconfig: options.tsconfig } : {}),\n ...(options.baselineDir ? { baselineDir: options.baselineDir } : {}),\n };\n\n // Policy chains and JSON Schemas are multi-line by nature, so asking for\n // either is asking for the view that can hold them.\n const detail = options.detail === true || options.explain === true || options.schemas === true;\n\n // `null` when Ink cannot run here (React 18 host), which is a fallback to\n // plain text rather than a failed command — see loadInk().\n const ink = isPlain(options) ? null : await loadInk();\n // Ink separates blocks with its own margin; plain text has to be asked.\n const say = async (blocks: ReportBlock[], lead = true): Promise<void> => {\n if (ink) await paint(<ink.Report blocks={blocks} />);\n else write(`${lead ? \"\\n\" : \"\"}${renderReportPlain(blocks)}`);\n };\n\n // The TypeScript program is read synchronously and the app loads after it;\n // together that is seconds on a real repository, and a terminal that shows\n // nothing for them looks wedged. Nothing transient is ever written in plain\n // mode: `AS-CLI-003` wants byte-stable output, and a spinner is neither.\n let stopWaiting = ink ? await transient(<ink.Loading label=\"reading the source\" />) : undefined;\n const settle = (): void => {\n stopWaiting?.();\n stopWaiting = undefined;\n };\n const waitFor = async (label: string): Promise<void> => {\n settle();\n if (ink) stopWaiting = await transient(<ink.Loading label={label} />);\n };\n /** `mounting anonymous (2 of 2)` — which one, and how much is left. */\n const mounting = (list: string[], index: number): string =>\n `mounting ${list[index]}${list.length > 1 ? ` (${index + 1} of ${list.length})` : \"\"}`;\n\n const inventory = readInventory(analysis);\n const scenarios: ScenarioReport[] = [];\n const stats: ScenarioStats[] = [];\n const views: SurfaceView[] = [];\n const reach = new Map<string, CapabilityReach>();\n let plan: RuntimePlan | undefined;\n\n const scope = (): string[] | undefined => plan?.scope ?? staticConfigScope(analysis);\n const scopedInventory = (): ReturnType<typeof scopeInventory> =>\n scopeInventory(inventory, scope());\n const domainCount = (): number | undefined =>\n plan?.domainManifestConfigured\n ? scopeCapabilityIds(plan.domainCapabilities, scope()).length\n : undefined;\n\n const header = async (): Promise<void> => {\n settle();\n if (options.json) return;\n const active = scope();\n await say(\n // At `--depth static` the catalog *is* the answer, so it opens the report\n // beside the run it came from. At every other depth it is a detail behind\n // the summary, and prints down there instead.\n runHeaderBlocks(\n \"SURFACE INSPECT\",\n {\n configPath: options.configPath,\n depth: options.depth,\n ...(active ? { scope: active } : {}),\n ...(plan ? { scenarios: plan.scenarios, declaredScenarios: plan.declaredScenarios } : {}),\n },\n plan ? undefined : scopedInventory(),\n domainCount(),\n ),\n false,\n );\n if (!plan && inventory) {\n const catalog = renderCatalogDetailPlain(scopedInventory() ?? inventory, {\n ...(detail ? { detail: true } : {}),\n });\n if (catalog) write(`\\n${catalog}`);\n }\n };\n\n const runtime = await mountScenarios(analysis, {\n onPlan: async (current) => {\n plan = current;\n await header();\n if (current.scenarios.length > 0) await waitFor(mounting(current.scenarios, 0));\n },\n onEach: async (result) => {\n const view = buildView(result, {\n ...(options.explain ? { explain: true } : {}),\n ...(options.schemas ? { schemas: true } : {}),\n });\n trackReach(reach, flatRows(view), result.scenario);\n stats.push(scenarioStats(result));\n if (options.json) {\n scenarios.push(\n scenarioReport(result, {\n ...(options.explain ? { attribution: true } : {}),\n ...(options.schemas ? { schemas: true } : {}),\n }),\n );\n } else {\n views.push(view);\n }\n // Named, and only while there is one left: a spinner announcing work\n // nobody is doing has to be read twice before it can be dismissed.\n if (plan && stats.length < plan.scenarios.length) {\n await waitFor(mounting(plan.scenarios, stats.length));\n }\n },\n });\n settle();\n if (!runtime) await header();\n\n const effectiveScope = options.scope ?? runtime?.scope ?? staticConfigScope(analysis);\n const reportInventory = scopeInventory(inventory, effectiveScope);\n const reportDomain = runtime?.domainManifestConfigured\n ? scopeCapabilityIds(runtime.domainCapabilities, effectiveScope)\n : undefined;\n const coverage = joinCoverage(inventory, runtime, analysis);\n const dark = neverCallable(reach);\n\n if (options.json) {\n write(\n JSON.stringify(\n {\n // One shape whatever the depth, so a consumer never branches on how\n // the command was invoked. A half the depth did not compute is\n // `null`, which is a different statement from `[]` or `{}`.\n depth: options.depth,\n catalog: inventoryReport(reportInventory, reportDomain),\n scenarios,\n failures: runtime?.failures ?? [],\n coverage: coverageReport(coverage),\n // Mounted, and callable in no scenario — a gap the coverage join\n // cannot see, because every one of these *was* reached.\n neverCallable: dark.map((entry) => ({\n capabilityId: entry.capabilityId,\n outcome: entry.best,\n ...(entry.note ? { reason: entry.note } : {}),\n scenarios: entry.scenarios,\n })),\n },\n null,\n 2,\n ),\n );\n return runtime && runtime.failures.length > 0 ? 2 : 0;\n }\n\n if (!runtime) return 0;\n\n // A scenario that threw is not in `stats`, and every count below is missing\n // whatever it held — so it takes a row of its own rather than appearing only\n // at the bottom of the report.\n for (const failure of runtime.failures) {\n stats.push({\n scenario: failure.scenario,\n callable: 0,\n disabled: 0,\n hidden: 0,\n rejected: 0,\n failed: true,\n failure: failure.message,\n });\n }\n stats.sort((a, b) => runtime.scenarios.indexOf(a.scenario) - runtime.scenarios.indexOf(b.scenario));\n const mounted = stats.filter((entry) => !entry.failed).length;\n\n await say([\n {\n title: \"SURFACE SUMMARY\",\n rows: surfaceSummaryRows({\n depth: options.depth,\n ...(coverage ? { coverage } : {}),\n scenarios: stats,\n failures: runtime.failures.length,\n reach,\n }),\n },\n ]);\n\n // One row per scenario, so a config with more than one can be compared in a\n // single place rather than by scrolling through its tables.\n if (stats.length > 1) {\n const table = scenarioTable(stats);\n const title = `SCENARIOS (${stats.length})`;\n if (ink) await paint(<ink.Table title={title} headers={table.headers} rows={table.rows} />);\n else write(`\\n${title}\\n${renderTablePlain(table.headers, table.rows)}`);\n }\n\n if (runtime.failures.length > 0) {\n writeError(`\\n${renderFailuresPlain(runtime.failures)}`);\n if (inventory) writeError(`\\n${renderNoVerdictPlain(runtime.failures)}`);\n }\n\n // Over one scenario, \"never callable\" repeats that scenario's own table row\n // for row. It is a finding only once there is more than one scenario for a\n // capability to have been callable in.\n const sections: FindingSection[] = [\n ...(coverage ? coverageSections(coverage) : []),\n ...(dark.length > 0 && mounted > 1 ? [neverCallableSection(dark)] : []),\n ];\n if (sections.length > 0) {\n if (ink) await paint(<ink.Findings sections={sections} />);\n else write(`\\n${renderSectionsPlain(sections)}`);\n }\n\n // Details. The catalog first, because the scenario tables below are what it\n // is the denominator of.\n const catalog = scopeInventory(inventory, effectiveScope);\n if (catalog) {\n await say([\n {\n title: \"STATIC CATALOG\",\n rows: catalogRows(catalog, {\n ...(domainCount() === undefined ? {} : { domainCapabilities: domainCount()! }),\n mounted: true,\n }),\n },\n ]);\n }\n\n for (const view of views) {\n if (ink) await paint(<ink.Surface view={view} detail={detail} />);\n else write(`\\n${renderSurfacePlain(view, { detail })}`);\n }\n\n // A scenario that would not mount is not a finding about the surface, it is\n // the command failing to observe one. `2` — the same code a usage error gets,\n // because CI has to tell both apart from \"the surface changed\".\n return runtime.failures.length > 0 ? 2 : 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GyB;AAnBzB,eAAsB,WAAW,SAA0C;AACzE,QAAM,WAA4B;AAAA,IAChC,YAAY,QAAQ;AAAA,IACpB,OAAO,QAAQ;AAAA,IACf,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,IACzD,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,IAChD,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,IACzD,GAAI,QAAQ,cAAc,EAAE,aAAa,QAAQ,YAAY,IAAI,CAAC;AAAA,EACpE;AAIA,QAAM,SAAS,QAAQ,WAAW,QAAQ,QAAQ,YAAY,QAAQ,QAAQ,YAAY;AAI1F,QAAM,MAAM,QAAQ,OAAO,IAAI,OAAO,MAAM,QAAQ;AAEpD,QAAM,MAAM,OAAO,QAAuB,OAAO,SAAwB;AACvE,QAAI,IAAK,OAAM,MAAM,oBAAC,IAAI,QAAJ,EAAW,QAAgB,CAAE;AAAA,QAC9C,OAAM,GAAG,OAAO,OAAO,EAAE,GAAG,kBAAkB,MAAM,CAAC,EAAE;AAAA,EAC9D;AAMA,MAAI,cAAc,MAAM,MAAM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B,QAAI,IAAK,OAAM,MAAM,oBAAC,IAAI,SAAJ,EAAY,MAAY,QAAgB,CAAE;AAAA,QAC3D,OAAM;AAAA,EAAK,mBAAmB,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE;AAAA,EACxD;AAKA,SAAO,QAAQ,SAAS,SAAS,IAAI,IAAI;AAC3C;","names":["catalog"]}
@@ -1,77 +0,0 @@
1
- import {
2
- renderFailuresPlain,
3
- renderSurfaceSummaryPlain,
4
- scenarioBaseline
5
- } from "./chunk-L7GHSC2Z.js";
6
- import {
7
- buildView,
8
- displayPath,
9
- flatRows,
10
- scenarioStats,
11
- trackReach
12
- } from "./chunk-VX6GBEP3.js";
13
- import {
14
- baselinePath,
15
- joinCoverage,
16
- mountScenarios,
17
- readInventory,
18
- writeBaseline,
19
- writeScenarioManifest
20
- } from "./chunk-IALBMW3R.js";
21
- import {
22
- UsageError,
23
- write,
24
- writeError
25
- } from "./chunk-3AJ343NA.js";
26
- import "./chunk-UGCLJ5JX.js";
27
-
28
- // src/commands/snapshot.ts
29
- async function runSnapshot(options) {
30
- if (options.depth === "static") {
31
- throw new UsageError(
32
- "snapshot --depth static has nothing to write \u2014 a baseline is a projection, and at this depth nothing is mounted."
33
- );
34
- }
35
- const analysis = {
36
- configPath: options.configPath,
37
- depth: options.depth,
38
- ...options.scenario ? { scenario: options.scenario } : {},
39
- ...options.scope ? { scope: options.scope } : {},
40
- ...options.tsconfig ? { tsconfig: options.tsconfig } : {},
41
- ...options.baselineDir ? { baselineDir: options.baselineDir } : {}
42
- };
43
- const inventory = readInventory(analysis);
44
- const runtime = await mountScenarios(analysis);
45
- if (!runtime) throw new UsageError("snapshot needs a mount, and this depth performs none");
46
- for (const result of runtime.results) {
47
- const path = baselinePath(runtime.baselineDir, result.scenario);
48
- writeBaseline(path, scenarioBaseline(result));
49
- write(`wrote ${displayPath(path)}`);
50
- }
51
- writeScenarioManifest(runtime.baselineDir, runtime.declaredScenarios);
52
- const reach = /* @__PURE__ */ new Map();
53
- for (const result of runtime.results) {
54
- trackReach(reach, flatRows(buildView(result)), result.scenario);
55
- }
56
- const coverage = joinCoverage(inventory, runtime, analysis);
57
- write("");
58
- write(
59
- renderSurfaceSummaryPlain({
60
- depth: options.depth,
61
- ...coverage ? { coverage } : {},
62
- scenarios: runtime.results.map(scenarioStats),
63
- failures: runtime.failures.length,
64
- reach
65
- })
66
- );
67
- if (runtime.failures.length > 0) {
68
- writeError(`
69
- ${renderFailuresPlain(runtime.failures)}`);
70
- return 2;
71
- }
72
- return 0;
73
- }
74
- export {
75
- runSnapshot
76
- };
77
- //# sourceMappingURL=snapshot-ZGTAF2Y5.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/snapshot.ts"],"sourcesContent":["import {\n joinCoverage,\n mountScenarios,\n readInventory,\n UsageError,\n type AnalysisOptions,\n type Depth,\n} from \"../analysis.js\";\nimport { baselinePath, writeBaseline, writeScenarioManifest } from \"../baseline.js\";\nimport { scenarioBaseline } from \"../report.js\";\nimport { buildView, flatRows } from \"../render/model.js\";\nimport { renderFailuresPlain, renderSurfaceSummaryPlain } from \"../render/plain.js\";\nimport {\n displayPath,\n scenarioStats,\n trackReach,\n type CapabilityReach,\n} from \"../render/summary.js\";\nimport { write, writeError } from \"../output.js\";\n\nexport interface SnapshotOptions {\n configPath: string;\n depth: Depth;\n scenario?: string;\n scope?: string[];\n tsconfig?: string;\n baselineDir?: string;\n}\n\n/**\n * Writes (or refreshes) the committed baseline `check` compares against.\n *\n * It prints the coverage verdict too. This is the command you run to *accept* a\n * change to the surface, which makes it the last moment before a reviewer sees\n * the diff — and accepting a projection while a capability sits behind a route\n * no scenario visits is exactly the state worth hearing about. It reports;\n * `check` is still the only thing that fails.\n */\nexport async function runSnapshot(options: SnapshotOptions): Promise<number> {\n if (options.depth === \"static\") {\n throw new UsageError(\n \"snapshot --depth static has nothing to write — a baseline is a projection, and \" +\n \"at this depth nothing is mounted.\",\n );\n }\n\n const analysis: AnalysisOptions = {\n configPath: options.configPath,\n depth: options.depth,\n ...(options.scenario ? { scenario: options.scenario } : {}),\n ...(options.scope ? { scope: options.scope } : {}),\n ...(options.tsconfig ? { tsconfig: options.tsconfig } : {}),\n ...(options.baselineDir ? { baselineDir: options.baselineDir } : {}),\n };\n\n const inventory = readInventory(analysis);\n const runtime = await mountScenarios(analysis);\n if (!runtime) throw new UsageError(\"snapshot needs a mount, and this depth performs none\");\n\n for (const result of runtime.results) {\n const path = baselinePath(runtime.baselineDir, result.scenario);\n writeBaseline(path, scenarioBaseline(result));\n write(`wrote ${displayPath(path)}`);\n }\n writeScenarioManifest(runtime.baselineDir, runtime.declaredScenarios);\n\n const reach = new Map<string, CapabilityReach>();\n for (const result of runtime.results) {\n trackReach(reach, flatRows(buildView(result)), result.scenario);\n }\n const coverage = joinCoverage(inventory, runtime, analysis);\n write(\"\");\n write(\n renderSurfaceSummaryPlain({\n depth: options.depth,\n ...(coverage ? { coverage } : {}),\n scenarios: runtime.results.map(scenarioStats),\n failures: runtime.failures.length,\n reach,\n }),\n );\n\n if (runtime.failures.length > 0) {\n // A baseline written for some scenarios and not others is a baseline that\n // will fail `check` for a reason that has nothing to do with the surface.\n writeError(`\\n${renderFailuresPlain(runtime.failures)}`);\n return 2;\n }\n return 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,eAAsB,YAAY,SAA2C;AAC3E,MAAI,QAAQ,UAAU,UAAU;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AAEA,QAAM,WAA4B;AAAA,IAChC,YAAY,QAAQ;AAAA,IACpB,OAAO,QAAQ;AAAA,IACf,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,IACzD,GAAI,QAAQ,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAAA,IAChD,GAAI,QAAQ,WAAW,EAAE,UAAU,QAAQ,SAAS,IAAI,CAAC;AAAA,IACzD,GA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