#!/usr/bin/env bash
# Read Claude Code's statusline JSON on stdin. Print one line:
# model display name, git branch, session cost, context used_percentage.
# The branch is not a JSON field. This asks git, in this process's working directory.
set -euo pipefail

input=$(cat)
model=$(printf '%s' "$input" | jq -r '.model.display_name // "unknown"')
pct=$(printf '%s' "$input" | jq -r '.context_window.used_percentage // 0')
cost=$(printf '%s' "$input" | jq -r '.cost.total_cost_usd // 0')
branch=$(git branch --show-current 2>/dev/null || true)
if [ -z "$branch" ]; then
  branch="no-branch"
fi

printf '%s | %s | $%s | context %s%%\n' "$model" "$branch" "$cost" "$pct"
