跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    nero-sensei

    Cache Timer

    v0.1.2模型接入
    opencode-cache-timer

    OpenCode TUI sidebar plugin: prompt cache TTL countdown for Claude, GPT, Gemini, DeepSeek, and more

    GitHub 星标

    2

    月装机量

    56

    近 7 天 8

    综合评分SCORE

    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"]
    }

    opencode 启动时会通过内嵌运行时自动加载 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:modelIDproviderID → 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