Preface

When developing the DeepSeek Harness (DSH) agent, enabling the Agent to understand codebase structure is a common requirement. A usual approach is to have the LLM directly read a large amount of code, or to build a crawler service. The former is costly and slow, while the latter requires maintaining an extra service.

dsh-repo-analyzer is a local repository intelligent plugin aimed at providing stack detection, dependency maps, and module reference information through static analysis. It does not rely on external services; all computation runs on the current file system.

Core Features

The plugin provides three main tools:

  • repo_scan: Scan the repository. Identify the tech stack, validate manifest files, recognize extensions and system files, and list the directory hierarchy.
  • repo_deps: Analyze dependencies. Parse package.json, pyproject.toml, go.mod, Cargo.toml; support querying a single dependency, locating files, and locating configuration files for available tools.
  • repo_refs: Local module references. Support import/require parsing, identify the most-used module nodes and folder dependencies.

Installation and Enablement

Install using the official command:

dsh plugin --profile <name> add dsh-repo-analyzer

After installation, the plugin will automatically load into the specified profile.

Configuration

The plugin supports the following configuration items (YAML format):

- insert:
    - id: dsh-repo-analyzer
      name: dsh-repo-analyzer
      config:
        root: '.'            # 仓库根目录,指向 agent 的 cwd
        maxDepth: 4          # 目录遍历深度限制,0 表示不限制
        maxFiles: 20000      # 单次解析文件数量上限
        maxFileBytes: 1048576
        exclude:             # 需要排除的路径(默认已包含 node_modules/.git/dist 等)
          - node_modules
          - .git
          - lib

Typical Usage

  1. Get repository inventory: Use repo_scan to obtain the repository’s tech stack inventory and directory structure.
  2. Query dependency references: Use repo_deps to query which files reference a dependency (such as lodash) and assess its impact scope.
  3. Locate module: Use repo_refs to export the reference graph, analyze module dependencies, and tell the user which directory is most suitable for this module.

Technical Implementation Details

  • Runs entirely locally: It relies on the high likelihood of manifest files (such as package.json) existing.
  • Dependency parsing: package.json is parsed using JSON.parse; pyproject.toml, go.mod, and Cargo.toml are parsed using regular expressions, and invalid values are ignored.
  • Reference graph: It scans import/require statements in .ts, .tsx, .js, .jsx, .mjs, .cjs, and .py files, converts references into file paths, and groups them by directory.
  • Security validation: All user-input paths are validated using resolveWithin (default under root), preventing chained linked-file attacks.

Conclusion

This plugin is suitable for scenarios that require local codebase analysis and can help agents quickly build an understanding of the code structure.

Plugin directory
GitHub repository