Foreword¶
Running agents in DeepSeek Harness (DSH) involves frequent file reading operations. Repeatedly reading the same source code, having to resend entire files when only a few lines in a large file are changed, or reusing already-seen content that still consumes tokens—these all directly eat into the window budget. The native read tool returns the full content each time, with no cross-invocation ledger.
This introduces the community plugin dsh-file-mount (maintainer acefun29). It intercepts read/write/edit calls in the tools/post-execute phase, recording which line ranges of each file have entered the model context. Repeated reads only send the missing parts, and disk changes trigger line-level diffs to send only the modified lines. It also provides a “Mounted Files” dashboard on the web interface. The mechanism is ported from piwpi’s context-mount.
What is this¶
dsh-file-mount is a dual-component plugin for DSH: the host side (dsh.bundle.patch) handles file read/write results, and the browser side (dsh.client manifest) renders the mount dashboard. The current version is 0.5.1, licensed under MIT, with approximately 13 stars on GitHub. Directory page: SkillHub; Source code: github.com/acefun29/dsh-file-mount.
It requires DSH 0.1.0-rc.5 or later, along with local pnpm and Node ^22.19 || >=24.
Core Features¶
Model Side: Incremental Reading and Deduplication¶
The plugin makes a three-way decision before returning read results to the model:
- Full Coverage: If the read line range is entirely within the ledger, the result is replaced with a deduplication marker, and the full content is not resent.
- Partial Coverage or File Hash Change: The missing or modified content is written into this read tool’s result (each line prefixed with
N:line numbers, aligned with the nativeread); the ledger slip only retains a head-only declaration. - Initial Mount: The native
readcontent is preserved, and a ledger slip is appended.
When a file changes on disk, the plugin performs a diff using the line-level draft, sending only the modified lines; for log appends, only the new tail is sent. Files that the AI has written via write are considered fully known, and subsequent read calls are free. The model can also call the file_mount_forget tool to invalidate the ledger for a specific file, forcing a full re-read next time.
write marks the entire file as “known”; edit invalidates the cache but retains the line fingerprint draft, causing the next read to re-read the disk and perform a line-level diff.
Interface Side: Mounted Files Dashboard¶
The web interface’s “Mounted Files” tab provides:
- A top bar with a fixed net savings display and path search; the file list scrolls independently.
- Each file row expands into a list of file segments, each with a freshness color band (green / yellow / orange / red / gray) and expiration count.
- An overlay map uses color blocks to show the positions of mounted lines in the file, supporting search, sorting, net savings, and RMB conversion.
- The conversation area has collapsible context injection rows; a badge appears on the line when “File has changed”.
Savings statistics are estimated using approximately 1 token per Chinese character or 4 tokens per other character. The interface displays net value (savings minus ledger slip cost; shows 0 if negative). An optional statsFile configuration persists cross-session totals.
Freshness and Safety Valves¶
Mounted segments record the carrier message’s seq and determine deduplication suitability based on its position in the current context. As the window limit approaches, earlier content is more likely to be evicted; after one expiration, it is pinned according to pinAfter. There is also a re-read safety valve (valveReads): after consecutive full-coverage deduplication reaches the set count, native reads are allowed.
Installation and Activation¶
The plugin runs with the current DSH process permissions. Before installation, review the repository source code and MIT license. After installing the profile, you must restart the harness (refreshing the page is insufficient).
Recommended: GitHub Release¶
npx --yes @deepseek-ai/dsh plugin --profile web add https://github.com/acefun29/dsh-file-mount/releases/latest/download/dsh-file-mount.tgz
npx --yes @deepseek-ai/dsh --profile web
If you have a global dsh command, the first line can be replaced with:
dsh plugin --profile web add https://github.com/acefun29/dsh-file-mount/releases/latest/download/dsh-file-mount.tgz
This installs a pre-built package, requiring no allowBuilds and bypassing npm. Do not install from source using github:acefun29/dsh-file-mount—the repository lacks a lib/ directory, and the package omits the prepare script.
Development Version from Repository¶
pnpm dsh:install
On Windows, do not use dsh plugin add . or file:E:\... for directory paths (pnpm may append the drive letter to the profile directory, installing the plugin but not activating it).
Configuration¶
Add the following to your profile’s plugin configuration:
- id: file-mount
name: dsh-file-mount
config:
enabled: true # Master switch; when disabled, all reads pass through natively
capacity: 32 # File identity cache capacity (mounted files are not evicted)
ttlMs: 300000 # Cache safety valve: fallback re-read interval if stat content changes within this period
maxPinnedFiles: 256 # Maximum number of pinned mounted files per session
minSavedTokens: 16 # If deduplication/incremental net benefit is below this, pass through natively and do not write to the ledger
maxFingerprintBytes: 1000000 # Files larger than this do not retain line-level drafts
maxManagedBytes: 16777216 # Files larger than this are not intercepted and pass through as-is
excludeGlobs: ['**/node_modules/**'] # These paths are always passed through as-is
statsFile: ./dsh-file-mount-stats.json # Optional: Cross-session ledger persistence path
freshnessEnabled: true # Freshness: enabled by default
pinAfter: 1 # Pin after one expiration
contextWindow: 128000 # Default window size if the session does not report it
valveReads: 2 # Re-read safety valve: trigger native re-read after this many consecutive interceptions (0=disabled)
To manage fewer files, adjust excludeGlobs and maxManagedBytes; files outside the list or exceeding the size limit pass through as-is.
Typical Usage¶
After following the installation steps, use the normal read / write / edit tools as usual—the plugin intervenes automatically with no additional commands required.
Force re-reading a specific file: Have the model call file_mount_forget to invalidate the ledger for that file, causing the next read to resend the full content. The deduplication marker will also prompt: if the content is not found in the context, forget it first, then read.
View cross-session statistics: With statsFile configured, statistics accumulate automatically and can be accessed via fileMount.stats() (UI display is pending).
Exclude directories from interception: Add patterns to excludeGlobs, e.g., ['**/node_modules/**', '**/dist/**'].
Use Cases and Considerations¶
Suitable for
- Agent tasks that repeatedly read the same source code, configuration, or documentation in long sessions.
- Scenarios where large files are partially modified and only diff lines need to be sent.
- Developers who want a visual dashboard of context mount status and token savings on the web interface.
Known Limitations
- The “mounted” guarantee fails after compaction: mounted content removed from the model context by compression will be re-anchored on the next read.
- Incremental/deduplication replaces result text, causing the UI’s read card to degrade to a generic card (canonical values are fully preserved).
- Files exceeding
maxManagedBytesand paths matchingexcludeGlobsare not intercepted. - Freshness is heuristic: segment expiration does not mean content was removed from context (only compaction does); expired retransmission is an intentional token cost.
- Savings figures are estimates and should not be used as precise billing references.
The plugin is structurally coupled to the DSH host and read/write/edit tools; after upgrading DSH, check if plugin releases follow suit. The community directory SkillHub is an independent site with no official affiliation to DeepSeek or High-Flyer.
Conclusion¶
dsh-file-mount transforms file reading from “full content every time” to “ledger + incremental,” saving context tokens in three scenarios: repeated reads, partial changes, and long sessions. It also visualizes mount status via a dashboard. If you are running code-related agents on DSH, it’s worth a try.
- Directory page: https://www.skillhub.cn/plugins/acefun29/dsh-file-mount
- GitHub: https://github.com/acefun29/dsh-file-mount