diff --git a/docs/plugins/memory-wiki.md b/docs/plugins/memory-wiki.md index 12719fe96da..17b04a102b9 100644 --- a/docs/plugins/memory-wiki.md +++ b/docs/plugins/memory-wiki.md @@ -441,6 +441,9 @@ knowledge layer: { memory: { backend: "qmd", + }, + plugins: { + entries: { "memory-wiki": { enabled: true, config: { diff --git a/src/docs/plugin-doc-examples.test.ts b/src/docs/plugin-doc-examples.test.ts new file mode 100644 index 00000000000..248fa61077c --- /dev/null +++ b/src/docs/plugin-doc-examples.test.ts @@ -0,0 +1,49 @@ +import fs from "node:fs"; +import path from "node:path"; +import JSON5 from "json5"; +import { describe, expect, it } from "vitest"; + +const PLUGIN_DOCS_DIR = path.join(process.cwd(), "docs", "plugins"); + +function lineNumberAt(source: string, index: number): number { + return source.slice(0, index).split("\n").length; +} + +function listMarkdownFiles(dir: string): string[] { + const files: string[] = []; + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const entryPath = path.join(dir, entry.name); + if (entry.isDirectory()) { + files.push(...listMarkdownFiles(entryPath)); + } else if (entry.isFile() && entry.name.endsWith(".md")) { + files.push(entryPath); + } + } + return files; +} + +describe("plugin docs examples", () => { + it("keeps plugin docs JSON fences parseable", () => { + const failures: string[] = []; + for (const docPath of listMarkdownFiles(PLUGIN_DOCS_DIR)) { + const markdown = fs.readFileSync(docPath, "utf8"); + const blocks = markdown.matchAll(/```(json5|json)\n([\s\S]*?)```/g); + for (const match of blocks) { + const lang = match[1] ?? ""; + const code = match[2] ?? ""; + const relativePath = path.relative(process.cwd(), docPath).split(path.sep).join("/"); + const location = `${relativePath}:${lineNumberAt(markdown, match.index ?? 0)}`; + try { + if (lang === "json") { + JSON.parse(code); + } else { + JSON5.parse(code); + } + } catch (error) { + failures.push(`${location} ${lang.toUpperCase()} parse failed: ${String(error)}`); + } + } + } + expect(failures).toEqual([]); + }); +}); diff --git a/test/vitest/vitest.unit-fast-paths.mjs b/test/vitest/vitest.unit-fast-paths.mjs index 4ce9cd9fa6b..f5a445c0f85 100644 --- a/test/vitest/vitest.unit-fast-paths.mjs +++ b/test/vitest/vitest.unit-fast-paths.mjs @@ -93,6 +93,7 @@ export const forcedUnitFastTestFiles = [ "src/canvas-host/server.state-dir.test.ts", "src/docs/clawhub-plugin-docs.test.ts", "src/docs/channel-config-examples.test.ts", + "src/docs/plugin-doc-examples.test.ts", "src/docs/install-cloud-secrets.test.ts", "src/docker-build-cache.test.ts", "src/docker-image-digests.test.ts",