Skip to content

feat(ui-plugins): add Sheet To App (sheet-to-app) - #250

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

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

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

What / 改动内容

New community UI plugin Sheet To App / 表格转小应用: an inventory, booking or customer spreadsheet becomes a single-file offline web app with search, filters and validated forms.

Tools:

  • app_new, app_update, app_refresh, app_check, app_list.
  • App-only: app_state, app_sheets.

How it works:

  • Reading: .xlsx via ExcelJS (date cells become YYYY-MM-DD, formulas use their cached results), CSV/TSV with GB18030 fallback. Duplicate headers get suffixes.
  • Inference (src/schema.ts):
    • Types: boolean (是/否, yes/no…), money vs number (≥85 % numeric; price-like header), date (≥85 % Y-M-D / Y/M/D / Y年M月D日, validated), email / phone (header hint or value share), url, longtext (average > 60 chars), select (few distinct short values), text.
    • Required = fully filled (or ≥90 % with ≥8 rows). Key column from the header name (SKU/ID/编号…) or a unique short text column; title column from name-like headers.
    • Field keys are ASCII-safe (f<n> for Chinese headers). The first 7 non-longtext fields are listed.
  • Data issues: required, number, date, email, phone, url, yes/no, select option, missing or duplicate key, all with sheet row numbers. Bad values are kept as-is and shown in red in the app.
  • Generated app (src/app.ts; about 20 KB for the 15-row sample): one HTML file with inline CSS and vanilla JS. Config and seed data are embedded as JSON (< escaped).
    • Search, filters, sort and pagination; add/edit/delete in a <dialog> form with validation and unique-key checks; highlight rule.
    • CSV export (BOM) and import (append/replace, headers matched by label/column), JSON backup and restore, reset.
    • localStorage keyed by app id. A seed version hash lets open copies show an "updated" banner after app_refresh (load new data / keep mine). zh/en UI.
  • Refresh: keeps existing field settings by column name, infers new columns, drops removed ones (and any highlight/sort/key pointing at them), and reports the changes.
  • Mappings are saved in .sheet-to-app/apps.json.

Panel:

  • Sheet picker and Make app.
  • Field table: label, type, select options, required/list/filter/hide.
  • Settings: title, language, accent, page size, highlight rule. Refresh and Apply & rebuild.
  • Data issues list.
  • Static sandboxed preview (srcdoc, no scripts) of the first 15 rows.

Network / API / side effects: none. No API keys. Writes apps/<id>/index.html and .sheet-to-app/apps.json; the spreadsheet is never modified. No hooks. The output folder can later be uploaded to a static host such as Cloudflare Pages; that is not part of this PR.

Testing:

  • vitest (7 tests): inference unit tests plus tool tests on fictional café samples (samples/sheet/make-sheets.mjs): inventory CSV with Chinese headers and planted problems, an updated version (column added and removed, rows added and removed), and a bookings .xlsx with a bad email.
  • Chrome e2e: the real panel in the AppBridge harness (pick sheet → make → hide column, add highlight → apply). Then the generated file is opened via file://:
    • Search, filter and sort.
    • Required and duplicate-key validation, then add.
    • Edit the bad "十" row; data persists across reload.
    • CSV export checked; delete.
    • app_refresh after the sheet changes → banner → load new data.

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, asked it to turn sheet/库存表.csv into the offline app kucun and then refresh it from an updated sheet; the agent ran app_new (4 data problems found) → replaced the CSV → app_refresh (15 → 16 rows, column changes, 1 problem left); a second short task ran app_check on the existing app with the panel shown; demo video in the comments)

@ppppp2005-p

Copy link
Copy Markdown
Author

ZCode desktop demo (ZCode 4.0.0, macOS arm64)

sheet-to-app-demo.mp4

How this was tested:

  1. Installed sheet-to-app from a local marketplace built from this PR's branch.
  2. Main run (screen recording not usable because the ZCode window was minimized during it, so it is described here instead): asked ZCode to turn sheet/库存表.csv into the offline single-file app "咖啡店库存" (id kucun), report the output and data problems, then replace the sheet with sheet/库存表-更新.csv and refresh. The agent called app_new, which wrote apps/kucun/index.html and reported 4 data problems (a stock value written as "十", an empty restock date, a row with empty SKU and supplier). After copying the updated CSV over the original it called app_refresh: rows went from 15 to 16 (2 added, 1 removed), the 备注 column was dropped, 货架位置 was added, the stock value was fixed, and 1 problem was left.
  3. Recorded follow-up (the video above, a separate short task): asked ZCode to run only app_check on the existing app kucun. The panel shows the remaining problem (row 13, required 补货日期 is empty; such rows still import and are highlighted for fixing) and a static preview of the "咖啡店库存" app with search, category/supplier/on-sale filters, 新增 and 导出 CSV. The agent reports 16 rows and 1 problem. The last card is the final state.

演示说明:本地 marketplace 安装 → 正式运行 app_new(4 处数据问题)→ 覆盖 CSV → app_refresh(15 → 16 行,剩 1 处问题;该次录屏因窗口被最小化无效)→ 另开一个短任务录屏,只调 app_check,面板显示剩余问题和应用预览。

@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