Instructions for humans and coding agents working in opencode-cache-hit. End-user docs: README.md · README.zh-CN.md.
OpenCode TUI sidebar plugin: cache hit rate, tokens, cost, with sub-agent (child session) rollup. Optional per-call JSONL timeline (timeline.enabled).
Not a fork of opencode-visual-cache. UI patterns and src/tui-panel/ are heavily inspired by visual-cache; product focus differs (see README comparison table).
| Topic | English | 中文 |
|---|---|---|
| Users | README.md | README.zh-CN.md |
| Architecture | docs/en/design.md | docs/zh-CN/design.md |
| Timeline / JSONL | docs/en/timeline.md | docs/zh-CN/timeline.md |
| Token Speed | docs/en/token-speed.md | docs/zh-CN/token-speed.md |
| TTFT Hybrid | docs/en/ttft-hybrid.md | docs/zh-CN/ttft-hybrid.md |
| TTFT Troubleshooting | docs/en/ttft-troubleshooting.md | docs/zh-CN/ttft-troubleshooting.md |
| TUI panel | src/tui-panel/README.md | src/tui-panel/README.zh-CN.md |
| Migration plan | docs/en/frontend-migration-plan.md | docs/zh-CN/frontend-migration-plan.md |
| Contributing / npm | CONTRIBUTING.md | — |
| Index | docs/README.md |
bun test # full unit + module-load smoke
bun run check # same as testAfter moving or renaming exports: run full bun test; tests/module-load.test.ts imports the real consumer graph.
- Minimal diffs; match existing naming and module boundaries.
- Pure logic in
stats.ts,first-part-time.ts,timeline/,format-*.ts,format-model.ts,tui-panel/layout.ts— avoid pulling JSX into modules used by tests (importlayout.ts/palette.tsdirectly, nottui-panel/index.tswhen possible). - Sub-agent row UI:
format-model.ts+agents-view.tsx; behavior in design doc § Sub-agent row display / 子 session 行展示. PLUGIN_ROOTinload-config.tsisfileURLToPath(new URL("..", import.meta.url))— do not wrap with an extradirname(breaks config path).- Sub-agent ids: only from
session.listoverwrite inchild-session-sync.ts; do not append viasession.get. - Agents UI totals: child sessions only; main session excluded by design (see design doc).
- Comments only for non-obvious behavior.
- Example: cache-hit.config.example.json — included in npm
files. - Runtime:
~/.config/opencode/cache-hit.json(preferred) orcache-hit.config.jsonbeside package root (legacy fallback); not published; gitignored. - Defaults: src/plugin-config.ts.
- Timeline log dir default:
~/.local/share/opencode/logs/cache-hit/. Supports~/expansion intimeline.dir.
- Tarball =
package.json"files"only (source TSX, example config, docs — notests/,logs/, user config). - No build step required for OpenCode
./tuientry (index.tsx). - Run
bun testbeforenpm publish; see CONTRIBUTING.md.
- Entry: index.tsx → src/plugin.tsx.
- Slot:
sidebar_content,order: 56(near visual-cache). - Peers:
@opencode-ai/plugin,@opencode-ai/sdk,@opentui/solid,solid-js(see package.json).
- Do not
git reset --hard,checkout --, or force-push unless the user explicitly asks. - Do not commit unless asked; do not commit
logs/or personalcache-hit.config.jsonif gitignored.
- Prefer config file over slash commands unless parity with visual-cache is an explicit goal.
- Timeline changes: update both
docs/en/timeline.mdanddocs/zh-CN/timeline.md. - User-facing README changes: update English README and mirror key points in README.zh-CN.md.