@svgrid/mcp 3.0.44 → 3.0.46

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/README.md CHANGED
@@ -85,9 +85,10 @@ What it checks:
85
85
  - **Svelte 5 rules.** `export let` and `$:` in a runes file (compiler errors),
86
86
  `on:` / `<slot>` / `createEventDispatcher` (deprecations), and a plain `let`
87
87
  array that gets mutated and silently never re-renders.
88
- - **The file, compiled.** When a Svelte compiler is reachable - the user's
89
- project copy first, then the one shipped here - real parse errors come back
90
- too. The result says which of the two ran in its `compiler` field, so
88
+ - **The file, compiled.** When a Svelte compiler is reachable - the copy in
89
+ the project the server starts in, or one installed beside `@svgrid/mcp` -
90
+ real parse errors come back too. Svelte is an optional peer, so a bare
91
+ `npx -y @svgrid/mcp` does not download it and starts in a few seconds. The result says which of the two ran in its `compiler` field, so
91
92
  "no errors" is never mistaken for "this compiles".
92
93
 
93
94
  It is tuned to shut up when the code is right: it reports **nothing** across
@@ -102,9 +103,9 @@ The `studio_*` tools let an agent build and edit the **same validated project mo
102
103
  server's env. Tools that need a licence to be useful should not cost every
103
104
  other user context on every request.
104
105
 
105
- These tools and `svgrid_scaffold` run on `@svgrid/enterprise`, an optional
106
- peer that `npx -y @svgrid/mcp` does not install (it would double the cold
107
- start). Install both in the project and run the local server:
106
+ These tools and `svgrid_scaffold` run on `@svgrid/enterprise`, which
107
+ `npx -y @svgrid/mcp` does not install (it would double the cold start).
108
+ Install both in the project and run the local server:
108
109
 
109
110
  ```bash
110
111
  npm i -D @svgrid/mcp @svgrid/enterprise
@@ -1,2 +1,5 @@
1
1
  import type { CompileFn } from './validate.js';
2
+ import { type CompileApi } from './compile-core.js';
3
+ /** The Svelte compiler of the project in `dir`; throws when it has none. */
4
+ export declare function projectCompiler(dir: string): Promise<CompileApi>;
2
5
  export declare const compileWithSvelte: CompileFn;
@@ -13,18 +13,27 @@ import { join } from 'node:path';
13
13
  import { compileDiagnostics } from './compile-core.js';
14
14
  /**
15
15
  * Prefer the Svelte the USER's project is on, so the check matches what their
16
- * build will do; fall back to the copy that ships with this package. Resolved
17
- * once and reused - the compiler is not cheap to load.
16
+ * build will do; fall back to one installed beside this package. Svelte is an
17
+ * optional peer, not a dependency: it and its dependencies were most of a cold
18
+ * `npx -y @svgrid/mcp` install, and a slow one ran past the 30 s a client
19
+ * waits to connect. Resolved once and reused - the compiler is not cheap to
20
+ * load.
18
21
  */
19
22
  let cached;
23
+ /** The Svelte compiler of the project in `dir`; throws when it has none. */
24
+ export async function projectCompiler(dir) {
25
+ // require.resolve picks svelte's `require` entry, a CommonJS file, so the
26
+ // import puts `compile` on `default`. Reading only the top level missed it,
27
+ // and the project's Svelte was never used.
28
+ const require = createRequire(join(dir, 'package.json'));
29
+ const mod = (await import(pathToFileURL(require.resolve('svelte/compiler')).href));
30
+ return typeof mod.compile === 'function' ? mod : mod.default;
31
+ }
20
32
  async function loadCompiler() {
21
33
  if (cached !== undefined)
22
34
  return cached;
23
35
  const attempts = [
24
- async () => {
25
- const require = createRequire(join(process.cwd(), 'package.json'));
26
- return (await import(pathToFileURL(require.resolve('svelte/compiler')).href));
27
- },
36
+ () => projectCompiler(process.cwd()),
28
37
  async () => (await import('svelte/compiler')),
29
38
  ];
30
39
  for (const attempt of attempts) {