Wenyi EPUB Tools
A local agent plugin that guides an agent through parsing EPUB books with the
official Wenyi CLI. The bundled runner validates the EPUB path and delegates to
wenyi parse; Wenyi itself stores the parsed document and state beside the
input book.
Layout
wenyi_plugin/
├── plugin.json # Agent Plugins manifest
├── skills/
│ ├── wenyi-epub/
│ │ └── SKILL.md # Parse workflow and subagent handoff
│ ├── language-detection/
│ │ └── SKILL.md # Source detection and target resolution
│ └── subagent-workflow/
│ └── SKILL.md # Delegation workflow bundled with the plugin
├── tools/
│ ├── parse_book.py # Parse one EPUB through Wenyi CLI
│ ├── assemble_book.py # Export and finalize translated EPUB
│ ├── finalize_epub.py # Localize NAV/NCX and repair cover metadata/page
│ ├── translation_batches.py # Plan and validate paragraph-safe batches
│ ├── setup_wenyi.sh # Clone/install the upstream CLI
│ └── README.md
└── assets/
├── icon.png # Full-color plugin icon
├── icon-source.svg # Editable icon source
└── prompts/
├── chapter_digest_*.txt # Per-chapter summary prompt templates
├── analyzer_*.txt # Whole-book style analysis templates
├── book_synopsis_*.txt # Whole-book understanding templates
├── translator_*.txt # Main text translation templates
└── *.txt # Other retained Wenyi prompt templates
Requirements
- macOS or Linux shell environment
- Git
uv- Python 3.10+ (managed by
uvwhen needed) - A host that supports subagents for language identification, parallel chapter digests, style/synopsis generation, and user-authorized parallel translation
Prepare Wenyi
./tools/setup_wenyi.sh
By default, the upstream checkout and CLI environment are placed under
~/.cache/wenyi-cli/wenyi. To use an existing clone:
WENYI_REPO=/path/to/wenyi ./tools/setup_wenyi.sh
Parse an EPUB
python3 ./tools/parse_book.py /path/to/book.epub
The parser lists chapter titles and paragraph counts, and writes
parsed_document.json into Wenyi's state directory. After parsing, the
the wenyi-epub skill delegates language identification to a subagent, then
uses the bundled chapter digest prompts to generate each chapter's summary in
parallel. When every digest is complete, it delegates one full-book style
analysis task using the bundled Wenyi analyzer prompts. After style analysis,
it delegates one whole-book synopsis task using Wenyi's synopsis prompts and
the style analysis plus all chapter digests. The synopsis is saved as
agent_book_synopsis.txt. Parsing, digest generation, style analysis, and
synopsis generation do not translate the book or create an EPUB export. See
tools/README.md for details.
The workflow stops after the whole-book synopsis is saved and reported. It
waits for the user's explicit instruction before beginning whole-book
translation. After that instruction, it writes a range manifest and batches
contiguous segments to about 10,000 source characters, splitting long chapters
only between paragraphs. Each returned translation carries its chapter and
segment indices so the workflow can detect missing, duplicate, or reordered
ranges before writing targets into Wenyi state. It translates batches in
parallel subagents with Wenyi's prompts in
assets/prompts/translator_*.txt. Accepted translations are checkpointed in
agent_translations.json and merged into Wenyi chapter state. During export,
the workflow localizes the EPUB 3 navigation document and EPUB 2 NCX by default
(the user can keep original TOC labels), then repairs EPUB 3 and EPUB 2 cover
metadata and simplifies inline SVG cover pages when a raster cover image exists.
Export runs Wenyi's official assemble command through
tools/assemble_book.py.
Retained prompts
The original language-detection prompt template is also kept in
assets/prompts/ for reference.