Introduction¶
After integrating Codebase Memory (CBM) via MCP in DeepSeek Harness (DSH), semantic queries often work fine, but the knowledge graph can become stale without your knowledge: the MCP cwd is a profile-level constant, making CBM’s monitoring and auto-indexing prone to targeting the wrong directory trees; the built-in watcher lacks an observable rebuild process; and the MCP tool index_repository has a 60-second timeout. The README references a requirement document (P5) that recorded a real-world test: the graph was lagging by 33 hours, 37 commits, and 988 files, yet the user still assumed the index was up-to-date.
Below is an introduction to the DSH plugin dsh-codebase-watcher (Category: Memory), released by maintainer WwW7olFWwW. It independently determines how much the graph lags behind various git working trees, performs conditional rebuilds via the CBM CLI only when necessary, and centrally displays status on the DSH settings page and via REST interfaces. Apart from installing this plugin, there is no need to modify CBM or DSH core configurations, nor to set up additional systemd timers on the host.
What is this¶
dsh-codebase-watcher is a “graph freshness” layer beyond the single line of MCP integration: it aligns the CBM knowledge graph with the git rev-parse HEAD of each managed project to avoid silent staleness.
- Repository: github.com/WwW7olFWwW/dsh-codebase-watcher
- Community Directory: skillhub.cn plugin page (Independent site, with no official affiliation to DeepSeek / High-Flyer)
- Current package version: 0.7.1, License MIT
- Runtime Environment: Node.js ≥ 20.13, DSH ≥ 0.2.0-rc.2; requires the codebase-memory-mcp CLI to be installed (README tested with 0.11.0; versions outside the manifest will trigger a warning on the settings card)
- Prerequisites: Managed paths must be git working trees; lag determination relies on comparing HEAD with
Branch.head_shain the graph.
Core Functions¶
Lag Detection and Conditional Rebuild¶
The plugin compares Branch.head_sha in the graph with the repository’s current HEAD to provide a precise behindBy; if there is no Branch node, it falls back to using indexed_at and the database mtime. If evidence is insufficient, it explicitly reports “Cannot Determine”. Rebuilds are queued only for projects that are still lagging; if the graph is already consistent with HEAD, POST /rebuild returns queued: 0 and produces no indexing work.
Rebuilds invoke codebase-memory-mcp cli index_repository via a subprocess, bypassing the 60-second limit of the MCP tool. Global rebuild concurrency is set to 1. The README records a full rebuild taking approximately 60,980 ms, with a database size of about 658 MB and peak memory usage of roughly 2.8 GB (similar costs to CBM auto_index).
Per-project Watching and Debounce¶
Each managed project has file watching capabilities: preferring chokidar, and falling back to node:fs.watch if missing. Recursive fs.watch on Linux is available starting from Node 20.13.0 (versions 20.0–20.12 will cause per-project watching to fail directly, though scanning and conditional rebuilds are unaffected).
Settings Page “CBM Graph” Card and Sidebar Indicators¶
After installation and refreshing the settings page, a “CBM Graph” card appears. The top section displays rebuild effectiveness since the current DSH startup (queued / succeeded / failed, instances saved by cooldown and gates, cumulative time spent). The bottom section compares the graph HEAD with the working tree HEAD for each project, sorting lagging items first. The card actions share the same source as the REST control plane, totaling 7 REST routes and 18 adjustable fields (see docs/CONFIGURATION.md in the repository for details).
Persistent sidebar indicators: A warn dot is displayed if there are lagging projects; an error dot is displayed if there are rebuild/watch/scan failures or if a project is no longer in the graph; nothing is rendered when all are synced. This is purely an indicator and is not clickable.
Read-only status examples:
curl -s http://127.0.0.1:3080/api/codebase-watcher/state
curl -s http://127.0.0.1:3080/api/codebase-watcher/config
- If
statehas content andstatus.revisionis a number, it indicates the host has completed at least one scan. - If
config.runtimecontainsrebuildCooldownMs, it indicates the new generation module has been loaded; if this field is missing, restartdsh webto clear the old module cache.
Status file: ~/.dsh/codebase-watcher/state.json; Keeper log: ~/.dsh/codebase-watcher/keeper.log.
Installation and Activation¶
The package name does not yet exist on npm; do not use the bare name add dsh-codebase-watcher (it will result in a 404). Choose one of the full specifications provided in the README. Replace --profile web with your local profile name:
# GitHub Specification
dsh plugin --profile web add github:WwW7olFWwW/dsh-codebase-watcher
# Release tarball (Pre-packaged, no local build required)
dsh plugin --profile web add https://github.com/WwW7olFWwW/dsh-codebase-watcher/releases/latest/download/dsh-codebase-watcher.tgz
# Or search for dsh-codebase-watcher in the DSH Plugin Market
If codebase-memory-mcp is not in the PATH, the card will display “(Unresolved)”; you can fill in cliPath on the settings page.
It is recommended to disable CBM’s unconditional full auto_index. Otherwise, every session may still waste approximately 61 seconds, duplicating the rebuild work of this plugin. The plugin will leave a named warning on the card if it detects that it is still enabled:
codebase-memory-mcp config set auto_index false
Typical Usage¶
First Startup: Observe First, Then Scale Up¶
The first scan will manage all projects already indexed by CBM, and lagging items will enter the rebuild queue. A magnitude of three projects might correspond to several minutes of CPU usage and several GB of peak memory. The README suggests narrowing the scope on the settings page first:
includeProjects: Only manage one or two projects for a trial run.autoRebuild: false: Only observe whether the lag detection is correct before enabling automatic rebuilds.
Changes to these two items take effect immediately upon modification on the settings page.
Triggering Rebuilds via REST (Equivalent to the Card)¶
The conditional rebuild logic is consistent with the settings page button; nothing will be queued if the graph is already synced. Specific paths and request bodies are detailed in docs/CONFIGURATION.md.
Uninstallation¶
dsh plugin --profile web remove dsh-codebase-watcher
rm -rf ~/.dsh/codebase-watcher
rm -f ~/.dsh/profiles/web/node_modules/dsh-codebase-watcher
The profile name and the path in the last line need to be adjusted according to your local machine; uninstallation will not automatically delete the status directory.
Applicable Scenarios and Notes¶
Who it is for: Developers who have already integrated CBM in DSH, share the same profile across multiple projects, need observable “whether the graph keeps up with HEAD” status, and wish to rebuild only when lagging.
Differences from similar approaches (README summary):
- The similar plugin
dsh-codebase-memoryhad no new commits for a long time as of the check on 2026-10-20, had Linux path resolution issues, and lacked coverage configuration. - CBM
auto_indexperforms a full rebuild for every session; if turned off, there is no automatic update at all. - Host systemd timers or one profile per project involve touching the host or duplicating configurations, and do not easily fit the deployment mode where DSH is resident via systemd with a fixed
WorkingDirectory.
Security and Permissions: The plugin runs under the user and permissions of the current dsh web process. It executes git probes, calls the CBM CLI, and listens to project directories. You should read the repository source code and the MIT license before installation to confirm that the paths and CLI sources are trustworthy.
Known Limitations: Projects rooted at the home directory do not support CBM monitoring (upstream policy); graph structure declarations alone cannot serve as evidence for lag; for others, see docs/LIMITATIONS.md.
Conclusion¶
dsh-codebase-watcher transforms CBM graph freshness from “assuming it is up-to-date” into a verifiable, throttle-able, and REST-controllable process: rebuild only when lagging, with effectiveness displayed on the settings card. The DeepSeek Harness ecosystem advocates “Everything is a Plugin”; if you are already using CBM, you can install it via the commands above and verify the detection using includeProjects and autoRebuild: false on the first startup.
- Directory Page: https://www.skillhub.cn/plugins/WwW7olFWwW/dsh-codebase-watcher
- Source Code and Documentation: https://github.com/WwW7olFWwW/dsh-codebase-watcher