sbuilder-mcp 0.98.5 → 0.98.7

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 CHANGED
@@ -6,6 +6,22 @@ All notable changes to this project are documented in this file.
6
6
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
7
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.98.7] - 2026-10-29
10
+
11
+ ### Fixed
12
+ - `sb_publish` drops remembered cascade page ids that no longer exist in the page list instead of sending them, so an unknown id no longer makes the platform refuse the whole batch.
13
+ - `sb_page_state` reports `draft_ahead` for a page whose draft is hidden by the cascade, matching `unpublished_drafts`.
14
+ - A queued request that is cancelled before it reaches the front of the line no longer runs, so `sb_add` no longer saves a section twice.
15
+
16
+ ## [0.98.6] - 2026-10-29
17
+
18
+ ### Added
19
+ - `sb_add` and `sb_set` report a `hidden_band` check, once per process, when a node is hidden at base, because that hides it only at 1440px and wider, and name the per-breakpoint writes that hide it at every width.
20
+ - `sb_add`, `sb_set` and `sb_review` report `form_register_phone` for a register form whose phone field is not named `phone`.
21
+
22
+ ### Fixed
23
+ - `sb_set` and `sb_add` write `config.hidden` set at desktop to base, because the renderer reads only base for desktop and never read the desktop slot it was written to.
24
+
9
25
  ## [0.98.5] - 2026-10-29
10
26
 
11
27
  ### Added
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,22 @@ Mọi thay đổi đáng chú ý của dự án được ghi lại trong file n
6
6
  Định dạng dựa trên [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
7
  và dự án tuân theo [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.98.7] - 2026-10-29
10
+
11
+ ### Fixed
12
+ - `sb_publish` xoá khỏi bộ nhớ cascade các page id đã nhớ mà không còn trong danh sách trang thay vì gửi đi, nên một id lạ không còn làm platform từ chối cả lô.
13
+ - `sb_page_state` báo `draft_ahead` với trang có bản nháp bị cascade che, khớp với `unpublished_drafts`.
14
+ - Request đang xếp hàng mà bị huỷ trước khi tới đầu hàng không còn chạy, nên `sb_add` không còn lưu một section hai lần.
15
+
16
+ ## [0.98.6] - 2026-10-29
17
+
18
+ ### Added
19
+ - `sb_add` và `sb_set` báo check `hidden_band` (một lần mỗi process) khi node bị ẩn ở base, vì cách đó chỉ ẩn từ 1440px trở lên, và nêu các cách ghi theo từng breakpoint để ẩn ở mọi độ rộng.
20
+ - `sb_add`, `sb_set` và `sb_review` báo `form_register_phone` với form đăng ký có trường số điện thoại không tên `phone`.
21
+
22
+ ### Fixed
23
+ - `sb_set` và `sb_add` ghi `config.hidden` đặt ở desktop vào base, vì renderer chỉ đọc base cho desktop và không bao giờ đọc slot desktop mà giá trị này từng được ghi vào.
24
+
9
25
  ## [0.98.5] - 2026-10-29
10
26
 
11
27
  ### Added
@@ -45,17 +45,25 @@ const EXCEPTIONS = new Set(BASE_ONLY_EXCEPTIONS);
45
45
  export function isBaseOnlyConfig(type, key) {
46
46
  return BASE_ONLY.has(key) && !EXCEPTIONS.has(`${type}:${key}`);
47
47
  }
48
+ /**
49
+ * `config.hidden` AT DESKTOP IS THE BASE KEY. It does not cascade: desktop reads
50
+ * `node.config.hidden` and every narrower band only its own slot
51
+ * (render/css.go hiddenAt, editor trait/display.ts isHiddenAt), so
52
+ * `responsive.desktop.config.hidden` — where a default sb_set landed — is read by
53
+ * nothing. Not reported as base-only: it is not, at any other breakpoint.
54
+ */
55
+ const atBase = (type, key, bp) => isBaseOnlyConfig(type, key) || (key === 'hidden' && bp === 'desktop');
48
56
  /**
49
57
  * Split a config write into the keys that must land at base and the rest.
50
58
  *
51
59
  * Both halves are returned even when one is empty, so the caller writes the same
52
60
  * two patch groups every time rather than branching on which case it is in.
53
61
  */
54
- export function splitBaseOnly(type, keys) {
62
+ export function splitBaseOnly(type, keys, bp) {
55
63
  const base = {};
56
64
  const responsive = {};
57
65
  for (const [k, v] of Object.entries(keys)) {
58
- if (isBaseOnlyConfig(type, k))
66
+ if (atBase(type, k, bp))
59
67
  base[k] = v;
60
68
  else
61
69
  responsive[k] = v;
@@ -63,11 +71,11 @@ export function splitBaseOnly(type, keys) {
63
71
  return { base, responsive };
64
72
  }
65
73
  /** The same split for `unset`, which shares the slot a write lands in. */
66
- export function splitBaseOnlyKeys(type, keys) {
74
+ export function splitBaseOnlyKeys(type, keys, bp) {
67
75
  const base = [];
68
76
  const responsive = [];
69
77
  for (const k of keys) {
70
- if (isBaseOnlyConfig(type, k))
78
+ if (atBase(type, k, bp))
71
79
  base.push(k);
72
80
  else
73
81
  responsive.push(k);
@@ -169,7 +169,7 @@ export function addSubtree(doc, parentId, spec, index, guard) {
169
169
  if (responsive) {
170
170
  responsive = {};
171
171
  for (const [bp, slot] of Object.entries(s.responsive)) {
172
- const split = splitBaseOnly(s.type, slot.config ?? {});
172
+ const split = splitBaseOnly(s.type, slot.config ?? {}, bp);
173
173
  if (Object.keys(split.base).length)
174
174
  config = { ...config, ...split.base };
175
175
  responsive[bp] = { ...slot, ...(slot.config ? { config: split.responsive } : {}) };
@@ -508,9 +508,9 @@ export function setKeys(doc, id, keys, opts) {
508
508
  // routing precedent: the caller's intent is not in doubt, but a caller who
509
509
  // reads the node back must not have to hunt for the keys.
510
510
  const type = doc.node(id).data.type;
511
- const split = namespace === 'config' ? splitBaseOnly(type, keys) : { base: {}, responsive: keys };
511
+ const split = namespace === 'config' ? splitBaseOnly(type, keys, bp) : { base: {}, responsive: keys };
512
512
  const unsetSplit = namespace === 'config'
513
- ? splitBaseOnlyKeys(type, opts.unset ?? [])
513
+ ? splitBaseOnlyKeys(type, opts.unset ?? [], bp)
514
514
  : { base: [], responsive: opts.unset ?? [] };
515
515
  return [
516
516
  ...Object.entries(split.responsive).map(([k, v]) => ({
@@ -179,6 +179,8 @@ export const FIX = {
179
179
  form_booking_dates: 'Keep one date (an appointment) or two (a stay: check-in then check-out) — sb_remove id ' +
180
180
  '"<id>", or ask for it as text. Booking rules (closedDates, min/maxStayNights, capacity) ' +
181
181
  'read only the first two date fields.',
182
+ form_register_phone: 'sb_set id "<id>", namespace specials, keys { "name": "phone", "mapTo": "customer.phone", "inputType": "tel" } ' +
183
+ '— the palette\'s contact-phone row, the one name the sign-up reads.',
182
184
  };
183
185
  /** The template for `code`, with every `<name>` in `vars` substituted. */
184
186
  export function fill(code, vars) {
@@ -170,6 +170,27 @@ export function formFieldFindings(d, formType) {
170
170
  });
171
171
  }
172
172
  }
173
+ // A REGISTER form stores a phone only from the control named exactly `phone`
174
+ // (web_builder 6427c495b, runtime form.ts authValues — the palette's
175
+ // contact-phone row): any other name answers 200 and saves phone "". Silent
176
+ // when some field already posts as `phone`; the re-entry box is not a phone.
177
+ if (formType === 'register') {
178
+ const fields = formFields(d).filter((n) => collectsValue(n.data.type));
179
+ const phoneish = fields.find((n) => {
180
+ const s = n.specials ?? {};
181
+ return s.mapTo === 'customer.phone' || (s.inputType === 'tel' && s.mapTo !== 'customer.confirmPhone');
182
+ });
183
+ if (phoneish && !fields.some((n) => postedName(n) === 'phone')) {
184
+ out.push({
185
+ code: 'form_register_phone',
186
+ nodeId: phoneish.id,
187
+ type: phoneish.data.type,
188
+ key: 'name',
189
+ problem: `A register form saves the customer's phone only from the field named "phone"; this one posts as ` +
190
+ `"${postedName(phoneish)}", so every sign-up stores an empty phone.`,
191
+ });
192
+ }
193
+ }
173
194
  return out;
174
195
  }
175
196
  /** A posted-name suggestion from a label: "Dịch vụ" → "dich_vu". */
@@ -441,6 +441,34 @@ export function cascadeTail(node, written, id) {
441
441
  }
442
442
  return out;
443
443
  }
444
+ /**
445
+ * `config.hidden` IS PER BAND AND NEVER CASCADES (render/css.go hiddenAt,
446
+ * editor trait/display.ts isHiddenAt): base hides the node at ≥1440px ONLY, and
447
+ * laptop / tablet / mobile each read their own slot alone. An agent hiding at
448
+ * base expects it gone everywhere, so say which bands still show it — once per
449
+ * process, since the fact is the same for every node. `node` is AS IT WILL BE.
450
+ */
451
+ export function hiddenBand(node, id) {
452
+ if (node.config?.hidden !== true)
453
+ return [];
454
+ const shown = ['laptop', 'tablet', 'mobile'].filter((bp) => node.responsive?.[bp]?.config?.hidden !== true);
455
+ if (!shown.length)
456
+ return [];
457
+ return [
458
+ {
459
+ once: 'hidden-band',
460
+ note: {
461
+ code: 'hidden_band',
462
+ ...(id ? { id } : {}),
463
+ key: 'config.hidden',
464
+ problem: 'config.hidden does not cascade: at base it hides the node at ≥1440px only; laptop (1025–1439), ' +
465
+ `tablet (768–1024) and mobile (≤767) each read their own slot, so ${shown.join(', ')} still show it.`,
466
+ fix: `To hide it at every width, also write hidden:true at breakpoint ${shown.map((b) => `"${b}"`).join(', ')} — ` +
467
+ 'one sb_set with edits[] (sb_add: responsive.<bp>.config). To drop it from the page instead, sb_remove it.',
468
+ },
469
+ },
470
+ ];
471
+ }
444
472
  /** The same, for every node of a nested `sb_add` spec, as each will be born. */
445
473
  export function specCheck(spec, idOf) {
446
474
  const out = [];
@@ -451,6 +479,8 @@ export function specCheck(spec, idOf) {
451
479
  const born = d?.specials ?? {};
452
480
  if (s.config)
453
481
  out.push(...writeCheck(s.type, 'config', s.config));
482
+ // Born as addSubtree stores it: a desktop-slot `hidden` lands at base.
483
+ out.push(...hiddenBand({ config: { hidden: s.responsive?.desktop?.config?.hidden ?? s.config?.hidden }, responsive: s.responsive }, id));
454
484
  for (const slot of Object.values(s.responsive ?? {}))
455
485
  if (slot.config)
456
486
  out.push(...writeCheck(s.type, 'config', slot.config));
@@ -1,4 +1,4 @@
1
- import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
1
+ import { CallToolRequestSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
2
2
  /**
3
3
  * ONE OPEN DOCUMENT, ONE CALL AT A TIME, IN ARRIVAL ORDER.
4
4
  *
@@ -15,6 +15,12 @@ import { CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
15
15
  * library) and stay parallel. Call before the first `registerTool`, which is
16
16
  * when McpServer installs its `tools/call` handler.
17
17
  *
18
+ * A call the client CANCELLED while it waited (notifications/cancelled, or its
19
+ * own timeout) is skipped when it reaches the head: the SDK sends nothing for an
20
+ * aborted request either way, so running it only performs a write nobody sees —
21
+ * a timed-out sb_add, retried, stored its section twice. Thrown the way the SDK's
22
+ * own sendRequest refuses a cancelled call; the SDK discards it unsent.
23
+ *
18
24
  * ponytail: one FIFO for every session tool, so a slow sb_look delays the next
19
25
  * sb_set; a per-document lock only matters if two documents are ever open.
20
26
  */
@@ -28,7 +34,11 @@ export function serializeToolCalls(server, free) {
28
34
  return set(schema, ((req, extra) => {
29
35
  if (free(req.params.name))
30
36
  return handler(req, extra);
31
- const run = tail.then(() => handler(req, extra));
37
+ const run = tail.then(() => {
38
+ if (extra?.signal?.aborted)
39
+ throw new McpError(ErrorCode.ConnectionClosed, 'Request was cancelled');
40
+ return handler(req, extra);
41
+ });
32
42
  tail = run.catch(() => undefined);
33
43
  return run;
34
44
  }));
@@ -22,7 +22,7 @@ import { request, redact, watchPageWrites, onPageSourceWrite, onGlobalWrite, onF
22
22
  import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds } from '../core/tree.js';
23
23
  import { siteToken } from './credentialpick.js';
24
24
  import { validateForSave } from '../domains/site/validate.js';
25
- import { cascadeTail, formDocChecks, sayChecks, specCheck, writeCheck } from '../domains/site/writecheck.js';
25
+ import { cascadeTail, formDocChecks, hiddenBand, sayChecks, specCheck, writeCheck } from '../domains/site/writecheck.js';
26
26
  import { reviewDesign, REVIEW_NOTICE } from '../domains/site/review.js';
27
27
  import { exampleCopy } from '../domains/site/examplecopy.js';
28
28
  import { compactFindings } from '../domains/site/findings.js';
@@ -1713,7 +1713,17 @@ export function registerPageTools(server, ctx) {
1713
1713
  applyPatches(probe, patches.filter((p) => p.path[0] === 'nodes' && p.path[1] === e.id));
1714
1714
  return cascadeTail(probe.nodes[e.id], { [bp]: e.keys }, e.id);
1715
1715
  });
1716
- const found = sayChecks([...checked, ...tail, ...session.formChecks(patches)], say);
1716
+ // config.hidden at base/desktop hides ≥1440px only — judged on the node
1717
+ // AS IT WILL BE, so a batch that hides every band says nothing.
1718
+ const hidden = batch.flatMap((e) => {
1719
+ const bp = e.breakpoint ?? 'desktop';
1720
+ if (e.namespace !== 'config' || e.state || e.keys.hidden !== true || (!e.base && bp !== 'desktop') || !d.doc.nodes[e.id])
1721
+ return [];
1722
+ const probe = { nodes: { [e.id]: JSON.parse(JSON.stringify(d.doc.nodes[e.id])) } };
1723
+ applyPatches(probe, patches.filter((p) => p.path[0] === 'nodes' && p.path[1] === e.id));
1724
+ return hiddenBand(probe.nodes[e.id], e.id);
1725
+ });
1726
+ const found = sayChecks([...checked, ...tail, ...hidden, ...session.formChecks(patches)], say);
1717
1727
  const checks = found.length ? { checks: found } : {};
1718
1728
  // A FIELD-SKIN KNOB ON THE WRONG NODE renders nowhere. The FORM dresses
1719
1729
  // every field it holds with the input vocabulary; a payment card, choice
@@ -2651,8 +2661,15 @@ export function registerPageTools(server, ctx) {
2651
2661
  });
2652
2662
  const state = (p) => driftOf(p.updatedAt, p.publishedAt).state;
2653
2663
  drafts = others.filter((p) => state(p) === 'draft_ahead').map(row);
2654
- for (const m of cascadeMasked.get(site_id)?.values() ?? []) {
2655
- if (m.pageId !== page_id && !drafts.some((d) => d.pageId === m.pageId))
2664
+ // A remembered page no longer listed was DELETED: sending its id makes
2665
+ // the platform's publishTargets refuse the whole batch (ErrPageNotFound),
2666
+ // on every publish_drafts:true until restart. Forget it.
2667
+ const listed = new Set((got.pages ?? []).map((p) => String(p.id)));
2668
+ const memory = cascadeMasked.get(site_id);
2669
+ for (const m of memory?.values() ?? []) {
2670
+ if (!listed.has(m.pageId))
2671
+ memory.delete(m.pageId);
2672
+ else if (m.pageId !== page_id && !drafts.some((d) => d.pageId === m.pageId))
2656
2673
  drafts.push(m);
2657
2674
  }
2658
2675
  const unborn = others.filter((p) => state(p) === 'never_published').map(row);
@@ -2825,7 +2842,16 @@ export function registerPageTools(server, ctx) {
2825
2842
  }));
2826
2843
  const row = (live.published ?? []).find((p) => p.pageId === pageId);
2827
2844
  const publishedNodes = Object.keys((row?.document?.nodes ?? {})).length;
2828
- const drift = driftOf(src.updatedAt, row?.publishedAt);
2845
+ // The same cascade memory sb_publish lists unpublished_drafts from: a
2846
+ // cascade moved publishedAt past this draft, so the timestamps lie.
2847
+ const drift = cascadeMasked.get(site_id)?.has(pageId)
2848
+ ? {
2849
+ state: 'draft_ahead',
2850
+ note: 'The draft has changes the live page does not. A cascade this process ran republished ' +
2851
+ 'this page from its LAST PUBLISHED version and moved publishedAt past the draft, so the ' +
2852
+ 'timestamps read in step. Publish it by its own page_id.',
2853
+ }
2854
+ : driftOf(src.updatedAt, row?.publishedAt);
2829
2855
  // Projected to id + label + when, never the documents: one version of a
2830
2856
  // two-node page measured 1,690 bytes over the wire, so a realistic page
2831
2857
  // is ~70 KB per version and a listing of twenty is 1.4 MB in one answer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.98.5",
3
+ "version": "0.98.7",
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",