DeepSeek Harness (DSH) adopts a plugin-based architecture. When a coding agent needs to locate structured information in a codebase, traditional regular expression search often suffers from high token consumption and low semantic accuracy. dsh-tool-ast-grep is designed to address this pain point. Based on the ast-grep engine, it provides DSH with Abstract Syntax Tree (AST)-based structured code search and syntax outline extraction capabilities.

Plugin Positioning

This tool is an AST-based structured code search and syntax outline plugin for DeepSeek Harness, maintained by developer Jaylor-Wang. It belongs to the “Model Reasoning” category and helps agents understand code structure by providing a more efficient search method than regular expressions.

Core Features

The plugin mainly provides the following three core capabilities:

  1. ast_search
    Search code structures using AST patterns and metavariables (such as $NAME, $$$). It supports multi-line matching, does not rely on specific formatting or whitespace characters, and can query by node type.
  2. ast_outline
    Extract an ultra-compact structural outline from source files (functions, classes, types, interfaces, exports, etc.). Compared with reading the full file, this can save 80%-95% of tokens and supports depth control (for example, top-level methods only or including nested classes).
  3. Zero Shell Quoting Issues
    Uses secure subprocess invocation, immune to Windows shell escaping and quoting issues, ensuring stable invocation across different operating systems.

Installation and Activation

Before using the plugin, ensure that the ast-grep CLI tool is installed on the machine. The following installation methods are supported:

# npm
npm install -g @ast-grep/cli

# pip
pip install ast-grep-cli

# cargo
cargo install ast-grep --locked

# brew (macOS/Linux)
brew install ast-grep

After installing ast-grep, install the DSH plugin with the following command:

dsh plugin --profile web add dsh-tool-ast-grep

If ast-grep is installed in a non-standard path, you can set the AST_GREP_PATH environment variable to specify its full path.

Typical Usage

ast_search Parameters

Parameter Description
pattern AST pattern, e.g. function $NAME($$$) { $$$ } or $OBJ.push($ITEM)
kind AST node type, e.g. class_declaration
path Search path; defaults to the workspace root directory
lang Language override (e.g. ts, python, rust)
globs File glob patterns (e.g. src/**/*.ts)
limit Maximum number of returned results (default: 50)

ast_outline Parameters

Parameter Description
file_path File path to inspect
lang Language override (auto-detected if omitted)
depth Depth control: 1 is top-level only (default), 2 includes class methods

Supported Languages

TypeScript (ts, tsx), JavaScript (js, jsx), Python (py), Rust (rs), Go (go), Java (java), C (c, h), and C++ (cpp, hpp, cc).

Notes

  1. The plugin depends on a preinstalled ast-grep CLI; please ensure it is installed.
  2. The plugin runs with the permissions of the current DSH process; please inspect the source code and license before use.
  3. The plugin is released under the MIT License.

Summary

dsh-tool-ast-grep is an important tool in the DeepSeek Harness ecosystem for improving code search efficiency. By introducing AST-level search capabilities, it significantly reduces token consumption when agents process code while ensuring semantic accuracy.

  • Plugin directory: https://www.skillhub.cn/plugins/Jaylor-Wang/dsh-tool-ast-grep
  • GitHub repository: https://github.com/Jaylor-Wang/dsh-tool-ast-grep