feat(pet): agent emojis + multi-agent display + plan emoji + language icons
Some checks are pending
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / preflight (push) Waiting to run
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / vps-smoke (push) Waiting to run
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:frustration-matrix,kei-frustration-loop,kei-skill-importer,kei-projects-index,kei-projects-watcher,kei-gdrive-import,kei-leak-matrix,kei-skills,kei-gateway,kei-cron-scheduler,kei-export-trajectories,kei-backend-daytona,kei-d… (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-compute-baremetal,kei-compute-vultr,kei-compute-linode,kei-compute-digitalocean,kei-svc-systemd,kei-llm-bridge-mlx name:hosted-sleep-compute]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-diff,kei-scheduler,kei-watch,kei-prune,kei-discover,kei-brain-view,kei-hibernate,kei-ledger-sign,kei-fork name:wave13-15]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-git-gitea,kei-git-forgejo,kei-git-gitlab,kei-git-bitbucket,kei-memory-sled,kei-memory-redis,kei-memory-postgres,kei-memory-sqlite,kei-auth-google,kei-auth-apple,kei-auth-magiclink,kei-auth-webauthn,kei-notify-slack,kei-n… (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-ledger,kei-migrate,kei-changelog,kei-memory,kei-store,kei-conflict-scan,kei-refactor-engine,kei-graph-check,kei-shared,kei-dna-index,kei-pet name:core]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-machine-probe,kei-llm-ollama,kei-llm-llamacpp,kei-llm-mlx,kei-llm-router,kei-model name:llm-stack]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:kei-router,kei-sage,kei-task,kei-chat-store,kei-crossdomain,kei-search-core,kei-content-store,kei-social-store,kei-curator,kei-auth,kei-artifact name:mcp-lbm]) (push) Blocked by required conditions
CI (Forgejo Actions — self-hosted runner on Mac, host mode) / rust-primitives (map[crates:keisei,kei-forge,kei-runtime,kei-runtime-core,kei-atom-discovery,kei-agent-runtime,kei-capability,kei-provision,kei-entity-store,kei-pipe,kei-cache,kei-spawn,kei-replay name:atom-substrate]) (push) Blocked by required conditions

This commit is contained in:
denis 2026-05-21 12:20:45 +00:00
parent cb694cc96a
commit e129745319

View file

@ -1,67 +1,93 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# KeiSei tamagotchi — statusline renderer. # KeiSei tamagotchi — statusline renderer. Outputs ONE line.
# Called by Claude Code on every prompt render. Outputs ONE line. # Shows: running sub-agents (emoji·name·elapsed) + agent token spend +
# Reads state from ~/.claude/pet/state (written by keisei-pet-update.sh). # plan state + mood face + message + counters + current language + project.
# State written by keisei-pet-update.sh under ~/.claude/pet/.
set -u set -u
# Discard any stdin (Claude Code may pipe session JSON to statusLine) # Discard any stdin (Claude Code pipes session JSON to statusLine).
if [ ! -t 0 ]; then if [ ! -t 0 ]; then cat >/dev/null 2>&1 || true; fi
cat >/dev/null 2>&1 || true
fi
STATE="${HOME}/.claude/pet/state" STATE_DIR="${HOME}/.claude/pet"
STATE="${STATE_DIR}/state"
# Defaults (if state file missing/stale) AGENTS_DIR="${STATE_DIR}/agents"
mood="neutral" TOKENS_FILE="${STATE_DIR}/agent_tokens"
message=""
since=$(date +%s)
rust_today=0
patents_today=0
violations=0
mood="neutral"; message=""; since=$(date +%s)
rust_today=0; patents_today=0; violations=0; lang=""; plan=""
# shellcheck source=/dev/null # shellcheck source=/dev/null
[ -f "$STATE" ] && source "$STATE" 2>/dev/null || true [ -f "$STATE" ] && source "$STATE" 2>/dev/null || true
now=$(date +%s) now=$(date +%s)
idle=$((now - since))
# Idle >5 min → pet sleeps (unless it's angry/alert about something) dim=$'\033[2m'; reset=$'\033[0m'
if [ "$idle" -gt 300 ] && [ "$mood" != "angry" ] && [ "$mood" != "alert" ]; then
mood="sleep" # ── elapsed pretty-printer (s / m / h) ──────────────────────────────────────
message="zzz" _elapsed() {
local s=$1
if [ "$s" -lt 60 ] ; then printf '%ds' "$s"
elif [ "$s" -lt 3600 ] ; then printf '%dm' $(( s / 60 ))
else printf '%dh%dm' $(( s / 3600 )) $(( (s % 3600) / 60 ))
fi
}
# ── running sub-agents (self-clean stale > 1h) ──────────────────────────────
agents=""
if [ -d "$AGENTS_DIR" ]; then
for f in "$AGENTS_DIR"/*; do
[ -f "$f" ] || continue
IFS='|' read -r em name start < "$f"
[ -z "${start:-}" ] && { rm -f "$f" 2>/dev/null; continue; }
age=$(( now - start ))
if [ "$age" -gt 3600 ]; then rm -f "$f" 2>/dev/null; continue; fi
agents+=" ${em}${name}·$(_elapsed "$age")"
done
fi fi
# Face + color by mood # ── agent token spend this session ──────────────────────────────────────────
toks=""
if [ -f "$TOKENS_FILE" ]; then
t=$(cat "$TOKENS_FILE" 2>/dev/null || echo 0)
if [ "${t:-0}" -gt 0 ] 2>/dev/null; then
if [ "$t" -ge 1000000 ]; then toks=" 🪙$(( t / 1000000 ))M"
elif [ "$t" -ge 1000 ] ; then toks=" 🪙$(( t / 1000 ))k"
else toks=" 🪙${t}"
fi
fi
fi
# ── mood face + color ───────────────────────────────────────────────────────
idle=$(( now - since ))
if [ "$idle" -gt 300 ] && [ "$mood" != "angry" ] && [ "$mood" != "alert" ] && [ -z "${agents// }" ]; then
mood="sleep"; message="zzz"
fi
case "$mood" in case "$mood" in
happy) face="(ᵔᴥᵔ)"; color=$'\033[32m' ;; # green happy) face="(ᵔᴥᵔ)"; color=$'\033[32m' ;;
proud) face="(•̀ᴗ•́)و"; color=$'\033[1;32m';; # bright green proud) face="(•̀ᴗ•́)و"; color=$'\033[1;32m';;
thinking) face="(⊙.⊙)"; color=$'\033[36m' ;; # cyan thinking) face="(⊙.⊙)"; color=$'\033[36m' ;;
alert) face="(ʘᴗʘ)"; color=$'\033[33m' ;; # yellow alert) face="(ʘᴗʘ)"; color=$'\033[33m' ;;
angry) face="(ò_ó)"; color=$'\033[31m' ;; # red angry) face="(ò_ó)"; color=$'\033[31m' ;;
sad) face="(╥﹏╥)"; color=$'\033[34m' ;; # blue sad) face="(╥﹏╥)"; color=$'\033[34m' ;;
sleep) face="(-.-)"; color=$'\033[2;37m';; # dim gray sleep) face="(-.-)"; color=$'\033[2;37m';;
*) face="(•ᴗ•)"; color=$'\033[37m' ;; # white (neutral) *) face="(•ᴗ•)"; color=$'\033[37m' ;;
esac esac
dim=$'\033[2m' # ── counters ────────────────────────────────────────────────────────────────
reset=$'\033[0m'
# stats line (compact)
stats="" stats=""
[ "$rust_today" -gt 0 ] && stats+=" 🦀${rust_today}" [ "${rust_today:-0}" -gt 0 ] 2>/dev/null && stats+=" 🦀${rust_today}"
[ "$patents_today" -gt 0 ] && stats+=" 📜${patents_today}" [ "${patents_today:-0}" -gt 0 ] 2>/dev/null && stats+=" 📜${patents_today}"
[ "$violations" -gt 0 ] && stats+="${violations}" [ "${violations:-0}" -gt 0 ] 2>/dev/null && stats+="${violations}"
# Project name from PWD proj="${PWD##*/}"; [ -z "$proj" ] && proj="~"
proj="${PWD##*/}"
[ -z "$proj" ] && proj="~"
# Render: face | message | stats | project # ── render ONE line: [agents][tokens] [plan] face msg stats [lang] 📁proj ────
# Keep it ≤ one line out=""
printf "%s%s%s %s%s%s%s%s %s%s%s" \ [ -n "${agents// }" ] && out+="${agents# }${toks} "
"$color" "$face" "$reset" \ [ -n "$plan" ] && out+="${plan} "
"$dim" "$message" "$reset" \ out+="${color}${face}${reset}"
"$stats" \ [ -n "$message" ] && out+=" ${dim}${message}${reset}"
"" \ out+="${stats}"
"$dim" "📁 $proj" "$reset" [ -n "$lang" ] && out+=" ${lang}"
out+=" ${dim}📁 ${proj}${reset}"
printf '%s' "$out"