sbuilder-mcp 0.101.2 → 0.101.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 +16 -0
- package/CHANGELOG.vi.md +16 -0
- package/dist/domains/site/filtervalues.js +38 -4
- package/dist/domains/site/findings.js +4 -0
- package/dist/domains/site/review.js +26 -0
- package/dist/domains/site/theme.js +3 -1
- package/dist/tools/page.js +16 -7
- package/package.json +1 -1
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.101.4] - 2026-10-30
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- `sb_review` accepts an optional `page_id` and refuses with an error when it is not the open page, and its result names the reviewed page in `page`.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- `sb_review` scores a button with its own `transparent` background against the real surface behind it instead of the preset's fill, so it no longer reports false low-contrast findings.
|
|
16
|
+
|
|
17
|
+
## [0.101.3] - 2026-10-29
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- `sb_review` reports a `filter_no_rows` finding for a filter or sort element with no enabled rows, except price filters with ranges or auto mode.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- `sb_add` seeds a sort select with the six product orders (newest, oldest, price, name) in the site language instead of publishing an empty panel, unless it targets a record list.
|
|
24
|
+
|
|
9
25
|
## [0.101.2] - 2026-10-29
|
|
10
26
|
|
|
11
27
|
### Fixed
|
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.101.4] - 2026-10-30
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- `sb_review` nhận thêm `page_id` tùy chọn và báo lỗi khi nó không phải trang đang mở, đồng thời kết quả ghi tên trang được review trong `page`.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- `sb_review` chấm nút có nền `transparent` riêng trên nền thật phía sau thay vì màu nền của preset, nên không còn báo sai lỗi tương phản thấp.
|
|
16
|
+
|
|
17
|
+
## [0.101.3] - 2026-10-29
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- `sb_review` báo finding `filter_no_rows` cho phần tử filter hoặc sắp xếp không có dòng nào được bật, trừ filter giá có khoảng giá hoặc chế độ auto.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- `sb_add` gieo cho select sắp xếp sáu thứ tự sản phẩm (mới nhất, cũ nhất, giá, tên) theo ngôn ngữ của site thay vì xuất bản panel rỗng, trừ khi nó nhắm tới danh sách bản ghi.
|
|
24
|
+
|
|
9
25
|
## [0.101.2] - 2026-10-29
|
|
10
26
|
|
|
11
27
|
### Fixed
|
|
@@ -12,7 +12,12 @@ import { siteToken } from '../../tools/credentialpick.js';
|
|
|
12
12
|
* attribute axis), the FIXED pairs from `schema/src/filters/sources.ts`, and
|
|
13
13
|
* price rows from the author's `filterRanges` in the `<from>-<to>` grammar
|
|
14
14
|
* `matchesRange` parses (measured live: `f.price=4500000000-7000000000` filters,
|
|
15
|
-
* `..` returns nothing). `sort`
|
|
15
|
+
* `..` returns nothing). A `sort` select gets the six product orders the editor's
|
|
16
|
+
* "Sort control" preset seeds (editor/src/element/sortOptions.ts, render/filters
|
|
17
|
+
* SortKeys; the vi labels are this server's) — without them it published an
|
|
18
|
+
* empty panel (TTG, 2026-10-30). Not
|
|
19
|
+
* when it aims at a record list, whose keys are `<fieldId>_asc|desc`. The
|
|
20
|
+
* blog/course sources are not covered.
|
|
16
21
|
*/
|
|
17
22
|
export const FILTER_VALUE_TYPES = new Set(['filter-checkbox', 'filter-radio', 'filter-tag', 'filter-color', 'select']);
|
|
18
23
|
/** The keys whose change re-derives the rows on sb_set. */
|
|
@@ -24,20 +29,49 @@ const FIXED = {
|
|
|
24
29
|
['in_stock', { en: 'In stock', vi: 'Còn hàng' }],
|
|
25
30
|
['out_of_stock', { en: 'Out of stock', vi: 'Hết hàng' }],
|
|
26
31
|
],
|
|
32
|
+
sort: [
|
|
33
|
+
['newest', { en: 'Newest', vi: 'Mới nhất' }],
|
|
34
|
+
['oldest', { en: 'Oldest', vi: 'Cũ nhất' }],
|
|
35
|
+
['price_asc', { en: 'Price: low to high', vi: 'Giá: thấp đến cao' }],
|
|
36
|
+
['price_desc', { en: 'Price: high to low', vi: 'Giá: cao đến thấp' }],
|
|
37
|
+
['name_asc', { en: 'Name: A-Z', vi: 'Tên: A-Z' }],
|
|
38
|
+
['name_desc', { en: 'Name: Z-A', vi: 'Tên: Z-A' }],
|
|
39
|
+
],
|
|
27
40
|
purchase_history: [
|
|
28
41
|
['purchased', { en: 'Purchased', vi: 'Đã mua' }],
|
|
29
42
|
['not_purchased', { en: 'Not purchased', vi: 'Chưa mua' }],
|
|
30
43
|
],
|
|
31
44
|
};
|
|
32
|
-
/**
|
|
33
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The node's source as the renderer reads it: a `select` with none publishes as
|
|
47
|
+
* a sort (render/nodes/dropdown WireSource(n, "sort")).
|
|
48
|
+
*/
|
|
49
|
+
export function sourceOf(type, sp) {
|
|
50
|
+
if (typeof sp.filterSource === 'string' && sp.filterSource)
|
|
51
|
+
return sp.filterSource;
|
|
52
|
+
return type === 'select' ? 'sort' : '';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Would the dialog's save write rows for this node? `force` = its source just
|
|
56
|
+
* moved. `nodes` = the document, to leave a sort aimed at a record list alone.
|
|
57
|
+
*/
|
|
58
|
+
export function wantsRows(type, sp, force = false, nodes = {}) {
|
|
34
59
|
if (!FILTER_VALUE_TYPES.has(type))
|
|
35
60
|
return false;
|
|
36
61
|
const mode = sp.filterValueMode ?? 'all';
|
|
37
62
|
if (mode !== 'all' && mode !== '')
|
|
38
63
|
return false;
|
|
39
|
-
|
|
64
|
+
const source = sourceOf(type, sp);
|
|
65
|
+
if (!source)
|
|
40
66
|
return false;
|
|
67
|
+
if (source === 'sort') {
|
|
68
|
+
const targets = [
|
|
69
|
+
...(typeof sp.filterTarget === 'string' && sp.filterTarget ? [sp.filterTarget] : []),
|
|
70
|
+
...(Array.isArray(sp.filterTargets) ? sp.filterTargets.map(String) : []),
|
|
71
|
+
];
|
|
72
|
+
if (targets.some((t) => nodes[t]?.data.type === 'list-dataset' && nodes[t]?.config?.datasetSource === 'record'))
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
41
75
|
return force || !Array.isArray(sp.filterValues) || sp.filterValues.length === 0;
|
|
42
76
|
}
|
|
43
77
|
/** Category facets in the dialog's order: depth-first under each parent, strays appended flat. */
|
|
@@ -149,6 +149,10 @@ export const FIX = {
|
|
|
149
149
|
'{ "filterSource": "record", "filterAxis": "fld_…", "filterTargets": ["<list id>"], "filterBehavior": "filter" } — ' +
|
|
150
150
|
'axis types text/select/reference/url/date/boolean/integer/number. A sort select takes filterValues ' +
|
|
151
151
|
'[{ "value": "fld_…_asc" | "fld_…_desc", "label": "…" }].',
|
|
152
|
+
filter_no_rows: 'Re-derive its rows: sb_set id "<id>", namespace specials, keys { "filterSource": "<its source>" } — a product ' +
|
|
153
|
+
'sort gets the six orders, a catalogue source reads the facets, a price filter needs filterRanges. A sort aimed ' +
|
|
154
|
+
'at a record list takes filterValues [{ "value": "fld_…_asc" | "fld_…_desc", "label": "…", "enabled": true }]; ' +
|
|
155
|
+
'anything else, write specials.filterValues [{ "value": …, "label": …, "enabled": true }] yourself.',
|
|
152
156
|
record_relation_unset: 'Link it to its parent row: sb_set id "<id>", namespace config, keys { "recordRelationField": "fld_…" } — ' +
|
|
153
157
|
'the ID of a "reference" field in THIS list\'s collection that targets the enclosing list\'s collection ' +
|
|
154
158
|
'(GET /api/sites/{siteId}/collections/{id}/fields, refCollectionId).',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { FILTER_VALUE_TYPES, sourceOf } from './filtervalues.js';
|
|
2
3
|
import { childrenOf, childrenWithSatellites, isOverlay, isSharedSection, pageChildren, subtreeIds, appBlockRoot, SPEC_GLOBAL_REF, SPEC_APP_BLOCK_REF } from '../../core/tree.js';
|
|
3
4
|
import { STUCK_STATE, stickyBlockedBy, stuckHostOf, isPinnedNode } from './sticky.js';
|
|
4
5
|
import { bandOf, isGlobal } from './traps.js';
|
|
@@ -918,6 +919,31 @@ opts = {}) {
|
|
|
918
919
|
});
|
|
919
920
|
}
|
|
920
921
|
}
|
|
922
|
+
// A FILTER OR SORT WITH NO ROWS shows nothing to choose (TTG, 2026-10-30: the
|
|
923
|
+
// category page's "Sắp xếp" opened onto an empty panel; a filter-* with no
|
|
924
|
+
// rows renders nothing at all). The renderer prints ONLY specials.filterValues,
|
|
925
|
+
// except price rows derived from filterRanges and the `auto` mode that follows
|
|
926
|
+
// the page. Record filters are left out: their rows are a field's values this
|
|
927
|
+
// server cannot derive, and record_filter_invalid judges them.
|
|
928
|
+
{
|
|
929
|
+
const sp = (n.specials ?? {});
|
|
930
|
+
const mode = sp.filterValueMode ?? 'all';
|
|
931
|
+
const source = sourceOf(type, sp);
|
|
932
|
+
const rows = Array.isArray(sp.filterValues) ? sp.filterValues : [];
|
|
933
|
+
const priceDerived = source === 'price' && Array.isArray(sp.filterRanges) && sp.filterRanges.length > 0;
|
|
934
|
+
if (FILTER_VALUE_TYPES.has(type) &&
|
|
935
|
+
mode !== 'auto' &&
|
|
936
|
+
source && source !== 'record' && !priceDerived &&
|
|
937
|
+
!rows.some((r) => r?.enabled !== false && String(r?.value ?? '') !== '')) {
|
|
938
|
+
out.push({
|
|
939
|
+
code: 'filter_no_rows',
|
|
940
|
+
nodeId: id,
|
|
941
|
+
type,
|
|
942
|
+
problem: `A ${source} ${type} with no enabled rows — ${type === 'select' ? 'it opens onto an empty panel' : 'it renders nothing'}; a shopper has nothing to choose.`,
|
|
943
|
+
fix: fill('filter_no_rows', { id }),
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
}
|
|
921
947
|
// RECORD LINK PARAMETERS and VISITOR FAVORITES (web_builder v1.0.174, contract §7.6/§7.7).
|
|
922
948
|
// Both read the record of the row they sit in — or the page's, on a record page.
|
|
923
949
|
{
|
|
@@ -92,7 +92,9 @@ export function groundOf(node, theme) {
|
|
|
92
92
|
if (own && own !== 'transparent') {
|
|
93
93
|
return { color: theme ? resolveVars(theme, own) : own, literal: !own.includes('var(') };
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
// An OWN `transparent` overrides the preset's fill (TTG: header links on
|
|
96
|
+
// button-default's #2e86ae read 2.28:1 while the page showed the bar's #eceef0).
|
|
97
|
+
if (own || !theme)
|
|
96
98
|
return null;
|
|
97
99
|
const id = presetIdOf(node);
|
|
98
100
|
const p = id ? s(findPreset(theme, id)?.base.backgroundColor) : '';
|
package/dist/tools/page.js
CHANGED
|
@@ -41,7 +41,7 @@ import { stickyWarning } from '../domains/site/sticky.js';
|
|
|
41
41
|
import { HOVER_STATE, PARENT_HOVER_STATE, hoverHostNote, hoverRoutingNote } from '../domains/site/hover.js';
|
|
42
42
|
import { siteFor } from './context.js';
|
|
43
43
|
import { projectList, PAGE_FIELDS, TEMPLATE_FIELDS } from './project.js';
|
|
44
|
-
import { FILTER_VALUE_TYPES, RESOURCE_KEYS, filterPatches, wantsRows } from '../domains/site/filtervalues.js';
|
|
44
|
+
import { FILTER_VALUE_TYPES, RESOURCE_KEYS, filterPatches, sourceOf, wantsRows } from '../domains/site/filtervalues.js';
|
|
45
45
|
/**
|
|
46
46
|
* Findings, in the shape every surface returns them.
|
|
47
47
|
*
|
|
@@ -1638,8 +1638,8 @@ export function registerPageTools(server, ctx) {
|
|
|
1638
1638
|
const after = d.preview(patches).doc.nodes;
|
|
1639
1639
|
const targets = ids
|
|
1640
1640
|
.map((id) => ({ id, node: after[id] }))
|
|
1641
|
-
.filter(({ node }) => node && wantsRows(node.data.type, (node.specials ?? {})))
|
|
1642
|
-
.map(({ id, node }) => ({ id, specials: (node.specials ?? {}) }));
|
|
1641
|
+
.filter(({ node }) => node && wantsRows(node.data.type, (node.specials ?? {}), false, after))
|
|
1642
|
+
.map(({ id, node }) => ({ id, specials: { ...(node.specials ?? {}), filterSource: sourceOf(node.data.type, (node.specials ?? {})) } }));
|
|
1643
1643
|
if (targets.length) {
|
|
1644
1644
|
const got = await filterPatches(ctx, session.site(), targets);
|
|
1645
1645
|
patches.push(...got.patches);
|
|
@@ -1736,7 +1736,8 @@ export function registerPageTools(server, ctx) {
|
|
|
1736
1736
|
const resourced = batch
|
|
1737
1737
|
.filter((e) => e.namespace === 'specials' && !('filterValues' in e.keys) && RESOURCE_KEYS.some((k) => k in e.keys))
|
|
1738
1738
|
.map((e) => ({ id: e.id, specials: { ...(d.doc.nodes[e.id]?.specials ?? {}), ...e.keys } }))
|
|
1739
|
-
.filter((t) => wantsRows(d.doc.nodes[t.id]?.data.type ?? '', t.specials, true))
|
|
1739
|
+
.filter((t) => wantsRows(d.doc.nodes[t.id]?.data.type ?? '', t.specials, true, d.doc.nodes))
|
|
1740
|
+
.map((t) => ({ ...t, specials: { ...t.specials, filterSource: sourceOf(d.doc.nodes[t.id]?.data.type ?? '', t.specials) } }));
|
|
1740
1741
|
// Its patches join the batch only on the real write: a dry run's `patches`
|
|
1741
1742
|
// never echoes what a GET read (rule 8) — `filters` says the row counts.
|
|
1742
1743
|
const refiltered = resourced.length ? await filterPatches(ctx, session.site(), resourced) : null;
|
|
@@ -2037,11 +2038,18 @@ export function registerPageTools(server, ctx) {
|
|
|
2037
2038
|
server.registerTool('sb_review', {
|
|
2038
2039
|
description: 'What a VISITOR would meet on the open page (blank band, placeholder, dead binding) AND ' +
|
|
2039
2040
|
"what stands between this store and a paid order (checkout page, gateway, delivery, a " +
|
|
2040
|
-
'
|
|
2041
|
-
inputSchema: {},
|
|
2041
|
+
'cart link). Run it before calling a page done; page_id: only that page.',
|
|
2042
|
+
inputSchema: { page_id: z.string().optional() },
|
|
2042
2043
|
annotations: { readOnlyHint: true },
|
|
2043
|
-
}, async () => {
|
|
2044
|
+
}, async ({ page_id }) => {
|
|
2044
2045
|
const doc = session.current();
|
|
2046
|
+
// A REVIEW OF THE WRONG PAGE READS AS A CLEAN ONE. Measured on TTG: sb_page_open
|
|
2047
|
+
// batched with sb_review reached the server SECOND (the client's own dispatch,
|
|
2048
|
+
// past serial.ts), and the account page's review was the search page's.
|
|
2049
|
+
const open = session.page()?.pageId;
|
|
2050
|
+
if (page_id && page_id !== open) {
|
|
2051
|
+
throw new Error(`sbuilder: the open page is ${open}, not ${page_id} — call sb_page_open first, then review.`);
|
|
2052
|
+
}
|
|
2045
2053
|
// THE STORE'S OWN READINESS, which no API exposes and no page document
|
|
2046
2054
|
// can show. A page can review perfectly clean and still sit on a store
|
|
2047
2055
|
// with no checkout page, no gateway and no way back to the cart.
|
|
@@ -2101,6 +2109,7 @@ export function registerPageTools(server, ctx) {
|
|
|
2101
2109
|
// Clean = no finding a visitor meets; `advice` (maintenance) rides beside the verdict.
|
|
2102
2110
|
const clean = !field.findings;
|
|
2103
2111
|
return text({
|
|
2112
|
+
page: open,
|
|
2104
2113
|
...(clean ? { findings: [], verdict: 'Nothing a visitor would notice on this page.' } : {}),
|
|
2105
2114
|
...field,
|
|
2106
2115
|
...store,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sbuilder-mcp",
|
|
3
|
-
"version": "0.101.
|
|
3
|
+
"version": "0.101.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",
|