Skip to content

feat(ui-plugins): add Word Count Report (word-count-report) - #307

Open
ppppp2005-p wants to merge 11 commits into
zai-org:mainfrom
ppppp2005-p:feat/word-count-report
Open

ppppp2005-p wants to merge 11 commits into
zai-org:mainfrom
ppppp2005-p:feat/word-count-report

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) / 涉及的插件名称:word-count-report (UI Plugin, new)

What / 改动内容

New community UI plugin Word Count Report / 字数统计: Count the words in a whole folder of manuscripts — Word documents, Markdown, plain text and PDFs — the way Chinese editors and translators count them: Chinese characters, Chinese punctuation and English words separately, with a 字数 total that matches Word. Every file is split into chapters by its headings or “第一章 / Chapter 1” lines, with reading time and an optional fee per thousand words. Leave out code blocks, tables, references and anything matching your own rules, or switch off single chapters. Export the report as Excel or CSV. Runs locally; no upload, account or API keys.

  • Tools: wordcount_open, wordcount_edit, wordcount_status, wordcount_export (all share one side panel: file picker, settings, issue list, editable table, preview, export).
  • Chinese-aware counting: CJK characters, CJK punctuation and other words separately; 字数 = all three, the same as Word's count. Japanese and Korean count as characters.
  • Many formats at once: .docx, .md, .txt and text-based .pdf — single files or whole folders.
  • Chapters: DOCX heading styles, Markdown # / ##, and “第一章 / 序章 / Chapter 1” lines in text and PDF.
  • Leave things out: code blocks, tables, headings, everything from 参考文献 / References onward, paragraphs matching your text or /regex/ rules, or any chapter you switch off.
  • Reading time and fees: reading speed for Chinese and English, and a rate per 1,000 words, characters or English words.
  • Report: per chapter, per file and totals in Excel, plus a CSV.
  • Scope (v0.1):
    • Scanned PDFs without a text layer count as 0 (no OCR).
    • Footnotes, comments and text boxes in DOCX headers and footers are not counted.
  • Local only; writes only word-count-report/ 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 a manuscripts folder (4 files: pdf, md, txt, docx; 235 words by chapter, references not counted), exported word-count.xlsx and word-count.csv with a ¥120 per 1,000 words fee; 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)

word-count-report-demo.mp4

Flow shown:

  1. Installed word-count-report from a local marketplace built from this PR's branch.
  2. Asked ZCode to open the folder p100/word-count-report/manuscripts (a .pdf, .md, .txt and .docx) with a rate of 120 per 1,000 words, fix anything that blocks the export with wordcount_edit, then export.
  3. wordcount_open counted 4 files by chapter (12 rows), with no blocking errors, so wordcount_edit was not needed. It reported two info notes: one paragraph in the 绿茶 chapter of notes.md was skipped by an exclude rule, and tea-book.docx stops counting from the 参考文献 heading (the default "stop counting from these headings" setting).
  4. The panel (字数统计) shows the settings: by chapter, heading level 2, exclude rules, stop headings 参考文献|References, count tables/headings/numbers, reading speeds, and the 120 per 1,000 rate.
  5. wordcount_export wrote word-count-report/manuscripts/word-count.xlsx (By chapter, By file, Totals) and word-count.csv. The second image shows the By file sheet and the Totals sheet: 235 words (175 CJK characters, 23 CJK punctuation, 37 Latin words), with a fee of ¥28.20 (235 × 120 / 1000). The references chapter is listed as not counted.

演示流程:本地 marketplace 安装 → wordcount_open(文件夹内 4 个文件按章节统计,参考文献章不计入)→ wordcount_export 导出 Excel 和 CSV;第二张图是“按文件”和“汇总”两张表:共 235 字,按每千字 120 元计稿费 ¥28.2。

@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