DeepSeek Harness Plugin Hub

发布与管理完整 Harness Profiles,发现适合你的插件。

探索

插件目录环境预设文档中心动态

社区

发布插件联系我们报告问题

相关链接

Plugin Hub GitHubDeepSeek Harness 官方项目系统状态隐私说明
© 2026 DeepSeek Harness Plugin HubPowered byPaxTech

独立、非官方社区项目,与 DeepSeek 官方无隶属、授权或背书关系。

Plugin Codemode — DeepSeek Harness 插件(DSH Plugin)
DeepSeek Harness Plugin Hub
ProfilesPlugins分类动态文档登录管理 Profiles
ProfilesPlugins分类动态文档登录
← Plugins
P

dsh-plugin-codemode

Plugin Codemode

适用于 DeepSeek Harness 的 Pi-style Code Mode:通过 QuickJS-WASM 沙箱进行程序化工具调用

插件会安装到这里;不确定时保持 web。

npx -y @deepseek-ai/dsh plugin --profile web add github:Yum-wu/dsh-plugin-codemode#40041897163d9a904cb63269331e82feb769ab1c
README兼容性版本

兼容性与来源证明

Plugin Codemode 以 dsh-plugin-codemode 发布,当前版本为 0.1.1。Plugin Hub 会校验它的 manifest,并保存精确安装来源,便于复现安装结果。

DSH 兼容范围
*
运行环境
web
发布来源
github
Registry 更新时间
2026/10/4

版本

0.1.1stable
2026/10/4

相关插件

正在加载相关插件…

最新版
0.1.1
DSH
*
HMR
重启进程
Tree shaking
未声明可安全裁剪
解包体积
未提供
文件数
未提供
Surface
web
许可证
MIT
发布源
github
GitHub
★ 1
周下载
0
最近提交
2026/10/15
查看源码 ↗
README Badge

点击下方 Badge 复制 Markdown,粘贴到 README 即可。

这是你的 Plugin?认领权益 · 优先安全扫描

验证 package.json 声明的 GitHub 仓库,即可管理这个公开页面。认领后,Hub 会优先安排当前版本的安全扫描,并在通过后公开展示结果。

认领这个 Plugin →
报告问题

相关插件

继续浏览 developer-tools 分类下经过校验的插件。

Web App@deepseek-ai/dsh-web-appdsh 浏览器界面捆绑包:位于 dsh-base 之上的 Web 补丁层,加上运行时粘合插件(提供前端 dist、Web 界面提示符、bash 运行时变量和 URL 行)Sdk App@deepseek-ai/dsh-sdk-appdsh SDK 配置包:基于 dsh-base 提供 stdio JSON-RPC 服务和进程生命周期管理Experimental Inspector@deepseek-ai/dsh-experimental-inspector用于 Host 调试和 Client Runtime 检查的实验性跨 realm CDP hubExperimental Inspector Profile@deepseek-ai/dsh-experimental-inspector-profile用于原始 Session 日志和 Chat 节点检查的可选 Web 捆绑包

README

dsh-plugin-codemode

English | 中文说明

Pi-style Code Mode (Programmatic Tool Calling) for DeepSeek Harness (DSH).
Turn verbose O(N) multi-turn ReAct loops into a single O(1) JavaScript orchestration script executed in an isolated memory sandbox.


⚡ The Benchmark: Hard Numbers

Tested against all 17 real markdown documents in the repository's docs/ folder (including a 131 KB operational ledger, totaling 215,011 raw characters). The task: scan all documents, filter by keywords (JEV, Polymarket, Architecture), extract titles & line metrics, and return a sorted Top-5 summary JSON.

MetricTraditional ReAct LoopCode Mode (Sandbox Orchestration)Measured Improvement
Data Loaded into Context215,011 chars676 chars99.7% Reduction (318:1 distillation)
Estimated Input Tokens~67,191 tokens~211 tokens99.7% Saved (67k tokens spared)
Agent / LLM Turns19 round trips1 turn94.7% Fewer Turns (18 turns eliminated)
Local I/O & Compute Time3.94 ms2.76 msParity (sub-3ms execution)
End-to-End Elapsed Time~47.5 s (at 2.5s / LLM turn)~2.5 s19× Faster (94.7% latency drop)
Computation AccuracyProne to LLM counting hallucinationsNative JS Array.filter().sort()100% Deterministic & Accurate

Reproduce locally: node tests/benchmark-codemode-vs-react.mjs


💡 Why Code Mode?

Modern LLM agents suffer from tool explosion and context pollution:

  1. Context Bloat: Reading 20 files fills the transcript with 200k tokens of raw data. The model loses track, forgets system instructions, or triggers expensive context compaction.
  2. High Latency: Every single tool call requires a full round trip of network latency and model inference.
  3. Calculation Flaws: Asking LLMs to count lines, sort arrays, or calculate statistics over huge text chunks often yields subtle hallucinations.

The Code Mode Paradigm

"Put deterministic things in code, non-deterministic in LLM." — Hacker News Community Consensus on Code Mode

Inspired by Pi 1.0 (Earendil)'s Code Mode architecture and Cloudflare's production agent rewrite:

  • Pi.dev 1.0 Official Codemode Docs: Established the Programmatic Tool Calling paradigm via memory-isolated sandboxing and deferred tool exposure.
  • Cloudflare / CamelAI Case Study: Rewrote agents from heavy VM containers to Pi Code Mode in Durable Objects, reporting an order-of-magnitude reduction in latency and token costs.
  • Hacker News Discussion (#49019301): Highlighted that orchestrating multi-tool workflows via local sandboxed code delivers up to a 99.2% cost reduction compared to traditional ReAct loops.

With Code Mode, the agent writes a concise JavaScript async function. The script executes inside an isolated sandbox, concurrently calls registered host and MCP tools, filters out unnecessary data in memory, and only returns the final distilled result to the conversation context.


🏗 Architecture

┌──────────────────────────────────────────────────────────┐
│                   DeepSeek Harness (DSH)                 │
│                                                          │
│  ┌──────────────────────┐      ┌──────────────────────┐  │
│  │ LLM Conversation     │      │   ctx.tools / MCP    │  │
│  │ (Main Context)       │      │  (read, pwsh, mcp..) │  │
│  └──────────┬───────────┘      └──────────▲───────────┘  │
│             │ script                       │             │
│             ▼                              │ invoke      │
│  ┌─────────────────────────────────────────┴──────────┐  │
│  │ dsh-plugin-codemode (Cordis Extension)             │  │
│  │                                                    │  │
│  │  ┌──────────────────────────────────────────────┐  │  │
│  │  │ Dual-Engine Sandbox (Isolated Context)       │  │  │
│  │  │                                              │  │  │
│  │  │  • V8 VM Sandbox (Default): native speed,    │  │  │
│  │  │    zero memory caps, unconstrained concurrency│  │  │
│  │  │  • QuickJS-WASM: WebAssembly memory sandbox   │  │  │
│  │  │                                              │  │  │
│  │  │  - Proxy bridge: tools.<name>(args)          │  │  │
│  │  │  - Supports Promise.all concurrency          │  │  │
│  │  │  - Hard timeout guard (default 60s)          │  │  │
│  │  │  - Recursion & leak prevention               │  │  │
│  │  └──────────────────────────────────────────────┘  │  │
│  └──────────────────────────┬─────────────────────────┘  │
│                             │ distilled output only      │
│                             ▼                            │
│  ┌────────────────────────────────────────────────────┐  │
│  │ Return to LLM: [Logs] + [Return Value]             │  │
│  └────────────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────────────┘

✨ Features

  • 🚀 Dual-Engine Execution:
    • V8 VM Engine (engine: 'vm', Default): Aligns with DSH's official PTC workflow architecture. Zero overhead, handles multi-megabyte payloads, native microsecond performance.
    • QuickJS-WASM Engine (engine: 'quickjs'): Strict WebAssembly memory isolation, zero Node/OS footprint.
  • 🔄 Universal Tool Proxy & Dynamic Introspection:
    • Access all DSH built-in tools (read, edit, pwsh, glob) and MCP tools (mcp__github__*, mcp__cua*, mcp__tavily__*) via tools.<tool_name>(args).
    • Zero-Token Tool Discovery: Introspect tools dynamically at runtime without polluting system prompts or wasting context tokens:
      • tools.list(): Returns the full array of registered tool names in memory.
      • tools.help('namePattern'): Inspects parameters and JSON Schemas on-demand inside the sandbox, cutting system prompt bloat by over 90%.
  • 🛡 Hard-Safety Protections:
    • Configurable hard timeout (default 60,000 ms) kills infinite loops automatically.
    • Recursion blocker prevents scripts from invoking codemode inside codemode.
    • Result truncator caps output at 50,000 characters to prevent accidental prompt floods.
  • 📦 Zero-Patch, 100% Reversible: Pure dynamic Cordis extension. Modifies zero core DSH runtime files.

📖 Example Scripts

1. Parallel File Scan & Distillation

// Scan 10 files simultaneously and extract matching headers
const files = await tools.glob({ path: 'src', pattern: '**/*.ts' });
const results = await Promise.all(files.slice(0, 10).map(async (file) => {
  const code = await tools.read({ file_path: file });
  const exportedFns = code.match(/export (?:async )?function \w+/g) || [];
  return { file, count: exportedFns.length, functions: exportedFns };
}));

// Sort by number of exports and return top 3
return results.sort((a, b) => b.count - a.count).slice(0, 3);

2. Zero-Token Dynamic Introspection & On-Demand MCP Execution

// Discover tools dynamically without polluting the prompt with 140+ tool schemas
const available = tools.list();
console.log(`Discovered ${available.length} active tools`);

// Inspect parameters on-demand only when needed
const issueHelp = tools.help('github__list_issues');
console.log(issueHelp);

// Fetch latest issues via GitHub MCP and summarize in memory
const issues = await tools.mcp__github__list_issues({ owner: 'deepseek-ai', repo: 'deepseek-harness' });
const topIssues = issues.slice(0, 3).map(i => ({
  number: i.number,
  title: i.title,
  author: i.user?.login
}));

return topIssues;

🚀 Installation & Setup

Option A: dsh plugin add (Recommended)

dsh plugin add dsh-plugin-codemode

The package declares dsh.bundle.patch (cordis.patch.yml), so the host row is inserted into your profile automatically — nothing to hand-edit. Restart DSH and the codemode tool appears.

Option B: Install from npm manually

In your DSH profile directory (e.g. ~/.dsh/profiles/web):

pnpm add dsh-plugin-codemode
# or: npm install dsh-plugin-codemode

Then add the row yourself to ~/.dsh/profiles/web/cordis.patch.yml:

- insert:
    - id: plugin-codemode
      name: 'dsh-plugin-codemode'
      config:                  # 全部可选;省略即用默认值
        toolName: 'codemode'
        engine: 'vm'           # 'vm' (default) or 'quickjs'
        maxResultChars: 50000
        timeoutMs: 60000
        injectGuidance: true

Option C: Install from Source (Development)

git clone https://github.com/Yum-wu/dsh-plugin-codemode.git
cd dsh-plugin-codemode
npm install
npm run build

Link into your DSH web profile (~/.dsh/profiles/web/package.json):

{
  "dependencies": {
    "dsh-plugin-codemode": "link:C:/Users/Yum/Desktop/dsh-plugin-codemode"
  }
}

Then add the row from Option B.

Restart DSH

Restart the DSH service from your desktop management console. The agent will immediately receive the codemode tool declaration and execution guidance.


⚙️ Configuration Reference

OptionTypeDefaultDescription
toolNamestring'codemode'Name of the tool declared to the LLM.
engine'vm' | 'quickjs''vm'Execution engine: high-throughput V8 VM or WASM sandbox.
maxResultCharsnumber50000Maximum length of distilled output returned to context.
timeoutMsnumber60000Hard deadline per script before auto-termination.
injectGuidancebooleantrueInjects Code Mode orchestration tips into system prompt.
autoReasoningbooleanfalseEnables Auto Reasoning Effort takeover. Must be turned on explicitly — see below.

🧠 Auto Reasoning Effort

Set reasoningEffort to the sentinel auto in your model config and turn on autoReasoning: true in this plugin's config; the plugin then projects a legal tier based on task complexity onto the model's real effort ladder before the request goes out.

# cordis.patch.yml
- id: agent-default-model
  name: "@deepseek-ai/dsh-agent-default-model"
  config:
    provider: opencodex
    model: google-antigravity/gemini-3.8-flash
    reasoningEffort: auto          # <- sentinel
- id: plugin-codemode
  name: 'dsh-plugin-codemode'
  config:
    autoReasoning: true            # <- without this the plugin never intervenes

Both are required: auto alone is handed to the host and raises UNSUPPORTED_REASONING_EFFORT; autoReasoning alone does nothing unless the incoming tier really is auto (a manually picked tier, or one already stored in the session header, is always left untouched).

AspectDetail
Hookcordis agent/request waterfall, registered {global, prepend}; the return value goes straight into llm.prepareCall.
Why not llm/streamIts options is deepFreezed for agent-loop requests, and cordis next(x) ignores arguments — the tier cannot be changed there.
Ladder sourcectx.llm.resolveModelInfo(provider, model).reasoning.efforts — never hardcoded.
ScoringDeterministic 1-10 keyword tiers (auto-reasoning.ts): concurrency/deadlock/risk = 9, derivation/refactor = 7, routine dev = 5, lookup = 2.
FallbackNo ladder or a failing resolveModelInfo -> omit reasoningEffort so the model default applies. auto is never handed back to the host.
VisibilityRead-only route GET /api/codemode.auto-effort?sessionId=<id> on the host's shared /api channel (same-origin auth applies); the composer-dock pill polls it every 3s.
Session isolationDecisions are archived per sessionId (LRU, cap 50, AUTO_DECISION_CAP). agent/request is a global waterfall, so a single module-level slot made every conversation's pill show the same "most recent" record. The session id comes from payload.agent.id, falling back to ctx.get('agents').currentInitiator() — the real host dispatches agent/request with {turn, step, signal} only, so the initiator boundary is the path that resolves in practice (lastAgentSource reports which one fired).

Showing Auto in the model picker

The picker's effort menu is built verbatim from the model's declared reasoningEfforts, so auto has to be listed there for the entry to exist at all:

- id: google-antigravity/gemini-3.8-flash
  reasoningEfforts:
    auto: auto            # <- adds the "auto" entry to the picker
    low: low
    medium: medium
    high: high

Verified on dsh-0.2.0-rc.2 (2026-10-04): with auto: auto declared, the picker offers Auto, selecting it sends reasoningEffort: 'auto' to agent/request, and the plugin replaces it before the request leaves. The pill turns green/amber/red/purple per projected tier.

⚠️ auto is not a DSH effort key (the legal escalation set is off/minimal/low/medium/high/xhigh/max), so it is only meaningful as a picker sentinel that this plugin always rewrites. Never leave auto as the value actually handed to llm.prepareCall — the plugin's fallback path omits the field rather than doing that.


🛟 3-Level Zero-Risk Rollback Strategy

LevelScenarioActionRecovery TimeImpact
Level 1 (Soft Disable)Unstable model behaviorAdd disabled: true to plugin-codemode in cordis.patch.yml and restart DSH.< 15 secondsUnregisters codemode, reverts to standard single-turn tools.
Level 2 (Runtime Fallback)Script syntax or runtime errorAutomatic: plugin catches errors and prompts model to fallback to native step-by-step tools.0 seconds (instant)Session is never interrupted; graceful degradation.
Level 3 (Physical Clean)Complete uninstallRemove from cordis.patch.yml and package.json, delete directory.< 15 seconds0 runtime traces, 0 configuration residues.

🧪 Testing

npm test

Runs the test suite (21 cases) verifying:

  • Parallel Promise.all multi-tool execution.
  • Recursive invocation guards.
  • Isolation boundaries (no Node process/require leaks).
  • Output truncation and formatting.
  • Infinite loop timeout aborts.
  • Auto-effort sentinel rewriting against a real cordis dispatcher (ladder projection, prepend ordering, fallback paths).
  • Per-session decision isolation, bounded archival, and the currentInitiator() fallback.

📄 License

MIT © Yum-wu