The core philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” In practical development, frequently referencing large files or web page content can easily cause context window overflow and consume a large number of tokens. dsh-context-mode was created specifically to solve this problem. It does nothing fancy; it focuses solely on reducing the amount of raw data that enters the context, achieving this goal through three aspects: local knowledge bases, routing interception, and sandbox execution.

Feature Description

Local Knowledge Base Indexing

The plugin provides a SQLite-based local knowledge base indexing system with FTS5 (full-text search) support.
- ctx_index: Splits files or entire directories into smaller chunks and stores them in the knowledge base. The knowledge base is located at ~/.context-mode/content by default.
- ctx_search: Retrieves fragments from the knowledge base. By default, it returns no more than 12000 bytes each time, rather than returning an entire book.
- ctx_fetch_and_index: Fetches and indexes web pages, so the original webpage bytes do not enter the context.

Routing Interception

The plugin performs routing interception before tool execution to prevent large files from overflowing the context.
- Hard blocking: Directly rejects commands such as curl, wget, and inline-fetch that will definitely retrieve large files.
- Soft guidance: For files exceeding approximately 50KB, unless precise segmented reading is used (such as with offset/limit), usage is redirected to ctx_index or ctx_search.
- Whitelist: Harmless commands such as pwd, echo, ls, and whoami are directly allowed.

Sandbox Execution

The plugin provides sandbox execution capabilities. Raw data remains in the sandbox, and only conclusions are returned.
- ctx_execute: Runs code in an isolated sandbox and brings back only the results of console.log.
- ctx_execute_file: Analyzes file content (passed via FILE_SRC) as input data and returns only conclusions.
- ctx_batch_execute: Supports parallel execution of multiple analysis tasks, with results that can be automatically stored and retrieved from the knowledge base.

Note: The sandbox has no module system. You cannot write require('node:fs') or import in the code. The sandbox provides resource isolation, but it does not guarantee that the program absolutely cannot read host files.

Installation and Enablement

  1. Enter the plugin directory and clone the repository (if it has not already been cloned):
cd "$HOME/.dsh/plugins/dsh-context-mode"
git clone https://github.com/pharaohnie/dsh-context-mode.git .
  1. Add the plugin and link it:
dsh plugin --profile web add "$HOME/.dsh/plugins/dsh-context-mode"
./relink-dsh-context-mode.sh
  1. After installation is complete, restart DSH (restart the UI or restart the service process).

  2. Verify the status:
    Run ctx_doctor. The key items (tools, systemPrompt, FTS5, knowledge base, and gatekeeping) should show as ✓. Session memory capture (memoryCapture) and the security baseline (securityEnabled) are disabled by default, so showing ✗ is normal.

Runtime Requirements and Configuration

  • Environment requirements: Node.js version must be 24 or higher. DSH version is v0.1.1-rc.2.
  • Knowledge base location: By default, it is located at ~/.context-mode/content.
  • Configuration notes: The plugin does not compress content that is already in the context; it only provides guidance at the entry point. During sandbox execution, FILE_SRC already contains the complete file content. You can process it directly without reading the file path again.

Summary

dsh-context-mode effectively alleviates the context window pressure in DSH by indexing files, intercepting high-volume tools, and sandboxing execution, making the context window more efficiently utilized.