sbuilder-mcp 0.30.0 → 0.30.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,18 @@ 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.30.1] - 2026-09-11
10
+
11
+ ### Changed
12
+ - sb_import and sb_import_site's default `max_images` and `max_nodes` rise from 24/300 to 60/900, so a real shop homepage's full catalogue is no longer cut off mid-band.
13
+ - A flex or grid container that wraps is now capped at 60 columns per row instead of 12, so a wide product shelf is captured as its own row instead of being coerced into a vertical stack.
14
+
15
+ ### Fixed
16
+ - sb_import and sb_import_site no longer read images from `src` alone: a lazy-loaded `data-src`/`data-original`/`data-lazy-src`/`srcset` (widest candidate) is now read as the real photo, so a lazy-loaded product gallery is no longer imported as a handful of pictures with the rest reported as missing.
17
+ - Content hidden inside a tab panel, carousel slide or filtered grid (`display:none` beside a visible sibling of the same kind) is now revealed and captured, so a homepage that lays its catalogue out in tabs no longer loses every tab but the one shown at load.
18
+ - `<button>` elements are no longer skipped as form controls: a button with words in it is now captured as a call-to-action or link the same way an `<a>` is, so "Add to cart"-style buttons are no longer dropped from the import.
19
+ - The section-candidate fallback now fires whenever the chosen sections cover under half of the page's non-chrome text, not only when they capture nothing at all, so a page whose only `<section>` elements are a breadcrumb no longer imports as that breadcrumb alone.
20
+
9
21
  ## [0.30.0] - 2026-09-10
10
22
 
11
23
  ### Added
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,18 @@ 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.30.1] - 2026-09-11
10
+
11
+ ### Changed
12
+ - Giá trị mặc định `max_images` và `max_nodes` của sb_import và sb_import_site tăng từ 24/300 lên 60/900, nên toàn bộ catalogue trên trang chủ một shop thật không còn bị cắt cụt giữa chừng một band.
13
+ - Một container flex hoặc grid có wrap giờ được giới hạn 60 cột mỗi hàng thay vì 12, nên một kệ sản phẩm rộng được chụp lại đúng thành một hàng thay vì bị ép thành một cột dọc.
14
+
15
+ ### Fixed
16
+ - sb_import và sb_import_site không còn chỉ đọc ảnh từ `src`: một ảnh lazy-load qua `data-src`/`data-original`/`data-lazy-src`/`srcset` (chọn ứng viên rộng nhất) giờ được đọc như ảnh thật, nên một thư viện ảnh sản phẩm lazy-load không còn bị nhập vào với vài tấm còn lại bị báo là thiếu.
17
+ - Nội dung ẩn trong một tab panel, slide carousel hay lưới lọc (`display:none` cạnh một anh em cùng loại đang hiển thị) giờ được hiện ra và chụp lại, nên một trang chủ trình bày catalogue theo dạng tab không còn mất hết các tab trừ tab đang mở lúc tải.
18
+ - Phần tử `<button>` không còn bị bỏ qua như một control của form: một button có chữ bên trong giờ được chụp lại như một nút kêu gọi hành động hoặc liên kết, giống cách một `<a>` được xử lý, nên các nút kiểu "Thêm vào giỏ" không còn bị rớt khỏi bản nhập.
19
+ - Cơ chế dự phòng chọn section giờ kích hoạt bất cứ khi nào các section được chọn chỉ phủ dưới một nửa nội dung chữ không phải chrome của trang, chứ không chỉ khi chúng không chụp được gì cả, nên một trang mà các phần tử `<section>` duy nhất là một breadcrumb sẽ không còn bị nhập vào chỉ như breadcrumb đó.
20
+
9
21
  ## [0.30.0] - 2026-09-10
10
22
 
11
23
  ### Added
@@ -464,7 +464,13 @@ export function registerImportTools(server, ctx, session) {
464
464
  }
465
465
  }
466
466
  const tokens = tokenDoc ? tokensFromPage(tokenDoc.doc) : {};
467
- const shots = await captureMany(plan.pages.map((p) => p.url), { maxImages: max_images ?? 24, maxNodes: max_nodes ?? 300 });
467
+ const shots = await captureMany(plan.pages.map((p) => p.url),
468
+ // 900, not 300. The old ceiling was chosen against marketing pages;
469
+ // a real shop's homepage is a different quantity — ttgshop.vn measured
470
+ // 9,829px of catalogue across a dozen collection bands, and 300 cut it
471
+ // off in the middle of the third. A cap is here to stop a runaway page,
472
+ // not to decide how much of an ordinary one survives.
473
+ { maxImages: max_images ?? 60, maxNodes: max_nodes ?? 900 });
468
474
  const byUrl = new Map(shots.map((s) => [s.url, s]));
469
475
  // ONE UPLOAD PER IMAGE FOR THE WHOLE SITE, not per page. A logo, a payment
470
476
  // strip and a footer badge appear on every page of a real site, and
@@ -74,7 +74,16 @@ function capturePage(limits) {
74
74
  // nothing, so a contact page says it had one. The CONTROLS stay ignored —
75
75
  // a stray input outside a form is chrome, and the fields of a form that IS
76
76
  // reported are counted there rather than walked into.
77
- 'NAV', 'INPUT', 'SELECT', 'TEXTAREA', 'BUTTON',
77
+ //
78
+ // BUTTON IS NOT HERE EITHER, AND USED TO BE — filed with the form controls,
79
+ // on the reasoning that fits `input` and does not fit it. A `<button>` with
80
+ // words in it is a CALL TO ACTION, which on a shop is the most important
81
+ // interactive thing on the page: MEASURED on ttgshop.vn, 27 of them dropped
82
+ // in one capture, every "Mua ngay" and "Thêm vào giỏ" among them. A button
83
+ // that really is a form control is unreachable anyway — the FORM branch
84
+ // returns without walking its children — so the only ones this reaches are
85
+ // the ones a reader would press.
86
+ 'NAV', 'INPUT', 'SELECT', 'TEXTAREA',
78
87
  ]);
79
88
  const forms = [];
80
89
  /** The provider and id behind an embed URL, or null if this platform has no element for it. */
@@ -136,6 +145,89 @@ function capturePage(limits) {
136
145
  // a throwaway tab that is closed straight after.
137
146
  for (const d of Array.from(document.querySelectorAll('details')))
138
147
  d.setAttribute('open', '');
148
+ // A TAB PANEL THAT IS NOT THE OPEN ONE MEASURES AS ZERO, and on a shop that
149
+ // is most of the page.
150
+ //
151
+ // Same principle as the `<details>` pass above and the same sentence decides
152
+ // it: the source's collapsed state is not content. MEASURED on ttgshop.vn —
153
+ // a homepage that lays its catalogue out in tabs (PC GAMING, WORKSTATION,
154
+ // AMD, MINI, …) — 73% of the page's own text was in panels carrying
155
+ // `display:none`, so the import kept one tab's products and silently dropped
156
+ // every other tab: product names, prices, discounts, stock. Nothing reported
157
+ // it, because a hidden element is indistinguishable from an absent one once
158
+ // it has been skipped.
159
+ //
160
+ // REVEALED BY THE SHAPE OF A PANEL SET, never by unhiding what is hidden. A
161
+ // `display:none` element with no visible SIBLING is a modal, a drop-down, an
162
+ // off-canvas menu or a mobile-only copy of a desktop bar — showing those is
163
+ // how an import grows a navigation drawer in the middle of a page. What marks
164
+ // a panel is that it sits beside a peer of the same kind that IS shown: one
165
+ // tab open, the rest waiting. So the reveal needs a visible sibling, real
166
+ // content of its own, and a parent that is not page chrome.
167
+ //
168
+ // The display value is COPIED from that visible sibling rather than forced to
169
+ // `block`: a flex row of cards revealed as a block would stack, and the walk
170
+ // reads `display` to decide what is a row.
171
+ const revealPanels = () => {
172
+ const parents = new Set();
173
+ for (const el of Array.from(document.querySelectorAll('[style*="display"], .hidden, [hidden], [aria-hidden]'))) {
174
+ const p = el.parentElement;
175
+ if (p)
176
+ parents.add(p);
177
+ }
178
+ // Any container can hold a panel set; the attribute scan above only finds
179
+ // the common spellings, so the sweep below is over every parent of more
180
+ // than one element, bounded by the document itself.
181
+ for (const el of Array.from(document.querySelectorAll('*'))) {
182
+ if (el.children.length > 1)
183
+ parents.add(el);
184
+ }
185
+ for (const parent of parents) {
186
+ if (inPageChrome(parent))
187
+ continue;
188
+ const kids = Array.from(parent.children);
189
+ if (kids.length < 2)
190
+ continue;
191
+ // A VISIBLE PEER IS NOT ENOUGH, and the first version of this stopped
192
+ // there — which reveals every hidden thing on the page, because anything
193
+ // in a content flow has visible siblings. A pinned test caught it: a
194
+ // `<p style="display:none">` beside a visible paragraph came back as
195
+ // content, and that `<p>` is hidden because its author hid it.
196
+ //
197
+ // A PANEL IS A CONTAINER THAT MATCHES ITS PEER. Same tag as a sibling
198
+ // that IS shown, and children of its own — which is what a tab body, a
199
+ // carousel track or a filtered grid always is, and what a hidden
200
+ // paragraph, a stray span and an empty slot never are.
201
+ const shownByTag = {};
202
+ const hidden = [];
203
+ for (const k of kids) {
204
+ const cs = getComputedStyle(k);
205
+ const r = k.getBoundingClientRect();
206
+ if (cs.display === 'none')
207
+ hidden.push(k);
208
+ else if (!shownByTag[k.tagName] && r.width > 0 && r.height > 0) {
209
+ shownByTag[k.tagName] = cs.display;
210
+ }
211
+ }
212
+ if (!hidden.length)
213
+ continue;
214
+ for (const k of hidden) {
215
+ // Real content only — an empty slot or a script-filled placeholder is
216
+ // not a panel worth showing, and revealing it costs a skip either way.
217
+ // Low floor on purpose: a panel whose whole content is a price —
218
+ // "1.490.000 VNĐ", thirteen characters — is exactly the panel a shop
219
+ // hides, and a threshold tuned for prose skipped it.
220
+ const shownDisplay = shownByTag[k.tagName];
221
+ if (!shownDisplay || k.children.length === 0)
222
+ continue;
223
+ const holds = clean(k.textContent).length > 2 || k.querySelectorAll('img').length > 0;
224
+ if (!holds)
225
+ continue;
226
+ const was = k.getAttribute('style') ?? '';
227
+ k.setAttribute('style', `${was};display:${shownDisplay} !important`);
228
+ }
229
+ }
230
+ };
139
231
  /**
140
232
  * What the page CALLS this icon, in its own words. A candidate, never a verdict.
141
233
  *
@@ -145,6 +237,64 @@ function capturePage(limits) {
145
237
  * decides whether this platform has one by that name — nothing in the page can
146
238
  * answer that.
147
239
  */
240
+ /**
241
+ * THE REAL FILE, wherever the page put it — and on a shop that is almost never
242
+ * `src`.
243
+ *
244
+ * MEASURED on ttgshop.vn: 100 images, and 84 of them carry `data-src` with no
245
+ * `src` at all. Those 84 are the PRODUCT PHOTOS. Reading `src` alone imported
246
+ * a shop with a sixth of its pictures and reported the rest as
247
+ * `image-without-src`, which reads like the page's fault rather than ours.
248
+ *
249
+ * Lazy loading is not an edge case, it is how the web ships images: every
250
+ * mainstream loader (lazysizes, lozad, and most CMS themes) parks the URL in a
251
+ * data attribute and fills `src` only when the image nears the viewport — and
252
+ * a full-page screenshot does not scroll, which is the same reason `sb_look`
253
+ * walks the page before it fires.
254
+ *
255
+ * `srcset` is read for its LARGEST candidate rather than its first: the
256
+ * platform re-encodes what it is given, so handing it the 350w thumbnail when
257
+ * the page also offers 1400w throws away detail nothing can recover. A
258
+ * `data:` URI is refused wherever it appears — it is the 1x1 placeholder the
259
+ * loader is displaying until the real one arrives, which is precisely the
260
+ * placeholder this import must not ship.
261
+ */
262
+ const LAZY_SRC = ['data-src', 'data-original', 'data-lazy-src', 'data-lazy', 'data-echo', 'data-url'];
263
+ const widest = (srcset) => {
264
+ let best = '';
265
+ let bestW = -1;
266
+ for (const part of srcset.split(',')) {
267
+ const bits = part.trim().split(/\s+/);
268
+ if (!bits[0])
269
+ continue;
270
+ const w = /^([0-9]+)w$/.exec(bits[1] ?? '');
271
+ const n = w ? Number(w[1]) : 0;
272
+ if (n >= bestW) {
273
+ bestW = n;
274
+ best = bits[0];
275
+ }
276
+ }
277
+ return best;
278
+ };
279
+ const realSrc = (el) => {
280
+ const direct = el.getAttribute('src');
281
+ if (direct && !direct.startsWith('data:'))
282
+ return direct;
283
+ for (const a of LAZY_SRC) {
284
+ const v = el.getAttribute(a);
285
+ if (v && !v.startsWith('data:'))
286
+ return v;
287
+ }
288
+ for (const a of ['srcset', 'data-srcset']) {
289
+ const v = el.getAttribute(a);
290
+ if (v) {
291
+ const w = widest(v);
292
+ if (w && !w.startsWith('data:'))
293
+ return w;
294
+ }
295
+ }
296
+ return '';
297
+ };
148
298
  const iconName = (el) => {
149
299
  const use = Array.from(el.querySelectorAll('use'))[0];
150
300
  const ref = use ? use.getAttribute('href') ?? use.getAttribute('xlink:href') : null;
@@ -385,8 +535,8 @@ function capturePage(limits) {
385
535
  return [{ kind: 'heading', level: Number(tag.slice(1)), text }];
386
536
  }
387
537
  if (tag === 'IMG') {
388
- const src = el.getAttribute('src');
389
- if (!src || src.startsWith('data:')) {
538
+ const src = realSrc(el);
539
+ if (!src) {
390
540
  skip('image-without-src');
391
541
  return [];
392
542
  }
@@ -398,6 +548,31 @@ function capturePage(limits) {
398
548
  taken.nodes++;
399
549
  return [{ kind: 'image', src: abs(src), alt: clean(el.getAttribute('alt')) }];
400
550
  }
551
+ if (tag === 'BUTTON') {
552
+ // Read exactly as an `<a>` is, minus the href: painted is a call to
553
+ // action, unpainted is a plain control, and the variant is what stops
554
+ // every one of them arriving as a pink pill — the defect the anchor
555
+ // branch below records from a documentation sidebar.
556
+ const text = clean(el.textContent);
557
+ // A BUTTON WITH MARKUP INSIDE IT IS A CARD, not a label — the same
558
+ // reading the anchor branch below already applies, and taking the text
559
+ // whole instead COST coverage rather than gaining it: a product tile
560
+ // wrapped in a `<button>` came back as one run-on string with the name,
561
+ // the price and the discount glued together, replacing three nodes that
562
+ // had been captured separately. Measured: 89.7% down to 82.7% on
563
+ // ttgshop.vn, recovered by descending first.
564
+ if (el.children.length > 0) {
565
+ const inner = walkChildren(el);
566
+ if (inner.length > 0)
567
+ return inner;
568
+ }
569
+ if (!text) {
570
+ skip('button-without-words');
571
+ return [];
572
+ }
573
+ taken.nodes++;
574
+ return [{ kind: 'button', variant: looksLikeButton(el) ? 'cta' : 'link', text }];
575
+ }
401
576
  if (tag === 'A') {
402
577
  const text = clean(el.textContent);
403
578
  // A LINK THAT IS NOT A BUTTON IS STILL A LINK. It used to contribute
@@ -526,7 +701,20 @@ function capturePage(limits) {
526
701
  // wrapping it — so the honest translation is the stack it already reads
527
702
  // as. Twelve is above any real row seen here and far below a content
528
703
  // grid.
529
- const ROW_MAX = 12;
704
+ // THE CAP IS ABOUT SLIVERS, so it belongs on the containers that make
705
+ // them. A NOWRAP row divides one width by its column count — that is
706
+ // how 279 columns became 279 slivers — but a container that WRAPS never
707
+ // does: it lays out as many as fit and starts a new line, which is the
708
+ // same thing a twenty-card product shelf wants and exactly what the
709
+ // source was already showing.
710
+ //
711
+ // Twelve on a wrapping shelf was a rule coercing the layout rather than
712
+ // reading it: a shop's collection band came back as a vertical stack of
713
+ // cards because it had more than a dozen. The bound that remains is the
714
+ // whole-import node budget, which is the honest place for "this page is
715
+ // enormous".
716
+ const wraps = grid || cs.flexWrap === 'wrap';
717
+ const ROW_MAX = wraps ? 60 : 12;
530
718
  if (lays && row && kids.length >= 2 && kids.length <= ROW_MAX) {
531
719
  taken.nodes++;
532
720
  return [{
@@ -535,7 +723,7 @@ function capturePage(limits) {
535
723
  // A GRID ALWAYS WRAPS — that is what a grid IS — and `flexWrap` reads
536
724
  // `nowrap` on one because the property does not apply. Carrying that
537
725
  // literally gave the columns nowhere to go at any width.
538
- wrap: grid || cs.flexWrap === 'wrap',
726
+ wrap: wraps,
539
727
  children: kids,
540
728
  }];
541
729
  }
@@ -561,6 +749,12 @@ function capturePage(limits) {
561
749
  };
562
750
  return walk(root);
563
751
  };
752
+ // AFTER `inPageChrome` exists, and that ordering is load-bearing: the reveal
753
+ // asks whether a container is page chrome, and a `const` arrow read before
754
+ // its own definition throws inside `evaluate`, which kills the whole capture.
755
+ // The same class as the closure trap this file already carries — a name that
756
+ // exists but is not yet initialised.
757
+ revealPanels();
564
758
  // SECTION CANDIDATES, widest first: a page that marks its bands up
565
759
  // semantically is read that way, and one that does not falls back to the
566
760
  // top-level children of its main content, which is what a hand-written page
@@ -614,15 +808,119 @@ function capturePage(limits) {
614
808
  return acc;
615
809
  };
616
810
  let sections = build(candidates);
617
- // THE FALLBACK HAS TO FIRE ON AN EMPTY RESULT, not only on an empty candidate
618
- // LIST. A page can offer `<section>` elements that hold nothing this platform
619
- // renders — a wrapper around a canvas, a slot filled by script later — and the
620
- // old order took "we found candidates" as "we found content", so the whole
621
- // page came back empty. Measured: tailwindcss.com kept 0 of 6,004 characters
622
- // while reporting one skipped empty section.
623
- if (sections.length === 0) {
811
+ // THE FALLBACK HAS TO FIRE ON A DERISORY RESULT, not only on an empty one —
812
+ // and this entry has now been widened TWICE, each time by a real page.
813
+ //
814
+ // First it fired only on an empty candidate LIST, so a page offering
815
+ // `<section>`s that hold nothing this platform renders came back empty
816
+ // (tailwindcss.com: 0 of 6,004 characters, one skipped empty section). That
817
+ // was fixed by firing on an empty RESULT.
818
+ //
819
+ // An empty result is still the wrong test, because it treats "we captured
820
+ // something" as "we captured the page". MEASURED on ttgshop.vn, a shop with
821
+ // 2,856 divs, 602 paragraphs, 110 headings and 100 images: the whole page
822
+ // lives in `div.homepage`, and the document's only two `<section>` elements
823
+ // are a BREADCRUMB and one more. The selector privileges `<section>`
824
+ // absolutely, so the breadcrumb WAS the result — one section, one text node,
825
+ // 34 of 4,993 characters — and because that is not empty, nothing fell back.
826
+ // A shop imported as its own breadcrumb, with no error at any step.
827
+ //
828
+ // So the question is coverage, against the denominator this file already
829
+ // records as the honest one: page chrome is skipped ON PURPOSE and must not
830
+ // count against the result, or every correct import of a nav-heavy site would
831
+ // look like a failure. Below half of the non-chrome text, the candidate set
832
+ // was simply the wrong reading of the page, and the body walk is tried and
833
+ // kept only if it does better — so a page where the sections really are the
834
+ // content pays one comparison and keeps its own answer.
835
+ const textOf = (nodes) => {
836
+ let n = 0;
837
+ const walk = (c) => {
838
+ if (typeof c.text === 'string')
839
+ n += c.text.length;
840
+ for (const k of c.children ?? [])
841
+ walk(k);
842
+ };
843
+ for (const c of nodes)
844
+ walk(c);
845
+ return n;
846
+ };
847
+ let chromeChars = 0;
848
+ for (const el of Array.from(document.querySelectorAll('header, nav, footer'))) {
849
+ if (inPageChrome(el))
850
+ chromeChars += (el.innerText ?? '').length;
851
+ }
852
+ const contentChars = Math.max(0, (document.body.innerText ?? '').length - chromeChars);
853
+ // NO SIZE FLOOR ON THE CHECK. An earlier version only asked the question on
854
+ // pages with more than 400 characters, which is the guard you write when you
855
+ // fear a fallback firing too often — but the fallback cannot do harm here: it
856
+ // BUILDS the alternative and keeps it only if it captured more, so the worst
857
+ // case is one wasted walk on a page that was already right. A small page is
858
+ // also exactly where one stray band is the whole import.
859
+ if (sections.length === 0 || (contentChars > 0 && textOf(sections) < contentChars * 0.5)) {
860
+ // THE CONTENT ROOT, not `body` — otherwise the whole page comes back as ONE
861
+ // band and every arrangement the source had is gone. Measured on
862
+ // ttgshop.vn: `body` yields `div.homepage`, one candidate holding 9,829px of
863
+ // shop, so the import produced a single section with 467 text nodes in it.
864
+ //
865
+ // A real page wraps its content two or three deep before the bands start
866
+ // (`body > div.homepage > div.container > div.section-collection…`), so the
867
+ // root is found by DESCENDING while one child still holds nearly all the
868
+ // text. That child is a wrapper by definition — it has siblings that are
869
+ // scripts, chrome and empty slots — and its children are the bands.
870
+ // Bounded, and it stops the moment the text spreads out, which is exactly
871
+ // when the bands have been reached.
872
+ const textLen = (el) => (el.innerText ?? el.textContent ?? '').length;
873
+ let root = document.querySelectorAll('main')[0] ?? document.body;
874
+ for (let depth = 0; depth < 6; depth += 1) {
875
+ const kids = Array.from(root.children).filter((k) => !inPageChrome(k));
876
+ if (kids.length === 0)
877
+ break;
878
+ const total = textLen(root);
879
+ let biggest = kids[0];
880
+ for (const k of kids)
881
+ if (textLen(k) > textLen(biggest))
882
+ biggest = k;
883
+ if (total < 200 || textLen(biggest) < total * 0.7)
884
+ break;
885
+ root = biggest;
886
+ }
887
+ // BOTH READINGS, AND THE ONE THAT COVERS MORE WINS. Descending finds the
888
+ // band split on a page that wraps its content; it LOSES material on a page
889
+ // whose content is spread across two wrappers, because everything outside
890
+ // the biggest one is left behind — measured here as 89.7% falling to 82.7%.
891
+ // Neither rule is right for every page and the comparison costs one walk,
892
+ // so the page decides rather than the heuristic.
893
+ // A SPECULATIVE BUILD MUST LEAVE NO TRACE, and the first version of this
894
+ // left three. `build` is not pure — it pushes every `<form>` it meets onto
895
+ // the shared list, counts every skip, and spends the image and node budget
896
+ // — so trying a second reading REPORTED a one-form page as having three and
897
+ // trebled every skip count. Caught by two tests that were already there,
898
+ // which is the argument for asserting side effects and not only results.
899
+ const snap = () => ({
900
+ forms: forms.length,
901
+ skipped: { ...skipped },
902
+ taken: { ...taken },
903
+ });
904
+ const restore = (was) => {
905
+ forms.length = was.forms;
906
+ for (const k of Object.keys(skipped))
907
+ delete skipped[k];
908
+ Object.assign(skipped, was.skipped);
909
+ taken.images = was.taken.images;
910
+ taken.nodes = was.taken.nodes;
911
+ };
912
+ const before = snap();
913
+ let bestState = snap();
624
914
  const main = document.querySelectorAll('main')[0] ?? document.body;
625
- sections = build(Array.from(main.children));
915
+ for (const from of [root, main]) {
916
+ restore(before);
917
+ const wider = build(Array.from(from.children));
918
+ if (textOf(wider) > textOf(sections)) {
919
+ sections = wider;
920
+ bestState = snap();
921
+ }
922
+ }
923
+ restore(bestState);
626
924
  }
627
925
  const link = Array.from(document.querySelectorAll('link[rel="canonical"]'))[0];
628
926
  const canonical = link ? (link.getAttribute('href') ?? '') : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.30.0",
3
+ "version": "0.30.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",