mosaic-headless 1.36.3 → 1.37.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/SKILL.md +179 -1119
- package/assets/templates/platforms/claude-ai.json +1 -1
- package/assets/templates/platforms/claude-code.json +5 -2
- package/assets/templates/platforms/codex-cli.json +1 -1
- package/assets/templates/platforms/copilot.json +1 -1
- package/assets/templates/platforms/gemini-cli.json +1 -1
- package/data/pending.csv +8 -0
- package/data/terms-zh.csv +97 -0
- package/evals/RESULTS.md +41 -0
- package/evals/cases.json +329 -0
- package/evals/grade.py +121 -0
- package/evals/runs/2026-11-16-final-with-skill.json +29 -0
- package/evals/runs/2026-11-16-final-without-skill.json +30 -0
- package/evals/runs/2026-11-16-r1-with-skill.json +19 -0
- package/evals/runs/2026-11-16-r1-without-skill.json +19 -0
- package/evals/runs/2026-11-16-r2-with-skill.json +9 -0
- package/evals/runs/2026-11-16-r2-without-skill.json +9 -0
- package/evals/runs/2026-11-16-r3-without-skill.json +1 -0
- package/package.json +1 -1
- package/references/building.md +93 -0
- package/references/core-rules.md +143 -0
- package/references/data-files.md +102 -0
- package/references/design-system.md +1 -1
- package/references/facts.md +261 -0
- package/references/failure-modes.md +1 -1
- package/references/maintenance.md +70 -0
- package/references/tools.md +84 -0
- package/references/tutorials.md +1 -1
- package/references/upgrading.md +2 -2
- package/references/verification-record.md +395 -0
- package/scripts/check-release.mjs +10 -5
- package/scripts/install.mjs +7 -5
- package/tools/check_numbers.py +196 -0
- package/tools/mo.py +132 -7
- package/tools/test_mosaic.py +373 -0
- package/tools/verify_menus.py +1 -1
package/evals/grade.py
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
grade.py — evals 評分:同一組真題,比「有 skill」與「沒有 skill」的答對率。
|
|
4
|
+
|
|
5
|
+
流程(給其他 skill 照抄,只要換 cases.json):
|
|
6
|
+
1. python evals/grade.py --questions > q.txt 只印題目,不含答案,交給作答者
|
|
7
|
+
2. 作答者各跑一次,答案存成 evals/runs/<日期>-with-skill.json、-without-skill.json
|
|
8
|
+
格式:{"meta": {"date": ..., "model": ..., "how": ...}, "answers": {"<id>": "<答案全文>"}}
|
|
9
|
+
3. python evals/grade.py --with <檔> --without <檔> [--write]
|
|
10
|
+
--write 把結果加到 evals/RESULTS.md 最上面(舊紀錄保留)
|
|
11
|
+
|
|
12
|
+
評分規則:cases.json 每題的 must 是「組」的清單,每一組至少命中一個正規式(不分大小寫),
|
|
13
|
+
全部組都命中才算對。沒有 skill 也答對的題沒有鑑別度(SOP 6-4),不列入計分,要換題。
|
|
14
|
+
|
|
15
|
+
exit code:有 skill 的計分題答對率低於 --min(預設 90%)就回 1。
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
import re
|
|
22
|
+
import sys
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
HERE = Path(__file__).resolve().parent
|
|
26
|
+
CASES = HERE / "cases.json"
|
|
27
|
+
RESULTS = HERE / "RESULTS.md"
|
|
28
|
+
|
|
29
|
+
for _s in (sys.stdout, sys.stderr):
|
|
30
|
+
if hasattr(_s, "reconfigure"):
|
|
31
|
+
_s.reconfigure(encoding="utf-8", errors="replace")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def load_cases() -> list[dict]:
|
|
35
|
+
# retired:已確認沒有鑑別度而換掉的題,保留在檔案裡當紀錄,不再作答與評分
|
|
36
|
+
return [c for c in json.loads(CASES.read_text(encoding="utf-8"))["cases"] if not c.get("retired")]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def correct(case: dict, answer: str) -> bool:
|
|
40
|
+
return all(any(re.search(p, answer or "", re.I) for p in group) for group in case["must"])
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def load_run(path: str) -> tuple[dict, dict]:
|
|
44
|
+
data = json.loads(Path(path).read_text(encoding="utf-8"))
|
|
45
|
+
return data.get("meta", {}), data["answers"]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def report(cases, with_run, without_run) -> tuple[str, float]:
|
|
49
|
+
(wm, wa), (om, oa) = with_run, without_run
|
|
50
|
+
rows, counted, w_ok, o_ok, w_all, o_all = [], 0, 0, 0, 0, 0
|
|
51
|
+
for c in cases:
|
|
52
|
+
w, o = correct(c, wa.get(c["id"], "")), correct(c, oa.get(c["id"], ""))
|
|
53
|
+
w_all += w
|
|
54
|
+
o_all += o
|
|
55
|
+
if o and w:
|
|
56
|
+
note = "沒 skill 也對:不計分,要換題"
|
|
57
|
+
else:
|
|
58
|
+
counted += 1
|
|
59
|
+
w_ok += w
|
|
60
|
+
o_ok += o
|
|
61
|
+
note = "" if w else "有 skill 仍答錯"
|
|
62
|
+
rows.append(f"| `{c['id']}` | {c['trust']} | {'✅' if w else '❌'} | {'✅' if o else '❌'} | {note} |")
|
|
63
|
+
n = len(cases)
|
|
64
|
+
rate = w_ok / counted * 100 if counted else 0.0
|
|
65
|
+
date = wm.get("date") or om.get("date") or "?"
|
|
66
|
+
out = [
|
|
67
|
+
f"## {date}",
|
|
68
|
+
"",
|
|
69
|
+
"| 項目 | 有 skill | 沒有 skill |",
|
|
70
|
+
"|---|---|---|",
|
|
71
|
+
f"| 計分題答對率({counted} 題) | **{w_ok}/{counted}({rate:.1f}%)** | "
|
|
72
|
+
f"{o_ok}/{counted}({(o_ok / counted * 100 if counted else 0):.1f}%) |",
|
|
73
|
+
f"| 全部題目({n} 題) | {w_all}/{n} | {o_all}/{n} |",
|
|
74
|
+
f"| 模型 | {wm.get('model', '?')} | {om.get('model', '?')} |",
|
|
75
|
+
f"| 作答方式 | {wm.get('how', '?')} | {om.get('how', '?')} |",
|
|
76
|
+
f"| 答案檔 | `{wm.get('file', '')}` | `{om.get('file', '')}` |",
|
|
77
|
+
"",
|
|
78
|
+
"| 題目 | 可信度 | 有 skill | 沒有 skill | 備註 |",
|
|
79
|
+
"|---|---|---|---|---|",
|
|
80
|
+
*rows,
|
|
81
|
+
"",
|
|
82
|
+
]
|
|
83
|
+
return "\n".join(out), rate
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def main() -> int:
|
|
87
|
+
ap = argparse.ArgumentParser()
|
|
88
|
+
ap.add_argument("--questions", action="store_true", help="只印題目(給作答者,不含答案與評分)")
|
|
89
|
+
ap.add_argument("--with", dest="with_", help="有 skill 的答案檔")
|
|
90
|
+
ap.add_argument("--without", help="沒有 skill 的答案檔")
|
|
91
|
+
ap.add_argument("--write", action="store_true", help="把結果加到 RESULTS.md 最上面")
|
|
92
|
+
ap.add_argument("--min", type=float, default=90.0, help="有 skill 計分題答對率門檻(%%)")
|
|
93
|
+
args = ap.parse_args()
|
|
94
|
+
cases = load_cases()
|
|
95
|
+
|
|
96
|
+
if args.questions:
|
|
97
|
+
for c in cases:
|
|
98
|
+
print(f"{c['id']}\t{c['question']}")
|
|
99
|
+
return 0
|
|
100
|
+
if not (args.with_ and args.without):
|
|
101
|
+
ap.error("要給 --with 與 --without,或用 --questions")
|
|
102
|
+
|
|
103
|
+
runs = []
|
|
104
|
+
for p in (args.with_, args.without):
|
|
105
|
+
meta, ans = load_run(p)
|
|
106
|
+
meta.setdefault("file", Path(p).as_posix().split("mosaic-headless/")[-1])
|
|
107
|
+
runs.append((meta, ans))
|
|
108
|
+
text, rate = report(cases, runs[0], runs[1])
|
|
109
|
+
print(text)
|
|
110
|
+
|
|
111
|
+
if args.write:
|
|
112
|
+
head = "# evals 結果\n\n最新的在最上面。題目與評分標準見 `cases.json`,評分程式 `grade.py`。\n\n"
|
|
113
|
+
old = RESULTS.read_text(encoding="utf-8") if RESULTS.exists() else head
|
|
114
|
+
body = old[len(head):] if old.startswith(head) else old
|
|
115
|
+
RESULTS.write_text(head + text + "\n" + body, encoding="utf-8")
|
|
116
|
+
print(f"已寫入 {RESULTS}")
|
|
117
|
+
return 0 if rate >= args.min else 1
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
if __name__ == "__main__":
|
|
121
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"date": "2026-11-16",
|
|
4
|
+
"model": "claude-opus-5-5",
|
|
5
|
+
"how": "subagent 讀 SKILL.md、用 mo.py 與 references 查(r1+r2 合併)"
|
|
6
|
+
},
|
|
7
|
+
"answers": {
|
|
8
|
+
"select-split-1012": "1.0.12 的結構:select > select-toggle(內含 select-placeholder 與 icon 箭頭)+ select-options > select-option。select-option 的標籤改成子節點(text > wysiwyg-text),不再用 text 屬性;值放在 value。舊的 select-input 已不存在(mo.py type select-input 回 no such node type)。原生下拉改用 listbox > listbox-option(多選或 size>1 時,data upgrade 會轉成這個)。前台輸出 <mosaic-select class=m-select> 加一個隱藏的 <input class=m-select-input>。來源:mo.py type select / select-toggle / select-options / select-option、references/upgrading.md(Select split)、failure-modes.md。",
|
|
9
|
+
"scrolldepth-slot-1010": "1.0.10 起 scrollDepth 宣告兩個 slot:reached(捲到門檻)與 returned(捲回門檻以上)。動作要寫在 actionSlots.reached。如果還放在舊的 slot 名稱 scrollDepth 底下,資料會被存下來,但因為該 type 已經不宣告這個 key,不會匯出,動作永遠不會執行,而且沒有任何錯誤。data upgrade 會把舊資料(含 completedAfter: scrollDepth)搬到 reached;interactionShorthand 寫法不受影響。來源:references/dialog-and-triggers.md、facts.md、upgrading.md。",
|
|
10
|
+
"popover-trigger-slots": "popover 觸發器(Popover visibility change,Element events 群組)有三個 slot:show、beforeClose(原生隱藏會等它跑完)、afterClose(popover 已經隱藏之後)。三步驟導覽的下一步要掛在目前這一步自己的 afterClose(在 afterClose 裡執行 popoverOpen 下一步)。不能在第一步內的「下一步」按鈕直接開下一步:從 dialog 裡打開的 dialog 會變成它的子層,父層關閉時會一起被關掉;關閉 popover 也會暫停它裡面所有元素的 interactions。「下一步」按鈕只負責關閉自己這一步。來源:mo.py interactions、references/dialog-and-triggers.md、facts.md。",
|
|
11
|
+
"popover-flipped-state": "用 style state ___popover--flipped(mo.py states --grep flip:scope node-type、host popover、swept COMPILED,selector 是 .m-popover[data-mosaic-popover-flipped])。來源:mo.py states --grep flip、facts.md。",
|
|
12
|
+
"shorthand-interaction-types": "只有三種:pageLoad、exitIntent、scrollDepth(來源碼 InteractionTypesManager::getShorthandInteractionTypes())。這三種都不需要元素先可見、可互動,而 modal 在打開前是 display:none。用其他種(例如 elementScrollIntoView)會被無聲丟棄:modal 的 aria 屬性照常輸出,但頁面的 mosaicInteractions 沒有它,modal 永遠不會打開。「不要自動打開」要寫 type: manual。另外 shorthand 不能帶 conditions。來源:references/dialog-and-triggers.md、facts.md。",
|
|
13
|
+
"interaction-value-shape": "initial 和 keyframe 的 properties 要用屬性 META 的 uuid 當 key,不能用屬性名稱(例如 opacity)。值要寫成帶單位的 CSS 字串,例如 「0%」「40px」「0px」,不能寫數字。timed 觸發器的 keyframe 用 duration / delay(毫秒);只有 progress 類(scrollIntoView、pointerMove)用 progressData 0-100。用數字或用屬性名稱當 key,存下來的都是零值。建議用 tools/interactions.py 產生,不要手寫。來源:references/interactions.md、mo.py interactions。",
|
|
14
|
+
"wysiwyg-text-escape-1011": "1.0.11 起 wysiwyg-text 會跳脫 < 和 >,前台會直接顯示文字 A<strong>B</strong>(HTML 是 A<strong>B</strong>),不會變成粗體。正確做法是用節點:粗體在 wysiwyg-text 設 format: [bold](輸出 <strong>;斜體是 [italic]),或用 wysiwyg-span(<span class=m-span>,再加樣式);換行用 wysiwyg-linebreak(<br>);行內連結用帶 url 的 wysiwyg-link。每個節點底下都放自己的 wysiwyg-text。bold 和 italic 同時設在 1.0.11 會巢狀錯誤,inline_html.py 改成用有樣式的 wysiwyg-span。舊站可以用 scan_inline_tags.py / fix_inline_tags.py 修正。來源:references/facts.md、upgrading.md。",
|
|
15
|
+
"pro-only-types-1011": "1.0.11 之後需要 Pro 的只剩 5 個:code、modal、modal-overlay、modal-window、popover。表單系統、slider、tabs 共 49 個 type 移到 Free。來源:mo.py types --edition pro、references/upgrading.md。",
|
|
16
|
+
"url-capable-types": "只有四種:button、menu-link、wysiwyg-link、dropdown-toggle。url 放在 text 或 image 上會被接受、也會存下來,但完全不會輸出 <a>。要讓其他東西可點,要用 button 包起來,style.variant 設成 Link variant(m-link),帶 url 就會輸出 <a class=m-link href>;這就是編輯器「Wrap in link」寫入的結構。來源:references/facts.md。",
|
|
17
|
+
"section-default-padding": "上下各 80px(實測:spec 沒設 padding 的 section,前台量到 top / bottom 各 80px,夾在兩個區塊之間就會多出 160px 空白)。要明確設定 paddingTop / paddingBottom。來源:references/facts.md、responsive.md。",
|
|
18
|
+
"unsafe-type-count": "27 個(BROKE_PAGE 12 + COMMIT_500 14 + COMMIT_502 1):accordion-content、accordion-item、accordion-title、checkbox-input、component-instance、document、form-multi-steps-steps、loop、loop-items、loop-pagination、loop-pagination-button-next、loop-pagination-button-previous、loop-pagination-number、loop-pagination-numbers、multi-steps-form-step、multi-steps-forms、radio-input、slider、slider-navigation、slider-navigation-bullet、slider-slide、slider-slides、tabs-content、tabs-loop-tabs、tabs-menu、tabs-tab、wysiwyg-variable。來源:mo.py stats、mo.py types --unsafe。",
|
|
19
|
+
"modal-open-1010": "1.0.10 的 modal 是 <dialog popover=manual>,用 showPopover() 打開,會進入 top layer。dialog.open 不能用,它永遠是 false,拿它判斷的話每個 modal 都會被當成關著。要用 el.matches(':popover-open') 判斷,或讀 data-mosaic-dialog-state=open。要從程式關閉,用 el.mosaicDialog.requestClose()(回傳 Promise);close() 已經不存在。來源:references/dialog-and-triggers.md、facts.md。",
|
|
20
|
+
"custom-declarations-dvh": "整個 customDeclarations 區塊都會被無聲丟棄。驗證器會解析每一條宣告,只要一個值不合格就丟掉整塊,而 dvh(還有 svh、lvh、dvw、容器單位)不在 ValidatorCustomDeclarations 的單位清單裡,!important 也一樣會失敗。要用 dvh 的話,改用結構化的 height / maxHeight 欄位,它們接受 dvh。來源:references/facts.md、styling.md。",
|
|
21
|
+
"accordion-content-bare": "會 BROKE_PAGE:提交成功,但整個公開頁面變成一行錯誤字串(AccordionItemElementMResource instance required)。mo.py 判定為 UNSAFE - DO NOT COMMIT。它要放在 accordion-item 底下(accordion-title 與 accordion-content 是 accordion-item 透過 heal() 帶進來的子節點),accordion-item 再放在 accordion 裡。來源:mo.py type accordion-content。",
|
|
22
|
+
"local-loop-source": "loopType: localContext 的 loopSource 要寫成 {\"v\": \"@VAR('post/<loop名稱>')\"},例如 @VAR('post/loopacf_rel')。不能用 @LOOP():loop evaluator 只執行它拿到的函式呼叫,不看函式名稱;@VAR 會解析出 loop,@LOOP 則會呼叫 null。前台兩種都能顯示,但 @LOOP 在編輯器會丟出 _loopEvaluatorFunction is not a function,畫布永遠載入不完,build_page.py 也會拒絕。@LOOP(…) 放在文字裡面沒問題。來源:references/facts.md、custom-fields.md、failure-modes.md。",
|
|
23
|
+
"button-text-editable": "要用編輯器原生的結構 button > text(Inherited text variant,6381b2f3…)> wysiwyg-text。如果把 wysiwyg-text 直接放在 button 底下,前台看起來一樣,但在編輯器裡 navigator 看不到子節點,雙擊只會打開連結設定,沒辦法編輯文字。build_page.py 會自動包好(wrap_text_runs),所以 spec 用 「text」 簡寫就安全;舊站可以用 tools/fix_text_runs.py 修正。menu-link、dropdown-toggle、tabs、submit 的標籤也一樣。來源:references/facts.md、SKILL.md 的五個常見錯誤。",
|
|
24
|
+
"no-template-status": "HTTP 406。406 是 Mosaic 的「沒有範本對應」:FrontendRenderer 接到 TemplateNotFoundException 時呼叫 status_header(406),說明文字只印給管理員看,所以未登入訪客拿到的是一個空白頁加上 406 狀態碼,看起來像伺服器出問題。最常踩到的情況:剛 wp theme activate 一個新佈景、還沒建好範本(或建置失敗)時,整站都會是 406。所以驗證要用登出狀態讀頁面。(來源:`mo.py facts visitor` → references/core-rules.md「406 is Mosaic's \"no template matched\"」)",
|
|
25
|
+
"unprobed-node-props": "`ariaLive` 和 `positioning`。這兩個都只宣告在 `popover` 上,`mo.py prop` 查出來的 verified 都是「not probed」(ariaLive 的值是 off / polite / assertive)。`mo.py stats` 也列出:191 筆探測紀錄涵蓋了 120 個宣告名稱中的 118 個。(來源:SKILL.md Sources 表、`mo.py stats`、`mo.py prop ariaLive`、`mo.py prop positioning`)",
|
|
26
|
+
"variant-delete": "Variant 不能刪除,只能清空。對 variant 送 `status:\"delete\"`,伺服器會接受但直接忽略,因為 variant 那一列有 catalog 撐著。正確做法是把那一列 commit 回去,內容設成 `{\"states\": {\"&\": {\"_\": {}}}}`,這樣它的 CSS 規則就會消失(在 Heading 2 上實測過)。對照組:universal class 沒有 catalog 撐著,用 `status:\"delete\"` 就真的會刪掉。ID 要用 `name` 去 data/variants.csv 查(用 `mo.py classes --grep Heading`)。(來源:`mo.py facts status` → references/facts.md、references/design-system.md)",
|
|
27
|
+
"class-name-grammar": "每一段最多 60 個字元。名稱會被整理成 `[a-z0-9_-]` 的段落,段落之間用 `--` 串起來(例如 `m-button--primary--sm`)。保留前綴是 `m-`;段落也不能以 `_` 或數字開頭(`m-` 會被拿掉)。名稱撞到時,系統會自動在後面加 `-2`、`-3` 去重複;emitted name 在同一個佈景內是唯一的(四張表的 `emittedName` 欄位有 unique index),所以兩個 class 不可能是同一個拼法。整理完變成空字串的名稱,會退回成 `class`。整理規則還包括:轉寫成拉丁字母、轉小寫、連續的 `-` 合併,尺寸級距也會統一(`s`→`sm`、`m`→`md`、`l`→`lg`、`xxs`→`2xs`)。(來源:`mo.py facts reserved` → references/facts.md「User class names have a grammar」、references/upgrading.md ClassNameHelper 段落、references/design-system.md)"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {
|
|
3
|
+
"date": "2026-11-16",
|
|
4
|
+
"model": "claude-opus-5-5",
|
|
5
|
+
"how": "subagent 不用任何工具,憑記憶作答(r1+r2+r3 合併)"
|
|
6
|
+
},
|
|
7
|
+
"answers": {
|
|
8
|
+
"select-split-1012": "猜測:改成父容器 select(或 form-select)底下放多個 option(select-option)子節點,由使用者自己組選項;舊的單一 type「select-field」(選項寫在屬性陣列裡的那種)已移除。實際 type 名稱我不確定,這是猜的。",
|
|
9
|
+
"scrolldepth-slot-1010": "猜測:動作改放在「onReach」(或 reached)slot 底下;舊的 slot 名稱(推測是 actions / onScroll)不會再被讀取,觸發器不報錯但動作不會執行。名稱為猜測。",
|
|
10
|
+
"popover-trigger-slots": "猜測:三個 slot 是 onOpen(開啟時)、onClose(關閉時)、onToggle;做三步驟導覽時,下一步應掛在 onClose(第一步關閉後再開第二個 popover)。名稱為猜測。",
|
|
11
|
+
"popover-flipped-state": "猜測:用 style state「flipped」(例如 :flipped/state id 'flipped')來設定翻轉後的樣式。不確定確切 ID。",
|
|
12
|
+
"shorthand-interaction-types": "猜測:只有 click、hover、pageLoad(載入)這類簡單觸發可以當 shorthand;其他種(如 scroll、exitIntent)用 shorthand 會被忽略或驗證失敗,需改用完整的 interaction 物件。為猜測。",
|
|
13
|
+
"interaction-value-shape": "猜測:initial 與 properties 的 key 用 CSS 屬性名稱(如 opacity、transform、translateY),值寫成數字(例如 opacity: 0、translateY: 20)。不確定。",
|
|
14
|
+
"wysiwyg-text-escape-1011": "猜測:1.0.11 會把 HTML 跳脫,前台會直接顯示字面文字「A<strong>B</strong>」。要做行內粗體或換行,應該用富文字結構(例如 text 子節點的 marks/格式陣列,或段落內的 inline 節點),換行用 line break 節點,而不是寫原始 HTML 字串。具體結構不確定。",
|
|
15
|
+
"pro-only-types-1011": "猜測:popover、modal、tabs、accordion、slider/carousel、form 相關(form、input、select)、map、loop/query-loop、lottie 等需要 Pro。不確定 1.0.11 實際調整後的清單。",
|
|
16
|
+
"url-capable-types": "猜測:只有 link(連結區塊)與 button 的 url 會輸出 <a href>;把 url 放在 image 或 text 上會被忽略,前台不會產生連結(不報錯)。",
|
|
17
|
+
"section-default-padding": "猜測:上下各約 80px(也可能是 64px)內距。為猜測。",
|
|
18
|
+
"unsafe-type-count": "不知道;猜測約 5 個。",
|
|
19
|
+
"modal-open-1010": "改用 Popover API 後元素不再是 <dialog> 的 modal 開啟狀態,dialog.open 不能可靠判斷;應該用 element.matches(':popover-open') 判斷是否開啟。",
|
|
20
|
+
"custom-declarations-dvh": "猜測:dvh 單位可能被 Mosaic 的 CSS 解析器視為無效,導致整段 customDeclarations(同一區塊的其他宣告)一起被丟掉、不輸出。為猜測。",
|
|
21
|
+
"accordion-content-bare": "猜測:accordion-content 必須放在 accordion-item(在 accordion 底下,與 accordion-header/trigger 同層)裡;直接放在一般 div 底下會提交失敗或前台不渲染/編輯器顯示壞掉。",
|
|
22
|
+
"local-loop-source": "猜測:loopSource 應寫成指向本地資料的路徑或陣列(例如 {\"type\":\"local\",\"items\":[...]} 或直接是資料陣列的 JSON),@LOOP() 是在 loop 內讀取目前項目欄位用的動態變數,不是用來指定資料來源,所以放在 loopSource 會解析不出資料。為猜測。",
|
|
23
|
+
"button-text-editable": "猜測:按鈕文字要放在 button 底下的一個 text(文字)子節點裡,而不是寫在 button 的屬性(label)上,客戶才能在編輯器雙擊直接編輯。",
|
|
24
|
+
"no-template-status": "不確定,猜測:Mosaic 找不到對應範本時會退回佈景主題(或 WordPress 預設)的版型輸出,訪客多半拿到 HTTP 200 加上一般的佈景主題頁面;若網址本身不存在則是 WordPress 的 404。我沒有實測過,無法確定 Mosaic 是否會回傳空白頁或特定狀態碼。",
|
|
25
|
+
"unprobed-node-props": "不知道。這是 mosaic-headless skill 內部的實測資料,憑記憶無法得知是哪兩個 property 名稱尚未探測;猜測可能是較少用的屬性(例如與無障礙或 SEO 相關的 property),但這只是猜的。",
|
|
26
|
+
"image-attachment-path": "猜測:wp-attachment:// 後面的路徑應該相對於 WordPress 的上傳目錄(wp-content/uploads),例如 wp-attachment://2026/11/photo.jpg。如果寫成完整的 wp-content/uploads/... 會變成重複路徑(uploads/wp-content/uploads/...),圖片找不到、前台顯示破圖或空白。不確定,未實測。",
|
|
27
|
+
"variant-delete": "猜測:送 status:\"delete\" 可能不會真的刪除(被忽略、或只是標記,或 REST 驗證失敗回錯誤),variant 仍存在。正確做法推測是呼叫對應 REST 路由的 DELETE 方法(或把 status 設為 trash/從 variants 清單中移除後整份存回),並確認引用該 variant 的節點改掉。不確定,未實測。",
|
|
28
|
+
"class-name-grammar": "(以下為猜測,沒有實測根據)Mosaic 自訂 class 名稱大致要符合 CSS class 規則:小寫英數字、連字號、底線,不能用數字開頭。每一段長度上限我猜是 64 個字元。保留的前綴我猜是 `mosaic-`(或簡寫 `mo-`),因為那是外掛內建 class 用的命名空間,使用者不能拿來用。名稱撞到時,我猜編輯器會擋下來、顯示「名稱已存在」之類的錯誤,不讓你建立重複的 class;也可能自動在後面加數字後綴(例如 -2)來區分。這三點都不確定。"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{"meta": {"date": "2026-11-16", "model": "claude-opus-5-5", "how": "subagent 讀 SKILL.md、用 mo.py 與 references 查"},
|
|
2
|
+
"answers": {
|
|
3
|
+
"select-split-1012": "1.0.12 的結構:select > select-toggle(內含 select-placeholder 與 icon 箭頭)+ select-options > select-option。select-option 的標籤改成子節點(text > wysiwyg-text),不再用 text 屬性;值放在 value。舊的 select-input 已不存在(mo.py type select-input 回 no such node type)。原生下拉改用 listbox > listbox-option(多選或 size>1 時,data upgrade 會轉成這個)。前台輸出 <mosaic-select class=m-select> 加一個隱藏的 <input class=m-select-input>。來源:mo.py type select / select-toggle / select-options / select-option、references/upgrading.md(Select split)、failure-modes.md。",
|
|
4
|
+
"scrolldepth-slot-1010": "1.0.10 起 scrollDepth 宣告兩個 slot:reached(捲到門檻)與 returned(捲回門檻以上)。動作要寫在 actionSlots.reached。如果還放在舊的 slot 名稱 scrollDepth 底下,資料會被存下來,但因為該 type 已經不宣告這個 key,不會匯出,動作永遠不會執行,而且沒有任何錯誤。data upgrade 會把舊資料(含 completedAfter: scrollDepth)搬到 reached;interactionShorthand 寫法不受影響。來源:references/dialog-and-triggers.md、facts.md、upgrading.md。",
|
|
5
|
+
"popover-trigger-slots": "popover 觸發器(Popover visibility change,Element events 群組)有三個 slot:show、beforeClose(原生隱藏會等它跑完)、afterClose(popover 已經隱藏之後)。三步驟導覽的下一步要掛在目前這一步自己的 afterClose(在 afterClose 裡執行 popoverOpen 下一步)。不能在第一步內的「下一步」按鈕直接開下一步:從 dialog 裡打開的 dialog 會變成它的子層,父層關閉時會一起被關掉;關閉 popover 也會暫停它裡面所有元素的 interactions。「下一步」按鈕只負責關閉自己這一步。來源:mo.py interactions、references/dialog-and-triggers.md、facts.md。",
|
|
6
|
+
"popover-flipped-state": "用 style state ___popover--flipped(mo.py states --grep flip:scope node-type、host popover、swept COMPILED,selector 是 .m-popover[data-mosaic-popover-flipped])。來源:mo.py states --grep flip、facts.md。",
|
|
7
|
+
"shorthand-interaction-types": "只有三種:pageLoad、exitIntent、scrollDepth(來源碼 InteractionTypesManager::getShorthandInteractionTypes())。這三種都不需要元素先可見、可互動,而 modal 在打開前是 display:none。用其他種(例如 elementScrollIntoView)會被無聲丟棄:modal 的 aria 屬性照常輸出,但頁面的 mosaicInteractions 沒有它,modal 永遠不會打開。「不要自動打開」要寫 type: manual。另外 shorthand 不能帶 conditions。來源:references/dialog-and-triggers.md、facts.md。",
|
|
8
|
+
"interaction-value-shape": "initial 和 keyframe 的 properties 要用屬性 META 的 uuid 當 key,不能用屬性名稱(例如 opacity)。值要寫成帶單位的 CSS 字串,例如 「0%」「40px」「0px」,不能寫數字。timed 觸發器的 keyframe 用 duration / delay(毫秒);只有 progress 類(scrollIntoView、pointerMove)用 progressData 0-100。用數字或用屬性名稱當 key,存下來的都是零值。建議用 tools/interactions.py 產生,不要手寫。來源:references/interactions.md、mo.py interactions。",
|
|
9
|
+
"wysiwyg-text-escape-1011": "1.0.11 起 wysiwyg-text 會跳脫 < 和 >,前台會直接顯示文字 A<strong>B</strong>(HTML 是 A<strong>B</strong>),不會變成粗體。正確做法是用節點:粗體在 wysiwyg-text 設 format: [bold](輸出 <strong>;斜體是 [italic]),或用 wysiwyg-span(<span class=m-span>,再加樣式);換行用 wysiwyg-linebreak(<br>);行內連結用帶 url 的 wysiwyg-link。每個節點底下都放自己的 wysiwyg-text。bold 和 italic 同時設在 1.0.11 會巢狀錯誤,inline_html.py 改成用有樣式的 wysiwyg-span。舊站可以用 scan_inline_tags.py / fix_inline_tags.py 修正。來源:references/facts.md、upgrading.md。",
|
|
10
|
+
"pro-only-types-1011": "1.0.11 之後需要 Pro 的只剩 5 個:code、modal、modal-overlay、modal-window、popover。表單系統、slider、tabs 共 49 個 type 移到 Free。來源:mo.py types --edition pro、references/upgrading.md。",
|
|
11
|
+
"url-capable-types": "只有四種:button、menu-link、wysiwyg-link、dropdown-toggle。url 放在 text 或 image 上會被接受、也會存下來,但完全不會輸出 <a>。要讓其他東西可點,要用 button 包起來,style.variant 設成 Link variant(m-link),帶 url 就會輸出 <a class=m-link href>;這就是編輯器「Wrap in link」寫入的結構。來源:references/facts.md。",
|
|
12
|
+
"section-default-padding": "上下各 80px(實測:spec 沒設 padding 的 section,前台量到 top / bottom 各 80px,夾在兩個區塊之間就會多出 160px 空白)。要明確設定 paddingTop / paddingBottom。來源:references/facts.md、responsive.md。",
|
|
13
|
+
"unsafe-type-count": "27 個(BROKE_PAGE 12 + COMMIT_500 14 + COMMIT_502 1):accordion-content、accordion-item、accordion-title、checkbox-input、component-instance、document、form-multi-steps-steps、loop、loop-items、loop-pagination、loop-pagination-button-next、loop-pagination-button-previous、loop-pagination-number、loop-pagination-numbers、multi-steps-form-step、multi-steps-forms、radio-input、slider、slider-navigation、slider-navigation-bullet、slider-slide、slider-slides、tabs-content、tabs-loop-tabs、tabs-menu、tabs-tab、wysiwyg-variable。來源:mo.py stats、mo.py types --unsafe。",
|
|
14
|
+
"modal-open-1010": "1.0.10 的 modal 是 <dialog popover=manual>,用 showPopover() 打開,會進入 top layer。dialog.open 不能用,它永遠是 false,拿它判斷的話每個 modal 都會被當成關著。要用 el.matches(':popover-open') 判斷,或讀 data-mosaic-dialog-state=open。要從程式關閉,用 el.mosaicDialog.requestClose()(回傳 Promise);close() 已經不存在。來源:references/dialog-and-triggers.md、facts.md。",
|
|
15
|
+
"custom-declarations-dvh": "整個 customDeclarations 區塊都會被無聲丟棄。驗證器會解析每一條宣告,只要一個值不合格就丟掉整塊,而 dvh(還有 svh、lvh、dvw、容器單位)不在 ValidatorCustomDeclarations 的單位清單裡,!important 也一樣會失敗。要用 dvh 的話,改用結構化的 height / maxHeight 欄位,它們接受 dvh。來源:references/facts.md、styling.md。",
|
|
16
|
+
"accordion-content-bare": "會 BROKE_PAGE:提交成功,但整個公開頁面變成一行錯誤字串(AccordionItemElementMResource instance required)。mo.py 判定為 UNSAFE - DO NOT COMMIT。它要放在 accordion-item 底下(accordion-title 與 accordion-content 是 accordion-item 透過 heal() 帶進來的子節點),accordion-item 再放在 accordion 裡。來源:mo.py type accordion-content。",
|
|
17
|
+
"local-loop-source": "loopType: localContext 的 loopSource 要寫成 {\"v\": \"@VAR('post/<loop名稱>')\"},例如 @VAR('post/loopacf_rel')。不能用 @LOOP():loop evaluator 只執行它拿到的函式呼叫,不看函式名稱;@VAR 會解析出 loop,@LOOP 則會呼叫 null。前台兩種都能顯示,但 @LOOP 在編輯器會丟出 _loopEvaluatorFunction is not a function,畫布永遠載入不完,build_page.py 也會拒絕。@LOOP(…) 放在文字裡面沒問題。來源:references/facts.md、custom-fields.md、failure-modes.md。",
|
|
18
|
+
"button-text-editable": "要用編輯器原生的結構 button > text(Inherited text variant,6381b2f3…)> wysiwyg-text。如果把 wysiwyg-text 直接放在 button 底下,前台看起來一樣,但在編輯器裡 navigator 看不到子節點,雙擊只會打開連結設定,沒辦法編輯文字。build_page.py 會自動包好(wrap_text_runs),所以 spec 用 「text」 簡寫就安全;舊站可以用 tools/fix_text_runs.py 修正。menu-link、dropdown-toggle、tabs、submit 的標籤也一樣。來源:references/facts.md、SKILL.md 的五個常見錯誤。"
|
|
19
|
+
}}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{"meta": {"date": "2026-11-16", "model": "claude-opus-5-5", "how": "subagent 不用任何工具,憑記憶作答"},
|
|
2
|
+
"answers": {
|
|
3
|
+
"select-split-1012": "猜測:改成父容器 select(或 form-select)底下放多個 option(select-option)子節點,由使用者自己組選項;舊的單一 type「select-field」(選項寫在屬性陣列裡的那種)已移除。實際 type 名稱我不確定,這是猜的。",
|
|
4
|
+
"scrolldepth-slot-1010": "猜測:動作改放在「onReach」(或 reached)slot 底下;舊的 slot 名稱(推測是 actions / onScroll)不會再被讀取,觸發器不報錯但動作不會執行。名稱為猜測。",
|
|
5
|
+
"popover-trigger-slots": "猜測:三個 slot 是 onOpen(開啟時)、onClose(關閉時)、onToggle;做三步驟導覽時,下一步應掛在 onClose(第一步關閉後再開第二個 popover)。名稱為猜測。",
|
|
6
|
+
"popover-flipped-state": "猜測:用 style state「flipped」(例如 :flipped/state id 'flipped')來設定翻轉後的樣式。不確定確切 ID。",
|
|
7
|
+
"shorthand-interaction-types": "猜測:只有 click、hover、pageLoad(載入)這類簡單觸發可以當 shorthand;其他種(如 scroll、exitIntent)用 shorthand 會被忽略或驗證失敗,需改用完整的 interaction 物件。為猜測。",
|
|
8
|
+
"interaction-value-shape": "猜測:initial 與 properties 的 key 用 CSS 屬性名稱(如 opacity、transform、translateY),值寫成數字(例如 opacity: 0、translateY: 20)。不確定。",
|
|
9
|
+
"wysiwyg-text-escape-1011": "猜測:1.0.11 會把 HTML 跳脫,前台會直接顯示字面文字「A<strong>B</strong>」。要做行內粗體或換行,應該用富文字結構(例如 text 子節點的 marks/格式陣列,或段落內的 inline 節點),換行用 line break 節點,而不是寫原始 HTML 字串。具體結構不確定。",
|
|
10
|
+
"pro-only-types-1011": "猜測:popover、modal、tabs、accordion、slider/carousel、form 相關(form、input、select)、map、loop/query-loop、lottie 等需要 Pro。不確定 1.0.11 實際調整後的清單。",
|
|
11
|
+
"url-capable-types": "猜測:只有 link(連結區塊)與 button 的 url 會輸出 <a href>;把 url 放在 image 或 text 上會被忽略,前台不會產生連結(不報錯)。",
|
|
12
|
+
"section-default-padding": "猜測:上下各約 80px(也可能是 64px)內距。為猜測。",
|
|
13
|
+
"unsafe-type-count": "不知道;猜測約 5 個。",
|
|
14
|
+
"modal-open-1010": "改用 Popover API 後元素不再是 <dialog> 的 modal 開啟狀態,dialog.open 不能可靠判斷;應該用 element.matches(':popover-open') 判斷是否開啟。",
|
|
15
|
+
"custom-declarations-dvh": "猜測:dvh 單位可能被 Mosaic 的 CSS 解析器視為無效,導致整段 customDeclarations(同一區塊的其他宣告)一起被丟掉、不輸出。為猜測。",
|
|
16
|
+
"accordion-content-bare": "猜測:accordion-content 必須放在 accordion-item(在 accordion 底下,與 accordion-header/trigger 同層)裡;直接放在一般 div 底下會提交失敗或前台不渲染/編輯器顯示壞掉。",
|
|
17
|
+
"local-loop-source": "猜測:loopSource 應寫成指向本地資料的路徑或陣列(例如 {\"type\":\"local\",\"items\":[...]} 或直接是資料陣列的 JSON),@LOOP() 是在 loop 內讀取目前項目欄位用的動態變數,不是用來指定資料來源,所以放在 loopSource 會解析不出資料。為猜測。",
|
|
18
|
+
"button-text-editable": "猜測:按鈕文字要放在 button 底下的一個 text(文字)子節點裡,而不是寫在 button 的屬性(label)上,客戶才能在編輯器雙擊直接編輯。"
|
|
19
|
+
}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {"date": "2026-11-16", "model": "claude-opus-5-5", "how": "subagent 讀 SKILL.md、用 mo.py 與 references 查"},
|
|
3
|
+
"answers": {
|
|
4
|
+
"no-template-status": "HTTP 406。406 是 Mosaic 的「沒有範本對應」:FrontendRenderer 接到 TemplateNotFoundException 時呼叫 status_header(406),說明文字只印給管理員看,所以未登入訪客拿到的是一個空白頁加上 406 狀態碼,看起來像伺服器出問題。最常踩到的情況:剛 wp theme activate 一個新佈景、還沒建好範本(或建置失敗)時,整站都會是 406。所以驗證要用登出狀態讀頁面。(來源:`mo.py facts visitor` → references/core-rules.md「406 is Mosaic's \"no template matched\"」)",
|
|
5
|
+
"unprobed-node-props": "`ariaLive` 和 `positioning`。這兩個都只宣告在 `popover` 上,`mo.py prop` 查出來的 verified 都是「not probed」(ariaLive 的值是 off / polite / assertive)。`mo.py stats` 也列出:191 筆探測紀錄涵蓋了 120 個宣告名稱中的 118 個。(來源:SKILL.md Sources 表、`mo.py stats`、`mo.py prop ariaLive`、`mo.py prop positioning`)",
|
|
6
|
+
"variant-delete": "Variant 不能刪除,只能清空。對 variant 送 `status:\"delete\"`,伺服器會接受但直接忽略,因為 variant 那一列有 catalog 撐著。正確做法是把那一列 commit 回去,內容設成 `{\"states\": {\"&\": {\"_\": {}}}}`,這樣它的 CSS 規則就會消失(在 Heading 2 上實測過)。對照組:universal class 沒有 catalog 撐著,用 `status:\"delete\"` 就真的會刪掉。ID 要用 `name` 去 data/variants.csv 查(用 `mo.py classes --grep Heading`)。(來源:`mo.py facts status` → references/facts.md、references/design-system.md)",
|
|
7
|
+
"class-name-grammar": "每一段最多 60 個字元。名稱會被整理成 `[a-z0-9_-]` 的段落,段落之間用 `--` 串起來(例如 `m-button--primary--sm`)。保留前綴是 `m-`;段落也不能以 `_` 或數字開頭(`m-` 會被拿掉)。名稱撞到時,系統會自動在後面加 `-2`、`-3` 去重複;emitted name 在同一個佈景內是唯一的(四張表的 `emittedName` 欄位有 unique index),所以兩個 class 不可能是同一個拼法。整理完變成空字串的名稱,會退回成 `class`。整理規則還包括:轉寫成拉丁字母、轉小寫、連續的 `-` 合併,尺寸級距也會統一(`s`→`sm`、`m`→`md`、`l`→`lg`、`xxs`→`2xs`)。(來源:`mo.py facts reserved` → references/facts.md「User class names have a grammar」、references/upgrading.md ClassNameHelper 段落、references/design-system.md)"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"meta": {"date": "2026-11-16", "model": "claude-opus-5-5", "how": "subagent 不用任何工具,憑記憶作答"},
|
|
3
|
+
"answers": {
|
|
4
|
+
"no-template-status": "不確定,猜測:Mosaic 找不到對應範本時會退回佈景主題(或 WordPress 預設)的版型輸出,訪客多半拿到 HTTP 200 加上一般的佈景主題頁面;若網址本身不存在則是 WordPress 的 404。我沒有實測過,無法確定 Mosaic 是否會回傳空白頁或特定狀態碼。",
|
|
5
|
+
"unprobed-node-props": "不知道。這是 mosaic-headless skill 內部的實測資料,憑記憶無法得知是哪兩個 property 名稱尚未探測;猜測可能是較少用的屬性(例如與無障礙或 SEO 相關的 property),但這只是猜的。",
|
|
6
|
+
"image-attachment-path": "猜測:wp-attachment:// 後面的路徑應該相對於 WordPress 的上傳目錄(wp-content/uploads),例如 wp-attachment://2026/11/photo.jpg。如果寫成完整的 wp-content/uploads/... 會變成重複路徑(uploads/wp-content/uploads/...),圖片找不到、前台顯示破圖或空白。不確定,未實測。",
|
|
7
|
+
"variant-delete": "猜測:送 status:\"delete\" 可能不會真的刪除(被忽略、或只是標記,或 REST 驗證失敗回錯誤),variant 仍存在。正確做法推測是呼叫對應 REST 路由的 DELETE 方法(或把 status 設為 trash/從 variants 清單中移除後整份存回),並確認引用該 variant 的節點改掉。不確定,未實測。"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"meta": {"date": "2026-11-16", "model": "claude-opus-5-5", "how": "subagent 不用任何工具,憑記憶作答"}, "answers": {"class-name-grammar": "(以下為猜測,沒有實測根據)Mosaic 自訂 class 名稱大致要符合 CSS class 規則:小寫英數字、連字號、底線,不能用數字開頭。每一段長度上限我猜是 64 個字元。保留的前綴我猜是 `mosaic-`(或簡寫 `mo-`),因為那是外掛內建 class 用的命名空間,使用者不能拿來用。名稱撞到時,我猜編輯器會擋下來、顯示「名稱已存在」之類的錯誤,不讓你建立重複的 class;也可能自動在後面加數字後綴(例如 -2)來區分。這三點都不確定。"}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mosaic-headless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.37.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",
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Building pages, sites and themes
|
|
2
|
+
|
|
3
|
+
Moved out of SKILL.md on 2026-11-16 (skill SOP pass).
|
|
4
|
+
|
|
5
|
+
## Building a page
|
|
6
|
+
|
|
7
|
+
`tools/build_page.py` consumes a declarative spec and commits it through the verified
|
|
8
|
+
write path, refusing anything the tables say is unsafe. `tools/build_site.py` does the
|
|
9
|
+
same for a whole site: one master carrying the header and footer, one template document
|
|
10
|
+
per page.
|
|
11
|
+
|
|
12
|
+
The example page is deliberately varied rather than uniform: seven numbered clauses
|
|
13
|
+
in one rhythm, and then the things a document has that are NOT clauses - an
|
|
14
|
+
unnumbered plate, a capability table read as a grid, a figure drawn in hairline
|
|
15
|
+
boxes, a type specimen inverted onto the ink ground. The page changes ground five
|
|
16
|
+
times. A builder that can only produce one section shape has not been exercised.
|
|
17
|
+
|
|
18
|
+
**`sites/_moksa.py` is the worked example** - a real studio homepage (hero, statistics,
|
|
19
|
+
services, a nine-item work list, products, testimonials, CTA, footer) generated as a
|
|
20
|
+
spec and committed entirely through the tables. Read it for the shape of a real build:
|
|
21
|
+
the `bp()` breakpoint helper, the `code` node that carries the keyframes, the glass
|
|
22
|
+
header, and `apply_type()`.
|
|
23
|
+
|
|
24
|
+
A spec can carry a `theme` block, which is how a real site should be styled — design
|
|
25
|
+
tokens and element-class typography rather than per-node values:
|
|
26
|
+
|
|
27
|
+
```jsonc
|
|
28
|
+
"theme": {
|
|
29
|
+
"variables": {"--brand": {"type": "color", "value": "rgb(13,108,102)"}},
|
|
30
|
+
"variants": {"Heading 1": {"&": {"_": {"color": {"token": "--brand"}}}}}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`{"token": "--brand"}` anywhere in a style resolves to the `{"var": "<uuid>"}`
|
|
35
|
+
reference the compiler wants.
|
|
36
|
+
|
|
37
|
+
**Two brands in one theme need namespaced tokens and no variants at all.**
|
|
38
|
+
Collection variables and variants are both theme-global: two specs that each
|
|
39
|
+
declare `--ink` produce one `:root` with duplicate declarations, and two specs that
|
|
40
|
+
each style `Heading 1` produce one set of rules. Whichever committed last wins, for
|
|
41
|
+
every page. `sites/_moksa.py` namespaces its tokens (`--mk-*`) and bakes the type
|
|
42
|
+
system onto the nodes with `apply_type()` instead of using variants, which is
|
|
43
|
+
what lets it share an install with a completely different design.
|
|
44
|
+
|
|
45
|
+
Whole themes move between installs with `theme_export.php` / `theme_import.php`.
|
|
46
|
+
A theme is a themeID scattered across nineteen tables, and every one of them has a
|
|
47
|
+
COMPOSITE primary key of `(themeID, ID)` — so an import can keep every internal id
|
|
48
|
+
and rewrite nothing but the theme, which means no id remapping and nothing left
|
|
49
|
+
dangling. Round-tripped and verified: a full theme exported, re-imported as a copy,
|
|
50
|
+
and the copy served byte-identical pages.
|
|
51
|
+
|
|
52
|
+
Mosaic also has its own: `POST /theme/<id>/export` and `POST /theme/import/upload`
|
|
53
|
+
(or `/import/download` from a URL), plus `/duplicate` on themes, masters, templates,
|
|
54
|
+
components and style guides. The native export is a ZIP with the theme's
|
|
55
|
+
attachments inside, produced by a chunked, lock-protected milestone flow — you POST
|
|
56
|
+
repeatedly with `milestoneID` to step it through collect → compress → download — and
|
|
57
|
+
it is gated on admin capability only, not on a licence. It moves a whole theme, never
|
|
58
|
+
a single page. `tools/theme_zip.py` drives both directions from outside the editor.
|
|
59
|
+
Two things about the import that the route list does not tell you: with no
|
|
60
|
+
`themeActivateMode` it defaults to `live` and switches every visitor to the imported
|
|
61
|
+
theme (the tool sends `test` unless `--activate`). Test mode is per USER, not per
|
|
62
|
+
admin role: it is user meta `mosaic_<blogID>_test_mode_theme`, so the account whose
|
|
63
|
+
cookie made the import sees the imported theme on every later fetch while visitors
|
|
64
|
+
keep the live one - read a page logged out to see what visitors see; and a
|
|
65
|
+
milestone must be called until it answers `isCompleted:true` - stop one call early,
|
|
66
|
+
as the first version of the tool did after its last upload chunk, and that
|
|
67
|
+
milestone's batch bookkeeping is left in the lock for the NEXT milestone to read as
|
|
68
|
+
its own, which is how `extract` came to skip creating its directories and fail on
|
|
69
|
+
the first nested file with "Could not copy file".
|
|
70
|
+
|
|
71
|
+
Round-tripped and measured (`data/theme-zip-verification.csv`, 22 checks): export,
|
|
72
|
+
import in test mode, compare. Every scoped table equal; 68,337 of 68,337 nodes
|
|
73
|
+
outside overrides keep their ids; the 1,024 override nodes are re-keyed, with their
|
|
74
|
+
`originalID` re-pointed at the re-keyed component internals; the live theme
|
|
75
|
+
untouched. The node table came back one row short, and that row is the difference
|
|
76
|
+
between the two tools in one line: an orphan `div` with no parent, left by an
|
|
77
|
+
interrupted build, which a tree-walking import correctly does not carry and a
|
|
78
|
+
row-copying one (`theme_import.php`) would. `theme_export.php` exists because a
|
|
79
|
+
2 MB JSON of rows is easier to diff, version and reason about than a ZIP, and
|
|
80
|
+
because it needs nothing but WP-CLI; the ZIP is what the editor's buttons speak.
|
|
81
|
+
|
|
82
|
+
`copy_styles.py` pushes one node's style onto others by attrID or prefix, optionally
|
|
83
|
+
only certain `state.breakpoint` slices, and shows the diff before writing.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
wp eval-file tools/bootstrap_probe_theme.php # licence-free scratch theme
|
|
87
|
+
python tools/build_all.py --config sweep.json # reset + build every design
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Rebuilding a single page without a reset leaves an orphan template bound to the same
|
|
91
|
+
post — `build_all.py` resets first for that reason. `build_site.py` re-binds the post
|
|
92
|
+
to a fresh master and template and leaves the old pair bound to nothing; clear them
|
|
93
|
+
with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Core rules: look it up, check the page, build native
|
|
2
|
+
|
|
3
|
+
Moved out of SKILL.md on 2026-11-16 (skill SOP pass). SKILL.md keeps the routing; the reasoning and the failure-mode table live here.
|
|
4
|
+
|
|
5
|
+
## The one rule that overrides everything
|
|
6
|
+
|
|
7
|
+
**Never write a node type, property name, enum value, style key or Free/Pro claim
|
|
8
|
+
from memory. Look it up in `data/`.**
|
|
9
|
+
|
|
10
|
+
And look it up with `mo.py`, not with grep. Grep answers the question you typed;
|
|
11
|
+
it does not answer the question you have. Ask grep about `accordion-content` and it
|
|
12
|
+
confirms the type exists. The sweep table says BROKE_PAGE: place one and the entire
|
|
13
|
+
public page becomes a 54-byte error string. Both are true, and both are the wrong
|
|
14
|
+
answer - the note beside the row says the string is `AccordionItemElementMResource
|
|
15
|
+
instance required`, that this is a type committed without the parent its factory
|
|
16
|
+
needs, and that nested under `accordion > accordion-item` it commits, renders and
|
|
17
|
+
gives you a keyboard-operable disclosure for free. `mo.py type` shows all three in
|
|
18
|
+
one answer. Grep shows one, the CSV shows two, and the skill was itself wrong about
|
|
19
|
+
this type for a week.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
python tools/mo.py stats # the surface, and what is unsafe
|
|
23
|
+
python tools/mo.py type accordion-content # ONE type, joined to every sweep
|
|
24
|
+
python tools/mo.py params text # EVERYTHING settable on a type:
|
|
25
|
+
# data properties, the states that
|
|
26
|
+
# reach it, the style surface, placement
|
|
27
|
+
python tools/mo.py types --edition pro --safe
|
|
28
|
+
python tools/mo.py check div text button # exits 1 on an unsafe or unknown type
|
|
29
|
+
python tools/mo.py placement accordion-item # what goes inside what, both directions
|
|
30
|
+
python tools/mo.py prop tagName # one node property + how it was probed
|
|
31
|
+
python tools/mo.py props --shared # the ones every element carries
|
|
32
|
+
python tools/mo.py style --grouped # the 20 that are inert set on their own
|
|
33
|
+
python tools/mo.py css border-radius # which Mosaic key drives this CSS
|
|
34
|
+
python tools/mo.py states --grep hover # state IDs and their selector templates
|
|
35
|
+
python tools/mo.py states --verified # only the ones measured to compile
|
|
36
|
+
python tools/mo.py vars --namespace post # the @VAR() surface
|
|
37
|
+
python tools/mo.py classes --grep Heading # variants: the theme-global element classes
|
|
38
|
+
python tools/mo.py routes --grep template
|
|
39
|
+
python tools/mo.py tables wp_mosaic_nodes
|
|
40
|
+
python tools/mo.py skeleton # a minimal valid page spec
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`--json` on any of them for machine-readable output. Every answer leads with the
|
|
44
|
+
measured verdict rather than the declaration, because on this platform the two
|
|
45
|
+
disagree for 52 of the 122 types they were first counted on.
|
|
46
|
+
|
|
47
|
+
Then check the page. Mosaic has eight failure modes and **only three of them change the
|
|
48
|
+
HTTP status code**:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
clean validator rejection HTTP 200 + an `exceptions` array in the body
|
|
52
|
+
PHP fatal during commit HTTP 500 (15 of 129 types do this from a plain div)
|
|
53
|
+
structurally invalid node HTTP 200, committed, row in the DB, and the whole
|
|
54
|
+
public page becomes a 54-byte error string
|
|
55
|
+
wrong value SHAPE HTTP 200, stored, and the CSS rule is simply absent -
|
|
56
|
+
or worse, compiles to `transform:none`
|
|
57
|
+
right rule, wrong result HTTP 200, in the stylesheet, correct, and the BROWSER
|
|
58
|
+
computes something else: a unit that resolves against
|
|
59
|
+
something you forgot, a font that cannot render the
|
|
60
|
+
text, a property the layout mode overrides
|
|
61
|
+
no template for the URL HTTP 406 with an EMPTY BODY for anyone not logged in
|
|
62
|
+
render-time fatal from HTTP 500 - the commit went through and the page dies
|
|
63
|
+
CONTENT when Mosaic parses it. A `code` node's content is a
|
|
64
|
+
template: `@media(` (as every minifier writes it) is
|
|
65
|
+
read as a function call and kills the whole page.
|
|
66
|
+
`@media (` renders. build_page refuses the former.
|
|
67
|
+
plugin upgrade renamed HTTP 200, page intact, rows migrated - and a selector
|
|
68
|
+
what the page emits you wrote against an emitted class matches nothing.
|
|
69
|
+
1.0.8: `M_EL4 M_EL_Div` -> `m-div _e`, the state
|
|
70
|
+
classes with them, `customStyles` -> `customDeclarations`.
|
|
71
|
+
The worked example's tap-to-enlarge stopped opening
|
|
72
|
+
and only `verify_loop.py` OPENS said so.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
That last one also fooled every checker here for a day: WordPress answers a fatal
|
|
76
|
+
with a 2,697-byte error document, which is larger than the 2,000-byte "healthy"
|
|
77
|
+
floor, and `Client.page()` returned that body as if it were the page - so
|
|
78
|
+
`build_site` printed `OK 2645 bytes` over an HTTP 500. A 5xx now reads as an
|
|
79
|
+
empty page, which is what it is.
|
|
80
|
+
|
|
81
|
+
**406 is Mosaic's "no template matched".** `FrontendRenderer` answers
|
|
82
|
+
`TemplateNotFoundException` with `status_header(406)` and prints the explanation
|
|
83
|
+
only for an admin, so a logged-out visitor gets a blank page and a status code
|
|
84
|
+
that looks like a server problem. Two things make it easy to hit:
|
|
85
|
+
|
|
86
|
+
- **There are TWO ways to bind a template, and `createManualTemplate` is only one
|
|
87
|
+
of them.** That endpoint takes `resourceQuery=post/<id>` and `post` is the only
|
|
88
|
+
resource type it registers (`setResourceType('post')`, three call sites), so
|
|
89
|
+
through it there is no catch-all. But `assign` and `path` are first-class columns
|
|
90
|
+
on `wp_mosaic_templates`, and a template row committed with `assign:"auto"` and
|
|
91
|
+
`path:"index.php"` binds to a template PATH instead of a post. Measured A/B on a
|
|
92
|
+
URL with no template of its own: 406 with no such row, handled with it, 406 again
|
|
93
|
+
after deleting it. `X-Mosaic-Paths` on any 406 names the paths Mosaic looked for,
|
|
94
|
+
and `index.php` is in every list.
|
|
95
|
+
|
|
96
|
+
This `index.php` row is the editor's **Fallback → Empty** template: priority
|
|
97
|
+
`PHP_INT_MAX`, matching every request (`Plugins/Paths/PathIndex.php`). Since 1.0.10
|
|
98
|
+
an auto template is an ordinary writable one - it is listed by
|
|
99
|
+
`adminTemplateEditorInstance` and its document carries a `template-internal`
|
|
100
|
+
root, so content goes in like any page's (the commit shape is in
|
|
101
|
+
`references/templates-and-conditions.md`). Before 1.0.10 both were missing and a
|
|
102
|
+
direct commit answered HTTP 500.
|
|
103
|
+
|
|
104
|
+
For `/` specifically the WordPress-side fix is the sound one: point the front page
|
|
105
|
+
at a post that has a template (`show_on_front=page`, `page_on_front=<id>`).
|
|
106
|
+
- **Activating a theme is not the same as populating it.** A fresh theme has no
|
|
107
|
+
templates, so between `wp theme activate` and a successful build the whole site
|
|
108
|
+
is 406 - and if the build fails, it stays that way. Never activate a new theme
|
|
109
|
+
as a step that can be separated from the commit that fills it.
|
|
110
|
+
|
|
111
|
+
A successful commit is not evidence of a working page, and neither is a correct
|
|
112
|
+
stylesheet. Fetch the page and check its size; then run `verify_browser.py` and let
|
|
113
|
+
the element say what it actually got. `references/failure-modes.md` has all of them,
|
|
114
|
+
measured.
|
|
115
|
+
|
|
116
|
+
## Native first: what the client can open in the editor
|
|
117
|
+
|
|
118
|
+
The second rule, and the one an agent breaks most often: **build with Mosaic's own
|
|
119
|
+
features, not with code.** A `code` node, a `script` action, or a pile of
|
|
120
|
+
`customDeclarations` renders fine and is a dead end for the client - the editor
|
|
121
|
+
shows a box of text they cannot change, the Navigator shows nothing of its
|
|
122
|
+
structure, and the next agent has to reverse-engineer it. Mosaic's tutorials build
|
|
123
|
+
every one of the effects below with no custom code; this skill can now write all of
|
|
124
|
+
them headlessly, measured.
|
|
125
|
+
|
|
126
|
+
| the job | the native way | how, headlessly |
|
|
127
|
+
|---|---|---|
|
|
128
|
+
| dark / light mode, themed sections | a second mode on the colour collection; `collectionModesData` on a band, or the Variable modes action on `document` for the whole site | references/design-system.md (modes), the switcher recipe in references/interactions.md |
|
|
129
|
+
| any animation: reveal, fade, slide, loop, parallax | an interaction (`pageLoad`, `click`, `hover`, `elementScrollIntoView`, `scrollIntoView`...) | `tools/interactions.py`; never `@keyframes` in a code node |
|
|
130
|
+
| the same animation on many elements | a universal class as the interaction's trigger, empty target | `trigger=class_target(...)`, recipe in references/interactions.md |
|
|
131
|
+
| a hover / focus look with no motion sequence | a style state (`hover`, `focus`...) with a `transition` | references/styling.md |
|
|
132
|
+
| a loading screen, a cookie bar | a fixed div + `pageLoad` + `hide_at_end`, `data.hidden: true` so it does not block editing | recipe in references/interactions.md |
|
|
133
|
+
| a block repeated on several pages | a component, one definition, overrides per instance | references/design-system.md (components) |
|
|
134
|
+
| a popup, a drawer, a tour | the `modal` / `popover` nodes and their actions | references/dialog-and-triggers.md |
|
|
135
|
+
| a site menu: desktop hover dropdown + phone drawer | `dropdown` / `dropdown-wide` with `openOn: hover`; a `modal` drawer opened by `modalOpen` (there is no off-canvas node) | references/design-system.md (site menus), `tools/verify_menus.py` |
|
|
136
|
+
| a typeface, site-wide | a `fontFamily` collection variable, `{"var": id}` in styles; Settings: `saveGoogleFontsLocally` on and `fontDisplay: swap` (unset is `block`) | references/styling.md (fonts) - saving Google fonts locally took a CJK page from 68 to 96 on mobile |
|
|
137
|
+
| remembering a visitor's choice | `setCookie`, `remember` / `forget`, cookie conditions | references/interactions.md |
|
|
138
|
+
| text that comes from the post, the user, a field | a dynamic `{"v": "@VAR(...)"}` value | references/dynamic-content.md |
|
|
139
|
+
| a colour, a size used twice | a collection variable | references/design-system.md |
|
|
140
|
+
|
|
141
|
+
Reach for custom code only when no row above fits and `mo.py` finds no node,
|
|
142
|
+
property or action for the job - and then say in the spec, next to the code, which
|
|
143
|
+
native path was checked and why it falls short.
|