sbuilder-mcp 0.102.0 → 0.103.0

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,24 @@ 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.103.0] - 2026-10-30
10
+
11
+ ### Added
12
+ - `sb_code` accepts a `language` of html, css, javascript, scss, typescript, json or text, infers it from the file extension when omitted, and refuses unknown extensions until `language` is passed.
13
+ - `sb_code` accepts `placement` set to `none`, which is the only placement json and text files take.
14
+ - `sb_code` returns a `compile_error` when a scss or typescript build fails, stating whether the previous build is still served or nothing is served.
15
+ - `sb_code` returns a `url` of the form `/_wb/code/<name>` for site-wide, enabled files with `placement` set to `none`.
16
+
17
+ ### Changed
18
+ - `sb_code` sends `expectedUpdatedAt` on updates and deletes, and a `code_file_changed` conflict tells the caller to re-run.
19
+ - `sb_code` rejects scss and typescript sources that start with a wrapper tag, and re-validates css and javascript served verbatim when they move out of `none`.
20
+ - The generated catalog is regenerated against web_builder v1.0.199 and now covers 923 operations.
21
+
22
+ ## [0.102.1] - 2026-10-30
23
+
24
+ ### Fixed
25
+ - `sb_review` no longer reports `tag_filters_share_key` for tag filters that carry the same values, such as a desktop sidebar and its mobile accordion copy sharing one key on purpose.
26
+
9
27
  ## [0.102.0] - 2026-10-30
10
28
 
11
29
  ### Added
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,24 @@ 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.103.0] - 2026-10-30
10
+
11
+ ### Added
12
+ - `sb_code` nhận `language` là html, css, javascript, scss, typescript, json hoặc text, tự suy từ đuôi tên file khi bỏ trống và từ chối đuôi lạ cho đến khi truyền `language`.
13
+ - `sb_code` nhận `placement` là `none`, đây là giá trị duy nhất mà file json và text chấp nhận.
14
+ - `sb_code` trả về `compile_error` khi bản build scss hoặc typescript hỏng, nêu rõ bản build cũ vẫn còn được phục vụ hay chưa có gì được phục vụ.
15
+ - `sb_code` trả về `url` dạng `/_wb/code/<name>` cho file site-wide đang bật có `placement` là `none`.
16
+
17
+ ### Changed
18
+ - `sb_code` gửi `expectedUpdatedAt` khi cập nhật và xóa, và xung đột `code_file_changed` yêu cầu người gọi chạy lại.
19
+ - `sb_code` từ chối nguồn scss và typescript mở đầu bằng thẻ bao, và kiểm tra lại css và javascript được phục vụ nguyên văn khi chuyển ra khỏi `none`.
20
+ - Catalog sinh tự động được sinh lại theo web_builder v1.0.199 và nay gồm 923 operation.
21
+
22
+ ## [0.102.1] - 2026-10-30
23
+
24
+ ### Fixed
25
+ - `sb_review` không còn báo `tag_filters_share_key` cho các bộ lọc thẻ có cùng giá trị, chẳng hạn sidebar desktop và bản accordion mobile dùng chung một khóa có chủ đích.
26
+
9
27
  ## [0.102.0] - 2026-10-30
10
28
 
11
29
  ### Added
package/README.md CHANGED
@@ -100,7 +100,7 @@ in this client: one would put the very key the platform exists to hold back into
100
100
  | `sb_page_create` | Create a page — a store type arrives with the editor's own starting document; `type` is the route for checkout, product, category, post, course |
101
101
  | `sb_page_update` | Edit a page's name, slug, home flag, order, SEO (title, description, Open Graph, robots, meta tags, JSON-LD) and members-only flag — merged into `settings`, so the keys it does not name survive. On a template page: make it the type's default, or choose which products/categories/posts render through it |
102
102
  | `sb_page_version` | A page's platform recovery points — list named versions and autosave history, snapshot the draft, restore one |
103
- | `sb_code` | The site's custom code files (tracking pixels, analytics, chat widgets, site CSS) injected into every page or one — list, create, merge-update, remove |
103
+ | `sb_code` | The site's custom code files (tracking pixels, analytics, chat widgets, site CSS; html/css/js/scss/ts injected, json/text served at `/_wb/code/<name>`) for every page or one — list, create, merge-update, remove; scss/ts compile on write and report `compile_error` |
104
104
  | `sb_publish` | Compile the draft into the live page (cascades to shared globals), report which revision went live, and with `verify` check the origin is serving it; lists other pages with unpublished drafts and never-published pages (`publish_drafts` publishes both) |
105
105
  | `sb_page_state` | Which of a page's three copies is which — the DRAFT the editor canvas shows, the PUBLISHED row the storefront serves, and this session's — plus whether the editor will render the canvas BLANK, and where the recovery points are |
106
106
  | `sb_page_repair` | Rename a page root that is not `ROOT` (left by older seeds) so every editor build draws it — one page or the whole site |
@@ -118,7 +118,7 @@ in this client: one would put the very key the platform exists to hold back into
118
118
  | `sb_store` | Run a store flow that must happen in a fixed order — `checkout` (the four writes that make a working one), `checkout_sync` (the store's current payment and delivery methods into every existing order form, checkout page republished), `form` (any of the platform's 17 templates with its own field document), `chrome` (one shared header or footer on a real site menu — site name linked home, desktop menu, mobile drawer, search, cart and account icons), `menu` (a menu node bound to the site's menu, its links resolved), `overlay_attach` (a pop-up or quick view on the open page), `cart` (the site's cart drawer, when it has none; `relocalize` puts an existing one in the site's language) and `app` (a built-in app plus the pages it needs), `global_attach` / `global_detach` (put an EXISTING shared section on the open page, or take it off), `global_promote` (make a section on the page a NEW shared section) and `template_save` (save a section as a reusable template) |
119
119
  | `sb_undo` | Undo / redo this session's writes — page and form edits and `sb_api_call` PUTs, each named by tool and target, the open page's by default (`all: true` for every page); a page is refused if someone else saved it since. The platform's versions and history (`sb_page_version`) outlive this process |
120
120
 
121
- Twenty-eight tools, **919 API operations** (344 of the 429 writes carrying a body shape read
121
+ Twenty-eight tools, **923 API operations** (346 of the 431 writes carrying a body shape read
122
122
  off the handler), 124 elements, 96 binding sources. `sb_api_find`
123
123
  is an index rather than a tool per endpoint, so the tool list stays short while everything
124
124
  the platform can do stays reachable — and operations added to the platform arrive with the
package/README.vi.md CHANGED
@@ -97,7 +97,7 @@ nhét ngược lại vào mọi bản cài.
97
97
  | `sb_page_create` | Tạo một trang — trang cửa hàng sinh ra đã có sẵn tài liệu như trong editor; `type` là đường đi cho checkout, product, category, post, course |
98
98
  | `sb_page_update` | Sửa tên, slug, cờ trang chủ, thứ tự, SEO (title, description, Open Graph, robots, meta tag, JSON-LD) và cờ chỉ-thành-viên của một trang — merge vào `settings`, nên các khoá không nhắc tới vẫn còn nguyên. Với trang template: đặt làm mặc định của loại, hoặc chọn sản phẩm/danh mục/bài viết nào hiển thị qua nó |
99
99
  | `sb_page_version` | Các điểm khôi phục của trang trên platform — liệt kê phiên bản có tên và lịch sử autosave, chụp draft, khôi phục |
100
- | `sb_code` | Các file mã tuỳ chỉnh của site (pixel theo dõi, analytics, widget chat, CSS toàn site) chèn vào mọi trang hoặc một trang — liệt kê, tạo, cập nhật gộp, xoá |
100
+ | `sb_code` | Các file mã tuỳ chỉnh của site (pixel theo dõi, analytics, widget chat, CSS toàn site; html/css/js/scss/ts được chèn, json/text phục vụ tại `/_wb/code/<name>`) cho mọi trang hoặc một trang — liệt kê, tạo, cập nhật gộp, xoá; scss/ts biên dịch lúc ghi và báo `compile_error` |
101
101
  | `sb_publish` | Biên dịch bản nháp thành trang live (lan sang global dùng chung), báo bản nào đã lên live, và với `verify` kiểm origin đã phục vụ đúng bản đó chưa; liệt kê các trang khác còn nháp chưa publish và các trang chưa từng publish (`publish_drafts` publish luôn cả hai) |
102
102
  | `sb_page_state` | Ba bản sao của một trang, bản nào là bản nào — bản NHÁP canvas editor hiển thị, dòng PUBLISHED storefront phục vụ, và bản phiên này giữ — kèm dự báo editor có render canvas TRẮNG không, và các điểm phục hồi nằm ở đâu |
103
103
  | `sb_page_repair` | Đổi gốc trang khác `ROOT` (do seed cũ để lại) về `ROOT` để mọi bản editor vẽ được — một trang hoặc cả site |
@@ -115,7 +115,7 @@ nhét ngược lại vào mọi bản cài.
115
115
  | `sb_store` | Chạy một luồng cửa hàng bắt buộc đúng thứ tự — `checkout` (bốn lệnh ghi tạo nên trang thanh toán), `checkout_sync` (đưa phương thức thanh toán và giao hàng hiện tại vào mọi form đặt hàng đã có, publish lại trang thanh toán), `form` (một trong 17 template của nền tảng kèm field document của nó), `chrome` (một header hoặc footer dùng chung trên menu thật của site — tên site dẫn về trang chủ, menu desktop, drawer mobile, ô tìm kiếm, icon giỏ hàng và tài khoản), `menu` (một node menu bind vào menu của site, link đã phân giải), `overlay_attach` (một pop-up hay quick view trên trang đang mở), `cart` (ngăn giỏ hàng của site, khi chưa có; `relocalize` đưa ngăn giỏ đã có về ngôn ngữ của site), `app` (một app dựng sẵn kèm những trang nó cần), và `global_attach` / `global_detach` (đặt một section dùng chung ĐÃ CÓ lên trang đang mở, hoặc gỡ ra), `global_promote` (biến một section trên trang thành section dùng chung MỚI) và `template_save` (lưu một section làm mẫu dùng lại) |
116
116
  | `sb_undo` | Hoàn tác / làm lại các thao tác ghi trong phiên — chỉnh sửa trang, form và PUT qua `sb_api_call`, mỗi mục ghi tên tool và đối tượng, mặc định của trang đang mở (`all: true` cho mọi trang); trang bị từ chối nếu người khác đã lưu sau đó. Version và history của nền tảng (`sb_page_version`) sống lâu hơn process này |
117
117
 
118
- Hai mươi tám tool, **919 operation API** (344 trong 429 lệnh ghi có hình dạng body đọc thẳng
118
+ Hai mươi tám tool, **923 operation API** (346 trong 431 lệnh ghi có hình dạng body đọc thẳng
119
119
  từ handler), 124 element, 96 nguồn binding. `sb_api_find` là
120
120
  một chỉ mục chứ không phải mỗi endpoint một tool, nên danh sách tool vẫn ngắn trong khi mọi
121
121
  thứ nền tảng làm được vẫn với tới — và operation mới thêm bên nền tảng sẽ tự có sau lần
@@ -1,7 +1,7 @@
1
1
  export const SWAGGER_SOURCE = {
2
- "operations": 919,
3
- "definitions": 329,
4
- "bodyCarrying": 430,
2
+ "operations": 923,
3
+ "definitions": 331,
4
+ "bodyCarrying": 434,
5
5
  "bodyUndescribed": 115,
6
6
  "generatedFrom": "server/docs/swagger.json"
7
7
  };
@@ -1881,6 +1881,90 @@ export const API_OPERATIONS = [
1881
1881
  "bodyRef": null,
1882
1882
  "credential": "siteScoped"
1883
1883
  },
1884
+ {
1885
+ "id": "get:/api/admin/template-categories",
1886
+ "method": "GET",
1887
+ "path": "/api/admin/template-categories",
1888
+ "tags": [
1889
+ "admin"
1890
+ ],
1891
+ "summary": "Platform template categories (list / create / edit / delete)",
1892
+ "params": [
1893
+ {
1894
+ "name": "category",
1895
+ "in": "body",
1896
+ "required": false,
1897
+ "type": "object",
1898
+ "description": "Category (POST/PATCH)"
1899
+ }
1900
+ ],
1901
+ "bodyDescribed": true,
1902
+ "bodyRef": "github_com_webbuilder_server_internal_platformadmin.TemplateCategoryInput",
1903
+ "credential": "siteScoped"
1904
+ },
1905
+ {
1906
+ "id": "post:/api/admin/template-categories",
1907
+ "method": "POST",
1908
+ "path": "/api/admin/template-categories",
1909
+ "tags": [
1910
+ "admin"
1911
+ ],
1912
+ "summary": "Platform template categories (list / create / edit / delete)",
1913
+ "params": [
1914
+ {
1915
+ "name": "category",
1916
+ "in": "body",
1917
+ "required": false,
1918
+ "type": "object",
1919
+ "description": "Category (POST/PATCH)"
1920
+ }
1921
+ ],
1922
+ "bodyDescribed": true,
1923
+ "bodyRef": "github_com_webbuilder_server_internal_platformadmin.TemplateCategoryInput",
1924
+ "credential": "siteScoped"
1925
+ },
1926
+ {
1927
+ "id": "patch:/api/admin/template-categories/{id}",
1928
+ "method": "PATCH",
1929
+ "path": "/api/admin/template-categories/{id}",
1930
+ "tags": [
1931
+ "admin"
1932
+ ],
1933
+ "summary": "Platform template categories (list / create / edit / delete)",
1934
+ "params": [
1935
+ {
1936
+ "name": "category",
1937
+ "in": "body",
1938
+ "required": false,
1939
+ "type": "object",
1940
+ "description": "Category (POST/PATCH)"
1941
+ }
1942
+ ],
1943
+ "bodyDescribed": true,
1944
+ "bodyRef": "github_com_webbuilder_server_internal_platformadmin.TemplateCategoryInput",
1945
+ "credential": "siteScoped"
1946
+ },
1947
+ {
1948
+ "id": "delete:/api/admin/template-categories/{id}",
1949
+ "method": "DELETE",
1950
+ "path": "/api/admin/template-categories/{id}",
1951
+ "tags": [
1952
+ "admin"
1953
+ ],
1954
+ "summary": "Platform template categories (list / create / edit / delete)",
1955
+ "params": [
1956
+ {
1957
+ "name": "category",
1958
+ "in": "body",
1959
+ "required": false,
1960
+ "type": "object",
1961
+ "description": "Category (POST/PATCH)"
1962
+ }
1963
+ ],
1964
+ "bodyDescribed": true,
1965
+ "bodyRef": "github_com_webbuilder_server_internal_platformadmin.TemplateCategoryInput",
1966
+ "credential": "siteScoped"
1967
+ },
1884
1968
  {
1885
1969
  "id": "get:/api/admin/translation-keys",
1886
1970
  "method": "GET",
@@ -27075,7 +27159,15 @@ export const API_OPERATIONS = [
27075
27159
  "templates"
27076
27160
  ],
27077
27161
  "summary": "The site templates a new store can be created from",
27078
- "params": [],
27162
+ "params": [
27163
+ {
27164
+ "name": "locale",
27165
+ "in": "query",
27166
+ "required": false,
27167
+ "type": "string",
27168
+ "description": "Language for category names (falls back to the platform default, then the slug)"
27169
+ }
27170
+ ],
27079
27171
  "bodyDescribed": false,
27080
27172
  "bodyRef": null,
27081
27173
  "credential": "siteScoped"
@@ -29574,6 +29666,13 @@ export const API_DEFINITIONS = {
29574
29666
  "github_com_webbuilder_server_internal_codefiles.CodeFile": {
29575
29667
  "type": "object",
29576
29668
  "properties": {
29669
+ "compileError": {
29670
+ "type": "string"
29671
+ },
29672
+ "compiled": {
29673
+ "description": "Compiled and CompileError are SERVER-OWNED build output of a scss or\ntypescript row (\"\" for every other language): Compiled is what the\nstorefront injects or serves, CompileError the last failure as\n\"<name>:<line>:<column>: <message>\". The adapters persist both exactly as\ngiven; the compile decorator (codefiles/compile) is what assigns them on\nevery write, whatever a request body carried.",
29674
+ "type": "string"
29675
+ },
29577
29676
  "content": {
29578
29677
  "type": "string"
29579
29678
  },
@@ -29614,12 +29713,20 @@ export const API_DEFINITIONS = {
29614
29713
  "enum": [
29615
29714
  "html",
29616
29715
  "css",
29617
- "javascript"
29716
+ "javascript",
29717
+ "scss",
29718
+ "typescript",
29719
+ "json",
29720
+ "text"
29618
29721
  ],
29619
29722
  "x-enum-varnames": [
29620
29723
  "LanguageHTML",
29621
29724
  "LanguageCSS",
29622
- "LanguageJavaScript"
29725
+ "LanguageJavaScript",
29726
+ "LanguageSCSS",
29727
+ "LanguageTypeScript",
29728
+ "LanguageJSON",
29729
+ "LanguageText"
29623
29730
  ]
29624
29731
  },
29625
29732
  "github_com_webbuilder_server_internal_codefiles.Placement": {
@@ -29627,12 +29734,14 @@ export const API_DEFINITIONS = {
29627
29734
  "enum": [
29628
29735
  "head",
29629
29736
  "body_start",
29630
- "body_end"
29737
+ "body_end",
29738
+ "none"
29631
29739
  ],
29632
29740
  "x-enum-varnames": [
29633
29741
  "PlacementHead",
29634
29742
  "PlacementBodyStart",
29635
- "PlacementBodyEnd"
29743
+ "PlacementBodyEnd",
29744
+ "PlacementNone"
29636
29745
  ]
29637
29746
  },
29638
29747
  "github_com_webbuilder_server_internal_collections.Field": {
@@ -31262,6 +31371,37 @@ export const API_DEFINITIONS = {
31262
31371
  }
31263
31372
  }
31264
31373
  },
31374
+ "github_com_webbuilder_server_internal_platformadmin.TemplateCategoryInput": {
31375
+ "type": "object",
31376
+ "properties": {
31377
+ "enabled": {
31378
+ "type": "boolean"
31379
+ },
31380
+ "position": {
31381
+ "type": "integer"
31382
+ },
31383
+ "slug": {
31384
+ "type": "string"
31385
+ },
31386
+ "translations": {
31387
+ "type": "array",
31388
+ "items": {
31389
+ "$ref": "#/definitions/github_com_webbuilder_server_internal_platformadmin.TemplateCategoryTranslation"
31390
+ }
31391
+ }
31392
+ }
31393
+ },
31394
+ "github_com_webbuilder_server_internal_platformadmin.TemplateCategoryTranslation": {
31395
+ "type": "object",
31396
+ "properties": {
31397
+ "locale": {
31398
+ "type": "string"
31399
+ },
31400
+ "name": {
31401
+ "type": "string"
31402
+ }
31403
+ }
31404
+ },
31265
31405
  "github_com_webbuilder_server_internal_pos.AddLinesInput": {
31266
31406
  "type": "object",
31267
31407
  "properties": {
@@ -36677,6 +36817,9 @@ export const API_DEFINITIONS = {
36677
36817
  "internal_publicapi.CodeFile": {
36678
36818
  "type": "object",
36679
36819
  "properties": {
36820
+ "compileError": {
36821
+ "type": "string"
36822
+ },
36680
36823
  "content": {
36681
36824
  "type": "string"
36682
36825
  },
@@ -1,6 +1,6 @@
1
1
  export const DEAD_KEY_SOURCE = {
2
- "files": 6066,
3
- "identifiers": 111445,
2
+ "files": 6771,
3
+ "identifiers": 112741,
4
4
  "seededKeys": 461,
5
5
  "dead": 0
6
6
  };
@@ -1,10 +1,10 @@
1
1
  export const SHAPE_SOURCE = {
2
- "writeOperations": 429,
3
- "shaped": 344,
4
- "fromHandlers": 334,
2
+ "writeOperations": 431,
3
+ "shaped": 346,
4
+ "fromHandlers": 336,
5
5
  "fromSwaggerOnly": 10,
6
6
  "withReadOnly": 29,
7
- "structsRead": 3494
7
+ "structsRead": 3502
8
8
  };
9
9
  export const REQUEST_SHAPES = {
10
10
  "post:/api/sites/{id}/ai-credits/purchase": {
@@ -1387,11 +1387,11 @@ export const REQUEST_SHAPES = {
1387
1387
  },
1388
1388
  {
1389
1389
  "name": "language",
1390
- "type": "\"html\" | \"css\" | \"javascript\""
1390
+ "type": "Language"
1391
1391
  },
1392
1392
  {
1393
1393
  "name": "placement",
1394
- "type": "\"head\" | \"body_start\" | \"body_end\""
1394
+ "type": "Placement"
1395
1395
  },
1396
1396
  {
1397
1397
  "name": "content",
@@ -1412,6 +1412,15 @@ export const REQUEST_SHAPES = {
1412
1412
  {
1413
1413
  "name": "updatedAt",
1414
1414
  "type": "string (RFC3339)"
1415
+ },
1416
+ {
1417
+ "name": "compiled",
1418
+ "type": "string",
1419
+ "note": "Compiled and CompileError are SERVER-OWNED build output of a scss or typescript row (\"\" for every other language): Compiled is what the storefront injects or serves, CompileError the last failure as \"<name>:<line>:<column>: <message>\"."
1420
+ },
1421
+ {
1422
+ "name": "compileError",
1423
+ "type": "string"
1415
1424
  }
1416
1425
  ],
1417
1426
  "source": "go",
@@ -1420,7 +1429,9 @@ export const REQUEST_SHAPES = {
1420
1429
  "id",
1421
1430
  "siteId",
1422
1431
  "createdAt",
1423
- "updatedAt"
1432
+ "updatedAt",
1433
+ "compiled",
1434
+ "compileError"
1424
1435
  ]
1425
1436
  },
1426
1437
  "put:/api/sites/{siteId}/code-files/{id}": {
@@ -1443,11 +1454,11 @@ export const REQUEST_SHAPES = {
1443
1454
  },
1444
1455
  {
1445
1456
  "name": "language",
1446
- "type": "\"html\" | \"css\" | \"javascript\""
1457
+ "type": "Language"
1447
1458
  },
1448
1459
  {
1449
1460
  "name": "placement",
1450
- "type": "\"head\" | \"body_start\" | \"body_end\""
1461
+ "type": "Placement"
1451
1462
  },
1452
1463
  {
1453
1464
  "name": "content",
@@ -1469,6 +1480,15 @@ export const REQUEST_SHAPES = {
1469
1480
  "name": "updatedAt",
1470
1481
  "type": "string (RFC3339)"
1471
1482
  },
1483
+ {
1484
+ "name": "compiled",
1485
+ "type": "string",
1486
+ "note": "Compiled and CompileError are SERVER-OWNED build output of a scss or typescript row (\"\" for every other language): Compiled is what the storefront injects or serves, CompileError the last failure as \"<name>:<line>:<column>: <message>\"."
1487
+ },
1488
+ {
1489
+ "name": "compileError",
1490
+ "type": "string"
1491
+ },
1472
1492
  {
1473
1493
  "name": "expectedUpdatedAt",
1474
1494
  "type": "string (RFC3339) | null"
@@ -6985,6 +7005,70 @@ export const REQUEST_SHAPES = {
6985
7005
  "source": "go",
6986
7006
  "goType": "payoutBody"
6987
7007
  },
7008
+ "post:/api/admin/template-categories": {
7009
+ "fields": [
7010
+ {
7011
+ "name": "slug",
7012
+ "type": "string"
7013
+ },
7014
+ {
7015
+ "name": "position",
7016
+ "type": "number"
7017
+ },
7018
+ {
7019
+ "name": "enabled",
7020
+ "type": "boolean"
7021
+ },
7022
+ {
7023
+ "name": "translations",
7024
+ "type": "TemplateCategoryTranslation[] | null",
7025
+ "fields": [
7026
+ {
7027
+ "name": "locale",
7028
+ "type": "string"
7029
+ },
7030
+ {
7031
+ "name": "name",
7032
+ "type": "string"
7033
+ }
7034
+ ]
7035
+ }
7036
+ ],
7037
+ "source": "go",
7038
+ "goType": "platformadmin.TemplateCategoryInput"
7039
+ },
7040
+ "patch:/api/admin/template-categories/{id}": {
7041
+ "fields": [
7042
+ {
7043
+ "name": "slug",
7044
+ "type": "string"
7045
+ },
7046
+ {
7047
+ "name": "position",
7048
+ "type": "number"
7049
+ },
7050
+ {
7051
+ "name": "enabled",
7052
+ "type": "boolean"
7053
+ },
7054
+ {
7055
+ "name": "translations",
7056
+ "type": "TemplateCategoryTranslation[] | null",
7057
+ "fields": [
7058
+ {
7059
+ "name": "locale",
7060
+ "type": "string"
7061
+ },
7062
+ {
7063
+ "name": "name",
7064
+ "type": "string"
7065
+ }
7066
+ ]
7067
+ }
7068
+ ],
7069
+ "source": "go",
7070
+ "goType": "platformadmin.TemplateCategoryInput"
7071
+ },
6988
7072
  "post:/api/admin/translation-keys": {
6989
7073
  "fields": [
6990
7074
  {
@@ -1,7 +1,7 @@
1
1
  // GENERATED by scripts/gen-catalog.ts — do not edit by hand.
2
2
  // The platform commit every other generated file here describes.
3
3
  export const PLATFORM_SOURCE = {
4
- "commit": "933548d70fed2991e00069b2b3b705870edb8175",
5
- "committedAt": "2026-10-30T10:19:43+07:00",
4
+ "commit": "c2ff3588b205ab26d5abf17b9ce696cb90db8f9a",
5
+ "committedAt": "2026-10-30T18:07:20+07:00",
6
6
  "dirty": false
7
7
  };
@@ -473,6 +473,8 @@ opts = {}) {
473
473
  // emptied the shelf on two CPUs. Since web_builder's tag filter groups each filter owns
474
474
  // `f.tag.<filterGroupKey>`: values OR within it, groups AND. Event filters write no URL.
475
475
  {
476
+ // A MIRROR — the same values on another breakpoint's copy (desktop sidebar, mobile
477
+ // accordion) — shares the key on purpose; only DIFFERENT value sets are two facets.
476
478
  const byKey = new Map();
477
479
  for (const id of walkOrder) {
478
480
  const n = d.nodes[id];
@@ -485,12 +487,14 @@ opts = {}) {
485
487
  ...(Array.isArray(sp.filterTargets) ? sp.filterTargets.filter((t) => typeof t === 'string' && t !== '') : []),
486
488
  ];
487
489
  const key = g ? `tag.${g}` : 'tag';
488
- byKey.set(key, [...(byKey.get(key) ?? []), { id, type: n.data.type, targets }]);
490
+ const rows = Array.isArray(sp.filterValues) ? sp.filterValues : [];
491
+ const values = rows.map((r) => String(r?.value ?? '').toLowerCase()).sort().join('\n');
492
+ byKey.set(key, [...(byKey.get(key) ?? []), { id, type: n.data.type, targets, values }]);
489
493
  }
490
494
  for (const [key, list] of byKey) {
491
495
  const overlaps = (a, b) => a.length === 0 || b.length === 0 || a.some((t) => b.includes(t));
492
496
  for (let i = 1; i < list.length; i++) {
493
- if (!list.slice(0, i).some((p) => overlaps(p.targets, list[i].targets)))
497
+ if (!list.slice(0, i).some((p) => p.values !== list[i].values && overlaps(p.targets, list[i].targets)))
494
498
  continue;
495
499
  out.push({
496
500
  code: 'tag_filters_share_key',
@@ -1,14 +1,75 @@
1
1
  import { z } from 'zod';
2
2
  import { text } from '../mcp/response.js';
3
- import { request, redact } from '../transport/http.js';
3
+ import { request, redact, ApiError } from '../transport/http.js';
4
4
  import { siteToken } from './credentialpick.js';
5
5
  import { siteFor } from './context.js';
6
+ /**
7
+ * A site's CUSTOM CODE — the editor's "Mã tuỳ chỉnh" for the site and per page
8
+ * (`server/internal/codefiles`). This is where a tracking pixel, an analytics
9
+ * tag or a chat widget goes: a snippet injected into the served document at
10
+ * head, body start or body end. Not `custom-code` the ELEMENT, which renders
11
+ * inside the page body where the canvas can see it.
12
+ *
13
+ * THE PUT IS A FULL REPLACE (`store.go Update` writes the body wholesale), so a
14
+ * partial body blanks `content` — an update here always reads the row first and
15
+ * sends it back whole with only the named fields moved.
16
+ *
17
+ * INJECTED AT SERVE TIME (`codeinject.go`), so a write is live on the next
18
+ * request without a publish. css is wrapped in <style>, javascript in <script>,
19
+ * unless the content already OPENS with that tag; scss/typescript output is
20
+ * ALWAYS wrapped (codeinject.wrap has no exemption for them); html goes in
21
+ * verbatim. scss/typescript are COMPILED on write and inject (or serve) their
22
+ * output; a failed build stores the source plus `compileError`, and keeps the
23
+ * previous output only when one existed and the language did not change. json/text are never injected — placement `none` only — and an
24
+ * ENABLED SITE-WIDE `none` row is served at `/_wb/code/<name>` on the store host.
25
+ */
26
+ const LANGUAGES = ['html', 'css', 'javascript', 'scss', 'typescript', 'json', 'text'];
27
+ const PLACEMENTS = ['head', 'body_start', 'body_end', 'none'];
28
+ /** Mirrors the Code Dock's `EXT` (editor/src/features/codedock/paths.ts); test/code-tables.test.ts checks it against WB_REPO. */
29
+ export const CODE_EXT = {
30
+ css: 'css', js: 'javascript', mjs: 'javascript', html: 'html', htm: 'html', scss: 'scss',
31
+ ts: 'typescript', tsx: 'typescript', json: 'json', webmanifest: 'json',
32
+ txt: 'text', md: 'text', xml: 'text', svg: 'text', csv: 'text',
33
+ };
34
+ /** Mirrors Go `codefiles.DefaultPlacement` / paths.ts `DEFAULT_PLACEMENT`. */
35
+ export const CODE_DEFAULT_PLACEMENT = {
36
+ html: 'body_end', css: 'head', javascript: 'body_end', scss: 'head',
37
+ typescript: 'body_end', json: 'none', text: 'none',
38
+ };
39
+ /**
40
+ * A known extension names the language; NO extension stays javascript ("Analytics tag").
41
+ * An UNKNOWN one is refused rather than taken as text (the editor's rule): "Pixel v2.1"
42
+ * would be stored at placement none and never run, where it used to be injected.
43
+ */
44
+ function languageFromName(name) {
45
+ const m = /\.([a-z0-9]+)$/i.exec(name);
46
+ if (!m)
47
+ return 'javascript';
48
+ const lang = CODE_EXT[m[1].toLowerCase()];
49
+ if (lang)
50
+ return lang;
51
+ throw new Error(`sbuilder: "${name}" ends in an extension sb_code does not recognise (.${m[1]}) — pass language explicitly ` +
52
+ `(${LANGUAGES.join('/')}; "text" stores it as a raw file served at /_wb/code/).`);
53
+ }
54
+ /** The optimistic-concurrency guard's 409 (codefiles/rest writeErr): the next call re-reads, so re-running is the fix. */
55
+ function guarded(p) {
56
+ return p.catch((e) => {
57
+ if (e instanceof ApiError && e.code === 'code_file_changed') {
58
+ e.message += ' — someone else wrote this file since it was read; re-run this sb_code call (it re-reads first).';
59
+ }
60
+ throw e;
61
+ });
62
+ }
63
+ /** The tag the server wraps a language's content in; html/json/text are not wrapped. */
64
+ const WRAP = { css: 'style', scss: 'style', javascript: 'script', typescript: 'script' };
6
65
  const LIVE_NOTICE = 'Custom code is injected when a page is served — it is live on the next request, no publish needed. ' +
7
66
  'It runs unsandboxed on every page it applies to.';
8
67
  export function registerCodeTools(server, ctx) {
9
68
  server.registerTool('sb_code', {
10
69
  description: 'The site\'s custom code files — tracking pixels, analytics, chat widgets, site-wide CSS — ' +
11
70
  'injected at head, body_start or body_end of every page (no page_id) or one page. ' +
71
+ 'Create infers language from the extension, placement from the language. scss/typescript compile ' +
72
+ 'on write (compile_error). json/text: placement "none" only; an enabled site-wide "none" file is served at its url. ' +
12
73
  'action:"list" | "set" (no id creates; with id merges the named fields over the stored row) ' +
13
74
  '| "remove". Not the custom-code element.',
14
75
  inputSchema: {
@@ -17,8 +78,8 @@ export function registerCodeTools(server, ctx) {
17
78
  id: z.string().optional(),
18
79
  page_id: z.string().optional().describe('list: that page\'s files plus site-wide; set: scope to it ("" = site-wide)'),
19
80
  name: z.string().optional(),
20
- language: z.enum(['html', 'css', 'javascript']).optional(),
21
- placement: z.enum(['head', 'body_start', 'body_end']).optional(),
81
+ language: z.enum(LANGUAGES).optional(),
82
+ placement: z.enum(PLACEMENTS).optional(),
22
83
  content: z.string().optional(),
23
84
  enabled: z.boolean().optional(),
24
85
  position: z.number().int().min(0).optional(),
@@ -37,6 +98,11 @@ export function registerCodeTools(server, ctx) {
37
98
  placement: f.placement,
38
99
  enabled: f.enabled,
39
100
  chars: f.content.length,
101
+ ...(f.compileError ? { compile_error: f.compileError } : {}),
102
+ // Served only when enabled, site-wide, `none` — and for scss/ts only once a build succeeded.
103
+ ...(!f.pageId && f.enabled && f.placement === 'none' && (f.compiled || !(f.language === 'scss' || f.language === 'typescript'))
104
+ ? { url: `/_wb/code/${f.name.split('/').map(encodeURIComponent).join('/')}` }
105
+ : {}),
40
106
  });
41
107
  if (action === 'list') {
42
108
  const q = page_id ? `?pageId=${encodeURIComponent(page_id)}&includeSiteWide=true` : '';
@@ -46,14 +112,16 @@ export function registerCodeTools(server, ctx) {
46
112
  if (action === 'remove') {
47
113
  if (!id)
48
114
  throw new Error('sbuilder: action:"remove" needs id — sb_code action:"list" names them.');
49
- const path = `${base}/${encodeURIComponent(id)}`;
50
- const cur = (await call('GET', path)).codeFile;
115
+ const item = `${base}/${encodeURIComponent(id)}`;
116
+ const cur = (await call('GET', item)).codeFile;
51
117
  if (!cur)
52
118
  throw new Error(`sbuilder: no code file "${id}" on this site.`);
119
+ // Guarded by the row just read: a 409 instead of deleting someone else's newer edit.
120
+ const path = cur.updatedAt ? `${item}?expectedUpdatedAt=${encodeURIComponent(cur.updatedAt)}` : item;
53
121
  if (dry_run !== false) {
54
122
  return text({ dry_run: true, would_send: redact({ method: 'DELETE', path }), removes: brief(cur) });
55
123
  }
56
- await call('DELETE', path);
124
+ await guarded(call('DELETE', path));
57
125
  return text({ removed: brief(cur) });
58
126
  }
59
127
  // set
@@ -63,17 +131,20 @@ export function registerCodeTools(server, ctx) {
63
131
  let path;
64
132
  let body;
65
133
  let changes;
134
+ /** The stored row sat at none (served raw, never wrapped) — moving it out must be judged. */
135
+ let wasNone = false;
66
136
  if (!id) {
67
137
  if (!name?.trim() || content === undefined) {
68
- throw new Error('sbuilder: creating a code file needs name and content (language default javascript, placement body_end).');
138
+ throw new Error('sbuilder: creating a code file needs name and content (language from the extension, placement from the language).');
69
139
  }
70
140
  method = 'POST';
71
141
  path = base;
142
+ const lang = language ?? languageFromName(name.trim());
72
143
  body = {
73
144
  pageId: page_id ?? '',
74
145
  name: name.trim(),
75
- language: language ?? 'javascript',
76
- placement: placement ?? 'body_end',
146
+ language: lang,
147
+ placement: placement ?? CODE_DEFAULT_PLACEMENT[lang],
77
148
  content,
78
149
  enabled: enabled ?? true,
79
150
  position: position ?? 0,
@@ -87,6 +158,7 @@ export function registerCodeTools(server, ctx) {
87
158
  const cur = (await call('GET', path)).codeFile;
88
159
  if (!cur)
89
160
  throw new Error(`sbuilder: no code file "${id}" on this site.`);
161
+ wasNone = cur.placement === 'none';
90
162
  changes = {};
91
163
  for (const [k, v] of Object.entries(named)) {
92
164
  const was = k === 'pageId' ? cur.pageId ?? '' : cur[k];
@@ -98,19 +170,34 @@ export function registerCodeTools(server, ctx) {
98
170
  }
99
171
  method = 'PUT';
100
172
  // WHOLE ROW BACK: the PUT replaces wholesale.
101
- const { id: _id, ...rest } = cur;
102
- void _id;
103
- body = { ...rest, ...named };
173
+ // compiled/compileError are the server's build output, never ours to send.
174
+ const { id: _id, compiled: _c, compileError: _e, ...rest } = cur;
175
+ void _id, void _c, void _e;
176
+ // expectedUpdatedAt: the PUT refuses (409) if the row moved since this read.
177
+ body = { ...rest, ...named, ...(cur.updatedAt ? { expectedUpdatedAt: cur.updatedAt } : {}) };
178
+ }
179
+ const lang = body.language;
180
+ // Go LanguageAllowsPlacement: the injector has no wrapper for json/text — a 400 otherwise.
181
+ if ((lang === 'json' || lang === 'text') && body.placement !== 'none') {
182
+ throw new Error(`sbuilder: a ${lang} file is never injected — pass placement:"none" (an enabled site-wide one is served at /_wb/code/<name>).`);
104
183
  }
105
184
  // A <script> pasted into a css file, or markup into javascript, would be wrapped
106
185
  // again and reach the page as text — say so before it is stored. Only when this
107
186
  // call sets content or language: a stored row must stay editable (enable, move).
108
- const lang = body.language;
187
+ const tag = WRAP[lang];
109
188
  // The server trims ASCII whitespace only (codeinject.startsWithTag).
110
189
  const opens = body.content.replace(/^[ \t\r\n\f]+/, '').slice(0, 8).toLowerCase();
111
- if ((content !== undefined || language !== undefined) && lang !== 'html' && opens.startsWith('<') && !opens.startsWith(lang === 'css' ? '<style' : '<script')) {
190
+ const checks = content !== undefined || language !== undefined || (wasNone && body.placement !== 'none');
191
+ // scss/ts: compiled at ANY placement and always wrapped, so no leading markup at all —
192
+ // a .tsx opening <script> compiles to React.createElement("script") and throws on every page.
193
+ if (checks && (lang === 'scss' || lang === 'typescript') && opens.startsWith('<')) {
194
+ throw new Error(`sbuilder: language "${lang}" is compiled and the platform always wraps the output in <${tag}> — ` +
195
+ `write plain ${lang === 'scss' ? 'SCSS' : 'TypeScript'} with no tags, or use language:"html" for a vendor snippet with its own tags.`);
196
+ }
197
+ // css/javascript at placement none are served raw, never wrapped.
198
+ if (checks && body.placement !== 'none' && tag && opens.startsWith('<') && !opens.startsWith(`<${tag}`)) {
112
199
  throw new Error(`sbuilder: this content opens with markup but language is "${lang}", which wraps it in ` +
113
- `<${lang === 'css' ? 'style' : 'script'}> — use language:"html" for a vendor snippet with its own tags.`);
200
+ `<${tag}> — use language:"html" for a vendor snippet with its own tags.`);
114
201
  }
115
202
  if (dry_run !== false) {
116
203
  return text({
@@ -120,10 +207,17 @@ export function registerCodeTools(server, ctx) {
120
207
  ...(ctx.notices.peek('code_live', LIVE_NOTICE) ? { note: LIVE_NOTICE } : {}),
121
208
  });
122
209
  }
123
- const res = (await call(method, path, body));
210
+ const res = (await guarded(call(method, path, body)));
124
211
  const note = ctx.notices.once('code_live', LIVE_NOTICE);
212
+ // A failed build is stored, not refused — so it leads the answer rather than hiding in the row.
213
+ const { compile_error, ...row } = res.codeFile ? brief(res.codeFile) : { compile_error: undefined };
214
+ // The server keeps the previous output only if one existed and the language did not change.
215
+ const kept = res.codeFile?.compiled
216
+ ? 'source stored, the site keeps the previous build'
217
+ : 'source stored, nothing is served or injected until a build succeeds';
125
218
  return text({
126
- [id ? 'updated' : 'created']: res.codeFile ? brief(res.codeFile) : id ?? null,
219
+ ...(compile_error ? { compile_error: `${compile_error} — ${kept}` } : {}),
220
+ [id ? 'updated' : 'created']: res.codeFile ? row : id ?? null,
127
221
  ...(changes ? { changes } : {}),
128
222
  ...(note ? { note } : {}),
129
223
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.102.0",
3
+ "version": "0.103.0",
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",