omdsh-dev/dsh-tool-calculator

DSH calculator tool plugin: safe mathematical expression evaluator, zero-dependency recursive descent parser

dsh-tool-calculator registers the calculator tool (@deepseek-ai/dsh-tool-calculator) for DeepSeek Harness: a safe mathematical expression evaluator with zero dependencies, zero processes, and pure functions — a single function call returns the result in milliseconds, covering common elementary math functions without spawning a bash process per operation. The security model matters: new Function + regex whitelisting is unsafe (constructor.constructor(...) can reach the Function constructor and process.exit(0) can kill the host process — both reproduced in testing), so this implementation uses a hand-written recursive descent parser that evaluates only whitelisted nodes and rejects quotes, semicolons, backticks, {} and [] outright.

uncategorized ★ 6 updated 2026-08-14 ❌ failed test
View on GitHub ↗

Install

dsh plugin --profile web add github:omdsh-dev/dsh-tool-calculator

GitHub bundle install per README (DSH 0.1.0-rc.8 (npm) profile-bundle): dsh plugin --profile web add github:omdsh-dev/dsh-tool-calculator (web profile), or dsh plugin --profile headless add github:omdsh-dev/dsh-tool-calculator for one-off headless tasks. Tarball alternative: git clone, npm install && npm pack, then dsh plugin --profile web add ./deepseek-ai-dsh-tool-calculator-*.tgz. Verify: dsh --profile web --dump-config | grep tool-calculator. Legacy monorepo/source scenarios: cp -r calculator ~/.dsh/source/master/packages/tools/calculator plus a profile user-layer patch row (id tool-calculator, name @deepseek-ai/dsh-tool-calculator).

Compatibility

DeepSeek Harness 0.1.0-rc.8 (npm), any profile. Zero-dependency, zero-process, pure-function calculator: hand-written recursive descent parser (lexer + parser), no eval and no new Function, whitelisted nodes only. Supported: + - * / % ** (right-associative), parentheses, unary ±, functions abs/ceil/floor/round/sqrt/pow/log/log2/log10/exp/sin/cos/tan/max/min, constants PI and E. Results must be finite; NaN/Infinity (division by zero, sqrt of negative) uniformly rejected. timeoutMs 1000.

Details

Recent updates

The current English README (README.en.md) documents: motivation (bash arithmetic spawns processes and lacks math functions; LLM arithmetic is unreliable), the security model (no eval/new Function, whitelist, finiteness checks), architecture, the tool declaration, supported operations with precedence, npm 0.1.0-rc.8 compatibility verification, and installation paths.

FAQ

Why is a dedicated calculator tool needed?
Every bash arithmetic operation spawns a process (especially expensive on Windows with cumulative latency under high-frequency calls), and bash syntax lacks math functions like sqrt, sin, cos, log, pow — where agents otherwise guess or write scripts.
Is it safe against code injection?
Yes — no eval and no new Function. A hand-written recursive descent parser recognizes only numeric literals, whitelisted identifiers, and operators; quotes, semicolons, backticks, {} and [] fail directly, and unknown identifiers throw.
What does it support?
Arithmetic + - * / % ** (right-associative), parentheses, unary plus/minus, functions abs ceil floor round sqrt pow log log2 log10 exp sin cos tan max min, and constants PI and E. Division by zero or sqrt of a negative number is uniformly rejected.

Alternatives

omdsh-dev/dsh-tool-stat · ccch1mneyyy/dsh-cc-tui · orriduck/dsh-tui

More plugins in uncategorized

Browse more in uncategorized

Guides for uncategorized plugins