dsh-plugin-interpreters
編輯精選維護狀態: 活躍huanlinoto/dsh-plugin-interpreters
暴露 run_python/run_node 工具,通過 stdin 執行程式碼返回 stdout/stderr/exit,含直譯器路徑配置卡 | Exposes run_python/run_node tools that execute code via stdin and return stdout/stderr/exit, with interpreter-path config card
9
星數
0
Fork
JavaScript
語言
NOASSERTION
授權條款
2026-08-12
建立於
2026-08-19
最近推送
README
dsh-interpreters
DSH 插件:暴露 run_python 和 run_node 两个模型可调用工具,通过 stdin 执行代码并返回 stdout/stderr/exit code。在设置页「插件配置」分区提供配置卡片,让用户设置 Python 和 Node.js 解释器的可执行文件路径,工具描述中会告知模型解释器位置。
架构
- 工具:
run_python/run_node,通过spawn(executable, ['-'])执行代码,代码经 stdin 传入(无命令行长度限制) - 设置持久化:通过
ctx.settings命名空间interpreters持久化到$DSH_HOME/settings.yaml - 动态 description:工具的
description在注册时根据配置计算,包含解释器路径;设置变更时通过bridge.onChange()自动重新注册 - 配置暴露(TypertRemoteService 模式):DSH 的 settings RPC 域(api-proxy)只向配置客户端提供白名单命名空间(
interpreters不在其中),所以浏览器通过 host 内置的 typertRemote/apiRPC 通道读写interpreters命名空间——InterpretersConfigGateway继承TypertRemoteService并用@Remote('get')/@Remote('set')标记方法,typertRemote 的 SRC discovery 自动 claim/api/interpreters/get和/api/interpreters/set端点。gateway 在 host 进程内 in-process 调ctx.settings.update(ns, patch),绕过 wire-layer allowlist - 客户端 bundle:配置卡片通过
settings.plugin.itemslot 注册(「插件配置」分区),卡片用connection.rpc.call('/api', 'interpreters/get'|'set', { args: {...} })读写,不依赖settingsScope(因为interpreters不在白名单中);connection/reset事件触发卡片重载
开发
pnpm install # 安装依赖(link: 指向 ~/.dsh/source/current/)
pnpm run typecheck # tsc --noEmit
pnpm test # vitest run
pnpm run build # tsdown + tsc(生成 lib/index.js, lib/client.js, lib/types/*.d.ts)
目录结构
src/
├── index.ts # Host 入口:name, inject, apply(实例化 bridge + gateway + 工具注册)
├── config.ts # Config schema (schemastery), ResolvedConfig, resolveConfig
├── settings.ts # installInterpretersSettings: 注册 namespace,返回 bridge (source() + onChange())
├── gateway.ts # InterpretersConfigGateway: TypertRemoteService + @Remote('get'|'set')
├── tools.ts # registerTools: 注册 run_python + run_node
├── runner.ts # runCode: spawn + stdin + stdout/stderr 收集
└── client/
├── index.ts # Client 入口:slots.inject('settings.plugin.item') + connection/reset
├── store.ts # 卡片响应式 store(通过 connection.rpc 读写 /api/interpreters/*)
├── InterpretersCard.tsx # 配置卡片组件
└── locales.ts # i18n (zh + en)
运行
本地安装
# 从 npm 安装(推荐):
dsh plugin --profile web add @huanlin/dsh-plugin-interpreters
# 本地开发(热更新):
dsh plugin --profile web add "link:D:/Projects/deepseek-harness/dsh-interpreters"
配置
默认配置(cordis.patch.yml):
pythonPath: 'python' # Python 可执行文件路径
nodePath: 'node' # Node.js 可执行文件路径
timeoutMs: 30000 # 执行超时(毫秒)
运行时通过设置页「插件配置」分区的卡片修改,持久化到 $DSH_HOME/settings.yaml。
检查
pnpm run typecheck && pnpm test && pnpm run build
验证 lib/ 产物:
lib/index.js— host bundle(ESM,external:@deepseek-ai/dsh-typert-protocol,@deepseek-ai/dsh-settings,@deepseek-ai/dsh-tools,schemastery)lib/client.js— client bundle(CJS,window.__ModuleLoader__.load包裹,external:react)lib/types/— TypeScript 声明文件cordis.patch.yml— bundle 配置层
更多「開發者工具」外掛
brooks-lint
作者 hyhmrright
基於 12 本經典工程書籍的 AI 程式碼評審工具,提供腐化風險診斷、書籍引用、嚴重度標籤及 6 種分析模式。
oh-dsh
作者 hust-open-atom-club
一套 DSH runtime,Desktop、Web 與 TUI 三種開發體驗。
dsh-gitbash-preset
作者 liceses
DeepSeek Harness 外掛:一鍵安裝「極簡模式 (Git Bash)」agent preset —— 把 DSH 自帶極簡模式中的 bash 呼叫對映到 Git for Windows 的 bash(MSYS),讓 Windows 上的極簡模式真正可用。
dsh-super-injector
作者 yjh051108
BepInEx 風格執行時模組注入器,可將本地外掛包注入執行中的 DSH Web,支援熱過載、暫存與解除安裝。
