@fyeeme/pi-statusline 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/README.md +26 -4
- package/package.json +1 -1
- package/pricing/deepseek.ts +22 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [1.2.2] - 2026-08-23
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Follow DeepSeek's weekend flat-rate adjustment (effective 2026-08-23 00:00 Beijing time): weekends (Saturday/Sunday) no longer distinguish peak/off-peak periods and are billed at the off-peak price all day. `isDeepSeekPeakTime()` now returns false for any Beijing-time Saturday/Sunday from the effective date onward; messages before that instant keep the old per-hour rule, so long sessions spanning 2026-08-23 are still priced correctly per message. Footer indicator and registry patch follow automatically.
|
|
13
|
+
|
|
14
|
+
## [1.2.1] - 2026-08-21
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Support `deepseek-v4-flash-vision-exp` (V4 Flash Vision): the model was missing from the CNY price table, so its cost fell back to pi's recorded USD price (understated ~7x for CNY accounts, often rendering `¥0.00`). Official pricing is identical to V4-Flash (images are billed as tokens, no vision surcharge); the model now follows the same peak/off-peak rates.
|
|
9
19
|
|
|
10
20
|
## [1.2.0] - 2026-08-21
|
|
11
21
|
|
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ A rich custom status bar for [pi](https://pi.dev) that replaces the default foot
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
10
|
- **Provider-aware usage** — special support for DeepSeek and GLM/ZAI (see [Provider Support](#provider-support))
|
|
11
|
+
- **DeepSeek peak/off-peak pricing** — session cost follows DeepSeek's 2026-08-17 peak/off-peak billing (peak 9:00-12:00 / 14:00-18:00 Beijing time on weekdays; weekends are off-peak all day since 2026-08-23), priced per-message by timestamp, with a live `peak`/`off-peak` indicator in the footer (see [DeepSeek](#deepseek))
|
|
11
12
|
- **Token usage**: input, output, cache read/write, total per session, with cache hit rate
|
|
12
13
|
- **Cost**: cumulative session cost with currency auto-detection (¥ for DeepSeek/CNY, $ otherwise)
|
|
13
14
|
- **Context window**: usage percentage and size
|
|
@@ -20,7 +21,29 @@ This extension uses a provider-aware strategy: when the active model belongs to
|
|
|
20
21
|
|
|
21
22
|
### DeepSeek
|
|
22
23
|
|
|
23
|
-
Shows live **account balance** and **
|
|
24
|
+
Shows live **account balance**, **weekly token usage**, and **peak/off-peak aware session cost**. Since DeepSeek introduced peak/off-peak pricing on 2026-08-17, pi-statusline tracks it automatically.
|
|
25
|
+
|
|
26
|
+
#### Peak / Off-peak pricing (since 2026-08-17)
|
|
27
|
+
|
|
28
|
+
DeepSeek now bills in two periods — **peak hours are 9:00-12:00 and 14:00-18:00 Beijing time** (UTC+8) on weekdays, all other hours are off-peak, and **off-peak is half the peak price**. Since **2026-08-23 00:00 Beijing time**, weekends (Saturday/Sunday) no longer distinguish periods and bill at the off-peak price all day. Official CNY prices per million tokens:
|
|
29
|
+
|
|
30
|
+
| Model | Period | Cache-hit input | Cache-miss input | Output |
|
|
31
|
+
|---|---|---|---|---|
|
|
32
|
+
| deepseek-v4-flash / deepseek-v4-flash-vision-exp | off-peak / peak | ¥0.05 / ¥0.10 | ¥1.5 / ¥3.0 | ¥4.5 / ¥9.0 |
|
|
33
|
+
| deepseek-v4-pro | off-peak / peak | ¥0.15 / ¥0.30 | ¥4.5 / ¥9.0 | ¥13.5 / ¥27.0 |
|
|
34
|
+
|
|
35
|
+
- **Per-message pricing by timestamp** — each message is priced at the rate of its own time (`AssistantMessage.timestamp`), so a long session spanning a period boundary (9:00/12:00/14:00/18:00) accounts every message correctly instead of using a single fixed rate.
|
|
36
|
+
- **Peak/off-peak indicator** — the footer appends the current period so you always know which rate is in effect: `peak` during weekday 9:00-12:00 / 14:00-18:00 Beijing time, `off-peak` otherwise (including all day on weekends since 2026-08-23):
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
¥0.12/50.00 · 7d:1.2M · off-peak
|
|
40
|
+
¥0.12/50.00 · 7d:1.2M · peak
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- **Registry pricing patch** — for CNY-billed accounts the model registry cost is aligned to the current period at runtime (and re-aligned automatically when the period flips), so pi's recorded `usage.cost` tracks the period too.
|
|
44
|
+
- **USD-billed accounts** keep pi's built-in USD prices (no CNY override, no peak/off-peak indicator).
|
|
45
|
+
|
|
46
|
+
#### Balance & weekly tokens
|
|
24
47
|
|
|
25
48
|
| Segment | Example | Source |
|
|
26
49
|
|---------|---------|--------|
|
|
@@ -28,7 +51,6 @@ Shows live **account balance** and **weekly token usage**.
|
|
|
28
51
|
| Weekly tokens | `7d:1.2M` | Local session file scan (rolling 7 days) |
|
|
29
52
|
|
|
30
53
|
- Currency auto-detected as `¥` (CNY) from the balance API response
|
|
31
|
-
- Session cost follows DeepSeek's peak/off-peak pricing (since 2026-08-17): peak hours are 9:00-12:00 and 14:00-18:00 Beijing time, off-peak is half price. Each message is priced at the rate of its own timestamp; the footer marks the current period (`peak` / `off-peak`).
|
|
32
54
|
- Balance is fetched on startup and refreshed in the background; cached for 5 minutes
|
|
33
55
|
- Triggered when `model.provider === "deepseek"`
|
|
34
56
|
|
|
@@ -97,12 +119,12 @@ See the Pi Packages guide on [pi.dev](https://pi.dev) for the full list of sourc
|
|
|
97
119
|
|
|
98
120
|
```
|
|
99
121
|
~/projects/my-repo (main) deepseek-v4-pro · xhigh
|
|
100
|
-
tokens 65k(in 12k, out 8k, cache 45k) · ¥0.12/50.00 · 7d:1.2M · 45.2%/64k · 2m30s 38.2tok/s
|
|
122
|
+
tokens 65k(in 12k, out 8k, cache 45k) · ¥0.12/50.00 · 7d:1.2M · off-peak · 45.2%/64k · 2m30s 38.2tok/s
|
|
101
123
|
```
|
|
102
124
|
|
|
103
125
|
**Line 1**: cwd + git branch (left) | model + thinking level (right)
|
|
104
126
|
|
|
105
|
-
**Line 2**: token stats · provider usage · context window · timing
|
|
127
|
+
**Line 2**: token stats · provider usage (incl. DeepSeek peak/off-peak indicator) · context window · timing
|
|
106
128
|
|
|
107
129
|
### GLM/ZAI example
|
|
108
130
|
|
package/package.json
CHANGED
package/pricing/deepseek.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* 因此所有「修正」都必须跟随结算币种与峰谷时段:
|
|
11
11
|
* 1. `billedInCny()`:判定是否按 CNY 计价 —— 用户显式 `/currency` 优先;否则按 balance API
|
|
12
12
|
* 探测到的账户币种(探测失败/未知时按 CNY,保持原有「deepseek → ¥」默认行为)。
|
|
13
|
-
* 2. `isDeepSeekPeakTime()`:按北京时间(UTC+8
|
|
13
|
+
* 2. `isDeepSeekPeakTime()`:按北京时间(UTC+8,无夏令时)判定指定时刻是否高峰时段
|
|
14
|
+
* (2026-08-23 00:00 起周末周六、周日全天不再区分峰谷,统一按低谷价)。
|
|
14
15
|
* 3. `messageCost()`:按消息时刻对应的峰谷单价重算单条消息成本(仅 CNY 计价时接管;USD 计价
|
|
15
16
|
* 返回 null 回退 pi 记录的 cost —— 会话文件里已记录的 cost 无法追溯修正)。
|
|
16
17
|
* 4. `applyPricingPatch()`:运行时把注册表中 deepseek 模型定价覆盖为当前时段的官方 CNY 价
|
|
@@ -38,6 +39,11 @@ export const DEEPSEEK_CNY_PRICES: Record<string, DeepSeekCnyPrice> = {
|
|
|
38
39
|
peak: { input: 3.0, output: 9.0, cacheRead: 0.1, cacheWrite: 0 },
|
|
39
40
|
offPeak: { input: 1.5, output: 4.5, cacheRead: 0.05, cacheWrite: 0 },
|
|
40
41
|
},
|
|
42
|
+
// 视觉变体:官方定价与 V4-Flash 完全相同(图片按 token 计费,单张最高 384 tokens,无视觉专项费用)
|
|
43
|
+
"deepseek-v4-flash-vision-exp": {
|
|
44
|
+
peak: { input: 3.0, output: 9.0, cacheRead: 0.1, cacheWrite: 0 },
|
|
45
|
+
offPeak: { input: 1.5, output: 4.5, cacheRead: 0.05, cacheWrite: 0 },
|
|
46
|
+
},
|
|
41
47
|
"deepseek-v4-pro": {
|
|
42
48
|
peak: { input: 9.0, output: 27.0, cacheRead: 0.3, cacheWrite: 0 },
|
|
43
49
|
offPeak: { input: 4.5, output: 13.5, cacheRead: 0.15, cacheWrite: 0 },
|
|
@@ -46,12 +52,26 @@ export const DEEPSEEK_CNY_PRICES: Record<string, DeepSeekCnyPrice> = {
|
|
|
46
52
|
|
|
47
53
|
const PER_MILLION = 1_000_000;
|
|
48
54
|
|
|
55
|
+
const BJ_OFFSET_MS = 8 * 60 * 60 * 1000;
|
|
56
|
+
|
|
57
|
+
/** 周末全天低谷价生效起点:2026-08-23 00:00 北京时间 = 2026-08-22T16:00Z。 */
|
|
58
|
+
const WEEKEND_OFFPEAK_SINCE_MS = Date.parse("2026-08-22T16:00:00Z");
|
|
59
|
+
|
|
49
60
|
/**
|
|
50
61
|
* DeepSeek 高峰时段判定:北京时间(UTC+8,无夏令时)9:00-12:00、14:00-18:00 为高峰,
|
|
51
62
|
* 其余为空闲时段(官方定价页备注)。`at` 可指定时刻,默认当前时间。
|
|
63
|
+
*
|
|
64
|
+
* 2026-08-23(周日)00:00 北京时间起,官方调整:周末(周六、周日)全天不再区分峰谷,
|
|
65
|
+
* 统一按低谷价收取 —— 即生效后的周六/周日任何时刻均判为空闲时段。生效前(如 2026-08-22
|
|
66
|
+
* 周六)的历史消息仍按旧规则计价,保证跨生效日的长会话逐条重算正确。
|
|
52
67
|
*/
|
|
53
68
|
export function isDeepSeekPeakTime(at: Date = new Date()): boolean {
|
|
54
|
-
const
|
|
69
|
+
const beijing = new Date(at.getTime() + BJ_OFFSET_MS);
|
|
70
|
+
if (at.getTime() >= WEEKEND_OFFPEAK_SINCE_MS) {
|
|
71
|
+
const bjDay = beijing.getUTCDay(); // 0=周日 6=周六(按北京日期,非 UTC 日期)
|
|
72
|
+
if (bjDay === 0 || bjDay === 6) return false;
|
|
73
|
+
}
|
|
74
|
+
const beijingHour = beijing.getUTCHours();
|
|
55
75
|
return (beijingHour >= 9 && beijingHour < 12) || (beijingHour >= 14 && beijingHour < 18);
|
|
56
76
|
}
|
|
57
77
|
|