flowpad-mcp 0.1.0 → 0.1.2
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/dist/index.js +27 -26
- package/package.json +12 -12
- package/dist/client.js +0 -281
- package/dist/client.js.map +0 -1
- package/dist/diff.js +0 -58
- package/dist/diff.js.map +0 -1
- package/dist/http.js +0 -174
- package/dist/http.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib.js +0 -10
- package/dist/lib.js.map +0 -1
- package/dist/local-engine.js +0 -82
- package/dist/local-engine.js.map +0 -1
- package/dist/server.js +0 -956
- package/dist/server.js.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/version.js +0 -8
- package/dist/version.js.map +0 -1
package/dist/local-engine.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// Local engine intelligence — the moat (vs Figma). flowpad-mcp carries flowpad-core
|
|
2
|
-
// (the SAME engine the web client ships to the browser) so an external AI can:
|
|
3
|
-
// 1. learn the engine's rules up front (describeEngine), then
|
|
4
|
-
// 2. validate what it built ON THE USER'S MACHINE before any network round-trip
|
|
5
|
-
// (validateLocal) — fast, free, self-correcting feedback.
|
|
6
|
-
// This is why flowpad-mcp depends on flowpad-core at RUNTIME, not just for types:
|
|
7
|
-
// validation is the genuine engine, identical to web + backend → no drift.
|
|
8
|
-
import { validateDiffPayload, layoutContainerChildren, detectLayoutOverflows, NODE_RULES, LAYOUT_RULES, BOUNDS_RULES, EDGE_RULES, } from 'flowpad-core';
|
|
9
|
-
/**
|
|
10
|
-
* Validate a canvas diff with the real engine, locally — the exact check the web
|
|
11
|
-
* client (`guardUpdateProject`) and the backend run. `existingNodeCount` lets the
|
|
12
|
-
* engine apply project-size limits; pass 0 when unknown (skips the total-count rule).
|
|
13
|
-
*
|
|
14
|
-
* BaseNode is permissive (index signature); core's DiffLike is structural. They
|
|
15
|
-
* line up on the fields core actually reads (id/bounds/edges/layout), so we cast to
|
|
16
|
-
* core's param type instead of re-declaring its contract here (which would drift).
|
|
17
|
-
*/
|
|
18
|
-
export function validateLocal(diff, existingNodeCount = 0) {
|
|
19
|
-
return validateDiffPayload(diff, existingNodeCount);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Run the REAL layout engine locally to preview where a container's children
|
|
23
|
-
* land — the same `layoutContainerChildren` the canvas renders with — AND flag
|
|
24
|
-
* overflows (children that don't fit), the same `detectLayoutOverflows` analyze
|
|
25
|
-
* uses. Lets an external AI SEE both how its auto-layout frame tree renders and
|
|
26
|
-
* what overflows BEFORE sending it, instead of hand-computing x/y or
|
|
27
|
-
* round-tripping. Pure: clones the input, never mutates the caller's nodes.
|
|
28
|
-
*
|
|
29
|
-
* Only auto-layout containers position their children; nodes outside a container
|
|
30
|
-
* (no isAutoLayout ancestor) keep their given bounds.
|
|
31
|
-
*/
|
|
32
|
-
export function previewLayout(nodes) {
|
|
33
|
-
const doc = { nodes: structuredClone(nodes) };
|
|
34
|
-
layoutContainerChildren(doc);
|
|
35
|
-
const laid = doc.nodes;
|
|
36
|
-
return {
|
|
37
|
-
nodes: laid.map((n) => ({ id: String(n.id), bounds: n.bounds })),
|
|
38
|
-
// Overflow is judged on the engine-computed bounds, so run it on the laid-out
|
|
39
|
-
// nodes (not the caller's input).
|
|
40
|
-
overflows: detectLayoutOverflows(laid),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* A concise, accurate description of the engine's constraints, DERIVED from
|
|
45
|
-
* flowpad-core's exported rule constants — no hand-maintained copy to drift. Gives
|
|
46
|
-
* an external AI the vocabulary + limits up front so what it builds passes
|
|
47
|
-
* `validateLocal` on the first try.
|
|
48
|
-
*/
|
|
49
|
-
export function describeEngine() {
|
|
50
|
-
const styleLines = Object.entries(NODE_RULES.STYLE_CAPABILITIES)
|
|
51
|
-
.filter(([, props]) => props.length > 0)
|
|
52
|
-
.map(([type, props]) => ` ${type}: ${props.join(', ')}`);
|
|
53
|
-
return [
|
|
54
|
-
'FLOWPAD ENGINE — rules an edit must satisfy (validated locally before send):',
|
|
55
|
-
'',
|
|
56
|
-
'NODES',
|
|
57
|
-
` allowed types: ${NODE_RULES.ALLOWED_TYPES.join(', ')}`,
|
|
58
|
-
` name ≤ ${NODE_RULES.NAME_MAX_LENGTH} chars; ≤ ${NODE_RULES.MAX_CHILDREN} children/node;`,
|
|
59
|
-
` ≤ ${NODE_RULES.MAX_EDGES_PER_NODE} edges/node; ≤ ${NODE_RULES.MAX_NODES_PER_PROJECT} nodes/project.`,
|
|
60
|
-
' box fill/border style props are type-specific:',
|
|
61
|
-
...styleLines,
|
|
62
|
-
' (text/sticky/image paint their own colors via separate fields, not these.)',
|
|
63
|
-
'',
|
|
64
|
-
'BOUNDS (x, y, width, height — all finite numbers)',
|
|
65
|
-
` width/height ≥ 0 (0 collapses a flex item; negative rejected), ≤ ${BOUNDS_RULES.MAX_WIDTH}.`,
|
|
66
|
-
` x/y within ${BOUNDS_RULES.MIN_COORDINATE}…${BOUNDS_RULES.MAX_COORDINATE}.`,
|
|
67
|
-
'',
|
|
68
|
-
'LAYOUT (only when isAutoLayout:true — node becomes a flex container)',
|
|
69
|
-
` flexDirection: ${LAYOUT_RULES.ALLOWED_FLEX_DIRECTIONS.join(' | ')}`,
|
|
70
|
-
` justifyContent: ${LAYOUT_RULES.ALLOWED_JUSTIFY_CONTENT.join(' | ')}`,
|
|
71
|
-
` alignItems: ${LAYOUT_RULES.ALLOWED_ALIGN_ITEMS.join(' | ')}`,
|
|
72
|
-
` gap ${LAYOUT_RULES.MIN_GAP}…${LAYOUT_RULES.MAX_GAP}, padding ${LAYOUT_RULES.MIN_PADDING}…${LAYOUT_RULES.MAX_PADDING},`,
|
|
73
|
-
` margin ${LAYOUT_RULES.MIN_MARGIN}…${LAYOUT_RULES.MAX_MARGIN}, flexGrow/Shrink ${LAYOUT_RULES.MIN_FLEX_GROW}…${LAYOUT_RULES.MAX_FLEX_GROW}.`,
|
|
74
|
-
' defaults are browser-parity: flexShrink 1, flexWrap nowrap, alignItems stretch.',
|
|
75
|
-
'',
|
|
76
|
-
'EDGES (connections FROM a node TO another)',
|
|
77
|
-
` ports: ${EDGE_RULES.ALLOWED_PORTS.join(', ')}; no self-loops; no dangling targets.`,
|
|
78
|
-
' direction rule: an edge may NOT point INTO a task node — connect task→regular,',
|
|
79
|
-
' never regular→task or task→task (such edges are dropped).',
|
|
80
|
-
].join('\n');
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=local-engine.js.map
|
package/dist/local-engine.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-engine.js","sourceRoot":"","sources":["../src/local-engine.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,+EAA+E;AAC/E,gEAAgE;AAChE,kFAAkF;AAClF,+DAA+D;AAC/D,kFAAkF;AAClF,2EAA2E;AAC3E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,GAEX,MAAM,cAAc,CAAC;AAGtB;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAe,EACf,iBAAiB,GAAG,CAAC;IAErB,OAAO,mBAAmB,CACxB,IAA4D,EAC5D,iBAAiB,CAClB,CAAC;AACJ,CAAC;AASD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,MAAM,GAAG,GAAG,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,EAEvC,CAAC;IACL,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,KAA8B,CAAC;IAChD,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAA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