@vitest-agent/mcp 1.0.1 → 1.2.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.
Files changed (229) hide show
  1. package/README.md +1 -2
  2. package/bin/vitest-agent-mcp.js +1 -17
  3. package/index.d.ts +324 -315
  4. package/index.js +2 -4
  5. package/middleware/idempotency.js +1 -1
  6. package/package.json +2 -2
  7. package/server.js +2 -4
  8. package/tools/acceptance-metrics.js +1 -1
  9. package/tools/cache-health.js +1 -1
  10. package/tools/commit-changes.js +1 -1
  11. package/tools/configure.js +1 -1
  12. package/tools/coverage.js +1 -1
  13. package/tools/errors.js +1 -1
  14. package/tools/failure-signature-get.js +1 -1
  15. package/tools/file-coverage.js +1 -1
  16. package/tools/history.js +1 -1
  17. package/tools/inventory.js +1 -1
  18. package/tools/overview.js +1 -1
  19. package/tools/run-tests.js +15 -3
  20. package/tools/settings-list.js +1 -1
  21. package/tools/status.js +1 -1
  22. package/tools/tdd-artifact.js +1 -1
  23. package/tools/tdd-task.js +1 -1
  24. package/tools/test.js +1 -1
  25. package/tools/trends.js +1 -1
  26. package/tools/turn-search.js +1 -1
  27. package/public/patterns/_meta.json +0 -67
  28. package/public/patterns/authoring-a-custom-vitest-agent-reporter.md +0 -82
  29. package/public/patterns/known-issues-and-caveats.md +0 -52
  30. package/public/patterns/operating-vitest-agent-as-an-agent.md +0 -53
  31. package/public/patterns/running-tests-via-mcp.md +0 -58
  32. package/public/patterns/silencing-leaking-output-in-tests.md +0 -91
  33. package/public/patterns/testing-effect-schema-definitions.md +0 -71
  34. package/public/patterns/testing-effect-services-with-mock-layers.md +0 -63
  35. package/public/vendor/vitest-docs/ATTRIBUTION.md +0 -5
  36. package/public/vendor/vitest-docs/api/advanced/artifacts.md +0 -189
  37. package/public/vendor/vitest-docs/api/advanced/metadata.md +0 -68
  38. package/public/vendor/vitest-docs/api/advanced/plugin.md +0 -168
  39. package/public/vendor/vitest-docs/api/advanced/reporters.md +0 -342
  40. package/public/vendor/vitest-docs/api/advanced/runner.md +0 -334
  41. package/public/vendor/vitest-docs/api/advanced/test-case.md +0 -302
  42. package/public/vendor/vitest-docs/api/advanced/test-collection.md +0 -89
  43. package/public/vendor/vitest-docs/api/advanced/test-module.md +0 -140
  44. package/public/vendor/vitest-docs/api/advanced/test-project.md +0 -321
  45. package/public/vendor/vitest-docs/api/advanced/test-specification.md +0 -96
  46. package/public/vendor/vitest-docs/api/advanced/test-suite.md +0 -230
  47. package/public/vendor/vitest-docs/api/advanced/vitest.md +0 -684
  48. package/public/vendor/vitest-docs/api/assert-type.md +0 -22
  49. package/public/vendor/vitest-docs/api/assert.md +0 -1960
  50. package/public/vendor/vitest-docs/api/browser/assertions.md +0 -1277
  51. package/public/vendor/vitest-docs/api/browser/commands.md +0 -154
  52. package/public/vendor/vitest-docs/api/browser/context.md +0 -338
  53. package/public/vendor/vitest-docs/api/browser/interactivity.md +0 -681
  54. package/public/vendor/vitest-docs/api/browser/locators.md +0 -1171
  55. package/public/vendor/vitest-docs/api/browser/react.md +0 -346
  56. package/public/vendor/vitest-docs/api/browser/svelte.md +0 -292
  57. package/public/vendor/vitest-docs/api/browser/vue.md +0 -222
  58. package/public/vendor/vitest-docs/api/describe.md +0 -374
  59. package/public/vendor/vitest-docs/api/expect-typeof.md +0 -571
  60. package/public/vendor/vitest-docs/api/expect.md +0 -2304
  61. package/public/vendor/vitest-docs/api/hooks.md +0 -463
  62. package/public/vendor/vitest-docs/api/mock.md +0 -701
  63. package/public/vendor/vitest-docs/api/test.md +0 -926
  64. package/public/vendor/vitest-docs/api/vi.md +0 -1372
  65. package/public/vendor/vitest-docs/config/alias.md +0 -13
  66. package/public/vendor/vitest-docs/config/allowonly.md +0 -32
  67. package/public/vendor/vitest-docs/config/api.md +0 -27
  68. package/public/vendor/vitest-docs/config/attachmentsdir.md +0 -6
  69. package/public/vendor/vitest-docs/config/bail.md +0 -9
  70. package/public/vendor/vitest-docs/config/benchmark.md +0 -65
  71. package/public/vendor/vitest-docs/config/browser/api.md +0 -23
  72. package/public/vendor/vitest-docs/config/browser/commands.md +0 -6
  73. package/public/vendor/vitest-docs/config/browser/connecttimeout.md +0 -10
  74. package/public/vendor/vitest-docs/config/browser/detailspanelposition.md +0 -38
  75. package/public/vendor/vitest-docs/config/browser/enabled.md +0 -40
  76. package/public/vendor/vitest-docs/config/browser/expect.md +0 -250
  77. package/public/vendor/vitest-docs/config/browser/headless.md +0 -7
  78. package/public/vendor/vitest-docs/config/browser/instances.md +0 -47
  79. package/public/vendor/vitest-docs/config/browser/isolate.md +0 -11
  80. package/public/vendor/vitest-docs/config/browser/locators.md +0 -24
  81. package/public/vendor/vitest-docs/config/browser/orchestratorscripts.md +0 -39
  82. package/public/vendor/vitest-docs/config/browser/playwright.md +0 -214
  83. package/public/vendor/vitest-docs/config/browser/preview.md +0 -32
  84. package/public/vendor/vitest-docs/config/browser/provider.md +0 -79
  85. package/public/vendor/vitest-docs/config/browser/screenshotdirectory.md +0 -6
  86. package/public/vendor/vitest-docs/config/browser/screenshotfailures.md +0 -6
  87. package/public/vendor/vitest-docs/config/browser/testerhtmlpath.md +0 -5
  88. package/public/vendor/vitest-docs/config/browser/trace.md +0 -43
  89. package/public/vendor/vitest-docs/config/browser/trackunhandlederrors.md +0 -10
  90. package/public/vendor/vitest-docs/config/browser/ui.md +0 -7
  91. package/public/vendor/vitest-docs/config/browser/viewport.md +0 -6
  92. package/public/vendor/vitest-docs/config/browser/webdriverio.md +0 -64
  93. package/public/vendor/vitest-docs/config/cache.md +0 -26
  94. package/public/vendor/vitest-docs/config/chaiconfig.md +0 -29
  95. package/public/vendor/vitest-docs/config/clearmocks.md +0 -22
  96. package/public/vendor/vitest-docs/config/coverage.md +0 -455
  97. package/public/vendor/vitest-docs/config/css.md +0 -47
  98. package/public/vendor/vitest-docs/config/dangerouslyignoreunhandlederrors.md +0 -23
  99. package/public/vendor/vitest-docs/config/deps.md +0 -127
  100. package/public/vendor/vitest-docs/config/detectasyncleaks.md +0 -39
  101. package/public/vendor/vitest-docs/config/diff.md +0 -96
  102. package/public/vendor/vitest-docs/config/dir.md +0 -7
  103. package/public/vendor/vitest-docs/config/disableconsoleintercept.md +0 -15
  104. package/public/vendor/vitest-docs/config/env.md +0 -5
  105. package/public/vendor/vitest-docs/config/environment.md +0 -96
  106. package/public/vendor/vitest-docs/config/environmentoptions.md +0 -30
  107. package/public/vendor/vitest-docs/config/exclude.md +0 -49
  108. package/public/vendor/vitest-docs/config/execargv.md +0 -10
  109. package/public/vendor/vitest-docs/config/expandsnapshotdiff.md +0 -7
  110. package/public/vendor/vitest-docs/config/expect.md +0 -38
  111. package/public/vendor/vitest-docs/config/experimental.md +0 -510
  112. package/public/vendor/vitest-docs/config/faketimers.md +0 -51
  113. package/public/vendor/vitest-docs/config/fileparallelism.md +0 -11
  114. package/public/vendor/vitest-docs/config/forcereruntriggers.md +0 -19
  115. package/public/vendor/vitest-docs/config/globals.md +0 -42
  116. package/public/vendor/vitest-docs/config/globalsetup.md +0 -72
  117. package/public/vendor/vitest-docs/config/hideskippedtests.md +0 -7
  118. package/public/vendor/vitest-docs/config/hooktimeout.md +0 -7
  119. package/public/vendor/vitest-docs/config/include-source.md +0 -115
  120. package/public/vendor/vitest-docs/config/include.md +0 -71
  121. package/public/vendor/vitest-docs/config/includetasklocation.md +0 -17
  122. package/public/vendor/vitest-docs/config/index.md +0 -85
  123. package/public/vendor/vitest-docs/config/isolate.md +0 -13
  124. package/public/vendor/vitest-docs/config/logheapusage.md +0 -7
  125. package/public/vendor/vitest-docs/config/maxconcurrency.md +0 -9
  126. package/public/vendor/vitest-docs/config/maxworkers.md +0 -49
  127. package/public/vendor/vitest-docs/config/mockreset.md +0 -22
  128. package/public/vendor/vitest-docs/config/mode.md +0 -7
  129. package/public/vendor/vitest-docs/config/name.md +0 -111
  130. package/public/vendor/vitest-docs/config/onconsolelog.md +0 -25
  131. package/public/vendor/vitest-docs/config/onstacktrace.md +0 -32
  132. package/public/vendor/vitest-docs/config/onunhandlederror.md +0 -35
  133. package/public/vendor/vitest-docs/config/open.md +0 -7
  134. package/public/vendor/vitest-docs/config/outputfile.md +0 -7
  135. package/public/vendor/vitest-docs/config/passwithnotests.md +0 -7
  136. package/public/vendor/vitest-docs/config/pool.md +0 -45
  137. package/public/vendor/vitest-docs/config/printconsoletrace.md +0 -6
  138. package/public/vendor/vitest-docs/config/projects.md +0 -6
  139. package/public/vendor/vitest-docs/config/provide.md +0 -45
  140. package/public/vendor/vitest-docs/config/reporters.md +0 -69
  141. package/public/vendor/vitest-docs/config/resolvesnapshotpath.md +0 -36
  142. package/public/vendor/vitest-docs/config/restoremocks.md +0 -22
  143. package/public/vendor/vitest-docs/config/retry.md +0 -140
  144. package/public/vendor/vitest-docs/config/root.md +0 -6
  145. package/public/vendor/vitest-docs/config/runner.md +0 -6
  146. package/public/vendor/vitest-docs/config/sequence.md +0 -158
  147. package/public/vendor/vitest-docs/config/server.md +0 -68
  148. package/public/vendor/vitest-docs/config/setupfiles.md +0 -40
  149. package/public/vendor/vitest-docs/config/silent.md +0 -9
  150. package/public/vendor/vitest-docs/config/slowtestthreshold.md +0 -7
  151. package/public/vendor/vitest-docs/config/snapshotenvironment.md +0 -27
  152. package/public/vendor/vitest-docs/config/snapshotformat.md +0 -28
  153. package/public/vendor/vitest-docs/config/snapshotserializers.md +0 -6
  154. package/public/vendor/vitest-docs/config/stricttags.md +0 -30
  155. package/public/vendor/vitest-docs/config/tags.md +0 -141
  156. package/public/vendor/vitest-docs/config/teardowntimeout.md +0 -7
  157. package/public/vendor/vitest-docs/config/testnamepattern.md +0 -21
  158. package/public/vendor/vitest-docs/config/testtimeout.md +0 -7
  159. package/public/vendor/vitest-docs/config/typecheck.md +0 -77
  160. package/public/vendor/vitest-docs/config/ui.md +0 -15
  161. package/public/vendor/vitest-docs/config/unstubenvs.md +0 -20
  162. package/public/vendor/vitest-docs/config/unstubglobals.md +0 -20
  163. package/public/vendor/vitest-docs/config/update.md +0 -16
  164. package/public/vendor/vitest-docs/config/vmmemorylimit.md +0 -30
  165. package/public/vendor/vitest-docs/config/watch.md +0 -11
  166. package/public/vendor/vitest-docs/config/watchtriggerpatterns.md +0 -29
  167. package/public/vendor/vitest-docs/guide/advanced/index.md +0 -147
  168. package/public/vendor/vitest-docs/guide/advanced/pool.md +0 -148
  169. package/public/vendor/vitest-docs/guide/advanced/reporters.md +0 -93
  170. package/public/vendor/vitest-docs/guide/advanced/tests.md +0 -125
  171. package/public/vendor/vitest-docs/guide/browser/aria-snapshots.md +0 -470
  172. package/public/vendor/vitest-docs/guide/browser/component-testing.md +0 -571
  173. package/public/vendor/vitest-docs/guide/browser/index.md +0 -630
  174. package/public/vendor/vitest-docs/guide/browser/multiple-setups.md +0 -121
  175. package/public/vendor/vitest-docs/guide/browser/trace-view.md +0 -126
  176. package/public/vendor/vitest-docs/guide/browser/visual-regression-testing.md +0 -734
  177. package/public/vendor/vitest-docs/guide/cli-generated.md +0 -972
  178. package/public/vendor/vitest-docs/guide/cli.md +0 -234
  179. package/public/vendor/vitest-docs/guide/common-errors.md +0 -163
  180. package/public/vendor/vitest-docs/guide/coverage.md +0 -515
  181. package/public/vendor/vitest-docs/guide/debugging.md +0 -127
  182. package/public/vendor/vitest-docs/guide/environment.md +0 -101
  183. package/public/vendor/vitest-docs/guide/extending-matchers.md +0 -160
  184. package/public/vendor/vitest-docs/guide/features.md +0 -310
  185. package/public/vendor/vitest-docs/guide/filtering.md +0 -175
  186. package/public/vendor/vitest-docs/guide/ide.md +0 -43
  187. package/public/vendor/vitest-docs/guide/improving-performance.md +0 -245
  188. package/public/vendor/vitest-docs/guide/in-source.md +0 -159
  189. package/public/vendor/vitest-docs/guide/index.md +0 -128
  190. package/public/vendor/vitest-docs/guide/learn/async.md +0 -147
  191. package/public/vendor/vitest-docs/guide/learn/debugging-tests.md +0 -210
  192. package/public/vendor/vitest-docs/guide/learn/matchers.md +0 -277
  193. package/public/vendor/vitest-docs/guide/learn/mock-functions.md +0 -277
  194. package/public/vendor/vitest-docs/guide/learn/setup-teardown.md +0 -240
  195. package/public/vendor/vitest-docs/guide/learn/snapshots.md +0 -166
  196. package/public/vendor/vitest-docs/guide/learn/testing-in-practice.md +0 -430
  197. package/public/vendor/vitest-docs/guide/learn/writing-tests-with-ai.md +0 -127
  198. package/public/vendor/vitest-docs/guide/learn/writing-tests.md +0 -231
  199. package/public/vendor/vitest-docs/guide/lifecycle.md +0 -379
  200. package/public/vendor/vitest-docs/guide/migration.md +0 -863
  201. package/public/vendor/vitest-docs/guide/mocking/classes.md +0 -158
  202. package/public/vendor/vitest-docs/guide/mocking/dates.md +0 -52
  203. package/public/vendor/vitest-docs/guide/mocking/file-system.md +0 -74
  204. package/public/vendor/vitest-docs/guide/mocking/functions.md +0 -61
  205. package/public/vendor/vitest-docs/guide/mocking/globals.md +0 -20
  206. package/public/vendor/vitest-docs/guide/mocking/modules.md +0 -414
  207. package/public/vendor/vitest-docs/guide/mocking/requests.md +0 -114
  208. package/public/vendor/vitest-docs/guide/mocking/timers.md +0 -48
  209. package/public/vendor/vitest-docs/guide/mocking.md +0 -239
  210. package/public/vendor/vitest-docs/guide/open-telemetry.md +0 -156
  211. package/public/vendor/vitest-docs/guide/parallelism.md +0 -82
  212. package/public/vendor/vitest-docs/guide/profiling-test-performance.md +0 -243
  213. package/public/vendor/vitest-docs/guide/projects.md +0 -291
  214. package/public/vendor/vitest-docs/guide/recipes.md +0 -59
  215. package/public/vendor/vitest-docs/guide/reporters.md +0 -723
  216. package/public/vendor/vitest-docs/guide/snapshot.md +0 -620
  217. package/public/vendor/vitest-docs/guide/test-annotations.md +0 -103
  218. package/public/vendor/vitest-docs/guide/test-context.md +0 -902
  219. package/public/vendor/vitest-docs/guide/test-tags.md +0 -314
  220. package/public/vendor/vitest-docs/guide/testing-types.md +0 -149
  221. package/public/vendor/vitest-docs/guide/ui.md +0 -160
  222. package/public/vendor/vitest-docs/guide/using-plugins.md +0 -5
  223. package/public/vendor/vitest-docs/manifest.json +0 -1691
  224. package/resources/index.js +0 -166
  225. package/resources/indexes.js +0 -77
  226. package/resources/manifest-schema.js +0 -46
  227. package/resources/paths.js +0 -20
  228. package/resources/patterns.js +0 -22
  229. package/resources/upstream-docs.js +0 -22
@@ -1,166 +0,0 @@
1
- import { renderPatternsIndex, renderUpstreamIndex } from "./indexes.js";
2
- import { decodePatternsManifest, decodeUpstreamManifest } from "./manifest-schema.js";
3
- import { readPattern } from "./patterns.js";
4
- import { readUpstreamDoc } from "./upstream-docs.js";
5
- import { Effect } from "effect";
6
- import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
7
- import { existsSync } from "node:fs";
8
- import { readFile } from "node:fs/promises";
9
- import { dirname, join } from "node:path";
10
- import { fileURLToPath } from "node:url";
11
-
12
- //#region src/resources/index.ts
13
- /**
14
- * Convert the readonly ResourceAnnotations decoded from a manifest into
15
- * the mutable shape the MCP SDK's Annotations type expects. The shape is
16
- * structurally identical; only the readonly-ness differs.
17
- */
18
- function toSdkAnnotations(a) {
19
- const out = {};
20
- if (a.audience !== void 0) out.audience = [...a.audience];
21
- if (a.priority !== void 0) out.priority = a.priority;
22
- return out;
23
- }
24
- /**
25
- * Locate the `public/` directory that holds the served corpus across the
26
- * source and built layouts. `@savvy-web/bundler` mirrors the package-root
27
- * `public/` tree next to the emitted chunk (`<pkg>/public/`), so:
28
- *
29
- * built (bundle): index.js at dist/<env>/pkg/resources/ -> ../public
30
- * source (vitest): index.ts at packages/mcp/src/resources/ -> ../../public
31
- *
32
- * Probe both and fail loudly when neither carries the patterns index, so a
33
- * broken build surfaces a clear path list at startup instead of an opaque
34
- * ENOENT the first time a consumer reads `vitest-agent://patterns/`.
35
- */
36
- function resolveContentRoots() {
37
- const here = dirname(fileURLToPath(import.meta.url));
38
- const candidates = [join(here, "..", "public"), join(here, "..", "..", "public")];
39
- for (const base of candidates) if (existsSync(join(base, "patterns", "_meta.json"))) return {
40
- vendorRoot: join(base, "vendor", "vitest-docs"),
41
- patternsRoot: join(base, "patterns")
42
- };
43
- throw new Error(`[vitest-agent-mcp] cannot locate the served corpus: no public/patterns/_meta.json found (tried: ${candidates.join(", ")})`);
44
- }
45
- async function listManifestPages(vendorRoot) {
46
- const manifestPath = join(vendorRoot, "manifest.json");
47
- if (!existsSync(manifestPath)) return [];
48
- let raw;
49
- try {
50
- raw = await readFile(manifestPath, "utf8");
51
- } catch {
52
- return [];
53
- }
54
- let parsed;
55
- try {
56
- parsed = JSON.parse(raw);
57
- } catch {
58
- return [];
59
- }
60
- const decoded = await Effect.runPromise(decodeUpstreamManifest(parsed).pipe(Effect.catchAll(() => Effect.succeed(null))));
61
- if (!decoded?.pages) return [];
62
- return decoded.pages.map((page) => ({
63
- relativePath: page.path,
64
- title: page.title,
65
- description: page.description,
66
- ...page.annotations ? { annotations: page.annotations } : {}
67
- }));
68
- }
69
- async function listPatternEntries(patternsRoot) {
70
- const metaPath = join(patternsRoot, "_meta.json");
71
- if (!existsSync(metaPath)) return [];
72
- let raw;
73
- try {
74
- raw = await readFile(metaPath, "utf8");
75
- } catch {
76
- return [];
77
- }
78
- let parsed;
79
- try {
80
- parsed = JSON.parse(raw);
81
- } catch {
82
- return [];
83
- }
84
- const decoded = await Effect.runPromise(decodePatternsManifest(parsed).pipe(Effect.catchAll(() => Effect.succeed(null))));
85
- if (!decoded) return [];
86
- return decoded.patterns.map((p) => ({
87
- slug: p.slug,
88
- title: p.title,
89
- summary: p.summary,
90
- ...p.annotations ? { annotations: p.annotations } : {}
91
- }));
92
- }
93
- function registerAllResources(server) {
94
- const { vendorRoot, patternsRoot } = resolveContentRoots();
95
- server.registerResource("vitest_docs_index", "vitest://docs/", {
96
- title: "Vitest documentation: index",
97
- description: "Use first when you need any Vitest API, configuration, or behavioral information and aren't sure which page covers it — lists every page in the vendored snapshot grouped by section (api, config, guide) so you can pick the right `vitest://docs/<path>` URI before fetching.",
98
- mimeType: "text/markdown"
99
- }, async (uri) => {
100
- const result = await renderUpstreamIndex(vendorRoot);
101
- return { contents: [{
102
- uri: uri.href,
103
- mimeType: result.mimeType,
104
- text: result.content
105
- }] };
106
- });
107
- server.registerResource("vitest_docs_page", new ResourceTemplate("vitest://docs/{+path}", { list: async () => {
108
- return { resources: (await listManifestPages(vendorRoot)).map((page) => ({
109
- name: `vitest_docs_${page.relativePath.replace(/\//g, "_")}`,
110
- uri: `vitest://docs/${page.relativePath}`,
111
- title: page.title ?? page.relativePath,
112
- description: page.description ?? `Vitest docs page: ${page.relativePath}`,
113
- mimeType: "text/markdown",
114
- ...page.annotations ? { annotations: toSdkAnnotations(page.annotations) } : {}
115
- })) };
116
- } }), {
117
- title: "Vitest Documentation Page",
118
- description: "A single page from the vendored vitest.dev docs.",
119
- mimeType: "text/markdown"
120
- }, async (uri, variables) => {
121
- const path = variables.path;
122
- const result = await readUpstreamDoc(vendorRoot, Array.isArray(path) ? path.join("/") : String(path));
123
- return { contents: [{
124
- uri: uri.href,
125
- mimeType: result.mimeType,
126
- text: result.content
127
- }] };
128
- });
129
- server.registerResource("vitest_agent_patterns_index", "vitest-agent://patterns/", {
130
- title: "vitest-agent patterns: index",
131
- description: "Use first when you need a curated vitest-agent pattern and want to discover what's available — lists every pattern slug with its title and one-line summary so you can pick the right `vitest-agent://patterns/<slug>` URI before fetching.",
132
- mimeType: "text/markdown"
133
- }, async (uri) => {
134
- const result = await renderPatternsIndex(patternsRoot);
135
- return { contents: [{
136
- uri: uri.href,
137
- mimeType: result.mimeType,
138
- text: result.content
139
- }] };
140
- });
141
- server.registerResource("vitest_agent_pattern", new ResourceTemplate("vitest-agent://patterns/{slug}", { list: async () => {
142
- return { resources: (await listPatternEntries(patternsRoot)).map((p) => ({
143
- name: `vitest_agent_pattern_${p.slug.replace(/[^A-Za-z0-9]/g, "_")}`,
144
- uri: `vitest-agent://patterns/${p.slug}`,
145
- title: p.title,
146
- description: p.summary,
147
- mimeType: "text/markdown",
148
- ...p.annotations ? { annotations: toSdkAnnotations(p.annotations) } : {}
149
- })) };
150
- } }), {
151
- title: "vitest-agent Pattern",
152
- description: "A single curated pattern from the vitest-agent project.",
153
- mimeType: "text/markdown"
154
- }, async (uri, variables) => {
155
- const slug = variables.slug;
156
- const result = await readPattern(patternsRoot, Array.isArray(slug) ? slug[0] : String(slug));
157
- return { contents: [{
158
- uri: uri.href,
159
- mimeType: result.mimeType,
160
- text: result.content
161
- }] };
162
- });
163
- }
164
-
165
- //#endregion
166
- export { registerAllResources };
@@ -1,77 +0,0 @@
1
- import { readFile, readdir } from "node:fs/promises";
2
- import { join } from "node:path";
3
-
4
- //#region src/resources/indexes.ts
5
- async function listMarkdownPages(root) {
6
- const out = [];
7
- async function walk(rel) {
8
- const entries = await readdir(join(root, rel), { withFileTypes: true });
9
- for (const entry of entries) {
10
- if (entry.name.startsWith(".") || entry.name.startsWith("_")) continue;
11
- const next = rel ? `${rel}/${entry.name}` : entry.name;
12
- if (entry.isDirectory()) await walk(next);
13
- else if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "ATTRIBUTION.md") out.push(next.replace(/\.md$/, ""));
14
- }
15
- }
16
- await walk("");
17
- out.sort();
18
- return out;
19
- }
20
- async function renderUpstreamIndex(vendorRoot) {
21
- const manifestRaw = await readFile(join(vendorRoot, "manifest.json"), "utf8");
22
- const manifest = JSON.parse(manifestRaw);
23
- const pages = await listMarkdownPages(vendorRoot);
24
- const grouped = /* @__PURE__ */ new Map();
25
- for (const page of pages) {
26
- const slash = page.indexOf("/");
27
- const section = slash === -1 ? "root" : page.slice(0, slash);
28
- const list = grouped.get(section) ?? [];
29
- list.push(page);
30
- grouped.set(section, list);
31
- }
32
- const lines = [];
33
- lines.push("# Vitest Documentation (Upstream Snapshot)");
34
- lines.push("");
35
- lines.push(`Snapshotted from [vitest-dev/vitest](https://github.com/vitest-dev/vitest) at tag \`${manifest.tag}\` (commit \`${manifest.commitSha.slice(0, 12)}\`).`);
36
- lines.push("");
37
- lines.push("Fetch any page by URI: `vitest://docs/<path>` (e.g., `vitest://docs/api/mock`).");
38
- lines.push("");
39
- const sections = [...grouped.keys()].sort();
40
- for (const section of sections) {
41
- lines.push(`## ${section}`);
42
- lines.push("");
43
- for (const page of grouped.get(section) ?? []) {
44
- const display = page.startsWith(`${section}/`) ? page.slice(section.length + 1) : page;
45
- lines.push(`- \`vitest://docs/${page}\` — ${display}`);
46
- }
47
- lines.push("");
48
- }
49
- return {
50
- content: lines.join("\n"),
51
- mimeType: "text/markdown"
52
- };
53
- }
54
- async function renderPatternsIndex(patternsRoot) {
55
- const metaRaw = await readFile(join(patternsRoot, "_meta.json"), "utf8");
56
- const meta = JSON.parse(metaRaw);
57
- const lines = [];
58
- lines.push("# vitest-agent Curated Patterns");
59
- lines.push("");
60
- lines.push("Hand-written patterns specific to the vitest-agent project. Fetch any pattern by URI: `vitest-agent://patterns/<slug>`.");
61
- lines.push("");
62
- for (const pattern of meta.patterns) {
63
- lines.push(`## ${pattern.title}`);
64
- lines.push("");
65
- lines.push(pattern.summary);
66
- lines.push("");
67
- lines.push(`- URI: \`vitest-agent://patterns/${pattern.slug}\``);
68
- lines.push("");
69
- }
70
- return {
71
- content: lines.join("\n"),
72
- mimeType: "text/markdown"
73
- };
74
- }
75
-
76
- //#endregion
77
- export { renderPatternsIndex, renderUpstreamIndex };
@@ -1,46 +0,0 @@
1
- import { Schema } from "effect";
2
-
3
- //#region src/resources/manifest-schema.ts
4
- const RELATIVE_PATH = /^[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;
5
- /**
6
- * MCP 2025-11-25 resource annotations. Both sub-fields are optional so a
7
- * partially-annotated manifest decodes cleanly during an editorial pass.
8
- *
9
- * `audience` is the set of client roles a resource is relevant to; today
10
- * only `assistant` is meaningful for the vitest-agent MCP server.
11
- * `priority` is a float in [0, 1] that lets a client rank or filter
12
- * results before pulling content into context. See the editorial guide
13
- * in `docs/superpowers/specs/2.0-resource-annotations.md` for the
14
- * priority bands per content type.
15
- */
16
- const ResourceAnnotations = Schema.Struct({
17
- audience: Schema.optional(Schema.Array(Schema.Literal("user", "assistant"))),
18
- priority: Schema.optional(Schema.Number.pipe(Schema.between(0, 1)))
19
- });
20
- const ManifestPage = Schema.Struct({
21
- path: Schema.String.pipe(Schema.pattern(RELATIVE_PATH)),
22
- title: Schema.NonEmptyString,
23
- description: Schema.NonEmptyString,
24
- annotations: Schema.optional(ResourceAnnotations)
25
- });
26
- const UpstreamManifest = Schema.Struct({
27
- tag: Schema.NonEmptyString,
28
- commitSha: Schema.NonEmptyString,
29
- capturedAt: Schema.NonEmptyString,
30
- source: Schema.NonEmptyString,
31
- pages: Schema.optional(Schema.Array(ManifestPage))
32
- });
33
- const decodeUpstreamManifest = Schema.decodeUnknown(UpstreamManifest);
34
- const encodeUpstreamManifest = Schema.encodeUnknown(UpstreamManifest);
35
- const SLUG_PATTERN = /^[A-Za-z0-9._]+(?:[/-][A-Za-z0-9._]+)*$/;
36
- const PatternEntry = Schema.Struct({
37
- slug: Schema.String.pipe(Schema.pattern(SLUG_PATTERN)),
38
- title: Schema.NonEmptyString,
39
- summary: Schema.NonEmptyString,
40
- annotations: Schema.optional(ResourceAnnotations)
41
- });
42
- const PatternsManifest = Schema.Struct({ patterns: Schema.Array(PatternEntry) });
43
- const decodePatternsManifest = Schema.decodeUnknown(PatternsManifest);
44
-
45
- //#endregion
46
- export { decodePatternsManifest, decodeUpstreamManifest };
@@ -1,20 +0,0 @@
1
- import { isAbsolute, normalize, resolve, sep } from "node:path";
2
-
3
- //#region src/resources/paths.ts
4
- /**
5
- * Resolves a user-provided relative path against a vendored root,
6
- * appending `.md` if missing and rejecting traversal attempts.
7
- */
8
- function resolveResourcePath(root, relativePath) {
9
- if (relativePath === "") return root;
10
- if (relativePath.includes("\0")) throw new Error("path contains null byte");
11
- if (isAbsolute(relativePath)) throw new Error("absolute path not allowed");
12
- const stripped = relativePath.replace(/^\/+/, "");
13
- const resolved = resolve(root, normalize(stripped.endsWith(".md") ? stripped : `${stripped}.md`));
14
- const rootWithSep = root.endsWith(sep) ? root : `${root}${sep}`;
15
- if (!resolved.startsWith(rootWithSep) && resolved !== root) throw new Error("path escapes vendor root");
16
- return resolved;
17
- }
18
-
19
- //#endregion
20
- export { resolveResourcePath };
@@ -1,22 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
-
4
- //#region src/resources/patterns.ts
5
- const SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
6
- async function readPattern(patternsRoot, slug) {
7
- if (!SLUG_PATTERN.test(slug)) throw new Error(`invalid slug: ${slug}`);
8
- const absPath = join(patternsRoot, `${slug}.md`);
9
- try {
10
- return {
11
- content: await readFile(absPath, "utf8"),
12
- mimeType: "text/markdown"
13
- };
14
- } catch (err) {
15
- const code = err.code;
16
- if (code === "ENOENT" || code === "EISDIR") throw new Error(`pattern not found: ${slug}. See vitest-agent://patterns/ for the index.`);
17
- throw err;
18
- }
19
- }
20
-
21
- //#endregion
22
- export { readPattern };
@@ -1,22 +0,0 @@
1
- import { resolveResourcePath } from "./paths.js";
2
- import { readFile } from "node:fs/promises";
3
-
4
- //#region src/resources/upstream-docs.ts
5
- async function readUpstreamDoc(vendorRoot, relativePath) {
6
- const absPath = resolveResourcePath(vendorRoot, relativePath);
7
- let content;
8
- try {
9
- content = await readFile(absPath, "utf8");
10
- } catch (err) {
11
- const code = err.code;
12
- if (code === "ENOENT" || code === "EISDIR") throw new Error(`upstream doc not found: ${relativePath}`);
13
- throw err;
14
- }
15
- return {
16
- content,
17
- mimeType: "text/markdown"
18
- };
19
- }
20
-
21
- //#endregion
22
- export { readUpstreamDoc };