cloverleaf-larry/VERSION
Bryan Johnson c34b8900fb v0.6.9: persistent status line above the prompt
Adds a dim status line printed immediately above each `you[model]>` prompt
every turn, surfacing context-window usage + rate-limit visibility.

Two render modes auto-selected from $LARRY_AUTH_MODE:
  OAuth:    ─ ctx 12% (24K/1.0M) ─ 5h 1.8% reset 19:45 ─ 7d 73.7% reset Mon Jun 2 ─
  API key:  ─ ctx 12% (24K/200K) ─ $0.213 session ─ 14 turns ─

Implementation areas:
- call_api / call_api_stream now capture response headers via curl -D into
  tempfiles. Streaming path drains its header file in the parent shell after
  the SSE body completes (subshell-update problem avoided).
- New parser _parse_response_headers handles BOTH header families per Pax's
  research (Deliverables/2026-05-27-anthropic-rate-limit-headers-research.md):
    * API-key:  RFC 3339 datetimes → converted to epoch
    * OAuth:    Unix epoch integer-as-string → used as-is
  Both 5h and 7d buckets are displayed simultaneously; representative-claim
  is honored for enforcement but not for what to render (anti-pattern noted
  by Pax — Claude Code itself once shipped buggy logic that picked one).
- Static model-context-window lookup (Pax §4): opus-4-7 / sonnet-4-6 = 1M,
  haiku-4-5 and legacy 4-5/4-1 families = 200K, unknown defaults to 200K.
- Safety net: first 50 OAuth response header blocks are logged to
  $LARRY_HOME/log/headers.log so the empirical schema can be diff'd against
  Pax's spec on Bryan's actual account. Auto-disables after limit reached.
- New /status slash command force-renders the line on demand. New env knob
  LARRY_NO_STATUS=1 disables the status line entirely.
- parse_stream_to_response synthetic JSON now also carries
  cache_read_input_tokens + cache_creation_input_tokens so the parent shell
  can compute ctx_used = input + cache_creation + cache_read per Pax §5.

Fallback rules followed:
- First turn of a session: status line is NOT rendered (no zero-lies).
- Missing reset values: display "reset —" not a fabricated time.
- Reset already passed: display "— reset" (data stale).
- Narrow terminal (< 100 cols): drop the reset times, keep the percentages.

Verification (synthetic fixtures; no live OAuth session in this environment):
- 25 parser/renderer assertions pass (test-harness covering all 8 spec
  scenarios + model lookup + token humanization).
- SSE parser still produces a valid synthetic response JSON, now including
  cache fields (7 assertions pass).
- TOOLS_JSON heredoc still parses cleanly via jq.
- bash -n on larry.sh: clean.
- Pax's OAuth headers were NOT empirically observed against a live account
  in this environment — only validated against the documented schema via
  fixtures derived verbatim from Pax's research. The header-log safety net
  is in place to verify on Bryan's account on first use.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 16:02:13 -07:00

2 lines
6 B
Plaintext