@finedesign/cli 0.1.0-rc.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.
- package/CHANGELOG.md +25 -11
- package/README.md +142 -62
- package/data/1.24.9/catalog.json +1 -1
- package/data/1.24.9/manifest.json +6 -6
- package/data/1.25.0/catalog.json +1 -0
- package/data/1.25.0/manifest.json +17 -0
- package/data/index.json +5 -1
- package/package.json +1 -1
- package/skills/fine-design/SKILL.md +4 -4
- package/skills/fine-design/references/browser-runtime-legacy.json +71 -0
- package/skills/fine-design/references/component-guide.md +1 -0
- package/skills/fine-design/references/docs-slug-map.md +12 -0
- package/skills/fine-design/references/imports-and-setup.md +41 -10
- package/skills/fine-design/references/theme-and-dark-mode.md +1 -0
- package/src/cli.mjs +137 -13
- package/src/core/catalog.mjs +63 -8
- package/src/core/contracts.mjs +12 -2
- package/src/core/data.mjs +7 -1
- package/src/core/version.mjs +17 -2
- package/src/mcp.mjs +3 -3
package/src/core/version.mjs
CHANGED
|
@@ -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,12 +13,26 @@ 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' &&
|
|
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;
|
|
21
31
|
}
|
|
22
|
-
throw new ToolError('VERSION_NOT_DETECTED', 'Cannot
|
|
32
|
+
throw new ToolError('VERSION_NOT_DETECTED', 'Cannot find an installed @fx-ui/fine-design version in this project or its parent directories.', 3, { suggestions: [
|
|
33
|
+
'Run from the component project or pass --project <directory>.',
|
|
34
|
+
'For offline documentation without installing components, pass --fd-version <exact-supported-version>.',
|
|
35
|
+
'If component installation fails, check the effective registry with npm config get @fx-ui:registry and npm config get registry.',
|
|
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
|
+
] });
|
|
23
38
|
}
|
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
|
|
17
|
-
get_component_example: 'Read example source files, dependencies and
|
|
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' }),
|