@ompo-design/mcp-server 0.1.9 → 0.1.10
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/apply-plan.js +108 -27
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
package/dist/apply-plan.js
CHANGED
|
@@ -2,8 +2,99 @@ const OMPO_GLOSSARY = {
|
|
|
2
2
|
gap: `Ompo "Gap" is the space between children inside a flex or grid container. Apply \`gap\` on the parent layout element (not on children). The parent needs \`display: flex\` or \`display: grid\`. Example: gap "16px" → CSS \`gap: 16px\` or Tailwind \`gap-4\`.`,
|
|
3
3
|
fill: `Ompo "Fill" means an element should expand to consume free space inside its parent. Fill is NOT a CSS property — read \`widthMode: fill\` / \`heightMode: fill\` together with \`ensureParentFlex\`, \`flexGrow\`, \`flexShrink\`, \`flexBasis\`, and \`alignSelf\` on the same selector. Parent must be \`display: flex\`. Main axis (direction of flex): use \`flex: 1 1 0\` (grow/shrink/basis). Cross axis: use \`align-self: stretch\` and remove fixed width/height on that axis. If \`ensureParentFlex\` is present, make the parent a flex container with that direction first.`,
|
|
4
4
|
fit: `Ompo "Fit" means size to content. Map \`widthMode: fit\` → \`width: fit-content\`, \`heightMode: fit\` → \`height: fit-content\` (or the project's equivalent).`,
|
|
5
|
-
imageFill: `Ompo image background fill: copy the source file from \`backgroundImageSource\` into the project (e.g. public/images/), then set \`background-image\` to a project-relative url(), with \`background-size: cover\`, \`background-position: center\`, and \`background-repeat: no-repeat\`. Do not commit file:// URLs to source
|
|
5
|
+
imageFill: `Ompo image background fill: copy the source file from \`backgroundImageSource\` into the project (e.g. public/images/), then set \`background-image\` to a project-relative url(), with \`background-size: cover\`, \`background-position: center\`, and \`background-repeat: no-repeat\`. Do not commit file:// URLs to source.`,
|
|
6
|
+
domMove: `Ompo DOM move: reorder or reparent elements in source markup/components. Use movedElement anchors (tag, id, class, textSnippet) to find nodes. destinationChildren is the authoritative sibling order after the move — match this order in JSX/HTML or reorder mapped arrays. CSS alone cannot satisfy a dom.move.`
|
|
6
7
|
};
|
|
8
|
+
function describeAnchor(anchor) {
|
|
9
|
+
const parts = [anchor.tagName];
|
|
10
|
+
if (anchor.id)
|
|
11
|
+
parts.push(`#${anchor.id}`);
|
|
12
|
+
if (anchor.className) {
|
|
13
|
+
const classes = anchor.className.split(/\s+/).filter(Boolean).slice(0, 3).join('.');
|
|
14
|
+
if (classes)
|
|
15
|
+
parts.push(`.${classes}`);
|
|
16
|
+
}
|
|
17
|
+
if (anchor.textSnippet)
|
|
18
|
+
parts.push(`"${anchor.textSnippet}"`);
|
|
19
|
+
return parts.join(' ');
|
|
20
|
+
}
|
|
21
|
+
function formatChildOrder(children, movedSelector) {
|
|
22
|
+
return children.map((child, index) => {
|
|
23
|
+
const marker = child.selector === movedSelector ? ' ← moved element' : '';
|
|
24
|
+
return `${index + 1}. ${describeAnchor(child)}${marker}`;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function buildDomMovePlan(operation) {
|
|
28
|
+
const reordered = operation.fromParentSelector === operation.toParentSelector;
|
|
29
|
+
const moved = operation.movedElement;
|
|
30
|
+
const steps = [];
|
|
31
|
+
if (moved) {
|
|
32
|
+
steps.push(`Find the moved element in source: ${describeAnchor(moved)}.`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
steps.push(`Locate element "${operation.selector}" in source using tag, id, class, or visible text.`);
|
|
36
|
+
}
|
|
37
|
+
if (operation.toParent) {
|
|
38
|
+
steps.push(`Destination parent: ${describeAnchor(operation.toParent)}.`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
steps.push(`Destination parent selector: "${operation.toParentSelector}".`);
|
|
42
|
+
}
|
|
43
|
+
if (operation.insertBefore) {
|
|
44
|
+
steps.push(`Place the moved element immediately before: ${describeAnchor(operation.insertBefore)}.`);
|
|
45
|
+
}
|
|
46
|
+
else if (operation.destinationChildren && operation.destinationChildren.length > 0) {
|
|
47
|
+
steps.push('Place the moved element as the last child of the destination parent.');
|
|
48
|
+
}
|
|
49
|
+
if (operation.destinationChildren && operation.destinationChildren.length > 0) {
|
|
50
|
+
steps.push('Match this sibling order in source (structural snapshot after the move):');
|
|
51
|
+
steps.push(...formatChildOrder(operation.destinationChildren, operation.selector));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
steps.push(reordered
|
|
55
|
+
? `Reorder inside the parent from index ${operation.fromIndex} to index ${operation.index}.`
|
|
56
|
+
: `Move from "${operation.fromParentSelector}" (index ${operation.fromIndex}) to "${operation.toParentSelector}" at index ${operation.index}.`);
|
|
57
|
+
}
|
|
58
|
+
if (operation.fromChildrenBefore && operation.fromChildrenBefore.length > 0) {
|
|
59
|
+
steps.push('Previous sibling order before the move:');
|
|
60
|
+
steps.push(...formatChildOrder(operation.fromChildrenBefore, operation.selector));
|
|
61
|
+
}
|
|
62
|
+
steps.push('Update JSX/HTML/component structure — this is a markup or children-order change, not CSS.', 'If children come from a mapped array (React .map, v-for, etc.), reorder that array or its data source.', 'Preserve element content and styling that Ompo did not change.');
|
|
63
|
+
const payload = {
|
|
64
|
+
selector: operation.selector,
|
|
65
|
+
fromParentSelector: operation.fromParentSelector,
|
|
66
|
+
fromIndex: operation.fromIndex,
|
|
67
|
+
toParentSelector: operation.toParentSelector,
|
|
68
|
+
insertIndex: operation.index,
|
|
69
|
+
reordered
|
|
70
|
+
};
|
|
71
|
+
if (moved)
|
|
72
|
+
payload.movedElement = moved;
|
|
73
|
+
if (operation.fromParent)
|
|
74
|
+
payload.fromParent = operation.fromParent;
|
|
75
|
+
if (operation.toParent)
|
|
76
|
+
payload.toParent = operation.toParent;
|
|
77
|
+
if (operation.insertBefore)
|
|
78
|
+
payload.insertBefore = operation.insertBefore;
|
|
79
|
+
if (operation.destinationChildren) {
|
|
80
|
+
payload.destinationChildren = operation.destinationChildren;
|
|
81
|
+
}
|
|
82
|
+
if (operation.fromChildrenBefore) {
|
|
83
|
+
payload.fromChildrenBefore = operation.fromChildrenBefore;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
kind: 'dom.move',
|
|
87
|
+
summary: moved
|
|
88
|
+
? reordered
|
|
89
|
+
? `Reorder ${describeAnchor(moved)} within its parent`
|
|
90
|
+
: `Move ${describeAnchor(moved)} to ${operation.toParent ? describeAnchor(operation.toParent) : operation.toParentSelector}`
|
|
91
|
+
: reordered
|
|
92
|
+
? `Reorder element within parent "${operation.toParentSelector}"`
|
|
93
|
+
: `Move element to parent "${operation.toParentSelector}"`,
|
|
94
|
+
steps,
|
|
95
|
+
payload
|
|
96
|
+
};
|
|
97
|
+
}
|
|
7
98
|
function formatChangedValue(property, value) {
|
|
8
99
|
const text = String(value);
|
|
9
100
|
if (text !== '')
|
|
@@ -199,32 +290,8 @@ function buildDomStructurePlan(operation) {
|
|
|
199
290
|
selector: operation.selector
|
|
200
291
|
}
|
|
201
292
|
};
|
|
202
|
-
case 'dom.move':
|
|
203
|
-
|
|
204
|
-
return {
|
|
205
|
-
kind: 'dom.move',
|
|
206
|
-
summary: reordered
|
|
207
|
-
? `Reorder element within parent "${operation.toParentSelector}"`
|
|
208
|
-
: `Move element to a new parent "${operation.toParentSelector}"`,
|
|
209
|
-
steps: [
|
|
210
|
-
`Locate element "${operation.selector}" in source using selector, tag, id, class, or nearby text.`,
|
|
211
|
-
reordered
|
|
212
|
-
? `Reorder it inside "${operation.toParentSelector}" from child index ${operation.fromIndex} to index ${operation.index}.`
|
|
213
|
-
: `Move it from "${operation.fromParentSelector}" (index ${operation.fromIndex}) to "${operation.toParentSelector}" at index ${operation.index}.`,
|
|
214
|
-
'Update JSX/HTML/component structure in source — this is a markup change, not a CSS tweak.',
|
|
215
|
-
'Preserve the element’s content and non-Ompo styling.',
|
|
216
|
-
'If the project uses mapped lists or arrays, update item order in data when that drives rendering.'
|
|
217
|
-
],
|
|
218
|
-
payload: {
|
|
219
|
-
selector: operation.selector,
|
|
220
|
-
fromParentSelector: operation.fromParentSelector,
|
|
221
|
-
fromIndex: operation.fromIndex,
|
|
222
|
-
toParentSelector: operation.toParentSelector,
|
|
223
|
-
insertIndex: operation.index,
|
|
224
|
-
reordered
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
}
|
|
293
|
+
case 'dom.move':
|
|
294
|
+
return buildDomMovePlan(operation);
|
|
228
295
|
case 'dom.delete':
|
|
229
296
|
return {
|
|
230
297
|
kind: 'dom.delete',
|
|
@@ -295,6 +362,14 @@ export function buildApplyPlan(bundle) {
|
|
|
295
362
|
if (domPlan)
|
|
296
363
|
domStructurePlans.push(domPlan);
|
|
297
364
|
domChanges.push(operation);
|
|
365
|
+
if (operation.kind === 'dom.move') {
|
|
366
|
+
if (!operation.movedElement && operation.selector.includes('nth-of-type')) {
|
|
367
|
+
warnings.push(`DOM move "${operation.selector}" uses nth-of-type selectors. Re-export from Ompo after rearranging to get richer anchors, or match by visible text and parent structure.`);
|
|
368
|
+
}
|
|
369
|
+
else if (operation.movedElement && !operation.movedElement.id && !operation.movedElement.textSnippet) {
|
|
370
|
+
warnings.push(`DOM move target "${describeAnchor(operation.movedElement)}" has no id or text. Use destinationChildren order and parent context to locate it in source.`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
298
373
|
if (operation.kind === 'dom.flexWrap') {
|
|
299
374
|
for (const child of operation.children) {
|
|
300
375
|
if (!child.id && !child.className && child.selector.includes('nth-of-type')) {
|
|
@@ -318,6 +393,8 @@ export function buildApplyPlan(bundle) {
|
|
|
318
393
|
'When widthMode or heightMode is "fill", apply the grouped flex properties together (flexGrow, flexBasis, alignSelf, removed width/height) — do not set a fixed px width/height on the filled axis.',
|
|
319
394
|
'Gap belongs on the flex/grid parent. Fill belongs on the child inside a flex parent.',
|
|
320
395
|
'DOM moves are in domStructurePlans and domChanges — reorder or reparent elements in source markup/components, not just CSS.',
|
|
396
|
+
'Read ompoGlossary.domMove before applying dom.move operations.',
|
|
397
|
+
'For dom.move: destinationChildren is the structural snapshot of the final sibling order — match it in JSX/HTML or reorder mapped arrays.',
|
|
321
398
|
'For dom.flexWrap: create a new wrapper, move matched children, then apply wrapperStyles.',
|
|
322
399
|
'Use child anchors (tag, id, class, textSnippet) to find elements in source when selectors are unstable.',
|
|
323
400
|
'Prefer the smallest possible diff for each file.'
|
|
@@ -329,6 +406,7 @@ export function explainEdit(bundle) {
|
|
|
329
406
|
const styleCount = bundle.operations.filter((operation) => operation.kind === 'style').length;
|
|
330
407
|
const textCount = bundle.operations.filter((operation) => operation.kind === 'text').length;
|
|
331
408
|
const flexWrapCount = bundle.operations.filter((operation) => operation.kind === 'dom.flexWrap').length;
|
|
409
|
+
const moveCount = bundle.operations.filter((operation) => operation.kind === 'dom.move').length;
|
|
332
410
|
const domCount = bundle.operations.length - styleCount - textCount;
|
|
333
411
|
const scopeLabel = bundle.scope.mode === 'subtree' && bundle.scope.rootLabel
|
|
334
412
|
? `${bundle.scope.rootLabel} and its children`
|
|
@@ -342,6 +420,9 @@ export function explainEdit(bundle) {
|
|
|
342
420
|
if (flexWrapCount > 0) {
|
|
343
421
|
lines.push(`${flexWrapCount} flex-wrap operation${flexWrapCount === 1 ? '' : 's'}`);
|
|
344
422
|
}
|
|
423
|
+
if (moveCount > 0) {
|
|
424
|
+
lines.push(`${moveCount} DOM move${moveCount === 1 ? '' : 's'} — apply via domStructurePlans (markup/children order, not CSS)`);
|
|
425
|
+
}
|
|
345
426
|
lines.push(`Source preview: ${bundle.source.url}`);
|
|
346
427
|
return lines.join('\n');
|
|
347
428
|
}
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import { getOmpoEditsStorePath } from './edits-path.js';
|
|
|
7
7
|
import { readOmpoMcpSession } from './session.js';
|
|
8
8
|
import { readMcpTokenBalance } from './tokens.js';
|
|
9
9
|
const PACKAGE_NAME = '@ompo-design/mcp-server';
|
|
10
|
-
const PACKAGE_VERSION = '0.1.
|
|
10
|
+
const PACKAGE_VERSION = '0.1.10';
|
|
11
11
|
const SERVER_NAME = 'ompo';
|
|
12
12
|
function resolveExecutable(name) {
|
|
13
13
|
try {
|
|
@@ -187,7 +187,7 @@ async function runDoctor() {
|
|
|
187
187
|
console.log('Edits: none yet (click Send in Ompo first)');
|
|
188
188
|
}
|
|
189
189
|
console.log('');
|
|
190
|
-
console.log('If tools skip token usage, quit and reopen Claude Code to reload MCP v0.1.
|
|
190
|
+
console.log('If tools skip token usage, quit and reopen Claude Code to reload MCP v0.1.10+');
|
|
191
191
|
console.log('Global install: npx @ompo-design/mcp-server setup-global');
|
|
192
192
|
}
|
|
193
193
|
function printProjectNextSteps(projectRoot) {
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { getOmpoEditsStorePath } from './edits-path.js';
|
|
|
10
10
|
import { McpTokenError } from './tokens.js';
|
|
11
11
|
const server = new McpServer({
|
|
12
12
|
name: 'ompo-mcp-server',
|
|
13
|
-
version: '0.1.
|
|
13
|
+
version: '0.1.10'
|
|
14
14
|
});
|
|
15
15
|
function requireEditsStore() {
|
|
16
16
|
const storePath = getOmpoEditsStorePath();
|
package/dist/types.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export type DomMoveOperation = {
|
|
|
23
23
|
fromIndex: number;
|
|
24
24
|
toParentSelector: string;
|
|
25
25
|
index: number;
|
|
26
|
+
movedElement?: ElementAnchor;
|
|
27
|
+
fromParent?: ElementAnchor;
|
|
28
|
+
toParent?: ElementAnchor;
|
|
29
|
+
insertBefore?: ElementAnchor;
|
|
30
|
+
destinationChildren?: ElementAnchor[];
|
|
31
|
+
fromChildrenBefore?: ElementAnchor[];
|
|
26
32
|
};
|
|
27
33
|
export type DomDeleteOperation = {
|
|
28
34
|
kind: 'dom.delete';
|