bestax-mcp 1.18.37 → 1.18.39
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/data/catalog.json +1 -1
- package/data/components/Dropdown.json +2 -2
- package/data/components/Media.json +3 -3
- package/dist/format.d.ts +13 -1
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +15 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +94 -34
- package/package.json +2 -2
package/data/catalog.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"code": "<Dropdown label=\"Dropdown Menu\" active>\n <Dropdown.Item>First Item</Dropdown.Item>\n <Dropdown.Item>Second Item</Dropdown.Item>\n <Dropdown.Divider />\n <Dropdown.Item>Third Item</Dropdown.Item>\n</Dropdown>"
|
|
43
43
|
}
|
|
44
44
|
],
|
|
45
|
-
"accessibility": "- The
|
|
45
|
+
"accessibility": "- The trigger is a `<button>` with `aria-haspopup=\"true\"` and `aria-expanded`, and its\n `aria-controls` points at the menu, with or without an `id` on the Dropdown.\n- The menu is `role=\"menu\"`, and `aria-labelledby` names it after the trigger, so a screen\n reader moving into it hears the trigger's label. That makes the `label` the menu's name too,\n so a trigger that shows only an icon needs text a screen reader can read, as in the\n [split button](https://bestax.io/docs/api/components/dropdown#split-button).\n- Each item is `role=\"menuitem\"`. An item given `role=\"menuitemcheckbox\"` or\n `role=\"menuitemradio\"` stays in the arrow-key order.\n- A click between items, on a divider say, focuses the menu itself, so the arrow keys still\n reach the items from there.\n- `Dropdown.Item as=\"button\"` defaults to `type=\"button\"`, so a menu item inside a form doesn't\n submit it. Pass `type=\"submit\"` or `type=\"reset\"` and yours is used instead; any other value\n renders `type=\"button\"`.\n- Pressing outside an open menu closes it.\n\nThe keyboard follows the [WAI-ARIA Menu Button pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/).\nUnlike the pattern's menu items, each item is also a tab stop, so <kbd>Tab</kbd> from the\ntrigger of a `hoverable` menu the pointer holds open goes through its items.\n\n- On the trigger: <kbd>ArrowDown</kbd> or <kbd>Enter</kbd>/<kbd>Space</kbd> open the menu and\n focus the first item; <kbd>ArrowUp</kbd> opens the menu and focuses the last item;\n <kbd>Escape</kbd> closes an open menu. On the trigger of a menu that's already open,\n <kbd>ArrowDown</kbd>/<kbd>ArrowUp</kbd> focus the first/last item and\n <kbd>Enter</kbd>/<kbd>Space</kbd> close it.\n- Inside the menu: <kbd>ArrowDown</kbd>/<kbd>ArrowUp</kbd> move between items and wrap around;\n <kbd>Home</kbd>/<kbd>End</kbd> jump to the first/last item; <kbd>Escape</kbd> closes the menu\n and returns focus to the trigger; <kbd>Tab</kbd> closes the menu and lets focus continue\n naturally.\n- Typing a letter moves to the next item whose text starts with it, and typing it again cycles\n through the items that do. Letters typed in quick succession add up to one search, so\n <kbd>d</kbd> then <kbd>u</kbd> lands on \"Duplicate\" past \"Download\". Text hidden with\n `aria-hidden`, such as an icon's ligature name, doesn't count, and a new search starts each\n time the menu opens. Typing searches once focus is in the menu, where the trigger's keys\n above put it. A letter typed on the trigger itself does nothing.\n- On an item: <kbd>Enter</kbd> or <kbd>Space</kbd> activates it the way a click does, so its\n `onClick` runs and the menu closes unless `closeOnClick` is `false`. That includes the\n default anchor without an `href` and `as=\"div\"`, which the browser would not activate on\n its own. Holding the key down runs it once.\n- When running an item closes the menu, by click or by key, focus goes back to the trigger,\n as it does for <kbd>Escape</kbd>. An item whose `onClick` moves focus somewhere else keeps\n it there.\n- Disabled items (a `Dropdown.Item` rendered with a native `disabled` attribute or\n `aria-disabled=\"true\"`) and dividers are skipped by the arrow keys and by typing.\n- For a panel built around fields, [`Popover`](https://bestax.io/docs/api/components/popover) fits better: `role=\"menu\"` owns\n menu items, and the default `closeOnClick` shuts the menu on a click anywhere in it, a field\n included. Anything focusable you put in the menu anyway that isn't an item (a field, a\n button, a checkbox, a link without a menu-item role) keeps its own keys, so its arrows,\n <kbd>Home</kbd>, <kbd>End</kbd> and letters don't move to the items. A field needs\n `closeOnClick={false}`, or a click into it closes the menu. <kbd>Escape</kbd> and\n <kbd>Tab</kbd> still close the menu from any of them, except an <kbd>Escape</kbd> the\n control used itself by calling `preventDefault()` in its `onKeyDown`, such as an Autocomplete\n closing its list or a date picker closing its calendar.\n The next <kbd>Escape</kbd> closes the menu.",
|
|
46
46
|
"related": ["Button", "ContextMenu", "Popover", "useBulmaClasses"],
|
|
47
47
|
"storybook": "https://bestax.io/storybook/?path=/story/components-dropdown--default",
|
|
48
48
|
"summary": "The `Dropdown` component provides Bulma's versatile dropdown menu for your Bulma React UI. Down, Enter and Space on the trigger open the menu on its first enabled item, and Up opens it on its last. On the trigger of a menu that's already open, Down and Up move focus to its first and last item. In the menu, the arrow keys, Home and End move between the items, and Enter and Space run the focused one the way a click does. Typing a letter moves to the next item whose text starts with it, skipping disabled ones, and letters typed in quick succession add up to one search. Typing searches once focus is in the menu, so a letter typed on the trigger does nothing. Escape closes the menu and focuses the trigger, and Tab closes it and lets focus move on. Anything focusable in the menu that isn't an item, such as a field, keeps its own keys apart from Escape and Tab, though an Escape it calls `preventDefault()` on in its own `onKeyDown` stays its own and leaves the menu open. For a panel built around fields, use `Popover`.",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"name": "id",
|
|
159
159
|
"type": "string",
|
|
160
160
|
"default": null,
|
|
161
|
-
"description": "Root element ID
|
|
161
|
+
"description": "Root element ID. The trigger gets `<id>-trigger` and the menu `<id>-menu`, which the trigger's `aria-controls` and the menu's `aria-labelledby` point at. Without one, both ids come from `useId`.",
|
|
162
162
|
"required": false,
|
|
163
163
|
"inherited": false,
|
|
164
164
|
"deprecated": false
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
9
|
"title": "Default Media",
|
|
10
|
-
"code": "<Media>\n <Media.Left>\n <Image\n as=\"p\"\n size=\"64x64\"\n src=\"https://bulma.io/assets/images/placeholders/128x128.png\"\n alt=\"\"\n />\n </Media.Left>\n <Media.Content>\n <Content>\n <Paragraph>\n <Strong>Alexander Hamilton</Strong> <small>@hamilton</small>{' '}\n <small>31m</small>\n <br />\n If men were angels, no government would be necessary. If angels were to\n govern men, neither external nor internal controls on government would\n be necessary.\n </Paragraph>\n </Content>\n <Level isMobile>\n <Level.Left>\n <Level.Item as=\"a\">\n <Icon name=\"reply\" variant=\"solid\" size=\"small\" />\n </Level.Item>\n <Level.Item as=\"a\">\n <Icon name=\"retweet\" variant=\"solid\" size=\"small\" />\n </Level.Item>\n <Level.Item as=\"a\">\n <Icon name=\"heart\" variant=\"solid\" size=\"small\" />\n </Level.Item>\n </Level.Left>\n </Level>\n </Media.Content>\n <Media.Right>\n <Delete aria-label=\"delete\" />\n </Media.Right>\n</Media>"
|
|
10
|
+
"code": "<Media>\n <Media.Left>\n <Image\n as=\"p\"\n size=\"64x64\"\n src=\"https://bulma.io/assets/images/placeholders/128x128.png\"\n alt=\"\"\n />\n </Media.Left>\n <Media.Content>\n <Content>\n <Paragraph>\n <Strong>Alexander Hamilton</Strong> <small>@hamilton</small>{' '}\n <small>31m</small>\n <br />\n If men were angels, no government would be necessary. If angels were to\n govern men, neither external nor internal controls on government would\n be necessary.\n </Paragraph>\n </Content>\n <Level as=\"div\" isMobile>\n <Level.Left>\n <Level.Item as=\"a\">\n <Icon name=\"reply\" variant=\"solid\" size=\"small\" />\n </Level.Item>\n <Level.Item as=\"a\">\n <Icon name=\"retweet\" variant=\"solid\" size=\"small\" />\n </Level.Item>\n <Level.Item as=\"a\">\n <Icon name=\"heart\" variant=\"solid\" size=\"small\" />\n </Level.Item>\n </Level.Left>\n </Level>\n </Media.Content>\n <Media.Right>\n <Delete aria-label=\"delete\" />\n </Media.Right>\n</Media>"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"title": "Media With Inputs",
|
|
14
|
-
"code": "<Media>\n <Media.Left>\n <Image\n as=\"p\"\n size=\"64x64\"\n src=\"https://bulma.io/assets/images/placeholders/128x128.png\"\n alt=\"\"\n />\n </Media.Left>\n <Media.Content>\n <Field>\n <Control as=\"p\">\n <TextArea placeholder=\"Add a comment...\" />\n </Control>\n </Field>\n <Level>\n <Level.Left>\n <Level.Item>\n <Button as=\"a\" color=\"info\">\n Submit\n </Button>\n </Level.Item>\n </Level.Left>\n <Level.Right>\n <Level.Item>\n <Checkbox>Press enter to submit</Checkbox>\n </Level.Item>\n </Level.Right>\n </Level>\n </Media.Content>\n</Media>"
|
|
14
|
+
"code": "<Media>\n <Media.Left>\n <Image\n as=\"p\"\n size=\"64x64\"\n src=\"https://bulma.io/assets/images/placeholders/128x128.png\"\n alt=\"\"\n />\n </Media.Left>\n <Media.Content>\n <Field>\n <Control as=\"p\">\n <TextArea placeholder=\"Add a comment...\" />\n </Control>\n </Field>\n <Level as=\"div\">\n <Level.Left>\n <Level.Item>\n <Button as=\"a\" color=\"info\">\n Submit\n </Button>\n </Level.Item>\n </Level.Left>\n <Level.Right>\n <Level.Item>\n <Checkbox>Press enter to submit</Checkbox>\n </Level.Item>\n </Level.Right>\n </Level>\n </Media.Content>\n</Media>"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"title": "Nested Media",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"code": "<Media>\n <Media.Left>\n <Image\n as=\"p\"\n size=\"64x64\"\n src=\"https://bulma.io/assets/images/placeholders/128x128.png\"\n alt=\"\"\n />\n </Media.Left>\n <Media.Content>\n <Content>\n <p>\n <strong>John Smith</strong> <small>@johnsmith</small>\n <br />\n Composed entirely from the single Media import via dot notation.\n </p>\n </Content>\n </Media.Content>\n <Media.Right>\n <Button as=\"a\" size=\"small\">\n Reply\n </Button>\n </Media.Right>\n</Media>"
|
|
27
27
|
}
|
|
28
28
|
],
|
|
29
|
-
"accessibility": "- The Media root renders as a semantic `<article>` by default. Use `as=\"div\"` for a generic container.\n- The left section is commonly used for avatars (as `<figure>`) and is screen-reader accessible.\n- Use clear and descriptive text in content and actions for best accessibility.\n\n:::note\nWhen using only icons or controls, provide `aria-label` or screen-reader-only content as appropriate.\n:::",
|
|
29
|
+
"accessibility": "- The Media root renders as a semantic `<article>` by default. Use `as=\"div\"` for a generic container.\n- The left section is commonly used for avatars (as `<figure>`) and is screen-reader accessible.\n- Use clear and descriptive text in content and actions for best accessibility.\n- The `Level` rows in these examples hold actions, not navigation, so they pass `as=\"div\"` rather than render Level's default `<nav>`, a navigation landmark.\n\n:::note\nWhen using only icons or controls, provide `aria-label` or screen-reader-only content as appropriate.\n:::",
|
|
30
30
|
"related": [
|
|
31
31
|
"Button",
|
|
32
32
|
"Checkbox",
|
package/dist/format.d.ts
CHANGED
|
@@ -94,11 +94,23 @@ export declare function referencePointer(record: ComponentRecord): string;
|
|
|
94
94
|
* `Navbar.Brand` with Navbar's own table and no word about the switch (#935).
|
|
95
95
|
*/
|
|
96
96
|
export interface PartFocus {
|
|
97
|
-
/** The dot-path as
|
|
97
|
+
/** The dot-path, as the record it names a part of spells it. */
|
|
98
98
|
wanted: string;
|
|
99
99
|
/** The part it names, or null when it names none. */
|
|
100
100
|
part: Part | null;
|
|
101
|
+
/**
|
|
102
|
+
* The dot-path as asked, when it ran through a static that is a component
|
|
103
|
+
* of its own: `Stats.Stat.Label`, for `Stat.Label` (#1480).
|
|
104
|
+
*/
|
|
105
|
+
asked?: string;
|
|
101
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* What a dot-path that ran through a static that is a component of its own
|
|
109
|
+
* names: `Stats.Stat` is `Stat`, so `Stats.Stat.Label` is `Stat.Label`. Each
|
|
110
|
+
* step keeps the rest of the path, so the static is the path as asked less
|
|
111
|
+
* the segments after the component's name.
|
|
112
|
+
*/
|
|
113
|
+
export declare function throughLine(asked: string, path: string): string;
|
|
102
114
|
/**
|
|
103
115
|
* The import a part is used through: its record's, or one of its own for a
|
|
104
116
|
* standalone export that import leaves out (`Input`'s names no `InputBase`).
|
package/dist/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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AI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;;;;;EAM3D;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM;;;;;;EAK1C"}
|
package/dist/format.js
CHANGED
|
@@ -307,6 +307,18 @@ export function referencePointer(record) {
|
|
|
307
307
|
`\`get_component({ name: "${record.name}", include: ["reference"] })\` ` +
|
|
308
308
|
`returns all of it (${referenceOf(record).length.toLocaleString('en-US')} characters).`);
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* What a dot-path that ran through a static that is a component of its own
|
|
312
|
+
* names: `Stats.Stat` is `Stat`, so `Stats.Stat.Label` is `Stat.Label`. Each
|
|
313
|
+
* step keeps the rest of the path, so the static is the path as asked less
|
|
314
|
+
* the segments after the component's name.
|
|
315
|
+
*/
|
|
316
|
+
export function throughLine(asked, path) {
|
|
317
|
+
const [component, ...rest] = path.split('.');
|
|
318
|
+
const segments = asked.split('.');
|
|
319
|
+
const via = segments.slice(0, segments.length - rest.length).join('.');
|
|
320
|
+
return `\`${via}\` is \`${component}\`, so \`${asked}\` is \`${path}\`.`;
|
|
321
|
+
}
|
|
310
322
|
/**
|
|
311
323
|
* The import a part is used through: its record's, or one of its own for a
|
|
312
324
|
* standalone export that import leaves out (`Input`'s names no `InputBase`).
|
|
@@ -348,6 +360,9 @@ export function partLists(record) {
|
|
|
348
360
|
export function renderComponent(record, include, focus, { hasEntry } = {}) {
|
|
349
361
|
const part = focus?.part && focus.part !== record.parts[0] ? focus.part : null;
|
|
350
362
|
const out = [`# ${part ? part.path : record.name}`];
|
|
363
|
+
if (focus?.asked) {
|
|
364
|
+
out.push(throughLine(focus.asked, focus.part?.path ?? focus.wanted));
|
|
365
|
+
}
|
|
351
366
|
if (part?.standalone) {
|
|
352
367
|
out.push(`${standaloneLine(part, record.name)} The props are its own; any ` +
|
|
353
368
|
`examples, CSS variables and notes are \`${record.name}\`'s, and ` +
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,SAAS,EAEV,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,SAAS,EAEV,MAAM,yCAAyC,CAAC;AA0OjD,MAAM,WAAW,mBAAmB;IAClC,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAsB,YAAY,CAChC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,SAAS,CAAC,CA06BpB"}
|
package/dist/server.js
CHANGED
|
@@ -24,7 +24,7 @@ import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
|
24
24
|
import { z } from 'zod';
|
|
25
25
|
import { classTokens, lookupClasses, renderLookup } from './bulma-classes.js';
|
|
26
26
|
import { documentedExport, dotPath, loadBulmaClasses, loadCatalog, loadComponent, loadServerVersion, loadSkills, loadSkillFile, resolveName, } from './data.js';
|
|
27
|
-
import { errorResult, HELPER_PROPS_PAGE, partLists, renderCatalog, renderComponent, renderCssVarsAnswer, renderExamples, renderHelperApi, renderPart, renderSkills, referenceOf, referencePointer, table, textResult, } from './format.js';
|
|
27
|
+
import { errorResult, HELPER_PROPS_PAGE, partLists, renderCatalog, renderComponent, renderCssVarsAnswer, renderExamples, renderHelperApi, renderPart, renderSkills, referenceOf, referencePointer, table, textResult, throughLine, } from './format.js';
|
|
28
28
|
import { GROUP_NAMES, renderHelperDefault, renderHelperGroup, resolveGroup, } from './helper-props.js';
|
|
29
29
|
import { searchAll, skillSections, suggest, usesExport, } from './search.js';
|
|
30
30
|
import { missingInstallNote, resolveVersions, versionNote, } from './version.js';
|
|
@@ -107,15 +107,51 @@ const notFoundError = (message) => new McpError(ErrorCode.InvalidParams, message
|
|
|
107
107
|
async function wantedPath(input) {
|
|
108
108
|
return dotPath(input) ?? (await documentedExport(input))?.entry.path ?? null;
|
|
109
109
|
}
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
/** The part a dot-path names in a record, as spelled there or in any letter case. */
|
|
111
|
+
function findPart(record, path) {
|
|
112
|
+
return (record.parts.find(p => p.path === path) ??
|
|
113
|
+
record.parts.find(p => p.path.toLowerCase() === path.toLowerCase()));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The record a dot-path names a part of, and the path as that record spells it.
|
|
117
|
+
* A static that is a component with an entry of its own hands the rest of the
|
|
118
|
+
* path to that component's record: `Stats.Stat` is `Stat`, so `Stats.Stat.Label`
|
|
119
|
+
* is `Stat.Label` (#1480). Only a part's `component` is followed, so the rest of
|
|
120
|
+
* a path through `Combobox.Menu`, which is no export of its own, stays
|
|
121
|
+
* Combobox's rather than going to `Menu`, another component. A path the record
|
|
122
|
+
* names a part for as it stands (`Card.Header.Title`) is never followed.
|
|
123
|
+
*/
|
|
124
|
+
async function followPath(record, wanted) {
|
|
125
|
+
if (findPart(record, wanted))
|
|
126
|
+
return { record, wanted };
|
|
127
|
+
const { components } = await loadCatalog();
|
|
128
|
+
const segments = wanted.split('.');
|
|
129
|
+
// The longest prefix first, so a static inside another static wins. Each
|
|
130
|
+
// step leaves a shorter path than it took, so the walk ends.
|
|
131
|
+
for (let i = segments.length - 1; i >= 2; i--) {
|
|
132
|
+
const via = findPart(record, segments.slice(0, i).join('.'))?.component;
|
|
133
|
+
if (via && components.some(c => c.name === via)) {
|
|
134
|
+
return followPath(await loadComponent(via), [via, ...segments.slice(i)].join('.'));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { record, wanted };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* What a name names: the record whose part it is, with that part, or the record
|
|
141
|
+
* as resolved and no focus for a name that asks for none.
|
|
142
|
+
*/
|
|
143
|
+
async function focusOn(record, input) {
|
|
144
|
+
const asked = await wantedPath(input);
|
|
145
|
+
if (!asked)
|
|
146
|
+
return { record };
|
|
147
|
+
const followed = await followPath(record, asked);
|
|
148
|
+
const focus = {
|
|
149
|
+
wanted: followed.wanted,
|
|
150
|
+
part: findPart(followed.record, followed.wanted) ?? null,
|
|
151
|
+
};
|
|
152
|
+
if (followed.wanted !== asked)
|
|
153
|
+
focus.asked = asked;
|
|
154
|
+
return { record: followed.record, focus };
|
|
119
155
|
}
|
|
120
156
|
/** Load every component record. Only `search_bestax` needs this much. */
|
|
121
157
|
async function allComponents() {
|
|
@@ -383,8 +419,8 @@ export async function createServer(options = {}) {
|
|
|
383
419
|
const resolved = await resolveName(name);
|
|
384
420
|
if (!resolved)
|
|
385
421
|
return notFound(name);
|
|
386
|
-
const record = await loadComponent(resolved);
|
|
387
|
-
return textResult(renderComponent(record, include ?? ['props'],
|
|
422
|
+
const { record, focus } = await focusOn(await loadComponent(resolved), name);
|
|
423
|
+
return textResult(renderComponent(record, include ?? ['props'], focus, { hasEntry }), note());
|
|
388
424
|
});
|
|
389
425
|
server.registerTool('get_props', {
|
|
390
426
|
title: 'Get props',
|
|
@@ -407,27 +443,31 @@ export async function createServer(options = {}) {
|
|
|
407
443
|
const resolved = await resolveName(component);
|
|
408
444
|
if (!resolved)
|
|
409
445
|
return notFound(component);
|
|
410
|
-
const
|
|
411
|
-
if (
|
|
446
|
+
const named = await loadComponent(resolved);
|
|
447
|
+
if (named.kind === 'helper') {
|
|
412
448
|
// The signature itself rather than a pointer at a tool that has it, so the
|
|
413
449
|
// question is answered on this call.
|
|
414
|
-
return textResult(`# ${
|
|
450
|
+
return textResult(`# ${named.name}\n\n${renderHelperApi(named)}`, note());
|
|
415
451
|
}
|
|
416
452
|
// A dot-path given as `path`, or folded into `component` ("Navbar.Brand"), or
|
|
417
453
|
// the part an export documented with this record is ("InputBase").
|
|
418
|
-
const
|
|
454
|
+
const asked = path ??
|
|
419
455
|
(component.includes('.') ? component : await wantedPath(component));
|
|
420
|
-
if (!
|
|
456
|
+
if (!asked) {
|
|
421
457
|
const body = [
|
|
422
|
-
renderPart(
|
|
423
|
-
...partLists(
|
|
458
|
+
renderPart(named.parts[0], { heading: false }),
|
|
459
|
+
...partLists(named),
|
|
424
460
|
];
|
|
425
|
-
if (
|
|
426
|
-
body.push(referencePointer(
|
|
427
|
-
return textResult(`# ${
|
|
461
|
+
if (named.doc)
|
|
462
|
+
body.push(referencePointer(named));
|
|
463
|
+
return textResult(`# ${named.name}\n\n${body.join('\n\n')}`, note());
|
|
428
464
|
}
|
|
429
|
-
|
|
430
|
-
|
|
465
|
+
// A path through a static that is a component of its own names a part of
|
|
466
|
+
// that component's record, and the answer says which (#1480).
|
|
467
|
+
const { record, wanted } = await followPath(named, asked);
|
|
468
|
+
const part = findPart(record, wanted);
|
|
469
|
+
const through = wanted === asked ? '' : throughLine(asked, part?.path ?? wanted);
|
|
470
|
+
const lead = through && `${through} `;
|
|
431
471
|
if (!part) {
|
|
432
472
|
// `path` reads like it could take a prop ("Button.isLoading"), and the old
|
|
433
473
|
// answer listed the parts without saying a prop is the wrong thing to pass.
|
|
@@ -435,13 +475,13 @@ export async function createServer(options = {}) {
|
|
|
435
475
|
const [nearPart] = suggest(wanted, subs, 1);
|
|
436
476
|
// `Carousel.Item` for `CarouselItem`: no dot-path names a separate export.
|
|
437
477
|
if (record.parts.find(p => p.path === nearPart)?.standalone) {
|
|
438
|
-
return errorResult(`${record.name} has no "${wanted}". Did you mean "${nearPart}"? It is ` +
|
|
478
|
+
return errorResult(`${lead}${record.name} has no "${wanted}". Did you mean "${nearPart}"? It is ` +
|
|
439
479
|
`a separate export, not a dot-path, so it is written <${nearPart}>, ` +
|
|
440
480
|
`and its props are in get_props({ component: "${nearPart}" }).`);
|
|
441
481
|
}
|
|
442
482
|
const tail = wanted.split('.').pop() ?? wanted;
|
|
443
483
|
const [prop] = suggest(tail, [...new Set(record.parts.flatMap(p => p.props.map(r => r.name)))], 1);
|
|
444
|
-
return errorResult(
|
|
484
|
+
return errorResult(`${lead}"${wanted}" is not a part of ${record.name}. ` +
|
|
445
485
|
(nearPart ? `Did you mean "${nearPart}"? ` : '') +
|
|
446
486
|
`\`path\` names a subcomponent, such as "Navbar.Brand", not a prop. ` +
|
|
447
487
|
(subs.length
|
|
@@ -452,7 +492,8 @@ export async function createServer(options = {}) {
|
|
|
452
492
|
`get_props({ component: "${record.name}" }).`
|
|
453
493
|
: `Its props are in get_props({ component: "${record.name}" }).`));
|
|
454
494
|
}
|
|
455
|
-
return textResult(
|
|
495
|
+
return textResult((through && `${through}\n\n`) +
|
|
496
|
+
renderPart(part, { owner: record.name, hasEntry }), note());
|
|
456
497
|
});
|
|
457
498
|
server.registerTool('get_examples', {
|
|
458
499
|
title: 'Get usage examples',
|
|
@@ -543,7 +584,13 @@ export async function createServer(options = {}) {
|
|
|
543
584
|
const resolved = await resolveName(component);
|
|
544
585
|
if (!resolved)
|
|
545
586
|
return notFound(component);
|
|
546
|
-
const
|
|
587
|
+
const named = await loadComponent(resolved);
|
|
588
|
+
// A part that is a component of its own has that component's variables,
|
|
589
|
+
// not its family's: `Buttons.Button` is `Button`, and `Stats.Stat.Label`
|
|
590
|
+
// is a part of `Stat` (#1480).
|
|
591
|
+
const { record: owner, focus } = await focusOn(named, component);
|
|
592
|
+
const own = focus?.part?.component;
|
|
593
|
+
const record = own && hasEntry(own) ? await loadComponent(own) : owner;
|
|
547
594
|
const vars = query
|
|
548
595
|
? record.cssVars.filter(v => v.css.toLowerCase().includes(query.toLowerCase()))
|
|
549
596
|
: record.cssVars;
|
|
@@ -564,10 +611,21 @@ export async function createServer(options = {}) {
|
|
|
564
611
|
`component.`, note());
|
|
565
612
|
}
|
|
566
613
|
const documented = await documentedExport(component);
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
614
|
+
const lead = [
|
|
615
|
+
documented &&
|
|
616
|
+
`\`${documented.name}\` is documented with \`${record.name}\`, ` +
|
|
617
|
+
`whose variables these are.`,
|
|
618
|
+
focus?.part && record !== owner
|
|
619
|
+
? `\`${focus.asked ?? focus.part.path}\` is \`${record.name}\`.`
|
|
620
|
+
: focus?.asked &&
|
|
621
|
+
throughLine(focus.asked, focus.part?.path ?? focus.wanted),
|
|
622
|
+
record !== named &&
|
|
623
|
+
named.cssVars.length > 0 &&
|
|
624
|
+
`\`${named.name}\`'s own variables are in ` +
|
|
625
|
+
`\`get_css_variables({ component: "${named.name}" })\`.`,
|
|
626
|
+
].filter(Boolean);
|
|
627
|
+
return textResult((lead.length ? `${lead.join(' ')}\n\n` : '') +
|
|
628
|
+
renderCssVarsAnswer(record, vars, query), note());
|
|
571
629
|
}
|
|
572
630
|
if (!query) {
|
|
573
631
|
return errorResult("Pass `component` for one component's variables, or `query` to " +
|
|
@@ -721,13 +779,15 @@ export async function createServer(options = {}) {
|
|
|
721
779
|
? ` Did you mean ${near.map(n => `"${n}"`).join(', ')}?`
|
|
722
780
|
: ''));
|
|
723
781
|
}
|
|
724
|
-
const record = await loadComponent(resolved);
|
|
782
|
+
const { record, focus } = await focusOn(await loadComponent(resolved), String(name));
|
|
725
783
|
return {
|
|
726
784
|
contents: [
|
|
727
785
|
{
|
|
728
786
|
uri: uri.href,
|
|
729
787
|
mimeType: 'text/markdown',
|
|
730
|
-
text: renderComponent(record, RESOURCE_INCLUDES,
|
|
788
|
+
text: renderComponent(record, RESOURCE_INCLUDES, focus, {
|
|
789
|
+
hasEntry,
|
|
790
|
+
}),
|
|
731
791
|
},
|
|
732
792
|
],
|
|
733
793
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bestax-mcp",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.39",
|
|
4
4
|
"mcpName": "io.github.allxsmith/bestax-mcp",
|
|
5
5
|
"description": "MCP server for @allxsmith/bestax-bulma — component props, examples, CSS variables and agent skills, served offline from a version-pinned index",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
44
44
|
"zod": "^4.6.7",
|
|
45
|
-
"@allxsmith/bestax-bulma": "^5.67.
|
|
45
|
+
"@allxsmith/bestax-bulma": "^5.67.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/node": "^26.6.6",
|