@svgrid/mcp 3.0.29 → 3.0.31

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/dist/preview.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare const UI_MIME_TYPE = "text/html;profile=mcp-app";
8
8
  * start failing in a way nobody is watching for. `tools/mcp-tools.test.ts` checks these
9
9
  * against the workspace so they cannot quietly rot either.
10
10
  */
11
- export declare const PREVIEW_GRID_WC_VERSION = "3.0.30";
11
+ export declare const PREVIEW_GRID_WC_VERSION = "3.0.32";
12
12
  export declare function previewResource(): {
13
13
  uri: string;
14
14
  name: string;
package/dist/preview.js CHANGED
@@ -27,7 +27,7 @@ export const UI_MIME_TYPE = 'text/html;profile=mcp-app';
27
27
  * start failing in a way nobody is watching for. `tools/mcp-tools.test.ts` checks these
28
28
  * against the workspace so they cannot quietly rot either.
29
29
  */
30
- export const PREVIEW_GRID_WC_VERSION = '3.0.30';
30
+ export const PREVIEW_GRID_WC_VERSION = '3.0.32';
31
31
  const EXT_APPS_VERSION = '1.7.5';
32
32
  const CDN = 'https://cdn.jsdelivr.net/npm';
33
33
  /**
@@ -111,6 +111,16 @@ export declare function blankOut(src: string): string;
111
111
  * small relative to the word so "foo" does not "resolve" to "bar".
112
112
  */
113
113
  export declare function nearest(word: string, candidates: readonly string[]): string | null;
114
+ /**
115
+ * Known names about the same thing as `word`, best first, for when `nearest`
116
+ * found no spelling to offer. `detailRenderer` is no typo of anything, but it
117
+ * shares "detail" with `renderDetailRow` and `isDetailRow`, and that short list
118
+ * is what lets a model pick instead of guessing again.
119
+ *
120
+ * Advice only - never a rename. A shared word must be one that few candidates
121
+ * carry, so `rowFoo` does not come back with every prop that starts with `row`.
122
+ */
123
+ export declare function related(word: string, candidates: readonly string[], limit?: number): string[];
114
124
  /** Run every static rule. Exported for tests and for hosts that skip compiling. */
115
125
  /**
116
126
  * Apply the mechanically-safe renames to the source, returning the corrected
package/dist/validate.js CHANGED
@@ -118,6 +118,12 @@ export function nearest(word, candidates) {
118
118
  // same idea, so the comparison also runs with the verb prefix removed.
119
119
  const core = (s) => s.replace(/^(?:get|set|create|make|build|use|enable|with)/i, '');
120
120
  const lowerCore = core(lower);
121
+ // `rowHeightAuto` for `autoRowHeight`: the same words in another order is as
122
+ // certain as a typo, and edit distance cannot see it.
123
+ const order = (s) => words(s).sort().join(' ');
124
+ const sameWords = candidates.filter((c) => c !== word && order(c) === order(word));
125
+ if (sameWords.length === 1)
126
+ return sameWords[0];
121
127
  const budget = word.length <= 4 ? 1 : word.length <= 8 ? 2 : 3;
122
128
  let best = null;
123
129
  let bestScore = Infinity;
@@ -129,8 +135,103 @@ export function nearest(word, candidates) {
129
135
  best = c;
130
136
  }
131
137
  }
138
+ // Three edits turn `onRowSelected` into `onRowsDelete`, the opposite. When
139
+ // another name shares more of the words, the spelling match is a
140
+ // coincidence, and since a guess here is applied as a rename, offer none.
141
+ if (best) {
142
+ const top = related(word, candidates, 1)[0];
143
+ if (top && top !== best && sharedStems(word, top) > sharedStems(word, best))
144
+ return null;
145
+ }
132
146
  return best;
133
147
  }
148
+ /** `onRowSelectionChange` -> `on row selection change`. */
149
+ function words(name) {
150
+ return name
151
+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')
152
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
153
+ .toLowerCase()
154
+ .split(/[^a-z0-9]+/)
155
+ .filter(Boolean);
156
+ }
157
+ // Words that say how a prop is switched on, not what it is about.
158
+ const FILLER_WORDS = new Set(['enable', 'show', 'allow', 'use', 'is', 'has', 'get', 'set', 'with']);
159
+ const STEM_SUFFIXES = ['ations', 'ation', 'ings', 'ing', 'able', 'ion', 'ed', 'es', 's'];
160
+ const STEM_ALIASES = { pagin: 'pag', paginat: 'pag', renderer: 'render' };
161
+ /** Crude stem, so `sorting`, `sortable` and `sorted` all read as `sort`. */
162
+ function stem(word) {
163
+ let w = STEM_ALIASES[word] ?? word;
164
+ for (const s of STEM_SUFFIXES) {
165
+ if (w.length - s.length >= 3 && w.endsWith(s)) {
166
+ w = w.slice(0, -s.length);
167
+ break;
168
+ }
169
+ }
170
+ if (w.length > 3 && w.endsWith('e'))
171
+ w = w.slice(0, -1);
172
+ return STEM_ALIASES[w] ?? w;
173
+ }
174
+ const stems = (name) => new Set(words(name).filter((w) => !FILLER_WORDS.has(w)).map(stem));
175
+ function sharedStems(a, b) {
176
+ const other = stems(b);
177
+ let n = 0;
178
+ for (const w of stems(a))
179
+ if (other.has(w))
180
+ n++;
181
+ return n;
182
+ }
183
+ /**
184
+ * Known names about the same thing as `word`, best first, for when `nearest`
185
+ * found no spelling to offer. `detailRenderer` is no typo of anything, but it
186
+ * shares "detail" with `renderDetailRow` and `isDetailRow`, and that short list
187
+ * is what lets a model pick instead of guessing again.
188
+ *
189
+ * Advice only - never a rename. A shared word must be one that few candidates
190
+ * carry, so `rowFoo` does not come back with every prop that starts with `row`.
191
+ */
192
+ export function related(word, candidates, limit = 5) {
193
+ const mine = stems(word);
194
+ if (!mine.size)
195
+ return [];
196
+ const sets = candidates.map((c) => ({ name: c, stems: stems(c) }));
197
+ const df = new Map();
198
+ for (const { stems: s } of sets)
199
+ for (const w of s)
200
+ df.set(w, (df.get(w) ?? 0) + 1);
201
+ const distinctive = Math.max(2, Math.floor(candidates.length / 10));
202
+ const scored = [];
203
+ for (const { name, stems: s } of sets) {
204
+ if (name === word)
205
+ continue;
206
+ let score = 0;
207
+ let sharp = false;
208
+ for (const w of mine) {
209
+ if (!s.has(w))
210
+ continue;
211
+ const n = df.get(w);
212
+ score += Math.log(1 + candidates.length / n);
213
+ if (n <= distinctive)
214
+ sharp = true;
215
+ }
216
+ if (!sharp)
217
+ continue;
218
+ // Of two names sharing the same words, the one with fewer others is closer.
219
+ scored.push({ name, score: score - 0.1 * (s.size - 1) });
220
+ }
221
+ return scored
222
+ .sort((a, b) => b.score - a.score || a.name.length - b.name.length)
223
+ .slice(0, limit)
224
+ .map((s) => s.name);
225
+ }
226
+ /** "`a`, `b` (boolean)" - a member's type rides along when it is short enough to help. */
227
+ function listMembers(names, members) {
228
+ return names
229
+ .map((n) => {
230
+ const type = members?.find((m) => m.name === n)?.type.replace(/\s+/g, ' ');
231
+ return type && type.length <= 40 ? `\`${n}\` (${type})` : `\`${n}\``;
232
+ })
233
+ .join(', ');
234
+ }
134
235
  /** Index of the bracket matching the one at `open`, or -1. */
135
236
  function matchBracket(src, open) {
136
237
  const pairs = { '{': '}', '[': ']', '(': ')' };
@@ -549,6 +650,7 @@ function checkGridProps(ctx) {
549
650
  continue;
550
651
  }
551
652
  const guess = nearest(name, known);
653
+ const near = guess ? [] : related(name, known);
552
654
  push(ctx, {
553
655
  rule: 'svgrid/unknown-prop',
554
656
  severity: 'error',
@@ -556,7 +658,9 @@ function checkGridProps(ctx) {
556
658
  message: `\`${name}\` is not a prop of <SvGrid> in @svgrid/grid@${surface.gridVersion}.`,
557
659
  fix: guess
558
660
  ? `Did you mean \`${guess}\`?`
559
- : 'Call svgrid_search with the prop name, or read the reference/SvGrid doc for the prop list.',
661
+ : near.length
662
+ ? `Related props: ${listMembers(near, surface.props)}. If none fits, call svgrid_search with what the prop should do.`
663
+ : 'Call svgrid_search with the prop name, or read the reference/SvGrid doc for the prop list.',
560
664
  rename: guess ? { from: name, to: guess } : undefined,
561
665
  see: 'reference/SvGrid',
562
666
  });
@@ -697,12 +801,15 @@ function checkColumns(ctx) {
697
801
  continue;
698
802
  }
699
803
  const guess = nearest(key, known);
804
+ const near = guess ? [] : related(key, known, 3);
700
805
  push(ctx, {
701
806
  rule: 'svgrid/unknown-column-key',
702
807
  severity: 'error',
703
808
  line,
704
809
  message: `\`${key}\` is not a key of ColumnDef in @svgrid/grid@${surface.gridVersion}.`,
705
- fix: guess ? `Did you mean \`${guess}\`?` : `Valid keys: ${known.join(', ')}.`,
810
+ fix: guess
811
+ ? `Did you mean \`${guess}\`?`
812
+ : `${near.length ? `Related: ${listMembers(near, surface.columnDef)}. ` : ''}Valid keys: ${known.join(', ')}.`,
706
813
  see: 'help/columns/column-definitions',
707
814
  });
708
815
  }
@@ -920,12 +1027,17 @@ function checkEnterpriseUsage(ctx) {
920
1027
  const hint = API_METHOD_HINTS[method];
921
1028
  const spelling = nearest(method, all);
922
1029
  const guess = hint ?? spelling;
1030
+ const near = guess ? [] : related(method, all);
923
1031
  push(ctx, {
924
1032
  rule: 'svgrid/unknown-api-method',
925
1033
  severity: 'error',
926
1034
  line,
927
1035
  message: `The grid API has no \`${method}()\` in @svgrid/grid@${ctx.surface.gridVersion}.`,
928
- fix: guess ? `Use \`${guess}\`.` : 'Call svgrid_get with ref:"api" for the api surface.',
1036
+ fix: guess
1037
+ ? `Use \`${guess}\`.`
1038
+ : near.length
1039
+ ? `Related methods: ${listMembers(near)}. If none fits, call svgrid_get with ref:"api" for the api surface.`
1040
+ : 'Call svgrid_get with ref:"api" for the api surface.',
929
1041
  // Only the spelling guess is a bare identifier. An API_METHOD_HINTS
930
1042
  // value is a call expression - `exportData({ format: "xlsx" })` - and
931
1043
  // substituting that for an identifier would emit `api.exportData({...})(...)`.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "commercial",
6
6
  "url": "https://svgrid.com/pricing"
7
7
  },
8
- "version": "3.0.29",
8
+ "version": "3.0.31",
9
9
  "description": "Model Context Protocol server for SvGrid, the Svelte 5 data grid: checks the code your AI writes against the real API surface, plus version-pinned docs, API reference and 373 demo sources.",
10
10
  "license": "MIT",
11
11
  "author": "jQWidgets <sales@jqwidgets.com>",
@@ -35,7 +35,7 @@
35
35
  "zod": "^3.23.8"
36
36
  },
37
37
  "peerDependencies": {
38
- "@svgrid/enterprise": "^3.1.23"
38
+ "@svgrid/enterprise": "^3.1.25"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@svgrid/enterprise": {
@@ -45,7 +45,7 @@
45
45
  "devDependencies": {
46
46
  "@types/node": "^22.10.7",
47
47
  "typescript": "6.0.3",
48
- "@svgrid/enterprise": "^3.1.23"
48
+ "@svgrid/enterprise": "^3.1.25"
49
49
  },
50
50
  "engines": {
51
51
  "node": ">=18"
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "com.svgrid/svgrid",
4
4
  "title": "SvGrid",
5
5
  "description": "Checks AI-written SvGrid code against the real API, plus version-pinned Svelte 5 grid docs.",
6
- "version": "3.0.29",
6
+ "version": "3.0.31",
7
7
  "websiteUrl": "https://svgrid.com/docs/help/mcp-server/",
8
8
  "repository": {
9
9
  "url": "https://github.com/sv-grid/sv-grid",
@@ -15,7 +15,7 @@
15
15
  "registryType": "npm",
16
16
  "registryBaseUrl": "https://registry.npmjs.org",
17
17
  "identifier": "@svgrid/mcp",
18
- "version": "3.0.29",
18
+ "version": "3.0.31",
19
19
  "runtimeHint": "npx",
20
20
  "transport": {
21
21
  "type": "stdio"