feat: OpenViking Active Daemon - Automatic Knowledge Extraction from Claude Code Logs#2629
feat: OpenViking Active Daemon - Automatic Knowledge Extraction from Claude Code Logs#2629huang-yi-dae wants to merge 22 commits into
Conversation
The vector DB layer already stores timestamps for all memories, but the Markdown file layer (MEMORY_FIELDS metadata) never included them. This meant that reading a memory file directly gave no indication of when it was created or last updated. Changes: - memory_updater.py: _apply_upsert now injects created_at (preserved on updates, set to now for new files) and updated_at (always refreshed) into MEMORY_FIELDS after merging schema fields. - memory_type_registry.py: initialize_memory_files now includes created_at/updated_at when creating initial identity.md, soul.md, etc. - Added TestUpsertTimestamps with two regression tests covering new-file and update scenarios. The serialization/deserialization infrastructure in memory_file_utils.py already supported these fields — the gap was only in the write path. 🤖 Generated with [Qoder][https://qoder.com]
- Add i18n translations for daemon status in English and Chinese - Create DaemonStatusCard component with real-time status polling - Integrate daemon status card into home page layout - Card displays enabled/running status, watch directory, batch settings, cursor count, and last flush time - Auto-refreshes every 30 seconds with graceful error handling
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
duplicated with #2674 |
Summary
This PR implements the OpenViking Active Daemon, a background service that automatically monitors Claude Code JSONL logs and extracts valuable knowledge into viking:// storage.
Features
Core Functionality
~/.claude/projects/for Claude Code session changes using watchdogThree Ways to Enable
ov.conf configuration (recommended):
{ "server": { "daemon": { "enabled": true, "watch_dir": "~/.claude/projects", "batch_trigger_lines": 50, "batch_trigger_seconds": 300 } } }CLI argument:
Environment variables:
export OV_DAEMON_ENABLED=true openviking serveWeb Studio Integration
/studio/home)API Endpoint
GET /api/v1/daemon/statusreturns current daemon stateArchitecture
Files Changed
New Files (12)
openviking/daemon/models.py- Data models (FileCursor, BatchBuffer, ConversationTurn, ExtractedKnowledge)openviking/daemon/cursor_manager.py- SQLite-based cursor persistenceopenviking/daemon/deduplicator.py- MD5 content deduplicationopenviking/daemon/watchers/claude_code_watcher.py- Watchdog-based file monitoringopenviking/daemon/filters.py- Rule-based low-value conversation filteringopenviking/daemon/conversation_reconstructor.py- User/assistant pairing logicopenviking/daemon/knowledge_extractor.py- LLM-based knowledge extractionopenviking/daemon/etl_pipeline.py- Batch ETL orchestrationopenviking/daemon/knowledge_router.py- viking:// URI routingopenviking/daemon/storage_adapter.py- ResourceService write adapteropenviking/daemon/service.py- Main DaemonService with lifecycle managementtests/daemon/* (8 test files)- 45 unit/integration testsModified Files (5)
openviking/server/config.py- Added DaemonConfig nested in ServerConfigopenviking/server/bootstrap.py- Added --with-daemon CLI argumentopenviking/server/app.py- Integrated daemon lifecycle in FastAPI lifespanweb-studio/src/routes/home/route.tsx- Added DaemonStatusCard componentweb-studio/src/i18n/locales/*- Added daemon translations (en/zh-CN)Testing
Usage Example
Start server with daemon enabled:
export OV_DAEMON_ENABLED=true openviking serveVisit http://127.0.0.1:1933/studio/home to see the daemon status card.
Commits: 22 commits on
feature/active-daemonbranchTest Coverage: 45 tests, all passing