title: src/layout/justify.rs: Spread/space-between gap distribution

description: Distribute extra space evenly across gaps. Center separator core within each gap. Remainder chars distributed left-to-right.

status: closed

issue_type: task

created_by: tayloreernisse

close_reason: Justify: space-between gap distribution with centered separator core

type: blocks


title: src/lib.rs: Module declarations and public API

description: Declare all pub mod: error, config, input, theme, color, glyph, width, cache, trend, format, shell, metrics, section, layout. Re-export key types.

close_reason: Fully implemented during scaffold: all pub mod declarations, Error re-export


title: Project scaffold: Cargo.toml, build.rs, src/ structure

description: Create Cargo.toml with all deps per PRD. Create build.rs for defaults.json/schema.json rerun-if-changed. Create src/ directory structure with empty module files. Verify cargo check passes.

close_reason: Scaffold complete: Cargo.toml, build.rs, all modules, CLI, stubs compile clean


title: src/format.rs: display_width, human_tokens, human_duration, truncation, apply_formatting

description: display_width via unicode-width. human_tokens (k/M). human_duration (s/m/h). Grapheme-safe truncation (right/middle/left). apply_formatting: prefix/suffix, color override, pad+align.

close_reason: Fully implemented during scaffold: display_width, human_tokens, human_duration, truncate, apply_formatting


title: src/layout/priority.rs: Priority drop algorithm

description: Drop tier 3 all at once, then tier 2 if still overflowing. Priority 1 never drops. line_width calculation with separator suppression at spacers.

close_reason: Priority drop: tier 3 all-at-once, then tier 2, P1 never drops


title: src/trend.rs: Append-only trend files + sparkline

description: Append with write throttle (5s). Skip if unchanged. Max N points, trim from left. Sparkline: 8 Unicode block chars, normalized min/max. Flat-series guard (mid-height).

close_reason: Full trend: append with throttle + sparkline with flat-series guard


title: src/section/mod.rs: SectionOutput, RenderContext, registry, dispatch

description: SectionOutput{raw,ansi}. RenderFn type alias. RenderContext struct with all fields. Registry of (id, render_fn). render_section dispatch. is_spacer check.

close_reason: Fully implemented during scaffold: registry, dispatch, RenderContext, SectionOutput, VcsType


title: src/input.rs: InputData struct (serde from stdin JSON)

description: InputData, ModelInfo, CostInfo, ContextWindow, CurrentUsage, Workspace, OutputStyle. All fields Option with serde(default). Matches stdin JSON shape from Claude Code.

close_reason: Fully implemented during scaffold: all InputData structs with serde


title: src/color.rs: ANSI constants, resolve_color, should_use_color

description: 10 ANSI const strings. resolve_color with palette refs (p:key), compound styles (red bold), single names. should_use_color: NO_COLOR, cli flag, config, atty check.

close_reason: Fully implemented during scaffold: ANSI consts, resolve_color, should_use_color, atty


title: src/glyph.rs: Nerd Font + ASCII fallback

description: glyph() function: lookup named glyph, return Nerd Font icon when enabled, ASCII fallback otherwise.

close_reason: Fully implemented during scaffold: glyph function with Nerd Font lookup + ASCII fallback


title: src/error.rs: Error enum with From impls

description: Error enum: Io, Json, ConfigNotFound, EmptyStdin. Display impl, std::error::Error impl, From<io::Error> and From<serde_json::Error>.

close_reason: Fully implemented during scaffold: Error enum, Display, From impls


title: 17 pure sections (no shell-out)

description: Implement all pure sections: model, provider, project, context_bar, context_usage, context_remaining, tokens_raw, cache_efficiency, cost, cost_velocity, token_velocity, lines_changed, duration, tools, turns, version, output_style. Each returns Option<SectionOutput>.

close_reason: All 17 pure sections implemented: model, provider, project, context_bar, context_usage, context_remaining, tokens_raw, cache_efficiency, cost, cost_velocity, token_velocity, lines_changed, duration, tools, turns, version, output_style


title: Shell-out sections: vcs, beads, load, hostname, time, custom

description: Port remaining 7 shell-out sections. Combined git status, jj support, beads br status, sysctl/proc load, hostname, date, custom command exec. All use cache + stale fallback.

close_reason: All 8 shell-out sections implemented: vcs, beads, load, hostname, time, custom, cost_trend, context_trend. Compiles clean, clippy clean, --test output verified.


title: src/shell.rs: exec_with_timeout, GIT_ENV, parse_git_status_v2

description: Polling try_wait with 5ms sleep. GIT_ENV constants. Combined git status --porcelain=v2 --branch parsing. Circuit breaker tracking.

close_reason: Fully implemented during scaffold: exec_with_timeout, parse_git_status_v2


title: src/bin/claude-statusline.rs: CLI entry point with --test and --help

description: Manual CLI flag parsing (no clap). Stdin read, config load, theme detect, render, stdout. Support --help, --test, --config-schema, --print-defaults, --list-sections, --validate-config, --dump-state, --config, --width, --color, --no-cache, --no-shell, --clear-cache.

close_reason: CLI fully implemented during scaffold, all dependencies now closed


title: src/layout/flex.rs: Flex expansion with context_bar rebuild

description: Spacer wins over non-spacer flex. Only one flex winner per line. Spacer=spaces, context_bar=rebuild at wider width, other=trailing pad. Re-apply apply_formatting after context_bar rebuild.

close_reason: Flex expansion: spacer wins, context_bar rebuilds with wider bar, others pad


title: src/config.rs: Config structs, deep merge, load_config

description: Full typed Config struct hierarchy with SectionBase flatten pattern. Deep merge via recursive serde_json::Value. Config loading: embedded defaults + user overrides from XDG/dot-config/legacy paths. Unknown key warnings via serde_ignored. All section configs per PRD.

close_reason: Fully implemented during scaffold: config hierarchy, deep merge, load_config, unknown key warnings


title: src/metrics.rs: ComputedMetrics from InputData

description: Compute derived metrics once: cost_velocity, token_velocity, usage_pct, total_tokens, cache_efficiency_pct. Reused by all sections via RenderContext.metrics.

close_reason: Fully implemented during scaffold: ComputedMetrics with from_input computing all derived values


title: src/layout/mod.rs: resolve_layout, render_line, render_all

description: Three-phase pipeline: Plan > Render survivors > Reflow. resolve_layout (preset lookup, responsive override). render_line per layout line. render_all joins with newlines.

close_reason: Full 3-phase layout pipeline: ActiveSection, render_line with priority/flex/justify, assemble_left, section_meta


title: src/width.rs: Terminal width detection chain with memoization

description: Full priority chain: cli > env > config > ioctl > process tree walk > stty > COLUMNS > tput > 120. 1s in-memory memoization via Mutex<Option<(u16, Instant)>>. WidthTier enum.

close_reason: Full 9-level width detection chain with 1s memoization: cli > env > config > ioctl > process tree > stty > COLUMNS > tput > 120


title: Phase 1 verification: --test produces correct output for all pure sections

description: Create test_data.json with realistic mock data. Verify --test renders all 17 pure sections correctly. Snapshot test.

close_reason: Phase 1 verification complete. --test produces 3-line verbose output with all pure and shell-out sections rendering correctly. Release build 864K, clippy/fmt/test all clean.

issue_id: bd-ape


title: src/cache.rs: Secure dir, per-key TTL, flock, atomic writes

description: Cache struct with secure dir creation (chmod 700, ownership verify, symlink check). Per-key TTL via mtime. Atomic write-rename. Non-blocking flock. Stale fallback. Session ID from MD5 of project_dir.

close_reason: Full cache: secure dir, ownership check, per-key TTL, flock, atomic writes


title: src/theme.rs: COLORFGBG detection

description: Theme enum (Dark/Light). Detection: config override > COLORFGBG env var > default dark.

close_reason: Fully implemented during scaffold: Theme enum, COLORFGBG detection

issue_id: bd-wdi