@finedesign/cli 0.1.0 → 0.2.0-rc.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.
@@ -1,5 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { exactVersion } from './data.mjs';
3
4
  import { ToolError } from './errors.mjs';
4
5
 
5
6
  export function resolveVersion(explicit, project = process.cwd()) {
@@ -12,9 +13,18 @@ export function resolveVersion(explicit, project = process.cwd()) {
12
13
  const filename = path.join(directory, 'node_modules', '@fx-ui', 'fine-design', 'package.json');
13
14
  if (fs.existsSync(filename)) {
14
15
  const installed = JSON.parse(fs.readFileSync(filename, 'utf8'));
15
- if (installed.name === '@fx-ui/fine-design' && typeof installed.version === 'string' && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(installed.version)) return installed.version;
16
+ if (installed.name === '@fx-ui/fine-design' && typeof installed.version === 'string' && exactVersion.test(installed.version)) return installed.version;
16
17
  throw new ToolError('VERSION_NOT_DETECTED', 'Installed Fine Design package has no valid exact version.', 3, { suggestions: ['Specify --fd-version with an exact supported version.'] });
17
18
  }
19
+ const selfFilename = path.join(directory, 'package.json');
20
+ if (fs.existsSync(selfFilename) && fs.statSync(selfFilename).isFile()) {
21
+ let selfPkg = null;
22
+ try { selfPkg = JSON.parse(fs.readFileSync(selfFilename, 'utf8')); } catch { selfPkg = null; }
23
+ if (selfPkg?.name === '@fx-ui/fine-design') {
24
+ if (typeof selfPkg.version === 'string' && exactVersion.test(selfPkg.version)) return selfPkg.version;
25
+ throw new ToolError('VERSION_NOT_DETECTED', 'Workspace Fine Design package has no valid exact version.', 3, { suggestions: ['Specify --fd-version with an exact supported version.'] });
26
+ }
27
+ }
18
28
  const parent = path.dirname(directory);
19
29
  if (parent === directory) break;
20
30
  directory = parent;
package/src/mcp.mjs CHANGED
@@ -12,9 +12,9 @@ export async function startMcp() {
12
12
  const packageInfo = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
13
13
  const server = new Server({ name: 'fine-design', version: packageInfo.version }, { capabilities: { tools: {} } });
14
14
  const descriptions = {
15
- search_components: 'Search components; use nextOffset to browse subsequent pages.',
16
- get_component_doc: 'Read component documentation and discover sections and example IDs.',
17
- get_component_example: 'Read example source files, dependencies and binary asset metadata. Set includeAssets to include base64 asset content.'
15
+ search_components: 'Search components, subcomponents and built-in icons; use nextOffset to browse subsequent pages.',
16
+ get_component_doc: 'Read component documentation, or pass summary: true to list section headings and example IDs first.',
17
+ get_component_example: 'Read example source files, dependencies and asset metadata. Set includeAssets to include binary base64 and oversized JSON fixture content.'
18
18
  };
19
19
  server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: Object.entries(schemas).map(([name, schema]) => ({
20
20
  name, description: descriptions[name], inputSchema: z.toJSONSchema(schema, { target: 'draft-07' }),