dsh-bili-scroll
c1overzz
DSH 插件:每天替你刷一轮 B站,读字幕挑出值得的、写一份日报,值得的 @ 你
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:QqiqiQ/dsh-calculator
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A deterministic math tool for DSH agents: it gives the model a
real evaluation engine instead of mental arithmetic, so 0.1 + 0.2 answers 0.3 and money math does
not drift.
The engine is a hand-written tokenizer plus a recursive-descent parser — no eval, no Function —
in one dependency-free file, core.js.
+ - * / ^ (or **) % !, parentheses, unary minus, scientific notation 1.5e-3,
and the × ÷ − × aliases.pi e tau phi inf.sqrt cbrt abs sign ceil floor round trunc exp expm1 ln log(x) log(x,base) log2 log10 sin cos tan asin acos atan atan2 sinh cosh tanh pow mod gcd lcm min max hypot radians degrees.[[1,2],[3,4]], row vectors [1,2,3]; + - elementwise,
* matrix multiply (A * [x,y] treats the vector as a column), scalar * and /,
A^n integer power (negative = inverse), A' transpose; functions
det inv transpose trace rank solve(A,b) dot cross norm eye zeros ones shape.integrate(f, x, a, b) definite integral (adaptive Simpson,
finite bounds), deriv(f, x, p) derivative at a point (central difference + Richardson).
Results carry ~12 significant digits.variables: {"r": 3.5} and reference r in the expression;
a value may also be a matrix (number[][]) or a vector (number[]).expression, up to 50 expressions per call.float (default) — IEEE doubles, output rounded to 15 significant digits.exact — arbitrary-precision decimal (BigInt backed) for money math. Supports + - * / %,
integer ^ and !; functions and irrational constants are rejected explicitly rather than
silently rounded.From the plugin market (search for "DSH Calculator"), or by hand:
dsh plugin --profile web add https://github.com/QqiqiQ/dsh-calculator/releases/latest/download/dsh-calculator.tgz
Then restart dsh web. The bundle registers a single calculate tool for every session of the profile,
and appends a short usage rule to the system prompt so the model reaches for the tool instead of
estimating.
// single expression
{ "expression": "sqrt(2)^2" } // → 2
// variables
{ "expression": "2 * pi * r", "variables": { "r": 3 } } // → 18.8495559215388
// batch
{ "expression": ["0.1 + 0.2", "10!", "log(8, 2)"] } // → 0.3 / 3628800 / 3
// exact decimal mode
{ "expression": "price * qty",
"variables": { "price": "19.99", "qty": 3 },
"precision": "exact" } // → 59.97
// matrices
{ "expression": "[[1,2],[3,4]] * [[5,6],[7,8]]" } // → [[19, 22], [43, 50]]
{ "expression": "solve([[2,1],[1,3]], [1,2])" } // → [0.2, 0.6]
{ "expression": "det(A)", "variables": { "A": [[1,2],[3,4]] } } // → -2
// numeric calculus
{ "expression": "integrate(sin(x), x, 0, pi)" } // → 2
{ "expression": "deriv(x^3, x, 2)" } // → 12
The same engine also runs as an OpenCode custom tool —
opencode/tools/calculate.ts; the tool name comes from the filename.
Copy it together with a copy of core.js named calculator.core.js into .opencode/tools/ (project)
or ~/.config/opencode/tools/ (global):
$dst = "<your project>\.opencode\tools"
New-Item -ItemType Directory -Force $dst
Copy-Item .\opencode\tools\calculate.ts $dst
Copy-Item .\core.js "$dst\calculator.core.js"
Re-copy calculator.core.js after upgrading the engine, so both sides stay on the same implementation.
node test.js # 102 assertions, no dependencies
MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: 无有效分类标签。