Staleness keeper for the Codebase Memory knowledge graph: it compares the graph Branch node head_sha with git rev-parse HEAD and reports an exact behindBy, rebuilds only the stale projects through the codebase-memory-mcp CLI so the MCP tool 60-second cap does not apply, watches each project for edits, and mirrors the same state into a settings card and a REST control surface.
Install
# from a prebuilt release tarball
dsh plugin --profile web add -w "https://github.com/WwW7olFWwW/dsh-codebase-watcher/releases/latest/download/dsh-codebase-watcher.tgz"
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:WwW7olFWwW/dsh-codebase-watcher
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
English | 中文
Wiring Codebase Memory (CBM) into DeepSeek Harness (DSH) with a single MCP row works fine for queries; what breaks is that the graph goes stale silently. The MCP cwd is a profile-level constant, so CBM's watching and auto-index land on the wrong tree. CBM's built-in watcher produces no observable rebuild, and the MCP tool index_repository has a 60-second cap. In one measured case the graph was 33 hours, 37 commits and 988 files behind while everyone believed it was current (raw data: P5 in docs/REQUIREMENTS.md).
dsh-codebase-watcher measures how far the graph is behind, calls CBM's CLI to rebuild only when it has to, and shows the result on the settings card. Beyond installing the plugin there is nothing to change in CBM or DSH, and no systemd timer to set up.
Requirements
- Codebase Memory: the
codebase-memory-mcpCLI, tested on 0.11.0. Other versions still work and turn into a card warning. When the CLI is not onPATHthe card shows "(unresolved)"; setcliPathon the settings page. - Node.js ≥ 20.13 and DSH ≥ 0.2.0-rc.2, both declared in this plugin's
engines. Recursivefs.watchon Linux only exists from Node 20.13.0 (nodejs/node#45098); on 20.0–20.12 per-project watching fails outright, while scanning and conditional rebuilds keep working. - The project must be a git worktree: staleness comes from comparing
git rev-parse HEADagainst the graph'sBranch.head_sha.
Installation
This package is not on npm yet, so the bare name add dsh-codebase-watcher returns 404. Use one of these full specs:
# 1. GitHub spec
dsh plugin --profile web add github:WwW7olFWwW/dsh-codebase-watcher
# 2. Release tarball (prebuilt: no build step, no build-script approval)
dsh plugin --profile web add https://github.com/WwW7olFWwW/dsh-codebase-watcher/releases/latest/download/dsh-codebase-watcher.tgz
# 3. Plugin market: search dsh-codebase-watcher
--profile web is the profile name on this machine — substitute your own: dsh plugin --profile <your profile> add ….
A "CBM Graph" card then appears under Settings; reload the page once if it does not.

How to confirm it worked
curl -s http://127.0.0.1:3080/api/codebase-watcher/state
curl -s http://127.0.0.1:3080/api/codebase-watcher/config
statereturns something andstatus.revisionis a number ⇒ the host half is alive and at least one scan has run.runtime.rebuildCooldownMsis visible inconfig⇒ the new generation is loaded. If that field is missing you are still on the old module cache; restartdsh web.
Turn off the upstream full rebuild
CBM's auto_index is an unconditional full rebuild: the graph may have just been updated and HEAD may not have moved, but opening a session runs it again anyway. Measured at 60,980 ms / 658 MB of database / 2,858 MB peak memory.
codebase-memory-mcp config set auto_index false
Leave it on and every session burns about 61 seconds for nothing, while duplicating this plugin's rebuilds. When the plugin starts and sees it still enabled, it leaves a named warning on the card.
First run
The first scan adopts every project Codebase Memory has already indexed, and queues the stale ones for rebuild. Rebuilds run one at a time (global concurrency 1) at the cost above — three projects can mean three minutes of CPU and several GB of peak memory. Narrow the scope before you widen it:
includeProjects: adopt only one or two named projects; start with one.autoRebuild: false: observe only, touch nothing, until you trust the verdicts.
Both are settings-page fields and take effect immediately.
Features
- Staleness detection: the graph's
Branch.head_shaagainstgit rev-parse HEAD, giving an exactbehindBy. With noBranchnode it falls back toindexed_atand the database mtime; when the evidence is insufficient it reports "cannot be determined". - Conditional rebuild: only stale projects are queued. When the graph already matches HEAD,
POST /rebuildreturnsqueued: 0and no indexing work happens. - Visible payoff: the card carries a payoff block showing rebuilds queued / succeeded / failed since this process started (aborted attempts are counted separately, not as failures), how many rebuilds the cooldown and gate skipped, and cumulative rebuild time.
- Sidebar indicator: visible without opening Settings — a warn dot when projects are stale, an error dot when a rebuild, a watcher or a scan has failed, or a project is no longer in the graph; nothing is rendered at all when everything is up to date (quiet is the default). It is informational only, not clickable.
Rebuilds run as a child process, codebase-memory-mcp cli index_repository, which sidesteps the 60-second cap on the MCP tool. Every adopted project gets file watching with debounce, so a save is picked up on its own; without chokidar it falls back to node:fs.watch.
The settings card and the REST control plane share one source, so every card action can also be hit with curl. The card header and each project row link into the CBM graph UI (?project= deep-links to a single project); when the UI is disabled or its URL is invalid no link is shown, and when it is enabled but unreachable the header keeps the link and marks it "not responding" while project rows show none.
Measured
| Item | Result |
|---|---|
| Unit tests | node --test test/*.test.js → 244 tests / 244 pass / 0 fail (the count only grows) |
| Host half against the real CBM CLI | node tools/verify-keeper.mjs → 23/23 |
| Client rendering (fixtures, no server) | node tools/verify-client.mjs --fixture-only → 316/316 |
All three are re-runnable. The unit tests need no prior index; verify-keeper needs the CLI on PATH and at least one indexed project; verify-client in --fixture-only mode needs no server (the same command CI runs), while the full mode without the flag also compares against a running dsh web and its count varies with the number of live projects. The end-to-end item — the graph catching up after a commit, and how long the index itself takes — is in the verification table in docs/DEVELOPMENT.md.
Rebuild chasing: A/B
The 45-second cooldown in 0.3.0 lowered the frequency of the rebuild storm without curing it — a project being actively edited still burned a full rebuild at a steady interval, every one of them aborted mid-flight, and the graph never caught up once. The same tool, two versions:
| 0.3.0 | 0.4.0 (dirtySettleSeconds: 90) |
|
|---|---|---|
| Rebuilds during editing | 10 | 0 |
| Successful rebuilds | 0 | 1 |
Aborted by aborted_previous_preserved |
10 | 0 |
| Graph caught up after you stop | no | yes |
| Injected probe calls | 214 | 66 (−69%) |
| — of which CBM CLI | 112 | 9 (−92%) |
npm run bench re-runs it with zero external dependencies; CI runs the same tool with --assert --settle 90, so this behaviour coming back turns the build red.
This is a proportional model, not wall-clock seconds. The real CbmKeeper, the real node:fs.watch and real timers are used, but the git probe, the CBM CLI and the rebuild itself are injected stand-ins — a call count equals the number of real child processes. Time is compressed by about 1/30 (ratios preserved, so it extrapolates), which means the catch-up seconds have to be scaled back up to get real time.
Why not an existing option
- A sibling plugin:
dsh-codebase-memoryhas had no new commits since 2026-08-26 (checked 2026-10-20); its Linux path resolution always fails with no setting to override it, and its bundle id collides. - CBM's built-in
auto_index: an unconditional full rebuild that burns 61 seconds at every session start; switch it off and you get no automatic updates at all. This plugin rebuilds only what is stale. - Anything outside the host: a systemd timer means touching the host; one profile per project means copying every other setting N times; starting DSH from the project directory is impossible because DSH runs under systemd with a fixed
WorkingDirectory.
The full comparison is in section 7 of docs/REQUIREMENTS.md.
Compatibility
| Plugin | DSH | Codebase Memory |
|---|---|---|
0.7.x |
>=0.2.0-rc.2 (verified locally on 0.2.1-rc.2; declared via engines.dsh) |
codebase-memory-mcp@0.11.0 (versions outside the list turn into a card warning) |
Configuration
18 tunable fields and 7 REST routes: docs/CONFIGURATION.md. Edit the fields right on the card (Settings → "CBM Graph" → Show settings) and press Save changes; defaults are one click away (only the fields you changed are cleared).

State lives in ~/.dsh/codebase-watcher/state.json and the log in ~/.dsh/codebase-watcher/keeper.log. Read-only query: curl -s http://127.0.0.1:3080/api/codebase-watcher/state.
Known limitations
chokidar is an optional dependency; without it the watcher falls back to node:fs.watch. Projects rooted at the home directory are not watched by CBM (upstream security policy). The graph's structural claims cannot be used as evidence.
Everything else is in docs/LIMITATIONS.md.
Removal
dsh plugin --profile web remove dsh-codebase-watcher
rm -rf ~/.dsh/codebase-watcher
rm -f ~/.dsh/profiles/web/node_modules/dsh-codebase-watcher
Substitute your own profile name in the first line too. The last line clears a known pnpm leftover for link: packages: the symlink stays in node_modules after the dependency is gone. Uninstalling does not delete the state directory; remove it yourself.
Development
node --test test/*.test.js # 244 unit tests, no real index needed
Architecture | Verification status | Requirements | Publishing | Contributing | Changelog | Issues
License
MIT © 2026 WwW7olFWwW
Links
More in this category
yjh051108/dsh-routing-suite★ 7027
One repository, three parts: a runtime injector for DSH plugin packages (inject, hot-reload, unload, promote a dev staging tool to the front, route self-heal, plus a settings-page plugin manager that lists, unloads and drags folders in to internalize), a task-aware reasoning-mode router agent preset (router-standard / router-spec / router-react), and a graded two-level task protocol whose six tools (commit_star, lock_stage, revise_do, edit_plan, mark_task, redteam_verdict) pin task state to disk. The injector implementation ships in-tree, so the install carries its own behaviour rather than a dependency list.
strukto-ai/mirage#dsh★ 3950
Swaps the filesystem and bash providers for a mirage virtual workspace: file tools and shell commands run over mounted resources (RAM, S3, Redis, Slack, Gmail, Notion, Postgres) instead of the host disk, with per-mount read/write/exec modes, per-command sandbox routing (monty, pyodide, quickjs in process; docker, e2b, daytona remote), and installed CLIs (git, gh, slack, linear, ntn, gws, or one you register) as head words in the virtual terminal.
first-fluke/oh-my-agent#dsh★ 1494
Runs project OMA checks before and after tool execution and when a turn tries to finish. Installs its OMA CLI dependency and initializes unconfigured projects on first use. Requires Node.js 22+; initial setup needs network access and project write access.
MichengAI/dsh-skills-manager★ 631
Manages local DeepSeek Harness skills in Settings and shows shared Agent skills as read-only.
hust-open-atom-club/oh-dsh★ 326
Community distribution: TUI, desktop, and Web UI as one bundle with layered installation.
Fishquito7/dsh-skill-mcp-panel★ 291
Manages DSH skills and MCP servers from the web settings: skill cards with hot enable/disable, workspace scopes, groups, batch migration and drag-and-drop import, plus stdio/HTTP MCP CRUD with connection tests, secret redaction and the unified dsh-panel CLI.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.