Introduction

One of the core philosophies of DeepSeek Harness (DSH) is “everything is a plugin.” In code search scenarios, the default grep tool rescans the entire workspace every time it is invoked. As a result, in mid-sized or large codebases, query latency increases as the file tree grows. To address this issue, the dsh-tgrep plugin was introduced. By using Microsoft’s tgrep engine, it provides trigram index support while preserving the original tool contract, significantly improving search performance.

Plugin Overview

dsh-tgrep is a plugin maintained by huuthuan-nguyen, designed to provide ultra-fast trigram-indexed code search for DeepSeek Harness based on Microsoft tgrep. It replaces the built-in grep tool using Agent-plane shadowing technology, ensuring the model’s perception remains unchanged while the underlying execution engine is upgraded.

Core Features

The plugin has the following characteristics:
1. Trigram index: Uses the index mechanism of tgrep to avoid repeatedly scanning files, greatly improving query speed.
2. Shadowing the built-in grep: Registered on the Agent-plane to replace the built-in grep tool, with no need to modify the model or system presets.
3. Automatic daemon: Automatically starts tgrep serve on first use, keeps the index warm, and supports reuse across sessions.
4. Graceful degradation: Without an index or daemon, tgrep falls back to a full file scan mode similar to grep, ensuring basic functionality remains available.
5. Contract consistency: Preserves the native Web GUI search card, PTC mode, and parameter contracts such as pattern, path, and include.
6. Zero runtime dependencies: Written in pure modern ESM JavaScript with no build steps.

Environment and Dependencies

Before using this plugin, ensure the environment meets the following requirements:
* Node.js version 22.19.0 or higher.
* The tgrep binary is available on the system PATH.

Usage Examples

The plugin provides a command-line interface for checking status and viewing statistics:
* Check whether the server is serving the current directory:

    tgrep status .
  • Query a specific pattern and get the query plan and duration:
    tgrep <pattern> . --stats
  • Configuration file example (used to control file size limits):
    config:
      maxFileSize: '64M'

Use Cases and Notes

  • Index benefits: The plugin can only deliver its performance advantages when an index has been built. Without an index, search speed is comparable to native grep.
  • File size limits: By default, the plugin skips files larger than 64 MiB (this is the default behavior of tgrep). If you need to search large files, you must adjust this through configuration or parameters; otherwise, matches may be missed.
  • Query types: For small repositories or broad queries, the performance improvement from indexing may not be significant.
  • Broad flag fallback: Certain broad command-line flags (such as -E and --encoding) bypass the index and cause a fallback to full file scanning.

Summary

dsh-tgrep introduces Microsoft tgrep to address slow code search in large repositories within DeepSeek Harness. Without changing the model interaction interface, it significantly improves search efficiency through indexing and a daemon mechanism. For full documentation or source code, visit the plugin directory or GitHub repository.