@nifrajs/cli 5.0.0 → 5.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.
- package/CHANGELOG.md +3211 -0
- package/README.md +10 -2
- package/dist/agent-files.d.ts +19 -11
- package/dist/agent-files.d.ts.map +1 -1
- package/dist/agent-files.js +26 -18
- package/dist/agent-files.js.map +1 -1
- package/dist/assure-hydration.d.ts.map +1 -1
- package/dist/assure-hydration.js +5 -2
- package/dist/assure-hydration.js.map +1 -1
- package/dist/assure.d.ts +12 -2
- package/dist/assure.d.ts.map +1 -1
- package/dist/assure.js +73 -9
- package/dist/assure.js.map +1 -1
- package/dist/capabilities-tool.d.ts.map +1 -1
- package/dist/capabilities-tool.js +152 -49
- package/dist/capabilities-tool.js.map +1 -1
- package/dist/check-diagnostics.d.ts +7 -0
- package/dist/check-diagnostics.d.ts.map +1 -1
- package/dist/check-diagnostics.js +3 -0
- package/dist/check-diagnostics.js.map +1 -1
- package/dist/check-scan.d.ts +8 -2
- package/dist/check-scan.d.ts.map +1 -1
- package/dist/check-scan.js +49 -13
- package/dist/check-scan.js.map +1 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +91 -45
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +128 -59
- package/dist/cli.js.map +1 -1
- package/dist/client-module.d.ts +5 -3
- package/dist/client-module.d.ts.map +1 -1
- package/dist/client-module.js +34 -10
- package/dist/client-module.js.map +1 -1
- package/dist/command-catalog.d.ts +9 -1
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog.js +75 -26
- package/dist/command-catalog.js.map +1 -1
- package/dist/dev-bun-config.d.ts +6 -3
- package/dist/dev-bun-config.d.ts.map +1 -1
- package/dist/dev-bun-config.js +13 -10
- package/dist/dev-bun-config.js.map +1 -1
- package/dist/dev-feed-tool.d.ts +19 -1
- package/dist/dev-feed-tool.d.ts.map +1 -1
- package/dist/dev-feed-tool.js +114 -0
- package/dist/dev-feed-tool.js.map +1 -1
- package/dist/doctor.d.ts +15 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +79 -61
- package/dist/doctor.js.map +1 -1
- package/dist/fix-recipes.d.ts +2 -0
- package/dist/fix-recipes.d.ts.map +1 -1
- package/dist/fix-recipes.js +93 -12
- package/dist/fix-recipes.js.map +1 -1
- package/dist/i18n-check.d.ts +11 -1
- package/dist/i18n-check.d.ts.map +1 -1
- package/dist/i18n-check.js +170 -17
- package/dist/i18n-check.js.map +1 -1
- package/dist/init-agents.d.ts +60 -4
- package/dist/init-agents.d.ts.map +1 -1
- package/dist/init-agents.js +196 -33
- package/dist/init-agents.js.map +1 -1
- package/dist/internal/config-paths.d.ts +16 -0
- package/dist/internal/config-paths.d.ts.map +1 -0
- package/dist/internal/config-paths.js +124 -0
- package/dist/internal/config-paths.js.map +1 -0
- package/dist/internal/installed-package.d.ts +4 -0
- package/dist/internal/installed-package.d.ts.map +1 -0
- package/dist/internal/installed-package.js +17 -0
- package/dist/internal/installed-package.js.map +1 -0
- package/dist/internal/project-specifiers.d.ts +14 -1
- package/dist/internal/project-specifiers.d.ts.map +1 -1
- package/dist/internal/project-specifiers.js +63 -16
- package/dist/internal/project-specifiers.js.map +1 -1
- package/dist/internal/source-facts.d.ts +12 -1
- package/dist/internal/source-facts.d.ts.map +1 -1
- package/dist/internal/source-facts.js +117 -5
- package/dist/internal/source-facts.js.map +1 -1
- package/dist/internal/typescript-import.d.ts.map +1 -1
- package/dist/internal/typescript-import.js +5 -3
- package/dist/internal/typescript-import.js.map +1 -1
- package/dist/internal/workspace-packages.d.ts +22 -0
- package/dist/internal/workspace-packages.d.ts.map +1 -0
- package/dist/internal/workspace-packages.js +215 -0
- package/dist/internal/workspace-packages.js.map +1 -0
- package/dist/introspect.d.ts +9 -0
- package/dist/introspect.d.ts.map +1 -1
- package/dist/introspect.js +32 -1
- package/dist/introspect.js.map +1 -1
- package/dist/levels-tool.d.ts.map +1 -1
- package/dist/levels-tool.js +5 -8
- package/dist/levels-tool.js.map +1 -1
- package/dist/load.d.ts +9 -4
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +32 -3
- package/dist/load.js.map +1 -1
- package/dist/lock-links.d.ts +42 -0
- package/dist/lock-links.d.ts.map +1 -0
- package/dist/lock-links.js +144 -0
- package/dist/lock-links.js.map +1 -0
- package/dist/mcp-context.d.ts.map +1 -1
- package/dist/mcp-context.js +6 -21
- package/dist/mcp-context.js.map +1 -1
- package/dist/mcp-delegate.d.ts +2 -2
- package/dist/mcp-delegate.d.ts.map +1 -1
- package/dist/mcp-delegate.js +19 -7
- package/dist/mcp-delegate.js.map +1 -1
- package/dist/mcp-exec.d.ts +1 -0
- package/dist/mcp-exec.d.ts.map +1 -1
- package/dist/mcp-exec.js +13 -5
- package/dist/mcp-exec.js.map +1 -1
- package/dist/mcp-http.js +1 -1
- package/dist/mcp-io.d.ts +13 -0
- package/dist/mcp-io.d.ts.map +1 -1
- package/dist/mcp-io.js +23 -0
- package/dist/mcp-io.js.map +1 -1
- package/dist/mcp-path.d.ts +2 -1
- package/dist/mcp-path.d.ts.map +1 -1
- package/dist/mcp-path.js +9 -24
- package/dist/mcp-path.js.map +1 -1
- package/dist/mcp-root.d.ts +6 -4
- package/dist/mcp-root.d.ts.map +1 -1
- package/dist/mcp-root.js +12 -8
- package/dist/mcp-root.js.map +1 -1
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +40 -17
- package/dist/mcp.js.map +1 -1
- package/dist/migrate-layout.d.ts +41 -1
- package/dist/migrate-layout.d.ts.map +1 -1
- package/dist/migrate-layout.js +1729 -236
- package/dist/migrate-layout.js.map +1 -1
- package/dist/output-schemas.d.ts +34 -0
- package/dist/output-schemas.d.ts.map +1 -1
- package/dist/output-schemas.js +132 -21
- package/dist/output-schemas.js.map +1 -1
- package/dist/project-path.d.ts +6 -0
- package/dist/project-path.d.ts.map +1 -1
- package/dist/project-path.js +48 -14
- package/dist/project-path.js.map +1 -1
- package/dist/project-site.d.ts +7 -0
- package/dist/project-site.d.ts.map +1 -0
- package/dist/project-site.js +19 -0
- package/dist/project-site.js.map +1 -0
- package/dist/recipes/4.0.0.d.ts.map +1 -1
- package/dist/recipes/4.0.0.js +2 -0
- package/dist/recipes/4.0.0.js.map +1 -1
- package/dist/recipes/5.1.0.d.ts +9 -0
- package/dist/recipes/5.1.0.d.ts.map +1 -0
- package/dist/recipes/5.1.0.js +22 -0
- package/dist/recipes/5.1.0.js.map +1 -0
- package/dist/recipes/5.2.0.d.ts +10 -0
- package/dist/recipes/5.2.0.d.ts.map +1 -0
- package/dist/recipes/5.2.0.js +32 -0
- package/dist/recipes/5.2.0.js.map +1 -0
- package/dist/recipes/index.d.ts +3 -0
- package/dist/recipes/index.d.ts.map +1 -1
- package/dist/recipes/index.js +7 -0
- package/dist/recipes/index.js.map +1 -1
- package/dist/release-verification.d.ts +5 -0
- package/dist/release-verification.d.ts.map +1 -1
- package/dist/release-verification.js +14 -0
- package/dist/release-verification.js.map +1 -1
- package/dist/review.d.ts.map +1 -1
- package/dist/review.js +7 -0
- package/dist/review.js.map +1 -1
- package/dist/rule-explain.d.ts +26 -0
- package/dist/rule-explain.d.ts.map +1 -0
- package/dist/rule-explain.js +49 -0
- package/dist/rule-explain.js.map +1 -0
- package/dist/rules/codes.d.ts +5 -1
- package/dist/rules/codes.d.ts.map +1 -1
- package/dist/rules/codes.js +5 -1
- package/dist/rules/codes.js.map +1 -1
- package/dist/rules/contract-visibility.d.ts.map +1 -1
- package/dist/rules/contract-visibility.js +93 -21
- package/dist/rules/contract-visibility.js.map +1 -1
- package/dist/rules/data-guard.d.ts +6 -0
- package/dist/rules/data-guard.d.ts.map +1 -1
- package/dist/rules/data-guard.js +37 -0
- package/dist/rules/data-guard.js.map +1 -1
- package/dist/rules/explanations.d.ts +14 -0
- package/dist/rules/explanations.d.ts.map +1 -0
- package/dist/rules/explanations.js +316 -0
- package/dist/rules/explanations.js.map +1 -0
- package/dist/rules/legacy.d.ts.map +1 -1
- package/dist/rules/legacy.js +44 -2
- package/dist/rules/legacy.js.map +1 -1
- package/dist/rules/merge-auth.d.ts +12 -0
- package/dist/rules/merge-auth.d.ts.map +1 -0
- package/dist/rules/merge-auth.js +52 -0
- package/dist/rules/merge-auth.js.map +1 -0
- package/dist/rules/pages.d.ts +56 -3
- package/dist/rules/pages.d.ts.map +1 -1
- package/dist/rules/pages.js +412 -23
- package/dist/rules/pages.js.map +1 -1
- package/dist/rules/routes.d.ts +3 -2
- package/dist/rules/routes.d.ts.map +1 -1
- package/dist/rules/routes.js +4 -3
- package/dist/rules/routes.js.map +1 -1
- package/dist/rules/security.d.ts +3 -2
- package/dist/rules/security.d.ts.map +1 -1
- package/dist/rules/security.js +42 -11
- package/dist/rules/security.js.map +1 -1
- package/dist/rules/zones.d.ts.map +1 -1
- package/dist/rules/zones.js +34 -11
- package/dist/rules/zones.js.map +1 -1
- package/dist/stylex-migrate.d.ts.map +1 -1
- package/dist/stylex-migrate.js +127 -17
- package/dist/stylex-migrate.js.map +1 -1
- package/dist/test-tool.d.ts.map +1 -1
- package/dist/test-tool.js +3 -9
- package/dist/test-tool.js.map +1 -1
- package/dist/typecheck-coverage.d.ts +11 -0
- package/dist/typecheck-coverage.d.ts.map +1 -1
- package/dist/typecheck-coverage.js +50 -7
- package/dist/typecheck-coverage.js.map +1 -1
- package/dist/upgrade.d.ts +57 -6
- package/dist/upgrade.d.ts.map +1 -1
- package/dist/upgrade.js +247 -19
- package/dist/upgrade.js.map +1 -1
- package/dist/verification-plan.d.ts.map +1 -1
- package/dist/verification-plan.js +7 -2
- package/dist/verification-plan.js.map +1 -1
- package/dist/version-drift.d.ts.map +1 -1
- package/dist/version-drift.js +66 -3
- package/dist/version-drift.js.map +1 -1
- package/dist/web-app-options.d.ts +1 -1
- package/dist/web-app-options.d.ts.map +1 -1
- package/dist/web-app-options.js.map +1 -1
- package/docs/examples.json +21 -3
- package/docs/llms-full.txt +1083 -168
- package/docs/types.json +535 -112
- package/package.json +13 -12
- package/src/agent-files.ts +27 -17
- package/src/assure-hydration.ts +5 -1
- package/src/assure.ts +99 -11
- package/src/capabilities-tool.ts +188 -53
- package/src/check-diagnostics.ts +10 -0
- package/src/check-scan.ts +65 -12
- package/src/check.ts +122 -51
- package/src/cli.ts +127 -45
- package/src/client-module.ts +45 -9
- package/src/command-catalog.ts +92 -28
- package/src/dev-bun-config.ts +13 -9
- package/src/dev-feed-tool.ts +146 -1
- package/src/doctor.ts +102 -66
- package/src/fix-recipes.ts +101 -10
- package/src/i18n-check.ts +254 -18
- package/src/init-agents.ts +225 -44
- package/src/internal/config-paths.ts +154 -0
- package/src/internal/installed-package.ts +15 -0
- package/src/internal/project-specifiers.ts +78 -17
- package/src/internal/source-facts.ts +147 -5
- package/src/internal/typescript-import.ts +5 -3
- package/src/internal/workspace-packages.ts +218 -0
- package/src/introspect.ts +39 -1
- package/src/levels-tool.ts +7 -9
- package/src/load.ts +46 -4
- package/src/lock-links.ts +173 -0
- package/src/mcp-context.ts +5 -18
- package/src/mcp-delegate.ts +22 -10
- package/src/mcp-exec.ts +14 -4
- package/src/mcp-http.ts +1 -1
- package/src/mcp-io.ts +33 -0
- package/src/mcp-path.ts +8 -22
- package/src/mcp-root.ts +14 -8
- package/src/mcp.ts +48 -19
- package/src/migrate-layout.ts +1968 -245
- package/src/output-schemas.ts +179 -23
- package/src/project-path.ts +44 -13
- package/src/project-site.ts +18 -0
- package/src/recipes/4.0.0.ts +2 -0
- package/src/recipes/5.1.0.ts +23 -0
- package/src/recipes/5.2.0.ts +33 -0
- package/src/recipes/index.ts +7 -0
- package/src/release-verification.ts +20 -0
- package/src/review.ts +7 -0
- package/src/rule-explain.ts +75 -0
- package/src/rules/codes.ts +5 -1
- package/src/rules/contract-visibility.ts +118 -20
- package/src/rules/data-guard.ts +40 -0
- package/src/rules/explanations.ts +329 -0
- package/src/rules/legacy.ts +46 -2
- package/src/rules/merge-auth.ts +55 -0
- package/src/rules/pages.ts +486 -25
- package/src/rules/routes.ts +4 -3
- package/src/rules/security.ts +49 -11
- package/src/rules/zones.ts +33 -9
- package/src/stylex-migrate.ts +117 -17
- package/src/test-tool.ts +3 -9
- package/src/typecheck-coverage.ts +51 -6
- package/src/upgrade.ts +312 -19
- package/src/verification-plan.ts +15 -2
- package/src/version-drift.ts +68 -2
- package/src/web-app-options.ts +9 -1
package/src/mcp-path.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs"
|
|
2
|
-
import {
|
|
2
|
+
import { isAbsolute, relative, resolve } from "node:path"
|
|
3
|
+
import { writeTargetOf } from "./project-path.ts"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Resolve an MCP path without allowing lexical or symlink escapes from the selected project.
|
|
6
7
|
*
|
|
7
8
|
* MCP callers are not equivalent to a local CLI user: the selected checkout is their filesystem
|
|
8
9
|
* capability boundary. The nearest-existing-ancestor walk also supports output files that do not
|
|
9
|
-
* exist yet while still canonicalizing every existing path component
|
|
10
|
+
* exist yet while still canonicalizing every existing path component, and a dangling symlink is
|
|
11
|
+
* judged by where it points.
|
|
10
12
|
*/
|
|
11
13
|
export function resolveMcpProjectPath(root: string, value: string): string | null {
|
|
12
14
|
if (value.length === 0 || isAbsolute(value)) return null
|
|
@@ -23,26 +25,10 @@ export function resolveMcpProjectPath(root: string, value: string): string | nul
|
|
|
23
25
|
return null
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const canonicalProbe = realpathSync(probe)
|
|
31
|
-
const canonicalRelative = relative(canonicalRoot, canonicalProbe)
|
|
32
|
-
if (canonicalRelative.startsWith("..") || isAbsolute(canonicalRelative)) return null
|
|
33
|
-
|
|
34
|
-
const candidate = resolve(canonicalProbe, ...missing.reverse())
|
|
35
|
-
const candidateRelative = relative(canonicalRoot, candidate)
|
|
36
|
-
return candidateRelative.startsWith("..") || isAbsolute(candidateRelative) ? null : candidate
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (!(error && typeof error === "object" && (error as { code?: string }).code === "ENOENT"))
|
|
39
|
-
return null
|
|
40
|
-
const parent = resolve(probe, "..")
|
|
41
|
-
if (parent === probe) return null
|
|
42
|
-
missing.push(basename(probe))
|
|
43
|
-
probe = parent
|
|
44
|
-
}
|
|
45
|
-
}
|
|
28
|
+
const candidate = writeTargetOf(target)
|
|
29
|
+
if (candidate === undefined) return null
|
|
30
|
+
const candidateRelative = relative(canonicalRoot, candidate)
|
|
31
|
+
return candidateRelative.startsWith("..") || isAbsolute(candidateRelative) ? null : candidate
|
|
46
32
|
}
|
|
47
33
|
|
|
48
34
|
export function mcpProjectPathError(label: string, value: string): string {
|
package/src/mcp-root.ts
CHANGED
|
@@ -156,13 +156,13 @@ const isFile = (path: string): Promise<boolean> =>
|
|
|
156
156
|
.catch(() => false)
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
160
|
-
* `
|
|
161
|
-
*
|
|
159
|
+
* `dir`'s package-manager workspace members, in declaration order; `null` when `dir` declares no
|
|
160
|
+
* `workspaces`. A member is a directory a pattern matches that holds a `package.json`; `node_modules`
|
|
161
|
+
* is never a member.
|
|
162
162
|
*/
|
|
163
|
-
export async function
|
|
163
|
+
export async function workspaceMemberDirs(dir: string): Promise<string[] | null> {
|
|
164
164
|
const patterns = await workspacePatterns(dir)
|
|
165
|
-
if (patterns === null) return
|
|
165
|
+
if (patterns === null) return null
|
|
166
166
|
const members = new Set<string>()
|
|
167
167
|
const budget = { directories: MAX_WORKSPACE_DIRECTORIES }
|
|
168
168
|
for (const pattern of patterns) {
|
|
@@ -171,8 +171,14 @@ export async function workspaceProjects(dir: string): Promise<string[]> {
|
|
|
171
171
|
members.add(join(dir, member))
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
return [...members]
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The nifra projects among `dir`'s workspace members, in declaration order. */
|
|
178
|
+
export async function workspaceProjects(dir: string): Promise<string[]> {
|
|
174
179
|
const projects: string[] = []
|
|
175
|
-
for (const member of
|
|
180
|
+
for (const member of (await workspaceMemberDirs(dir)) ?? [])
|
|
181
|
+
if (await isNifraProjectDir(member)) projects.push(member)
|
|
176
182
|
return projects
|
|
177
183
|
}
|
|
178
184
|
|
|
@@ -376,7 +382,7 @@ export interface ToolingDrift {
|
|
|
376
382
|
export const driftNote = (drift: ToolingDrift): string =>
|
|
377
383
|
`WARNING: this server runs nifra CLI ${drift.cli}, but the project installs ${drift.package} ${drift.project}. ` +
|
|
378
384
|
"Types, checks, and docs may describe a different version than your code builds with. " +
|
|
379
|
-
`Fix:
|
|
385
|
+
`Fix: point the project's MCP launch at the nifra it installs with \`${syncMcpCommand(drift.cli)}\` (run in the project directory), then restart the agent. ` +
|
|
380
386
|
"If this server is not launched from the project's .mcp.json, run the project's own CLI instead (`bunx --bun nifra mcp` from the project directory, or point the client at ./node_modules/.bin/nifra)."
|
|
381
387
|
|
|
382
388
|
/** Feature-level agreement. Patch drift is not reported: it never changes the surface being described. */
|
|
@@ -434,7 +440,7 @@ export async function installedNifraVersion(
|
|
|
434
440
|
return undefined
|
|
435
441
|
}
|
|
436
442
|
|
|
437
|
-
/** The command that
|
|
443
|
+
/** The command that points a project's MCP launch at the nifra it installs. Named with the running
|
|
438
444
|
* CLI's own exact version: the binary printing this is the one known to have `--sync-mcp`, and it pins
|
|
439
445
|
* to the project's version, not its own. */
|
|
440
446
|
export const syncMcpCommand = (cliVersion: string): string =>
|
package/src/mcp.ts
CHANGED
|
@@ -181,6 +181,13 @@ function appFeatures(cwd: string, surface: IsolatedSurface): McpServerFeatures {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
const ROOTS_REQUEST_ID = "nifra:roots/list"
|
|
184
|
+
/** Messages whose answer reads nothing the app declares: the handshake is never held up by its import. */
|
|
185
|
+
const ANSWERED_WITHOUT_THE_APP: ReadonlySet<string> = new Set([
|
|
186
|
+
"initialize",
|
|
187
|
+
"ping",
|
|
188
|
+
"notifications/initialized",
|
|
189
|
+
"notifications/roots/list_changed",
|
|
190
|
+
])
|
|
184
191
|
const MAX_STDIO_MESSAGE_BYTES = 8 * 1024 * 1024
|
|
185
192
|
const STDIO_ENCODER = new TextEncoder()
|
|
186
193
|
|
|
@@ -207,8 +214,12 @@ async function createProjectContext(root: string): Promise<ProjectContext> {
|
|
|
207
214
|
)
|
|
208
215
|
const allResources: McpResource[] = []
|
|
209
216
|
const allPrompts: McpPrompt[] = []
|
|
210
|
-
|
|
211
|
-
|
|
217
|
+
// Each app loads in its own subprocess, so they load side by side.
|
|
218
|
+
const loaded = await Promise.all(
|
|
219
|
+
apps.map(async (app) => ({ app, surface: await app.surface() })),
|
|
220
|
+
)
|
|
221
|
+
for (const { app, surface } of loaded) {
|
|
222
|
+
const ns = namespaceForApp(app.name, [], appFeatures(app.cwd, surface))
|
|
212
223
|
allResources.push(...(ns.features.resources ?? []))
|
|
213
224
|
allPrompts.push(...(ns.features.prompts ?? []))
|
|
214
225
|
}
|
|
@@ -251,7 +262,9 @@ export async function runMcpServer(
|
|
|
251
262
|
return
|
|
252
263
|
}
|
|
253
264
|
}
|
|
254
|
-
|
|
265
|
+
// Loaded in the background: the app's import can take seconds, and the handshake needs none of it.
|
|
266
|
+
let ctx = createProjectContext(rootState.root)
|
|
267
|
+
ctx.catch(() => {})
|
|
255
268
|
let drift: ToolingDrift | undefined = await detectToolingDrift(rootState.root, version)
|
|
256
269
|
const serverInfo = { name: "nifra", version }
|
|
257
270
|
const state = createMcpProtocolState()
|
|
@@ -286,7 +299,8 @@ export async function runMcpServer(
|
|
|
286
299
|
if (result === undefined) return
|
|
287
300
|
const next = await applyClientRoots(rootState, pathsFromRootsResult(result))
|
|
288
301
|
if (next.root !== rootState.root) {
|
|
289
|
-
ctx =
|
|
302
|
+
ctx = createProjectContext(next.root)
|
|
303
|
+
ctx.catch(() => {})
|
|
290
304
|
drift = await detectToolingDrift(next.root, version)
|
|
291
305
|
}
|
|
292
306
|
rootState = next
|
|
@@ -313,15 +327,38 @@ export async function runMcpServer(
|
|
|
313
327
|
// the code it started with: re-read the installed version per call so no answer is for a stale one.
|
|
314
328
|
if (message.method === "tools/call") drift = await detectToolingDrift(rootState.root, version)
|
|
315
329
|
|
|
330
|
+
const method = message.method ?? ""
|
|
331
|
+
if (ANSWERED_WITHOUT_THE_APP.has(method)) {
|
|
332
|
+
const response = await handleRpc(
|
|
333
|
+
message,
|
|
334
|
+
[],
|
|
335
|
+
serverInfo,
|
|
336
|
+
{
|
|
337
|
+
resources: projectResources(rootState.root, noAppInServer),
|
|
338
|
+
prompts: projectPrompts(),
|
|
339
|
+
instructions: rootInstructions(rootState, drift),
|
|
340
|
+
},
|
|
341
|
+
{ state, sendNotification: send, exposeToolErrors: true },
|
|
342
|
+
)
|
|
343
|
+
if (response) send(response)
|
|
344
|
+
// Ask for the client's workspace roots once the handshake completes, and again whenever the
|
|
345
|
+
// client says they changed. The answer comes back through the interception above.
|
|
346
|
+
if (method.startsWith("notifications/")) requestRoots()
|
|
347
|
+
return
|
|
348
|
+
}
|
|
349
|
+
const project = await ctx
|
|
316
350
|
let activeTools: McpTool[]
|
|
317
|
-
if (
|
|
351
|
+
if (project.apps) {
|
|
352
|
+
const loaded = await Promise.all(
|
|
353
|
+
project.apps.map(async (app) => ({ app, surface: await app.surface() })),
|
|
354
|
+
)
|
|
318
355
|
const allTools: McpTool[] = []
|
|
319
|
-
for (const {
|
|
356
|
+
for (const { app, surface } of loaded) {
|
|
320
357
|
const tools = [
|
|
321
|
-
...refuseVersionSensitive(isolatedProjectTools(
|
|
322
|
-
...
|
|
358
|
+
...refuseVersionSensitive(isolatedProjectTools(app.cwd), drift),
|
|
359
|
+
...surface.tools,
|
|
323
360
|
]
|
|
324
|
-
const ns = namespaceForApp(name, tools, { resources: [], prompts: [] })
|
|
361
|
+
const ns = namespaceForApp(app.name, tools, { resources: [], prompts: [] })
|
|
325
362
|
allTools.push(...ns.tools)
|
|
326
363
|
}
|
|
327
364
|
activeTools = [
|
|
@@ -334,7 +371,7 @@ export async function runMcpServer(
|
|
|
334
371
|
} else {
|
|
335
372
|
activeTools = [
|
|
336
373
|
...refuseVersionSensitive(isolatedProjectTools(rootState.root), drift),
|
|
337
|
-
...(await
|
|
374
|
+
...(await project.surface()).tools,
|
|
338
375
|
]
|
|
339
376
|
}
|
|
340
377
|
const verdict = await rootVerdict(rootState)
|
|
@@ -346,7 +383,7 @@ export async function runMcpServer(
|
|
|
346
383
|
)
|
|
347
384
|
|
|
348
385
|
const features: McpServerFeatures = {
|
|
349
|
-
...
|
|
386
|
+
...project.features,
|
|
350
387
|
instructions: rootInstructions(rootState, drift),
|
|
351
388
|
}
|
|
352
389
|
const response = await handleRpc(message, activeTools, serverInfo, features, {
|
|
@@ -356,14 +393,6 @@ export async function runMcpServer(
|
|
|
356
393
|
exposeToolErrors: true,
|
|
357
394
|
})
|
|
358
395
|
if (response) send(response)
|
|
359
|
-
// Ask for the client's workspace roots once the handshake completes, and again whenever the
|
|
360
|
-
// client says they changed. The answer comes back through the interception above.
|
|
361
|
-
if (
|
|
362
|
-
message.method === "notifications/initialized" ||
|
|
363
|
-
message.method === "notifications/roots/list_changed"
|
|
364
|
-
) {
|
|
365
|
-
requestRoots()
|
|
366
|
-
}
|
|
367
396
|
}
|
|
368
397
|
|
|
369
398
|
const decoder = new TextDecoder()
|