Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ contextUsedTokens = usage.input_tokens +
mode = "conversation" # 或 "session"
```

##### 💱 货币显示

`usage` 组件默认使用 `currency = "auto"`。自动模式会先应用你配置的 endpoint/model 规则,再读取 Claude Code 传入的 `cost.currency`,随后匹配内置 endpoint/model 规则,最后回退到 USD。DeepSeek、MiniMax、Kimi、GLM、百炼、火山方舟、MiMo 等中外站点不同币种的 provider,建议优先用 endpoint 规则区分。

注意:`conversation` 模式读取的是历史聚合的 `total_cost_usd` 存储值。为避免只换符号、不换金额,`currency = "auto"` 在该模式下会显示 USD;如果你确认自己的聚合成本已经是其他币种,可用 `currency = "CNY"` 等固定值强制显示。

```toml
[components.usage]
currency = "auto" # auto | USD | CNY | EUR | GBP | JPY ...

[components.usage.currency_endpoint_rules]
"api.example.cn" = "CNY"
"api.example.com" = "USD"

[components.usage.currency_model_rules]
"my-cny-model" = "CNY"
```

##### 📊 成本计算公式

```javascript
Expand Down Expand Up @@ -669,6 +687,24 @@ Set in `config.toml`:
mode = "conversation" # or "session"
```

##### 💱 Currency Display

The `usage` component defaults to `currency = "auto"`. Auto mode first applies your custom endpoint/model rules, then trusts `cost.currency` from Claude Code when present, then matches built-in endpoint/model rules, and finally falls back to USD. For providers with different China/global pricing, such as DeepSeek, MiniMax, Kimi, GLM, Model Studio, Volcengine/BytePlus, and MiMo, prefer endpoint rules.

Note: `conversation` mode reads historical `total_cost_usd` aggregate values from storage. To avoid changing only the symbol without converting the amount, `currency = "auto"` displays USD in that mode; use a fixed value such as `currency = "CNY"` only when you know the aggregate costs are already in that currency.

```toml
[components.usage]
currency = "auto" # auto | USD | CNY | EUR | GBP | JPY ...

[components.usage.currency_endpoint_rules]
"api.example.cn" = "CNY"
"api.example.com" = "USD"

[components.usage.currency_model_rules]
"my-cny-model" = "CNY"
```

##### 📊 Cost Calculation Formula

```javascript
Expand Down
17 changes: 17 additions & 0 deletions configs/config.template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ text_icon = "[$]"
# 数值精度 | Decimal precision - 成本显示的小数位数
precision = 2

# 货币显示 | Currency display
# "auto": 根据自定义规则、ANTHROPIC_BASE_URL endpoint、上游 cost.currency 和模型名推断
# conversation 模式的历史聚合值来自 total_cost_usd 存储,auto 会保持 USD 符号
# 也可强制指定 "USD"、"CNY"、"EUR"、"GBP"、"JPY" 等
currency = "auto"

# 显示模式 | Display mode
# "session": 仅显示当前session成本(如 "$0.05")
# "conversation": 显示跨session累加成本(如 "$6.96 (2 sessions)")
Expand All @@ -382,6 +388,17 @@ show_lines_added = true
# 显示删除的代码行数 | Show lines removed
show_lines_removed = false

# 自定义 endpoint -> currency 映射,优先级高于上游 cost.currency 和内置自动规则
# 规则 key 可以写 host,也可以写完整 base URL;按 host 后缀匹配
[components.usage.currency_endpoint_rules]
# "api.example.cn" = "CNY"
# "https://api.example.com/v1" = "USD"

# 自定义 model name -> currency 映射,优先级低于 endpoint 映射,高于上游 cost.currency 和内置规则
# 规则 key 按大小写不敏感的子串匹配
[components.usage.currency_model_rules]
# "my-cny-model" = "CNY"

# -------------------- Status组件 --------------------
# 显示Claude Code的当前状态和最近错误信息
[components.status]
Expand Down
Loading