DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

ruaibeite /

ruaibeite/dsh-preflight

Verified

Preflight and budget for DeepSeek Harness: predict a task's steps, tokens, duration and cost from local session history, with a live budget strip under the composer.

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@bf41a643

dsh-preflight · 预检

Forecast a task's steps, tokens, duration and cost from this machine's own session history, with a local price table for cost estimates · A DeepSeek Harness plugin

English: Before you run a task, open Settings → Preflight, describe the task, and see what similar past sessions on this machine cost: steps, input/output tokens, wall-clock duration and (when you configure prices) money — each as a P25 / P50 / P75 range. A local price table drives the cost estimate; nothing runs under the composer.

中文: 执行任务前,打开 设置 → 预检,输入任务描述,看看这台机器上相似的历史会话花了多少:步数、输入/输出 token、时长,以及(配置价格后)费用,都以 P25 / P50 / P75 区间给出。价格表只用于预测结果里的费用估算;输入框下方不再显示常驻预算条。

The plugin is read-only and local: it derives everything from the session projection cache DeepSeek Harness already writes, adds no prompt, tool or model call, writes no session, and never contacts the network.

中文说明 →

Screenshots

Preflight settings page in light theme: price table and prediction form Prediction result: P25/P50/P75 ranges for steps, tokens, duration and cost, plus similar sessions Preflight settings page in dark theme

Screenshots are taken from a demo profile seeded with synthetic sessions; no user data is shown.

What you get

Settings page: Preflight

Open the Harness settings and pick Preflight (「预检」) in the left navigation. One scroll, three blocks:

  1. Price table — provider/model → input and output price per 1M tokens. Saving validates and writes atomically to the plugin's own cache. Prices are used only for the cost estimate in the forecast card; the plugin does not display or enforce a token budget.
  2. Preflight — a task description, an optional working directory and an optional model. Predict returns a card with:
    • steps P25–P75 and the median,
    • input, output and total tokens,
    • human-readable duration,
    • cost when the selected sessions' models have a price; otherwise “No price configured”,
    • a confidence badge (normal / low) derived from the spread of the token forecast,
    • the five most similar sessions the forecast was drawn from.
  3. History samples — the 20 most recent finished sessions (title, model, steps, total tokens, duration, time) and how many sessions/files were used or skipped.

The page has four states: loading (skeletons while the first scan runs), error (with a Retry button), empty (no usable samples yet — explains how samples appear), and populated.

Install

Three ways:

  • Market — search for dsh-preflight (or 预检) in the plugin market and install.
  • From GitHub — dsh plugin --profile <profile> add github:ruaibeite/dsh-preflight
  • From a local checkout — plugin_manager: install_bundle target=/path/to/dsh-preflight

The host row is injected by the package's own cordis.patch.yml. The browser half loads with the next page load; the host half registers at startup, so if the Preflight page appears but the data does not load, restart DSH once. Uninstall with plugin_manager: remove_bundle (or from the market), then restart the app so the host half unloads.

How it works

$DSH_HOME/storages/session_projcache/sessions/*.json
        │  read-only parse: prompt · cwd · model · steps · tokens · duration
        ▼
$DSH_HOME/cache/preflight/samples.json     (path + size + mtime, incremental)
        │  similarity scoring over this machine's sessions
        ▼
GET|POST /dsh-preflight/api
        │  report · predict · settings · save-settings
        ▼
Settings → Preflight

$DSH_HOME is DSH_HOME when set, ~/.dsh otherwise.

Samples

Every projection-cache file is parsed into one compact sample: the first prompt (turnOutline.turns[0].prompt, falling back to titleInput.first.text and the title), cwd (workingDirectory, falling back to identity.cwd), provider/model (modelSelection.lastUsed), steps/turns (sessionStats), the four token buckets (tokenUsage.totals), and duration (lastPromptAt - identity.createdAt when plausible, otherwise llmMs + toolMs). Sessions without steps, without token usage or without a timestamp are skipped and counted. Corrupt files are skipped, never fatal. The scan keeps an incremental cache keyed by path + size + mtime in $DSH_HOME/cache/preflight/samples.json, and readers share a 30-second in-process cache.

Prediction

The forecast is a nearest-neighbour statistic, not a model call:

  1. Similarity — same cwd +3, prompt word-set Jaccard ×2 (English words and CJK 2-grams), prompt length ratio ×1, same model +0.5. The 12 highest-scoring sessions are the candidate pool.
  2. Fallback — fewer than three sessions score above 0.15: fall back to the 12 most recent sessions in the same cwd, then to the 30 most recent overall.
  3. Quantiles — P25 / P50 / P75 with linear interpolation for steps, input tokens, output tokens, total tokens and duration.
  4. Cost — only when a matching price row exists: (uncached input × input price + cache read × input price × 10% + cache write × input price + output × output price) / 1M. No price, no guess.
  5. Confidence — low when the interquartile range of total tokens is above 1.2× the median, otherwise ok.

Privacy

  • Local only. The plugin reads the session projection cache on this machine. It makes no external network request and adds no prompt, tool or model call.
  • Read-only on your data. It never writes a session, never appends an event, and never touches your repositories.
  • Its own cache only. Settings and the incremental samples cache live under $DSH_HOME/cache/preflight/ and are written atomically (temp file + rename).
  • One local route. The only network surface is the same-origin GET|POST /dsh-preflight/api route the settings page calls on the DSH host. Nothing is uploaded.
  • No credentials. The plugin never reads .credentials.yaml or any provider credential, and it does not log prompts.

Known limitations (v0.1.1)

  • This version only forecasts: it never blocks, stops or cancels an Agent, and it no longer shows a session budget strip (DSH's own composer statistics cover that).
  • The forecast is a heuristic statistic over your local sessions, not a bill. A provider's bill charges cache tokens, discounts and plan differences the plugin cannot know.
  • Only sessions that have a projection cache entry are counted; sessions without one contribute nothing.
  • Prices are entered by hand and stored locally; cost uses cache reads at 10% of the input price and cache writes at the input price, which is an approximation.
  • UI copy follows the DSH language setting; the prediction itself is language-agnostic and works for Chinese and English prompts alike.

Verify

cd dsh-preflight
npm test

Two plain-Node suites, no dependencies, no Harness process, no browser, no network, and no real $DSH_HOME (every filesystem test uses mkdtemp).

  • test/host.mjs covers projection-cache parsing (complete records, missing model/cwd, corrupt JSON, missing token usage), the incremental cache (reuse, rewrite, deletion), percentiles, similarity scoring and fallbacks, prediction and cost, settings validation/atomic write/read-back, all route actions and error paths (400/405/413/500), and apply() with a fake context.
  • test/render.mjs loads the real client.js in a small in-repo React harness and checks the four page states, the price table form, the forecast card with and without prices, and that the bundled dictionaries match locale/*.json key-for-key.

Layout

index.js            host half: projcache parsing, prediction, settings, route, activation
client.js           browser half: settings section, price table, forecast form
locale/zh.json      bundled copy (registered through the locale service)
locale/en.json
test/host.mjs       host tests
test/render.mjs     browser-half tests
—/ 5

No ratings yet

Verified DSH bundle

Commit bf41a643d352

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