@nifrajs/cli 2.14.1 → 3.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 (203) hide show
  1. package/README.md +10 -0
  2. package/dist/assure-hydration.d.ts.map +1 -1
  3. package/dist/assure-hydration.js +6 -1
  4. package/dist/assure-hydration.js.map +1 -1
  5. package/dist/assure.d.ts.map +1 -1
  6. package/dist/assure.js +3 -2
  7. package/dist/assure.js.map +1 -1
  8. package/dist/check-diagnostics.d.ts +165 -0
  9. package/dist/check-diagnostics.d.ts.map +1 -0
  10. package/dist/check-diagnostics.js +1009 -0
  11. package/dist/check-diagnostics.js.map +1 -0
  12. package/dist/check-scan.d.ts +245 -0
  13. package/dist/check-scan.d.ts.map +1 -0
  14. package/dist/check-scan.js +1599 -0
  15. package/dist/check-scan.js.map +1 -0
  16. package/dist/check.d.ts +4 -324
  17. package/dist/check.d.ts.map +1 -1
  18. package/dist/check.js +8 -2346
  19. package/dist/check.js.map +1 -1
  20. package/dist/cli.d.ts.map +1 -1
  21. package/dist/cli.js +285 -10
  22. package/dist/cli.js.map +1 -1
  23. package/dist/command-catalog.d.ts +27 -1
  24. package/dist/command-catalog.d.ts.map +1 -1
  25. package/dist/command-catalog.js +142 -2
  26. package/dist/command-catalog.js.map +1 -1
  27. package/dist/doctor.d.ts +42 -0
  28. package/dist/doctor.d.ts.map +1 -1
  29. package/dist/doctor.js +64 -7
  30. package/dist/doctor.js.map +1 -1
  31. package/dist/env-file.d.ts +17 -0
  32. package/dist/env-file.d.ts.map +1 -0
  33. package/dist/env-file.js +113 -0
  34. package/dist/env-file.js.map +1 -0
  35. package/dist/fix-recipes.d.ts.map +1 -1
  36. package/dist/fix-recipes.js +91 -15
  37. package/dist/fix-recipes.js.map +1 -1
  38. package/dist/frontend-guidance.d.ts +57 -0
  39. package/dist/frontend-guidance.d.ts.map +1 -0
  40. package/dist/frontend-guidance.js +195 -0
  41. package/dist/frontend-guidance.js.map +1 -0
  42. package/dist/internal/reserved-segment-codemod.d.ts +36 -0
  43. package/dist/internal/reserved-segment-codemod.d.ts.map +1 -0
  44. package/dist/internal/reserved-segment-codemod.js +134 -0
  45. package/dist/internal/reserved-segment-codemod.js.map +1 -0
  46. package/dist/internal/typescript-import.d.ts +1 -1
  47. package/dist/internal/typescript-import.d.ts.map +1 -1
  48. package/dist/internal/typescript-import.js +62 -11
  49. package/dist/internal/typescript-import.js.map +1 -1
  50. package/dist/introspect.d.ts +26 -1
  51. package/dist/introspect.d.ts.map +1 -1
  52. package/dist/introspect.js +74 -24
  53. package/dist/introspect.js.map +1 -1
  54. package/dist/levels-tool.d.ts.map +1 -1
  55. package/dist/levels-tool.js +6 -0
  56. package/dist/levels-tool.js.map +1 -1
  57. package/dist/load.d.ts.map +1 -1
  58. package/dist/load.js +4 -1
  59. package/dist/load.js.map +1 -1
  60. package/dist/mcp-context.d.ts +48 -0
  61. package/dist/mcp-context.d.ts.map +1 -0
  62. package/dist/mcp-context.js +215 -0
  63. package/dist/mcp-context.js.map +1 -0
  64. package/dist/mcp-docs-tools.d.ts.map +1 -1
  65. package/dist/mcp-docs-tools.js +31 -0
  66. package/dist/mcp-docs-tools.js.map +1 -1
  67. package/dist/mcp-exec.d.ts +74 -0
  68. package/dist/mcp-exec.d.ts.map +1 -0
  69. package/dist/mcp-exec.js +844 -0
  70. package/dist/mcp-exec.js.map +1 -0
  71. package/dist/mcp-http.js +1 -1
  72. package/dist/mcp-http.js.map +1 -1
  73. package/dist/mcp-io.d.ts +26 -0
  74. package/dist/mcp-io.d.ts.map +1 -0
  75. package/dist/mcp-io.js +100 -0
  76. package/dist/mcp-io.js.map +1 -0
  77. package/dist/mcp-reflect.d.ts +16 -0
  78. package/dist/mcp-reflect.d.ts.map +1 -0
  79. package/dist/mcp-reflect.js +101 -0
  80. package/dist/mcp-reflect.js.map +1 -0
  81. package/dist/mcp-root.d.ts +7 -0
  82. package/dist/mcp-root.d.ts.map +1 -1
  83. package/dist/mcp-root.js +51 -3
  84. package/dist/mcp-root.js.map +1 -1
  85. package/dist/mcp.d.ts +10 -84
  86. package/dist/mcp.d.ts.map +1 -1
  87. package/dist/mcp.js +13 -1170
  88. package/dist/mcp.js.map +1 -1
  89. package/dist/openapi-tool.d.ts +5 -10
  90. package/dist/openapi-tool.d.ts.map +1 -1
  91. package/dist/openapi-tool.js +21 -2
  92. package/dist/openapi-tool.js.map +1 -1
  93. package/dist/openapi-types.d.ts +21 -0
  94. package/dist/openapi-types.d.ts.map +1 -0
  95. package/dist/openapi-types.js +214 -0
  96. package/dist/openapi-types.js.map +1 -0
  97. package/dist/port.d.ts.map +1 -1
  98. package/dist/port.js +2 -1
  99. package/dist/port.js.map +1 -1
  100. package/dist/project-facts.d.ts +2 -1
  101. package/dist/project-facts.d.ts.map +1 -1
  102. package/dist/project-facts.js.map +1 -1
  103. package/dist/recipes/3.0.0.d.ts +10 -0
  104. package/dist/recipes/3.0.0.d.ts.map +1 -0
  105. package/dist/recipes/3.0.0.js +23 -0
  106. package/dist/recipes/3.0.0.js.map +1 -0
  107. package/dist/recipes/index.d.ts.map +1 -1
  108. package/dist/recipes/index.js +2 -0
  109. package/dist/recipes/index.js.map +1 -1
  110. package/dist/release-verification.d.ts +4 -1
  111. package/dist/release-verification.d.ts.map +1 -1
  112. package/dist/release-verification.js +6 -123
  113. package/dist/release-verification.js.map +1 -1
  114. package/dist/rules/codes.d.ts +4 -0
  115. package/dist/rules/codes.d.ts.map +1 -1
  116. package/dist/rules/codes.js +4 -0
  117. package/dist/rules/codes.js.map +1 -1
  118. package/dist/rules/islands.d.ts +4 -0
  119. package/dist/rules/islands.d.ts.map +1 -0
  120. package/dist/rules/islands.js +155 -0
  121. package/dist/rules/islands.js.map +1 -0
  122. package/dist/rules/nano.d.ts +6 -0
  123. package/dist/rules/nano.d.ts.map +1 -0
  124. package/dist/rules/nano.js +264 -0
  125. package/dist/rules/nano.js.map +1 -0
  126. package/dist/rules/routes.d.ts.map +1 -1
  127. package/dist/rules/routes.js +17 -30
  128. package/dist/rules/routes.js.map +1 -1
  129. package/dist/rules/security.d.ts.map +1 -1
  130. package/dist/rules/security.js +38 -4
  131. package/dist/rules/security.js.map +1 -1
  132. package/dist/scaffold.d.ts +12 -6
  133. package/dist/scaffold.d.ts.map +1 -1
  134. package/dist/scaffold.js +149 -10
  135. package/dist/scaffold.js.map +1 -1
  136. package/dist/search-terms.d.ts.map +1 -1
  137. package/dist/search-terms.js +5 -3
  138. package/dist/search-terms.js.map +1 -1
  139. package/dist/stylex-migrate.d.ts +38 -0
  140. package/dist/stylex-migrate.d.ts.map +1 -0
  141. package/dist/stylex-migrate.js +1052 -0
  142. package/dist/stylex-migrate.js.map +1 -0
  143. package/dist/sync-manifest.d.ts.map +1 -1
  144. package/dist/sync-manifest.js +2 -1
  145. package/dist/sync-manifest.js.map +1 -1
  146. package/dist/verification-plan.d.ts +24 -0
  147. package/dist/verification-plan.d.ts.map +1 -0
  148. package/dist/verification-plan.js +116 -0
  149. package/dist/verification-plan.js.map +1 -0
  150. package/dist/work-graph.d.ts.map +1 -1
  151. package/dist/work-graph.js +6 -3
  152. package/dist/work-graph.js.map +1 -1
  153. package/dist/workspace-link.d.ts +37 -0
  154. package/dist/workspace-link.d.ts.map +1 -0
  155. package/dist/workspace-link.js +72 -0
  156. package/dist/workspace-link.js.map +1 -0
  157. package/docs/examples.json +37 -1
  158. package/docs/llms-full.txt +1598 -44
  159. package/docs/types.json +5157 -172
  160. package/package.json +9 -9
  161. package/src/assure-hydration.ts +6 -1
  162. package/src/assure.ts +4 -2
  163. package/src/check-diagnostics.ts +1219 -0
  164. package/src/check-scan.ts +1825 -0
  165. package/src/check.ts +47 -2731
  166. package/src/cli.ts +291 -10
  167. package/src/command-catalog.ts +177 -2
  168. package/src/doctor.ts +99 -8
  169. package/src/env-file.ts +121 -0
  170. package/src/fix-recipes.ts +101 -15
  171. package/src/frontend-guidance.ts +259 -0
  172. package/src/internal/reserved-segment-codemod.ts +150 -0
  173. package/src/internal/typescript-import.ts +61 -11
  174. package/src/introspect.ts +82 -21
  175. package/src/levels-tool.ts +6 -0
  176. package/src/load.ts +4 -1
  177. package/src/mcp-context.ts +266 -0
  178. package/src/mcp-docs-tools.ts +37 -0
  179. package/src/mcp-exec.ts +1040 -0
  180. package/src/mcp-http.ts +1 -1
  181. package/src/mcp-io.ts +118 -0
  182. package/src/mcp-reflect.ts +140 -0
  183. package/src/mcp-root.ts +62 -4
  184. package/src/mcp.ts +61 -1436
  185. package/src/openapi-tool.ts +32 -2
  186. package/src/openapi-types.ts +261 -0
  187. package/src/port.ts +2 -1
  188. package/src/project-facts.ts +2 -4
  189. package/src/recipes/3.0.0.ts +24 -0
  190. package/src/recipes/index.ts +2 -0
  191. package/src/release-verification.ts +22 -147
  192. package/src/rules/codes.ts +4 -0
  193. package/src/rules/islands.ts +171 -0
  194. package/src/rules/nano.ts +295 -0
  195. package/src/rules/routes.ts +17 -30
  196. package/src/rules/security.ts +40 -4
  197. package/src/scaffold.ts +169 -9
  198. package/src/search-terms.ts +7 -3
  199. package/src/stylex-migrate.ts +1139 -0
  200. package/src/sync-manifest.ts +2 -1
  201. package/src/verification-plan.ts +242 -0
  202. package/src/work-graph.ts +6 -3
  203. package/src/workspace-link.ts +80 -0
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Project context and trust-local utilities for the MCP server.
3
+ *
4
+ * Resources, prompts, path scoping, and monorepo namespacing are independent of the JSON-RPC loop and
5
+ * of backend reflection. App loading is injected through the shared cached loader seam.
6
+ */
7
+ import { realpathSync } from "node:fs";
8
+ import { readFile } from "node:fs/promises";
9
+ import { basename, isAbsolute, relative, resolve, sep } from "node:path";
10
+ import { createCachedAppLoader } from "./mcp-exec.js";
11
+ function openApiFormat(args) {
12
+ const format = args.format;
13
+ return format === "yaml" ? "yaml" : "json";
14
+ }
15
+ export async function openApiHandler(args, loadAppCached) {
16
+ const { renderOpenApiWithTypes } = await import("./openapi-tool.js");
17
+ const pathPrefix = typeof args.path === "string" ? args.path : undefined;
18
+ return renderOpenApiWithTypes(await loadAppCached(), openApiFormat(args), pathPrefix);
19
+ }
20
+ async function readProjectFile(cwd, relativeFile, maxChars) {
21
+ const target = resolve(cwd, relativeFile);
22
+ const root = resolve(cwd);
23
+ if (target !== root && !target.startsWith(`${root}${sep}`)) {
24
+ throw new Error(`refusing to read outside project root: ${relativeFile}`);
25
+ }
26
+ try {
27
+ const text = await readFile(target, "utf8");
28
+ return text.length <= maxChars
29
+ ? text
30
+ : `${text.slice(0, maxChars)}\n…(trimmed; read ${relativeFile} directly for the rest)`;
31
+ }
32
+ catch (err) {
33
+ if (err && typeof err === "object" && err.code === "ENOENT") {
34
+ return `No ${relativeFile} found in ${basename(cwd)}.`;
35
+ }
36
+ throw err;
37
+ }
38
+ }
39
+ function promptText(text) {
40
+ return [{ role: "user", content: { type: "text", text } }];
41
+ }
42
+ export function projectResources(cwd, loadAppCached = createCachedAppLoader(cwd)) {
43
+ return [
44
+ {
45
+ uri: "nifra://routes",
46
+ name: "API routes",
47
+ description: "Structured API routes with typed-client calls and compact request/response shapes.",
48
+ mimeType: "application/json",
49
+ read: async () => {
50
+ const { routesToJson } = await import("./introspect.js");
51
+ return { text: JSON.stringify(routesToJson(await loadAppCached()), null, 2) };
52
+ },
53
+ },
54
+ {
55
+ uri: "nifra://openapi",
56
+ name: "OpenAPI 3.1",
57
+ description: "OpenAPI document generated from backend.ts using @nifrajs/schema.",
58
+ mimeType: "application/json",
59
+ read: async () => ({ text: await openApiHandler({ format: "json" }, loadAppCached) }),
60
+ },
61
+ {
62
+ uri: "nifra://package-json",
63
+ name: "package.json",
64
+ description: "Project package metadata and scripts.",
65
+ mimeType: "application/json",
66
+ read: async () => ({ text: await readProjectFile(cwd, "package.json", 40_000) }),
67
+ },
68
+ {
69
+ uri: "nifra://agents-md",
70
+ name: "AGENTS.md",
71
+ description: "Repository-specific agent instructions if the project has them.",
72
+ mimeType: "text/markdown",
73
+ read: async () => ({ text: await readProjectFile(cwd, "AGENTS.md", 40_000) }),
74
+ },
75
+ ];
76
+ }
77
+ export function projectPrompts() {
78
+ return [
79
+ {
80
+ name: "nifra_new_route",
81
+ description: "Implement a new file route with the right routes/ filename, examples, and checks.",
82
+ arguments: [
83
+ { name: "path", description: 'URL path, e.g. "/users/:id".', required: true },
84
+ { name: "goal", description: "What the page should do.", required: false },
85
+ ],
86
+ handler: async (args) => promptText([
87
+ `Create a nifra page route for ${JSON.stringify(args.path ?? "/new-route")}.`,
88
+ args.goal ? `Goal: ${String(args.goal)}` : undefined,
89
+ 'Use `nifra_context` with `{ kind: "pages" }`, then `nifra_scaffold` for the exact file path.',
90
+ "If the stub is not writable for this framework, call `nifra_example` for a verified page/loader example before editing.",
91
+ "Verify with `nifra_render` for the route and finish with `nifra_check`.",
92
+ ]
93
+ .filter(Boolean)
94
+ .join("\n")),
95
+ },
96
+ {
97
+ name: "nifra_add_endpoint",
98
+ description: "Add or update a backend endpoint with schemas, typed-client usage, and verification.",
99
+ arguments: [
100
+ { name: "method", description: "HTTP method.", required: true },
101
+ { name: "path", description: 'API path, e.g. "/users/:id".', required: true },
102
+ { name: "goal", description: "What the endpoint should do.", required: false },
103
+ ],
104
+ handler: async (args) => promptText([
105
+ `Add a nifra backend endpoint: ${String(args.method ?? "GET").toUpperCase()} ${String(args.path ?? "/api")}.`,
106
+ args.goal ? `Goal: ${String(args.goal)}` : undefined,
107
+ "Read `nifra://routes` or call `nifra_routes` first so the new route fits the existing API shape.",
108
+ "Use route schemas for untrusted body/query input and declare `response` when the frontend consumes the shape.",
109
+ "Verify behavior with `nifra_run`, then run `nifra_check` and `nifra_test` for the touched area.",
110
+ ]
111
+ .filter(Boolean)
112
+ .join("\n")),
113
+ },
114
+ {
115
+ name: "nifra_debug_drift",
116
+ description: "Debug frontend/backend contract drift using the typed client and checker output.",
117
+ arguments: [
118
+ { name: "symptom", description: "The error or behavior to investigate.", required: false },
119
+ ],
120
+ handler: async (args) => promptText([
121
+ "Debug nifra contract drift.",
122
+ args.symptom ? `Symptom: ${String(args.symptom)}` : undefined,
123
+ "Start with `nifra_check`; use each diagnostic as the source of truth.",
124
+ "Read `nifra://routes` for the exact typed-client calls and compact body/query/response shapes.",
125
+ "Prefer `client<typeof app>` over hand-rolled internal `fetch`. Verify fixed endpoints with `nifra_run`.",
126
+ ]
127
+ .filter(Boolean)
128
+ .join("\n")),
129
+ },
130
+ ];
131
+ }
132
+ export function projectFeatures(cwd, loadAppCached = createCachedAppLoader(cwd)) {
133
+ return { resources: projectResources(cwd, loadAppCached), prompts: projectPrompts() };
134
+ }
135
+ /**
136
+ * Resolve an optional `dir` tool argument - a subdirectory of the project root the caller wants to scope a
137
+ * check/test to (e.g. `nifra check` on `app/` when the MCP server's root is a monorepo). Returns the
138
+ * absolute target, or `null` if `dir` escapes the root (a path-traversal guard: no `..` out, no absolute
139
+ * path elsewhere). `undefined`/empty → the root itself.
140
+ */
141
+ export function resolveProjectDir(root, dir) {
142
+ if (dir === undefined || dir === "")
143
+ return root;
144
+ const target = resolve(root, dir);
145
+ let canonicalRoot;
146
+ try {
147
+ canonicalRoot = realpathSync(root);
148
+ }
149
+ catch {
150
+ const lexical = relative(root, target);
151
+ return lexical === "" || (!lexical.startsWith("..") && !isAbsolute(lexical)) ? target : null;
152
+ }
153
+ let probe = target;
154
+ const missing = [];
155
+ while (true) {
156
+ try {
157
+ const canonicalProbe = realpathSync(probe);
158
+ const rel = relative(canonicalRoot, canonicalProbe);
159
+ if (rel.startsWith("..") || isAbsolute(rel))
160
+ return null;
161
+ return missing.length === 0 ? canonicalProbe : resolve(canonicalProbe, ...missing.reverse());
162
+ }
163
+ catch {
164
+ const parent = resolve(probe, "..");
165
+ if (parent === probe)
166
+ return null;
167
+ // `basename`, not a slice past `parent`: when `parent` is the filesystem root its trailing
168
+ // separator is part of it, so `parent.length + 1` eats the first character of the segment and
169
+ // the path gets rebuilt wrong.
170
+ missing.push(basename(probe));
171
+ probe = parent;
172
+ }
173
+ }
174
+ }
175
+ /** Consistent error string for a `dir` that escapes the project root. */
176
+ export function dirError(dir) {
177
+ return JSON.stringify({ ok: false, error: `dir must be a subdirectory of the project root - "${dir}" escapes it.` }, null, 2);
178
+ }
179
+ /** Adapt one executable catalog spec to its MCP descriptor and project-scoped handler. */
180
+ export function namespaceForApp(name, tools, features) {
181
+ const prefix = `nifra_${name}_`;
182
+ const namespacedTools = tools.map((t) => ({
183
+ ...t,
184
+ name: t.name.startsWith("nifra_") ? t.name.replace(/^nifra_/, prefix) : `${name}_${t.name}`,
185
+ }));
186
+ const namespacedResources = (features.resources ?? []).map((r) => ({
187
+ ...r,
188
+ uri: r.uri.replace(/^nifra:\/\//, `nifra://${name}/`),
189
+ }));
190
+ const namespacedPrompts = (features.prompts ?? []).map((p) => ({
191
+ ...p,
192
+ name: p.name.replace(/^nifra_/, prefix),
193
+ }));
194
+ return {
195
+ tools: namespacedTools,
196
+ features: { resources: namespacedResources, prompts: namespacedPrompts },
197
+ };
198
+ }
199
+ /**
200
+ * Merge the backend-derived resources/prompts into `base` - and keep a project that cannot be loaded
201
+ * from deciding whether the server starts at all.
202
+ *
203
+ * Resources and prompts are OPTIONAL capabilities extracted from the app's backend, so this load is a
204
+ * best-effort enrichment. It was awaited unguarded, which made it a hard boot requirement: `loadApp`
205
+ * needs a web config (`adapter` + `clientModule`) and a `routes/` directory, and a backend-only
206
+ * project - the shape `create-nifra`'s DEFAULT template produces - has neither. On those projects the
207
+ * throw escaped before the JSON-RPC loop began, so the server wrote nothing and exited. `nifra
208
+ * init-agents` would happily register an `.mcp.json` pointing at a server that could never start, and
209
+ * every tool went with it, including the twelve that never touch the app (docs, examples, types,
210
+ * check, doctor, levels, test).
211
+ *
212
+ * Degrading costs only the backend resources/prompts. Tools that genuinely need the app still fail,
213
+ * but per call, with their own message - which is a diagnosis instead of a silence.
214
+ */
215
+ //# sourceMappingURL=mcp-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-context.js","sourceRoot":"","sources":["../src/mcp-context.ts"],"names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+ {"version":3,"file":"mcp-docs-tools.d.ts","sourceRoot":"","sources":["../src/mcp-docs-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,OAAO,EAAwB,MAAM,eAAe,CAAA;AAGlE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAKrE,yFAAyF;AACzF,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,EAC3C,YAAY,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,EAClD,SAAS,EAAE,MAAM,OAAO,CAAC,SAAS,EAAE,GAAG,SAAS,CAAC,GAChD,OAAO,EAAE,CAmKX"}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import { renderDocsResult } from "./docs-search.js";
10
10
  import { renderExamplesResult } from "./examples.js";
11
+ import { renderFrontendResult } from "./frontend-guidance.js";
11
12
  import { renderLearnResult } from "./learn.js";
12
13
  import { renderTypesResult } from "./types-search.js";
13
14
  const clamp = (n, lo, hi, dflt) => Math.min(Math.max(typeof n === "number" ? n : dflt, lo), hi);
@@ -126,6 +127,36 @@ export function docsTools(loadDocs, loadExamples, loadTypes) {
126
127
  },
127
128
  handler: async (args) => renderLearnResult(args.step),
128
129
  },
130
+ {
131
+ name: "nifra_frontend",
132
+ annotations: {
133
+ title: "Frontend footgun guidance",
134
+ readOnlyHint: true,
135
+ openWorldHint: false,
136
+ },
137
+ description: 'Diagnose a CLIENT-SIDE nifra problem by symptom, across every adapter (React/Preact/Solid/Vue/Svelte/vanilla). Returns the cause, the concrete fix, and how to verify it. Covers the nifra SEAM (a server-only import leaking into a client component, a hydration mismatch, a duplicated framework runtime, loader-data typing) - where it points at the nifra_* tool that fixes and checks it - and the per-framework reactivity-loss idioms (Vue ref, Solid props, Svelte runes, React effect deps), where it points at that framework\'s own ESLint plugin. Call with no args for the index; pass `symptom` (e.g. "hydration mismatch", "value stopped updating") and/or `adapter` to filter. Use this when a rendered page misbehaves and nifra_check is green (check owns the static seam; this owns the rest).',
138
+ inputSchema: {
139
+ type: "object",
140
+ properties: {
141
+ symptom: {
142
+ type: "string",
143
+ maxLength: 256,
144
+ description: "What you observe (omit for the index).",
145
+ },
146
+ adapter: {
147
+ type: "string",
148
+ enum: ["react", "preact", "solid", "vue", "svelte", "vanilla"],
149
+ description: "Filter to one adapter's entries (plus the adapter-independent seam entries).",
150
+ },
151
+ limit: { type: "number", description: "Max entries to return (default 3, max 5)." },
152
+ },
153
+ additionalProperties: false,
154
+ },
155
+ handler: async (args) => {
156
+ const { symptom, adapter, limit } = args;
157
+ return renderFrontendResult({ symptom, adapter, limit: clamp(limit, 1, 5, 3) });
158
+ },
159
+ },
129
160
  ];
130
161
  }
131
162
  //# sourceMappingURL=mcp-docs-tools.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-docs-tools.js","sourceRoot":"","sources":["../src/mcp-docs-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAgB,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,OAAO,EAAE,iBAAiB,EAAkB,MAAM,mBAAmB,CAAA;AAErE,MAAM,KAAK,GAAG,CAAC,CAAqB,EAAE,EAAU,EAAE,EAAU,EAAE,IAAY,EAAU,EAAE,CACpF,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9D,yFAAyF;AACzF,MAAM,UAAU,SAAS,CACvB,QAA2C,EAC3C,YAAkD,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,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC;wBAC9D,WAAW,EACT,8EAA8E;qBACjF;oBACD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2CAA2C,EAAE;iBACpF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;YACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACtB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAInC,CAAA;gBACD,OAAO,oBAAoB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;YACjF,CAAC;SACF;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Shared project-tool execution for stdio, run, and render.
3
+ *
4
+ * This module owns child-process limits, warm-worker lifecycle, source fingerprinting, and cached app
5
+ * loading. It has no JSON-RPC transport or root-trust policy, so those seams remain independently
6
+ * replaceable.
7
+ */
8
+ import { type CommandCatalogEntry, type CommandSpec } from "./command-catalog.js";
9
+ import type { LoadAppOptions, LoadedApp } from "./load.js";
10
+ import { type CommandMcpToolOptions } from "./mcp-context.js";
11
+ import type { McpTool, McpToolContext } from "./mcp-protocol.js";
12
+ /** Path to a sibling child entry (`mcp-run` / `mcp-render` / `mcp-ws`), resolved next to this module (`.ts` in
13
+ * dev, `.js` once built). Each runs in a FRESH subprocess per call so the project's current code loads. */
14
+ export declare function toMcpTool(source: CommandSpec<unknown, unknown> | CommandCatalogEntry, options: CommandMcpToolOptions): McpTool;
15
+ export declare function catalogProjectTools(cwd: string, loadAppCached?: () => Promise<LoadedApp>): McpTool[];
16
+ export declare function projectTools(cwd: string, loadAppCached?: (outDirName?: string) => Promise<LoadedApp>): McpTool[];
17
+ /** Spawn `bun <child> <cwd>`, pipe `input` to its stdin, return its stdout (or a stderr-backed error). */
18
+ /**
19
+ * How long a child gets before it is killed.
20
+ *
21
+ * A child loads the app, which runs its module side effects - a database pool, a Redis client, a
22
+ * metrics interval. Any of those keeps the child's event loop alive after the work is done, and the
23
+ * parent is sitting in `await proc.exited`. The children now exit explicitly, so this is the backstop
24
+ * rather than the fix: without it a single wedged child blocks an agent indefinitely, and the caller
25
+ * has no way to tell "still working" from "never returning".
26
+ *
27
+ * Generous enough for a cold start that compiles route modules, short enough that a hang is reported
28
+ * within one attention span rather than after minutes of polling.
29
+ */
30
+ export declare function spawnChild(child: "mcp-run" | "mcp-render" | "mcp-ws", cwd: string, input: unknown, label: string, signal?: AbortSignal): Promise<string>;
31
+ /** A persistent `mcp-run`/`mcp-render` `--worker` subprocess: the backend/web app is loaded ONCE and
32
+ * reused across newline-delimited `{ id, input }` requests, replying `{ id, output }`. The same machinery
33
+ * powers both `nifra_run warm` and `nifra_render warm` - `child` selects which engine, `label` shapes the
34
+ * cancellation message. The owning handler ({@link createWarmHandler}) fingerprints the source tree and
35
+ * replaces the worker when a file changes, so warm reuse never serves a stale result. Exported for the
36
+ * concurrency test that proves a single per-request cancel doesn't tear down the shared worker. */
37
+ export declare class WarmWorker {
38
+ readonly fingerprint: string;
39
+ private readonly label;
40
+ private readonly proc;
41
+ private readonly pending;
42
+ private stdoutBuffer;
43
+ private stderrBuffer;
44
+ private nextId;
45
+ private closed;
46
+ constructor(child: "mcp-run" | "mcp-render", cwd: string, fingerprint: string, label: string);
47
+ stop(): void;
48
+ request(input: unknown, signal?: AbortSignal): Promise<string>;
49
+ private readStdout;
50
+ private readStderr;
51
+ private handleLine;
52
+ }
53
+ /** A warm handler that reuses a hot {@link WarmWorker} across calls and falls back to a one-shot fresh
54
+ * subprocess on any worker failure. Shared by `nifra_run` (`child: "mcp-run"`, `label: "run"`) and
55
+ * `nifra_render` (`child: "mcp-render"`, `label: "render"`) - the only differences are the engine and the
56
+ * message label, so there's a single source for the reuse + auto-restart-on-file-change logic. */
57
+ export declare function createWarmHandler(child: "mcp-run" | "mcp-render", cwd: string, label: string): (input: unknown, signal?: AbortSignal) => Promise<string>;
58
+ /** The `nifra_run` handler: run requests through the project's CURRENT backend, return structured results. */
59
+ export declare function runHandler(cwd: string, args: Record<string, unknown>, context: McpToolContext, warmRun: (input: unknown, signal?: AbortSignal) => Promise<string>): Promise<string>;
60
+ /** The `nifra_render` handler: SSR page routes through the project's CURRENT web app, return the HTML.
61
+ * By default a fresh subprocess loads the current code each call; `warm:true` reuses a hot worker (like
62
+ * `nifra_run`) that auto-restarts when a source file changes. */
63
+ export declare function renderHandler(cwd: string, args: Record<string, unknown>, context: McpToolContext, warmRender: (input: unknown, signal?: AbortSignal) => Promise<string>): Promise<string>;
64
+ /** The `nifra_ws` handler: verify WebSocket routes through a fresh app subprocess. */
65
+ export declare function wsHandler(cwd: string, args: Record<string, unknown>, context: McpToolContext): Promise<string>;
66
+ type LoadAppForCache = (cwd: string, outDirName?: string, options?: LoadAppOptions) => Promise<LoadedApp>;
67
+ export interface CachedAppLoaderOptions {
68
+ readonly loadApp?: LoadAppForCache;
69
+ readonly fingerprint?: (cwd: string) => Promise<string>;
70
+ }
71
+ /** Cache LoadedApp inside one MCP server process, invalidating when config/backend mtimes change. */
72
+ export declare function createCachedAppLoader(cwd: string, options?: CachedAppLoaderOptions): (outDirName?: string) => Promise<LoadedApp>;
73
+ export {};
74
+ //# sourceMappingURL=mcp-exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-exec.d.ts","sourceRoot":"","sources":["../src/mcp-exec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,WAAW,EAIjB,MAAM,sBAAsB,CAAA;AAI7B,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,EACL,KAAK,qBAAqB,EAI3B,MAAM,kBAAkB,CAAA;AAY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