opencode-cache-timerOpenCode TUI sidebar plugin: prompt cache TTL countdown for Claude, GPT, Gemini, DeepSeek, and more
2
56
近 7 天 8
27.6
生态多维模型
4 个月前
2026-04-09
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-cache-timer@0.1.2"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-cache-timer@0.1.2"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-cache-timeropencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Sidebar countdown showing time until your prompt cache expires.
Cache
4m 23s
Install
Add to ~/.config/opencode/tui.json:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["opencode-cache-timer"]
}
Restart OpenCode. The Cache panel appears in the sidebar.
While iterating locally, point at the source file instead:
"plugin": ["/absolute/path/to/opencode-cache-timer/src/index.tsx"]
Configure
Edit src/providers/registry.ts to set TTLs per provider or per model.
export const DEFAULT_REGISTRY: TTLRegistry = {
// Provider-level: applies to every model under that provider
anthropic: 5 * MINUTE,
openai: 5 * MINUTE,
deepseek: 2 * HOUR,
google: 1 * HOUR,
xai: 5 * MINUTE,
// Per-model override (wins over provider-level)
"anthropic:claude-opus-4-6": 1 * HOUR,
"openai:gpt-5.4": 24 * HOUR,
}
Lookup order: providerID:modelID → providerID → no timer.
If a provider isn't in the registry, the panel shows ◦ idle and no countdown runs. Add an entry to enable it.
Defaults shipped
| Provider | TTL | Notes |
|---|---|---|
| Anthropic | 5 min | Default ephemeral cache. Override per-model for the 1h tier. |
| OpenAI | 5 min | Conservative; actual 5–10 min. Override per-model for the 24h tier. |
| DeepSeek | 2 hrs | Conservative; docs say "hours to days". |
| Google Gemini | 1 hr | Explicit Context Caching API default. |
| xAI Grok | 5 min | No SLA — treated as ephemeral. |
| Mistral | — | Undocumented; intentionally omitted. |
Design bias: conservative. A timer that says expired while the cache is still warm is harmless; a timer counting down on an already-dead cache is misleading.
Develop
bun install
bun test