feat: Ink CLI with rich UX and OCR preprocessing#11
Merged
Conversation
Replace ora/chalk with Ink (React for CLIs) for a richer terminal experience: Components: - OllamaStatus: Health check with clear setup instructions - ExtractionProgress: Live elapsed time for slow extractions - ErrorDisplay: Friendly errors with suggestions - Result: JSON output display UX improvements: - When Ollama isn't running: show install/setup instructions - When extraction is slow: show elapsed time + reassurance - Clear visual hierarchy with colors and symbols Dependencies: - ink ^6.5.1 (React for CLIs) - react ^19.2.1 - ink-spinner ^5.0.0 Addresses #5
Features: - Add Ink React components for interactive CLI experience - Implement Ollama auto-install/auto-start flow with prompts - Add native Ink progress bar for model pulling via HTTP API - Support multiple providers (Ollama, Gemini) with --model flag - Extract services/hooks/contexts for testable architecture - Add dependency injection via React Context Tests (67 total, 75% coverage): - Add useExtraction hook tests (extraction flow, dry-run, errors) - Add useOllama hook tests (install/start flows, auto-confirm) - Add OllamaStatus component tests using ink-testing-library - Add Ollama service tests (API checks, model pulling) - Exclude barrel files from coverage Other: - Make Zod schema lenient to handle model output variations - Update default Gemini model to gemini-2.5-flash - Add example receipt PDF for testing
- Add tesseract.js for OCR text extraction - OCR all PDF pages in parallel before vision model processing - Include OCR text in prompt as primary reference for text/numbers - Vision model uses image for layout context only Fixes #10: Botella Agua price now correctly extracts as $3.49 (was $1.90) Trade-offs: - +15MB install size (WASM files) - +2-5s processing time per page - Significantly improved accuracy for financial documents
- Add OCR processing tests (5 tests) - Mock tesseract.js to avoid worker cleanup issues in tests - Update existing test to expect OCR text in prompts 72 tests passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a rich, interactive CLI experience using Ink (React for terminals) and OCR preprocessing for accurate document extraction.
Closes
Changes
CLI UX (Issue #5)
--modelflagOCR Preprocessing (Issue #10)
Testing
Trade-offs
Test