Introduction

In DSH sessions, when agents explore code, they often rely on grep and file-by-file reading. This approach brings a large amount of file content into the context, increasing token consumption.

Miku196/dsh-tokensave integrates the local semantic graph engine of tokensave into DSH, allowing agents to use semantic queries instead of brute-force grep/file reading, thereby saving tokens.

What is this

Miku196/dsh-tokensave is a DSH plugin maintained by Miku196 under the MIT license.

It connects the local semantic graph capabilities of tokensave to DSH and executes init/sync during apply for automatic indexing and synchronization. Starting from 0.2.0, it provides tokensave_* tools via direct cli connection, without a serve process or MCP.

Core Capabilities

The following outlines the main capabilities of the plugin:

  1. Injects tool instructions into the system prompt, guiding the model to prioritize semantic graph tools.
  2. Provides semantic graph tools such as search, callers, callees, body, entities, status, dead_code, and circular.
  3. Tool calls automatically follow the session working directory and look up the nearest index; new directories are automatically initialized.
  4. Checks for a new version of tokensave upon startup and alerts.
  5. Automatically adds .tokensave/ to .gitignore.
  6. Only alerts when the binary is missing; it does not block profile startup or inject prompts.

Installation and Enablement

The following commands use the web profile as an example.

Prerequisites:

  1. tokensave is installed (cargo install tokensave, or download from GitHub Releases and place it in PATH).
  2. dsh is available, and the profile directory contains pnpm.

Install from GitHub:

dsh plugin --profile web add github:Miku196/dsh-tokensave

Install for local development:

dsh plugin --profile web add file:/path/to/dsh-tokensave

Update the plugin:

dsh plugin --profile web update dsh-tokensaver

This plugin is a bundle plugin with zero configuration by default. After saving the configuration, dsh web will automatically hot reload, allowing the model to call tools like tokensave_search and tokensave_callers in new sessions.

Do not insert a duplicate tokensaver entry; duplicate declarations will cause dsh to crash.

Typical Usage

The tool call format is:

tokensave tool <name> --args <json>

In new sessions, the model can call tools like tokensave_search and tokensave_callers. Tool calls follow the session working directory and look up the nearest index; new directories are automatically initialized.

tokensave only finds indexes in the exact directory; the plugin looks up ancestor indexes and automatically initializes if no index is found. The main directory and its direct subdirectories are never automatically initialized to prevent mistakenly indexing the entire main directory.

To fix the operation root, configure config.binary, config.cwd, and config.autoSync under id tokensaver in $DSH_HOME/profiles/web/cordis.patch.yml:

- id: tokensaver
  config:
    binary: tokensave
    cwd: /path/to/your/project
    autoSync: true

config performs a complete replacement; unwritten fields fall back to the plugin’s schema defaults.

Starting from 0.2.0, only cli direct connection is supported; the MCP mode has been removed. Configuring bridge to mcp will result in an error.

Use Cases and Notes

Suitable for scenarios in DSH sessions where the agent needs to understand code through semantic graph queries to reduce context consumption.

Usage Notes:

  1. The plugin depends on the tokensave executable; it only alerts when the binary is missing and does not block profile startup or inject prompts.
  2. The plugin runs with the permissions of the current dsh process; you should check the source code and license before installing.
  3. The license is MIT.

Reference Links

Directory Page: https://www.skillhub.cn/plugins/Miku196/dsh-tokensave

GitHub: https://github.com/Miku196/dsh-tokensave