Skip to content

feat(ui-plugins): add Theme From Design (theme-from-design) - #241

Open
ppppp2005-p wants to merge 10 commits into
zai-org:mainfrom
ppppp2005-p:feat/theme-from-design
Open

ppppp2005-p wants to merge 10 commits into
zai-org:mainfrom
ppppp2005-p:feat/theme-from-design

Conversation

@ppppp2005-p

Copy link
Copy Markdown

Plugin type (required) / 插件类型(必填)

  • UI Plugin / 是 UI 插件 — provides MCP Apps interactive pages / 提供 MCP Apps 交互页面
  • Standard plugin / 普通插件(非 UI)
  • Not applicable / 不适用

Affected plugin name(s) / 涉及的插件名称:theme-from-design (UI Plugin, new)

What / 改动内容

New community UI plugin Theme From Design / 设计稿转店铺主题: a store design → a Shopify Online Store 2.0 theme (Liquid sections + JSON templates), checked with Shopify's theme-check, previewed next to the design, and zipped for upload.

Defaults (stated in the READMEs):

  • Platform: Shopify OS 2.0 only.

  • Validation: built-in checks + Shopify theme-check (@shopify/theme-check-node 4.0.2, bundled, offline, recommended config).

  • Preview: an approximation with liquidjs and fictional data.

  • Upload: none (the zip is uploaded by the merchant in Shopify admin).

  • Tools: theme_new (name, design images, colours, Shopify font handles, radius, width), theme_write (files / delete inside the theme folders + built-in checks), theme_check (built-in + theme-check, file:line), theme_preview (template, locale → HTML + render errors), theme_package (zip; refuses on errors unless forced). App-only: theme_state, theme_file, theme_design, workspace_images.

  • Skeleton:

    • Structure: layout with content_for_header / content_for_layout, header/footer section groups, and 7 JSON templates.
    • Sections: 12 base sections, plus the product-card snippet.
    • Settings: settings_schema / settings_data driven by the brand (colours, font_picker, radius, page width).
    • Locales and CSS: en.default + zh-CN locales, base.css, and an empty custom.css.
    • The skeleton passes theme-check with 0 offenses.
  • Built-in checks:

    • Liquid parse through liquidjs with Shopify tags registered.
    • Schema JSON, name length, and an allowed setting-type list (no liquid / html settings).
    • Duplicate ids, select and range defaults, and the range step limit.
    • section.settings.X / block.settings.X references against the schema.
    • JSON templates and groups: missing section files, unknown block types and settings, and broken order / block_order.
    • Required files.
  • theme-check bundling:

    • Docs data and configs are copied to dist/data and dist/configs via zcode.dirs, and WEBPACK_MODE is set only when running from the bundle.
    • node-fetch is stubbed, so the online docs update fails fast and the bundled fallback data is used. No network access.
    • mainFields: ["module","main"] avoids jsonc-parser's UMD entry.
    • The banner defines __dirname / __filename for the bundled CommonJS code.
  • Preview:

    • Filters and tags: liquidjs with t (locale + fallback), money*, asset_url + stylesheet_tag (CSS inlined), image_url / image_tag, placeholder_svg_tag, link_to, font helpers, form / paginate / style / section(s).
    • Settings: resolved by type (collection, product, link_list, image_picker, font_picker), with global objects for rendered snippets.
    • Sample data: fictional products, collections, menus and cart with inline SVG images.
    • Render errors show inline and are also returned.
  • Panel: create from design images, design and preview side by side (desktop 1280 / mobile 390, sandboxed srcdoc iframe without scripts), template switcher, problems list with source badges (built-in / theme-check), file viewer, full check, package.

Network / API / side effects: none. No API keys and no Shopify login or upload. Writes themes/<name>/, themes/<name>.zip and .theme-from-design/. theme-check's docs manager creates an empty cache folder in the user cache dir. No hooks.

Third-party: liquidjs (MIT), @shopify/theme-check-node and dependencies (MIT, including theme docs data), fflate (MIT), MCP SDK / ext-apps (MIT), zod (MIT).

Tests:

  • vitest:
    • The skeleton has no built-in issues and renders all 7 templates (prices, cart total, zh-CN strings, inlined CSS).
    • Shopify tags work in liquidjs.
    • The built-in checks catch schema, setting-type, default, undefined-setting, template-reference and syntax problems.
    • Full flow with the fictional Hearth & Bean design: theme_new (theme-check 0 offenses) → agent sections (hero-split, usp-bar, newsletter, index.json, custom.css) → theme-check finds 3 missing zh-CN translations (MatchingTranslations) and packaging is refused → fix → a broken section is caught by the built-in checks and theme-check (LiquidHTMLSyntaxError) → delete → path escape refused → 0 offenses → the preview contains the design's texts, colours and fonts → the zip has the theme folders at its root and correct theme_info.
  • Chrome e2e (bundled server, so the offline theme-check path is exercised; official AppBridge host):
    1. The user creates the theme from the design in the panel.
    2. The agent writes the sections, and the preview updates next to the design.
    3. The full check shows 3 theme-check problems, and the user opens the file.
    4. The agent fixes them, and the badge shows no errors, including theme-check.
    5. The user views the mobile product page and packages the theme.
    6. There are no console errors.
  • validate.py, build_dist.py, git diff --check and tsc pass. Shopify's theme-check is bundled, so no Ruby gem or CLI install is needed.

A ZCode Desktop demo recording is attached in the comments. / ZCode 桌面版演示录屏见评论。

Self-check / 自查清单

  • Plugin name is unique kebab-case; new external plugin directory is external_plugins/<name>/
  • Usage category is set (productivity)
  • Plugin type and affected names are declared above
  • version 0.1.0 in both plugin.json and marketplace.json
  • README.md (EN) and README_CN.md (中文) both provided and equivalent
  • description_i18n has both en and zh-CN
  • No secrets, machine-specific paths, or private dependencies
  • Model/API/network dependencies documented
  • python3 scripts/validate.py and python3 scripts/build_dist.py pass locally
  • Exercised in ZCode Desktop (ZCode 4.0.0, macOS arm64: installed from a local marketplace, installed from a local marketplace, theme_new from a design image → panel → theme_write home page sections → theme_preview (desktop, compared with the design) → theme_check: 0 errors / 0 warnings incl. Shopify theme-check → theme_package themes/hearth-bean.zip; demo video in the comments; demo video in the comments)

@ppppp2005-p

Copy link
Copy Markdown
Author

ZCode desktop demo (ZCode 4.0.0, macOS arm64)

theme-from-design-demo.mp4

Flow shown:

  1. Installed theme-from-design from a local marketplace built from this PR's branch.
  2. Asked ZCode to build a Shopify theme "hearth-bean" from the design image theme/hearth-bean-home.png: create the theme, write the home page sections, preview the home page, run the theme check, fix errors (both the en and zh-CN locale files), and report the output folder and check result.
  3. The agent called theme_new (side panel: theme summary, full check / package buttons, template picker, desktop/phone preview with "compare with design"), wrote the home page sections with theme_write (announcement bar, header, hero, value props, "This week's roasts" collection and more), rendered it with theme_preview and ran theme_check, which came back clean (0 errors, 0 warnings, Shopify theme-check included), so no fix round was needed. theme_package then ran the full check again and wrote themes/hearth-bean.zip.
  4. The output is themes/hearth-bean/ (16 sections, 7 templates, 34 files). The last card shows the design next to the generated home page preview.

演示流程:本地 marketplace 安装 → theme_new 打开面板 → theme_write 写首页区块 → theme_preview 预览并与设计图对照 → theme_check 0 错误 0 警告 → theme_package 打包 hearth-bean.zip。

@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants