@warlock.js/grimoire 5.62.0 → 5.63.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 +28 -0
- package/esm/book/build.d.mts +17 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +78 -16
- package/esm/book/build.mjs.map +1 -1
- package/esm/book/index.mjs +2 -2
- package/esm/codes/codes.d.mts +2 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +2 -1
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/book.d.mts +7 -0
- package/esm/contracts/book.d.mts.map +1 -1
- package/esm/contracts/book.mjs.map +1 -1
- package/esm/contracts/scry.d.mts +29 -5
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +8 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/devtools/snapshot-source.mjs +27 -7
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/index.d.mts +5 -3
- package/esm/index.mjs +4 -2
- package/esm/scry/error.mjs +20 -0
- package/esm/scry/error.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +22 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/index.mjs +3 -2
- package/esm/scry/parse.d.mts +1 -1
- package/esm/scry/parse.d.mts.map +1 -1
- package/esm/scry/parse.mjs +12 -9
- package/esm/scry/parse.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +77 -268
- package/esm/scry/query.mjs.map +1 -1
- package/esm/scry/search.d.mts +8 -0
- package/esm/scry/search.d.mts.map +1 -0
- package/esm/scry/search.mjs +401 -0
- package/esm/scry/search.mjs.map +1 -0
- package/esm/warlock/actions.mjs +15 -12
- package/esm/warlock/actions.mjs.map +1 -1
- package/esm/warlock/commands.mjs +14 -4
- package/esm/warlock/commands.mjs.map +1 -1
- package/esm/warlock/mcp-tools.mjs +46 -21
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/cache.mjs +13 -1
- package/esm/workspace/cache.mjs.map +1 -1
- package/esm/workspace/derived.mjs +107 -0
- package/esm/workspace/derived.mjs.map +1 -0
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +22 -18
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/workspace/stored.d.mts +12 -0
- package/esm/workspace/stored.d.mts.map +1 -0
- package/esm/workspace/stored.mjs +46 -0
- package/esm/workspace/stored.mjs.map +1 -0
- package/llms-full.txt +28 -12
- package/package.json +3 -3
- package/skills/use-the-grimoire/SKILL.md +28 -12
- package/ui/grimoire-view.js +16 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"book.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/book.ts"],"sourcesContent":["/**\n * The generated book under `grimoire/book/`. Warlock writes every file here;\n * the folder is ignored by git and rebuilt when sources or written files\n * change. Paths of the files are decided by `bookEntryPath()` and the\n * constants in `src/paths`.\n *\n * JSON files carry no timestamps except `manifest.json`, so an unchanged\n * project rewrites nothing and golden files stay stable.\n */\nimport type {\n BookFacts,\n BookFileType,\n BookMobileApp,\n BookPage,\n BookScreen,\n BookSite,\n} from \"./adapter\";\nimport type { RouteFreshness } from \"./findings\";\n\n/** The version of every book and collected JSON shape. Bumped only for a breaking change. */\nexport const BOOK_SCHEMA_VERSION = 1;\n\n/** A route as a book entry or list shows it. */\nexport type BookRouteRef = {\n method: string;\n path: string;\n name: string | null;\n};\n\n/**\n * `grimoire/book/<mirror path>.json`: one per code file.\n * `src/app/auth/controllers/login.controller.ts` →\n * `grimoire/book/app/auth/controllers/login.controller.json`.\n */\nexport type BookEntry = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** The source file. */\n file: string;\n module: string;\n type: BookFileType;\n lines: number;\n /** The header sentence, or `null`. */\n about: string | null;\n /** The feature that owns the file, or `null`. */\n feature: string | null;\n /** Features that import the file without owning it. */\n borrowedBy: string[];\n /** `<feature>/<flow>` of every flow whose steps reach the file. */\n flows: string[];\n exports: { name: string; about: string | null }[];\n /** External packages it imports (`@warlock.js/core`, `dayjs`), by package name. */\n packages: string[];\n /** Project files it imports. */\n imports: string[];\n /** The part of `imports` that is type-only (erased at runtime), sorted. */\n typeOnlyImports: string[];\n /** Project files that import it. */\n importedBy: string[];\n /**\n * Routes this file registers (`via: \"registers\"`, a routes file) or handles\n * (`via: \"handles\"`, the handler's file). Routes that only reach the file\n * through imports are answered by `scry --impact`, not stored here.\n */\n routes: (BookRouteRef & { via: \"registers\" | \"handles\" })[];\n /** Pages this file is the page, setup or layout file of: `<site> <route>`. */\n pages: { site: string; route: string; via: \"page\" | \"setup\" | \"layout\" }[];\n /** Mobile screens this file is the screen or layout file of. */\n screens: { app: string; route: string; via: \"screen\" | \"layout\" }[];\n};\n\n/** `grimoire/book/app/routes.json`: every route, grouped by the module of its routes file. */\nexport type BookRoutesFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** Module (`src/app/catalog`) → routes, in registration order. `(none)` holds routes with no source file. */\n modules: Record<string, (BookRouteRef & { handlerFile: string | null })[]>;\n};\n\n/** `grimoire/book/web/<site>.pages.json`: the pages of one site. */\nexport type BookSitePagesFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n site: BookSite;\n pages: BookPage[];\n};\n\n/** `grimoire/book/mobile/<app>.screens.json`: one mobile app and its screens. */\nexport type BookMobileScreensFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n app: Omit<BookMobileApp, \"screens\">;\n screens: BookScreen[];\n};\n\n/**\n * The data behind `grimoire/book/<module>/index.md`, the module summary.\n *\n * The Markdown is:\n *\n * ```md\n * # src/app/catalog\n *\n * Feature: catalog. 14 files, 820 lines.\n *\n * ## Files\n * - controllers/new-arrivals.controller.ts controller Answers the new arrivals request.\n *\n * ## Routes\n * - GET /products/new-arrivals\n *\n * ## Used by\n * - src/app/orders (3 files)\n * ```\n *\n * Sections with nothing in them are left out. Files are listed by path\n * relative to the module, in path order; the header sentence is omitted when\n * the file has none.\n */\nexport type BookModuleSummary = {\n module: string;\n /** Owning features of the module's files, most files first. */\n features: string[];\n files: { file: string; type: BookFileType; lines: number; about: string | null }[];\n routes: BookRouteRef[];\n /** Other modules importing files of this one, with how many of their files do. */\n usedBy: { module: string; files: number }[];\n};\n\n/** One source file as the manifest remembers it. */\nexport type BookManifestFile = {\n /** sha256 of the content (hex). */\n hash: string;\n /** Size and modification time, to skip hashing unchanged files. */\n size: number;\n mtimeMs: number;\n /** The book entry path (`grimoire/book/...json`), or `null` for a file with no entry. */\n entry: string | null;\n};\n\n/**\n * `grimoire/book/manifest.json`: the fingerprint that says whether the book is\n * fresh. The book is fresh when the grimoire version, adapter name and version\n * and `schemaVersion` match, the set of files under the source roots is the\n * same, every file's hash matches, and the written-files hash matches.\n */\nexport type BookManifest = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** `@warlock.js/grimoire` version that wrote the book. */\n grimoireVersion: string;\n adapter: { name: string; version: string };\n /** ISO time of the last build that changed anything. */\n builtAt: string;\n sourceRoots: string[];\n /** Every file under the source roots (code or not), by project-relative path. */\n files: Record<string, BookManifestFile>;\n /** Test files scanned for `@proves`, with their hashes. */\n tests: Record<string, string>;\n /** `WrittenGrimoire.hash` the ownership and book maps were built from. */\n writtenHash: string;\n /**\n * The cache of facts that need the app booted (routes, named things). It is\n * stale when any input's hash differs from the one stored here, or an input\n * was added or removed.\n */\n boot: {\n /** ISO time the routes were read, or `null` when never. */\n collectedAt: string | null;\n inputs: Record<string, string>;\n };\n};\n\n/**\n * `grimoire/book/.cache/facts.json`: the adapter's last answer, so a file-only\n * question never calls the adapter's `routes()` and loading the book reads one\n * file. Machine use only.\n */\nexport type BookFactsCache = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n facts: BookFacts;\n};\n\n/** The book as `loadBook()` returns it. */\nexport type LoadedBook = {\n /** Absolute project root. */\n root: string;\n manifest: BookManifest;\n facts: BookFacts;\n routes: RouteFreshness;\n};\n\n/** Options of `buildBook()`. */\nexport type BuildBookOptions = {\n /**\n * `fresh`: refresh stale route facts (may boot the app through the adapter).\n * `cached`: never boot; reuse cached route facts, reported `stale` when their\n * inputs changed and `missing` when there are none.\n * Default `cached`. `warlock grimoire build` and `check` pass `fresh`.\n */\n routes?: \"fresh\" | \"cached\";\n /** Rebuild every entry even when the manifest says the book is fresh. */\n force?: boolean;\n /** Clock for `builtAt`. */\n now?: () => Date;\n /** `false` computes the book in memory only and writes nothing. Default `true`. */\n write?: boolean;\n};\n\n/** What `buildBook()` did. */\nexport type BuildBookResult = {\n book: LoadedBook;\n /** `false` when the manifest matched: the adapter was not called and nothing was written. */\n rebuilt: boolean;\n /** Source files added, changed or removed since the previous manifest. */\n changed: string[];\n};\n\n/**\n * What the book entries need from the written files: owner, borrowers and\n * flows per source file. `openGrimoire()` computes it (ownership and book\n * maps) and hands it to `writeBook()`.\n */\nexport type BookAnnotations = {\n /** `WrittenGrimoire.hash` it was computed from; stored in the manifest. */\n writtenHash: string;\n /** Test file → sha256, stored in the manifest. */\n tests: Record<string, string>;\n files: Record<string, { feature: string | null; borrowedBy: string[]; flows: string[] }>;\n};\n\n/** What `writeBook()` wrote. Unchanged files are not rewritten. */\nexport type WriteBookResult = {\n /** Book files created or changed (entries, summaries, lists), project-relative. */\n written: string[];\n /** Book files removed because their source is gone. */\n removed: string[];\n};\n"],"mappings":";;AAoBA,MAAa,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"book.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/book.ts"],"sourcesContent":["/**\n * The generated book under `grimoire/book/`. Warlock writes every file here;\n * the folder is ignored by git and rebuilt when sources or written files\n * change. Paths of the files are decided by `bookEntryPath()` and the\n * constants in `src/paths`.\n *\n * JSON files carry no timestamps except `manifest.json`, so an unchanged\n * project rewrites nothing and golden files stay stable.\n */\nimport type {\n BookFacts,\n BookFileType,\n BookMobileApp,\n BookPage,\n BookScreen,\n BookSite,\n} from \"./adapter\";\nimport type { RouteFreshness } from \"./findings\";\n\n/** The version of every book and collected JSON shape. Bumped only for a breaking change. */\nexport const BOOK_SCHEMA_VERSION = 1;\n\n/** A route as a book entry or list shows it. */\nexport type BookRouteRef = {\n method: string;\n path: string;\n name: string | null;\n};\n\n/**\n * `grimoire/book/<mirror path>.json`: one per code file.\n * `src/app/auth/controllers/login.controller.ts` →\n * `grimoire/book/app/auth/controllers/login.controller.json`.\n */\nexport type BookEntry = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** The source file. */\n file: string;\n module: string;\n type: BookFileType;\n lines: number;\n /** The header sentence, or `null`. */\n about: string | null;\n /** The feature that owns the file, or `null`. */\n feature: string | null;\n /** Features that import the file without owning it. */\n borrowedBy: string[];\n /** `<feature>/<flow>` of every flow whose steps reach the file. */\n flows: string[];\n exports: { name: string; about: string | null }[];\n /** External packages it imports (`@warlock.js/core`, `dayjs`), by package name. */\n packages: string[];\n /** Project files it imports. */\n imports: string[];\n /** The part of `imports` that is type-only (erased at runtime), sorted. */\n typeOnlyImports: string[];\n /** Project files that import it. */\n importedBy: string[];\n /**\n * Routes this file registers (`via: \"registers\"`, a routes file) or handles\n * (`via: \"handles\"`, the handler's file). Routes that only reach the file\n * through imports are answered by `scry --impact`, not stored here.\n */\n routes: (BookRouteRef & { via: \"registers\" | \"handles\" })[];\n /** Pages this file is the page, setup or layout file of: `<site> <route>`. */\n pages: { site: string; route: string; via: \"page\" | \"setup\" | \"layout\" }[];\n /** Mobile screens this file is the screen or layout file of. */\n screens: { app: string; route: string; via: \"screen\" | \"layout\" }[];\n};\n\n/** `grimoire/book/app/routes.json`: every route, grouped by the module of its routes file. */\nexport type BookRoutesFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** Module (`src/app/catalog`) → routes, in registration order. `(none)` holds routes with no source file. */\n modules: Record<string, (BookRouteRef & { handlerFile: string | null })[]>;\n};\n\n/** `grimoire/book/web/<site>.pages.json`: the pages of one site. */\nexport type BookSitePagesFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n site: BookSite;\n pages: BookPage[];\n};\n\n/** `grimoire/book/mobile/<app>.screens.json`: one mobile app and its screens. */\nexport type BookMobileScreensFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n app: Omit<BookMobileApp, \"screens\">;\n screens: BookScreen[];\n};\n\n/**\n * The data behind `grimoire/book/<module>/index.md`, the module summary.\n *\n * The Markdown is:\n *\n * ```md\n * # src/app/catalog\n *\n * Feature: catalog. 14 files, 820 lines.\n *\n * ## Files\n * - controllers/new-arrivals.controller.ts controller Answers the new arrivals request.\n *\n * ## Routes\n * - GET /products/new-arrivals\n *\n * ## Used by\n * - src/app/orders (3 files)\n * ```\n *\n * Sections with nothing in them are left out. Files are listed by path\n * relative to the module, in path order; the header sentence is omitted when\n * the file has none.\n */\nexport type BookModuleSummary = {\n module: string;\n /** Owning features of the module's files, most files first. */\n features: string[];\n files: { file: string; type: BookFileType; lines: number; about: string | null }[];\n routes: BookRouteRef[];\n /** Other modules importing files of this one, with how many of their files do. */\n usedBy: { module: string; files: number }[];\n};\n\n/** One source file as the manifest remembers it. */\nexport type BookManifestFile = {\n /** sha256 of the content (hex). */\n hash: string;\n /** Size and modification time, to skip hashing unchanged files. */\n size: number;\n mtimeMs: number;\n /** The book entry path (`grimoire/book/...json`), or `null` for a file with no entry. */\n entry: string | null;\n};\n\n/**\n * `grimoire/book/manifest.json`: the fingerprint that says whether the book is\n * fresh. The book is fresh when the grimoire version, adapter name and version\n * and `schemaVersion` match, the set of files under the source roots is the\n * same, every file's hash matches, and the written-files hash matches.\n */\nexport type BookManifest = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** `@warlock.js/grimoire` version that wrote the book. */\n grimoireVersion: string;\n adapter: { name: string; version: string };\n /** ISO time of the last build that changed anything. */\n builtAt: string;\n sourceRoots: string[];\n /** Every file under the source roots (code or not), by project-relative path. */\n files: Record<string, BookManifestFile>;\n /** Test files scanned for `@proves`, with their hashes. */\n tests: Record<string, string>;\n /** `WrittenGrimoire.hash` the ownership and book maps were built from. */\n writtenHash: string;\n /**\n * The cache of facts that need the app booted (routes, named things). It is\n * stale when any input's hash differs from the one stored here, or an input\n * was added or removed.\n */\n boot: {\n /** ISO time the routes were read, or `null` when never. */\n collectedAt: string | null;\n inputs: Record<string, string>;\n /** How many routes and pages the last read found; absent in books written before it was stored. */\n counts?: { routes: number; pages: number };\n };\n};\n\n/**\n * `grimoire/book/.cache/facts.json`: the adapter's last answer, so a file-only\n * question never calls the adapter's `routes()` and loading the book reads one\n * file. Machine use only.\n */\nexport type BookFactsCache = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n facts: BookFacts;\n};\n\n/** The book as `loadBook()` returns it. */\nexport type LoadedBook = {\n /** Absolute project root. */\n root: string;\n manifest: BookManifest;\n facts: BookFacts;\n routes: RouteFreshness;\n /** Set when a live read of the route facts was refused (it found far fewer routes than the book holds); the book keeps its list. */\n routeNote?: string;\n};\n\n/** Options of `buildBook()`. */\nexport type BuildBookOptions = {\n /**\n * `fresh`: refresh stale route facts (may boot the app through the adapter).\n * `cached`: never boot; reuse cached route facts, reported `stale` when their\n * inputs changed and `missing` when there are none.\n * Default `cached`. `warlock grimoire build` and `check` pass `fresh`.\n */\n routes?: \"fresh\" | \"cached\";\n /** Rebuild every entry even when the manifest says the book is fresh. */\n force?: boolean;\n /** Clock for `builtAt`. */\n now?: () => Date;\n /** `false` computes the book in memory only and writes nothing. Default `true`. */\n write?: boolean;\n};\n\n/** What `buildBook()` did. */\nexport type BuildBookResult = {\n book: LoadedBook;\n /** `false` when the manifest matched: the adapter was not called and nothing was written. */\n rebuilt: boolean;\n /** Source files added, changed or removed since the previous manifest. */\n changed: string[];\n};\n\n/**\n * What the book entries need from the written files: owner, borrowers and\n * flows per source file. `openGrimoire()` computes it (ownership and book\n * maps) and hands it to `writeBook()`.\n */\nexport type BookAnnotations = {\n /** `WrittenGrimoire.hash` it was computed from; stored in the manifest. */\n writtenHash: string;\n /** Test file → sha256, stored in the manifest. */\n tests: Record<string, string>;\n files: Record<string, { feature: string | null; borrowedBy: string[]; flows: string[] }>;\n};\n\n/** What `writeBook()` wrote. Unchanged files are not rewritten. */\nexport type WriteBookResult = {\n /** Book files created or changed (entries, summaries, lists), project-relative. */\n written: string[];\n /** Book files removed because their source is gone. */\n removed: string[];\n};\n"],"mappings":";;AAoBA,MAAa,sBAAsB"}
|
package/esm/contracts/scry.d.mts
CHANGED
|
@@ -20,6 +20,7 @@ export type ScryQuery =
|
|
|
20
20
|
type: "route";
|
|
21
21
|
method: string;
|
|
22
22
|
path: string;
|
|
23
|
+
site?: string;
|
|
23
24
|
} |
|
|
24
25
|
/** `warlock scry --feature <id>` */
|
|
25
26
|
{
|
|
@@ -32,11 +33,12 @@ export type ScryQuery =
|
|
|
32
33
|
feature: string;
|
|
33
34
|
flow: string;
|
|
34
35
|
} |
|
|
35
|
-
/** `warlock scry --search "<text>"`; `limit` defaults to 20. */
|
|
36
|
+
/** `warlock scry --search "<text>"`; `limit` defaults to 20; `app` keeps the hits of one app. */
|
|
36
37
|
{
|
|
37
38
|
type: "search";
|
|
38
39
|
text: string;
|
|
39
40
|
limit?: number;
|
|
41
|
+
app?: string;
|
|
40
42
|
};
|
|
41
43
|
/** Notes every result may carry (stale routes, a book rebuilt on the way). */
|
|
42
44
|
export type ScryNotes = {
|
|
@@ -82,8 +84,9 @@ export type ScryImpactResult = Omit<ScryNotes, "routes"> & {
|
|
|
82
84
|
};
|
|
83
85
|
export type ScryRouteResult = ScryNotes & {
|
|
84
86
|
type: "route";
|
|
85
|
-
route
|
|
86
|
-
|
|
87
|
+
/** The API route, or `null` when the path is a page or screen only (GET and HEAD). */
|
|
88
|
+
route: BookRoute | null;
|
|
89
|
+
/** The handler file and everything it imports, transitively, sorted (for a page: its file, setup file and layouts). */
|
|
87
90
|
files: string[];
|
|
88
91
|
/** Flow steps that name the route. */
|
|
89
92
|
steps: {
|
|
@@ -92,6 +95,25 @@ export type ScryRouteResult = ScryNotes & {
|
|
|
92
95
|
}[];
|
|
93
96
|
/** Page whose route matches, for a page route. */
|
|
94
97
|
page: BookPage | null;
|
|
98
|
+
/** Every page or screen that serves the path (one per site), each with its own files; empty for an API route. */
|
|
99
|
+
pages: ScryRoutePage[];
|
|
100
|
+
};
|
|
101
|
+
/** A page or screen found by its URL, with the import closure of its file, setup file and layouts. */
|
|
102
|
+
export type ScryRoutePage = ScryPageRef & {
|
|
103
|
+
/** Site id of a page, or the mobile app id of a screen. */
|
|
104
|
+
site: string;
|
|
105
|
+
setupFile: string | null;
|
|
106
|
+
layouts: string[];
|
|
107
|
+
files: string[];
|
|
108
|
+
};
|
|
109
|
+
/** What a failed scry prints under `--json` and returns from the MCP tools. */
|
|
110
|
+
export type ScryError = {
|
|
111
|
+
type: "error";
|
|
112
|
+
/** The `GRnnnn` code. */
|
|
113
|
+
code: string;
|
|
114
|
+
message: string;
|
|
115
|
+
/** What to do next, or an empty string when the code has no fix text. */
|
|
116
|
+
fix: string;
|
|
95
117
|
};
|
|
96
118
|
/** One flow of a feature answer, with the counts the flow cards show. */
|
|
97
119
|
export type ScryFeatureFlow = {
|
|
@@ -142,7 +164,9 @@ export type ScryHit = {
|
|
|
142
164
|
id: string;
|
|
143
165
|
/** Short text shown after the id (a header sentence, a block's flow). */
|
|
144
166
|
detail: string | null;
|
|
145
|
-
/**
|
|
167
|
+
/** The app of a page, screen, block or file hit; absent for the rest. */
|
|
168
|
+
app?: string;
|
|
169
|
+
/** Higher is better. Only the order is meaningful: name matches score above every written-text match. */
|
|
146
170
|
score: number;
|
|
147
171
|
/**
|
|
148
172
|
* For a feature or flow found by its written text: the part that matched
|
|
@@ -155,7 +179,7 @@ export type ScrySearchResult = ScryNotes & {
|
|
|
155
179
|
text: string;
|
|
156
180
|
/** How many candidates matched, per type, before the limit cut the list. */
|
|
157
181
|
counts: Partial<Record<ScryHitType, number>>;
|
|
158
|
-
/**
|
|
182
|
+
/** Best first, whatever the type; on an equal score features and flows come first. */
|
|
159
183
|
hits: ScryHit[];
|
|
160
184
|
};
|
|
161
185
|
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;;;;
|
|
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;;YAGU,mBAAmB;EAC7B;EACA;;EAEA,QAAQ,QAAQ,OAAO;;EAEvB,MAAM;;YAGI,aACR,iBACA,mBACA,kBACA,oBACA,iBACA"}
|
|
@@ -28,6 +28,14 @@ export type GrimoireSnapshot = {
|
|
|
28
28
|
collected: CollectedFiles;
|
|
29
29
|
annotations: BookAnnotations;
|
|
30
30
|
routes: RouteFreshness;
|
|
31
|
+
/**
|
|
32
|
+
* Set only by the read-only open (`openStoredGrimoire`): the code, test and
|
|
33
|
+
* written files that changed since the last build. The snapshot is the
|
|
34
|
+
* stored one; `scry` says so in a note.
|
|
35
|
+
*/
|
|
36
|
+
behind?: {
|
|
37
|
+
changed: number;
|
|
38
|
+
};
|
|
31
39
|
/** What the adapter's `host()` reported (framework brand, app name and version); `null` or absent when it reports none. */
|
|
32
40
|
host?: BookHost | null;
|
|
33
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/snapshot.ts"],"mappings":";;;;;;;YAYY;;EAEV;EACA,SAAS;;EAET,WAAW;EACX,MAAM;EACN,WAAW;;EAEX,MAAM,eAAe;EACrB,QAAQ;;EAER,eAAe;;EAEf,SAAS;;;;;EAKT;EACA,WAAW;EACX,aAAa;EACb,QAAQ
|
|
1
|
+
{"version":3,"file":"snapshot.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/snapshot.ts"],"mappings":";;;;;;;YAYY;;EAEV;EACA,SAAS;;EAET,WAAW;EACX,MAAM;EACN,WAAW;;EAEX,MAAM,eAAe;EACrB,QAAQ;;EAER,eAAe;;EAEf,SAAS;;;;;EAKT;EACA,WAAW;EACX,aAAa;EACb,QAAQ;;;;;;EAMR;IAAW;;;EAEX,OAAO;;;YAIG;;EAEV;;EAEA;;EAEA;;;;;;EAMA;EACA,YAAY;;;YAIF,gBAAgB,UAAU,qBAAqB;;;;;;;YAQ/C;EACV;EACA;EACA,MAAM;EACN,QAAQ"}
|
|
@@ -9,8 +9,10 @@ import { stat } from "node:fs/promises";
|
|
|
9
9
|
* Where the panel's routes get the snapshot: opened once with
|
|
10
10
|
* `routes: "cached"` (a devtools request never boots the app) and kept in
|
|
11
11
|
* memory. Concurrent requests share one open. A change stamp (the book
|
|
12
|
-
* manifest
|
|
13
|
-
* no directory walk) tells when the book changed.
|
|
12
|
+
* manifest, the agent-written folders and indexes and the files the route
|
|
13
|
+
* facts were read from, a few `stat` calls and no directory walk) tells when the book changed. With live
|
|
14
|
+
* facts (`liveFacts`, development), an edit to a file the route facts were read from reads them again from
|
|
15
|
+
* the running app on the next open, so a route edit shows without `warlock grimoire build`.
|
|
14
16
|
*
|
|
15
17
|
* - Production (`mode: "production"`): a snapshot is reused until the stamp
|
|
16
18
|
* changes, with no time limit, unless `ttlMs` is set. A request that finds
|
|
@@ -41,8 +43,8 @@ const STAMPED = [
|
|
|
41
43
|
GRIMOIRE_PATHS.doneTasks,
|
|
42
44
|
GRIMOIRE_PATHS.releases
|
|
43
45
|
];
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
/** The modified times of `files`, joined (`0` for a missing file). */
|
|
47
|
+
async function timesOf(files) {
|
|
46
48
|
return (await Promise.all(files.map(async (file) => {
|
|
47
49
|
try {
|
|
48
50
|
return (await stat(file)).mtimeMs;
|
|
@@ -51,6 +53,19 @@ async function changeStamp(root, resultsFile) {
|
|
|
51
53
|
}
|
|
52
54
|
}))).join(",");
|
|
53
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The change stamp in two parts: `book` (the book manifest, the written folders, the results file) and `routes`
|
|
58
|
+
* (the project-relative files the route facts were read from, `manifest.boot.inputs`). An edit to a route input
|
|
59
|
+
* ends the reuse window; with live facts the next open reads the routes again, otherwise it reports them stale.
|
|
60
|
+
*/
|
|
61
|
+
async function changeStamp(root, resultsFile, routeInputs = []) {
|
|
62
|
+
const [book, routes] = await Promise.all([timesOf([...STAMPED.map((entry) => path.join(root, ...entry.split("/"))), resultsFile]), timesOf(routeInputs.map((file) => path.join(root, ...file.split("/"))))]);
|
|
63
|
+
return {
|
|
64
|
+
book,
|
|
65
|
+
routes
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const routeInputsOf = (snapshot) => Object.keys(snapshot.book.manifest.boot.inputs).sort();
|
|
54
69
|
async function loadAdapter(option) {
|
|
55
70
|
if (option === void 0) {
|
|
56
71
|
const { createWarlockAdapter } = await import("../warlock/index.mjs");
|
|
@@ -65,6 +80,7 @@ function createSnapshotSource(root, options = {}) {
|
|
|
65
80
|
const live = options.liveFacts === true && options.mode !== "production";
|
|
66
81
|
let collected = options.collectRoutes !== true || options.mode === "production";
|
|
67
82
|
let liveCollected = !live;
|
|
83
|
+
let refreshRoutes = false;
|
|
68
84
|
const resultsFile = resolveResultsFile(root, options.testResultsFile);
|
|
69
85
|
const keepUntilChanged = options.mode === "production" && options.ttlMs === void 0;
|
|
70
86
|
const reuseFor = (took) => options.ttlMs ?? Math.max(2e3, took * 5);
|
|
@@ -76,8 +92,9 @@ function createSnapshotSource(root, options = {}) {
|
|
|
76
92
|
...options.testResultsFile === void 0 ? {} : { testResultsFile: options.testResultsFile }
|
|
77
93
|
};
|
|
78
94
|
let snapshot;
|
|
79
|
-
if (!liveCollected) {
|
|
95
|
+
if (!liveCollected || refreshRoutes) {
|
|
80
96
|
liveCollected = true;
|
|
97
|
+
refreshRoutes = false;
|
|
81
98
|
try {
|
|
82
99
|
snapshot = await openGrimoire(root, adapter, {
|
|
83
100
|
routes: "fresh",
|
|
@@ -106,7 +123,7 @@ function createSnapshotSource(root, options = {}) {
|
|
|
106
123
|
cached = {
|
|
107
124
|
snapshot,
|
|
108
125
|
at,
|
|
109
|
-
stamp: await changeStamp(root, resultsFile),
|
|
126
|
+
stamp: await changeStamp(root, resultsFile, routeInputsOf(snapshot)),
|
|
110
127
|
took: at - started
|
|
111
128
|
};
|
|
112
129
|
return snapshot;
|
|
@@ -122,7 +139,10 @@ function createSnapshotSource(root, options = {}) {
|
|
|
122
139
|
async get() {
|
|
123
140
|
if (cached === null) return ensureOpening();
|
|
124
141
|
const known = cached;
|
|
125
|
-
const
|
|
142
|
+
const stamp = await changeStamp(root, resultsFile, routeInputsOf(known.snapshot));
|
|
143
|
+
const routesMoved = stamp.routes !== known.stamp.routes;
|
|
144
|
+
const changed = routesMoved || stamp.book !== known.stamp.book;
|
|
145
|
+
if (routesMoved && live) refreshRoutes = true;
|
|
126
146
|
if (changed || options.mode === "production") {
|
|
127
147
|
if (!changed && (keepUntilChanged || Date.now() - known.at < reuseFor(known.took))) return known.snapshot;
|
|
128
148
|
return ensureOpening().catch(() => known.snapshot);
|
|
@@ -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 plus the agent-written folders and indexes, a few `stat` calls and\n * no directory walk) tells when the book changed.\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];\n\nasync function changeStamp(root: string, resultsFile: string): Promise<string> {\n const files = [...STAMPED.map((entry) => path.join(root, ...entry.split(\"/\"))), resultsFile];\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\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: { snapshot: GrimoireSnapshot; at: number; stamp: string; took: number } | 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 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) {\n // One pass: the book and the live route facts together, so a first open never builds twice.\n liveCollected = true;\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 = { snapshot, at, stamp: await changeStamp(root, resultsFile), took: at - started };\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 changed = (await changeStamp(root, resultsFile)) !== known.stamp;\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().catch(() => {});\n },\n async idle() {\n await opening?.catch(() => {});\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAM,UAAU;CACd,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,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,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\"`): 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];\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().catch(() => {});\n },\n async idle() {\n await opening?.catch(() => {});\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAM,UAAU;CACd,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;AACjB;;AAGA,eAAe,QAAQ,OAAkC;CAWvD,QAAO,MAVa,QAAQ,IAC1B,MAAM,IAAI,OAAO,SAAS;EACxB,IAAI;GACF,QAAQ,MAAM,KAAK,IAAI,EAAC,CAAE;EAC5B,QAAQ;GACN,OAAO;EACT;CACF,CAAC,CACH,EAEY,CAAC,KAAK,GAAG;AACvB;;;;;;AAOA,eAAe,YACb,MACA,aACA,cAAwB,CAAC,GACkB;CAC3C,MAAM,CAAC,MAAM,UAAU,MAAM,QAAQ,IAAI,CACvC,QAAQ,CAAC,GAAG,QAAQ,KAAK,UAAU,KAAK,KAAK,MAAM,GAAG,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,GACtF,QAAQ,YAAY,KAAK,SAAS,KAAK,KAAK,MAAM,GAAG,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,CACxE,CAAC;CAED,OAAO;EAAE;EAAM;CAAO;AACxB;AAEA,MAAM,iBAAiB,aACrB,OAAO,KAAK,SAAS,KAAK,SAAS,KAAK,MAAM,CAAC,CAAC,KAAK;AAEvD,eAAe,YAAY,QAAgE;CACzF,IAAI,WAAW,QAAW;EACxB,MAAM,EAAE,yBAAyB,MAAM,OAAO;EAE9C,OAAO,qBAAqB;CAC9B;CAEA,OAAO,OAAO,WAAW,aAAa,OAAO,IAAI;AACnD;;AAGA,SAAgB,qBACd,MACA,UAAiC,CAAC,GAClB;CAChB,IAAI,SAKO;CACX,IAAI,UAA4C;CAEhD,MAAM,O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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
|
@@ -6,7 +6,7 @@ import { CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, CaseQuest
|
|
|
6
6
|
import { CriterionStatus, ProofLine, ProofResult, TestOutcome, TestResultsInfo, TestResultsStore, UnmatchedProof } from "./contracts/test-results.mjs";
|
|
7
7
|
import { CollectedFiles, FeatureBookmap, FeaturesIndex, FileOwnership, FlowBookmap, FlowBookmapCriterion, FlowBookmapStep, Ownership, TaskSummary, TasksIndex } from "./contracts/bookmap.mjs";
|
|
8
8
|
import { AppMatch, GrimoireRule, GrimoireSnapshot, OpenGrimoireOptions } from "./contracts/snapshot.mjs";
|
|
9
|
-
import { ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRouteResult, ScrySearchResult } from "./contracts/scry.mjs";
|
|
9
|
+
import { ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchResult } from "./contracts/scry.mjs";
|
|
10
10
|
import { CollectedListText, ReleaseCollection, ReleaseEntry, WriteReleaseResult } from "./contracts/releases.mjs";
|
|
11
11
|
import { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST, GrimoireCode } from "./codes/codes.mjs";
|
|
12
12
|
import { GRIMOIRE_CODES_DOCS_URL, GrimoireError, createFinding, explainGrimoireCode, grimoireCodeDocsUrl, isGrimoireCode } from "./codes/index.mjs";
|
|
@@ -14,13 +14,14 @@ import { BookPathInput, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, boo
|
|
|
14
14
|
import { FrontMatterField, FrontMatterResult, FrontMatterValue, readFrontMatter } from "./front-matter/index.mjs";
|
|
15
15
|
import { FileGraph, fileGraph, importClosure, importerClosure } from "./graph/index.mjs";
|
|
16
16
|
import { ParseGrimoireResult, parseGrimoire } from "./written/parse-grimoire.mjs";
|
|
17
|
-
import { buildBook, loadBook } from "./book/build.mjs";
|
|
17
|
+
import { BookCheck, buildBook, checkBook, loadBook } from "./book/build.mjs";
|
|
18
18
|
import { writeBook } from "./book/write.mjs";
|
|
19
19
|
import { resolveOwnership } from "./ownership/index.mjs";
|
|
20
20
|
import { matchApps } from "./apps/match-apps.mjs";
|
|
21
21
|
import { CollectedInput, buildCollectedFiles } from "./bookmap/build.mjs";
|
|
22
22
|
import { writeCollectedFiles } from "./bookmap/write.mjs";
|
|
23
23
|
import { openGrimoire } from "./workspace/index.mjs";
|
|
24
|
+
import { openStoredGrimoire } from "./workspace/stored.mjs";
|
|
24
25
|
import { ScanProofsResult, scanProofs, scanProofsInText } from "./proves/scan-proofs.mjs";
|
|
25
26
|
import { checkGrimoire } from "./check/check-grimoire.mjs";
|
|
26
27
|
import { formatCheckReport } from "./check/format-check-report.mjs";
|
|
@@ -30,4 +31,5 @@ import { readTestResults } from "./test-results/index.mjs";
|
|
|
30
31
|
import { formatScryResult } from "./scry/format.mjs";
|
|
31
32
|
import { parseScryQuery } from "./scry/parse.mjs";
|
|
32
33
|
import { scry } from "./scry/query.mjs";
|
|
33
|
-
|
|
34
|
+
import { SCRY_STOP_WORDS } from "./scry/search.mjs";
|
|
35
|
+
export { AppMatch, 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, COLLECTED_END_MARKER, COLLECTED_START_MARKER, CaseQuestion, ChangeWord, CollectedFiles, type CollectedInput, CollectedListText, CriterionId, CriterionStatus, type CriterionTestResult, 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, GrimoireRule, GrimoireSeverity, GrimoireSnapshot, LoadedBook, Located, OpenGrimoireOptions, Ownership, type ParseGrimoireResult, ProofLine, ProofResult, ReleaseCollection, ReleaseEntry, RouteFreshness, SCRY_STOP_WORDS, type ScanProofsResult, ScryError, ScryFeatureFlow, ScryFeatureResult, ScryFileResult, ScryFlowResult, ScryHit, ScryHitType, ScryImpactResult, ScryNotes, ScryPageRef, ScryQuery, ScryResult, ScryRoutePage, ScryRouteResult, ScrySearchResult, SourceLocation, StepType, TaskStatus, TaskSummary, TaskType, TasksIndex, TestOutcome, TestResultsInfo, TestResultsStore, UnmatchedProof, WriteBookResult, WriteReleaseResult, WrittenApp, WrittenBlockFile, WrittenBlockRow, WrittenCase, WrittenChangelog, WrittenChangelogEntry, WrittenChangelogSection, WrittenChangesWith, WrittenCriterion, WrittenEntryPoint, WrittenFeature, WrittenFeatureReadme, WrittenFlow, WrittenGrimoire, WrittenLayout, WrittenListLine, WrittenOrigin, WrittenPage, WrittenRelease, WrittenReleaseListed, WrittenScreenshot, 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, scanProofs, scanProofsInText, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
package/esm/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { readFrontMatter } from "./front-matter/index.mjs";
|
|
|
7
7
|
import { fileGraph, importClosure, importerClosure } from "./graph/index.mjs";
|
|
8
8
|
import { parseGrimoire } from "./written/parse-grimoire.mjs";
|
|
9
9
|
import "./written/index.mjs";
|
|
10
|
-
import { buildBook, loadBook } from "./book/build.mjs";
|
|
10
|
+
import { buildBook, checkBook, loadBook } from "./book/build.mjs";
|
|
11
11
|
import { writeBook } from "./book/write.mjs";
|
|
12
12
|
import "./book/index.mjs";
|
|
13
13
|
import { resolveOwnership } from "./ownership/index.mjs";
|
|
@@ -21,13 +21,15 @@ import "./bookmap/index.mjs";
|
|
|
21
21
|
import { scanProofs, scanProofsInText } from "./proves/scan-proofs.mjs";
|
|
22
22
|
import "./proves/index.mjs";
|
|
23
23
|
import { openGrimoire } from "./workspace/index.mjs";
|
|
24
|
+
import { openStoredGrimoire } from "./workspace/stored.mjs";
|
|
24
25
|
import { collectRelease, renderCollectedList, writeRelease } from "./releases/index.mjs";
|
|
25
26
|
import { checkGrimoire } from "./check/check-grimoire.mjs";
|
|
26
27
|
import { formatCheckReport } from "./check/format-check-report.mjs";
|
|
27
28
|
import "./check/index.mjs";
|
|
28
29
|
import { formatScryResult } from "./scry/format.mjs";
|
|
29
30
|
import { parseScryQuery } from "./scry/parse.mjs";
|
|
31
|
+
import { SCRY_STOP_WORDS } from "./scry/search.mjs";
|
|
30
32
|
import { scry } from "./scry/query.mjs";
|
|
31
33
|
import "./scry/index.mjs";
|
|
32
34
|
|
|
33
|
-
export { BOOK_SCHEMA_VERSION, CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireError, bookEntryPath, bookEntryPaths, buildBook, buildCollectedFiles, checkGrimoire, collectRelease, createFinding, criterionStatus, explainGrimoireCode, fileGraph, formatCheckReport, formatScryResult, grimoireCodeDocsUrl, importClosure, importerClosure, isGrimoireCode, loadBook, matchApps, openGrimoire, parseGrimoire, parseScryQuery, readFrontMatter, readTestResults, renderCollectedList, resolveOwnership, scanProofs, scanProofsInText, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
|
35
|
+
export { BOOK_SCHEMA_VERSION, CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GRIMOIRE_DIR, GRIMOIRE_IGNORE_RULES, GRIMOIRE_PATHS, GrimoireError, SCRY_STOP_WORDS, 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, scanProofs, scanProofsInText, scry, toPosixPath, writeBook, writeCollectedFiles, writeRelease };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { explainGrimoireCode } from "../codes/index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/grimoire/src/scry/error.ts
|
|
4
|
+
/**
|
|
5
|
+
* The `ScryError` of a failed question: what `warlock scry --json` prints on
|
|
6
|
+
* stdout and what the scry MCP tools return as their error text.
|
|
7
|
+
*/
|
|
8
|
+
/** The code, the message and the code's fix text (`""` when it has none). */
|
|
9
|
+
function scryErrorOf(error) {
|
|
10
|
+
return {
|
|
11
|
+
type: "error",
|
|
12
|
+
code: error.code,
|
|
13
|
+
message: error.message,
|
|
14
|
+
fix: explainGrimoireCode(error.code)?.fix ?? ""
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { scryErrorOf };
|
|
20
|
+
//# sourceMappingURL=error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/error.ts"],"sourcesContent":["/**\n * The `ScryError` of a failed question: what `warlock scry --json` prints on\n * stdout and what the scry MCP tools return as their error text.\n */\nimport { explainGrimoireCode, type GrimoireError } from \"../codes\";\nimport type { ScryError } from \"../contracts/scry\";\n\n/** The code, the message and the code's fix text (`\"\"` when it has none). */\nexport function scryErrorOf(error: GrimoireError): ScryError {\n return {\n type: \"error\",\n code: error.code,\n message: error.message,\n fix: explainGrimoireCode(error.code)?.fix ?? \"\",\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,YAAY,OAAiC;CAC3D,OAAO;EACL,MAAM;EACN,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,KAAK,oBAAoB,MAAM,IAAI,CAAC,EAAE,OAAO;CAC/C;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;;;;;;wBA+Yc,iBAAiB,QAAQ,YAAY,UAAS"}
|
package/esm/scry/format.mjs
CHANGED
|
@@ -76,6 +76,17 @@ function formatImpact(result, options) {
|
|
|
76
76
|
function formatRoute(result) {
|
|
77
77
|
const route = result.route;
|
|
78
78
|
const width = 12;
|
|
79
|
+
if (route === null) {
|
|
80
|
+
const first = result.pages[0];
|
|
81
|
+
return [
|
|
82
|
+
first === void 0 ? "page" : `GET ${first.route} (${first.type})`,
|
|
83
|
+
...section("pages", result.pages.map((page) => `${page.app} ${page.route} ${page.file}`), width),
|
|
84
|
+
...section("setup", result.pages.flatMap((page) => page.setupFile === null ? [] : [page.setupFile]), width),
|
|
85
|
+
...section("layouts", [...new Set(result.pages.flatMap((page) => page.layouts))], width),
|
|
86
|
+
...section("files", result.files, width),
|
|
87
|
+
...notes(result)
|
|
88
|
+
];
|
|
89
|
+
}
|
|
79
90
|
const auth = route.auth.required ? `required (${route.auth.userTypes.length > 0 ? route.auth.userTypes.join(", ") : "any user"})` : "none";
|
|
80
91
|
return [
|
|
81
92
|
`${route.method} ${route.path}${route.name === null ? "" : ` ${route.name}`}`,
|
|
@@ -181,11 +192,21 @@ function truncatedLine(result) {
|
|
|
181
192
|
const parts = Object.entries(result.counts).map(([type, count]) => `${count} ${type}`);
|
|
182
193
|
return [`showing ${result.hits.length} of ${total} (${parts.join(", ")}); raise --limit for more`];
|
|
183
194
|
}
|
|
195
|
+
/** A score for print: one decimal, or none from 100 up. */
|
|
196
|
+
function scoreText(score) {
|
|
197
|
+
return score >= 100 ? score.toFixed(0) : score.toFixed(1);
|
|
198
|
+
}
|
|
199
|
+
/** Hits in score order, one line each: `score type id detail (app) [matched]`. */
|
|
184
200
|
function formatSearch(result) {
|
|
185
201
|
if (result.hits.length === 0) return [`no match for ${JSON.stringify(result.text)}`, ...notes(result)];
|
|
202
|
+
const scoreWidth = Math.max(...result.hits.map((hit) => scoreText(hit.score).length));
|
|
186
203
|
const idWidth = Math.min(32, Math.max(0, ...result.hits.map((hit) => hit.id.length)));
|
|
187
204
|
return [
|
|
188
|
-
...result.hits.map((hit) =>
|
|
205
|
+
...result.hits.map((hit) => {
|
|
206
|
+
const head = `${scoreText(hit.score).padStart(scoreWidth)} ${hit.type.padEnd(9)}`;
|
|
207
|
+
const app = hit.app !== void 0 && hit.type === "file" ? ` (${hit.app})` : "";
|
|
208
|
+
return (hit.detail === null ? `${head}${hit.id}${app}` : `${head}${hit.id.padEnd(idWidth)} ${hit.detail}${app}`).trimEnd() + (hit.matched === void 0 ? "" : ` [${hit.matched}]`);
|
|
209
|
+
}),
|
|
189
210
|
...truncatedLine(result),
|
|
190
211
|
...notes(result)
|
|
191
212
|
];
|
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 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\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 idWidth = Math.min(32, Math.max(0, ...result.hits.map((hit) => hit.id.length)));\n\n return [\n ...result.hits.map(\n (hit) =>\n (hit.detail === null\n ? `${hit.type.padEnd(9)}${hit.id}`\n : `${hit.type.padEnd(9)}${hit.id.padEnd(idWidth)} ${hit.detail}`\n ).trimEnd() + (hit.matched === undefined ? \"\" : ` [${hit.matched}]`),\n ),\n ...truncatedLine(result),\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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,IAAI,OAC5B,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,IAAI,GAAG,OAAO,OAAO,EAAE,IAAI,IAAI,SAAQ,CACjE,QAAQ,KAAK,IAAI,YAAY,SAAY,KAAK,OAAO,IAAI,QAAQ,GACvE;EACA,GAAG,cAAc,MAAM;EACvB,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"}
|
|
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/** 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 ...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,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AM;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/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { formatScryResult } from "./format.mjs";
|
|
2
|
-
import { parseFeatureText, parseFlowText, parseLimit, parseRouteText, parseScryQuery } from "./parse.mjs";
|
|
2
|
+
import { parseApp, parseFeatureText, parseFlowText, parseLimit, parseRouteText, parseScryQuery } from "./parse.mjs";
|
|
3
|
+
import { SCRY_STOP_WORDS } from "./search.mjs";
|
|
3
4
|
import { scry } from "./query.mjs";
|
|
4
5
|
|
|
5
|
-
export { formatScryResult, parseFeatureText, parseFlowText, parseLimit, parseRouteText, parseScryQuery, scry };
|
|
6
|
+
export { SCRY_STOP_WORDS, formatScryResult, parseApp, parseFeatureText, parseFlowText, parseLimit, parseRouteText, parseScryQuery, scry };
|
package/esm/scry/parse.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { ScryQuery } from "../contracts/scry.mjs";
|
|
|
2
2
|
//#region ../../packages/grimoire/src/scry/parse.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The query of `warlock scry` arguments: a positional file, or one of the
|
|
5
|
-
* options `impact`, `route`, `feature`, `flow`, `search` (with `limit`).
|
|
5
|
+
* options `impact`, `route`, `feature`, `flow`, `search` (with `limit` and `app`).
|
|
6
6
|
* Throws `GrimoireError` `GR9006` for none, several, or a malformed value.
|
|
7
7
|
*/
|
|
8
8
|
export declare function parseScryQuery(args: readonly string[], options: Readonly<Record<string, string | boolean | number>>): ScryQuery;
|
package/esm/scry/parse.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/parse.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"parse.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/scry/parse.ts"],"mappings":";;;;;;;wBA6FgB,eACd,yBACA,SAAS,SAAS,6CACjB"}
|