Preface¶
When doing agent-assisted development in DeepSeek Harness (DSH), a common need is not to immediately modify code but to first understand the repository structure: which files exist in a certain directory, which symbols a file exports, which files depend on it, and which imports are unused. If you rely on manual searches or reading files one by one every time, the cost of organizing context can be quite high.
The approach of dsh-plugin-knowledge-graph is: first build an in-memory codebase knowledge graph based on the workspace root directory, then expose a read_graph tool to DSH, allowing agents to retrieve file structure, symbol exports, import dependencies, and other information through queries.
What Is This¶
dsh-plugin-knowledge-graph is a DeepSeek Harness (DSH) plugin, with the GitHub repository located at Luke-Yong/dsh-plugin-knowledge-graph. It registers a tool named read_graph, backed by a codebase knowledge graph.
This plugin is derived from the knowledge graph tool in Luke-Yong/H and adapted to DSH’s “everything is a plugin” model. The license is MIT. The project describes itself as being in its infancy stage, and execution behavior, query surface, and compatibility may change in subsequent iterations.
Core Features¶
This plugin mainly provides the following capabilities:
- Exposes the
read_graphtool. - Builds an in-memory codebase knowledge graph covering files, directories, exported symbols, and their relationships.
- Supports the following query types:
structureexportsimports_ofexporters_ofdependentsunused_imports- Resolves symbols in TypeScript/JavaScript, as well as module-level bindings in Python; Python support covers module-level
def,class, andname = valuebindings. - Uses node types
dir,file,symbol, and edge typesCONTAINS,EXPORTS,IMPORTS,IMPORTS_SYMBOL.
Installation and Activation¶
First, confirm that the runtime environment meets the requirements: Node >=22.19 is needed, with peer dependencies @deepseek-ai/cordis and @deepseek-ai/dsh-tools.
Install the plugin to a specific profile via the DSH CLI:
dsh plugin --profile web add github:Luke-Yong/dsh-plugin-knowledge-graph
If you need to pin to a specific commit for reproducibility, you can install it like this:
dsh plugin --profile web add github:Luke-Yong/dsh-plugin-knowledge-graph#<commit-sha>
Typical Usage¶
The tool registered by the plugin is read_graph. Its parameters are as follows:
query: Required, string, formatted as<query_type> <target>.root: Optional, absolute path, used to specify the workspace root directory for building the graph. The default value isprocess.cwd().
Note here: the default root may be a parent directory containing multiple independent projects. To prevent queries like structure from expanding into sibling project trees, it is recommended to explicitly pass the single workspace root directory currently being analyzed when calling.
Common query examples are as follows:
structure
exports src/index.ts
exporters_of buildKnowledgeGraph
imports_of src/query.ts
dependents src/knowledgeGraph.ts
unused_imports app.py
These queries are used respectively to get the directory structure, view file exports, find where a symbol is exported, view file import relationships, find files that depend on a specific file, and list unused imports in a file.
Applicable Scenarios and Notes¶
This plugin is suitable for developers who need structured code Q&A in DSH agent workflows, especially for TypeScript/JavaScript or Python workspaces, where they want the agent to query directory structures, symbol exports, import dependencies, and unused imports.
There are three points to note when using it:
-
The project is in its early stages; the query interface, execution behavior, and compatibility may all change.
-
The plugin reads workspace files and builds the graph. DSH plugins typically run with the permissions of the current
dshprocess, so you should inspect the source code before installation and confirm that the MIT license meets your usage requirements. -
The paths, symbol names, and query strings in the examples should be replaced with the actual content in your own workspace.
Links¶
GitHub: https://github.com/Luke-Yong/dsh-plugin-knowledge-graph