Skip to content

feat(ui-plugins): add DOCX Mail Merge (docx-mail-merge) - #254

Open
ppppp2005-p wants to merge 11 commits into
zai-org:mainfrom
ppppp2005-p:feat/docx-mail-merge
Open

ppppp2005-p wants to merge 11 commits into
zai-org:mainfrom
ppppp2005-p:feat/docx-mail-merge

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) / 涉及的插件名称:docx-mail-merge (UI Plugin, new)

What / 改动内容

New community UI plugin DOCX Mail Merge / Word 批量套打: Fill a Word template’s {{field}} placeholders from a spreadsheet to make one .docx per row — offer letters, contracts, notices, certificates — with all formatting, tables, headers and footers kept. Check missing columns and empty values, fix data in the panel, preview the first document and export the files plus a zip. Runs locally; no API keys.

  • Tools: merge_open, merge_edit, merge_status, merge_export (all share one side panel: file picker, settings, issue list, editable table, preview, export).
  • Template: type placeholders like {{Name}} or {{姓名}} anywhere in a Word document — body text, tables, headers, footers, footnotes. Placeholders that Word split across differently formatted runs are still found, and the replaced text keeps the formatting of the placeholder’s first character.
  • Data: .xlsx or .csv; column names must match the field names. Multi-line values become line breaks.
  • Checks: fields with no matching column (blocks export), columns the template does not use, rows with empty values, and repeated file names.
  • File names: a pattern such as {姓名}-录用通知书 or {n} for the row number.
  • Output: one .docx per row, an optional zip of all documents, and a CSV log listing empty fields per file.
  • Scope (v0.1):
    • Plain text replacement only: no conditional sections, repeating table rows, images or Word MERGEFIELD fields in v0.1.
    • Output is DOCX (convert to PDF in Word or WPS if needed). Old .doc templates: save as .docx first.
    • Nothing is emailed.
  • Local only; writes only docx-mail-merge/ in the workspace. Workspace paths are checked so symlinks cannot lead reads or writes outside the workspace (regression test included).
  • Tests: vitest unit + MCP tool tests on real sample files, and a browser e2e with the official AppBridge host (panel → open → edit → export).

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, opened offer-template.docx + new-hires.xlsx from p100/docx-mail-merge/ and exported 3 merged .docx files, the zip and the log; demo video in the comments)

@ppppp2005-p

Copy link
Copy Markdown
Author

ZCode desktop demo (ZCode 4.0.0, macOS arm64)

docx-mail-merge-demo.mp4

Flow shown:

  1. Installed docx-mail-merge from a local marketplace built from this PR's branch.
  2. Asked ZCode to open the Word template offer-template.docx and the data sheet new-hires.xlsx and export right away (only merge_open and merge_export).
  3. merge_open found 9 fields in the template ({{姓名}} {{职位}} {{部门}} {{入职日期}} {{月薪}} {{试用期}} {{上级}} {{回复截止}} {{公司}}), 0 missing, and 3 documents to make. The side panel (Word 批量套打) shows the file-name rule, the rows (李明, 陈晓雨, Alex Turner), a live preview of 李明.docx, and 1 warning: row 2 (Alex Turner) has an empty 上级.
  4. merge_export wrote docx-mail-merge/offer-template/documents/李明.docx, 陈晓雨.docx, Alex Turner.docx, plus all-documents.zip and merge-log.csv. The last card shows the final state and the generated 李明.docx (all fields filled, template styles kept).

演示流程:本地 marketplace 安装 → merge_open(模板 9 个字段、3 份文档、1 条提醒:Alex Turner 的上级为空)→ merge_export 生成 3 份录用通知书 docx、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