feat: dynamic pricing — time-of-day & context tiers (v0.7.0) - #8
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/ runtimetiers/experimentalOver200K), instead of a single static price.Changes
dynamicPricingconfig (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, optionalcurrency/rate) ormultipliers. Built-in DeepSeek off-peak 0.5× default;enabled: falserestores fully static pricing.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.setTimeoutrefresh (no polling); session cost recomputed per message (request time + context tier), marked≈; sub-agents priced at session creation time (session.list).dynCost) reading opencode.json (JSONC-aware, incl. trailing commas); newscripts/fetch-deepseek-pricing.tsrefreshes official DeepSeek rates.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)