Commit Graph

16 Commits

Author SHA1 Message Date
teernisse
9cbfa06c58 fix: remove jj status check as it was causing divergences for other agents 2026-02-12 12:25:20 -05:00
Taylor Eernisse
90454efe9f fix: install.sh respects CARGO_TARGET_DIR via cargo metadata
The installer hardcoded target/ as the build output directory, but
CARGO_TARGET_DIR (or [build] target-dir in cargo config) can redirect
output anywhere (e.g., /tmp/cargo-target). Now uses cargo metadata
--format-version 1 to get the actual target_directory, falling back
to $SCRIPT_DIR/target if metadata fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 08:45:21 -05:00
Taylor Eernisse
f35d665c19 fix: install.sh adds smoke test, settings verification, and error recovery
The script now: runs the binary with --test after install to verify it
actually works, prints the statusLine JSON that was written to settings,
handles corrupt/invalid settings.json by backing up and writing fresh,
and emphasizes that Claude Code must be restarted to pick up the change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:54:09 -05:00
Taylor Eernisse
f94a3170b1 fix: install.sh finds binary under custom target triples
Nightly toolchains with CARGO_BUILD_TARGET set (or .cargo/config.toml
[build] target) put the binary in target/<triple>/release/ instead of
target/release/. The installer now falls back to a find search across
all target subdirectories when the standard path doesn't exist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:51:36 -05:00
Taylor Eernisse
23d4d59c71 fix: install.sh shows build errors instead of failing silently
cargo build --quiet swallowed compiler errors, and the subshell (...)
didn't reliably propagate exit codes across bash versions. The script
continued past a failed build, then ls/cp failed on the missing binary.

Now: removed --quiet so errors are visible, explicit exit-code check
with common-cause hints (build-essential, libc6-dev), and a secondary
check that the binary actually exists before attempting to install it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:49:45 -05:00
Taylor Eernisse
e5b18b17ff chore: remove completed PRD and superseded bash implementation
rust_prd.md (3,091 lines):
  The Rust port PRD has been fully implemented — all beads closed,
  all features delivered across 7 prior commits. Keeping the PRD
  in-repo adds confusion about what's aspirational vs actual.

statusline.sh (2,245 lines):
  The original bash implementation is fully superseded by the Rust
  binary (claude-statusline). The bash script had fundamental
  limitations: ~200ms render time, no caching, no gradient support,
  no per-tool breakdown, and fragile process-tree width detection.
  The Rust binary renders in <5ms with full feature parity and then
  some. install.sh now targets the Rust binary exclusively.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:43:12 -05:00
Taylor Eernisse
8853afffa1 feat: update defaults, schema, and installer for new capabilities
Configuration and deployment updates to match the new feature set.

defaults.json:
  - Dark theme palette switched from named ANSI to Dracula-inspired hex:
    success=#50fa7b, warning=#f1fa8c, danger=#ff5555, accent=#8be9fd,
    info=#bd93f9. Light theme unchanged (named ANSI with bold).
  - Glyph characters normalized to Unicode escapes (clean/ahead/behind).
  - Verbose layout (3 lines) reorganized:
    Line 1: model, provider, spacer, lines_changed, project, vcs, beads
    Line 2: context_bar, context_usage, cache_efficiency, spacer, cost,
             cost_velocity, cost_trend, duration
    Line 3: context_trend, tokens_raw, spacer, tools, turns, load,
             cloud_profile, k8s_context, python_env, toolchain
  - context_usage, cost_trend, context_trend now enabled by default.
  - Trend widths increased from 8 to 12 characters.
  - Context bar: bar_style=block, gradient=true.
  - Tools: show_breakdown=true, top_n=7.
  - New sections enabled: cloud_profile (P2), k8s_context (P3, ttl=30),
    python_env (P3), toolchain (P3).

schema.json:
  - Added $schema self-reference field for editor autocomplete.
  - Expanded colorName from fixed enum to freeform string with docs
    covering hex, bg:, modifiers, and palette refs.
  - New section schemas: trendSection, contextTrendSection with width,
    gradient, and threshold properties.
  - context_bar: added bar_style, gradient, fill_char, empty_char.
  - tools: added show_breakdown, top_n, palette array.
  - All section types: added background and placeholder properties.
  - Width description updated to clarify it's a max cap + fallback,
    not an override.
  - colorMatch additionalProperties relaxed from enum to string.

install.sh:
  Complete rewrite for Rust binary workflow:
  - Checks cargo and jq prerequisites.
  - Builds release binary via cargo build --release.
  - Installs to ~/.local/bin/claude-statusline with PATH check.
  - Creates/updates ~/.claude/settings.json with statusLine command
    (type: "command", --color=always, padding: 0).
  - Symlinks statusline.json config if present in project.
  - Removed all bash-script-era logic (symlinks, bash version checks).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:42:58 -05:00
Taylor Eernisse
c03b0b1bd7 feat: add environment sections, visual enhancements, enhanced tools/beads, and /clear detection
The feature layer that builds on the new infrastructure modules. Adds
4 new environment-aware sections, rewrites the tools/beads/turns sections,
introduces gradient sparklines and block-style context bars, and wires
/clear detection into the main binary.

New sections (4):
  cloud_profile — Shows active cloud provider profile from env vars
    ($AWS_PROFILE, $CLOUDSDK_CORE_PROJECT, $AZURE_SUBSCRIPTION_ID).
    Provider-specific coloring (AWS orange, GCP blue, Azure blue).

  k8s_context — Parses kubeconfig for current-context and namespace.
    Minimal YAML scanning (no yaml dependency). 30s TTL cache.
    Shows "context/namespace" with split coloring.

  python_env — Detects active virtualenv ($VIRTUAL_ENV) or conda
    ($CONDA_DEFAULT_ENV, excluding "base"). Shows just the env name.

  toolchain — Detects Rust (rust-toolchain.toml) and Node.js (.nvmrc,
    .node-version) versions. Compares expected vs actual ($RUSTUP_TOOLCHAIN,
    $NODE_VERSION) and highlights mismatches in yellow.

Tools section rewrite:
  Progressive disclosure based on terminal width:
    - Narrow: just the count ("245")
    - Medium: count + last tool name ("245 tools (Bash)")
    - Wide: per-tool color-coded breakdown ("245 tools (Bash: 84/Read: 35/...)")
  Adaptive width budgeting: breakdown reduces tool count until it fits
  within 1/3 of terminal width. Color palette priority: config > terminal
  ANSI palette (via OSC 4) > built-in Dracula palette.

Beads section rewrite:
  Switched from `br ready --json` to `br stats --json` to show all
  statuses. Now renders multi-status breakdown: "3 ready 1 wip 2 open"
  with per-status visibility toggles in config.

Turns section:
  Falls back to transcript-derived turn count when cost.total_turns is
  absent. Requires at least one data source to render (vanishes when
  no session data exists at all).

Visual enhancements:
  trend.rs:
    - append_delta(): tracks rate-of-change (delta between cumulative
      samples) so sparklines show burn intensity, not monotonic growth
    - sparkline(): now renders exactly `width` chars with left-padding
      for missing data. Baseline (space) vs flatline (lowest bar) chars.
    - sparkline_colored(): per-character gradient coloring via colorgrad,
      returns (raw, ansi) tuple for layout compatibility.

  context_bar.rs:
    - Block style: Unicode full-block fill + light-shade empty chars
    - Per-character green->yellow->red gradient for block style
    - Classic style preserved (= and - chars) with single threshold color
    - Configurable fill_char/empty_char overrides

  context_trend + cost_trend:
    Switched to append_delta for rate-based sparklines. Gradient coloring
    with green->yellow->red via sparkline_colored().

  format.rs:
    Background color support via resolve_background(). Accepts named
    colors, hex, and palette refs. Applied as ANSI bg wrap around section
    output, preserving foreground colors.

  layout/mod.rs:
    - Separator styles: text (default), powerline (Nerd Font), arrow
      (Unicode), none (spaces). Powerline auto-falls-back to arrow when
      glyphs disabled.
    - Placeholder support: when an enabled section returns None (no data),
      substitutes a configurable placeholder character (default: box-draw)
      to maintain layout stability during justify/flex.

Section refinements:
  cost, cost_velocity, token_velocity, duration, tokens_raw — now show
  zero/baseline values instead of hiding entirely. This prevents layout
  jumps when sessions start or after /clear.

  context_usage — uses current_usage fields (input_tokens +
  cache_creation + cache_read) for precise token counts instead of
  percentage-derived estimates. Shows one decimal place on percentage.

  metrics.rs — prefers total_api_duration_ms over total_duration_ms for
  velocity calculations (active processing vs wall clock with idle time).
  Cache efficiency now divides by total input (not just cache tokens).

Config additions (config.rs):
  SeparatorStyle enum (text/powerline/arrow/none), BarStyle enum
  (classic/block), gradient toggle on trends + context_bar, background
  and placeholder on SectionBase, tools breakdown config (show_breakdown,
  top_n, palette), 4 new section structs.

Main binary (/clear detection + wiring):
  detect_clear() — watches for significant context usage drops (>15%
  to <5%, >20pp drop) to identify /clear. On detection: saves transcript
  offset so derived stats only count post-clear entries, flushes trend
  caches for fresh sparklines.

  resolve_transcript_stats() — cached transcript parsing with 5s TTL,
  respects clear offset, skipped when cost already has tool counts.

  resolve_terminal_palette() — cached palette detection with 1h TTL.

  Debug: CLAUDE_STATUSLINE_DEBUG env var dumps raw input JSON to
  /tmp/claude-statusline-input.json. dump-state now includes input data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:42:34 -05:00
Taylor Eernisse
e0c4a0fa9a feat: add colorgrad, transcript parser, terminal palette detection, and expanded color/input systems
Infrastructure layer for the TUI visual overhaul. Introduces foundational
modules and capabilities that the section-level features build on:

colorgrad (0.7) dependency:
  OKLab gradient interpolation for per-character color transitions in
  sparklines and context bars. Adds ~100K to binary (929K -> 1.0M).

color.rs expansion:
  - parse_hex(): #RRGGBB and #RGB -> (u8, u8, u8) conversion
  - fg_rgb()/bg_rgb(): 24-bit true-color ANSI escape generation
  - gradient_fg(): two-point interpolation via colorgrad
  - make_gradient()/sample_fg(): multi-stop gradient construction and sampling
  - resolve_color() now supports: hex (#FF6B35), bg:color, bg:#hex,
    italic, underline, strikethrough, and palette refs (p:success)
  - Named background constants (BG_RED through BG_WHITE)

transcript.rs (new module):
  Parses Claude Code transcript JSONL files to derive tool use counts,
  turn counts, and per-tool breakdowns. Claude Code doesn't include
  total_tool_uses or total_turns in its JSON — we compute them by scanning
  the transcript. Includes compact cache serialization format and
  skip_lines support for /clear offset handling.

terminal.rs (new module):
  Auto-detects the terminal's ANSI color palette for theme-aware tool
  coloring. Priority chain: WezTerm config > Kitty config > Alacritty
  config > OSC 4 escape sequence query. Parses Lua (WezTerm), key-value
  (Kitty), and TOML/YAML (Alacritty) config formats. OSC 4 queries
  use raw /dev/tty I/O with termios to avoid pipe interference. Includes
  cache serialization helpers for 1-hour TTL caching.

input.rs updates:
  - All structs now derive Serialize (for --dump-state diagnostics)
  - New fields: transcript_path, session_id, cwd, vim.mode, agent.name,
    exceeds_200k_tokens, cost.total_api_duration_ms
  - CurrentUsage: added input_tokens and output_tokens fields
  - #[serde(flatten)] extras on InputData and CostInfo for forward compat

cache.rs:
  Added flush_prefix() for /clear detection — removes all cache entries
  matching a key prefix (e.g., "trend_" to reset all sparkline history).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 23:41:50 -05:00
Taylor Eernisse
f46c3da69c fix: width detection prioritizes dynamic sources over config
Config `width` was position #3 in the detection chain, overriding all
dynamic detection (ioctl, process tree, stty, etc). This meant the
statusline couldn't adapt to terminal/pane resizes.

Now config `width` serves two roles:
- Max cap on dynamically detected widths (prevents absurd widths)
- Fallback when all dynamic detection methods fail

Also adds:
- ioctl on stderr (works when stdout is piped)
- stdin JSON `terminal_width` field for Claude Code to pass width
- Distinct diagnostic sources: config_cap, config_fallback, stdin_json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 16:18:51 -05:00
Taylor Eernisse
4e38b8259b fix: 6 bugs found during fresh-eyes code review
1. cache: record diagnostic miss before early-return on modified()/duration_since() failure
2. dump-state: resolve all cache_dir template vars ({cache_version}, {config_hash})
3. config: remove dead breakpoint_hysteresis field from GlobalConfig (breakpoints.hysteresis is used)
4. config: align Rust Default cache_dir with defaults.json template
5. vcs: apply branch truncation in render_stale_cache (--no-shell path)
6. vcs: fix jj prefetch retry on already-failed command (flatten→unwrap_or_else)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 16:11:02 -05:00
Taylor Eernisse
4c9139ec42 feat: implement remaining PRD features (10 beads)
Complete the PRD feature set with shell gating pipeline, cache
improvements, layout enhancements, and diagnostics:

- Shell: exec_gated with allowlist/denylist, circuit breaker, env merge
- Shell: parallel prefetch via std::thread::scope for cold renders
- Cache: TTL jitter (FNV-1a), config hash namespace, garbage collection
- Cache: diagnostic tracking (hit/miss, age) for dump-state
- Layout: gradual drop strategy (one-by-one vs tiered)
- Layout: render budget timer with graceful priority-based degradation
- Layout: breakpoint hysteresis to prevent preset toggling
- Width: detection source tracking for diagnostics
- CLI: --no-cache, --no-shell, --clear-cache, env var overrides
- Diagnostics: enhanced --dump-state with section timing and cache stats

Closes: bd-3oy, bd-62g, bd-khk, bd-3q1, bd-ywx, bd-3l2,
        bd-2vm, bd-1if, bd-2qr, bd-30o, bd-3ax, bd-3uw, bd-4b1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:59:15 -05:00
Taylor Eernisse
73401beb47 chore: enrich 6 beads with agent-ready descriptions
Revised bd-3uw, bd-ywx, bd-62g, bd-4b1, bd-1if, bd-3ax from
score 3/5 to 4+/5 with concrete approach steps, code snippets,
TDD loops, and edge cases sourced from rust_prd.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 15:25:03 -05:00
Taylor Eernisse
50bc2d989e fix: 3 bugs from peer code review
- justify: gate DIM/RESET separator coloring on color_enabled param;
  previously leaked ANSI escapes when --color=never or NO_COLOR was set
- vcs: apply branch name truncation per config (truncate.enabled,
  truncate.max, truncate.style) for both git and jj renderers;
  previously ignored truncate config causing long branch names to
  overflow and trigger unnecessary priority drops
- flex: account for prefix/suffix overhead when computing context_bar
  flex expansion width; previously double-applied apply_formatting
  causing line to overshoot term_width when prefix/suffix configured

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 14:52:23 -05:00
Taylor Eernisse
9c24617642 fix: 4 bugs found during code review against PRD
- output_style: use MAGENTA color per PRD (was incorrectly DIM)
- vcs: pass project dir to jj exec (was None, causing wrong cwd)
- tools: singular "tool" when count is 1 (was always "tools")
- layout: wire up apply_formatting() in render pipeline (prefix,
  suffix, color override, pad, align were completely dead code)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 14:28:50 -05:00
Taylor Eernisse
b55d1aefd1 feat: complete Rust port of claude-statusline
Port the entire 2236-line bash statusline script to Rust.
Implements all 25 sections, 3-phase layout engine (render, priority
drop, flex/justify), file-based caching with flock, 9-level terminal
width detection, trend sparklines, and deep-merge JSON config.

Release binary: 864K with LTO. Render time: <1ms warm.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 14:21:57 -05:00