Introduction

When using DeepSeek Harness (DSH), if every new session requires reconfirming which development tools are available locally, which paths are reliable, and what the network latency is like, it consumes a large number of tokens and slows down the conversation pace. dsh-env-profile solves this problem: it automatically probes the local environment in the background, consolidates the information into a persistent cross-session global profile, and injects a low-overhead summary into the system prompt of each turn.

Plugin Overview

dsh-env-profile is a DSH global experience plugin. It automatically probes the local environment (dependent tools, convenient paths, network, disk), subscribes to session/event to aggregate per-session statistics, consolidates them into a cross-session global profile, and injects a low-overhead summary into every system prompt turn.

  • Maintainer: Yvesgao
  • Category: Memory
  • License: MIT
  • Current status: skeleton stage v0.1

Core Features

The plugin provides the following core capabilities:

  1. Automatic local environment probing: It collects tool lists, paths, network status, and disk information through host-side probing (e.g., where.exe, TCP connection establishment, disk sampling).
  2. Cross-session global profile consolidation: It stores probe results and session statistics in $DSH_HOME/storages/env_profile.json, forming a persistent environment memory.
  3. Low-overhead summary injection: It injects the environment summary into each conversation turn as systemPrompt.section (order 500), with a default hard budget limit of 600 characters.
  4. On-demand query tool: It provides the env_profile tool, supporting queries against the full profile through the scope parameter (e.g., summary/env/sessions/facts/all).
  5. Automatic LLM extraction: It automatically extracts knowledge entries from conversation history (e.g., user preferences, project conventions) and supplements them into the profile.
  6. Key tool version probing: It probes the versions and first PATH paths of common tools such as git, node, npm, pnpm, and python.

Installation and Activation

Official Installation

Install directly from the plugin repository:

dsh plugin --profile web add dsh-env-profile

After installation, restart dsh web for the changes to take effect.

Local Development Notes

During local development, pnpm builds junctions (symbolic links) by default, which may cause ESM resolution failures, so installation must be done using physical copies:

# 1) 登记依赖
dsh plugin --profile web add "E:\YourPath\dsh-env-profile"

# 2) 物理拷贝替换 junction(关键步骤)
$dst = "$env:USERPROFILE\.dsh\profiles\web\node_modules\dsh-env-profile"
cmd /c rmdir "$dst"
Copy-Item -Recurse "E:\YourPath\dsh-env-profile" "$dst"

# 3) 重启 dsh web

Verify Installation

  1. Check the storage directory: env_profile.json appears under $DSH_HOME/storages/.
  2. Check the system prompt: in any session, verify whether the ## Environment profile section appears at the end of the system prompt.
  3. Test the tool: ask “What common tools are installed on this machine?” The model should answer directly without on-the-spot probing.

How It Works

The plugin builds a complete closed-loop architecture:

  1. Probing: lib/probes.js triggers probing (tools, paths, network, disk) periodically or manually, and stores the results in the domain model.
  2. Storage: lib/store.js is responsible for in-memory mirroring and persistence, synchronously writes the JSON file, and performs session mirror pruning.
  3. Injection: lib/injector.js inserts the generated summary into the system prompt (order 500) and controls the injection budget.
  4. Query: lib/tool.js provides the env_profile tool for the LLM to query full or specific-scope data on demand.

Token-Saving Mechanism

  1. Prefix cache stability: The summary is generated by summarize() with fixed sorting and formatting. When the profile state does not change, the summary injected each turn is byte-for-byte identical, so DeepSeek’s prefix cache continues to hit; it is invalidated only when the tail changes.
  2. Hard injection budget limit: The default is 600 characters. If the limit is exceeded, the content is truncated and the model is prompted to use the tool to obtain the full content, preventing the cost of injected context from exceeding its benefits.
  3. Zero model cost for probing: All probing operations (where.exe, file existence checks, TCP connection establishment, disk reads/writes) are deterministic host-side operations and do not consume any tokens.

Configuration Options

By overriding the configuration in cordis.patch.yml, you can adjust plugin behavior:

- id: env-profile
  config:
    injectMaxChars: 400        # 注入预算调小
    probeIntervalHours: 24     # 探测更懒
    networkHost: api.deepseek.com
    trackSessions: true
    learnEnabled: false        # 关闭 LLM 自动抽取(有 token 成本)
    learnIntervalTurns: 5      # 每 5 轮抽取一次
    learnMaxInputChars: 4000   # 抽取输入上限

Typical Usage

  • Query summary: Call the tool in a session.
    env_profile scope=summary
  • Query full profile:
    env_profile scope=env/sessions/facts/all
  • Refresh probing: Force re-execution of probing.
    env_profile refresh

Notes

  • Windows only: Current probing relies on where.exe and Windows environment variables; POSIX systems are not currently supported.
  • Single-process write constraint: The JSON backend does not support concurrent writes from multiple processes. Do not have multiple DSH processes simultaneously write to the same DSH_HOME.
  • Skeleton-stage status: Currently it is at v0.1 skeleton stage; the core closed loop is functional, and some features (e.g., synonym merging, Web settings page) are on the roadmap.

Conclusion

dsh-env-profile turns environment information from “explained every time” to “known from the start” through the “probe-consolidate-inject-query” closed loop, effectively reducing repeated probing and repeated explanation, and lowering token consumption. For development scenarios that require frequent environment switching or long-running sessions, it is a practical auxiliary tool.

Plugin directory | GitHub repository