Skip to content

feat(ui-plugins): add Text Cleanup (text-cleanup) - #309

Open
ppppp2005-p wants to merge 13 commits into
zai-org:mainfrom
ppppp2005-p:feat/text-cleanup
Open

ppppp2005-p wants to merge 13 commits into
zai-org:mainfrom
ppppp2005-p:feat/text-cleanup

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

What / 改动内容

New community UI plugin Text Cleanup / 中文文本排版清洗: Tidy up Chinese and mixed Chinese–English writing in Markdown and text files. It fixes half-width punctuation inside Chinese sentences, full-width letters and digits, …… and ——, straight quotes, the space between Chinese and English words or numbers, stray spaces around punctuation, repeated spaces and extra blank lines. Code blocks, inline code, link addresses and front matter are never touched. Review every changed line side by side, skip or hand-edit any of them, then export cleaned copies of the files, a diff and a change list. Your originals stay as they are. Runs locally; no upload or API keys.

  • Tools: cleanup_open, cleanup_edit, cleanup_status, cleanup_export (all share one side panel: file picker, settings, issue list, editable table, preview, export).
  • Punctuation: half-width , . ! ? : ; ( ) inside Chinese → full-width; … and -- → …… and ——; straight quotes → “ ” in Chinese sentences.
  • Spacing: a space between Chinese and English, numbers or inline code; no spaces around full-width punctuation; repeated spaces collapsed.
  • Width: full-width letters and digits (ABC123) → half-width.
  • Lines: trailing spaces trimmed, extra blank lines removed; optionally !!! → !.
  • Safe for Markdown: code blocks, inline code, link URLs, images, HTML tags, math and front matter are left alone; English-only lines aren't changed.
  • Review first: every changed line with before/after highlighted; skip it or edit the result; choices survive when you toggle rules.
  • Copies, not overwrites: cleaned files in their own folder, a unified diff and a CSV change list.
  • Scope (v0.1):
    • UTF-8 text, .md and .txt; Word documents are not edited.
    • Typography only — no spelling or grammar checks.
  • Local only; writes only text-cleanup/ 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 docs folder (draft.md, notes.txt: 12 changes in 2 files, code, links and front matter untouched), exported cleaned copies, changes.diff and changes.csv; 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)

text-cleanup-demo.mp4

Flow shown:

  1. Installed text-cleanup from a local marketplace built from this PR's branch.
  2. Asked ZCode to open the folder p100/text-cleanup/docs (draft.md, notes.txt) with "merge repeated punctuation" turned on, fix anything that blocks the export with cleanup_edit, then export.
  3. cleanup_open found 12 changed lines in 2 files and no blocking issues, so cleanup_edit was not needed. All changes were accepted.
  4. cleanup_export wrote cleaned copies under text-cleanup/docs/cleaned/… (the originals are not touched), plus changes.diff and changes.csv. The second image lists the changed lines from changes.csv. It covers a space between Chinese and Latin text or digits, half-width punctuation inside Chinese changed to full-width, full-width ABC123 changed to half-width, .../-- changed to ……/——, straight quotes changed to “ ”, extra blank lines and spaces collapsed, and !!! changed to !. The front matter, inline code, the link URL, the code block and the English line were left unchanged.
  5. ZCode pointed out one miss in this run: 地点:3楼 kept its half-width colon, because the rule skipped a colon followed by a digit. Follow-up commit "fix(text-cleanup): convert a colon or comma after Chinese even when a digit follows" on this branch fixes it, with unit tests (地点:3楼,价格:12元 → 地点:3楼,价格:12元, while 时间 10:30 is unchanged).

演示流程:本地 marketplace 安装 → cleanup_open(2 个文件 12 处修改,全部接受)→ cleanup_export 导出清洗后的副本、changes.diff 和 changes.csv;第二张图是改动前后对照。本次发现 地点:3楼 冒号后跟数字时没转全角,已在本分支追加提交修复。

@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