af0fe03f12
- Add 02-01-SUMMARY.md with full execution record and deviation documentation - Update STATE.md: Phase 2 Plan 1 complete, resume at 02-02-PLAN.md - Update REQUIREMENTS.md: mark REND-03, REND-10, NAV-06, NAV-07 complete
4.5 KiB
4.5 KiB
phase, plan, subsystem, tags, dependency_graph, tech_stack, key_files, decisions, metrics
| phase | plan | subsystem | tags | dependency_graph | tech_stack | key_files | decisions | metrics | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 02-vault-core-and-rendering | 01 | vault-and-highlighter |
|
|
|
|
|
|
Phase 02 Plan 01: Vault Core and Highlighter Summary
One-liner: pulldown-cmark/syntect/syntect-tui dependencies added with VaultDocument file-loading enum and OnceLock-based CGA-mapped syntax highlighter.
What Was Built
Task 1: Dependencies and vault file-loading module
Added three new dependencies to Cargo.toml:
pulldown-cmark = "0.13.1"— markdown event parsersyntect = { version = "5.3", default-features = false, features = ["default-fancy"] }— syntax highlighting with pure-Rust regex enginesyntect-tui = "3.0"— bridge between syntect and ratatui
Created src/vault.rs with:
VaultDocumentenum:Loaded { path, content },Missing { path },ReadError { path, reason }load_document(vault_path: &Path, relative: &str) -> VaultDocumentusingstd::fs::read_to_stringwith properErrorKind::NotFounddiscrimination
Task 2: Syntax highlighter module with CGA color mapping
Created src/highlighter.rs with:
static SYNTAX_SET: OnceLock<SyntaxSet>andstatic THEME_SET: OnceLock<ThemeSet>for one-time initializationinit_highlighter()— call once beforeApp::new()syntax_set()andtheme_set()accessor functions with expect panics on uninitialized statesyntect_color_to_cga(c: Color) -> ratatui::style::Color— Euclidean distance RGB-to-CGA 16-color quantization across the full classic CGA palettehighlight_code(code: &str, lang: &str) -> Vec<Line<'static>>— full pipeline: syntax lookup by token/name/fallback,base16-ocean.darktheme, per-lineHighlightLines::highlight_line(), CGA color mapping, owned String SpansLinesWithNewlinesprivate iterator that preserves trailing\nper line for correct syntect grammar matching
Verification
cargo buildsucceeds with all new dependencies (53 packages locked)src/vault.rscontainsVaultDocumentenum withLoaded,Missing,ReadErrorvariantssrc/vault.rscontainsload_document()function usingstd::fs::read_to_stringsrc/highlighter.rscontainsinit_highlighter(),highlight_code(),syntect_color_to_cga()- No changes to existing Phase 1 files (app.rs, main.rs, config.rs, signals.rs, terminal.rs)
Deviations from Plan
Auto-fixed Issues
1. [Rule 2 - Missing Critical Functionality] Added LinesWithNewlines iterator
- Found during: Task 2
- Issue: syntect's
highlight_line()expects lines to include their trailing\nterminator so language grammars can match end-of-line anchors. Usingstr::lines()strips newlines, causing grammar state machine errors in some syntect definitions. - Fix: Added a private
LinesWithNewlinesiterator that yields substrings including the\nterminator, with correct handling for the final line without a trailing newline. - Files modified: src/highlighter.rs
- Commit:
8d45a7c
Commits
| Hash | Task | Description |
|---|---|---|
7622d41 |
Task 1 | feat(02-01): add Phase 2 deps and vault file-loading module |
8d45a7c |
Task 2 | feat(02-01): add syntax highlighter module with CGA color mapping |