webcake-landing-mcp 1.13.6 → 1.14.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.md CHANGED
@@ -102,18 +102,20 @@ Zero install, always the latest version, needs Node.js 18+. **One line** grabs y
102
102
 
103
103
  ```bash
104
104
  # Opens the browser — click Connect, your installed IDEs are configured (prod)
105
- npx -y webcake-landing-mcp install
105
+ npx -y webcake-landing-mcp@latest install
106
106
 
107
107
  # Developers only — step by step: environment, login or JWT, org, IDE(s)
108
- npx -y webcake-landing-mcp install --dev
108
+ npx -y webcake-landing-mcp@latest install --dev
109
109
 
110
110
  # Scripts and CI — every supported IDE, even ones not installed yet
111
- npx -y webcake-landing-mcp install --ide all --jwt <your-jwt>
111
+ npx -y webcake-landing-mcp@latest install --ide all --jwt <your-jwt>
112
112
 
113
113
  # Remove the server from every IDE config
114
- npx -y webcake-landing-mcp uninstall
114
+ npx -y webcake-landing-mcp@latest uninstall
115
115
  ```
116
116
 
117
+ > **Troubleshooting (Claude Desktop):** compare the path(s) printed by `install` with **Settings → Developer → Edit Config**, and fully quit Claude Desktop (tray icon → Quit) before reopening.
118
+
117
119
  **`install` asks nothing.** It connects to production, opens your browser so you can click *Connect*, then adds the server
118
120
  to every AI app it finds on this computer. Your other servers are kept, and any config file it changes is backed up next to
119
121
  the original as `<file>.webcake-landing-backup`. No AI app found? It says so and exits with an error: install one and run it again,
package/README.vi.md CHANGED
@@ -102,18 +102,20 @@ Không cần cài đặt, luôn bản mới nhất, cần Node.js 18+. **Một d
102
102
 
103
103
  ```bash
104
104
  # Mở trình duyệt — bấm Kết nối, các IDE trên máy được cấu hình tự động (prod)
105
- npx -y webcake-landing-mcp install
105
+ npx -y webcake-landing-mcp@latest install
106
106
 
107
107
  # Chỉ dành cho dev — từng bước: môi trường, đăng nhập hoặc JWT, org, IDE
108
- npx -y webcake-landing-mcp install --dev
108
+ npx -y webcake-landing-mcp@latest install --dev
109
109
 
110
110
  # Script và CI — mọi IDE được hỗ trợ, kể cả IDE chưa cài
111
- npx -y webcake-landing-mcp install --ide all --jwt <your-jwt>
111
+ npx -y webcake-landing-mcp@latest install --ide all --jwt <your-jwt>
112
112
 
113
113
  # Gỡ server khỏi mọi cấu hình IDE
114
- npx -y webcake-landing-mcp uninstall
114
+ npx -y webcake-landing-mcp@latest uninstall
115
115
  ```
116
116
 
117
+ > **Xử lý sự cố (Claude Desktop):** so sánh đường dẫn `install` in ra với **Settings → Developer → Edit Config**, và thoát hẳn Claude Desktop (icon khay → Quit) rồi mở lại.
118
+
117
119
  **`install` không hỏi gì cả.** Lệnh kết nối tới production, mở trình duyệt để bạn bấm *Kết nối*, rồi thêm server vào mọi ứng dụng AI
118
120
  tìm thấy trên máy. Các server khác của bạn được giữ nguyên, và file cấu hình nào bị đổi đều có bản sao lưu ngay cạnh, tên
119
121
  `<file>.webcake-landing-backup`. Không tìm thấy ứng dụng AI nào? Lệnh báo rõ và thoát với lỗi: hãy cài một ứng dụng rồi chạy lại, hoặc chỉ định bằng `--ide`.
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "v": "1.14.0",
4
+ "d": "23/11/2026",
5
+ "type": "Added",
6
+ "en": "ingest_html and ingest_url with intent:'clone' now measure a page that is not an absolute-canvas export in a real browser, the same way clone_page…",
7
+ "vi": "ingest_html và ingest_url với intent:'clone' nay đo trang không phải export dạng canvas tuyệt đối bằng một trình duyệt thật, giống cách clone_page…"
8
+ },
9
+ {
10
+ "v": "1.13.7",
11
+ "d": "22/11/2026",
12
+ "type": "Fixed",
13
+ "en": "install now writes the Claude Desktop config to every location Claude may read on Windows (Store/MSIX package containers, Claude-Data,…",
14
+ "vi": "install nay ghi config Claude Desktop vào mọi vị trí Claude có thể đọc trên Windows (container gói Store/MSIX, Claude-Data, %APPDATA%\\Claude) thay…"
15
+ },
2
16
  {
3
17
  "v": "1.13.6",
4
18
  "d": "20/11/2026",
@@ -26,19 +40,5 @@
26
40
  "type": "Fixed",
27
41
  "en": "settings.thumbnail/settings.favicon no longer end up as a 404 sNaN resize URL after an MCP save followed by an editor publish: rehosting now skips…",
28
42
  "vi": "settings.thumbnail/settings.favicon không còn bị thành URL resize sNaN lỗi 404 sau khi lưu qua MCP rồi publish lại từ editor: bước rehost nay bỏ qua…"
29
- },
30
- {
31
- "v": "1.13.2",
32
- "d": "20/11/2026",
33
- "type": "Added",
34
- "en": "A new live-comment element (livestream-style scrolling comment feed above a fake input) is now in the catalog, with full docs in…",
35
- "vi": "Danh mục có thêm element live-comment (luồng bình luận kiểu livestream cuộn lên trên một ô input giả), kèm tài liệu đầy đủ trong…"
36
- },
37
- {
38
- "v": "1.13.1",
39
- "d": "20/11/2026",
40
- "type": "Fixed",
41
- "en": "update_page, patch_page, add_section (legacy fallback path), and completing a cached draft via create_page/patch_page/update_page with a draft_id…",
42
- "vi": "update_page, patch_page, add_section (đường fallback cho backend cũ), và việc hoàn tất một draft đã cache qua create_page/patch_page/update_page với…"
43
43
  }
44
44
  ]
@@ -17,6 +17,7 @@
17
17
  */
18
18
  import { createPageSource } from "./page.js";
19
19
  import { ANIMATABLE_TYPES, ANIMATION_NAMES, CANVAS } from "./vocab.js";
20
+ import { fieldSpec } from "./elements/form.js";
20
21
  const MOBILE_W = CANVAS.mobileWidth;
21
22
  const DESKTOP_W = CANVAS.desktopWidth;
22
23
  // ─── small helpers ────────────────────────────────────────────────────────────
@@ -223,6 +224,11 @@ function mapEvents(ctx, e) {
223
224
  out.push({ id, type: "click", action: "open_link", target: ev.action, targetURL: "_blank" });
224
225
  else if (ev.type === "phone")
225
226
  out.push({ id, type: "click", action: "open_link", target: `tel:${ev.action}` });
227
+ // accordion trigger: the renderer collapses the panel on load (unless showCollapse) and shifts what is below
228
+ else if (ev.type === "collapse")
229
+ out.push({ id, type: "click", action: "collapse", target: idOf(ev.action), ...(ev.show ? { showCollapse: true } : {}) });
230
+ else if (ev.type === "tab")
231
+ out.push({ id, type: "click", action: "change_tab", target: idOf(ev.action), moveTo: "index", tabIndex: ev.index ?? 0 });
226
232
  else
227
233
  ctx.notes.push(`${e.id}: unsupported event type '${ev.type}' skipped`);
228
234
  }
@@ -294,16 +300,6 @@ function applySticky(ctx, node, e) {
294
300
  setBothConfigs(node, cfg);
295
301
  ctx.notes.push(`${e.id}: position:fixed → pinned as a sticky '${pos}' element (was floating ${e.sticky ?? "bottom_right"}).`);
296
302
  }
297
- const FIELD_NAME_MAP = {
298
- name: "full_name",
299
- fullname: "full_name",
300
- full_name: "full_name",
301
- phone: "phone_number",
302
- tel: "phone_number",
303
- phone_number: "phone_number",
304
- email: "email",
305
- address: "address",
306
- };
307
303
  // ─── element conversion ──────────────────────────────────────────────────────
308
304
  function convertChildren(ctx, e, sectionH) {
309
305
  return (e.children ?? []).map((c) => convertElement(ctx, c, sectionH)).filter(Boolean);
@@ -315,6 +311,8 @@ function convertElement(ctx, e, sectionH) {
315
311
  applySticky(ctx, node, e);
316
312
  if (node && (e.hover || e.transition))
317
313
  ctx.css.push(hoverCss(node, e.hover, e.transition));
314
+ if (node && e.keyframes)
315
+ ctx.css.push(keyframesCss(ctx, node, e.keyframes));
318
316
  return node;
319
317
  }
320
318
  const ICON_CDN = /^https:\/\/(cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net|unpkg\.com|fonts\.googleapis\.com|use\.fontawesome\.com|maxcdn\.bootstrapcdn\.com|stackpath\.bootstrapcdn\.com|code\.ionicframework\.com|unicons\.iconscout\.com|cdn\.lineicons\.com|site-assets\.fontawesome\.com)\//;
@@ -353,6 +351,16 @@ function hoverCss(node, hover, transition) {
353
351
  css += `${id}:hover${inner}{${paint.join(";")}}`;
354
352
  return css;
355
353
  }
354
+ /**
355
+ * A source animation the native set cannot express (loop, float, pulse…): the page's own @keyframes
356
+ * (once per name) + the animation on #w-<id>. Raw CSS goes into <style>: nothing that could close it.
357
+ */
358
+ function keyframesCss(ctx, node, kf) {
359
+ if (/[<\\]/.test(kf.css) || /[<>{}\\;]/.test(kf.animation))
360
+ return "";
361
+ const defs = ctx.css.some((c) => c.includes(kf.css)) ? "" : kf.css; // each @keyframes once
362
+ return `${defs}#w-${node.id}{animation:${kf.animation}}`;
363
+ }
356
364
  function convertElementInner(ctx, e, sectionH) {
357
365
  const t = e.type;
358
366
  const style = e.style ?? {};
@@ -416,7 +424,8 @@ function convertElementInner(ctx, e, sectionH) {
416
424
  id: uniqueId(ctx, e.id),
417
425
  type: "image-block",
418
426
  responsive: responsiveOf(ctx, e.box, mapStyles(style, "image-block"), sectionH),
419
- specials: { src: e.src ?? "", imageCompression: true },
427
+ // an svg (incl. a multi-colour inline svg captured as data:image/svg+xml) stays vector
428
+ specials: { src: e.src ?? "", imageCompression: !/^data:image\/svg|\.svg(\?|#|$)/i.test(e.src ?? "") },
420
429
  };
421
430
  if (e.crop) {
422
431
  const crop = {};
@@ -532,23 +541,18 @@ function convertElementInner(ctx, e, sectionH) {
532
541
  node.specials.redirect_url = redirect;
533
542
  node.specials.target_url = "_self";
534
543
  }
535
- // Inputs/buttons must be DIRECT children of the form to submit.
544
+ // Inputs/buttons must be DIRECT children of the form to submit. Each control becomes the field
545
+ // type that renders it (select keeps its options, radio/checkbox their choices, textarea…).
546
+ const taken = new Set();
536
547
  for (const c of e.children ?? []) {
537
548
  if (c.type === "form_item") {
538
- const rawName = c.input?.name ?? `input_${idOf(c.id)}`;
539
- const fieldName = FIELD_NAME_MAP[rawName.toLowerCase()] ?? rawName;
540
- const child = {
549
+ const spec = fieldSpec(c.input ?? {}, taken);
550
+ node.children.push({
541
551
  id: uniqueId(ctx, c.id),
542
- type: "input",
552
+ type: spec.type,
543
553
  responsive: responsiveOf(ctx, c.box, mapStyles(c.style, "rectangle"), sectionH),
544
- specials: {
545
- field_name: fieldName,
546
- field_placeholder: c.input?.placeholder ?? "",
547
- field_type: fieldName === "phone_number" ? "phone" : c.input?.input_type === "email" ? "email" : "text",
548
- ...(c.input?.required ? { required: true } : {}),
549
- },
550
- };
551
- node.children.push(child);
554
+ specials: spec.specials,
555
+ });
552
556
  }
553
557
  else {
554
558
  const conv = convertElement(ctx, c, sectionH);
@@ -636,10 +640,13 @@ function convertElementInner(ctx, e, sectionH) {
636
640
  const mshow = m ? Math.max(1, Math.round(m.width / msw)) : show;
637
641
  node.responsive.desktop.styles.width = show * sw;
638
642
  node.responsive.mobile.styles.width = mshow * msw;
639
- const base = { showNavigation: !!e.config?.["nav"], autoplayMode: "repeat", delayTimeMs: 5000, infinity: true };
643
+ // a tab set: one panel at a time, switched only by its tab buttons (change_tab)
644
+ const base = e.config?.["tabs"]
645
+ ? { showNavigation: false, autoplayMode: "off", infinity: false, transition: "none" }
646
+ : { showNavigation: !!e.config?.["nav"], autoplayMode: "repeat", delayTimeMs: 5000, infinity: true };
640
647
  node.responsive.desktop.config = { ...(node.responsive.desktop.config ?? {}), ...base, slideWidth: sw, slideToShow: show };
641
648
  node.responsive.mobile.config = { ...(node.responsive.mobile.config ?? {}), ...base, slideWidth: msw, slideToShow: mshow };
642
- ctx.notes.push(`${e.id}: slider → native carousel (${slides.length} slides, ${show} visible on desktop, ${mshow} on mobile)`);
649
+ ctx.notes.push(`${e.id}: ${e.config?.["tabs"] ? "tab set" : "slider"} → native carousel (${slides.length} slides, ${show} visible on desktop, ${mshow} on mobile)`);
643
650
  return node;
644
651
  }
645
652
  if (t === "carousel" || t === "gallery") {
@@ -818,7 +825,7 @@ export function canvasToPageSource(canvas, meta = {}) {
818
825
  const css = ctx.css.filter(Boolean).join("\n");
819
826
  if (css) {
820
827
  source.settings.extra_css = css;
821
- ctx.notes.push(`hover effects of ${ctx.css.filter(Boolean).length} element(s) → settings.extra_css (scoped to #w-<id>)`);
828
+ ctx.notes.push(`hover / animation effects of ${ctx.css.filter(Boolean).length} element(s) → settings.extra_css (scoped to #w-<id>)`);
822
829
  }
823
830
  // icon-font stylesheets only from the public CDNs that serve them (a cloned page must not get an
824
831
  // arbitrary third-party stylesheet on the user's domain)
@@ -417,9 +417,88 @@ const SYSTEM_FIELD_ALIASES = {
417
417
  so_luong: "quantity", soluong: "quantity", qty: "quantity",
418
418
  ma_giam_gia: "coupon", voucher: "coupon",
419
419
  };
420
+ /** lowercase, accents stripped, non-alphanumerics → `_` ("Số điện thoại" → "so_dien_thoai"). */
421
+ function slugField(s) {
422
+ return s.normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/đ/gi, "d")
423
+ .toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
424
+ }
420
425
  /** The system column a non-canonical field_name was clearly meant to be, else undefined. */
421
426
  export function systemFieldAlias(fieldName) {
422
- const slug = fieldName.normalize("NFD").replace(/[̀-ͯ]/g, "").replace(/đ/gi, "d")
423
- .toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
424
- return SYSTEM_FIELD_ALIASES[slug];
427
+ return SYSTEM_FIELD_ALIASES[slugField(fieldName)];
428
+ }
429
+ /**
430
+ * Map one source form control onto the Webcake field element that renders AND submits it:
431
+ * select → select ({id,name} options + field_placeholder), multi-select / checkbox → checkbox-group,
432
+ * radio → radio, textarea → textarea, date/time → input-datetime, file → input-file, else input
433
+ * (field_type email/phone/number/text). field_name = the system column when the name, label or
434
+ * placeholder clearly means one (name/"Họ và tên" → full_name, tel/"Số điện thoại" → phone_number),
435
+ * else the slugged name/label; `taken` (one Set per form) keeps names unique.
436
+ */
437
+ export function fieldSpec(f, taken) {
438
+ const kind = (f.input_type || "text").toLowerCase();
439
+ const options = (f.options ?? []).map((o) => o.trim()).filter(Boolean)
440
+ .map((name, i) => ({ id: `opt${i + 1}`, name }));
441
+ const type = kind === "select" ? (f.multiple ? "checkbox-group" : "select")
442
+ : kind === "checkbox" ? "checkbox-group"
443
+ : kind === "radio" ? "radio"
444
+ : kind === "textarea" ? "textarea"
445
+ : /^(date|time|datetime-local|month|week)$/.test(kind) ? "input-datetime"
446
+ : kind === "file" ? "input-file"
447
+ : "input";
448
+ // system columns only for free-text fields (a <select name="name"> is not the customer's name)
449
+ const cands = [f.name, f.label, f.placeholder].filter((s) => !!s && !!s.trim());
450
+ let fieldName;
451
+ if (type === "input" || type === "textarea") {
452
+ for (const c of cands) {
453
+ const sys = SYSTEM_FIELD_NAMES.has(c) ? c : systemFieldAlias(c);
454
+ if (sys && !sys.includes("/") && !taken.has(sys)) {
455
+ fieldName = sys;
456
+ break;
457
+ }
458
+ }
459
+ if (!fieldName && kind === "email" && !taken.has("email"))
460
+ fieldName = "email";
461
+ if (!fieldName && kind === "tel" && !taken.has("phone_number"))
462
+ fieldName = "phone_number";
463
+ }
464
+ if (!fieldName) {
465
+ const base = cands.map(slugField).find((s) => s && s.length <= 40) || type.replace(/-/g, "_");
466
+ fieldName = base;
467
+ for (let n = 2; taken.has(fieldName); n++)
468
+ fieldName = `${base}_${n}`;
469
+ }
470
+ taken.add(fieldName);
471
+ const prompt = f.placeholder || f.label || "";
472
+ const specials = { field_name: fieldName };
473
+ if (f.required)
474
+ specials.required = true;
475
+ if (type === "input") {
476
+ specials.field_placeholder = prompt;
477
+ specials.field_type =
478
+ fieldName === "phone_number" || kind === "tel" ? "phone"
479
+ : fieldName === "email" || kind === "email" ? "email"
480
+ : kind === "number" || kind === "range" ? "number"
481
+ : "text";
482
+ }
483
+ else if (type === "textarea" || type === "input-file") {
484
+ specials.field_placeholder = prompt;
485
+ }
486
+ else if (type === "input-datetime") {
487
+ specials.field_placeholder = prompt;
488
+ specials.datetime_type = kind === "time" || kind === "datetime-local" ? kind : "date";
489
+ }
490
+ else if (type === "select") {
491
+ specials.field_placeholder = prompt || "Chọn...";
492
+ specials.default_value = "default-none";
493
+ specials.options = options;
494
+ }
495
+ else {
496
+ // radio / checkbox-group: a lone checkbox ("Tôi đồng ý…") is a one-option group; the runtime
497
+ // splits these DOM ids on "-", so option names carry an en dash instead of a hyphen
498
+ const opts = options.length ? options : [{ id: "opt1", name: f.label || f.placeholder || "Đồng ý" }];
499
+ specials.options = opts.map((o) => ({ ...o, name: o.name.replace(/-/g, "–") }));
500
+ if (type === "radio")
501
+ specials.default_value = "none";
502
+ }
503
+ return { type, specials };
425
504
  }
@@ -106,7 +106,7 @@ SECTION BUILD HINTS (apply to whichever sections the chosen archetype uses)
106
106
  - FEATURES / BENEFITS — a row of equal cards (icon + title + text) or a 2-column list. Center the row with the ROW math; on mobile shrink to one canvas width or stack. ICONS: do NOT use keyboard emoji (🎯💼📱✅⭐) as feature icons — instead use a small rectangle (e.g. 48×48px) with per-breakpoint config.svgMask set to a raw SVG string and styles.background set to the brand accent color; write a simple inline SVG path per icon (e.g. a checkmark, star, or arrow). Emoji are acceptable only inline within sentences, never as standalone card icons.
107
107
  - PRODUCT / OFFER — image beside name + price + benefit list + CTA (swap sides per balance). Price and CTA stand out.
108
108
  - SOCIAL PROOF — testimonial cards, a logo strip, or a row of stat counters (auto-number + label). Center the row.
109
- - FORM / CTA — center the form box; stack inputs vertically with comfortable spacing; each input needs a unique specials.field_name (canonical: full_name, phone_number, email, address, quantity); prominent submit button.
109
+ - FORM / CTA — center the form box; stack inputs vertically with comfortable spacing; each input needs a unique specials.field_name (canonical: full_name, phone_number, email, address, quantity); prominent submit button. EVERY field the user (or the reference) asks for gets the DEDICATED type that renders and submits it — never an input standing in for something else: pick one of a few → radio; pick several / a consent tick → checkbox-group (a lone checkbox = one option); pick from a list → select (options [{id,name}] + field_placeholder); message/notes → textarea; date/time → input-datetime; file → input-file; province/district/ward → address; quantity → quantity_input. Choices go in specials.options as {id,name} (never {label,value}); no hyphens in radio/checkbox ids or option ids. A visible field label is a text-block placed above its field (inputs have no label of their own; put the hint in field_placeholder). Fields AND the submit button are DIRECT children of the form (the build makes only such a button submit); size the form box so every child fits inside it on BOTH breakpoints. From ingest_html/ingest_url, each form_fields[] item carries \`webcake\` = { type, specials } (field type, canonical field_name, options, placeholder, required) — use it as that child's type + specials verbatim, keep every field (none dropped, none merged), and keep the order.
110
110
  - FOOTER — name + real contact lines, usually centered on a dark band. Only real data the user provided.
111
111
  - TAG/BADGE "PILL" recipe — a rounded rectangle (borderRadius "13px", the pill bg color) BEHIND a text-block (zIndex 2, styles.backgroundTxt for the box fill if needed, textAlign center). NEVER put the pill color in styles.background on the text-block — ANY styles.background on a text-block paints the TEXT FILL (the renderer emits -webkit-text-fill-color:transparent and forces background-clip:text itself), so it colors the glyphs, not a box. borderRadius is emitted on the inner text tag while backgroundTxt paints the outer box, so the box fill is NOT rounded — the rounded shape must come from a rectangle behind the text.
112
112
  - COMPLEX COMPOSITE VISUAL (phone/chat mockup, mini dashboard, browser-window frame, inbox/notification list, ticket-style card) → ONE html-box with inline-styled HTML (root div: width:100%;height:100%;box-sizing:border-box;overflow:hidden; flex/grid allowed inside; content must fit styles.height or it overflows silently) instead of dozens of tiny elements. Never use html-box for primary copy, CTAs, form fields, or any element that events must target — it is an opaque blob in the editor.
@@ -26,7 +26,7 @@ RULES (follow for every request):
26
26
  A wrong element type is the most common error → { op:'update', id:'<element id>', type:'<allowed type>' } (run list_elements if unsure). Drafts expire in ~2 h.
27
27
  - DRY-RUN CACHE: create_page, update_page, and add_section dry_run=true all cache the validated payload and return a draft_id. Re-run the same tool with { draft_id, dry_run:false } — no need to re-send the source.
28
28
  - ORGANIZATION FIRST — the org is REQUIRED for the API and must be settled in INTAKE, before any image or build work. Call list_organizations at the START (part of the same first batch as your intake questions). Exactly ONE org → it is auto-selected everywhere, no need to ask. MULTIPLE orgs → show them and ask the user which to use (is_default is the suggested default) as one of your intake questions, then pass that SAME organization_id to create_page AND to upload_images. Both refuse to guess: they return ok:false with reason:"organization_required" and the org list. Pass organization_id:"personal" only when the user explicitly wants no org. Endpoints are owner-scoped (only the account's own pages). WHY IT MUST COME FIRST: the org decides WHICH media collection the page's images are filed into, so an image uploaded before the org is settled has no collection to go into — do NOT call search_images/upload_images or start building until the org is known. One org, chosen once, used for the page and every image on it.
29
- - REFERENCE INPUT — if the user provides a layout reference, USE it as the layout anchor (don't ignore it, don't re-invent from scratch). Three input modes: (1) IMAGE/screenshot attached in chat → analyze it natively (no tool call): identify section flow (hero/features/form/cta/footer), heading hierarchy, dominant colors, font feel, then map sections to Webcake elements using role→element hints (hero → section with background image/overlay + heading + paragraph + button; features → group blocks with icon/title/text; stats bar → group with heading+text per stat; pricing → group with text list + button; footer → section with text + links). When the reference contains a composite widget (phone/device mockup, chat thread, mini dashboard, browser frame) → rebuild it as ONE html-box (clone its HTML with all styles inlined), not as element soup. (2) HTML string → call ingest_html(html, detail:'full') to get the richer AST when cloning; use detail:'compact' (default) for a layout-only reference. (3) URL → call ingest_url(url, detail:'full') for the same richer AST. (4) GOOGLE STITCH design (when a Stitch MCP is connected and the user points at a Stitch screen/project) → bridge the two MCPs: call the Stitch tool get_screen, take the returned htmlCode.downloadUrl, and pass THAT url to ingest_url(detail:'full') (or fetch the HTML and use ingest_html) — Stitch output is a Tailwind-CDN page, so the AST comes back with a token-named palette + design_tokens (the real spacing/radii/type-scale) + gradients (Tailwind gradient utilities reconstructed as linear-gradient(...) with resolved color stops — apply them as the element's background, e.g. on CTA/hero) + per-section hover_effects (the interactions Stitch packs in: scale/image-zoom/lift/underline/color-change — REPRODUCE them via Webcake hover events: change_color (change_color_type text/background/border) for color/underline, the button's hovered* specials or animation_hover for scale/lift/zoom — don't ship a static page); LOCK the design system from those tokens, reuse the page's image URLs (they auto-host on save — Stitch's googleusercontent images included), then create_page. ABSOLUTE-CANVAS builder exports (LadiPage-family / Webcake-published HTML) are AUTO-DETECTED by ingest_html/ingest_url and converted DETERMINISTICALLY into a ready-to-save source (folded into the response as source + clone_notes + clone_notice, the per-element geometry summarized to canvas_summary) — a faithful 1:1 clone on the matching 420/960 canvas: pass that source STRAIGHT to create_page (dry_run:true first to validate, then dry_run:false) instead of hand-rebuilding; its images auto-host on save (no upload_images), and clone_notes lists the few lossy approximations (fixed/floating elements, svg-less shapes, skipped social-proof toasts) to patch_page afterward. The AST classifies sections by role and lists headings/subheadings/ctas/images/form_fields plus brand hints (colors/fonts), a token-named palette + design_tokens (for Tailwind-CDN pages like Google Stitch, lifted from the page's tailwind.config: palette names every color token e.g. primary→#a43b38, and design_tokens carries the resolved spacing grid + corner radii + TYPE SCALE e.g. display-lg→48px — rebuild sizing/spacing/color FROM these tokens, not by guessing), background_images from stylesheets, gradients (incl. reconstructed Tailwind gradient backgrounds), per-section hover_effects (reproduce them — via hover events, or the custom-CSS escape hatch below), and in full mode: per-section blocks (cards/tiles/steps with title/body/image/cta) and li lists — use it for LAYOUT + HIERARCHY, then generate FRESH content tailored to the user's brand (don't 1:1 copy text). IMAGES FROM THE REFERENCE ARE THE USER'S ASSETS — for BOTH intents (adapt AND clone), put every real image URL found in the AST (images, background_images, og_image, canvas src/background) straight into the corresponding slot's specials.src / url(...) background / gallery link; the save AUTO-HOSTS it to the Webcake CDN, so you do NOT need to call upload_images first — just carry the URL through un-altered (never drop it, never swap it for a search_images stock photo or a placeholder). Call search_images ONLY for slots that have no source image in the reference. intent='clone' only when the user explicitly asks to mirror the original; default intent='adapt' (adapt rewrites TEXT, not the imagery). The reference workflow PRESERVES craft rules above (centering, page margin, premium spacing, real images) — apply them on top of the reference layout, don't bypass them.
29
+ - REFERENCE INPUT — if the user provides a layout reference, USE it as the layout anchor (don't ignore it, don't re-invent from scratch). Three input modes: (1) IMAGE/screenshot attached in chat → analyze it natively (no tool call): identify section flow (hero/features/form/cta/footer), heading hierarchy, dominant colors, font feel, then map sections to Webcake elements using role→element hints (hero → section with background image/overlay + heading + paragraph + button; features → group blocks with icon/title/text; stats bar → group with heading+text per stat; pricing → group with text list + button; footer → section with text + links). When the reference contains a composite widget (phone/device mockup, chat thread, mini dashboard, browser frame) → rebuild it as ONE html-box (clone its HTML with all styles inlined), not as element soup. (2) HTML string → call ingest_html(html, detail:'full') to get the richer AST when cloning; use detail:'compact' (default) for a layout-only reference. (3) URL → call ingest_url(url, detail:'full') for the same richer AST. When the user wants a FAITHFUL COPY of an HTML/URL (not an adaptation), pass intent:'clone' (HTML saved from a site: also base_url = its original URL): with a browser on the host the page is MEASURED and the result is a ready draft_id (mode:'browser_clone' — forms, accordions, tabs, popups, sliders and animations already native) → create_page({ draft_id, dry_run:false }); never hand-rebuild a page that came back as a draft. Without a browser the AST comes back with a warning — rebuild from it, copying each form_fields[].webcake as the form's child. (4) GOOGLE STITCH design (when a Stitch MCP is connected and the user points at a Stitch screen/project) → bridge the two MCPs: call the Stitch tool get_screen, take the returned htmlCode.downloadUrl, and pass THAT url to ingest_url(detail:'full') (or fetch the HTML and use ingest_html) — Stitch output is a Tailwind-CDN page, so the AST comes back with a token-named palette + design_tokens (the real spacing/radii/type-scale) + gradients (Tailwind gradient utilities reconstructed as linear-gradient(...) with resolved color stops — apply them as the element's background, e.g. on CTA/hero) + per-section hover_effects (the interactions Stitch packs in: scale/image-zoom/lift/underline/color-change — REPRODUCE them via Webcake hover events: change_color (change_color_type text/background/border) for color/underline, the button's hovered* specials or animation_hover for scale/lift/zoom — don't ship a static page); LOCK the design system from those tokens, reuse the page's image URLs (they auto-host on save — Stitch's googleusercontent images included), then create_page. ABSOLUTE-CANVAS builder exports (LadiPage-family / Webcake-published HTML) are AUTO-DETECTED by ingest_html/ingest_url and converted DETERMINISTICALLY into a ready-to-save source (folded into the response as source + clone_notes + clone_notice, the per-element geometry summarized to canvas_summary) — a faithful 1:1 clone on the matching 420/960 canvas: pass that source STRAIGHT to create_page (dry_run:true first to validate, then dry_run:false) instead of hand-rebuilding; its images auto-host on save (no upload_images), and clone_notes lists the few lossy approximations (fixed/floating elements, svg-less shapes, skipped social-proof toasts) to patch_page afterward. The AST classifies sections by role and lists headings/subheadings/ctas/images/form_fields plus brand hints (colors/fonts), a token-named palette + design_tokens (for Tailwind-CDN pages like Google Stitch, lifted from the page's tailwind.config: palette names every color token e.g. primary→#a43b38, and design_tokens carries the resolved spacing grid + corner radii + TYPE SCALE e.g. display-lg→48px — rebuild sizing/spacing/color FROM these tokens, not by guessing), background_images from stylesheets, gradients (incl. reconstructed Tailwind gradient backgrounds), per-section hover_effects (reproduce them — via hover events, or the custom-CSS escape hatch below), and in full mode: per-section blocks (cards/tiles/steps with title/body/image/cta) and li lists — use it for LAYOUT + HIERARCHY, then generate FRESH content tailored to the user's brand (don't 1:1 copy text). IMAGES FROM THE REFERENCE ARE THE USER'S ASSETS — for BOTH intents (adapt AND clone), put every real image URL found in the AST (images, background_images, og_image, canvas src/background) straight into the corresponding slot's specials.src / url(...) background / gallery link; the save AUTO-HOSTS it to the Webcake CDN, so you do NOT need to call upload_images first — just carry the URL through un-altered (never drop it, never swap it for a search_images stock photo or a placeholder). Call search_images ONLY for slots that have no source image in the reference. intent='clone' only when the user explicitly asks to mirror the original; default intent='adapt' (adapt rewrites TEXT, not the imagery). The reference workflow PRESERVES craft rules above (centering, page margin, premium spacing, real images) — apply them on top of the reference layout, don't bypass them.
30
30
 
31
31
  MODEL (essentials):
32
32
  - Top-level: { page:[sections], popup:[popups], dynamic_pages:[], settings:{}, options:{mobileOnly,versionID}, cartConfigs:{isActive:false}, svariations:[] }. Popups are a SEPARATE top-level array, NOT inside page; currency lives in settings.currency (not options). Leave dynamic_pages/svariations as [] for a static page, but keep them on edit round-trips.
@@ -712,6 +712,10 @@ export function validatePage(input) {
712
712
  if (type === "form" && !hasField(node)) {
713
713
  warnings.push(`[EMPTY_RENDER] ${path} (form): has no input fields — nothing to fill in or submit. Add fields (input with field_name full_name / phone_number, …) and a button.`);
714
714
  }
715
+ else if (type === "form" && !(node.children ?? []).some((c) => c?.type === "button")) {
716
+ // the build emits the hidden <button type=submit> only inside a button whose parent is the form
717
+ warnings.push(`${path} (form): no button among its direct children — the form can never be submitted. Add a button as a DIRECT child of the form (inside a group/rectangle it does not submit).`);
718
+ }
715
719
  if (OPTION_NAME_FIELDS.has(type) && type !== "select" && !(Array.isArray(node.specials?.options) && node.specials.options.length)) {
716
720
  warnings.push(`[EMPTY_RENDER] ${path} (${type}): specials.options is empty — no choices render. Add [{ id, name }, …].`);
717
721
  }
package/dist/install.js CHANGED
@@ -116,7 +116,7 @@ function mergeJson(file, launch, env, key = "mcpServers") {
116
116
  mkdirSync(dirname(file), { recursive: true });
117
117
  let cfg = {};
118
118
  if (existsSync(file)) {
119
- const raw = readFileSync(file, "utf8").trim();
119
+ const raw = readFileSync(file, "utf8").replace(/^\uFEFF/, "").trim();
120
120
  if (raw) {
121
121
  try {
122
122
  cfg = JSON.parse(raw);
@@ -144,7 +144,7 @@ function mergeOpencodeJson(file, launch, env) {
144
144
  mkdirSync(dirname(file), { recursive: true });
145
145
  let cfg = {};
146
146
  if (existsSync(file)) {
147
- const raw = readFileSync(file, "utf8").trim();
147
+ const raw = readFileSync(file, "utf8").replace(/^\uFEFF/, "").trim();
148
148
  if (raw) {
149
149
  try {
150
150
  cfg = JSON.parse(raw);
@@ -182,29 +182,82 @@ function configureCodex(launch, env) {
182
182
  writeConfig(cfg, content.trimEnd() + "\n" + block);
183
183
  }
184
184
  // ── IDE config-file locations ────────────────────────────────────────────────
185
- function claudeDesktopPath() {
185
+ // Every location a Claude Desktop build may read its config from. A machine can have
186
+ // several (MSIX/Store package container, Claude-Data, classic %APPDATA%) and only one is
187
+ // the live one, so on Windows we write to all candidates.
188
+ function findConfigsUnder(dir, depth, out) {
189
+ if (depth < 0)
190
+ return;
191
+ let entries;
192
+ try {
193
+ entries = readdirSync(dir, { withFileTypes: true });
194
+ }
195
+ catch {
196
+ return;
197
+ }
198
+ for (const e of entries) {
199
+ const full = join(dir, e.name);
200
+ if (e.isFile() && e.name.toLowerCase() === "claude_desktop_config.json")
201
+ out.push(full);
202
+ else if (e.isDirectory())
203
+ findConfigsUnder(full, depth - 1, out);
204
+ }
205
+ }
206
+ function claudeDesktopPaths() {
186
207
  if (PLAT === "win32") {
187
- // Microsoft Store build is MSIX-sandboxed: it reads/writes config inside
188
- // its package container, NOT %APPDATA%\Claude. Detect that container first
189
- // (the package name is Claude_<publisher-hash>, e.g. Claude_pzs8sxrjxfjjc)
190
- // so installs land in the file the Store app actually loads.
208
+ const found = [];
191
209
  const packages = join(LOCALAPPDATA, "Packages");
192
- if (existsSync(packages)) {
193
- try {
194
- const pkg = readdirSync(packages).find((n) => /^Claude_/i.test(n));
195
- if (pkg) {
196
- return join(packages, pkg, "LocalCache", "Roaming", "Claude", "claude_desktop_config.json");
210
+ try {
211
+ if (existsSync(packages)) {
212
+ for (const n of readdirSync(packages)) {
213
+ if (!/claude/i.test(n))
214
+ continue;
215
+ const cache = join(packages, n, "LocalCache");
216
+ if (existsSync(cache))
217
+ found.push(join(cache, "Roaming", "Claude", "claude_desktop_config.json"));
197
218
  }
198
219
  }
199
- catch {
200
- /* fall through to the Win32 default */
201
- }
202
220
  }
203
- return join(APPDATA, "Claude", "claude_desktop_config.json");
221
+ catch {
222
+ /* ignore */
223
+ }
224
+ try {
225
+ const data = join(LOCALAPPDATA, "Claude-Data");
226
+ if (existsSync(data))
227
+ findConfigsUnder(data, 4, found);
228
+ }
229
+ catch {
230
+ /* ignore */
231
+ }
232
+ const roaming = join(APPDATA, "Claude");
233
+ if (existsSync(roaming) || found.length === 0)
234
+ found.push(join(roaming, "claude_desktop_config.json"));
235
+ const seen = new Set();
236
+ return found.filter((p) => {
237
+ const k = p.toLowerCase();
238
+ if (seen.has(k))
239
+ return false;
240
+ seen.add(k);
241
+ return true;
242
+ });
204
243
  }
205
244
  const mac = join(HOME, "Library", "Application Support", "Claude");
206
245
  const dir = existsSync(mac) ? mac : join(HOME, ".config", "Claude");
207
- return join(dir, "claude_desktop_config.json");
246
+ return [join(dir, "claude_desktop_config.json")];
247
+ }
248
+ function claudeDesktopRunning() {
249
+ try {
250
+ if (PLAT === "win32") {
251
+ const r = spawnSync("tasklist", ["/FI", "IMAGENAME eq claude.exe", "/NH"], { stdio: "pipe", encoding: "utf8" });
252
+ return /claude\.exe/i.test(String(r.stdout ?? ""));
253
+ }
254
+ if (PLAT === "darwin")
255
+ return spawnSync("pgrep", ["-x", "Claude"], { stdio: "pipe" }).status === 0;
256
+ }
257
+ catch {
258
+ /* ignore */
259
+ }
260
+ return false;
208
261
  }
209
262
  function vscodeUserDir() {
210
263
  if (PLAT === "win32")
@@ -237,7 +290,7 @@ function hasClaudeCli() {
237
290
  // install needs no IDE question and never creates config for an app the user lacks.
238
291
  function detectIdes() {
239
292
  const marks = {
240
- "claude-desktop": dirname(claudeDesktopPath()),
293
+ "claude-desktop": "",
241
294
  "claude-code": claudeJsonPath(),
242
295
  cursor: join(HOME, ".cursor"),
243
296
  windsurf: join(HOME, ".codeium", "windsurf"),
@@ -249,7 +302,7 @@ function detectIdes() {
249
302
  kiro: join(HOME, ".kiro"),
250
303
  opencode: dirname(opencodePath()),
251
304
  };
252
- return Object.keys(marks).filter((id) => existsSync(marks[id]) || (id === "claude-code" && hasClaudeCli()));
305
+ return Object.keys(marks).filter((id) => (id === "claude-desktop" ? claudeDesktopPaths().some((p) => existsSync(dirname(p))) : existsSync(marks[id])) || (id === "claude-code" && hasClaudeCli()));
253
306
  }
254
307
  // ── per-IDE configure ────────────────────────────────────────────────────────
255
308
  function configureClaudeCode(launch, env) {
@@ -269,10 +322,21 @@ function configureClaudeCode(launch, env) {
269
322
  }
270
323
  function configureClaudeDesktop(launch, env) {
271
324
  info("Claude Desktop…");
272
- if (mergeJson(claudeDesktopPath(), launch, env)) {
273
- ok(`Claude Desktop configured (${claudeDesktopPath()})`);
274
- warn("Restart Claude Desktop to load the server.");
325
+ if (claudeDesktopRunning()) {
326
+ warn("Claude Desktop đang chạy — thoát hẳn (chuột phải icon khay → Quit) rồi mở lại để nạp server");
275
327
  }
328
+ const paths = claudeDesktopPaths();
329
+ let wrote = 0;
330
+ for (const p of paths) {
331
+ if (mergeJson(p, launch, env)) {
332
+ ok(`Claude Desktop configured (${p})`);
333
+ wrote++;
334
+ }
335
+ }
336
+ if (paths.length > 1)
337
+ info("Wrote to every location Claude Desktop may read its config from.");
338
+ if (wrote)
339
+ warn("Restart Claude Desktop to load the server.");
276
340
  }
277
341
  function configureCursor(launch, env) {
278
342
  info("Cursor…");
@@ -376,7 +440,7 @@ function removeFromJson(file) {
376
440
  if (!existsSync(file))
377
441
  return;
378
442
  try {
379
- const cfg = JSON.parse(readFileSync(file, "utf8"));
443
+ const cfg = JSON.parse(readFileSync(file, "utf8").replace(/^\uFEFF/, ""));
380
444
  const holders = [cfg.mcpServers, cfg.servers].filter((s) => s && s[NAME]);
381
445
  if (holders.length) {
382
446
  for (const s of holders)
@@ -395,7 +459,7 @@ function uninstall() {
395
459
  spawnSync("claude", ["mcp", "remove", NAME], { stdio: "ignore" });
396
460
  [
397
461
  claudeJsonPath(),
398
- claudeDesktopPath(),
462
+ ...claudeDesktopPaths(),
399
463
  join(HOME, ".config", "Claude", "claude_desktop_config.json"),
400
464
  cursorPath(),
401
465
  windsurfPath(),
@@ -410,7 +474,7 @@ function uninstall() {
410
474
  const oc = opencodePath();
411
475
  if (existsSync(oc)) {
412
476
  try {
413
- const cfg = JSON.parse(readFileSync(oc, "utf8"));
477
+ const cfg = JSON.parse(readFileSync(oc, "utf8").replace(/^\uFEFF/, ""));
414
478
  if (cfg.mcp && cfg.mcp[NAME]) {
415
479
  delete cfg.mcp[NAME];
416
480
  writeFileSync(oc, JSON.stringify(cfg, null, 2) + "\n");