@copilotkit/aimock 1.43.0 → 1.45.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +46 -0
- package/README.md +14 -2
- package/dist/agui-handler.d.ts.map +1 -1
- package/dist/aimock-cli.cjs +31 -5
- package/dist/aimock-cli.cjs.map +1 -1
- package/dist/aimock-cli.d.cts.map +1 -1
- package/dist/aimock-cli.d.ts.map +1 -1
- package/dist/aimock-cli.js +31 -5
- package/dist/aimock-cli.js.map +1 -1
- package/dist/bedrock-converse.cjs +344 -43
- package/dist/bedrock-converse.cjs.map +1 -1
- package/dist/bedrock-converse.d.cts.map +1 -1
- package/dist/bedrock-converse.d.ts.map +1 -1
- package/dist/bedrock-converse.js +345 -44
- package/dist/bedrock-converse.js.map +1 -1
- package/dist/bedrock.cjs +195 -42
- package/dist/bedrock.cjs.map +1 -1
- package/dist/bedrock.d.cts.map +1 -1
- package/dist/bedrock.d.ts.map +1 -1
- package/dist/bedrock.js +196 -43
- package/dist/bedrock.js.map +1 -1
- package/dist/chaos.cjs +9 -5
- package/dist/chaos.cjs.map +1 -1
- package/dist/chaos.d.cts.map +1 -1
- package/dist/chaos.d.ts.map +1 -1
- package/dist/chaos.js +10 -7
- package/dist/chaos.js.map +1 -1
- package/dist/cli.cjs +238 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +242 -13
- package/dist/cli.js.map +1 -1
- package/dist/cohere.cjs +159 -72
- package/dist/cohere.cjs.map +1 -1
- package/dist/cohere.d.cts.map +1 -1
- package/dist/cohere.d.ts.map +1 -1
- package/dist/cohere.js +160 -73
- package/dist/cohere.js.map +1 -1
- package/dist/config-loader.cjs +63 -5
- package/dist/config-loader.cjs.map +1 -1
- package/dist/config-loader.d.cts +37 -4
- package/dist/config-loader.d.cts.map +1 -1
- package/dist/config-loader.d.ts +37 -4
- package/dist/config-loader.d.ts.map +1 -1
- package/dist/config-loader.js +63 -5
- package/dist/config-loader.js.map +1 -1
- package/dist/constants.cjs +8 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +6 -2
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +8 -1
- package/dist/constants.js.map +1 -1
- package/dist/echo-text.cjs +65 -0
- package/dist/echo-text.cjs.map +1 -0
- package/dist/echo-text.d.cts +22 -0
- package/dist/echo-text.d.cts.map +1 -0
- package/dist/echo-text.d.ts +22 -0
- package/dist/echo-text.d.ts.map +1 -0
- package/dist/echo-text.js +65 -0
- package/dist/echo-text.js.map +1 -0
- package/dist/embeddings.cjs +18 -1
- package/dist/embeddings.cjs.map +1 -1
- package/dist/embeddings.d.cts +1 -1
- package/dist/embeddings.d.cts.map +1 -1
- package/dist/embeddings.d.ts +1 -1
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/embeddings.js +18 -1
- package/dist/embeddings.js.map +1 -1
- package/dist/fakes-plugin.cjs +131 -0
- package/dist/fakes-plugin.cjs.map +1 -0
- package/dist/fakes-plugin.d.cts +23 -0
- package/dist/fakes-plugin.d.cts.map +1 -0
- package/dist/fakes-plugin.d.ts +23 -0
- package/dist/fakes-plugin.d.ts.map +1 -0
- package/dist/fakes-plugin.js +127 -0
- package/dist/fakes-plugin.js.map +1 -0
- package/dist/files.cjs +9 -11
- package/dist/files.cjs.map +1 -1
- package/dist/files.d.cts.map +1 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +10 -13
- package/dist/files.js.map +1 -1
- package/dist/fine-tuning.cjs +1 -19
- package/dist/fine-tuning.cjs.map +1 -1
- package/dist/fine-tuning.d.cts.map +1 -1
- package/dist/fine-tuning.d.ts.map +1 -1
- package/dist/fine-tuning.js +2 -20
- package/dist/fine-tuning.js.map +1 -1
- package/dist/fixture-loader-services.cjs +116 -0
- package/dist/fixture-loader-services.cjs.map +1 -0
- package/dist/fixture-loader-services.d.cts +48 -0
- package/dist/fixture-loader-services.d.cts.map +1 -0
- package/dist/fixture-loader-services.d.ts +48 -0
- package/dist/fixture-loader-services.d.ts.map +1 -0
- package/dist/fixture-loader-services.js +114 -0
- package/dist/fixture-loader-services.js.map +1 -0
- package/dist/fixture-loader.cjs +552 -29
- package/dist/fixture-loader.cjs.map +1 -1
- package/dist/fixture-loader.d.cts +140 -2
- package/dist/fixture-loader.d.cts.map +1 -1
- package/dist/fixture-loader.d.ts +140 -2
- package/dist/fixture-loader.d.ts.map +1 -1
- package/dist/fixture-loader.js +542 -31
- package/dist/fixture-loader.js.map +1 -1
- package/dist/gemini-embeddings.cjs +42 -2
- package/dist/gemini-embeddings.cjs.map +1 -1
- package/dist/gemini-embeddings.js +43 -3
- package/dist/gemini-embeddings.js.map +1 -1
- package/dist/gemini-interactions.cjs +288 -52
- package/dist/gemini-interactions.cjs.map +1 -1
- package/dist/gemini-interactions.d.cts.map +1 -1
- package/dist/gemini-interactions.d.ts.map +1 -1
- package/dist/gemini-interactions.js +289 -53
- package/dist/gemini-interactions.js.map +1 -1
- package/dist/gemini.cjs +234 -38
- package/dist/gemini.cjs.map +1 -1
- package/dist/gemini.d.cts.map +1 -1
- package/dist/gemini.d.ts.map +1 -1
- package/dist/gemini.js +235 -39
- package/dist/gemini.js.map +1 -1
- package/dist/helpers.cjs +1157 -12
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +85 -4
- package/dist/helpers.d.cts.map +1 -1
- package/dist/helpers.d.ts +85 -4
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +1113 -14
- package/dist/helpers.js.map +1 -1
- package/dist/images.cjs +3 -2
- package/dist/images.cjs.map +1 -1
- package/dist/images.js +3 -2
- package/dist/images.js.map +1 -1
- package/dist/index.cjs +39 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +11 -4
- package/dist/jest.cjs +43 -14
- package/dist/jest.cjs.map +1 -1
- package/dist/jest.d.cts +47 -5
- package/dist/jest.d.cts.map +1 -1
- package/dist/jest.d.ts +47 -5
- package/dist/jest.d.ts.map +1 -1
- package/dist/jest.js +45 -16
- package/dist/jest.js.map +1 -1
- package/dist/journal.cjs +155 -13
- package/dist/journal.cjs.map +1 -1
- package/dist/journal.d.cts +54 -4
- package/dist/journal.d.cts.map +1 -1
- package/dist/journal.d.ts +54 -4
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +155 -13
- package/dist/journal.js.map +1 -1
- package/dist/live-sanitize.cjs +4 -32
- package/dist/live-sanitize.cjs.map +1 -1
- package/dist/live-sanitize.js +4 -32
- package/dist/live-sanitize.js.map +1 -1
- package/dist/llmock.cjs +204 -39
- package/dist/llmock.cjs.map +1 -1
- package/dist/llmock.d.cts +51 -1
- package/dist/llmock.d.cts.map +1 -1
- package/dist/llmock.d.ts +51 -1
- package/dist/llmock.d.ts.map +1 -1
- package/dist/llmock.js +206 -41
- package/dist/llmock.js.map +1 -1
- package/dist/mcp-fakes-mount.cjs +217 -0
- package/dist/mcp-fakes-mount.cjs.map +1 -0
- package/dist/mcp-fakes-mount.js +211 -0
- package/dist/mcp-fakes-mount.js.map +1 -0
- package/dist/mcp-fakes-report.cjs +111 -0
- package/dist/mcp-fakes-report.cjs.map +1 -0
- package/dist/mcp-fakes-report.d.cts +40 -0
- package/dist/mcp-fakes-report.d.cts.map +1 -0
- package/dist/mcp-fakes-report.d.ts +40 -0
- package/dist/mcp-fakes-report.d.ts.map +1 -0
- package/dist/mcp-fakes-report.js +107 -0
- package/dist/mcp-fakes-report.js.map +1 -0
- package/dist/mcp-fakes.cjs +1942 -0
- package/dist/mcp-fakes.cjs.map +1 -0
- package/dist/mcp-fakes.d.cts +504 -0
- package/dist/mcp-fakes.d.cts.map +1 -0
- package/dist/mcp-fakes.d.ts +504 -0
- package/dist/mcp-fakes.d.ts.map +1 -0
- package/dist/mcp-fakes.js +1937 -0
- package/dist/mcp-fakes.js.map +1 -0
- package/dist/mcp-handler.cjs +534 -27
- package/dist/mcp-handler.cjs.map +1 -1
- package/dist/mcp-handler.d.cts +49 -0
- package/dist/mcp-handler.d.cts.map +1 -0
- package/dist/mcp-handler.d.ts +49 -0
- package/dist/mcp-handler.d.ts.map +1 -0
- package/dist/mcp-handler.js +530 -28
- package/dist/mcp-handler.js.map +1 -1
- package/dist/mcp-mock.cjs +326 -47
- package/dist/mcp-mock.cjs.map +1 -1
- package/dist/mcp-mock.d.cts +97 -1
- package/dist/mcp-mock.d.cts.map +1 -1
- package/dist/mcp-mock.d.ts +97 -1
- package/dist/mcp-mock.d.ts.map +1 -1
- package/dist/mcp-mock.js +327 -48
- package/dist/mcp-mock.js.map +1 -1
- package/dist/mcp-recorder.cjs +1224 -0
- package/dist/mcp-recorder.cjs.map +1 -0
- package/dist/mcp-recorder.d.cts +108 -0
- package/dist/mcp-recorder.d.cts.map +1 -0
- package/dist/mcp-recorder.d.ts +108 -0
- package/dist/mcp-recorder.d.ts.map +1 -0
- package/dist/mcp-recorder.js +1215 -0
- package/dist/mcp-recorder.js.map +1 -0
- package/dist/mcp-stub.cjs +5 -1
- package/dist/mcp-stub.d.cts +3 -1
- package/dist/mcp-stub.d.ts +3 -1
- package/dist/mcp-stub.js +3 -1
- package/dist/mcp-types.d.cts +6 -0
- package/dist/mcp-types.d.ts +6 -0
- package/dist/message-text.cjs +192 -0
- package/dist/message-text.cjs.map +1 -0
- package/dist/message-text.d.cts +31 -0
- package/dist/message-text.d.cts.map +1 -0
- package/dist/message-text.d.ts +31 -0
- package/dist/message-text.d.ts.map +1 -0
- package/dist/message-text.js +184 -0
- package/dist/message-text.js.map +1 -0
- package/dist/messages.cjs +400 -56
- package/dist/messages.cjs.map +1 -1
- package/dist/messages.d.cts.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +401 -58
- package/dist/messages.js.map +1 -1
- package/dist/metrics.cjs +46 -66
- package/dist/metrics.cjs.map +1 -1
- package/dist/metrics.d.cts +14 -6
- package/dist/metrics.d.cts.map +1 -1
- package/dist/metrics.d.ts +14 -6
- package/dist/metrics.d.ts.map +1 -1
- package/dist/metrics.js +32 -40
- package/dist/metrics.js.map +1 -1
- package/dist/misbehavior.cjs +1523 -0
- package/dist/misbehavior.cjs.map +1 -0
- package/dist/misbehavior.d.cts +43 -0
- package/dist/misbehavior.d.cts.map +1 -0
- package/dist/misbehavior.d.ts +43 -0
- package/dist/misbehavior.d.ts.map +1 -0
- package/dist/misbehavior.js +1511 -0
- package/dist/misbehavior.js.map +1 -0
- package/dist/ollama.cjs +315 -113
- package/dist/ollama.cjs.map +1 -1
- package/dist/ollama.d.cts.map +1 -1
- package/dist/ollama.d.ts.map +1 -1
- package/dist/ollama.js +316 -114
- package/dist/ollama.js.map +1 -1
- package/dist/openapi.cjs +3405 -0
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +30 -0
- package/dist/openapi.d.cts.map +1 -0
- package/dist/openapi.d.ts +30 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +3404 -0
- package/dist/openapi.js.map +1 -0
- package/dist/openrouter-video.cjs +4 -4
- package/dist/openrouter-video.cjs.map +1 -1
- package/dist/openrouter-video.d.cts.map +1 -1
- package/dist/openrouter-video.d.ts.map +1 -1
- package/dist/openrouter-video.js +4 -4
- package/dist/openrouter-video.js.map +1 -1
- package/dist/record-sanitize.cjs +231 -0
- package/dist/record-sanitize.cjs.map +1 -0
- package/dist/record-sanitize.js +224 -0
- package/dist/record-sanitize.js.map +1 -0
- package/dist/recorder.cjs +115 -6
- package/dist/recorder.cjs.map +1 -1
- package/dist/recorder.d.cts +2 -1
- package/dist/recorder.d.cts.map +1 -1
- package/dist/recorder.d.ts +2 -1
- package/dist/recorder.d.ts.map +1 -1
- package/dist/recorder.js +116 -8
- package/dist/recorder.js.map +1 -1
- package/dist/responses.cjs +701 -166
- package/dist/responses.cjs.map +1 -1
- package/dist/responses.d.cts +5 -13
- package/dist/responses.d.cts.map +1 -1
- package/dist/responses.d.ts +5 -13
- package/dist/responses.d.ts.map +1 -1
- package/dist/responses.js +699 -169
- package/dist/responses.js.map +1 -1
- package/dist/route-registry.cjs +951 -0
- package/dist/route-registry.cjs.map +1 -0
- package/dist/route-registry.d.cts +33 -0
- package/dist/route-registry.d.cts.map +1 -0
- package/dist/route-registry.d.ts +33 -0
- package/dist/route-registry.d.ts.map +1 -0
- package/dist/route-registry.js +866 -0
- package/dist/route-registry.js.map +1 -0
- package/dist/router.cjs +24 -2
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +25 -4
- package/dist/router.js.map +1 -1
- package/dist/server.cjs +1159 -264
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +4 -1
- package/dist/server.d.cts.map +1 -1
- package/dist/server.d.ts +4 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1067 -172
- package/dist/server.js.map +1 -1
- package/dist/speech.cjs +4 -2
- package/dist/speech.cjs.map +1 -1
- package/dist/speech.js +4 -2
- package/dist/speech.js.map +1 -1
- package/dist/stream-collapse.cjs +236 -34
- package/dist/stream-collapse.cjs.map +1 -1
- package/dist/stream-collapse.d.cts +39 -4
- package/dist/stream-collapse.d.cts.map +1 -1
- package/dist/stream-collapse.d.ts +39 -4
- package/dist/stream-collapse.d.ts.map +1 -1
- package/dist/stream-collapse.js +235 -35
- package/dist/stream-collapse.js.map +1 -1
- package/dist/suite.cjs +1 -1
- package/dist/suite.js +1 -1
- package/dist/transcription.cjs +2 -2
- package/dist/transcription.cjs.map +1 -1
- package/dist/transcription.d.cts.map +1 -1
- package/dist/transcription.d.ts.map +1 -1
- package/dist/transcription.js +2 -2
- package/dist/transcription.js.map +1 -1
- package/dist/types.cjs +18 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +516 -5
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +516 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/validate-cli.cjs +123 -33
- package/dist/validate-cli.cjs.map +1 -1
- package/dist/validate-cli.js +125 -35
- package/dist/validate-cli.js.map +1 -1
- package/dist/vector-stores.cjs +1180 -0
- package/dist/vector-stores.cjs.map +1 -0
- package/dist/vector-stores.d.cts +106 -0
- package/dist/vector-stores.d.cts.map +1 -0
- package/dist/vector-stores.d.ts +106 -0
- package/dist/vector-stores.d.ts.map +1 -0
- package/dist/vector-stores.js +1164 -0
- package/dist/vector-stores.js.map +1 -0
- package/dist/vector-types.d.cts.map +1 -1
- package/dist/version.cjs +45 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.js +44 -0
- package/dist/version.js.map +1 -0
- package/dist/video.cjs +19 -0
- package/dist/video.cjs.map +1 -1
- package/dist/video.d.cts.map +1 -1
- package/dist/video.d.ts.map +1 -1
- package/dist/video.js +19 -0
- package/dist/video.js.map +1 -1
- package/dist/vitest.cjs +77 -16
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.d.cts +38 -5
- package/dist/vitest.d.cts.map +1 -1
- package/dist/vitest.d.ts +38 -5
- package/dist/vitest.d.ts.map +1 -1
- package/dist/vitest.js +78 -17
- package/dist/vitest.js.map +1 -1
- package/dist/watcher.cjs +6 -2
- package/dist/watcher.cjs.map +1 -1
- package/dist/watcher.js +6 -2
- package/dist/watcher.js.map +1 -1
- package/dist/ws-gemini-live.cjs +210 -101
- package/dist/ws-gemini-live.cjs.map +1 -1
- package/dist/ws-gemini-live.d.cts +9 -3
- package/dist/ws-gemini-live.d.cts.map +1 -1
- package/dist/ws-gemini-live.d.ts +9 -3
- package/dist/ws-gemini-live.d.ts.map +1 -1
- package/dist/ws-gemini-live.js +211 -102
- package/dist/ws-gemini-live.js.map +1 -1
- package/dist/ws-realtime.cjs +175 -62
- package/dist/ws-realtime.cjs.map +1 -1
- package/dist/ws-realtime.d.cts +8 -3
- package/dist/ws-realtime.d.cts.map +1 -1
- package/dist/ws-realtime.d.ts +8 -3
- package/dist/ws-realtime.d.ts.map +1 -1
- package/dist/ws-realtime.js +176 -63
- package/dist/ws-realtime.js.map +1 -1
- package/dist/ws-responses.cjs +121 -16
- package/dist/ws-responses.cjs.map +1 -1
- package/dist/ws-responses.d.cts +8 -12
- package/dist/ws-responses.d.cts.map +1 -1
- package/dist/ws-responses.d.ts +8 -12
- package/dist/ws-responses.d.ts.map +1 -1
- package/dist/ws-responses.js +123 -18
- package/dist/ws-responses.js.map +1 -1
- package/package.json +13 -2
- package/skills/write-fixtures/SKILL.md +179 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-cli.cjs","names":["Logger","entryToFixture","validateFixtures","renderValidationRef"],"sources":["../src/validate-cli.ts"],"sourcesContent":["/**\n * `aimock validate` subcommand — offline fixture lint.\n *\n * Usage: `aimock validate [--strict] [--json] [--] <path> [more paths ...]`\n *\n * Each path is a fixture file or a directory; directories are walked\n * recursively for `*.json` in the same order `--fixtures <dir>` loads them.\n * For each file: read bytes, JSON-parse, require a top-level\n * `{ \"fixtures\": [...] }` envelope, convert the entries (surfacing the\n * per-entry conversion warnings the server logs), then run the\n * `validateFixtures` rules over that file's entries alone, so its findings\n * are attributed to it.\n *\n * `validateFixtures` is then run a SECOND time over the union of every\n * successfully-parsed file's entries, in load order. Its rules are not all\n * per-fixture: `duplicate userMessage` and the catch-all ordering check look\n * at the other fixtures in the array they are given. Run per file those two\n * cannot see across files, so the findings the union pass adds — a\n * `userMessage` duplicated in two files, a catch-all that is last in its own\n * file but not last overall — are the cross-file ones. They are reported\n * against the file that owns the fixture, with the other file named in the\n * message; findings the per-file pass already made are not repeated.\n *\n * How this compares to the server's `--validate-on-load`, in both directions:\n * - Stricter: there an unreadable, unparseable or wrong-shape file is\n * non-fatal — it warns on stderr, contributes zero fixtures, and startup\n * continues as long as the run loaded at least one fixture from somewhere.\n * Here every such file fails the run — with one deliberate exception, for\n * parity: a `*.json` file the WALK turned up that parses but carries no\n * top-level `fixtures` array is not a fixture file (this package's own\n * `fixtures/` tree holds aimock config files alongside fixtures), and is\n * passed over with a note, exactly as the loader passes over it. A file\n * the caller NAMES is still validated, wrong shape and all. Two walk\n * hazards the server does not\n * survive are refused outright rather than mirrored: a `*.json` path that\n * is not a regular file (a FIFO, a socket, a device) is a per-file error\n * here, where the server's `readFileSync` blocks on it forever; and a\n * directory symlink that points back at a directory already being walked\n * is reported once as a cycle, where the server recurses through it until\n * the kernel returns ELOOP (~32 levels deep) and loads those levels'\n * fixtures over and over. One diagnostic here has no counterpart there at\n * all: an entry whose `match` is a string, a number, a boolean or an array\n * converts, on both sides, into an EMPTY match — a catch-all answering\n * every request — and the server loads it without a word. That is a server\n * bug, not a rule this lint may quietly invent an error for, so it is a\n * `[warning]` (which `--strict` promotes to a failure) rather than an\n * error, and the fixture still goes on to the rules exactly as the server\n * would build it.\n * - Equal: the `validateFixtures` rules themselves, because of the union\n * pass above, and the zero-fixture rule — a run whose inputs yield no\n * fixtures at all is an error here, matching the server's \"No fixtures\n * loaded and validation/strict mode is enabled — aborting.\" A single\n * `{\"fixtures\": []}` file alongside files that do load fixtures is an\n * error in neither place. Equal too in what the inputs expand to: a path\n * named twice, and a directory reached both directly and through an\n * acyclic symlink to it, are validated once per mention, exactly as the\n * server loads one `--fixtures` source per mention — so the duplicate\n * fixtures that produces are reported here as the server reports them,\n * one finding per (fixture, rule), the same count the server logs.\n *\n * A path mentioned more than once in one run is therefore several DIFFERENT\n * loads that happen to share a name, and printing that bare name for each of\n * them made them indistinguishable: a warning read as if a fixture shadowed\n * itself. Each mention is numbered, and every rendering surface carries that\n * number — human lines and their summary, cross-file references, and a\n * `mention` field on each `--json` `files[]` entry. The `<path>[<n>]` suffix\n * is printed only for a path that IS mentioned more than once, because for\n * every other path the name alone already names one load; the `--json` field\n * is always present so a consumer never has to infer it.\n * - Weaker: this is a static lint. It never starts a server, so it covers\n * nothing about binding, remote `--fixtures <url>` sources (it reads local\n * paths only), `--watch` reloads, or any runtime behaviour.\n *\n * Nothing the filesystem or a fixture entry can do is allowed to escape this\n * function: a malformed entry, an unreadable path, a stat failure or a symlink\n * cycle each becomes a per-file `[error]` in the report, and a crash inside\n * either `validateFixtures` pass becomes a file-level or run-level `[error]`,\n * so the run still emits a report (valid JSON under `--json`) and still exits\n * 1. Run-level errors print after the per-file output, and the \"no fixtures\n * loaded\" one is withheld when a file already reported why it loaded none.\n *\n * Prints human lines by default (`file: [error|warning] #i message`) or a\n * JSON document with `--json`. Everything that contributes to a non-zero exit\n * goes to stderr, so a CI log's stderr always shows the reason; `--json` keeps\n * stdout to the report alone and puts the reason on stderr. The two modes\n * report the same facts: a fatal file is one record that both the stdout\n * tally and `files[].errors` count, and `--json` emits a document for a usage\n * error too — stdout is never empty on a `--json` run, whatever failed it.\n * A path naming a remote source (`https://...`) is refused as unsupported\n * rather than read as a filename. Exit codes:\n * 0 = clean (warnings allowed unless `--strict`), 1 = everything that fails\n * the run — errors / unreadable / unparseable / wrong shape / unwalkable path\n * / no fixtures loaded at all, and a usage error (no paths or an unknown\n * option) too, because every other CLI surface in this package exits 1 on a\n * usage error and nothing here uses sysexits codes. `--help` is handled\n * separately and exits 0.\n */\n\nimport { readFileSync, readdirSync, realpathSync, statSync } from \"node:fs\";\nimport type { Stats } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { format, parseArgs } from \"node:util\";\nimport { entryToFixture, renderValidationRef, validateFixtures } from \"./fixture-loader.js\";\nimport type { ValidationRef } from \"./fixture-loader.js\";\nimport { Logger } from \"./logger.js\";\nimport type { Fixture, FixtureFile } from \"./types.js\";\n\nexport const VALIDATE_HELP = `\nUsage: aimock validate [options] [--] <path> [more paths ...]\n\nValidate aimock fixture files offline. Each path is a fixture file or a\ndirectory of them (walked recursively for *.json, like --fixtures <dir>).\nFiles are checked one at a time and then as one combined set, so the rules\nthat span files -- a userMessage duplicated across two files, a catch-all\nthat is not last overall -- are reported here as the server reports them.\n\nWhere the server's --validate-on-load differs: there an unreadable,\nunparseable or wrong-shape file only warns and startup continues, while here\nevery such file fails the run. The one exception, which matches the loader: a\n*.json file found by WALKING a directory that has no top-level \"fixtures\"\narray is not a fixture file (an aimock config, say) and is skipped with a\nnote -- a file you name on the command line is still validated. As on the\nserver, a run that loads no fixtures at all is an error. This is a static lint: it starts no server and reads\nlocal paths only (no remote --fixtures URL).\n\nA path given twice is validated twice, because the server loads one set of\nfixtures per --fixtures it is given; the duplicate fixtures that produces are\nreported as the server reports them, one finding per fixture and rule. Such a\npath is printed as <path>[<n>], numbering its mentions from 1, so each load\nand every reference to its fixtures names one of them (--json reports the\nnumber as \"mention\" on every file). A directory symlink pointing back at a\ndirectory already being walked is a symlink cycle and fails the run; one\npointing anywhere else is followed, as the server follows it.\n\nOptions:\n --strict Treat warnings as errors (exit 1 on warnings)\n --json Emit a JSON report instead of human lines\n -h, --help Show this help message\n -- Stop option parsing; every later argument is a path\n (use this for a path that begins with \"-\")\n\nExit codes:\n 0 all files valid (warnings allowed unless --strict)\n 1 anything that failed the run: validation errors; a malformed fixture\n entry; an unreadable or unparseable file; a named path of the wrong\n shape (a walked one is skipped instead); a path that\n cannot be stat'd, read or walked (including a symlink cycle, or a\n *.json path that is not a regular file); a directory holding no *.json;\n no fixtures loaded from any input; --strict warnings; or a usage error\n (no paths given, or an unknown option)\n`.trim();\n\nexport interface ValidateCliDeps {\n argv?: string[];\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n}\n\n/**\n * One finding against a file. `index` is the fixture entry it belongs to and is\n * ABSENT when the finding is about the file as a whole (a crash inside the\n * validator, say) rather than an entry — attributing such a finding to entry #0\n * blames a fixture that may be perfectly valid. `detail` carries the raw\n * underlying text (a thrown error's message) for a finding whose `message` is a\n * human-facing rephrasing of it; the `--json` report carries it as its own\n * field and the human report prints it on an indented continuation line.\n */\ninterface Finding {\n index?: number;\n message: string;\n detail?: string;\n}\n\ninterface FileReport {\n file: string;\n /**\n * Which mention of `file` this report is, 1-based, in the order the run\n * expanded its paths. It is the only thing that tells two reports of the\n * same path apart — they are separate loads with separate findings.\n */\n mention: number;\n fixtures: number;\n errors: Finding[];\n warnings: Finding[];\n fatal?: string;\n /** Set when the walk passed the file over; see `nonFixtureSkipReason`. */\n skipped?: string;\n}\n\n/**\n * A rule finding the per-file pass made, with what the cross-file pass needs\n * to recognise its own restatement of it.\n *\n * Both passes run the same rules, and each rule fires at most once per fixture\n * — which is why the server, whose single pass IS the union pass, logs exactly\n * one line per (fixture, rule). So the SITE identifies the finding: the file\n * (supplied by the caller, the only thing that knows the file id), the entry\n * index, the severity and the rule. Two findings at one site can differ only\n * in which other fixtures they name, and the union pass's answer to that is\n * the authoritative one — it sees every file — so its wording REPLACES the\n * per-file wording rather than printing beside it, which is what made a\n * repeated path report one duplicate twice.\n *\n * `refs` holds the entry indices this finding names, so a restatement that\n * names the same fixtures can be recognised as adding nothing and leave the\n * per-file wording alone. Matching on the rendered message with its digits\n * masked (a previous scheme) both collapsed distinct findings that happened to\n * mask alike and hid genuine cross-file ones, because a union index and a\n * file-local index mask to the same \"#\".\n *\n * `finding` is the very object in the report, so an upgrade is an in-place\n * rewrite that keeps the finding in the position it was reported at.\n */\ninterface FindingIdentity {\n severity: \"error\" | \"warning\";\n index: number;\n /** The rule id for a ref-carrying finding, else its verbatim message. */\n kind: string;\n /** Entry indices this finding names, within the SAME file. */\n refs: number[];\n /** The finding as it sits in the file's report, for an in-place upgrade. */\n finding: Finding;\n}\n\n/** The indices a ref names, in a fixed order, for identity purposes. */\nfunction refIndices(ref: ValidationRef): number[] {\n return ref.rule === \"duplicate-user-message\"\n ? [ref.shadows]\n : [ref.shadowsFrom, ref.shadowsThrough];\n}\n\n/**\n * A path argument that names a remote source rather than a local file: any\n * `scheme://` prefix, not just http(s), so `ftp://` and friends get the same\n * explanation instead of a filesystem error. A Windows drive letter (\"C:\\\\x\")\n * has no `//` and is not matched.\n */\nconst REMOTE_SOURCE = /^[a-z][a-z0-9+.-]*:\\/\\//i;\n\n/** Render an unknown thrown value as a one-line message. */\nfunction errText(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/**\n * Record why a file produced no report at all. A fatal is ONE fact, so it is\n * written once, here, into both shapes that report it: `fatal`, which names\n * the reason, and `errors`, which is what every tally — the human summary\n * line, the `--json` consumer counting `files[].errors` — actually counts.\n * Set on `fatal` alone, the two modes disagreed: stdout said \"1 error(s)\"\n * while the same run's JSON said `\"errors\": []`, so a CI script adding up the\n * JSON saw a clean run that had exited 1.\n *\n * The finding carries no `index`: a fatal is about the file, not an entry\n * (see `Finding.index`).\n */\nfunction setFatal(report: FileReport, message: string): void {\n report.fatal = message;\n report.errors.push({ message });\n}\n\n/** A file that never got as far as a report, with its fatal already recorded. */\nfunction fatalReport(file: string, mention: number, message: string): FileReport {\n const report: FileReport = { file, mention, fixtures: 0, errors: [], warnings: [] };\n setFatal(report, message);\n return report;\n}\n\n/**\n * Logger that routes `warn` AND `error` into caller-supplied sinks instead of\n * the console, so the per-entry conversion diagnostics `entryToFixture` emits\n * land in the report rather than being dropped on the floor — and, under\n * `--json`, never interleave with the JSON document on stdout/stderr.\n * Exported for tests only; it is not part of the package's public API.\n * `info`/`debug` are inert: they are already below this logger's \"warn\" level,\n * and silencing them explicitly keeps future call sites off stdout too.\n */\nexport class CollectingLogger extends Logger {\n private readonly warnSink: (msg: string) => void;\n private readonly errorSink: (msg: string) => void;\n\n constructor(warnSink: (msg: string) => void, errorSink: (msg: string) => void) {\n super(\"warn\");\n this.warnSink = warnSink;\n this.errorSink = errorSink;\n }\n\n /**\n * Serialise exactly as the sink this logger replaces does — byte for byte.\n * `Logger` writes `console.warn(\"[aimock]\", ...args)`, and console's\n * formatting IS `util.format`, so the call it makes is\n * `format(\"[aimock]\", ...args)`: `\"[aimock]\"` is the FORMAT STRING and holds\n * no specifiers, which is what makes a caller's own `%s`/`%d` inert and its\n * arguments plain trailing values. Calling `format(...args)` instead\n * promoted the caller's message into the format slot — so a message that\n * happened to contain `%s` (a fixture path, say) swallowed the next\n * argument — and dropped the `[aimock]` prefix, leaving the report and the\n * server's own stderr disagreeing about the same diagnostic.\n * `util.inspect` still renders object arguments readably, which is what\n * `String(a)` could not do.\n */\n private static format(args: unknown[]): string {\n return format(\"[aimock]\", ...args);\n }\n\n override warn(...args: unknown[]): void {\n this.warnSink(CollectingLogger.format(args));\n }\n\n override error(...args: unknown[]): void {\n this.errorSink(CollectingLogger.format(args));\n }\n\n override info(...args: unknown[]): void {\n void args; /* suppressed: never write to stdout from inside a --json run */\n }\n\n override debug(...args: unknown[]): void {\n void args; /* suppressed: never write to stdout from inside a --json run */\n }\n}\n\n/**\n * One product of the walk: a `*.json` file to validate, or — with `fatal`\n * set — a path that could not be walked, reported as its own per-file error,\n * or — with `skipped` set — a `*.json` file the walk found that is not a\n * fixture file at all and is passed over (see `nonFixtureSkipReason`).\n */\ninterface CollectEntry {\n file: string;\n fatal?: string;\n skipped?: string;\n}\n\n/**\n * Why a `*.json` file the WALK turned up is not a fixture file, or\n * `undefined` if it is one (or if the question cannot be answered cheaply).\n *\n * A directory is not a fixture directory: this package ships `fixtures/`\n * holding both fixture files and eight aimock CONFIG files — the six\n * `fixtures/examples/**\\/*-config.json`, `full-suite.json`, and\n * `agui/agui-text-response.json`, whose AG-UI fixtures sit NESTED under\n * `agui` where `--fixtures` cannot see them — which is why the documented\n * `aimock validate ./fixtures/` exited 1 on the package's own tree. The\n * server has the same mixture to deal with and passes over it:\n * `loadFixtureFile` warns \"Missing or invalid \\\"fixtures\\\" array\", returns no\n * fixtures, and startup continues. This mirrors that skip, so a walked\n * directory reports on the fixture files in it and says what it passed over.\n *\n * Non-fixture means the file carries no top-level `fixtures` key at all (or\n * is an aimock config). A `fixtures` key that is present but not an array is\n * a MALFORMED fixture file and still fails the run, as the loader would refuse\n * it. The skip applies ONLY to files the walk discovered — a path the caller named explicitly is still validated, and a\n * wrong-shape file there still fails the run, because naming a file is\n * asking about that file.\n *\n * A file carrying an aimock config section (`configSections`) is named as\n * what it is rather than by what it lacks, because \"not a fixture file\" on\n * its own is read as \"holds no fixtures\" — false of `agui`-sectioned configs,\n * which hold AG-UI fixtures that `aimock --config`, not `--fixtures`, serves.\n *\n * Unreadable and unparseable are deliberately NOT skips. Returning\n * `undefined` for them hands the file to `validateOneFile`, which reports the\n * real read error or JSON syntax error — a defect in any `*.json` file, and\n * one no config file has an excuse for either.\n */\nfunction nonFixtureSkipReason(file: string): string | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(file, \"utf-8\")) as unknown;\n } catch {\n return undefined;\n }\n const asConfig = aimockConfigDescription(parsed);\n if (asConfig !== undefined) return `not a fixture file — ${asConfig}`;\n // A present `fixtures` key of the wrong shape is a MALFORMED fixture file,\n // not a non-fixture file: hand it to `validateOneFile`, which fails it the\n // way the same file fails when named.\n if (typeof parsed === \"object\" && parsed !== null && \"fixtures\" in parsed) return undefined;\n return 'not a fixture file — no top-level \"fixtures\" key';\n}\n\n/**\n * The mock sections of `AimockConfig` (config-loader.ts). An object carrying\n * any of them is an aimock config file: `aimock --config <path>` starts a\n * server from it, while `--fixtures <path>` loads nothing from it.\n */\nconst CONFIG_SECTIONS = [\"llm\", \"mcp\", \"a2a\", \"agui\", \"vector\", \"services\"] as const;\n\n/**\n * What a parsed-but-not-fixture-shaped JSON document IS, when it is an aimock\n * config file, or `undefined` when it is not one. Used by both the walk's skip\n * note and the fatal a NAMED file of that shape gets, so the two surfaces\n * describe the same file the same way. The sections found are listed, so an\n * `agui` config is never described as a file holding no fixtures — it holds\n * AG-UI ones, nested where the fixture loader does not look.\n */\nfunction aimockConfigDescription(parsed: unknown): string | undefined {\n if (typeof parsed !== \"object\" || parsed === null) return undefined;\n const doc = parsed as Record<string, unknown>;\n const sections = CONFIG_SECTIONS.filter((key) => typeof doc[key] === \"object\" && doc[key]);\n if (sections.length === 0) return undefined;\n return `an aimock config file (${sections.join(\", \")}), which \"aimock --config\" serves and \"--fixtures\" does not load`;\n}\n\n/**\n * Collect `*.json` files under `dirPath`, recursing into subdirectories.\n * Mirrors `loadFixturesFromDir`: within a directory the `*.json` files come\n * first in sorted order, then its subdirectories in sorted order, so the\n * reported order matches the server's load order, and the same stat-error\n * handling — a vanished entry (ENOENT) is skipped silently, every other\n * failure is surfaced. Unlike the loader, which only warns, each surfaced\n * failure becomes a `fatal` entry that fails the run, and it is emitted in\n * walk position (an unreadable subdirectory is reported where that\n * subdirectory was reached, not after every file in the tree) so the report\n * reads in encounter order. Entries that are neither directories nor\n * `*.json` files are ignored, as they are by the loader.\n *\n * `ancestors` holds the real paths of the directories this call is nested\n * inside. A directory whose real path is one of them closes a symlink cycle\n * and is reported instead of walked; the server has no such guard and\n * recurses through the cycle until the kernel returns ELOOP. A repeat visit\n * that is NOT an ancestor — `root/link -> root/sub` alongside `root/sub` — is\n * no cycle: it is walked again, because the server walks it again and loads\n * those fixtures twice.\n *\n * A `*.json` entry that is not a regular file (a FIFO, a socket, a device)\n * is a `fatal` entry rather than a target, because reading it is what the\n * containment promise above cannot keep: `readFileSync` on a FIFO with no\n * writer blocks forever, as it does on the server.\n */\nfunction collectJsonFiles(\n dirPath: string,\n ancestors: string[],\n out: CollectEntry[] = [],\n): CollectEntry[] {\n let realPath: string;\n try {\n realPath = realpathSync(dirPath);\n } catch (err) {\n out.push({ file: dirPath, fatal: `Could not resolve directory: ${errText(err)}` });\n return out;\n }\n if (ancestors.includes(realPath)) {\n out.push({\n file: dirPath,\n fatal: `Symlink cycle detected: already walking ${realPath}`,\n });\n return out;\n }\n\n let names: string[];\n try {\n names = readdirSync(dirPath);\n } catch (err) {\n out.push({ file: dirPath, fatal: `Could not read directory: ${errText(err)}` });\n return out;\n }\n\n // Sort the whole entry list, not just the `*.json` names, so a stat failure\n // or a non-regular `*.json` lands at a deterministic place in the report\n // whatever order the filesystem hands entries back in.\n const subdirs: string[] = [];\n for (const name of [...names].sort()) {\n const fullPath = join(dirPath, name);\n let stats: Stats;\n try {\n stats = statSync(fullPath);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") {\n out.push({ file: fullPath, fatal: `Could not stat: ${errText(err)}` });\n }\n continue;\n }\n if (stats.isDirectory()) subdirs.push(name);\n else if (!name.endsWith(\".json\")) continue;\n else if (stats.isFile()) {\n const skipped = nonFixtureSkipReason(fullPath);\n out.push(skipped === undefined ? { file: fullPath } : { file: fullPath, skipped });\n } else out.push({ file: fullPath, fatal: \"Not a regular file\" });\n }\n\n const chain = [...ancestors, realPath];\n for (const sub of subdirs) collectJsonFiles(join(dirPath, sub), chain, out);\n return out;\n}\n\n/** The entry shape the loader and the server both assume, quoted verbatim. */\nconst ENTRY_SHAPE = 'every entry needs { \"match\": { ... }, \"response\": { ... } }';\n\n/** Name a value the way a fixture author would read it back in their JSON. */\nfunction gotText(value: unknown): string {\n if (value === null) return \"null\";\n if (value === undefined) return \"absent\";\n if (Array.isArray(value)) return \"an array\";\n return `a ${typeof value}`;\n}\n\n/**\n * A shape defect in a raw fixture entry, classified BEFORE conversion.\n *\n * `convertible` is what the SERVER does with the same entry, and it is the\n * whole reason this is a classifier and not a catch handler. `entryToFixture`\n * only reads `entry.match.userMessage` and friends, so it throws for exactly\n * two shapes: a non-object `entry`, and an `entry.match` that is null or\n * absent. A `match` that is a STRING, a NUMBER, a BOOLEAN or an ARRAY has no\n * such properties either, but reading them is perfectly legal — every field\n * comes back `undefined`, the entry converts into an EMPTY match, and an empty\n * match is a catch-all that answers every request. Classifying after the throw\n * therefore never saw that case at all, and `validate` printed `OK`.\n */\ntype EntryDefect =\n /** `entryToFixture` would throw: report it and skip the entry. */\n | { severity: \"error\"; convertible: false; why: string }\n /** Converts, but not into the fixture the author meant: report and convert. */\n | { severity: \"warning\"; convertible: true; why: string };\n\n/**\n * Classify a raw entry's shape, or return `undefined` when nothing about it is\n * worth saying. Runs before `entryToFixture`, so every branch below is driven\n * by the entry itself rather than by whichever exception the conversion\n * happened to throw.\n *\n * A missing or non-object `response` is deliberately NOT classified here: the\n * conversion accepts it (`{ ...undefined }` is `{}`), the server accepts it,\n * and the `validateFixtures` rules already reject it by name — \"response is\n * not a recognized type (must have content, toolCalls, ...)\" — which is the\n * more actionable message of the two. Saying it here as well would report one\n * defect twice. It is still named alongside `match` when `match` is fatal,\n * because then the rules never run on the entry at all and an author fixing\n * `{}` would otherwise need one round trip per missing key.\n */\nfunction classifyEntry(entry: unknown): EntryDefect | undefined {\n if (entry === null || typeof entry !== \"object\" || Array.isArray(entry)) {\n return {\n severity: \"error\",\n convertible: false,\n why: `entry is ${gotText(entry)}, expected an object — ${ENTRY_SHAPE}`,\n };\n }\n const match = (entry as Record<string, unknown>).match;\n if (match === null || match === undefined) {\n const missing = ([\"match\", \"response\"] as const).filter((key) => {\n const value = (entry as Record<string, unknown>)[key];\n return value === null || typeof value !== \"object\" || Array.isArray(value);\n });\n return {\n severity: \"error\",\n convertible: false,\n why: `missing or non-object ${missing.map((k) => `\"${k}\"`).join(\" and \")} — ${ENTRY_SHAPE}`,\n };\n }\n if (typeof match !== \"object\" || Array.isArray(match)) {\n return {\n severity: \"warning\",\n convertible: true,\n why:\n `\"match\" is ${gotText(match)}, not an object — every match field reads as ` +\n `undefined, so this entry is an empty match: a CATCH-ALL answering every ` +\n `request. The server loads it the same way, so this warns rather than ` +\n `errors; --strict fails on it. ${ENTRY_SHAPE}`,\n };\n }\n return undefined;\n}\n\n/**\n * The backstop for an entry `classifyEntry` passed and `entryToFixture` threw\n * on anyway (a `toolCalls: [null]`, say, which `normalizeResponse` walks).\n * Which entry it was is the actionable half, so that leads; the raw thrown\n * text follows as `detail`, which `--json` carries as its own field and the\n * human report prints on an indented continuation line. It used to say\n * `see \"detail\"`, naming a field only the `--json` report has — in human mode\n * that pointed at nothing at all.\n */\nfunction unexpectedEntryFailure(index: number, err: unknown): Finding {\n return {\n index,\n message: `Invalid fixture entry #${index}: could not be converted to a fixture`,\n detail: errText(err),\n };\n}\n\n/**\n * Validate one fixture file into a report. Every failure mode — unreadable,\n * unparseable, wrong shape, or a single malformed entry — is recorded in the\n * returned report rather than thrown.\n *\n * The converted fixtures are handed back alongside the report, with\n * `indices[i]` giving the entry index `fixtures[i]` was converted from, so the\n * cross-file union pass can append them and map its findings back to a file\n * and an entry index.\n */\nfunction validateOneFile(\n file: string,\n mention: number,\n): {\n report: FileReport;\n fixtures: Fixture[];\n indices: number[];\n identities: FindingIdentity[];\n runErrors: string[];\n} {\n const report: FileReport = { file, mention, fixtures: 0, errors: [], warnings: [] };\n const fixtures: Fixture[] = [];\n const sourceIndex: number[] = [];\n // Findings that belong to no entry because an index could not be resolved.\n // They are raised at run level rather than filed against a guessed entry.\n const runErrors: string[] = [];\n // Identities of the findings the RULES produced (not the conversion\n // diagnostics, which the union pass cannot produce and so cannot repeat).\n const identities: FindingIdentity[] = [];\n\n let raw: string;\n try {\n raw = readFileSync(file, \"utf-8\");\n } catch (err) {\n setFatal(report, `Could not read file: ${errText(err)}`);\n return { report, fixtures, indices: sourceIndex, identities, runErrors };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch (err) {\n setFatal(report, `Invalid JSON: ${errText(err)}`);\n return { report, fixtures, indices: sourceIndex, identities, runErrors };\n }\n if (\n typeof parsed !== \"object\" ||\n parsed === null ||\n !Array.isArray((parsed as { fixtures?: unknown }).fixtures)\n ) {\n // Naming a file is asking about that file, so the wrong shape is still\n // fatal — the loader refuses it too. Say WHICH wrong shape when the file\n // is an aimock config, so the answer names the file for what it is rather\n // than implying it holds nothing.\n const asConfig = aimockConfigDescription(parsed);\n setFatal(\n report,\n asConfig === undefined\n ? 'Missing or invalid \"fixtures\" array (expected { \"fixtures\": [...] })'\n : `Missing or invalid \"fixtures\" array (expected { \"fixtures\": [...] }) — this is ${asConfig}`,\n );\n return { report, fixtures, indices: sourceIndex, identities, runErrors };\n }\n\n // Convert the entries we already parsed rather than re-reading the file,\n // and give the conversion a logger so its per-entry diagnostics are\n // attributed to the entry that produced them instead of being discarded.\n let entryIndex = 0;\n const entryLogger = new CollectingLogger(\n (message) => report.warnings.push({ index: entryIndex, message }),\n (message) => report.errors.push({ index: entryIndex, message }),\n );\n\n // Classify each entry's shape FIRST, then convert. A `{}`, `null` or\n // match-less entry makes `entryToFixture` throw, so it is reported and\n // skipped; a convertible-but-wrong entry (a non-object `match`) is reported\n // and still converted, so the rules go on seeing exactly the fixture array\n // the server would build. The `try` stays as a backstop for a throw the\n // classifier did not predict. Which entry each converted fixture came from\n // is remembered so `validateFixtures` indices stay entry indices.\n const entries = (parsed as FixtureFile).fixtures;\n for (let index = 0; index < entries.length; index++) {\n entryIndex = index;\n const defect = classifyEntry(entries[index]);\n if (defect !== undefined) {\n const label = defect.severity === \"error\" ? \"Invalid fixture entry\" : \"Fixture entry\";\n const finding: Finding = { index, message: `${label} #${index}: ${defect.why}` };\n if (!defect.convertible) {\n report.errors.push(finding);\n continue;\n }\n report.warnings.push(finding);\n }\n try {\n fixtures.push(entryToFixture(entries[index], entryLogger));\n sourceIndex.push(index);\n } catch (err) {\n report.errors.push(unexpectedEntryFailure(index, err));\n }\n }\n\n report.fixtures = fixtures.length;\n // `validateFixtures` reports against the COMPACTED array, which skips the\n // entries that failed to convert. The finding's own index is mapped back to\n // an entry index — and so are the indices its message NAMES, or one line\n // would print two different index spaces: \"#2 ... shadows fixture 0\" where\n // \"#2\" is an entry and \"0\" is a compacted slot.\n // `?? fixtureIndex` here USED to mask an unresolvable index by printing a\n // compacted slot as if it were an entry index — two different index spaces\n // in one line, with nothing to say so. It is unreachable while `sourceIndex`\n // is pushed in lockstep with `fixtures`, so if it ever fires the run is\n // wrong, not merely imprecise: raise it at run level (which fails the run)\n // instead of quietly printing a number that means something else.\n const unresolved = new Set<number>();\n const toEntryIndex = (fixtureIndex: number): number => {\n const entry = sourceIndex[fixtureIndex];\n if (entry !== undefined) return entry;\n if (!unresolved.has(fixtureIndex)) {\n unresolved.add(fixtureIndex);\n runErrors.push(\n `finding for fixture index ${fixtureIndex}, which maps to no entry in this file`,\n );\n }\n return fixtureIndex;\n };\n try {\n for (const r of validateFixtures(fixtures)) {\n const index = toEntryIndex(r.fixtureIndex);\n const refs = r.ref === undefined ? [] : refIndices(r.ref).map(toEntryIndex);\n const message =\n r.ref === undefined\n ? r.message\n : renderValidationRef(r.ref, (i) => String(toEntryIndex(i)));\n const finding: Finding = { index, message };\n identities.push({\n severity: r.severity,\n index,\n kind: r.ref === undefined ? `message:${r.message}` : r.ref.rule,\n refs,\n finding,\n });\n if (r.severity === \"error\") report.errors.push(finding);\n else report.warnings.push(finding);\n }\n } catch (err) {\n // File-level: the validator walks every entry, so which one tripped it is\n // unknown. Filing it at #0 would accuse the file's first fixture, which is\n // very likely innocent, so this finding carries no entry index at all.\n report.errors.push({ message: `Validation failed for this file: ${errText(err)}` });\n }\n return { report, fixtures, indices: sourceIndex, identities, runErrors };\n}\n\n/**\n * `#<index> ` for a finding that belongs to one entry; empty for a file-level\n * finding, which names no entry (see Finding.index). Shared by the human lines\n * and the failure summary so a reader of either can locate the same entry.\n */\nconst findingAt = (f: Finding): string => (f.index === undefined ? \"\" : `#${f.index} `);\n\n/**\n * One-line reason a run failed, for the stderr side of `--json` output.\n *\n * It NAMES the failure first — the file and the finding that caused the\n * non-zero exit — and only then totals what else failed, because the line is\n * often the single line a CI log shows. Leading with a fixed list of counts\n * put two zeros (\"0 unreadable/invalid file(s), 0 file(s) with errors\") in\n * front of every strict-warning failure, where the reader has to get past the\n * things that did NOT happen to reach the one that did. Counts that are zero\n * are omitted for the same reason, and a file whose fatal is already the lead\n * is counted as unreadable/invalid only, not a second time under \"with\n * errors\" — its fatal now rides in `errors` as well (see `setFatal`).\n */\nfunction summarizeFailure(\n reports: FileReport[],\n strict: boolean,\n runErrors: string[],\n name: (r: FileReport) => string,\n): string {\n const fatalFiles = reports.filter((r) => r.fatal !== undefined);\n const erroredFiles = reports.filter((r) => r.fatal === undefined && r.errors.length > 0);\n const warnedFiles = reports.filter((r) => r.warnings.length > 0);\n\n // First failure in report order: a fatal file, else a file with errors, else\n // a run-level error, else (under --strict) the warning that failed the run.\n let lead: string;\n if (fatalFiles[0] !== undefined) lead = `${name(fatalFiles[0])}: ${fatalFiles[0].fatal}`;\n else if (erroredFiles[0] !== undefined)\n lead = `${name(erroredFiles[0])}: ${findingAt(erroredFiles[0].errors[0])}${erroredFiles[0].errors[0].message}`;\n else if (runErrors[0] !== undefined) lead = runErrors[0];\n else if (warnedFiles[0] !== undefined)\n lead = `${name(warnedFiles[0])}: ${findingAt(warnedFiles[0].warnings[0])}${warnedFiles[0].warnings[0].message} (--strict)`;\n /* v8 ignore next -- a failed run always has one of the four above */ else\n lead = \"the run failed\";\n\n const counts: string[] = [];\n if (fatalFiles.length > 0) counts.push(`${fatalFiles.length} unreadable/invalid file(s)`);\n if (erroredFiles.length > 0) counts.push(`${erroredFiles.length} file(s) with errors`);\n // A run-level error (no fixtures loaded from any input) belongs to no single\n // file, so it is counted on its own.\n if (runErrors.length > 0) counts.push(`${runErrors.length} run-level error(s)`);\n if (strict && warnedFiles.length > 0)\n counts.push(`${warnedFiles.length} file(s) with warnings (--strict)`);\n\n return `Error: fixture validation failed — ${lead} [${counts.join(\", \")}].`;\n}\n\nexport function runValidateCli(deps: ValidateCliDeps = {}): void {\n const argv = deps.argv ?? process.argv.slice(2);\n const log = deps.log ?? console.log.bind(console);\n const logError = deps.logError ?? console.error.bind(console);\n const exit = deps.exit ?? process.exit.bind(process);\n\n /**\n * Is `flag` present as an OPTION in argv — i.e. before the `--` terminator,\n * after which every argument is a path? Needed because a usage error can be\n * a `parseArgs` throw, which leaves no parsed `values` to consult, and the\n * output mode still has to be honoured. `--flag=value` counts: these are all\n * boolean options, so giving one a value IS the usage error being reported,\n * and matching the bare token alone answered \"no `--json` here\" for the one\n * argv that most obviously asked for JSON — leaving stdout empty.\n */\n const flagInArgv = (flag: string): boolean => {\n for (const arg of argv) {\n if (arg === \"--\") return false;\n if (arg === flag || arg.startsWith(`${flag}=`)) return true;\n }\n return false;\n };\n\n /**\n * A usage error, in whichever mode the argv asked for. `--json` promises\n * \"one document on stdout\" (README), and a run that fails on its own argv is\n * still a run: emitting nothing there handed a CI job parsing stdout an\n * empty buffer — a JSON parse error standing in for a perfectly ordinary\n * \"no paths given\". The document reports the usage error the same way a\n * run-level error is reported, so one consumer shape reads both. The\n * human-readable reason plus the help text stay on stderr in both modes, so\n * `--json` stdout is still the document alone.\n */\n const usageError = (message: string): void => {\n logError(`Error: ${message}\\n\\n${VALIDATE_HELP}`);\n if (flagInArgv(\"--json\")) {\n log(\n JSON.stringify(\n {\n strict: flagInArgv(\"--strict\"),\n failed: true,\n files: [],\n run: { fixtures: 0, errors: [message] },\n },\n null,\n 2,\n ),\n );\n }\n exit(1);\n };\n\n // Parse with node:util parseArgs, like the main CLI (src/cli.ts) and the\n // server path in src/aimock-cli.ts: strict mode rejects unknown options and\n // the \"--\" terminator falls out for free, so a fixture path that begins with\n // \"-\" is still reachable.\n let values: { strict?: boolean; json?: boolean; help?: boolean };\n let paths: string[];\n try {\n const parsed = parseArgs({\n args: argv,\n options: {\n strict: { type: \"boolean\", default: false },\n json: { type: \"boolean\", default: false },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n strict: true,\n allowPositionals: true,\n });\n values = parsed.values;\n paths = parsed.positionals;\n } catch (err) {\n /* v8 ignore next -- parseArgs always throws Error subclasses */\n const msg = err instanceof Error ? err.message : String(err);\n usageError(msg);\n return;\n }\n\n if (values.help === true) {\n // `--json --help` still has to leave one JSON document on stdout and\n // nothing else (README, docs): a consumer that forwards its own argv to\n // `validate --json \"$@\"` and pipes stdout to `jq` gets a parse error the\n // moment a user asks for help. The help text is the document's one field.\n log(values.json === true ? JSON.stringify({ help: VALIDATE_HELP }, null, 2) : VALIDATE_HELP);\n exit(0);\n return;\n }\n const strict = values.strict === true;\n const json = values.json === true;\n\n if (paths.length === 0) {\n usageError(\"no fixture paths given.\");\n return;\n }\n\n // Expand directory arguments into their `*.json` members. A missing path is\n // passed through untouched so the read below reports the real per-file\n // error; any other stat failure (ELOOP, EACCES, ...) is its own error, and\n // a path that exists but is neither a directory nor a regular file is\n // refused rather than read (see `collectJsonFiles`).\n //\n // Targets are NOT de-duplicated: the server loads one set of fixtures per\n // `--fixtures` it is given, so a path named twice — or a file named both\n // directly and via its parent directory — is loaded twice there, and the\n // duplicate-`userMessage` findings that produces are exactly what this lint\n // exists to surface. Validating it twice here is what makes the union pass\n // see what the server sees.\n const targets: CollectEntry[] = [];\n for (const path of paths) {\n // A remote source is refused by NAME. `--fixtures <url>` is a runtime\n // feature of the server; this lint reads local paths only, and handing a\n // URL to `statSync` produced a bare ENOENT quoting the URL back — which\n // reads as \"you typed the path wrong\", not \"this input is unsupported\".\n if (REMOTE_SOURCE.test(path)) {\n targets.push({\n file: path,\n fatal:\n \"Remote fixture source: this lint reads local paths only (the server's --fixtures accepts a URL; validate does not) — download the file and validate the local copy\",\n });\n continue;\n }\n let stats: Stats;\n try {\n stats = statSync(path);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") targets.push({ file: path });\n else targets.push({ file: path, fatal: `Could not stat: ${errText(err)}` });\n continue;\n }\n if (!stats.isDirectory()) {\n if (stats.isFile()) targets.push({ file: path });\n else targets.push({ file: path, fatal: \"Not a regular file\" });\n continue;\n }\n const entries = collectJsonFiles(path, []);\n // Only an actually-walkable, actually-empty directory is \"no fixtures\n // found\" — an unreadable one reports why it could not be read.\n if (entries.length === 0) {\n targets.push({ file: path, fatal: \"No .json fixture files found in directory\" });\n continue;\n }\n targets.push(...entries);\n }\n\n // How many times each path is mentioned by the expanded target list, and a\n // running count that hands each target its own 1-based mention number. Both\n // are needed before the first report is printed: whether a name is ambiguous\n // is a property of the whole run, not of the file being reported. Both key\n // on the resolved path, not its spelling: a walked entry is `join`-normalised\n // while a named one is verbatim, and `./d/a.json` named beside the walk of\n // `./d` is the same load twice. The spelling is still what gets displayed.\n const mentionKey = (file: string): string => resolve(file);\n const mentionCount = new Map<string, number>();\n for (const target of targets)\n mentionCount.set(mentionKey(target.file), (mentionCount.get(mentionKey(target.file)) ?? 0) + 1);\n const mentionsSoFar = new Map<string, number>();\n const nextMention = (file: string): number => {\n const mention = (mentionsSoFar.get(mentionKey(file)) ?? 0) + 1;\n mentionsSoFar.set(mentionKey(file), mention);\n return mention;\n };\n /**\n * How a file is NAMED in human output and in cross-file references. A path\n * this run loads more than once gets its mention number, because the bare\n * path names all of those loads at once: without it a second load's findings\n * read as a file shadowing itself. A path loaded once is printed unadorned —\n * there is nothing to tell it apart from, and \"[1]\" on every line of an\n * ordinary run is noise. The `--json` report carries `mention` regardless.\n */\n const displayName = (report: FileReport): string =>\n (mentionCount.get(mentionKey(report.file)) ?? 1) > 1\n ? `${report.file}[${report.mention}]`\n : report.file;\n\n const reports: FileReport[] = [];\n // Every successfully-parsed entry, in load order, plus the file and local\n // index each one came from. `validateFixtures` reports by array index, so\n // the union pass below needs this to map its findings back to a file.\n const union: Fixture[] = [];\n const provenance: { report: FileReport; index: number }[] = [];\n // The rule findings the per-file pass already reported, by SITE — the file\n // (by id, so two mentions of one path are two sites), the entry index, the\n // severity and the rule. Each rule fires at most once per fixture in either\n // pass, so a union finding that lands on an occupied site is that same\n // finding seen with every file in view: it never prints a second line, and\n // it rewrites the first one only when it names different fixtures. Keying on\n // the rendered text with digits masked (a previous scheme) instead made every\n // \"shadows fixtures <n>+\" look alike, which both collapsed distinct findings\n // and silently swallowed genuine cross-file ones.\n const reportedBySite = new Map<string, { finding: Finding; refs: string[] }[]>();\n const fileIds = new Map<FileReport, number>();\n // Declared before the per-file loop because that loop contributes to it: an\n // index a file could not resolve belongs to no entry and no file section.\n const runErrors: string[] = [];\n const siteKey = (fileId: number, index: number, severity: string, kind: string): string =>\n [fileId, index, severity, kind].join(\"\\u0000\");\n\n for (const target of targets) {\n // Passed over by the walk: it appears in the report so nothing the walk\n // touched vanishes, but it contributes no fixtures and no findings.\n if (target.skipped !== undefined) {\n reports.push({\n file: target.file,\n mention: nextMention(target.file),\n fixtures: 0,\n errors: [],\n warnings: [],\n skipped: target.skipped,\n });\n continue;\n }\n if (target.fatal !== undefined) {\n reports.push(fatalReport(target.file, nextMention(target.file), target.fatal));\n continue;\n }\n\n let report: FileReport;\n let fixtures: Fixture[] = [];\n let indices: number[] = [];\n let identities: FindingIdentity[] = [];\n let fileRunErrors: string[] = [];\n const mention = nextMention(target.file);\n try {\n ({\n report,\n fixtures,\n indices,\n identities,\n runErrors: fileRunErrors,\n } = validateOneFile(target.file, mention));\n } catch (err) {\n // Backstop: nothing unexpected gets to abandon the remaining files.\n report = fatalReport(target.file, mention, `Validation failed: ${errText(err)}`);\n }\n reports.push(report);\n // These are raised inside `validateOneFile`, which knows the path but not\n // how many times this run loads it, so they are named here instead.\n runErrors.push(...fileRunErrors.map((e) => `${displayName(report)}: ${e}`));\n const fileId = fileIds.size;\n fileIds.set(report, fileId);\n\n // Only RULE findings are registered: a conversion diagnostic or a\n // file-level finding (no entry index) can never be restated by the union\n // pass, so it has no identity here.\n for (const identity of identities) {\n const key = siteKey(fileId, identity.index, identity.severity, identity.kind);\n const atSite = reportedBySite.get(key) ?? [];\n atSite.push({\n finding: identity.finding,\n refs: identity.refs.map((ref) => `${fileId}:${ref}`),\n });\n reportedBySite.set(key, atSite);\n }\n for (let i = 0; i < fixtures.length; i++) {\n // Same masking as `toEntryIndex` above, one level out: `?? i` silently\n // relabelled a union fixture with a compacted slot number. Keep the\n // union aligned with what the server loads (so the cross-file rules see\n // the same array), but fail the run rather than print a wrong index.\n const index = indices[i];\n if (index === undefined) {\n runErrors.push(\n `${displayName(report)}: converted fixture ${i} has no source entry index; ` +\n `cross-file findings against it are reported at its array position`,\n );\n }\n union.push(fixtures[i]);\n provenance.push({ report, index: index ?? i });\n }\n }\n\n // Cross-file pass. The server validates every loaded fixture as one array,\n // so its duplicate-userMessage and catch-all-ordering rules see across\n // files; run per file they never can. Validate the union and keep only the\n // findings the per-file pass did not already make.\n // Set when the run failed because it loaded nothing at all, so the human\n // printer can withhold \"OK\" from the files that loaded nothing — see below.\n let noFixturesLoaded = false;\n // When a file already said WHY it produced no fixtures (unreadable, invalid\n // JSON, wrong shape, a bad entry), the run-level line below would repeat that\n // same cause as a second, causeless error. Report it only when nothing else\n // has; the run still fails either way, on the per-file finding.\n const causeAlreadyReported = reports.some((r) => r.fatal !== undefined || r.errors.length > 0);\n if (union.length === 0) {\n // The server aborts startup on this exact condition\n // (\"No fixtures loaded and validation/strict mode is enabled\"), so a run\n // whose inputs yield nothing — `{\"fixtures\": []}` and nothing else —\n // fails here too. Parsed-but-empty files alongside files that do load\n // fixtures are fine in both places.\n if (!causeAlreadyReported) {\n runErrors.push(\n \"No fixtures loaded from any input — the server aborts startup on this under --validate-on-load/--strict\",\n );\n noFixturesLoaded = true;\n }\n } else {\n // A union index as the reader sees it: the load that owns the fixture —\n // named by path, plus its mention number when that path is loaded more\n // than once — and its index inside that load.\n const describe = (unionIndex: number): string => {\n const origin = provenance[unionIndex];\n return origin === undefined\n ? String(unionIndex)\n : `${displayName(origin.report)} #${origin.index}`;\n };\n // The same index as an identity for de-duplication. An unresolvable one\n // gets its own namespace rather than aliasing onto a real file.\n const targetOf = (unionIndex: number): string => {\n const origin = provenance[unionIndex];\n if (origin === undefined) return `union:${unionIndex}`;\n const fileId = fileIds.get(origin.report);\n return fileId === undefined ? `union:${unionIndex}` : `${fileId}:${origin.index}`;\n };\n // Cross-file wording is rendered from the finding's REF DATA, never by\n // rewriting its prose: `duplicate userMessage` quotes the fixture's own\n // text, and text that itself reads \"fixture 3\" is not an index.\n const renderCrossFile = (ref: ValidationRef): string => {\n if (ref.rule === \"duplicate-user-message\") {\n return `duplicate userMessage '${ref.userMessage}' — shadows fixture ${describe(ref.shadows)}`;\n }\n // Both ends are named because the point of the cross-file pass is that\n // the shadowed range reaches past the catch-all's own file; a bare\n // \"<file> #0+\" would read as if \"+\" were part of the index.\n const head = \"empty match acts as catch-all but is not the last fixture\";\n return ref.shadowsFrom === ref.shadowsThrough\n ? `${head} — shadows ${describe(ref.shadowsFrom)}`\n : `${head} — shadows every later fixture, from ${describe(ref.shadowsFrom)} through ${describe(ref.shadowsThrough)}`;\n };\n // The per-file pass above is wrapped per file; this one is the run's only\n // other call into `validateFixtures`, and an uncontained throw here killed\n // the process with no report at all and a truncated (invalid) `--json`\n // stdout. Contain it as a run-level error so the report is still emitted,\n // is still valid JSON, and the run still exits 1.\n try {\n for (const r of validateFixtures(union)) {\n const origin = provenance[r.fixtureIndex];\n if (origin === undefined) {\n // Unreachable while `provenance` is pushed in lockstep with `union`.\n // A bare `continue` here DROPPED the finding: an error finding could\n // vanish and leave the run exiting 0, reporting a clean bill of\n // health for fixtures the server would refuse. Raise it at run level,\n // as the adjacent unrecognised-file case already does.\n runErrors.push(\n `Cross-file finding for an unknown fixture index ${r.fixtureIndex}: ${r.message}`,\n );\n continue;\n }\n const fileId = fileIds.get(origin.report);\n if (fileId === undefined) {\n // Unreachable while provenance is built from reported files; recorded\n // as a run-level error rather than defaulted onto file 0, which would\n // attribute the finding to an unrelated file.\n runErrors.push(`Cross-file finding for an unrecognised file: ${r.message}`);\n continue;\n }\n const kind = r.ref === undefined ? `message:${r.message}` : r.ref.rule;\n const refTargets = r.ref === undefined ? [] : refIndices(r.ref).map(targetOf);\n const message = `cross-file: ${r.ref === undefined ? r.message : renderCrossFile(r.ref)}`;\n const already = reportedBySite\n .get(siteKey(fileId, origin.index, r.severity, kind))\n ?.shift();\n if (already !== undefined) {\n // The per-file pass already reported this rule against this fixture,\n // and the server would log it once. If the union names the same\n // fixtures it adds nothing and the file-local wording stands; if it\n // names others — a shadow that reaches into another load — that is\n // the fuller truth, so it replaces the wording in place rather than\n // printing a second line about the same fixture.\n const same =\n already.refs.length === refTargets.length &&\n already.refs.every((target, i) => target === refTargets[i]);\n if (!same) already.finding.message = message;\n continue;\n }\n if (r.severity === \"error\") origin.report.errors.push({ index: origin.index, message });\n else origin.report.warnings.push({ index: origin.index, message });\n }\n } catch (err) {\n runErrors.push(`Cross-file validation failed: ${errText(err)}`);\n }\n }\n\n const hasFatal = reports.some((r) => r.fatal !== undefined);\n const hasErrors = reports.some((r) => r.errors.length > 0) || runErrors.length > 0;\n const hasWarnings = reports.some((r) => r.warnings.length > 0);\n const failed = hasFatal || hasErrors || (strict && hasWarnings);\n\n // Anything that CAUSES the non-zero exit must reach stderr, or a CI log shows\n // a failure with no reason. Warnings are informational by default and are the\n // cause under --strict, so they follow the exit they produce.\n const logWarning = strict ? logError : log;\n\n if (json) {\n log(\n JSON.stringify(\n { strict, failed, files: reports, run: { fixtures: union.length, errors: runErrors } },\n null,\n 2,\n ),\n );\n // Keep stdout to the JSON document alone, but still say on stderr why the\n // run failed.\n if (failed) logError(summarizeFailure(reports, strict, runErrors, displayName));\n } else {\n const at = findingAt;\n // `detail` (the raw thrown text behind a rephrased message) is a field of\n // the `--json` document, so human mode used to lose it entirely. Print it\n // on an indented continuation line under its own finding, where it reads\n // as belonging to that line rather than as another finding.\n const emitDetail = (f: Finding, sink: (msg: string) => void): void => {\n if (f.detail !== undefined) sink(` ${f.detail}`);\n };\n for (const r of reports) {\n const name = displayName(r);\n // A file the WALK turned up that is not fixture-shaped is passed over,\n // exactly as the server passes over it, and says so on its one line.\n if (r.skipped !== undefined) {\n log(`${name}: skipped (${r.skipped})`);\n continue;\n }\n // A fatal file needs no branch of its own: its reason rides in `errors`\n // (see `setFatal`), so the loop below prints the same `[error]` line and\n // the counting summary below tallies it — the stdout count and the\n // `--json` `errors` array can no longer drift apart. Every file still\n // gets exactly one summary line on stdout (README), including this one:\n // a reader tallying stdout must not silently lose a file.\n for (const e of r.errors) {\n logError(`${name}: [error] ${at(e)}${e.message}`);\n emitDetail(e, logError);\n }\n for (const w of r.warnings) {\n logWarning(`${name}: [warning] ${at(w)}${w.message}`);\n emitDetail(w, logWarning);\n }\n if (r.errors.length === 0 && r.warnings.length === 0) {\n // \"OK\" is a claim about the RUN as well as the file: a reader tallying\n // stdout on a run that failed would otherwise read \"OK\" against the very\n // file that loaded none, on an exit of 1. Keying this on the RUN-level\n // \"no fixtures loaded\" error was not enough — that error is withheld as\n // soon as another file reports a cause, which is exactly when a failed\n // run still has a zero-fixture file to print.\n if (r.fixtures === 0 && failed) {\n const why = noFixturesLoaded ? \"see the run-level error\" : \"the run failed elsewhere\";\n log(`${name}: ${r.fixtures} fixture(s), loaded nothing — ${why}`);\n } else {\n log(`${name}: OK (${r.fixtures} fixture(s))`);\n }\n } else {\n log(\n `${name}: ${r.fixtures} fixture(s), ${r.errors.length} error(s), ${r.warnings.length} warning(s)`,\n );\n }\n }\n // Run-level errors last: they are consequences of (or additions to) the\n // per-file output above, and printing them first put the summary before\n // the detail it summarises.\n for (const e of runErrors) logError(`[error] ${e}`);\n }\n\n exit(failed ? 1 : 0);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GA,MAAa,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2C3B,MAAM;;AA4ER,SAAS,WAAW,KAA8B;AAChD,QAAO,IAAI,SAAS,2BAChB,CAAC,IAAI,QAAQ,GACb,CAAC,IAAI,aAAa,IAAI,eAAe;;;;;;;;AAS3C,MAAM,gBAAgB;;AAGtB,SAAS,QAAQ,KAAsB;AACrC,QAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;;;;;;;;;;;;;;AAezD,SAAS,SAAS,QAAoB,SAAuB;AAC3D,QAAO,QAAQ;AACf,QAAO,OAAO,KAAK,EAAE,SAAS,CAAC;;;AAIjC,SAAS,YAAY,MAAc,SAAiB,SAA6B;CAC/E,MAAM,SAAqB;EAAE;EAAM;EAAS,UAAU;EAAG,QAAQ,EAAE;EAAE,UAAU,EAAE;EAAE;AACnF,UAAS,QAAQ,QAAQ;AACzB,QAAO;;;;;;;;;;;AAYT,IAAa,mBAAb,MAAa,yBAAyBA,sBAAO;CAC3C,AAAiB;CACjB,AAAiB;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;AAEzB,QAAK,MAAM,KAAK,EAAE,UAAU;AAC1B,eAAW,GAAG,KAAK,cAAc,GAAG,EAAE,GAAG,EAAE,UAAU;AACrD,eAAW,GAAG,WAAW;;AAE3B,OAAI,EAAE,OAAO,WAAW,KAAK,EAAE,SAAS,WAAW,EAOjD,KAAI,EAAE,aAAa,KAAK,QAAQ;IAC9B,MAAM,MAAM,mBAAmB,4BAA4B;AAC3D,QAAI,GAAG,KAAK,IAAI,EAAE,SAAS,gCAAgC,MAAM;SAEjE,KAAI,GAAG,KAAK,QAAQ,EAAE,SAAS,cAAc;OAG/C,KACE,GAAG,KAAK,IAAI,EAAE,SAAS,eAAe,EAAE,OAAO,OAAO,aAAa,EAAE,SAAS,OAAO,aACtF;;AAML,OAAK,MAAM,KAAK,UAAW,UAAS,WAAW,IAAI;;AAGrD,MAAK,SAAS,IAAI,EAAE"}
|
|
1
|
+
{"version":3,"file":"validate-cli.cjs","names":["Logger","hasMcpFakesKey","validateMcpFakes","entryToFixture","MisbehaviorConfigError","validateFixtures","renderValidationRef","sep","McpFakeStore","McpFakesAddError","build","plainText"],"sources":["../src/validate-cli.ts"],"sourcesContent":["/**\n * `aimock validate` subcommand — offline fixture lint.\n *\n * Usage: `aimock validate [--strict] [--json] [--] <path> [more paths ...]`\n *\n * Each path is a fixture file or a directory; directories are walked\n * recursively for `*.json` in the same order `--fixtures <dir>` loads them.\n * For each file: read bytes, JSON-parse, require a top-level\n * `{ \"fixtures\": [...] }` envelope, convert the entries (surfacing the\n * per-entry conversion warnings the server logs), then run the\n * `validateFixtures` rules over that file's entries alone, so its findings\n * are attributed to it.\n *\n * `validateFixtures` is then run a SECOND time over the union of every\n * successfully-parsed file's entries, in load order. Its rules are not all\n * per-fixture: `duplicate userMessage` and the catch-all ordering check look\n * at the other fixtures in the array they are given. Run per file those two\n * cannot see across files, so the findings the union pass adds — a\n * `userMessage` duplicated in two files, a catch-all that is last in its own\n * file but not last overall — are the cross-file ones. They are reported\n * against the file that owns the fixture, with the other file named in the\n * message; findings the per-file pass already made are not repeated.\n *\n * How this compares to the server's `--validate-on-load`, in both directions:\n * - Stricter: there an unreadable, unparseable or wrong-shape file is\n * non-fatal — it warns on stderr, contributes zero fixtures, and startup\n * continues as long as the run loaded at least one fixture from somewhere.\n * Here every such file fails the run — with one deliberate exception, for\n * parity: a `*.json` file the WALK turned up that parses but carries no\n * top-level `fixtures` array is not a fixture file (this package's own\n * `fixtures/` tree holds aimock config files alongside fixtures), and is\n * passed over with a note, exactly as the loader passes over it. A file\n * the caller NAMES is still validated, wrong shape and all. Two walk\n * hazards the server does not\n * survive are refused outright rather than mirrored: a `*.json` path that\n * is not a regular file (a FIFO, a socket, a device) is a per-file error\n * here, where the server's `readFileSync` blocks on it forever; and a\n * directory symlink that points back at a directory already being walked\n * is reported once as a cycle, where the server recurses through it until\n * the kernel returns ELOOP (~32 levels deep) and loads those levels'\n * fixtures over and over. Malformed scalar or array matches are rejected\n * before conversion, as they are by the server's fixture loader. The lint\n * reports an entry error and continues validating valid siblings.\n * - Equal: the `validateFixtures` rules themselves, because of the union\n * pass above, and the zero-fixture rule — a run whose inputs yield no\n * fixtures at all is an error here, matching the server's \"No fixtures\n * loaded and validation/strict mode is enabled — aborting.\" A single\n * `{\"fixtures\": []}` file alongside files that do load fixtures is an\n * error in neither place. Equal too in what the inputs expand to: a path\n * named twice, and a directory reached both directly and through an\n * acyclic symlink to it, are validated once per mention, exactly as the\n * server loads one `--fixtures` source per mention — so the duplicate\n * fixtures that produces are reported here as the server reports them,\n * one finding per (fixture, rule), the same count the server logs.\n *\n * A path mentioned more than once in one run is therefore several DIFFERENT\n * loads that happen to share a name, and printing that bare name for each of\n * them made them indistinguishable: a warning read as if a fixture shadowed\n * itself. Each mention is numbered, and every rendering surface carries that\n * number — human lines and their summary, cross-file references, and a\n * `mention` field on each `--json` `files[]` entry. The `<path>[<n>]` suffix\n * is printed only for a path that IS mentioned more than once, because for\n * every other path the name alone already names one load; the `--json` field\n * is always present so a consumer never has to infer it.\n * - Weaker: this is a static lint. It never starts a server, so it covers\n * nothing about binding, remote `--fixtures <url>` sources (it reads local\n * paths only), `--watch` reloads, or any runtime behaviour.\n *\n * Nothing the filesystem or a fixture entry can do is allowed to escape this\n * function: a malformed entry, an unreadable path, a stat failure or a symlink\n * cycle each becomes a per-file `[error]` in the report, and a crash inside\n * either `validateFixtures` pass becomes a file-level or run-level `[error]`,\n * so the run still emits a report (valid JSON under `--json`) and still exits\n * 1. Run-level errors print after the per-file output, and the \"no fixtures\n * loaded\" one is withheld when a file already reported why it loaded none.\n *\n * Prints human lines by default (`file: [error|warning] #i message`) or a\n * JSON document with `--json`. Everything that contributes to a non-zero exit\n * goes to stderr, so a CI log's stderr always shows the reason; `--json` keeps\n * stdout to the report alone and puts the reason on stderr. The two modes\n * report the same facts: a fatal file is one record that both the stdout\n * tally and `files[].errors` count, and `--json` emits a document for a usage\n * error too — stdout is never empty on a `--json` run, whatever failed it.\n * A path naming a remote source (`https://...`) is refused as unsupported\n * rather than read as a filename. Exit codes:\n * 0 = clean (warnings allowed unless `--strict`), 1 = everything that fails\n * the run — errors / unreadable / unparseable / wrong shape / unwalkable path\n * / no fixtures loaded at all, and a usage error (no paths or an unknown\n * option) too, because every other CLI surface in this package exits 1 on a\n * usage error and nothing here uses sysexits codes. `--help` is handled\n * separately and exits 0.\n */\n\nimport { readFileSync, readdirSync, realpathSync, statSync } from \"node:fs\";\nimport type { Stats } from \"node:fs\";\nimport { join, relative, resolve, sep } from \"node:path\";\nimport { format, parseArgs } from \"node:util\";\nimport {\n entryToFixture,\n enableHeldFixtureMisbehavior,\n markFixtureResponsesToolsExtended,\n FixtureLoadError,\n MisbehaviorConfigError,\n hasMcpFakesKey,\n renderValidationRef,\n validateFixtures,\n} from \"./fixture-loader.js\";\nimport type { ValidationRef } from \"./fixture-loader.js\";\nimport { Logger } from \"./logger.js\";\nimport { McpFakesAddError, McpFakeStore, validateMcpFakes } from \"./mcp-fakes.js\";\nimport type { McpFakeIssue } from \"./mcp-fakes.js\";\nimport { build, msg, plainText } from \"./message-text.js\";\nimport type { Fixture, FixtureFile, McpFakeSource } from \"./types.js\";\n\nexport const VALIDATE_HELP = `\nUsage: aimock validate [options] [--] <path> [more paths ...]\n\nValidate aimock fixture files offline. Each path is a fixture file or a\ndirectory of them (walked recursively for *.json, like --fixtures <dir>).\nFiles are checked one at a time and then as one combined set, so the rules\nthat span files -- a userMessage duplicated across two files, a catch-all\nthat is not last overall -- are reported here as the server reports them.\n\nWhere the server's --validate-on-load differs: there an unreadable,\nunparseable or wrong-shape file only warns and startup continues, while here\nevery such file fails the run. The one exception, which matches the loader: a\n*.json file found by WALKING a directory that has no top-level \"fixtures\"\narray is not a fixture file (an aimock config, say) and is skipped with a\nnote -- a file you name on the command line is still validated. As on the\nserver, a run that loads no fixtures at all is an error. This is a static lint: it starts no server and reads\nlocal paths only (no remote --fixtures URL).\n\nA path given twice is validated twice, because the server loads one set of\nfixtures per --fixtures it is given; the duplicate fixtures that produces are\nreported as the server reports them, one finding per fixture and rule. Such a\npath is printed as <path>[<n>], numbering its mentions from 1, so each load\nand every reference to its fixtures names one of them (--json reports the\nnumber as \"mention\" on every file). A directory symlink pointing back at a\ndirectory already being walked is a symlink cycle and fails the run; one\npointing anywhere else is followed, as the server follows it.\n\nOptions:\n --strict Treat warnings as errors (exit 1 on warnings)\n --json Emit a JSON report instead of human lines\n --misbehavior Check fixture misbehavior keys, as the server does with\n --misbehavior (without it they are not read)\n --responses-tools <legacy|extended>\n With \"extended\", check match.toolNamespace,\n customToolCalls and responsesBlocks, as a server with\n --responses-tools extended reads them (default\n \"legacy\": they are not read)\n -h, --help Show this help message\n -- Stop option parsing; every later argument is a path\n (use this for a path that begins with \"-\")\n\nExit codes:\n 0 all files valid (warnings allowed unless --strict)\n 1 anything that failed the run: validation errors; a malformed fixture\n entry; an unreadable or unparseable file; a named path of the wrong\n shape (a walked one is skipped instead); a path that\n cannot be stat'd, read or walked (including a symlink cycle, or a\n *.json path that is not a regular file); a directory holding no *.json;\n no fixtures loaded from any input; --strict warnings; or a usage error\n (no paths given, or an unknown option)\n`.trim();\n\nexport interface ValidateCliDeps {\n argv?: string[];\n log?: (msg: string) => void;\n logError?: (msg: string) => void;\n exit?: (code: number) => void;\n}\n\n/**\n * One finding against a file. `index` is the fixture entry it belongs to and is\n * ABSENT when the finding is about the file as a whole (a crash inside the\n * validator, say) rather than an entry — attributing such a finding to entry #0\n * blames a fixture that may be perfectly valid. `detail` carries the raw\n * underlying text (a thrown error's message) for a finding whose `message` is a\n * human-facing rephrasing of it; the `--json` report carries it as its own\n * field and the human report prints it on an indented continuation line.\n */\ninterface Finding {\n index?: number;\n message: string;\n detail?: string;\n}\n\ninterface FileReport {\n file: string;\n /**\n * Which mention of `file` this report is, 1-based, in the order the run\n * expanded its paths. It is the only thing that tells two reports of the\n * same path apart — they are separate loads with separate findings.\n */\n mention: number;\n fixtures: number;\n /**\n * `mcpFakes` blocks this file loaded (F8); set only for a file that has a\n * top-level `mcpFakes` key.\n */\n mcpFakeBlocks?: number;\n errors: Finding[];\n warnings: Finding[];\n fatal?: string;\n /** Set when the walk passed the file over; see `nonFixtureSkipReason`. */\n skipped?: string;\n}\n\n/**\n * A rule finding the per-file pass made, with what the cross-file pass needs\n * to recognise its own restatement of it.\n *\n * Both passes run the same rules, and each rule fires at most once per fixture\n * — which is why the server, whose single pass IS the union pass, logs exactly\n * one line per (fixture, rule). So the SITE identifies the finding: the file\n * (supplied by the caller, the only thing that knows the file id), the entry\n * index, the severity and the rule. Two findings at one site can differ only\n * in which other fixtures they name, and the union pass's answer to that is\n * the authoritative one — it sees every file — so its wording REPLACES the\n * per-file wording rather than printing beside it, which is what made a\n * repeated path report one duplicate twice.\n *\n * `refs` holds the entry indices this finding names, so a restatement that\n * names the same fixtures can be recognised as adding nothing and leave the\n * per-file wording alone. Matching on the rendered message with its digits\n * masked (a previous scheme) both collapsed distinct findings that happened to\n * mask alike and hid genuine cross-file ones, because a union index and a\n * file-local index mask to the same \"#\".\n *\n * `finding` is the very object in the report, so an upgrade is an in-place\n * rewrite that keeps the finding in the position it was reported at.\n */\ninterface FindingIdentity {\n severity: \"error\" | \"warning\";\n index: number;\n /** The rule id for a ref-carrying finding, else its verbatim message. */\n kind: string;\n /** Entry indices this finding names, within the SAME file. */\n refs: number[];\n /** The finding as it sits in the file's report, for an in-place upgrade. */\n finding: Finding;\n}\n\n/** The indices a ref names, in a fixed order, for identity purposes. */\nfunction refIndices(ref: ValidationRef): number[] {\n return ref.rule === \"duplicate-user-message\"\n ? [ref.shadows]\n : [ref.shadowsFrom, ref.shadowsThrough];\n}\n\n/**\n * A path argument that names a remote source rather than a local file: any\n * `scheme://` prefix, not just http(s), so `ftp://` and friends get the same\n * explanation instead of a filesystem error. A Windows drive letter (\"C:\\\\x\")\n * has no `//` and is not matched.\n */\nconst REMOTE_SOURCE = /^[a-z][a-z0-9+.-]*:\\/\\//i;\n\n/** Render an unknown thrown value as a one-line message. */\nfunction errText(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/**\n * Record why a file produced no report at all. A fatal is ONE fact, so it is\n * written once, here, into both shapes that report it: `fatal`, which names\n * the reason, and `errors`, which is what every tally — the human summary\n * line, the `--json` consumer counting `files[].errors` — actually counts.\n * Set on `fatal` alone, the two modes disagreed: stdout said \"1 error(s)\"\n * while the same run's JSON said `\"errors\": []`, so a CI script adding up the\n * JSON saw a clean run that had exited 1.\n *\n * The finding carries no `index`: a fatal is about the file, not an entry\n * (see `Finding.index`).\n */\nfunction setFatal(report: FileReport, message: string): void {\n report.fatal = message;\n report.errors.push({ message });\n}\n\n/** A file that never got as far as a report, with its fatal already recorded. */\nfunction fatalReport(file: string, mention: number, message: string): FileReport {\n const report: FileReport = { file, mention, fixtures: 0, errors: [], warnings: [] };\n setFatal(report, message);\n return report;\n}\n\n/**\n * Logger that routes `warn` AND `error` into caller-supplied sinks instead of\n * the console, so the per-entry conversion diagnostics `entryToFixture` emits\n * land in the report rather than being dropped on the floor — and, under\n * `--json`, never interleave with the JSON document on stdout/stderr.\n * Exported for tests only; it is not part of the package's public API.\n * `info`/`debug` are inert: they are already below this logger's \"warn\" level,\n * and silencing them explicitly keeps future call sites off stdout too.\n */\nexport class CollectingLogger extends Logger {\n private readonly warnSink: (msg: string) => void;\n private readonly errorSink: (msg: string) => void;\n\n constructor(warnSink: (msg: string) => void, errorSink: (msg: string) => void) {\n super(\"warn\");\n this.warnSink = warnSink;\n this.errorSink = errorSink;\n }\n\n /**\n * Serialise exactly as the sink this logger replaces does — byte for byte.\n * `Logger` writes `console.warn(\"[aimock]\", ...args)`, and console's\n * formatting IS `util.format`, so the call it makes is\n * `format(\"[aimock]\", ...args)`: `\"[aimock]\"` is the FORMAT STRING and holds\n * no specifiers, which is what makes a caller's own `%s`/`%d` inert and its\n * arguments plain trailing values. Calling `format(...args)` instead\n * promoted the caller's message into the format slot — so a message that\n * happened to contain `%s` (a fixture path, say) swallowed the next\n * argument — and dropped the `[aimock]` prefix, leaving the report and the\n * server's own stderr disagreeing about the same diagnostic.\n * `util.inspect` still renders object arguments readably, which is what\n * `String(a)` could not do.\n */\n private static format(args: unknown[]): string {\n return format(\"[aimock]\", ...args);\n }\n\n override warn(...args: unknown[]): void {\n this.warnSink(CollectingLogger.format(args));\n }\n\n override error(...args: unknown[]): void {\n this.errorSink(CollectingLogger.format(args));\n }\n\n override info(...args: unknown[]): void {\n void args; /* suppressed: never write to stdout from inside a --json run */\n }\n\n override debug(...args: unknown[]): void {\n void args; /* suppressed: never write to stdout from inside a --json run */\n }\n}\n\n/**\n * One product of the walk: a `*.json` file to validate, or — with `fatal`\n * set — a path that could not be walked, reported as its own per-file error,\n * or — with `skipped` set — a `*.json` file the walk found that is not a\n * fixture file at all and is passed over (see `nonFixtureSkipReason`).\n */\ninterface CollectEntry {\n file: string;\n fatal?: string;\n skipped?: string;\n /**\n * The entry-id `source` (I6) of the file's `mcpFakes` blocks: its path\n * relative to the walked directory, with `/` separators, as\n * `loadFixturesFromDirWithServices` derives it. Absent for a named file,\n * whose source is its path as given.\n */\n source?: string;\n}\n\n/**\n * Why a `*.json` file the WALK turned up is not a fixture file, or\n * `undefined` if it is one (or if the question cannot be answered cheaply).\n *\n * A directory is not a fixture directory: this package ships `fixtures/`\n * holding both fixture files and eight aimock CONFIG files — the six\n * `fixtures/examples/**\\/*-config.json`, `full-suite.json`, and\n * `agui/agui-text-response.json`, whose AG-UI fixtures sit NESTED under\n * `agui` where `--fixtures` cannot see them — which is why the documented\n * `aimock validate ./fixtures/` exited 1 on the package's own tree. The\n * server has the same mixture to deal with and passes over it:\n * `loadFixtureFile` warns \"Missing or invalid \\\"fixtures\\\" array\", returns no\n * fixtures, and startup continues. This mirrors that skip, so a walked\n * directory reports on the fixture files in it and says what it passed over.\n *\n * Non-fixture means the file carries no top-level `fixtures` key at all (or\n * is an aimock config). A `fixtures` key that is present but not an array is\n * a MALFORMED fixture file and still fails the run, as the loader would refuse\n * it. The skip applies ONLY to files the walk discovered — a path the caller named explicitly is still validated, and a\n * wrong-shape file there still fails the run, because naming a file is\n * asking about that file.\n *\n * A file carrying an aimock config section (`configSections`) is named as\n * what it is rather than by what it lacks, because \"not a fixture file\" on\n * its own is read as \"holds no fixtures\" — false of `agui`-sectioned configs,\n * which hold AG-UI fixtures that `aimock --config`, not `--fixtures`, serves.\n *\n * Unreadable and unparseable are deliberately NOT skips. Returning\n * `undefined` for them hands the file to `validateOneFile`, which reports the\n * real read error or JSON syntax error — a defect in any `*.json` file, and\n * one no config file has an excuse for either.\n */\nfunction nonFixtureSkipReason(file: string): string | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(file, \"utf-8\")) as unknown;\n } catch {\n return undefined;\n }\n // F6: a top-level `mcpFakes` key makes it a fixture file (fakes-only or not).\n // D2: checked before the config sections, because the loader loads the\n // fakes of any file with the key, config-shaped or not.\n if (hasMcpFakesKey(parsed)) return undefined;\n const asConfig = aimockConfigDescription(parsed);\n if (asConfig !== undefined) return `not a fixture file — ${asConfig}`;\n // A present `fixtures` key of the wrong shape is a MALFORMED fixture file,\n // not a non-fixture file: hand it to `validateOneFile`, which fails it the\n // way the same file fails when named.\n if (typeof parsed === \"object\" && parsed !== null && \"fixtures\" in parsed) return undefined;\n return 'not a fixture file — no top-level \"fixtures\" key';\n}\n\n/**\n * The mock sections of `AimockConfig` (config-loader.ts). An object carrying\n * any of them is an aimock config file: `aimock --config <path>` starts a\n * server from it, while `--fixtures <path>` loads nothing from it.\n */\nconst CONFIG_SECTIONS = [\"llm\", \"mcp\", \"a2a\", \"agui\", \"vector\", \"services\"] as const;\n\n/**\n * What a parsed-but-not-fixture-shaped JSON document IS, when it is an aimock\n * config file, or `undefined` when it is not one. Used by both the walk's skip\n * note and the fatal a NAMED file of that shape gets, so the two surfaces\n * describe the same file the same way. The sections found are listed, so an\n * `agui` config is never described as a file holding no fixtures — it holds\n * AG-UI ones, nested where the fixture loader does not look.\n */\nfunction aimockConfigDescription(parsed: unknown): string | undefined {\n if (typeof parsed !== \"object\" || parsed === null) return undefined;\n const doc = parsed as Record<string, unknown>;\n const sections = CONFIG_SECTIONS.filter((key) => typeof doc[key] === \"object\" && doc[key]);\n if (sections.length === 0) return undefined;\n return `an aimock config file (${sections.join(\", \")}), which \"aimock --config\" serves and \"--fixtures\" does not load`;\n}\n\n/**\n * Collect `*.json` files under `dirPath`, recursing into subdirectories.\n * Mirrors `loadFixturesFromDir`: within a directory the `*.json` files come\n * first in sorted order, then its subdirectories in sorted order, so the\n * reported order matches the server's load order, and the same stat-error\n * handling — a vanished entry (ENOENT) is skipped silently, every other\n * failure is surfaced. Unlike the loader, which only warns, each surfaced\n * failure becomes a `fatal` entry that fails the run, and it is emitted in\n * walk position (an unreadable subdirectory is reported where that\n * subdirectory was reached, not after every file in the tree) so the report\n * reads in encounter order. Entries that are neither directories nor\n * `*.json` files are ignored, as they are by the loader.\n *\n * `ancestors` holds the real paths of the directories this call is nested\n * inside. A directory whose real path is one of them closes a symlink cycle\n * and is reported instead of walked; the server has no such guard and\n * recurses through the cycle until the kernel returns ELOOP. A repeat visit\n * that is NOT an ancestor — `root/link -> root/sub` alongside `root/sub` — is\n * no cycle: it is walked again, because the server walks it again and loads\n * those fixtures twice.\n *\n * A `*.json` entry that is not a regular file (a FIFO, a socket, a device)\n * is a `fatal` entry rather than a target, because reading it is what the\n * containment promise above cannot keep: `readFileSync` on a FIFO with no\n * writer blocks forever, as it does on the server.\n */\nfunction collectJsonFiles(\n dirPath: string,\n ancestors: string[],\n out: CollectEntry[] = [],\n): CollectEntry[] {\n let realPath: string;\n try {\n realPath = realpathSync(dirPath);\n } catch (err) {\n out.push({ file: dirPath, fatal: `Could not resolve directory: ${errText(err)}` });\n return out;\n }\n if (ancestors.includes(realPath)) {\n out.push({\n file: dirPath,\n fatal: `Symlink cycle detected: already walking ${realPath}`,\n });\n return out;\n }\n\n let names: string[];\n try {\n names = readdirSync(dirPath);\n } catch (err) {\n out.push({ file: dirPath, fatal: `Could not read directory: ${errText(err)}` });\n return out;\n }\n\n // Sort the whole entry list, not just the `*.json` names, so a stat failure\n // or a non-regular `*.json` lands at a deterministic place in the report\n // whatever order the filesystem hands entries back in.\n const subdirs: string[] = [];\n for (const name of [...names].sort()) {\n const fullPath = join(dirPath, name);\n let stats: Stats;\n try {\n stats = statSync(fullPath);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code !== \"ENOENT\") {\n out.push({ file: fullPath, fatal: `Could not stat: ${errText(err)}` });\n }\n continue;\n }\n if (stats.isDirectory()) subdirs.push(name);\n else if (!name.endsWith(\".json\")) continue;\n else if (stats.isFile()) {\n const skipped = nonFixtureSkipReason(fullPath);\n out.push(skipped === undefined ? { file: fullPath } : { file: fullPath, skipped });\n } else out.push({ file: fullPath, fatal: \"Not a regular file\" });\n }\n\n const chain = [...ancestors, realPath];\n for (const sub of subdirs) collectJsonFiles(join(dirPath, sub), chain, out);\n return out;\n}\n\n/** The entry shape the loader and the server both assume, quoted verbatim. */\nconst ENTRY_SHAPE = 'every entry needs { \"match\": { ... }, \"response\": { ... } }';\n\n/** Name a value the way a fixture author would read it back in their JSON. */\nfunction gotText(value: unknown): string {\n if (value === null) return \"null\";\n if (value === undefined) return \"absent\";\n if (Array.isArray(value)) return \"an array\";\n return `a ${typeof value}`;\n}\n\n/**\n * A shape defect in a raw fixture entry, classified BEFORE conversion.\n *\n * Classifying before conversion gives known malformed shapes an actionable\n * explanation while leaving unexpected conversion failures to the backstop.\n */\ntype EntryDefect =\n /** `entryToFixture` would throw: report it and skip the entry. */\n | { severity: \"error\"; convertible: false; why: string }\n /** Converts, but not into the fixture the author meant: report and convert. */\n | { severity: \"warning\"; convertible: true; why: string };\n\n/**\n * Classify a raw entry's shape, or return `undefined` when nothing about it is\n * worth saying. Runs before `entryToFixture`, so every branch below is driven\n * by the entry itself rather than by whichever exception the conversion\n * happened to throw.\n *\n * A missing or non-object `response` is deliberately NOT classified here: the\n * conversion accepts it (`{ ...undefined }` is `{}`), the server accepts it,\n * and the `validateFixtures` rules already reject it by name — \"response is\n * not a recognized type (must have content, toolCalls, ...)\" — which is the\n * more actionable message of the two. Saying it here as well would report one\n * defect twice. It is still named alongside `match` when `match` is fatal,\n * because then the rules never run on the entry at all and an author fixing\n * `{}` would otherwise need one round trip per missing key.\n */\nfunction classifyEntry(entry: unknown): EntryDefect | undefined {\n if (entry === null || typeof entry !== \"object\" || Array.isArray(entry)) {\n return {\n severity: \"error\",\n convertible: false,\n why: `entry is ${gotText(entry)}, expected an object — ${ENTRY_SHAPE}`,\n };\n }\n const match = (entry as Record<string, unknown>).match;\n if (match === null || match === undefined) {\n const missing = ([\"match\", \"response\"] as const).filter((key) => {\n const value = (entry as Record<string, unknown>)[key];\n return value === null || typeof value !== \"object\" || Array.isArray(value);\n });\n return {\n severity: \"error\",\n convertible: false,\n why: `missing or non-object ${missing.map((k) => `\"${k}\"`).join(\" and \")} — ${ENTRY_SHAPE}`,\n };\n }\n if (typeof match !== \"object\" || Array.isArray(match)) {\n return {\n severity: \"error\",\n convertible: false,\n why: `\"match\" is ${gotText(match)}, expected an object — ${ENTRY_SHAPE}`,\n };\n }\n return undefined;\n}\n\n/**\n * The backstop for an entry `classifyEntry` passed and `entryToFixture` threw\n * on anyway (a `toolCalls: [null]`, say, which `normalizeResponse` walks).\n * Which entry it was is the actionable half, so that leads; the raw thrown\n * text follows as `detail`, which `--json` carries as its own field and the\n * human report prints on an indented continuation line. It used to say\n * `see \"detail\"`, naming a field only the `--json` report has — in human mode\n * that pointed at nothing at all.\n */\nfunction unexpectedEntryFailure(index: number, err: unknown): Finding {\n return {\n index,\n message: `Invalid fixture entry #${index}: could not be converted to a fixture`,\n detail: errText(err),\n };\n}\n\n/**\n * Validate one fixture file into a report. Every failure mode — unreadable,\n * unparseable, wrong shape, or a single malformed entry — is recorded in the\n * returned report rather than thrown.\n *\n * The converted fixtures are handed back alongside the report, with\n * `indices[i]` giving the entry index `fixtures[i]` was converted from, so the\n * cross-file union pass can append them and map its findings back to a file\n * and an entry index.\n */\nfunction validateOneFile(\n file: string,\n mention: number,\n source: string,\n misbehavior = false,\n extendedResponsesTools = false,\n): {\n report: FileReport;\n fixtures: Fixture[];\n indices: number[];\n identities: FindingIdentity[];\n runErrors: string[];\n mcpFakes: McpFakeSource[];\n} {\n const report: FileReport = { file, mention, fixtures: 0, errors: [], warnings: [] };\n const fixtures: Fixture[] = [];\n const sourceIndex: number[] = [];\n // Findings that belong to no entry because an index could not be resolved.\n // They are raised at run level rather than filed against a guessed entry.\n const runErrors: string[] = [];\n // Identities of the findings the RULES produced (not the conversion\n // diagnostics, which the union pass cannot produce and so cannot repeat).\n const identities: FindingIdentity[] = [];\n // The file's `mcpFakes` blocks, when they pass `validateMcpFakes`, for the\n // run's entry-id check across files (I8).\n const mcpFakes: McpFakeSource[] = [];\n\n let raw: string;\n try {\n raw = readFileSync(file, \"utf-8\");\n } catch (err) {\n setFatal(report, `Could not read file: ${errText(err)}`);\n return { report, fixtures, indices: sourceIndex, identities, runErrors, mcpFakes };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch (err) {\n setFatal(report, `Invalid JSON: ${errText(err)}`);\n return { report, fixtures, indices: sourceIndex, identities, runErrors, mcpFakes };\n }\n // F7: a file with a top-level `mcpFakes` key may leave `fixtures` out\n // (spec 5.4), as the loader allows; a `fixtures` key it does have must\n // still be an array.\n const fakesDoc = hasMcpFakesKey(parsed) ? parsed : undefined;\n const fixturesLeftOut =\n fakesDoc !== undefined && !Object.prototype.hasOwnProperty.call(fakesDoc, \"fixtures\");\n const badShape =\n !fixturesLeftOut &&\n (typeof parsed !== \"object\" ||\n parsed === null ||\n !Array.isArray((parsed as { fixtures?: unknown }).fixtures));\n if (badShape) {\n // Naming a file is asking about that file, so the wrong shape is still\n // fatal — the loader refuses it too. Say WHICH wrong shape when the file\n // is an aimock config, so the answer names the file for what it is rather\n // than implying it holds nothing.\n const asConfig = aimockConfigDescription(parsed);\n setFatal(\n report,\n asConfig === undefined\n ? 'Missing or invalid \"fixtures\" array (expected { \"fixtures\": [...] })'\n : `Missing or invalid \"fixtures\" array (expected { \"fixtures\": [...] }) — this is ${asConfig}`,\n );\n // D3: the loader still loads the fakes of such a file (it only warns\n // about `fixtures`), so they are checked below before returning.\n }\n\n if (fakesDoc !== undefined) {\n // F7: validate the blocks under the file's entry-id source (I6). A bad\n // block is an error of this file; L8 shadowed entries are warnings.\n const fakes = fakesDoc.mcpFakes;\n const validation = validateMcpFakes(fakes, source);\n report.errors.push(...validation.errors.map(loadErrorFinding));\n report.mcpFakeBlocks = 0;\n // A recording's `_warnings` (S7): what the recorder redacted or skipped.\n const recorded = fakesDoc._warnings;\n if (Array.isArray(recorded)) {\n for (const w of recorded) {\n if (typeof w === \"string\") report.warnings.push({ message: w });\n }\n }\n if (validation.errors.length > 0) {\n report.warnings.push(...validation.warnings.map(issueFinding));\n } else if (Array.isArray(fakes)) {\n // The warnings of clean blocks come from the run's store, which gives\n // each block its real entry ids (a repeated load is `@<k>`, I7).\n fakes.forEach((block: unknown, blockIndex: number) => {\n mcpFakes.push({ source, blockIndex, raw: block });\n });\n } else {\n mcpFakes.push({ source, blockIndex: null, raw: fakes });\n }\n }\n if (fixturesLeftOut || badShape) {\n return { report, fixtures, indices: sourceIndex, identities, runErrors, mcpFakes };\n }\n\n // Convert the entries we already parsed rather than re-reading the file,\n // and give the conversion a logger so its per-entry diagnostics are\n // attributed to the entry that produced them instead of being discarded.\n let entryIndex = 0;\n const entryLogger = new CollectingLogger(\n (message) => report.warnings.push({ index: entryIndex, message }),\n (message) => report.errors.push({ index: entryIndex, message }),\n );\n\n // Classify known malformed shapes before conversion and skip those entries.\n // Keep the catch as a backstop for unexpected conversion failures. Remember\n // each converted fixture's source index so findings retain entry indices.\n const entries = (parsed as FixtureFile).fixtures;\n for (let index = 0; index < entries.length; index++) {\n entryIndex = index;\n const defect = classifyEntry(entries[index]);\n if (defect !== undefined) {\n const label = defect.severity === \"error\" ? \"Invalid fixture entry\" : \"Fixture entry\";\n const finding: Finding = { index, message: `${label} #${index}: ${defect.why}` };\n if (!defect.convertible) {\n report.errors.push(finding);\n continue;\n }\n report.warnings.push(finding);\n }\n try {\n const fixture = entryToFixture(entries[index], entryLogger, undefined, {\n file: source,\n index,\n });\n // --misbehavior: check `misbehavior` keys as a server with misbehavior enabled does.\n if (misbehavior) enableHeldFixtureMisbehavior(fixture);\n // --responses-tools extended: check the keys only that mode reads.\n if (extendedResponsesTools) markFixtureResponsesToolsExtended(fixture);\n fixtures.push(fixture);\n sourceIndex.push(index);\n } catch (err) {\n report.errors.push(\n err instanceof MisbehaviorConfigError\n ? { index, message: err.message }\n : unexpectedEntryFailure(index, err),\n );\n }\n }\n\n report.fixtures = fixtures.length;\n // `validateFixtures` reports against the COMPACTED array, which skips the\n // entries that failed to convert. The finding's own index is mapped back to\n // an entry index — and so are the indices its message NAMES, or one line\n // would print two different index spaces: \"#2 ... shadows fixture 0\" where\n // \"#2\" is an entry and \"0\" is a compacted slot.\n // `?? fixtureIndex` here USED to mask an unresolvable index by printing a\n // compacted slot as if it were an entry index — two different index spaces\n // in one line, with nothing to say so. It is unreachable while `sourceIndex`\n // is pushed in lockstep with `fixtures`, so if it ever fires the run is\n // wrong, not merely imprecise: raise it at run level (which fails the run)\n // instead of quietly printing a number that means something else.\n const unresolved = new Set<number>();\n const toEntryIndex = (fixtureIndex: number): number => {\n const entry = sourceIndex[fixtureIndex];\n if (entry !== undefined) return entry;\n if (!unresolved.has(fixtureIndex)) {\n unresolved.add(fixtureIndex);\n runErrors.push(\n `finding for fixture index ${fixtureIndex}, which maps to no entry in this file`,\n );\n }\n return fixtureIndex;\n };\n try {\n for (const r of validateFixtures(fixtures)) {\n const index = toEntryIndex(r.fixtureIndex);\n const refs = r.ref === undefined ? [] : refIndices(r.ref).map(toEntryIndex);\n const message =\n r.ref === undefined\n ? r.message\n : renderValidationRef(r.ref, (i) => String(toEntryIndex(i)));\n const finding: Finding = { index, message };\n identities.push({\n severity: r.severity,\n index,\n kind: r.ref === undefined ? `message:${r.message}` : r.ref.rule,\n refs,\n finding,\n });\n if (r.severity === \"error\") report.errors.push(finding);\n else report.warnings.push(finding);\n }\n } catch (err) {\n // File-level: the validator walks every entry, so which one tripped it is\n // unknown. Filing it at #0 would accuse the file's first fixture, which is\n // very likely innocent, so this finding carries no entry index at all.\n report.errors.push({ message: `Validation failed for this file: ${errText(err)}` });\n }\n return { report, fixtures, indices: sourceIndex, identities, runErrors, mcpFakes };\n}\n\n/**\n * A `FixtureLoadError` from an `mcpFakes` block as a file-level finding (no\n * fixture entry index): its message names the rule, file, block and entry.\n */\nfunction loadErrorFinding(err: FixtureLoadError): Finding {\n return { message: err.message };\n}\n\n/** An L8 shadowed-entry warning as a file-level finding. */\nfunction issueFinding(issue: McpFakeIssue): Finding {\n return { message: issue.message };\n}\n\n/**\n * `#<index> ` for a finding that belongs to one entry; empty for a file-level\n * finding, which names no entry (see Finding.index). Shared by the human lines\n * and the failure summary so a reader of either can locate the same entry.\n */\nconst findingAt = (f: Finding): string => (f.index === undefined ? \"\" : `#${f.index} `);\n\n/**\n * One-line reason a run failed, for the stderr side of `--json` output.\n *\n * It NAMES the failure first — the file and the finding that caused the\n * non-zero exit — and only then totals what else failed, because the line is\n * often the single line a CI log shows. Leading with a fixed list of counts\n * put two zeros (\"0 unreadable/invalid file(s), 0 file(s) with errors\") in\n * front of every strict-warning failure, where the reader has to get past the\n * things that did NOT happen to reach the one that did. Counts that are zero\n * are omitted for the same reason, and a file whose fatal is already the lead\n * is counted as unreadable/invalid only, not a second time under \"with\n * errors\" — its fatal now rides in `errors` as well (see `setFatal`).\n */\nfunction summarizeFailure(\n reports: FileReport[],\n strict: boolean,\n runErrors: string[],\n name: (r: FileReport) => string,\n): string {\n const fatalFiles = reports.filter((r) => r.fatal !== undefined);\n const erroredFiles = reports.filter((r) => r.fatal === undefined && r.errors.length > 0);\n const warnedFiles = reports.filter((r) => r.warnings.length > 0);\n\n // First failure in report order: a fatal file, else a file with errors, else\n // a run-level error, else (under --strict) the warning that failed the run.\n let lead: string;\n if (fatalFiles[0] !== undefined) lead = `${name(fatalFiles[0])}: ${fatalFiles[0].fatal}`;\n else if (erroredFiles[0] !== undefined)\n lead = `${name(erroredFiles[0])}: ${findingAt(erroredFiles[0].errors[0])}${erroredFiles[0].errors[0].message}`;\n else if (runErrors[0] !== undefined) lead = runErrors[0];\n else if (warnedFiles[0] !== undefined)\n lead = `${name(warnedFiles[0])}: ${findingAt(warnedFiles[0].warnings[0])}${warnedFiles[0].warnings[0].message} (--strict)`;\n /* v8 ignore next -- a failed run always has one of the four above */ else\n lead = \"the run failed\";\n\n const counts: string[] = [];\n if (fatalFiles.length > 0) counts.push(`${fatalFiles.length} unreadable/invalid file(s)`);\n if (erroredFiles.length > 0) counts.push(`${erroredFiles.length} file(s) with errors`);\n // A run-level error (no fixtures loaded from any input) belongs to no single\n // file, so it is counted on its own.\n if (runErrors.length > 0) counts.push(`${runErrors.length} run-level error(s)`);\n if (strict && warnedFiles.length > 0)\n counts.push(`${warnedFiles.length} file(s) with warnings (--strict)`);\n\n return `Error: fixture validation failed — ${lead} [${counts.join(\", \")}].`;\n}\n\nexport function runValidateCli(deps: ValidateCliDeps = {}): void {\n const argv = deps.argv ?? process.argv.slice(2);\n const log = deps.log ?? console.log.bind(console);\n const logError = deps.logError ?? console.error.bind(console);\n const exit = deps.exit ?? process.exit.bind(process);\n\n /**\n * Is `flag` present as an OPTION in argv — i.e. before the `--` terminator,\n * after which every argument is a path? Needed because a usage error can be\n * a `parseArgs` throw, which leaves no parsed `values` to consult, and the\n * output mode still has to be honoured. `--flag=value` counts: these are all\n * boolean options, so giving one a value IS the usage error being reported,\n * and matching the bare token alone answered \"no `--json` here\" for the one\n * argv that most obviously asked for JSON — leaving stdout empty.\n */\n const flagInArgv = (flag: string): boolean => {\n for (const arg of argv) {\n if (arg === \"--\") return false;\n if (arg === flag || arg.startsWith(`${flag}=`)) return true;\n }\n return false;\n };\n\n /**\n * A usage error, in whichever mode the argv asked for. `--json` promises\n * \"one document on stdout\" (README), and a run that fails on its own argv is\n * still a run: emitting nothing there handed a CI job parsing stdout an\n * empty buffer — a JSON parse error standing in for a perfectly ordinary\n * \"no paths given\". The document reports the usage error the same way a\n * run-level error is reported, so one consumer shape reads both. The\n * human-readable reason plus the help text stay on stderr in both modes, so\n * `--json` stdout is still the document alone.\n */\n const usageError = (message: string): void => {\n logError(`Error: ${message}\\n\\n${VALIDATE_HELP}`);\n if (flagInArgv(\"--json\")) {\n log(\n JSON.stringify(\n {\n strict: flagInArgv(\"--strict\"),\n failed: true,\n files: [],\n run: { fixtures: 0, mcpFakeBlocks: 0, errors: [message] },\n },\n null,\n 2,\n ),\n );\n }\n exit(1);\n };\n\n // Parse with node:util parseArgs, like the main CLI (src/cli.ts) and the\n // server path in src/aimock-cli.ts: strict mode rejects unknown options and\n // the \"--\" terminator falls out for free, so a fixture path that begins with\n // \"-\" is still reachable.\n let values: {\n strict?: boolean;\n json?: boolean;\n misbehavior?: boolean;\n \"responses-tools\"?: string;\n help?: boolean;\n };\n let paths: string[];\n try {\n const parsed = parseArgs({\n args: argv,\n options: {\n strict: { type: \"boolean\", default: false },\n json: { type: \"boolean\", default: false },\n misbehavior: { type: \"boolean\", default: false },\n \"responses-tools\": { type: \"string\" },\n help: { type: \"boolean\", short: \"h\", default: false },\n },\n strict: true,\n allowPositionals: true,\n });\n values = parsed.values;\n paths = parsed.positionals;\n } catch (err) {\n /* v8 ignore next -- parseArgs always throws Error subclasses */\n const msg = err instanceof Error ? err.message : String(err);\n usageError(msg);\n return;\n }\n\n if (values.help === true) {\n // `--json --help` still has to leave one JSON document on stdout and\n // nothing else (README, docs): a consumer that forwards its own argv to\n // `validate --json \"$@\"` and pipes stdout to `jq` gets a parse error the\n // moment a user asks for help. The help text is the document's one field.\n log(values.json === true ? JSON.stringify({ help: VALIDATE_HELP }, null, 2) : VALIDATE_HELP);\n exit(0);\n return;\n }\n const strict = values.strict === true;\n const json = values.json === true;\n const misbehavior = values.misbehavior === true;\n const responsesTools = values[\"responses-tools\"];\n if (\n responsesTools !== undefined &&\n responsesTools !== \"legacy\" &&\n responsesTools !== \"extended\"\n ) {\n usageError(`invalid --responses-tools \"${responsesTools}\" (expected \"legacy\" or \"extended\").`);\n return;\n }\n const extendedResponsesTools = responsesTools === \"extended\";\n\n if (paths.length === 0) {\n usageError(\"no fixture paths given.\");\n return;\n }\n\n // Expand directory arguments into their `*.json` members. A missing path is\n // passed through untouched so the read below reports the real per-file\n // error; any other stat failure (ELOOP, EACCES, ...) is its own error, and\n // a path that exists but is neither a directory nor a regular file is\n // refused rather than read (see `collectJsonFiles`).\n //\n // Targets are NOT de-duplicated: the server loads one set of fixtures per\n // `--fixtures` it is given, so a path named twice — or a file named both\n // directly and via its parent directory — is loaded twice there, and the\n // duplicate-`userMessage` findings that produces are exactly what this lint\n // exists to surface. Validating it twice here is what makes the union pass\n // see what the server sees.\n const targets: CollectEntry[] = [];\n for (const path of paths) {\n // A remote source is refused by NAME. `--fixtures <url>` is a runtime\n // feature of the server; this lint reads local paths only, and handing a\n // URL to `statSync` produced a bare ENOENT quoting the URL back — which\n // reads as \"you typed the path wrong\", not \"this input is unsupported\".\n if (REMOTE_SOURCE.test(path)) {\n targets.push({\n file: path,\n fatal:\n \"Remote fixture source: this lint reads local paths only (the server's --fixtures accepts a URL; validate does not) — download the file and validate the local copy\",\n });\n continue;\n }\n let stats: Stats;\n try {\n stats = statSync(path);\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") targets.push({ file: path });\n else targets.push({ file: path, fatal: `Could not stat: ${errText(err)}` });\n continue;\n }\n if (!stats.isDirectory()) {\n if (stats.isFile()) targets.push({ file: path });\n else targets.push({ file: path, fatal: \"Not a regular file\" });\n continue;\n }\n const entries = collectJsonFiles(path, []);\n // Only an actually-walkable, actually-empty directory is \"no fixtures\n // found\" — an unreadable one reports why it could not be read.\n if (entries.length === 0) {\n targets.push({ file: path, fatal: \"No .json fixture files found in directory\" });\n continue;\n }\n // I6: a walked file's `mcpFakes` source is its path relative to the\n // directory named on the command line, with `/` separators.\n for (const entry of entries) {\n targets.push({ ...entry, source: relative(path, entry.file).split(sep).join(\"/\") });\n }\n }\n\n // How many times each path is mentioned by the expanded target list, and a\n // running count that hands each target its own 1-based mention number. Both\n // are needed before the first report is printed: whether a name is ambiguous\n // is a property of the whole run, not of the file being reported. Both key\n // on the resolved path, not its spelling: a walked entry is `join`-normalised\n // while a named one is verbatim, and `./d/a.json` named beside the walk of\n // `./d` is the same load twice. The spelling is still what gets displayed.\n const mentionKey = (file: string): string => resolve(file);\n const mentionCount = new Map<string, number>();\n for (const target of targets)\n mentionCount.set(mentionKey(target.file), (mentionCount.get(mentionKey(target.file)) ?? 0) + 1);\n const mentionsSoFar = new Map<string, number>();\n const nextMention = (file: string): number => {\n const mention = (mentionsSoFar.get(mentionKey(file)) ?? 0) + 1;\n mentionsSoFar.set(mentionKey(file), mention);\n return mention;\n };\n /**\n * How a file is NAMED in human output and in cross-file references. A path\n * this run loads more than once gets its mention number, because the bare\n * path names all of those loads at once: without it a second load's findings\n * read as a file shadowing itself. A path loaded once is printed unadorned —\n * there is nothing to tell it apart from, and \"[1]\" on every line of an\n * ordinary run is noise. The `--json` report carries `mention` regardless.\n */\n const displayName = (report: FileReport): string =>\n (mentionCount.get(mentionKey(report.file)) ?? 1) > 1\n ? `${report.file}[${report.mention}]`\n : report.file;\n\n const reports: FileReport[] = [];\n // Every successfully-parsed entry, in load order, plus the file and local\n // index each one came from. `validateFixtures` reports by array index, so\n // the union pass below needs this to map its findings back to a file.\n const union: Fixture[] = [];\n const provenance: { report: FileReport; index: number }[] = [];\n // The rule findings the per-file pass already reported, by SITE — the file\n // (by id, so two mentions of one path are two sites), the entry index, the\n // severity and the rule. Each rule fires at most once per fixture in either\n // pass, so a union finding that lands on an occupied site is that same\n // finding seen with every file in view: it never prints a second line, and\n // it rewrites the first one only when it names different fixtures. Keying on\n // the rendered text with digits masked (a previous scheme) instead made every\n // \"shadows fixtures <n>+\" look alike, which both collapsed distinct findings\n // and silently swallowed genuine cross-file ones.\n const reportedBySite = new Map<string, { finding: Finding; refs: string[] }[]>();\n const fileIds = new Map<FileReport, number>();\n // Declared before the per-file loop because that loop contributes to it: an\n // index a file could not resolve belongs to no entry and no file section.\n const runErrors: string[] = [];\n // One throwaway store for the run: adding each file's `mcpFakes` blocks to\n // it, in load order, applies the entry-id uniqueness check across files\n // (I8, bad block (f)). A mount conflict needs the running server's mounts\n // and cannot be found here (spec 5.4, known limitation).\n const fakeStore = new McpFakeStore();\n let mcpFakeBlocks = 0;\n const siteKey = (fileId: number, index: number, severity: string, kind: string): string =>\n [fileId, index, severity, kind].join(\"\\u0000\");\n\n for (const target of targets) {\n // Passed over by the walk: it appears in the report so nothing the walk\n // touched vanishes, but it contributes no fixtures and no findings.\n if (target.skipped !== undefined) {\n reports.push({\n file: target.file,\n mention: nextMention(target.file),\n fixtures: 0,\n errors: [],\n warnings: [],\n skipped: target.skipped,\n });\n continue;\n }\n if (target.fatal !== undefined) {\n reports.push(fatalReport(target.file, nextMention(target.file), target.fatal));\n continue;\n }\n\n let report: FileReport;\n let fixtures: Fixture[] = [];\n let indices: number[] = [];\n let identities: FindingIdentity[] = [];\n let fileRunErrors: string[] = [];\n let mcpFakes: McpFakeSource[] = [];\n const mention = nextMention(target.file);\n try {\n ({\n report,\n fixtures,\n indices,\n identities,\n runErrors: fileRunErrors,\n mcpFakes,\n } = validateOneFile(\n target.file,\n mention,\n target.source ?? target.file,\n misbehavior,\n extendedResponsesTools,\n ));\n } catch (err) {\n // Backstop: nothing unexpected gets to abandon the remaining files.\n report = fatalReport(target.file, mention, `Validation failed: ${errText(err)}`);\n }\n if (mcpFakes.length > 0) {\n try {\n const added = fakeStore.add(mcpFakes, { kind: \"file\" });\n report.mcpFakeBlocks = mcpFakes.length;\n mcpFakeBlocks += mcpFakes.length;\n report.warnings.push(...added.warnings.map(issueFinding));\n } catch (err) {\n if (err instanceof McpFakesAddError) {\n report.errors.push(...err.errors.map(loadErrorFinding));\n report.warnings.push(...err.warnings.map(issueFinding));\n } else {\n // D1: nothing may escape this function (see the module comment):\n // any other throw is a finding of this file, so the run still\n // reports every file and `--json` stays one valid document.\n report.errors.push({\n message: build(msg`mcpFakes check failed: ${plainText(errText(err), Infinity)}`),\n });\n }\n }\n }\n reports.push(report);\n // These are raised inside `validateOneFile`, which knows the path but not\n // how many times this run loads it, so they are named here instead.\n runErrors.push(...fileRunErrors.map((e) => `${displayName(report)}: ${e}`));\n const fileId = fileIds.size;\n fileIds.set(report, fileId);\n\n // Only RULE findings are registered: a conversion diagnostic or a\n // file-level finding (no entry index) can never be restated by the union\n // pass, so it has no identity here.\n for (const identity of identities) {\n const key = siteKey(fileId, identity.index, identity.severity, identity.kind);\n const atSite = reportedBySite.get(key) ?? [];\n atSite.push({\n finding: identity.finding,\n refs: identity.refs.map((ref) => `${fileId}:${ref}`),\n });\n reportedBySite.set(key, atSite);\n }\n for (let i = 0; i < fixtures.length; i++) {\n // Same masking as `toEntryIndex` above, one level out: `?? i` silently\n // relabelled a union fixture with a compacted slot number. Keep the\n // union aligned with what the server loads (so the cross-file rules see\n // the same array), but fail the run rather than print a wrong index.\n const index = indices[i];\n if (index === undefined) {\n runErrors.push(\n `${displayName(report)}: converted fixture ${i} has no source entry index; ` +\n `cross-file findings against it are reported at its array position`,\n );\n }\n union.push(fixtures[i]);\n provenance.push({ report, index: index ?? i });\n }\n }\n\n // Cross-file pass. The server validates every loaded fixture as one array,\n // so its duplicate-userMessage and catch-all-ordering rules see across\n // files; run per file they never can. Validate the union and keep only the\n // findings the per-file pass did not already make.\n // Set when the run failed because it loaded nothing at all, so the human\n // printer can withhold \"OK\" from the files that loaded nothing — see below.\n let noFixturesLoaded = false;\n // When a file already said WHY it produced no fixtures (unreadable, invalid\n // JSON, wrong shape, a bad entry), the run-level line below would repeat that\n // same cause as a second, causeless error. Report it only when nothing else\n // has; the run still fails either way, on the per-file finding.\n const causeAlreadyReported = reports.some((r) => r.fatal !== undefined || r.errors.length > 0);\n if (union.length === 0) {\n // F8: loaded `mcpFakes` blocks count as loaded.\n // The server aborts startup on this exact condition\n // (\"No fixtures loaded and validation/strict mode is enabled\"), so a run\n // whose inputs yield nothing — `{\"fixtures\": []}` and nothing else —\n // fails here too. Parsed-but-empty files alongside files that do load\n // fixtures are fine in both places.\n if (!causeAlreadyReported && mcpFakeBlocks === 0) {\n runErrors.push(\n \"No fixtures loaded from any input — the server aborts startup on this under --validate-on-load/--strict\",\n );\n noFixturesLoaded = true;\n }\n } else {\n // A union index as the reader sees it: the load that owns the fixture —\n // named by path, plus its mention number when that path is loaded more\n // than once — and its index inside that load.\n const describe = (unionIndex: number): string => {\n const origin = provenance[unionIndex];\n return origin === undefined\n ? String(unionIndex)\n : `${displayName(origin.report)} #${origin.index}`;\n };\n // The same index as an identity for de-duplication. An unresolvable one\n // gets its own namespace rather than aliasing onto a real file.\n const targetOf = (unionIndex: number): string => {\n const origin = provenance[unionIndex];\n if (origin === undefined) return `union:${unionIndex}`;\n const fileId = fileIds.get(origin.report);\n return fileId === undefined ? `union:${unionIndex}` : `${fileId}:${origin.index}`;\n };\n // Cross-file wording is rendered from the finding's REF DATA, never by\n // rewriting its prose: `duplicate userMessage` quotes the fixture's own\n // text, and text that itself reads \"fixture 3\" is not an index.\n const renderCrossFile = (ref: ValidationRef): string => {\n if (ref.rule === \"duplicate-user-message\") {\n return `duplicate userMessage '${ref.userMessage}' — shadows fixture ${describe(ref.shadows)}`;\n }\n // Both ends are named because the point of the cross-file pass is that\n // the shadowed range reaches past the catch-all's own file; a bare\n // \"<file> #0+\" would read as if \"+\" were part of the index.\n const head = \"empty match acts as catch-all but is not the last fixture\";\n return ref.shadowsFrom === ref.shadowsThrough\n ? `${head} — shadows ${describe(ref.shadowsFrom)}`\n : `${head} — shadows every later fixture, from ${describe(ref.shadowsFrom)} through ${describe(ref.shadowsThrough)}`;\n };\n // The per-file pass above is wrapped per file; this one is the run's only\n // other call into `validateFixtures`, and an uncontained throw here killed\n // the process with no report at all and a truncated (invalid) `--json`\n // stdout. Contain it as a run-level error so the report is still emitted,\n // is still valid JSON, and the run still exits 1.\n try {\n for (const r of validateFixtures(union)) {\n const origin = provenance[r.fixtureIndex];\n if (origin === undefined) {\n // Unreachable while `provenance` is pushed in lockstep with `union`.\n // A bare `continue` here DROPPED the finding: an error finding could\n // vanish and leave the run exiting 0, reporting a clean bill of\n // health for fixtures the server would refuse. Raise it at run level,\n // as the adjacent unrecognised-file case already does.\n runErrors.push(\n `Cross-file finding for an unknown fixture index ${r.fixtureIndex}: ${r.message}`,\n );\n continue;\n }\n const fileId = fileIds.get(origin.report);\n if (fileId === undefined) {\n // Unreachable while provenance is built from reported files; recorded\n // as a run-level error rather than defaulted onto file 0, which would\n // attribute the finding to an unrelated file.\n runErrors.push(`Cross-file finding for an unrecognised file: ${r.message}`);\n continue;\n }\n const kind = r.ref === undefined ? `message:${r.message}` : r.ref.rule;\n const refTargets = r.ref === undefined ? [] : refIndices(r.ref).map(targetOf);\n const message = `cross-file: ${r.ref === undefined ? r.message : renderCrossFile(r.ref)}`;\n const already = reportedBySite\n .get(siteKey(fileId, origin.index, r.severity, kind))\n ?.shift();\n if (already !== undefined) {\n // The per-file pass already reported this rule against this fixture,\n // and the server would log it once. If the union names the same\n // fixtures it adds nothing and the file-local wording stands; if it\n // names others — a shadow that reaches into another load — that is\n // the fuller truth, so it replaces the wording in place rather than\n // printing a second line about the same fixture.\n const same =\n already.refs.length === refTargets.length &&\n already.refs.every((target, i) => target === refTargets[i]);\n if (!same) already.finding.message = message;\n continue;\n }\n if (r.severity === \"error\") origin.report.errors.push({ index: origin.index, message });\n else origin.report.warnings.push({ index: origin.index, message });\n }\n } catch (err) {\n runErrors.push(`Cross-file validation failed: ${errText(err)}`);\n }\n }\n\n const hasFatal = reports.some((r) => r.fatal !== undefined);\n const hasErrors = reports.some((r) => r.errors.length > 0) || runErrors.length > 0;\n const hasWarnings = reports.some((r) => r.warnings.length > 0);\n const failed = hasFatal || hasErrors || (strict && hasWarnings);\n\n // Anything that CAUSES the non-zero exit must reach stderr, or a CI log shows\n // a failure with no reason. Warnings are informational by default and are the\n // cause under --strict, so they follow the exit they produce.\n const logWarning = strict ? logError : log;\n\n if (json) {\n log(\n JSON.stringify(\n {\n strict,\n failed,\n files: reports,\n // D4: the blocks count as loaded, so a fakes-only run is not read\n // as one that loaded nothing.\n run: { fixtures: union.length, mcpFakeBlocks, errors: runErrors },\n },\n null,\n 2,\n ),\n );\n // Keep stdout to the JSON document alone, but still say on stderr why the\n // run failed.\n if (failed) logError(summarizeFailure(reports, strict, runErrors, displayName));\n } else {\n const at = findingAt;\n // `detail` (the raw thrown text behind a rephrased message) is a field of\n // the `--json` document, so human mode used to lose it entirely. Print it\n // on an indented continuation line under its own finding, where it reads\n // as belonging to that line rather than as another finding.\n const emitDetail = (f: Finding, sink: (msg: string) => void): void => {\n if (f.detail !== undefined) sink(` ${f.detail}`);\n };\n for (const r of reports) {\n const name = displayName(r);\n // A file the WALK turned up that is not fixture-shaped is passed over,\n // exactly as the server passes over it, and says so on its one line.\n if (r.skipped !== undefined) {\n log(`${name}: skipped (${r.skipped})`);\n continue;\n }\n // A fatal file needs no branch of its own: its reason rides in `errors`\n // (see `setFatal`), so the loop below prints the same `[error]` line and\n // the counting summary below tallies it — the stdout count and the\n // `--json` `errors` array can no longer drift apart. Every file still\n // gets exactly one summary line on stdout (README), including this one:\n // a reader tallying stdout must not silently lose a file.\n for (const e of r.errors) {\n logError(`${name}: [error] ${at(e)}${e.message}`);\n emitDetail(e, logError);\n }\n for (const w of r.warnings) {\n logWarning(`${name}: [warning] ${at(w)}${w.message}`);\n emitDetail(w, logWarning);\n }\n if (r.errors.length === 0 && r.warnings.length === 0) {\n // \"OK\" is a claim about the RUN as well as the file: a reader tallying\n // stdout on a run that failed would otherwise read \"OK\" against the very\n // file that loaded none, on an exit of 1. Keying this on the RUN-level\n // \"no fixtures loaded\" error was not enough — that error is withheld as\n // soon as another file reports a cause, which is exactly when a failed\n // run still has a zero-fixture file to print.\n const blocks = r.mcpFakeBlocks ?? 0;\n if (r.fixtures === 0 && blocks === 0 && failed) {\n const why = noFixturesLoaded ? \"see the run-level error\" : \"the run failed elsewhere\";\n log(`${name}: ${r.fixtures} fixture(s), loaded nothing — ${why}`);\n } else if (blocks > 0) {\n log(\n build(\n msg`${plainText(name, Infinity)}: OK (${r.fixtures} fixture(s), ${blocks} mcpFakes block(s))`,\n ),\n );\n } else {\n log(`${name}: OK (${r.fixtures} fixture(s))`);\n }\n } else {\n log(\n `${name}: ${r.fixtures} fixture(s), ${r.errors.length} error(s), ${r.warnings.length} warning(s)`,\n );\n }\n }\n // Run-level errors last: they are consequences of (or additions to) the\n // per-file output above, and printing them first put the summary before\n // the detail it summarises.\n for (const e of runErrors) logError(`[error] ${e}`);\n }\n\n exit(failed ? 1 : 0);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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