Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
fix(contextbricks): v3.0.0 - Disable context tracking due to Anthropic API bug
Jeze9ad7aeffe57
diff --git a/tools/statusline-npm/README.md b/tools/statusline-npm/README.mdindex 572ac3a4..cee3dc7a 100644--- a/tools/statusline-npm/README.md+++ b/tools/statusline-npm/README.md@@ -1,26 +1,28 @@# π§± ContextBricks-**Real-time context tracking with brick visualization for Claude Code CLI**+**Git-aware statusline for Claude Code CLI**[](https://www.npmjs.com/package/contextbricks)[](https://opensource.org/licenses/MIT)-A custom status line for Claude Code that displays accurate token usage with a beautiful brick visualization, plus git integration and session metrics.+A custom status line for Claude Code with rich git integration and session metrics.-+> β οΈ **v3.0.0 Notice**: Context tracking is **temporarily disabled** due to [Anthropic API bug #13783](https://github.com/anthropics/claude-code/issues/13783). The `context_window` API provides cumulative session tokens that never reset after compaction, making context percentages meaningless. The code is preserved and will be re-enabled when Anthropic fixes the API.## β¨ Features-- π― **Native context_window support** (Claude Code 2.0.65+) - accurate token data-- π¦ **Compaction detection** (v2.1+) - shows real context usage after automatic compaction-- π **Backwards compatible** - falls back to transcript parsing for older versions-- π§± **Brick visualization** showing context usage at a glance- π§ **Git integration**: repo:branch [commit] message | github-repo *ββ- β±οΈ **Session duration**: track how long you've been working- π° **Session cost**: API users see spending (hidden for Max subscribers)-- π **Session metrics**: model name, lines changed, free space+- π **Session metrics**: model name, lines changed- β‘ **Zero config**: Auto-detects everything, just install and go+### Temporarily Disabled (pending Anthropic fix)++- ~~π§± **Brick visualization** showing context usage at a glance~~+- ~~π― **Native context_window support** - accurate token data~~+- ~~π¦ **Compaction detection** - shows real context usage after compaction~~+## π Quick Start```bashdiff --git a/tools/statusline-npm/package.json b/tools/statusline-npm/package.jsonindex 0659ecb3..c4cdf43c 100644--- a/tools/statusline-npm/package.json+++ b/tools/statusline-npm/package.json@@ -1,7 +1,7 @@{"name": "contextbricks",- "version": "2.1.0",- "description": "Real-time context tracking with brick visualization for Claude Code CLI",+ "version": "3.0.0",+ "description": "Git-aware statusline for Claude Code CLI (context tracking disabled pending Anthropic API fix)","keywords": ["claude","claude-code",diff --git a/tools/statusline-npm/scripts/statusline.sh b/tools/statusline-npm/scripts/statusline.shindex 6960958b..dca2427a 100755--- a/tools/statusline-npm/scripts/statusline.sh+++ b/tools/statusline-npm/scripts/statusline.sh@@ -1,9 +1,14 @@#!/bin/bash-# Claude Code Custom Status Line with Context Brick Visualization-# v2.0 - Uses native context_window data from Claude Code 2.0.65++# Claude Code Custom Status Line+# v3.0 - Context tracking DISABLED due to Anthropic API bug# Shows: Model | Repo:Branch [commit] message | GitHub | git status | lines changed-# Context usage as horizontal brick visualization+# Session duration and cost+#+# NOTE: Context brick visualization disabled because context_window API provides+# cumulative session tokens that never reset after compaction, making it useless.+# See: https://github.com/anthropics/claude-code/issues/13783+# Re-enable when Anthropic fixes the API.# Read JSON from stdininput=$(cat)@@ -92,87 +97,11 @@ if [[ "$lines_added" -gt 0 || "$lines_removed" -gt 0 ]]; thenline1+=" | \033[0;32m+$lines_added\033[0m/\033[0;31m-$lines_removed\033[0m"fi-# Build Line 2: Context Brick Visualization-# Try native context_window first (Claude Code 2.0.65+)-cumulative_input=$(echo "$input" | jq -r '.context_window.total_input_tokens // null')-cumulative_output=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')-total_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')--compacted=false--if [[ "$cumulative_input" != "null" && -n "$cumulative_input" && "$cumulative_input" != "0" ]]; then- cumulative_total=$((cumulative_input + cumulative_output))-- # Detect compaction: cumulative exceeds context limit- if [[ $cumulative_total -gt $total_tokens ]]; then- compacted=true-- # Get ACTUAL current context from last message's input_tokens- transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')-- if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then- # Get the last assistant message's input_tokens (actual context sent)- last_input=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \- tail -1 | \- jq -r '.message.usage.input_tokens // 0' 2>/dev/null)-- if [[ -n "$last_input" && "$last_input" =~ ^[0-9]+$ && "$last_input" -gt 0 ]]; then- # Add cache tokens for complete picture- cache_read=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \- tail -1 | \- jq -r '.message.usage.cache_read_input_tokens // 0' 2>/dev/null)- [[ ! "$cache_read" =~ ^[0-9]+$ ]] && cache_read=0-- used_tokens=$((last_input + cache_read))- else- # Fallback: cap at 90% if we can't determine actual usage- used_tokens=$(( (total_tokens * 90) / 100 ))- fi- else- used_tokens=$(( (total_tokens * 90) / 100 ))- fi- else- # Normal state: use cumulative (it's accurate when < limit)- used_tokens=$cumulative_total- fi-else- # Fallback for older Claude Code versions (no native data)- transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')-- if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then- last_usage=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \- tail -1 | \- jq -r '.message.usage // null' 2>/dev/null)-- if [[ -n "$last_usage" && "$last_usage" != "null" ]]; then- used_tokens=$(echo "$last_usage" | jq '- (.input_tokens // 0) +- (.cache_read_input_tokens // 0) +- (.cache_creation_input_tokens // 0) +- (.output_tokens // 0)- ')- else- used_tokens=0- fi-- [[ ! "$used_tokens" =~ ^[0-9]+$ ]] && used_tokens=0- else- used_tokens=0- fi-fi--# Calculate metrics-free_tokens=$((total_tokens - used_tokens))-if [[ $total_tokens -gt 0 ]]; then- usage_pct=$(( (used_tokens * 100) / total_tokens ))-else- usage_pct=0-fi--# Convert to 'k' format for display-used_k=$(( used_tokens / 1000 ))-total_k=$(( total_tokens / 1000 ))-free_k=$(( free_tokens / 1000 ))+# Build Line 2: Session info (duration + cost)+# NOTE: Context tracking disabled - Anthropic's context_window API provides cumulative+# session tokens that never reset after compaction, making it useless for tracking+# actual context usage. See: https://github.com/anthropics/claude-code/issues/13783+# Re-enable when Anthropic fixes the API to provide actual current context usage.# Get session duration (convert ms to HHh MMm format)duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')@@ -182,52 +111,164 @@ duration_min=$(((duration_ms % 3600000) / 60000))# Get session cost (only show if > 0, for API users)cost_usd=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')-# Generate brick visualization (40 bricks total)-total_bricks=40-used_bricks=$(( (used_tokens * total_bricks) / total_tokens ))-free_bricks=$((total_bricks - used_bricks))--# Build brick line with single colour (cyan for used, dim white for free)-brick_line="ctx ["--# Used bricks (cyan)-for ((i=0; i<used_bricks; i++)); do- brick_line+="\033[0;36mβ \033[0m"-done--# Free bricks (dim/gray hollow squares)-for ((i=0; i<free_bricks; i++)); do- brick_line+="\033[2;37mβ‘\033[0m"-done--brick_line+="]"--# Add compaction indicator if applicable-if [[ "$compacted" == "true" ]]; then- brick_line+=" \033[1;35mπ¦\033[0m"-fi--brick_line+=" \033[1m${usage_pct}%\033[0m (${used_k}k/${total_k}k)"--# Add free space-brick_line+=" | \033[1;32m${free_k}k free\033[0m"--# Add duration (HHh MMm format)-brick_line+=" | ${duration_hours}h ${duration_min}m"+# Build line 2 with just duration and cost+line2="${duration_hours}h ${duration_min}m"# Add cost only if non-zero, rounded to 2 decimal placesif command -v bc &> /dev/null; thenif (( $(echo "$cost_usd > 0" | bc -l 2>/dev/null || echo "0") )); thencost_formatted=$(printf "%.2f" "$cost_usd" 2>/dev/null || echo "0.00")- brick_line+=" | \033[0;33m\$${cost_formatted}\033[0m"+ line2+=" | \033[0;33m\$${cost_formatted}\033[0m"fielse# Fallback without bc: simple string comparisonif [[ "$cost_usd" != "0" && "$cost_usd" != "0.0" && "$cost_usd" != "0.00" && -n "$cost_usd" ]]; then- brick_line+=" | \033[0;33m\$${cost_usd}\033[0m"+ line2+=" | \033[0;33m\$${cost_usd}\033[0m"fifi# Output both linesecho -e "$line1"-echo -e "$brick_line"+echo -e "$line2"++# =============================================================================+# DISABLED: Context Brick Visualization+# =============================================================================+# The code below is preserved for when Anthropic fixes the context_window API.+# Currently, total_input_tokens and total_output_tokens are CUMULATIVE session+# totals that never reset after compaction, making them useless for tracking+# actual context window usage.+#+# To re-enable: uncomment this section and replace the line2 output above.+# =============================================================================+#+# # Try native context_window first (Claude Code 2.0.65+)+# cumulative_input=$(echo "$input" | jq -r '.context_window.total_input_tokens // null')+# cumulative_output=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')+# total_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')+#+# compacted=false+#+# if [[ "$cumulative_input" != "null" && -n "$cumulative_input" && "$cumulative_input" != "0" ]]; then+# cumulative_total=$((cumulative_input + cumulative_output))+#+# # Detect compaction: cumulative exceeds context limit+# if [[ $cumulative_total -gt $total_tokens ]]; then+# compacted=true+#+# # Get ACTUAL current context from last message's input_tokens+# transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')+#+# if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then+# # Get the last assistant message's input_tokens (actual context sent)+# last_input=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \+# tail -1 | \+# jq -r '.message.usage.input_tokens // 0' 2>/dev/null)+#+# if [[ -n "$last_input" && "$last_input" =~ ^[0-9]+$ && "$last_input" -gt 0 ]]; then+# # Add cache tokens for complete picture+# cache_read=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \+# tail -1 | \+# jq -r '.message.usage.cache_read_input_tokens // 0' 2>/dev/null)+# [[ ! "$cache_read" =~ ^[0-9]+$ ]] && cache_read=0+#+# used_tokens=$((last_input + cache_read))+# else+# # Fallback: cap at 90% if we can't determine actual usage+# used_tokens=$(( (total_tokens * 90) / 100 ))+# fi+# else+# used_tokens=$(( (total_tokens * 90) / 100 ))+# fi+# else+# # Normal state: use cumulative (it's accurate when < limit)+# used_tokens=$cumulative_total+# fi+# else+# # Fallback for older Claude Code versions (no native data)+# transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')+#+# if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then+# last_usage=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \+# tail -1 | \+# jq -r '.message.usage // null' 2>/dev/null)+#+# if [[ -n "$last_usage" && "$last_usage" != "null" ]]; then+# used_tokens=$(echo "$last_usage" | jq '+# (.input_tokens // 0) ++# (.cache_read_input_tokens // 0) ++# (.cache_creation_input_tokens // 0) ++# (.output_tokens // 0)+# ')+# else+# used_tokens=0+# fi+#+# [[ ! "$used_tokens" =~ ^[0-9]+$ ]] && used_tokens=0+# else+# used_tokens=0+# fi+# fi+#+# # Calculate metrics+# free_tokens=$((total_tokens - used_tokens))+# if [[ $total_tokens -gt 0 ]]; then+# usage_pct=$(( (used_tokens * 100) / total_tokens ))+# else+# usage_pct=0+# fi+#+# # Convert to 'k' format for display+# used_k=$(( used_tokens / 1000 ))+# total_k=$(( total_tokens / 1000 ))+# free_k=$(( free_tokens / 1000 ))+#+# # Generate brick visualization (40 bricks total)+# total_bricks=40+# used_bricks=$(( (used_tokens * total_bricks) / total_tokens ))+# free_bricks=$((total_bricks - used_bricks))+#+# # Build brick line with single colour (cyan for used, dim white for free)+# brick_line="ctx ["+#+# # Used bricks (cyan)+# for ((i=0; i<used_bricks; i++)); do+# brick_line+="\033[0;36mβ \033[0m"+# done+#+# # Free bricks (dim/gray hollow squares)+# for ((i=0; i<free_bricks; i++)); do+# brick_line+="\033[2;37mβ‘\033[0m"+# done+#+# brick_line+="]"+#+# # Add compaction indicator if applicable+# if [[ "$compacted" == "true" ]]; then+# brick_line+=" \033[1;35mπ¦\033[0m"+# fi+#+# brick_line+=" \033[1m${usage_pct}%\033[0m (${used_k}k/${total_k}k)"+#+# # Add free space+# brick_line+=" | \033[1;32m${free_k}k free\033[0m"+#+# # Add duration (HHh MMm format)+# brick_line+=" | ${duration_hours}h ${duration_min}m"+#+# # Add cost only if non-zero, rounded to 2 decimal places+# if command -v bc &> /dev/null; then+# if (( $(echo "$cost_usd > 0" | bc -l 2>/dev/null || echo "0") )); then+# cost_formatted=$(printf "%.2f" "$cost_usd" 2>/dev/null || echo "0.00")+# brick_line+=" | \033[0;33m\$${cost_formatted}\033[0m"+# fi+# else+# # Fallback without bc: simple string comparison+# if [[ "$cost_usd" != "0" && "$cost_usd" != "0.0" && "$cost_usd" != "0.00" && -n "$cost_usd" ]]; then+# brick_line+=" | \033[0;33m\$${cost_usd}\033[0m"+# fi+# fi+#+# # Output both lines+# echo -e "$line1"+# echo -e "$brick_line"diff --git a/tools/statusline/statusline.sh b/tools/statusline/statusline.shindex 6960958b..dca2427a 100755--- a/tools/statusline/statusline.sh+++ b/tools/statusline/statusline.sh@@ -1,9 +1,14 @@#!/bin/bash-# Claude Code Custom Status Line with Context Brick Visualization-# v2.0 - Uses native context_window data from Claude Code 2.0.65++# Claude Code Custom Status Line+# v3.0 - Context tracking DISABLED due to Anthropic API bug# Shows: Model | Repo:Branch [commit] message | GitHub | git status | lines changed-# Context usage as horizontal brick visualization+# Session duration and cost+#+# NOTE: Context brick visualization disabled because context_window API provides+# cumulative session tokens that never reset after compaction, making it useless.+# See: https://github.com/anthropics/claude-code/issues/13783+# Re-enable when Anthropic fixes the API.# Read JSON from stdininput=$(cat)@@ -92,87 +97,11 @@ if [[ "$lines_added" -gt 0 || "$lines_removed" -gt 0 ]]; thenline1+=" | \033[0;32m+$lines_added\033[0m/\033[0;31m-$lines_removed\033[0m"fi-# Build Line 2: Context Brick Visualization-# Try native context_window first (Claude Code 2.0.65+)-cumulative_input=$(echo "$input" | jq -r '.context_window.total_input_tokens // null')-cumulative_output=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')-total_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')--compacted=false--if [[ "$cumulative_input" != "null" && -n "$cumulative_input" && "$cumulative_input" != "0" ]]; then- cumulative_total=$((cumulative_input + cumulative_output))-- # Detect compaction: cumulative exceeds context limit- if [[ $cumulative_total -gt $total_tokens ]]; then- compacted=true-- # Get ACTUAL current context from last message's input_tokens- transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')-- if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then- # Get the last assistant message's input_tokens (actual context sent)- last_input=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \- tail -1 | \- jq -r '.message.usage.input_tokens // 0' 2>/dev/null)-- if [[ -n "$last_input" && "$last_input" =~ ^[0-9]+$ && "$last_input" -gt 0 ]]; then- # Add cache tokens for complete picture- cache_read=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \- tail -1 | \- jq -r '.message.usage.cache_read_input_tokens // 0' 2>/dev/null)- [[ ! "$cache_read" =~ ^[0-9]+$ ]] && cache_read=0-- used_tokens=$((last_input + cache_read))- else- # Fallback: cap at 90% if we can't determine actual usage- used_tokens=$(( (total_tokens * 90) / 100 ))- fi- else- used_tokens=$(( (total_tokens * 90) / 100 ))- fi- else- # Normal state: use cumulative (it's accurate when < limit)- used_tokens=$cumulative_total- fi-else- # Fallback for older Claude Code versions (no native data)- transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')-- if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then- last_usage=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \- tail -1 | \- jq -r '.message.usage // null' 2>/dev/null)-- if [[ -n "$last_usage" && "$last_usage" != "null" ]]; then- used_tokens=$(echo "$last_usage" | jq '- (.input_tokens // 0) +- (.cache_read_input_tokens // 0) +- (.cache_creation_input_tokens // 0) +- (.output_tokens // 0)- ')- else- used_tokens=0- fi-- [[ ! "$used_tokens" =~ ^[0-9]+$ ]] && used_tokens=0- else- used_tokens=0- fi-fi--# Calculate metrics-free_tokens=$((total_tokens - used_tokens))-if [[ $total_tokens -gt 0 ]]; then- usage_pct=$(( (used_tokens * 100) / total_tokens ))-else- usage_pct=0-fi--# Convert to 'k' format for display-used_k=$(( used_tokens / 1000 ))-total_k=$(( total_tokens / 1000 ))-free_k=$(( free_tokens / 1000 ))+# Build Line 2: Session info (duration + cost)+# NOTE: Context tracking disabled - Anthropic's context_window API provides cumulative+# session tokens that never reset after compaction, making it useless for tracking+# actual context usage. See: https://github.com/anthropics/claude-code/issues/13783+# Re-enable when Anthropic fixes the API to provide actual current context usage.# Get session duration (convert ms to HHh MMm format)duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')@@ -182,52 +111,164 @@ duration_min=$(((duration_ms % 3600000) / 60000))# Get session cost (only show if > 0, for API users)cost_usd=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')-# Generate brick visualization (40 bricks total)-total_bricks=40-used_bricks=$(( (used_tokens * total_bricks) / total_tokens ))-free_bricks=$((total_bricks - used_bricks))--# Build brick line with single colour (cyan for used, dim white for free)-brick_line="ctx ["--# Used bricks (cyan)-for ((i=0; i<used_bricks; i++)); do- brick_line+="\033[0;36mβ \033[0m"-done--# Free bricks (dim/gray hollow squares)-for ((i=0; i<free_bricks; i++)); do- brick_line+="\033[2;37mβ‘\033[0m"-done--brick_line+="]"--# Add compaction indicator if applicable-if [[ "$compacted" == "true" ]]; then- brick_line+=" \033[1;35mπ¦\033[0m"-fi--brick_line+=" \033[1m${usage_pct}%\033[0m (${used_k}k/${total_k}k)"--# Add free space-brick_line+=" | \033[1;32m${free_k}k free\033[0m"--# Add duration (HHh MMm format)-brick_line+=" | ${duration_hours}h ${duration_min}m"+# Build line 2 with just duration and cost+line2="${duration_hours}h ${duration_min}m"# Add cost only if non-zero, rounded to 2 decimal placesif command -v bc &> /dev/null; thenif (( $(echo "$cost_usd > 0" | bc -l 2>/dev/null || echo "0") )); thencost_formatted=$(printf "%.2f" "$cost_usd" 2>/dev/null || echo "0.00")- brick_line+=" | \033[0;33m\$${cost_formatted}\033[0m"+ line2+=" | \033[0;33m\$${cost_formatted}\033[0m"fielse# Fallback without bc: simple string comparisonif [[ "$cost_usd" != "0" && "$cost_usd" != "0.0" && "$cost_usd" != "0.00" && -n "$cost_usd" ]]; then- brick_line+=" | \033[0;33m\$${cost_usd}\033[0m"+ line2+=" | \033[0;33m\$${cost_usd}\033[0m"fifi# Output both linesecho -e "$line1"-echo -e "$brick_line"+echo -e "$line2"++# =============================================================================+# DISABLED: Context Brick Visualization+# =============================================================================+# The code below is preserved for when Anthropic fixes the context_window API.+# Currently, total_input_tokens and total_output_tokens are CUMULATIVE session+# totals that never reset after compaction, making them useless for tracking+# actual context window usage.+#+# To re-enable: uncomment this section and replace the line2 output above.+# =============================================================================+#+# # Try native context_window first (Claude Code 2.0.65+)+# cumulative_input=$(echo "$input" | jq -r '.context_window.total_input_tokens // null')+# cumulative_output=$(echo "$input" | jq -r '.context_window.total_output_tokens // 0')+# total_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')+#+# compacted=false+#+# if [[ "$cumulative_input" != "null" && -n "$cumulative_input" && "$cumulative_input" != "0" ]]; then+# cumulative_total=$((cumulative_input + cumulative_output))+#+# # Detect compaction: cumulative exceeds context limit+# if [[ $cumulative_total -gt $total_tokens ]]; then+# compacted=true+#+# # Get ACTUAL current context from last message's input_tokens+# transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')+#+# if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then+# # Get the last assistant message's input_tokens (actual context sent)+# last_input=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \+# tail -1 | \+# jq -r '.message.usage.input_tokens // 0' 2>/dev/null)+#+# if [[ -n "$last_input" && "$last_input" =~ ^[0-9]+$ && "$last_input" -gt 0 ]]; then+# # Add cache tokens for complete picture+# cache_read=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \+# tail -1 | \+# jq -r '.message.usage.cache_read_input_tokens // 0' 2>/dev/null)+# [[ ! "$cache_read" =~ ^[0-9]+$ ]] && cache_read=0+#+# used_tokens=$((last_input + cache_read))+# else+# # Fallback: cap at 90% if we can't determine actual usage+# used_tokens=$(( (total_tokens * 90) / 100 ))+# fi+# else+# used_tokens=$(( (total_tokens * 90) / 100 ))+# fi+# else+# # Normal state: use cumulative (it's accurate when < limit)+# used_tokens=$cumulative_total+# fi+# else+# # Fallback for older Claude Code versions (no native data)+# transcript_path=$(echo "$input" | jq -r '.transcript_path // ""')+#+# if [[ -f "$transcript_path" && -s "$transcript_path" ]]; then+# last_usage=$(grep '"type":"assistant"' "$transcript_path" 2>/dev/null | \+# tail -1 | \+# jq -r '.message.usage // null' 2>/dev/null)+#+# if [[ -n "$last_usage" && "$last_usage" != "null" ]]; then+# used_tokens=$(echo "$last_usage" | jq '+# (.input_tokens // 0) ++# (.cache_read_input_tokens // 0) ++# (.cache_creation_input_tokens // 0) ++# (.output_tokens // 0)+# ')+# else+# used_tokens=0+# fi+#+# [[ ! "$used_tokens" =~ ^[0-9]+$ ]] && used_tokens=0+# else+# used_tokens=0+# fi+# fi+#+# # Calculate metrics+# free_tokens=$((total_tokens - used_tokens))+# if [[ $total_tokens -gt 0 ]]; then+# usage_pct=$(( (used_tokens * 100) / total_tokens ))+# else+# usage_pct=0+# fi+#+# # Convert to 'k' format for display+# used_k=$(( used_tokens / 1000 ))+# total_k=$(( total_tokens / 1000 ))+# free_k=$(( free_tokens / 1000 ))+#+# # Generate brick visualization (40 bricks total)+# total_bricks=40+# used_bricks=$(( (used_tokens * total_bricks) / total_tokens ))+# free_bricks=$((total_bricks - used_bricks))+#+# # Build brick line with single colour (cyan for used, dim white for free)+# brick_line="ctx ["+#+# # Used bricks (cyan)+# for ((i=0; i<used_bricks; i++)); do+# brick_line+="\033[0;36mβ \033[0m"+# done+#+# # Free bricks (dim/gray hollow squares)+# for ((i=0; i<free_bricks; i++)); do+# brick_line+="\033[2;37mβ‘\033[0m"+# done+#+# brick_line+="]"+#+# # Add compaction indicator if applicable+# if [[ "$compacted" == "true" ]]; then+# brick_line+=" \033[1;35mπ¦\033[0m"+# fi+#+# brick_line+=" \033[1m${usage_pct}%\033[0m (${used_k}k/${total_k}k)"+#+# # Add free space+# brick_line+=" | \033[1;32m${free_k}k free\033[0m"+#+# # Add duration (HHh MMm format)+# brick_line+=" | ${duration_hours}h ${duration_min}m"+#+# # Add cost only if non-zero, rounded to 2 decimal places+# if command -v bc &> /dev/null; then+# if (( $(echo "$cost_usd > 0" | bc -l 2>/dev/null || echo "0") )); then+# cost_formatted=$(printf "%.2f" "$cost_usd" 2>/dev/null || echo "0.00")+# brick_line+=" | \033[0;33m\$${cost_formatted}\033[0m"+# fi+# else+# # Fallback without bc: simple string comparison+# if [[ "$cost_usd" != "0" && "$cost_usd" != "0.0" && "$cost_usd" != "0.00" && -n "$cost_usd" ]]; then+# brick_line+=" | \033[0;33m\$${cost_usd}\033[0m"+# fi+# fi+#+# # Output both lines+# echo -e "$line1"+# echo -e "$brick_line"