| version | 1.0.0 |
| name | epub-rendering-and-cfi |
| description | Implement resilient EPUB rendering and annotation anchoring per ADR-006. Activate for reader-core, TOC, locator, or highlight anchoring changes.
|
| category | workflow |
| allowed-tools | Read Write Edit Grep Glob |
| license | MIT |
Skill: epub-rendering-and-cfi
Purpose: implement resilient EPUB rendering, locator extraction, and annotation anchoring for d.o.EPUB Studio.
When to run
- Integrating EPUB.js or reader-core changes.
- Working on TOC, locator, or highlight/comment anchoring logic.
- Debugging annotation drift or EPUB loading regressions.
Inputs
plans/006-adr-annotation-model.md
packages/reader-core/*
- EPUB sample assets (if needed)
Workflow
- Read ADR + data model – confirm multi-signal locator requirements (CFI + text + chapter + DOM fallback).
- Design anchors – map DOM selections →
{ cfi, selectedText, chapterRef, elementIndex, charOffset }.
- Implement – use EPUB.js APIs (
rendition.annotations, book.getToc(), book.locations.generate()), ensure async cleanup.
- Resilience – add re-anchoring strategy (exact match → fuzzy text → chapter fallback → user notice).
- Performance – lazy-load EPUB assets, reuse single rendition, clean up listeners to avoid leaks.
- Testing – add Vitest cases for locator serialization + re-anchor helpers; capture regressions with reader-core testkit.
Checklist