sbuilder-mcp 0.95.2 → 0.95.4
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 +12 -0
- package/CHANGELOG.vi.md +12 -0
- package/dist/catalog/elements.generated.js +4450 -1042
- package/dist/domains/site/builder.js +28 -2
- package/dist/domains/site/readiness.js +30 -2
- package/dist/domains/site/writecheck.js +3 -0
- package/dist/tools/page.js +30 -4
- package/package.json +1 -1
|
@@ -143,17 +143,43 @@ export function addSubtree(doc, parentId, spec, index, guard) {
|
|
|
143
143
|
soft(guard, () => refuseSecondTemplate(doc.doc, parentId, 'Adding'));
|
|
144
144
|
const patches = [];
|
|
145
145
|
const ids = [];
|
|
146
|
+
const pending = new Map();
|
|
146
147
|
const build = (s, parentNodeId) => {
|
|
147
148
|
refuseComposedStamp(s.specials);
|
|
149
|
+
// A base-only config key in a breakpoint slot is read from BASE alone, so
|
|
150
|
+
// it is routed there exactly as sb_set routes it (trap 4).
|
|
151
|
+
let config = s.config;
|
|
152
|
+
let responsive = s.responsive;
|
|
153
|
+
if (responsive) {
|
|
154
|
+
responsive = {};
|
|
155
|
+
for (const [bp, slot] of Object.entries(s.responsive)) {
|
|
156
|
+
const split = splitBaseOnly(s.type, slot.config ?? {});
|
|
157
|
+
if (Object.keys(split.base).length)
|
|
158
|
+
config = { ...config, ...split.base };
|
|
159
|
+
responsive[bp] = { ...slot, ...(slot.config ? { config: split.responsive } : {}) };
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// A REPEATER'S CARD INHERITS ITS ENTITY (editor migrateDatasetSource.ts). A
|
|
163
|
+
// `dataset-block` reads its OWN datasetSource, unset reads as product, so in a
|
|
164
|
+
// record/category list it derives bind-href ← product.url and publishes no
|
|
165
|
+
// card link — the editor heals that on open, the Go renderer never does, and
|
|
166
|
+
// the platform names the sb_* authoring API as where such cards come from.
|
|
167
|
+
if (s.type === 'dataset-block' && !config?.datasetSource) {
|
|
168
|
+
const listCfg = (pending.get(parentNodeId) ?? doc.doc.nodes[parentNodeId]);
|
|
169
|
+
const src = listCfg?.data?.type === 'list-dataset' ? listCfg.config?.datasetSource : undefined;
|
|
170
|
+
if (typeof src === 'string' && src !== '' && src !== 'product')
|
|
171
|
+
config = { ...config, datasetSource: src };
|
|
172
|
+
}
|
|
148
173
|
const n = createNode(s.type, {
|
|
149
174
|
name: s.name,
|
|
150
175
|
parent: parentNodeId,
|
|
151
176
|
style: s.style,
|
|
152
|
-
config
|
|
177
|
+
config,
|
|
153
178
|
specials: s.specials,
|
|
154
|
-
responsive
|
|
179
|
+
responsive,
|
|
155
180
|
states: s.states,
|
|
156
181
|
});
|
|
182
|
+
pending.set(n.id, n);
|
|
157
183
|
// A child the element declares as a SATELLITE (an icon's cart-count, a
|
|
158
184
|
// list's empty state) hangs off `config[key]`, exactly as a top-level
|
|
159
185
|
// `sb_add` of one does. The caller's nested spec takes the place of the
|
|
@@ -66,9 +66,37 @@ function isStore(input) {
|
|
|
66
66
|
}
|
|
67
67
|
if (input.pageNodes.some(boundProductAction))
|
|
68
68
|
return true;
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const byId = new Map();
|
|
70
|
+
for (const n of input.pageNodes)
|
|
71
|
+
if (n.id)
|
|
72
|
+
byId.set(n.id, n);
|
|
73
|
+
return input.pageNodes.some((n) => COMMERCE_TYPES.includes(n.data.type) && sellsThrough(n, byId));
|
|
71
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* A dataset node is commerce only over the CATALOGUE. Each one reads its own
|
|
77
|
+
* `config.datasetSource` (absent = the product default); a Collections list
|
|
78
|
+
* (`record`) is a hotel directory, not a shop — AURA, a booking-request site
|
|
79
|
+
* with no product anywhere, drew eight checkout/payment/shipping gaps from its
|
|
80
|
+
* hotel list alone.
|
|
81
|
+
*/
|
|
82
|
+
function sellsThrough(n, byId) {
|
|
83
|
+
if (!DATASET_TYPES.has(n.data.type))
|
|
84
|
+
return true;
|
|
85
|
+
// A card that does not name its own source sits in the list that does —
|
|
86
|
+
// AURA's hotel cards carry none inside a `record` list. Bounded: a document
|
|
87
|
+
// is a tree, but a malformed parent loop must not hang a review.
|
|
88
|
+
let src;
|
|
89
|
+
let x = n;
|
|
90
|
+
for (let hops = 0; x && src === undefined && hops < 64; hops++) {
|
|
91
|
+
src = x.config?.datasetSource;
|
|
92
|
+
if (src === undefined && x !== n && x.data.type === 'list-dataset')
|
|
93
|
+
break;
|
|
94
|
+
x = x.data.parent ? byId.get(x.data.parent) : undefined;
|
|
95
|
+
}
|
|
96
|
+
// brand: the product catalogue's brands (datasetEntities.ts) — a brand grid is a shop.
|
|
97
|
+
return src === undefined || src === '' || src === 'product' || src === 'category' || src === 'brand';
|
|
98
|
+
}
|
|
99
|
+
const DATASET_TYPES = new Set(['list-dataset', 'dataset-block', 'media-dataset', 'pricing-dataset', 'quantity-dataset']);
|
|
72
100
|
const published = (pages, type) => pages.some((p) => p.type === type && p.status === 'published');
|
|
73
101
|
const drafted = (pages, type) => pages.some((p) => p.type === type && p.status !== 'published');
|
|
74
102
|
/**
|
|
@@ -299,6 +299,9 @@ export function specCheck(spec) {
|
|
|
299
299
|
const born = ELEMENTS[s.type]?.defaults.specials ?? {};
|
|
300
300
|
if (s.config)
|
|
301
301
|
out.push(...writeCheck(s.type, 'config', s.config));
|
|
302
|
+
for (const slot of Object.values(s.responsive ?? {}))
|
|
303
|
+
if (slot.config)
|
|
304
|
+
out.push(...writeCheck(s.type, 'config', slot.config));
|
|
302
305
|
if (s.specials)
|
|
303
306
|
out.push(...writeCheck(s.type, 'specials', s.specials, { specials: { ...born, ...s.specials } }));
|
|
304
307
|
for (const c of s.children ?? [])
|
package/dist/tools/page.js
CHANGED
|
@@ -10,7 +10,7 @@ import { canvasVerdict, driftOf } from '../domains/site/pagestate.js';
|
|
|
10
10
|
import { PageDoc } from '../domains/site/document.js';
|
|
11
11
|
import { canonicalRoot, PAGE_ROOT_ID } from '../domains/site/ids.js';
|
|
12
12
|
import { addSubtree, setMany, baseOnlyKeys, moveNode, removeNode, duplicateNode, copyNodeInto, } from '../domains/site/builder.js';
|
|
13
|
-
import { baseOnlyNote } from '../domains/site/baseonly.js';
|
|
13
|
+
import { baseOnlyNote, splitBaseOnly } from '../domains/site/baseonly.js';
|
|
14
14
|
import { detachNote, presetIdOf, presetLayer } from '../domains/site/theme.js';
|
|
15
15
|
import { inertHintsFor } from '../domains/site/inert.js';
|
|
16
16
|
import { emptyEntityTemplateNote, hasSeed, layoutDocument, seedDocument, seedSummary, seededTypes, } from '../domains/site/storepage.js';
|
|
@@ -1043,14 +1043,24 @@ function heldTree(rootId, nodes) {
|
|
|
1043
1043
|
function formDocPath(siteId, formId) {
|
|
1044
1044
|
return `/api/sites/${encodeURIComponent(siteId)}/forms/${encodeURIComponent(formId)}/document`;
|
|
1045
1045
|
}
|
|
1046
|
-
|
|
1046
|
+
// STRICT. A plain z.object strips what it does not name, so `responsive` (a
|
|
1047
|
+
// nav hidden on phones) was dropped in silence, and so was an `events` list
|
|
1048
|
+
// the builder never reads: the node saved, looked right on desktop, and was
|
|
1049
|
+
// wrong everywhere else. An unknown key is now a refusal. `states` stays out:
|
|
1050
|
+
// a hover's home differs per element (config.stateHover on a button), which
|
|
1051
|
+
// sb_set routes and a raw spec slot would not.
|
|
1052
|
+
const slotSchema = z.object({ style: z.record(z.unknown()).optional(), config: z.record(z.unknown()).optional() }).strict();
|
|
1053
|
+
const specSchema = z.lazy(() => z
|
|
1054
|
+
.object({
|
|
1047
1055
|
type: z.string(),
|
|
1048
1056
|
name: z.string().optional(),
|
|
1049
1057
|
style: z.record(z.unknown()).optional(),
|
|
1050
1058
|
config: z.record(z.unknown()).optional(),
|
|
1051
1059
|
specials: z.record(z.unknown()).optional(),
|
|
1060
|
+
responsive: z.record(z.enum(['desktop', 'laptop', 'tablet', 'mobile']), slotSchema).optional(),
|
|
1052
1061
|
children: z.array(specSchema).optional(),
|
|
1053
|
-
})
|
|
1062
|
+
})
|
|
1063
|
+
.strict('spec keys are type, name, style, config, specials, responsive, children — a click is sb_event, data sb_bind, a hover sb_set with state'));
|
|
1054
1064
|
/**
|
|
1055
1065
|
* THE SITE'S OWN HEADER AND FOOTER, read off the page that already answers it.
|
|
1056
1066
|
*
|
|
@@ -1475,6 +1485,21 @@ export function registerPageTools(server, ctx) {
|
|
|
1475
1485
|
// node of the nested spec, as each will be born. Warned, still written.
|
|
1476
1486
|
const found = sayChecks([...specCheck(spec), ...session.formChecks(patches)], say);
|
|
1477
1487
|
const checks = found.length ? { checks: found } : {};
|
|
1488
|
+
// A base-only key in a breakpoint slot lands at BASE (addSubtree routes it,
|
|
1489
|
+
// as sb_set does) and so reaches every width — routed AND said.
|
|
1490
|
+
const movedKeys = new Map();
|
|
1491
|
+
const walkMoved = (n) => {
|
|
1492
|
+
for (const [bp, slot] of Object.entries(n.responsive ?? {})) {
|
|
1493
|
+
for (const k of Object.keys(splitBaseOnly(n.type, slot.config ?? {}).base))
|
|
1494
|
+
if (!movedKeys.has(k))
|
|
1495
|
+
movedKeys.set(k, bp);
|
|
1496
|
+
}
|
|
1497
|
+
for (const c of n.children ?? [])
|
|
1498
|
+
walkMoved(c);
|
|
1499
|
+
};
|
|
1500
|
+
walkMoved(spec);
|
|
1501
|
+
const moved = [...movedKeys].map(([k, bp]) => say(`base-only:${k}`, baseOnlyNote([k], bp))).filter((n) => !!n);
|
|
1502
|
+
const base_only = moved.length ? { base_only: moved.join(' ') } : {};
|
|
1478
1503
|
if (dry_run !== false) {
|
|
1479
1504
|
const refuse = session.wouldRefuse(patches);
|
|
1480
1505
|
return text({
|
|
@@ -1484,11 +1509,12 @@ export function registerPageTools(server, ctx) {
|
|
|
1484
1509
|
...(refuse ? { would_refuse: refuse } : {}),
|
|
1485
1510
|
...(inert ? { inert } : {}),
|
|
1486
1511
|
...checks,
|
|
1512
|
+
...base_only,
|
|
1487
1513
|
...forced,
|
|
1488
1514
|
});
|
|
1489
1515
|
}
|
|
1490
1516
|
await session.applyAndSave(patches);
|
|
1491
|
-
return text({ added: ids, rev: d.rev, ...(inert ? { inert } : {}), ...checks, ...forced });
|
|
1517
|
+
return text({ added: ids, rev: d.rev, ...(inert ? { inert } : {}), ...checks, ...base_only, ...forced });
|
|
1492
1518
|
});
|
|
1493
1519
|
server.registerTool('sb_set', {
|
|
1494
1520
|
description: 'Write style, config or specials keys on one node, or on many through edits (one ' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sbuilder-mcp",
|
|
3
|
-
"version": "0.95.
|
|
3
|
+
"version": "0.95.4",
|
|
4
4
|
"description": "MCP server that designs and operates a Store Builder site — pages, data, theme and publish — through the platform's own API and live-edit protocol.",
|
|
5
5
|
"mcpName": "io.github.vuluu2k/sbuilder-mcp",
|
|
6
6
|
"type": "module",
|