@reedchan/statusline 1.4.0 → 1.5.0

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/README.md CHANGED
@@ -53,29 +53,34 @@ Configuration lives at the top of [`render.ts`](render.ts):
53
53
  ## Currency
54
54
 
55
55
  pi prices every model in USD and its `cost` field carries no unit at all, so the footer cannot know
56
- what you were actually billed. What a session cost in RMB is set by whoever sold you the credit, not
57
- by a market feed, which is why the rate is configured rather than fetched.
58
-
59
- Create `~/.pi/agent/statusline.json`:
56
+ what you were actually billed. The currency and the rate live in `~/.pi/agent/statusline.json`:
60
57
 
61
58
  ```json
62
59
  {
63
60
  "currency": {
64
- "code": "CNY",
65
- "perUsd": 7.12
61
+ "code": "CNY"
66
62
  }
67
63
  }
68
64
  ```
69
65
 
70
- - `code` picks the symbol (`CNY` and `RMB` give `¥`; the table also knows `USD`, `EUR`, `GBP`, `JPY`,
71
- `HKD`, `TWD`, `SGD`, `KRW` and `INR`). A code the table does not know is printed as it is.
72
- - `symbol` overrides the table, for a currency it does not list or a different separator.
73
- - `perUsd` is how many units of that currency one dollar buys the rate you were actually charged.
74
- It has to be a positive number; anything else is refused and the footer stays in USD.
66
+ Two ways to set the rate:
67
+
68
+ - **Follow the market.** A `code` with no rate fetches the day's table from open.er-api.com on the
69
+ first session of each day and caches the whole table in the file (`rates` + `fetchedAt`), so the
70
+ next session starts warm and switching codes is instant and offline.
71
+ - **Pin it.** Add `"perUsd": 7.12` and the footer always uses that rate, never touching the network
72
+ — the right choice when your platform bills in RMB directly, because a domestic price list is not
73
+ the dollar list times a market rate.
74
+
75
+ `code` picks the symbol: `¥` for `CNY` and `RMB`, `JP¥` for `JPY` so the two never trade places, and
76
+ the table also knows `USD`, `EUR`, `GBP`, `HKD`, `TWD`, `SGD`, `KRW`, `INR`, `AUD`, `CAD`, `NZD` and
77
+ `CHF`; an unknown code is printed as it is. `symbol` overrides all of that.
75
78
 
76
- With the file above, the same session reads `Cost ¥1.63` instead of `Cost $0.229`. The file is read
77
- once per session, so edit it and `/reload`. A file that is there but unusable says so in a
78
- notification, rather than silently showing dollars with nothing to explain why.
79
+ Switching is editing `code`, or `make currency CODE=JPY` from a checkout. The file is read once per
80
+ session, so finish with `/reload`. A file that is there but unusable says so in a notification,
81
+ rather than silently showing dollars with nothing to explain why.
82
+
83
+ ## Metrics
79
84
 
80
85
  ## Metrics
81
86
 
package/README_CN.md CHANGED
@@ -51,27 +51,31 @@ LSP Active: typescript
51
51
  ## 币种
52
52
 
53
53
  pi 里所有模型价格都是美元,而且它的 `cost` 字段**不带任何单位**,所以 footer 无从知道你实际是按什么币种付的。
54
- 这次会话折合多少人民币,取决于卖你额度那家给的汇率,而不是市场汇率——所以汇率是**配置**出来的,不是联网抓的。
55
-
56
- 创建 `~/.pi/agent/statusline.json`:
54
+ 币种与汇率放在 `~/.pi/agent/statusline.json`:
57
55
 
58
56
  ```json
59
57
  {
60
58
  "currency": {
61
- "code": "CNY",
62
- "perUsd": 7.12
59
+ "code": "CNY"
63
60
  }
64
61
  }
65
62
  ```
66
63
 
67
- - `code` 决定符号(`CNY` 与 `RMB` 得到 `¥`;符号表还认 `USD`、`EUR`、`GBP`、`JPY`、`HKD`、`TWD`、
68
- `SGD`、`KRW`、`INR`)。表里没有的代码就原样打印。
69
- - `symbol` 可覆盖符号表,用于表里没列的币种,或想换分隔方式。
70
- - `perUsd` 是一美元等于多少该币种,也就是**你实际被收的汇率**。必须是正数;
71
- 否则整块被拒绝,footer 继续显示美元。
64
+ 汇率有两种设法:
65
+
66
+ - **跟随市场。** 只写 `code` 不写汇率时,每天第一个会话会从 open.er-api.com 拉取当日汇率表,
67
+ 并把整张表缓存进文件(`rates` + `fetchedAt`),下个会话热启动;切换币种即时生效、离线也能切。
68
+ - **钉死。** 加上 `"perUsd": 7.12`,footer 永远用这个汇率、绝不联网——如果你的平台直接按人民币计费,
69
+ 这是正确选择:国内价目表不是美元价目表乘以市场汇率。
70
+
71
+ `code` 决定符号:`CNY` 和 `RMB` 得到 `¥`,`JPY` 得到 `JP¥`(两者永不混用),符号表还认 `USD`、
72
+ `EUR`、`GBP`、`HKD`、`TWD`、`SGD`、`KRW`、`INR`、`AUD`、`CAD`、`NZD`、`CHF`;表里没有的代码原样打印。
73
+ `symbol` 可覆盖这一切。
72
74
 
73
- 配置成上面这样,同一个会话就从 `Cost $0.229` 变成 `Cost ¥1.63`。该文件每个会话只读一次,
74
- 改完需 `/reload`。文件存在但不可用时会给出通知,而不是静默继续显示美元。
75
+ 切换就是改 `code`,或者在检出里执行 `make currency CODE=JPY`。该文件每个会话只读一次,改完需 `/reload`。
76
+ 文件存在但不可用时会给出通知,而不是静默继续显示美元。
77
+
78
+ ## 指标口径
75
79
 
76
80
  ## 指标口径
77
81
 
@@ -143,13 +143,18 @@ export const USD: Currency = { symbol: '$', perUsd: 1 }
143
143
 
144
144
  /** Currencies the config can name by `code` alone. Anything else needs an explicit `symbol`. */
145
145
  const CURRENCY_SYMBOLS: Record<string, string> = {
146
+ AUD: 'A$',
147
+ CAD: 'CA$',
148
+ CHF: 'CHF',
146
149
  CNY: '¥',
147
150
  EUR: '€',
148
151
  GBP: '£',
149
152
  HKD: 'HK$',
150
153
  INR: '₹',
151
- JPY: '¥',
154
+ // ¥ is CNY's by default; JPY wears the prefixed form so the two never trade places.
155
+ JPY: 'JP¥',
152
156
  KRW: '₩',
157
+ NZD: 'NZ$',
153
158
  RMB: '¥',
154
159
  SGD: 'S$',
155
160
  TWD: 'NT$',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reedchan/statusline",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Replaces pi's footer with a labelled two-row status line: context pressure as a fixed-size meter, cache and cost, the model and effort level, and the latest turn's TTFT and decode throughput in tokens/second.",
5
5
  "keywords": [
6
6
  "bun",