useful-pi-extensions 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "useful-pi-extensions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A small collection of pi extensions, installed with one command — a labelled status line with context pressure, cache, cost, effort, TTFT and tokens/sec.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -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.
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
68
|
-
|
|
69
|
-
- `
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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$',
|