@ompo-design/mcp-server 0.1.10 → 0.1.11
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 +75 -17
- 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
|
@@ -3,7 +3,10 @@ const OMPO_GLOSSARY = {
|
|
|
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
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
|
+
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.`,
|
|
7
|
+
insertText: `Ompo text insert: the user added a new text block (usually <p>). insertedElement carries insertKind "text", a stable data-ompo-insert-id selector, and textSnippet for the current copy. Apply as markup or a text component at parent/index; check separate text operations for edits after insert.`,
|
|
8
|
+
insertIcon: `Ompo icon insert: the user added an Iconify icon (span.ompo-insert-icon) or editable SVG. iconId is the Iconify name (e.g. lucide:home) when known. Prefer the project's icon library or @iconify/react with that id instead of inlining raw SVG when possible. Size, fill color, and stroke changes appear as style operations on the same stable data-ompo-insert-id or data-ompo-icon-id selector.`,
|
|
9
|
+
iconStroke: `Ompo icon/SVG stroke: iconStrokeWidth sets stroke-width on the inner SVG; iconStrokeColor sets stroke (often currentColor). Applies to inserted icons and native SVG elements selected in Ompo.`
|
|
7
10
|
};
|
|
8
11
|
function describeAnchor(anchor) {
|
|
9
12
|
const parts = [anchor.tagName];
|
|
@@ -14,10 +17,62 @@ function describeAnchor(anchor) {
|
|
|
14
17
|
if (classes)
|
|
15
18
|
parts.push(`.${classes}`);
|
|
16
19
|
}
|
|
20
|
+
if (anchor.insertKind === 'icon' && anchor.iconId) {
|
|
21
|
+
parts.push(`icon:${anchor.iconId}`);
|
|
22
|
+
}
|
|
17
23
|
if (anchor.textSnippet)
|
|
18
24
|
parts.push(`"${anchor.textSnippet}"`);
|
|
19
25
|
return parts.join(' ');
|
|
20
26
|
}
|
|
27
|
+
function buildDomInsertPlan(operation) {
|
|
28
|
+
const inserted = operation.insertedElement;
|
|
29
|
+
const isIcon = operation.insertKind === 'icon';
|
|
30
|
+
const isText = operation.insertKind === 'text';
|
|
31
|
+
const steps = [];
|
|
32
|
+
if (operation.parent) {
|
|
33
|
+
steps.push(`Locate destination parent: ${describeAnchor(operation.parent)}.`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
steps.push(`Locate parent "${operation.parentSelector}" in source.`);
|
|
37
|
+
}
|
|
38
|
+
if (inserted) {
|
|
39
|
+
steps.push(`New element anchor: ${describeAnchor(inserted)} (selector: "${inserted.selector}").`);
|
|
40
|
+
}
|
|
41
|
+
else if (operation.selector) {
|
|
42
|
+
steps.push(`Inserted element selector: "${operation.selector}".`);
|
|
43
|
+
}
|
|
44
|
+
if (isText) {
|
|
45
|
+
steps.push(OMPO_GLOSSARY.insertText);
|
|
46
|
+
}
|
|
47
|
+
else if (isIcon) {
|
|
48
|
+
steps.push(OMPO_GLOSSARY.insertIcon);
|
|
49
|
+
if (operation.iconId) {
|
|
50
|
+
steps.push(`Iconify id: ${operation.iconId}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
steps.push(`Insert at child index ${operation.index}.`);
|
|
54
|
+
steps.push('Sanitize and adapt the HTML to the project’s component conventions before writing.');
|
|
55
|
+
const summary = isIcon
|
|
56
|
+
? `Insert Iconify icon${operation.iconId ? ` (${operation.iconId})` : ''}`
|
|
57
|
+
: isText
|
|
58
|
+
? 'Insert text block'
|
|
59
|
+
: 'Insert new element into the page';
|
|
60
|
+
return {
|
|
61
|
+
kind: 'dom.insert',
|
|
62
|
+
summary,
|
|
63
|
+
steps,
|
|
64
|
+
payload: {
|
|
65
|
+
parentSelector: operation.parentSelector,
|
|
66
|
+
insertIndex: operation.index,
|
|
67
|
+
html: operation.html,
|
|
68
|
+
selector: operation.selector,
|
|
69
|
+
insertKind: operation.insertKind,
|
|
70
|
+
iconId: operation.iconId,
|
|
71
|
+
insertedElement: operation.insertedElement,
|
|
72
|
+
parent: operation.parent
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
21
76
|
function formatChildOrder(children, movedSelector) {
|
|
22
77
|
return children.map((child, index) => {
|
|
23
78
|
const marker = child.selector === movedSelector ? ' ← moved element' : '';
|
|
@@ -224,6 +279,14 @@ function styleSuggestionForProperty(property, value, changed) {
|
|
|
224
279
|
};
|
|
225
280
|
}
|
|
226
281
|
break;
|
|
282
|
+
case 'iconStrokeWidth':
|
|
283
|
+
case 'iconStrokeColor':
|
|
284
|
+
return {
|
|
285
|
+
property,
|
|
286
|
+
value: formatChangedValue(property, value),
|
|
287
|
+
strategy: 'inline-style',
|
|
288
|
+
notes: OMPO_GLOSSARY.iconStroke
|
|
289
|
+
};
|
|
227
290
|
}
|
|
228
291
|
return {
|
|
229
292
|
property,
|
|
@@ -275,21 +338,7 @@ function buildDomStructurePlan(operation) {
|
|
|
275
338
|
}
|
|
276
339
|
};
|
|
277
340
|
case 'dom.insert':
|
|
278
|
-
return
|
|
279
|
-
kind: 'dom.insert',
|
|
280
|
-
summary: 'Insert new element into the page',
|
|
281
|
-
steps: [
|
|
282
|
-
`Locate parent "${operation.parentSelector}" in source.`,
|
|
283
|
-
`Insert the provided HTML at child index ${operation.index}.`,
|
|
284
|
-
'Sanitize and adapt the HTML to the project’s component conventions before writing.'
|
|
285
|
-
],
|
|
286
|
-
payload: {
|
|
287
|
-
parentSelector: operation.parentSelector,
|
|
288
|
-
insertIndex: operation.index,
|
|
289
|
-
html: operation.html,
|
|
290
|
-
selector: operation.selector
|
|
291
|
-
}
|
|
292
|
-
};
|
|
341
|
+
return buildDomInsertPlan(operation);
|
|
293
342
|
case 'dom.move':
|
|
294
343
|
return buildDomMovePlan(operation);
|
|
295
344
|
case 'dom.delete':
|
|
@@ -396,7 +445,8 @@ export function buildApplyPlan(bundle) {
|
|
|
396
445
|
'Read ompoGlossary.domMove before applying dom.move operations.',
|
|
397
446
|
'For dom.move: destinationChildren is the structural snapshot of the final sibling order — match it in JSX/HTML or reorder mapped arrays.',
|
|
398
447
|
'For dom.flexWrap: create a new wrapper, move matched children, then apply wrapperStyles.',
|
|
399
|
-
'
|
|
448
|
+
'For dom.insert with insertKind text or icon: read ompoGlossary.insertText / insertIcon; use insertedElement anchors and iconId when applying.',
|
|
449
|
+
'Use child anchors (tag, id, class, textSnippet, insertKind, iconId) to find elements in source when selectors are unstable.',
|
|
400
450
|
'Prefer the smallest possible diff for each file.'
|
|
401
451
|
],
|
|
402
452
|
ompoGlossary: OMPO_GLOSSARY
|
|
@@ -407,6 +457,8 @@ export function explainEdit(bundle) {
|
|
|
407
457
|
const textCount = bundle.operations.filter((operation) => operation.kind === 'text').length;
|
|
408
458
|
const flexWrapCount = bundle.operations.filter((operation) => operation.kind === 'dom.flexWrap').length;
|
|
409
459
|
const moveCount = bundle.operations.filter((operation) => operation.kind === 'dom.move').length;
|
|
460
|
+
const textInsertCount = bundle.operations.filter((operation) => operation.kind === 'dom.insert' && operation.insertKind === 'text').length;
|
|
461
|
+
const iconInsertCount = bundle.operations.filter((operation) => operation.kind === 'dom.insert' && operation.insertKind === 'icon').length;
|
|
410
462
|
const domCount = bundle.operations.length - styleCount - textCount;
|
|
411
463
|
const scopeLabel = bundle.scope.mode === 'subtree' && bundle.scope.rootLabel
|
|
412
464
|
? `${bundle.scope.rootLabel} and its children`
|
|
@@ -423,6 +475,12 @@ export function explainEdit(bundle) {
|
|
|
423
475
|
if (moveCount > 0) {
|
|
424
476
|
lines.push(`${moveCount} DOM move${moveCount === 1 ? '' : 's'} — apply via domStructurePlans (markup/children order, not CSS)`);
|
|
425
477
|
}
|
|
478
|
+
if (textInsertCount > 0) {
|
|
479
|
+
lines.push(`${textInsertCount} text insert${textInsertCount === 1 ? '' : 's'} — apply via domStructurePlans (markup at parent/index)`);
|
|
480
|
+
}
|
|
481
|
+
if (iconInsertCount > 0) {
|
|
482
|
+
lines.push(`${iconInsertCount} icon insert${iconInsertCount === 1 ? '' : 's'} — map iconId to project icons when possible`);
|
|
483
|
+
}
|
|
426
484
|
lines.push(`Source preview: ${bundle.source.url}`);
|
|
427
485
|
return lines.join('\n');
|
|
428
486
|
}
|
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.11';
|
|
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.11+');
|
|
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.11'
|
|
14
14
|
});
|
|
15
15
|
function requireEditsStore() {
|
|
16
16
|
const storePath = getOmpoEditsStorePath();
|
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ export type DomInsertOperation = {
|
|
|
15
15
|
index: number;
|
|
16
16
|
html: string;
|
|
17
17
|
selector?: string;
|
|
18
|
+
insertKind?: 'text' | 'icon';
|
|
19
|
+
iconId?: string;
|
|
20
|
+
insertedElement?: ElementAnchor;
|
|
21
|
+
parent?: ElementAnchor;
|
|
18
22
|
};
|
|
19
23
|
export type DomMoveOperation = {
|
|
20
24
|
kind: 'dom.move';
|
|
@@ -40,6 +44,8 @@ export type ElementAnchor = {
|
|
|
40
44
|
id?: string;
|
|
41
45
|
className?: string;
|
|
42
46
|
textSnippet?: string;
|
|
47
|
+
insertKind?: 'text' | 'icon';
|
|
48
|
+
iconId?: string;
|
|
43
49
|
};
|
|
44
50
|
export type DomFlexWrapOperation = {
|
|
45
51
|
kind: 'dom.flexWrap';
|