@warlock.js/grimoire 5.56.0 → 5.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +2 -1
- package/esm/book/build.mjs.map +1 -1
- package/esm/book/render.mjs +10 -0
- package/esm/book/render.mjs.map +1 -1
- package/esm/bookmap/build.d.mts.map +1 -1
- package/esm/bookmap/build.mjs +2 -2
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +53 -38
- package/esm/bookmap/steps.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +4 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/criteria.mjs +21 -2
- package/esm/check/rules/criteria.mjs.map +1 -1
- package/esm/check/rules/screenshots.mjs +57 -0
- package/esm/check/rules/screenshots.mjs.map +1 -0
- package/esm/codes/codes.d.mts +12 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +6 -0
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +6 -0
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/book.d.mts +2 -0
- package/esm/contracts/book.d.mts.map +1 -1
- package/esm/contracts/book.mjs.map +1 -1
- package/esm/contracts/bookmap.d.mts +19 -1
- package/esm/contracts/bookmap.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +11 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/test-results.d.mts +34 -0
- package/esm/contracts/test-results.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +44 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/data.mjs +126 -4
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/index.d.mts +31 -1
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +94 -5
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/product-map.d.mts +14 -0
- package/esm/devtools/product-map.d.mts.map +1 -0
- package/esm/devtools/product-map.mjs +385 -0
- package/esm/devtools/product-map.mjs.map +1 -0
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +97 -21
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +71 -22
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/graph/index.d.mts +10 -1
- package/esm/graph/index.d.mts.map +1 -1
- package/esm/graph/index.mjs +3 -2
- package/esm/graph/index.mjs.map +1 -1
- package/esm/index.d.mts +4 -4
- package/esm/paths/index.d.mts +2 -0
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +3 -1
- package/esm/paths/index.mjs.map +1 -1
- package/esm/scry/compact.mjs +169 -0
- package/esm/scry/compact.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +7 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +12 -1
- package/esm/scry/query.mjs.map +1 -1
- package/esm/test-results/index.d.mts +7 -2
- package/esm/test-results/index.d.mts.map +1 -1
- package/esm/test-results/index.mjs +79 -12
- package/esm/test-results/index.mjs.map +1 -1
- package/esm/vitest/index.d.mts +6 -0
- package/esm/vitest/index.d.mts.map +1 -1
- package/esm/vitest/index.mjs +22 -6
- package/esm/vitest/index.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +6 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/mcp-tools.mjs +48 -12
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +4 -2
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/written/apps.mjs +4 -2
- package/esm/written/apps.mjs.map +1 -1
- package/esm/written/features.mjs +119 -6
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/markdown.mjs +66 -1
- package/esm/written/markdown.mjs.map +1 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +1 -1
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/llms-full.txt +77 -2
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +5 -0
- package/skills/describe-an-app/SKILL.md +12 -0
- package/skills/record-a-change/SKILL.md +8 -0
- package/skills/use-the-grimoire/SKILL.md +15 -0
- package/skills/write-a-feature/SKILL.md +37 -2
- package/ui/grimoire-static.js +4 -0
- package/ui/grimoire-view.js +2283 -428
- package/ui/grimoire.css +1036 -45
- package/ui/product-map.css +636 -0
- package/ui/product-map.js +817 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/adapter.ts"],"sourcesContent":["/**\n * The Warlock adapter: turns core's inspect report into the book's facts.\n * It never parses app source itself: files come from `collectFiles()`,\n * routes, events and jobs from `inspectApp()` after the `warlock inspect`\n * boot pass, pages from `inspectApp()` (the web page graph, no boot), and\n * mobile apps from their folders.\n *\n * `@warlock.js/core/tooling` is imported inside the methods, never at the\n * top: this module is reached from `warlock.config.ts`.\n */\nimport { readFileSync } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n InspectFile,\n InspectReport,\n InspectRoute,\n InspectSection,\n} from \"@warlock.js/core/tooling\";\nimport type {\n BookAdapter,\n BookFile,\n BookMobileApp,\n BookNamedThing,\n BookPage,\n BookRoute,\n BookSite,\n} from \"../contracts/adapter\";\nimport { isCodeFile, isInsideFolder, toPosixPath } from \"../paths\";\nimport { collectMobileFacts, type MobileAppOption } from \"./mobile-facts\";\n\n/**\n * Reads the sections of the inspect report that need the app booted\n * (`routes`, `events`, `jobs`) for the project at `root`. The default boots\n * the app once, the `warlock inspect` way (connectors boot, none starts).\n * `warlock mcp` passes its own, which shares the server's boot.\n */\nexport type WarlockInspect = (\n root: string,\n sections: readonly InspectSection[],\n) => Promise<InspectReport>;\n\n/** Options of `createWarlockAdapter()`. */\nexport type WarlockAdapterOptions = {\n /**\n * Mobile apps in the repository: folder, id and routing. Default: every\n * top-level folder with an `app.json` or an `app.config.*` file; it is\n * file-routed when its `package.json` lists `expo-router` (screens come\n * from the files), and code-navigated otherwise (no screens: the agent\n * declares them in `grimoire/apps/<app>/screens/`).\n */\n mobile?: readonly MobileAppOption[];\n /** How the booted sections are read. Default: the `warlock inspect` boot pass, run at most once. Pages never boot. */\n inspect?: WarlockInspect;\n};\n\n/** The `version` of a `package.json` named `name`, or `null` when the file is not that package's. */\nfunction versionIn(file: string, name: string): string | null {\n try {\n const manifest = JSON.parse(readFileSync(file, \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n return manifest.name === name && typeof manifest.version === \"string\" ? manifest.version : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The installed version of a package, read from its `package.json` without\n * going through its `exports` (published `@warlock.js/core` exports neither\n * `./package.json` nor a `require` condition). It resolves the package's\n * entry and walks up to the `package.json` with that name; when the entry\n * cannot be resolved, it looks in each `node_modules` above `from`.\n *\n * @param from Absolute folder to look from.\n * @param resolve Resolves a bare specifier to a file URL or path (`import.meta.resolve`).\n */\nexport function installedVersion(\n name: string,\n from: string,\n resolve: ((specifier: string) => string) | undefined,\n): string | null {\n try {\n const entry = resolve?.(name);\n\n if (entry !== undefined) {\n let folder = path.dirname(entry.startsWith(\"file:\") ? fileURLToPath(entry) : entry);\n\n for (;;) {\n const version = versionIn(path.join(folder, \"package.json\"), name);\n\n if (version !== null) return version;\n\n const parent = path.dirname(folder);\n\n if (parent === folder) break;\n\n folder = parent;\n }\n }\n } catch {\n // Not resolvable from here: look in the node_modules folders below.\n }\n\n for (let folder = from; ; folder = path.dirname(folder)) {\n const version = versionIn(\n path.join(folder, \"node_modules\", ...name.split(\"/\"), \"package.json\"),\n name,\n );\n\n if (version !== null) return version;\n if (path.dirname(folder) === folder) return null;\n }\n}\n\n/** The framework version, for the book manifest (a core upgrade rebuilds the book). */\nfunction coreVersion(): string {\n const resolve =\n typeof import.meta.resolve === \"function\"\n ? (specifier: string) => import.meta.resolve(specifier)\n : undefined;\n\n return (\n installedVersion(\"@warlock.js/core\", path.dirname(fileURLToPath(import.meta.url)), resolve) ??\n \"unknown\"\n );\n}\n\n/** Run `work` with `console.log`/`info`/`debug` on stderr, so a boot never mixes with `--json` output. */\nasync function withConsoleOnStderr<T>(work: () => Promise<T>): Promise<T> {\n const { log, info, debug } = console;\n const toStderr = (...args: unknown[]) => console.error(...args);\n\n console.log = toStderr;\n console.info = toStderr;\n console.debug = toStderr;\n\n try {\n return await work();\n } finally {\n console.log = log;\n console.info = info;\n console.debug = debug;\n }\n}\n\n/** The default booted `inspect`: one boot pass, shared by every call. */\nfunction bootedInspect(): WarlockInspect {\n let boot: Promise<unknown> | undefined;\n\n return async (root, sections) => {\n const tooling = await import(\"@warlock.js/core/tooling\");\n\n boot ??= withConsoleOnStderr(() => tooling.bootForInspect(root));\n\n const booted = (await boot) as Awaited<ReturnType<typeof tooling.bootForInspect>>;\n\n if (!booted.context.booted) {\n const failures = booted.context.moduleFailures.map(\n (failure) => `${failure.file}: ${failure.message}`,\n );\n\n throw new Error(\n `the app did not boot${failures.length > 0 ? ` (${failures.join(\"; \")})` : \"\"}. Run warlock doctor to see why.`,\n );\n }\n\n return tooling.inspectApp({ ...tooling.inspectOptionsFromBoot(booted), cwd: root, sections });\n };\n}\n\n/** `send-receipt.job.ts` → `send-receipt` (the stem without the role suffix). */\nfunction stemOf(file: string, ...suffixes: string[]): string {\n const base = path.posix.basename(file).replace(/\\.(?:d\\.ts|[cm]?[jt]sx?)$/, \"\");\n\n for (const suffix of suffixes) {\n if (base.endsWith(`.${suffix}`)) return base.slice(0, -suffix.length - 1);\n }\n\n return base;\n}\n\nfunction toBookFile(file: InspectFile, mobile: readonly BookMobileApp[]): BookFile {\n const docs = file.exportDocs ?? {};\n const app = mobile.find((item) => isInsideFolder(file.file, item.root));\n\n return {\n file: file.file,\n module: file.module,\n type: file.role,\n lines: file.lines ?? 0,\n about: file.about ?? null,\n tags: file.tags ?? {},\n exports: file.exports.map((name) => ({ name, about: docs[name] ?? null })),\n imports: file.imports.map((entry) => ({ specifier: entry.specifier, file: entry.file })),\n importedBy: [...file.importedBy],\n mobileApp: app?.id ?? null,\n };\n}\n\n/** Files by the names they export, built once per `routes()` call. */\ntype ExportIndex = () => ReadonlyMap<string, readonly string[]>;\n\nfunction exportIndex(files: ReadonlyMap<string, BookFile>): ExportIndex {\n let index: Map<string, string[]> | undefined;\n\n return () => {\n if (index) return index;\n\n index = new Map();\n\n for (const file of files.values()) {\n for (const entry of file.exports) {\n const list = index.get(entry.name) ?? [];\n\n list.push(file.file);\n index.set(entry.name, list);\n }\n }\n\n return index;\n };\n}\n\n/** The file that defines a route's handler: the controller's file for a tuple, else the file exporting the handler. */\nfunction handlerFileOf(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): string | null {\n if (route.isPage) {\n return pages.find((page) => page.route === route.path)?.file ?? null;\n }\n\n const exportsName = (file: string | null | undefined, name: string): boolean =>\n file !== null &&\n file !== undefined &&\n files.get(file)?.exports.some((entry) => entry.name === name) === true;\n const imported =\n route.sourceFile === null\n ? []\n : (files.get(route.sourceFile)?.imports ?? []).map((entry) => entry.file);\n const name = route.controller ?? route.handler;\n\n if (!name || name === \"anonymous\") return null;\n\n const fromImports = imported.find((file) => exportsName(file, name));\n\n if (fromImports) return fromImports;\n if (exportsName(route.sourceFile, name)) return route.sourceFile;\n\n // Not imported by the routes file: the one file in the project exporting it, when there is only one.\n const anywhere = [...new Set(exporters().get(name) ?? [])];\n\n return anywhere.length === 1 ? (anywhere[0] ?? null) : null;\n}\n\nfunction toBookRoute(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): BookRoute {\n const controller = route.controller ?? null;\n const action = route.action ?? null;\n const handler =\n controller !== null && action !== null && !route.handler.includes(\".\")\n ? `${controller}.${action}`\n : route.handler;\n\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name,\n sourceFile: route.sourceFile === null ? null : toPosixPath(route.sourceFile),\n handler,\n controller,\n action,\n handlerFile: handlerFileOf(route, files, pages, exporters),\n middleware: [...route.middleware],\n auth: { required: route.auth.required, userTypes: [...route.auth.userTypes] },\n isPage: route.isPage,\n description: route.description,\n };\n}\n\nasync function folderNames(dir: string): Promise<string[]> {\n try {\n return (await readdir(dir, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n } catch {\n return [];\n }\n}\n\n/** The site folders of a multi-site app (`src/web/$sites/<id>`), sorted; empty for a single site. */\nfunction siteFolders(root: string): Promise<string[]> {\n return folderNames(path.join(root, \"src\", \"web\", \"$sites\"));\n}\n\n/** `web.sites` from the loaded config, or `undefined` when `src/config/web.ts` is not loaded. */\nasync function webSitesConfig(): Promise<\n Record<string, { basePath?: unknown } | undefined> | undefined\n> {\n const { config } = await import(\"@warlock.js/core\");\n const sites: unknown = config.key(\"web.sites\");\n\n return typeof sites === \"object\" && sites !== null\n ? (sites as Record<string, { basePath?: unknown }>)\n : undefined;\n}\n\n/**\n * Folders of a mobile app that hold native projects, build output or tool\n * caches, never app source. `node_modules` and dot folders are skipped too.\n */\nconst MOBILE_SKIPPED_FOLDERS = new Set([\n \"android\",\n \"ios\",\n \"build\",\n \"dist\",\n \"web-build\",\n \"coverage\",\n \"node_modules\",\n]);\n\n/**\n * The source folders of a mobile app: its top-level folders minus native\n * projects and build output (`android/`, `ios/` with Pods and builds can hold\n * hundreds of megabytes). Code files directly in the app folder (`App.tsx`)\n * are not read: `collectFiles` scans folders only.\n */\nasync function mobileSourceFolders(root: string, app: BookMobileApp): Promise<string[]> {\n return (await folderNames(path.join(root, ...app.root.split(\"/\"))))\n .filter((name) => !name.startsWith(\".\") && !MOBILE_SKIPPED_FOLDERS.has(name))\n .map((name) => `${app.root}/${name}`);\n}\n\n/** The adapter over `inspectApp()`, `collectFiles()` and the mobile app folders. */\nexport function createWarlockAdapter(options: WarlockAdapterOptions = {}): BookAdapter {\n const inspect = options.inspect ?? bootedInspect();\n const mobileOptions = options.mobile === undefined ? {} : { mobile: options.mobile };\n let lastFiles: { root: string; files: BookFile[] } | null = null;\n let lastPages: { root: string; pages: BookPage[] } | null = null;\n\n const mobileApps = (root: string) => collectMobileFacts(root, mobileOptions);\n\n /** `src` and each mobile app's source folders: what `files()` reads and the book fingerprints. */\n async function sourceFolders(root: string, mobile: readonly BookMobileApp[]): Promise<string[]> {\n const folders = await Promise.all(mobile.map((app) => mobileSourceFolders(root, app)));\n\n return [\"src\", ...folders.flat()];\n }\n\n async function files(root: string): Promise<BookFile[]> {\n const { collectFiles } = await import(\"@warlock.js/core/tooling\");\n const mobile = await mobileApps(root);\n const dirs = await sourceFolders(root, mobile);\n const collected = collectFiles(root, [], { dirs })\n .filter((file) => isCodeFile(file.file))\n .map((file) => toBookFile(file, mobile));\n\n lastFiles = { root, files: collected };\n\n return collected;\n }\n\n /** File facts for the routes: the last `files()` answer, else the book's cache, else a new scan. */\n async function currentFiles(root: string): Promise<BookFile[]> {\n if (lastFiles?.root === root) return lastFiles.files;\n\n const { loadBook } = await import(\"../book\");\n const book = await loadBook(root);\n\n return book?.facts.files ?? files(root);\n }\n\n async function pages(root: string): Promise<BookPage[]> {\n // A multi-site app's routes depend on `web.sites` (base paths), which only `src/config/web.ts` holds.\n if ((await siteFolders(root)).length > 0 && (await webSitesConfig()) === undefined) {\n throw new Error(\n \"This app has several sites (src/web/$sites), and their page routes need src/config/web.ts, which is not loaded. Run the command through the warlock CLI, which loads it.\",\n );\n }\n\n // Pages come from the web page graph: files only, never a boot.\n const { inspectApp } = await import(\"@warlock.js/core/tooling\");\n const report = await inspectApp({ cwd: root, sections: [\"pages\"] });\n const found = (report.pages ?? []).map((page): BookPage => ({\n site: page.site ?? \"default\",\n route: page.path,\n name: page.name,\n file: toPosixPath(page.file),\n setupFile: page.setupFile === null ? null : toPosixPath(page.setupFile),\n layouts: page.layouts.map(toPosixPath),\n loaders: page.loaders.map(toPosixPath),\n actions: [...page.actions],\n requires: page.guard === null ? [] : [page.guard],\n reachedFrom: null,\n }));\n\n lastPages = { root, pages: found };\n\n return found;\n }\n\n return {\n name: \"warlock\",\n version: coreVersion(),\n async sourceRoots(root) {\n return sourceFolders(root, await mobileApps(root));\n },\n files,\n async routes(root) {\n const report = await inspect(root, [\"routes\"]);\n const known = new Map((await currentFiles(root)).map((file) => [file.file, file]));\n // Pages only name the file of a page route; a page problem is reported by `pages()` itself.\n const sitePages =\n lastPages?.root === root ? lastPages.pages : await pages(root).catch(() => []);\n\n const exporters = exportIndex(known);\n\n return (report.routes ?? []).map((route) => toBookRoute(route, known, sitePages, exporters));\n },\n async named(root) {\n const report = await inspect(root, [\"events\", \"jobs\", \"schedules\"]);\n const known = await currentFiles(root);\n const ofType = (type: string) => known.filter((file) => file.type === type);\n const named: BookNamedThing[] = [];\n\n // `*.mail.ts`, `*.email.ts` and the files of a `mails/` or `emails/` folder are all typed as mails.\n for (const file of ofType(\"mail\")) {\n named.push({\n type: \"mail\",\n name: stemOf(file.file, \"mail\", \"email\"),\n file: file.file,\n });\n }\n\n const jobFiles = ofType(\"job\");\n const jobFileOf = (name: string): string | null =>\n jobFiles.find((item) => {\n const stem = stemOf(item.file, \"job\");\n\n return name === stem || name.endsWith(`.${stem}`) || name.endsWith(`/${stem}`);\n })?.file ?? null;\n const seen = new Set<string>();\n\n // Queue jobs (`defineJob()`) and scheduled tasks are both jobs a flow can name.\n for (const name of [\n ...(report.jobs ?? []).map((job) => job.name),\n ...(report.schedules ?? []).map((schedule) => schedule.name),\n ]) {\n if (seen.has(name)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: jobFileOf(name) });\n }\n\n // A job file the registries do not list is still a job by its file name.\n for (const file of jobFiles) {\n const name = stemOf(file.file, \"job\");\n\n if (seen.has(name) || [...seen].some((item) => jobFileOf(item) === file.file)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: file.file });\n }\n\n for (const event of report.events ?? []) {\n const source = event.listeners[0]?.sourceFile;\n\n named.push({\n type: \"event\",\n name: event.event,\n file: source === undefined ? null : toPosixPath(source),\n });\n }\n\n for (const file of known) {\n if (/\\.notification\\.[cm]?[jt]sx?$/.test(file.file)) {\n named.push({\n type: \"notification\",\n name: stemOf(file.file, \"notification\"),\n file: file.file,\n });\n }\n }\n\n return named;\n },\n async sites(root): Promise<BookSite[]> {\n const multi = await siteFolders(root);\n\n if (multi.length > 0) {\n const configured = await webSitesConfig();\n\n return multi.map((id) => {\n const basePath: unknown = configured?.[id]?.basePath;\n\n return {\n id,\n root: `src/web/$sites/${id}`,\n basePath: typeof basePath === \"string\" ? basePath : null,\n };\n });\n }\n\n return (await folderNames(path.join(root, \"src\"))).includes(\"web\")\n ? [{ id: \"default\", root: \"src/web\", basePath: null }]\n : [];\n },\n pages,\n mobile: mobileApps,\n async tests(root) {\n const known = await currentFiles(root);\n const specs = known.filter((file) => file.type === \"spec\").map((file) => file.file);\n const outside: string[] = [];\n\n const walk = async (dir: string, pattern: RegExp): Promise<void> => {\n let entries;\n\n try {\n entries = await readdir(path.join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n\n const relative = `${dir}/${entry.name}`;\n\n if (entry.isDirectory()) await walk(relative, pattern);\n else if (entry.isFile() && pattern.test(entry.name)) outside.push(relative);\n }\n };\n\n await walk(\"e2e\", /\\.e2e\\.(?:ts|mts|js|mjs)$/);\n await walk(\"tests\", /\\.(?:test|spec)\\.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IAAI,MAAM,YAAY,GAAG,MAAM,KAAK,UAAU,OAAO;UAChD,IAAI,MAAM,OAAO,KAAK,QAAQ,KAAK,MAAM,IAAI,GAAG,QAAQ,KAAK,QAAQ;IAC5E;GACF;GAEA,MAAM,KAAK,OAAO,2BAA2B;GAC7C,MAAM,KAAK,SAAS,sBAAsB;GAE1C,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK;EACnD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"adapter.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/adapter.ts"],"sourcesContent":["/**\n * The Warlock adapter: turns core's inspect report into the book's facts.\n * It never parses app source itself: files come from `collectFiles()`,\n * routes, events and jobs from `inspectApp()` after the `warlock inspect`\n * boot pass, pages from `inspectApp()` (the web page graph, no boot), and\n * mobile apps from their folders.\n *\n * `@warlock.js/core/tooling` is imported inside the methods, never at the\n * top: this module is reached from `warlock.config.ts`.\n */\nimport { readFileSync } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n InspectFile,\n InspectReport,\n InspectRoute,\n InspectSection,\n} from \"@warlock.js/core/tooling\";\nimport type {\n BookAdapter,\n BookFile,\n BookMobileApp,\n BookNamedThing,\n BookPage,\n BookRoute,\n BookSite,\n} from \"../contracts/adapter\";\nimport { isCodeFile, isInsideFolder, toPosixPath } from \"../paths\";\nimport { collectMobileFacts, type MobileAppOption } from \"./mobile-facts\";\n\n/**\n * Reads the sections of the inspect report that need the app booted\n * (`routes`, `events`, `jobs`) for the project at `root`. The default boots\n * the app once, the `warlock inspect` way (connectors boot, none starts).\n * `warlock mcp` passes its own, which shares the server's boot.\n */\nexport type WarlockInspect = (\n root: string,\n sections: readonly InspectSection[],\n) => Promise<InspectReport>;\n\n/** Options of `createWarlockAdapter()`. */\nexport type WarlockAdapterOptions = {\n /**\n * Mobile apps in the repository: folder, id and routing. Default: every\n * top-level folder with an `app.json` or an `app.config.*` file; it is\n * file-routed when its `package.json` lists `expo-router` (screens come\n * from the files), and code-navigated otherwise (no screens: the agent\n * declares them in `grimoire/apps/<app>/screens/`).\n */\n mobile?: readonly MobileAppOption[];\n /** How the booted sections are read. Default: the `warlock inspect` boot pass, run at most once. Pages never boot. */\n inspect?: WarlockInspect;\n};\n\n/** The `version` of a `package.json` named `name`, or `null` when the file is not that package's. */\nfunction versionIn(file: string, name: string): string | null {\n try {\n const manifest = JSON.parse(readFileSync(file, \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n return manifest.name === name && typeof manifest.version === \"string\" ? manifest.version : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The installed version of a package, read from its `package.json` without\n * going through its `exports` (published `@warlock.js/core` exports neither\n * `./package.json` nor a `require` condition). It resolves the package's\n * entry and walks up to the `package.json` with that name; when the entry\n * cannot be resolved, it looks in each `node_modules` above `from`.\n *\n * @param from Absolute folder to look from.\n * @param resolve Resolves a bare specifier to a file URL or path (`import.meta.resolve`).\n */\nexport function installedVersion(\n name: string,\n from: string,\n resolve: ((specifier: string) => string) | undefined,\n): string | null {\n try {\n const entry = resolve?.(name);\n\n if (entry !== undefined) {\n let folder = path.dirname(entry.startsWith(\"file:\") ? fileURLToPath(entry) : entry);\n\n for (;;) {\n const version = versionIn(path.join(folder, \"package.json\"), name);\n\n if (version !== null) return version;\n\n const parent = path.dirname(folder);\n\n if (parent === folder) break;\n\n folder = parent;\n }\n }\n } catch {\n // Not resolvable from here: look in the node_modules folders below.\n }\n\n for (let folder = from; ; folder = path.dirname(folder)) {\n const version = versionIn(\n path.join(folder, \"node_modules\", ...name.split(\"/\"), \"package.json\"),\n name,\n );\n\n if (version !== null) return version;\n if (path.dirname(folder) === folder) return null;\n }\n}\n\n/** The framework version, for the book manifest (a core upgrade rebuilds the book). */\nfunction coreVersion(): string {\n const resolve =\n typeof import.meta.resolve === \"function\"\n ? (specifier: string) => import.meta.resolve(specifier)\n : undefined;\n\n return (\n installedVersion(\"@warlock.js/core\", path.dirname(fileURLToPath(import.meta.url)), resolve) ??\n \"unknown\"\n );\n}\n\n/** Run `work` with `console.log`/`info`/`debug` on stderr, so a boot never mixes with `--json` output. */\nasync function withConsoleOnStderr<T>(work: () => Promise<T>): Promise<T> {\n const { log, info, debug } = console;\n const toStderr = (...args: unknown[]) => console.error(...args);\n\n console.log = toStderr;\n console.info = toStderr;\n console.debug = toStderr;\n\n try {\n return await work();\n } finally {\n console.log = log;\n console.info = info;\n console.debug = debug;\n }\n}\n\n/** The default booted `inspect`: one boot pass, shared by every call. */\nfunction bootedInspect(): WarlockInspect {\n let boot: Promise<unknown> | undefined;\n\n return async (root, sections) => {\n const tooling = await import(\"@warlock.js/core/tooling\");\n\n boot ??= withConsoleOnStderr(() => tooling.bootForInspect(root));\n\n const booted = (await boot) as Awaited<ReturnType<typeof tooling.bootForInspect>>;\n\n if (!booted.context.booted) {\n const failures = booted.context.moduleFailures.map(\n (failure) => `${failure.file}: ${failure.message}`,\n );\n\n throw new Error(\n `the app did not boot${failures.length > 0 ? ` (${failures.join(\"; \")})` : \"\"}. Run warlock doctor to see why.`,\n );\n }\n\n return tooling.inspectApp({ ...tooling.inspectOptionsFromBoot(booted), cwd: root, sections });\n };\n}\n\n/** `send-receipt.job.ts` → `send-receipt` (the stem without the role suffix). */\nfunction stemOf(file: string, ...suffixes: string[]): string {\n const base = path.posix.basename(file).replace(/\\.(?:d\\.ts|[cm]?[jt]sx?)$/, \"\");\n\n for (const suffix of suffixes) {\n if (base.endsWith(`.${suffix}`)) return base.slice(0, -suffix.length - 1);\n }\n\n return base;\n}\n\nfunction toBookFile(file: InspectFile, mobile: readonly BookMobileApp[]): BookFile {\n const docs = file.exportDocs ?? {};\n const app = mobile.find((item) => isInsideFolder(file.file, item.root));\n\n return {\n file: file.file,\n module: file.module,\n type: file.role,\n lines: file.lines ?? 0,\n about: file.about ?? null,\n tags: file.tags ?? {},\n exports: file.exports.map((name) => ({ name, about: docs[name] ?? null })),\n imports: file.imports.map((entry) =>\n entry.typeOnly === true\n ? { specifier: entry.specifier, file: entry.file, typeOnly: true }\n : { specifier: entry.specifier, file: entry.file },\n ),\n importedBy: [...file.importedBy],\n mobileApp: app?.id ?? null,\n };\n}\n\n/** Files by the names they export, built once per `routes()` call. */\ntype ExportIndex = () => ReadonlyMap<string, readonly string[]>;\n\nfunction exportIndex(files: ReadonlyMap<string, BookFile>): ExportIndex {\n let index: Map<string, string[]> | undefined;\n\n return () => {\n if (index) return index;\n\n index = new Map();\n\n for (const file of files.values()) {\n for (const entry of file.exports) {\n const list = index.get(entry.name) ?? [];\n\n list.push(file.file);\n index.set(entry.name, list);\n }\n }\n\n return index;\n };\n}\n\n/** The file that defines a route's handler: the controller's file for a tuple, else the file exporting the handler. */\nfunction handlerFileOf(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): string | null {\n if (route.isPage) {\n return pages.find((page) => page.route === route.path)?.file ?? null;\n }\n\n const exportsName = (file: string | null | undefined, name: string): boolean =>\n file !== null &&\n file !== undefined &&\n files.get(file)?.exports.some((entry) => entry.name === name) === true;\n const imported =\n route.sourceFile === null\n ? []\n : (files.get(route.sourceFile)?.imports ?? []).map((entry) => entry.file);\n const name = route.controller ?? route.handler;\n\n if (!name || name === \"anonymous\") return null;\n\n const fromImports = imported.find((file) => exportsName(file, name));\n\n if (fromImports) return fromImports;\n if (exportsName(route.sourceFile, name)) return route.sourceFile;\n\n // Not imported by the routes file: the one file in the project exporting it, when there is only one.\n const anywhere = [...new Set(exporters().get(name) ?? [])];\n\n return anywhere.length === 1 ? (anywhere[0] ?? null) : null;\n}\n\nfunction toBookRoute(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): BookRoute {\n const controller = route.controller ?? null;\n const action = route.action ?? null;\n const handler =\n controller !== null && action !== null && !route.handler.includes(\".\")\n ? `${controller}.${action}`\n : route.handler;\n\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name,\n sourceFile: route.sourceFile === null ? null : toPosixPath(route.sourceFile),\n handler,\n controller,\n action,\n handlerFile: handlerFileOf(route, files, pages, exporters),\n middleware: [...route.middleware],\n auth: { required: route.auth.required, userTypes: [...route.auth.userTypes] },\n isPage: route.isPage,\n description: route.description,\n };\n}\n\nasync function folderNames(dir: string): Promise<string[]> {\n try {\n return (await readdir(dir, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n } catch {\n return [];\n }\n}\n\n/** The site folders of a multi-site app (`src/web/$sites/<id>`), sorted; empty for a single site. */\nfunction siteFolders(root: string): Promise<string[]> {\n return folderNames(path.join(root, \"src\", \"web\", \"$sites\"));\n}\n\n/** `web.sites` from the loaded config, or `undefined` when `src/config/web.ts` is not loaded. */\nasync function webSitesConfig(): Promise<\n Record<string, { basePath?: unknown } | undefined> | undefined\n> {\n const { config } = await import(\"@warlock.js/core\");\n const sites: unknown = config.key(\"web.sites\");\n\n return typeof sites === \"object\" && sites !== null\n ? (sites as Record<string, { basePath?: unknown }>)\n : undefined;\n}\n\n/**\n * Folders of a mobile app that hold native projects, build output or tool\n * caches, never app source. `node_modules` and dot folders are skipped too.\n */\nconst MOBILE_SKIPPED_FOLDERS = new Set([\n \"android\",\n \"ios\",\n \"build\",\n \"dist\",\n \"web-build\",\n \"coverage\",\n \"node_modules\",\n]);\n\n/**\n * The source folders of a mobile app: its top-level folders minus native\n * projects and build output (`android/`, `ios/` with Pods and builds can hold\n * hundreds of megabytes). Code files directly in the app folder (`App.tsx`)\n * are not read: `collectFiles` scans folders only.\n */\nasync function mobileSourceFolders(root: string, app: BookMobileApp): Promise<string[]> {\n return (await folderNames(path.join(root, ...app.root.split(\"/\"))))\n .filter((name) => !name.startsWith(\".\") && !MOBILE_SKIPPED_FOLDERS.has(name))\n .map((name) => `${app.root}/${name}`);\n}\n\n/** The adapter over `inspectApp()`, `collectFiles()` and the mobile app folders. */\nexport function createWarlockAdapter(options: WarlockAdapterOptions = {}): BookAdapter {\n const inspect = options.inspect ?? bootedInspect();\n const mobileOptions = options.mobile === undefined ? {} : { mobile: options.mobile };\n let lastFiles: { root: string; files: BookFile[] } | null = null;\n let lastPages: { root: string; pages: BookPage[] } | null = null;\n\n const mobileApps = (root: string) => collectMobileFacts(root, mobileOptions);\n\n /** `src` and each mobile app's source folders: what `files()` reads and the book fingerprints. */\n async function sourceFolders(root: string, mobile: readonly BookMobileApp[]): Promise<string[]> {\n const folders = await Promise.all(mobile.map((app) => mobileSourceFolders(root, app)));\n\n return [\"src\", ...folders.flat()];\n }\n\n async function files(root: string): Promise<BookFile[]> {\n const { collectFiles } = await import(\"@warlock.js/core/tooling\");\n const mobile = await mobileApps(root);\n const dirs = await sourceFolders(root, mobile);\n const collected = collectFiles(root, [], { dirs })\n .filter((file) => isCodeFile(file.file))\n .map((file) => toBookFile(file, mobile));\n\n lastFiles = { root, files: collected };\n\n return collected;\n }\n\n /** File facts for the routes: the last `files()` answer, else the book's cache, else a new scan. */\n async function currentFiles(root: string): Promise<BookFile[]> {\n if (lastFiles?.root === root) return lastFiles.files;\n\n const { loadBook } = await import(\"../book\");\n const book = await loadBook(root);\n\n return book?.facts.files ?? files(root);\n }\n\n async function pages(root: string): Promise<BookPage[]> {\n // A multi-site app's routes depend on `web.sites` (base paths), which only `src/config/web.ts` holds.\n if ((await siteFolders(root)).length > 0 && (await webSitesConfig()) === undefined) {\n throw new Error(\n \"This app has several sites (src/web/$sites), and their page routes need src/config/web.ts, which is not loaded. Run the command through the warlock CLI, which loads it.\",\n );\n }\n\n // Pages come from the web page graph: files only, never a boot.\n const { inspectApp } = await import(\"@warlock.js/core/tooling\");\n const report = await inspectApp({ cwd: root, sections: [\"pages\"] });\n const found = (report.pages ?? []).map((page): BookPage => ({\n site: page.site ?? \"default\",\n route: page.path,\n name: page.name,\n file: toPosixPath(page.file),\n setupFile: page.setupFile === null ? null : toPosixPath(page.setupFile),\n layouts: page.layouts.map(toPosixPath),\n loaders: page.loaders.map(toPosixPath),\n actions: [...page.actions],\n requires: page.guard === null ? [] : [page.guard],\n reachedFrom: null,\n }));\n\n lastPages = { root, pages: found };\n\n return found;\n }\n\n return {\n name: \"warlock\",\n version: coreVersion(),\n async sourceRoots(root) {\n return sourceFolders(root, await mobileApps(root));\n },\n files,\n async routes(root) {\n const report = await inspect(root, [\"routes\"]);\n const known = new Map((await currentFiles(root)).map((file) => [file.file, file]));\n // Pages only name the file of a page route; a page problem is reported by `pages()` itself.\n const sitePages =\n lastPages?.root === root ? lastPages.pages : await pages(root).catch(() => []);\n\n const exporters = exportIndex(known);\n\n return (report.routes ?? []).map((route) => toBookRoute(route, known, sitePages, exporters));\n },\n async named(root) {\n const report = await inspect(root, [\"events\", \"jobs\", \"schedules\"]);\n const known = await currentFiles(root);\n const ofType = (type: string) => known.filter((file) => file.type === type);\n const named: BookNamedThing[] = [];\n\n // `*.mail.ts`, `*.email.ts` and the files of a `mails/` or `emails/` folder are all typed as mails.\n for (const file of ofType(\"mail\")) {\n named.push({\n type: \"mail\",\n name: stemOf(file.file, \"mail\", \"email\"),\n file: file.file,\n });\n }\n\n const jobFiles = ofType(\"job\");\n const jobFileOf = (name: string): string | null =>\n jobFiles.find((item) => {\n const stem = stemOf(item.file, \"job\");\n\n return name === stem || name.endsWith(`.${stem}`) || name.endsWith(`/${stem}`);\n })?.file ?? null;\n const seen = new Set<string>();\n\n // Queue jobs (`defineJob()`) and scheduled tasks are both jobs a flow can name.\n for (const name of [\n ...(report.jobs ?? []).map((job) => job.name),\n ...(report.schedules ?? []).map((schedule) => schedule.name),\n ]) {\n if (seen.has(name)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: jobFileOf(name) });\n }\n\n // A job file the registries do not list is still a job by its file name.\n for (const file of jobFiles) {\n const name = stemOf(file.file, \"job\");\n\n if (seen.has(name) || [...seen].some((item) => jobFileOf(item) === file.file)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: file.file });\n }\n\n for (const event of report.events ?? []) {\n const source = event.listeners[0]?.sourceFile;\n\n named.push({\n type: \"event\",\n name: event.event,\n file: source === undefined ? null : toPosixPath(source),\n });\n }\n\n for (const file of known) {\n if (/\\.notification\\.[cm]?[jt]sx?$/.test(file.file)) {\n named.push({\n type: \"notification\",\n name: stemOf(file.file, \"notification\"),\n file: file.file,\n });\n }\n }\n\n return named;\n },\n async sites(root): Promise<BookSite[]> {\n const multi = await siteFolders(root);\n\n if (multi.length > 0) {\n const configured = await webSitesConfig();\n\n return multi.map((id) => {\n const basePath: unknown = configured?.[id]?.basePath;\n\n return {\n id,\n root: `src/web/$sites/${id}`,\n basePath: typeof basePath === \"string\" ? basePath : null,\n };\n });\n }\n\n return (await folderNames(path.join(root, \"src\"))).includes(\"web\")\n ? [{ id: \"default\", root: \"src/web\", basePath: null }]\n : [];\n },\n pages,\n mobile: mobileApps,\n async tests(root) {\n const known = await currentFiles(root);\n const specs = known.filter((file) => file.type === \"spec\").map((file) => file.file);\n const outside: string[] = [];\n\n const walk = async (dir: string, pattern: RegExp): Promise<void> => {\n let entries;\n\n try {\n entries = await readdir(path.join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n\n const relative = `${dir}/${entry.name}`;\n\n if (entry.isDirectory()) await walk(relative, pattern);\n else if (entry.isFile() && pattern.test(entry.name)) outside.push(relative);\n }\n };\n\n await walk(\"e2e\", /\\.e2e\\.(?:ts|mts|js|mjs)$/);\n await walk(\"tests\", /\\.(?:test|spec)\\.ts$/);\n\n return [...new Set([...specs, ...outside])].sort();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0DA,SAAS,UAAU,MAAc,MAA6B;CAC5D,IAAI;EACF,MAAM,WAAW,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC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AI,GAAG,QAAQ,KAAK,QAAQ;IAC5E;GACF;GAEA,MAAM,KAAK,OAAO,2BAA2B;GAC7C,MAAM,KAAK,SAAS,sBAAsB;GAE1C,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK;EACnD;CACF;AACF"}
|
|
@@ -106,19 +106,55 @@ function createGrimoireMcpTools(context, options = {}, adapterFor) {
|
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
name: "grimoire_flow",
|
|
109
|
-
description: "One flow: steps with the
|
|
110
|
-
input: inputSchema({
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
description: "One flow: its summary, steps with file counts (direct, in the feature, reachable, type-only) and the first direct imports of each, cases, criteria with their tests and last results (pass, fail, stale, not run, no test), where it is shown, history and findings. Pass files with step to list one step's reachable or type-only files, a page at a time. Read-only.",
|
|
110
|
+
input: inputSchema({
|
|
111
|
+
flow: {
|
|
112
|
+
type: "string",
|
|
113
|
+
description: "<feature>/<flow>, like catalog/new-arrivals."
|
|
114
|
+
},
|
|
115
|
+
files: {
|
|
116
|
+
type: "string",
|
|
117
|
+
enum: ["reachable", "type-only"],
|
|
118
|
+
description: "With step: list the step's files that run (reachable) or only type imports reach (type-only)."
|
|
119
|
+
},
|
|
120
|
+
step: {
|
|
121
|
+
type: "integer",
|
|
122
|
+
description: "Step number, for files.",
|
|
123
|
+
minimum: 0
|
|
124
|
+
},
|
|
125
|
+
offset: {
|
|
126
|
+
type: "integer",
|
|
127
|
+
description: "First file to list (default 0); a page holds 200.",
|
|
128
|
+
minimum: 0
|
|
129
|
+
}
|
|
130
|
+
}, ["flow"]),
|
|
114
131
|
writes: false,
|
|
115
|
-
run:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
run: async (input) => {
|
|
133
|
+
try {
|
|
134
|
+
const [{ parseFlowText, scry }, { openGrimoire }, compact] = await Promise.all([
|
|
135
|
+
scryParts(),
|
|
136
|
+
import("../workspace/index.mjs"),
|
|
137
|
+
import("../scry/compact.mjs")
|
|
138
|
+
]);
|
|
139
|
+
const query = {
|
|
140
|
+
type: "flow",
|
|
141
|
+
...parseFlowText(text(input, "flow"))
|
|
142
|
+
};
|
|
143
|
+
const snapshot = await openGrimoire(root, await loadAdapter(), { routes: "cached" });
|
|
144
|
+
const result = scry(snapshot, query);
|
|
145
|
+
if (result.type !== "flow") return result;
|
|
146
|
+
const set = input.files;
|
|
147
|
+
if (set === void 0 || set === null) return compact.compactFlow(snapshot, result);
|
|
148
|
+
if (set !== "reachable" && set !== "type-only") throw new GrimoireError("GR9006", "Pass files as \"reachable\" or \"type-only\".");
|
|
149
|
+
const stepNumber = input.step;
|
|
150
|
+
const step = result.bookmap.steps.find((item) => item.index === stepNumber);
|
|
151
|
+
if (typeof stepNumber !== "number" || step === void 0) throw new GrimoireError("GR9006", `Pass step as one of the step numbers of ${result.bookmap.ref} (${result.bookmap.steps.map((item) => item.index).join(", ")}).`);
|
|
152
|
+
const offset = typeof input.offset === "number" && input.offset > 0 ? input.offset : 0;
|
|
153
|
+
return compact.stepFilePage(snapshot, result.bookmap, step, set, offset, 200);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return toolError(error);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
122
158
|
},
|
|
123
159
|
{
|
|
124
160
|
name: "grimoire_search",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tools.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/mcp-tools.ts"],"sourcesContent":["/**\n * The Grimoire tools `warlock mcp` and `warlock dev --mcp` serve. Each tool\n * loads its code inside `run`, so registering them costs nothing at start.\n * Answers are the same JSON objects `--json` prints.\n */\nimport { inputSchema, type WarlockMcpContext, type WarlockMcpTool } from \"@warlock.js/core\";\nimport { explainGrimoireCode, GrimoireError, grimoireCodeDocsUrl } from \"../codes\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { ScryQuery } from \"../contracts/scry\";\nimport type { WarlockAdapterOptions } from \"./adapter\";\n\n/** The names of the tools, in the order they are listed. */\nexport const GRIMOIRE_MCP_TOOL_NAMES = [\n \"grimoire_file\",\n \"grimoire_impact\",\n \"grimoire_route\",\n \"grimoire_feature\",\n \"grimoire_flow\",\n \"grimoire_search\",\n \"grimoire_check\",\n \"grimoire_build\",\n \"grimoire_release\",\n \"grimoire_explain\",\n] as const;\n\n/** A Grimoire error as a tool error: the code, what failed, and what to do. */\nfunction toolError(error: unknown): never {\n if (error instanceof GrimoireError) {\n const fix = explainGrimoireCode(error.code)?.fix;\n\n throw new Error(`${error.code}: ${error.message}${fix ? ` Fix: ${fix}` : \"\"}`);\n }\n\n throw error;\n}\n\nfunction text(input: Record<string, unknown>, name: string): string {\n const value = input[name];\n\n return typeof value === \"string\" ? value : \"\";\n}\n\n/** The tools for one MCP server. `adapterFor` is replaced in specs. */\nexport function createGrimoireMcpTools(\n context: Pick<WarlockMcpContext, \"cwd\" | \"inspect\">,\n options: WarlockAdapterOptions = {},\n adapterFor?: () => Promise<BookAdapter>,\n): WarlockMcpTool[] {\n const root = context.cwd;\n let adapter: Promise<BookAdapter> | undefined;\n\n // The server's own inspect: `warlock mcp` boots once for every tool, `warlock dev --mcp` reads the live app.\n const loadAdapter = (): Promise<BookAdapter> => {\n adapter ??=\n adapterFor?.() ??\n import(\"./adapter\").then(({ createWarlockAdapter }) =>\n createWarlockAdapter({\n ...options,\n inspect: (_root, sections) => context.inspect(sections),\n }),\n );\n\n return adapter;\n };\n\n const ask =\n (query: (input: Record<string, unknown>) => Promise<ScryQuery> | ScryQuery) =>\n async (input: Record<string, unknown>): Promise<unknown> => {\n try {\n const { answer } = await import(\"./actions\");\n\n return await answer(root, await loadAdapter(), await query(input));\n } catch (error) {\n return toolError(error);\n }\n };\n\n const scryParts = () => import(\"../scry\");\n\n return [\n {\n name: \"grimoire_file\",\n description:\n \"One source file from the Grimoire book: header sentence, owning feature and borrowers, flows that reach it, exports, imports, importers, routes, pages. Read-only; reads cached route facts and never boots the app.\",\n input: inputSchema(\n { file: { type: \"string\", description: \"Project-relative path (either separator).\" } },\n [\"file\"],\n ),\n writes: false,\n run: ask((input) => ({ type: \"file\", file: text(input, \"file\") })),\n },\n {\n name: \"grimoire_impact\",\n description:\n \"What a change to a file reaches: importers (direct and all), API routes, pages and screens, flows, features (owner and borrowers) and tests. Read-only.\",\n input: inputSchema(\n { file: { type: \"string\", description: \"Project-relative path of the file to change.\" } },\n [\"file\"],\n ),\n writes: false,\n run: ask((input) => ({ type: \"impact\", file: text(input, \"file\") })),\n },\n {\n name: \"grimoire_route\",\n description:\n \"One HTTP route: handler and its file, routes file, middleware, guard, the files behind it and the flow steps that name it. Read-only.\",\n input: inputSchema(\n {\n method: { type: \"string\", description: \"HTTP method (GET, POST…).\" },\n path: { type: \"string\", description: \"Path as registered (/api/products/:id).\" },\n },\n [\"method\", \"path\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { parseRouteText } = await scryParts();\n\n return {\n type: \"route\",\n ...parseRouteText(`${text(input, \"method\")} ${text(input, \"path\")}`),\n };\n }),\n },\n {\n name: \"grimoire_feature\",\n description:\n \"One feature: README, flows with status, its book map (own, borrowed and unreached files, routes, pages), recent changes, open tasks and its check findings. Read-only.\",\n input: inputSchema(\n {\n feature: { type: \"string\", description: \"Feature id (folder under grimoire/features/).\" },\n },\n [\"feature\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { parseFeatureText } = await scryParts();\n\n return { type: \"feature\", feature: parseFeatureText(text(input, \"feature\")) };\n }),\n },\n {\n name: \"grimoire_flow\",\n description:\n \"One flow: steps with the files behind each, cases, criteria with their tests and last results (pass, fail, stale, not run, no test), where it is shown, history and findings. Read-only.\",\n input: inputSchema(\n { flow: { type: \"string\", description: \"<feature>/<flow>, like catalog/new-arrivals.\" } },\n [\"flow\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { parseFlowText } = await scryParts();\n\n return { type: \"flow\", ...parseFlowText(text(input, \"flow\")) };\n }),\n },\n {\n name: \"grimoire_search\",\n description:\n \"Search the Grimoire by words: features, flows, blocks, pages, screens, routes, file paths, export names, header sentences and tasks, best match first. Read-only.\",\n input: inputSchema(\n {\n text: { type: \"string\", description: \"Words to look for, in any order.\" },\n limit: { type: \"integer\", description: \"Most hits to return (default 20).\", minimum: 1 },\n },\n [\"text\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const limit = input.limit;\n\n if (limit === undefined || limit === null)\n return { type: \"search\", text: text(input, \"text\") };\n\n const { parseLimit } = await scryParts();\n\n // A limit of 0, a negative or a fraction is refused with GR9006, as `--limit` is.\n return {\n type: \"search\",\n text: text(input, \"text\"),\n limit: parseLimit(typeof limit === \"number\" || typeof limit === \"string\" ? limit : true),\n };\n }),\n },\n {\n name: \"grimoire_check\",\n description:\n \"Run the Grimoire check: written names that point at nothing, files without a header or feature, criteria without tests, version and changelog problems. Findings on proposed work are marked expected. Read-only; uses cached route facts.\",\n input: inputSchema({}),\n writes: false,\n run: async () => {\n try {\n const [{ openGrimoire }, { checkGrimoire }] = await Promise.all([\n import(\"../workspace\"),\n import(\"../check\"),\n ]);\n\n return checkGrimoire(await openGrimoire(root, await loadAdapter(), { routes: \"cached\" }));\n } catch (error) {\n return toolError(error);\n }\n },\n },\n {\n name: \"grimoire_build\",\n description:\n \"Bring the generated book (grimoire/book, a git-ignored cache) up to date, reading the routes again when they changed. Writes no project file.\",\n input: inputSchema({ force: { type: \"boolean\", description: \"Rebuild every entry.\" } }),\n writes: false,\n run: async (input) => {\n try {\n const { runGrimoire } = await import(\"../workspace\");\n const loaded = await loadAdapter();\n const force = input.force === true;\n let run;\n let note: string | null = null;\n\n try {\n run = await runGrimoire(root, loaded, { routes: \"fresh\", force });\n } catch (error) {\n if (!(error instanceof GrimoireError) || error.code !== \"GR8002\") throw error;\n\n note = `${error.code}: ${error.message}`;\n run = await runGrimoire(root, loaded, { routes: \"cached\", force });\n }\n\n return {\n rebuilt: run.rebuilt,\n written: [...run.book.written, ...run.collected.written],\n removed: [...run.book.removed, ...run.collected.removed],\n routes: run.snapshot.routes,\n ...(note === null ? {} : { note }),\n };\n } catch (error) {\n return toolError(error);\n }\n },\n },\n {\n name: \"grimoire_release\",\n description:\n \"Write the collected list of a release into grimoire/releases/<release>.md (between its markers; the agent writes the brief and stamps the changelog entries first). Writes a project file.\",\n input: inputSchema(\n { release: { type: \"string\", description: \"Release name, like 1.1.0.\" } },\n [\"release\"],\n ),\n writes: true,\n run: async (input) => {\n try {\n const [{ parseGrimoire }, { writeRelease }] = await Promise.all([\n import(\"../written\"),\n import(\"../releases\"),\n ]);\n const release = text(input, \"release\").trim();\n\n if (release === \"\" || /[\\\\/]/.test(release)) {\n throw new GrimoireError(\n \"GR9006\",\n `Pass a release name like 1.1.0 (got ${JSON.stringify(release)}).`,\n );\n }\n\n return await writeRelease(root, (await parseGrimoire(root)).written, release);\n } catch (error) {\n return toolError(error);\n }\n },\n },\n {\n name: \"grimoire_explain\",\n description:\n \"What a Grimoire code (GR1001…GR9006) means, what to do, the skill that explains it and its docs link. Read-only.\",\n input: inputSchema({ code: { type: \"string\", description: \"The code, like GR2001.\" } }, [\n \"code\",\n ]),\n writes: false,\n run: async (input) => {\n const definition = explainGrimoireCode(text(input, \"code\"));\n\n if (!definition) {\n throw new Error(\n `Unknown Grimoire code ${JSON.stringify(text(input, \"code\"))}. Codes look like GR2001; the full list is at the check guide.`,\n );\n }\n\n return { ...definition, docs: grimoireCodeDocsUrl(definition.code) };\n },\n },\n ];\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAS,UAAU,OAAuB;CACxC,IAAI,iBAAiB,eAAe;EAClC,MAAM,MAAM,oBAAoB,MAAM,IAAI,CAAC,EAAE;EAE7C,MAAM,IAAI,MAAM,GAAG,MAAM,KAAK,IAAI,MAAM,UAAU,MAAM,SAAS,QAAQ,IAAI;CAC/E;CAEA,MAAM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ACF,OAAO,YACL,EAAE,SAAS;IAAE,MAAM;IAAU,aAAa;GAA4B,EAAE,GACxE,CAAC,SAAS,CACZ;GACA,QAAQ;GACR,KAAK,OAAO,UAAU;IACpB,IAAI;KACF,MAAM,CAAC,EAAE,iBAAiB,EAAE,kBAAkB,MAAM,QAAQ,IAAI,CAC9D,OAAO,yBACP,OAAO,wBACT,CAAC;KACD,MAAM,UAAU,KAAK,OAAO,SAAS,CAAC,CAAC,KAAK;KAE5C,IAAI,YAAY,MAAM,QAAQ,KAAK,OAAO,GACxC,MAAM,IAAI,cACR,UACA,uCAAuC,KAAK,UAAU,OAAO,EAAE,GACjE;KAGF,OAAO,MAAM,aAAa,OAAO,MAAM,cAAc,IAAI,EAAC,CAAE,SAAS,OAAO;IAC9E,SAAS,OAAO;KACd,OAAO,UAAU,KAAK;IACxB;GACF;EACF;EACA;GACE,MAAM;GACN,aACE;GACF,OAAO,YAAY,EAAE,MAAM;IAAE,MAAM;IAAU,aAAa;GAAyB,EAAE,GAAG,CACtF,MACF,CAAC;GACD,QAAQ;GACR,KAAK,OAAO,UAAU;IACpB,MAAM,aAAa,oBAAoB,KAAK,OAAO,MAAM,CAAC;IAE1D,IAAI,CAAC,YACH,MAAM,IAAI,MACR,yBAAyB,KAAK,UAAU,KAAK,OAAO,MAAM,CAAC,EAAE,+DAC/D;IAGF,OAAO;KAAE,GAAG;KAAY,MAAM,oBAAoB,WAAW,IAAI;IAAE;GACrE;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"mcp-tools.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/mcp-tools.ts"],"sourcesContent":["/**\n * The Grimoire tools `warlock mcp` and `warlock dev --mcp` serve. Each tool\n * loads its code inside `run`, so registering them costs nothing at start.\n * Answers are the same JSON objects `--json` prints.\n */\nimport { inputSchema, type WarlockMcpContext, type WarlockMcpTool } from \"@warlock.js/core\";\nimport { explainGrimoireCode, GrimoireError, grimoireCodeDocsUrl } from \"../codes\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { ScryQuery } from \"../contracts/scry\";\nimport type { WarlockAdapterOptions } from \"./adapter\";\n\n/** The names of the tools, in the order they are listed. */\nexport const GRIMOIRE_MCP_TOOL_NAMES = [\n \"grimoire_file\",\n \"grimoire_impact\",\n \"grimoire_route\",\n \"grimoire_feature\",\n \"grimoire_flow\",\n \"grimoire_search\",\n \"grimoire_check\",\n \"grimoire_build\",\n \"grimoire_release\",\n \"grimoire_explain\",\n] as const;\n\n/** A Grimoire error as a tool error: the code, what failed, and what to do. */\nfunction toolError(error: unknown): never {\n if (error instanceof GrimoireError) {\n const fix = explainGrimoireCode(error.code)?.fix;\n\n throw new Error(`${error.code}: ${error.message}${fix ? ` Fix: ${fix}` : \"\"}`);\n }\n\n throw error;\n}\n\nfunction text(input: Record<string, unknown>, name: string): string {\n const value = input[name];\n\n return typeof value === \"string\" ? value : \"\";\n}\n\n/** The tools for one MCP server. `adapterFor` is replaced in specs. */\nexport function createGrimoireMcpTools(\n context: Pick<WarlockMcpContext, \"cwd\" | \"inspect\">,\n options: WarlockAdapterOptions = {},\n adapterFor?: () => Promise<BookAdapter>,\n): WarlockMcpTool[] {\n const root = context.cwd;\n let adapter: Promise<BookAdapter> | undefined;\n\n // The server's own inspect: `warlock mcp` boots once for every tool, `warlock dev --mcp` reads the live app.\n const loadAdapter = (): Promise<BookAdapter> => {\n adapter ??=\n adapterFor?.() ??\n import(\"./adapter\").then(({ createWarlockAdapter }) =>\n createWarlockAdapter({\n ...options,\n inspect: (_root, sections) => context.inspect(sections),\n }),\n );\n\n return adapter;\n };\n\n const ask =\n (query: (input: Record<string, unknown>) => Promise<ScryQuery> | ScryQuery) =>\n async (input: Record<string, unknown>): Promise<unknown> => {\n try {\n const { answer } = await import(\"./actions\");\n\n return await answer(root, await loadAdapter(), await query(input));\n } catch (error) {\n return toolError(error);\n }\n };\n\n const scryParts = () => import(\"../scry\");\n\n return [\n {\n name: \"grimoire_file\",\n description:\n \"One source file from the Grimoire book: header sentence, owning feature and borrowers, flows that reach it, exports, imports, importers, routes, pages. Read-only; reads cached route facts and never boots the app.\",\n input: inputSchema(\n { file: { type: \"string\", description: \"Project-relative path (either separator).\" } },\n [\"file\"],\n ),\n writes: false,\n run: ask((input) => ({ type: \"file\", file: text(input, \"file\") })),\n },\n {\n name: \"grimoire_impact\",\n description:\n \"What a change to a file reaches: importers (direct and all), API routes, pages and screens, flows, features (owner and borrowers) and tests. Read-only.\",\n input: inputSchema(\n { file: { type: \"string\", description: \"Project-relative path of the file to change.\" } },\n [\"file\"],\n ),\n writes: false,\n run: ask((input) => ({ type: \"impact\", file: text(input, \"file\") })),\n },\n {\n name: \"grimoire_route\",\n description:\n \"One HTTP route: handler and its file, routes file, middleware, guard, the files behind it and the flow steps that name it. Read-only.\",\n input: inputSchema(\n {\n method: { type: \"string\", description: \"HTTP method (GET, POST…).\" },\n path: { type: \"string\", description: \"Path as registered (/api/products/:id).\" },\n },\n [\"method\", \"path\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { parseRouteText } = await scryParts();\n\n return {\n type: \"route\",\n ...parseRouteText(`${text(input, \"method\")} ${text(input, \"path\")}`),\n };\n }),\n },\n {\n name: \"grimoire_feature\",\n description:\n \"One feature: README, flows with status, its book map (own, borrowed and unreached files, routes, pages), recent changes, open tasks and its check findings. Read-only.\",\n input: inputSchema(\n {\n feature: { type: \"string\", description: \"Feature id (folder under grimoire/features/).\" },\n },\n [\"feature\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { parseFeatureText } = await scryParts();\n\n return { type: \"feature\", feature: parseFeatureText(text(input, \"feature\")) };\n }),\n },\n {\n name: \"grimoire_flow\",\n description:\n \"One flow: its summary, steps with file counts (direct, in the feature, reachable, type-only) and the first direct imports of each, cases, criteria with their tests and last results (pass, fail, stale, not run, no test), where it is shown, history and findings. Pass files with step to list one step's reachable or type-only files, a page at a time. Read-only.\",\n input: inputSchema(\n {\n flow: { type: \"string\", description: \"<feature>/<flow>, like catalog/new-arrivals.\" },\n files: {\n type: \"string\",\n enum: [\"reachable\", \"type-only\"],\n description: \"With step: list the step's files that run (reachable) or only type imports reach (type-only).\",\n },\n step: { type: \"integer\", description: \"Step number, for files.\", minimum: 0 },\n offset: { type: \"integer\", description: \"First file to list (default 0); a page holds 200.\", minimum: 0 },\n },\n [\"flow\"],\n ),\n writes: false,\n run: async (input) => {\n try {\n const [{ parseFlowText, scry }, { openGrimoire }, compact] = await Promise.all([\n scryParts(),\n import(\"../workspace\"),\n import(\"../scry/compact\"),\n ]);\n const query = { type: \"flow\" as const, ...parseFlowText(text(input, \"flow\")) };\n const snapshot = await openGrimoire(root, await loadAdapter(), { routes: \"cached\" });\n const result = scry(snapshot, query);\n\n if (result.type !== \"flow\") return result;\n\n const set = input.files;\n\n if (set === undefined || set === null) return compact.compactFlow(snapshot, result);\n\n if (set !== \"reachable\" && set !== \"type-only\") {\n throw new GrimoireError(\"GR9006\", 'Pass files as \"reachable\" or \"type-only\".');\n }\n\n const stepNumber = input.step;\n const step = result.bookmap.steps.find((item) => item.index === stepNumber);\n\n if (typeof stepNumber !== \"number\" || step === undefined) {\n throw new GrimoireError(\n \"GR9006\",\n `Pass step as one of the step numbers of ${result.bookmap.ref} (${result.bookmap.steps.map((item) => item.index).join(\", \")}).`,\n );\n }\n\n const offset = typeof input.offset === \"number\" && input.offset > 0 ? input.offset : 0;\n\n return compact.stepFilePage(snapshot, result.bookmap, step, set, offset, 200);\n } catch (error) {\n return toolError(error);\n }\n },\n },\n {\n name: \"grimoire_search\",\n description:\n \"Search the Grimoire by words: features, flows, blocks, pages, screens, routes, file paths, export names, header sentences and tasks, best match first. Read-only.\",\n input: inputSchema(\n {\n text: { type: \"string\", description: \"Words to look for, in any order.\" },\n limit: { type: \"integer\", description: \"Most hits to return (default 20).\", minimum: 1 },\n },\n [\"text\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const limit = input.limit;\n\n if (limit === undefined || limit === null)\n return { type: \"search\", text: text(input, \"text\") };\n\n const { parseLimit } = await scryParts();\n\n // A limit of 0, a negative or a fraction is refused with GR9006, as `--limit` is.\n return {\n type: \"search\",\n text: text(input, \"text\"),\n limit: parseLimit(typeof limit === \"number\" || typeof limit === \"string\" ? limit : true),\n };\n }),\n },\n {\n name: \"grimoire_check\",\n description:\n \"Run the Grimoire check: written names that point at nothing, files without a header or feature, criteria without tests, version and changelog problems. Findings on proposed work are marked expected. Read-only; uses cached route facts.\",\n input: inputSchema({}),\n writes: false,\n run: async () => {\n try {\n const [{ openGrimoire }, { checkGrimoire }] = await Promise.all([\n import(\"../workspace\"),\n import(\"../check\"),\n ]);\n\n return checkGrimoire(await openGrimoire(root, await loadAdapter(), { routes: \"cached\" }));\n } catch (error) {\n return toolError(error);\n }\n },\n },\n {\n name: \"grimoire_build\",\n description:\n \"Bring the generated book (grimoire/book, a git-ignored cache) up to date, reading the routes again when they changed. Writes no project file.\",\n input: inputSchema({ force: { type: \"boolean\", description: \"Rebuild every entry.\" } }),\n writes: false,\n run: async (input) => {\n try {\n const { runGrimoire } = await import(\"../workspace\");\n const loaded = await loadAdapter();\n const force = input.force === true;\n let run;\n let note: string | null = null;\n\n try {\n run = await runGrimoire(root, loaded, { routes: \"fresh\", force });\n } catch (error) {\n if (!(error instanceof GrimoireError) || error.code !== \"GR8002\") throw error;\n\n note = `${error.code}: ${error.message}`;\n run = await runGrimoire(root, loaded, { routes: \"cached\", force });\n }\n\n return {\n rebuilt: run.rebuilt,\n written: [...run.book.written, ...run.collected.written],\n removed: [...run.book.removed, ...run.collected.removed],\n routes: run.snapshot.routes,\n ...(note === null ? {} : { note }),\n };\n } catch (error) {\n return toolError(error);\n }\n },\n },\n {\n name: \"grimoire_release\",\n description:\n \"Write the collected list of a release into grimoire/releases/<release>.md (between its markers; the agent writes the brief and stamps the changelog entries first). Writes a project file.\",\n input: inputSchema(\n { release: { type: \"string\", description: \"Release name, like 1.1.0.\" } },\n [\"release\"],\n ),\n writes: true,\n run: async (input) => {\n try {\n const [{ parseGrimoire }, { writeRelease }] = await Promise.all([\n import(\"../written\"),\n import(\"../releases\"),\n ]);\n const release = text(input, \"release\").trim();\n\n if (release === \"\" || /[\\\\/]/.test(release)) {\n throw new GrimoireError(\n \"GR9006\",\n `Pass a release name like 1.1.0 (got ${JSON.stringify(release)}).`,\n );\n }\n\n return await writeRelease(root, (await parseGrimoire(root)).written, release);\n } catch (error) {\n return toolError(error);\n }\n },\n },\n {\n name: \"grimoire_explain\",\n description:\n \"What a Grimoire code (GR1001…GR9006) means, what to do, the skill that explains it and its docs link. Read-only.\",\n input: inputSchema({ code: { type: \"string\", description: \"The code, like GR2001.\" } }, [\n \"code\",\n ]),\n writes: false,\n run: async (input) => {\n const definition = explainGrimoireCode(text(input, \"code\"));\n\n if (!definition) {\n throw new Error(\n `Unknown Grimoire code ${JSON.stringify(text(input, \"code\"))}. Codes look like GR2001; the full list is at the check guide.`,\n );\n }\n\n return { ...definition, docs: grimoireCodeDocsUrl(definition.code) };\n },\n },\n ];\n}\n"],"mappings":";;;;;;;;;;AA0BA,SAAS,UAAU,OAAuB;CACxC,IAAI,iBAAiB,eAAe;EAClC,MAAM,MAAM,oBAAoB,MAAM,IAAI,CAAC,EAAE;EAE7C,MAAM,IAAI,MAAM,GAAG,MAAM,KAAK,IAAI,MAAM,UAAU,MAAM,SAAS,QAAQ,IAAI;CAC/E;CAEA,MAAM;AACR;AAEA,SAAS,KAAK,OAAgC,MAAsB;CAClE,MAAM,QAAQ,MAAM;CAEpB,OAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;;AAGA,SAAgB,uBACd,SACA,UAAiC,CAAC,GAClC,YACkB;CAClB,MAAM,OAAO,QAAQ;CACrB,IAAI;CAGJ,MAAM,oBAA0C;EAC9C,YACE,aAAa,KACb,OAAO,gBAAY,CAAC,MAAM,EAAE,2BAC1B,qBAAqB;GACnB,GAAG;GACH,UAAU,OAAO,aAAa,QAAQ,QAAQ,QAAQ;EACxD,CAAC,CACH;EAEF,OAAO;CACT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AAO,YAAY,EAAE,MAAM;IAAE,MAAM;IAAU,aAAa;GAAyB,EAAE,GAAG,CACtF,MACF,CAAC;GACD,QAAQ;GACR,KAAK,OAAO,UAAU;IACpB,MAAM,aAAa,oBAAoB,KAAK,OAAO,MAAM,CAAC;IAE1D,IAAI,CAAC,YACH,MAAM,IAAI,MACR,yBAAyB,KAAK,UAAU,KAAK,OAAO,MAAM,CAAC,EAAE,+DAC/D;IAGF,OAAO;KAAE,GAAG;KAAY,MAAM,oBAAoB,WAAW,IAAI;IAAE;GACrE;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/workspace/index.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/workspace/index.ts"],"mappings":";;;;;;;;wBAoJsB,aACpB,cACA,SAAS,aACT,UAAS,sBACR,QAAQ"}
|
package/esm/workspace/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import "../book/index.mjs";
|
|
|
7
7
|
import { resolveOwnership } from "../ownership/index.mjs";
|
|
8
8
|
import { matchApps } from "../apps/match-apps.mjs";
|
|
9
9
|
import "../apps/index.mjs";
|
|
10
|
-
import { readTestResults } from "../test-results/index.mjs";
|
|
10
|
+
import { readTestResults, resultsFileLabel } from "../test-results/index.mjs";
|
|
11
11
|
import { annotationsFrom, buildCollectedFiles } from "../bookmap/build.mjs";
|
|
12
12
|
import { writeCollectedFiles } from "../bookmap/write.mjs";
|
|
13
13
|
import "../bookmap/index.mjs";
|
|
@@ -62,7 +62,8 @@ async function runGrimoire(root, adapter, options = {}) {
|
|
|
62
62
|
const apps = matchApps(written.apps, book.facts);
|
|
63
63
|
const ownership = resolveOwnership(written, book.facts);
|
|
64
64
|
const { proofs, findings: proofFindings } = await scanProofs(root, book.facts.tests);
|
|
65
|
-
const
|
|
65
|
+
const resultsFile = resultsFileLabel(root, options.testResultsFile);
|
|
66
|
+
const results = await readTestResults(root, options.testResultsFile);
|
|
66
67
|
const testHashes = await testFileHashes(root, book.facts.tests, book.manifest.tests);
|
|
67
68
|
const input = {
|
|
68
69
|
written,
|
|
@@ -98,6 +99,7 @@ async function runGrimoire(root, adapter, options = {}) {
|
|
|
98
99
|
proofs,
|
|
99
100
|
proofFindings,
|
|
100
101
|
results,
|
|
102
|
+
resultsFile,
|
|
101
103
|
collected,
|
|
102
104
|
annotations,
|
|
103
105
|
routes: book.routes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/workspace/index.ts"],"sourcesContent":["/**\n * The pipeline every command runs first (owned by T-128):\n *\n * 1. `parseGrimoire(root)`;\n * 2. `buildBook(root, adapter, { routes })`;\n * 3. `matchApps`, `resolveOwnership`, `scanProofs`, `readTestResults`;\n * 4. `buildCollectedFiles`, `annotationsFrom`;\n * 5. when `write` is not `false`: `writeBook` and `writeCollectedFiles`.\n *\n * A second run with nothing changed calls no adapter method and writes no file.\n */\nimport { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { matchApps } from \"../apps\";\nimport { buildBook, writeBook } from \"../book\";\nimport {\n annotationsFrom,\n buildCollectedFiles,\n writeCollectedFiles,\n type CollectedInput,\n} from \"../bookmap\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { BuildBookOptions, WriteBookResult } from \"../contracts/book\";\nimport type { GrimoireSnapshot, OpenGrimoireOptions } from \"../contracts/snapshot\";\nimport { resolveOwnership } from \"../ownership\";\nimport { toPosixPath } from \"../paths\";\nimport { scanProofs } from \"../proves\";\nimport { readTestResults } from \"../test-results\";\nimport { parseGrimoire } from \"../written\";\n\n/** The current sha256 of each test file: the manifest's, else read now (missing files are left out). */\nasync function testFileHashes(\n root: string,\n tests: readonly string[],\n known: Readonly<Record<string, string>>,\n): Promise<Record<string, string>> {\n const hashes: Record<string, string> = {};\n\n for (const test of [...new Set(tests.map(toPosixPath))].sort()) {\n const hash = known[test];\n\n if (hash !== undefined) {\n hashes[test] = hash;\n continue;\n }\n\n try {\n const content = await readFile(path.join(root, ...test.split(\"/\")));\n hashes[test] = createHash(\"sha256\").update(content).digest(\"hex\");\n } catch {\n // A listed test file that is gone has no hash; its results are not marked stale.\n }\n }\n\n return hashes;\n}\n\n/** What one pass of the pipeline did, with the snapshot it produced (`warlock grimoire build` prints it). */\nexport type GrimoireRun = {\n snapshot: GrimoireSnapshot;\n /** `false` when the book's fingerprint matched and the adapter was not asked for files. */\n rebuilt: boolean;\n /** Source files added, changed or removed since the last build. */\n changed: string[];\n /** Book files written and removed (both empty with `write: false`). */\n book: WriteBookResult;\n /** Collected files (book maps, indexes) written and removed (both empty with `write: false`). */\n collected: { written: string[]; removed: string[] };\n};\n\n/**\n * Run the pipeline and say what it wrote. `openGrimoire` is this without the\n * counts.\n *\n * @param root Absolute project root.\n */\nexport async function runGrimoire(\n root: string,\n adapter: BookAdapter,\n options: OpenGrimoireOptions = {},\n): Promise<GrimoireRun> {\n const write = options.write !== false;\n const { written, findings: structure } = await parseGrimoire(root);\n\n const bookOptions: BuildBookOptions & { write?: boolean } = {\n routes: options.routes ?? \"cached\",\n };\n\n if (options.force !== undefined) bookOptions.force = options.force;\n if (options.now !== undefined) bookOptions.now = options.now;\n if (!write) bookOptions.write = false;\n\n const { book, rebuilt, changed } = await buildBook(root, adapter, bookOptions);\n const apps = matchApps(written.apps, book.facts);\n const ownership = resolveOwnership(written, book.facts);\n const { proofs, findings: proofFindings } = await scanProofs(root, book.facts.tests);\n const results = await readTestResults(root);\n const testHashes = await testFileHashes(root, book.facts.tests, book.manifest.tests);\n\n const input: CollectedInput = {\n written,\n facts: book.facts,\n ownership,\n apps,\n proofs,\n results,\n testHashes,\n };\n const collected = buildCollectedFiles(input);\n const annotations = annotationsFrom(input, collected, { tests: testHashes });\n let bookWrite: WriteBookResult = { written: [], removed: [] };\n let collectedWrite: { written: string[]; removed: string[] } = { written: [], removed: [] };\n\n if (write) {\n bookWrite = await writeBook(book, annotations);\n collectedWrite = await writeCollectedFiles(root, collected);\n }\n\n return {\n snapshot: {\n root,\n written,\n structure,\n book,\n ownership,\n apps,\n proofs,\n proofFindings,\n results,\n collected,\n annotations,\n routes: book.routes,\n },\n rebuilt,\n changed,\n book: bookWrite,\n collected: collectedWrite,\n };\n}\n\n/**\n * Load, refresh and return everything about the project's grimoire.\n *\n * @param root Absolute project root.\n */\nexport async function openGrimoire(\n root: string,\n adapter: BookAdapter,\n options: OpenGrimoireOptions = {},\n): Promise<GrimoireSnapshot> {\n return (await runGrimoire(root, adapter, options)).snapshot;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,eAAe,eACb,MACA,OACA,OACiC;CACjC,MAAM,SAAiC,CAAC;CAExC,KAAK,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;EAC9D,MAAM,OAAO,MAAM;EAEnB,IAAI,SAAS,QAAW;GACtB,OAAO,QAAQ;GACf;EACF;EAEA,IAAI;GACF,MAAM,UAAU,MAAM,SAAS,KAAK,KAAK,MAAM,GAAG,KAAK,MAAM,GAAG,CAAC,CAAC;GAClE,OAAO,QAAQ,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK;EAClE,QAAQ,CAER;CACF;CAEA,OAAO;AACT;;;;;;;AAqBA,eAAsB,YACpB,MACA,SACA,UAA+B,CAAC,GACV;CACtB,MAAM,QAAQ,QAAQ,UAAU;CAChC,MAAM,EAAE,SAAS,UAAU,cAAc,MAAM,cAAc,IAAI;CAEjE,MAAM,cAAsD,EAC1D,QAAQ,QAAQ,UAAU,SAC5B;CAEA,IAAI,QAAQ,UAAU,QAAW,YAAY,QAAQ,QAAQ;CAC7D,IAAI,QAAQ,QAAQ,QAAW,YAAY,MAAM,QAAQ;CACzD,IAAI,CAAC,OAAO,YAAY,QAAQ;CAEhC,MAAM,EAAE,MAAM,SAAS,YAAY,MAAM,UAAU,MAAM,SAAS,WAAW;CAC7E,MAAM,OAAO,UAAU,QAAQ,MAAM,KAAK,KAAK;CAC/C,MAAM,YAAY,iBAAiB,SAAS,KAAK,KAAK;CACtD,MAAM,EAAE,QAAQ,UAAU,kBAAkB,MAAM,WAAW,MAAM,KAAK,MAAM,KAAK;CACnF,MAAM,UAAU,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/workspace/index.ts"],"sourcesContent":["/**\n * The pipeline every command runs first (owned by T-128):\n *\n * 1. `parseGrimoire(root)`;\n * 2. `buildBook(root, adapter, { routes })`;\n * 3. `matchApps`, `resolveOwnership`, `scanProofs`, `readTestResults`;\n * 4. `buildCollectedFiles`, `annotationsFrom`;\n * 5. when `write` is not `false`: `writeBook` and `writeCollectedFiles`.\n *\n * A second run with nothing changed calls no adapter method and writes no file.\n */\nimport { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { matchApps } from \"../apps\";\nimport { buildBook, writeBook } from \"../book\";\nimport {\n annotationsFrom,\n buildCollectedFiles,\n writeCollectedFiles,\n type CollectedInput,\n} from \"../bookmap\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { BuildBookOptions, WriteBookResult } from \"../contracts/book\";\nimport type { GrimoireSnapshot, OpenGrimoireOptions } from \"../contracts/snapshot\";\nimport { resolveOwnership } from \"../ownership\";\nimport { toPosixPath } from \"../paths\";\nimport { scanProofs } from \"../proves\";\nimport { readTestResults, resultsFileLabel } from \"../test-results\";\nimport { parseGrimoire } from \"../written\";\n\n/** The current sha256 of each test file: the manifest's, else read now (missing files are left out). */\nasync function testFileHashes(\n root: string,\n tests: readonly string[],\n known: Readonly<Record<string, string>>,\n): Promise<Record<string, string>> {\n const hashes: Record<string, string> = {};\n\n for (const test of [...new Set(tests.map(toPosixPath))].sort()) {\n const hash = known[test];\n\n if (hash !== undefined) {\n hashes[test] = hash;\n continue;\n }\n\n try {\n const content = await readFile(path.join(root, ...test.split(\"/\")));\n hashes[test] = createHash(\"sha256\").update(content).digest(\"hex\");\n } catch {\n // A listed test file that is gone has no hash; its results are not marked stale.\n }\n }\n\n return hashes;\n}\n\n/** What one pass of the pipeline did, with the snapshot it produced (`warlock grimoire build` prints it). */\nexport type GrimoireRun = {\n snapshot: GrimoireSnapshot;\n /** `false` when the book's fingerprint matched and the adapter was not asked for files. */\n rebuilt: boolean;\n /** Source files added, changed or removed since the last build. */\n changed: string[];\n /** Book files written and removed (both empty with `write: false`). */\n book: WriteBookResult;\n /** Collected files (book maps, indexes) written and removed (both empty with `write: false`). */\n collected: { written: string[]; removed: string[] };\n};\n\n/**\n * Run the pipeline and say what it wrote. `openGrimoire` is this without the\n * counts.\n *\n * @param root Absolute project root.\n */\nexport async function runGrimoire(\n root: string,\n adapter: BookAdapter,\n options: OpenGrimoireOptions = {},\n): Promise<GrimoireRun> {\n const write = options.write !== false;\n const { written, findings: structure } = await parseGrimoire(root);\n\n const bookOptions: BuildBookOptions & { write?: boolean } = {\n routes: options.routes ?? \"cached\",\n };\n\n if (options.force !== undefined) bookOptions.force = options.force;\n if (options.now !== undefined) bookOptions.now = options.now;\n if (!write) bookOptions.write = false;\n\n const { book, rebuilt, changed } = await buildBook(root, adapter, bookOptions);\n const apps = matchApps(written.apps, book.facts);\n const ownership = resolveOwnership(written, book.facts);\n const { proofs, findings: proofFindings } = await scanProofs(root, book.facts.tests);\n const resultsFile = resultsFileLabel(root, options.testResultsFile);\n const results = await readTestResults(root, options.testResultsFile);\n const testHashes = await testFileHashes(root, book.facts.tests, book.manifest.tests);\n\n const input: CollectedInput = {\n written,\n facts: book.facts,\n ownership,\n apps,\n proofs,\n results,\n testHashes,\n };\n const collected = buildCollectedFiles(input);\n const annotations = annotationsFrom(input, collected, { tests: testHashes });\n let bookWrite: WriteBookResult = { written: [], removed: [] };\n let collectedWrite: { written: string[]; removed: string[] } = { written: [], removed: [] };\n\n if (write) {\n bookWrite = await writeBook(book, annotations);\n collectedWrite = await writeCollectedFiles(root, collected);\n }\n\n return {\n snapshot: {\n root,\n written,\n structure,\n book,\n ownership,\n apps,\n proofs,\n proofFindings,\n results,\n resultsFile,\n collected,\n annotations,\n routes: book.routes,\n },\n rebuilt,\n changed,\n book: bookWrite,\n collected: collectedWrite,\n };\n}\n\n/**\n * Load, refresh and return everything about the project's grimoire.\n *\n * @param root Absolute project root.\n */\nexport async function openGrimoire(\n root: string,\n adapter: BookAdapter,\n options: OpenGrimoireOptions = {},\n): Promise<GrimoireSnapshot> {\n return (await runGrimoire(root, adapter, options)).snapshot;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,eAAe,eACb,MACA,OACA,OACiC;CACjC,MAAM,SAAiC,CAAC;CAExC,KAAK,MAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG;EAC9D,MAAM,OAAO,MAAM;EAEnB,IAAI,SAAS,QAAW;GACtB,OAAO,QAAQ;GACf;EACF;EAEA,IAAI;GACF,MAAM,UAAU,MAAM,SAAS,KAAK,KAAK,MAAM,GAAG,KAAK,MAAM,GAAG,CAAC,CAAC;GAClE,OAAO,QAAQ,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK;EAClE,QAAQ,CAER;CACF;CAEA,OAAO;AACT;;;;;;;AAqBA,eAAsB,YACpB,MACA,SACA,UAA+B,CAAC,GACV;CACtB,MAAM,QAAQ,QAAQ,UAAU;CAChC,MAAM,EAAE,SAAS,UAAU,cAAc,MAAM,cAAc,IAAI;CAEjE,MAAM,cAAsD,EAC1D,QAAQ,QAAQ,UAAU,SAC5B;CAEA,IAAI,QAAQ,UAAU,QAAW,YAAY,QAAQ,QAAQ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adings, findSection, lineAt, normalizeKey, paragraphAfterTitle, readDocument } from "./markdown.mjs";
|
|
1
|
+
import { checkHeadings, findSection, lineAt, normalizeKey, paragraphAfterTitle, readDocument, readScreenshots } from "./markdown.mjs";
|
|
2
2
|
import { FLOW_REF, FrontMatterReader, checks, projectFolder } from "./fields.mjs";
|
|
3
3
|
import { readListLines } from "./lists.mjs";
|
|
4
4
|
import { ORIGINS } from "./features.mjs";
|
|
@@ -198,6 +198,7 @@ function parsePage(file, text, app, type, id, sink) {
|
|
|
198
198
|
origin: fields.optionalOneOf("origin", ORIGINS),
|
|
199
199
|
heading: heading(document),
|
|
200
200
|
purpose: paragraphAfterTitle(document),
|
|
201
|
+
screenshots: readScreenshots(file, document.body, sink),
|
|
201
202
|
blocks: blocks ? parseBlocksTable(file, blocks, sink) : [],
|
|
202
203
|
alsoReachedFrom,
|
|
203
204
|
blockFiles: []
|
|
@@ -218,7 +219,8 @@ function parseBlockFile(file, text, app, page, id, sink) {
|
|
|
218
219
|
check: checks.flowRef
|
|
219
220
|
}),
|
|
220
221
|
heading: heading(document),
|
|
221
|
-
details: readListLines(file, document.body, "detail", sink)
|
|
222
|
+
details: readListLines(file, document.body, "detail", sink),
|
|
223
|
+
screenshots: readScreenshots(file, document.body, sink)
|
|
222
224
|
};
|
|
223
225
|
}
|
|
224
226
|
|
package/esm/written/apps.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apps.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/apps.ts"],"sourcesContent":["/**\n * The files of one app folder: `README.md`, `layouts/<id>.md`,\n * `pages/<id>/README.md`, `screens/<id>/README.md` and their\n * `blocks/<id>.md` files, and the `## Blocks` table they share.\n */\nimport type {\n WrittenBlockFile,\n WrittenBlockRow,\n WrittenChangesWith,\n WrittenEntryPoint,\n WrittenLayout,\n WrittenListLine,\n WrittenOrigin,\n WrittenPage,\n} from \"../contracts/written\";\nimport type { Located } from \"../contracts/location\";\nimport { ORIGINS } from \"./features\";\nimport { FLOW_REF, FrontMatterReader, checks, projectFolder } from \"./fields\";\nimport { readListLines } from \"./lists\";\nimport {\n checkHeadings,\n findSection,\n lineAt,\n normalizeKey,\n paragraphAfterTitle,\n readDocument,\n type BodyLine,\n type WrittenDocument,\n} from \"./markdown\";\nimport type { FindingSink } from \"./sink\";\n\n/** The parts of `grimoire/apps/<id>/README.md` (the folder's other files are added by the walker). */\nexport type AppReadme = {\n id: Located<string>;\n type: Located<\"site\" | \"mobile\">;\n root: Located<string>;\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n conditions: WrittenListLine[];\n};\n\nconst BLOCK_COLUMNS = [\"block\", \"flow\", \"who sees it\", \"changes with\"];\nconst EMPTY_CELL = /^(?:—|–|-+)?$/;\nconst SEPARATOR_CELL = /^:?-+:?$/;\nconst CONDITION_ITEM = /^([a-z][a-z0-9-]*(?::[a-z0-9-]+)?):[ \\t]+(\\S.*)$/;\n\nfunction heading(document: WrittenDocument): Located<string> | null {\n return document.title\n ? { value: document.title.text, at: lineAt(document.file, document.title.line) }\n : null;\n}\n\n/** The cells of a table row, with or without outer pipes; `\\|` stays a pipe inside a cell. */\nexport function tableCells(row: string): string[] {\n let text = row.trim();\n\n if (text.startsWith(\"|\")) text = text.slice(1);\n if (text.endsWith(\"|\") && !text.endsWith(\"\\\\|\")) text = text.slice(0, -1);\n\n return text.split(/(?<!\\\\)\\|/).map((cell) => cell.trim().replace(/\\\\\\|/g, \"|\"));\n}\n\n/**\n * Read the `## Blocks` table: a header row `Block | Flow | Who sees it |\n * Changes with`, a separator row, then one row per block. Text before the\n * table is allowed; the table ends at the first line without a `|`.\n */\nexport function parseBlocksTable(\n file: string,\n section: { line: number; lines: readonly BodyLine[] },\n sink: FindingSink,\n): WrittenBlockRow[] {\n const rows: WrittenBlockRow[] = [];\n const lines = section.lines;\n const start = lines.findIndex((line) => !line.fenced && line.text.includes(\"|\"));\n\n if (start === -1) {\n sink.report(\"GR1018\", \"the Blocks section has no table.\", lineAt(file, section.line));\n\n return rows;\n }\n\n const header = lines[start];\n const separator = lines[start + 1];\n\n if (header === undefined) return rows;\n\n const columns = tableCells(header.text).map(normalizeKey);\n\n if (\n columns.length !== BLOCK_COLUMNS.length ||\n columns.some((column, index) => column !== BLOCK_COLUMNS[index])\n ) {\n sink.report(\n \"GR1018\",\n `the Blocks table header is ${JSON.stringify(header.text.trim())}; use the columns Block | Flow | Who sees it | Changes with.`,\n lineAt(file, header.line),\n );\n\n return rows;\n }\n\n const separatorCells =\n separator === undefined || separator.fenced ? [] : tableCells(separator.text);\n\n if (\n separatorCells.length !== BLOCK_COLUMNS.length ||\n !separatorCells.every((cell) => SEPARATOR_CELL.test(cell))\n ) {\n sink.report(\n \"GR1018\",\n \"the Blocks table header is not followed by a separator row (`| --- | --- | --- | --- |`).\",\n lineAt(file, separator?.line ?? header.line),\n );\n\n return rows;\n }\n\n for (let index = start + 2; index < lines.length; index++) {\n const line = lines[index];\n\n if (line === undefined || line.fenced || !line.text.includes(\"|\")) break;\n\n const at = lineAt(file, line.line);\n const cells = tableCells(line.text);\n\n if (cells.length !== BLOCK_COLUMNS.length) {\n sink.report(\"GR1018\", `the Blocks row has ${cells.length} cells instead of 4.`, at);\n continue;\n }\n\n const [block = \"\", flow = \"\", who = \"\", changesWith = \"\"] = cells;\n\n if (block === \"\") {\n sink.report(\"GR1018\", \"the Blocks row has no block name.\", at);\n continue;\n }\n\n if (!EMPTY_CELL.test(flow) && !FLOW_REF.test(flow)) {\n sink.report(\n \"GR1018\",\n `the Flow cell ${JSON.stringify(flow)} of block \"${block}\" is not <feature>/<flow> or —.`,\n at,\n );\n continue;\n }\n\n if (EMPTY_CELL.test(who)) {\n sink.report(\n \"GR1018\",\n `the \"Who sees it\" cell of block \"${block}\" is empty; write everyone or condition names.`,\n at,\n );\n continue;\n }\n\n const whoItems = who\n .split(\",\")\n .map((item) => item.trim())\n .filter((item) => item !== \"\");\n\n rows.push({\n block,\n flow: EMPTY_CELL.test(flow) ? null : flow,\n who: {\n everyone: whoItems.some((item) => item.toLowerCase() === \"everyone\"),\n conditions: whoItems.filter((item) => item.toLowerCase() !== \"everyone\"),\n },\n changesWith: EMPTY_CELL.test(changesWith)\n ? []\n : changesWith\n .split(\";\")\n .map((item) => item.trim())\n .filter((item) => item !== \"\")\n .map((item): WrittenChangesWith => {\n const condition = CONDITION_ITEM.exec(item);\n\n return condition\n ? { condition: condition[1] ?? \"\", text: (condition[2] ?? \"\").trim() }\n : { condition: null, text: item };\n }),\n at,\n });\n }\n\n return rows;\n}\n\n/** `grimoire/apps/<id>/README.md`. */\nexport function parseAppReadme(\n file: string,\n text: string,\n folder: string,\n fallbackType: \"site\" | \"mobile\",\n sink: FindingSink,\n): AppReadme {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"id\", \"type\", \"root\", \"origin\"], \"app README\");\n\n const id = fields.required(\"id\", checks.id);\n\n if (id.value !== \"\" && id.value !== folder) {\n sink.report(\n \"GR1019\",\n `the app id ${JSON.stringify(id.value)} must equal its folder name ${JSON.stringify(folder)}.`,\n id.at,\n );\n }\n\n const root = fields.required(\"root\", checks.folder);\n\n checkHeadings(document, { title: false, required: [\"Conditions\"], optional: [] }, sink);\n\n return {\n id: id.value === \"\" ? { value: folder, at: id.at } : id,\n type: fields.oneOf(\"type\", [\"site\", \"mobile\"] as const, fallbackType),\n root: { value: projectFolder(root.value) ?? root.value, at: root.at },\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n conditions: readListLines(file, findSection(document, \"conditions\")?.lines, \"Conditions\", sink),\n };\n}\n\n/** `grimoire/apps/<app>/layouts/<id>.md`. */\nexport function parseLayout(\n file: string,\n text: string,\n app: string,\n id: string,\n sink: FindingSink,\n): WrittenLayout {\n const document = readDocument(file, text, \"none\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"origin\"], \"a layout\");\n checkHeadings(document, { title: false, required: [\"Blocks\"], optional: [] }, sink);\n\n const blocks = findSection(document, \"blocks\");\n\n return {\n file,\n app,\n id,\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n blocks: blocks ? parseBlocksTable(file, blocks, sink) : [],\n };\n}\n\n/** `grimoire/apps/<app>/pages/<id>/README.md` or `screens/<id>/README.md`. */\nexport function parsePage(\n file: string,\n text: string,\n app: string,\n type: \"page\" | \"screen\",\n id: string,\n sink: FindingSink,\n): WrittenPage {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys(\n type === \"page\" ? [\"route\", \"layout\", \"origin\"] : [\"route\", \"screen\", \"layout\", \"origin\"],\n type,\n );\n\n const route = fields.scalar(\"route\", { required: type === \"page\", check: checks.route });\n const screen =\n type === \"screen\" ? fields.scalar(\"screen\", { required: false, check: checks.name }) : null;\n\n if (type === \"screen\" && fields.present && route === null && screen === null) {\n sink.report(\n \"GR1003\",\n 'a screen needs the front matter key \"route\" (file-based routing) or \"screen\" (its name in code).',\n lineAt(file, 1),\n );\n }\n\n checkHeadings(\n document,\n { title: true, required: [], optional: [\"Blocks\", \"Also reached from\"] },\n sink,\n );\n\n const blocks = findSection(document, \"blocks\");\n const alsoReachedFrom: WrittenEntryPoint[] = readListLines(\n file,\n findSection(document, \"also reached from\")?.lines,\n \"Also reached from\",\n sink,\n ).map((line) => ({ type: line.name, name: line.text, at: line.at }));\n\n return {\n file,\n app,\n type,\n id,\n route,\n screen,\n layout: fields.scalar(\"layout\", { required: false, check: checks.id }),\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n purpose: paragraphAfterTitle(document),\n blocks: blocks ? parseBlocksTable(file, blocks, sink) : [],\n alsoReachedFrom,\n blockFiles: [],\n };\n}\n\n/** `grimoire/apps/<app>/pages/<page>/blocks/<id>.md`. */\nexport function parseBlockFile(\n file: string,\n text: string,\n app: string,\n page: string,\n id: string,\n sink: FindingSink,\n): WrittenBlockFile {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"flow\"], \"block file\");\n\n return {\n file,\n app,\n page,\n id,\n flow: fields.scalar(\"flow\", { required: true, check: checks.flowRef }),\n heading: heading(document),\n details: readListLines(file, document.body, \"detail\", sink),\n };\n}\n"],"mappings":";;;;;;AAyCA,MAAM,gBAAgB;CAAC;CAAS;CAAQ;CAAe;AAAc;AACrE,MAAM,aAAa;AACnB,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAEvB,SAAS,QAAQ,UAAmD;CAClE,OAAO,SAAS,QACZ;EAAE,OAAO,SAAS,MAAM;EAAM,IAAI,OAAO,SAAS,MAAM,SAAS,MAAM,IAAI;CAAE,IAC7E;AACN;;AAGA,SAAgB,WAAW,KAAuB;CAChD,IAAI,OAAO,IAAI,KAAK;CAEpB,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO,KAAK,MAAM,CAAC;CAC7C,IAAI,KAAK,SAAS,GAAG,KAAK,CAAC,KAAK,SAAS,KAAK,GAAG,OAAO,KAAK,MAAM,GAAG,EAAE;CAExE,OAAO,KAAK,MAAM,WAAW,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,QAAQ,SAAS,GAAG,CAAC;AAChF;;;;;;AAOA,SAAgB,iBACd,MACA,SACA,MACmB;CACnB,MAAM,OAA0B,CAAC;CACjC,MAAM,QAAQ,QAAQ;CACtB,MAAM,QAAQ,MAAM,WAAW,SAAS,CAAC,KAAK,UAAU,KAAK,KAAK,SAAS,GAAG,CAAC;CAE/E,IAAI,UAAU,IAAI;EAChB,KAAK,OAAO,UAAU,oCAAoC,OAAO,MAAM,QAAQ,IAAI,CAAC;EAEpF,OAAO;CACT;CAEA,MAAM,SAAS,MAAM;CACrB,MAAM,YAAY,MAAM,QAAQ;CAEhC,IAAI,WAAW,QAAW,OAAO;CAEjC,MAAM,UAAU,WAAW,OAAO,IAAI,CAAC,CAAC,IAAI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O,OAAO;CAAK,CAAC,IAAI;CAEzF,IAAI,SAAS,YAAY,OAAO,WAAW,UAAU,QAAQ,WAAW,MACtE,KAAK,OACH,UACA,wGACA,OAAO,MAAM,CAAC,CAChB;CAGF,cACE,UACA;EAAE,OAAO;EAAM,UAAU,CAAC;EAAG,UAAU,CAAC,UAAU,mBAAmB;CAAE,GACvE,IACF;CAEA,MAAM,SAAS,YAAY,UAAU,QAAQ;CAC7C,MAAM,kBAAuC,cAC3C,MACA,YAAY,UAAU,mBAAmB,CAAC,EAAE,OAC5C,qBACA,IACF,CAAC,CAAC,KAAK,UAAU;EAAE,MAAM,KAAK;EAAM,MAAM,KAAK;EAAM,IAAI,KAAK;CAAG,EAAE;CAEnE,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ,OAAO,OAAO,UAAU;GAAE,UAAU;GAAO,OAAO,OAAO;EAAG,CAAC;EACrE,QAAQ,OAAO,cAAc,UAAU,OAAO;EAC9C,SAAS,QAAQ,QAAQ;EACzB,SAAS,oBAAoB,QAAQ;EACrC,QAAQ,SAAS,iBAAiB,MAAM,QAAQ,IAAI,IAAI,CAAC;EACzD;EACA,YAAY,CAAC;CACf;AACF;;AAGA,SAAgB,eACd,MACA,MACA,KACA,MACA,IACA,MACkB;CAClB,MAAM,WAAW,aAAa,MAAM,MAAM,YAAY,IAAI;CAC1D,MAAM,SAAS,IAAI,kBAAkB,UAAU,IAAI;CAEnD,OAAO,SAAS,CAAC,MAAM,GAAG,YAAY;CAEtC,OAAO;EACL;EACA;EACA;EACA;EACA,MAAM,OAAO,OAAO,QAAQ;GAAE,UAAU;GAAM,OAAO,OAAO;EAAQ,CAAC;EACrE,SAAS,QAAQ,QAAQ;EACzB,SAAS,cAAc,MAAM,SAAS,MAAM,UAAU,IAAI;CAC5D;AACF"}
|
|
1
|
+
{"version":3,"file":"apps.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/apps.ts"],"sourcesContent":["/**\n * The files of one app folder: `README.md`, `layouts/<id>.md`,\n * `pages/<id>/README.md`, `screens/<id>/README.md` and their\n * `blocks/<id>.md` files, and the `## Blocks` table they share.\n */\nimport type {\n WrittenBlockFile,\n WrittenBlockRow,\n WrittenChangesWith,\n WrittenEntryPoint,\n WrittenLayout,\n WrittenListLine,\n WrittenOrigin,\n WrittenPage,\n} from \"../contracts/written\";\nimport type { Located } from \"../contracts/location\";\nimport { ORIGINS } from \"./features\";\nimport { FLOW_REF, FrontMatterReader, checks, projectFolder } from \"./fields\";\nimport { readListLines } from \"./lists\";\nimport {\n checkHeadings,\n findSection,\n lineAt,\n normalizeKey,\n paragraphAfterTitle,\n readDocument,\n readScreenshots,\n type BodyLine,\n type WrittenDocument,\n} from \"./markdown\";\nimport type { FindingSink } from \"./sink\";\n\n/** The parts of `grimoire/apps/<id>/README.md` (the folder's other files are added by the walker). */\nexport type AppReadme = {\n id: Located<string>;\n type: Located<\"site\" | \"mobile\">;\n root: Located<string>;\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n conditions: WrittenListLine[];\n};\n\nconst BLOCK_COLUMNS = [\"block\", \"flow\", \"who sees it\", \"changes with\"];\nconst EMPTY_CELL = /^(?:—|–|-+)?$/;\nconst SEPARATOR_CELL = /^:?-+:?$/;\nconst CONDITION_ITEM = /^([a-z][a-z0-9-]*(?::[a-z0-9-]+)?):[ \\t]+(\\S.*)$/;\n\nfunction heading(document: WrittenDocument): Located<string> | null {\n return document.title\n ? { value: document.title.text, at: lineAt(document.file, document.title.line) }\n : null;\n}\n\n/** The cells of a table row, with or without outer pipes; `\\|` stays a pipe inside a cell. */\nexport function tableCells(row: string): string[] {\n let text = row.trim();\n\n if (text.startsWith(\"|\")) text = text.slice(1);\n if (text.endsWith(\"|\") && !text.endsWith(\"\\\\|\")) text = text.slice(0, -1);\n\n return text.split(/(?<!\\\\)\\|/).map((cell) => cell.trim().replace(/\\\\\\|/g, \"|\"));\n}\n\n/**\n * Read the `## Blocks` table: a header row `Block | Flow | Who sees it |\n * Changes with`, a separator row, then one row per block. Text before the\n * table is allowed; the table ends at the first line without a `|`.\n */\nexport function parseBlocksTable(\n file: string,\n section: { line: number; lines: readonly BodyLine[] },\n sink: FindingSink,\n): WrittenBlockRow[] {\n const rows: WrittenBlockRow[] = [];\n const lines = section.lines;\n const start = lines.findIndex((line) => !line.fenced && line.text.includes(\"|\"));\n\n if (start === -1) {\n sink.report(\"GR1018\", \"the Blocks section has no table.\", lineAt(file, section.line));\n\n return rows;\n }\n\n const header = lines[start];\n const separator = lines[start + 1];\n\n if (header === undefined) return rows;\n\n const columns = tableCells(header.text).map(normalizeKey);\n\n if (\n columns.length !== BLOCK_COLUMNS.length ||\n columns.some((column, index) => column !== BLOCK_COLUMNS[index])\n ) {\n sink.report(\n \"GR1018\",\n `the Blocks table header is ${JSON.stringify(header.text.trim())}; use the columns Block | Flow | Who sees it | Changes with.`,\n lineAt(file, header.line),\n );\n\n return rows;\n }\n\n const separatorCells =\n separator === undefined || separator.fenced ? [] : tableCells(separator.text);\n\n if (\n separatorCells.length !== BLOCK_COLUMNS.length ||\n !separatorCells.every((cell) => SEPARATOR_CELL.test(cell))\n ) {\n sink.report(\n \"GR1018\",\n \"the Blocks table header is not followed by a separator row (`| --- | --- | --- | --- |`).\",\n lineAt(file, separator?.line ?? header.line),\n );\n\n return rows;\n }\n\n for (let index = start + 2; index < lines.length; index++) {\n const line = lines[index];\n\n if (line === undefined || line.fenced || !line.text.includes(\"|\")) break;\n\n const at = lineAt(file, line.line);\n const cells = tableCells(line.text);\n\n if (cells.length !== BLOCK_COLUMNS.length) {\n sink.report(\"GR1018\", `the Blocks row has ${cells.length} cells instead of 4.`, at);\n continue;\n }\n\n const [block = \"\", flow = \"\", who = \"\", changesWith = \"\"] = cells;\n\n if (block === \"\") {\n sink.report(\"GR1018\", \"the Blocks row has no block name.\", at);\n continue;\n }\n\n if (!EMPTY_CELL.test(flow) && !FLOW_REF.test(flow)) {\n sink.report(\n \"GR1018\",\n `the Flow cell ${JSON.stringify(flow)} of block \"${block}\" is not <feature>/<flow> or —.`,\n at,\n );\n continue;\n }\n\n if (EMPTY_CELL.test(who)) {\n sink.report(\n \"GR1018\",\n `the \"Who sees it\" cell of block \"${block}\" is empty; write everyone or condition names.`,\n at,\n );\n continue;\n }\n\n const whoItems = who\n .split(\",\")\n .map((item) => item.trim())\n .filter((item) => item !== \"\");\n\n rows.push({\n block,\n flow: EMPTY_CELL.test(flow) ? null : flow,\n who: {\n everyone: whoItems.some((item) => item.toLowerCase() === \"everyone\"),\n conditions: whoItems.filter((item) => item.toLowerCase() !== \"everyone\"),\n },\n changesWith: EMPTY_CELL.test(changesWith)\n ? []\n : changesWith\n .split(\";\")\n .map((item) => item.trim())\n .filter((item) => item !== \"\")\n .map((item): WrittenChangesWith => {\n const condition = CONDITION_ITEM.exec(item);\n\n return condition\n ? { condition: condition[1] ?? \"\", text: (condition[2] ?? \"\").trim() }\n : { condition: null, text: item };\n }),\n at,\n });\n }\n\n return rows;\n}\n\n/** `grimoire/apps/<id>/README.md`. */\nexport function parseAppReadme(\n file: string,\n text: string,\n folder: string,\n fallbackType: \"site\" | \"mobile\",\n sink: FindingSink,\n): AppReadme {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"id\", \"type\", \"root\", \"origin\"], \"app README\");\n\n const id = fields.required(\"id\", checks.id);\n\n if (id.value !== \"\" && id.value !== folder) {\n sink.report(\n \"GR1019\",\n `the app id ${JSON.stringify(id.value)} must equal its folder name ${JSON.stringify(folder)}.`,\n id.at,\n );\n }\n\n const root = fields.required(\"root\", checks.folder);\n\n checkHeadings(document, { title: false, required: [\"Conditions\"], optional: [] }, sink);\n\n return {\n id: id.value === \"\" ? { value: folder, at: id.at } : id,\n type: fields.oneOf(\"type\", [\"site\", \"mobile\"] as const, fallbackType),\n root: { value: projectFolder(root.value) ?? root.value, at: root.at },\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n conditions: readListLines(file, findSection(document, \"conditions\")?.lines, \"Conditions\", sink),\n };\n}\n\n/** `grimoire/apps/<app>/layouts/<id>.md`. */\nexport function parseLayout(\n file: string,\n text: string,\n app: string,\n id: string,\n sink: FindingSink,\n): WrittenLayout {\n const document = readDocument(file, text, \"none\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"origin\"], \"a layout\");\n checkHeadings(document, { title: false, required: [\"Blocks\"], optional: [] }, sink);\n\n const blocks = findSection(document, \"blocks\");\n\n return {\n file,\n app,\n id,\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n blocks: blocks ? parseBlocksTable(file, blocks, sink) : [],\n };\n}\n\n/** `grimoire/apps/<app>/pages/<id>/README.md` or `screens/<id>/README.md`. */\nexport function parsePage(\n file: string,\n text: string,\n app: string,\n type: \"page\" | \"screen\",\n id: string,\n sink: FindingSink,\n): WrittenPage {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys(\n type === \"page\" ? [\"route\", \"layout\", \"origin\"] : [\"route\", \"screen\", \"layout\", \"origin\"],\n type,\n );\n\n const route = fields.scalar(\"route\", { required: type === \"page\", check: checks.route });\n const screen =\n type === \"screen\" ? fields.scalar(\"screen\", { required: false, check: checks.name }) : null;\n\n if (type === \"screen\" && fields.present && route === null && screen === null) {\n sink.report(\n \"GR1003\",\n 'a screen needs the front matter key \"route\" (file-based routing) or \"screen\" (its name in code).',\n lineAt(file, 1),\n );\n }\n\n checkHeadings(\n document,\n { title: true, required: [], optional: [\"Blocks\", \"Also reached from\"] },\n sink,\n );\n\n const blocks = findSection(document, \"blocks\");\n const alsoReachedFrom: WrittenEntryPoint[] = readListLines(\n file,\n findSection(document, \"also reached from\")?.lines,\n \"Also reached from\",\n sink,\n ).map((line) => ({ type: line.name, name: line.text, at: line.at }));\n\n return {\n file,\n app,\n type,\n id,\n route,\n screen,\n layout: fields.scalar(\"layout\", { required: false, check: checks.id }),\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n purpose: paragraphAfterTitle(document),\n screenshots: readScreenshots(file, document.body, sink),\n blocks: blocks ? parseBlocksTable(file, blocks, sink) : [],\n alsoReachedFrom,\n blockFiles: [],\n };\n}\n\n/** `grimoire/apps/<app>/pages/<page>/blocks/<id>.md`. */\nexport function parseBlockFile(\n file: string,\n text: string,\n app: string,\n page: string,\n id: string,\n sink: FindingSink,\n): WrittenBlockFile {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"flow\"], \"block file\");\n\n return {\n file,\n app,\n page,\n id,\n flow: fields.scalar(\"flow\", { required: true, check: checks.flowRef }),\n heading: heading(document),\n details: readListLines(file, document.body, \"detail\", sink),\n screenshots: readScreenshots(file, document.body, sink),\n };\n}\n"],"mappings":";;;;;;AA0CA,MAAM,gBAAgB;CAAC;CAAS;CAAQ;CAAe;AAAc;AACrE,MAAM,aAAa;AACnB,MAAM,iBAAiB;AACvB,MAAM,iBAAiB;AAEvB,SAAS,QAAQ,UAAmD;CAClE,OAAO,SAAS,QACZ;EAAE,OAAO,SAAS,MAAM;EAAM,IAAI,OAAO,SAAS,MAAM,SAAS,MAAM,IAAI;CAAE,IAC7E;AACN;;AAGA,SAAgB,WAAW,KAAuB;CAChD,IAAI,OAAO,IAAI,KAAK;CAEpB,IAAI,KAAK,WAAW,GAAG,GAAG,OAAO,KAAK,MAAM,CAAC;CAC7C,IAAI,KAAK,SAAS,GAAG,KAAK,CAAC,KAAK,SAAS,KAAK,GAAG,OAAO,KAAK,MAAM,GAAG,EAAE;CAExE,OAAO,KAAK,MAAM,WAAW,CAAC,CAAC,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,QAAQ,SAAS,GAAG,CAAC;AAChF;;;;;;AAOA,SAAgB,iBACd,MACA,SACA,MACmB;CACnB,MAAM,OAA0B,CAAC;CACjC,MAAM,QAAQ,QAAQ;CACtB,MAAM,QAAQ,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