How It Works
The plugin uses OpenViking’s session memory system:- Session Start: Creates a new OpenViking session when Claude starts
- During Conversation: Accumulates user and assistant messages
- Stop Hook: Summarizes each conversation turn and appends to session
- Session End: Commits the session to extract long-term memories
- Memory Recall: Provides a skill to search memories from
viking://user/memoriesandviking://agent/memories
Architecture
Mode Detection
The plugin auto-detects the backend mode:- HTTP mode (preferred): Connects to existing OpenViking server
- Reads
server.hostandserver.portfrom./ov.conf - Health checks
/healthendpoint
- Reads
- Local mode (fallback): Starts embedded OpenViking if HTTP unreachable
State Persistence
Plugin state is stored in./.openviking/memory/session_state.json:
Installation
Plugin Structure
Hook Behavior
SessionStart
./ov.conf and auto-detects backend mode (HTTP or local).
UserPromptSubmit
Adds a lightweight hint that memory is available:Stop (Async)
After each turn:- Parses the transcript for the last user and assistant messages
- Summarizes the turn (uses
claude -p --model haikuif available, otherwise local summary) - Appends both messages to the OpenViking session
- Deduplicates by turn UUID
SessionEnd
Commits the session to extract long-term memories:viking://user/memories/- User facts, preferencesviking://agent/memories/- Task execution patterns, learnings
Memory Recall Skill
Thememory-recall skill searches both user and agent memories:
Testing
E2E Test Script
Run a complete end-to-end test:- Creates Python 3.11 virtual environment
- Generates temporary
./ov.conffrom source config - Starts OpenViking HTTP server
- Runs real
claude -psession with plugin - Triggers Stop + SessionEnd
- Verifies
session_state.jsonand session archive
Configuration Options
Plugin Manifest (.claude-plugin/plugin.json)
Hook Config (hooks/hooks.json)
Async Hooks: The
stop hook runs asynchronously to avoid blocking Claude’s response. Other hooks are synchronous to ensure proper state management.Troubleshooting
Plugin not loading
Plugin not loading
Verify the plugin manifest:Ensure hooks directory exists:
ov.conf missing
ov.conf missing
The plugin requires
./ov.conf in the project root. If missing:Server connection failed
Server connection failed
Check server status:If not running:
No memories extracted
No memories extracted
Check the session was committed:Manually commit if needed:
Memory Categories
OpenViking automatically categorizes extracted memories:| Category | Storage Path | Examples |
|---|---|---|
| Preferences | viking://user/memories/preferences/ | Favorite colors, coding style, timezone |
| Events | viking://user/memories/events/ | Meeting notes, decisions, milestones |
| Facts | viking://user/memories/facts/ | User’s name, location, role |
| Skills | viking://agent/memories/skills/ | How to accomplish tasks |
| Cases | viking://agent/memories/cases/ | Task execution examples |
Limitations
- Requires
./ov.confin project root (strict mode) - Plugin state is per-project (in
./.openviking/memory/) - Does not modify OpenViking core — uses standard API
- Summarization uses
claude -p --model haikuwhen available; falls back to simple extraction
