claude: re-sync CLAUDE.md and statusline-command.sh from live and restore the symlinks
Both files had been replaced in ~/.claude by detached real files (CLAUDE.md around 2026-09-18, statusline-command.sh by 2026-09-16), so the repo copies had gone stale while every session loaded the live ones. The live versions are canonical and are now committed here, and ~/.claude links back into the repo. CLAUDE.md changes that ride along with the re-sync: - Operator identity: alias Prime, callsign Papa Romeo Mike. Legal, license and git attribution stay Vuong Hoang. - Miranda: the notification route to Prime (althing handle miranda), limited to high-priority matters, plus sender conventions. Route verified 2026-09-24. - Header warning: the file is a symlink into this repo. Never edit it with sed -i or any temp-then-rename tool, which detaches the link.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Claude Code statusline. Layout:
|
||||
# [📬N] [🔔/🔕] | <proj> ⎇<branch> *<dirty> ↑<unpushed> | <model> | ctx:<pct> <toks> | $<session-cost> | 5h:% 7d:%
|
||||
# [📬N] [🔔/🔕/📵] | <proj> ⎇<branch> *<dirty> ↑<unpushed> | <model> | ctx:<pct> <toks> | $<session-cost> | 5h:% 7d:%
|
||||
#
|
||||
# 🔔 reachable — the post office will push to this session
|
||||
# 🔕 pull-only — nothing will poke it; mail waits until it looks
|
||||
# 📵 the post office could not be asked — an OUTAGE, not an empty inbox
|
||||
# ctx% and rate-limit %s are threshold-colored: green <60, yellow 60-90, red >90.
|
||||
# All segments degrade gracefully (missing tool / non-git dir / no handle => segment omitted).
|
||||
input=$(cat)
|
||||
@@ -54,6 +58,21 @@ IFS=$'\x1f' read -r model used_pct input_tok five_pct week_pct cwd fast cost_usd
|
||||
)
|
||||
[ -z "$model" ] && model="unknown"
|
||||
|
||||
# --- persist the rate-limit window for agents (added 2026-09-05, operator directive) ---
|
||||
# The percentages arrive here on stdin and nowhere else: no CLI subcommand exposes them and
|
||||
# nothing else on disk carries them, so an agent that must throttle on them cannot see them.
|
||||
# Written atomically (tmp + mv) so a reader never catches a half-written file. Empty fields
|
||||
# are preserved as null rather than 0 -- a session with no rate_limits must read as UNKNOWN,
|
||||
# never as "plenty left", which is the one way this file could cause the harm it prevents.
|
||||
{
|
||||
_rl_dir="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"; _rl_tmp="$_rl_dir/rate-limits.json.$$"
|
||||
printf '{"five_hour_pct":%s,"seven_day_pct":%s,"five_hour_resets_at":%s,"seven_day_resets_at":%s,"written_at":%s,"written_at_iso":"%s"}\n' \
|
||||
"${five_pct:-null}" "${week_pct:-null}" "${five_reset:-null}" "${week_reset:-null}" \
|
||||
"$(date +%s)" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > "$_rl_tmp" 2>/dev/null \
|
||||
&& mv -f "$_rl_tmp" "$_rl_dir/rate-limits.json" 2>/dev/null
|
||||
rm -f "$_rl_tmp" 2>/dev/null
|
||||
} || true
|
||||
|
||||
# --- model (compact) + fast-mode flag ---
|
||||
model="${model%% (*}" # "Opus 4.8 (1M context)" -> "Opus 4.8"
|
||||
[ "$fast" = "true" ] && model="⚡$model"
|
||||
@@ -103,30 +122,28 @@ if [ -n "$cwd" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- althing: unread count (📬 N) + monitor-armed (🔔 armed / 🔕 not) ---
|
||||
# --- althing: unread count (📬 N) + reachability (🔔 push / 🔕 pull / 📵 outage) ---
|
||||
# NOT implemented here any more. `althing-statusline` is the canonical segment,
|
||||
# shipped as a console script by the althing package (3.4.0+).
|
||||
#
|
||||
# This block used to be one of THREE hand-maintained copies of the same twelve
|
||||
# lines -- this file, althing's plugin/scripts/statusline.sh, and infra-ops'
|
||||
# copy in eshpfi-management. An audit on 2026-09-02 found DIFFERENT defects in
|
||||
# each and all three were fixed separately, by hand, on the same day. That is a
|
||||
# drift surface with a countdown on it, and it is the same failure that left
|
||||
# this very block dead for a month after the v3 cutover deleted the binary it
|
||||
# gated on. A script, unlike a document, has somewhere to be installed: PATH.
|
||||
#
|
||||
# The payload goes in on STDIN -- the segment resolves the handle from the cwd
|
||||
# it carries, and falls back to nothing rather than guessing.
|
||||
#
|
||||
# The outer `timeout` is deliberately LOOSER than the program's own 2s budget.
|
||||
# If the outer one fired first we would get an empty segment, which reads as
|
||||
# "not an althing directory" -- the outage conflation, reintroduced by the
|
||||
# guard meant to prevent a hang.
|
||||
althing=""; mon=""
|
||||
if command -v althing-cli >/dev/null 2>&1; then
|
||||
althing=$(althing-cli statusline 2>/dev/null </dev/null)
|
||||
# suppress the empty-inbox form (📪 0) — only surface actual unread mail (📬 N)
|
||||
case "$althing" in *📪*) althing="" ;; esac
|
||||
h="${ALTHING_HANDLE:-}"
|
||||
# ALTHING_HANDLE isn't set in the statusline env — resolve the per-project handle from
|
||||
# althing's session map (keyed by the cwd Claude Code passes on stdin), the same source
|
||||
# `althing-cli use` writes. Without this the monitor bell (🔔/🔕) never renders.
|
||||
[ -z "$h" ] && [ -n "$cwd" ] && h=$(jq -r --arg d "$cwd" '.[$d] // empty' "$HOME/.althing/session_handles.json" 2>/dev/null)
|
||||
if [ -n "$h" ]; then
|
||||
mon="🔕"
|
||||
# Three independent arming mechanisms, one lock each — any live one means "armed":
|
||||
# monitor-$h.lock <- `althing-cli monitor` (the CC-native exit-0-re-arm loop)
|
||||
# wake-listener-$h.lock <- `althing-wake-listener` (herald inbound)
|
||||
# light-monitor-$h.lock <- `althing-light-monitor` (standing watch)
|
||||
# The kill -0 liveness gate below discards stale locks, so listing all three is safe.
|
||||
for lk in "$HOME/.althing/monitor-$h.lock" "$HOME/.althing/wake-listener-$h.lock" "$HOME/.althing/light-monitor-$h.lock"; do
|
||||
[ -f "$lk" ] || continue
|
||||
pid=$(tr -dc '0-9' < "$lk" 2>/dev/null)
|
||||
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then mon="🔔"; break; fi
|
||||
done
|
||||
fi
|
||||
if command -v althing-statusline >/dev/null 2>&1; then
|
||||
althing=$(printf '%s' "$input" | timeout 5 althing-statusline 2>/dev/null)
|
||||
fi
|
||||
|
||||
# --- assemble ---
|
||||
|
||||
Reference in New Issue
Block a user