openfig-mcp 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -25,12 +25,14 @@ Built on [OpenFig](https://github.com/OpenFig-org)'s `.fig` parser ([openfig-cor
25
25
  }
26
26
  ```
27
27
 
28
- 3. Open Copilot Chat in **Agent** mode and ask:
28
+ 3. Open Copilot Chat in **Agent** mode and describe what you want built. For example:
29
29
 
30
30
  > Implement the "Login" screen from the design in React + Tailwind.
31
31
 
32
32
  > Use openfig to build `https://www.figma.com/design/…?node-id=12-345` as a Vue component.
33
33
 
34
+ These are only examples: ask in your own words, for your own stack.
35
+
34
36
  The file given in `args` is the default for every tool. Frames can be referenced by **name** (`"Login"`),
35
37
  **id** (`"12:345"`) or a **Figma URL** with `node-id`. Working with several files? Pass a folder
36
38
  (`"${workspaceFolder}/designs"`) instead, and name the file in the prompt ("…from `designs/app.fig`").
@@ -203,21 +205,4 @@ npm test # unit + end-to-end MCP tests (FIG_SA
203
205
  npm run fidelity -- design.fig [frameId…] # browser-based fidelity report (needs Edge/Chrome or CHROME_PATH)
204
206
  ```
205
207
 
206
-
207
- ## Releasing
208
-
209
- CI (`.github/workflows/ci.yml`) runs the tests on Linux, Windows and macOS for every push and PR.
210
- Publishing is tag-driven (`.github/workflows/release.yml`):
211
-
212
- ```bash
213
- npm version patch # or minor / major: bumps package.json, commits, creates tag vX.Y.Z
214
- git push --follow-tags # pushes main + the tag → CI tests, publishes to npm (with provenance), creates a GitHub release
215
- ```
216
-
217
- The release job only publishes if the tag points at a commit on `main` and matches `package.json`'s version.
218
- It uses npm [trusted publishing](https://docs.npmjs.com/trusted-publishers): there is no npm token
219
- in the repo. npm accepts the publish because it comes from `release.yml` in this repository, as
220
- configured under the package's *Settings → Trusted publishing* on npmjs.com. Provenance is attached
221
- automatically.
222
-
223
208
  MIT. Figma is a trademark of Figma, Inc. This project is not affiliated with Figma.
@@ -1,71 +1,71 @@
1
- #!/usr/bin/env node
2
- // openfig-mcp — MCP server (default) + a small CLI for humans/CI.
3
- import { resolve } from 'path';
4
- import { writeFileSync } from 'fs';
5
-
6
- const HELP = `openfig-mcp — Figma .fig files as LLM-ready design data (MCP server + CLI)
7
-
8
- MCP server (stdio):
9
- openfig-mcp [file.fig | folder ...] Serve the given .fig files / folders (default: workspace roots, then cwd)
10
-
11
- CLI:
12
- openfig-mcp frames <file.fig> [query] List pages / frames
13
- openfig-mcp export <file.fig> <frame> [-o dir] Export frame → index.html, styles.css, tokens.css, assets/, spec.json, preview.png
14
- openfig-mcp render <file.fig> <frame> [-o out.png] [--max 1600]
15
- openfig-mcp tokens <file.fig> [--json] Design tokens as CSS variables (or JSON)
16
- openfig-mcp components <file.fig> [query]
17
- openfig-mcp search <file.fig> <query>
18
- openfig-mcp flows <file.fig>
19
-
20
- <frame> = node id ("1:234"), Figma URL with node-id, or frame name.
21
- Env: OPENFIG_MCP_FONT_DIRS=dir1;dir2 (extra local font folders used for preview renders)`;
22
-
23
- const argv = process.argv.slice(2);
24
- const CMDS = new Set(['frames', 'export', 'render', 'tokens', 'components', 'search', 'flows']);
25
- const flag = (name, def) => { const i = argv.indexOf(name); if (i < 0) return def; const v = argv[i + 1]; argv.splice(i, 2); return v; };
26
- const bool = name => { const i = argv.indexOf(name); if (i < 0) return false; argv.splice(i, 1); return true; };
27
-
28
- if (argv[0] === '-h' || argv[0] === '--help') { console.log(HELP); process.exit(0); }
29
- if (argv[0] === '-v' || argv[0] === '--version') { const { createRequire } = await import('module'); console.log(createRequire(import.meta.url)('../package.json').version); process.exit(0); }
30
-
31
- if (!CMDS.has(argv[0])) {
32
- // ---------------- MCP server
33
- const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
34
- const { createServer } = await import('../src/server.mjs');
35
- const server = createServer({ paths: argv.filter(a => !a.startsWith('-')) });
36
- await server.connect(new StdioServerTransport());
37
- process.stderr.write(`[openfig-mcp] ready (${argv.length ? argv.join(', ') : 'workspace roots / cwd'})\n`);
38
- } else {
39
- // ---------------- CLI
40
- const { FigFile } = await import('../src/api.mjs');
41
- const cmd = argv.shift();
42
- const out = flag('-o') ?? flag('--out');
43
- const max = +flag('--max', 1600);
44
- const asJson = bool('--json');
45
- const [file, arg] = argv;
46
- if (!file) { console.error(HELP); process.exit(1); }
47
- const f = await FigFile.open(file);
48
- try {
49
- if (cmd === 'frames') {
50
- for (const fr of f.listFrames({ query: arg })) console.log(`${fr.id.padEnd(10)} ${fr.kind.padEnd(13)} ${fr.size.padEnd(10)} ${fr.page}${fr.group ? ' / ' + fr.group : ''} / ${fr.name}${fr.flowStart ? ' ▶ ' + fr.flowStart : ''}`);
51
- } else if (cmd === 'export') {
52
- const r = await f.getFrame(arg, { outDir: out });
53
- console.log(r.summary);
54
- console.log(`Exported to ${r.dir}`);
55
- } else if (cmd === 'render') {
56
- const { png, node } = await f.render(arg, { maxDim: max });
57
- const p = resolve(out || `${node.id.replace(':', '-')}.png`);
58
- writeFileSync(p, png); console.log(`Wrote ${p}`);
59
- } else if (cmd === 'tokens') {
60
- const t = f.tokens();
61
- if (asJson) { const { css, ...rest } = t; console.log(JSON.stringify(rest, null, 1)); } else console.log(t.css);
62
- } else if (cmd === 'components') {
63
- for (const c of f.components({ query: arg })) console.log(`${c.id.padEnd(10)} ${c.name} — ${c.variants} variant(s), used ${c.uses}× ${Object.entries(c.properties).map(([k, v]) => `${k}=${Array.isArray(v) ? v.join('|') : v}`).join('; ')}`);
64
- } else if (cmd === 'search') {
65
- for (const h of f.search(arg)) console.log(`${h.id.padEnd(10)} ${h.type.padEnd(10)} ${h.name}${h.text ? ` "${h.text}"` : ''} (${h.page}${h.path ? ' / ' + h.path : ''})`);
66
- } else if (cmd === 'flows') {
67
- console.log(JSON.stringify(f.flows(), null, 1));
68
- }
69
- } catch (e) { console.error(`Error: ${e.message}`); process.exit(1); }
70
- process.exit(0);
71
- }
1
+ #!/usr/bin/env node
2
+ // openfig-mcp — MCP server (default) + a small CLI for humans/CI.
3
+ import { resolve } from 'path';
4
+ import { writeFileSync } from 'fs';
5
+
6
+ const HELP = `openfig-mcp — Figma .fig files as LLM-ready design data (MCP server + CLI)
7
+
8
+ MCP server (stdio):
9
+ openfig-mcp [file.fig | folder ...] Serve the given .fig files / folders (default: workspace roots, then cwd)
10
+
11
+ CLI:
12
+ openfig-mcp frames <file.fig> [query] List pages / frames
13
+ openfig-mcp export <file.fig> <frame> [-o dir] Export frame → index.html, styles.css, tokens.css, assets/, spec.json, preview.png
14
+ openfig-mcp render <file.fig> <frame> [-o out.png] [--max 1600]
15
+ openfig-mcp tokens <file.fig> [--json] Design tokens as CSS variables (or JSON)
16
+ openfig-mcp components <file.fig> [query]
17
+ openfig-mcp search <file.fig> <query>
18
+ openfig-mcp flows <file.fig>
19
+
20
+ <frame> = node id ("1:234"), Figma URL with node-id, or frame name.
21
+ Env: OPENFIG_MCP_FONT_DIRS=dir1;dir2 (extra local font folders used for preview renders)`;
22
+
23
+ const argv = process.argv.slice(2);
24
+ const CMDS = new Set(['frames', 'export', 'render', 'tokens', 'components', 'search', 'flows']);
25
+ const flag = (name, def) => { const i = argv.indexOf(name); if (i < 0) return def; const v = argv[i + 1]; argv.splice(i, 2); return v; };
26
+ const bool = name => { const i = argv.indexOf(name); if (i < 0) return false; argv.splice(i, 1); return true; };
27
+
28
+ if (argv[0] === '-h' || argv[0] === '--help') { console.log(HELP); process.exit(0); }
29
+ if (argv[0] === '-v' || argv[0] === '--version') { const { createRequire } = await import('module'); console.log(createRequire(import.meta.url)('../package.json').version); process.exit(0); }
30
+
31
+ if (!CMDS.has(argv[0])) {
32
+ // ---------------- MCP server
33
+ const { StdioServerTransport } = await import('@modelcontextprotocol/sdk/server/stdio.js');
34
+ const { createServer } = await import('../src/server.mjs');
35
+ const server = createServer({ paths: argv.filter(a => !a.startsWith('-')) });
36
+ await server.connect(new StdioServerTransport());
37
+ process.stderr.write(`[openfig-mcp] ready (${argv.length ? argv.join(', ') : 'workspace roots / cwd'})\n`);
38
+ } else {
39
+ // ---------------- CLI
40
+ const { FigFile } = await import('../src/api.mjs');
41
+ const cmd = argv.shift();
42
+ const out = flag('-o') ?? flag('--out');
43
+ const max = +flag('--max', 1600);
44
+ const asJson = bool('--json');
45
+ const [file, arg] = argv;
46
+ if (!file) { console.error(HELP); process.exit(1); }
47
+ const f = await FigFile.open(file);
48
+ try {
49
+ if (cmd === 'frames') {
50
+ for (const fr of f.listFrames({ query: arg })) console.log(`${fr.id.padEnd(10)} ${fr.kind.padEnd(13)} ${fr.size.padEnd(10)} ${fr.page}${fr.group ? ' / ' + fr.group : ''} / ${fr.name}${fr.flowStart ? ' ▶ ' + fr.flowStart : ''}`);
51
+ } else if (cmd === 'export') {
52
+ const r = await f.getFrame(arg, { outDir: out });
53
+ console.log(r.summary);
54
+ console.log(`Exported to ${r.dir}`);
55
+ } else if (cmd === 'render') {
56
+ const { png, node } = await f.render(arg, { maxDim: max });
57
+ const p = resolve(out || `${node.id.replace(':', '-')}.png`);
58
+ writeFileSync(p, png); console.log(`Wrote ${p}`);
59
+ } else if (cmd === 'tokens') {
60
+ const t = f.tokens();
61
+ if (asJson) { const { css, ...rest } = t; console.log(JSON.stringify(rest, null, 1)); } else console.log(t.css);
62
+ } else if (cmd === 'components') {
63
+ for (const c of f.components({ query: arg })) console.log(`${c.id.padEnd(10)} ${c.name} — ${c.variants} variant(s), used ${c.uses}× ${Object.entries(c.properties).map(([k, v]) => `${k}=${Array.isArray(v) ? v.join('|') : v}`).join('; ')}`);
64
+ } else if (cmd === 'search') {
65
+ for (const h of f.search(arg)) console.log(`${h.id.padEnd(10)} ${h.type.padEnd(10)} ${h.name}${h.text ? ` "${h.text}"` : ''} (${h.page}${h.path ? ' / ' + h.path : ''})`);
66
+ } else if (cmd === 'flows') {
67
+ console.log(JSON.stringify(f.flows(), null, 1));
68
+ }
69
+ } catch (e) { console.error(`Error: ${e.message}`); process.exit(1); }
70
+ process.exit(0);
71
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openfig-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MCP server that turns Figma .fig files into LLM-ready design specs: frames, HTML/CSS, tokens, components, hover states, animations, SVG icons, images and fonts. Works offline, no Figma API token.",
5
5
  "type": "module",
6
6
  "bin": {