feat(extract): implement Ollama extraction strategy#8
Merged
Conversation
Implement local privacy-first document extraction using Ollama API. Implementation: - Add extractWithOllama function using Ollama API (/api/generate) - Create Zod schema for DocumentData validation - Add MIME type detection helper for PDF/image files - Implement retry logic (once) on Zod validation failure - System prompt enforces strict JSON output format Features: - Supports llama3.2-vision model (default) - Handles PDF and image formats (PNG, JPEG, GIF, WebP) - Validates AI output against DocumentData schema - Graceful error handling for API and parsing errors Testing: - 5 tests covering successful extraction, retry logic, error handling - Mock fetch for isolated unit testing - 100% function coverage for Ollama extraction Issue: #3
Refactor MCP server to use the modern McpServer high-level API, replacing the deprecated Server class. Add barrel exports across packages for cleaner imports. Implementation: - Migrate from deprecated Server to McpServer (registerTool API) - Create sdk.ts barrel to hide .js extension ESM imports - Add zod for schema validation in MCP tool definitions - Add barrel exports to storage package (db, schema types) - Add barrel exports to mcp package (server, sdk) - Add tsup configs for all packages Features: - McpServer with declarative registerTool() API - Zod schemas for automatic input validation - Clean imports via barrel files (no .js extensions in main code) - Comprehensive re-exports from storage package Testing: - 32 tests, all passing - Build succeeds across all packages - Lint clean Breaking Changes: - MCP server internals refactored (external API unchanged)
Add minimal, search-optimized READMEs to all packages: - core (8 lines): Type definitions - extract (24 lines): Vision AI providers, env vars - storage (22 lines): SQLite persistence, schema - vector-store (15 lines): Stub status, planned features - cli (35 lines): Commands, MCP tools, options Also update: - AGENTS.md: Add storage package to repo structure - README.md: Add Ollama usage example Design: - Problem-oriented descriptions for semantic search - Use cases as searchable bullet points - Exports, dependencies, gotchas - No fluff, just signal
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
Implements local, privacy-first document extraction using Ollama with
llama3.2-vision.Changes
1. Ollama Extraction (
packages/extract)extractWithOllamaAPI client with vision model support2. MCP Server Refactor (
packages/cli/mcp)ServertoMcpServerhigh-level APIsdk.tsbarrel to hide ESM.jsextensionsregisterTool()with Zod schemas3. Documentation
Testing
Closes
Closes #3
Checklist