mosaic-headless 1.34.3 → 1.34.5

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
@@ -304,6 +304,7 @@ and heading level — and it earned its place at once: it caught the converter l
304
304
  | `prune_unbound.php` | clears the templates and masters that page rebuilds leave bound to nothing, with their nodes; dry run unless `--apply` |
305
305
  | `fix_text_runs.py` | makes buttons built before v1.34.1 editable in the Mosaic editor by wrapping their text the way the editor does; dry run unless `--apply` |
306
306
  | `scan_inline_tags.py` | read only: finds text that holds HTML tags, which Mosaic 1.0.11+ prints as visible `<p>` / `<br>` on the page |
307
+ | `fix_inline_tags.py` | fixes what `scan_inline_tags.py` finds, turning the tags into real inline nodes; dry run unless `--apply` |
307
308
  | `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 |
308
309
  | `list_fields.php` | every `@VAR` / `@LOOP` name a post's custom fields register, with values |
309
310
  | `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.34.3"
8
+ version: "1.34.5"
9
9
  homepage: "https://github.com/Moksa1123/mosaic-headless"
10
10
  ---
11
11
 
@@ -885,7 +885,15 @@ with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
885
885
  before or after the update, on any site not built by `build_page.py` (another
886
886
  converter, hand edits, an older helper). On the test theme it listed 179 runs on
887
887
  the Elementor-converted `el-*` pages, and each listed page printed `&lt;p&gt;` while
888
- the rest printed none.
888
+ the rest printed none. `tools/fix_inline_tags.py` then rewrites them in place
889
+ (dry run, then `--apply`): 179 fixed, 0 skipped, a second run found nothing, no
890
+ page printed a tag afterwards, and every page's visible text was identical.
891
+ One layout change to expect: a run that was `<p>…</p>` used to put a real `<p>`
892
+ inside the text node, and that `<p>` picked up the WordPress theme's own `p` rule
893
+ (here `margin:24px 0 0; font-size:16px; line-height:24px`), overriding the node's
894
+ own font size and line height. After the fix the node's own style applies, so
895
+ each such block lost 8-49px of height. Giving the node `tagName: p` does not
896
+ bring it back: Mosaic zeroes the margin on its own `p.m-text`.
889
897
  - **`menu-link` is `width: fit-content` by default** (`.m-menu-link{display:flex;gap:4px;
890
898
  padding:4px 8px;width:fit-content;…}`). Used as a cell of a button row or a grid -
891
899
  a phone contact bar on `2fr 1fr 1fr` - its background hugs the text and the cell
@@ -958,6 +966,7 @@ with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
958
966
  | `theme_delete.php` | remove a theme completely through the plugin's own routine; refuses the live one |
959
967
  | `fix_text_runs.py` | wrap text runs that sit directly under a button, menu-link or other non-text element (built before v1.34.1) in an Inherited text `text` node, so the editor can edit them - every master, template and component, through each document's own commit; dry run unless `--apply`, idempotent, component overrides kept |
960
968
  | `scan_inline_tags.py` | read only: list every `wysiwyg-text` run whose text holds HTML tags (printed literally on 1.0.11+), with the nearest attrID above it, across every master, template and component - run it before or after a site updates from 1.0.10 |
969
+ | `fix_inline_tags.py` | rewrite those runs in place as `wysiwyg-span` / `-link` / `-linebreak` nodes (inline_html.py's mapping); a run that is one `<p>`/`<hN>` gives its tag to a text node that has none; lists, tables, images and mixed block/inline runs are skipped and listed; dry run unless `--apply`, idempotent |
961
970
  | `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 |
962
971
  | `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 |
963
972
  | `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 |
@@ -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, 101 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.34.3"
23
+ "version": "1.34.5"
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, 101 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.34.3"
23
+ "version": "1.34.5"
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, 101 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.34.3"
23
+ "version": "1.34.5"
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, 101 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.34.3"
23
+ "version": "1.34.5"
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, 101 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.34.3"
23
+ "version": "1.34.5"
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.34.3",
3
+ "version": "1.34.5",
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",
@@ -73,6 +73,19 @@ it commits without complaint and delivers
73
73
  `href="http://concat('/contact/?ref=%27…"` - the leading `@` dropped and the rest taken
74
74
  as a URL (measured on a client build on 1.0.10). As `{"v": "@concat(…)"}` it delivers the evaluated link.
75
75
 
76
+ The same holds for a field that is not in the sweep tables. A form's
77
+ `actionOptions.entryName` and `formName` go through `LocalContext::evaluateText`,
78
+ which computes only `{"v": …}` and returns a plain string as it is. A plain
79
+ `"entryName": "@VAR('form/field_name')"` stores that text as every submission's
80
+ `entryLabel`, so the admin's Form Submissions list shows the raw code (measured on a
81
+ live form on 1.0.11). The label is stored per submission, so fixing the setting
82
+ does not change submissions already saved. The action settings inside
83
+ `actionOptions.actions[]` (email subject, replyTo, webhook body) accept either form.
84
+ `build_page.py` refuses `@fn(` code in a plain data string, except where a plain
85
+ string is evaluated: `code` content, `wpShortcode`, `wysiwyg-variable`'s
86
+ `dynamicCode` (and a condition's variable subject), a loop source, and form
87
+ action settings.
88
+
76
89
 
77
90
  ## The variable namespace
78
91
 
@@ -220,7 +220,10 @@ the sweep tables.
220
220
  keeps one open.
221
221
  - **form**: `submitType` is `action` (default) or `native`; the options sit in
222
222
  `actionOptions {actions[], formName, entryName}` or `nativeOptions {url, target,
223
- method get|post, encoding}`, and switching type deletes the other group. A native
223
+ method get|post, encoding}`, and switching type deletes the other group.
224
+ `formName` and `entryName` take dynamic code only as `{"v": "@VAR('form/…')"}`;
225
+ a plain string is not computed, and a plain `entryName` is what the submissions
226
+ list shows. A native
224
227
  submit skips server validation, the honeypot and CAPTCHA. The success screen
225
228
  shows only for `action` with no redirect. With no error-message element, errors
226
229
  appear in the browser's own bubble. Every label and legend is required; hide one
@@ -73,6 +73,26 @@ def load_csv(name):
73
73
  # `<br>` prints as those characters on the page. Inline formatting is written as
74
74
  # nodes instead: wysiwyg-span, wysiwyg-linebreak, wysiwyg-link.
75
75
  PROSE_TAG = re.compile(r"</?[a-zA-Z][a-zA-Z0-9-]*\s*[^>]*>")
76
+ DYNAMIC_CALL = re.compile(r"@[A-Za-z_][A-Za-z0-9_]*\s*\(")
77
+ # types whose own content is parsed as code from a plain string
78
+ RAW_CODE_TYPES = {"code", "wpShortcode", "wysiwyg-variable", "wysiwyg-text"}
79
+ # data keys whose plain string is evaluated (loop source; form action settings;
80
+ # a condition's variable subject)
81
+ RAW_CODE_KEYS = {"localContextOptions", "actions", "dynamicCode"}
82
+
83
+
84
+ def plain_code_paths(value, path="data"):
85
+ """Paths of plain strings holding @fn( code where only {"v": ...} is computed."""
86
+ if isinstance(value, str):
87
+ return [path] if DYNAMIC_CALL.search(value) else []
88
+ if isinstance(value, dict):
89
+ if isinstance(value.get("v"), str):
90
+ return []
91
+ return [p for k, v in value.items() if k not in RAW_CODE_KEYS
92
+ for p in plain_code_paths(v, "%s.%s" % (path, k))]
93
+ if isinstance(value, list):
94
+ return [p for i, v in enumerate(value) for p in plain_code_paths(v, "%s[%d]" % (path, i))]
95
+ return []
76
96
  AT_RULE_GLUED = re.compile(
77
97
  r"@(media|supports|container|layer|scope|import|page|starting-style|"
78
98
  r"font-feature-values|counter-style|property|document)\(")
@@ -134,6 +154,16 @@ class Surface:
134
154
  problems.append("code content contains `%s` - Mosaic's template parser reads "
135
155
  "it as a function call and the page renders as HTTP 500; "
136
156
  "write `%s (`" % (hit.group(0), hit.group(0)[:-1]))
157
+ # Node data is computed only in the {"v": "..."} object form
158
+ # (DynamicCodeHelper::isDynamicCode); evaluateText hands a plain string back
159
+ # verbatim. So `"entryName": "@VAR('form/field_name')"` stores and shows the
160
+ # code itself - measured on a live form's submission list. Raw strings that ARE
161
+ # evaluated: code content, wpShortcode, wysiwyg-variable dynamicCode, a loop
162
+ # source, and form action settings (getSetting takes either form).
163
+ if not force and t not in RAW_CODE_TYPES:
164
+ for path in plain_code_paths(node.get("data") or {}):
165
+ problems.append("%s holds dynamic code as a plain string - it is stored "
166
+ "and shown literally; write it as {\"v\": \"...\"}" % path)
137
167
  # A local-context loop's source written as `@LOOP('post/x')` renders on the
138
168
  # front end - LoopEvaluator.php reads the loop name out of any function call -
139
169
  # and throws in the editor, whose evaluateLoop only resolves `@VAR`
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env python3
2
+ """Rewrite text runs that hold HTML tags as the inline nodes Mosaic 1.0.11 renders.
3
+
4
+ python fix_inline_tags.py --config site.json # dry run: lists each change
5
+ python fix_inline_tags.py --config site.json --apply # commit, document by document
6
+
7
+ Why this exists
8
+ ---------------
9
+ scan_inline_tags.py finds the runs; this fixes them in place. A run like
10
+ `<p>Call <a href="tel:1">us</a><br>today</p>` printed fine through 1.0.10 and prints
11
+ its tags as text on 1.0.11. Here it becomes
12
+
13
+ text (tagName p) > wysiwyg-text "Call " , wysiwyg-link(url) > wysiwyg-text "us",
14
+ wysiwyg-linebreak , wysiwyg-text "today"
15
+
16
+ using inline_html.py's mapping (strong/em/u/s -> styled wysiwyg-span, a -> link,
17
+ br -> linebreak, other inline tags unwrapped). When the whole run is one block
18
+ (`<p>...</p>`, `<h2>...</h2>`) and the text node around it has no tagName of its
19
+ own, that tag moves onto the text node, so the page keeps the element it had.
20
+ Several blocks in one run (`<p>a</p><p>b</p>`) are joined with a blank line
21
+ (two linebreaks): the text stays in one node, the paragraph margins do not.
22
+
23
+ Skipped and listed, never guessed: runs holding a list (`<ul>`/`<ol>`), a table, or
24
+ an image; runs under a component instance's override; runs whose parent is not a
25
+ `text` node. Those need a rebuild from source.
26
+
27
+ Every document on the theme is covered - masters, templates, components - through
28
+ each document's own commit, never SQL. Back up the wp_mosaic_* tables first.
29
+ """
30
+ import mosaic_config
31
+ import argparse
32
+ import os
33
+ import sys
34
+
35
+ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
36
+ import inline_html # noqa: E402
37
+ from build_page import Surface, flatten # noqa: E402
38
+ from fix_text_runs import documents # noqa: E402
39
+ from scan_inline_tags import scan # noqa: E402
40
+ from sweep_node_types import Client, envelopes, exceptions_of # noqa: E402
41
+
42
+ # fractional-index digits; a key may not end in "0", so suffixes skip it
43
+ DIGITS = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
44
+ UNSUPPORTED = {"ul", "ol", "li", "table", "img", "picture", "video", "iframe", "svg",
45
+ "script", "style", "form", "input", "select", "textarea"}
46
+
47
+
48
+ def _tags(nodes):
49
+ for n in nodes:
50
+ if isinstance(n, list):
51
+ yield n[0]
52
+ yield from _tags(n[2])
53
+
54
+
55
+ def convert(text):
56
+ """(inline spec children, block tag to give the parent or None) or (None, reason)."""
57
+ top = [n for n in inline_html._parse(text) if not (isinstance(n, str) and not n.strip())]
58
+ bad = sorted(set(_tags(top)) & UNSUPPORTED)
59
+ if bad:
60
+ return None, "holds " + ", ".join("<%s>" % t for t in bad)
61
+ blocks = [n for n in top if isinstance(n, list) and n[0] in inline_html.BLOCK]
62
+ if blocks and len(blocks) == len(top):
63
+ nested = [t for b in blocks for t in _tags(b[2]) if t in inline_html.BLOCK]
64
+ if nested:
65
+ return None, "nested blocks"
66
+ parts = [inline_html._inline(b[2]) for b in blocks]
67
+ out = []
68
+ for p in parts:
69
+ if out and p:
70
+ out += [{"type": "wysiwyg-linebreak", "data": {}},
71
+ {"type": "wysiwyg-linebreak", "data": {}}]
72
+ out += p
73
+ tag = blocks[0][0] if len(blocks) == 1 and blocks[0][0] in inline_html.TEXT_TAGS else None
74
+ return out, tag
75
+ if blocks:
76
+ return None, "block and inline content mixed"
77
+ return inline_html._inline(top), None
78
+
79
+
80
+ def plan(nodes, surface):
81
+ """Revision records for every fixable run, plus (run, reason) for the rest."""
82
+ live = {n["ID"]: n for n in nodes if n.get("status") != "delete"}
83
+ kids = {}
84
+ for n in live.values():
85
+ kids.setdefault(n.get("parentID"), []).append(n)
86
+ records, skipped, fixed = [], [], []
87
+ for run, _anchor, _tags_found in scan(nodes):
88
+ parent = live.get(run.get("parentID"))
89
+ if run.get("parentType") != "node" or not parent or parent["type"] != "text":
90
+ skipped.append((run, "parent is not a text node"))
91
+ continue
92
+ children, extra = convert(run["data"]["text"])
93
+ if children is None:
94
+ skipped.append((run, extra))
95
+ continue
96
+ base = run.get("ordering") or "a0"
97
+ if len(children) > len(DIGITS) or any(
98
+ s is not run and (s.get("ordering") or "").startswith(base)
99
+ for s in kids.get(parent["ID"], [])):
100
+ skipped.append((run, "no room in the sibling ordering"))
101
+ continue
102
+ new = []
103
+ for i, child in enumerate(children):
104
+ flatten(child, parent["ID"], run.get("documentID"), surface, False,
105
+ ordering=base + DIGITS[i], parent_type="text", out=new)
106
+ for r in new:
107
+ r["documentType"], r["documentID"] = run.get("documentType"), run.get("documentID")
108
+ records.append({"newRevisionRecord": r, "originalRevisionRecord": None})
109
+ records.append({"newRevisionRecord": dict(run, status="delete"),
110
+ "originalRevisionRecord": run})
111
+ pdata = parent.get("data") or {}
112
+ if extra and not pdata.get("tagName"):
113
+ records.append({"newRevisionRecord": dict(parent, data=dict(pdata, tagName=extra)),
114
+ "originalRevisionRecord": parent})
115
+ fixed.append((run, len(children), extra))
116
+ return records, fixed, skipped
117
+
118
+
119
+ def main():
120
+ ap = argparse.ArgumentParser()
121
+ ap.add_argument("--config",
122
+ help="JSON with base/cookie/nonce/themeID; omit it and the MOSAIC_* environment variables supply them")
123
+ ap.add_argument("--apply", action="store_true", help="commit; without it nothing is written")
124
+ a = ap.parse_args()
125
+ sys.stdout.reconfigure(errors="replace")
126
+ client = Client(mosaic_config.load(a.config))
127
+ surface = Surface()
128
+
129
+ n_fixed = n_skipped = 0
130
+ for instance, key, label in documents(client):
131
+ resp = client.get(instance)
132
+ if "_httperror" in resp or "response" not in resp:
133
+ print(" skip %-40s (could not read)" % label)
134
+ continue
135
+ doc = resp["response"]
136
+ records, fixed, skipped = plan(doc.get(key) or [], surface)
137
+ if not fixed and not skipped:
138
+ continue
139
+ print("%s: %d fixed, %d skipped" % (label, len(fixed), len(skipped)))
140
+ for run, count, tag in fixed:
141
+ print(" fix %s -> %d node(s)%s" % (run["ID"][:8], count,
142
+ ", parent tagName %s" % tag if tag else ""))
143
+ for run, why in skipped:
144
+ text = " ".join(run["data"]["text"].split())
145
+ print(" SKIP %s %s: %s" % (run["ID"][:8], why, text[:80]))
146
+ n_fixed += len(fixed)
147
+ n_skipped += len(skipped)
148
+ if a.apply and records:
149
+ err = exceptions_of(client.commit(instance, envelopes(doc), {key: records}))
150
+ if err:
151
+ sys.exit("commit failed on %s: %s" % (label, err[:400]))
152
+
153
+ print("%s %d run(s), skipped %d" % ("fixed" if a.apply else "would fix", n_fixed, n_skipped))
154
+ if n_fixed and not a.apply:
155
+ print("dry run - nothing written. Add --apply to commit.")
156
+ elif n_fixed:
157
+ print("purge the page cache, then re-run scan_inline_tags.py: it should list only the skipped runs.")
158
+
159
+
160
+ if __name__ == "__main__":
161
+ main()