Skip to content

feat(ui-plugins): add App Installer Builder (app-installer-builder) - #243

Open
ppppp2005-p wants to merge 10 commits into
zai-org:mainfrom
ppppp2005-p:feat/app-installer-builder
Open

ppppp2005-p wants to merge 10 commits into
zai-org:mainfrom
ppppp2005-p:feat/app-installer-builder

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) / 涉及的插件名称:app-installer-builder (UI Plugin, new)

What / 改动内容

New community UI plugin App Installer Builder / 应用安装包制作: wraps an existing website or Node project as a desktop app with electron-builder, generates the config, and builds the installers this computer can build.

Defaults (stated in the READMEs):

  • Targets: electron-builder with macOS dmg + Windows nsis (Linux AppImage and dir are optional).
  • Signing: optional and only with the user's own certificate. macOS uses a keychain identity name; Windows uses a .pfx path, with the password read only from the WIN_CSC_KEY_PASSWORD env var and never stored. Without a certificate the build is unsigned, and the generated README says so. No notarization.
  • Where builds can run: dmg only on macOS; nsis on Windows or with Wine.

Tools:

  • app_scan: static site (index.html in dist/build/out/public…) or Node server (start script / entry with listen(), reads PORT?), package.json metadata, and square PNG icons.
  • app_setup: generates <project>/desktop/:
    • main.cjs: static sites served via app://local/ with SPA fallback; Node servers spawned with Electron's Node (ELECTRON_RUN_AS_NODE) on a free port, with APP_DATA_DIR and a server.log; single instance; external links open in the browser; sandboxed renderer.
    • package.json with pinned electron 45.5.0 and electron-builder 26.18.0.
    • electron-builder.yml: dmg, nsis (assisted installer, shortcuts), AppImage, extraResources and signing fields.
    • build/icon.png (user PNG ≥512, or a generated 1024 icon) and README.md.
  • app_check: validation plus a per-target matrix of what this OS can build.
  • app_build / app_status: npm install on first use, then electron-builder --publish never, run as a background job with a log; outputs are listed. Targets this OS can't build are refused with the command to run elsewhere. CSC_IDENTITY_AUTO_DISCOVERY=false is set when unsigned.
  • App-only: app_state, app_projects, app_file, app_icon.

Panel:

  • Project picker, then detection.
  • Form: name, appId, version, window size, web folder or entry, icon, targets, and an optional signing section.
  • Issues list.
  • "Build on this computer" matrix with per-target buttons.
  • Live log and outputs.
  • Viewer for the generated files.

Network / API / side effects: no API keys and no accounts. app_build runs npm install in desktop/, which downloads electron and electron-builder from npm/GitHub. Writes <project>/desktop/ and .app-installer/state.json. No hooks.

Third-party: generated projects depend on electron (MIT) and electron-builder (MIT); these are not bundled in the plugin. MCP SDK / ext-apps (MIT), zod (MIT).

Tests: samples are fictional. Focus Timer is a static SPA with absolute /assets paths, a /stats client route and a 1024 icon. Team Notes is a dependency-free Node server reading PORT and APP_DATA_DIR.

  • vitest:
    • Detection.
    • Validation (appId, semver, web folder, icon size, fixed port, com.example warning, unsigned notes).
    • The yml for unsigned builds and with a macOS identity + Windows .pfx (no password written).
    • Static and server main.cjs pass node --check.
    • The per-OS build matrix and builder arguments; the default icon PNG.
    • The tool flow on simulated linux/darwin: wrong-platform refusal for dmg/nsis, invalid config refusal, generated icon, and a path outside the workspace refused.
  • Chrome e2e with real electron-builder runs on Linux:
    1. The user picks the project, generates the config, sets the appId and adds AppImage. dmg shows "needs a Mac".
    2. The user builds dir from the panel, and the log streams.
    3. The packaged app is launched under xvfb: it serves app://local/stats with the SPA route working.
    4. The agent configures the Node server and builds an AppImage. Launching it shows the server started on a free port with Electron's Node, the page and data loaded, and server.log written.
    5. There are no console errors.
  • Also run by hand: Linux dir and AppImage builds of both samples, and the electron-builder schema validation of the full config (mac/dmg/win/nsis sections).
  • Not run on the box: real dmg and nsis builds. They need macOS (and Wine or Windows for nsis) and must be run on the user's Mac with npx electron-builder --mac dmg / --win nsis in desktop/.
  • validate.py, build_dist.py, git diff --check and tsc pass.

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, npm run build → app_scan on app/focus-timer → panel → app_setup (name, appId, version 1.0.0, dmg, unsigned) → app_check → app_build + app_status: Focus Timer-1.0.0-arm64.dmg, 115.1 MB; demo video in the comments; demo video in the comments)

@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.

@ppppp2005-p

Copy link
Copy Markdown
Author

ZCode desktop demo (ZCode 4.0.0, macOS arm64)

app-installer-builder-demo.mp4

Flow shown:

  1. Installed app-installer-builder from a local marketplace built from this PR's branch.
  2. Asked ZCode to package app/focus-timer (a small static web app) as a Mac installer: run npm run build first, then set name "Focus Timer", appId com.penova.focustimer, version 1.0.0, target dmg (unsigned), check, and build the dmg (waiting with app_status while Electron downloads on first use).
  3. The agent ran npm run build, then called app_scan, which opened the side panel (project card with icon, name / appId / version / window size / web folder / icon / targets form), set the fields with app_setup (saved to desktop/app-installer.json, static mode serving dist/, icon taken from the project's branding/icon-1024.png), ran app_check, started app_build and polled app_status until it finished.
  4. Result: app/focus-timer/desktop/release/Focus Timer-1.0.0-arm64.dmg (115.1 MB, arm64, unsigned, so first launch needs right-click → Open, as the agent noted) plus the unpacked mac-arm64/Focus Timer.app. The last card shows the panel after the build.

演示流程:本地 marketplace 安装 → npm run build → app_scan 打开面板 → app_setup 设置名称/appId/版本/dmg → app_check → app_build + app_status 等待 → 生成未签名的 Focus Timer-1.0.0-arm64.dmg(115.1 MB)。

@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.

@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