dsh-knowcode: Unified Code Graph and Knowledge Base on DSH

Foreword

Running agents that modify code in DeepSeek Harness (DSH) commonly relies on grep or flat full-text indexes: they can find strings, but struggle to answer questions like “who will be affected if I change this exported function” or “which call chains do the features described in the documentation map to.” As repositories grow larger and monorepos contain multiple packages, risks in practice include guessing signatures incorrectly, missing test runs, and underestimating the blast radius when modifying shared symbols.

This article introduces the community plugin dsh-knowcode (maintainer huuthuan-nguyen): it brings Tree-sitter WebAssembly AST code graphs, Markdown knowledge bases, and embedded FalkorDB (Cypher) into a single graph database, and provides a tgrep-style daemon with incremental file watching via the knowcode CLI. On the DSH side, it exposes roughly 25 tools through a Cordis plugin, allowing agents to perform symbol lookup, refactor impact analysis, clone detection, and spec-to-code traceability.

What Is This

dsh-knowcode is the npm package name; the GitHub repository is huuthuan-nguyen/dsh-knowcode, MIT licensed. It is categorized as “Memory” in the community directory SkillHub. SkillHub is a community plugin directory with no official affiliation with DeepSeek / 幻方 (High-Flyer); DSH itself follows an “everything is a plugin” extension model.

In one sentence: it embeds FalkorDB locally, maintaining a unified code symbol graph (classes, functions, calls, inheritance, test associations, etc.) and documentation/rule knowledge, and establishes bidirectional edges between documentation nodes and code symbols (e.g., (:DocSection)-[:DOCUMENTS]->(:Symbol), (:Rule)-[:GOVERNS]->(:File)).

Core Capabilities

Code Graph (Tree-sitter WASM)

The parsing engine is based on Tree-sitter WebAssembly; the README states that there is no fixed language whitelist: built-in grammars cover common languages, others can be loaded on demand, and custom .wasm grammars can also be placed.

Built-in coverage includes TypeScript/TSX, JavaScript/JSX, Go, Rust, C/C++, Java, C#, Python, Ruby, PHP, Lua, Shell, Kotlin, Scala, Swift, Zig, Elixir, OCaml, ReScript, Solidity, and more; the same graph model includes qualified names, import edges, call edges, line ranges, etc.

Extended grammars can be placed in:

  • Within the project: <workspace>/.knowcode/grammars/tree-sitter-<lang>.wasm
  • User directory: ~/.knowcode/grammars/tree-sitter-<lang>.wasm
  • Environment variable: KNOWCODE_GRAMMARS_DIR=/path/to/grammars

Knowledge Graph and Cross-Linking

It indexes Markdown content such as ADRs, READMEs, design documents, and coding standards, and automatically associates it with code symbols, facilitating “finding implementations from specs” or “looking up documentation from symbols.”

Graph Queries and Engineering-Oriented Analysis

Compared to dsh-tool-codegraph and dsh-knowledge-base mentioned in the README, this plugin emphasizes:

  • Refactor blast radius (transitive calls, risk scoring, associated tests)
  • Circular dependency detection (cycle traversal on the graph)
  • Code clones (based on AST token fingerprints)
  • Interface contracts and dependency blueprints related to cross-language porting
  • spec ↔ code bidirectional traceability

Data is stored in the workspace default directory .knowcode (adjustable via configuration or the CLI’s --data-dir).

Architecture: index / serve and the Daemon

It adopts the Microsoft tgrep style: one-shot indexing with knowcode index ., or long-running knowcode serve . (with debounced file watching and SHA-based incremental updates). The README notes that serve reconciles the index itself on startup, so in most scenarios you don’t need to run index first; for one-time graph building in CI you can use index (which starts the daemon, indexes, and exits).

The daemon listens on http://127.0.0.1:48123 by default; Harness tools access it via HTTP/IPC.

DSH Agent Tools (Excerpt)

The plugin registers multiple tool groups with Cordis; tool names follow the README, for example:

Direction Representative Tools Purpose
Exploration code_get_architecture_overview Entry symbols, call hubs, language distribution
Safe Refactoring code_analyze_refactor_blast_radius Evaluate transitive impact and tests before modifying
Call Relations code_find_function_callers / code_find_function_callees Upstream/downstream call sites and line numbers
Quality code_detect_circular_dependencies, code_find_similar_duplicate_functions Cycle dependencies, clone detection
Traceability spec_find_code_flow_for_feature, code_find_spec_features_for_symbol Documentation features ↔ code flow
Knowledge knowledge_search_documentation_and_rules ADR/standard search linked to symbols
Operations knowcode_check_index_health_and_stats, knowcode_execute_custom_cypher_query Index health, Cypher escape hatch

For the complete list, see the “The 25 Agent Tools” section of the repository README.

Environment and Dependencies

Item Description
Node.js ^22.19.0 \|\| >=24.0.0 (consistent with DSH requirements)
Platform macOS Apple Silicon and Linux x64 ship with embedded FalkorDB; other platforms can set FALKORDB_URL to connect to an external instance (see README Platform Support)
Peer @deepseek-ai/cordis, @deepseek-ai/dsh-tools (optional)

knowcode is not a separately downloaded binary, but a CLI inside the package: "bin": { "knowcode": "./bin/knowcode.js" } in package.json.

Installation and Activation

Install and register the plugin in one line under the target profile (the README example uses the profile name web; replace it with the profile you actually use):

dsh plugin add --profile web dsh-knowcode

After installation, knowcode will be available in that profile’s node_modules/.bin, for example:

~/.dsh/profiles/web/node_modules/.bin/knowcode index .

For local development on plugin source, you can link a checkout (change the path to your local absolute path):

dsh plugin add --profile web link:/absolute/path/to/dsh-knowcode

Configuration via Cordis Patch

Insert the bundle into the profile’s cordis.patch.yml (fields follow the README):

- insert:
    - id: knowcode
      name: 'dsh-knowcode'
      config:
        daemonPort: 48123
        dataDir: .knowcode
        blastRadiusMaxDepth: 3
        autoStartDaemon: true

Common configuration options include: daemonPort (default 48123), dataDir (default .knowcode), falkordbUrl (empty for embedded), blastRadiusMaxDepth (default 3), autoStartDaemon (default true), stopDaemonOnExit (default true), etc. See the README “Configuration options” section for details.

Try the CLI via npm Only

You can verify indexing and the daemon without installing DSH:

npx dsh-knowcode index .
npx dsh-knowcode serve .

Verify that the commands are available:

knowcode --version
knowcode --help

Typical Usage

1. Build the Graph and Start the Daemon

Enter the repository root directory. For daily development, serve is usually sufficient; use --force-index when you need a forced full rescan (the README also recommends forcing a re-index or deleting .knowcode/falkordb.rdb after upgrading the parser).

knowcode serve .

Optional: index once first, then keep the daemon running (warm-up so the first tool call is faster):

knowcode index .
knowcode serve .

For debugging the watcher and RPC:

knowcode serve . --trace

2. Check Graph Status

knowcode status .

It outputs whether the daemon is online, the .knowcode path, file/symbol/call/document counts, and language distribution (the exact fields follow the CLI output).

3. Run Cypher Directly

Suitable for scripts or manual graph exploration:

knowcode query "MATCH (s:Symbol {kind: 'class'}) RETURN s.name, s.file"

4. Use in a DSH Session

  1. Install the plugin as described above and enable autoStartDaemon, or manually run knowcode serve . in the project root.
  2. In the Harness, have the agent call tools such as code_get_symbol_definition_and_signature and code_analyze_refactor_blast_radius; before modifying shared APIs, prioritize running blast radius and affected-tests tools.
  3. When cross-referencing ADRs/PRDs, use spec_find_code_flow_for_feature or knowledge_search_documentation_and_rules.

Stop the daemon for this workspace:

knowcode stop .

Fitting Scenarios and Caveats

Better suited for: medium-to-large monorepos or multi-package repositories, DSH workflows that need AST-level symbols and call graphs, impact analysis before refactoring, and bidirectional traceability between documentation and code.

Relative limitations: The README explicitly states that the indexing layer has an extension whitelist and binary sniffing, and does not read running database files; storage structure knowledge comes from text such as schema/SQL within the repository. The native Windows environment requires WSL2 or Docker + FALKORDB_URL; see the README platform notes.

Security and permissions: The plugin and knowcode run with the current DSH/terminal user privileges; they read workspace source code and documentation, write to .knowcode, and may start a local HTTP daemon. Before installing, please read the source code and the MIT license, and use it on trusted repositories; the star count on the community directory page is 0, which does not represent a quality conclusion — evaluate it yourself.

Conclusion

After the steps above, you can understand dsh-knowcode as adding a layer of local graph database between the DSH agent and the repository, using AST and Cypher to answer “who calls whom, what will affect tests if changed here, which call chain the documentation corresponds to,” rather than relying only on string search.

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

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

Xiaoye