@plitzi/sdk-mcp 0.38.6 → 0.38.8
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 +397 -0
- package/README.md +9 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -3
- package/dist/modules/mcp/helpers/guide.js +74 -35
- package/dist/modules/mcp/index.d.ts +2 -2
- package/dist/modules/mcp/server.d.ts +4 -4
- package/dist/modules/mcp/server.js +10 -5
- package/dist/modules/mcp/tests/cheapMistakes.test.d.ts +1 -0
- package/dist/modules/mcp/tests/helpers.d.ts +9 -2
- package/dist/modules/mcp/tests/intents.test.d.ts +1 -0
- package/dist/modules/mcp/tests/look.test.d.ts +1 -0
- package/dist/modules/mcp/tools/apply/index.d.ts +706 -62
- package/dist/modules/mcp/tools/apply/index.js +70 -20
- package/dist/modules/mcp/tools/describeOperation.d.ts +11 -0
- package/dist/modules/mcp/tools/describeOperation.js +40 -0
- package/dist/modules/mcp/tools/describeOperation.test.d.ts +1 -0
- package/dist/modules/mcp/tools/index.d.ts +1 -6
- package/dist/modules/mcp/tools/index.js +12 -9
- package/dist/modules/mcp/tools/intents.d.ts +5 -0
- package/dist/modules/mcp/tools/intents.js +201 -0
- package/dist/modules/mcp/tools/look.d.ts +17 -0
- package/dist/modules/mcp/tools/look.js +32 -0
- package/dist/modules/mcp/tools/operations/closed.d.ts +7 -0
- package/dist/modules/mcp/tools/operations/closed.js +29 -0
- package/dist/modules/mcp/tools/operations/index.d.ts +2928 -359
- package/dist/modules/mcp/tools/operations/index.js +72 -51
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/schema/operations.d.ts +5 -5
- package/dist/modules/mcp/tools/operations/schema/shared.d.ts +3 -3
- package/dist/modules/mcp/tools/operations/schema/shared.js +7 -6
- package/dist/modules/mcp/tools/operations/schemaIds.js +11 -5
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +2 -1
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +2 -1
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +8 -1
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +90 -0
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +2 -1
- package/dist/modules/mcp/tools/operations/style/operations.d.ts +639 -9
- package/dist/modules/mcp/tools/operations/style/shared.d.ts +394 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +26 -8
- package/dist/modules/mcp/tools/operations/style/translator.js +26 -1
- package/dist/modules/mcp/tools/operations/style/validate.d.ts +4 -0
- package/dist/modules/mcp/tools/operations/style/validate.js +63 -0
- package/dist/modules/mcp/tools/operations/style/write.d.ts +1 -1
- package/dist/modules/mcp/tools/operations/style/write.js +88 -2
- package/dist/modules/mcp/tools/render.d.ts +675 -45
- package/dist/modules/mcp/tools/render.js +5 -1
- package/dist/modules/mcp/tools/shared/draftBatch.d.ts +3 -2
- package/dist/modules/mcp/tools/shared/draftBatch.js +16 -5
- package/dist/modules/mcp/tools/shared/effects.d.ts +2 -0
- package/dist/modules/mcp/tools/shared/effects.js +155 -0
- package/dist/modules/mcp/tools/shared/effects.test.d.ts +1 -0
- package/dist/modules/mcp/tools/shared/look.d.ts +32 -0
- package/dist/modules/mcp/tools/shared/look.js +128 -0
- package/dist/modules/mcp/tools/shared/normalizeOperations.d.ts +6 -0
- package/dist/modules/mcp/tools/shared/normalizeOperations.js +37 -0
- package/dist/modules/mcp/tools/shared/repeats.d.ts +13 -0
- package/dist/modules/mcp/tools/shared/repeats.js +38 -0
- package/dist/modules/mcp/tools/shared/tool.d.ts +9 -6
- package/dist/modules/mcp/tools/shared/tool.js +2 -1
- package/dist/modules/mcp/tools/shared/validator/context.d.ts +0 -1
- package/dist/modules/mcp/tools/shared/validator/elements.js +0 -1
- package/dist/modules/mcp/tools/shared/validator/index.js +25 -2
- package/dist/modules/mcp/types/aiSchema.d.ts +13 -1
- package/dist/modules/mcp/types/screenshotTypes.d.ts +3 -3
- package/dist/modules/mcp/types/toolTypes.d.ts +2 -4
- package/dist/options.d.ts +4 -5
- package/dist/preview/createPreview.js +9 -18
- package/package.json +7 -7
- package/skills/plitzi-render/SKILL.md +8 -184
- package/skills/plitzi-render/reference/good-call.md +88 -0
- package/skills/plitzi-render/reference/interactive.md +64 -0
- package/skills/plitzi-render/reference/looks.md +29 -0
- package/dist/modules/mcp/tools/preview.d.ts +0 -793
- package/dist/modules/mcp/tools/preview.js +0 -37
- package/dist/modules/mcp/tools/screenshot.d.ts +0 -1078
- package/dist/modules/mcp/tools/screenshot.js +0 -127
- package/dist/modules/mcp/tools/validate.d.ts +0 -1069
- package/dist/modules/mcp/tools/validate.js +0 -32
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { expandShorthand } from "../../../catalogs/index.js";
|
|
2
|
+
import { fail } from "../../../helpers/opResult.js";
|
|
3
|
+
import { STYLE_MOTION_CONDITIONS, canonicalCondition } from "@plitzi/sdk-shared/style/styleConditions";
|
|
4
|
+
import { CONTENT_PSEUDOS, GENERATED_PSEUDOS, PSEUDO_PROPERTIES, STYLE_PSEUDOS, isContentValue, isStylePseudo, pseudoHonours } from "@plitzi/sdk-shared/style/stylePseudos";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/style/validate.ts
|
|
6
|
+
var MODES = [
|
|
7
|
+
"desktop",
|
|
8
|
+
"tablet",
|
|
9
|
+
"mobile"
|
|
10
|
+
];
|
|
11
|
+
var CONDITION_HINT = `Use ${STYLE_MOTION_CONDITIONS.join(" or ")}, or a container's width — "container (max-width: 30rem)", "container card (min-width: 480px)" (min-width, max-width or both joined by "and", in px, rem, em or ch).`;
|
|
12
|
+
/** Every rule set of a part — per breakpoint and in each of its states — as it is stored: longhands. */
|
|
13
|
+
var rulesOf = (part) => [...MODES.flatMap((mode) => part[mode] ? [expandShorthand(part[mode])] : []), ...Object.values(part.states ?? {}).flatMap((states) => MODES.flatMap((mode) => states[mode] ? [expandShorthand(states[mode])] : []))];
|
|
14
|
+
var pseudoProblem = (path, name, part) => {
|
|
15
|
+
if (!isStylePseudo(name)) {
|
|
16
|
+
const bare = name.replace(/^:+/, "");
|
|
17
|
+
return fail(path, `"${name}" is not a pseudo-element a class dresses`, isStylePseudo(bare) ? `Write it without the colons: "${bare}".` : `Use one of ${STYLE_PSEUDOS.join(", ")}.`, [...STYLE_PSEUDOS]);
|
|
18
|
+
}
|
|
19
|
+
const rules = rulesOf(part);
|
|
20
|
+
for (const rule of rules) for (const [property, value] of Object.entries(rule)) {
|
|
21
|
+
if (property === "content") {
|
|
22
|
+
if (!CONTENT_PSEUDOS.includes(name)) return fail(path, `content on ::${name} draws nothing`, `Only ${CONTENT_PSEUDOS.map((pseudo) => `::${pseudo}`).join(", ")} take one.`);
|
|
23
|
+
if (!isContentValue(String(value))) return fail(path, `content: ${String(value)} on ::${name} is not text CSS can read, so nothing is drawn`, `Write the text in quotes inside the string — "\\"${String(value)}\\"" — and an empty box as "\\"\\""; counter(), attr() and url() are written as they are.`);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (!pseudoHonours(name, property)) return fail(path, `${property} on ::${name} is dropped by every browser`, `::${name} honours ${(PSEUDO_PROPERTIES[name] ?? []).join(", ")}; style the element itself for the rest.`);
|
|
27
|
+
}
|
|
28
|
+
if (GENERATED_PSEUDOS.includes(name) && !rules.some((rule) => Object.hasOwn(rule, "content"))) return fail(path, `::${name} has no content, so nothing is drawn`, "Give it one: content \"\\\"\\\"\" for an empty box.");
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
var pseudosProblem = (path, pseudos) => {
|
|
32
|
+
for (const [name, part] of Object.entries(pseudos ?? {})) {
|
|
33
|
+
const problem = pseudoProblem(`${path}pseudos.${name}`, name, part);
|
|
34
|
+
if (problem) return problem;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
var slotProblem = (path, slot) => {
|
|
39
|
+
const own = pseudosProblem(path, slot.pseudos);
|
|
40
|
+
if (own) return own;
|
|
41
|
+
for (const [name, variant] of Object.entries(slot.variants ?? {})) {
|
|
42
|
+
const problem = pseudosProblem(`${path}variants.${name}.`, variant.pseudos);
|
|
43
|
+
if (problem) return problem;
|
|
44
|
+
}
|
|
45
|
+
for (const [key, condition] of Object.entries(slot.conditions ?? {})) {
|
|
46
|
+
if (!canonicalCondition(key)) return fail(`${path}conditions.${key}`, `"${key}" is not a condition a class's rules can hold under`, CONDITION_HINT);
|
|
47
|
+
const problem = pseudosProblem(`${path}conditions.${key}.`, condition.pseudos);
|
|
48
|
+
if (problem) return problem;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
/** The first problem with a style write — its base selector, then each slot — or `null` when it can be written. */
|
|
53
|
+
var styleInputProblem = (base, slots) => {
|
|
54
|
+
const own = slotProblem("", base);
|
|
55
|
+
if (own) return own;
|
|
56
|
+
for (const [name, slot] of Object.entries(slots ?? {})) {
|
|
57
|
+
const problem = slotProblem(`slots.${name}.`, slot);
|
|
58
|
+
if (problem) return problem;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { styleInputProblem };
|
|
@@ -5,7 +5,7 @@ import { DisplayMode, Style, TagType } from '@plitzi/sdk-shared';
|
|
|
5
5
|
export declare const MODES: DisplayMode[];
|
|
6
6
|
export { defUri, defsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from '../../../helpers';
|
|
7
7
|
export declare const guardKind: (style: Style, ref: string, want: TagType) => OpResult | null;
|
|
8
|
-
export declare const writeStyleItem: (style: Style, ref: string, base: DefinitionSlotInput, slots: Record<string, DefinitionSlotInput> | undefined, itemType: TagType, componentType: string | undefined) =>
|
|
8
|
+
export declare const writeStyleItem: (style: Style, ref: string, base: DefinitionSlotInput, slots: Record<string, DefinitionSlotInput> | undefined, itemType: TagType, componentType: string | undefined) => OpResult | null;
|
|
9
9
|
export declare const mergePatch: (existing: AIDefinition, basePatch: DefinitionSlotPatch, slotsPatch: Record<string, DefinitionSlotPatch> | undefined) => {
|
|
10
10
|
base: DefinitionSlotInput;
|
|
11
11
|
slots: Record<string, DefinitionSlotInput> | undefined;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { defUri, defsUri, globalUri, globalsUri, idUri, idsUri, styleVarUri, styleVarsUri } from "../../../helpers/uris.js";
|
|
2
2
|
import { expandShorthand, expandShorthandPatch } from "../../../catalogs/index.js";
|
|
3
3
|
import { fail } from "../../../helpers/opResult.js";
|
|
4
|
+
import { styleInputProblem } from "./validate.js";
|
|
5
|
+
import { canonicalCondition } from "@plitzi/sdk-shared/style/styleConditions";
|
|
6
|
+
import { isStylePseudo } from "@plitzi/sdk-shared/style/stylePseudos";
|
|
4
7
|
import processSelector from "@plitzi/sdk-style/helpers/processSelector";
|
|
5
8
|
//#region src/modules/mcp/tools/operations/style/write.ts
|
|
6
9
|
var MODES = [
|
|
@@ -28,6 +31,30 @@ var guardKind = (style, ref, want) => {
|
|
|
28
31
|
if (!clash) return null;
|
|
29
32
|
return fail(KIND_FIELD[want], `"${ref}" is already ${KIND_LABEL[clash.type]}; it cannot be edited as ${KIND_LABEL[want]}`, `Edit it with ${KIND_TOOL[clash.type]}, or choose a different ${KIND_FIELD[want]}.`);
|
|
30
33
|
};
|
|
34
|
+
/** A part with rules and states — a pseudo-element, a variant, a condition — at one breakpoint, or nothing there. */
|
|
35
|
+
var partAt = (part, mode) => {
|
|
36
|
+
const block = {};
|
|
37
|
+
const css = part[mode];
|
|
38
|
+
if (css && Object.keys(css).length > 0) block.default = expandShorthand(css);
|
|
39
|
+
for (const [state, dm] of Object.entries(part.states ?? {})) if (dm[mode]) (block.states ??= {})[state] = expandShorthand(dm[mode]);
|
|
40
|
+
return block.default || block.states ? block : void 0;
|
|
41
|
+
};
|
|
42
|
+
var pseudosAt = (pseudos, mode) => {
|
|
43
|
+
const entries = Object.entries(pseudos ?? {}).flatMap(([pseudo, part]) => {
|
|
44
|
+
const block = partAt(part, mode);
|
|
45
|
+
return block && isStylePseudo(pseudo) ? [[pseudo, block]] : [];
|
|
46
|
+
});
|
|
47
|
+
return entries.length > 0 ? Object.fromEntries(entries) : void 0;
|
|
48
|
+
};
|
|
49
|
+
/** A variant or a condition at one breakpoint: its own part, and its pseudo-elements'. */
|
|
50
|
+
var variantAt = (part, mode) => {
|
|
51
|
+
const block = partAt(part, mode);
|
|
52
|
+
const pseudos = pseudosAt(part.pseudos, mode);
|
|
53
|
+
return block || pseudos ? {
|
|
54
|
+
...block,
|
|
55
|
+
...pseudos ? { pseudos } : {}
|
|
56
|
+
} : void 0;
|
|
57
|
+
};
|
|
31
58
|
var slotToBlocks = (slot) => {
|
|
32
59
|
const perMode = {};
|
|
33
60
|
for (const mode of MODES) {
|
|
@@ -35,7 +62,20 @@ var slotToBlocks = (slot) => {
|
|
|
35
62
|
const baseCss = slot[mode];
|
|
36
63
|
if (baseCss && Object.keys(baseCss).length > 0) block.default = expandShorthand(baseCss);
|
|
37
64
|
for (const [state, dm] of Object.entries(slot.states ?? {})) if (dm[mode]) (block.states ??= {})[state] = expandShorthand(dm[mode]);
|
|
38
|
-
for (const [name,
|
|
65
|
+
for (const [name, variant] of Object.entries(slot.variants ?? {})) {
|
|
66
|
+
const variantBlock = variantAt(variant, mode);
|
|
67
|
+
if (variantBlock) (block.variants ??= {})[name] = {
|
|
68
|
+
default: {},
|
|
69
|
+
...variantBlock
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const pseudos = pseudosAt(slot.pseudos, mode);
|
|
73
|
+
if (pseudos) block.pseudos = pseudos;
|
|
74
|
+
for (const [key, condition] of Object.entries(slot.conditions ?? {})) {
|
|
75
|
+
const conditionBlock = variantAt(condition, mode);
|
|
76
|
+
const canonical = canonicalCondition(key) ?? key;
|
|
77
|
+
if (conditionBlock) (block.conditions ??= {})[canonical] = conditionBlock;
|
|
78
|
+
}
|
|
39
79
|
for (const [ancestor, condition] of Object.entries(slot.ancestors ?? {})) {
|
|
40
80
|
const conditionBlock = slotToBlocks(condition)[mode];
|
|
41
81
|
if (conditionBlock) (block.ancestors ??= {})[ancestor] = {
|
|
@@ -49,6 +89,8 @@ var slotToBlocks = (slot) => {
|
|
|
49
89
|
return perMode;
|
|
50
90
|
};
|
|
51
91
|
var writeStyleItem = (style, ref, base, slots, itemType, componentType) => {
|
|
92
|
+
const problem = styleInputProblem(base, slots);
|
|
93
|
+
if (problem) return problem;
|
|
52
94
|
for (const mode of MODES) {
|
|
53
95
|
const attributes = {};
|
|
54
96
|
const baseBlocks = slotToBlocks(base);
|
|
@@ -70,6 +112,7 @@ var writeStyleItem = (style, ref, base, slots, itemType, componentType) => {
|
|
|
70
112
|
style.platform[mode][ref] = styleItem;
|
|
71
113
|
}
|
|
72
114
|
}
|
|
115
|
+
return null;
|
|
73
116
|
};
|
|
74
117
|
var mergeCss = (base, patch) => {
|
|
75
118
|
const merged = { ...base };
|
|
@@ -111,14 +154,57 @@ var mergeAncestors = (base, patch) => {
|
|
|
111
154
|
}
|
|
112
155
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
113
156
|
};
|
|
157
|
+
var mergePart = (base, patch) => {
|
|
158
|
+
const merged = mergeDisplayMode(base, patch);
|
|
159
|
+
const states = mergeNamedModes(base?.states, patch?.states);
|
|
160
|
+
if (states) merged.states = states;
|
|
161
|
+
return merged;
|
|
162
|
+
};
|
|
163
|
+
var mergePseudos = (base, patch) => {
|
|
164
|
+
const names = /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...Object.keys(patch ?? {})]);
|
|
165
|
+
const result = {};
|
|
166
|
+
for (const name of names) {
|
|
167
|
+
const partPatch = patch?.[name];
|
|
168
|
+
if (partPatch === null) continue;
|
|
169
|
+
const merged = mergePart(base?.[name], partPatch);
|
|
170
|
+
if (Object.keys(merged).length > 0) result[name] = merged;
|
|
171
|
+
}
|
|
172
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
173
|
+
};
|
|
174
|
+
var mergeVariantPart = (base, patch) => {
|
|
175
|
+
const merged = mergePart(base, patch);
|
|
176
|
+
const pseudos = mergePseudos(base?.pseudos, patch?.pseudos);
|
|
177
|
+
if (pseudos) merged.pseudos = pseudos;
|
|
178
|
+
return merged;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Variants or conditions, each merged whole — its rules, states and pseudo-elements — and one patched to `null`
|
|
182
|
+
* removed. A condition is matched by the one spelling the document keeps, so a patch may write it as it likes.
|
|
183
|
+
*/
|
|
184
|
+
var mergeVariantParts = (base, patch, keyOf = (key) => key) => {
|
|
185
|
+
const patches = new Map(Object.entries(patch ?? {}).map(([key, value]) => [keyOf(key), value]));
|
|
186
|
+
const names = /* @__PURE__ */ new Set([...Object.keys(base ?? {}), ...patches.keys()]);
|
|
187
|
+
const result = {};
|
|
188
|
+
for (const name of names) {
|
|
189
|
+
const partPatch = patches.get(name);
|
|
190
|
+
if (partPatch === null) continue;
|
|
191
|
+
const merged = mergeVariantPart(base?.[name], partPatch);
|
|
192
|
+
if (Object.keys(merged).length > 0) result[name] = merged;
|
|
193
|
+
}
|
|
194
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
195
|
+
};
|
|
114
196
|
var mergeSlot = (base, patch) => {
|
|
115
197
|
const merged = mergeDisplayMode(base, patch);
|
|
116
198
|
const states = mergeNamedModes(base?.states, patch.states);
|
|
117
199
|
if (states) merged.states = states;
|
|
118
|
-
const variants =
|
|
200
|
+
const variants = mergeVariantParts(base?.variants, patch.variants);
|
|
119
201
|
if (variants) merged.variants = variants;
|
|
120
202
|
const ancestors = mergeAncestors(base?.ancestors, patch.ancestors);
|
|
121
203
|
if (ancestors) merged.ancestors = ancestors;
|
|
204
|
+
const pseudos = mergePseudos(base?.pseudos, patch.pseudos);
|
|
205
|
+
if (pseudos) merged.pseudos = pseudos;
|
|
206
|
+
const conditions = mergeVariantParts(base?.conditions, patch.conditions, (key) => canonicalCondition(key) ?? key);
|
|
207
|
+
if (conditions) merged.conditions = conditions;
|
|
122
208
|
return merged;
|
|
123
209
|
};
|
|
124
210
|
var mergePatch = (existing, basePatch, slotsPatch) => {
|