Phase 2 Slice 1: File Tools and Real Embeddings - #4
Conversation
… Slice 1) Add read_file, list_watched, and index_document tools with real Ollama embeddings support. Replace placeholder random vectors in search_memory with actual nomic-embed-text embeddings via Ollama /api/embeddings endpoint. Wire collector ingest pipeline to upload files and trigger indexing for text documents when folder watcher detects changes. - Add embeddings.ts with shared getEmbedding() for Ollama integration - Add file-tools.ts with read_file and list_watched tools - Add index-document.ts with index_document tool and vector upsert - Add ingest.ts with collector → bucket → index pipeline - Update folder-watcher.ts to call ingestFile() for text files - Update createJerryTools() to register new tools - Update agent instructions with new tool descriptions - Add comprehensive unit tests with mocked dependencies - Add opt-in Ollama integration tests (JERRY_OLLAMA_TEST=1) Co-authored-by: Cursor <cursoragent@cursor.com>
Replace custom embeddings.ts implementation with footnote's OllamaEmbedder which provides better error handling, automatic context length truncation, retry logic, and caching. - Add @mieweb/footnote as workspace dependency - Refactor embeddings.ts to use footnote's createEmbedder - Update tests to reset cached embedder between test runs - Keep same getEmbedding() function signature for compatibility Co-authored-by: Cursor <cursoragent@cursor.com>
|
Note: Screenshot / visual vector indexing is deferred The folder watcher already captures image files ( Indexing images meaningfully requires a multimodal embedding model (e.g. This feature will be revisited when the BYO-cloud infrastructure option lands, where larger models can be hosted remotely and accessed without requiring them to run on the developer's machine. For now, only text files ( |
tsx@^4.19.0 was removed from cloud-agent-cli and cli package.json but not from the root lockfile, causing frozen-lockfile CI failure. Co-authored-by: Cursor <cursoragent@cursor.com>
- Rewrite embeddings.ts with direct Ollama fetch calls — removes @mieweb/footnote dependency whose dist/ is gitignored and absent in CI - Fix embeddings.test.ts mock fetch casts (unknown as typeof fetch) - Remove unused StoredActivityEvent import from file-tools.ts - Add missing messages:[] to all ToolExecutionOptions in test files - Fix unknown[] index access in index-document.test.ts - Remove @mieweb/footnote from tools package.json and update lockfile Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Implements Phase 2 Slice 1 — file tools and real Ollama embeddings to complete deferred Phase 1 functionality:
read_fileandlist_watchedtools for reading bucket content and listing folder-watcher captured filesindex_documentfor embedding content into the vector storesearch_memorywith actual Ollamanomic-embed-textembeddingsChanges
packages/tools/src/runtime/embeddings.ts— shared Ollama embedding modulepackages/tools/src/runtime/file-tools.ts—read_fileandlist_watchedtoolspackages/tools/src/runtime/index-document.ts—index_documenttoolpackages/collector/src/ingest.ts— collector ingest pipelinepackages/collector/src/folder-watcher.ts— wire ingestFile() for text filespackages/tools/src/runtime/index.ts— register new tools in createJerryTools()packages/jerry-app/src/agent.ts— update agent instructions with new toolsAcceptance Criteria
read_fileandlist_watchedtools implemented and testedindex_documenttool working with real embeddingssearch_memoryuses Ollama embeddings (no random vectors).txt/.md→ collector detects → index → search)Dependencies
Testing
JERRY_OLLAMA_TEST=1Notes
nomic-embed-textmodel (768 dimensions) — must be pulled locally:ollama pull nomic-embed-text/v1/filesand/v1/indexHTTP endpoints on the worker (will be added as follow-up or documented as worker extension)Made with Cursor