DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

zhirai-tech /

zhirai-tech/dsh-token-manager

Verified

ControlX · 智控引擎 — AI Resource Optimization Engine for AI Agents (adaptive reasoning, context optimization, caching, resource orchestration)

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHubProject homepage
READMESource: main@2666161d

ControlX · 智控引擎

ControlX · 智控引擎

AI Resource Optimization Engine

Make AI Work Smarter, Not Harder.

An intelligent optimization engine for AI Agents, improving task efficiency through adaptive reasoning, context optimization, caching, and resource orchestration.

Adaptive Reasoning:Pick the reasoning depth a task actually needs instead of always paying for the deepest mode. Context Optimization:Pass only the information a task needs, cutting repeated history, repeated files and dead context. Intelligent Orchestration:Coordinate main agents, subagents, models and resources so work finishes with less churn. Cache Optimization:Reuse results and cache instead of recomputing or re-requesting them. Quality & Efficiency:Optimise total resource use without trading away task quality.

Repository: https://github.com/zhirai-tech/dsh-token-manager · Author: ZHIRAI

English | 简体中文

DSH Tests Dependencies License

Token cost monitoring, model-call efficiency analysis, AUTO reasoning-effort scheduling and reversible context optimization for DeepSeek Harness.

ZHIRAI · 智睿科技 · independent developer


Plugin disabled vs enabled

Dashboard Live top strip Compression records
Dashboard Live strip Cache

A/B measurement

Real screenshots from a running DSH desktop app: left = plugin disabled, right = plugin enabled (same machine, only the plugin toggled). The A/B chart comes from a real model-call comparison: 44,067 → 30,068 tokens (−31.8%) with identical answers.


What it is

A Cordis plugin for DeepSeek Harness that answers five questions without touching Harness core, the model adapters, the compression/statistics pipeline, or dsh-mnemon:

  1. Where did my tokens go? Per-call four-bucket ledger, per task, session, project, today and all-time; input/output/reasoning/cache-hit/cache-miss split with explicit provenance (API value / estimated / missing).
  2. Which calls are wasteful? 15 finding types: repeated file reads, repeated tools, repeated build/test/deploy commands, redundant confirmations, repeated plans/summaries, simple-task step inflation, cache-hit drops, task-cost anomalies, subagent fork history, oversized delegation prompts, usage gaps and more.
  3. What can be compressed safely? Large shell/build/test/log outputs are replaced by structured summaries; the original is always recoverable via token_manager_read; byte-identical repeated results are reused as tiny references.
  4. What did it cost and save? Cost per task with your price table, plus estimated tokens and money saved by compression/reuse.
  5. How much reasoning does this task need? AUTO reasoning: picks OFF / LOW / HIGH / MAX per task, escalates one level at a time on genuine reasoning failures, keeps manual levels untouched.
Area Capability
Accounting Per-call four buckets (uncached input / cache read / cache write / output) + reasoning-token provenance; deduplicated by (session, turn, step, attempt); totals cross-checked field-by-field against DSH's own tokenUsage projection.
Efficiency analysis 15 finding types with per-type switches and thresholds; 5 task types with same-type historical baselines (median / p80).
AUTO reasoning Per-task classification (intent, files, modules, multi-cause, subagent), first step already at the selected level, agent/pre-step escalation on evidence, environment failures never escalate, new task re-judges from scratch, manual selection exits AUTO.
Context optimization Byte-identical tool-result reuse (reference + blob recovery), token_manager_context layered context pack, subagent spawn/fork audit (who inherits full history, how big the delegation prompt is).
Compression 2.0 Shell-output aware (file lists, JSON/JSONL, Markdown, git diff/log, build, test, logs); every error/warning line preserved with its original line number; read results and error results are never compressed; history/prefix is never rewritten.
Recovery Content-addressed blobs; token_manager_read paginates the original by blob id or reads a file inside the session workspace.
Tasks & projects Merge tasks, 9-field task summaries, versioned 8-section project summaries, JSON/Markdown/CSV export.
Interface Chinese-first dark dashboard, composer AUTO control, AUTO vs manual cost comparison, 1600 / 897 / 390 responsive, help text collapsed into ? icons.

Measured (not marketing numbers)

Scenario Result
A/B, same command, compression off → on 44,067 → 30,068 tokens (−31.8%), both answers identical
AUTO vs manual HIGH (same A–D task set, real calls) 1,063,769 → 620,623 tokens (−41.7%), cost −44.7%, latency −54.4%, same 4/4 success
Env-failure task (should not escalate): manual HIGH misuse → AUTO 617,106 → 147,417 tokens (−76.1%), cost −77.7%; AUTO stays LOW with holds
Task switch: after a complex task reached MAX, a new simple task re-classified as OFF, no inheritance
Accuracy check, 1500-line output, ask line count + exact error line Both modes answered identically and correctly (1500 lines, exact L777 text, 1 ERROR / 1 WARNING)
Real 493k-token session (offline audit of 12 shell outputs) 521,347 B → 169,738 B (−67.4%), error/warning lines preserved 20/20
Historical projects, cumulative tokens avoidable (estimate) large/long sessions 30%–50%, small projects 5%–15%

A/B and AUTO rows are real model calls (DeepSeek deepseek-account/deepseek-flash); costs use the built-in reference prices, not a live bill. AUTO spends ~12% more than always-LOW — the price of genuinely escalating on complex tasks — while saving 41.7% versus always-HIGH.

AUTO reasoning (v1.4.0)

A compact AUTO control sits beside the composer model selector. Manual levels keep working exactly as before — picking one simply leaves AUTO.

AUTO vs manual (same A–D task set, real calls) Manual HIGH AUTO Change
Total tokens 1,063,769 620,623 −41.7%
Cost (reference-price estimate) ¥0.8347 ¥0.4612 −44.7%
Latency 271.0s 123.5s −54.4%
Success 4/4 4/4 same
  • Simple tasks (button color, copy, lookup) → OFF; normal tasks → LOW; only evidence (multi-file scope, reasoning failures, several failed approaches) escalates one level at a time to HIGH/MAX, at most 3 steps per task, never skipping a level.
  • Environment failures never escalate: missing path, permissions, missing dependency, network, missing command, test environment, external API — recorded, not reasoned about. On such a task AUTO used 76% fewer tokens than manual HIGH.
  • Tasks are judged independently: after a task that reached MAX, a following simple task starts again at OFF (verified in a real run).
  • Every decision is logged (reason/evidence/applied) and the cost-analysis page shows AUTO vs manual plus the decision timeline.
Overview · AUTO panel Cost analysis · AUTO vs manual
AUTO overview AUTO cost analysis
Composer · AUTO menu Settings · AUTO
AUTO menu AUTO settings

Distribution build

This repository is a distribution build, not an open-source repository:

  • lib/ contains the compiled, minified host and client bundles that DSH loads;
  • src/ and tests/ contain README notes only — sources and tests are not published;
  • scripts/ contains two real, usable helpers;
  • the plugin is proprietary (UNLICENSED, all rights reserved).
Path Content
lib/ index.js (host, ~522 KB) and client.js (browser, ~361 KB), minified
src/ README only — source not published
tests/ README only — test-suite summary (350 tests), no test sources
scripts/ token-report.mjs (per-call token report), install-sandbox.ps1 (isolated profile install)
locale/ Chinese and English dictionaries
docs/ install, config, troubleshooting, compression 2.0 report, market guide, video script, screenshots
.github/ issue templates

Install

From npm:

dsh plugin --profile <profile> add dsh-token-manager@1.4.0

From GitHub (no market or npm needed):

dsh plugin --profile <profile> add github:zhirai-tech/dsh-token-manager

Then restart the profile. This installs the compiled release (v1.4.0) from this repository.

From this repository (local clone):

# from this repository (linked dev install)
dsh plugin --profile <profile> add "file:<absolute-path-to-this-repo>"

# or from the release zip
#   download dsh-token-manager-1.4.0.zip, unzip, then install the unzipped folder
dsh <profile> --no-open      # restart the GUI

Or in the DSH desktop app: Settings → Plugins → install from local directory.

Verify: the sidebar shows 智控引擎 ControlX (ControlX) and /token-manager/api/health returns ok: true.

Full steps, upgrade and uninstall: docs/INSTALL.md.

Requirements

DeepSeek Harness 0.2.x (verified on 0.2.1-rc.5), Node.js 24.x bundled with DSH, no network access, no API keys.

Configuration

Everything lives in ControlX → 设置: collection switches, 11 analysis toggles and thresholds, price table (4 buckets, currency, unit), compression mode (off / observe / on) and thresholds, cache limits, context analysis (dry-run only).

Defaults are safe: monitoring on, compression in observe mode (records but never replaces), context analysis dry-run only. Auto-compression must be enabled explicitly.

Full reference: docs/CONFIG.md.

Compatibility and safety

  • No core changes: no edits to DeepSeek Harness source, dsh-mnemon, model adapters or the compression/statistics pipeline. AUTO changes the per-request reasoning effort only through the documented agent.model.select() API, and only while the user has AUTO enabled.
  • dsh-mnemon coexistence: messages injected by mnemon (source.kind = "dsh-mnemon") are classified as protected and never compressed, deduplicated or removed (verified with real conversations; message hashes unchanged).
  • Local-only data: %DSH_HOME%\dsh-token-manager\ (SQLite + content-addressed blobs); no telemetry, no network calls.
  • HTTP boundary: every request goes through DSH's connection fence; token_manager_read validates session ownership and confines path reads to the session workspace.
  • Reversible: uninstall removes listeners, routes, tool and UI; data remains until you delete it.

Repository layout

See docs/, .github/ and the table above. Sources are not published; issues about behaviour, compatibility and security are welcome.

Market

DSH's plugin market is a JSON index any static host can serve. This repository ships a ready index:

https://raw.githubusercontent.com/zhirai-tech/dsh-token-manager/main/docs/market/index.json

Add it under Plugins → Discover → Add index source. See docs/MARKET.md for the format and how to get listed in community catalogs.

Development

The test suite (350 unit tests + real-run acceptance logs) is maintained privately and run before every release. The public repository intentionally contains no source or test files.

License

Proprietary / All rights reserved — UNLICENSED. See LICENSE. No permission is granted to copy, modify or redistribute without written permission.


ZHIRAI · 智睿科技
Build Ideas Into Reality · 把想法变成现实
zhirai.cloud · xtang3125@gmail.com
© 2026 ZHIRAI. All Rights Reserved.

—/ 5

No ratings yet

Verified DSH bundle

Commit 2666161dabf9

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout