@finedesign/cli 0.3.1 → 0.4.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.
@@ -2,10 +2,10 @@
2
2
  "schemaVersion": 1,
3
3
  "version": "1.25.0",
4
4
  "sourceKind": "repository-snapshot",
5
- "sourceRevision": "39a9955314410af35f1b6096076dcbdf2cc45e9a",
5
+ "sourceRevision": "f3b3f5e7beeab4daa6b50769926aefeb7307397c",
6
6
  "sourceDirty": false,
7
- "contentHash": "30d2e3ea566ad4fd5eed2f53b6cae59de2030db49d2f90eb81b20b3d85e66e4e",
8
- "catalogSha256": "67db385543fa667b5a81b70f4fe35a01a7d8b2bdc8c7a559ced808babd88c7b0",
7
+ "contentHash": "03496e7d7b1884c260875186dc5ab970406b841e2efb4392ad8cbacb61cc7e3b",
8
+ "catalogSha256": "c05adc6576ace248890df647a8ba1c6f3730b1548c37429ce7d7d72cdab77f21",
9
9
  "skillFiles": {
10
10
  "references/component-guide.md": "612948840948e65f250998231eaa16fc41e8e27b9c03b19af32571422ca8185a",
11
11
  "references/docs-slug-map.md": "440ce5cf137fd22eabfcc5b51c3f55b85174aa643773ef0cedd5df542e77bbc2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finedesign/cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Read-only, versioned Fine Design documentation for coding agents",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
package/src/cli.mjs CHANGED
@@ -4,10 +4,9 @@ import { fileURLToPath } from 'node:url';
4
4
  import { parseArgs } from 'node:util';
5
5
  import { queryCatalog, getComponentInfo, getComponentTokens, diffCatalogs } from './core/catalog.mjs';
6
6
  import { loadCatalog, readIndex } from './core/data.mjs';
7
- import { resolveVersion } from './core/version.mjs';
7
+ import { resolveLintVersion, resolveVersion } from './core/version.mjs';
8
8
  import { ToolError, errorResult } from './core/errors.mjs';
9
9
  import { listRuntimes, resolveRuntime } from './core/runtime.mjs';
10
- import { lintFiles } from './core/lint.mjs';
11
10
  import html from './core/html.cjs';
12
11
 
13
12
  const help = `Usage: fine-design <command> [arguments] [options]
@@ -216,8 +215,12 @@ export async function main(argv) {
216
215
  if (values.version || values.section !== undefined || summaryFlag || values.offset !== undefined || values.limit !== undefined || values['include-assets'] !== undefined || !['text', 'json'].includes(format)) {
217
216
  throw new ToolError('INVALID_ARGUMENT', 'Usage: fine-design lint [files-or-dirs...] [--format text|json]', 2);
218
217
  }
219
- const version = resolveVersion(values['fd-version'], values.project);
220
- const report = lintFiles(loadCatalog(version), args.length ? args : [values.project || process.cwd()]);
218
+ const targets = args.length ? args : [values.project || '.'];
219
+ const version = values.project === undefined
220
+ ? resolveLintVersion(values['fd-version'], targets)
221
+ : resolveVersion(values['fd-version'], values.project);
222
+ const { lintFiles } = await import('./core/lint.mjs');
223
+ const report = lintFiles(loadCatalog(version), targets);
221
224
  if (format === 'json') {
222
225
  console.log(JSON.stringify(report));
223
226
  } else if (!report.diagnostics.length) {
@@ -16,6 +16,26 @@ export const schemas = {
16
16
  section: z.string().min(1).max(200).optional(),
17
17
  summary: z.boolean().optional().describe('Return only metadata, section headings and example IDs without full markdown.')
18
18
  }).strict(),
19
+ get_component_info: z.object({
20
+ version,
21
+ component
22
+ }).strict(),
23
+ get_component_tokens: z.object({
24
+ version,
25
+ component: component.optional(),
26
+ query: z.string().max(200).optional()
27
+ }).strict(),
28
+ diff_catalogs: z.object({
29
+ version: version.optional(),
30
+ fromVersion: version.optional(),
31
+ toVersion: version.optional()
32
+ }).strict(),
33
+ lint_files: z.object({
34
+ version: version.optional(),
35
+ paths: z.array(z.string().min(1).max(1024)).optional(),
36
+ files: z.array(z.string().min(1).max(1024)).optional(),
37
+ path: z.string().min(1).max(1024).optional()
38
+ }).strict(),
19
39
  list_browser_runtimes: z.object({ runtimeURL: z.string().max(2048).optional() }).strict(),
20
40
  get_browser_runtime: z.object({ version, runtimeURL: z.string().max(2048).optional() }).strict(),
21
41
  get_component_example: z.object({
@@ -27,7 +47,7 @@ export const schemas = {
27
47
  };
28
48
 
29
49
  export function validateInput(tool, input) {
30
- const result = schemas[tool]?.safeParse(input);
50
+ const result = Object.hasOwn(schemas, tool) ? schemas[tool].safeParse(input) : undefined;
31
51
  if (!result?.success) {
32
52
  throw new ToolError('INVALID_ARGUMENT', result?.error.issues.map((issue) => `${issue.path.join('.') || 'input'}: ${issue.message}`).join('; ') || `Unknown tool: ${tool}`, 2);
33
53
  }
package/src/core/lint.mjs CHANGED
@@ -13,12 +13,13 @@ const KNOWN_TYPE_EXPORTS = new Set([
13
13
  'BadgeProps', 'ButtonGroupProps', 'ButtonHTMLType', 'ButtonProps', 'ButtonSize', 'ButtonType',
14
14
  'CheckGroupDirection', 'CheckGroupProps', 'CheckProps', 'ComboCheckProps',
15
15
  'ComboDropdownAsyncParams', 'ComboDropdownGroupItem', 'ComboDropdownItem', 'ComboProps',
16
- 'DatePickerMode', 'DatePickerProps', 'DatetimeProps', 'DialogAnimation', 'DialogImperativeProps',
17
- 'DialogProps', 'DialogTheme', 'DialogTitleAlign', 'DrawerEdge', 'DrawerPlacement', 'DrawerProps',
18
- 'FileItem', 'FilePreviewActionProps', 'FilePreviewFileActionsRender', 'FilePreviewFileActionsRenderInfo',
19
- 'FilePreviewProps', 'FormItemProps', 'FormLayout', 'FormProps', 'IRuleDescriptor',
20
- 'InputCountConfig', 'InputCountInfo', 'InputProps', 'InputRef', 'InputSize', 'InputState',
21
- 'InputValue', 'TextAreaProps', 'InputNumberControlInfo', 'InputNumberControlTooltip',
16
+ 'CustomSvgIconProps', 'DatePickerMode', 'DatePickerProps', 'DatetimeProps', 'DialogAnimation',
17
+ 'DialogImperativeProps', 'DialogProps', 'DialogTheme', 'DialogTitleAlign', 'DrawerEdge',
18
+ 'DrawerPlacement', 'DrawerProps', 'FileItem', 'FilePreviewActionProps',
19
+ 'FilePreviewFileActionsRender', 'FilePreviewFileActionsRenderInfo', 'FilePreviewProps',
20
+ 'FormItemProps', 'FormLayout', 'FormProps', 'IRuleDescriptor', 'InputCountConfig',
21
+ 'InputCountInfo', 'InputProps', 'InputRef', 'InputSize', 'InputState', 'InputValue',
22
+ 'TextAreaProps', 'InputNumberControlInfo', 'InputNumberControlTooltip',
22
23
  'InputNumberControlTooltipProps', 'InputNumberProps', 'InputNumberRef', 'InputNumberSize',
23
24
  'InputNumberState', 'InputNumberStep', 'InputNumberValidationProps', 'InputNumberValue',
24
25
  'LabelProps', 'ListProps', 'PaginationProps', 'PaginationThemeType', 'RadioGroupDirection',
@@ -42,9 +43,10 @@ const KNOWN_TYPE_EXPORTS = new Set([
42
43
  'DropdownButtonType', 'DropdownProps', 'ImageProps', 'NavigationDividerProps',
43
44
  'NavigationItemGroupProps', 'NavigationItemProps', 'NavigationItemType', 'NavigationProps',
44
45
  'NavigationTheme', 'SubNavigationProps', 'SelectDisplayValueType', 'SelectProps',
45
- 'SliderRangeProps', 'SliderRef', 'SliderSingleProps', 'TreeSelectProps', 'TreeTagProps',
46
- 'TypographyProps', 'TIMEZONE_KEY', 'NextTableCellProps', 'NextTableColumnGroupProps',
47
- 'NextTableColumnProps', 'NextTableHeaderCellProps', 'NextTableProps'
46
+ 'SliderRangeProps', 'SliderRef', 'SliderSingleProps', 'SvgIconProps', 'TreeSelectProps',
47
+ 'TreeTagProps', 'TypographyProps', 'TIMEZONE_KEY', 'NextTableCellProps',
48
+ 'NextTableColumnGroupProps', 'NextTableColumnProps', 'NextTableHeaderCellProps',
49
+ 'NextTableProps'
48
50
  ]);
49
51
 
50
52
  const EXTRA_VALUE_EXPORTS = new Set([
@@ -277,8 +279,11 @@ export function lintFiles(catalog, targets = ['.']) {
277
279
  try {
278
280
  ast = parse(source.content, {
279
281
  sourceType: 'unambiguous', startLine: source.startLine, attachComment: false,
280
- plugins: [...(typescript ? [['typescript', { dts: /\.d\.[cm]?ts$/i.test(file) }]] : []),
281
- ...(!typescript || /tsx$/i.test(file) ? ['jsx'] : [])]
282
+ plugins: [
283
+ 'decorators-legacy',
284
+ ...(typescript ? [['typescript', { dts: /\.d\.[cm]?ts$/i.test(file) }]] : []),
285
+ ...(!typescript || /tsx$/i.test(file) ? ['jsx'] : [])
286
+ ]
282
287
  });
283
288
  } catch (error) {
284
289
  if (!(error instanceof SyntaxError)) throw error;
@@ -36,3 +36,19 @@ export function resolveVersion(explicit, project = process.cwd()) {
36
36
  'Reuse existing npm credentials with --userconfig=/absolute/path/to/.npmrc; configuration may also come from user/global files or environment variables. See README installation troubleshooting.'
37
37
  ] });
38
38
  }
39
+
40
+ export function resolveLintVersion(explicit, targets) {
41
+ if (explicit !== undefined) return explicit;
42
+ const versions = new Set(targets.map((target) => {
43
+ const filename = path.resolve(target);
44
+ const stat = fs.statSync(filename, { throwIfNoEntry: false });
45
+ if (!stat) throw new ToolError('INVALID_ARGUMENT', `Lint target does not exist: ${target}`, 2);
46
+ const resolved = fs.realpathSync(filename);
47
+ return resolveVersion(undefined, stat.isDirectory() ? resolved : path.dirname(resolved));
48
+ }));
49
+ if (versions.size > 1) {
50
+ throw new ToolError('INVALID_ARGUMENT', 'Lint targets use different Fine Design versions. Specify an exact version or lint them separately.', 2);
51
+ }
52
+ const [version] = versions;
53
+ return version;
54
+ }
package/src/mcp.mjs CHANGED
@@ -3,11 +3,19 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
4
  import fs from 'node:fs';
5
5
  import { z } from 'zod';
6
- import { queryCatalog } from './core/catalog.mjs';
7
- import { loadCatalog } from './core/data.mjs';
6
+ import { queryCatalog, getComponentInfo, getComponentTokens, diffCatalogs } from './core/catalog.mjs';
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';
12
+
13
+ const aliases = {
14
+ info: 'get_component_info',
15
+ token: 'get_component_tokens',
16
+ diff: 'diff_catalogs',
17
+ lint: 'lint_files'
18
+ };
11
19
 
12
20
  export async function startMcp() {
13
21
  const packageInfo = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
@@ -15,6 +23,10 @@ export async function startMcp() {
15
23
  const descriptions = {
16
24
  search_components: 'Search components, subcomponents and built-in icons; use nextOffset to browse subsequent pages.',
17
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.',
28
+ diff_catalogs: 'Compare component changes, new sections/examples/aliases and migrations between versions.',
29
+ lint_files: 'Scan code for Fine Design API traps. Pass an exact version if it cannot be detected from the targets.',
18
30
  get_component_example: 'Read example source files, dependencies and asset metadata. Set includeAssets to include binary base64 and oversized JSON fixture content.',
19
31
  list_browser_runtimes: 'Read the one currently hosted UMD version from its online manifest. Requires network access.',
20
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.'
@@ -25,9 +37,31 @@ export async function startMcp() {
25
37
  })) }));
26
38
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
27
39
  try {
28
- const { name, arguments: input } = request.params;
29
- const args = validateInput(name, input);
30
- const result = name === 'get_browser_runtime' ? await resolveRuntime(args) : name === 'list_browser_runtimes' ? await listRuntimes(args.runtimeURL) : queryCatalog(loadCatalog(args.version), name, args);
40
+ const { name, arguments: input = {} } = request.params;
41
+ const toolName = Object.hasOwn(aliases, name) ? aliases[name] : name;
42
+ const args = validateInput(toolName, input);
43
+ let result;
44
+ if (toolName === 'get_browser_runtime') {
45
+ result = await resolveRuntime(args);
46
+ } else if (toolName === 'list_browser_runtimes') {
47
+ result = await listRuntimes(args.runtimeURL);
48
+ } else if (toolName === 'get_component_info') {
49
+ result = getComponentInfo(loadCatalog(args.version), args);
50
+ } else if (toolName === 'get_component_tokens') {
51
+ result = getComponentTokens(loadCatalog(args.version), args);
52
+ } else if (toolName === 'diff_catalogs') {
53
+ const available = Object.keys(readIndex().versions).sort();
54
+ const fromVer = args.fromVersion || args.version || available[0];
55
+ const toVer = args.toVersion || available.at(-1);
56
+ result = diffCatalogs(loadCatalog(fromVer), loadCatalog(toVer));
57
+ } else if (toolName === 'lint_files') {
58
+ const targets = args.paths?.length ? args.paths : args.files?.length ? args.files : args.path ? [args.path] : ['.'];
59
+ const version = resolveLintVersion(args.version, targets);
60
+ const { lintFiles } = await import('./core/lint.mjs');
61
+ result = lintFiles(loadCatalog(version), targets);
62
+ } else {
63
+ result = queryCatalog(loadCatalog(args.version), toolName, args);
64
+ }
31
65
  return { content: [{ type: 'text', text: JSON.stringify(result) }] };
32
66
  } catch (error) {
33
67
  return { isError: true, content: [{ type: 'text', text: JSON.stringify(errorResult(error)) }] };