@agent-surface/cli 0.9.1 → 0.11.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.
- package/README.md +64 -23
- package/dist/bin.js +75 -28
- package/dist/bin.js.map +1 -1
- package/dist/check-BYQ34OVQ.js +122 -0
- package/dist/check-BYQ34OVQ.js.map +1 -0
- package/dist/chunk-DYDSJM7R.js +170 -0
- package/dist/chunk-DYDSJM7R.js.map +1 -0
- package/dist/chunk-GXXKZTQB.js +553 -0
- package/dist/chunk-GXXKZTQB.js.map +1 -0
- package/dist/{chunk-S2LM3N6D.js → chunk-QIVOZAWX.js} +14 -12
- package/dist/chunk-QIVOZAWX.js.map +1 -0
- package/dist/chunk-RXX63JSL.js +298 -0
- package/dist/chunk-RXX63JSL.js.map +1 -0
- package/dist/collect.js +18 -1
- package/dist/collect.js.map +1 -1
- package/dist/index.d.ts +126 -1
- package/dist/init-LYYVXFEQ.js +141 -0
- package/dist/init-LYYVXFEQ.js.map +1 -0
- package/dist/ink-P23VKP4H.js +217 -0
- package/dist/ink-P23VKP4H.js.map +1 -0
- package/dist/inspect-3CBRKTDM.js +108 -0
- package/dist/inspect-3CBRKTDM.js.map +1 -0
- package/dist/snapshot-DJ22WCT4.js +59 -0
- package/dist/snapshot-DJ22WCT4.js.map +1 -0
- package/package.json +5 -4
- package/dist/check-7Z2VNN5R.js +0 -79
- package/dist/check-7Z2VNN5R.js.map +0 -1
- package/dist/chunk-KZUR4CAU.js +0 -84
- package/dist/chunk-KZUR4CAU.js.map +0 -1
- package/dist/chunk-ODUIFFPM.js +0 -104
- package/dist/chunk-ODUIFFPM.js.map +0 -1
- package/dist/chunk-S2LM3N6D.js.map +0 -1
- package/dist/ink-GCWDO4ML.js +0 -122
- package/dist/ink-GCWDO4ML.js.map +0 -1
- package/dist/inspect-SLYLBZAH.js +0 -204
- package/dist/inspect-SLYLBZAH.js.map +0 -1
- package/dist/snapshot-3D55FL63.js +0 -36
- package/dist/snapshot-3D55FL63.js.map +0 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
authoredIds,
|
|
3
|
+
extractCapabilities,
|
|
4
|
+
findTsconfig,
|
|
5
|
+
unresolved
|
|
6
|
+
} from "./chunk-GXXKZTQB.js";
|
|
7
|
+
import {
|
|
8
|
+
UsageError,
|
|
9
|
+
isPlain,
|
|
10
|
+
loadInk,
|
|
11
|
+
write,
|
|
12
|
+
writeError
|
|
13
|
+
} from "./chunk-QIVOZAWX.js";
|
|
14
|
+
|
|
15
|
+
// src/commands/init.tsx
|
|
16
|
+
import { existsSync, writeFileSync } from "fs";
|
|
17
|
+
import { join, relative } from "path";
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
var CONFIG_NAME = "agent-surface.config.tsx";
|
|
20
|
+
var ENTRY_CANDIDATES = [
|
|
21
|
+
"src/main.tsx",
|
|
22
|
+
"src/main.ts",
|
|
23
|
+
"src/index.tsx",
|
|
24
|
+
"src/App.tsx",
|
|
25
|
+
"src/app/App.tsx",
|
|
26
|
+
"app/root.tsx"
|
|
27
|
+
];
|
|
28
|
+
function scaffold(entry) {
|
|
29
|
+
const importPath = entry ? `./${entry.replace(/\.tsx?$/, ".js")}` : "./src/App.js";
|
|
30
|
+
return `import { defineSurface } from "@agent-surface/cli";
|
|
31
|
+
// TODO: point these at your own composition root \u2014 whatever \`main.tsx\` calls.
|
|
32
|
+
// The config should *reuse* how the app builds itself, not restate it.
|
|
33
|
+
import { App } from "${importPath}";
|
|
34
|
+
|
|
35
|
+
export default defineSurface({
|
|
36
|
+
mount: ({ user }) => {
|
|
37
|
+
// TODO: build the app the way the app builds itself, and hand back the
|
|
38
|
+
// registry it created plus the tree that registers into it.
|
|
39
|
+
const app = createApp({ environment: "test", user });
|
|
40
|
+
return { registry: app.registry, ui: <App app={app} />, app };
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// Named prop bundles. Free-form \u2014 a user, a route, a feature flag; the CLI
|
|
44
|
+
// never interprets them. Every scenario you leave out is a surface nothing
|
|
45
|
+
// measures, which is what \`--depth full\` reports as unreached.
|
|
46
|
+
scenarios: {
|
|
47
|
+
default: { user: { id: "u_1", permissions: [] } },
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
async function runInit(options) {
|
|
53
|
+
const configPath = join(options.cwd, CONFIG_NAME);
|
|
54
|
+
if (existsSync(configPath)) {
|
|
55
|
+
throw new UsageError(
|
|
56
|
+
`${relative(process.cwd(), configPath)} already exists \u2014 edit it, or delete it and re-run`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const tsconfig = options.tsconfig ?? findTsconfig(options.cwd);
|
|
60
|
+
if (!tsconfig) {
|
|
61
|
+
throw new UsageError(
|
|
62
|
+
`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`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
const inventory = extractCapabilities({ root: options.cwd, tsconfig });
|
|
66
|
+
const ids = authoredIds(inventory);
|
|
67
|
+
const unread = unresolved(inventory);
|
|
68
|
+
const components = new Set(
|
|
69
|
+
[...ids].map((id) => id.replace(/^view:/, "").split(".").slice(0, -1).join("."))
|
|
70
|
+
);
|
|
71
|
+
write(`Read ${inventory.filesAnalyzed} file${inventory.filesAnalyzed === 1 ? "" : "s"} from ${relative(process.cwd(), tsconfig) || "tsconfig.json"}`);
|
|
72
|
+
write("");
|
|
73
|
+
write(` authored capabilities ${ids.size}`);
|
|
74
|
+
write(` components ${components.size}`);
|
|
75
|
+
write(` unread call sites ${unread.length}`);
|
|
76
|
+
if (ids.size === 0) {
|
|
77
|
+
write("");
|
|
78
|
+
write(
|
|
79
|
+
"Nothing is annotated yet \u2014 that is the default, and it is the safe one: a capability exists only where someone wrote one. Start with `useAgentComponent` in a component that owns state worth acting on, then re-run this."
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
write("");
|
|
83
|
+
for (const component of [...components].sort()) write(` ${component}`);
|
|
84
|
+
}
|
|
85
|
+
const entry = ENTRY_CANDIDATES.find((candidate) => existsSync(join(options.cwd, candidate)));
|
|
86
|
+
write("");
|
|
87
|
+
write(`Write ${relative(process.cwd(), configPath)}?`);
|
|
88
|
+
write(
|
|
89
|
+
entry ? ` it will import from ./${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"
|
|
90
|
+
);
|
|
91
|
+
if (!options.yes) {
|
|
92
|
+
const answered = await ask(options, `Write ${CONFIG_NAME}?`);
|
|
93
|
+
if (!answered) {
|
|
94
|
+
write("");
|
|
95
|
+
write("Nothing written.");
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
writeFileSync(configPath, scaffold(entry), "utf8");
|
|
100
|
+
write("");
|
|
101
|
+
write(`wrote ${relative(process.cwd(), configPath)}`);
|
|
102
|
+
write("");
|
|
103
|
+
write("Next:");
|
|
104
|
+
write(" 1. fill in mount() \u2014 it should call your existing composition root");
|
|
105
|
+
write(" 2. `agent-surface inspect` to see what an agent can reach");
|
|
106
|
+
write(" 3. `agent-surface snapshot` to commit the baseline, then `check` in CI");
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
async function ask(options, question) {
|
|
110
|
+
if (isPlain(options) || process.stdin.isTTY !== true) {
|
|
111
|
+
writeError("");
|
|
112
|
+
writeError("stdin is not a terminal, so there is nobody to ask \u2014 re-run with --yes to accept.");
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
const ink = await loadInk();
|
|
116
|
+
if (!ink) {
|
|
117
|
+
writeError("");
|
|
118
|
+
writeError("no interactive renderer available here \u2014 re-run with --yes to accept.");
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
const { render } = await import("ink");
|
|
122
|
+
return new Promise((resolve) => {
|
|
123
|
+
const instance = render(
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
ink.Confirm,
|
|
126
|
+
{
|
|
127
|
+
question,
|
|
128
|
+
onAnswer: (yes) => {
|
|
129
|
+
instance.clear();
|
|
130
|
+
instance.unmount();
|
|
131
|
+
resolve(yes);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
runInit
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=init-LYYVXFEQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import {
|
|
2
|
+
flatRows
|
|
3
|
+
} from "./chunk-DYDSJM7R.js";
|
|
4
|
+
|
|
5
|
+
// src/render/ink.tsx
|
|
6
|
+
import { Box, Static, Text, useInput } from "ink";
|
|
7
|
+
import Spinner from "ink-spinner";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
var OUTCOME = {
|
|
10
|
+
expose: { mark: "\u25CF", color: "green", state: "callable" },
|
|
11
|
+
disable: { mark: "\u25D0", color: "yellow", state: "disabled" },
|
|
12
|
+
hide: { mark: "\u25CB", color: "red", state: "hidden" }
|
|
13
|
+
};
|
|
14
|
+
var NONE = "\u2014";
|
|
15
|
+
function widthsFor(headers, rows) {
|
|
16
|
+
return headers.map(
|
|
17
|
+
(header, column) => Math.max(header.length, ...rows.map((row) => (row[column] ?? "").length))
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
function pad(value, width) {
|
|
21
|
+
return value.padEnd(width);
|
|
22
|
+
}
|
|
23
|
+
function Confirm({
|
|
24
|
+
question,
|
|
25
|
+
onAnswer
|
|
26
|
+
}) {
|
|
27
|
+
useInput((input, key) => {
|
|
28
|
+
if (key.return || input.toLowerCase() === "y") onAnswer(true);
|
|
29
|
+
else if (key.escape || input.toLowerCase() === "n" || key.ctrl && input === "c") {
|
|
30
|
+
onAnswer(false);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ jsxs(Box, { marginTop: 1, children: [
|
|
34
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: question }),
|
|
35
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: " (Y/n) " })
|
|
36
|
+
] });
|
|
37
|
+
}
|
|
38
|
+
function Loading({ label }) {
|
|
39
|
+
return /* @__PURE__ */ jsxs(Text, { children: [
|
|
40
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: /* @__PURE__ */ jsx(Spinner, { type: "dots" }) }),
|
|
41
|
+
` ${label}`
|
|
42
|
+
] });
|
|
43
|
+
}
|
|
44
|
+
function PolicyLine({
|
|
45
|
+
policy
|
|
46
|
+
}) {
|
|
47
|
+
const vote = policy.discovery?.decision;
|
|
48
|
+
const color = vote === "hide" ? "red" : vote === "disable" ? "yellow" : "green";
|
|
49
|
+
return /* @__PURE__ */ jsxs(Box, { paddingLeft: 6, children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "policy " }),
|
|
51
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: policy.name }),
|
|
52
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ` (${policy.scope}${policy.phases.length ? `, ${policy.phases.join("/")}` : ""}) ` }),
|
|
53
|
+
vote ? /* @__PURE__ */ jsxs(Text, { color, children: [
|
|
54
|
+
vote,
|
|
55
|
+
policy.discovery?.decision === "disable" ? ` \u2014 ${policy.discovery.reason}` : ""
|
|
56
|
+
] }) : /* @__PURE__ */ jsx(Text, { dimColor: true, children: "no discovery hook" }),
|
|
57
|
+
policy.threw ? /* @__PURE__ */ jsx(Text, { color: "red", bold: true, children: " THREW" }) : null,
|
|
58
|
+
policy.confirmationEscalation ? /* @__PURE__ */ jsx(Text, { color: "magenta", children: " escalates-confirmation" }) : null
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
function Capability({ row }) {
|
|
62
|
+
const outcome = OUTCOME[row.outcome];
|
|
63
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
64
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(Text, { color: outcome.color, children: ` ${outcome.mark} ` }),
|
|
66
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: row.name }),
|
|
67
|
+
row.tags.length > 0 ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${row.tags.join(" \xB7 ")}` }) : null
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 4, children: /* @__PURE__ */ jsx(Text, { dimColor: true, wrap: "wrap", children: row.description }) }),
|
|
70
|
+
row.reason ? /* @__PURE__ */ jsx(Box, { paddingLeft: 4, children: /* @__PURE__ */ jsx(Text, { color: "yellow", wrap: "wrap", children: `\u2937 ${row.reason}` }) }) : null,
|
|
71
|
+
row.policies ? row.policies.length > 0 ? row.policies.map((policy, index) => /* @__PURE__ */ jsx(PolicyLine, { policy }, `${policy.name}-${index}`)) : [
|
|
72
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 6, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "policies: none" }) }, "none")
|
|
73
|
+
] : null,
|
|
74
|
+
row.policies && row.availability && !row.availability.available ? /* @__PURE__ */ jsx(Box, { paddingLeft: 6, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: `availability: unavailable${row.availability.reason ? ` \u2014 ${row.availability.reason}` : ""}` }) }) : null,
|
|
75
|
+
row.schemas?.input !== void 0 ? /* @__PURE__ */ jsx(Box, { paddingLeft: 6, children: /* @__PURE__ */ jsx(Text, { dimColor: true, wrap: "wrap", children: `input: ${JSON.stringify(row.schemas.input)}` }) }) : null,
|
|
76
|
+
row.schemas?.output !== void 0 ? /* @__PURE__ */ jsx(Box, { paddingLeft: 6, children: /* @__PURE__ */ jsx(Text, { dimColor: true, wrap: "wrap", children: `output: ${JSON.stringify(row.schemas.output)}` }) }) : null
|
|
77
|
+
] });
|
|
78
|
+
}
|
|
79
|
+
function Group({ group }) {
|
|
80
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
81
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
82
|
+
/* @__PURE__ */ jsx(Text, { backgroundColor: "blueBright", color: "black", bold: true, children: ` ${group.heading} ` }),
|
|
83
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${group.rows.length}` })
|
|
84
|
+
] }),
|
|
85
|
+
group.rows.map((row) => /* @__PURE__ */ jsx(Capability, { row }, `${row.capabilityId}-${row.name}`))
|
|
86
|
+
] });
|
|
87
|
+
}
|
|
88
|
+
function Header({ view }) {
|
|
89
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
90
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: view.scenario }),
|
|
91
|
+
view.route ? /* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${view.route}` }) : null,
|
|
92
|
+
view.scope && view.scope.length > 0 ? /* @__PURE__ */ jsx(Text, { color: "cyan", children: ` scope ${view.scope.join(" ")}` }) : null,
|
|
93
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: " \xB7 " }),
|
|
94
|
+
/* @__PURE__ */ jsx(Text, { color: "green", children: `${view.counts.callable} callable` }),
|
|
95
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ", " }),
|
|
96
|
+
/* @__PURE__ */ jsx(Text, { color: "yellow", children: `${view.counts.disabled} visible-disabled` }),
|
|
97
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ", " }),
|
|
98
|
+
/* @__PURE__ */ jsx(Text, { color: "red", children: `${view.counts.hidden} hidden` }),
|
|
99
|
+
view.rejections.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
100
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ", " }),
|
|
101
|
+
/* @__PURE__ */ jsx(Text, { color: "magenta", children: `${view.rejections.length} registration${view.rejections.length === 1 ? "" : "s"} rejected` })
|
|
102
|
+
] }) : null
|
|
103
|
+
] });
|
|
104
|
+
}
|
|
105
|
+
function Rejections({ view }) {
|
|
106
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
107
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
108
|
+
/* @__PURE__ */ jsx(Text, { backgroundColor: "magenta", color: "black", bold: true, children: " rejected during mount " }),
|
|
109
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${view.rejections.length}` })
|
|
110
|
+
] }),
|
|
111
|
+
view.rejections.map((rejection) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
112
|
+
/* @__PURE__ */ jsx(Text, { color: "magenta", children: " ! " }),
|
|
113
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: `${rejection.componentType} (${rejection.instanceId})` }),
|
|
114
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: rejection.reason === "duplicate" ? " duplicate \u2014 an earlier registration holds this key" : " guard \u2014 onRegister rejected this registration" })
|
|
115
|
+
] }, `${rejection.componentType}@${rejection.instanceId}-${rejection.reason}`))
|
|
116
|
+
] });
|
|
117
|
+
}
|
|
118
|
+
function Empty({ view }) {
|
|
119
|
+
if (view.counts.hidden > 0) {
|
|
120
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
121
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, wrap: "wrap", children: [
|
|
122
|
+
`Nothing is callable here \u2014 all ${view.counts.hidden} registered capabilities were hidden by policy. `,
|
|
123
|
+
"The surface is empty by decision, not because nothing was annotated."
|
|
124
|
+
] }),
|
|
125
|
+
view.explained ? null : /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Re-run with --explain to see which policy hid them." })
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
129
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, wrap: "wrap", children: "Nothing is registered for this scenario \u2014 the agent has no surface here. That is the default: capabilities exist only where they were explicitly annotated." }),
|
|
130
|
+
view.explained ? null : /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Re-run with --explain to see whether a policy hid it." })
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
var HEADERS = ["CAPABILITY", "KIND", "EFFECT", "STATE", "FLAGS"];
|
|
134
|
+
function cellsFor(row) {
|
|
135
|
+
return [
|
|
136
|
+
row.path,
|
|
137
|
+
row.kind,
|
|
138
|
+
row.effect ?? NONE,
|
|
139
|
+
OUTCOME[row.outcome].state,
|
|
140
|
+
row.flags.length > 0 ? row.flags.join(" \xB7 ") : NONE
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
function TableRow({
|
|
144
|
+
row,
|
|
145
|
+
cells,
|
|
146
|
+
widths
|
|
147
|
+
}) {
|
|
148
|
+
const outcome = OUTCOME[row.outcome];
|
|
149
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
150
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
151
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: `${pad(cells[0], widths[0])} ` }),
|
|
152
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: `${pad(cells[1], widths[1])} ` }),
|
|
153
|
+
/* @__PURE__ */ jsx(Text, { children: `${pad(cells[2], widths[2])} ` }),
|
|
154
|
+
/* @__PURE__ */ jsx(Text, { color: outcome.color, children: `${pad(cells[3], widths[3])} ` }),
|
|
155
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: cells[4] })
|
|
156
|
+
] }),
|
|
157
|
+
row.reason ? /* @__PURE__ */ jsx(Box, { paddingLeft: 4, children: /* @__PURE__ */ jsx(Text, { color: "yellow", wrap: "wrap", children: `\u2937 ${row.reason}` }) }) : null
|
|
158
|
+
] });
|
|
159
|
+
}
|
|
160
|
+
function CapabilityTable({ rows }) {
|
|
161
|
+
const cells = rows.map(cellsFor);
|
|
162
|
+
const widths = widthsFor(HEADERS, cells);
|
|
163
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
164
|
+
/* @__PURE__ */ jsx(Box, { children: HEADERS.map((header, column) => /* @__PURE__ */ jsx(Text, { dimColor: true, bold: true, children: column === HEADERS.length - 1 ? header : `${pad(header, widths[column])} ` }, header)) }),
|
|
165
|
+
rows.map((row, index) => /* @__PURE__ */ jsx(
|
|
166
|
+
TableRow,
|
|
167
|
+
{
|
|
168
|
+
row,
|
|
169
|
+
cells: cells[index],
|
|
170
|
+
widths
|
|
171
|
+
},
|
|
172
|
+
`${row.capabilityId}-${index}`
|
|
173
|
+
))
|
|
174
|
+
] });
|
|
175
|
+
}
|
|
176
|
+
function Surface({
|
|
177
|
+
view,
|
|
178
|
+
detail
|
|
179
|
+
}) {
|
|
180
|
+
const populated = view.groups.filter((group) => group.rows.length > 0);
|
|
181
|
+
const rows = flatRows(view);
|
|
182
|
+
const blocks = [
|
|
183
|
+
{ key: "__header" },
|
|
184
|
+
...detail ? populated.map((group) => ({ key: group.heading, group })) : rows.length > 0 ? [{ key: "__table", rows }] : []
|
|
185
|
+
];
|
|
186
|
+
return /* @__PURE__ */ jsx(Static, { items: blocks, children: (block) => block.group ? /* @__PURE__ */ jsx(Group, { group: block.group }, block.key) : block.rows ? /* @__PURE__ */ jsx(CapabilityTable, { rows: block.rows }, block.key) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
187
|
+
/* @__PURE__ */ jsx(Header, { view }),
|
|
188
|
+
view.rejections.length > 0 ? /* @__PURE__ */ jsx(Rejections, { view }) : null,
|
|
189
|
+
rows.length === 0 ? /* @__PURE__ */ jsx(Empty, { view }) : null
|
|
190
|
+
] }, block.key) });
|
|
191
|
+
}
|
|
192
|
+
function Coverage({ report }) {
|
|
193
|
+
const clean = report.unreached.length === 0 && report.unresolved.length === 0 && report.staleAllowlist.length === 0;
|
|
194
|
+
return /* @__PURE__ */ jsx(Static, { items: [{ key: "__coverage" }], children: (block) => /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
195
|
+
report.unreached.length > 0 ? /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
196
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
197
|
+
/* @__PURE__ */ jsx(Text, { backgroundColor: "red", color: "black", bold: true, children: " UNREACHED " }),
|
|
198
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ` authored, and no scenario mounts it ${report.unreached.length}` })
|
|
199
|
+
] }),
|
|
200
|
+
report.unreached.map((entry) => /* @__PURE__ */ jsxs(Box, { paddingLeft: 2, children: [
|
|
201
|
+
/* @__PURE__ */ jsx(Text, { bold: true, children: entry.capabilityId }),
|
|
202
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${entry.origin.file}:${entry.origin.line}` })
|
|
203
|
+
] }, entry.capabilityId))
|
|
204
|
+
] }) : null,
|
|
205
|
+
/* @__PURE__ */ jsxs(Box, { marginTop: report.unreached.length > 0 ? 1 : 0, children: [
|
|
206
|
+
/* @__PURE__ */ jsx(Text, { color: clean ? "green" : "red", bold: true, children: `${report.authored} authored \xB7 ${report.reached} reached \xB7 ${report.unreached.length} unreached` }),
|
|
207
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: ` ${report.scenarios.join(", ")}` })
|
|
208
|
+
] })
|
|
209
|
+
] }, block.key) });
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
Confirm,
|
|
213
|
+
Coverage,
|
|
214
|
+
Loading,
|
|
215
|
+
Surface
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=ink-P23VKP4H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/ink.tsx"],"sourcesContent":["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 type { CoverageReport } from \"../coverage.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 NONE = \"—\";\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 {` ${label}`}\n </Text>\n );\n}\n\nfunction PolicyLine({\n policy,\n}: {\n policy: NonNullable<CapabilityRow[\"policies\"]>[number];\n}): ReactElement {\n const vote = policy.discovery?.decision;\n const color = vote === \"hide\" ? \"red\" : vote === \"disable\" ? \"yellow\" : \"green\";\n return (\n <Box paddingLeft={6}>\n <Text dimColor>policy </Text>\n <Text bold>{policy.name}</Text>\n <Text dimColor>{` (${policy.scope}${policy.phases.length ? `, ${policy.phases.join(\"/\")}` : \"\"}) `}</Text>\n {vote ? (\n <Text color={color}>\n {vote}\n {policy.discovery?.decision === \"disable\" ? ` — ${policy.discovery.reason}` : \"\"}\n </Text>\n ) : (\n <Text dimColor>no discovery hook</Text>\n )}\n {policy.threw ? <Text color=\"red\" bold>{\" THREW\"}</Text> : null}\n {policy.confirmationEscalation ? (\n <Text color=\"magenta\">{\" escalates-confirmation\"}</Text>\n ) : null}\n </Box>\n );\n}\n\nfunction Capability({ row }: { row: CapabilityRow }): ReactElement {\n const outcome = OUTCOME[row.outcome];\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text color={outcome.color}>{` ${outcome.mark} `}</Text>\n <Text bold>{row.name}</Text>\n {row.tags.length > 0 ? <Text dimColor>{` ${row.tags.join(\" · \")}`}</Text> : null}\n </Box>\n <Box paddingLeft={4}>\n <Text dimColor wrap=\"wrap\">\n {row.description}\n </Text>\n </Box>\n {row.reason ? (\n <Box paddingLeft={4}>\n <Text color=\"yellow\" wrap=\"wrap\">{`⤷ ${row.reason}`}</Text>\n </Box>\n ) : null}\n {row.policies\n ? row.policies.length > 0\n ? row.policies.map((policy, index) => (\n <PolicyLine key={`${policy.name}-${index}`} policy={policy} />\n ))\n : [\n <Box key=\"none\" paddingLeft={6}>\n <Text dimColor>policies: none</Text>\n </Box>,\n ]\n : null}\n {row.policies && row.availability && !row.availability.available ? (\n <Box paddingLeft={6}>\n <Text dimColor>{`availability: unavailable${\n row.availability.reason ? ` — ${row.availability.reason}` : \"\"\n }`}</Text>\n </Box>\n ) : null}\n {row.schemas?.input !== undefined ? (\n <Box paddingLeft={6}>\n <Text dimColor wrap=\"wrap\">{`input: ${JSON.stringify(row.schemas.input)}`}</Text>\n </Box>\n ) : null}\n {row.schemas?.output !== undefined ? (\n <Box paddingLeft={6}>\n <Text dimColor wrap=\"wrap\">{`output: ${JSON.stringify(row.schemas.output)}`}</Text>\n </Box>\n ) : null}\n </Box>\n );\n}\n\nfunction Group({ group }: { group: CapabilityGroup }): ReactElement {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text backgroundColor=\"blueBright\" color=\"black\" bold>{` ${group.heading} `}</Text>\n <Text dimColor>{` ${group.rows.length}`}</Text>\n </Box>\n {group.rows.map((row) => (\n <Capability key={`${row.capabilityId}-${row.name}`} row={row} />\n ))}\n </Box>\n );\n}\n\n/**\n * The header states everything the counts are relative to (`AS-CLI-007`): the\n * scenario, the route, and the scope when one is active — a scope filters both\n * projections, so an unqualified count reads as a claim about the whole surface.\n * `hidden` is unconditional here for the same reason it is in plain text.\n */\nfunction Header({ view }: { view: SurfaceView }): ReactElement {\n return (\n <Box>\n <Text bold>{view.scenario}</Text>\n {view.route ? <Text dimColor>{` ${view.route}`}</Text> : null}\n {view.scope && view.scope.length > 0 ? (\n <Text color=\"cyan\">{` scope ${view.scope.join(\" \")}`}</Text>\n ) : null}\n <Text dimColor>{\" · \"}</Text>\n <Text color=\"green\">{`${view.counts.callable} callable`}</Text>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"yellow\">{`${view.counts.disabled} visible-disabled`}</Text>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"red\">{`${view.counts.hidden} hidden`}</Text>\n {view.rejections.length > 0 ? (\n <>\n <Text dimColor>{\", \"}</Text>\n <Text color=\"magenta\">\n {`${view.rejections.length} registration${\n view.rejections.length === 1 ? \"\" : \"s\"\n } rejected`}\n </Text>\n </>\n ) : null}\n </Box>\n );\n}\n\n/**\n * Rejected registrations (`AS-CLI-006`). A dead handle leaves no trace in either\n * projection, so without this block a copy-pasted component `type` removes a\n * capability and prints nothing anywhere.\n */\nfunction Rejections({ view }: { view: SurfaceView }): ReactElement {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Box>\n <Text backgroundColor=\"magenta\" color=\"black\" bold>\n {\" rejected during mount \"}\n </Text>\n <Text dimColor>{` ${view.rejections.length}`}</Text>\n </Box>\n {view.rejections.map((rejection) => (\n <Box key={`${rejection.componentType}@${rejection.instanceId}-${rejection.reason}`}>\n <Text color=\"magenta\">{\" ! \"}</Text>\n <Text bold>{`${rejection.componentType} (${rejection.instanceId})`}</Text>\n <Text dimColor>\n {rejection.reason === \"duplicate\"\n ? \" duplicate — an earlier registration holds this key\"\n : \" guard — onRegister rejected this registration\"}\n </Text>\n </Box>\n ))}\n </Box>\n );\n}\n\nfunction Empty({ view }: { view: SurfaceView }): ReactElement {\n if (view.counts.hidden > 0) {\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Text dimColor wrap=\"wrap\">\n {`Nothing is callable here — all ${view.counts.hidden} registered capabilities were hidden by policy. `}\n The surface is empty by decision, not because nothing was annotated.\n </Text>\n {view.explained ? null : (\n <Text dimColor>Re-run with --explain to see which policy hid them.</Text>\n )}\n </Box>\n );\n }\n return (\n <Box flexDirection=\"column\" marginTop={1}>\n <Text dimColor wrap=\"wrap\">\n Nothing is registered for this scenario — the agent has no surface here. That is the\n default: capabilities exist only where they were explicitly annotated.\n </Text>\n {view.explained ? null : (\n <Text dimColor>Re-run with --explain to see whether a policy hid it.</Text>\n )}\n </Box>\n );\n}\n\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/**\n * The verdict — authored minus reached. The finding the command surface used to\n * keep behind a fifth command, so it is the last thing painted and the thing a\n * reader stops on.\n */\nexport function Coverage({ report }: { report: CoverageReport }): ReactElement {\n const clean =\n report.unreached.length === 0 &&\n report.unresolved.length === 0 &&\n report.staleAllowlist.length === 0;\n\n return (\n <Static items={[{ key: \"__coverage\" }]}>\n {(block) => (\n <Box key={block.key} flexDirection=\"column\" marginTop={1}>\n {report.unreached.length > 0 ? (\n <Box flexDirection=\"column\">\n <Box>\n <Text backgroundColor=\"red\" color=\"black\" bold>\n {\" UNREACHED \"}\n </Text>\n <Text dimColor>{` authored, and no scenario mounts it ${report.unreached.length}`}</Text>\n </Box>\n {report.unreached.map((entry) => (\n <Box key={entry.capabilityId} paddingLeft={2}>\n <Text bold>{entry.capabilityId}</Text>\n <Text dimColor>{` ${entry.origin.file}:${entry.origin.line}`}</Text>\n </Box>\n ))}\n </Box>\n ) : null}\n <Box marginTop={report.unreached.length > 0 ? 1 : 0}>\n <Text color={clean ? \"green\" : \"red\"} bold>\n {`${report.authored} authored · ${report.reached} reached · ${report.unreached.length} unreached`}\n </Text>\n <Text dimColor>{` ${report.scenarios.join(\", \")}`}</Text>\n </Box>\n </Box>\n )}\n </Static>\n );\n}\n"],"mappings":";;;;;AACA,SAAS,KAAK,QAAQ,MAAM,gBAAgB;AAC5C,OAAO,aAAa;AAgDhB,SAoII,UAnIF,KADF;AA3CJ,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,OAAO;AAQb,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,O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AAe,WAAW;AAEnC,SACE,oBAAC,UAAO,OAAO,CAAC,EAAE,KAAK,aAAa,CAAC,GAClC,WAAC,UACA,qBAAC,OAAoB,eAAc,UAAS,WAAW,GACpD;AAAA,WAAO,UAAU,SAAS,IACzB,qBAAC,OAAI,eAAc,UACjB;AAAA,2BAAC,OACC;AAAA,4BAAC,QAAK,iBAAgB,OAAM,OAAM,SAAQ,MAAI,MAC3C,yBACH;AAAA,QACA,oBAAC,QAAK,UAAQ,MAAE,oDAA0C,OAAO,UAAU,MAAM,IAAG;AAAA,SACtF;AAAA,MACC,OAAO,UAAU,IAAI,CAAC,UACrB,qBAAC,OAA6B,aAAa,GACzC;AAAA,4BAAC,QAAK,MAAI,MAAE,gBAAM,cAAa;AAAA,QAC/B,oBAAC,QAAK,UAAQ,MAAE,eAAK,MAAM,OAAO,IAAI,IAAI,MAAM,OAAO,IAAI,IAAG;AAAA,WAFtD,MAAM,YAGhB,CACD;AAAA,OACH,IACE;AAAA,IACJ,qBAAC,OAAI,WAAW,OAAO,UAAU,SAAS,IAAI,IAAI,GAChD;AAAA,0BAAC,QAAK,OAAO,QAAQ,UAAU,OAAO,MAAI,MACvC,aAAG,OAAO,QAAQ,kBAAe,OAAO,OAAO,iBAAc,OAAO,UAAU,MAAM,cACvF;AAAA,MACA,oBAAC,QAAK,UAAQ,MAAE,eAAK,OAAO,UAAU,KAAK,IAAI,CAAC,IAAG;AAAA,OACrD;AAAA,OAtBQ,MAAM,GAuBhB,GAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderCatalogPlain,
|
|
3
|
+
renderCoveragePlain,
|
|
4
|
+
renderFailuresPlain,
|
|
5
|
+
renderNoVerdictPlain,
|
|
6
|
+
renderSurfacePlain
|
|
7
|
+
} from "./chunk-RXX63JSL.js";
|
|
8
|
+
import {
|
|
9
|
+
buildView
|
|
10
|
+
} from "./chunk-DYDSJM7R.js";
|
|
11
|
+
import {
|
|
12
|
+
joinCoverage,
|
|
13
|
+
mountScenarios,
|
|
14
|
+
readInventory
|
|
15
|
+
} from "./chunk-GXXKZTQB.js";
|
|
16
|
+
import {
|
|
17
|
+
isPlain,
|
|
18
|
+
loadInk,
|
|
19
|
+
paint,
|
|
20
|
+
write,
|
|
21
|
+
writeError
|
|
22
|
+
} from "./chunk-QIVOZAWX.js";
|
|
23
|
+
|
|
24
|
+
// src/commands/inspect.tsx
|
|
25
|
+
import { jsx } from "react/jsx-runtime";
|
|
26
|
+
function jsonForScenario(result, explain) {
|
|
27
|
+
return {
|
|
28
|
+
scenario: result.scenario,
|
|
29
|
+
...result.scope ? { scope: result.scope } : {},
|
|
30
|
+
snapshot: result.snapshot,
|
|
31
|
+
// Unconditional, and unconditionally present even when empty (`AS-CLI-006`):
|
|
32
|
+
// a consumer that has to distinguish "no rejections" from "this CLI predates
|
|
33
|
+
// the field" cannot rely on an absent key.
|
|
34
|
+
rejections: result.rejections,
|
|
35
|
+
...explain ? { explanation: result.explanation } : {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function runInspect(options) {
|
|
39
|
+
const analysis = {
|
|
40
|
+
configPath: options.configPath,
|
|
41
|
+
depth: options.depth,
|
|
42
|
+
...options.scenario ? { scenario: options.scenario } : {},
|
|
43
|
+
...options.scope ? { scope: options.scope } : {},
|
|
44
|
+
...options.tsconfig ? { tsconfig: options.tsconfig } : {},
|
|
45
|
+
...options.baselineDir ? { baselineDir: options.baselineDir } : {}
|
|
46
|
+
};
|
|
47
|
+
const detail = options.detail === true || options.explain === true || options.schemas === true;
|
|
48
|
+
const inventory = readInventory(analysis);
|
|
49
|
+
if (inventory && !options.json) {
|
|
50
|
+
write(renderCatalogPlain(inventory, { standalone: options.depth === "static" }));
|
|
51
|
+
}
|
|
52
|
+
const ink = isPlain(options) ? null : await loadInk();
|
|
53
|
+
const scenarios = [];
|
|
54
|
+
let printed = 0;
|
|
55
|
+
const runtime = await mountScenarios(analysis, async (result) => {
|
|
56
|
+
if (options.json) {
|
|
57
|
+
scenarios.push(jsonForScenario(result, options.explain === true));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const view = buildView(result, {
|
|
61
|
+
...options.explain ? { explain: true } : {},
|
|
62
|
+
...options.schemas ? { schemas: true } : {}
|
|
63
|
+
});
|
|
64
|
+
if (ink) await paint(/* @__PURE__ */ jsx(ink.Surface, { view, detail }));
|
|
65
|
+
else {
|
|
66
|
+
const rendered = renderSurfacePlain(view, { detail });
|
|
67
|
+
write(printed === 0 && !inventory ? rendered : `
|
|
68
|
+
${rendered}`);
|
|
69
|
+
}
|
|
70
|
+
printed += 1;
|
|
71
|
+
});
|
|
72
|
+
const coverage = joinCoverage(inventory, runtime, analysis);
|
|
73
|
+
if (options.json) {
|
|
74
|
+
write(
|
|
75
|
+
JSON.stringify(
|
|
76
|
+
{
|
|
77
|
+
// One shape whatever the depth, so a consumer never branches on how
|
|
78
|
+
// the command was invoked. A half the depth did not compute is
|
|
79
|
+
// `null`, which is a different statement from `[]` or `{}`.
|
|
80
|
+
depth: options.depth,
|
|
81
|
+
catalog: inventory ?? null,
|
|
82
|
+
scenarios,
|
|
83
|
+
failures: runtime?.failures ?? [],
|
|
84
|
+
coverage: coverage ?? null
|
|
85
|
+
},
|
|
86
|
+
null,
|
|
87
|
+
2
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
return runtime && runtime.failures.length > 0 ? 2 : 0;
|
|
91
|
+
}
|
|
92
|
+
if (runtime && runtime.failures.length > 0) {
|
|
93
|
+
writeError(`
|
|
94
|
+
${renderFailuresPlain(runtime.failures)}`);
|
|
95
|
+
}
|
|
96
|
+
if (coverage) {
|
|
97
|
+
write("");
|
|
98
|
+
write(renderCoveragePlain(coverage));
|
|
99
|
+
} else if (inventory && runtime && runtime.failures.length > 0) {
|
|
100
|
+
writeError(`
|
|
101
|
+
${renderNoVerdictPlain(runtime.failures)}`);
|
|
102
|
+
}
|
|
103
|
+
return runtime && runtime.failures.length > 0 ? 2 : 0;
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
runInspect
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=inspect-3CBRKTDM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/inspect.tsx"],"sourcesContent":["import {\n joinCoverage,\n mountScenarios,\n readInventory,\n type AnalysisOptions,\n type Depth,\n} from \"../analysis.js\";\nimport { buildView } from \"../render/model.js\";\nimport {\n renderCatalogPlain,\n renderCoveragePlain,\n renderFailuresPlain,\n renderNoVerdictPlain,\n renderSurfacePlain,\n} from \"../render/plain.js\";\nimport { isPlain, loadInk, paint, transient, write, writeError } from \"../output.js\";\nimport type { CollectResult } from \"../collect.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\nfunction jsonForScenario(result: CollectResult, explain: boolean): Record<string, unknown> {\n return {\n scenario: result.scenario,\n ...(result.scope ? { scope: result.scope } : {}),\n snapshot: result.snapshot,\n // Unconditional, and unconditionally present even when empty (`AS-CLI-006`):\n // a consumer that has to distinguish \"no rejections\" from \"this CLI predates\n // the field\" cannot rely on an absent key.\n rejections: result.rejections,\n ...(explain ? { explanation: result.explanation } : {}),\n };\n}\n\n/**\n * 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 * **Order is the design.** The catalog prints first because it is ready before\n * anything mounts; each scenario prints as it finishes, so a config with ten of\n * them is not ten mounts of blank terminal; the verdict prints last, because it\n * is the only part that needs every scenario to have finished — and because a\n * reader who stops at the bottom should stop on the finding.\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 const inventory = readInventory(analysis);\n if (inventory && !options.json) {\n // At `--depth static` this listing is the output. At `--depth full` the\n // scenario tables below carry the same capabilities and the verdict names\n // the ones they miss, so only the summary line prints here.\n write(renderCatalogPlain(inventory, { standalone: options.depth === \"static\" }));\n }\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 const scenarios: Array<Record<string, unknown>> = [];\n let printed = 0;\n\n const runtime = await mountScenarios(analysis, async (result) => {\n if (options.json) {\n scenarios.push(jsonForScenario(result, options.explain === true));\n return;\n }\n const view = buildView(result, {\n ...(options.explain ? { explain: true } : {}),\n ...(options.schemas ? { schemas: true } : {}),\n });\n if (ink) await paint(<ink.Surface view={view} detail={detail} />);\n else {\n const rendered = renderSurfacePlain(view, { detail });\n write(printed === 0 && !inventory ? rendered : `\\n${rendered}`);\n }\n printed += 1;\n });\n\n const coverage = joinCoverage(inventory, runtime, analysis);\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: inventory ?? null,\n scenarios,\n failures: runtime?.failures ?? [],\n coverage: coverage ?? null,\n },\n null,\n 2,\n ),\n );\n return runtime && runtime.failures.length > 0 ? 2 : 0;\n }\n\n if (runtime && runtime.failures.length > 0) {\n writeError(`\\n${renderFailuresPlain(runtime.failures)}`);\n }\n if (coverage) {\n write(\"\");\n write(renderCoveragePlain(coverage));\n } else if (inventory && runtime && runtime.failures.length > 0) {\n writeError(`\\n${renderNoVerdictPlain(runtime.failures)}`);\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 && runtime.failures.length > 0 ? 2 : 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiGyB;AAjEzB,SAAS,gBAAgB,QAAuB,SAA2C;AACzF,SAAO;AAAA,IACL,UAAU,OAAO;AAAA,IACjB,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;AAAA,IAC9C,UAAU,OAAO;AAAA;AAAA;AAAA;AAAA,IAIjB,YAAY,OAAO;AAAA,IACnB,GAAI,UAAU,EAAE,aAAa,OAAO,YAAY,IAAI,CAAC;AAAA,EACvD;AACF;AAiBA,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;AAE1F,QAAM,YAAY,cAAc,QAAQ;AACxC,MAAI,aAAa,CAAC,QAAQ,MAAM;AAI9B,UAAM,mBAAmB,WAAW,EAAE,YAAY,QAAQ,UAAU,SAAS,CAAC,CAAC;AAAA,EACjF;AAIA,QAAM,MAAM,QAAQ,OAAO,IAAI,OAAO,MAAM,QAAQ;AACpD,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B,QAAQ,QAAQ,CAAC,EAAE;AAAA,EAC1D;AAKA,SAAO,WAAW,QAAQ,SAAS,SAAS,IAAI,IAAI;AACtD;","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderCoveragePlain,
|
|
3
|
+
renderFailuresPlain
|
|
4
|
+
} from "./chunk-RXX63JSL.js";
|
|
5
|
+
import "./chunk-DYDSJM7R.js";
|
|
6
|
+
import {
|
|
7
|
+
baselinePath,
|
|
8
|
+
joinCoverage,
|
|
9
|
+
mountScenarios,
|
|
10
|
+
normalize,
|
|
11
|
+
readInventory,
|
|
12
|
+
writeBaseline
|
|
13
|
+
} from "./chunk-GXXKZTQB.js";
|
|
14
|
+
import {
|
|
15
|
+
UsageError,
|
|
16
|
+
write,
|
|
17
|
+
writeError
|
|
18
|
+
} from "./chunk-QIVOZAWX.js";
|
|
19
|
+
|
|
20
|
+
// src/commands/snapshot.ts
|
|
21
|
+
import { relative } from "path";
|
|
22
|
+
async function runSnapshot(options) {
|
|
23
|
+
if (options.depth === "static") {
|
|
24
|
+
throw new UsageError(
|
|
25
|
+
"snapshot --depth static has nothing to write \u2014 a baseline is a projection, and at this depth nothing is mounted."
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const analysis = {
|
|
29
|
+
configPath: options.configPath,
|
|
30
|
+
depth: options.depth,
|
|
31
|
+
...options.scenario ? { scenario: options.scenario } : {},
|
|
32
|
+
...options.scope ? { scope: options.scope } : {},
|
|
33
|
+
...options.tsconfig ? { tsconfig: options.tsconfig } : {},
|
|
34
|
+
...options.baselineDir ? { baselineDir: options.baselineDir } : {}
|
|
35
|
+
};
|
|
36
|
+
const inventory = readInventory(analysis);
|
|
37
|
+
const runtime = await mountScenarios(analysis);
|
|
38
|
+
if (!runtime) throw new UsageError("snapshot needs a mount, and this depth performs none");
|
|
39
|
+
for (const result of runtime.results) {
|
|
40
|
+
const path = baselinePath(runtime.baselineDir, result.scenario);
|
|
41
|
+
writeBaseline(path, normalize(result.snapshot));
|
|
42
|
+
write(`wrote ${relative(process.cwd(), path)}`);
|
|
43
|
+
}
|
|
44
|
+
const coverage = joinCoverage(inventory, runtime, analysis);
|
|
45
|
+
if (coverage) {
|
|
46
|
+
write("");
|
|
47
|
+
write(renderCoveragePlain(coverage));
|
|
48
|
+
}
|
|
49
|
+
if (runtime.failures.length > 0) {
|
|
50
|
+
writeError(`
|
|
51
|
+
${renderFailuresPlain(runtime.failures)}`);
|
|
52
|
+
return 2;
|
|
53
|
+
}
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
runSnapshot
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=snapshot-DJ22WCT4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/snapshot.ts"],"sourcesContent":["import { relative } from \"node:path\";\nimport {\n joinCoverage,\n mountScenarios,\n readInventory,\n UsageError,\n type AnalysisOptions,\n type Depth,\n} from \"../analysis.js\";\nimport { baselinePath, normalize, writeBaseline } from \"../baseline.js\";\nimport { renderCoveragePlain, renderFailuresPlain } from \"../render/plain.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, normalize(result.snapshot));\n write(`wrote ${relative(process.cwd(), path)}`);\n }\n\n const coverage = joinCoverage(inventory, runtime, analysis);\n if (coverage) {\n write(\"\");\n write(renderCoveragePlain(coverage));\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":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AA+BzB,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,GAAI,QAAQ,cAAc,EAAE,aAAa,QAAQ,YAAY,IAAI,CAAC;AAAA,EACpE;AAEA,QAAM,YAAY,cAAc,QAAQ;AACxC,QAAM,UAAU,MAAM,eAAe,QAAQ;AAC7C,MAAI,CAAC,QAAS,OAAM,IAAI,WAAW,sDAAsD;AAEzF,aAAW,UAAU,QAAQ,SAAS;AACpC,UAAM,OAAO,aAAa,QAAQ,aAAa,OAAO,QAAQ;AAC9D,kBAAc,MAAM,UAAU,OAAO,QAAQ,CAAC;AAC9C,UAAM,SAAS,SAAS,QAAQ,IAAI,GAAG,IAAI,CAAC,EAAE;AAAA,EAChD;AAEA,QAAM,WAAW,aAAa,WAAW,SAAS,QAAQ;AAC1D,MAAI,UAAU;AACZ,UAAM,EAAE;AACR,UAAM,oBAAoB,QAAQ,CAAC;AAAA,EACrC;AAEA,MAAI,QAAQ,SAAS,SAAS,GAAG;AAG/B,eAAW;AAAA,EAAK,oBAAoB,QAAQ,QAAQ,CAAC,EAAE;AACvD,WAAO;AAAA,EACT;AACA,SAAO;AACT;","names":[]}
|