Skip to content

Conversation

@prosdev
Copy link
Contributor

@prosdev prosdev commented Dec 7, 2025

Summary

Implements local, privacy-first document extraction using Ollama with llama3.2-vision.

Changes

1. Ollama Extraction (packages/extract)

  • extractWithOllama API client with vision model support
  • Base64 encoding for PDF/image input
  • Strict JSON system prompt for invoice/receipt parsing
  • Zod validation with retry on failure

2. MCP Server Refactor (packages/cli/mcp)

  • Migrate from deprecated Server to McpServer high-level API
  • Add sdk.ts barrel to hide ESM .js extensions
  • Declarative registerTool() with Zod schemas

3. Documentation

  • Add package READMEs (5 packages) optimized for semantic search
  • Update AGENTS.md with storage package
  • Add Ollama usage example to README

Testing

  • 32 tests, all passing
  • 100% statement/line/function coverage on extract package
  • Build and lint clean

Closes

Closes #3

Checklist

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
@prosdev prosdev merged commit 8708809 into main Dec 7, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intelligence: Ollama Extraction Strategy

2 participants