New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

dsh-context-mode

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsh-context-mode

Expose context-mode MCP tools as native DeepSeek Harness tools

latest
Source
npmnpm
Version
0.5.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

context-mode for DSH

npm license

dsh-context-mode exposes a self-contained context-mode server as native DeepSeek Harness tools. It registers the full ctx_* catalog at runtime and adds model-facing routing guidance, so dsh-TUI can use sandboxed execution, indexing, FTS5 retrieval, and web fetching without a second MCP client. It also registers the eight user-invocable skills from the upstream package, so the DSH skill surface includes /context-mode, /ctx-index, /ctx-purge, /ctx-search, and /ctx-upgrade; the diagnostics, analytics, and statistics skills are off by default with their tools.

Part of a pair. This is the tool half: the ctx_* tools, plus the archiver that files each compaction's transcript into the knowledge base. Its companion dsh-context-mode-compaction is the strategy half: it replaces DSH's compaction engine so a checkpoint rebuilds the conversation instead of only summarizing it.

Install both. Without the strategy package, the archive is still written but no checkpoint points at it; without this one, checkpoints point at an archive nothing fills.

The engine is vendored: vendor/context-mode/ carries the source and this package builds its own server.bundle.mjs from it. There is no context-mode npm dependency at runtime, and the eighteen upstream platform adapters (Claude Code, Codex, Cursor, Gemini CLI, …) were removed — DSH is the only supported host.

Two DSH-specific changes sit on top of the vendored engine:

  • CJK search. Upstream indexes with porter unicode61 and trigram, so Chinese queries largely fail (a run of Han characters becomes one token, and the trigram table cannot match two-character words). The adapter segments CJK text on both sides of the index, which took a five-query Chinese benchmark from 2/5 to 5/5.
  • Output containment. Results above 40 KB are truncated to head + tail, the full text is spilled to disk, and the model is told how to read it back.

See LICENSING.md: the adapter is MIT, the vendored engine is Elastic License 2.0.

Install

dsh plugin --profile dsh-tui add dsh-context-mode

To get the full pair — this package plus the compaction strategy that turns a checkpoint into a searchable transcript — add both and run the wiring step:

dsh plugin --profile dsh-tui add dsh-context-mode
dsh plugin --profile dsh-tui add dsh-context-mode-compaction
npx dsh-context-mode-compaction      # point the preset's compaction row here

Restart the profile afterwards either way. Removing a package removes its profile row as well:

dsh plugin --profile dsh-tui remove dsh-context-mode

The npm package ships a prebuilt vendor/context-mode/server.bundle.mjs, so no build step runs at install time. The bundled skills/context-mode/SKILL.md is registered with DSH's skill registry when the profile provides the skills service, so it should appear in /skills after a restart.

Configuration

The default patch starts the bridge with:

  • enabled: true
  • the installed context-mode/server.bundle.mjs
  • the current working directory as the project directory
  • ~/.dsh/context-mode as the isolated database root
  • a 60-second initialize and tool-catalog timeout
  • disabledTools: [ctx_doctor, ctx_insight, ctx_stats]

Override the row's config in a profile patch when needed:

- id: dsh-context-mode
  name: dsh-context-mode
  inject: [tools, systemPrompt]
  config:
    projectDir: /absolute/path/to/worktree
    storageDir: /absolute/path/to/context-mode-data
    handshakeTimeoutMs: 120000
    disabledTools: []          # opt the maintenance tools back in

Why some tools are off by default

Every registered tool ships its full schema on every request, so a tool nobody calls is a permanent token tax. ctx_doctor, ctx_insight, and ctx_stats report on context-mode itself rather than on the user's work — a human runs them deliberately. Their skills are suppressed with them, since a skill that teaches a model to call an unregistered tool helps nobody.

The tools behind disabledTools stay in the vendored engine; only their DSH registration is skipped. Set disabledTools: [] to restore all eleven.

serverPath is available for local development and pinned deployments. It may be an absolute path or a path relative to the profile process directory.

Runtime behavior

The plugin starts one long-lived child process per DSH composition. It performs MCP initialize and tools/list, registers each returned tool through the DSH tool registry, and forwards every call over MCP stdio. The child is terminated when the Cordis plugin is disposed.

Context-mode analysis, indexing, search, and diagnostics tools are marked concurrency-safe so independent model tool calls may overlap. ctx_insight, ctx_purge, and ctx_upgrade remain exclusive because they open external UI or mutate installation and stored data. ctx_batch_execute additionally parallelizes its own command batch through its concurrency parameter.

Eight of the eleven ctx_* capabilities are exposed on DSH by default — ctx_execute, ctx_execute_file, ctx_batch_execute, ctx_fetch_and_index, ctx_index, ctx_search, ctx_upgrade, and ctx_purge. ctx_stats, ctx_doctor, and ctx_insight are held back by disabledTools (see Configuration). Each registered tool carries DSH-specific routing guidance in its description, and the plugin injects a routing section plus a bundled context-mode skill so the model reaches for these tools by default.

The adapter targets DSH only. Cross-platform code you may see inside the context-mode dependency belongs to that package's prebuilt MCP server, which this adapter does not modify; it ships no Claude Code, Codex, or other host integration of its own. CONTEXT_MODE_PLATFORM=pi is set solely because upstream only accepts its own platform ids, and pi is its neutral MCP-only id — every store stays DSH-owned: CONTEXT_MODE_DIR isolates DSH data and CONTEXT_MODE_PROJECT_DIR pins project hashing to the configured workspace.

Compaction archiving

Compaction replaces the live conversation with a generated summary and prunes the events behind it, so anything the summary omits leaves the model's reach. The plugin listens for compaction/start and files the transcript into the knowledge base first, where ctx_search can still reach it afterwards.

Storage is layered rather than filtered — every transcript event is archived, and the layers differ only in the source label they carry, so precision is chosen at query time instead of at write time:

SourceContents
session/<id>/constraintuser messages — requirements, decisions, limits
session/<id>/findingtool results and assistant prose stating a concrete value
session/<id>/narrativeremaining assistant prose — reasoning, plans

Nothing is dropped at write, so a misclassification costs a query's precision rather than the content itself. Harness-injected blocks (<active_memory>, <current_runtime_context>, <system-reminder>, <resume_snapshot>) are the one exception: they ride on user/message, are per-turn runtime noise rather than transcript, and are discarded before layering. Set precompact: false to turn archiving off entirely.

Archives written before 0.3.2 may contain those injected blocks. A one-shot cleanup script removes them and leaves everything else alone:

node node_modules/dsh-context-mode/scripts/cleanup-injected.mjs --db <path>            # report only
node node_modules/dsh-context-mode/scripts/cleanup-injected.mjs --db <path> --apply    # delete

Checkpoint transcript and archive index

A checkpoint keeps only a summary of the span it replaces, and the shipped checkpoint format has no section for tool output — a long tool result survives only as whatever the summarizing model chose to keep. precompact files that same span into the knowledge base beforehand, but nothing told the model so, and a summary that omits a detail reads as if the detail never existed.

Closing that gap is a separate product, not part of this package:

npm install dsh-context-mode-compaction
npx dsh-context-mode-compaction

dsh-context-mode-compaction supplies the compaction engine that writes the transcript and the index; this package supplies the archiver that stores what those pointers name, and the ctx_search tool that reads it back. The two are independent — install both for the full path.

See dsh-context-mode-compaction for the checkpoint format, the tuning constants, and the preset wiring.

Development

pnpm install
pnpm build

The plugin needs Node ^22.19 || >=24. The upstream package installs better-sqlite3; a native build may be required on platforms without a prebuilt binary.

License

MIT for this adapter. The runtime dependency keeps its own license and terms; see the upstream context-mode package.

Keywords

dsh

FAQs

Package last updated on 14 Sep 2026

Related posts