@imenam/mcp-design 1.0.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 +231 -0
- package/dist/shared/node-defaults.d.ts +30 -0
- package/dist/shared/node-defaults.js +67 -0
- package/dist/shared/node-fields.d.ts +33 -0
- package/dist/shared/node-fields.js +40 -0
- package/dist/shared/render.d.ts +105 -0
- package/dist/shared/render.js +215 -0
- package/dist/shared/schemas/design.schema.d.ts +231 -0
- package/dist/shared/schemas/design.schema.js +98 -0
- package/dist/shared/tree.d.ts +93 -0
- package/dist/shared/tree.js +223 -0
- package/dist/src/cli/setup-mcp.d.ts +5 -0
- package/dist/src/cli/setup-mcp.js +87 -0
- package/dist/src/core/design-store.d.ts +61 -0
- package/dist/src/core/design-store.js +294 -0
- package/dist/src/core/diff.d.ts +22 -0
- package/dist/src/core/diff.js +97 -0
- package/dist/src/core/export.d.ts +6 -0
- package/dist/src/core/export.js +251 -0
- package/dist/src/core/hierarchy.d.ts +18 -0
- package/dist/src/core/hierarchy.js +68 -0
- package/dist/src/core/ids.d.ts +4 -0
- package/dist/src/core/ids.js +21 -0
- package/dist/src/core/log-dir.d.ts +6 -0
- package/dist/src/core/log-dir.js +12 -0
- package/dist/src/core/migrate.d.ts +18 -0
- package/dist/src/core/migrate.js +54 -0
- package/dist/src/core/node-factory.d.ts +19 -0
- package/dist/src/core/node-factory.js +103 -0
- package/dist/src/core/screenshot.d.ts +31 -0
- package/dist/src/core/screenshot.js +53 -0
- package/dist/src/gui-worker.d.ts +1 -0
- package/dist/src/gui-worker.js +334 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +673 -0
- package/dist/src/tools/add-nodes.d.ts +7 -0
- package/dist/src/tools/add-nodes.js +26 -0
- package/dist/src/tools/create-design.d.ts +7 -0
- package/dist/src/tools/create-design.js +15 -0
- package/dist/src/tools/delete-design.d.ts +3 -0
- package/dist/src/tools/delete-design.js +7 -0
- package/dist/src/tools/delete-nodes.d.ts +3 -0
- package/dist/src/tools/delete-nodes.js +29 -0
- package/dist/src/tools/export-design.d.ts +3 -0
- package/dist/src/tools/export-design.js +21 -0
- package/dist/src/tools/get-changes.d.ts +11 -0
- package/dist/src/tools/get-changes.js +27 -0
- package/dist/src/tools/get-design.d.ts +7 -0
- package/dist/src/tools/get-design.js +29 -0
- package/dist/src/tools/group-nodes.d.ts +10 -0
- package/dist/src/tools/group-nodes.js +83 -0
- package/dist/src/tools/list-designs.d.ts +3 -0
- package/dist/src/tools/list-designs.js +13 -0
- package/dist/src/tools/mark-synced.d.ts +7 -0
- package/dist/src/tools/mark-synced.js +19 -0
- package/dist/src/tools/reorder-nodes.d.ts +7 -0
- package/dist/src/tools/reorder-nodes.js +60 -0
- package/dist/src/tools/screenshot-design.d.ts +3 -0
- package/dist/src/tools/screenshot-design.js +36 -0
- package/dist/src/tools/types.d.ts +25 -0
- package/dist/src/tools/types.js +13 -0
- package/dist/src/tools/ungroup-nodes.d.ts +7 -0
- package/dist/src/tools/ungroup-nodes.js +64 -0
- package/dist/src/tools/update-design.d.ts +4 -0
- package/dist/src/tools/update-design.js +33 -0
- package/dist/src/tools/update-nodes.d.ts +3 -0
- package/dist/src/tools/update-nodes.js +35 -0
- package/dist/src/version.d.ts +1 -0
- package/dist/src/version.js +2 -0
- package/package.json +58 -0
- package/scripts/generate-version.js +20 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { applyPatch, DesignError } from "../core/node-factory.js";
|
|
2
|
+
import { requireString, textResult } from "./types.js";
|
|
3
|
+
export function updateNodes(store, args) {
|
|
4
|
+
const id = requireString(args, "design_id");
|
|
5
|
+
const updates = args?.updates;
|
|
6
|
+
if (!Array.isArray(updates) || updates.length === 0) {
|
|
7
|
+
throw new Error(`"updates" is required and must be a non-empty array of { id, ...fields }.`);
|
|
8
|
+
}
|
|
9
|
+
const current = store.get(id);
|
|
10
|
+
const byId = new Map(current.nodes.map((n) => [n.id, n]));
|
|
11
|
+
// Validation complète d'abord : un patch partiellement appliqué laisserait le
|
|
12
|
+
// design dans un état que l'agent n'a pas demandé.
|
|
13
|
+
const patched = updates.map((raw) => {
|
|
14
|
+
const patch = raw;
|
|
15
|
+
const nodeId = typeof patch.id === "string" ? patch.id : "";
|
|
16
|
+
const node = byId.get(nodeId);
|
|
17
|
+
if (!node) {
|
|
18
|
+
throw new DesignError(`Node "${nodeId}" not found in design "${id}". Known ids: ${current.nodes.map((n) => n.id).join(", ") || "(none)"}.`);
|
|
19
|
+
}
|
|
20
|
+
const { id: _ignored, ...fields } = patch;
|
|
21
|
+
if (Object.keys(fields).length === 0) {
|
|
22
|
+
throw new DesignError(`Update for node "${nodeId}" contains no field to change.`);
|
|
23
|
+
}
|
|
24
|
+
return applyPatch(node, fields);
|
|
25
|
+
});
|
|
26
|
+
const patchedById = new Map(patched.map((n) => [n.id, n]));
|
|
27
|
+
const design = store.mutate(id, "agent", (draft) => {
|
|
28
|
+
draft.nodes = draft.nodes.map((n) => patchedById.get(n.id) ?? n);
|
|
29
|
+
});
|
|
30
|
+
const lines = patched.map((n) => `- ${n.id} — "${n.name}" (${n.type})`);
|
|
31
|
+
return {
|
|
32
|
+
...textResult([`Updated ${patched.length} node(s) in "${design.name}":`, ...lines].join("\n")),
|
|
33
|
+
design,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const APP_VERSION = "1.0.1";
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@imenam/mcp-design",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "dist/src/index.js",
|
|
5
|
+
"directories": {
|
|
6
|
+
"test": "test"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"generate-version": "node scripts/generate-version.js",
|
|
10
|
+
"build:backend": "npm run generate-version && tsc",
|
|
11
|
+
"build:gui": "cd gui && npm install && npm run build",
|
|
12
|
+
"build": "npm run build:backend && npm run build:gui",
|
|
13
|
+
"start": "node dist/src/index.js",
|
|
14
|
+
"test": "node --test \"dist/test/*.test.js\"",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"release": "npm version patch && npm publish && git push --follow-tags"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"mcp",
|
|
20
|
+
"model-context-protocol",
|
|
21
|
+
"design",
|
|
22
|
+
"canvas",
|
|
23
|
+
"ui",
|
|
24
|
+
"mockup",
|
|
25
|
+
"ai",
|
|
26
|
+
"agent"
|
|
27
|
+
],
|
|
28
|
+
"author": "Imena",
|
|
29
|
+
"license": "ISC",
|
|
30
|
+
"description": "MCP server providing a simple design canvas: the agent creates shapes and text, the user refines them in a GUI, and the agent picks the edits back up.",
|
|
31
|
+
"type": "module",
|
|
32
|
+
"bin": {
|
|
33
|
+
"mcp-design": "dist/src/index.js"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist/src",
|
|
40
|
+
"dist/shared",
|
|
41
|
+
"gui/dist",
|
|
42
|
+
"README.md",
|
|
43
|
+
"scripts"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@hono/node-server": "^2.1.1",
|
|
47
|
+
"@imenam/mcp-gui-interface": "^1.0.11",
|
|
48
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
49
|
+
"@resvg/resvg-js": "^2.6.2",
|
|
50
|
+
"dotenv": "^17.4.2",
|
|
51
|
+
"hono": "^4.13.4",
|
|
52
|
+
"zod": "^4.4.3"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^26.3.0",
|
|
56
|
+
"typescript": "^7.0.2"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const rootDir = path.join(__dirname, '..');
|
|
8
|
+
|
|
9
|
+
const packagePath = path.join(rootDir, 'package.json');
|
|
10
|
+
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
11
|
+
|
|
12
|
+
const versionContent = `// Auto-generated version file - do not edit manually
|
|
13
|
+
export const APP_VERSION = '${pkg.version}';
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const outputPath = path.join(rootDir, 'src', 'version.ts');
|
|
17
|
+
fs.writeFileSync(outputPath, versionContent, 'utf8');
|
|
18
|
+
|
|
19
|
+
console.log(`Generated version file: ${outputPath}`);
|
|
20
|
+
console.log(` Version: ${pkg.version}`);
|