When debugging model behavior in DSH (DeepSeek Harness), you often need to know whether the model has produced specific phrasing or patterns during a conversation. Conventional log inspection lacks aggregated statistics and makes it hard to quickly quantify a behavior (for example, whether the model frequently uses “Actually, wait, let me…” as a pause phrase).

The dsh-pattern-search plugin provides the ability to search for patterns using regular expressions in the current session. Through a client-side floating window and a model-invocable tool, it lets developers count matches, inspect hit details, and analyze hit rates.

Installation and Activation

The plugin is maintained by yzhangjy and uses the MIT license.

Installation steps:

  1. Run the install command:
    dsh plugin --profile web add github:yzhangjy/dsh-pattern-search
  1. Restart the dsh web service.
  2. Hard refresh the page in the browser (Cmd+Shift+R or Ctrl+Shift+R).

Core Features

1. /pattern-search command

This is a client-owned trigger source. After entering /pattern-search, a floating window opens. The whole process does not involve a host round trip, leaves no record in the session log, and the model cannot perceive the operation.

The standard regex flags are supported:
* i (case-insensitive)
* s (dot matches newline)
* m (multiline mode)
* g (global matching, always enabled)

Regex syntax is validated in real time while typing; if invalid, an inline error is shown. The search button is explicit; searches are not triggered automatically while typing.

3. Statistics and data display

Search results include the following metrics:
* Total Matches: total number of strings matching the pattern.
* Deduplicated Match Strings: case-insensitive deduplicated count.
* Matched Turns / Matched Messages: which turns or messages contain hits.
* Hit Rate: calculated by message count, i.e., hit messages divided by messages in the window.
* Source and Turn Breakdown: distribution of hits across different sources such as user, assistant, and tool results.

4. Paginated details table

Results are shown in a table and support pagination (10/20/50/100 rows per page). Matching text is highlighted in the table, and a context preview is provided (±60 characters before and after the match position).

5. Global view and streaming output

  • Partial Toggle: when enabled, searches include the current incomplete output that is being streamed.
  • Full Session: loads the full history via loadOlder and combines it with host projection to provide overview data for the entire session.

6. Theme adaptation

The window color system is fully derived from DSH Web design tokens (--dsw-alias-*), ensuring visual consistency across themes.

Usage

GUI operation

Enter /pattern-search in the dialog box and press Enter. After the window opens:
1. Enter a regular expression (for example, Actually,?\\s*wait,?\\s*let me\\b).
2. Click the Search button.
3. View the statistics panel and paginated details.

Model tool invocation

The model can directly call the pattern_search tool during a session for self-observation. Example parameters:

{ 
  "pattern": "Actually,?\\s*wait,?\\s*let me\\b", 
  "flags": "i", 
  "source": "assistant", 
  "context": 60, 
  "limit": 20 
}

Development and Updates

Development environment

The plugin is developed in TypeScript and depends on the @deepseek-ai/dsh-* package family. Development commands include:
* npm install: install dependencies.
* npm run build: build host-side and client-side code.
* npm test: run tests.
* npm run register: register the plugin.

Updating the plugin

Because pnpm up does not re-resolve github: dependencies (it reports “Already up to date”), updating this plugin requires removing it first and then adding it again:

dsh plugin --profile web remove dsh-pattern-search
dsh plugin --profile web add github:yzhangjy/dsh-pattern-search

After installation, restart dsh web and hard refresh the browser as well. For client-side code changes, a hard refresh is usually sufficient; however, host-side changes (such as tool definitions) require restarting the service.

Summary

dsh-pattern-search provides a lightweight pattern-observation tool for the DSH plugin ecosystem. Through regex search, statistics panels, and paginated tables, it helps developers quantitatively analyze model behavior, making it suitable for debugging logic, analyzing pause patterns, or verifying the execution frequency of specific instructions.