Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
25173b3
docs: add V2 roadmap, Legado comparison, and archive old plans
Mar 15, 2026
9f3d73e
feat(F01): ReaderLifecycleCoordinator — extract shared lifecycle from…
Mar 16, 2026
47b1d91
feat(F02): FormatCapabilities — per-format feature flags with context…
Mar 16, 2026
b2c8f63
feat(F03): ReflowableTextSource — unified text segment provider for T…
Mar 16, 2026
ae192c4
feat(F04): BackupProvider — shared protocol for WebDAV and iCloud backup
Mar 16, 2026
f78a9a9
feat(F09): LocatorNormalizer — cross-mode position normalization
Mar 16, 2026
91fbc11
feat(F11): PageNavigator — shared page navigation protocol + base class
Mar 16, 2026
bf7ec4a
chore: Phase 0 Sprint 1 project file updates + phase0 plan
Mar 16, 2026
7f3ff46
feat(F05): sample-based encoding detection for large TXT files
Mar 16, 2026
a235563
feat(F06): persistent FTS5 search index with corruption recovery
Mar 16, 2026
489a46e
feat(F07): ReadingMode toggle — Native vs Unified engine selector
Mar 16, 2026
a3e1035
feat(F08): TextKit 2 spike — DECISION: USE TextKit 2
Mar 16, 2026
725edad
feat(F10): mode-switch persistence tests — 17 integration tests
Mar 16, 2026
7a9e9e9
chore: Phase 0 Sprint 2 project file updates
Mar 16, 2026
e281408
fix: Phase 0 Codex audit — 5 findings fixed + 10 new tests
Mar 16, 2026
413fbb0
feat(A01): #22 search match highlighting in result list
Mar 16, 2026
95aa091
feat(A02): #30 custom book covers — store + tests
Mar 16, 2026
dddefef
feat(A03): #25 configurable tap zones — left/center/right actions
Mar 16, 2026
13ada03
feat(A04): #32 reading theme backgrounds — custom images + opacity
Mar 16, 2026
98f2db7
feat(A05): #37 per-book reading settings — optional overrides
Mar 16, 2026
08991ad
chore: Phase A project file updates + settings integration
Mar 16, 2026
27e00ec
fix: Phase A Codex audit — 4 findings fixed
Mar 16, 2026
e1bde46
feat(B01): #23 TXT TOC rules — Legado 25 patterns ported
Mar 16, 2026
e0c86f9
feat(B02): #33 dictionary / define / translate-on-select
Mar 16, 2026
45ad1d8
feat(B12): #21 EPUB simple vs complex classifier
Mar 16, 2026
afed6be
chore: Phase B Sprint 1 project files + reader integration
Mar 16, 2026
26964f3
feat(B03): #26 TTS read aloud — AVSpeechSynthesizer + control bar
Mar 16, 2026
9e16d9a
feat(B06): #21 Native EPUB paged layout via CSS columns
Mar 16, 2026
ccffc8f
feat(B08): #21 Native TXT/MD paged layout via TextKit 1
Mar 16, 2026
73cae0c
feat(B09): #21 Native PDF page navigation via tap zones
Mar 16, 2026
26e2874
chore: Phase B Sprint 3 project file updates
Mar 16, 2026
4a4ba05
feat(B04): #21 Unified TXT reflow engine — TextKit 2 scroll + paged
Mar 16, 2026
d446326
docs: add phase plans (A-E) + manual test checklist
Mar 16, 2026
2e53005
feat(B05): #21 Unified MD reflow — attributed text pagination
Mar 17, 2026
b61803b
feat(B07): #21 Unified EPUB text-mode — strip HTML to attributed text
Mar 17, 2026
b8fbd58
feat(B10): #31 auto page turning — timer-based page advancement
Mar 17, 2026
c294add
feat(B11): #21 page turn animations — none/slide/cover
Mar 17, 2026
23338ff
feat(B13): #21 pagination cache invalidation
Mar 17, 2026
d70ba3c
chore: Phase B completion + Codex-reviewed plan fixes for C/D/E
Mar 17, 2026
54cdcf9
fix: Phase B Codex audit — 10 findings fixed + 38 new tests
Mar 17, 2026
6eda06e
refactor: split ReaderContainerView + wire F01/A05/B08/B10/B11
Mar 17, 2026
0312ee3
feat(C01): #34 collections / tags / series — SchemaV3
Mar 17, 2026
501b0d8
feat(C02): #35 annotation export — Markdown + JSON
Mar 17, 2026
2d42add
feat(C04): #36 OPDS catalog — browse + download from OPDS 1.2 feeds
Mar 17, 2026
07eeddc
chore: Phase C Sprint 1 project files
Mar 17, 2026
b20718f
feat(C03): #35 annotation import — VReader JSON round-trip
Mar 17, 2026
1251d64
feat(D01): #24 BookSource model + SwiftData + management UI
Mar 17, 2026
eb151a9
feat(D02): #24 HTTP client + encoding detection + rate limiting
Mar 17, 2026
281dd45
feat(D03): #24 rule engine — CSS selectors + regex + Legado syntax
Mar 17, 2026
fa760ec
feat(D05): #24 Legado JSON import/export + compatibility classification
Mar 17, 2026
1bb4827
chore: Phase D Sprint 2 project files
Mar 17, 2026
e06c449
feat(D04): #24 pipeline MVP — search → info → chapters → content
Mar 17, 2026
cf9d8b5
feat(D06): #24 chapter cache + offline reading
Mar 17, 2026
4b70dd4
feat(D07): #24 update detection + source sharing
Mar 17, 2026
055b11e
chore: Phase D Sprint 4 project files
Mar 17, 2026
f0e0078
feat(E01): #29 WebDAV backup and restore
Mar 17, 2026
f63e09d
feat(E03+E04+E05): text-mapping layer + simp/trad + replacement rules
Mar 17, 2026
a5d6e95
feat(E06): #26 HTTP TTS — cloud voice synthesis
Mar 17, 2026
a917dd5
chore: Phase E project files — V2 ROADMAP COMPLETE
Mar 17, 2026
84230cb
fix: final V2 audit — 5 critical integration gaps closed
Mar 17, 2026
4d796d6
fix: wire all 10 missing UI integrations — every feature reachable
Mar 17, 2026
9bfc48e
fix: 17 bug fixes (#60-#78) — performance, gestures, chrome, TOC, per…
Mar 21, 2026
fa17a91
chore: architecture doc, device-verified feature status, 21 bug issues
Mar 21, 2026
1dd414d
refactor(R1+R2): persistence tests + unified notification modifier
Mar 21, 2026
80a11af
refactor(R4a+R4b): highlight renderer protocol, format adapters, coor…
Mar 21, 2026
bede264
refactor(R5a+R5b): slim containers under 350 lines, bridges under 400…
Mar 21, 2026
9f27443
refactor(R6): extract shared ViewModel lifecycle to ReaderLifecycleHe…
Mar 21, 2026
64849e9
refactor: audit fixes — PDF coordinator wiring, dead code removal, do…
Mar 22, 2026
7dbf63f
refactor: final audit cleanup — orphaned tests, plan/doc alignment
Mar 22, 2026
7f3749c
test(R1): highlight integration tests — coordinator + renderer flows
Mar 22, 2026
33a56eb
fix: 6 high-severity bugs (#89, #92, #95, #96, #100, #101)
Mar 22, 2026
cbee042
fix: Codex audit — SchemaV4 migration, TTS session release, AI tab reset
Mar 22, 2026
862810d
chore: revised feature fix plan + architecture doc update
Mar 22, 2026
a864d96
fix: Phase 2 quick fixes — #97, #85, #86, #84
Mar 22, 2026
79d9ebb
test(Phase 0): RED tests for bugs #77, #82, #98
Mar 22, 2026
70e00bd
fix: Phase 2 moderate bugs — #77, #82, #83, #88, #98
Mar 22, 2026
30362b7
feat: Phase 4 — tap zones UI, theme bg picker, TTS highlight + scroll
Mar 22, 2026
b23cf20
chore: update plan — Phase 4 done (4/5 features implemented)
Mar 22, 2026
24f52e1
feat: iCloud Sync foundation — Phase 1 + Phase 2 infrastructure
Mar 22, 2026
6e051a7
feat: add SyncRecordDTOs — lightweight CK transfer types
Mar 22, 2026
f1fc445
fix: Codex audit — 3 High + 3 Med findings in Sync layer
Mar 22, 2026
56be108
fix: verify pass — flush race + tombstone throwing (audit follow-up)
Mar 22, 2026
14c9cba
docs: update README — 38 features, iCloud Sync, TTS highlight
Mar 22, 2026
813f291
fix: EPUB rendering overhaul — comprehensive CSS, pagination, preproc…
Mar 22, 2026
8785d26
perf: defer non-critical work from book open path (all formats)
Mar 22, 2026
a495fad
perf: permanent fix — lazy EPUB extraction + background TXT decode
Mar 22, 2026
06b09c2
test: update expectations for perf changes (session non-fatal, CSS)
Mar 22, 2026
4971d34
test: update EPUB parser test for persistent cache behavior
Mar 22, 2026
eff3d87
feat: vendor foliate-js bridge — CFI, SVG overlay, TTS SSML, footnotes
Mar 22, 2026
b8781ff
feat: wire foliate-js — SVG highlights, footnote detection, TTS SSML
Mar 22, 2026
36d0779
fix: Codex audit — 4 High issues in perf + foliate changes
Mar 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .claude/tdd-guardian/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enabled": true,
"testCommand": "xcodebuild test -project vreader.xcodeproj -scheme vreader -destination 'platform=iOS Simulator,name=iPhone 16' -quiet",
"testCommand": "DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcodebuild test -project vreader.xcodeproj -scheme vreader -destination 'platform=iOS Simulator,name=iPhone 17 Pro' -only-testing:vreaderTests -quiet",
"coverageCommand": "",
"coverageSummaryPath": "",
"mutationCommand": "",
Expand Down
2 changes: 1 addition & 1 deletion .claude/tdd-guardian/state.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"last_gate_passed_at": "2026-03-11T12:00:00Z", "tests_passed": 1508, "coverage_passed": true, "last_head_sha": "ea2fb68e7a90bfd2a28149d1924e968151bb8909"}
{"last_gate_passed_at": "2026-03-22T02:48:19Z", "tests_passed": 3167, "coverage_passed": true, "last_head_sha": "cbee04292cfa0465bd8e408e8dcd62376eec740e"}
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Shared instructions for all AI agents (Claude, Codex, etc.).

- You are an AI assistant working on the project.
- **Read `docs/architecture.md` before making any code changes. Update it when adding new layers, patterns, services, or changing how components communicate.**
- Use English unless another language is requested.
- Follow the working agreement:
- Run `git status -sb` at session start.
Expand All @@ -21,7 +22,8 @@ Shared instructions for all AI agents (Claude, Codex, etc.).
- Write a failing test (RED), implement minimally (GREEN), refactor (REFACTOR).
- Coverage thresholds are enforced — `ut` fails if coverage drops.
- Exceptions: CSS-only, docs, config. See `.claude/rules/10-tdd.md` for full scope.
- Run ut for gates.
- Run `xcodebuild test -only-testing:vreaderTests` for unit test gates. Skip UI tests during development.
- Default simulator: **iPhone 17 Pro** (Dynamic Island — catches safe area bugs).
- **Task workflow** (three files, one flow):
- `docs/tasks.md` — **inbox**. User writes free-form descriptions. Agent triages (classify only, do not fix or implement during triage). See `docs/tasks.md` for classification rules, deduplication, and triage record format.
- `docs/bugs.md` — **bug tracker**. Something implemented but broken. Follow the bug fix workflow defined in `docs/bugs.md` (Understand → RED → GREEN → REFACTOR → Verify → Track).
Expand Down
119 changes: 82 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,83 @@
# VReader

An iOS reader app for EPUB, PDF, TXT, and Markdown files — built with Swift 6, SwiftUI, and SwiftData.
**Built entirely by AI — coded, tested, and debugged by AI agents. Human-directed.**

An iOS reader for EPUB, PDF, TXT, and Markdown — built entirely by AI coding agents, with Swift 6, SwiftUI, and SwiftData.

## About

VReader is a modern reading app designed for iPhone and iPad. It provides a unified reading experience across multiple document formats with features like reading position persistence, bookmarks, highlights, full-text search, and reading time tracking. Documents sync across devices via iCloud.
VReader is a modern reading app designed for iPhone and iPad, built entirely by AI coding agents (Claude Code + Codex CLI) with human direction on requirements and testing. It provides a dual-mode reading experience (native UIKit + unified TextKit 2 reflow) across multiple document formats with annotations, full-text search, AI assistant, TTS, book source scraping, and WebDAV backup.

## Features

- **Multi-format support** — Read EPUB, PDF, TXT, and Markdown files in a single app
- **Reading position persistence** — Automatically saves and restores your scroll position per book, surviving app backgrounding, kills, and relaunches
- **CJK & encoding support** — Automatic encoding detection for GBK, Big5, Shift-JIS, EUC-KR, and other non-UTF-8 files
- **Large file performance** — Chunked rendering (UITableView) for TXT files over 500K characters; no glyph storage blowup
- **Bookmarks & highlights** — Save your place and annotate passages with color-coded highlights and notes
- **EPUB/PDF annotation** — Text selection + highlight/note actions in EPUB (CSS Highlight API) and PDF (PDFAnnotation). Persists across sessions via unified AnnotationAnchor schema
- **Full-text search** — Search across your entire library with SQLite FTS5 and CJK-aware tokenization. Highlights match at destination
- **Reading progress bar** — Draggable scrubber in all 4 formats: continuous for TXT/MD, page-based for PDF, chapter-based for EPUB
- **Table of contents** — Auto-generated for Markdown (heading extraction), built-in for EPUB/PDF
- **AI assistant** — Summarize sections, multi-turn chat with book context, bilingual translation (9 languages), general AI chat. OpenAI-compatible API
- **Reading time tracking** — Automatic session tracking with per-book statistics and reading speed calculations
- **Reader settings** — Configurable font size, font family, line spacing, letter spacing, and theme
- **Library management** — Grid/list view with persistent preferences, book info sheet, share, context menu
- **Import from anywhere** — Open files via Share Sheet, Files app, or direct download
### Reading
- **Multi-format** — EPUB, PDF, TXT, Markdown in a single app
- **Dual-mode engine** — Native (UIKit bridges) + Unified (TextKit 2 reflow) rendering
- **Reading position** — Auto-saves scroll position, survives app kills and relaunches
- **CJK encoding** — Auto-detect GBK, Big5, Shift-JIS, EUC-KR (8KB sample-based)
- **Large file support** — Chunked UITableView for TXT files >500K characters
- **Paginated mode** — CSS columns (EPUB), TextKit containers (TXT/MD), PDFKit pages
- **Page turn animations** — Slide, cover-flip, or instant
- **Auto page turning** — Timer-based advancement with configurable interval
- **Configurable tap zones** — Left/center/right zones mapped to customizable actions

### Annotations
- **Bookmarks, highlights, notes** — Full CRUD for all formats (TXT/MD/PDF/EPUB)
- **EPUB highlights** — CSS Highlight API with JS bridge + buffered delivery
- **PDF highlights** — PDFAnnotation-based with selection detection
- **TXT/MD highlights** — NSAttributedString with persistent rendering
- **Export/import** — Markdown + JSON export, VReader JSON round-trip import

### Search & Navigation
- **Full-text search** — SQLite FTS5 with CJK tokenization, persistent index
- **Reading progress bar** — Draggable scrubber (continuous, page-based, chapter-based)
- **Table of contents** — EPUB nav/NCX, PDF outline, TXT auto-detection (25 Legado rules), MD headings
- **Dictionary** — System dictionary lookup + AI translation on text selection

### AI
- **Summarization** — Section and chapter summaries via OpenAI-compatible API
- **Chat** — Multi-turn conversation with book context
- **Translation** — Bilingual view (9 languages)
- **General chat** — AI chat without book context

### Library
- **Grid/list view** — Persistent sort order and view mode
- **Collections** — Tags, series, custom groups
- **Custom covers** — Set from photo library
- **Context menu** — Info, share, set cover, delete
- **OPDS catalog** — Browse and download from OPDS 1.2 feeds
- **Book sources** — Legado-compatible rule engine for web novel scraping

### Text Processing
- **TTS** — System (AVSpeechSynthesizer) + cloud HTTP TTS with playback controls
- **TTS sentence highlight** — NLTokenizer-based sentence detection synced to speech position
- **TTS auto-scroll** — Text view follows speech position in real-time
- **Simp/Trad Chinese** — Toggle conversion via ICU (live re-apply without reloading)
- **Content replacement** — Regex rules for text cleanup (live re-apply via source text storage)
- **Reading time tracking** — Per-book session stats and speed calculations

### Sync & Backup
- **iCloud Sync** (foundation) — CloudKit sync engine, record mapper (8 types), device identity, change tokens, durable tombstones, settings bridge (NSUbiquitousKeyValueStore)
- **WebDAV backup** — Archive to any WebDAV server (Nutstore compatible)
- **Per-book settings** — Font, theme, spacing overrides per book (JSON-persisted)
- **Theme backgrounds** — Custom background images via PhotosPicker with per-theme opacity

## Tech Stack

| Component | Technology |
| ----------- | -------------------------------------------------- |
| UI | SwiftUI |
| Persistence | SwiftData + CloudKit |
| Persistence | SwiftData (SchemaV4) |
| EPUB | WKWebView bridge with CSS theme injection + JS highlight API |
| PDF | PDFKit + PDFAnnotation for highlights |
| TXT | TextKit 1 (UITextView) + chunked UITableView |
| Markdown | NSAttributedString rendering via MDParser |
| Search | SQLite FTS5 with CJK tokenization |
| AI | OpenAI-compatible API (summarize, chat, translate) |
| TTS | AVSpeechSynthesizer + HTTP cloud TTS |
| Backup | WebDAV client + iCloud Sync foundation (CloudKit) |
| Encoding | ICU + heuristic detection (UTF-8/GBK/Big5/Shift-JIS) |
| Concurrency | Swift 6 strict concurrency |
| Project gen | XcodeGen |

## Requirements

Expand All @@ -59,27 +99,28 @@ Then select a simulator or device and run.

## Architecture

See [`docs/architecture.md`](docs/architecture.md) for the full architecture document.

```
vreader/
├── App/ # App entry point, configuration
├── Models/ # SwiftData models (Book, ReadingPosition, Bookmark, etc.)
├── App/ # App entry point, SwiftData schema init
├── Models/ # SwiftData models, DocumentFingerprint, Locator
├── ViewModels/ # Library and per-format reader view models
├── Views/
│ ├── Reader/ # Reader views per format (EPUB, PDF, TXT, MD)
│ ├── Library/ # Library views, book info, context menu
│ ├── Settings/ # AI settings, preferences
│ └── AI/ # Chat view
├── ViewModels/ # Per-reader and per-feature view models
│ ├── Reader/ # Reader container, format bridges, chrome overlay
│ ├── Bookmarks/ # BookmarkListView, TOCListView
│ ├── Annotations/ # HighlightListView, AnnotationListView
│ └── Settings/ # ReaderSettingsPanel, AI/TTS/WebDAV settings
├── Services/
│ ├── EPUB/ # EPUB parsing and rendering
│ ├── TXT/ # TXT service, chunker, attributed string builder
│ ├── MD/ # Markdown parser and renderer
│ ├── Search/ # FTS5 indexing, text extraction, tokenization
│ ├── AI/ # AI service, configuration, context extraction
│ ├── Sync/ # iCloud sync coordination
│ └── Locator/ # Reading position model (Readium-inspired)
└── Utils/ # Helpers, extensions, encoding detection
vreaderTests/ # Unit tests (2040+ test cases)
vreaderUITests/ # UI tests (XCTest)
│ ├── TXT/, EPUB/ # Format-specific parsing and loading
│ ├── Search/ # FTS5 indexing, text extraction
│ ├── AI/, TTS/ # AI service, TTS providers
│ ├── Backup/ # WebDAV client, BackupProvider
│ ├── Sync/ # iCloud sync engine, CloudKit mapper, tombstones
│ ├── TextMapping/ # Simp/Trad, replacement rules
│ └── Locator/ # Reading position (Readium-inspired)
vreaderTests/ # Unit tests (3200+ test cases)
vreaderUITests/ # UI tests (XCUITest)
```

### Key Design Decisions
Expand All @@ -92,7 +133,7 @@ vreaderUITests/ # UI tests (XCTest)

## AI-Powered Development

VReader is built using an AI-assisted coding workflow with multiple agents collaborating through structured processes.
All code, tests, bug fixes, and documentation are produced by AI coding agents. The human role is directing requirements, reporting bugs, and verifying on device.

### Tools

Expand Down Expand Up @@ -129,6 +170,10 @@ Shared rules for all AI agents live in [`AGENTS.md`](AGENTS.md):
- `CLAUDE.md` — Claude Code project instructions
- `AGENTS.md` — Shared instructions for all AI coding agents

## Status

Active development. See [features](docs/features.md) (38 done) and [bugs](docs/bugs.md) (87 fixed) for current state.

## License

TBD
MIT
Loading