Skip to content

Phase 2 Slice 1: File Tools and Real Embeddings - #4

Merged
SarkarShubhdeep merged 4 commits into
developmentfrom
phase2/file-tools-embeddings
Jul 8, 2026
Merged

Phase 2 Slice 1: File Tools and Real Embeddings#4
SarkarShubhdeep merged 4 commits into
developmentfrom
phase2/file-tools-embeddings

Conversation

@SarkarShubhdeep

@SarkarShubhdeep SarkarShubhdeep commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements Phase 2 Slice 1 — file tools and real Ollama embeddings to complete deferred Phase 1 functionality:

  • File tools: read_file and list_watched tools for reading bucket content and listing folder-watcher captured files
  • Index tool: index_document for embedding content into the vector store
  • Real embeddings: Replace random-vector placeholder in search_memory with actual Ollama nomic-embed-text embeddings
  • Ingest pipeline: Collector → bucket → vector index pipeline for text file indexing

Changes

  • packages/tools/src/runtime/embeddings.ts — shared Ollama embedding module
  • packages/tools/src/runtime/file-tools.tsread_file and list_watched tools
  • packages/tools/src/runtime/index-document.tsindex_document tool
  • packages/collector/src/ingest.ts — collector ingest pipeline
  • packages/collector/src/folder-watcher.ts — wire ingestFile() for text files
  • packages/tools/src/runtime/index.ts — register new tools in createJerryTools()
  • packages/jerry-app/src/agent.ts — update agent instructions with new tools
  • Unit tests for all new modules with mocked dependencies

Acceptance Criteria

  • read_file and list_watched tools implemented and tested
  • index_document tool working with real embeddings
  • search_memory uses Ollama embeddings (no random vectors)
  • Collector → footnote pipeline functional
  • Unit tests pass; Ollama integration test documented
  • Acceptance scenario verified manually for text files (drop .txt/.md → collector detects → index → search)
  • Acceptance scenario verified manually (drop screenshot → index → search)

Dependencies

  • Depends on: None (first slice)
  • Blocks: Slice 2 (MCP Consume), Slice 3 (MCP Expose)

Testing

  • Unit tests: All new tools have unit tests with mocked bucket/vectors/fetch — all pass
  • Integration tests: Opt-in Ollama integration test available via JERRY_OLLAMA_TEST=1
  • Manual verification: Pending (requires local stack with Ollama + nomic-embed-text model)

Notes

  • Uses nomic-embed-text model (768 dimensions) — must be pulled locally: ollama pull nomic-embed-text
  • Graceful fallback when Ollama unavailable — tools return informative error messages
  • Acceptance scenario requires /v1/files and /v1/index HTTP endpoints on the worker (will be added as follow-up or documented as worker extension)

Made with Cursor

SarkarShubhdeep and others added 2 commits July 6, 2026 10:35
… 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>
@SarkarShubhdeep

Copy link
Copy Markdown
Collaborator Author

Note: Screenshot / visual vector indexing is deferred

The folder watcher already captures image files (.png, .jpg, .gif, .webp) and pushes them as screenshot events, but embedding and indexing image content into the vector store is not implemented in this slice and is explicitly deferred.

Indexing images meaningfully requires a multimodal embedding model (e.g. llava, clip, or a vision-capable model), which is significantly larger than nomic-embed-text and not suitable for the current local-only runtime target.

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 (.txt, .md, .json) flow through the full collector → bucket → embed → vector index pipeline.

SarkarShubhdeep and others added 2 commits July 8, 2026 11:53
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>
@SarkarShubhdeep
SarkarShubhdeep merged commit 234154a into development Jul 8, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Review to Done in Scrum Team Jerry Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant