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
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
- **颜色自适应**:命中率 ≥85% 绿 · ≥70% 橙 · <70% 红,颜色从主题色自动去饱和
- **Token 分布**:按角色(系统提示 / 用户 / Agent 指令 / Tool 调用 / Tool 结果)展示估算 Token 占比
- **折叠记忆**:折叠状态持久化,重启后保持
- **语言适配**:自动检测系统语言,支持 `/cache-lang` 运行时切换中/英文,偏好持久化
- **语言适配**:支持 中文 / English / 日本語 / 한국어,自动检测系统语言,`/cache-lang` 运行时切换,偏好持久化优先
- **多币种**:通过 `/cache-currency` 切换货币,费用和节省同步换算
- **余额查询**:查询多家 AI 提供商的账户余额,支持自动切换跟随当前会话提供商
- **斜杠命令**:`/cache-session` `/cache-session-back` `/cache-rate` `/cache-section` `/cache-config` `/cache-lang` 动态配置面板
- **子代理缓存查看**:`/cache-session` 自动扫描并列出子代理,选择一个即可切换面板显示其缓存统计,支持 `/cache-session-back` 返回主会话
- **已加载技能**:检测 session 中 LLM 调用 `skill` tool 的记录,展示已加载技能名及估算 Token 占用
- **底部状态栏**:输入框提示行单行显示 命中率(含趋势)· Tokens · 余额,关闭侧边栏也能随时看到缓存统计,可经 `/cache-section` 隐藏

---

Expand Down Expand Up @@ -106,7 +107,7 @@ npm install -g opencode-visual-cache@latest
| `/cache-session-back` | 返回主会话统计 | 从子代理缓存视图切回主会话 |
| `/cache-currency` | 切换货币单位 | 从列表选择货币(USD / CNY / EUR / JPY / GBP / KRW),自动填入默认汇率 |
| `/cache-rate` | 调整汇率乘数 | 输入自定义汇率(如 `7.2`),用于费用换算 |
| `/cache-section` | 开关区块与边框 | 独立控制 Token 明细 / 模型与定价 / 估算 Token 分布 / 已加载技能 / 余额 / 面板边框的显隐 |
| `/cache-section` | 开关区块与边框 | 独立控制 Token 明细 / 模型与定价 / 估算 Token 分布 / 已加载技能 / 余额 / 底部状态栏 / 面板边框的显隐 |
| `/cache-config` | 查看当前配置 | 弹出当前货币、汇率、区块可见性状态 |
| `/cache-lang` | 切换显示语言 | 从列表选择中文或 English,界面即时切换,无需重启 |
| `/cache-balance` | 余额查询设置 | 选择余额提供商(菜单标注 Key 来源:用户 key / OpenCode / 未配置)/ 开关自动切换 |
Expand Down Expand Up @@ -145,6 +146,7 @@ npm install -g opencode-visual-cache@latest
- **估算 Token 分布**:按角色拆分的 Token 估算
- **已加载技能**:session 中 LLM 实际调用过的 Skill 名及估算 Token 占用
- **余额**:当前提供商账户余额(多提供商 + 自动切换)
- **底部状态栏**:输入框提示行的 命中率 · Tokens · 余额 单行统计

通过 `/cache-section` 切换后即时生效,无需重启。此外,该命令还可以开关面板的**外边框**——关闭后内容会顶格显示,释放额外空间。

Expand Down Expand Up @@ -172,6 +174,10 @@ npm install -g opencode-visual-cache@latest
> **自动切换**:默认开启;手动选择提供商后自动关闭,可在 `/cache-balance` 中重新开启。自动切换按当前会话的模型提供商匹配,未配置 Key 的提供商被选中时显示「未配置」提示。
>
> **希望支持**:已调研确认具备可行性的候选提供商,尚未实现。智谱 GLM 仅有社区逆向的非官方端点(无稳定性保障)。
>
> **统计口径**:命中率 = 缓存读 /(新鲜输入 + 缓存读 + 缓存写),与业界(OpenAI / Anthropic / Bedrock)口径一致;明细中「未命中」= 新鲜输入 + 缓存写。底部栏的 Tokens 为输入侧总量(不含输出)。未单独报告缓存写的提供商(如 DeepSeek)自动退化为 hit/miss 口径。
>
> **余额显示**:侧边栏与底部栏共享同一份余额数据,两处显示一致。当前提供商不支持余额查询时,侧边栏显示提示、底部栏隐藏余额项。

---

Expand Down Expand Up @@ -207,11 +213,11 @@ rm -rf ~/.cache/opencode/packages/opencode-visual-cache@latest

### 6.1 运行时切换(推荐)

在 TUI 中输入 `/cache-lang`,从弹窗选择「中文」或「English即可即时切换,无需重启。偏好会自动持久化,下次启动自动恢复
在 TUI 中输入 `/cache-lang`,从弹窗选择 中文 / English / 日本語 / 한국어 即可即时切换,无需重启。偏好会自动持久化,下次启动优先恢复用户选择

### 6.2 环境变量覆盖

启动前设置 `CACHE_TUI_LANG` 环境变量可强制指定语言:
启动前设置 `CACHE_TUI_LANG` 环境变量可强制指定语言(`zh` / `en` / `ja` / `ko`)

```powershell
# Windows PowerShell
Expand Down
14 changes: 10 additions & 4 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ Interested in sub-agent monitoring? Check out [opencode-subagent-magazine](https
- **Adaptive Colors**: ≥85% green · ≥70% orange · <70% red, auto-desaturated from current theme
- **Token Distribution**: Per-role (system / user / agent instr / tool call / tool result) estimated token breakdown
- **Persistent State**: Fold preferences and config remembered across restarts via api.kv
- **Language**: Auto-detects system locale, with `/cache-lang` for runtime switching between Chinese and English — preference persisted across restarts
- **Language**: Chinese / English / 日本語 / 한국어, auto-detects system locale, with `/cache-lang` for runtime switching — user preference takes priority over auto-detection
- **Multi-currency**: Switch via `/cache-currency` — costs, savings, and per-million rates convert in real time
- **Balance Query**: Query account balance across multiple AI providers, with auto-switch following the current session's provider
- **Slash Commands**: `/cache-session` `/cache-session-back` `/cache-rate` `/cache-section` `/cache-config` `/cache-lang` for live panel configuration
- **Sub-Agent Cache View**: `/cache-session` auto-scans and lists sub-agents; select one to switch the panel stats. Use `/cache-session-back` to return to the main session
- **Loaded Skills**: Detects `skill` tool calls in the session and displays loaded skill names with estimated token footprint
- **Bottom Status Bar**: single-line hit rate (with trend) · Tokens · Balance in the prompt hint row — visible even with the sidebar closed; hide it anytime via `/cache-section`

---

Expand Down Expand Up @@ -106,7 +107,7 @@ The plugin supports slash commands and command palette (`Ctrl + P`) for runtime
| `/cache-session-back` | Return to main session | Switch back to main session from sub-agent cache view |
| `/cache-currency` | Switch currency | Pick from a list (USD / CNY / EUR / JPY / GBP / KRW); default exchange rate auto-filled |
| `/cache-rate` | Adjust exchange rate | Enter a custom rate (e.g. `7.2` for CNY) |
| `/cache-section` | Toggle sections & border | Independently show/hide Detail, Model & Pricing, Token Distribution, Loaded Skills, Balance, or the panel border |
| `/cache-section` | Toggle sections & border | Independently show/hide Detail, Model & Pricing, Token Distribution, Loaded Skills, Balance, Bottom Bar, or the panel border |
| `/cache-config` | View current config | Displays currency, rate, and section visibility |
| `/cache-lang` | Switch display language | Pick Chinese or English from the dialog — takes effect immediately, no restart needed |
| `/cache-balance` | Balance query settings | Pick a balance provider (menu shows key source: user key / OpenCode / not set) / toggle auto-switch |
Expand Down Expand Up @@ -145,6 +146,7 @@ Three sub-sections can be toggled independently to save sidebar space:
- **Estimated Token Dist.**: per-role token breakdown
- **Loaded Skills**: skill names the LLM actually loaded via the `skill` tool, with estimated token counts
- **Balance**: the selected provider's account balance (multi-provider with auto-switch)
- **Bottom Status Bar**: the single-line hit rate · Tokens · Balance stats in the prompt hint row

Toggled via `/cache-section` — takes effect instantly, no restart required. The same command also toggles the panel **border**; turning it off removes the outline and padding so content fills the full width.

Expand All @@ -170,6 +172,10 @@ Supported balance providers:
> **Auto-switch**: enabled by default; picking a provider manually disables it — re-enable anytime via `/cache-balance`. Auto-switch matches the current session's model provider; a provider without a key shows a "not set" hint when selected.
>
> **Planned**: candidates confirmed feasible by research, not yet implemented. Zhipu GLM only has a community-reversed unofficial endpoint (no stability guarantee).
>
> **Metric semantics**: hit rate = cache read / (fresh input + cache read + cache write), consistent with the industry (OpenAI / Anthropic / Bedrock). "Miss" in the detail view = fresh input + cache write. The bottom-bar Tokens is the input-side total (output excluded). Providers that do not report cache writes separately (e.g. DeepSeek) automatically fall back to the hit/miss formula.
>
> **Balance display**: the sidebar and bottom bar share the same balance data, so both show identical values. When the current provider has no balance adapter, the sidebar shows a hint and the bottom bar hides the balance segment.

---

Expand Down Expand Up @@ -205,11 +211,11 @@ The plugin provides three ways to control the display language, listed by priori

### 6.1 Runtime Switching (recommended)

Type `/cache-lang` in the TUI and select **Chinese** or **English** from the dialog. The panel switches immediately without restarting, and your preference is persisted automatically for the next session.
Type `/cache-lang` in the TUI and select Chinese / English / 日本語 / 한국어 from the dialog. The panel switches immediately without restarting. Your preference is persisted and takes priority over auto-detection on the next launch.

### 6.2 Environment Variable Override

Set the `CACHE_TUI_LANG` environment variable before launching to force a specific language:
Set the `CACHE_TUI_LANG` environment variable before launching to force a specific language (`zh` / `en` / `ja` / `ko`):

```powershell
# Windows PowerShell
Expand Down
Loading
Loading