-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: Multi-source watcher framework for multi-tool AI log monitoring #2674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
huang-yi-dae
wants to merge
6
commits into
volcengine:main
Choose a base branch
from
huang-yi-dae:feature/multi-watcher
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
52b0a34
feat: Active Daemon - multi-source AI tool log watcher framework
huang-yi-dae 9623ca9
fix(daemon): fix ETL pipeline not flushing events and invalid URI routes
huang-yi-dae 0136fbc
feat(daemon): add BasePollingWatcher and CursorDBWatcher for SQLite-b…
huang-yi-dae f6f260f
docs(daemon): update db-watcher plan with E2E results and cursor fix
huang-yi-dae 17fd773
chore(daemon): add license headers, trim watchers to verified set, re…
huang-yi-dae 3b8a63d
fix(daemon): resolve CRLF cursor drift, file truncation, and quiet-se…
huang-yi-dae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # OpenViking Active Daemon | ||
|
|
||
| 自动监听 Claude Code 会话日志,提取知识并写入 OpenViking 知识库。 | ||
|
|
||
| ## 快速开始 | ||
|
|
||
| ### 启用 Daemon | ||
|
|
||
| 设置环境变量: | ||
|
|
||
| ```bash | ||
| export OV_DAEMON_ENABLED=true | ||
| export OV_DAEMON_WATCH_DIR=~/.claude/projects # 监听目录(可选) | ||
| export OV_DAEMON_BATCH_LINES=50 # 批处理触发行数(可选) | ||
| export OV_DAEMON_BATCH_SECONDS=300 # 批处理触发秒数(可选) | ||
| ``` | ||
|
|
||
| ### 启动 OpenViking Server | ||
|
|
||
| ```bash | ||
| openviking serve | ||
| ``` | ||
|
|
||
| Daemon 会在服务器启动时自动运行(如果 `OV_DAEMON_ENABLED=true`)。 | ||
|
|
||
| ## 工作原理 | ||
|
|
||
| 1. **文件监听** — 监控 `~/.claude/projects/` 下的 `.jsonl` 文件变化 | ||
| 2. **增量读取** — 文件游标技术,只处理新增内容 | ||
| 3. **批量处理** — 累积 50 行或 5 分钟后触发 ETL 管道 | ||
| 4. **知识提取** — 调用 LLM 过滤噪声,提取有价值的知识 | ||
| 5. **自动存储** — 写入 `viking://resources/skills/`、`viking://resources/memories/`、`viking://resources/` | ||
|
|
||
| ## 知识分类 | ||
|
|
||
| | 类型 | 目标路径 | 说明 | | ||
| |------|---------|------| | ||
| | Skills | `viking://resources/skills/<source>/<title>.md` | 可复用的操作指南 | | ||
| | Memories (有项目) | `viking://resources/memories/<project>/decisions.md` | 项目决策日志 | | ||
| | Memories (无项目) | `viking://resources/memories/global/<title>.md` | 全局记忆 | | ||
| | Resources | `viking://resources/<tech>/<title>.md` | 参考资源 | | ||
|
|
||
| > **注意**:viking:// URI 只支持 `resources/`、`user/`、`agent/` 三个顶级 scope。所有知识统一路由到 `resources/` 下。 | ||
|
|
||
| ## 架构 | ||
|
|
||
| ``` | ||
| Claude Code JSONL → File Watcher → Batch Buffer → Filter → Reconstruct | ||
| → LLM Extract → Deduplicate → Route → viking:// Storage | ||
| ``` | ||
|
|
||
| ## 故障排查 | ||
|
|
||
| ### Daemon 未启动 | ||
| 检查日志中是否有 `Active Daemon is disabled` 消息,确认 `OV_DAEMON_ENABLED=true`。 | ||
|
|
||
| ### 没有提取到知识 | ||
| - 确认 Claude Code 正在写入 JSONL 文件(`~/.claude/projects/` 下有 `.jsonl` 文件) | ||
| - 对话内容可能不够有价值(简单问答会被过滤) | ||
| - 查看日志中的 ETL 处理信息 | ||
|
|
||
| ### 知识写入失败 | ||
| 检查 OpenViking ResourceService 是否正常运行。 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Active Daemon 配置指南 | ||
|
|
||
| ## 环境变量 | ||
|
|
||
| | 变量 | 说明 | 默认值 | | ||
| |------|------|--------| | ||
| | `OV_DAEMON_ENABLED` | 启用 Daemon | `false` | | ||
| | `OV_DAEMON_WATCH_DIR` | 监听目录 | `~/.claude/projects` | | ||
| | `OV_DAEMON_DB_PATH` | 游标数据库路径 | `~/.qoderworkcn/openviking/daemon_cursors.db` | | ||
| | `OV_DAEMON_BATCH_LINES` | 批处理触发行数 | `50` | | ||
| | `OV_DAEMON_BATCH_SECONDS` | 批处理触发秒数 | `300` | | ||
|
|
||
| ## JSON 配置 (ov.conf) | ||
|
|
||
| > **重要**:daemon 配置必须放在 `"server"` 节内,不是顶层配置。ov.conf 的 JSON 解析器不支持 `#` 注释。 | ||
|
|
||
| 单 watcher 配置: | ||
|
|
||
| ```json | ||
| { | ||
| "server": { | ||
| "port": 1988, | ||
| "daemon": { | ||
| "enabled": true, | ||
| "watch_dir": "~/.claude/projects", | ||
| "batch_trigger_lines": 50, | ||
| "batch_trigger_seconds": 300 | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 多 watcher 配置(推荐,支持同时监听多个 AI 工具): | ||
|
|
||
| ```json | ||
| { | ||
| "server": { | ||
| "port": 1988, | ||
| "daemon": { | ||
| "enabled": true, | ||
| "watchers": [ | ||
| { | ||
| "tool_name": "claude_code", | ||
| "watch_dir": "C:\\Users\\xxx\\.claude\\projects", | ||
| "batch_trigger_lines": 5, | ||
| "batch_trigger_seconds": 60 | ||
| }, | ||
| { | ||
| "tool_name": "cursor_db", | ||
| "watch_dir": "C:\\Users\\xxx\\AppData\\Roaming\\Cursor\\User\\globalStorage", | ||
| "poll_interval": 60 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| `watchers` 数组中每项支持 `tool_name`、`watch_dir`、`batch_trigger_lines`、`batch_trigger_seconds`、`extra` 字段。当 `watchers` 存在时,顶层的 `watch_dir` 被忽略。 | ||
|
|
||
| ## Docker 部署 | ||
|
|
||
| ```yaml | ||
| services: | ||
| openviking: | ||
| image: openviking:latest | ||
| environment: | ||
| - OV_DAEMON_ENABLED=true | ||
| - OV_DAEMON_WATCH_DIR=/data/claude-projects | ||
| - OV_DAEMON_DB_PATH=/data/daemon.db | ||
| volumes: | ||
| - ./claude-projects:/data/claude-projects | ||
| - ./daemon-data:/data | ||
| ports: | ||
| - "1933:1933" | ||
| ``` | ||
|
|
||
| ## 日志 | ||
|
|
||
| Daemon 使用 OpenViking 标准日志系统。关键日志: | ||
|
|
||
| - `Claude Code watcher started on ...` — 监听器启动 | ||
| - `Flushing batch with N events` — 批处理触发 | ||
| - `Extracted N knowledge items` — 知识提取完成 | ||
| - `Knowledge ingested: viking://...` — 知识写入成功 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be placed in docs/zh/agent-integrations