Skip to content

feat: dynamic pricing — time-of-day & context tiers (v0.7.0) - #8

Merged
zhumengzhu merged 1 commit into
mainfrom
feat/dynamic-pricing
Aug 17, 2026
Merged

feat: dynamic pricing — time-of-day & context tiers (v0.7.0)#8
zhumengzhu merged 1 commit into
mainfrom
feat/dynamic-pricing

Conversation

@zhumengzhu

Copy link
Copy Markdown
Owner

Summary

Add dynamic pricing to the cache-hit sidebar: model rates now resolve by time-of-day tier (DeepSeek peak/off-peak) and context tier (context_over_200k / runtime tiers / experimentalOver200K), instead of a single static price.

Changes

  • dynamicPricing config (src/plugin-config.ts): schedule (default DeepSeek peak 09:00-12:00 / 14:00-18:00 Beijing), contextThreshold, per-model rules — levels (absolute prices, flat or nested cache, optional currency/rate) or multipliers. Built-in DeepSeek off-peak 0.5× default; enabled: false restores fully static pricing.
  • Pricing engine (src/dynamic-pricing/): timezone-aware schedule matching, runtime cost normalization (tiers[]/ experimentalOver200K → context tier with its own threshold), fallback chain explicit rules → built-in DeepSeek → static. Pure functions, all unit-tested.
  • UI: rates/saved switch at schedule boundaries via exact setTimeout refresh (no polling); session cost recomputed per message (request time + context tier), marked ; sub-agents priced at session creation time (session.list).
  • Timeline dashboard: offline recompute (dynCost) reading opencode.json (JSONC-aware, incl. trailing commas); new scripts/fetch-deepseek-pricing.ts refreshes official DeepSeek rates.
  • Version: 0.6.4 → 0.7.0 (minor).

Review history

Four review rounds addressed: wiring, type gaps (tsc-verified), billing formula (tokens.input excludes cache; context = input + cacheRead), enabled semantics, timer cleanup, currency conversion, docs sync. 406 tests pass.

Closes #8 (if applicable)

- dynamicPricing config: schedule-based peak/offpeak rates (built-in DeepSeek
  off-peak 0.5x) + context_over_200k tiering; levels support currency
  (CNY -> USD via cost.rate), multipliers or absolute levels per model
- rates/saved switch at schedule boundaries via exact setTimeout refresh
- session cost recomputed per message (request time + context tier), marked
  ≈; sub-agents priced at session creation time (session.list)
- timeline dashboard offline recompute (dynCost) reading opencode.json (JSONC)
- scripts/fetch-deepseek-pricing.ts refreshes official DeepSeek rates
- review fixes: wire dynamicPricing prop in plugin.tsx; EMPTY_PRICING type;
  billing formula (tokens.input excludes cache, context tier = input+cacheRead);
  dynamic sub-agent saved; isDeepSeek prefix match; schedule-empty guard;
  dead-code removal; jsonc module extracted + tested; tsc-verified
- review round 2: normalize runtime cost (tiers/experimentalOver200K -> context
  tier, was dead in TUI); enabled:false fully static; boundary timer cleaned on
  unmount; level-miss falls back to static; per-rule rate for non-USD levels
- docs: README/design/timeline (EN+ZH), AGENTS, plan doc
@zhumengzhu
zhumengzhu merged commit 41be4dd into main Aug 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant