flowpad-mcp 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,kFAAkF;AAClF,kFAAkF;AAClF,gFAAgF;AAChF,wBAAwB;AACxB,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,sFAAsF;AACtF,SAAS,SAAS;IAChB,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IACjD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;AACpE,CAAC;AAED,KAAK,UAAU,QAAQ;IACrB,+DAA+D;IAC/D,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC;QAC/B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,gBAAgB;QACxD,2EAA2E;QAC3E,kDAAkD;QAClD,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW;KAC/D,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,wDAAwD;IACxD,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACvD,CAAC;AAED,KAAK,UAAU,OAAO;IACpB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,iBAAiB,CAAC,CAAC;IAC/D,2EAA2E;IAC3E,kEAAkE;IAClE,gFAAgF;IAChF,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,CAAC;SACvD,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,MAAM,eAAe,CAAC;QACpB,IAAI;QACJ,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,gBAAgB;QACxD,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,MAAM;QACpC,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QAC7C,oBAAoB,EAAE,WAAW;KAClC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,IAAI,SAAS,EAAE,EAAE,CAAC;QAChB,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/dist/lib.js ADDED
@@ -0,0 +1,10 @@
1
+ // Library entry — lets flowpad-mcp-local (the bundled PUBLIC stdio tool) reuse the
2
+ // server + client WITHOUT copying any logic. flowpad-mcp-local imports these, attaches
3
+ // a StdioServerTransport, and esbuild-bundles the whole tree (this + flowpad-core) into
4
+ // one self-contained minified file. The CLI entry (index.ts / bin) stays the
5
+ // hosted-HTTP + local-dev runner.
6
+ // ts-unused-exports:disable-next-line
7
+ export { createServer } from './server.js';
8
+ // ts-unused-exports:disable-next-line
9
+ export { FlowpadClient } from './client.js';
10
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,uFAAuF;AACvF,wFAAwF;AACxF,6EAA6E;AAC7E,kCAAkC;AAClC,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,sCAAsC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,82 @@
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
@@ -0,0 +1 @@
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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