sbuilder-mcp 0.100.0 → 0.100.1

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,19 @@ 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.100.1] - 2026-10-29
10
+
11
+ ### Changed
12
+ - `sb_outline` collapses only shared headers, footers and overlays, not global custom sections, and a collapsed line carries `collapsed: true`.
13
+ - `sb_duplicate` lists at most 40 nodes in `copies`, and past that it returns the top-level copy plus `copied` and `copies_truncated`.
14
+ - `sb_publish` shows `cascade_note` once per process, on its first appearance in a dry run or a real publish.
15
+ - The error for a missing page source now reads "page <id> not found on site <site> (deleted, or not this site/key)".
16
+
17
+ ### Fixed
18
+ - `sb_store` with `action: "form"` and `node_id` places the form the same way as `sb_add` and checks that the position can be saved first, so a refused position no longer leaves a stray form behind.
19
+ - `sb_review` no longer reports `default_font` when `responsive[bp].style.fontFamily` is already set.
20
+ - `sb_review` no longer counts `background-color` or `border-color` as `color` for `link_colour`.
21
+
9
22
  ## [0.100.0] - 2026-10-29
10
23
 
11
24
  ### Added
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,19 @@ 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.100.1] - 2026-10-29
10
+
11
+ ### Changed
12
+ - `sb_outline` chỉ thu gọn header, footer dùng chung và overlay, không thu gọn global custom section, và dòng thu gọn mang `collapsed: true`.
13
+ - `sb_duplicate` liệt kê tối đa 40 node trong `copies`, quá giới hạn thì trả bản sao cấp trên cùng với `copied` và `copies_truncated`.
14
+ - `sb_publish` chỉ hiện `cascade_note` một lần mỗi process, ở lần xuất hiện đầu tiên khi chạy thử hoặc publish thật.
15
+ - Lỗi khi không tìm thấy nguồn trang nay ghi "page <id> not found on site <site> (deleted, or not this site/key)".
16
+
17
+ ### Fixed
18
+ - `sb_store` với `action: "form"` và `node_id` đặt form giống `sb_add` và kiểm tra vị trí có lưu được trước, nên vị trí bị từ chối không còn để lại form thừa.
19
+ - `sb_review` không còn báo `default_font` khi `responsive[bp].style.fontFamily` đã được đặt.
20
+ - `sb_review` không còn tính `background-color` hay `border-color` là `color` khi xét `link_colour`.
21
+
9
22
  ## [0.100.0] - 2026-10-29
10
23
 
11
24
  ### Added
@@ -189,8 +189,9 @@ export class PageDoc {
189
189
  */
190
190
  /**
191
191
  * `chrome: false` (the tool's default) stops at a shared header/footer or an
192
- * overlay: one line each, no kids. They are the same on every page and were
193
- * ~70% of a routine outline (TTG gap #52).
192
+ * overlay: one line each, no kids, marked `collapsed`. They are the same on
193
+ * every page and were ~70% of a routine outline (TTG gap #52). A CUSTOM global
194
+ * is middle-band content the agent designs in, so it stays expanded.
194
195
  */
195
196
  outline(opts = {}) {
196
197
  const depth = opts.depth ?? 1;
@@ -213,7 +214,10 @@ export class PageDoc {
213
214
  out.global = true;
214
215
  if (appBlockRoot(this.doc, id) === id)
215
216
  out.app = true;
216
- const collapsed = opts.chrome === false && level === 0 && (out.overlay || out.global);
217
+ const kind = n.specials?.globalKind;
218
+ const collapsed = opts.chrome === false && level === 0 && (out.overlay || (out.global && (kind === 'header' || kind === 'footer')));
219
+ if (collapsed && level + 1 < depth && (kidIds.length || satellitesOf(this.doc, id).length))
220
+ out.collapsed = true;
217
221
  if (level + 1 < depth && !collapsed) {
218
222
  // Satellites come FIRST, and are counted apart from `children`: they are
219
223
  // this node's own chrome, not content in it, and mixing the two would
@@ -542,7 +542,9 @@ opts = {}) {
542
542
  // is another family: a deliberate literal is the author's.
543
543
  const ff = n.style?.fontFamily;
544
544
  const seedFont = meta.defaults.style?.fontFamily;
545
- if (opts.bodyFont && typeof ff === 'string' && ff === seedFont && !ff.includes('var(') && family(ff) !== family(opts.bodyFont)) {
545
+ // A family set at any breakpoint is the author's answer too.
546
+ const perBp = Object.values(n.responsive ?? {}).some((r) => r?.style?.fontFamily !== undefined);
547
+ if (opts.bodyFont && !perBp && typeof ff === 'string' && ff === seedFont && !ff.includes('var(') && family(ff) !== family(opts.bodyFont)) {
546
548
  out.push({
547
549
  code: 'default_font',
548
550
  nodeId: id,
@@ -301,7 +301,7 @@ export function writeCheck(type, namespace, keys, opts = {}) {
301
301
  }
302
302
  /** `<a …>` tags in rich text that set no colour of their own. */
303
303
  export function unstyledLinks(html) {
304
- return (html.match(/<a\b[^>]*>/gi) ?? []).filter((tag) => !/style\s*=\s*["'][^"']*\bcolor\s*:/i.test(tag)).length;
304
+ return (html.match(/<a\b[^>]*>/gi) ?? []).filter((tag) => !/style\s*=\s*["'](?:[^"']*[;\s])?color\s*:/i.test(tag)).length;
305
305
  }
306
306
  export const LINK_COLOUR = {
307
307
  problem: "A link in this rich text has no colour of its own, so it renders in the browser's default link blue " +
@@ -20,7 +20,7 @@ import { skinLevelNote } from '../domains/site/fieldskin.js';
20
20
  import { siteTheme } from '../domains/site/theme-fetch.js';
21
21
  import { ensureSiteTheme } from './theme.js';
22
22
  import { request, redact, watchPageWrites, onPageSourceWrite, onGlobalWrite, onFormDocumentWrite } from '../transport/http.js';
23
- import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds, ancestors } from '../core/tree.js';
23
+ import { SPEC_GLOBAL_ID, SPEC_GLOBAL_REV, SPEC_OVERLAY_ID, SPEC_OVERLAY_REV, subtreeIds, ancestors, childrenOf } from '../core/tree.js';
24
24
  import { siteToken } from './credentialpick.js';
25
25
  import { validateForSave } from '../domains/site/validate.js';
26
26
  import { cascadeTail, formDocChecks, hiddenBand, sayChecks, specCheck, writeCheck } from '../domains/site/writecheck.js';
@@ -75,6 +75,8 @@ export function reviewField(ctx, doc, formTypes, pageType, formDocType, formRedi
75
75
  */
76
76
  /** How long a save in the live room waits for its ops' acks before leaving `X-WB-Live-Peer` off. */
77
77
  const LIVE_ACK_CAP_MS = 2_000;
78
+ /** sb_duplicate's full old → [new, type] map stops here; past it, the top level and a count. */
79
+ const DUPLICATE_COPIES_CAP = 40;
78
80
  /**
79
81
  * Why `applyAndSave` would refuse this batch on this document, or null — the
80
82
  * ONE place that question is answered, so a dry run and the real write cannot
@@ -99,6 +101,21 @@ export function saveRefusal(d, patches) {
99
101
  }
100
102
  return { before, refusal: null };
101
103
  }
104
+ /**
105
+ * `addSubtree` with sb_add's placement: ROOT WITH NO INDEX MEANS "ANOTHER
106
+ * SECTION OF THE PAGE" — the end of the middle band, as sb_template_use and
107
+ * sb_duplicate already place one. Appended last it landed after a shared
108
+ * footer, and the band-order check refused the save — on exactly the call
109
+ * empty_page's fix names. Only when a footer is there to land behind: a FORM
110
+ * document's root has none, and addSubtree's own default (above the submit
111
+ * button) is right. Shared with sb_store action:"form" + node_id, which
112
+ * appended after the footer and stored a stray form.
113
+ */
114
+ export function addPlaced(d, parentId, spec, index, guard) {
115
+ const rootKids = d.doc.nodes[d.doc.root_node_id]?.data.nodes.length ?? 0;
116
+ const mid = parentId === d.doc.root_node_id ? middleEnd(d.doc) : rootKids;
117
+ return addSubtree(d, parentId, spec, index ?? (mid < rootKids ? mid : undefined), guard);
118
+ }
102
119
  /** `once` for a real write, `peek` for a dry run — the same notes, spent once. */
103
120
  function noticeFor(ctx, dryRun) {
104
121
  return dryRun !== false ? (k, b) => ctx.notices.peek(k, b) : (k, b) => ctx.notices.once(k, b);
@@ -1520,16 +1537,7 @@ export function registerPageTools(server, ctx) {
1520
1537
  }, async ({ parent_id, spec, index, dry_run, force }) => {
1521
1538
  const d = session.current();
1522
1539
  const guard = { force, forced: [] };
1523
- // ROOT WITH NO INDEX MEANS "ANOTHER SECTION OF THE PAGE": the end of the
1524
- // middle band, as sb_template_use and sb_duplicate already place one.
1525
- // Appended last it landed after a shared footer, and the band-order check
1526
- // refused the save — on exactly the call empty_page's fix names.
1527
- // Only when a footer is there to land behind: a FORM document's root has
1528
- // none, and addSubtree's own default (above the submit button) is right.
1529
- const rootKids = d.doc.nodes[d.doc.root_node_id]?.data.nodes.length ?? 0;
1530
- const mid = parent_id === d.doc.root_node_id ? middleEnd(d.doc) : rootKids;
1531
- const at = index ?? (mid < rootKids ? mid : undefined);
1532
- const { patches, ids, idOf } = addSubtree(d, parent_id, spec, at, guard);
1540
+ const { patches, ids, idOf } = addPlaced(d, parent_id, spec, index, guard);
1533
1541
  const forced = guard.forced.length ? { forced: guard.forced } : {};
1534
1542
  // THE SEED COPY IN THE SITE'S LANGUAGE (TTG gap #46): an empty state minted
1535
1543
  // here said "No products yet" on a Vietnamese store, while sb_page_create
@@ -2086,8 +2094,25 @@ export function registerPageTools(server, ctx) {
2086
2094
  await session.applyAndSave(patches);
2087
2095
  // EVERY copy's id, not just the root's: editing the copied row's answer
2088
2096
  // used to take a whole sb_outline to find (TTG gap #53).
2089
- const copies = Object.fromEntries(Object.entries(map).map(([from, to]) => [from, [to, d.doc.nodes[from]?.data.type ?? '']]));
2090
- return text({ duplicated: id, into: ids[0], copies, rev: d.rev, ...forcedOf() });
2097
+ // CAPPED: the map grows with the subtree, and a 200-node section would
2098
+ // pour 200 pairs into the reader. Past the cap, the copy's top level only.
2099
+ const entry = (from) => [from, [map[from], d.doc.nodes[from]?.data.type ?? '']];
2100
+ const all = Object.keys(map);
2101
+ if (all.length <= DUPLICATE_COPIES_CAP) {
2102
+ return text({ duplicated: id, into: ids[0], copies: Object.fromEntries(all.map(entry)), rev: d.rev, ...forcedOf() });
2103
+ }
2104
+ const top = [id, ...childrenOf(d.doc, id)].filter((k) => k in map).slice(0, DUPLICATE_COPIES_CAP);
2105
+ const how = ctx.notices.once('duplicate-truncated', 'copies holds the copy and its direct children only (copied counts every node); a deeper sb_outline reads the rest.');
2106
+ return text({
2107
+ duplicated: id,
2108
+ into: ids[0],
2109
+ copied: all.length,
2110
+ copies: Object.fromEntries(top.map(entry)),
2111
+ copies_truncated: true,
2112
+ ...(how ? { copies_note: how } : {}),
2113
+ rev: d.rev,
2114
+ ...forcedOf(),
2115
+ });
2091
2116
  }
2092
2117
  // ONTO ANOTHER PAGE — the editor's paste (`useCanvasClipboard.ts`).
2093
2118
  const from = session.location();
@@ -2811,8 +2836,9 @@ export function registerPageTools(server, ctx) {
2811
2836
  // NO CASCADE PREVIEW EXISTS on the platform (page/globalservice.go
2812
2837
  // cascadeTargets runs inside publish only), so the dry run says the rule
2813
2838
  // rather than a list it cannot know (TTG gap #59); the real answer names
2814
- // the pages under `cascaded`.
2815
- const cascade = ctx.notices.peek('publish-cascade', 'Publishing also republishes, from their LAST PUBLISHED version (never their draft), every live page ' +
2839
+ // the pages under `cascaded`. SPENT on first show, dry or real: a dry
2840
+ // run repeated it on every preview.
2841
+ const cascade = ctx.notices.once('publish-cascade', 'Publishing also republishes, from their LAST PUBLISHED version (never their draft), every live page ' +
2816
2842
  'whose shared header/footer, overlay (cart drawer, pop-up) or app block is behind its master. The ' +
2817
2843
  'platform offers no preview of that list; the real publish names them under cascaded.');
2818
2844
  return text({ dry_run: true, would_post: path, body, ...draftNote(drafts, fresh), ...(cascade ? { cascade_note: cascade } : {}) });
@@ -42,7 +42,7 @@ import { API_DEFINITIONS } from '../catalog/api.generated.js';
42
42
  import { siteToken } from './credentialpick.js';
43
43
  import { siteFor } from './context.js';
44
44
  import { withFreshIds } from '../domains/site/ids.js';
45
- import { siteChrome, wearChrome } from './page.js';
45
+ import { addPlaced, saveRefusal, siteChrome, wearChrome } from './page.js';
46
46
  import { addSubtree } from '../domains/site/builder.js';
47
47
  import { attachGlobal, buildChrome, detachGlobal, promoteGlobal, saveTemplate } from './chrome.js';
48
48
  import { bindMenu } from './menu.js';
@@ -398,7 +398,11 @@ async function seedForm(ctx, session, siteId, key, formName, pageName, headline,
398
398
  throw new Error('sbuilder: action:"form" takes page_name (a new page) or node_id (the open page), not both.');
399
399
  if (session.site() !== siteId)
400
400
  throw new Error(`sbuilder: the open page is on site ${session.site()}, not ${siteId} — open a page of this site first.`);
401
- addSubtree(session.current(), parentId, { type: 'form', specials: { formId: 'frm_check' } });
401
+ // sb_add's placement AND the save's own verdict: a page that would refuse
402
+ // the form node must refuse it here, while there is still no form.
403
+ const refusal = saveRefusal(session.current(), addPlaced(session.current(), parentId, { type: 'form', specials: { formId: 'frm_check' } }).patches).refusal;
404
+ if (refusal)
405
+ throw new Error(`sbuilder: ${refusal} — no form was created.`);
402
406
  }
403
407
  const tpl = FORM_TEMPLATES[key];
404
408
  const site = encodeURIComponent(siteId);
@@ -499,7 +503,7 @@ async function seedForm(ctx, session, siteId, key, formName, pageName, headline,
499
503
  let placed;
500
504
  if (parentId) {
501
505
  try {
502
- const { patches, ids } = addSubtree(session.current(), parentId, { type: 'form', specials: { formId: form.id } });
506
+ const { patches, ids } = addPlaced(session.current(), parentId, { type: 'form', specials: { formId: form.id } });
503
507
  await session.applyAndSave(patches);
504
508
  placed = { id: ids[0], parent: parentId };
505
509
  }
@@ -16,14 +16,15 @@ export function sourcePath(siteId, pageId) {
16
16
  * back out on write.
17
17
  */
18
18
  /**
19
- * A 404 on a page's source is a DELETED page (or a wrong id), and the session
19
+ * A 404 on a page's source is a DELETED page, a wrong site id, or a key scoped to
20
+ * another site — and the session
20
21
  * may still be pointing at it: a bare "source not found [http 404]" after an
21
22
  * sb_api_call delete told the caller nothing (TTG gap #57). Same status and
22
23
  * code, a sentence that says what to do.
23
24
  */
24
- const gone = (pageId) => (e) => {
25
+ const gone = (siteId, pageId) => (e) => {
25
26
  if (e instanceof ApiError && e.status === 404) {
26
- throw new ApiError(404, e.code, `page ${pageId} no longer exists (deleted, or a wrong id) — sb_page_open another page; sb_page_list lists them`, e.details, e.fields);
27
+ throw new ApiError(404, e.code, `page ${pageId} not found on site ${siteId} (deleted, or not this site/key) — sb_page_open another page; sb_page_list lists them`, e.details, e.fields);
27
28
  }
28
29
  throw e;
29
30
  };
@@ -34,7 +35,7 @@ export async function loadSource(ctx, siteId, pageId) {
34
35
  path: sourcePath(siteId, pageId),
35
36
  token: siteToken(ctx),
36
37
  fetchImpl: ctx.fetchImpl,
37
- }).catch(gone(pageId)));
38
+ }).catch(gone(siteId, pageId)));
38
39
  return out.source;
39
40
  }
40
41
  /**
@@ -71,6 +72,6 @@ livePeer) {
71
72
  body: { document, schemaVersion: document.schema_version ?? 1, ...(baseRev ? { baseRev } : {}) },
72
73
  ...(livePeer && LIVE_PEER.test(livePeer) ? { headers: { 'X-WB-Live-Peer': livePeer } } : {}),
73
74
  fetchImpl: ctx.fetchImpl,
74
- }).catch(gone(pageId)));
75
+ }).catch(gone(siteId, pageId)));
75
76
  return out.source;
76
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.100.0",
3
+ "version": "0.100.1",
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",