@warlock.js/grimoire 5.64.0 → 5.65.1
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/CHANGELOG.md +17 -0
- package/esm/contracts/scry.d.mts +22 -1
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/devtools/index.d.mts +7 -0
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +1 -1
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +8 -2
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/index.d.mts +2 -2
- package/esm/scry/also-changes.mjs +3 -2
- package/esm/scry/also-changes.mjs.map +1 -1
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +14 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +34 -1
- package/esm/scry/query.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +11 -4
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/collect-off-thread.mjs +66 -0
- package/esm/warlock/collect-off-thread.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +2 -2
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/llms-full.txt +10 -4
- package/package.json +3 -3
- package/skills/use-the-grimoire/SKILL.md +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
`@warlock.js/grimoire` is new in 5.55.0 and experimental: its file layout, `GR` codes and API may change in any release until it is marked stable.
|
|
4
4
|
|
|
5
|
+
## 5.65.0 - 2026-11-26
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `warlock scry --search` (and the `grimoire_search` MCP tool) now folds the top file's impact into its answer: an `impact of <file>:` block with the importers not already listed (at most 8, with a `+n more` count) and the routes, flows and tests that reach it (at most 5 each). `--json` carries it as `impact`. One search answers "what changes with it" without a second `--impact` call; the `next:` line stays only when the answer has no impact block.
|
|
10
|
+
- The devtools panel takes a `warm` option to open the book ahead of the first tab view (default: on in development with the default adapter, off otherwise).
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Creating the devtools panel never scans the app. In production the book opens on the first tab view, from the stored book when it is current and built in memory otherwise; in development the optional warm-up starts after boot instead of during it.
|
|
15
|
+
- The source scan of a book build runs in a worker thread when the framework's tooling can be loaded there, so a large app keeps answering requests while the book builds.
|
|
16
|
+
- The `use-the-grimoire` skill and the MCP tool descriptions prefer the Grimoire MCP tools where a client supports them, and say the search answer already includes the impact list.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- The Grimoire devtools tab no longer blocks the event loop for seconds at server start on large apps.
|
|
21
|
+
|
|
5
22
|
## 5.64.0 - 2026-11-23
|
|
6
23
|
|
|
7
24
|
### Added
|
package/esm/contracts/scry.d.mts
CHANGED
|
@@ -185,6 +185,21 @@ export type ScryAlsoChange = {
|
|
|
185
185
|
/** The ids of the top hits that brought the file in. */
|
|
186
186
|
via: string[];
|
|
187
187
|
};
|
|
188
|
+
/** The impact of a search's top file, folded into the search answer: what reaches it, shortened. */
|
|
189
|
+
export type ScrySearchImpact = {
|
|
190
|
+
/** The file whose impact this is (the best top hit's file). */
|
|
191
|
+
file: string;
|
|
192
|
+
/** Files that import it, transitively, not already in `alsoChanges` or the hits; at most 8. */
|
|
193
|
+
files: string[];
|
|
194
|
+
/** How many more such files there are than `files` lists. */
|
|
195
|
+
more: number;
|
|
196
|
+
/** API routes that reach it, as `METHOD path`; at most 5. */
|
|
197
|
+
routes: string[];
|
|
198
|
+
/** `<feature>/<flow>` whose steps include it; at most 5. */
|
|
199
|
+
flows: string[];
|
|
200
|
+
/** Test files among the importers and the tests proving those flows; at most 5. */
|
|
201
|
+
tests: string[];
|
|
202
|
+
};
|
|
188
203
|
export type ScrySearchResult = ScryNotes & {
|
|
189
204
|
type: "search";
|
|
190
205
|
text: string;
|
|
@@ -198,9 +213,15 @@ export type ScrySearchResult = ScryNotes & {
|
|
|
198
213
|
* from before it existed.
|
|
199
214
|
*/
|
|
200
215
|
alsoChanges?: ScryAlsoChange[];
|
|
216
|
+
/**
|
|
217
|
+
* The impact of the top hit's file, so one search answers "what changes with it" without a second command:
|
|
218
|
+
* the same facts as `--impact`, shortened and without the files `alsoChanges` already lists. Absent when no top
|
|
219
|
+
* hit maps to a file, or in stored answers from before it existed.
|
|
220
|
+
*/
|
|
221
|
+
impact?: ScrySearchImpact;
|
|
201
222
|
/** The best hit is not a name match and holds fewer than half of the request's words: use grep for literal text. */
|
|
202
223
|
weak?: boolean;
|
|
203
|
-
/** The command
|
|
224
|
+
/** The full impact command for the top file (`warlock scry --impact <top file>`), for when `impact` is cut short. Absent when no top hit maps to a file. */
|
|
204
225
|
next?: string;
|
|
205
226
|
};
|
|
206
227
|
export type ScryResult = ScryFileResult | ScryImpactResult | ScryRouteResult | ScryFeatureResult | ScryFlowResult | ScrySearchResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scry.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/scry.ts"],"mappings":";;;;;;YAWY;;;EAEN;EAAc;;;;EAEd;EAAgB;;;;EAEhB;EAAe;EAAgB;EAAc;;;;EAE7C;EAAiB;;;;EAEjB;EAAc;EAAiB;;;;EAE/B;EAAgB;EAAc;EAAgB;;;YAGxC;EACV,QAAQ;EACR;;;YAIU;EAAgB;EAAa;EAAe;EAAc;;YAE1D,iBAAiB;EAC3B;EACA,OAAO;;EAEP;;YAIU,mBAAmB,KAAK;EAClC;EACA;;EAEA;IAAa;IAAkB;;;;;;EAK/B,QAAQ,KAAK;EACb,OAAO;;EAEP;;EAEA;IAAY;IAAY;;;EAExB;;YAGU,kBAAkB;EAC5B;;EAEA,OAAO;;EAEP;;EAEA;IAAS;IAAc;;;EAEvB,MAAM;;EAEN,OAAO;;;YAIG,gBAAgB;;EAE1B;EACA;EACA;EACA;;;YAIU;EACV;;EAEA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;YAGU,oBAAoB;EAC9B;EACA,QAAQ;EACR,OAAO;EACP,SAAS;;EAET,SAAS;;EAET,OAAO;EACP,UAAU;;YAGA,iBAAiB;EAC3B;EACA,MAAM;EACN,SAAS;;EAET,SAAS;EACT,UAAU;;;YAIA;;YAcA;EACV,MAAM;;;;;;EAMN;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;YAIU;EACV;;;;;EAKA;;EAEA;;YAGU,mBAAmB;EAC7B;EACA;;EAEA,QAAQ,QAAQ,OAAO;;EAEvB,MAAM;;;;;;EAMN,cAAc;;
|
|
1
|
+
{"version":3,"file":"scry.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/scry.ts"],"mappings":";;;;;;YAWY;;;EAEN;EAAc;;;;EAEd;EAAgB;;;;EAEhB;EAAe;EAAgB;EAAc;;;;EAE7C;EAAiB;;;;EAEjB;EAAc;EAAiB;;;;EAE/B;EAAgB;EAAc;EAAgB;;;YAGxC;EACV,QAAQ;EACR;;;YAIU;EAAgB;EAAa;EAAe;EAAc;;YAE1D,iBAAiB;EAC3B;EACA,OAAO;;EAEP;;YAIU,mBAAmB,KAAK;EAClC;EACA;;EAEA;IAAa;IAAkB;;;;;;EAK/B,QAAQ,KAAK;EACb,OAAO;;EAEP;;EAEA;IAAY;IAAY;;;EAExB;;YAGU,kBAAkB;EAC5B;;EAEA,OAAO;;EAEP;;EAEA;IAAS;IAAc;;;EAEvB,MAAM;;EAEN,OAAO;;;YAIG,gBAAgB;;EAE1B;EACA;EACA;EACA;;;YAIU;EACV;;EAEA;EACA;;EAEA;;;YAIU;EACV;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;YAGU,oBAAoB;EAC9B;EACA,QAAQ;EACR,OAAO;EACP,SAAS;;EAET,SAAS;;EAET,OAAO;EACP,UAAU;;YAGA,iBAAiB;EAC3B;EACA,MAAM;EACN,SAAS;;EAET,SAAS;EACT,UAAU;;;YAIA;;YAcA;EACV,MAAM;;;;;;EAMN;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;YAIU;EACV;;;;;EAKA;;EAEA;;;YAIU;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;YAGU,mBAAmB;EAC7B;EACA;;EAEA,QAAQ,QAAQ,OAAO;;EAEvB,MAAM;;;;;;EAMN,cAAc;;;;;;EAMd,SAAS;;EAET;;EAEA;;YAGU,aACR,iBACA,mBACA,kBACA,oBACA,iBACA"}
|
package/esm/devtools/index.d.mts
CHANGED
|
@@ -62,6 +62,13 @@ export type GrimoirePanelContext = {
|
|
|
62
62
|
* `grimoireReporter({ file })`.
|
|
63
63
|
*/
|
|
64
64
|
testResultsFile?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Open the book ahead of the first tab view. Default: `true` in development with the default adapter, `false`
|
|
67
|
+
* otherwise (production and a custom adapter), so creating the panel never scans the app: the book opens on the
|
|
68
|
+
* first view, from the stored book when it is current. When on, the open starts after the creating tick (never
|
|
69
|
+
* during boot) and its failures surface on the first request.
|
|
70
|
+
*/
|
|
71
|
+
warm?: boolean;
|
|
65
72
|
/** Captured error groups of the monitor (counts only), for the product map's health. Devtools passes it. */
|
|
66
73
|
errors?: () => Promise<readonly ProductErrorSummary[]>;
|
|
67
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"mappings":";;;;;YAkCY;EACV,QAAQ,SAAS;EACjB,OAAO,SAAS;EAChB;;EAEA;;;YAIU;EACV,eAAe;EACf;EACA;EACA;;;YAIU;EACV;EACA;EACA,eAAe;EACf;IACE;IACA;IACA,UAAU,SAAS;;EAErB,SAAS,SAAS,wBAAwB;;EAE1C;IAAU;IAAa;;;EAEvB,QAAQ;;EAER;;;YAIU;;EAEV;;;;;EAKA;;EAEA,UAAU,qBAAqB,QAAQ;;;;;;EAMvC;;;;;;;EAOA;;EAEA,eAAe,iBAAiB;;;wBAWZ,sBACpB,SAAS,uBACR,QAAQ"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"mappings":";;;;;YAkCY;EACV,QAAQ,SAAS;EACjB,OAAO,SAAS;EAChB;;EAEA;;;YAIU;EACV,eAAe;EACf;EACA;EACA;;;YAIU;EACV;EACA;EACA,eAAe;EACf;IACE;IACA;IACA,UAAU,SAAS;;EAErB,SAAS,SAAS,wBAAwB;;EAE1C;IAAU;IAAa;;;EAEvB,QAAQ;;EAER;;;YAIU;;EAEV;;;;;EAKA;;EAEA,UAAU,qBAAqB,QAAQ;;;;;;EAMvC;;;;;;;EAOA;;;;;;;EAOA;;EAEA,eAAe,iBAAiB;;;wBAWZ,sBACpB,SAAS,uBACR,QAAQ"}
|
package/esm/devtools/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ async function grimoireDevtoolsPanel(context) {
|
|
|
27
27
|
...context.ttlMs === void 0 ? {} : { ttlMs: context.ttlMs },
|
|
28
28
|
...context.testResultsFile === void 0 ? {} : { testResultsFile: context.testResultsFile }
|
|
29
29
|
});
|
|
30
|
-
if (
|
|
30
|
+
if (context.warm ?? (development && context.adapter === void 0)) setTimeout(() => source.warm(), 0).unref();
|
|
31
31
|
const answer = (read) => async (request) => read(await source.get(), request);
|
|
32
32
|
/** The product map answers: the shared flag from the request, the errors fetched per request. */
|
|
33
33
|
const product = (read) => async (request) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["data.summary","data.search","data.file","data.impact","data.route","data.features","data.feature","data.flowAnswer","data.stepFiles","data.apps","data.page","data.tasks","data.releases","data.release","data.check","data.checkPage","data.checkGroups","data.graphOfFile","data.graphOfFeature","data.graphOfPage","data.graphOfModules","data.GrimoirePanelError"],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"sourcesContent":["/**\n * `@warlock.js/grimoire/devtools`: the Grimoire tab of the devtools\n * dashboard. An app enables it in `src/config/devtools.ts`:\n *\n * ```ts\n * panels: [\"@warlock.js/grimoire/devtools\"]\n * ```\n *\n * The default export is a panel factory (devtools' `DevtoolsPanelExport`),\n * typed structurally here so this entry needs no `@warlock.js/devtools`\n * import. The browser view lives in the package's `ui/` folder. Data routes\n * open the snapshot with `routes: \"cached\"` (never booting the app) and keep\n * the generated book up to date; agent-written files are only read.\n */\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport path from \"node:path\";\nimport type { GrimoireCheckFilter } from \"./answers\";\nimport { approveFromPanel, rejectFromPanel } from \"./approvals\";\nimport * as data from \"./data\";\nimport { matrix } from \"./matrix\";\nimport {\n productFeature,\n productFlow,\n productMap,\n productWhatsNew,\n type ProductErrorSummary,\n} from \"./product-map\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\nexport { buildProductSiteData, exportGrimoireSite, exportGrimoireSiteDetailed } from \"./site\";\nexport type { ExportGrimoireSiteOptions, GrimoireSiteExport } from \"./site\";\n\n/** The parts of devtools' `DevtoolsPanelRequest` the routes read. */\nexport type GrimoirePanelRequest = {\n params: Readonly<Record<string, string>>;\n query: Readonly<Record<string, string | readonly string[]>>;\n body: unknown;\n /** `true` when the request came through a read-only share link. */\n shared?: boolean;\n};\n\n/** Devtools' `DevtoolsPanelShare`, structurally: what a share link may show. */\nexport type GrimoireDevtoolsPanelShare = {\n view: string | URL;\n routes: readonly string[];\n assets?: readonly string[];\n files?: boolean;\n};\n\n/** Devtools' `DevtoolsPanel`, structurally. */\nexport type GrimoireDevtoolsPanel = {\n id: string;\n title: string;\n view: string | URL;\n routes?: readonly {\n method?: \"GET\" | \"POST\";\n path: string;\n handler: (request: GrimoirePanelRequest) => unknown;\n }[];\n assets?: Readonly<Record<string, string | URL>>;\n /** A folder of images served next to the panel. */\n files?: { dir: string; extensions?: readonly string[] };\n /** What a read-only share link may show. */\n share?: GrimoireDevtoolsPanelShare;\n /** Safe for the production monitor: the tab only reads (see `GrimoirePanelContext.mode`). */\n production?: boolean;\n};\n\n/** What the panel factory takes: devtools passes `{ root, mode }`; the rest is for tests and custom setups. */\nexport type GrimoirePanelContext = {\n /** The app root. */\n root: string;\n /**\n * Where the dashboard runs. In `\"production\"` the tab writes no files:\n * it reads the book as it is on disk. Default: development.\n */\n mode?: \"development\" | \"production\";\n /** The adapter to open the book with. Default: the Warlock adapter, loaded on first request. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long an opened snapshot is reused when the book did not change (ms).\n * Default in development: 2000, longer after a slow open; the old snapshot is served while a\n * background open refreshes it. Default in production: until the book changes.\n */\n ttlMs?: number;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. Set it when the deploy ships\n * the results from CI; the Vitest reporter writes there with\n * `grimoireReporter({ file })`.\n */\n testResultsFile?: string;\n /** Captured error groups of the monitor (counts only), for the product map's health. Devtools passes it. */\n errors?: () => Promise<readonly ProductErrorSummary[]>;\n};\n\n/** The first value of a query parameter. */\nfunction one(query: GrimoirePanelRequest[\"query\"], name: string): string | undefined {\n const value = query[name];\n\n return Array.isArray(value) ? value[0] : (value as string | undefined);\n}\n\n/** Build the panel for the app at `root`. */\nexport async function grimoireDevtoolsPanel(\n context: GrimoirePanelContext,\n): Promise<GrimoireDevtoolsPanel> {\n // In development the tab keeps Warlock's generated files (book, book maps, indexes) up to date, so\n // the next open is incremental. In production it writes nothing. Agent-written files are only read,\n // and cached routes never boot the app.\n const development = context.mode !== \"production\";\n let live: Promise<BookAdapter> | undefined;\n const liveAdapter = (): Promise<BookAdapter> =>\n (live ??= import(\"../warlock\").then(({ createWarlockAdapter }) =>\n createWarlockAdapter({ live: true }),\n ));\n const source = createSnapshotSource(context.root, {\n write: context.mode !== \"production\",\n mode: context.mode ?? \"development\",\n // The panel runs inside the app's own process, so it never boots the app again (that would start every\n // connector twice and register the route and event modules twice). In development the default adapter\n // reads the route, event and job facts from the live registries; a custom adapter is used as given.\n ...(context.adapter === undefined\n ? development\n ? { adapter: liveAdapter, liveFacts: true }\n : {}\n : { adapter: context.adapter }),\n ...(context.ttlMs === undefined ? {} : { ttlMs: context.ttlMs }),\n ...(context.testResultsFile === undefined ? {} : { testResultsFile: context.testResultsFile }),\n });\n\n // Start opening the book now so the first tab view is fast. In development this runs in the background\n // (never awaited, failures ignored) and only with the default adapter, so a custom one is not called early.\n if (!development || context.adapter === undefined) source.warm();\n\n const answer =\n <Answer>(read: (snapshot: GrimoireSnapshot, request: GrimoirePanelRequest) => Answer) =>\n async (request: GrimoirePanelRequest): Promise<Answer> =>\n read(await source.get(), request);\n\n /** The product map answers: the shared flag from the request, the errors fetched per request. */\n const product =\n <Answer>(\n read: (\n snapshot: GrimoireSnapshot,\n request: GrimoirePanelRequest,\n options: { shared: boolean; errors: readonly ProductErrorSummary[] | null },\n ) => Answer,\n ) =>\n async (request: GrimoirePanelRequest): Promise<Answer> => {\n const snapshot = await source.get();\n let errors: readonly ProductErrorSummary[] | null = null;\n\n try {\n errors = (await context.errors?.()) ?? null;\n } catch {\n errors = null;\n }\n\n return read(snapshot, request, { shared: request.shared === true, errors });\n };\n\n const number = (value: string | undefined): number | undefined => {\n if (value === undefined || value === \"\") return undefined;\n\n const parsed = Number(value);\n\n return Number.isFinite(parsed) ? parsed : undefined;\n };\n\n const checkFilter = (query: GrimoirePanelRequest[\"query\"]): GrimoireCheckFilter | null => {\n const filter: GrimoireCheckFilter = {};\n const code = one(query, \"code\");\n const feature = one(query, \"feature\");\n const flow = one(query, \"flow\");\n const severity = one(query, \"severity\");\n const state = one(query, \"state\");\n const offset = number(one(query, \"offset\"));\n const limit = number(one(query, \"limit\"));\n let any = false;\n\n if (code) {\n filter.code = code;\n any = true;\n }\n if (feature) {\n filter.feature = feature;\n any = true;\n }\n if (flow) {\n filter.flow = flow;\n any = true;\n }\n if (severity === \"error\" || severity === \"warning\") {\n filter.severity = severity;\n any = true;\n }\n if (state === \"expected\" || state === \"unexpected\") {\n filter.state = state;\n any = true;\n }\n if (offset !== undefined) {\n filter.offset = offset;\n any = true;\n }\n if (limit !== undefined) {\n filter.limit = limit;\n any = true;\n }\n\n return any ? filter : null;\n };\n\n return {\n id: \"grimoire\",\n title: \"Grimoire\",\n production: true,\n view: new URL(\"../../ui/grimoire-view.js\", import.meta.url),\n assets: {\n \"grimoire.css\": new URL(\"../../ui/grimoire.css\", import.meta.url),\n \"product-map.js\": new URL(\"../../ui/product-map.js\", import.meta.url),\n \"product-map.css\": new URL(\"../../ui/product-map.css\", import.meta.url),\n },\n files: { dir: path.join(context.root, \"grimoire\", \"screenshots\") },\n share: {\n view: new URL(\"../../ui/product-map.js\", import.meta.url),\n routes: [\n \"/product\",\n \"/product/whats-new\",\n \"/product/features/:feature\",\n \"/product/flows/:feature/:flow\",\n ],\n assets: [\"product-map.css\"],\n files: true,\n },\n routes: [\n { path: \"/summary\", handler: answer((snapshot) => data.summary(snapshot)) },\n {\n path: \"/search\",\n handler: answer((snapshot, { query }) => {\n const limit = Number(one(query, \"limit\"));\n\n return data.search(\n snapshot,\n one(query, \"q\") ?? \"\",\n Number.isFinite(limit) && limit > 0 ? limit : undefined,\n );\n }),\n },\n {\n path: \"/file\",\n handler: answer((snapshot, { query }) => data.file(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/impact\",\n handler: answer((snapshot, { query }) => data.impact(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/route\",\n handler: answer((snapshot, { query }) =>\n data.route(snapshot, one(query, \"method\"), one(query, \"path\")),\n ),\n },\n { path: \"/features\", handler: answer((snapshot) => data.features(snapshot)) },\n {\n path: \"/features/:feature\",\n handler: answer((snapshot, { params }) => data.feature(snapshot, params.feature)),\n },\n {\n path: \"/flows/:feature/:flow\",\n handler: answer((snapshot, { params }) =>\n data.flowAnswer(snapshot, params.feature, params.flow),\n ),\n },\n {\n path: \"/flows/:feature/:flow/steps/:index/files\",\n handler: answer((snapshot, { params, query }) =>\n data.stepFiles(snapshot, params.feature, params.flow, params.index, {\n set: one(query, \"set\"),\n offset: one(query, \"offset\"),\n limit: one(query, \"limit\"),\n }),\n ),\n },\n {\n path: \"/product\",\n handler: product((snapshot, _request, options) => productMap(snapshot, options)),\n },\n {\n path: \"/product/whats-new\",\n handler: product((snapshot, _request, options) => productWhatsNew(snapshot, options)),\n },\n {\n path: \"/product/features/:feature\",\n handler: product((snapshot, { params }, options) =>\n productFeature(snapshot, params.feature, options),\n ),\n },\n {\n path: \"/product/flows/:feature/:flow\",\n handler: product((snapshot, { params }, options) =>\n productFlow(snapshot, params.feature, params.flow, options),\n ),\n },\n // The Bird view: never shared (it names the test status of every criterion).\n {\n path: \"/matrix\",\n handler: answer((snapshot) => ({ ...matrix(snapshot), development })),\n },\n { path: \"/apps\", handler: answer((snapshot) => data.apps(snapshot)) },\n {\n path: \"/apps/:app/pages/:page\",\n handler: answer((snapshot, { params }) => data.page(snapshot, params.app, params.page)),\n },\n { path: \"/tasks\", handler: answer((snapshot) => data.tasks(snapshot)) },\n { path: \"/releases\", handler: answer((snapshot) => data.releases(snapshot)) },\n {\n path: \"/releases/:release\",\n handler: answer((snapshot, { params }) => data.release(snapshot, params.release)),\n },\n {\n path: \"/check\",\n handler: answer((snapshot, { query }) => {\n const filter = checkFilter(query);\n\n return filter === null ? data.check(snapshot) : data.checkPage(snapshot, filter);\n }),\n },\n { path: \"/check/groups\", handler: answer((snapshot) => data.checkGroups(snapshot)) },\n {\n path: \"/graph/file\",\n handler: answer((snapshot, { query }) => data.graphOfFile(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/graph/feature/:feature\",\n handler: answer((snapshot, { params }) => data.graphOfFeature(snapshot, params.feature)),\n },\n {\n path: \"/graph/page\",\n handler: answer((snapshot, { query }) =>\n data.graphOfPage(snapshot, one(query, \"app\"), one(query, \"page\")),\n ),\n },\n { path: \"/graph/modules\", handler: answer((snapshot) => data.graphOfModules(snapshot)) },\n // The Bird view's buttons write the approved baseline: development only, never through a share link.\n {\n method: \"POST\",\n path: \"/approve\",\n handler: async (request) => {\n if (!development || request.shared === true) {\n throw new data.GrimoirePanelError(403, \"Approving is only possible in development.\");\n }\n\n return approveFromPanel(await source.get(), request.body);\n },\n },\n {\n method: \"POST\",\n path: \"/reject\",\n handler: async (request) => {\n if (!development || request.shared === true) {\n throw new data.GrimoirePanelError(403, \"Rejecting is only possible in development.\");\n }\n\n return rejectFromPanel(await source.get(), request.body);\n },\n },\n ],\n };\n}\n\nexport default grimoireDevtoolsPanel;\n"],"mappings":";;;;;;;;;;AAkGA,SAAS,IAAI,OAAsC,MAAkC;CACnF,MAAM,QAAQ,MAAM;CAEpB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAM;AAC5C;;AAGA,eAAsB,sBACpB,SACgC;CAIhC,MAAM,cAAc,QAAQ,SAAS;CACrC,IAAI;CACJ,MAAM,oBACH,SAAS,OAAO,uBAAa,CAAC,MAAM,EAAE,2BACrC,qBAAqB,EAAE,MAAM,KAAK,CAAC,CACrC;CACF,MAAM,SAAS,qBAAqB,QAAQ,MAAM;EAChD,OAAO,QAAQ,SAAS;EACxB,MAAM,QAAQ,QAAQ;EAItB,GAAI,QAAQ,YAAY,SACpB,cACE;GAAE,SAAS;GAAa,WAAW;EAAK,IACxC,CAAC,IACH,EAAE,SAAS,QAAQ,QAAQ;EAC/B,GAAI,QAAQ,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;EAC9D,GAAI,QAAQ,oBAAoB,SAAY,CAAC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;CAC9F,CAAC;CAID,IAAI,CAAC,eAAe,QAAQ,YAAY,QAAW,OAAO,KAAK;CAE/D,MAAM,UACK,SACT,OAAO,YACL,KAAK,MAAM,OAAO,IAAI,GAAG,O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,SAAS,YAAY,KAAK;KAEhC,OAAO,WAAW,OAAOC,MAAW,QAAQ,IAAIC,UAAe,UAAU,MAAM;IACjF,CAAC;GACH;GACA;IAAE,MAAM;IAAiB,SAAS,QAAQ,aAAaC,YAAiB,QAAQ,CAAC;GAAE;GACnF;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAAYC,YAAiB,UAAU,IAAI,OAAO,MAAM,CAAC,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,aAAaC,eAAoB,UAAU,OAAO,OAAO,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAC3BC,YAAiB,UAAU,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,MAAM,CAAC,CAClE;GACF;GACA;IAAE,MAAM;IAAkB,SAAS,QAAQ,aAAaC,eAAoB,QAAQ,CAAC;GAAE;GAEvF;IACE,QAAQ;IACR,MAAM;IACN,SAAS,OAAO,YAAY;KAC1B,IAAI,CAAC,eAAe,QAAQ,WAAW,MACrC,MAAM,IAAIC,mBAAwB,KAAK,4CAA4C;KAGrF,OAAO,iBAAiB,MAAM,OAAO,IAAI,GAAG,QAAQ,IAAI;IAC1D;GACF;GACA;IACE,QAAQ;IACR,MAAM;IACN,SAAS,OAAO,YAAY;KAC1B,IAAI,CAAC,eAAe,QAAQ,WAAW,MACrC,MAAM,IAAIA,mBAAwB,KAAK,4CAA4C;KAGrF,OAAO,gBAAgB,MAAM,OAAO,IAAI,GAAG,QAAQ,IAAI;IACzD;GACF;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["data.summary","data.search","data.file","data.impact","data.route","data.features","data.feature","data.flowAnswer","data.stepFiles","data.apps","data.page","data.tasks","data.releases","data.release","data.check","data.checkPage","data.checkGroups","data.graphOfFile","data.graphOfFeature","data.graphOfPage","data.graphOfModules","data.GrimoirePanelError"],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"sourcesContent":["/**\n * `@warlock.js/grimoire/devtools`: the Grimoire tab of the devtools\n * dashboard. An app enables it in `src/config/devtools.ts`:\n *\n * ```ts\n * panels: [\"@warlock.js/grimoire/devtools\"]\n * ```\n *\n * The default export is a panel factory (devtools' `DevtoolsPanelExport`),\n * typed structurally here so this entry needs no `@warlock.js/devtools`\n * import. The browser view lives in the package's `ui/` folder. Data routes\n * open the snapshot with `routes: \"cached\"` (never booting the app) and keep\n * the generated book up to date; agent-written files are only read.\n */\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport path from \"node:path\";\nimport type { GrimoireCheckFilter } from \"./answers\";\nimport { approveFromPanel, rejectFromPanel } from \"./approvals\";\nimport * as data from \"./data\";\nimport { matrix } from \"./matrix\";\nimport {\n productFeature,\n productFlow,\n productMap,\n productWhatsNew,\n type ProductErrorSummary,\n} from \"./product-map\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\nexport { buildProductSiteData, exportGrimoireSite, exportGrimoireSiteDetailed } from \"./site\";\nexport type { ExportGrimoireSiteOptions, GrimoireSiteExport } from \"./site\";\n\n/** The parts of devtools' `DevtoolsPanelRequest` the routes read. */\nexport type GrimoirePanelRequest = {\n params: Readonly<Record<string, string>>;\n query: Readonly<Record<string, string | readonly string[]>>;\n body: unknown;\n /** `true` when the request came through a read-only share link. */\n shared?: boolean;\n};\n\n/** Devtools' `DevtoolsPanelShare`, structurally: what a share link may show. */\nexport type GrimoireDevtoolsPanelShare = {\n view: string | URL;\n routes: readonly string[];\n assets?: readonly string[];\n files?: boolean;\n};\n\n/** Devtools' `DevtoolsPanel`, structurally. */\nexport type GrimoireDevtoolsPanel = {\n id: string;\n title: string;\n view: string | URL;\n routes?: readonly {\n method?: \"GET\" | \"POST\";\n path: string;\n handler: (request: GrimoirePanelRequest) => unknown;\n }[];\n assets?: Readonly<Record<string, string | URL>>;\n /** A folder of images served next to the panel. */\n files?: { dir: string; extensions?: readonly string[] };\n /** What a read-only share link may show. */\n share?: GrimoireDevtoolsPanelShare;\n /** Safe for the production monitor: the tab only reads (see `GrimoirePanelContext.mode`). */\n production?: boolean;\n};\n\n/** What the panel factory takes: devtools passes `{ root, mode }`; the rest is for tests and custom setups. */\nexport type GrimoirePanelContext = {\n /** The app root. */\n root: string;\n /**\n * Where the dashboard runs. In `\"production\"` the tab writes no files:\n * it reads the book as it is on disk. Default: development.\n */\n mode?: \"development\" | \"production\";\n /** The adapter to open the book with. Default: the Warlock adapter, loaded on first request. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long an opened snapshot is reused when the book did not change (ms).\n * Default in development: 2000, longer after a slow open; the old snapshot is served while a\n * background open refreshes it. Default in production: until the book changes.\n */\n ttlMs?: number;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. Set it when the deploy ships\n * the results from CI; the Vitest reporter writes there with\n * `grimoireReporter({ file })`.\n */\n testResultsFile?: string;\n /**\n * Open the book ahead of the first tab view. Default: `true` in development with the default adapter, `false`\n * otherwise (production and a custom adapter), so creating the panel never scans the app: the book opens on the\n * first view, from the stored book when it is current. When on, the open starts after the creating tick (never\n * during boot) and its failures surface on the first request.\n */\n warm?: boolean;\n /** Captured error groups of the monitor (counts only), for the product map's health. Devtools passes it. */\n errors?: () => Promise<readonly ProductErrorSummary[]>;\n};\n\n/** The first value of a query parameter. */\nfunction one(query: GrimoirePanelRequest[\"query\"], name: string): string | undefined {\n const value = query[name];\n\n return Array.isArray(value) ? value[0] : (value as string | undefined);\n}\n\n/** Build the panel for the app at `root`. */\nexport async function grimoireDevtoolsPanel(\n context: GrimoirePanelContext,\n): Promise<GrimoireDevtoolsPanel> {\n // In development the tab keeps Warlock's generated files (book, book maps, indexes) up to date, so\n // the next open is incremental. In production it writes nothing. Agent-written files are only read,\n // and cached routes never boot the app.\n const development = context.mode !== \"production\";\n let live: Promise<BookAdapter> | undefined;\n const liveAdapter = (): Promise<BookAdapter> =>\n (live ??= import(\"../warlock\").then(({ createWarlockAdapter }) =>\n createWarlockAdapter({ live: true }),\n ));\n const source = createSnapshotSource(context.root, {\n write: context.mode !== \"production\",\n mode: context.mode ?? \"development\",\n // The panel runs inside the app's own process, so it never boots the app again (that would start every\n // connector twice and register the route and event modules twice). In development the default adapter\n // reads the route, event and job facts from the live registries; a custom adapter is used as given.\n ...(context.adapter === undefined\n ? development\n ? { adapter: liveAdapter, liveFacts: true }\n : {}\n : { adapter: context.adapter }),\n ...(context.ttlMs === undefined ? {} : { ttlMs: context.ttlMs }),\n ...(context.testResultsFile === undefined ? {} : { testResultsFile: context.testResultsFile }),\n });\n\n // Open the book ahead of the first view only when asked (or in development with the default adapter, so a\n // custom adapter is not called early). Deferred past the creating tick so boot is never held up; never\n // awaited, failures ignored (they surface on the first request).\n const warm = context.warm ?? (development && context.adapter === undefined);\n\n if (warm) setTimeout(() => source.warm(), 0).unref();\n\n const answer =\n <Answer>(read: (snapshot: GrimoireSnapshot, request: GrimoirePanelRequest) => Answer) =>\n async (request: GrimoirePanelRequest): Promise<Answer> =>\n read(await source.get(), request);\n\n /** The product map answers: the shared flag from the request, the errors fetched per request. */\n const product =\n <Answer>(\n read: (\n snapshot: GrimoireSnapshot,\n request: GrimoirePanelRequest,\n options: { shared: boolean; errors: readonly ProductErrorSummary[] | null },\n ) => Answer,\n ) =>\n async (request: GrimoirePanelRequest): Promise<Answer> => {\n const snapshot = await source.get();\n let errors: readonly ProductErrorSummary[] | null = null;\n\n try {\n errors = (await context.errors?.()) ?? null;\n } catch {\n errors = null;\n }\n\n return read(snapshot, request, { shared: request.shared === true, errors });\n };\n\n const number = (value: string | undefined): number | undefined => {\n if (value === undefined || value === \"\") return undefined;\n\n const parsed = Number(value);\n\n return Number.isFinite(parsed) ? parsed : undefined;\n };\n\n const checkFilter = (query: GrimoirePanelRequest[\"query\"]): GrimoireCheckFilter | null => {\n const filter: GrimoireCheckFilter = {};\n const code = one(query, \"code\");\n const feature = one(query, \"feature\");\n const flow = one(query, \"flow\");\n const severity = one(query, \"severity\");\n const state = one(query, \"state\");\n const offset = number(one(query, \"offset\"));\n const limit = number(one(query, \"limit\"));\n let any = false;\n\n if (code) {\n filter.code = code;\n any = true;\n }\n if (feature) {\n filter.feature = feature;\n any = true;\n }\n if (flow) {\n filter.flow = flow;\n any = true;\n }\n if (severity === \"error\" || severity === \"warning\") {\n filter.severity = severity;\n any = true;\n }\n if (state === \"expected\" || state === \"unexpected\") {\n filter.state = state;\n any = true;\n }\n if (offset !== undefined) {\n filter.offset = offset;\n any = true;\n }\n if (limit !== undefined) {\n filter.limit = limit;\n any = true;\n }\n\n return any ? filter : null;\n };\n\n return {\n id: \"grimoire\",\n title: \"Grimoire\",\n production: true,\n view: new URL(\"../../ui/grimoire-view.js\", import.meta.url),\n assets: {\n \"grimoire.css\": new URL(\"../../ui/grimoire.css\", import.meta.url),\n \"product-map.js\": new URL(\"../../ui/product-map.js\", import.meta.url),\n \"product-map.css\": new URL(\"../../ui/product-map.css\", import.meta.url),\n },\n files: { dir: path.join(context.root, \"grimoire\", \"screenshots\") },\n share: {\n view: new URL(\"../../ui/product-map.js\", import.meta.url),\n routes: [\n \"/product\",\n \"/product/whats-new\",\n \"/product/features/:feature\",\n \"/product/flows/:feature/:flow\",\n ],\n assets: [\"product-map.css\"],\n files: true,\n },\n routes: [\n { path: \"/summary\", handler: answer((snapshot) => data.summary(snapshot)) },\n {\n path: \"/search\",\n handler: answer((snapshot, { query }) => {\n const limit = Number(one(query, \"limit\"));\n\n return data.search(\n snapshot,\n one(query, \"q\") ?? \"\",\n Number.isFinite(limit) && limit > 0 ? limit : undefined,\n );\n }),\n },\n {\n path: \"/file\",\n handler: answer((snapshot, { query }) => data.file(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/impact\",\n handler: answer((snapshot, { query }) => data.impact(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/route\",\n handler: answer((snapshot, { query }) =>\n data.route(snapshot, one(query, \"method\"), one(query, \"path\")),\n ),\n },\n { path: \"/features\", handler: answer((snapshot) => data.features(snapshot)) },\n {\n path: \"/features/:feature\",\n handler: answer((snapshot, { params }) => data.feature(snapshot, params.feature)),\n },\n {\n path: \"/flows/:feature/:flow\",\n handler: answer((snapshot, { params }) =>\n data.flowAnswer(snapshot, params.feature, params.flow),\n ),\n },\n {\n path: \"/flows/:feature/:flow/steps/:index/files\",\n handler: answer((snapshot, { params, query }) =>\n data.stepFiles(snapshot, params.feature, params.flow, params.index, {\n set: one(query, \"set\"),\n offset: one(query, \"offset\"),\n limit: one(query, \"limit\"),\n }),\n ),\n },\n {\n path: \"/product\",\n handler: product((snapshot, _request, options) => productMap(snapshot, options)),\n },\n {\n path: \"/product/whats-new\",\n handler: product((snapshot, _request, options) => productWhatsNew(snapshot, options)),\n },\n {\n path: \"/product/features/:feature\",\n handler: product((snapshot, { params }, options) =>\n productFeature(snapshot, params.feature, options),\n ),\n },\n {\n path: \"/product/flows/:feature/:flow\",\n handler: product((snapshot, { params }, options) =>\n productFlow(snapshot, params.feature, params.flow, options),\n ),\n },\n // The Bird view: never shared (it names the test status of every criterion).\n {\n path: \"/matrix\",\n handler: answer((snapshot) => ({ ...matrix(snapshot), development })),\n },\n { path: \"/apps\", handler: answer((snapshot) => data.apps(snapshot)) },\n {\n path: \"/apps/:app/pages/:page\",\n handler: answer((snapshot, { params }) => data.page(snapshot, params.app, params.page)),\n },\n { path: \"/tasks\", handler: answer((snapshot) => data.tasks(snapshot)) },\n { path: \"/releases\", handler: answer((snapshot) => data.releases(snapshot)) },\n {\n path: \"/releases/:release\",\n handler: answer((snapshot, { params }) => data.release(snapshot, params.release)),\n },\n {\n path: \"/check\",\n handler: answer((snapshot, { query }) => {\n const filter = checkFilter(query);\n\n return filter === null ? data.check(snapshot) : data.checkPage(snapshot, filter);\n }),\n },\n { path: \"/check/groups\", handler: answer((snapshot) => data.checkGroups(snapshot)) },\n {\n path: \"/graph/file\",\n handler: answer((snapshot, { query }) => data.graphOfFile(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/graph/feature/:feature\",\n handler: answer((snapshot, { params }) => data.graphOfFeature(snapshot, params.feature)),\n },\n {\n path: \"/graph/page\",\n handler: answer((snapshot, { query }) =>\n data.graphOfPage(snapshot, one(query, \"app\"), one(query, \"page\")),\n ),\n },\n { path: \"/graph/modules\", handler: answer((snapshot) => data.graphOfModules(snapshot)) },\n // The Bird view's buttons write the approved baseline: development only, never through a share link.\n {\n method: \"POST\",\n path: \"/approve\",\n handler: async (request) => {\n if (!development || request.shared === true) {\n throw new data.GrimoirePanelError(403, \"Approving is only possible in development.\");\n }\n\n return approveFromPanel(await source.get(), request.body);\n },\n },\n {\n method: \"POST\",\n path: \"/reject\",\n handler: async (request) => {\n if (!development || request.shared === true) {\n throw new data.GrimoirePanelError(403, \"Rejecting is only possible in development.\");\n }\n\n return rejectFromPanel(await source.get(), request.body);\n },\n },\n ],\n };\n}\n\nexport default grimoireDevtoolsPanel;\n"],"mappings":";;;;;;;;;;AAyGA,SAAS,IAAI,OAAsC,MAAkC;CACnF,MAAM,QAAQ,MAAM;CAEpB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAM;AAC5C;;AAGA,eAAsB,sBACpB,SACgC;CAIhC,MAAM,cAAc,QAAQ,SAAS;CACrC,IAAI;CACJ,MAAM,oBACH,SAAS,OAAO,uBAAa,CAAC,MAAM,EAAE,2BACrC,qBAAqB,EAAE,MAAM,KAAK,CAAC,CACrC;CACF,MAAM,SAAS,qBAAqB,QAAQ,MAAM;EAChD,OAAO,QAAQ,SAAS;EACxB,MAAM,QAAQ,QAAQ;EAItB,GAAI,QAAQ,YAAY,SACpB,cACE;GAAE,SAAS;GAAa,WAAW;EAAK,IACxC,CAAC,IACH,EAAE,SAAS,QAAQ,QAAQ;EAC/B,GAAI,QAAQ,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;EAC9D,GAAI,QAAQ,oBAAoB,SAAY,CAAC,IAAI,EAAE,iBAAiB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E_PATHS } from "../paths/index.mjs";
|
|
2
2
|
import { resolveResultsFile } from "../test-results/index.mjs";
|
|
3
3
|
import { openGrimoire } from "../workspace/index.mjs";
|
|
4
|
+
import { openStoredGrimoire } from "../workspace/stored.mjs";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import { stat } from "node:fs/promises";
|
|
6
7
|
|
|
@@ -14,7 +15,8 @@ import { stat } from "node:fs/promises";
|
|
|
14
15
|
* facts (`liveFacts`, development), an edit to a file the route facts were read from reads them again from
|
|
15
16
|
* the running app on the next open, so a route edit shows without `warlock grimoire build`.
|
|
16
17
|
*
|
|
17
|
-
* - Production (`mode: "production"`):
|
|
18
|
+
* - Production (`mode: "production"`): the stored book is read when it is current (no build), otherwise the
|
|
19
|
+
* book is built in memory. A snapshot is reused until the stamp
|
|
18
20
|
* changes, with no time limit, unless `ttlMs` is set. A request that finds
|
|
19
21
|
* the stamp changed waits for the new open. `warm()` opens the book ahead
|
|
20
22
|
* of the first request.
|
|
@@ -96,7 +98,11 @@ function createSnapshotSource(root, options = {}) {
|
|
|
96
98
|
...options.testResultsFile === void 0 ? {} : { testResultsFile: options.testResultsFile }
|
|
97
99
|
};
|
|
98
100
|
let snapshot;
|
|
99
|
-
if (
|
|
101
|
+
if (options.mode === "production") try {
|
|
102
|
+
const stored = await openStoredGrimoire(root, adapter, openOptions);
|
|
103
|
+
if (stored.behind === void 0) snapshot = stored;
|
|
104
|
+
} catch {}
|
|
105
|
+
if (snapshot !== void 0) {} else if (!liveCollected || refreshRoutes) {
|
|
100
106
|
liveCollected = true;
|
|
101
107
|
refreshRoutes = false;
|
|
102
108
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-source.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/snapshot-source.ts"],"sourcesContent":["/**\n * Where the panel's routes get the snapshot: opened once with\n * `routes: \"cached\"` (a devtools request never boots the app) and kept in\n * memory. Concurrent requests share one open. A change stamp (the book\n * manifest, the agent-written folders and indexes and the files the route\n * facts were read from, a few `stat` calls and no directory walk) tells when the book changed. With live\n * facts (`liveFacts`, development), an edit to a file the route facts were read from reads them again from\n * the running app on the next open, so a route edit shows without `warlock grimoire build`.\n *\n * - Production (`mode: \"production\"`): a snapshot is reused until the stamp\n * changes, with no time limit, unless `ttlMs` is set. A request that finds\n * the stamp changed waits for the new open. `warm()` opens the book ahead\n * of the first request.\n * - Development: the snapshot is reused for a short window (2 s, or five times\n * the last open when that is longer, so a slow open on a large app is not\n * repeated on every view; written files change while an agent works). A\n * request that finds the stamp changed waits for the new open. After the\n * window, with the stamp unchanged (a file edited in place), the cached\n * snapshot is served at once and one background open refreshes it (stale\n * while revalidate).\n *\n * An open that fails keeps serving the old snapshot; its error surfaces on a\n * request only when there is no snapshot at all. The panel passes\n * `write: true` in development, so the generated book stays current and the\n * next open is incremental; with `write: false` a stored book behind the\n * sources is rebuilt in memory on every open.\n */\nimport { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport { GRIMOIRE_PATHS } from \"../paths\";\nimport { resolveResultsFile } from \"../test-results\";\nimport { openGrimoire } from \"../workspace\";\n\n/** Options of the panel's snapshot source. */\nexport type SnapshotSourceOptions = {\n /** The adapter, or a function that loads it. Default: the Warlock adapter, imported on first use. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long a snapshot is reused when the book did not change (ms).\n * Default in development: 2000, or five times as long as the last open took\n * when that is longer. Default in production: no limit (reused until the\n * book changes).\n */\n ttlMs?: number;\n /** Where the source runs. `\"production\"` keeps a snapshot until the book changes. Default: `\"development\"`. */\n mode?: \"development\" | \"production\";\n /** Let `openGrimoire` write the generated book and collected files (never agent-written files). Default `false`; the devtools panel passes `true`. */\n write?: boolean;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. The file's modified time is part\n * of the change stamp, so results written after the snapshot opened show up\n * without a restart.\n */\n testResultsFile?: string;\n /**\n * Read the route facts once when the first open finds none (`routes: \"missing\"`), so the development tab is\n * never \"missing\" without a manual `warlock grimoire build`. The adapter's booted inspect runs at most once per\n * process; a boot that fails keeps the cached answer. Default `false`. Never set it in a process that serves the app: the boot\n * pass boots every connector and re-imports the route and event modules, which registers them twice. The devtools panel\n * does not set it; use it from a separate tool process.\n */\n collectRoutes?: boolean;\n /**\n * The adapter reads the route, event and job facts from the running process (`createWarlockAdapter({ live: true })`),\n * which is cheap and boots nothing. The first open then collects them in the same pass as the book\n * (`routes: \"fresh\"`), so the tab never opens \"missing\" and the first open runs once. Safe in the process that\n * serves the app. Default `false`; the devtools panel sets it in development with the Warlock adapter.\n */\n liveFacts?: boolean;\n};\n\n/** A cached, shared snapshot of one project. */\nexport type SnapshotSource = {\n get(): Promise<GrimoireSnapshot>;\n /** Forget the cached snapshot; the next `get()` opens again. */\n invalidate(): void;\n /** Start opening the book now, so the first `get()` is fast. Failures are ignored here and surface on `get()`. */\n warm(): void;\n /** Resolves when no open is running (specs and shutdown). Never rejects. */\n idle(): Promise<void>;\n};\n\n/** Files and folders whose modified time moves when the book or an agent-written file is added, removed or regenerated. */\nconst STAMPED = [\n GRIMOIRE_PATHS.bookManifest,\n GRIMOIRE_PATHS.featuresIndex,\n GRIMOIRE_PATHS.tasksIndex,\n GRIMOIRE_PATHS.features,\n GRIMOIRE_PATHS.apps,\n GRIMOIRE_PATHS.openTasks,\n GRIMOIRE_PATHS.doneTasks,\n GRIMOIRE_PATHS.releases,\n // Settings, the approved baseline and the capture index change what the tab shows.\n GRIMOIRE_PATHS.settings,\n GRIMOIRE_PATHS.approved,\n GRIMOIRE_PATHS.baseline,\n GRIMOIRE_PATHS.captureIndex,\n];\n\n/** The modified times of `files`, joined (`0` for a missing file). */\nasync function timesOf(files: string[]): Promise<string> {\n const times = await Promise.all(\n files.map(async (file) => {\n try {\n return (await stat(file)).mtimeMs;\n } catch {\n return 0;\n }\n }),\n );\n\n return times.join(\",\");\n}\n\n/**\n * The change stamp in two parts: `book` (the book manifest, the written folders, the results file) and `routes`\n * (the project-relative files the route facts were read from, `manifest.boot.inputs`). An edit to a route input\n * ends the reuse window; with live facts the next open reads the routes again, otherwise it reports them stale.\n */\nasync function changeStamp(\n root: string,\n resultsFile: string,\n routeInputs: string[] = [],\n): Promise<{ book: string; routes: string }> {\n const [book, routes] = await Promise.all([\n timesOf([...STAMPED.map((entry) => path.join(root, ...entry.split(\"/\"))), resultsFile]),\n timesOf(routeInputs.map((file) => path.join(root, ...file.split(\"/\")))),\n ]);\n\n return { book, routes };\n}\n\nconst routeInputsOf = (snapshot: GrimoireSnapshot): string[] =>\n Object.keys(snapshot.book.manifest.boot.inputs).sort();\n\nasync function loadAdapter(option: SnapshotSourceOptions[\"adapter\"]): Promise<BookAdapter> {\n if (option === undefined) {\n const { createWarlockAdapter } = await import(\"../warlock\");\n\n return createWarlockAdapter();\n }\n\n return typeof option === \"function\" ? option() : option;\n}\n\n/** Create the source for the project at `root`. */\nexport function createSnapshotSource(\n root: string,\n options: SnapshotSourceOptions = {},\n): SnapshotSource {\n let cached: {\n snapshot: GrimoireSnapshot;\n at: number;\n stamp: { book: string; routes: string };\n took: number;\n } | null = null;\n let opening: Promise<GrimoireSnapshot> | null = null;\n\n const live = options.liveFacts === true && options.mode !== \"production\";\n let collected = options.collectRoutes !== true || options.mode === \"production\";\n let liveCollected = !live;\n // Set when a route input changed: with live facts, the next open reads the routes from the running app again.\n let refreshRoutes = false;\n const resultsFile = resolveResultsFile(root, options.testResultsFile);\n\n const keepUntilChanged = options.mode === \"production\" && options.ttlMs === undefined;\n const reuseFor = (took: number): number => options.ttlMs ?? Math.max(2000, took * 5);\n\n async function open(): Promise<GrimoireSnapshot> {\n const started = Date.now();\n const adapter = await loadAdapter(options.adapter);\n const openOptions = {\n write: options.write ?? false,\n ...(options.testResultsFile === undefined\n ? {}\n : { testResultsFile: options.testResultsFile }),\n };\n let snapshot: GrimoireSnapshot;\n\n if (!liveCollected || refreshRoutes) {\n // One pass: the book and the live route facts together, so a first open never builds twice.\n // After a routes-file edit: the dev server reloads the file on save, so the live read sees its new routes.\n liveCollected = true;\n refreshRoutes = false;\n\n try {\n snapshot = await openGrimoire(root, adapter, { routes: \"fresh\", ...openOptions });\n } catch {\n // The facts could not be read: fall back to what the book already holds.\n snapshot = await openGrimoire(root, adapter, { routes: \"cached\", ...openOptions });\n }\n } else {\n snapshot = await openGrimoire(root, adapter, { routes: \"cached\", ...openOptions });\n }\n\n if (!collected && snapshot.routes === \"missing\") {\n // Once per source: the route, event and job facts come from one boot pass, then live in the book.\n collected = true;\n\n try {\n snapshot = await openGrimoire(root, adapter, { routes: \"fresh\", ...openOptions });\n } catch {\n // The app did not boot (GR8002): keep the cached answer; the tab says the facts are missing.\n }\n }\n\n const at = Date.now();\n\n cached = {\n snapshot,\n at,\n stamp: await changeStamp(root, resultsFile, routeInputsOf(snapshot)),\n took: at - started,\n };\n\n return snapshot;\n }\n\n /** The open in flight, or a new one; concurrent callers share it. */\n function ensureOpening(): Promise<GrimoireSnapshot> {\n opening ??= open().finally(() => {\n opening = null;\n });\n\n return opening;\n }\n\n return {\n async get() {\n if (cached === null) return ensureOpening();\n\n const known = cached;\n const stamp = await changeStamp(root, resultsFile, routeInputsOf(known.snapshot));\n const routesMoved = stamp.routes !== known.stamp.routes;\n const changed = routesMoved || stamp.book !== known.stamp.book;\n\n if (routesMoved && live) refreshRoutes = true;\n\n if (changed || options.mode === \"production\") {\n if (!changed && (keepUntilChanged || Date.now() - known.at < reuseFor(known.took))) {\n return known.snapshot;\n }\n\n // A failed open keeps the old snapshot; the next request tries again.\n return ensureOpening().catch(() => known.snapshot);\n }\n\n if (Date.now() - known.at < reuseFor(known.took)) return known.snapshot;\n\n // Development, nothing known to have changed: serve the old snapshot now and refresh behind it.\n ensureOpening().catch(() => {});\n\n return known.snapshot;\n },\n invalidate() {\n cached = null;\n },\n warm() {\n if (cached === null) ensureOpening().cat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L,MAAM,MAAM;GACV,IAAI,WAAW,MAAM,OAAO,cAAc;GAE1C,MAAM,QAAQ;GACd,MAAM,QAAQ,MAAM,YAAY,MAAM,aAAa,cAAc,MAAM,QAAQ,CAAC;GAChF,MAAM,cAAc,MAAM,WAAW,MAAM,MAAM;GACjD,MAAM,UAAU,eAAe,MAAM,SAAS,MAAM,MAAM;GAE1D,IAAI,eAAe,MAAM,gBAAgB;GAEzC,IAAI,WAAW,QAAQ,SAAS,cAAc;IAC5C,IAAI,CAAC,YAAY,oBAAoB,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,IAC9E,OAAO,MAAM;IAIf,OAAO,cAAc,CAAC,CAAC,YAAY,MAAM,QAAQ;GACnD;GAEA,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,GAAG,OAAO,MAAM;GAG/D,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;GAE9B,OAAO,MAAM;EACf;EACA,aAAa;GACX,SAAS;EACX;EACA,OAAO;GACL,IAAI,WAAW,MAAM,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;EACrD;EACA,MAAM,OAAO;GACX,MAAM,SAAS,YAAY,CAAC,CAAC;EAC/B;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"snapshot-source.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/snapshot-source.ts"],"sourcesContent":["/**\n * Where the panel's routes get the snapshot: opened once with\n * `routes: \"cached\"` (a devtools request never boots the app) and kept in\n * memory. Concurrent requests share one open. A change stamp (the book\n * manifest, the agent-written folders and indexes and the files the route\n * facts were read from, a few `stat` calls and no directory walk) tells when the book changed. With live\n * facts (`liveFacts`, development), an edit to a file the route facts were read from reads them again from\n * the running app on the next open, so a route edit shows without `warlock grimoire build`.\n *\n * - Production (`mode: \"production\"`): the stored book is read when it is current (no build), otherwise the\n * book is built in memory. A snapshot is reused until the stamp\n * changes, with no time limit, unless `ttlMs` is set. A request that finds\n * the stamp changed waits for the new open. `warm()` opens the book ahead\n * of the first request.\n * - Development: the snapshot is reused for a short window (2 s, or five times\n * the last open when that is longer, so a slow open on a large app is not\n * repeated on every view; written files change while an agent works). A\n * request that finds the stamp changed waits for the new open. After the\n * window, with the stamp unchanged (a file edited in place), the cached\n * snapshot is served at once and one background open refreshes it (stale\n * while revalidate).\n *\n * An open that fails keeps serving the old snapshot; its error surfaces on a\n * request only when there is no snapshot at all. The panel passes\n * `write: true` in development, so the generated book stays current and the\n * next open is incremental; with `write: false` a stored book behind the\n * sources is rebuilt in memory on every open.\n */\nimport { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport { GRIMOIRE_PATHS } from \"../paths\";\nimport { resolveResultsFile } from \"../test-results\";\nimport { openGrimoire } from \"../workspace\";\nimport { openStoredGrimoire } from \"../workspace/stored\";\n\n/** Options of the panel's snapshot source. */\nexport type SnapshotSourceOptions = {\n /** The adapter, or a function that loads it. Default: the Warlock adapter, imported on first use. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long a snapshot is reused when the book did not change (ms).\n * Default in development: 2000, or five times as long as the last open took\n * when that is longer. Default in production: no limit (reused until the\n * book changes).\n */\n ttlMs?: number;\n /** Where the source runs. `\"production\"` keeps a snapshot until the book changes. Default: `\"development\"`. */\n mode?: \"development\" | \"production\";\n /** Let `openGrimoire` write the generated book and collected files (never agent-written files). Default `false`; the devtools panel passes `true`. */\n write?: boolean;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. The file's modified time is part\n * of the change stamp, so results written after the snapshot opened show up\n * without a restart.\n */\n testResultsFile?: string;\n /**\n * Read the route facts once when the first open finds none (`routes: \"missing\"`), so the development tab is\n * never \"missing\" without a manual `warlock grimoire build`. The adapter's booted inspect runs at most once per\n * process; a boot that fails keeps the cached answer. Default `false`. Never set it in a process that serves the app: the boot\n * pass boots every connector and re-imports the route and event modules, which registers them twice. The devtools panel\n * does not set it; use it from a separate tool process.\n */\n collectRoutes?: boolean;\n /**\n * The adapter reads the route, event and job facts from the running process (`createWarlockAdapter({ live: true })`),\n * which is cheap and boots nothing. The first open then collects them in the same pass as the book\n * (`routes: \"fresh\"`), so the tab never opens \"missing\" and the first open runs once. Safe in the process that\n * serves the app. Default `false`; the devtools panel sets it in development with the Warlock adapter.\n */\n liveFacts?: boolean;\n};\n\n/** A cached, shared snapshot of one project. */\nexport type SnapshotSource = {\n get(): Promise<GrimoireSnapshot>;\n /** Forget the cached snapshot; the next `get()` opens again. */\n invalidate(): void;\n /** Start opening the book now, so the first `get()` is fast. Failures are ignored here and surface on `get()`. */\n warm(): void;\n /** Resolves when no open is running (specs and shutdown). Never rejects. */\n idle(): Promise<void>;\n};\n\n/** Files and folders whose modified time moves when the book or an agent-written file is added, removed or regenerated. */\nconst STAMPED = [\n GRIMOIRE_PATHS.bookManifest,\n GRIMOIRE_PATHS.featuresIndex,\n GRIMOIRE_PATHS.tasksIndex,\n GRIMOIRE_PATHS.features,\n GRIMOIRE_PATHS.apps,\n GRIMOIRE_PATHS.openTasks,\n GRIMOIRE_PATHS.doneTasks,\n GRIMOIRE_PATHS.releases,\n // Settings, the approved baseline and the capture index change what the tab shows.\n GRIMOIRE_PATHS.settings,\n GRIMOIRE_PATHS.approved,\n GRIMOIRE_PATHS.baseline,\n GRIMOIRE_PATHS.captureIndex,\n];\n\n/** The modified times of `files`, joined (`0` for a missing file). */\nasync function timesOf(files: string[]): Promise<string> {\n const times = await Promise.all(\n files.map(async (file) => {\n try {\n return (await stat(file)).mtimeMs;\n } catch {\n return 0;\n }\n }),\n );\n\n return times.join(\",\");\n}\n\n/**\n * The change stamp in two parts: `book` (the book manifest, the written folders, the results file) and `routes`\n * (the project-relative files the route facts were read from, `manifest.boot.inputs`). An edit to a route input\n * ends the reuse window; with live facts the next open reads the routes again, otherwise it reports them stale.\n */\nasync function changeStamp(\n root: string,\n resultsFile: string,\n routeInputs: string[] = [],\n): Promise<{ book: string; routes: string }> {\n const [book, routes] = await Promise.all([\n timesOf([...STAMPED.map((entry) => path.join(root, ...entry.split(\"/\"))), resultsFile]),\n timesOf(routeInputs.map((file) => path.join(root, ...file.split(\"/\")))),\n ]);\n\n return { book, routes };\n}\n\nconst routeInputsOf = (snapshot: GrimoireSnapshot): string[] =>\n Object.keys(snapshot.book.manifest.boot.inputs).sort();\n\nasync function loadAdapter(option: SnapshotSourceOptions[\"adapter\"]): Promise<BookAdapter> {\n if (option === undefined) {\n const { createWarlockAdapter } = await import(\"../warlock\");\n\n return createWarlockAdapter();\n }\n\n return typeof option === \"function\" ? option() : option;\n}\n\n/** Create the source for the project at `root`. */\nexport function createSnapshotSource(\n root: string,\n options: SnapshotSourceOptions = {},\n): SnapshotSource {\n let cached: {\n snapshot: GrimoireSnapshot;\n at: number;\n stamp: { book: string; routes: string };\n took: number;\n } | null = null;\n let opening: Promise<GrimoireSnapshot> | null = null;\n\n const live = options.liveFacts === true && options.mode !== \"production\";\n let collected = options.collectRoutes !== true || options.mode === \"production\";\n let liveCollected = !live;\n // Set when a route input changed: with live facts, the next open reads the routes from the running app again.\n let refreshRoutes = false;\n const resultsFile = resolveResultsFile(root, options.testResultsFile);\n\n const keepUntilChanged = options.mode === \"production\" && options.ttlMs === undefined;\n const reuseFor = (took: number): number => options.ttlMs ?? Math.max(2000, took * 5);\n\n async function open(): Promise<GrimoireSnapshot> {\n const started = Date.now();\n const adapter = await loadAdapter(options.adapter);\n const openOptions = {\n write: options.write ?? false,\n ...(options.testResultsFile === undefined\n ? {}\n : { testResultsFile: options.testResultsFile }),\n };\n let snapshot: GrimoireSnapshot | undefined;\n\n // Production reads the stored book when it is current: no build, so the first view is fast.\n if (options.mode === \"production\") {\n try {\n const stored = await openStoredGrimoire(root, adapter, openOptions);\n\n if (stored.behind === undefined) snapshot = stored;\n } catch {\n // No book, or one from another version: build it in memory below.\n }\n }\n\n if (snapshot !== undefined) {\n // The stored book answers as it is.\n } else if (!liveCollected || refreshRoutes) {\n // One pass: the book and the live route facts together, so a first open never builds twice.\n // After a routes-file edit: the dev server reloads the file on save, so the live read sees its new routes.\n liveCollected = true;\n refreshRoutes = false;\n\n try {\n snapshot = await openGrimoire(root, adapter, { routes: \"fresh\", ...openOptions });\n } catch {\n // The facts could not be read: fall back to what the book already holds.\n snapshot = await openGrimoire(root, adapter, { routes: \"cached\", ...openOptions });\n }\n } else {\n snapshot = await openGrimoire(root, adapter, { routes: \"cached\", ...openOptions });\n }\n\n if (!collected && snapshot.routes === \"missing\") {\n // Once per source: the route, event and job facts come from one boot pass, then live in the book.\n collected = true;\n\n try {\n snapshot = await openGrimoire(root, adapter, { routes: \"fresh\", ...openOptions });\n } catch {\n // The app did not boot (GR8002): keep the cached answer; the tab says the facts are missing.\n }\n }\n\n const at = Date.now();\n\n cached = {\n snapshot,\n at,\n stamp: await changeStamp(root, resultsFile, routeInputsOf(snapshot)),\n took: at - started,\n };\n\n return snapshot;\n }\n\n /** The open in flight, or a new one; concurrent callers share it. */\n function ensureOpening(): Promise<GrimoireSnapshot> {\n opening ??= open().finally(() => {\n opening = null;\n });\n\n return opening;\n }\n\n return {\n async get() {\n if (cached === null) return ensureOpening();\n\n const known = cached;\n const stamp = await changeStamp(root, resultsFile, routeInputsOf(known.snapshot));\n const routesMoved = stamp.routes !== known.stamp.routes;\n const changed = routesMoved || stamp.book !== known.stamp.book;\n\n if (routesMoved && live) refreshRoutes = true;\n\n if (changed || options.mode === \"production\") {\n if (!changed && (keepUntilChanged || Date.now() - known.at < reuseFor(known.took))) {\n return known.snapshot;\n }\n\n // A failed open keeps the old snapshot; the next request tries again.\n return ensureOpening().catch(() => known.snapshot);\n }\n\n if (Date.now() - known.at < reuseFor(known.took)) return known.snapshot;\n\n // Development, nothing known to have changed: serve the old snapshot now and refresh behind it.\n ensureOpening().catch(() => {});\n\n return known.snapshot;\n },\n invalidate() {\n cached = null;\n },\n warm() {\n if (cached === null)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,MAAM,aAAa,cAAc,QAAQ,CAAC;GACnE,MAAM,KAAK;EACb;EAEA,OAAO;CACT;;CAGA,SAAS,gBAA2C;EAClD,YAAY,KAAK,CAAC,CAAC,cAAc;GAC/B,UAAU;EACZ,CAAC;EAED,OAAO;CACT;CAEA,OAAO;EACL,MAAM,MAAM;GACV,IAAI,WAAW,MAAM,OAAO,cAAc;GAE1C,MAAM,QAAQ;GACd,MAAM,QAAQ,MAAM,YAAY,MAAM,aAAa,cAAc,MAAM,QAAQ,CAAC;GAChF,MAAM,cAAc,MAAM,WAAW,MAAM,MAAM;GACjD,MAAM,UAAU,eAAe,MAAM,SAAS,MAAM,MAAM;GAE1D,IAAI,eAAe,MAAM,gBAAgB;GAEzC,IAAI,WAAW,QAAQ,SAAS,cAAc;IAC5C,IAAI,CAAC,YAAY,oBAAoB,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,IAC9E,OAAO,MAAM;IAIf,OAAO,cAAc,CAAC,CAAC,YAAY,MAAM,QAAQ;GACnD;GAEA,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,GAAG,OAAO,MAAM;GAG/D,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;GAE9B,OAAO,MAAM;EACf;EACA,aAAa;GACX,SAAS;EACX;EACA,OAAO;GACL,IAAI,WAAW,MAAM,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;EACrD;EACA,MAAM,OAAO;GACX,MAAM,SAAS,YAAY,CAAC,CAAC;EAC/B;CACF;AACF"}
|
package/esm/index.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import { CriterionStatus, ProofLine, ProofResult, TestOutcome, TestResultsInfo,
|
|
|
8
8
|
import { CollectedFiles, FeatureBookmap, FeaturesIndex, FileOwnership, FlowBookmap, FlowBookmapCriterion, FlowBookmapStep, Ownership, TaskSummary, TasksIndex } from "./contracts/bookmap.mjs";
|
|
9
9
|
import { ApprovedBaseline, ApprovedFlow, ApprovedProof, ApprovedShot, DriftItem, DriftType, RejectedChange, ShotCapture, ShotCaptureIndex, ShotOutcome, ShotsState, ShowsLine } from "./contracts/shots.mjs";
|
|
10
10
|
import { AppMatch, GrimoireRule, GrimoireSnapshot, OpenGrimoireOptions } from "./contracts/snapshot.mjs";
|
|
11
|
-
import { ScryAlsoChange, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchResult } from "./contracts/scry.mjs";
|
|
11
|
+
import { ScryAlsoChange, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchImpact, ScrySearchResult } from "./contracts/scry.mjs";
|
|
12
12
|
import { ChangedFile, ChangedFileStatus, CommitInfo } from "./git/index.mjs";
|
|
13
13
|
import { ApiSnapshot, GuardFileText, GuardInput, GuardReport, RemoveEntry, TaskScope } from "./contracts/guard.mjs";
|
|
14
14
|
import { GrimoireMatrix, MatrixCell, MatrixCellState, MatrixCriterionRow, MatrixFeatureRow, MatrixFlowRow } from "./contracts/matrix.mjs";
|
|
@@ -39,4 +39,4 @@ import { formatScryResult } from "./scry/format.mjs";
|
|
|
39
39
|
import { parseScryQuery } from "./scry/parse.mjs";
|
|
40
40
|
import { scry } from "./scry/query.mjs";
|
|
41
41
|
import { SCRY_STOP_WORDS } from "./scry/search.mjs";
|
|
42
|
-
export { ApiSnapshot, AppMatch, ApprovedBaseline, ApprovedFlow, ApprovedProof, ApprovedShot, BOOK_SCHEMA_VERSION, BookAdapter, BookAnnotations, type BookCheck, BookEntry, BookExport, BookFacts, BookFactsCache, BookFile, BookFileType, BookHost, BookImport, BookManifest, BookManifestFile, BookMobileApp, BookMobileScreensFile, BookModuleSummary, BookNamedThing, BookNamedType, BookPage, BookPageLink, type BookPathInput, BookRoute, BookRouteRef, BookRoutesFile, BookScreen, BookSite, BookSitePagesFile, BuildBookOptions, BuildBookResult, CASE_QUESTIONS, CODE_RULES, COLLECTED_END_MARKER, COLLECTED_START_MARKER, CaseQuestion, ChangeWord, type ChangedFile, type ChangedFileStatus, CodeRuleName, CollectedFiles, type CollectedInput, CollectedListText, type CommitInfo, CriterionId, CriterionStatus, type CriterionTestResult, DEFAULT_GRIMOIRE_SETTINGS, DEFAULT_PROTECTED_AREAS, DriftItem, DriftType, FeatureBookmap, FeatureVersion, FeaturesIndex, type FileGraph, FileOwnership, FlowBookmap, FlowBookmapCriterion, FlowBookmapStep, FlowRef, type FrontMatterField, type FrontMatterResult, type FrontMatterValue, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireCheckReport, type GrimoireCode, GrimoireCodeArea, GrimoireCodeDefinition, GrimoireError, GrimoireFinding, GrimoireFindingInput, GrimoireMatrix, GrimoireRule, GrimoireSettings, GrimoireSeverity, GrimoireSnapshot, GuardFileText, GuardInput, GuardReport, LoadedBook, Located, MatrixCell, MatrixCellState, MatrixCriterionRow, MatrixFeatureRow, MatrixFlowRow, OpenGrimoireOptions, Ownership, type ParseGrimoireResult, ProofLine, ProofResult, ProtectedArea, RejectedChange, ReleaseCollection, ReleaseEntry, RemoveEntry, RouteFreshness, SCREENSHOT_MODES, SCRY_STOP_WORDS, type ScanProofsResult, type ScanShowsResult, ScreenshotMode, ScryAlsoChange, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchResult, ShotCapture, ShotCaptureIndex, ShotOutcome, ShotsState, ShowsLine, SourceLocation, StepType, TaskScope, TaskStatus, TaskSummary, TaskType, TasksIndex, TestOutcome, TestResultsInfo, TestResultsStore, UI_CASE_QUESTIONS, UiCaseQuestion, UnmatchedProof, WriteBookResult, WriteReleaseResult, WrittenApp, WrittenBlockFile, WrittenBlockRow, WrittenCase, WrittenChangelog, WrittenChangelogEntry, WrittenChangelogSection, WrittenChangesWith, WrittenCriterion, WrittenEntryPoint, WrittenFeature, WrittenFeatureReadme, WrittenFlow, WrittenGrimoire, WrittenLayout, WrittenListLine, WrittenOrigin, WrittenPage, WrittenRelease, WrittenReleaseListed, WrittenScreenshot, WrittenSettings, WrittenStatus, WrittenStep, WrittenStoryStep, WrittenTask, WrittenVersionBrief, WrittenWho, bookEntryPath, bookEntryPaths, buildBook, buildCollectedFiles, checkBook, checkGrimoire, collectRelease, createFinding, criterionStatus, explainGrimoireCode, fileGraph, formatCheckReport, formatScryResult, grimoireCodeDocsUrl, importClosure, importerClosure, isGrimoireCode, loadBook, matchApps, openGrimoire, openStoredGrimoire, parseGrimoire, parseScryQuery, readFrontMatter, readTestResults, renderCollectedList, resolveOwnership, resolveSettings, scanProofs, scanProofsInText, scanShows, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
|
42
|
+
export { ApiSnapshot, AppMatch, ApprovedBaseline, ApprovedFlow, ApprovedProof, ApprovedShot, BOOK_SCHEMA_VERSION, BookAdapter, BookAnnotations, type BookCheck, BookEntry, BookExport, BookFacts, BookFactsCache, BookFile, BookFileType, BookHost, BookImport, BookManifest, BookManifestFile, BookMobileApp, BookMobileScreensFile, BookModuleSummary, BookNamedThing, BookNamedType, BookPage, BookPageLink, type BookPathInput, BookRoute, BookRouteRef, BookRoutesFile, BookScreen, BookSite, BookSitePagesFile, BuildBookOptions, BuildBookResult, CASE_QUESTIONS, CODE_RULES, COLLECTED_END_MARKER, COLLECTED_START_MARKER, CaseQuestion, ChangeWord, type ChangedFile, type ChangedFileStatus, CodeRuleName, CollectedFiles, type CollectedInput, CollectedListText, type CommitInfo, CriterionId, CriterionStatus, type CriterionTestResult, DEFAULT_GRIMOIRE_SETTINGS, DEFAULT_PROTECTED_AREAS, DriftItem, DriftType, FeatureBookmap, FeatureVersion, FeaturesIndex, type FileGraph, FileOwnership, FlowBookmap, FlowBookmapCriterion, FlowBookmapStep, FlowRef, type FrontMatterField, type FrontMatterResult, type FrontMatterValue, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireCheckReport, type GrimoireCode, GrimoireCodeArea, GrimoireCodeDefinition, GrimoireError, GrimoireFinding, GrimoireFindingInput, GrimoireMatrix, GrimoireRule, GrimoireSettings, GrimoireSeverity, GrimoireSnapshot, GuardFileText, GuardInput, GuardReport, LoadedBook, Located, MatrixCell, MatrixCellState, MatrixCriterionRow, MatrixFeatureRow, MatrixFlowRow, OpenGrimoireOptions, Ownership, type ParseGrimoireResult, ProofLine, ProofResult, ProtectedArea, RejectedChange, ReleaseCollection, ReleaseEntry, RemoveEntry, RouteFreshness, SCREENSHOT_MODES, SCRY_STOP_WORDS, type ScanProofsResult, type ScanShowsResult, ScreenshotMode, ScryAlsoChange, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchImpact, ScrySearchResult, ShotCapture, ShotCaptureIndex, ShotOutcome, ShotsState, ShowsLine, SourceLocation, StepType, TaskScope, TaskStatus, TaskSummary, TaskType, TasksIndex, TestOutcome, TestResultsInfo, TestResultsStore, UI_CASE_QUESTIONS, UiCaseQuestion, UnmatchedProof, WriteBookResult, WriteReleaseResult, WrittenApp, WrittenBlockFile, WrittenBlockRow, WrittenCase, WrittenChangelog, WrittenChangelogEntry, WrittenChangelogSection, WrittenChangesWith, WrittenCriterion, WrittenEntryPoint, WrittenFeature, WrittenFeatureReadme, WrittenFlow, WrittenGrimoire, WrittenLayout, WrittenListLine, WrittenOrigin, WrittenPage, WrittenRelease, WrittenReleaseListed, WrittenScreenshot, WrittenSettings, WrittenStatus, WrittenStep, WrittenStoryStep, WrittenTask, WrittenVersionBrief, WrittenWho, bookEntryPath, bookEntryPaths, buildBook, buildCollectedFiles, checkBook, checkGrimoire, collectRelease, createFinding, criterionStatus, explainGrimoireCode, fileGraph, formatCheckReport, formatScryResult, grimoireCodeDocsUrl, importClosure, importerClosure, isGrimoireCode, loadBook, matchApps, openGrimoire, openStoredGrimoire, parseGrimoire, parseScryQuery, readFrontMatter, readTestResults, renderCollectedList, resolveOwnership, resolveSettings, scanProofs, scanProofsInText, scanShows, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
|
@@ -41,7 +41,7 @@ function provingTests(snapshot, hit) {
|
|
|
41
41
|
* The files that change with the top hits, most shared first (then step, imports,
|
|
42
42
|
* imported-by, test, then path), at most ten, none of them a hit's own file.
|
|
43
43
|
* `next` is the impact command for the file of the best top hit that is not a
|
|
44
|
-
* flow (else the first step file of the top flow).
|
|
44
|
+
* flow (else the first step file of the top flow); `topFile` is that file.
|
|
45
45
|
*/
|
|
46
46
|
function alsoChangesOf(snapshot, hits) {
|
|
47
47
|
const files = new Map(snapshot.book.facts.files.map((file) => [file.file, file]));
|
|
@@ -97,7 +97,8 @@ function alsoChangesOf(snapshot, hits) {
|
|
|
97
97
|
const first = (top.find((item) => item.hit.type !== "flow") ?? top[0])?.seeds[0];
|
|
98
98
|
return {
|
|
99
99
|
alsoChanges,
|
|
100
|
-
next: first === void 0 ? void 0 : `warlock scry --impact ${first}
|
|
100
|
+
next: first === void 0 ? void 0 : `warlock scry --impact ${first}`,
|
|
101
|
+
topFile: first
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
104
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"also-changes.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/also-changes.ts"],"sourcesContent":["/**\n * The files that usually change with the top hits of a search: what the hits'\n * files import and what imports them inside the same owning feature (the same\n * module when the file has no owner), and the tests that import them or prove\n * the hits' flows. Pure: reads the snapshot only.\n */\nimport type { ScryAlsoChange, ScryHit } from \"../contracts/scry\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\n\n/** How many top hits that map to files bring files in. */\nconst TOP_HITS = 3;\n\n/** The most files listed. */\nexport const ALSO_CHANGES_LIMIT = 10;\n\nconst REASON_ORDER: ScryAlsoChange[\"reason\"][] = [\"step\", \"imports\", \"imported-by\", \"test\"];\n\nconst byText = (left: string, right: string): number => (left < right ? -1 : left > right ? 1 : 0);\n\n/** The files a hit stands for: a file, the file of an export, page or screen, a flow's step entries, a route's handler. */\nfunction filesOfHit(snapshot: GrimoireSnapshot, hit: ScryHit): string[] {\n const facts = snapshot.book.facts;\n\n switch (hit.type) {\n case \"file\":\n return [hit.id];\n case \"export\":\n return [hit.id.split(\"#\")[0] ?? hit.id];\n case \"page\":\n case \"screen\":\n case \"mail\":\n case \"job\":\n return hit.detail === null ? [] : [hit.detail];\n case \"flow\": {\n const bookmap = snapshot.collected?.flows?.[hit.id];\n\n return [...new Set((bookmap?.steps ?? []).flatMap((step) => step.entries))].sort(byText);\n }\n case \"route\": {\n const found = (facts.routes ?? []).find(\n (route) => `${route.method} ${route.path}` === hit.id,\n );\n\n return found?.handlerFile == null ? [] : [found.handlerFile];\n }\n default:\n return [];\n }\n}\n\n/** Files that prove the flow of a flow hit. */\nfunction provingTests(snapshot: GrimoireSnapshot, hit: ScryHit): string[] {\n if (hit.type !== \"flow\") return [];\n\n const bookmap = snapshot.collected?.flows?.[hit.id];\n\n return [\n ...new Set((bookmap?.criteria ?? []).flatMap((item) => item.tests.map((test) => test.file))),\n ];\n}\n\n/**\n * The files that change with the top hits, most shared first (then step, imports,\n * imported-by, test, then path), at most ten, none of them a hit's own file.\n * `next` is the impact command for the file of the best top hit that is not a\n * flow (else the first step file of the top flow).\n */\nexport function alsoChangesOf(\n snapshot: GrimoireSnapshot,\n hits: readonly ScryHit[],\n): { alsoChanges: ScryAlsoChange[]; next: string | undefined } {\n const files = new Map(snapshot.book.facts.files.map((file) => [file.file, file]));\n const owner = (file: string): string | null => snapshot.ownership?.files?.[file]?.owner ?? null;\n const sameGroup = (left: string, right: string): boolean => {\n const leftOwner = owner(left);\n\n if (leftOwner !== null) return leftOwner === owner(right);\n\n const leftFile = files.get(left);\n\n return (\n owner(right) === null &&\n leftFile !== undefined &&\n leftFile.module === files.get(right)?.module\n );\n };\n const isSpec = (file: string): boolean => files.get(file)?.type === \"spec\";\n\n const top = hits\n .map((hit) => ({ hit, seeds: filesOfHit(snapshot, hit).filter((file) => files.has(file)) }))\n .filter((item) => item.seeds.length > 0)\n .slice(0, TOP_HITS);\n // A hit's own file is already in the answer; the step files of a flow hit are not.\n const hitFiles = new Set(\n hits.filter((hit) => hit.type !== \"flow\").flatMap((hit) => filesOfHit(snapshot, hit)),\n );\n const found = new Map<string, { reason: ScryAlsoChange[\"reason\"]; via: Set<string> }>();\n const add = (file: string, reason: ScryAlsoChange[\"reason\"], via: string): void => {\n if (hitFiles.has(file)) return;\n\n const existing = found.get(file);\n\n if (existing === undefined) {\n found.set(file, { reason, via: new Set([via]) });\n\n return;\n }\n\n existing.via.add(via);\n\n if (REASON_ORDER.indexOf(reason) < REASON_ORDER.indexOf(existing.reason))\n existing.reason = reason;\n };\n\n for (const { hit, seeds } of top) {\n if (hit.type === \"flow\") {\n for (const seed of seeds) add(seed, \"step\", hit.id);\n }\n\n for (const seed of seeds) {\n const book = files.get(seed);\n\n if (book === undefined) continue;\n\n // Facts built by hand (an adapter's own, a spec's) may leave the import lists out.\n for (const entry of book.imports ?? []) {\n if (entry.file === null || isSpec(entry.file) || !files.has(entry.file)) continue;\n if (sameGroup(seed, entry.file)) add(entry.file, \"imported-by\", hit.id);\n }\n\n for (const importer of book.importedBy ?? []) {\n if (!files.has(importer)) continue;\n if (isSpec(importer)) add(importer, \"test\", hit.id);\n else if (sameGroup(seed, importer)) add(importer, \"imports\", hit.id);\n }\n }\n\n for (const test of provingTests(snapshot, hit)) add(test, \"test\", hit.id);\n }\n\n const alsoChanges = [...found]\n .map(([file, { reason, via }]) => ({ file, reason, via: [...via] }))\n .sort(\n (left, right) =>\n right.via.length - left.via.length ||\n REASON_ORDER.indexOf(left.reason) - REASON_ORDER.indexOf(right.reason) ||\n byText(left.file, right.file),\n )\n .slice(0, ALSO_CHANGES_LIMIT);\n // The file of the best hit that is a file itself (a flow hit's step files have no order of their own).\n const first = (top.find((item) => item.hit.type !== \"flow\") ?? top[0])?.seeds[0];\n\n return {
|
|
1
|
+
{"version":3,"file":"also-changes.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/also-changes.ts"],"sourcesContent":["/**\n * The files that usually change with the top hits of a search: what the hits'\n * files import and what imports them inside the same owning feature (the same\n * module when the file has no owner), and the tests that import them or prove\n * the hits' flows. Pure: reads the snapshot only.\n */\nimport type { ScryAlsoChange, ScryHit } from \"../contracts/scry\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\n\n/** How many top hits that map to files bring files in. */\nconst TOP_HITS = 3;\n\n/** The most files listed. */\nexport const ALSO_CHANGES_LIMIT = 10;\n\nconst REASON_ORDER: ScryAlsoChange[\"reason\"][] = [\"step\", \"imports\", \"imported-by\", \"test\"];\n\nconst byText = (left: string, right: string): number => (left < right ? -1 : left > right ? 1 : 0);\n\n/** The files a hit stands for: a file, the file of an export, page or screen, a flow's step entries, a route's handler. */\nfunction filesOfHit(snapshot: GrimoireSnapshot, hit: ScryHit): string[] {\n const facts = snapshot.book.facts;\n\n switch (hit.type) {\n case \"file\":\n return [hit.id];\n case \"export\":\n return [hit.id.split(\"#\")[0] ?? hit.id];\n case \"page\":\n case \"screen\":\n case \"mail\":\n case \"job\":\n return hit.detail === null ? [] : [hit.detail];\n case \"flow\": {\n const bookmap = snapshot.collected?.flows?.[hit.id];\n\n return [...new Set((bookmap?.steps ?? []).flatMap((step) => step.entries))].sort(byText);\n }\n case \"route\": {\n const found = (facts.routes ?? []).find(\n (route) => `${route.method} ${route.path}` === hit.id,\n );\n\n return found?.handlerFile == null ? [] : [found.handlerFile];\n }\n default:\n return [];\n }\n}\n\n/** Files that prove the flow of a flow hit. */\nfunction provingTests(snapshot: GrimoireSnapshot, hit: ScryHit): string[] {\n if (hit.type !== \"flow\") return [];\n\n const bookmap = snapshot.collected?.flows?.[hit.id];\n\n return [\n ...new Set((bookmap?.criteria ?? []).flatMap((item) => item.tests.map((test) => test.file))),\n ];\n}\n\n/**\n * The files that change with the top hits, most shared first (then step, imports,\n * imported-by, test, then path), at most ten, none of them a hit's own file.\n * `next` is the impact command for the file of the best top hit that is not a\n * flow (else the first step file of the top flow); `topFile` is that file.\n */\nexport function alsoChangesOf(\n snapshot: GrimoireSnapshot,\n hits: readonly ScryHit[],\n): { alsoChanges: ScryAlsoChange[]; next: string | undefined; topFile: string | undefined } {\n const files = new Map(snapshot.book.facts.files.map((file) => [file.file, file]));\n const owner = (file: string): string | null => snapshot.ownership?.files?.[file]?.owner ?? null;\n const sameGroup = (left: string, right: string): boolean => {\n const leftOwner = owner(left);\n\n if (leftOwner !== null) return leftOwner === owner(right);\n\n const leftFile = files.get(left);\n\n return (\n owner(right) === null &&\n leftFile !== undefined &&\n leftFile.module === files.get(right)?.module\n );\n };\n const isSpec = (file: string): boolean => files.get(file)?.type === \"spec\";\n\n const top = hits\n .map((hit) => ({ hit, seeds: filesOfHit(snapshot, hit).filter((file) => files.has(file)) }))\n .filter((item) => item.seeds.length > 0)\n .slice(0, TOP_HITS);\n // A hit's own file is already in the answer; the step files of a flow hit are not.\n const hitFiles = new Set(\n hits.filter((hit) => hit.type !== \"flow\").flatMap((hit) => filesOfHit(snapshot, hit)),\n );\n const found = new Map<string, { reason: ScryAlsoChange[\"reason\"]; via: Set<string> }>();\n const add = (file: string, reason: ScryAlsoChange[\"reason\"], via: string): void => {\n if (hitFiles.has(file)) return;\n\n const existing = found.get(file);\n\n if (existing === undefined) {\n found.set(file, { reason, via: new Set([via]) });\n\n return;\n }\n\n existing.via.add(via);\n\n if (REASON_ORDER.indexOf(reason) < REASON_ORDER.indexOf(existing.reason))\n existing.reason = reason;\n };\n\n for (const { hit, seeds } of top) {\n if (hit.type === \"flow\") {\n for (const seed of seeds) add(seed, \"step\", hit.id);\n }\n\n for (const seed of seeds) {\n const book = files.get(seed);\n\n if (book === undefined) continue;\n\n // Facts built by hand (an adapter's own, a spec's) may leave the import lists out.\n for (const entry of book.imports ?? []) {\n if (entry.file === null || isSpec(entry.file) || !files.has(entry.file)) continue;\n if (sameGroup(seed, entry.file)) add(entry.file, \"imported-by\", hit.id);\n }\n\n for (const importer of book.importedBy ?? []) {\n if (!files.has(importer)) continue;\n if (isSpec(importer)) add(importer, \"test\", hit.id);\n else if (sameGroup(seed, importer)) add(importer, \"imports\", hit.id);\n }\n }\n\n for (const test of provingTests(snapshot, hit)) add(test, \"test\", hit.id);\n }\n\n const alsoChanges = [...found]\n .map(([file, { reason, via }]) => ({ file, reason, via: [...via] }))\n .sort(\n (left, right) =>\n right.via.length - left.via.length ||\n REASON_ORDER.indexOf(left.reason) - REASON_ORDER.indexOf(right.reason) ||\n byText(left.file, right.file),\n )\n .slice(0, ALSO_CHANGES_LIMIT);\n // The file of the best hit that is a file itself (a flow hit's step files have no order of their own).\n const first = (top.find((item) => item.hit.type !== \"flow\") ?? top[0])?.seeds[0];\n\n return {\n alsoChanges,\n next: first === undefined ? undefined : `warlock scry --impact ${first}`,\n topFile: first,\n };\n}\n"],"mappings":";;AAUA,MAAM,WAAW;;AAGjB,MAAa,qBAAqB;AAElC,MAAM,eAA2C;CAAC;CAAQ;CAAW;CAAe;AAAM;AAE1F,MAAM,UAAU,MAAc,UAA2B,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;;AAGhG,SAAS,WAAW,UAA4B,KAAwB;CACtE,MAAM,QAAQ,SAAS,KAAK;CAE5B,QAAQ,IAAI,MAAZ;EACE,K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CAAC,MAAM,IAAI,MAAM,IAAI,GAAG;IACzE,IAAI,UAAU,MAAM,MAAM,IAAI,GAAG,IAAI,MAAM,MAAM,eAAe,IAAI,EAAE;GACxE;GAEA,KAAK,MAAM,YAAY,KAAK,cAAc,CAAC,GAAG;IAC5C,IAAI,CAAC,MAAM,IAAI,QAAQ,GAAG;IAC1B,IAAI,OAAO,QAAQ,GAAG,IAAI,UAAU,QAAQ,IAAI,EAAE;SAC7C,IAAI,UAAU,MAAM,QAAQ,GAAG,IAAI,UAAU,WAAW,IAAI,EAAE;GACrE;EACF;EAEA,KAAK,MAAM,QAAQ,aAAa,UAAU,GAAG,GAAG,IAAI,MAAM,QAAQ,IAAI,EAAE;CAC1E;CAEA,MAAM,cAAc,CAAC,GAAG,KAAK,CAAC,CAC3B,KAAK,CAAC,MAAM,EAAE,QAAQ,YAAY;EAAE;EAAM;EAAQ,KAAK,CAAC,GAAG,GAAG;CAAE,EAAE,CAAC,CACnE,MACE,MAAM,UACL,MAAM,IAAI,SAAS,KAAK,IAAI,UAC5B,aAAa,QAAQ,KAAK,MAAM,IAAI,aAAa,QAAQ,MAAM,MAAM,KACrE,OAAO,KAAK,MAAM,MAAM,IAAI,CAChC,CAAC,CACA,MAAM,KAAqB;CAE9B,MAAM,SAAS,IAAI,MAAM,SAAS,KAAK,IAAI,SAAS,MAAM,KAAK,IAAI,GAAE,EAAG,MAAM;CAE9E,OAAO;EACL;EACA,MAAM,UAAU,SAAY,SAAY,yBAAyB;EACjE,SAAS;CACX;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/format.ts"],"mappings":";;;YAmCY;;EAEV;;;;;;
|
|
1
|
+
{"version":3,"file":"format.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/format.ts"],"mappings":";;;YAmCY;;EAEV;;;;;;wBAgdc,iBAAiB,QAAQ,YAAY,UAAS"}
|
package/esm/scry/format.mjs
CHANGED
|
@@ -215,6 +215,18 @@ function alsoChangesLines(result) {
|
|
|
215
215
|
const width = Math.min(60, Math.max(...list.map((change) => change.file.length)));
|
|
216
216
|
return ["changes with the top hits:", ...list.map((change) => ` ${change.file.padEnd(width)} ${alsoReason(change)}`)];
|
|
217
217
|
}
|
|
218
|
+
/** The top file's impact, folded into the search answer (what reaches it), or nothing when it adds nothing. */
|
|
219
|
+
function impactLines(result) {
|
|
220
|
+
const impact = result.impact;
|
|
221
|
+
if (impact === void 0) return [];
|
|
222
|
+
const rows = [];
|
|
223
|
+
if (impact.files.length > 0) rows.push(["files", impact.files.join(", ") + (impact.more > 0 ? `, +${impact.more} more` : "")]);
|
|
224
|
+
if (impact.routes.length > 0) rows.push(["routes", impact.routes.join(", ")]);
|
|
225
|
+
if (impact.flows.length > 0) rows.push(["flows", impact.flows.join(", ")]);
|
|
226
|
+
if (impact.tests.length > 0) rows.push(["tests", impact.tests.join(", ")]);
|
|
227
|
+
if (rows.length === 0) return [];
|
|
228
|
+
return [`impact of ${impact.file}:`, ...rows.map(([label, text]) => ` ${label.padEnd(6)} ${text}`)];
|
|
229
|
+
}
|
|
218
230
|
/** Hits in score order, one line each: `score type id detail (app) [matched]`. */
|
|
219
231
|
function formatSearch(result) {
|
|
220
232
|
if (result.hits.length === 0) return [`no match for ${JSON.stringify(result.text)}`, ...notes(result)];
|
|
@@ -229,7 +241,8 @@ function formatSearch(result) {
|
|
|
229
241
|
...truncatedLine(result),
|
|
230
242
|
...alsoChangesLines(result),
|
|
231
243
|
...result.weak === true ? ["weak match: no hit holds most of the request's words; use grep for literal text"] : [],
|
|
232
|
-
...result
|
|
244
|
+
...impactLines(result),
|
|
245
|
+
...result.next === void 0 || result.impact !== void 0 ? [] : [`next: ${result.next}`],
|
|
233
246
|
...notes(result)
|
|
234
247
|
];
|
|
235
248
|
}
|
package/esm/scry/format.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/format.ts"],"sourcesContent":["/**\n * The compact text of a scry answer: a title line, then `label value` lines\n * with the labels in one column. Empty sections are left out.\n */\nimport type { FlowBookmapCriterion, FlowBookmapStep } from \"../contracts/bookmap\";\nimport type { CriterionStatus } from \"../contracts/test-results\";\nimport type { GrimoireFinding } from \"../contracts/findings\";\nimport type {\n ScryFeatureResult,\n ScryFileResult,\n ScryFlowResult,\n ScryImpactResult,\n ScryResult,\n ScryRouteResult,\n ScrySearchResult,\n} from \"../contracts/scry\";\nimport type { WrittenChangelogEntry } from \"../contracts/written\";\n\nconst LABEL = 10;\n\n/** `label` padded to the column, then the first value; more values go on indented lines. */\nfunction section(label: string, values: readonly string[], width = LABEL): string[] {\n if (values.length === 0) return [];\n\n const pad = \" \".repeat(Math.max(width, label.length + 1));\n\n return values.map((value, index) =>\n index === 0 ? `${label.padEnd(pad.length)}${value}` : `${pad}${value}`,\n );\n}\n\n/** Longest list a text section prints before it says how many more there are. */\nconst SECTION_CAP = 20;\n\n/** What the text formatters may be told. */\nexport type FormatScryOptions = {\n /** Print every line of every section, not the first 20. */\n all?: boolean;\n};\n\n/** A section whose heading carries the count (`routes (3)`) and whose list stops at the cap. */\nfunction countedSection(\n label: string,\n values: readonly string[],\n options: FormatScryOptions,\n width: number,\n): string[] {\n const shown = options.all === true ? values : values.slice(0, SECTION_CAP);\n const lines = section(`${label} (${values.length})`, shown, width);\n\n if (shown.length < values.length) {\n lines.push(\n `${\" \".repeat(Math.max(width, label.length + 1))}… and ${values.length - shown.length} more (--all lists every one)`,\n );\n }\n\n return lines;\n}\n\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** Cut text at a word so it fits `max` characters, ending with ` …`. */\nfunction shorten(text: string, max: number): string {\n if (text.length <= max) return text;\n\n const words = text.split(\" \");\n let kept = \"\";\n\n for (const word of words) {\n const next = kept === \"\" ? word : `${kept} ${word}`;\n\n if (next.length + 2 > max) break;\n\n kept = next;\n }\n\n return `${kept === \"\" ? text.slice(0, max - 2) : kept} …`;\n}\n\nfunction notes(result: ScryResult): string[] {\n return section(\"note\", result.notes);\n}\n\nfunction countsLine(findings: readonly GrimoireFinding[]): string {\n const errors = findings.filter(\n (finding) => !finding.expected && finding.severity === \"error\",\n ).length;\n const warnings = findings.filter(\n (finding) => !finding.expected && finding.severity === \"warning\",\n ).length;\n const expected = findings.filter((finding) => finding.expected).length;\n\n return `${plural(errors, \"error\")}, ${plural(warnings, \"warning\")}, ${expected} expected`;\n}\n\nfunction releaseOf(entry: WrittenChangelogEntry): string {\n return entry.release === null ? \"unreleased\" : `${entry.release}, ${entry.date ?? \"no date\"}`;\n}\n\nfunction formatFile(result: ScryFileResult): string[] {\n const entry = result.entry;\n const feature =\n entry.feature === null && entry.borrowedBy.length === 0\n ? []\n : [\n `${entry.feature ?? \"none\"}${entry.borrowedBy.length > 0 ? ` (borrowed by: ${entry.borrowedBy.join(\", \")})` : \"\"}`,\n ];\n const exportWidth = Math.max(0, ...entry.exports.map((item) => item.name.length));\n\n return [\n `${entry.file} ${entry.type} ${plural(entry.lines, \"line\")}`,\n ...section(\"about\", entry.about === null ? [] : [entry.about]),\n ...section(\"feature\", feature),\n ...section(\"flows\", entry.flows),\n ...section(\n \"exports\",\n entry.exports.map((item) =>\n item.about === null ? item.name : `${item.name.padEnd(exportWidth)} ${item.about}`,\n ),\n ),\n ...section(\"packages\", entry.packages.length > 0 ? [entry.packages.join(\" \")] : []),\n ...section(\"imports\", entry.imports),\n ...section(\"used by\", entry.importedBy),\n ...section(\n \"routes\",\n entry.routes.map(\n (route) =>\n `${route.method} ${route.path}${route.via === \"handles\" ? \" (handles)\" : \" (registers)\"}`,\n ),\n ),\n ...section(\n \"pages\",\n entry.pages.map((page) => `${page.site} ${page.route} (${page.via})`),\n ),\n ...section(\n \"screens\",\n entry.screens.map((screen) => `${screen.app} ${screen.route} (${screen.via})`),\n ),\n ...section(\"entry\", result.bookEntry === null ? [] : [result.bookEntry]),\n ...notes(result),\n ];\n}\n\nfunction formatImpact(result: ScryImpactResult, options: FormatScryOptions): string[] {\n const width = 14;\n\n return [\n `impact of ${result.file}`,\n `${\"importers\".padEnd(width)}${result.importers.direct.length} direct, ${result.importers.all.length} in all`,\n ...countedSection(\n \"routes\",\n result.routes.map((route) => `${route.method} ${route.path}`),\n options,\n width,\n ),\n ...countedSection(\n \"pages\",\n result.pages.map((page) => `${page.app} ${page.route}`),\n options,\n width,\n ),\n ...countedSection(\"flows\", result.flows, options, width),\n ...countedSection(\n \"features\",\n result.features.map((feature) => `${feature.id} (${feature.via})`),\n options,\n width,\n ),\n ...countedSection(\"tests\", result.tests, options, width),\n ...notes(result),\n ];\n}\n\nfunction formatRoute(result: ScryRouteResult): string[] {\n const route = result.route;\n const width = 12;\n\n if (route === null) {\n const first = result.pages[0];\n\n return [\n first === undefined ? \"page\" : `GET ${first.route} (${first.type})`,\n ...section(\n \"pages\",\n result.pages.map((page) => `${page.app} ${page.route} ${page.file}`),\n width,\n ),\n ...section(\n \"setup\",\n result.pages.flatMap((page) => (page.setupFile === null ? [] : [page.setupFile])),\n width,\n ),\n ...section(\"layouts\", [...new Set(result.pages.flatMap((page) => page.layouts))], width),\n ...section(\"files\", result.files, width),\n ...notes(result),\n ];\n }\n\n const auth = route.auth.required\n ? `required (${route.auth.userTypes.length > 0 ? route.auth.userTypes.join(\", \") : \"any user\"})`\n : \"none\";\n\n return [\n `${route.method} ${route.path}${route.name === null ? \"\" : ` ${route.name}`}`,\n ...section(\n \"handler\",\n [`${route.handler}${route.handlerFile === null ? \"\" : ` ${route.handlerFile}`}`],\n width,\n ),\n ...section(\"registered\", route.sourceFile === null ? [] : [route.sourceFile], width),\n ...section(\n \"middleware\",\n route.middleware.length > 0 ? [route.middleware.join(\" \")] : [],\n width,\n ),\n ...section(\"auth\", [auth], width),\n ...section(\"description\", route.description === null ? [] : [route.description], width),\n ...section(\n \"page\",\n result.page === null ? [] : [`${result.page.site} ${result.page.route} ${result.page.file}`],\n width,\n ),\n ...section(\"files\", result.files, width),\n ...section(\n \"steps\",\n result.steps.map((step) => `${step.flow} step ${step.index}`),\n width,\n ),\n ...notes(result),\n ];\n}\n\nfunction changeLine(entry: WrittenChangelogEntry): string {\n const text = `${entry.flow === null ? \"\" : `${entry.flow}: `}${entry.text}`;\n\n return `${entry.version.value} ${entry.word} ${shorten(text, 60)} (${releaseOf(entry)})`;\n}\n\nfunction formatFeature(result: ScryFeatureResult): string[] {\n const readme = result.readme;\n const bookmap = result.bookmap;\n const idWidth = Math.max(0, ...result.flows.map((flow) => flow.id.length));\n const statusWidth = Math.max(0, ...result.flows.map((flow) => flow.status.length));\n const pages = Object.entries(bookmap.pages)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n .flatMap(([app, list]) => list.map((page) => `${app} ${page.route}`));\n const apps = readme.apps.map((app) => app.value);\n\n return [\n [\n readme.id.value,\n readme.title.value,\n `${readme.status.value} ${readme.version.value}`,\n `updated ${readme.updated.value}`,\n ...(apps.length > 0 ? [`apps ${apps.join(\", \")}`] : []),\n ].join(\" \"),\n ...section(\n \"flows\",\n result.flows.map(\n (flow) =>\n `${flow.id.padEnd(idWidth)} ${flow.status.padEnd(statusWidth)} since ${flow.since}`,\n ),\n ),\n ...section(\"own\", [\n `${plural(bookmap.own.length, \"file\")} (unreached: ${bookmap.unreached.length === 0 ? \"none\" : bookmap.unreached.length})`,\n ]),\n ...section(\"unreached\", bookmap.unreached),\n ...section(\n \"borrows\",\n bookmap.borrowed.map((item) => item.file),\n ),\n ...section(\n \"routes\",\n bookmap.routes.length > 0\n ? [bookmap.routes.map((route) => `${route.method} ${route.path}`).join(\" \")]\n : [],\n ),\n ...section(\"pages\", pages.length > 0 ? [pages.join(\" \")] : []),\n ...section(\"changes\", result.changes.map(changeLine)),\n ...section(\n \"tasks\",\n result.tasks.map((task) => `${task.id} ${task.status} ${task.title}`),\n ),\n ...section(\"check\", [countsLine(result.findings)]),\n ...notes(result),\n ];\n}\n\nconst STATUS_TEXT: Record<CriterionStatus, string> = {\n pass: \"pass\",\n fail: \"fail\",\n stale: \"stale\",\n \"not-run\": \"not run\",\n \"no-test\": \"no test\",\n};\n\n/** ` (+12 reachable, 3 type-only)`: what a step reaches beyond its entry file; empty when nothing. */\nfunction reachNote(step: FlowBookmapStep): string {\n const parts = [\n ...(step.files.length > 1 ? [`+${step.files.length - 1} reachable`] : []),\n ...(step.typeOnlyFiles.length > 0 ? [`${step.typeOnlyFiles.length} type-only`] : []),\n ];\n\n return parts.length === 0 ? \"\" : ` (${parts.join(\", \")})`;\n}\n\nfunction stepLines(steps: readonly FlowBookmapStep[]): string[] {\n const typeWidth = Math.max(0, ...steps.map((step) => step.type.length));\n const targetWidth = Math.max(0, ...steps.map((step) => step.target.length));\n\n return steps.map((step) => {\n const where =\n step.found === false\n ? \"not found\"\n : step.entry === null\n ? step.found === null && step.type === \"route\"\n ? \"no route facts\"\n : \"—\"\n : `${step.entry}${reachNote(step)}`;\n\n return `${step.index}. ${step.type.padEnd(typeWidth)} ${step.target.padEnd(targetWidth)} ${where}`;\n });\n}\n\nfunction criterionLines(criteria: readonly FlowBookmapCriterion[]): string[] {\n const labels = criteria.map(\n (criterion) => `${criterion.id}${criterion.app === null ? \"\" : ` [${criterion.app}]`}`,\n );\n const labelWidth = Math.max(0, ...labels.map((label) => label.length));\n const texts = criteria.map((criterion) => shorten(criterion.text, 36));\n const textWidth = Math.max(0, ...texts.map((text) => text.length));\n\n return criteria.map((criterion, index) => {\n const test = criterion.tests[0];\n const where =\n test === undefined\n ? \"\"\n : `${test.file}:${test.line}${criterion.tests.length > 1 ? ` (+${criterion.tests.length - 1})` : \"\"}`;\n const line = `${(labels[index] ?? \"\").padEnd(labelWidth)} ${STATUS_TEXT[criterion.status].padEnd(7)} ${\n where === \"\" ? (texts[index] ?? \"\") : `${(texts[index] ?? \"\").padEnd(textWidth)} ${where}`\n }`;\n\n return line.trimEnd();\n });\n}\n\nfunction formatFlow(result: ScryFlowResult): string[] {\n const flow = result.flow;\n const shown = result.bookmap.shownBy.map((item) => `${item.app} ${item.id}: ${item.block}`);\n\n return [\n [\n flow.ref,\n ...(flow.heading === null ? [] : [flow.heading.value]),\n `${flow.status.value} since ${flow.since.value}`,\n `who ${flow.who.value}`,\n ].join(\" \"),\n ...(flow.summary === null ? [] : [flow.summary]),\n ...stepLines(result.bookmap.steps),\n ...section(\n \"differs\",\n flow.differs.map((line) => `${line.name}: ${line.text}`),\n ),\n ...section(\n \"not handled\",\n flow.notHandled.map((line) => `${line.name}: ${line.text}`),\n 12,\n ),\n ...section(\n \"unknown\",\n flow.unknowns.map((item) => item.text.replace(/^Unknown:\\s*/, \"\")),\n ),\n ...criterionLines(result.bookmap.criteria),\n ...section(\"shown on\", shown.length > 0 ? [shown.join(\" \")] : []),\n ...section(\n \"history\",\n result.history.length > 0\n ? [\n result.history\n .map((entry) => `${entry.version.value} ${entry.word} (${releaseOf(entry)})`)\n .join(\" \"),\n ]\n : [],\n ),\n ...section(\"check\", [countsLine(result.findings)]),\n ...notes(result),\n ];\n}\n\n/** One line telling what the limit cut, per type, or nothing when every match is listed. */\nfunction truncatedLine(result: ScrySearchResult): string[] {\n const total = Object.values(result.counts).reduce((sum, count) => sum + (count ?? 0), 0);\n\n if (total <= result.hits.length) return [];\n\n const parts = Object.entries(result.counts).map(([type, count]) => `${count} ${type}`);\n\n return [\n `showing ${result.hits.length} of ${total} (${parts.join(\", \")}); raise --limit for more`,\n ];\n}\n\n/** A score for print: one decimal, or none from 100 up. */\nfunction scoreText(score: number): string {\n return score >= 100 ? score.toFixed(0) : score.toFixed(1);\n}\n\n/** How a file that changes with the top hits relates to them, in a few words. */\nfunction alsoReason(change: NonNullable<ScrySearchResult[\"alsoChanges\"]>[number]): string {\n const name = (id: string): string => id.split(/[\\s#]/)[0]?.split(\"/\").pop() ?? id;\n const first = name(change.via[0] ?? \"\");\n const more = change.via.length > 1 ? ` +${change.via.length - 1}` : \"\";\n\n switch (change.reason) {\n case \"imports\":\n return `imports ${first}${more}`;\n case \"imported-by\":\n return `imported by ${first}${more}`;\n case \"step\":\n return `step of ${change.via[0] ?? \"\"}${more}`;\n case \"test\":\n return \"test\";\n }\n}\n\n/** The `changes with the top hits:` block, at most 10 files (the answer's own cap), or nothing. */\nfunction alsoChangesLines(result: ScrySearchResult): string[] {\n const list = result.alsoChanges ?? [];\n\n if (list.length === 0) return [];\n\n const width = Math.min(60, Math.max(...list.map((change) => change.file.length)));\n\n return [\n \"changes with the top hits:\",\n ...list.map((change) => ` ${change.file.padEnd(width)} ${alsoReason(change)}`),\n ];\n}\n\n/** Hits in score order, one line each: `score type id detail (app) [matched]`. */\nfunction formatSearch(result: ScrySearchResult): string[] {\n if (result.hits.length === 0)\n return [`no match for ${JSON.stringify(result.text)}`, ...notes(result)];\n\n const scoreWidth = Math.max(...result.hits.map((hit) => scoreText(hit.score).length));\n const idWidth = Math.min(32, Math.max(0, ...result.hits.map((hit) => hit.id.length)));\n\n return [\n ...result.hits.map((hit) => {\n const head = `${scoreText(hit.score).padStart(scoreWidth)} ${hit.type.padEnd(9)}`;\n // Page, screen and block ids start with the app; a file's app is not in its path.\n const app = hit.app !== undefined && hit.type === \"file\" ? ` (${hit.app})` : \"\";\n const line =\n hit.detail === null\n ? `${head}${hit.id}${app}`\n : `${head}${hit.id.padEnd(idWidth)} ${hit.detail}${app}`;\n\n return line.trimEnd() + (hit.matched === undefined ? \"\" : ` [${hit.matched}]`);\n }),\n ...truncatedLine(result),\n ...alsoChangesLines(result),\n ...(result.weak === true\n ? [\"weak match: no hit holds most of the request's words; use grep for literal text\"]\n : []),\n ...(result.next === undefined ? [] : [`next: ${result.next}`]),\n ...notes(result),\n ];\n}\n\n/**\n * The compact text of a result (formats in the commands guide). Long lists in an\n * impact answer stop after 20 lines with a count; `options.all` prints them all.\n */\nexport function formatScryResult(result: ScryResult, options: FormatScryOptions = {}): string[] {\n switch (result.type) {\n case \"file\":\n return formatFile(result);\n case \"impact\":\n return formatImpact(result, options);\n case \"route\":\n return formatRoute(result);\n case \"feature\":\n return formatFeature(result);\n case \"flow\":\n return formatFlow(result);\n case \"search\":\n return formatSearch(result);\n }\n}\n"],"mappings":";AAkBA,MAAM,QAAQ;;AAGd,SAAS,QAAQ,OAAe,QAA2B,QAAQ,OAAiB;CAClF,IAAI,OAAO,WAAW,GAAG,OAAO,CAAC;CAEjC,MAAM,MAAM,IAAI,OAAO,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;CAExD,OAAO,OAAO,KAAK,OAAO,UACxB,UAAU,IAAI,GAAG,MAAM,OAAO,IAAI,MAAM,IAAI,UAAU,GAAG,MAAM,OACjE;AACF;;AAGA,MAAM,cAAc;;AASpB,SAAS,eACP,OACA,QACA,SACA,OACU;CACV,MAAM,QAAQ,QAAQ,QAAQ,OAAO,SAAS,OAAO,MAAM,GAAG,WAAW;CACzE,MAAM,QAAQ,QAAQ,GAAG,MAAM,IAAI,OAAO,OAAO,IAAI,OAAO,KAAK;CAEjE,IAAI,MAAM,SAAS,OAAO,QACxB,MAAM,KACJ,GAAG,IAAI,OAAO,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC,EAAE,QAAQ,OAAO,SAAS,MAAM,OAAO,8BACxF;CAGF,OAAO;AACT;AAEA,MAAM,UAAU,OAAe,SAAyB,GAAG,MAAM,GAAG,OAAO,UAAU,IAAI,KAAK;;AAG9F,SAAS,QAAQ,MAAc,KAAqB;CAClD,IAAI,KAAK,UAAU,KAAK,OAAO;CAE/B,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,IAAI,OAAO;CAEX,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,OAAO,SAAS,KAAK,OAAO,GAAG,KAAK,GAAG;EAE7C,IAAI,KAAK,SAAS,IAAI,KAAK;EAE3B,OAAO;CACT;CAEA,OAAO,GAAG,SAAS,KAAK,KAAK,MAAM,GAAG,MAAM,CAAC,IAAI,KAAK;AACxD;AAEA,SAAS,M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ACrC,KAAK,SACH,OAAO,YAAY,MAAM;EAC3B,KAAK,WACH,OAAO,cAAc,MAAM;EAC7B,KAAK,QACH,OAAO,WAAW,MAAM;EAC1B,KAAK,UACH,OAAO,aAAa,MAAM;CAC9B;AACF"}
|
|
1
|
+
{"version":3,"file":"format.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/format.ts"],"sourcesContent":["/**\n * The compact text of a scry answer: a title line, then `label value` lines\n * with the labels in one column. Empty sections are left out.\n */\nimport type { FlowBookmapCriterion, FlowBookmapStep } from \"../contracts/bookmap\";\nimport type { CriterionStatus } from \"../contracts/test-results\";\nimport type { GrimoireFinding } from \"../contracts/findings\";\nimport type {\n ScryFeatureResult,\n ScryFileResult,\n ScryFlowResult,\n ScryImpactResult,\n ScryResult,\n ScryRouteResult,\n ScrySearchResult,\n} from \"../contracts/scry\";\nimport type { WrittenChangelogEntry } from \"../contracts/written\";\n\nconst LABEL = 10;\n\n/** `label` padded to the column, then the first value; more values go on indented lines. */\nfunction section(label: string, values: readonly string[], width = LABEL): string[] {\n if (values.length === 0) return [];\n\n const pad = \" \".repeat(Math.max(width, label.length + 1));\n\n return values.map((value, index) =>\n index === 0 ? `${label.padEnd(pad.length)}${value}` : `${pad}${value}`,\n );\n}\n\n/** Longest list a text section prints before it says how many more there are. */\nconst SECTION_CAP = 20;\n\n/** What the text formatters may be told. */\nexport type FormatScryOptions = {\n /** Print every line of every section, not the first 20. */\n all?: boolean;\n};\n\n/** A section whose heading carries the count (`routes (3)`) and whose list stops at the cap. */\nfunction countedSection(\n label: string,\n values: readonly string[],\n options: FormatScryOptions,\n width: number,\n): string[] {\n const shown = options.all === true ? values : values.slice(0, SECTION_CAP);\n const lines = section(`${label} (${values.length})`, shown, width);\n\n if (shown.length < values.length) {\n lines.push(\n `${\" \".repeat(Math.max(width, label.length + 1))}… and ${values.length - shown.length} more (--all lists every one)`,\n );\n }\n\n return lines;\n}\n\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** Cut text at a word so it fits `max` characters, ending with ` …`. */\nfunction shorten(text: string, max: number): string {\n if (text.length <= max) return text;\n\n const words = text.split(\" \");\n let kept = \"\";\n\n for (const word of words) {\n const next = kept === \"\" ? word : `${kept} ${word}`;\n\n if (next.length + 2 > max) break;\n\n kept = next;\n }\n\n return `${kept === \"\" ? text.slice(0, max - 2) : kept} …`;\n}\n\nfunction notes(result: ScryResult): string[] {\n return section(\"note\", result.notes);\n}\n\nfunction countsLine(findings: readonly GrimoireFinding[]): string {\n const errors = findings.filter(\n (finding) => !finding.expected && finding.severity === \"error\",\n ).length;\n const warnings = findings.filter(\n (finding) => !finding.expected && finding.severity === \"warning\",\n ).length;\n const expected = findings.filter((finding) => finding.expected).length;\n\n return `${plural(errors, \"error\")}, ${plural(warnings, \"warning\")}, ${expected} expected`;\n}\n\nfunction releaseOf(entry: WrittenChangelogEntry): string {\n return entry.release === null ? \"unreleased\" : `${entry.release}, ${entry.date ?? \"no date\"}`;\n}\n\nfunction formatFile(result: ScryFileResult): string[] {\n const entry = result.entry;\n const feature =\n entry.feature === null && entry.borrowedBy.length === 0\n ? []\n : [\n `${entry.feature ?? \"none\"}${entry.borrowedBy.length > 0 ? ` (borrowed by: ${entry.borrowedBy.join(\", \")})` : \"\"}`,\n ];\n const exportWidth = Math.max(0, ...entry.exports.map((item) => item.name.length));\n\n return [\n `${entry.file} ${entry.type} ${plural(entry.lines, \"line\")}`,\n ...section(\"about\", entry.about === null ? [] : [entry.about]),\n ...section(\"feature\", feature),\n ...section(\"flows\", entry.flows),\n ...section(\n \"exports\",\n entry.exports.map((item) =>\n item.about === null ? item.name : `${item.name.padEnd(exportWidth)} ${item.about}`,\n ),\n ),\n ...section(\"packages\", entry.packages.length > 0 ? [entry.packages.join(\" \")] : []),\n ...section(\"imports\", entry.imports),\n ...section(\"used by\", entry.importedBy),\n ...section(\n \"routes\",\n entry.routes.map(\n (route) =>\n `${route.method} ${route.path}${route.via === \"handles\" ? \" (handles)\" : \" (registers)\"}`,\n ),\n ),\n ...section(\n \"pages\",\n entry.pages.map((page) => `${page.site} ${page.route} (${page.via})`),\n ),\n ...section(\n \"screens\",\n entry.screens.map((screen) => `${screen.app} ${screen.route} (${screen.via})`),\n ),\n ...section(\"entry\", result.bookEntry === null ? [] : [result.bookEntry]),\n ...notes(result),\n ];\n}\n\nfunction formatImpact(result: ScryImpactResult, options: FormatScryOptions): string[] {\n const width = 14;\n\n return [\n `impact of ${result.file}`,\n `${\"importers\".padEnd(width)}${result.importers.direct.length} direct, ${result.importers.all.length} in all`,\n ...countedSection(\n \"routes\",\n result.routes.map((route) => `${route.method} ${route.path}`),\n options,\n width,\n ),\n ...countedSection(\n \"pages\",\n result.pages.map((page) => `${page.app} ${page.route}`),\n options,\n width,\n ),\n ...countedSection(\"flows\", result.flows, options, width),\n ...countedSection(\n \"features\",\n result.features.map((feature) => `${feature.id} (${feature.via})`),\n options,\n width,\n ),\n ...countedSection(\"tests\", result.tests, options, width),\n ...notes(result),\n ];\n}\n\nfunction formatRoute(result: ScryRouteResult): string[] {\n const route = result.route;\n const width = 12;\n\n if (route === null) {\n const first = result.pages[0];\n\n return [\n first === undefined ? \"page\" : `GET ${first.route} (${first.type})`,\n ...section(\n \"pages\",\n result.pages.map((page) => `${page.app} ${page.route} ${page.file}`),\n width,\n ),\n ...section(\n \"setup\",\n result.pages.flatMap((page) => (page.setupFile === null ? [] : [page.setupFile])),\n width,\n ),\n ...section(\"layouts\", [...new Set(result.pages.flatMap((page) => page.layouts))], width),\n ...section(\"files\", result.files, width),\n ...notes(result),\n ];\n }\n\n const auth = route.auth.required\n ? `required (${route.auth.userTypes.length > 0 ? route.auth.userTypes.join(\", \") : \"any user\"})`\n : \"none\";\n\n return [\n `${route.method} ${route.path}${route.name === null ? \"\" : ` ${route.name}`}`,\n ...section(\n \"handler\",\n [`${route.handler}${route.handlerFile === null ? \"\" : ` ${route.handlerFile}`}`],\n width,\n ),\n ...section(\"registered\", route.sourceFile === null ? [] : [route.sourceFile], width),\n ...section(\n \"middleware\",\n route.middleware.length > 0 ? [route.middleware.join(\" \")] : [],\n width,\n ),\n ...section(\"auth\", [auth], width),\n ...section(\"description\", route.description === null ? [] : [route.description], width),\n ...section(\n \"page\",\n result.page === null ? [] : [`${result.page.site} ${result.page.route} ${result.page.file}`],\n width,\n ),\n ...section(\"files\", result.files, width),\n ...section(\n \"steps\",\n result.steps.map((step) => `${step.flow} step ${step.index}`),\n width,\n ),\n ...notes(result),\n ];\n}\n\nfunction changeLine(entry: WrittenChangelogEntry): string {\n const text = `${entry.flow === null ? \"\" : `${entry.flow}: `}${entry.text}`;\n\n return `${entry.version.value} ${entry.word} ${shorten(text, 60)} (${releaseOf(entry)})`;\n}\n\nfunction formatFeature(result: ScryFeatureResult): string[] {\n const readme = result.readme;\n const bookmap = result.bookmap;\n const idWidth = Math.max(0, ...result.flows.map((flow) => flow.id.length));\n const statusWidth = Math.max(0, ...result.flows.map((flow) => flow.status.length));\n const pages = Object.entries(bookmap.pages)\n .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0))\n .flatMap(([app, list]) => list.map((page) => `${app} ${page.route}`));\n const apps = readme.apps.map((app) => app.value);\n\n return [\n [\n readme.id.value,\n readme.title.value,\n `${readme.status.value} ${readme.version.value}`,\n `updated ${readme.updated.value}`,\n ...(apps.length > 0 ? [`apps ${apps.join(\", \")}`] : []),\n ].join(\" \"),\n ...section(\n \"flows\",\n result.flows.map(\n (flow) =>\n `${flow.id.padEnd(idWidth)} ${flow.status.padEnd(statusWidth)} since ${flow.since}`,\n ),\n ),\n ...section(\"own\", [\n `${plural(bookmap.own.length, \"file\")} (unreached: ${bookmap.unreached.length === 0 ? \"none\" : bookmap.unreached.length})`,\n ]),\n ...section(\"unreached\", bookmap.unreached),\n ...section(\n \"borrows\",\n bookmap.borrowed.map((item) => item.file),\n ),\n ...section(\n \"routes\",\n bookmap.routes.length > 0\n ? [bookmap.routes.map((route) => `${route.method} ${route.path}`).join(\" \")]\n : [],\n ),\n ...section(\"pages\", pages.length > 0 ? [pages.join(\" \")] : []),\n ...section(\"changes\", result.changes.map(changeLine)),\n ...section(\n \"tasks\",\n result.tasks.map((task) => `${task.id} ${task.status} ${task.title}`),\n ),\n ...section(\"check\", [countsLine(result.findings)]),\n ...notes(result),\n ];\n}\n\nconst STATUS_TEXT: Record<CriterionStatus, string> = {\n pass: \"pass\",\n fail: \"fail\",\n stale: \"stale\",\n \"not-run\": \"not run\",\n \"no-test\": \"no test\",\n};\n\n/** ` (+12 reachable, 3 type-only)`: what a step reaches beyond its entry file; empty when nothing. */\nfunction reachNote(step: FlowBookmapStep): string {\n const parts = [\n ...(step.files.length > 1 ? [`+${step.files.length - 1} reachable`] : []),\n ...(step.typeOnlyFiles.length > 0 ? [`${step.typeOnlyFiles.length} type-only`] : []),\n ];\n\n return parts.length === 0 ? \"\" : ` (${parts.join(\", \")})`;\n}\n\nfunction stepLines(steps: readonly FlowBookmapStep[]): string[] {\n const typeWidth = Math.max(0, ...steps.map((step) => step.type.length));\n const targetWidth = Math.max(0, ...steps.map((step) => step.target.length));\n\n return steps.map((step) => {\n const where =\n step.found === false\n ? \"not found\"\n : step.entry === null\n ? step.found === null && step.type === \"route\"\n ? \"no route facts\"\n : \"—\"\n : `${step.entry}${reachNote(step)}`;\n\n return `${step.index}. ${step.type.padEnd(typeWidth)} ${step.target.padEnd(targetWidth)} ${where}`;\n });\n}\n\nfunction criterionLines(criteria: readonly FlowBookmapCriterion[]): string[] {\n const labels = criteria.map(\n (criterion) => `${criterion.id}${criterion.app === null ? \"\" : ` [${criterion.app}]`}`,\n );\n const labelWidth = Math.max(0, ...labels.map((label) => label.length));\n const texts = criteria.map((criterion) => shorten(criterion.text, 36));\n const textWidth = Math.max(0, ...texts.map((text) => text.length));\n\n return criteria.map((criterion, index) => {\n const test = criterion.tests[0];\n const where =\n test === undefined\n ? \"\"\n : `${test.file}:${test.line}${criterion.tests.length > 1 ? ` (+${criterion.tests.length - 1})` : \"\"}`;\n const line = `${(labels[index] ?? \"\").padEnd(labelWidth)} ${STATUS_TEXT[criterion.status].padEnd(7)} ${\n where === \"\" ? (texts[index] ?? \"\") : `${(texts[index] ?? \"\").padEnd(textWidth)} ${where}`\n }`;\n\n return line.trimEnd();\n });\n}\n\nfunction formatFlow(result: ScryFlowResult): string[] {\n const flow = result.flow;\n const shown = result.bookmap.shownBy.map((item) => `${item.app} ${item.id}: ${item.block}`);\n\n return [\n [\n flow.ref,\n ...(flow.heading === null ? [] : [flow.heading.value]),\n `${flow.status.value} since ${flow.since.value}`,\n `who ${flow.who.value}`,\n ].join(\" \"),\n ...(flow.summary === null ? [] : [flow.summary]),\n ...stepLines(result.bookmap.steps),\n ...section(\n \"differs\",\n flow.differs.map((line) => `${line.name}: ${line.text}`),\n ),\n ...section(\n \"not handled\",\n flow.notHandled.map((line) => `${line.name}: ${line.text}`),\n 12,\n ),\n ...section(\n \"unknown\",\n flow.unknowns.map((item) => item.text.replace(/^Unknown:\\s*/, \"\")),\n ),\n ...criterionLines(result.bookmap.criteria),\n ...section(\"shown on\", shown.length > 0 ? [shown.join(\" \")] : []),\n ...section(\n \"history\",\n result.history.length > 0\n ? [\n result.history\n .map((entry) => `${entry.version.value} ${entry.word} (${releaseOf(entry)})`)\n .join(\" \"),\n ]\n : [],\n ),\n ...section(\"check\", [countsLine(result.findings)]),\n ...notes(result),\n ];\n}\n\n/** One line telling what the limit cut, per type, or nothing when every match is listed. */\nfunction truncatedLine(result: ScrySearchResult): string[] {\n const total = Object.values(result.counts).reduce((sum, count) => sum + (count ?? 0), 0);\n\n if (total <= result.hits.length) return [];\n\n const parts = Object.entries(result.counts).map(([type, count]) => `${count} ${type}`);\n\n return [\n `showing ${result.hits.length} of ${total} (${parts.join(\", \")}); raise --limit for more`,\n ];\n}\n\n/** A score for print: one decimal, or none from 100 up. */\nfunction scoreText(score: number): string {\n return score >= 100 ? score.toFixed(0) : score.toFixed(1);\n}\n\n/** How a file that changes with the top hits relates to them, in a few words. */\nfunction alsoReason(change: NonNullable<ScrySearchResult[\"alsoChanges\"]>[number]): string {\n const name = (id: string): string => id.split(/[\\s#]/)[0]?.split(\"/\").pop() ?? id;\n const first = name(change.via[0] ?? \"\");\n const more = change.via.length > 1 ? ` +${change.via.length - 1}` : \"\";\n\n switch (change.reason) {\n case \"imports\":\n return `imports ${first}${more}`;\n case \"imported-by\":\n return `imported by ${first}${more}`;\n case \"step\":\n return `step of ${change.via[0] ?? \"\"}${more}`;\n case \"test\":\n return \"test\";\n }\n}\n\n/** The `changes with the top hits:` block, at most 10 files (the answer's own cap), or nothing. */\nfunction alsoChangesLines(result: ScrySearchResult): string[] {\n const list = result.alsoChanges ?? [];\n\n if (list.length === 0) return [];\n\n const width = Math.min(60, Math.max(...list.map((change) => change.file.length)));\n\n return [\n \"changes with the top hits:\",\n ...list.map((change) => ` ${change.file.padEnd(width)} ${alsoReason(change)}`),\n ];\n}\n\n/** The top file's impact, folded into the search answer (what reaches it), or nothing when it adds nothing. */\nfunction impactLines(result: ScrySearchResult): string[] {\n const impact = result.impact;\n\n if (impact === undefined) return [];\n\n const rows: [string, string][] = [];\n\n if (impact.files.length > 0) {\n rows.push([\n \"files\",\n impact.files.join(\", \") + (impact.more > 0 ? `, +${impact.more} more` : \"\"),\n ]);\n }\n if (impact.routes.length > 0) rows.push([\"routes\", impact.routes.join(\", \")]);\n if (impact.flows.length > 0) rows.push([\"flows\", impact.flows.join(\", \")]);\n if (impact.tests.length > 0) rows.push([\"tests\", impact.tests.join(\", \")]);\n\n if (rows.length === 0) return [];\n\n return [\n `impact of ${impact.file}:`,\n ...rows.map(([label, text]) => ` ${label.padEnd(6)} ${text}`),\n ];\n}\n\n/** Hits in score order, one line each: `score type id detail (app) [matched]`. */\nfunction formatSearch(result: ScrySearchResult): string[] {\n if (result.hits.length === 0)\n return [`no match for ${JSON.stringify(result.text)}`, ...notes(result)];\n\n const scoreWidth = Math.max(...result.hits.map((hit) => scoreText(hit.score).length));\n const idWidth = Math.min(32, Math.max(0, ...result.hits.map((hit) => hit.id.length)));\n\n return [\n ...result.hits.map((hit) => {\n const head = `${scoreText(hit.score).padStart(scoreWidth)} ${hit.type.padEnd(9)}`;\n // Page, screen and block ids start with the app; a file's app is not in its path.\n const app = hit.app !== undefined && hit.type === \"file\" ? ` (${hit.app})` : \"\";\n const line =\n hit.detail === null\n ? `${head}${hit.id}${app}`\n : `${head}${hit.id.padEnd(idWidth)} ${hit.detail}${app}`;\n\n return line.trimEnd() + (hit.matched === undefined ? \"\" : ` [${hit.matched}]`);\n }),\n ...truncatedLine(result),\n ...alsoChangesLines(result),\n ...(result.weak === true\n ? [\"weak match: no hit holds most of the request's words; use grep for literal text\"]\n : []),\n ...impactLines(result),\n // The impact above is the same answer as `--impact`; the command is offered only when it is not in the output.\n ...(result.next === undefined || result.impact !== undefined ? [] : [`next: ${result.next}`]),\n ...notes(result),\n ];\n}\n\n/**\n * The compact text of a result (formats in the commands guide). Long lists in an\n * impact answer stop after 20 lines with a count; `options.all` prints them all.\n */\nexport function formatScryResult(result: ScryResult, options: FormatScryOptions = {}): string[] {\n switch (result.type) {\n case \"file\":\n return formatFile(result);\n case \"impact\":\n return formatImpact(result, options);\n case \"route\":\n return formatRoute(result);\n case \"feature\":\n return formatFeature(result);\n case \"flow\":\n return formatFlow(result);\n case \"search\":\n return formatSearch(result);\n }\n}\n"],"mappings":";AAkBA,MAAM,QAAQ;;AAGd,SAAS,QAAQ,OAAe,QAA2B,QAAQ,OAAiB;CAClF,IAAI,OAAO,WAAW,GAAG,OAAO,CAAC;CAEjC,MAAM,MAAM,IAAI,OAAO,KAAK,IAAI,OAAO,MAAM,SAAS,CAAC,CAAC;CAExD,OAAO,OAAO,KAAK,OAAO,UACxB,UAAU,IAAI,GAAG,MAAM,OAAO,IAAI,MAAM,IAAI,UAAU,GAAG,MAAM,OACjE;AACF;;AAGA,MAAM,cAAc;;AASpB,SAAS,eACP,OACA,QACA,SACA,OACU;CACV,MAAM,QAAQ,Q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,SAAS,UAAa,OAAO,WAAW,SAAY,CAAC,IAAI,CAAC,SAAS,OAAO,MAAM;EAC3F,GAAG,MAAM,MAAM;CACjB;AACF;;;;;AAMA,SAAgB,iBAAiB,QAAoB,UAA6B,CAAC,GAAa;CAC9F,QAAQ,OAAO,MAAf;EACE,KAAK,QACH,OAAO,WAAW,MAAM;EAC1B,KAAK,UACH,OAAO,aAAa,QAAQ,OAAO;EACrC,KAAK,SACH,OAAO,YAAY,MAAM;EAC3B,KAAK,WACH,OAAO,cAAc,MAAM;EAC7B,KAAK,QACH,OAAO,WAAW,MAAM;EAC1B,KAAK,UACH,OAAO,aAAa,MAAM;CAC9B;AACF"}
|
package/esm/scry/query.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/query.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"query.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/query.ts"],"mappings":";;;;;;;;wBAorBgB,KAAK,UAAU,kBAAkB,OAAO,YAAY"}
|