sbuilder-mcp 0.98.8 → 0.98.9

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,13 @@ 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.9] - 2026-10-29
10
+
11
+ ### Fixed
12
+ - `sb_set` and `sb_add` no longer fail with "Cannot read properties of undefined (reading 'responsive')", even with `dry_run`, when a hidden node's `data.parent` points at a node that no longer exists.
13
+ - `sb_set` evaluates `hidden_band` against the parent chain after applying all `edits[]`, so a batch that hides a parent in narrow bands and the child at base no longer warns, and a batch that unhides the parent does.
14
+ - A phone field that looks like a confirmation field (such as "SĐT nhận mã xác nhận" or `confirmed_phone`) is treated as a re-entry field only when the form has another phone field, so a form's only phone field is reported as the phone field.
15
+
9
16
  ## [0.98.8] - 2026-10-29
10
17
 
11
18
  ### Added
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,13 @@ 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.9] - 2026-10-29
10
+
11
+ ### Fixed
12
+ - `sb_set` và `sb_add` không còn lỗi "Cannot read properties of undefined (reading 'responsive')", kể cả khi dùng `dry_run`, khi `data.parent` của node bị ẩn trỏ vào node đã không còn tồn tại.
13
+ - `sb_set` xét `hidden_band` trên chuỗi node cha sau khi áp toàn bộ `edits[]`, nên batch ẩn node cha ở các dải hẹp và ẩn node con ở base không còn cảnh báo, còn batch bỏ ẩn node cha thì có.
14
+ - Ô số điện thoại trông như ô xác nhận (như "SĐT nhận mã xác nhận" hoặc `confirmed_phone`) chỉ được coi là ô nhập lại khi form còn một ô số điện thoại khác, nên ô số điện thoại duy nhất của form được báo là trường phone.
15
+
9
16
  ## [0.98.8] - 2026-10-29
10
17
 
11
18
  ### Added
package/dist/core/tree.js CHANGED
@@ -130,12 +130,16 @@ export function subtreeIds(doc, id) {
130
130
  walk(doc, id, (n) => out.push(n.id));
131
131
  return out;
132
132
  }
133
- /** Ids from this node's parent up to ROOT. Cycle-safe for the same reason. */
133
+ /**
134
+ * Ids from this node's parent up to ROOT. Cycle-safe for the same reason, and
135
+ * stops at a parent pointer naming a node the document does not hold — every
136
+ * caller maps the ids back to `doc.nodes[a]`, and a dangling one is undefined.
137
+ */
134
138
  export function ancestors(doc, id) {
135
139
  const out = [];
136
140
  const seen = new Set([id]);
137
141
  let cur = doc.nodes[id]?.data.parent ?? null;
138
- while (cur && !seen.has(cur)) {
142
+ while (cur && !seen.has(cur) && doc.nodes[cur]) {
139
143
  seen.add(cur);
140
144
  out.push(cur);
141
145
  cur = doc.nodes[cur]?.data.parent ?? null;
@@ -178,11 +178,10 @@ export function formFieldFindings(d, formType) {
178
178
  const fields = formFields(d).filter((n) => collectsValue(n.data.type));
179
179
  // A hand-built confirm box (tel, no mapTo) is told apart by its name or label.
180
180
  const reentry = (n) => /confirm|repeat|re_?enter|xac_?nhan|nhap_?lai/i.test(`${postedName(n)} ${nameFromLabel(String(n.specials?.label ?? ''))}`);
181
- const phoneish = fields.find((n) => {
182
- const s = n.specials ?? {};
183
- return (s.mapTo === 'customer.phone' ||
184
- (s.inputType === 'tel' && s.mapTo !== 'customer.confirmPhone' && !reentry(n)));
185
- });
181
+ const tel = (n) => n.specials?.mapTo === 'customer.phone' || n.specials?.inputType === 'tel';
182
+ // …but only when it confirms SOMETHING: the one phone-like box on the form
183
+ // ("SĐT nhận mã xác nhận", confirmed_phone) IS the phone, whatever it says.
184
+ const phoneish = fields.find((n) => n.specials?.mapTo === 'customer.phone' || (tel(n) && n.specials?.mapTo !== 'customer.confirmPhone' && !reentry(n))) ?? fields.find(tel);
186
185
  if (phoneish && !fields.some((n) => postedName(n) === 'phone')) {
187
186
  out.push({
188
187
  code: 'form_register_phone',
@@ -1714,14 +1714,16 @@ export function registerPageTools(server, ctx) {
1714
1714
  return cascadeTail(probe.nodes[e.id], { [bp]: e.keys }, e.id);
1715
1715
  });
1716
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.
1717
+ // AS IT WILL BE — and so are its ancestors, since one edits[] can hide the
1718
+ // parent at the narrow bands — so a batch that hides every band says nothing.
1718
1719
  const hidden = batch.flatMap((e) => {
1719
1720
  const bp = e.breakpoint ?? 'desktop';
1720
1721
  if (e.namespace !== 'config' || e.state || e.keys.hidden !== true || (!e.base && bp !== 'desktop') || !d.doc.nodes[e.id])
1721
1722
  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, ancestors(d.doc, e.id).map((a) => d.doc.nodes[a]));
1723
+ const chain = [e.id, ...ancestors(d.doc, e.id)];
1724
+ const probe = { nodes: Object.fromEntries(chain.map((a) => [a, JSON.parse(JSON.stringify(d.doc.nodes[a]))])) };
1725
+ applyPatches(probe, patches.filter((p) => p.path[0] === 'nodes' && chain.includes(String(p.path[1]))));
1726
+ return hiddenBand(probe.nodes[e.id], e.id, chain.slice(1).map((a) => probe.nodes[a]));
1725
1727
  });
1726
1728
  const found = sayChecks([...checked, ...tail, ...hidden, ...session.formChecks(patches)], say);
1727
1729
  const checks = found.length ? { checks: found } : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.98.8",
3
+ "version": "0.98.9",
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",