@finedesign/cli 0.5.0 → 0.6.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/src/mcp.mjs CHANGED
@@ -8,7 +8,7 @@ import { loadCatalog, readIndex } from './core/data.mjs';
8
8
  import { schemas, validateInput } from './core/contracts.mjs';
9
9
  import { errorResult } from './core/errors.mjs';
10
10
  import { listRuntimes, resolveRuntime } from './core/runtime.mjs';
11
- import { resolveLintVersion } from './core/version.mjs';
11
+ import { resolveLintVersion, resolveMcpVersion } from './core/version.mjs';
12
12
 
13
13
  const aliases = {
14
14
  info: 'get_component_info',
@@ -21,15 +21,15 @@ export async function startMcp() {
21
21
  const packageInfo = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
22
22
  const server = new Server({ name: 'fine-design', version: packageInfo.version }, { capabilities: { tools: {} } });
23
23
  const descriptions = {
24
- search_components: 'Search components, subcomponents and built-in icons; use nextOffset to browse subsequent pages.',
25
- get_component_doc: 'Read component documentation, or pass summary: true to list section headings and example IDs first.',
26
- get_component_info: 'Show component overview, exports, aliases and API/props table sections.',
27
- get_component_tokens: 'Inspect component or global Design Tokens and their default values.',
24
+ search_components: 'Search components, subcomponents and built-in icons. Version is optional and defaults to the project or latest bundled version; use nextOffset to browse subsequent pages.',
25
+ get_component_doc: 'Read component documentation, or pass summary: true to list section headings and example IDs first. Version is optional.',
26
+ get_component_info: 'Show component overview, exports, aliases and API/props table sections. Version is optional.',
27
+ get_component_tokens: 'Inspect component or global Design Tokens and their default values. Version is optional.',
28
28
  diff_catalogs: 'Compare documentation sections, examples, aliases and migration guidance between versions, optionally for one component.',
29
29
  lint_files: 'Scan code for Fine Design API traps. Pass an exact version if it cannot be detected from the targets.',
30
- get_component_example: 'List example IDs and titles, or pass exampleId to read source, dependencies and asset metadata. Set includeAssets with exampleId to include large assets.',
30
+ get_component_example: 'List example IDs and titles, or pass exampleId to read source, dependencies and asset metadata. Version is optional. Set includeAssets with exampleId to include large assets.',
31
31
  list_browser_runtimes: 'Read the one currently hosted UMD version from its online manifest. Requires network access.',
32
- get_browser_runtime: 'Resolve an exact component version to versioned current UMD URLs and SRI loading tags. Requires network access; never falls back to another version.'
32
+ get_browser_runtime: 'Resolve a component version to versioned current UMD URLs and SRI loading tags. Version is optional (defaults to hosted version). Requires network access; never falls back to another version.'
33
33
  };
34
34
  server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: Object.entries(schemas).map(([name, schema]) => ({
35
35
  name, description: descriptions[name], inputSchema: z.toJSONSchema(schema, { target: 'draft-07' }),
@@ -46,9 +46,11 @@ export async function startMcp() {
46
46
  } else if (toolName === 'list_browser_runtimes') {
47
47
  result = await listRuntimes(args.runtimeURL);
48
48
  } else if (toolName === 'get_component_info') {
49
- result = getComponentInfo(loadCatalog(args.version), args);
49
+ const ver = resolveMcpVersion(args.version);
50
+ result = getComponentInfo(loadCatalog(ver), args);
50
51
  } else if (toolName === 'get_component_tokens') {
51
- result = getComponentTokens(loadCatalog(args.version), args);
52
+ const ver = resolveMcpVersion(args.version);
53
+ result = getComponentTokens(loadCatalog(ver), args);
52
54
  } else if (toolName === 'diff_catalogs') {
53
55
  const available = Object.keys(readIndex().versions).sort();
54
56
  const fromVer = args.fromVersion || args.version || available[0];
@@ -60,7 +62,8 @@ export async function startMcp() {
60
62
  const { lintFiles } = await import('./core/lint.mjs');
61
63
  result = lintFiles(loadCatalog(version), targets);
62
64
  } else {
63
- result = queryCatalog(loadCatalog(args.version), toolName, args);
65
+ const ver = resolveMcpVersion(args.version);
66
+ result = queryCatalog(loadCatalog(ver), toolName, { ...args, version: ver });
64
67
  }
65
68
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
66
69
  } catch (error) {