Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.

feat: Add Ollama-based semantic memory system#102

Merged
Spacehunterz merged 1 commit into
mainfrom
feature/semantic-memory-ollama
Jan 29, 2026
Merged

feat: Add Ollama-based semantic memory system#102
Spacehunterz merged 1 commit into
mainfrom
feature/semantic-memory-ollama

Conversation

@Spacehunterz
Copy link
Copy Markdown
Owner

Summary

Adds semantic memory integration using Ollama embeddings (nomic-embed-text) for context-aware learning retrieval in Claude Code sessions.

This is an alternative implementation to the existing sentence-transformers approach, using Ollama for fully local embeddings without requiring cloud API keys.

Components Added

Component Description
src/semantic/ Flask daemon with /store, /recall, /health, /stats, /migrate-heuristics endpoints
src/hooks/semantic-hooks/ Bash hooks for Claude Code (UserPromptSubmit, PreCompact, Stop)
src/hooks/windows/ PowerShell equivalents with full feature parity
apps/dashboard/backend/routers/semantic.py Dashboard API integration
data/seed_heuristics.json Initial heuristics export (6 golden rules)

How It Works

  1. UserPromptSubmit hook: On every prompt, queries semantic memory and injects relevant learnings as XML context
  2. PreCompact hook: Captures session transcript before context compaction
  3. Stop hook: Captures session on clean exit for later learning extraction
  4. Daemon: Flask server on port 8888 using Ollama's nomic-embed-text (768 dimensions)

Test Coverage

  • Unit tests for daemon endpoints
  • Integration tests for hook chain
  • E2E workflow tests
  • Load testing utility
  • ~94% code coverage

Test plan

  • Verify Ollama is installed with ollama list
  • Run src/semantic/install.sh
  • Start daemon with src/semantic/start-daemon.sh
  • Test endpoints: curl http://localhost:8888/api/semantic/health
  • Run test suite: cd src/semantic/tests && ./run_tests.sh
  • Symlink hooks to ~/.claude/hooks/ and verify memory injection

🤖 Generated with Claude Code

Adds semantic memory integration using Ollama embeddings (nomic-embed-text)
for context-aware learning retrieval in Claude Code sessions.

Components added:
- src/semantic/ - Flask daemon for embedding storage/recall
  - daemon.py - /store, /recall, /health, /stats, /migrate-heuristics endpoints
  - install.sh, start-daemon.sh - Installation and startup scripts
  - systemd service file for Linux deployment
  - Comprehensive test suite (unit, integration, e2e, load tests)

- src/hooks/semantic-hooks/ - Claude Code hook scripts
  - UserPromptSubmit.sh - Injects relevant memories on each prompt
  - PreCompact.sh - Captures session before context compaction
  - Stop.sh - Captures session on clean exit

- src/hooks/windows/ - Windows PowerShell equivalents
  - Full feature parity with bash versions
  - .ps1 scripts + .cmd wrappers
  - Installation and test utilities

- apps/dashboard/backend/routers/semantic.py - Dashboard API integration
  - Store/recall/health/stats/migrate endpoints via REST

- data/seed_heuristics.json - Initial heuristics export (6 rules)

This is an alternative to the sentence-transformers approach, using
Ollama for local embeddings without requiring cloud API keys.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Spacehunterz Spacehunterz merged commit 6b24dc9 into main Jan 29, 2026
30 of 33 checks passed
@Spacehunterz Spacehunterz deleted the feature/semantic-memory-ollama branch January 29, 2026 08:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant