dsh-code-graph: Branch-aware Code Knowledge Graph Plugin for DSH

In the DSH ecosystem, agents often rely on grep to read code. However, grep only returns text and cannot reflect call chains, impact scope, or architectural relationships. dsh-code-graph solves this problem. It introduces branch-aware code knowledge graph capabilities to the DSH plugin system, allowing agents to understand code through graph queries rather than blind searching.

What Is This

This is a DSH plugin maintained by hoyyang. It reuses the local codebase-memory-mcp engine to provide structured code indexing and query capabilities. It does not depend on MCP sessions; instead, it interacts with the engine binary through a native tool dispatcher.

Core Features

  1. Structured code reading: supports callers, callees, impact (impact BFS), and trace (call and data-flow paths), architecture (architecture overview), covering 158+ languages.
  2. Automatic branch following: after checking out any branch, ask directly and the index graph automatically corresponds to the current branch; switching back to a previously visited branch requires zero reindexing.
  3. Rolling single index for large repositories: repositories over 500MB retain only one index for the current branch; switching branches deletes the old index and creates a new one, keeping disk usage to one copy.
  4. Freshness gating: each query compares the HEAD + dirty tree signature; drift automatically triggers a fast incremental reindex.
  5. Automatic fallback to ripgrep on zero graph matches: if a graph query returns no results, it automatically falls back to ripgrep; results are explicitly labeled as fallback and are never presented as graph results.
  6. Hard gate for code reading: code grep without calling codegraph first is rejected with guidance; gate exceptions always fail open.
  7. Cross-branch queries: query non-checked-out branches that already have indexes (frozen state) directly via the branch parameter.

Installation and Activation

Use the official installation command:

dsh plugin add github:hoyyang/dsh-code-graph

After installation, the plugin depends on the local codebase-memory-mcp engine binary (default path ~/.local/bin/codebase-memory-mcp). If the engine is missing, the plugin reports an error identifying the missing component when invoked, but this does not affect DSH startup.

Typical Usage

  1. View index status:
    /codegraph
  1. Create a new index:
    /codegraph <仓库绝对路径> fast
  1. Agent-side query:
    codegraph { "op": "callers", "repo_path": "<repo>", "name": "handleRequest" }
  1. Ask directly after switching branches: the index automatically follows.

Applicable Scenarios and Notes

This plugin is suitable for scenarios that require a deep understanding of code call relationships, architectural impact, or cross-branch code retrieval. Before installation, ensure the codebase-memory-mcp engine is configured locally.

Notes:
- Does not modify repository files: no git hooks are installed, .gitignore is not written, and no persistent listeners are started.
- Uninstall command:

  dsh plugin --profile web remove dsh-code-graph

This command automatically cleans up tools, commands, prompt section/skill files, and state files, but does not touch the graph database or the user’s repository.
- Ecosystem background: DSH’s philosophy is “everything is a plugin”; the community catalog is an independent site with no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-code-graph provides DSH with efficient code knowledge graph capabilities through native tool dispatch and freshness gating. For complete documentation, visit GitHub or the SkillHub catalog.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye