Skip to main content

Crate context_bar_core

Crate context_bar_core 

Source
Expand description

context-bar-core — the cross-platform engine.

Everything reusable across the surfaces lives here: transcript reading, the cost/token model, session/window bucketing, the agent-context assembler, and the HUD/HTML renderers. The crate is platform-free at the type/parse/assemble layer; the host-coupled bits (process spawning, the macOS keychain, the on-disk snapshot cache, and the wasm32 Worktree collectors) sit behind cfg(target_arch) gates inside their modules.

Consumers:

The seam that keeps the engine decoupled from any host is context_engine::assemble, which takes pre-collected signals.

Modules§

agent_context
Combined, agent-readable brief.
aggregate
Deterministic transforms — slice 2 of folding usage_signal.py into Rust (ROADMAP E1). Ported 1:1 from empty_metrics/_add_metrics, split_logical_sessions, _empty_bucket/_accumulate, bucket_aggregates, and project_name_from_cwd. Pure given (events, NOW, UTC offset) — pinned by a golden fixture generated from the Python (tests/aggregate_golden.rs).
claude_statusline
collect
Pure-Rust transcript collection — slice 3 of folding usage_signal.py into Rust (ROADMAP E1). Ports collect_claude / collect_codex (JSONL discovery, per-turn token extraction, rolling windows, last-turn + active-session fields, context-window heuristic) and build_active_sessions / claude_context_window, reusing the golden-pinned pricing + aggregate kernels.
context_engine
detail_html
Detail page renderer.
git_signal
hud
HUD rendering.
i18n
Bilingual (EN/TR) text selection, shared by every Rust surface.
live
5h-block burn status — the engine half of the live dashboard (ROADMAP B2) and the native popover gauge (C1). Pure: derives burn rate, % of limit, ETA-to-limit, and a projected block total from a snapshot + a clock.
online
Online / host enrichments — the final slice-4 piece of the Python→Rust port. Ports the statusline-snapshot overlay, the Anthropic usage API (account 5h/7d %), Codex transcript rate-limits, and cross-platform credential discovery (~/.claude/.credentials.json; macOS keychain). All best-effort: each degrades to a no-op offline / without credentials, exactly like the Python. Native-only (HTTP + subprocess + filesystem).
others
Other-AI-tool probes — part of slice 4 of the Python→Rust port (ROADMAP E1). Ports probe_gemini_cli, probe_aider, probe_shell_history, and collect_others from usage_signal.py. Native-only (reads ~/.gemini, ~/.aider, ~/.zsh_history). The llm CLI sqlite probe is intentionally omitted (would pull a sqlite dependency for a niche tool) — documented gap.
pricing
Cost kernel — the API-equivalent pricing math, ported 1:1 from usage_signal.py (the FALLBACK_PRICING table, model matcher, _tiered, turn_cost, turn_cache_savings). This is the first slice of folding the Python aggregator into Rust (ROADMAP E1). It is PURE — no I/O, no clock — so it is pinned by a golden fixture generated from the Python (tests/), guaranteeing byte-for-byte cost parity (see docs/ai/COST_MODEL.md).
report
Tabular usage/cost reports built from a UsageSnapshot.
state_writer
time_windows
usage_signal
Cross-project agent usage signals.