Files
AgentHub/docs/STATUSLINE.md
T
nntrivi2001 4aae61297f feat: analytics parity — tool cost, date ranges, budgets, query explorer, replay, snapshots (v2.4.0)
Analytics parity phases 2–7 (docs/plans/analytics-parity/), built on
138e706 and ported onto v2.3.1:
- Cost by AI tool (?tool= on cost/analytics/stats/workflows, by_tool,
  Codex fast/priority and flex tiers, agenthub_cost_usd_total{tool,model})
- Date ranges (from/to) on cost/analytics/workflows; Analytics range select
  with Today / This week (Monday) / This month (1st) / 7d / 30d / 90d / All /
  Custom; workflow filters carried into workflow-stats.js (read worker)
- Budgets and cost alerts as alert rule types (alert_rules rebuilt without
  its rule_type CHECK), GET /api/budgets/status, rule preview, spend pace,
  status-bar budget chip; rules stay editable in place
- Query Explorer (/query, allowlisted sort, CSV/JSON export) and scheduled
  reports (report_definitions/report_runs, Settings → Reports)
- Session Replay tab and immutable snapshots (session_snapshots, /snapshot/:token)
- Remote Codex sync, push ingest with a hashed token, privacy redaction and
  ignored folders (Settings → Data), Cursor sessions (no cost)
- Read-only MCP server, statusline, Grafana/Prometheus files

Also: resizable sidebar, pet run/wave animations, the workspace home keeps a
half-typed prompt, and the pre-commit hook runs only the related tests for a
small commit.
2026-10-06 17:12:28 +07:00

2.6 KiB

AgentHub statusline for Claude Code

statusline/statusline.js is a Claude Code statusline command. It prints one line under the prompt:

Opus 5.5 · main · ███░░░░░░░ 34% · $1.23 · today $45.68
Part Source
model model.display_name from Claude Code's statusline JSON
branch git symbolic-ref --short HEAD in the session's cwd (short sha when detached; 500 ms cap)
context bar context_window.used_percentage, else current_usage (input + cache) ÷ context_window_size; green < 50 %, yellow < 80 %, red above
$1.23 this session, Claude Code's own cost.total_cost_usd
today $… every session today, from the dashboard: GET /api/pricing/cost?tz_offset=<local> → today's daily_costs row

Today's cost has a 1-second timeout and is cached for 30 s in <os tmpdir>/agenthub-statusline-<uid>.json — a failed fetch is cached too, so a stopped dashboard costs one timeout per 30 s, not one per prompt. When the dashboard is down the part is simply left out. The script never throws, stops itself after 2.5 s and always exits 0. The dashboard is found like the CLI finds it (AGENTHUB_URL, then CLAUDE_DASHBOARD_PORT/DASHBOARD_PORT, then ~/.claude/.agenthub.json); DASHBOARD_TOKEN is sent when set.

Install / uninstall

Nothing is installed automatically. Run:

agenthub statusline install            # adds statusLine to ~/.claude/settings.json
agenthub statusline install --force    # also replaces a statusLine that is not AgentHub's
agenthub statusline uninstall          # removes AgentHub's statusLine only
agenthub statusline uninstall --force  # removes whatever statusLine is there
  • The file is $CLAUDE_HOME/settings.json (default ~/.claude/settings.json); every other key is kept.
  • A statusLine that is not AgentHub's is refused (exit 1) unless --force.
  • Before any write the old file is copied beside itself as settings.json.agenthub-backup-<timestamp>.
  • A plugin install registers "~/.local/bin/agenthub" statusline (absolute path) — the launcher the bootstrap repoints at every update, because the plugin cache directory is replaced on update. A checkout registers node "<checkout>/statusline/statusline.js".

agenthub statusline with no subcommand renders the line from stdin, which is what the plugin-install registration runs.

Tests

server/__tests__/statusline.test.js: the formatter, today's cost against a fake dashboard (cache, cached failure, timeout), the script end to end on stdin, and install/uninstall against a temp HOME.