mosaic-headless 1.33.2 → 1.33.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -301,6 +301,7 @@ and heading level — and it earned its place at once: it caught the converter l
301
301
  | `verify_rwd.py` | does every `_t`/`_m` declaration reach the served stylesheet |
302
302
  | `verify_intro.py` / `verify_loop.py` | a page-load sequence that ENDS; a perpetual one that loops, hides nothing, and opens |
303
303
  | `theme_export.php` / `theme_import.php` | a whole theme as JSON rows over WP-CLI, ids intact |
304
+ | `prune_unbound.php` | clears the templates and masters that page rebuilds leave bound to nothing, with their nodes; dry run unless `--apply` |
304
305
  | `theme_zip.py` / `theme_zip_compare.php` / `theme_delete.php` | Mosaic's own ZIP export/import from outside the editor, the copy held against the source, and a clean delete that refuses the live theme |
305
306
  | `list_fields.php` | every `@VAR` / `@LOOP` name a post's custom fields register, with values |
306
307
  | `verify_dialog.py` | the 1.0.9 modal, triggers, run rules and memory, driven in a browser |
package/SKILL.md CHANGED
@@ -5,7 +5,7 @@ description: |
5
5
  license: "MIT"
6
6
  metadata:
7
7
  author: "moksa (https://moksaweb.com)"
8
- version: "1.33.2"
8
+ version: "1.33.4"
9
9
  homepage: "https://github.com/Moksa1123/mosaic-headless"
10
10
  ---
11
11
 
@@ -675,7 +675,9 @@ python tools/build_all.py --config sweep.json # reset + build every design
675
675
  ```
676
676
 
677
677
  Rebuilding a single page without a reset leaves an orphan template bound to the same
678
- post — `build_all.py` resets first for that reason.
678
+ post — `build_all.py` resets first for that reason. `build_site.py` re-binds the post
679
+ to a fresh master and template and leaves the old pair bound to nothing; clear them
680
+ with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
679
681
 
680
682
  ## Facts worth knowing before you look anything up
681
683
 
@@ -701,7 +703,10 @@ post — `build_all.py` resets first for that reason.
701
703
  with them (`m-accordion-item--opened`, `m-menu-link--current`, `m-tab--active`).
702
704
  Any CSS you write against an emitted class is coupled to the plugin version.
703
705
  - **`body{opacity:0}`** — the theme reveals itself from JavaScript. Screenshot tooling
704
- must let scripts run or it captures a blank page.
706
+ must let scripts run or it captures a blank page. The reveal waits for
707
+ `DOMContentLoaded`, i.e. for every `defer` script, so deferring scripts blanks the
708
+ page longer; `html body{opacity:1!important}` is safe and was worth 72 → 86 mobile
709
+ (`references/styling.md`).
705
710
  - **Two themes can carry the same name, and only the ACTIVE one is bound to
706
711
  anything.** Every write to `theme/<themeID>/...` succeeds against an inactive
707
712
  theme - master, nodes, components, tokens, all of it - and then
@@ -736,7 +741,7 @@ post — `build_all.py` resets first for that reason.
736
741
  in templates when nginx closed the upstream at five minutes. Pruned to the bound
737
742
  set (masters not reached from a bound template, their templates, their nodes)
738
743
  the same import took under two minutes and compared 22 of 22. Prune before you
739
- export; `wp_mosaic_template_assigns.parentID` -> template -> `masterID` is the
744
+ export - `wp eval-file tools/prune_unbound.php <themeID>` counts, `--apply` deletes; `wp_mosaic_template_assigns.parentID` -> template -> `masterID` is the
740
745
  bound set, plus any `assign="auto"` template. Then sweep ORPHANS: a probe run
741
746
  that half-failed, or a prune that removed a parent, leaves nodes whose parent id
742
747
  points at nothing. The export skips them, so the copy is short by exactly those
@@ -895,6 +900,7 @@ post — `build_all.py` resets first for that reason.
895
900
  | `theme_export.php` / `theme_import.php` | move a whole theme across installs, ids intact |
896
901
  | `theme_zip.py` | drive Mosaic's OWN export/import - the ZIP the editor makes, attachments included, over the milestone protocol; import lands in test mode unless told `--activate` |
897
902
  | `theme_zip_compare.php` | hold an imported copy against its source, tree for tree - every scoped table, the (parentType, type) shape, which ids survive, and orphans named rather than counted |
903
+ | `prune_unbound.php` | delete the templates no post is bound to, the masters no kept template uses, their nodes, then orphan nodes pass after pass - one theme, dry run unless `--apply`, `assign="auto"` templates kept |
898
904
  | `theme_delete.php` | remove a theme completely through the plugin's own routine; refuses the live one |
899
905
  | `verify_slider.py` | the slider in a real browser: does it advance, do the arrows and bullets drive it, does the keyboard, does it stop when motion is not wanted - `--label`/`--append` put several sliders in one table, which is where a carousel and a plain slider can be held against each other |
900
906
  | `verify_navigation.py` | a multi-page site: is every menu item a real `<a href>`, does every page answer 200 (a template that was never bound answers 406 with an empty body, which only a logged-out visitor sees), and with `--viewports` does any page scroll SIDEWAYS - the one question no per-page checker asks - and whether every in-page `#fragment` resolves ON THE PAGE THAT CARRIES IT, which an HTTP check cannot see: a bare `#services` in a SHARED header fetches the current page, answers 200 everywhere, and does nothing on every page but the one that has that section |
@@ -20,7 +20,7 @@
20
20
  "description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
21
21
  "license": "MIT",
22
22
  "author": "moksa (https://moksaweb.com)",
23
- "version": "1.33.2"
23
+ "version": "1.33.4"
24
24
  },
25
25
  "loaderBehaviour": "Upload via Settings -> Skills -> Upload. Claude.ai parses SKILL.md frontmatter and surfaces the skill in your library. The extraction tool (extract-block-schema.php) needs a live WP-CLI connection and won't run in the sandbox; use it from a local terminal against your own site instead.",
26
26
  "uploadSteps": [
@@ -20,7 +20,7 @@
20
20
  "description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
21
21
  "license": "MIT",
22
22
  "author": "moksa (https://moksaweb.com)",
23
- "version": "1.33.2"
23
+ "version": "1.33.4"
24
24
  },
25
25
  "loaderBehaviour": "Auto-loads on session start when SKILL.md frontmatter parses successfully.",
26
26
  "verified": true,
@@ -20,7 +20,7 @@
20
20
  "description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
21
21
  "license": "MIT",
22
22
  "author": "moksa (https://moksaweb.com)",
23
- "version": "1.33.2"
23
+ "version": "1.33.4"
24
24
  },
25
25
  "loaderBehaviour": "Confirmed (2026-07-11): Codex CLI natively supports the SKILL.md spec. Place SKILL.md under .codex/skills/<name>/ (project) or ~/.codex/skills/<name>/ (personal) and Codex loads the name+description at session start, then the full body on demand. A parallel, broader convention .agents/skills/ (searched from cwd up to repo root, then ~/.agents/skills/) also exists across multiple tools - if your Codex CLI version prioritizes that path instead, mirror the same SKILL.md there.",
26
26
  "verified": true,
@@ -20,7 +20,7 @@
20
20
  "description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
21
21
  "license": "MIT",
22
22
  "author": "moksa (https://moksaweb.com)",
23
- "version": "1.33.2"
23
+ "version": "1.33.4"
24
24
  },
25
25
  "loaderBehaviour": "CHANGED as of 2026-07-11: GitHub Copilot added a proper '.github/skills/' Agent Skills directory (December 2025), alongside the older single-file .github/copilot-instructions.md convention. This config targets the new skills-directory form. If your Copilot version predates this (pre Dec 2025), use the instructions-append fallback instead (see fallback below).",
26
26
  "fallback": {
@@ -20,7 +20,7 @@
20
20
  "description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
21
21
  "license": "MIT",
22
22
  "author": "moksa (https://moksaweb.com)",
23
- "version": "1.33.2"
23
+ "version": "1.33.4"
24
24
  },
25
25
  "loaderBehaviour": "CHANGED as of 2026-07-11: Gemini CLI now natively supports the same SKILL.md standard as Claude Code and Codex CLI - the same directory-based skill works unmodified. Gemini CLI discovers skills in this precedence order: built-in, extension skills, ~/.gemini/skills/ (personal), .gemini/skills/ (project, shared via version control). At session start Gemini injects each discovered skill's name+description into the system prompt and calls activate_skill when a task matches.",
26
26
  "verified": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mosaic-headless",
3
- "version": "1.33.2",
3
+ "version": "1.33.4",
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",
@@ -102,6 +102,22 @@ Also note `body{opacity:0}` in the base block — the theme reveals itself from
102
102
  JavaScript. A page fetched without running scripts is fully styled but invisible;
103
103
  screenshot tooling must let the JS run before capturing.
104
104
 
105
+ The reveal is an inline script in `Builder/Header.php`: on `DOMContentLoaded`, one
106
+ `requestAnimationFrame` later, `body.style.opacity = "1"`. `DOMContentLoaded` waits for
107
+ every `defer` script, so deferring jQuery or Mosaic's own frontend - the usual
108
+ render-blocking fix - keeps the whole page blank until they have run. On a slow phone
109
+ that is the FCP and LCP. Overriding it is safe: the stylesheet is in the document
110
+ before the body, so nothing paints unstyled.
111
+
112
+ ```css
113
+ html body { opacity: 1 !important; }
114
+ ```
115
+
116
+ Measured on a migrated clinic site, Lighthouse 13.5 mobile, median of 3, same day:
117
+ performance 72 → 86, LCP 4.8 s → 3.2 s, CLS still 0, and a frame-by-frame check found
118
+ no unstyled frame. TBT rose (42 → 154 ms) only because the scripts now run inside the
119
+ measured window.
120
+
105
121
  ## Setting values
106
122
 
107
123
  The `factory` column in `data/style-properties.csv` tells you the value shape:
@@ -0,0 +1,116 @@
1
+ <?php
2
+ /**
3
+ * Remove the templates and masters no post is bound to, and the nodes under them.
4
+ *
5
+ * wp eval-file prune_unbound.php <themeID> # dry run: counts only
6
+ * wp eval-file prune_unbound.php <themeID> --apply # delete
7
+ *
8
+ * Every build_site.py / build_page.py run makes a fresh master and template and
9
+ * re-binds the post to them; the previous pair stays behind, bound to nothing.
10
+ * On the test theme that grew to 1,028 templates and 440k nodes with 75 templates
11
+ * actually in use, and Mosaic's own ZIP export of a theme that size dies at the
12
+ * nginx timeout. There is no REST route that deletes a template, so this is SQL.
13
+ *
14
+ * What is KEPT, in one theme only:
15
+ * - every template a row of wp_mosaic_template_assigns points at
16
+ * - every template with assign="auto" (fallbacks, condition-matched templates,
17
+ * the sweep's own Sweep Home) - they are bound by conditions, not assigns
18
+ * - every master a kept template uses
19
+ * Everything else of type template / master goes, with its nodes. Then nodes whose
20
+ * parent node no longer exists are removed pass after pass until none are left,
21
+ * because each pass orphans the next level down.
22
+ *
23
+ * Back up first - this has no undo:
24
+ * wp db export pre-prune.sql --tables=$(wp db tables "wp_mosaic_*" --all-tables --format=csv)
25
+ * (`wp db tables` without --all-tables finds no wp_mosaic_* tables: they are not
26
+ * registered with $wpdb.) Purge the page cache afterwards and fetch every bound page.
27
+ */
28
+ $args = isset($args) ? $args : [];
29
+ $id = isset($args[0]) ? trim($args[0]) : '';
30
+ $apply = in_array('--apply', $args, true);
31
+
32
+ if (!preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $id)) {
33
+ WP_CLI::error('usage: wp eval-file prune_unbound.php <themeID> [--apply]');
34
+ }
35
+
36
+ global $wpdb;
37
+ $p = $wpdb->prefix;
38
+ if (!$wpdb->get_var($wpdb->prepare("SELECT ID FROM {$p}mosaic_themes WHERE ID = %s", $id))) {
39
+ WP_CLI::error("no theme $id");
40
+ }
41
+
42
+ $unboundTemplates = $wpdb->get_col($wpdb->prepare(
43
+ "SELECT t.ID FROM {$p}mosaic_templates t
44
+ WHERE t.themeID = %s AND t.assign <> 'auto'
45
+ AND t.ID NOT IN (SELECT parentID FROM {$p}mosaic_template_assigns WHERE parentType = 'template')",
46
+ $id));
47
+ $unusedMasters = $wpdb->get_col($wpdb->prepare(
48
+ "SELECT m.ID FROM {$p}mosaic_masters m
49
+ WHERE m.themeID = %s
50
+ AND m.ID NOT IN (SELECT masterID FROM {$p}mosaic_templates
51
+ WHERE themeID = %s AND (assign = 'auto'
52
+ OR ID IN (SELECT parentID FROM {$p}mosaic_template_assigns WHERE parentType = 'template')))",
53
+ $id, $id));
54
+
55
+ $count = function ($type, $ids) use ($wpdb, $p, $id) {
56
+ $n = 0;
57
+ foreach (array_chunk($ids, 500) as $chunk) {
58
+ $in = implode(',', array_fill(0, count($chunk), '%s'));
59
+ $n += (int)$wpdb->get_var($wpdb->prepare(
60
+ "SELECT COUNT(*) FROM {$p}mosaic_nodes WHERE themeID = %s AND documentType = %s AND documentID IN ($in)",
61
+ array_merge([$id, $type], $chunk)));
62
+ }
63
+ return $n;
64
+ };
65
+
66
+ $kept = (int)$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$p}mosaic_templates WHERE themeID = %s", $id))
67
+ - count($unboundTemplates);
68
+ WP_CLI::log(sprintf('templates: %d unbound, %d kept', count($unboundTemplates), $kept));
69
+ WP_CLI::log(sprintf('masters: %d unused', count($unusedMasters)));
70
+ WP_CLI::log(sprintf('nodes: %d under those templates, %d under those masters',
71
+ $count('template', $unboundTemplates), $count('master', $unusedMasters)));
72
+
73
+ if (!$apply) {
74
+ $orphans = (int)$wpdb->get_var($wpdb->prepare(
75
+ "SELECT COUNT(*) FROM {$p}mosaic_nodes n LEFT JOIN {$p}mosaic_nodes q ON q.ID = n.parentID
76
+ WHERE n.themeID = %s AND n.parentType = 'node' AND q.ID IS NULL", $id));
77
+ WP_CLI::log("orphan nodes already present: $orphans");
78
+ WP_CLI::success('dry run - nothing deleted. Back up, then re-run with --apply');
79
+ return;
80
+ }
81
+
82
+ $delete = function ($table, $type, $ids) use ($wpdb, $p, $id) {
83
+ $nodes = $rows = 0;
84
+ foreach (array_chunk($ids, 500) as $chunk) {
85
+ $in = implode(',', array_fill(0, count($chunk), '%s'));
86
+ $nodes += (int)$wpdb->query($wpdb->prepare(
87
+ "DELETE FROM {$p}mosaic_nodes WHERE themeID = %s AND documentType = %s AND documentID IN ($in)",
88
+ array_merge([$id, $type], $chunk)));
89
+ $rows += (int)$wpdb->query($wpdb->prepare(
90
+ "DELETE FROM {$p}mosaic_{$table} WHERE themeID = %s AND ID IN ($in)",
91
+ array_merge([$id], $chunk)));
92
+ }
93
+ return [$rows, $nodes];
94
+ };
95
+
96
+ // nodes first, so a failure part-way never leaves a document row with half its tree
97
+ [$t, $tn] = $delete('templates', 'template', $unboundTemplates);
98
+ [$m, $mn] = $delete('masters', 'master', $unusedMasters);
99
+
100
+ $orphans = 0;
101
+ do {
102
+ // MariaDB cannot DELETE from a table it is also reading in a subquery; a JOIN it can
103
+ $n = (int)$wpdb->query($wpdb->prepare(
104
+ "DELETE n FROM {$p}mosaic_nodes n LEFT JOIN {$p}mosaic_nodes q ON q.ID = n.parentID
105
+ WHERE n.themeID = %s AND n.parentType = 'node' AND q.ID IS NULL", $id));
106
+ $orphans += $n;
107
+ } while ($n > 0);
108
+
109
+ $dangling = (int)$wpdb->get_var($wpdb->prepare(
110
+ "SELECT COUNT(*) FROM {$p}mosaic_templates t LEFT JOIN {$p}mosaic_masters m ON m.ID = t.masterID
111
+ WHERE t.themeID = %s AND m.ID IS NULL", $id));
112
+ WP_CLI::log("deleted: $t templates ($tn nodes), $m masters ($mn nodes), $orphans orphan nodes");
113
+ if ($dangling) {
114
+ WP_CLI::error("$dangling kept templates point at a master that is gone - restore the backup");
115
+ }
116
+ WP_CLI::success('pruned. Purge the page cache and fetch every bound page');