refactor: remove Ink, modularize extract package#13
Merged
Conversation
- types.ts: StreamChunk, StreamCallback, ExtractOptions types - schemas.ts: Zod schemas with flexible field mapping - mime.ts: MIME type detection helper - pdf.ts: PDF to image conversion (scale 3 for quality) - ocr.ts: Tesseract.js OCR with progress callbacks - providers/ollama.ts: Ollama extraction with kero logging - providers/gemini.ts: Gemini extraction (unchanged) - extract.ts: Main extraction orchestrator - index.ts: Barrel export Improves testability and maintainability.
BREAKING: Removed React-based Ink UI in favor of simpler CLI tools. Removed: - components/: ExtractApp, OllamaStatus, StreamingOutput, etc. - hooks/: useOllama, useExtraction - contexts/: OllamaContext, ExtractionContext - Dependencies: ink, ink-spinner, react, @types/react Added: - commands/extract.ts: New extraction command with ora spinners - Dependencies: ora, prompts, chalk, @lytics/kero Benefits: - Simpler architecture (no React overhead) - Kero logging visible in terminal (was swallowed by Ink) - LOG_LEVEL=debug support for debugging - Smaller bundle size (14KB vs 30KB)
- date: Normalized ISO format (YYYY-MM-DD) for querying - dateRaw: Original date string from document for audit trail
- vitest.config.ts: Exclude barrel exports from coverage - packages/extract/package.json: Add kero dependency - pnpm-lock.yaml: Updated lockfile
- Test vendor field alternatives (store_name, merchant, business_name) - Test amount field alternatives (total, total_amount) - Test date normalization and dateRaw preservation
14 tasks
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
Major refactor to simplify the CLI and improve maintainability of the extract package.
CLI Changes
orafor spinnerspromptsfor interactive inputchalkfor colors@lytics/kerofor structured loggingLOG_LEVEL=debugsupport for debugging extraction flowExtract Package Changes
index.tsinto modules:types.ts- StreamChunk, StreamCallback typesschemas.ts- Zod schemas with flexible field mappingmime.ts- MIME type detectionpdf.ts- PDF to image conversion (scale 3 for quality)ocr.ts- Tesseract.js OCRproviders/ollama.ts- Ollama extraction with kero loggingproviders/gemini.ts- Gemini extractionextract.ts- Main orchestratorstore_name/merchant/business_name→vendortotal/total_amount→amountdate(ISO) anddateRaw(original)Core Changes
dateRawfield toDocumentDatafor audit trailTesting