omdsh-dev/dsh-tool-calculator ↗★ 3
@deepseek-ai/dsh-tool-calculator
DSH 基础计算器工具插件
AI 分析
为 DSH 模型提供精确的数学计算辅助工具。适合需要进行高精度、确定性数值计算,避免大模型自身算术幻觉的通用任务。
安裝
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:omdsh-dev/dsh-tool-calculator說明文件
閱讀完整 README ↗一次性任务(headless)profile —— dsh run 默认使用 headless
dsh plugin --profile headless add "C:/path/to/dsh-tool-calculator"
包内 `dsh.bundle.patch`(指向 `cordis.patch.yml`)会在安装后自动把插件加入 profile 的 layer stack;插件的 `cordis.patch.yml` 以 `- insert:` 插入 `tool-calculator` 条目。插件缺失的 peer 依赖(`cordis`、`@deepseek-ai/dsh-tools`)由 profile 的 healed `profiles/node_modules` 回退安装提供。
> ⚠️ web 与 headless 是**不同 profile**:web 安装不会自动覆盖 headless;`dsh run` 默认使用 headless profile。Windows 路径使用正斜杠(`C:/...`)。
### 验证安装
```sh
dsh --profile web --dump-config | grep tool-calculator
运行验证
dsh run "使用 calculator 工具计算 1+2*3"
手动安装与旧版本兼容
仅适用于不支持 Profile Bundle 的旧快照或插件开发调试环境:
- 放入 monorepo:
cp -r calculator ~/.dsh/source/master/packages/tools/calculator(开发调试) apps/cli/package.json加"@deepseek-ai/dsh-tool-calculator": "workspace:^";tsconfig.host.jsonreferences 加{ "path": "./packages/tools/calculator" }pnpm install && pnpm run build- 在 profile 用户层 patch 插入插件(
~/.dsh/profiles//cordis.patch.yml):
- insert:
- id: tool-calculator
name: '@deepseek-ai/dsh-tool-calculator'
- 验证:
dsh --profile --dump-config | grep tool-calculator
0806 注意:patch 是 id-targeted 语义——裸
- id:条目会报entry "xxx" not found,必须用- insert:列表包裹。
用法
安装后,agent 自动获得 calculator 工具:
calculator { expression: "15 + 27 * sqrt(9)" } → 96
工具名满足 DeepSeek 函数名约束(≤64 字符,[A-Za-z0-9_-])。注册后自动进入 Code Mode SDK(await tools.calculator(...)),canonical 返回值为数字。
已知限制
- 分发链路:
@deepseek-ai/dsh-tools是 DSH monorepo 私有包(未发布 npm),本插件需放入 monorepo 走 workspace 解析 - 三角函数使用弧度:与
Math.sin/Math.cos一致;需要角度时写sin(30 * PI / 180) - 不支持大整数:JS
number是 IEEE 754 double,安全整数范围 ±9e15,超出有精度损失 - 不支持科学计数法:
1e5会被词法层拒绝
测试
pnpm test
包含功能用例与攻击载荷用例(constructor.constructor 链、process.exit(0)、globalThis、引号注入、分号语句等)。完整用例清单见本地维护的设计文档。
许可
MIT