codesign-mcp-next 0.3.2 → 0.3.3
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 +137 -121
- package/LICENSE +21 -21
- package/README.md +458 -458
- package/dist/prompts/design-to-code.js +16 -16
- package/dist/resources/workflow.js +16 -16
- package/package.json +58 -58
- package/userscripts/codesign-ai-selection.user.js +445 -445
|
@@ -108,21 +108,21 @@ function buildPrompt(args) {
|
|
|
108
108
|
const customWidthLine = args.customWidth != null ? `Custom width: ${args.customWidth}\n` : '';
|
|
109
109
|
const remBaseLine = args.remBasePx != null ? `Rem base px: ${args.remBasePx}\n` : '';
|
|
110
110
|
const outputDirLine = args.outputDir ? `Target directory: ${args.outputDir}\n` : '';
|
|
111
|
-
return `Implement the page from this Tencent CoDesign design.
|
|
112
|
-
|
|
113
|
-
CoDesign link: ${args.sharingUrl}
|
|
114
|
-
${passwordLine}${artboardLine}${screenIdLine}${layerNameLine}${layerIdLine}${selectionScopeLine}${platformLine}${unitLine}${customScaleLine}${customWidthLine}${remBaseLine}${outputDirLine}
|
|
115
|
-
Requirements:
|
|
116
|
-
1. Call the codesign-mcp list_artboards tool first to resolve the sharing link and inspect the available designs and artboards.
|
|
117
|
-
2. Select the requested artboard when a preferred artboard or screen ID is provided. Otherwise, choose the artboard that best matches the user's page request and state the selected artboard name.
|
|
118
|
-
3. Call get_artboard_spec for the selected artboard and use the official layer, text, color, CSS, coordinate, group, and slice metadata as the source of truth. When a layer object ID is provided, pass it as layerObjectId together with the requested selectionScope and implement only the returned selection.
|
|
119
|
-
4. For a selected region, use selection.layers, selection.groups, selection.hierarchy, selection.bounds, and each node's relativeRect to reconstruct its structure. selectionScope=region includes non-ancestor nodes fully contained by the selected bounds; selectionScope=subtree includes only strict descendants.
|
|
120
|
-
5. If a target platform is provided or implied by the user's request, pass it as get_artboard_spec.targetPlatform using the user's natural-language wording.
|
|
121
|
-
6. If the user specifies a unit, custom scale, target design width, or rem base, pass those as get_artboard_spec.targetUnit, customScale, customWidth, and remBasePx. For example, "1440px design width, rem, 1rem=100px" maps to targetUnit=rem, customWidth=1440, remBasePx=100.
|
|
122
|
-
7. Use spec.platformSpec or platformSelection when returned for platform id, units, converted rects, unit-adjusted CSS, and conversion metadata. Keep the raw CoDesign data available as the source of truth.
|
|
123
|
-
8. Unless the user's current request explicitly requires an absolute-positioned or canvas-style implementation, translate the CoDesign coordinates into semantic page structure and normal document flow before coding. Prefer Flexbox/Grid and existing layout primitives for page layout; do not recreate the whole page as a flat canvas of globally absolute-positioned layers. When the user explicitly requests absolute positioning, honor that instruction and scope positioning to the requested page or selection container where practical. Otherwise reserve absolute/fixed positioning for local overlays or intentionally overlapping elements required by the design.
|
|
124
|
-
9. When the design includes designer-exported slice assets, call download_slice for those assets. Do not crop production assets from the full preview image.
|
|
125
|
-
10. Use get_artboard_image only for visual comparison and final review.
|
|
126
|
-
11. Implement the page in the target directory when one is provided, following the existing project structure and styles.
|
|
111
|
+
return `Implement the page from this Tencent CoDesign design.
|
|
112
|
+
|
|
113
|
+
CoDesign link: ${args.sharingUrl}
|
|
114
|
+
${passwordLine}${artboardLine}${screenIdLine}${layerNameLine}${layerIdLine}${selectionScopeLine}${platformLine}${unitLine}${customScaleLine}${customWidthLine}${remBaseLine}${outputDirLine}
|
|
115
|
+
Requirements:
|
|
116
|
+
1. Call the codesign-mcp list_artboards tool first to resolve the sharing link and inspect the available designs and artboards.
|
|
117
|
+
2. Select the requested artboard when a preferred artboard or screen ID is provided. Otherwise, choose the artboard that best matches the user's page request and state the selected artboard name.
|
|
118
|
+
3. Call get_artboard_spec for the selected artboard and use the official layer, text, color, CSS, coordinate, group, and slice metadata as the source of truth. When a layer object ID is provided, pass it as layerObjectId together with the requested selectionScope and implement only the returned selection.
|
|
119
|
+
4. For a selected region, use selection.layers, selection.groups, selection.hierarchy, selection.bounds, and each node's relativeRect to reconstruct its structure. selectionScope=region includes non-ancestor nodes fully contained by the selected bounds; selectionScope=subtree includes only strict descendants.
|
|
120
|
+
5. If a target platform is provided or implied by the user's request, pass it as get_artboard_spec.targetPlatform using the user's natural-language wording.
|
|
121
|
+
6. If the user specifies a unit, custom scale, target design width, or rem base, pass those as get_artboard_spec.targetUnit, customScale, customWidth, and remBasePx. For example, "1440px design width, rem, 1rem=100px" maps to targetUnit=rem, customWidth=1440, remBasePx=100.
|
|
122
|
+
7. Use spec.platformSpec or platformSelection when returned for platform id, units, converted rects, unit-adjusted CSS, and conversion metadata. Keep the raw CoDesign data available as the source of truth.
|
|
123
|
+
8. Unless the user's current request explicitly requires an absolute-positioned or canvas-style implementation, translate the CoDesign coordinates into semantic page structure and normal document flow before coding. Prefer Flexbox/Grid and existing layout primitives for page layout; do not recreate the whole page as a flat canvas of globally absolute-positioned layers. When the user explicitly requests absolute positioning, honor that instruction and scope positioning to the requested page or selection container where practical. Otherwise reserve absolute/fixed positioning for local overlays or intentionally overlapping elements required by the design.
|
|
124
|
+
9. When the design includes designer-exported slice assets, call download_slice for those assets. Do not crop production assets from the full preview image.
|
|
125
|
+
10. Use get_artboard_image only for visual comparison and final review.
|
|
126
|
+
11. Implement the page in the target directory when one is provided, following the existing project structure and styles.
|
|
127
127
|
12. Surface any CoDesign access, password, login, or missing-spec failure clearly instead of fabricating design data.`;
|
|
128
128
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export const DESIGN_TO_CODE_WORKFLOW_URI = 'codesign://workflow/design-to-code';
|
|
2
|
-
const workflowMarkdown = `# CoDesign Design-to-Code Workflow
|
|
3
|
-
|
|
4
|
-
Use this workflow when a user asks an agent to implement, recreate, or inspect a Tencent CoDesign sharing link.
|
|
5
|
-
|
|
6
|
-
1. Call \`list_artboards\` with the CoDesign sharing URL and optional password. Use the returned design and artboard metadata to select the target screen.
|
|
7
|
-
2. Call \`get_artboard_spec\` for the selected artboard. Treat the official spec data as the source of truth for layout, text, color, CSS, coordinates, grouping, and slice metadata.
|
|
8
|
-
3. When the user supplies a copied CoDesign selection reference, pass its \`screenId\`, \`layerObjectId\`, and \`selectionScope\` to \`get_artboard_spec\`. Use \`selectionScope=region\` for a visual area or \`selectionScope=subtree\` for the selected node's strict descendants.
|
|
9
|
-
4. Reconstruct a selected area from \`selection.layers\`, \`selection.groups\`, \`selection.hierarchy\`, \`selection.bounds\`, and each node's \`relativeRect\`. Implement only that selection unless the user asks for the full page.
|
|
10
|
-
5. If the user specifies a development platform in natural language, such as Web, Android, 安卓, iOS, 微信小程序, or mini program, pass that wording as \`get_artboard_spec.targetPlatform\`.
|
|
11
|
-
6. If the user specifies a unit, custom scale, target design width, or rem base, pass those as \`targetUnit\`, \`customScale\`, \`customWidth\`, and \`remBasePx\`. For example, "1440px design width, rem, 1rem=100px" maps to \`targetUnit=rem\`, \`customWidth=1440\`, and \`remBasePx=100\`.
|
|
12
|
-
7. Use the returned \`spec.platformSpec\` or \`platformSelection\` for normalized platform id, units, converted rects, unit-adjusted CSS, and conversion metadata while keeping the raw spec as the original CoDesign data.
|
|
13
|
-
8. Unless the user's current request explicitly requires an absolute-positioned or canvas-style implementation, translate the CoDesign coordinates into semantic page structure and normal document flow before implementation. Prefer Flexbox/Grid and existing layout primitives for page layout; do not recreate the whole page as a flat canvas of globally absolute-positioned layers. When the user explicitly requests absolute positioning, honor that instruction and scope positioning to the requested page or selection container where practical. Otherwise reserve absolute/fixed positioning for local overlays or intentionally overlapping elements required by the design.
|
|
14
|
-
9. If the selected artboard includes designer-exported slice assets, call \`download_slice\` for those assets. Do not crop production assets from a preview image.
|
|
15
|
-
10. Use \`get_artboard_image\` only for visual comparison, review, or debugging.
|
|
16
|
-
11. Use \`codesign_status\` before private designs when login state or runtime paths need to be checked. Use \`codesign_login\` only when the user needs to establish a CoDesign browser session.
|
|
17
|
-
12. Surface access, password, login, network, missing-artboard, and missing-spec failures clearly. Do not fabricate design data when the official CoDesign data is unavailable.
|
|
2
|
+
const workflowMarkdown = `# CoDesign Design-to-Code Workflow
|
|
3
|
+
|
|
4
|
+
Use this workflow when a user asks an agent to implement, recreate, or inspect a Tencent CoDesign sharing link.
|
|
5
|
+
|
|
6
|
+
1. Call \`list_artboards\` with the CoDesign sharing URL and optional password. Use the returned design and artboard metadata to select the target screen.
|
|
7
|
+
2. Call \`get_artboard_spec\` for the selected artboard. Treat the official spec data as the source of truth for layout, text, color, CSS, coordinates, grouping, and slice metadata.
|
|
8
|
+
3. When the user supplies a copied CoDesign selection reference, pass its \`screenId\`, \`layerObjectId\`, and \`selectionScope\` to \`get_artboard_spec\`. Use \`selectionScope=region\` for a visual area or \`selectionScope=subtree\` for the selected node's strict descendants.
|
|
9
|
+
4. Reconstruct a selected area from \`selection.layers\`, \`selection.groups\`, \`selection.hierarchy\`, \`selection.bounds\`, and each node's \`relativeRect\`. Implement only that selection unless the user asks for the full page.
|
|
10
|
+
5. If the user specifies a development platform in natural language, such as Web, Android, 安卓, iOS, 微信小程序, or mini program, pass that wording as \`get_artboard_spec.targetPlatform\`.
|
|
11
|
+
6. If the user specifies a unit, custom scale, target design width, or rem base, pass those as \`targetUnit\`, \`customScale\`, \`customWidth\`, and \`remBasePx\`. For example, "1440px design width, rem, 1rem=100px" maps to \`targetUnit=rem\`, \`customWidth=1440\`, and \`remBasePx=100\`.
|
|
12
|
+
7. Use the returned \`spec.platformSpec\` or \`platformSelection\` for normalized platform id, units, converted rects, unit-adjusted CSS, and conversion metadata while keeping the raw spec as the original CoDesign data.
|
|
13
|
+
8. Unless the user's current request explicitly requires an absolute-positioned or canvas-style implementation, translate the CoDesign coordinates into semantic page structure and normal document flow before implementation. Prefer Flexbox/Grid and existing layout primitives for page layout; do not recreate the whole page as a flat canvas of globally absolute-positioned layers. When the user explicitly requests absolute positioning, honor that instruction and scope positioning to the requested page or selection container where practical. Otherwise reserve absolute/fixed positioning for local overlays or intentionally overlapping elements required by the design.
|
|
14
|
+
9. If the selected artboard includes designer-exported slice assets, call \`download_slice\` for those assets. Do not crop production assets from a preview image.
|
|
15
|
+
10. Use \`get_artboard_image\` only for visual comparison, review, or debugging.
|
|
16
|
+
11. Use \`codesign_status\` before private designs when login state or runtime paths need to be checked. Use \`codesign_login\` only when the user needs to establish a CoDesign browser session.
|
|
17
|
+
12. Surface access, password, login, network, missing-artboard, and missing-spec failures clearly. Do not fabricate design data when the official CoDesign data is unavailable.
|
|
18
18
|
`;
|
|
19
19
|
export function registerWorkflowResource(server) {
|
|
20
20
|
server.registerResource('design-to-code-workflow', DESIGN_TO_CODE_WORKFLOW_URI, {
|
package/package.json
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "codesign-mcp-next",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "Local MCP server for Tencent CoDesign — read sharing artboards, specs, screenshots and slices.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/DOIT008/codesign-mcp.git"
|
|
10
|
-
},
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/DOIT008/codesign-mcp/issues"
|
|
13
|
-
},
|
|
14
|
-
"homepage": "https://github.com/DOIT008/codesign-mcp#readme",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"mcp",
|
|
17
|
-
"codesign",
|
|
18
|
-
"tencent",
|
|
19
|
-
"design-to-code"
|
|
20
|
-
],
|
|
21
|
-
"engines": {
|
|
22
|
-
"node": ">=20"
|
|
23
|
-
},
|
|
24
|
-
"main": "dist/index.js",
|
|
25
|
-
"bin": {
|
|
26
|
-
"codesign-mcp-next": "dist/index.js"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"dist",
|
|
30
|
-
"!dist/**/*.map",
|
|
31
|
-
"userscripts",
|
|
32
|
-
"README.md",
|
|
33
|
-
"CHANGELOG.md",
|
|
34
|
-
"LICENSE",
|
|
35
|
-
"package.json"
|
|
36
|
-
],
|
|
37
|
-
"publishConfig": {
|
|
38
|
-
"access": "public",
|
|
39
|
-
"registry": "https://registry.npmjs.org/"
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "tsc -p tsconfig.json",
|
|
43
|
-
"start": "node dist/index.js",
|
|
44
|
-
"dev": "tsx watch src/index.ts",
|
|
45
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
46
|
-
"test": "npm run build && node --check userscripts/codesign-ai-selection.user.js && node --test tests/cache.test.mjs tests/config.test.mjs tests/download.test.mjs tests/hierarchy.test.mjs tests/http.test.mjs tests/integrity.test.mjs tests/login.test.mjs tests/manager.test.mjs tests/mcp.test.mjs tests/parser.test.mjs tests/platform.test.mjs tests/rate-limit.test.mjs tests/redact.test.mjs tests/result.test.mjs tests/retry.test.mjs tests/selection.test.mjs tests/sharing.test.mjs tests/slices.test.mjs tests/startup.test.mjs tests/url.test.mjs",
|
|
47
|
-
"prepack": "npm run build",
|
|
48
|
-
"install:browsers": "playwright install chromium"
|
|
49
|
-
},
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"playwright": "1.60.0"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@types/node": "22.19.19",
|
|
55
|
-
"tsx": "4.22.2",
|
|
56
|
-
"typescript": "5.9.3"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "codesign-mcp-next",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "Local MCP server for Tencent CoDesign — read sharing artboards, specs, screenshots and slices.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/DOIT008/codesign-mcp.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/DOIT008/codesign-mcp/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/DOIT008/codesign-mcp#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"codesign",
|
|
18
|
+
"tencent",
|
|
19
|
+
"design-to-code"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20"
|
|
23
|
+
},
|
|
24
|
+
"main": "dist/index.js",
|
|
25
|
+
"bin": {
|
|
26
|
+
"codesign-mcp-next": "dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist",
|
|
30
|
+
"!dist/**/*.map",
|
|
31
|
+
"userscripts",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"package.json"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -p tsconfig.json",
|
|
43
|
+
"start": "node dist/index.js",
|
|
44
|
+
"dev": "tsx watch src/index.ts",
|
|
45
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
46
|
+
"test": "npm run build && node --check userscripts/codesign-ai-selection.user.js && node --test tests/cache.test.mjs tests/config.test.mjs tests/download.test.mjs tests/hierarchy.test.mjs tests/http.test.mjs tests/integrity.test.mjs tests/login.test.mjs tests/manager.test.mjs tests/mcp.test.mjs tests/parser.test.mjs tests/platform.test.mjs tests/rate-limit.test.mjs tests/redact.test.mjs tests/result.test.mjs tests/retry.test.mjs tests/selection.test.mjs tests/sharing.test.mjs tests/slices.test.mjs tests/startup.test.mjs tests/url.test.mjs",
|
|
47
|
+
"prepack": "npm run build",
|
|
48
|
+
"install:browsers": "playwright install chromium"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"playwright": "1.60.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "22.19.19",
|
|
55
|
+
"tsx": "4.22.2",
|
|
56
|
+
"typescript": "5.9.3"
|
|
57
|
+
}
|
|
58
|
+
}
|