mosaic-headless 1.38.3 → 1.39.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/README.ja.md CHANGED
@@ -18,7 +18,7 @@
18
18
  <img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120 個の node プロパティ">
19
19
  <img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101 個のスタイルプロパティ">
20
20
  <img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733 件のレスポンシブ検査">
21
- <img src="https://img.shields.io/badge/self--tests-42-blueviolet?style=flat-square" alt="42 項目のセルフテスト">
21
+ <img src="https://img.shields.io/badge/self--tests-43-blueviolet?style=flat-square" alt="43 項目のセルフテスト">
22
22
  </p>
23
23
 
24
24
  <p align="center">
@@ -182,7 +182,7 @@ node type、node プロパティ、スタイルプロパティ、スタイル状
182
182
  | `data/theme-zip-verification.csv` | 22 | Mosaic 自身のテーマ ZIP を往復させて比較 |
183
183
  | `data/conversion-batch.csv` | 19 | あるサイトのすべての Elementor ページを変換・構築・検査 |
184
184
 
185
- - セルフテスト:`python tools/test_mosaic.py`、オフラインの 42 項目(検索、中国語の用語、構築結果の形と拒否ルール、公開されている構築インターフェース、このリポジトリの数値とプライバシー)。
185
+ - セルフテスト:`python tools/test_mosaic.py`、オフラインの 43 項目(検索、中国語の用語、構築結果の形と拒否ルール、公開されている構築インターフェース、このリポジトリの数値とプライバシー)。
186
186
  - evals:Mosaic 1.0.10〜1.0.12 の挙動に関する 16 問。skill ありで 16/16、なしで 0/16。結果:[evals/RESULTS.md](evals/RESULTS.md)。
187
187
  - `SKILL.md`、これらの README、バッジの数値は、`tools/check_numbers.py` がデータと照合しています。詳細:[verification-record.md](references/verification-record.md)。
188
188
 
package/README.ko.md CHANGED
@@ -18,7 +18,7 @@
18
18
  <img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120개 node 속성">
19
19
  <img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101개 스타일 속성">
20
20
  <img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733개 반응형 검사">
21
- <img src="https://img.shields.io/badge/self--tests-42-blueviolet?style=flat-square" alt="42개 자체 테스트">
21
+ <img src="https://img.shields.io/badge/self--tests-43-blueviolet?style=flat-square" alt="43개 자체 테스트">
22
22
  </p>
23
23
 
24
24
  <p align="center">
@@ -182,7 +182,7 @@ node type, node 속성, 스타일 속성, 스타일 상태는 플러그인 소
182
182
  | `data/theme-zip-verification.csv` | 22 | Mosaic 자체 테마 ZIP을 왕복시켜 비교 |
183
183
  | `data/conversion-batch.csv` | 19 | 한 사이트의 모든 Elementor 페이지를 변환, 구축, 검사 |
184
184
 
185
- - 자체 테스트: `python tools/test_mosaic.py`, 오프라인 테스트 42개(조회, 중국어 용어, 구축 결과의 형태와 거부 규칙, 공개된 구축 인터페이스, 이 저장소의 숫자와 개인정보).
185
+ - 자체 테스트: `python tools/test_mosaic.py`, 오프라인 테스트 43개(조회, 중국어 용어, 구축 결과의 형태와 거부 규칙, 공개된 구축 인터페이스, 이 저장소의 숫자와 개인정보).
186
186
  - evals: Mosaic 1.0.10~1.0.12 동작에 관한 16문항. skill 사용 시 16/16, 미사용 시 0/16. 결과: [evals/RESULTS.md](evals/RESULTS.md).
187
187
  - `SKILL.md`, 이 README들, 배지의 숫자는 `tools/check_numbers.py`가 데이터와 대조합니다. 자세한 내용: [verification-record.md](references/verification-record.md).
188
188
 
package/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
  <img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120 node properties">
19
19
  <img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101 style properties">
20
20
  <img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733 responsive checks">
21
- <img src="https://img.shields.io/badge/self--tests-42-blueviolet?style=flat-square" alt="42 self-tests">
21
+ <img src="https://img.shields.io/badge/self--tests-43-blueviolet?style=flat-square" alt="43 self-tests">
22
22
  </p>
23
23
 
24
24
  <p align="center">
@@ -182,7 +182,7 @@ Node types, node properties, style properties and style states are extracted fro
182
182
  | `data/theme-zip-verification.csv` | 22 | Mosaic's own theme ZIP round-tripped and compared |
183
183
  | `data/conversion-batch.csv` | 19 | every Elementor page of a site converted, built and checked |
184
184
 
185
- - Self-test: `python tools/test_mosaic.py`, 42 offline tests (lookups, Chinese terms, the build output's shape and refusals, the public build interface, this repository's numbers and privacy).
185
+ - Self-test: `python tools/test_mosaic.py`, 43 offline tests (lookups, Chinese terms, the build output's shape and refusals, the public build interface, this repository's numbers and privacy).
186
186
  - Evals: 16 questions about Mosaic 1.0.10 to 1.0.12 behaviour; with the skill 16/16, without it 0/16. Results: [evals/RESULTS.md](evals/RESULTS.md).
187
187
  - Every number in `SKILL.md`, these READMEs and their badges is checked against the data by `tools/check_numbers.py`. Detail: [verification-record.md](references/verification-record.md).
188
188
 
package/README.zh-TW.md CHANGED
@@ -18,7 +18,7 @@
18
18
  <img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120 個 node 屬性">
19
19
  <img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101 個樣式屬性">
20
20
  <img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733 條 RWD 檢查">
21
- <img src="https://img.shields.io/badge/self--tests-42-blueviolet?style=flat-square" alt="42 項自我測試">
21
+ <img src="https://img.shields.io/badge/self--tests-43-blueviolet?style=flat-square" alt="43 項自我測試">
22
22
  </p>
23
23
 
24
24
  <p align="center">
@@ -182,7 +182,7 @@ node type、node 屬性、樣式屬性、樣式狀態從外掛原始碼抽出(
182
182
  | `data/theme-zip-verification.csv` | 22 | Mosaic 自己的佈景 ZIP 匯出再匯入並比對 |
183
183
  | `data/conversion-batch.csv` | 19 | 一個網站的每個 Elementor 頁面都轉換、建置並檢查 |
184
184
 
185
- - 自我測試:`python tools/test_mosaic.py`,42 項離線測試(查詢、中文用語、建頁產出的結構與拒收規則、對外的建頁介面、本 repo 的數字與隱私)。
185
+ - 自我測試:`python tools/test_mosaic.py`,43 項離線測試(查詢、中文用語、建頁產出的結構與拒收規則、對外的建頁介面、本 repo 的數字與隱私)。
186
186
  - evals:16 題 Mosaic 1.0.10 到 1.0.12 的行為題;有 skill 16/16,沒有 skill 0/16。結果見 [evals/RESULTS.md](evals/RESULTS.md)。
187
187
  - `SKILL.md`、這幾份 README 和徽章上的數字,都由 `tools/check_numbers.py` 對照資料核對。細節見 [verification-record.md](references/verification-record.md)。
188
188
 
package/SKILL.md CHANGED
@@ -6,7 +6,7 @@ license: "MIT"
6
6
  user-invocable: true
7
7
  metadata:
8
8
  author: "moksa (https://moksaweb.com)"
9
- version: "1.38.3"
9
+ version: "1.39.0"
10
10
  homepage: "https://github.com/Moksa1123/mosaic-headless"
11
11
  ---
12
12
 
@@ -142,6 +142,8 @@ fits, and say in the spec which native path was checked.
142
142
  | **Move a theme** | `theme_zip.py export` / `import` (test mode unless `--activate`), or `theme_export.php` / `theme_import.php`; prune unbound masters first | `theme_zip_compare.php` all PASS |
143
143
  | **Plugin upgrade** | `data_upgrade.py`; re-extract (`extract_*.py`, `check_tables.py`); re-run the verifiers | [upgrading.md](references/upgrading.md) checklist; `scan_inline_tags.py` finds nothing |
144
144
  | **Elementor → Mosaic** | `from_elementor.py --strict`; build; check | `verify_conversion.py` exit 0 |
145
+ | **Rebuild a template** | build and validate the new tree first, replace the old nodes last - never clear first ([standard-fixes.md](references/standard-fixes.md)) | the page never served blank; delivered-page checks pass |
146
+ | **WooCommerce product page** | the lightbox toolbar fix and a sticky column scoped to its own container ([standard-fixes.md](references/standard-fixes.md)) | `verify_lightbox.py` and `verify_sticky.py` exit 0 |
145
147
  | **Old site shows literal tags** (1.0.11+) | `scan_inline_tags.py` (read only) → `fix_inline_tags.py`, dry run then `--apply` | a second scan finds nothing |
146
148
 
147
149
  Before writing anything, read [data-model.md](references/data-model.md) (where a
@@ -177,6 +179,8 @@ Every validator below exits 1 on any FAIL.
177
179
  | interactions, intro, loop | `verify_recipes.py`, `verify_intro.py`, `verify_loop.py` | exit 0 (the intro must END and hand the page back) |
178
180
  | slider, tabs, accordion, forms, map | `verify_slider.py`, `verify_components.py` | exit 0 |
179
181
  | Elementor conversion | `verify_conversion.py` | exit 0: every string, image, link and heading level found |
182
+ | product-image lightbox | `verify_lightbox.py --url <product>` | exit 0: close button flush top-right, counter top-left, spinner out of flow, at four widths |
183
+ | sticky element | `verify_sticky.py --url <page> --sticky <sel> --bound <sel> --avoid <sel> --top <px>` | exit 0: no overlap, stays inside its container, sticks at the offset - measured while scrolling, not read off `position` |
180
184
  | theme move | `wp eval-file tools/theme_zip_compare.php <src> <copy> out.csv` | no FAIL row |
181
185
  | component instances | `wp db query < tools/override_health.sql` (read only) | no instance newly all shells, no duplicate override nodes |
182
186
  | this skill | `python tools/test_mosaic.py` | all pass (offline) |
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.3",
24
+ "version": "1.39.0",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
@@ -24,7 +24,7 @@
24
24
  "user-invocable": true,
25
25
  "metadata": {
26
26
  "author": "moksa (https://moksaweb.com)",
27
- "version": "1.38.3",
27
+ "version": "1.39.0",
28
28
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
29
29
  }
30
30
  },
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.3",
24
+ "version": "1.39.0",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.3",
24
+ "version": "1.39.0",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "metadata": {
23
23
  "author": "moksa (https://moksaweb.com)",
24
- "version": "1.38.3",
24
+ "version": "1.39.0",
25
25
  "homepage": "https://github.com/Moksa1123/mosaic-headless"
26
26
  }
27
27
  },
package/data/pending.csv CHANGED
@@ -10,3 +10,4 @@ date,question,why_not_found,asked_by,status
10
10
  2026-11-17,Demo verifiers and sweeps not yet re-run on Mosaic 1.0.13,"the demo site was upgraded on 2026-11-17 and passed the page health check (90/90, no duplicate roots); the browser verifiers were held back because the shared host was under heavy load",user (Mosaic 1.0.13 release),open
11
11
  2026-11-18,"Demo site: 7 component instances (case-card x3, service-row x4) in two unbound templates have all 70 override nodes emptied to originalID-only shells","not a gap in the data but a known state: written 2026-11-04 18:05 UTC after a component rebuild re-keyed the components; the templates serve no post so no visitor sees it. Left as is (read-only check); prune_unbound.php would remove the templates, or the instances can be re-filled from a spec. Whether to delete the two unbound templates is the user's decision",skill 總機 (em925 override incident follow-up),waiting (user decision)
12
12
  2026-11-18,"Install the front-end write block for wp_mosaic_nodes on the demo site (references/facts.md, empty-root prevention)","a decision, not a gap: the block is measured on another live site; installing it on the shared demo site waits for the user",skill 總機 (em925 empty-root root cause),waiting (user decision)
13
+ 2026-11-21,"Can a child of an accordion item (an icon in the title) be styled through the ___accordion-item--opened state, or only the item itself?","conflicting: a second site (1.0.13) reported the state applies only to the item and needed outside CSS for an icon turn; the 1.0.13 selector template also targets the item's direct children and anything inside .m-accordion-title. This skill's state sweep recorded NO_HOST for it, so neither is measured here. Needs one accordion with a styled title icon, opened in Chromium","skill 總機 (second-site findings 2026-11-21, item 14)",open
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mosaic-headless",
3
- "version": "1.38.3",
3
+ "version": "1.39.0",
4
4
  "description": "AI-agent skill: build Mosaic Pro (Nextend) WordPress sites by writing the underlying data model directly - 23 custom tables, no visual editor, no DOM. Every node type, style property and node property swept against a live install and asserted on the delivered HTML and compiled CSS. Installs into Claude Code, Cursor, Codex CLI, Gemini CLI, Copilot, Continue, Windsurf and Claude.ai.",
5
5
  "keywords": [
6
6
  "wordpress",
@@ -42,6 +42,9 @@ Moved out of SKILL.md on 2026-11-16 (skill SOP pass). `scripts/check-release.mjs
42
42
  without root: where Mosaic looks for the binary, a no-root install, and the two
43
43
  things (PHP-FPM's disabled functions, a setting decided once) that make a working
44
44
  install look broken.
45
+ 17. `references/standard-fixes.md` — problems that kept coming back on real sites and
46
+ the one fix each: the WooCommerce lightbox toolbar, a sticky column riding over the
47
+ page, rebuilding a template without serving a blank page; each with its check.
45
48
 
46
49
  ## The data files
47
50
 
@@ -318,3 +318,59 @@ Platform and rendered-tag facts, each measured. Moved out of SKILL.md on 2026-11
318
318
  the uploads base a second time, serving a broken `src` with no error and no
319
319
  dimensions. A plain `https://` URL also works, and is the right fallback for an
320
320
  image that is not an attachment on this site.
321
+
322
+ ## Measured on a second site (Mosaic 1.0.13 + WooCommerce 11.3, 2026-11-20)
323
+
324
+ A store's Mosaic conversion, measured on its staging copy by that site's own session
325
+ (2026-11-20/21) and handed to this skill. Each line says what was also checked here
326
+ against the 1.0.13 source or this skill's tables; the rest is that site's measurement.
327
+
328
+ - **A WordPress menu nests through local-context loops, one namespace per level.**
329
+ `wp-menu` sub-menus are a loop with `loopType: localContext` and
330
+ `loopSource: @VAR('<parent namespace>/loop')`, and every level needs its own
331
+ `loopNamespace` (`m2`, `m3`, `m4`...). Without one, an inner level reads the outer
332
+ level's values: one menu came out as 4,227 duplicate links and a 6-second page.
333
+ - **A `list` cannot hold a `wp-menu`.** `list` accepts only `list-item` and
334
+ `list-loop-items` (also `data/placement-rules.csv`), and `build_page.py` refuses it.
335
+ Wrap the `wp-menu` in a `div` with `tagName: "ul"`; the output is a proper
336
+ `ul > li`.
337
+ - **`loop-items` arrives as a three-column grid with an 80px / 32px gap**
338
+ (`.m-loop-items{display:grid;grid-template-columns:1fr 1fr 1fr;gap:80px 32px}` in
339
+ the 1.0.13 stylesheet). Set `rowGap` and `columnGap` yourself on every nested loop.
340
+ - **There is no `flex` shorthand key** (only `flexDirection`, `flexWrap`,
341
+ `flexSizing`, `flexBasis`; `build_page.py` refuses `flex`). `display: list-item` was
342
+ refused on that site, and `list-item` renders `display:flex` with no bullet: put
343
+ either in `customDeclarations`.
344
+ - **`modal-window` arrived with 32px of padding** on that site. The 1.0.13 base
345
+ stylesheet gives `.m-modal-window` none, so it comes from the node's default style,
346
+ not from the stylesheet: set `padding*` when the window should be flush.
347
+ - **The accordion does not animate unless told to.** The panel jumps from 0 to full
348
+ height; `data.animation: "slide"` animates it (`accordion`'s `animation` takes
349
+ `none|slide`, `data/node-properties.csv`).
350
+ - **A server condition's `regexp` can exclude pages**: a negative look-ahead such as
351
+ `/^(?!(452|28786)$)/` means "not these post ids" (`regexp` is an operator of the
352
+ `text` comparator, `data/condition-comparators.csv`).
353
+ - **An image can name its thumbnail size**: `{"v": "@attachment(17321, '1536x1536')"}`
354
+ (`attachment` takes two arguments, `data/evaluator-functions.csv`).
355
+ - **No action closes a dropdown.** The close actions are `modalClose` and
356
+ `popoverClose` (and `popoverToggle`), so a phone sub-panel with a "back" button
357
+ cannot be built from dropdowns alone; build it from a modal or a popover.
358
+ - **`dropdown-wrapper-wide` works inside a modal** with `position: fixed` (left 520px,
359
+ top 0, height 100vh), and the pointer moving into the panel does not close it. Two
360
+ traps, both met on that site and fixed there:
361
+ - its default `clip-path: inset(0px -40px -40px -40px)` (in the 1.0.13 stylesheet)
362
+ clips a `position: fixed` panel inside it;
363
+ - in hover mode, leaving uses the convex hull of the toggle and the dropdown box as
364
+ a safe area; a full-height box takes the links above and below into that hull,
365
+ and hovering them does not close the dropdown.
366
+ Fix: shrink the dropdown box to a zero-width anchor and put the panel in a fixed
367
+ child.
368
+ - **An ACF field reads empty where its field group's location rule does not apply**:
369
+ `@VAR('post/meta_x')` is empty on that page even though the post meta has a value.
370
+ Check the group's location rules before suspecting the expression.
371
+ - **Never give a node inside a loop an `attrID`**: every repetition prints the same
372
+ id.
373
+ - **`wp media regenerate` deletes the old thumbnails by default**, so a page that
374
+ hard-codes an old thumbnail URL breaks; pass `--skip-delete`. Files WP-CLI writes
375
+ belong to the user that ran it: reset the owner and permissions afterwards. This is
376
+ WordPress, not Mosaic, and matters because Mosaic pages often carry thumbnail URLs.
@@ -0,0 +1,79 @@
1
+ # Standard fixes and procedures
2
+
3
+ Problems that came back on real Mosaic sites until they were fixed the same way each
4
+ time. Each one names its check; run the check before and after, and report the result,
5
+ not the intent. Measured on a Mosaic 1.0.13 + WooCommerce 11.3 store (2026-11-21):
6
+ every check failed before its fix and passed after.
7
+
8
+ ## The product-image lightbox: close button not in the corner
9
+
10
+ **Symptom.** Zoom a product image on a phone, tablet or small laptop and the close
11
+ button sits 44px in from the top-right corner.
12
+
13
+ **Cause.** WooCommerce's `photoswipe/default-skin.min.css` makes `.pswp__preloader`
14
+ `position: relative` and `float: right` at 1024px and narrower, so the loading spinner
15
+ takes the right-most 44px of the toolbar. It is WooCommerce's CSS, not Mosaic's, so
16
+ every Mosaic + WooCommerce site has it.
17
+
18
+ **Fix** (site CSS, after WooCommerce's):
19
+
20
+ ```css
21
+ .pswp .pswp__top-bar .pswp__preloader{position:absolute;left:50%;top:0;margin-left:-22px;float:none}
22
+ ```
23
+
24
+ **Check.** `python tools/verify_lightbox.py --url <a product page>`: at 390, 820, 1024
25
+ and 1440px the close button is flush with the toolbar's top-right corner, the counter
26
+ with its top-left, and the spinner is out of the flow. Exit 1 on any FAIL.
27
+
28
+ ## A sticky column that rides over the content below
29
+
30
+ **Symptom.** The product summary (or any sticky column) follows the reader down and
31
+ covers the tabs, the description or the related products.
32
+
33
+ **Cause.** `position: sticky` sticks within its parent. When the parent is the whole
34
+ product block, the column's range is the whole page section. `getComputedStyle` says
35
+ `sticky` throughout, so a check that only reads the computed position passes a page
36
+ that is plainly broken.
37
+
38
+ **Fix.** Give the sticky column a parent that holds only what it should travel beside:
39
+ on WooCommerce, wrap the gallery and the summary in their own container (through the
40
+ `woocommerce_before_single_product_summary` / `woocommerce_after_single_product_summary`
41
+ hooks, or a Mosaic `div` around the two), and make that container the sticky range.
42
+
43
+ **Check.** `python tools/verify_sticky.py --url <page> --sticky <column> --bound
44
+ <its container> --avoid <tabs> --avoid <related> --top <offset>`: it scrolls in steps
45
+ and measures rectangles at every step - no intersection with an `--avoid` element,
46
+ never past the bottom of `--bound`, and actually stuck at `--top` while the container
47
+ is on screen. Exit 1 on any FAIL.
48
+
49
+ ## Rebuilding a template: never clear it first
50
+
51
+ **Symptom.** A template is cleared (its children deleted), the rebuild then fails -
52
+ on that site with `style references token '--x' before it is declared in
53
+ theme.variables` - and the page it serves is blank until someone notices (8 minutes
54
+ there).
55
+
56
+ **Procedure.**
57
+
58
+ 1. Convert and validate the whole new tree first. `build_page.py` refuses a bad spec
59
+ before it commits the page's nodes (it has already created a new, empty master by
60
+ then, which `prune_unbound.php` clears later; the old template is untouched). A
61
+ token the spec uses must be declared in its `theme` block or already exist in the
62
+ theme.
63
+ 2. Only after the new tree validates, replace the old nodes - in one commit where the
64
+ tool allows it, otherwise build the new tree first and delete the old one last.
65
+ 3. Check the delivered page (`verify_rwd.py` / `verify_browser.py`, or at least an HTTP
66
+ 200 with Mosaic markup and its expected size).
67
+
68
+ **Tokens from the master.** A template that styles with the master theme's tokens
69
+ needs their ids before it is built: `build_page.theme_records()` loads them into
70
+ `VAR_IDS`. It also writes the theme's collection variables again, so a site with a
71
+ second mode (dark mode) must re-apply that mode's values afterwards
72
+ ([design-system.md](design-system.md), modes), and re-check them with
73
+ `verify_tokens.py`.
74
+
75
+ ## Before deleting a root or rebuilding a component
76
+
77
+ See [facts.md](facts.md), "Changing a component's roots or its node ids empties its
78
+ instances' overrides everywhere else": back up `wp_mosaic_nodes`, export the
79
+ instances' override nodes, change, render, then run `tools/override_health.sql`.
@@ -40,6 +40,8 @@ Every tool in `tools/`, and where the REST session comes from. Moved out of SKIL
40
40
  | `verify_dialog.py` | the modal in a real browser (1.0.9 and 1.0.10 alike: open is read as `:popover-open` or `dialog.open`): does it open, close, answer Esc, remember, cap - and does an OpenStreetMap carry the coordinates it was given |
41
41
  | `verify_popovers.py` | 1.0.10's popover in a real browser: opens, lands where its positioning says, blocks nothing, closes the way closedby says, flips, chains, and ends - every check reads `:popover-open`, never an attribute |
42
42
  | `verify_dialog_lab.py` | the question after "does the modal work": can three nodes be made into a bottom sheet, a side drawer, a corner notice, a full takeover and a gate with no way out - and does each one still fit at phone width, which the page's own width check cannot see |
43
+ | `verify_lightbox.py` | the WooCommerce product-image lightbox (PhotoSwipe) at 390 / 820 / 1024 / 1440px: close button flush with the toolbar's top-right corner, counter top-left, spinner out of the flow - WooCommerce's own skin breaks the first at 1024px and below (references/standard-fixes.md) |
44
+ | `verify_sticky.py` | a sticky element while the page scrolls: rectangle intersection with every `--avoid` element at each step, never past its `--bound` container, actually stuck at `--top` - a computed `position: sticky` passes a column that rides over the whole page |
43
45
  | `verify_tokens.py` | the design tokens as the BROWSER resolved them: every `:root` property declared once (a changed value does not retire the old one), non-empty, and actually pointed at by something - a wrong `skinsData` shape still emits the declaration and serves white |
44
46
  | `verify_components.py` | presses the interactive components on a page and asserts the RESULT - a pane actually swapped, an accordion item actually opened, the map carries the coordinates it was given - because "these all work" is worth what the last press proved |
45
47
  | `audit_mobile.py` | the RWD defects a sideways-scroll check cannot see - type under the legible floor, controls too small to hit, a grid that never collapsed, content escaping a box that is not clipping it - re-opened at every `--widths` |
@@ -0,0 +1,305 @@
1
+ #!/usr/bin/env python3
2
+ """build_directory.py - generate directory-plugin/, the Claude plugin directory edition.
3
+
4
+ Unverified publishers may only ship Markdown, text, JSON, YAML and images in a
5
+ directory plugin, with the skill under skills/<name>/. This script builds that
6
+ folder from the repository's own sources so nothing is maintained twice:
7
+
8
+ data/*.csv, data/browser-verification/*.csv -> data/*.json (split when large)
9
+ references/*.md (not tools.md, maintenance.md) -> references/*.md
10
+ SKILL.md description, references/data-files.md -> SKILL.md (scripts/directory/SKILL.md.tmpl)
11
+ .claude-plugin/plugin.json, icon.png, LICENSE -> the plugin manifest, icon, licence
12
+ scripts/directory/README.md.tmpl -> README.md
13
+
14
+ Scripts, CSV and package files are left out; the edition must not mention server
15
+ logins or credentials, and the build stops if it would. Standard library only.
16
+
17
+ Usage:
18
+ python scripts/build_directory.py # write directory-plugin/
19
+ python scripts/build_directory.py --check # exit 1 if directory-plugin/ is stale
20
+ """
21
+ from __future__ import annotations
22
+
23
+ import argparse
24
+ import csv
25
+ import json
26
+ import re
27
+ import sys
28
+ from pathlib import Path
29
+
30
+ ROOT = Path(__file__).resolve().parent.parent
31
+ OUT = ROOT / "directory-plugin"
32
+ TMPL = ROOT / "scripts" / "directory"
33
+ SKILL_DIR = "skills/mosaic-headless"
34
+ REPO = "https://github.com/Moksa1123/mosaic-headless"
35
+ MOSAIC_VERSION = "1.0.13" # the plugin the source tables were last extracted from (upgrading.md)
36
+ MAX_JSON = 240 * 1024 # the directory holds non-image files over 256 KiB for review
37
+ SKIP_REFERENCES = {"tools.md", "maintenance.md"} # about the scripts this edition does not ship
38
+ ALLOWED_SUFFIXES = {".md", ".json", ".png"}
39
+ UNSAFE = {"COMMIT_500", "COMMIT_502", "BROKE_PAGE"}
40
+
41
+ # What the directory's scanner reads as "sends the installer's credentials somewhere",
42
+ # plus server-login words. None of these may survive the build.
43
+ FORBIDDEN = re.compile(
44
+ r"\bssh\b|\bscp\b|wp-config|\.env\b|id_rsa|id_ed25519|\.pem\b|password|passwd|SSH_KEY"
45
+ r"|process\.env|os\.environ|\$\{?[A-Za-z_]*(?:KEY|SECRET|TOKEN|AUTH|PASSWORD|COOKIE|NONCE)\b"
46
+ r"|MOSAIC_REST_|mint_session|wordpress_logged_in|\bwp_rest\b|X-WP-Nonce|application.password"
47
+ # the demo site's host and hosting ids, built from parts so this file does not carry them
48
+ r"|mosaic\.moksaweb|" + "1469" + "814|" + "6656" + "199|" + r"159\.65\.",
49
+ re.I)
50
+
51
+ REFERENCE_NOTE = (
52
+ "> Directory edition: commands that mention `tools/` need the full edition (`npm` package "
53
+ "`mosaic-headless`); this folder ships reference files only. The `wp` commands run on your "
54
+ "WordPress host; how you reach it is up to you.\n"
55
+ )
56
+ AUTH_REPLACEMENT = (
57
+ "## Authentication\n\n"
58
+ "These are `wp-json` routes that need a logged-in WordPress administrator session on your "
59
+ "own site, which you supply yourself. The full edition explains how to provide one.\n\n"
60
+ )
61
+
62
+
63
+ def sanitize(text: str) -> str:
64
+ """Neutral wording for site names; the author's own site is not an example."""
65
+ text = re.sub(r"https?://(?:www\.)?moksaweb\.com/?", "https://example.com/", text)
66
+ text = text.replace("the em925 site's session", "a live site's maintainer")
67
+ text = re.sub(r"\bmoksaweb\.com\b", "the author's site", text)
68
+ return text
69
+
70
+
71
+ def rewrite_reference(name: str, text: str) -> str:
72
+ text = sanitize(text)
73
+ if name == "write-protocol.md":
74
+ text = re.sub(r"(?ms)^## Authentication\n.*?(?=^## )", AUTH_REPLACEMENT, text)
75
+ if name == "failure-modes.md":
76
+ text = text.replace("Argument #1 ($token)", "Argument #1 (token)")
77
+ if name == "styling.md":
78
+ text = text.replace("(set it yourself in `wp-config.php`)", "(set it yourself in your WordPress configuration)")
79
+ for skipped in SKIP_REFERENCES:
80
+ text = text.replace(f"references/{skipped}", f"{skipped} (full edition)")
81
+ first, _, rest = text.partition("\n")
82
+ return f"{first}\n\n{REFERENCE_NOTE}{rest}"
83
+
84
+
85
+ def csv_rows(path: Path) -> tuple[list[str], list[dict]]:
86
+ with open(path, encoding="utf-8", newline="") as fh:
87
+ reader = csv.DictReader(fh, restkey="_extra")
88
+ rows = list(reader)
89
+ return list(reader.fieldnames or []), rows
90
+
91
+
92
+ def data_sources() -> list[tuple[str, Path]]:
93
+ out = [(p.stem, p) for p in sorted((ROOT / "data").glob("*.csv"))]
94
+ out += [(f"browser-verification-{p.stem}", p)
95
+ for p in sorted((ROOT / "data" / "browser-verification").glob("*.csv"))]
96
+ return out
97
+
98
+
99
+ def to_json(stem: str, path: Path) -> dict[str, str]:
100
+ """One table as one JSON file, or as numbered parts when it would be too large."""
101
+ cols, rows = csv_rows(path)
102
+ rows = [{k: (sanitize(v) if isinstance(v, str) else [sanitize(x) for x in v]) for k, v in r.items()}
103
+ for r in rows]
104
+ src = path.relative_to(ROOT).as_posix()
105
+
106
+ def dump(part_rows, part=None, parts=None):
107
+ doc = {"source_file": src, "columns": cols, "rows": part_rows}
108
+ if part:
109
+ doc["part"] = f"{part} of {parts}"
110
+ return json.dumps(doc, ensure_ascii=False, indent=1) + "\n"
111
+
112
+ whole = dump(rows)
113
+ if len(whole.encode("utf-8")) <= MAX_JSON:
114
+ return {f"{stem}.json": whole}
115
+ n = 2
116
+ while True:
117
+ size = -(-len(rows) // n)
118
+ chunks = [rows[i:i + size] for i in range(0, len(rows), size)]
119
+ texts = [dump(c, i + 1, len(chunks)) for i, c in enumerate(chunks)]
120
+ if all(len(t.encode("utf-8")) <= MAX_JSON for t in texts):
121
+ return {f"{stem}-{i + 1}.json": t for i, t in enumerate(texts)}
122
+ n += 1
123
+
124
+
125
+ def data_descriptions() -> dict[str, str]:
126
+ text = (ROOT / "references" / "data-files.md").read_text(encoding="utf-8")
127
+ out = {}
128
+ for m in re.finditer(r"^\| `data/([^`]+?)(?:\.csv|/)` \| [^|]+ \| (.+?) \|$", text, re.M):
129
+ desc = re.sub(r"\*\*", "", m.group(2)).strip()
130
+ desc = re.split(r"(?<=[a-z)]) - ", desc, maxsplit=1)
131
+ out[m.group(1)] = desc[0] + (" - " + desc[1].split(". ")[0] if len(desc) > 1 else "")
132
+ out.setdefault("terms-zh", "Chinese and colloquial words mapped to Mosaic's English names, with source and trust")
133
+ out.setdefault("pending", "open questions not yet answered by a measurement or a documented source")
134
+ return out
135
+
136
+
137
+ def counts() -> dict[str, str]:
138
+ def n(stem):
139
+ return len(csv_rows(ROOT / "data" / f"{stem}.csv")[1])
140
+ props = csv_rows(ROOT / "data" / "node-properties.csv")[1]
141
+ ver = csv_rows(ROOT / "data" / "node-verification.csv")[1]
142
+ unsafe = sorted(r["type"] for r in ver if r["outcome"] in UNSAFE)
143
+ pkg = json.loads((ROOT / "package.json").read_text(encoding="utf-8"))
144
+ return {
145
+ "PKG_VERSION": pkg["version"],
146
+ "MOSAIC_VERSION": MOSAIC_VERSION,
147
+ "NODE_TYPES": str(n("node-types")),
148
+ "PROP_NAMES": str(len({r["property"] for r in props})),
149
+ "STYLE_PROPS": str(n("style-properties")),
150
+ "STATES": str(n("style-states")),
151
+ "VARIANTS": str(n("variants")),
152
+ "DYNVARS": str(n("dynamic-variables")),
153
+ "TRIGGERS": str(n("interaction-types")),
154
+ "ROUTES": str(n("rest-routes")),
155
+ "UNSAFE_COUNT": str(len(unsafe)),
156
+ "UNSAFE_LIST": ", ".join(f"`{t}`" for t in unsafe) + ".",
157
+ }
158
+
159
+
160
+ def description(values: dict) -> str:
161
+ root = (ROOT / "SKILL.md").read_text(encoding="utf-8")
162
+ zh = re.search(r"中文觸發:(.+)", root).group(1).strip()
163
+ text = (
164
+ f"Look up Mosaic Pro (Nextend) WordPress building blocks from measured data instead of memory: "
165
+ f"{values['NODE_TYPES']} node types with the outcome measured on a live site, {values['PROP_NAMES']} node "
166
+ f"properties, {values['STYLE_PROPS']} style properties and {values['STATES']} style states with the value "
167
+ f"shapes that compile, placement rules, variants, dynamic variables, interaction triggers and REST routes, "
168
+ f"plus guides to the data model and its failure modes. Directory edition: reference data and guides only; "
169
+ f"the page builder and verifiers ship in the full npm package mosaic-headless. Unofficial: not made by or "
170
+ f"affiliated with Nextend. 中文觸發:{zh}"
171
+ )
172
+ return text.replace("\\", "\\\\").replace('"', '\\"')
173
+
174
+
175
+ def fill(template: str, values: dict) -> str:
176
+ out = template
177
+ for k, v in values.items():
178
+ out = out.replace("{{" + k + "}}", v)
179
+ left = re.findall(r"\{\{[A-Z_]+\}\}", out)
180
+ if left:
181
+ raise SystemExit(f"unfilled placeholders: {left}")
182
+ return out
183
+
184
+
185
+ def plugin_json(values: dict) -> str:
186
+ pj = json.loads((ROOT / ".claude-plugin" / "plugin.json").read_text(encoding="utf-8"))
187
+ pj.pop("userConfig", None)
188
+ pj["displayName"] = "Mosaic Headless (unofficial, directory edition)"
189
+ pj["description"] = (
190
+ "Look up Mosaic Pro (Nextend) WordPress building blocks from measured data: node types, properties, "
191
+ "style keys that compile, placement rules and the failure modes behind broken pages. Directory edition: "
192
+ "reference files only, no scripts. Unofficial: not made by or affiliated with Nextend."
193
+ )
194
+ pj["author"] = {"name": "Moksa"}
195
+ pj["homepage"] = f"{REPO}/tree/main/directory-plugin#readme"
196
+ pj["documentationUrl"] = f"{REPO}/tree/main/directory-plugin#readme"
197
+ pj["privacyPolicyUrl"] = f"{REPO}/tree/main/directory-plugin#what-it-runs-and-connects-to"
198
+ pj["skills"] = [f"./{SKILL_DIR}"]
199
+ return json.dumps(pj, ensure_ascii=False, indent=2) + "\n"
200
+
201
+
202
+ def build() -> dict[str, bytes]:
203
+ values = counts()
204
+ desc = data_descriptions()
205
+ files: dict[str, str | bytes] = {}
206
+ data_rows = []
207
+ for stem, path in data_sources():
208
+ parts = to_json(stem, path)
209
+ for rel, text in parts.items():
210
+ files[f"{SKILL_DIR}/data/{rel}"] = text
211
+ key = stem if stem in desc else ("browser-verification" if stem.startswith("browser-verification") else stem)
212
+ names = ", ".join(f"`{r}`" for r in parts)
213
+ what = desc.get(key, "").replace("|", "\\|")
214
+ data_rows.append(f"| {names} | {len(csv_rows(path)[1])} | {what} |")
215
+ values["DATA_FILES"] = "\n".join(data_rows)
216
+ values["DESCRIPTION"] = description(values)
217
+ files[f"{SKILL_DIR}/SKILL.md"] = fill((TMPL / "SKILL.md.tmpl").read_text(encoding="utf-8"), values)
218
+ files["README.md"] = fill((TMPL / "README.md.tmpl").read_text(encoding="utf-8"), values)
219
+ for p in sorted((ROOT / "references").glob("*.md")):
220
+ if p.name not in SKIP_REFERENCES:
221
+ files[f"{SKILL_DIR}/references/{p.name}"] = rewrite_reference(p.name, p.read_text(encoding="utf-8"))
222
+ files["LICENSE"] = re.sub(r" \(https?://(?:www\.)?moksaweb\.com/?\)", "",
223
+ (ROOT / "LICENSE").read_text(encoding="utf-8"))
224
+ files[".claude-plugin/plugin.json"] = plugin_json(values)
225
+ files[".claude-plugin/icon.png"] = (ROOT / ".claude-plugin" / "icon.png").read_bytes()
226
+
227
+ out = {k: v if isinstance(v, bytes) else v.replace("\r\n", "\n").encode("utf-8") for k, v in files.items()}
228
+ problems = []
229
+ for rel, data in out.items():
230
+ suffix = Path(rel).suffix or rel
231
+ if suffix not in ALLOWED_SUFFIXES and rel != "LICENSE":
232
+ problems.append(f"{rel}: file type not allowed in the directory edition")
233
+ if rel.endswith(".png"):
234
+ continue
235
+ if len(data) > 256 * 1024:
236
+ problems.append(f"{rel}: {len(data) // 1024} KiB, over 256 KiB")
237
+ for i, line in enumerate(data.decode("utf-8").splitlines(), 1):
238
+ if FORBIDDEN.search(line):
239
+ problems.append(f"{rel}:{i}: {line.strip()[:100]}")
240
+ if problems:
241
+ raise SystemExit("directory edition would break the directory's rules:\n " + "\n ".join(problems))
242
+ return out
243
+
244
+
245
+ def existing() -> dict[str, bytes]:
246
+ if not OUT.exists():
247
+ return {}
248
+ return {p.relative_to(OUT).as_posix(): p.read_bytes() for p in OUT.rglob("*") if p.is_file()}
249
+
250
+
251
+ def untracked(want: dict[str, bytes]) -> list[str]:
252
+ """Generated files git does not track. The directory reads GitHub, not this disk: a
253
+ file a .gitignore rule swallows is missing there (`mosaic-*/` once hid all of skills/)."""
254
+ import subprocess
255
+ try:
256
+ out = subprocess.run(["git", "ls-files", "-z", "--", "directory-plugin"], cwd=ROOT,
257
+ capture_output=True, text=True, check=True).stdout
258
+ except (OSError, subprocess.CalledProcessError):
259
+ return ["git ls-files failed: cannot tell whether directory-plugin/ is committed"]
260
+ tracked = {p[len("directory-plugin/"):] for p in out.split("\0") if p}
261
+ return [f"not tracked by git (ignored or never added): {k}" for k in sorted(set(want) - tracked)]
262
+
263
+
264
+ def differences(want: dict[str, bytes], have: dict[str, bytes]) -> list[str]:
265
+ # a Windows checkout may turn LF into CRLF; that is not drift
266
+ def same(k):
267
+ a, b = want[k], have[k]
268
+ return a == b or (not k.endswith(".png") and a == b.replace(b"\r\n", b"\n"))
269
+ out = [f"missing: {k}" for k in sorted(set(want) - set(have))]
270
+ out += [f"stale (not built from sources): {k}" for k in sorted(set(have) - set(want))]
271
+ out += [f"out of date: {k}" for k in sorted(set(want) & set(have)) if not same(k)]
272
+ return out
273
+
274
+
275
+ def main() -> int:
276
+ for s in (sys.stdout, sys.stderr):
277
+ if hasattr(s, "reconfigure"):
278
+ s.reconfigure(encoding="utf-8", errors="replace")
279
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[1])
280
+ ap.add_argument("--check", action="store_true", help="only compare; exit 1 if stale")
281
+ args = ap.parse_args()
282
+ want = build()
283
+ diff = differences(want, existing())
284
+ if args.check:
285
+ diff += untracked(want)
286
+ if diff:
287
+ print("directory-plugin/ is out of step with its sources (run scripts/build_directory.py):")
288
+ for d in diff:
289
+ print(" x", d)
290
+ return 1
291
+ print(f"directory-plugin/ matches its sources ({len(want)} files).")
292
+ return 0
293
+ for rel, data in want.items():
294
+ p = OUT / rel
295
+ p.parent.mkdir(parents=True, exist_ok=True)
296
+ p.write_bytes(data)
297
+ stale = [d for d in diff if d.startswith("stale")]
298
+ print(f"wrote {len(want)} files to directory-plugin/")
299
+ for d in stale:
300
+ print(" !", d, "(remove it by hand)")
301
+ return 1 if stale else 0
302
+
303
+
304
+ if __name__ == "__main__":
305
+ raise SystemExit(main())
@@ -0,0 +1,67 @@
1
+ <h1 align="center">Mosaic Headless</h1>
2
+
3
+ <h3 align="center">Mosaic Pro 無編輯器建站工具(官方目錄精簡版)</h3>
4
+
5
+ <p align="center">
6
+ <strong>Measured node types · Style keys that really compile · What goes inside what</strong>
7
+ </p>
8
+
9
+ > This is an unofficial community project. It is not made by, endorsed by, or affiliated with Nextend, the maker of Mosaic Pro. Mosaic Pro is licensed third-party software and is not included here.
10
+
11
+ This is the **directory edition** of [mosaic-headless](https://github.com/Moksa1123/mosaic-headless): the same measured Mosaic data and reference guides, packaged as reference files only so it fits the Claude plugin directory. It contains no scripts.
12
+
13
+ ## What it does
14
+
15
+ | Area | What you get |
16
+ |---|---|
17
+ | Node types | {{NODE_TYPES}} node types, each with the outcome measured when it was committed alone on a live site; {{UNSAFE_COUNT}} are marked unsafe |
18
+ | Properties and styles | {{PROP_NAMES}} node properties, {{STYLE_PROPS}} style properties and {{STATES}} style states, with the value shapes that compile |
19
+ | Placement | what each type accepts as children, and what composite types need inside them |
20
+ | Design system | {{VARIANTS}} variants, {{DYNVARS}} dynamic variables, {{TRIGGERS}} interaction triggers, conditions |
21
+ | Chinese terms | designer wording mapped to Mosaic's names (`內距` → padding) |
22
+ | Guides | data model, write protocol, failure modes, styling, responsive, dialogs, interactions, upgrades |
23
+
24
+ ## When to use
25
+
26
+ | Use it for | Use something else for |
27
+ |---|---|
28
+ | Planning or reviewing Mosaic Pro pages, templates and components; "what is it called / is it safe" | Elementor or block-editor pages |
29
+ | Explaining why a Mosaic page renders wrong | WordPress health checks, plugin updates |
30
+
31
+ ## Install
32
+
33
+ ```
34
+ /plugin install mosaic-headless
35
+ ```
36
+
37
+ The full edition adds the page builder, the delivered-page verifiers and the theme tools:
38
+
39
+ ```bash
40
+ npx mosaic-headless@{{PKG_VERSION}} claude-code --global
41
+ ```
42
+
43
+ ## Quick start
44
+
45
+ - "Can I put an accordion-content directly inside a div in Mosaic?"
46
+ - "Which Mosaic style key sets the border radius, and what value shape does it take?"
47
+ - "Add a popover tour with three steps that advances when each step closes: which nodes and triggers?"
48
+
49
+ ## What it runs and connects to
50
+
51
+ - **Nothing.** This edition contains Markdown, JSON and an icon only: no scripts, no hooks, no MCP servers, no network access.
52
+ - Claude reads the JSON tables and guides in `skills/mosaic-headless/` to answer.
53
+ - It asks for no credentials and reads nothing outside its own folder.
54
+ - No data is sent to the author or anyone else.
55
+
56
+ ## How it's verified
57
+
58
+ The tables come from the Mosaic Pro {{MOSAIC_VERSION}} plugin source and from writing each item to a live install and reading the delivered page back. The full edition's self-test, evals and verification record are in the [source repository](https://github.com/Moksa1123/mosaic-headless). This folder is generated from that repository's files by `scripts/build_directory.py`, which also refuses to build if the output would mention server logins or credentials.
59
+
60
+ ## Limits
61
+
62
+ - Lookups only: committing pages, checking delivered pages and moving themes need the full edition.
63
+ - Features that live only in the Mosaic 1.0.13 editor are not measured yet; open questions are in `data/pending.json`.
64
+
65
+ ## License & author
66
+
67
+ MIT License. Made by Moksa.
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: mosaic-headless
3
+ description: "{{DESCRIPTION}}"
4
+ license: MIT
5
+ version: {{PKG_VERSION}}
6
+ user-invocable: true
7
+ ---
8
+
9
+ # Headless Mosaic (directory edition)
10
+
11
+ Answer questions about Mosaic Pro (Nextend) sites from measured data instead of
12
+ memory: which node types exist and which break a page, what each style key is
13
+ called and whether it compiles, what goes inside what, and how a page is stored.
14
+ This edition ships the measured tables as JSON and the reference guides; it has
15
+ no scripts. The page builder, verifiers and theme tools are in the full npm
16
+ package `mosaic-headless`.
17
+
18
+ **Scope: Mosaic page and template construction.** Not WordPress site health,
19
+ not plugin audits.
20
+
21
+ ## Sources
22
+
23
+ | | |
24
+ |---|---|
25
+ | Surface | Extracted from the Mosaic Pro {{MOSAIC_VERSION}} plugin source, then written to a live install one item at a time and asserted on the delivered HTML and compiled CSS. Detail: [verification-record.md](references/verification-record.md) |
26
+ | Size | {{NODE_TYPES}} node types, {{PROP_NAMES}} node properties, {{STYLE_PROPS}} style properties, {{STATES}} style states, {{VARIANTS}} variants, {{DYNVARS}} dynamic variables, {{TRIGGERS}} interaction triggers, {{ROUTES}} REST routes |
27
+ | Files | `data/*.json`, one per measured table; each has `source_file`, `columns` and `rows`. Large tables are split into `-1`, `-2` ... parts |
28
+ | Trust | `measured` (swept, probed, driven on a live site) > `documented` (plugin source, Mosaic's own zh_TW strings) > `inferred` / `house-style`. Never present the last two as Mosaic's own |
29
+ | Open gaps | `data/pending.json` |
30
+
31
+ ## Usage
32
+
33
+ Use it for building or changing Mosaic pages, templates, components, variants,
34
+ design tokens, popups, menus, sliders, forms and interactions, and for "what is
35
+ it called / what value shape / is it safe / does it render" questions.
36
+
37
+ | Request | Go to |
38
+ |---|---|
39
+ | Elementor pages | `elementor-headless` |
40
+ | Block-editor (Gutenberg) pages | `gutenberg-headless` |
41
+ | Site health checks, plugin updates, security | out of scope - say so |
42
+ | Writing pages to a site, checking a delivered page, moving a theme | the full edition: `npx mosaic-headless@{{PKG_VERSION}} claude-code --global` |
43
+
44
+ ## Routing
45
+
46
+ **Iron rule: look it up first, never answer from memory. Not in the data → say so, mark it 待補 (pending), and do not guess.**
47
+ Mosaic accepts most wrong writes with HTTP 200 and then renders nothing, drops a
48
+ CSS rule, or replaces the whole public page with an error string. Why, with the
49
+ eight failure modes: [core-rules.md](references/core-rules.md).
50
+
51
+ Search the JSON files for the name you need (grep for `"type": "accordion"`,
52
+ `"property": "paddingTop"` ...) and read only the matching rows; do not load the
53
+ large tables whole. Chinese and colloquial words: look them up in
54
+ `data/terms-zh.json` first (`內距` → padding, `懸停` → hover, `摺疊面板` →
55
+ accordion), then search for the English name.
56
+
57
+ | The user asks | Read | What to report |
58
+ |---|---|---|
59
+ | "is this node type safe / what does it render" | `node-verification` (outcome, rendered tag) + `node-type-notes` + `node-types` | the measured outcome first; `RENDERED` or `COMMITTED` is safe, the unsafe ones are listed below |
60
+ | "what goes inside what" | `placement-rules` + `default-children` | the allowed children, and what a composite type needs inside it |
61
+ | "what can I set on this type" | `node-properties` (by `owner_class`, walk `data-class-hierarchy` for inherited ones) + `node-property-verification` | each property's accepted values and whether it was seen to apply |
62
+ | "which key drives this CSS / padding / radius" | `style-verification` (`css_property` → `property`) + `style-properties` + `style-value-shapes` | the Mosaic key, its value shape, whether it compiled; a key with a `group` is inert set alone |
63
+ | "hover / focus / active styles" | `style-states` + `style-state-verification` | the state id and the selector it compiles to |
64
+ | "tablet / phone values", "RWD", "breakpoint" | [responsive.md](references/responsive.md) + `rwd-verification` | `_t` / `_m` keys |
65
+ | "popup", "modal", "popover", "tour" | [dialog-and-triggers.md](references/dialog-and-triggers.md) + `popover-verification`, `dialog-verification` | modal blocks, popover does not; shorthand triggers are only `pageLoad` / `exitIntent` / `scrollDepth` |
66
+ | "animation", "interaction" | `interaction-types` + [interactions.md](references/interactions.md) | trigger ids and the stored value shape |
67
+ | "site colours / fonts", "dark mode", "variant" | `variants` + [design-system.md](references/design-system.md) | variant ids and class names; tokens and modes |
68
+ | "show the post title / a custom field" | `dynamic-variables` + `custom-fields-verification` + [dynamic-content.md](references/dynamic-content.md) | the exact `@VAR()` expression |
69
+ | "show only on some pages" | `condition-subjects` + `condition-comparators` + [templates-and-conditions.md](references/templates-and-conditions.md) | subject ids and operators |
70
+ | "REST route", "database column" | `rest-routes`, `db-columns` | method, path, args; table and column |
71
+ | "why did that happen" | [facts.md](references/facts.md), [failure-modes.md](references/failure-modes.md) | the measured explanation |
72
+ | a word that matches nothing | - | retry in English; still nothing → say it is not in the data |
73
+
74
+ Types measured unsafe to commit ({{UNSAFE_COUNT}}; each kills the request or the
75
+ whole public page when placed the obvious way, most of them only when placed
76
+ without the parent their factory needs - check `placement-rules`):
77
+ {{UNSAFE_LIST}}
78
+
79
+ ## Tasks
80
+
81
+ **Build native, not code.** A `code` node, a `script` action or a pile of
82
+ `customDeclarations` renders and is a dead end: the client cannot edit it. Use
83
+ the native features listed in [core-rules.md](references/core-rules.md) first.
84
+
85
+ | Task | How, with this edition | Done when |
86
+ |---|---|---|
87
+ | Write a page spec | look up every type (safe? allowed under its parent?) and every style key (its shape, `_t` / `_m` for breakpoints); spec format in [building.md](references/building.md) | every type is safe and allowed where it sits, every key is in `style-properties` |
88
+ | Explain a broken page | [failure-modes.md](references/failure-modes.md) and [facts.md](references/facts.md) | the failure mode named, with the measured evidence |
89
+ | Plan a plugin upgrade | [upgrading.md](references/upgrading.md) | the checklist for that version |
90
+ | Commit a spec, verify the delivered page, move a theme, run a data upgrade | the full edition (`npm` package `mosaic-headless`); how you reach your WordPress host is up to you | - |
91
+
92
+ Five facts that cause most broken pages (the rest: [facts.md](references/facts.md)):
93
+
94
+ - A `button`'s words go in a `text` node; only four types take a `url`.
95
+ - A `wysiwyg-text` run prints tags literally since 1.0.11: inline formatting is `wysiwyg-span` / `-link` / `-linebreak`.
96
+ - One root per document, or every instance renders empty. Deleting a root or re-keying a component empties that component's overrides elsewhere.
97
+ - `@media(` in a `code` node is a function call and returns HTTP 500 after a clean commit; write `@media (`.
98
+ - `scrollDepth`'s action slot is `reached` since 1.0.10.
99
+
100
+ ## Verify
101
+
102
+ This edition has no verifier. A page written from its lookups is checked by the
103
+ full edition's verifiers against the page a visitor actually receives
104
+ ([core-rules.md](references/core-rules.md) explains why a successful commit
105
+ proves nothing). Without them, say the page is unverified.
106
+
107
+ ## Data files
108
+
109
+ | File | Rows | What |
110
+ |---|---:|---|
111
+ {{DATA_FILES}}
112
+
113
+ ## Maintenance
114
+
115
+ Generated by `scripts/build_directory.py` in the
116
+ [source repository](https://github.com/Moksa1123/mosaic-headless) from its
117
+ `data/*.csv`, `references/*.md` and `SKILL.md`; never edit this folder by hand.
@@ -398,6 +398,35 @@ class SkillDoc(unittest.TestCase):
398
398
  self.assertTrue(hits, name)
399
399
 
400
400
 
401
+ class DirectoryEdition(unittest.TestCase):
402
+ """directory-plugin/ is generated by scripts/build_directory.py for the Claude plugin
403
+ directory: Markdown, JSON and an icon only, nothing that reads like a server login or
404
+ a credential, and never edited by hand."""
405
+
406
+ def test_in_sync_and_clean(self):
407
+ # no scripts/__pycache__: scripts/ ships in the npm package
408
+ sys.dont_write_bytecode = True
409
+ sys.path.insert(0, os.path.join(ROOT, "scripts"))
410
+ import build_directory as bd
411
+ want = bd.build() # raises on a forbidden word, file type or size
412
+ self.assertEqual(bd.differences(want, bd.existing()), [],
413
+ "run python scripts/build_directory.py")
414
+ # GitHub is what the directory reads: every generated file must be committed
415
+ self.assertEqual(bd.untracked(want), [], "git add directory-plugin (check .gitignore)")
416
+ for rel in want:
417
+ self.assertIn(os.path.splitext(rel)[1] or rel, {".md", ".json", ".png", "LICENSE"}, rel)
418
+ skill = want["skills/mosaic-headless/SKILL.md"].decode("utf-8")
419
+ self.assertRegex(skill, r'(?m)^description: ".+"$')
420
+ self.assertNotIn("userConfig", want[".claude-plugin/plugin.json"].decode("utf-8"))
421
+ # the gate itself: each of these must be caught
422
+ for bad in ("ssh user@host", "cat ~/.ssh/id_rsa", "edit wp-config.php", "export $API_KEY",
423
+ "os.environ['TOKEN']", "Cookie: wordpress_logged_in_x", "X-WP-Nonce: 1",
424
+ "an application password", "https://mosaic." + "moksaweb.com/"):
425
+ self.assertTrue(bd.FORBIDDEN.search(bad), bad)
426
+ for fine in ("setCookie action", "a design token", "the cookie condition"):
427
+ self.assertFalse(bd.FORBIDDEN.search(fine), fine)
428
+
429
+
401
430
  class DataFiles(unittest.TestCase):
402
431
  def test_row_counts_match(self):
403
432
  text = read("references/data-files.md")
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env python3
2
+ """verify_lightbox.py - does the WooCommerce product-image lightbox (PhotoSwipe) toolbar sit right?
3
+
4
+ python tools/verify_lightbox.py --url https://example.com/product/some-product/
5
+ python tools/verify_lightbox.py --url ... --viewports 390x844,1024x768 --shots shots/
6
+
7
+ Opens the product gallery's zoom trigger at each viewport and measures the toolbar:
8
+ the close button flush with the top-right corner of the toolbar, the counter in the
9
+ top-left, and the loading spinner taken out of the flow (position:absolute).
10
+
11
+ Why: WooCommerce's photoswipe/default-skin.min.css makes `.pswp__preloader`
12
+ position:relative + float:right at 1024px and narrower, so it takes the right-most
13
+ 44px of the toolbar and pushes the close button inwards - the "close button not in the
14
+ corner" report that keeps coming back. Measured on a Mosaic 1.0.13 + WooCommerce 11.3
15
+ site, failing before and passing after the standard fix (references/standard-fixes.md):
16
+
17
+ .pswp .pswp__top-bar .pswp__preloader{position:absolute;left:50%;top:0;margin-left:-22px;float:none}
18
+
19
+ A computed `position` alone is not the check: the rectangles are.
20
+
21
+ Exit 1 on any FAIL. Needs playwright (`pip install playwright && playwright install chromium`).
22
+ """
23
+ from __future__ import annotations
24
+
25
+ import argparse
26
+ import os
27
+ import random
28
+ import sys
29
+
30
+ MEASURE = """()=>{
31
+ const R=s=>{const e=document.querySelector(s);if(!e)return null;const r=e.getBoundingClientRect();
32
+ return [r.left,r.top,r.right,r.bottom].map(Math.round)};
33
+ const pre=document.querySelector('.pswp__preloader');
34
+ return {close:R('.pswp__button--close'), counter:R('.pswp__counter'), bar:R('.pswp__top-bar'),
35
+ prePos: pre ? getComputedStyle(pre).position : null};
36
+ }"""
37
+
38
+
39
+ def viewports(spec: str) -> list[tuple[int, int]]:
40
+ out = []
41
+ for part in spec.split(","):
42
+ w, h = part.lower().split("x")
43
+ out.append((int(w), int(h)))
44
+ return out
45
+
46
+
47
+ def main() -> int:
48
+ for s in (sys.stdout, sys.stderr):
49
+ if hasattr(s, "reconfigure"):
50
+ s.reconfigure(encoding="utf-8", errors="replace")
51
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[1])
52
+ ap.add_argument("--url", required=True, help="a product page with a gallery")
53
+ ap.add_argument("--trigger", default=".woocommerce-product-gallery__trigger",
54
+ help="selector that opens the lightbox")
55
+ ap.add_argument("--viewports", default="390x844,820x1180,1024x768,1440x900")
56
+ ap.add_argument("--tolerance", type=int, default=1, help="px allowed off the corner")
57
+ ap.add_argument("--shots", help="folder for one screenshot per viewport")
58
+ a = ap.parse_args()
59
+ try:
60
+ from playwright.sync_api import sync_playwright
61
+ except ImportError:
62
+ sys.exit("pip install playwright && playwright install chromium")
63
+
64
+ sep = "&" if "?" in a.url else "?"
65
+ url = "%s%scb=%d" % (a.url, sep, random.randint(1, 999999)) # past the page cache
66
+ rows = []
67
+ with sync_playwright() as p:
68
+ browser = p.chromium.launch()
69
+ for vw, vh in viewports(a.viewports):
70
+ page = browser.new_page(viewport={"width": vw, "height": vh})
71
+ page.goto(url, wait_until="networkidle", timeout=90000)
72
+ page.wait_for_timeout(1000)
73
+ if not page.query_selector(a.trigger):
74
+ rows.append(("%d: lightbox trigger present" % vw, False, a.trigger + " not found"))
75
+ page.close()
76
+ continue
77
+ page.click(a.trigger)
78
+ try:
79
+ page.wait_for_selector(".pswp--open", timeout=10000)
80
+ except Exception:
81
+ rows.append(("%d: lightbox opens" % vw, False, ".pswp--open never appeared"))
82
+ page.close()
83
+ continue
84
+ page.wait_for_timeout(800)
85
+ m = page.evaluate(MEASURE)
86
+ c, bar, cnt, t = m["close"], m["bar"], m["counter"], a.tolerance
87
+ rows.append(("%d: close button in the top-right corner" % vw,
88
+ bool(c and bar and abs(c[2] - bar[2]) <= t and abs(c[1] - bar[1]) <= t),
89
+ "close %s toolbar %s" % (c, bar)))
90
+ rows.append(("%d: counter in the top-left corner" % vw,
91
+ bool(cnt and bar and abs(cnt[0] - bar[0]) <= t and abs(cnt[1] - bar[1]) <= t),
92
+ "counter %s" % (cnt,)))
93
+ rows.append(("%d: spinner out of the toolbar's flow" % vw,
94
+ m["prePos"] in (None, "absolute", "fixed"), "position %s" % m["prePos"]))
95
+ if a.shots:
96
+ os.makedirs(a.shots, exist_ok=True)
97
+ page.screenshot(path=os.path.join(a.shots, "lightbox-%d.png" % vw))
98
+ page.close()
99
+ browser.close()
100
+
101
+ bad = 0
102
+ for name, ok, note in rows:
103
+ print("%-4s %s %s" % ("PASS" if ok else "FAIL", name, note))
104
+ bad += 0 if ok else 1
105
+ print("\n%d checks, %d FAIL" % (len(rows), bad))
106
+ return 1 if bad else 0
107
+
108
+
109
+ if __name__ == "__main__":
110
+ sys.exit(main())
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env python3
2
+ """verify_sticky.py - does a sticky element stick, and stay where it belongs, while the page scrolls?
3
+
4
+ python tools/verify_sticky.py --url https://example.com/product/x/ \\
5
+ --sticky ".summary" --bound ".gallery-and-summary" \\
6
+ --avoid ".woocommerce-tabs" --avoid ".related.products" --top 32
7
+
8
+ Scrolls the page in steps (default 150px) from the top to the end of the last
9
+ `--avoid` element (or the page end) and measures every step:
10
+
11
+ OVERLAP the sticky element's rectangle intersects no `--avoid` element (area 0)
12
+ BOUND the sticky element's bottom never passes the bottom of `--bound`
13
+ STICKS while `--bound` is still on screen and taller than the sticky element,
14
+ the element sits at `--top` px (+/- 2) - i.e. sticky actually works
15
+
16
+ Why: a computed `position: sticky` says nothing about WHERE it sticks. Its range is
17
+ its parent: when the parent is the whole product block, a right column keeps
18
+ following the reader down over the tabs and the related products while
19
+ `getComputedStyle` reports sticky the whole way. Measured on a Mosaic 1.0.13 +
20
+ WooCommerce site, failing before and passing after the standard fix
21
+ (references/standard-fixes.md): wrap only the gallery and the summary in their own
22
+ container, so that container is the sticky range.
23
+
24
+ Exit 1 on any FAIL. Needs playwright (`pip install playwright && playwright install chromium`).
25
+ """
26
+ from __future__ import annotations
27
+
28
+ import argparse
29
+ import json
30
+ import random
31
+ import sys
32
+
33
+ MEASURE = """(sel)=>{
34
+ const R=s=>{const e=document.querySelector(s);if(!e)return null;const r=e.getBoundingClientRect();
35
+ return {t:r.top,b:r.bottom,l:r.left,r:r.right}};
36
+ const st=document.querySelector(sel.sticky);
37
+ return {y:scrollY, max:document.documentElement.scrollHeight-innerHeight,
38
+ sticky:R(sel.sticky), bound:sel.bound?R(sel.bound):null,
39
+ avoid:sel.avoid.map(R), pos: st ? getComputedStyle(st).position : null};
40
+ }"""
41
+
42
+
43
+ def overlap(a, b) -> float:
44
+ if not a or not b:
45
+ return 0
46
+ w = min(a["r"], b["r"]) - max(a["l"], b["l"])
47
+ h = min(a["b"], b["b"]) - max(a["t"], b["t"])
48
+ return max(0, w) * max(0, h)
49
+
50
+
51
+ def main() -> int:
52
+ for s in (sys.stdout, sys.stderr):
53
+ if hasattr(s, "reconfigure"):
54
+ s.reconfigure(encoding="utf-8", errors="replace")
55
+ ap = argparse.ArgumentParser(description=__doc__.split("\n")[1])
56
+ ap.add_argument("--url", required=True, action="append", help="page to check (repeatable)")
57
+ ap.add_argument("--sticky", required=True, help="selector of the sticky element")
58
+ ap.add_argument("--bound", help="selector of the block it must stay inside (its intended range)")
59
+ ap.add_argument("--avoid", action="append", default=[], help="selector it must never cover (repeatable)")
60
+ ap.add_argument("--top", type=float, help="expected top offset while stuck, e.g. 32")
61
+ ap.add_argument("--viewport", default="1440x900")
62
+ ap.add_argument("--step", type=int, default=150)
63
+ a = ap.parse_args()
64
+ try:
65
+ from playwright.sync_api import sync_playwright
66
+ except ImportError:
67
+ sys.exit("pip install playwright && playwright install chromium")
68
+
69
+ vw, vh = (int(x) for x in a.viewport.lower().split("x"))
70
+ sel = {"sticky": a.sticky, "bound": a.bound, "avoid": a.avoid}
71
+ rows = []
72
+ with sync_playwright() as p:
73
+ browser = p.chromium.launch()
74
+ for url in a.url:
75
+ page = browser.new_page(viewport={"width": vw, "height": vh})
76
+ sep = "&" if "?" in url else "?"
77
+ page.goto("%s%scb=%d" % (url, sep, random.randint(1, 999999)), wait_until="networkidle", timeout=90000)
78
+ page.wait_for_timeout(1200)
79
+ m0 = page.evaluate(MEASURE, sel)
80
+ if not m0["sticky"]:
81
+ rows.append((url + ": sticky element present", False, a.sticky + " not found"))
82
+ page.close()
83
+ continue
84
+ if a.bound:
85
+ rows.append((url + ": bound present", m0["bound"] is not None, a.bound))
86
+ ends = [r["b"] + m0["y"] for r in m0["avoid"] if r]
87
+ stop = min(max(ends) if ends else m0["max"], m0["max"])
88
+ hits, past, stuck, y = [], [], [], 0
89
+ while y <= stop:
90
+ page.evaluate("y=>window.scrollTo(0,y)", y)
91
+ page.wait_for_timeout(120)
92
+ m = page.evaluate(MEASURE, sel)
93
+ for name, box in zip(a.avoid, m["avoid"]):
94
+ area = overlap(m["sticky"], box)
95
+ if area > 0:
96
+ hits.append("y=%d covers %s (%dpx2)" % (m["y"], name, area))
97
+ bound = m["bound"]
98
+ if bound and m["sticky"]["b"] > bound["b"] + 1:
99
+ past.append("y=%d bottom %d > bound bottom %d" % (m["y"], m["sticky"]["b"], bound["b"]))
100
+ height = m["sticky"]["b"] - m["sticky"]["t"]
101
+ if a.top is not None and bound and m["y"] > 0 and bound["b"] > height + (a.top or 0) + 120 \
102
+ and m0["sticky"]["t"] + 0 < m["y"] + (a.top or 0):
103
+ stuck.append(round(m["sticky"]["t"]))
104
+ y += a.step
105
+ if a.avoid:
106
+ rows.append((url + ": OVERLAP none", not hits, "; ".join(hits[:4])))
107
+ if a.bound:
108
+ rows.append((url + ": BOUND stays inside " + a.bound, not past, "; ".join(past[:3])))
109
+ if a.top is not None and a.bound:
110
+ rows.append((url + ": STICKS at top %g" % a.top,
111
+ bool(stuck) and all(abs(t - a.top) <= 2 for t in stuck),
112
+ "measured tops %s (computed position %s)" % (json.dumps(stuck[:8]), m0["pos"])))
113
+ page.close()
114
+ browser.close()
115
+
116
+ bad = 0
117
+ for name, ok, note in rows:
118
+ print("%-4s %s %s" % ("PASS" if ok else "FAIL", name, note))
119
+ bad += 0 if ok else 1
120
+ print("\n%d checks, %d FAIL" % (len(rows), bad))
121
+ return 1 if bad else 0
122
+
123
+
124
+ if __name__ == "__main__":
125
+ sys.exit(main())