Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kimi Code Statusbar Plugin

中文

Adds extra metrics to the Kimi Code TUI status bar — TPS, TTFT, prompt-cache hit rate, and plan usage (dynamic frequency limits plus the weekly quota).

Requires the new kimi CLI with data under ~/.kimi-code (not legacy kimi-cli / ~/.kimi). The quota hook follows Kimi's rotating OAuth credentials and refreshes an expired access token automatically.

1. Install the plugin

In the Kimi Code TUI:

/plugins install /absolute/path/to/kimi-code-statusbar-plugin
/plugins enable statusline-usage
/plugins reload

Installed copy:

~/.kimi-code/plugins/managed/statusline-usage/
├── kimi.plugin.json
├── statusline.mjs                 ← referenced by tui.toml
└── hooks/refresh-usage-cache.mjs  ← refreshes quota on SessionStart / Heartbeat

After you edit the plugin source or pull updates, run /plugins install <path> again. Kimi always runs the managed copy, not your original directory.

2. Configure the footer (required)

Kimi’s plugin system cannot inject footer UI by itself. You must point status_line.command at the script.

Edit ~/.kimi-code/tui.toml (not ~/.kimi/). Use an absolute path in the command — ~ is only expanded by POSIX shells, not by Windows cmd.exe:

[status_line]
# Official L1 is fully replaced by this command.
# The script redraws the stock left strip, then appends custom metrics.
# macOS / Linux:
command = "node /Users/YOU/.kimi-code/plugins/managed/statusline-usage/statusline.mjs"
# Windows (forward slashes work in Node; or escape backslashes as \\):
# command = "node C:/Users/YOU/.kimi-code/plugins/managed/statusline-usage/statusline.mjs"

In the TUI:

/reload-tui

3. Verify

# Refresh the plan-usage cache once
node ~/.kimi-code/plugins/managed/statusline-usage/hooks/refresh-usage-cache.mjs

# Smoke-test the status line (swap in your sessionId / cwd)
printf '%s' '{"model":"K3-256k","cwd":"./project","gitBranch":"main","permissionMode":"yolo","planMode":false,"contextUsage":0.12,"contextTokens":32000,"maxContextTokens":262144,"sessionId":"YOUR_SESSION_ID","version":"0.34.0"}' \
  | node ~/.kimi-code/plugins/managed/statusline-usage/statusline.mjs

On Windows cmd.exe, replace every ~ above with the absolute path (e.g. C:/Users/YOU/.kimi-code/...) — cmd.exe does not expand ~.

Expected shape:

yolo  K3-256k thinking: high  …/Documents/code/project  main [+1585 -1259 ↑1]  TPS 38.3  TTFT 6.2s  cache 99.42%  5h …  week …          /theme to switch the terminal UI theme

Context stays on the official footer line 2 (context: N%). Rotating tips appear on the right of line 1 when there is room.

4. What each segment means

Segment Source Notes
yolo / auto / plan stdin permissionMode / planMode Same as the stock mode slot
K3-256k thinking: high stdin model + wire profile.bind / config.toml Thinking is not in the status-line payload; best-effort restore
[N agents running] session agents/*/tasks Best-effort; may differ slightly from the built-in BPM count
…/path stdin cwd Same path shortening as stock
main [+1585 -1259 ↑1] git status / diff --numstat (short TTL cache) Matches the stock git badge
TPS N wire step.endoutput / streamDurationMs Updates after each completed step, not mid-stream
TTFT N wire step.endllmFirstTokenLatencyMs Same step as TPS; 623ms / 6.2s / 1.3m
cache N.NN% wire usage.record Prompt-cache hit rate
frequency / week GET …/usagescache/statusline-usage.json Frequency label follows the API window (currently 5h); week is the weekly plan quota
extra ¥… boosterWallet Shown when Extra Usage is present
right-side tips built-in tip list 10s rotation; hidden when the row is too narrow

5. Environment variables

Variable Default Description
KIMI_CODE_HOME ~/.kimi-code Data root for the new CLI — do not point at ~/.kimi
STATUSLINE_CACHE_MODE last Cache hit rate: last step or whole session
STATUSLINE_CACHE_VERBOSE off 1cache 77.43% (13k/17k)
STATUSLINE_SHOW_CACHE on 0 hides the cache segment
STATUSLINE_SHOW_AGENTS on 0 hides the agent badge
STATUSLINE_SHOW_TPS on 0 hides TPS
STATUSLINE_TPS_VERBOSE off 1TPS 38.3 (487 tok)
STATUSLINE_SHOW_TTFT on 0 hides TTFT
STATUSLINE_TTFT_VERBOSE off 1TTFT 6.2s (339 tok)
STATUSLINE_SHOW_TIPS on 0 hides rotating tips
STATUSLINE_GIT_TTL_MS 5000 Local git-badge cache TTL
STATUSLINE_GIT_TIMEOUT_MS 120 Per git subprocess timeout (ms)
STATUSLINE_GIT_NUMSTAT on 0 skips diff --numstat (faster on huge repos)
STATUSLINE_CACHE_STALE_MS 45000 When plan-usage cache is older than this, kick a background refresh
STATUSLINE_USAGE_TIMEOUT_MS 8000 Timeout for usage and OAuth-refresh requests (ms)
STATUSLINE_COLUMNS / COLUMNS auto Terminal width for tip fit checks

6. Uninstall

/plugins disable statusline-usage
/plugins remove statusline-usage

Remove or comment out [status_line].command in tui.toml, then /reload-tui.

About

Adds extra metrics to the Kimi Code TUI status bar — TPS, prompt-cache hit rate and plan usage (5h / 7d windows).

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages