@warlock.js/grimoire 5.64.0 → 5.65.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/esm/contracts/scry.d.mts +22 -1
- package/esm/contracts/scry.d.mts.map +1 -1
- package/esm/devtools/index.d.mts +7 -0
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +1 -1
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +8 -2
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/index.d.mts +2 -2
- package/esm/scry/also-changes.mjs +3 -2
- package/esm/scry/also-changes.mjs.map +1 -1
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +14 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +34 -1
- package/esm/scry/query.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +11 -4
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/collect-off-thread.mjs +66 -0
- package/esm/warlock/collect-off-thread.mjs.map +1 -0
- package/esm/warlock/mcp-tools.mjs +2 -2
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/llms-full.txt +10 -4
- package/package.json +3 -3
- package/skills/use-the-grimoire/SKILL.md +10 -4
|
@@ -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 { scryErrorOf } from \"../scry/error\";\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 of a non-scry tool (check, build, release) 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\n/**\n * A scry error as a tool error whose text is the `ScryError` JSON that\n * `warlock scry --json` prints (`{ \"type\": \"error\", \"code\", \"message\", \"fix\" }`).\n * It stays a thrown error so the MCP result is still marked `isError`.\n */\nfunction scryToolError(error: unknown): never {\n if (error instanceof GrimoireError) throw new Error(JSON.stringify(scryErrorOf(error)));\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 scryToolError(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. Run it on the top hit of grimoire_search, and read the importers and tests: they are the files that usually change with it. 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. For GET and HEAD a page or screen URL also works: it returns every site serving the page with its file, setup file, layouts and their imports. Read-only.\",\n input: inputSchema(\n {\n method: { type: \"string\", description: \"HTTP method (GET, POST…).\" },\n path: {\n type: \"string\",\n description: \"Path as registered (/api/products/:id), or a page URL for GET and HEAD.\",\n },\n site: {\n type: \"string\",\n description: \"Only the page of this site or mobile app, when several serve the path.\",\n },\n },\n [\"method\", \"path\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { parseRouteText } = await scryParts();\n\n const site = text(input, \"site\").trim();\n\n return {\n type: \"route\",\n ...parseRouteText(`${text(input, \"method\")} ${text(input, \"path\")}`),\n ...(site === \"\" ? {} : { site }),\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:\n \"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: {\n type: \"integer\",\n description: \"First file to list (default 0); a page holds 200.\",\n minimum: 0,\n },\n },\n [\"flow\"],\n ),\n writes: false,\n run: async (input) => {\n try {\n const [{ parseFlowText, scry }, { openStoredGrimoireCached }, compact] =\n await Promise.all([\n scryParts(),\n import(\"../workspace/cache\"),\n import(\"../scry/compact\"),\n ]);\n const query = { type: \"flow\" as const, ...parseFlowText(text(input, \"flow\")) };\n const snapshot = await openStoredGrimoireCached(root, await loadAdapter());\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 scryToolError(error);\n }\n },\n },\n {\n name: \"grimoire_search\",\n description:\n \"Search the Grimoire with a sentence or words (pass the whole commit title or bug report, not two keywords): features, flows, blocks, pages, screens, routes, file paths, export names, header sentences, written text (summary, story, cases, criteria such as AC-5) and tasks. Hits whose name or title holds the words come first; every other hit follows by BM25F score. Hits are in score order and carry their score and app. Search first, then run grimoire_impact on the top hit: the answer's alsoChanges list names the files that usually change with the top hits, `next` is the impact command, and `weak: true` means no hit holds most of the request's words (use grep for literal text). Read-only.\",\n input: inputSchema(\n {\n text: {\n type: \"string\",\n description: \"A sentence or words to look for; whole words, in any order.\",\n },\n limit: { type: \"integer\", description: \"Most hits to return (default 20).\", minimum: 1 },\n app: {\n type: \"string\",\n description: \"Keep only the hits of this app (a page, screen, block or file of it).\",\n },\n },\n [\"text\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { limit, app } = input;\n const { parseLimit, parseApp } = 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 === undefined || limit === null\n ? {}\n : {\n limit: parseLimit(\n typeof limit === \"number\" || typeof limit === \"string\" ? limit : true,\n ),\n }),\n ...(app === undefined || app === null\n ? {}\n : { app: parseApp(typeof app === \"string\" ? app : 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; checks the stored book (run warlock grimoire build after editing); `note` says when the book is behind the files.\",\n input: inputSchema({}),\n writes: false,\n run: async () => {\n try {\n const [{ openStoredGrimoireCached }, { checkGrimoire }] = await Promise.all([\n import(\"../workspace/cache\"),\n import(\"../check\"),\n ]);\n\n const snapshot = await openStoredGrimoireCached(root, await loadAdapter());\n const report = checkGrimoire(snapshot);\n const changed = snapshot.behind?.changed;\n\n // The stored book may be behind the files: say so, as scry answers do.\n return changed === undefined\n ? report\n : {\n ...report,\n note: `book is stale (${changed} ${changed === 1 ? \"file\" : \"files\"} changed); run warlock grimoire build`,\n };\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 const routeNote = run.snapshot.book.routeNote;\n const notes = [note, routeNote ?? null].filter((item): item is string => item !== null);\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 ...(notes.length === 0 ? {} : { note: notes.join(\"; \") }),\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":";;;;;;;;;;;AA2BA,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;;;;;;AAOA,SAAS,cAAc,OAAuB;CAC5C,IAAI,iBAAiB,eAAe,MAAM,IAAI,MAAM,KAAK,UAAU,YAAY,KAAK,CAAC,CAAC;CAEtF,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,O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AA4B,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 { scryErrorOf } from \"../scry/error\";\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 of a non-scry tool (check, build, release) 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\n/**\n * A scry error as a tool error whose text is the `ScryError` JSON that\n * `warlock scry --json` prints (`{ \"type\": \"error\", \"code\", \"message\", \"fix\" }`).\n * It stays a thrown error so the MCP result is still marked `isError`.\n */\nfunction scryToolError(error: unknown): never {\n if (error instanceof GrimoireError) throw new Error(JSON.stringify(scryErrorOf(error)));\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 scryToolError(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. grimoire_search already folds a shortened version into its answer for the top hit; call this for the full lists, or for another file. Read the importers and tests: they are the files that usually change with it. 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. For GET and HEAD a page or screen URL also works: it returns every site serving the page with its file, setup file, layouts and their imports. Read-only.\",\n input: inputSchema(\n {\n method: { type: \"string\", description: \"HTTP method (GET, POST…).\" },\n path: {\n type: \"string\",\n description: \"Path as registered (/api/products/:id), or a page URL for GET and HEAD.\",\n },\n site: {\n type: \"string\",\n description: \"Only the page of this site or mobile app, when several serve the path.\",\n },\n },\n [\"method\", \"path\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { parseRouteText } = await scryParts();\n\n const site = text(input, \"site\").trim();\n\n return {\n type: \"route\",\n ...parseRouteText(`${text(input, \"method\")} ${text(input, \"path\")}`),\n ...(site === \"\" ? {} : { site }),\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:\n \"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: {\n type: \"integer\",\n description: \"First file to list (default 0); a page holds 200.\",\n minimum: 0,\n },\n },\n [\"flow\"],\n ),\n writes: false,\n run: async (input) => {\n try {\n const [{ parseFlowText, scry }, { openStoredGrimoireCached }, compact] =\n await Promise.all([\n scryParts(),\n import(\"../workspace/cache\"),\n import(\"../scry/compact\"),\n ]);\n const query = { type: \"flow\" as const, ...parseFlowText(text(input, \"flow\")) };\n const snapshot = await openStoredGrimoireCached(root, await loadAdapter());\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 scryToolError(error);\n }\n },\n },\n {\n name: \"grimoire_search\",\n description:\n \"Search the Grimoire with a sentence or words (pass the whole commit title or bug report, not two keywords): features, flows, blocks, pages, screens, routes, file paths, export names, header sentences, written text (summary, story, cases, criteria such as AC-5) and tasks. Hits whose name or title holds the words come first; every other hit follows by BM25F score. Hits are in score order and carry their score and app. Search first: the answer already holds what changes with the top hit, so you do not need grimoire_impact for it. Its alsoChanges list names the files that usually change with the top hits, `impact` lists the importers, routes, flows and tests that reach the top file, `next` is the full impact command (present when `impact` is not), and `weak: true` means no hit holds most of the request's words (use grep for literal text). Read-only.\",\n input: inputSchema(\n {\n text: {\n type: \"string\",\n description: \"A sentence or words to look for; whole words, in any order.\",\n },\n limit: { type: \"integer\", description: \"Most hits to return (default 20).\", minimum: 1 },\n app: {\n type: \"string\",\n description: \"Keep only the hits of this app (a page, screen, block or file of it).\",\n },\n },\n [\"text\"],\n ),\n writes: false,\n run: ask(async (input) => {\n const { limit, app } = input;\n const { parseLimit, parseApp } = 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 === undefined || limit === null\n ? {}\n : {\n limit: parseLimit(\n typeof limit === \"number\" || typeof limit === \"string\" ? limit : true,\n ),\n }),\n ...(app === undefined || app === null\n ? {}\n : { app: parseApp(typeof app === \"string\" ? app : 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; checks the stored book (run warlock grimoire build after editing); `note` says when the book is behind the files.\",\n input: inputSchema({}),\n writes: false,\n run: async () => {\n try {\n const [{ openStoredGrimoireCached }, { checkGrimoire }] = await Promise.all([\n import(\"../workspace/cache\"),\n import(\"../check\"),\n ]);\n\n const snapshot = await openStoredGrimoireCached(root, await loadAdapter());\n const report = checkGrimoire(snapshot);\n const changed = snapshot.behind?.changed;\n\n // The stored book may be behind the files: say so, as scry answers do.\n return changed === undefined\n ? report\n : {\n ...report,\n note: `book is stale (${changed} ${changed === 1 ? \"file\" : \"files\"} changed); run warlock grimoire build`,\n };\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 const routeNote = run.snapshot.book.routeNote;\n const notes = [note, routeNote ?? null].filter((item): item is string => item !== null);\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 ...(notes.length === 0 ? {} : { note: notes.join(\"; \") }),\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":";;;;;;;;;;;AA2BA,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;;;;;;AAOA,SAAS,cAAc,OAAuB;CAC5C,IAAI,iBAAiB,eAAe,MAAM,IAAI,MAAM,KAAK,UAAU,YAAY,KAAK,CAAC,CAAC;CAEtF,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,Q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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"}
|
package/llms-full.txt
CHANGED
|
@@ -818,13 +818,19 @@ edits a file you wrote either.
|
|
|
818
818
|
changes with the top hits:
|
|
819
819
|
src/app/catalog/repositories/products.repository.ts imported by new-arrivals.service.ts
|
|
820
820
|
src/app/catalog/tests/new-arrivals.test.ts test
|
|
821
|
-
|
|
821
|
+
impact of src/app/catalog/services/new-arrivals.service.ts:
|
|
822
|
+
files src/app/orders/controllers/orders.controller.ts
|
|
823
|
+
routes GET /api/products/new-arrivals
|
|
822
824
|
```
|
|
823
825
|
|
|
826
|
+
Where your client supports MCP, prefer the Grimoire MCP tools (`grimoire_search`, `grimoire_impact`, `grimoire_flow`)
|
|
827
|
+
to the CLI: the same answers, one call each, no shell.
|
|
828
|
+
|
|
824
829
|
The number in front is the score: hits are in score order, best first, whatever the type.
|
|
825
830
|
|
|
826
|
-
2.
|
|
827
|
-
|
|
831
|
+
2. Read the `changes with` and `impact of` lines of that same answer: they are the files that usually change with the
|
|
832
|
+
top hit (what it imports and what imports it, its routes, flows and tests). The search already includes them; run
|
|
833
|
+
`scry --impact <top file>` only when you need the full lists (the `next:` line appears when the answer has no impact block).
|
|
828
834
|
3. Use grep only for literal text, or when the answer says `weak match`.
|
|
829
835
|
4. Read the feature's `README.md`, then the flow file. They say what the behaviour should be.
|
|
830
836
|
5. Ask for the flow's book map. It lists the files behind each step, the tests that prove each
|
|
@@ -857,7 +863,7 @@ build, then ask again. A project with no book stops with `GR9007`. A note
|
|
|
857
863
|
|
|
858
864
|
Add `--json` for machine-readable output; a failed call then prints `{ "type": "error", "code", "message", "fix" }` on stdout and exits 1 (the scry MCP tools return the same JSON as their error text). `--impact` lists API routes, pages, flows and features,
|
|
859
865
|
including features that only borrow the file; each list has a count and stops at 20 lines, and `--all`
|
|
860
|
-
prints every line. `--search` takes the whole sentence (the commit title or the bug report, not two keywords): hits whose name or title holds the words come first, every other hit follows by score, and the list is printed in score order with the score in front. It also reads a flow's summary, story, cases and criteria (`AC-5` works); a hit found by written text shows the part that matched in brackets. Page, screen, block and file hits carry their app, and `--app <id>` keeps one app's hits. Specs, locale files and type files rank below code of an equal match. Search reads Arabic and accented Latin text too: accents, Arabic vowel marks, hamza forms and the leading article `ال` do not matter (`شحنة` finds `الشحنة`, `cafe` finds `café`). The answer's `alsoChanges` list (`changes with the top hits:`, at most 10 files) and `
|
|
866
|
+
prints every line. `--search` takes the whole sentence (the commit title or the bug report, not two keywords): hits whose name or title holds the words come first, every other hit follows by score, and the list is printed in score order with the score in front. It also reads a flow's summary, story, cases and criteria (`AC-5` works); a hit found by written text shows the part that matched in brackets. Page, screen, block and file hits carry their app, and `--app <id>` keeps one app's hits. Specs, locale files and type files rank below code of an equal match. Search reads Arabic and accented Latin text too: accents, Arabic vowel marks, hamza forms and the leading article `ال` do not matter (`شحنة` finds `الشحنة`, `cafe` finds `café`). The answer's `alsoChanges` list (`changes with the top hits:`, at most 10 files) comes from the top three hits, and its `impact` block (`impact of <file>:`, the importers, routes, flows and tests that reach the top file, shortened) from the top file, so `--impact` is only for the full lists (its `next` line is printed when there is no impact block); `weak: true` (the line `weak match: …`) says no hit holds most of the request's words. Read the flows it names and run their tests after
|
|
861
867
|
your change.
|
|
862
868
|
|
|
863
869
|
A file's entry is also at a fixed path: `src/app/auth/controllers/login.controller.ts` is described
|
package/package.json
CHANGED
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"environment": "server"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@warlock.js/core": "5.
|
|
30
|
-
"@warlock.js/web": "5.
|
|
29
|
+
"@warlock.js/core": "5.65.1",
|
|
30
|
+
"@warlock.js/web": "5.65.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependenciesMeta": {
|
|
33
33
|
"@warlock.js/web": {
|
|
34
34
|
"optional": true
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"version": "5.
|
|
37
|
+
"version": "5.65.1",
|
|
38
38
|
"type": "module",
|
|
39
39
|
"main": "./esm/index.mjs",
|
|
40
40
|
"module": "./esm/index.mjs",
|
|
@@ -38,13 +38,19 @@ edits a file you wrote either.
|
|
|
38
38
|
changes with the top hits:
|
|
39
39
|
src/app/catalog/repositories/products.repository.ts imported by new-arrivals.service.ts
|
|
40
40
|
src/app/catalog/tests/new-arrivals.test.ts test
|
|
41
|
-
|
|
41
|
+
impact of src/app/catalog/services/new-arrivals.service.ts:
|
|
42
|
+
files src/app/orders/controllers/orders.controller.ts
|
|
43
|
+
routes GET /api/products/new-arrivals
|
|
42
44
|
```
|
|
43
45
|
|
|
46
|
+
Where your client supports MCP, prefer the Grimoire MCP tools (`grimoire_search`, `grimoire_impact`, `grimoire_flow`)
|
|
47
|
+
to the CLI: the same answers, one call each, no shell.
|
|
48
|
+
|
|
44
49
|
The number in front is the score: hits are in score order, best first, whatever the type.
|
|
45
50
|
|
|
46
|
-
2.
|
|
47
|
-
|
|
51
|
+
2. Read the `changes with` and `impact of` lines of that same answer: they are the files that usually change with the
|
|
52
|
+
top hit (what it imports and what imports it, its routes, flows and tests). The search already includes them; run
|
|
53
|
+
`scry --impact <top file>` only when you need the full lists (the `next:` line appears when the answer has no impact block).
|
|
48
54
|
3. Use grep only for literal text, or when the answer says `weak match`.
|
|
49
55
|
4. Read the feature's `README.md`, then the flow file. They say what the behaviour should be.
|
|
50
56
|
5. Ask for the flow's book map. It lists the files behind each step, the tests that prove each
|
|
@@ -77,7 +83,7 @@ build, then ask again. A project with no book stops with `GR9007`. A note
|
|
|
77
83
|
|
|
78
84
|
Add `--json` for machine-readable output; a failed call then prints `{ "type": "error", "code", "message", "fix" }` on stdout and exits 1 (the scry MCP tools return the same JSON as their error text). `--impact` lists API routes, pages, flows and features,
|
|
79
85
|
including features that only borrow the file; each list has a count and stops at 20 lines, and `--all`
|
|
80
|
-
prints every line. `--search` takes the whole sentence (the commit title or the bug report, not two keywords): hits whose name or title holds the words come first, every other hit follows by score, and the list is printed in score order with the score in front. It also reads a flow's summary, story, cases and criteria (`AC-5` works); a hit found by written text shows the part that matched in brackets. Page, screen, block and file hits carry their app, and `--app <id>` keeps one app's hits. Specs, locale files and type files rank below code of an equal match. Search reads Arabic and accented Latin text too: accents, Arabic vowel marks, hamza forms and the leading article `ال` do not matter (`شحنة` finds `الشحنة`, `cafe` finds `café`). The answer's `alsoChanges` list (`changes with the top hits:`, at most 10 files) and `
|
|
86
|
+
prints every line. `--search` takes the whole sentence (the commit title or the bug report, not two keywords): hits whose name or title holds the words come first, every other hit follows by score, and the list is printed in score order with the score in front. It also reads a flow's summary, story, cases and criteria (`AC-5` works); a hit found by written text shows the part that matched in brackets. Page, screen, block and file hits carry their app, and `--app <id>` keeps one app's hits. Specs, locale files and type files rank below code of an equal match. Search reads Arabic and accented Latin text too: accents, Arabic vowel marks, hamza forms and the leading article `ال` do not matter (`شحنة` finds `الشحنة`, `cafe` finds `café`). The answer's `alsoChanges` list (`changes with the top hits:`, at most 10 files) comes from the top three hits, and its `impact` block (`impact of <file>:`, the importers, routes, flows and tests that reach the top file, shortened) from the top file, so `--impact` is only for the full lists (its `next` line is printed when there is no impact block); `weak: true` (the line `weak match: …`) says no hit holds most of the request's words. Read the flows it names and run their tests after
|
|
81
87
|
your change.
|
|
82
88
|
|
|
83
89
|
A file's entry is also at a fixed path: `src/app/auth/controllers/login.controller.ts` is described
|