#!/bin/bash
# TraxAgent status line for Claude Code: one-command install. Read it first: https://www.traxagent.io/statusline/install.sh
set -e
dir="$HOME/.claude"; script="$dir/traxagent-statusline.sh"; settings="$dir/settings.json"
mkdir -p "$dir"
if ! command -v jq >/dev/null 2>&1; then
  echo "TraxAgent status line needs jq. Install it (brew install jq, or apt install jq), then run this again."; exit 1
fi
curl -fsSL "https://www.traxagent.io/cc/statusline.sh" -o "$script.tmp" && mv "$script.tmp" "$script" && chmod +x "$script"
[ -s "$settings" ] || echo '{}' > "$settings"
cp "$settings" "$settings.bak-traxagent"
jq '.statusLine = {"type": "command", "command": "~/.claude/traxagent-statusline.sh", "refreshInterval": 60}' "$settings.bak-traxagent" > "$settings.tmp" \
  && mv "$settings.tmp" "$settings"
echo "Installed. Start a new Claude Code session to see it."
echo "Your old settings are saved in $settings.bak-traxagent. To remove: delete the statusLine entry from $settings."
echo "Nothing is sent anywhere unless you add a team token (TRAXAGENT_CC_TOKEN) from https://www.traxagent.io/statusline."
