Expand description
linesmith: Rust status line for Claude Code and other AI coding CLIs.
run reads a JSON payload from a Read, renders a status line, and
writes the result to a Write. The binary in main.rs wires this to
stdin/stdout. See docs/specs/ for the segment, theme, config, and
plugin contracts.
Modules§
- cli
- Command-line argument parsing via
lexopt. Full flag surface and rationale live indocs/specs/config.md. - config
- User config: parse
config.toml, resolve its path, and apply per-segment overrides. Full contract indocs/specs/config.md. - data_
context - Shared data-access context threaded through every segment’s
rendercall. - input
StatusContextmodels the parsed Claude Code statusline JSON. Rate-limit windows, cost, vim state, effort, output-style, and agent fields are added as segments start consuming them; seedocs/specs/input-schema.mdfor the full contract.- layout
- Layout engine. Takes a list of
Segments plus aStatusContextand fits their renders into a terminal-width budget, dropping the highest-priority (numerically largest) segments first. Priority-0 segments are never dropped, even when that overflows the budget. - logging
- In-crate structured-logging facade.
- plugins
- Rhai plugin runtime for user-authored segments.
- presets
- Embedded
config.tomlpresets perdocs/specs/config.md§Presets. - segments
- Segment trait and layout-intent types. Full contract lives in
docs/specs/segment-system.md; this module carries the subset the layout engine uses today: visibility, cell width, priority, separator preference, and theme role. - theme
- Role-based theme system. Segments declare semantic roles; themes map
roles to colors; the render path emits ANSI SGR around each segment
based on the terminal’s detected capability. Full contract in
docs/specs/theming.md.
Macros§
- lsm_
debug - Emit a debug-level diagnostic. Gated behind
LINESMITH_LOG=debug; theformat!call is skipped when suppressed. - lsm_
error - Emit a structural-failure diagnostic that bypasses the level gate.
Reserved for failures a user has no other way of seeing — segment
render errors, fatal plugin init, contract violations — so a user
who set
LINESMITH_LOG=offstill sees “the statusline broke.” - lsm_
warn - Emit a warning-level diagnostic. Fires at [
DEFAULT_LEVEL] and up.
Structs§
- CliEnv
- Process-ambient inputs the CLI reads: env vars consulted by
resolve_config_path, the color-policy env flags, an optional terminal-width override, and an optional color-capability override. Passed throughcli_mainso tests can drive the whole binary without touching the real process env.#[non_exhaustive]leaves room for future env vars (TERM, …) without breaking external construction. - Render
Context - Theme + capability + terminal width + cwd bundled for the render
path. Passed to
run_with_context; the CLI driver builds one from config (theme name), the color-policy precedence chain (CLI flags / env / config),CliEnv.terminal_widthminus any padding, and the process cwd.
Functions§
- build_
default_ segments - Build the default segment list: every built-in in canonical order, no overrides applied.
- build_
segments - Build a segment list from an optional
Config.Noneor a config without a[line]section uses the default order.warnreceives a one-line diagnostic for each validation rule triggered (pass|_| {}to discard). - cli_
main - CLI entry point. Returns a
u8exit code so callers convert toExitCodeonly at the outermost layer. - detect_
terminal_ width - Resolve the terminal width in cells. Prefers the OS-reported size, then
the
COLUMNSenv var, thenDEFAULT_TERMINAL_WIDTH. A set-but-invalidCOLUMNSvalue routes throughlsm_warn!so the user can correct their config; an unsetCOLUMNSfalls through silently (the common case when stdout is piped to Claude Code). - run
- Read a JSON payload from
reader, render a status line, and write it towriter. Parse failures render a?marker towriterand log detail to stderr; only I/O failures surface as errors. - run_
with_ context - Full-control entry with injected stderr and explicit render
context. Parse failures render a
?marker towriter; only stdin/stdout I/O failures surface as errors. - run_
with_ segments_ and_ width - Full-control entry: pre-built segment list plus explicit width.
Parse failures render a
?marker and log to the real process stderr; output is unstyled. For themed output or injected-stderr testability (used bycli_main), callrun_with_contextinstead. - run_
with_ width - Same as
runbut with an explicit terminal width. Exposed so callers with their own width source (tests, a TUI wrapper) can bypassdetect_terminal_width.