Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat(contextbricks): v4.0.0 — 3-line layout, cross-platform Node.js
Jeremy Dawesb0aa8c807aa3
diff --git a/tools/statusline-npm/LICENSE b/tools/statusline-npm/LICENSEnew file mode 100644index 00000000..6ea2e76c--- /dev/null+++ b/tools/statusline-npm/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2025 Jeremy Dawes (Jezweb)++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/tools/statusline-npm/README.md b/tools/statusline-npm/README.mdnew file mode 100644index 00000000..d1319a0c--- /dev/null+++ b/tools/statusline-npm/README.md@@ -0,0 +1,69 @@+# Context Bricks++Git-aware statusline for Claude Code CLI with context brick visualisation.++## Install++```bash+npx contextbricks init+```++Requires Node.js (already installed with Claude Code) and `git`.++## What It Shows++3-line display:++```+[Opus 4.6:expl] my-project:main *↑1 | @my-agent | wt+[abc1234] Fix auth redirect loop | +12/-3+[■■■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□] 30% | 140k free | 0h 12m | $1.50+```++| Line | Content |+|------|---------|+| 1 | Model, output style, repo:branch, git status, agent name, worktree |+| 2 | Latest commit hash + message, lines changed |+| 3 | Context brick bar, percentage, free tokens, duration, cost |++### Indicators++| Indicator | Meaning |+|-----------|---------|+| `*` | Uncommitted changes |+| `↑2` | 2 commits ahead of remote |+| `↓1` | 1 commit behind remote |+| `@agent-name` | Running with `claude --agent` |+| `wt` | Inside a git worktree |+| `:expl` | Output style (explanatory, concise, verbose) |+| `73%!` | Context exceeds 200k tokens (extended context) |++## Manual Install++```bash+cp scripts/statusline.js ~/.claude/statusline.js+```++Add to `~/.claude/settings.json`:++```json+{+ "statusLine": {+ "type": "command",+ "command": "node ~/.claude/statusline.js",+ "padding": 0+ }+}+```++Restart Claude Code.++## Uninstall++```bash+contextbricks uninstall+```++## License++MITdiff --git a/tools/statusline-npm/bin/cli.js b/tools/statusline-npm/bin/cli.jsnew file mode 100755index 00000000..f486cb1d--- /dev/null+++ b/tools/statusline-npm/bin/cli.js@@ -0,0 +1,116 @@+#!/usr/bin/env node++const { spawnSync } = require('child_process');+const path = require('path');+const fs = require('fs');++const command = process.argv[2];+const scriptsDir = path.join(__dirname, '../scripts');++// Colors for terminal output+const colors = {+ reset: '\x1b[0m',+ red: '\x1b[31m',+ green: '\x1b[32m',+ yellow: '\x1b[33m',+ cyan: '\x1b[36m',+};++// Check for jq dependency+function checkDependencies() {+ const jqCheck = spawnSync('which', ['jq'], { encoding: 'utf-8' });+ if (jqCheck.status !== 0) {+ console.error(`${colors.red}❌ Error: jq is required but not installed.${colors.reset}`);+ console.error(` ${colors.cyan}Install with:${colors.reset}`);+ console.error(` sudo apt install jq ${colors.yellow}# Ubuntu/Debian${colors.reset}`);+ console.error(` brew install jq ${colors.yellow}# macOS${colors.reset}`);+ console.error(` yum install jq ${colors.yellow}# RHEL/CentOS${colors.reset}`);+ process.exit(1);+ }++ const gitCheck = spawnSync('which', ['git'], { encoding: 'utf-8' });+ if (gitCheck.status !== 0) {+ console.warn(`${colors.yellow}⚠️ Warning: git not found. Git info will not be available.${colors.reset}`);+ }+}++// Display help+function showHelp() {+ console.log(`+${colors.cyan}🧱 ContextBricks${colors.reset} - Claude Code Status Line++${colors.green}Usage:${colors.reset}+ contextbricks init Interactive install+ contextbricks install Install status line+ contextbricks uninstall Uninstall status line+ contextbricks --help Show this help+ contextbricks --version Show version++${colors.green}Quick Start:${colors.reset}+ npx contextbricks init++${colors.green}Features:${colors.reset}+ • Real-time context tracking from transcript files+ • Brick visualization showing token breakdown+ • Git integration (repo, branch, commit, status)+ • Model-aware context limits (200k for all models in Claude Code)+ • Session metrics (lines changed, free space)++${colors.green}More Info:${colors.reset}+ GitHub: https://github.com/jezweb/claude-skills/tree/main/tools/statusline+ Issues: https://github.com/jezweb/claude-skills/issues+`);+}++// Main command handler+function main() {+ switch (command) {+ case 'install':+ case 'init':+ checkDependencies();+ const installResult = spawnSync('bash', [path.join(scriptsDir, 'install.sh')], {+ stdio: 'inherit',+ env: { ...process.env, NPM_INSTALL: '1' }+ });+ process.exit(installResult.status || 0);+ break;++ case 'uninstall':+ const uninstallResult = spawnSync('bash', [path.join(scriptsDir, 'uninstall.sh')], {+ stdio: 'inherit',+ env: { ...process.env, NPM_INSTALL: '1' }+ });+ process.exit(uninstallResult.status || 0);+ break;++ case '--version':+ case '-v':+ const packageJson = require('../package.json');+ console.log(`contextbricks v${packageJson.version}`);+ break;++ case '--help':+ case '-h':+ case 'help':+ showHelp();+ break;++ default:+ if (command) {+ // Unknown command - show error + help+ console.error(`${colors.red}❌ Unknown command: ${command}${colors.reset}\n`);+ showHelp();+ process.exit(1);+ } else {+ // No command - run interactive install as default+ checkDependencies();+ const defaultInstallResult = spawnSync('bash', [path.join(scriptsDir, 'install.sh')], {+ stdio: 'inherit',+ env: { ...process.env, NPM_INSTALL: '1' }+ });+ process.exit(defaultInstallResult.status || 0);+ }+ }+}++main();diff --git a/tools/statusline-npm/package.json b/tools/statusline-npm/package.jsonnew file mode 100644index 00000000..c1b64f14--- /dev/null+++ b/tools/statusline-npm/package.json@@ -0,0 +1,43 @@+{+ "name": "contextbricks",+ "version": "4.0.0",+ "description": "Git-aware statusline for Claude Code CLI with context brick visualization",+ "keywords": [+ "claude",+ "claude-code",+ "statusline",+ "cli",+ "context",+ "bricks",+ "git",+ "tokens",+ "terminal",+ "visualization"+ ],+ "bin": {+ "contextbricks": "bin/cli.js"+ },+ "scripts": {+ "postinstall": "echo '\n🧱 ContextBricks installed! Run: contextbricks init\n'"+ },+ "files": [+ "bin/",+ "scripts/",+ "README.md",+ "LICENSE"+ ],+ "engines": {+ "node": ">=14"+ },+ "repository": {+ "type": "git",+ "url": "git+https://github.com/jezweb/claude-skills.git",+ "directory": "tools/statusline-npm"+ },+ "bugs": {+ "url": "https://github.com/jezweb/claude-skills/issues"+ },+ "author": "Jeremy Dawes <[email protected]> (https://jezweb.com.au)",+ "license": "MIT",+ "homepage": "https://github.com/jezweb/claude-skills/tree/main/tools/statusline-npm"+}diff --git a/tools/statusline-npm/scripts/install.sh b/tools/statusline-npm/scripts/install.shnew file mode 100755index 00000000..a4a3fbb9--- /dev/null+++ b/tools/statusline-npm/scripts/install.sh@@ -0,0 +1,91 @@+#!/bin/bash++# Claude Code Status Line - Installation Script+# Installs cross-platform Node.js statusline (works on macOS, Linux, Windows)++set -e++SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"+STATUSLINE_SCRIPT="$SCRIPT_DIR/statusline.js"+INSTALL_PATH="$HOME/.claude/statusline.js"+SETTINGS_FILE="$HOME/.claude/settings.json"+BACKUP_SUFFIX=".backup-$(date +%Y%m%d-%H%M%S)"++echo "Installing Claude Code Custom Status Line..."+echo ""++# Check dependencies+echo "Checking dependencies..."+if ! command -v node &> /dev/null; then+ echo "Error: Node.js is required but not installed."+ echo " Claude Code requires Node.js, so this should already be available."+ exit 1+fi++if ! command -v git &> /dev/null; then+ echo "Warning: git not found. Git info will not be available."+fi++echo "Dependencies OK (Node.js + git)"+echo ""++# Backup existing statusline script if it exists+for old in "$HOME/.claude/statusline.js" "$HOME/.claude/statusline.sh"; do+ if [[ -f "$old" ]]; then+ echo "Backing up existing status line: $old"+ cp "$old" "${old}${BACKUP_SUFFIX}"+ echo " Backup saved: ${old}${BACKUP_SUFFIX}"+ fi+done++# Copy statusline script+echo "Installing status line script..."+mkdir -p "$HOME/.claude"+cp "$STATUSLINE_SCRIPT" "$INSTALL_PATH"+chmod +x "$INSTALL_PATH"+echo " Installed: $INSTALL_PATH"+echo ""++# Update settings.json+if [[ -f "$SETTINGS_FILE" ]]; then+ echo "Updating settings.json..."++ # Backup settings+ cp "$SETTINGS_FILE" "${SETTINGS_FILE}${BACKUP_SUFFIX}"+ echo " Backup saved: ${SETTINGS_FILE}${BACKUP_SUFFIX}"++ # Check for jq (needed to update settings)+ if command -v jq &> /dev/null; then+ jq '.statusLine = {+ "type": "command",+ "command": "node ~/.claude/statusline.js",+ "padding": 0+ }' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"+ echo " Settings updated"+ else+ echo " jq not found — please manually update statusLine.command in settings.json to:"+ echo " \"node ~/.claude/statusline.js\""+ fi+else+ echo "Creating settings.json..."+ cat > "$SETTINGS_FILE" <<'EOF'+{+ "statusLine": {+ "type": "command",+ "command": "node ~/.claude/statusline.js",+ "padding": 0+ }+}+EOF+ echo " Settings created: $SETTINGS_FILE"+fi++echo ""+echo "Installation complete!"+echo ""+echo "Your 3-line status bar shows:"+echo " Line 1: Model, repo:branch, git status, agent name, worktree"+echo " Line 2: Latest commit + lines changed"+echo " Line 3: Context bricks, percentage, free tokens, duration, cost"+echo ""+echo "Restart Claude Code to see your new status line!"diff --git a/tools/statusline-npm/scripts/statusline.js b/tools/statusline-npm/scripts/statusline.jsnew file mode 100755index 00000000..d8d3e6c0--- /dev/null+++ b/tools/statusline-npm/scripts/statusline.js@@ -0,0 +1,187 @@+#!/usr/bin/env node++// Claude Code Custom Status Line — Context Bricks+// v4.0.0 - Cross-platform Node.js version (no jq/bash dependencies)+//+// Line 1: [Model:style] repo:branch status | @agent | wt+// Line 2: [commit] message | +lines/-lines+// Line 3: [■■■■□□□□] 73%! | 52k free | 2h15m | $12.50++const { execFileSync } = require('child_process');++// Read JSON from stdin+const chunks = [];+const stdin = process.stdin;+stdin.setEncoding('utf8');++if (stdin.isTTY) {+ process.exit(0);+}++stdin.on('data', (chunk) => chunks.push(chunk));+stdin.on('end', () => {+ try {+ main(JSON.parse(chunks.join('') || '{}'));+ } catch {+ main({});+ }+});++// ANSI helpers+const c = {+ reset: '\x1b[0m',+ bold: '\x1b[1m',+ dim: '\x1b[2;37m',+ cyan: '\x1b[1;36m',+ green: '\x1b[1;32m',+ blue: '\x1b[1;34m',+ yellow: '\x1b[1;33m',+ red: '\x1b[1;31m',+ magenta: '\x1b[1;35m',+ greenDim: '\x1b[0;32m',+ redDim: '\x1b[0;31m',+ yellowDim: '\x1b[0;33m',+ cyanDim: '\x1b[0;36m',+};++// Safe git command execution using execFileSync (no shell injection risk)+function git(...args) {+ try {+ return execFileSync('git', args, { encoding: 'utf8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'] }).trim();+ } catch {+ return '';+ }+}++function main(data) {+ // Parse Claude data+ const model = (data.model?.display_name || 'Claude').replace('Claude ', '');+ const currentDir = data.workspace?.current_dir || process.env.PWD || process.cwd();+ const linesAdded = data.cost?.total_lines_added || 0;+ const linesRemoved = data.cost?.total_lines_removed || 0;+ const agentName = data.agent?.name || '';+ const outputStyle = data.output_style?.name || '';+ const exceeds200k = data.context_window?.exceeds_200k_tokens || false;++ // Style abbreviation+ let styleAbbrev = '';+ if (outputStyle && outputStyle !== 'default') {+ const map = { explanatory: 'expl', concise: 'conc', verbose: 'verb' };+ styleAbbrev = map[outputStyle] || outputStyle.slice(0, 4);+ }++ // Change to workspace directory+ try { process.chdir(currentDir); } catch { /* stay where we are */ }++ // Git info+ const isGit = git('rev-parse', '--git-dir') !== '';+ let repoName = '', branch = '', commitShort = '', commitMsg = '', gitStatus = '', inWorktree = false;++ if (isGit) {+ const toplevel = git('rev-parse', '--show-toplevel');+ repoName = toplevel ? toplevel.split('/').pop().split('\\').pop() : '';+ branch = git('branch', '--show-current') || 'detached';+ commitShort = git('rev-parse', '--short', 'HEAD');+ commitMsg = git('log', '-1', '--pretty=%s').slice(0, 50);++ // Worktree detection+ const gitDir = git('rev-parse', '--git-dir');+ inWorktree = gitDir.includes('/worktrees/') || gitDir.includes('\\worktrees\\');++ // Status+ const porcelain = git('status', '--porcelain');+ if (porcelain) gitStatus = '*';++ // Ahead/behind+ const upstream = git('rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}');+ if (upstream) {+ const ahead = parseInt(git('rev-list', '--count', `${upstream}..HEAD`)) || 0;+ const behind = parseInt(git('rev-list', '--count', `HEAD..${upstream}`)) || 0;+ if (ahead > 0) gitStatus += `\u2191${ahead}`;+ if (behind > 0) gitStatus += `\u2193${behind}`;+ }+ }++ // ── Line 1: Session identity ──────────────────────────────+ let line1 = '';+ line1 += styleAbbrev+ ? `${c.cyan}[${model}:${styleAbbrev}]${c.reset}`+ : `${c.cyan}[${model}]${c.reset}`;++ if (repoName) {+ line1 += ` ${c.green}${repoName}${c.reset}`;+ if (branch) line1 += `:${c.blue}${branch}${c.reset}`;+ }++ if (gitStatus) line1 += ` ${c.red}${gitStatus}${c.reset}`;+ if (agentName) line1 += ` | ${c.magenta}@${agentName}${c.reset}`;+ if (inWorktree) line1 += ` | ${c.yellow}wt${c.reset}`;++ // ── Line 2: Git state ─────────────────────────────────────+ let line2 = '';+ if (commitShort) {+ line2 += `${c.dim}[${c.reset}${c.yellowDim}${commitShort}${c.reset}${c.dim}]${c.reset}`;+ if (commitMsg) line2 += ` ${commitMsg}`;+ }++ if (linesAdded > 0 || linesRemoved > 0) {+ if (line2) line2 += ' | ';+ line2 += `${c.greenDim}+${linesAdded}${c.reset}/${c.redDim}-${linesRemoved}${c.reset}`;+ }++ // ── Line 3: Context bricks + metrics ──────────────────────+ const durationMs = data.cost?.total_duration_ms || 0;+ const durationH = Math.floor(durationMs / 3600000);+ const durationM = Math.floor((durationMs % 3600000) / 60000);+ const costUsd = data.cost?.total_cost_usd || 0;+ const totalTokens = data.context_window?.context_window_size || 200000;++ let usagePct, freeTokens;+ const usedPctRaw = data.context_window?.used_percentage;+ const remainingPctRaw = data.context_window?.remaining_percentage;++ if (usedPctRaw != null) {+ usagePct = Math.floor(usedPctRaw);+ const remainingPct = Math.floor(remainingPctRaw || 0);+ freeTokens = Math.floor((totalTokens * remainingPct) / 100);+ } else {+ const cu = data.context_window?.current_usage;+ let usedTokens = 0;+ if (cu) {+ usedTokens = (cu.input_tokens || 0) + (cu.cache_creation_input_tokens || 0) + (cu.cache_read_input_tokens || 0);+ }+ freeTokens = totalTokens - usedTokens;+ usagePct = totalTokens > 0 ? Math.floor((usedTokens * 100) / totalTokens) : 0;+ }++ const freeK = Math.floor(freeTokens / 1000);++ // Brick bar (40 bricks)+ const totalBricks = 40;+ const usedBricks = totalTokens > 0 ? Math.floor((usagePct * totalBricks) / 100) : 0;+ const freeBricks = totalBricks - usedBricks;++ let line3 = '[';+ for (let i = 0; i < usedBricks; i++) line3 += `${c.cyanDim}\u25a0${c.reset}`;+ for (let i = 0; i < freeBricks; i++) line3 += `${c.dim}\u25a1${c.reset}`;+ line3 += ']';++ // Percentage — yellow with ! when exceeding 200k+ if (exceeds200k) {+ line3 += ` ${c.yellow}${usagePct}%!${c.reset}`;+ } else {+ line3 += ` ${c.bold}${usagePct}%${c.reset}`;+ }++ line3 += ` | ${c.green}${freeK}k free${c.reset}`;+ line3 += ` | ${durationH}h ${durationM}m`;++ if (costUsd > 0) {+ line3 += ` | ${c.yellowDim}$${costUsd.toFixed(2)}${c.reset}`;+ }++ // Output+ console.log(line1);+ console.log(line2);+ console.log(line3);+}diff --git a/tools/statusline-npm/scripts/statusline.sh b/tools/statusline-npm/scripts/statusline.shnew file mode 100755index 00000000..b7af6413--- /dev/null+++ b/tools/statusline-npm/scripts/statusline.sh@@ -0,0 +1,215 @@+#!/bin/bash++# Claude Code Custom Status Line — Context Bricks+# v4.0.0 - 3-line layout with agent name, worktree, output style, extended context warning+#+# Line 1: [Model:style] repo:branch status | @agent | wt+# Line 2: [commit] message | +lines/-lines+# Line 3: [■■■■□□□□] 73%! | 52k free | 2h15m | $12.50+#+# Uses percentage fields (Claude Code 2.1.6+) with fallback to current_usage calculation.++# Read JSON from stdin+input=$(cat)++# Parse Claude data+model=$(echo "$input" | jq -r '.model.display_name // "Claude"' | sed 's/Claude //')+current_dir=$(echo "$input" | jq -r '.workspace.current_dir // env.PWD')+lines_added=$(echo "$input" | jq -r '.cost.total_lines_added // 0')+lines_removed=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')+agent_name=$(echo "$input" | jq -r '.agent.name // empty')+output_style=$(echo "$input" | jq -r '.output_style.name // empty')+exceeds_200k=$(echo "$input" | jq -r '.context_window.exceeds_200k_tokens // false')++# Abbreviate output style+style_abbrev=""+if [[ -n "$output_style" && "$output_style" != "default" ]]; then+ case "$output_style" in+ explanatory) style_abbrev="expl" ;;+ concise) style_abbrev="conc" ;;+ verbose) style_abbrev="verb" ;;+ *) style_abbrev="${output_style:0:4}" ;;+ esac+fi++# Get git information+cd "$current_dir" 2>/dev/null || cd "$HOME"++if git rev-parse --git-dir > /dev/null 2>&1; then+ repo_name=$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" || echo "")+ branch=$(git branch --show-current 2>/dev/null || echo "detached")+ commit_short=$(git rev-parse --short HEAD 2>/dev/null || echo "")+ commit_msg=$(git log -1 --pretty=%s 2>/dev/null | cut -c1-50 || echo "")++ # Worktree detection+ git_dir=$(git rev-parse --git-dir 2>/dev/null)+ in_worktree=false+ if echo "$git_dir" | grep -q '/worktrees/'; then+ in_worktree=true+ fi++ # Git status indicators+ git_status=""+ if [[ -n $(git status --porcelain 2>/dev/null) ]]; then+ git_status="*"+ fi++ # Check ahead/behind remote+ upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)+ if [[ -n "$upstream" ]]; then+ ahead=$(git rev-list --count "$upstream"..HEAD 2>/dev/null || echo "0")+ behind=$(git rev-list --count HEAD.."$upstream" 2>/dev/null || echo "0")+ [[ "$ahead" -gt 0 ]] && git_status="${git_status}↑${ahead}"+ [[ "$behind" -gt 0 ]] && git_status="${git_status}↓${behind}"+ fi+else+ repo_name=""+ branch=""+ commit_short=""+ commit_msg=""+ git_status=""+ in_worktree=false+fi++# ── Line 1: Session identity ──────────────────────────────────+line1=""++# Model in brackets, with optional style suffix+if [[ -n "$style_abbrev" ]]; then+ line1+="\033[1;36m[$model:$style_abbrev]\033[0m"+else+ line1+="\033[1;36m[$model]\033[0m"+fi++# Repo:Branch+if [[ -n "$repo_name" ]]; then+ line1+=" \033[1;32m$repo_name\033[0m"+ if [[ -n "$branch" ]]; then+ line1+=":\033[1;34m$branch\033[0m"+ fi+fi++# Git status indicators+if [[ -n "$git_status" ]]; then+ line1+=" \033[1;31m$git_status\033[0m"+fi++# Agent name+if [[ -n "$agent_name" ]]; then+ line1+=" | \033[1;35m@$agent_name\033[0m"+fi++# Worktree indicator+if [[ "$in_worktree" == "true" ]]; then+ line1+=" | \033[1;33mwt\033[0m"+fi++# ── Line 2: Git state ─────────────────────────────────────────+line2=""++# Commit info+if [[ -n "$commit_short" ]]; then+ line2+="\033[2;37m[\033[0m\033[1;33m$commit_short\033[0m\033[2;37m]\033[0m"+ if [[ -n "$commit_msg" ]]; then+ line2+=" $commit_msg"+ fi+fi++# Lines changed+if [[ "$lines_added" -gt 0 || "$lines_removed" -gt 0 ]]; then+ if [[ -n "$line2" ]]; then+ line2+=" | "+ fi+ line2+="\033[0;32m+$lines_added\033[0m/\033[0;31m-$lines_removed\033[0m"+fi++# ── Line 3: Context bricks + metrics ──────────────────────────+# Get session duration+duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')+duration_hours=$((duration_ms / 3600000))+duration_min=$(((duration_ms % 3600000) / 60000))++# Get session cost+cost_usd=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')++# Get context window data+total_tokens=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')++# Prefer v2.1.6+ percentage fields, fallback to calculation+used_pct_raw=$(echo "$input" | jq -r '.context_window.used_percentage // null')+remaining_pct_raw=$(echo "$input" | jq -r '.context_window.remaining_percentage // null')++if [[ "$used_pct_raw" != "null" && -n "$used_pct_raw" ]]; then+ usage_pct=${used_pct_raw%.*}+ remaining_pct=${remaining_pct_raw%.*}+ used_tokens=$(( (total_tokens * usage_pct) / 100 ))+ free_tokens=$(( (total_tokens * remaining_pct) / 100 ))+else+ current_usage=$(echo "$input" | jq -r '.context_window.current_usage // null')+ if [[ "$current_usage" != "null" ]]; then+ input_tokens=$(echo "$current_usage" | jq -r '.input_tokens // 0')+ cache_creation=$(echo "$current_usage" | jq -r '.cache_creation_input_tokens // 0')+ cache_read=$(echo "$current_usage" | jq -r '.cache_read_input_tokens // 0')+ used_tokens=$((input_tokens + cache_creation + cache_read))+ else+ used_tokens=0+ fi+ free_tokens=$((total_tokens - used_tokens))+ if [[ $total_tokens -gt 0 ]]; then+ usage_pct=$(( (used_tokens * 100) / total_tokens ))+ else+ usage_pct=0+ fi+fi++# Token display in 'k' format+free_k=$(( free_tokens / 1000 ))++# Generate brick visualization (40 bricks)+total_bricks=40+if [[ $total_tokens -gt 0 ]]; then+ used_bricks=$(( (used_tokens * total_bricks) / total_tokens ))+else+ used_bricks=0+fi+free_bricks=$((total_bricks - used_bricks))++# Build brick bar+line3="["+for ((i=0; i<used_bricks; i++)); do+ line3+="\033[0;36m■\033[0m"+done+for ((i=0; i<free_bricks; i++)); do+ line3+="\033[2;37m□\033[0m"+done+line3+="]"++# Percentage — yellow with ! when exceeding 200k+if [[ "$exceeds_200k" == "true" ]]; then+ line3+=" \033[1;33m${usage_pct}%!\033[0m"+else+ line3+=" \033[1m${usage_pct}%\033[0m"+fi++# Free space+line3+=" | \033[1;32m${free_k}k free\033[0m"++# Duration+line3+=" | ${duration_hours}h ${duration_min}m"++# Cost (only if non-zero)+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")+ line3+=" | \033[0;33m\$${cost_formatted}\033[0m"+ fi+else+ if [[ "$cost_usd" != "0" && "$cost_usd" != "0.0" && "$cost_usd" != "0.00" && -n "$cost_usd" ]]; then+ line3+=" | \033[0;33m\$${cost_usd}\033[0m"+ fi+fi++# Output all three lines+echo -e "$line1"+echo -e "$line2"+echo -e "$line3"diff --git a/tools/statusline-npm/scripts/uninstall.sh b/tools/statusline-npm/scripts/uninstall.shnew file mode 100755index 00000000..6db23dbe--- /dev/null+++ b/tools/statusline-npm/scripts/uninstall.sh@@ -0,0 +1,86 @@+#!/bin/bash++# Claude Code Status Line - Uninstallation Script+# Removes custom status line and optionally restores previous configuration++set -e++INSTALL_PATH="$HOME/.claude/statusline.sh"+SETTINGS_FILE="$HOME/.claude/settings.json"++echo "🗑️ Uninstalling Claude Code Custom Status Line..."+echo ""++# Find most recent backup+LATEST_BACKUP=$(ls -t "${INSTALL_PATH}.backup-"* 2>/dev/null | head -1 || echo "")+LATEST_SETTINGS_BACKUP=$(ls -t "${SETTINGS_FILE}.backup-"* 2>/dev/null | head -1 || echo "")++# Remove statusline script+if [[ -f "$INSTALL_PATH" ]]; then+ echo "📝 Removing status line script..."+ rm "$INSTALL_PATH"+ echo " Removed: $INSTALL_PATH"+else+ echo "⚠️ Status line script not found (already removed?)"+fi++echo ""++# Ask about settings.json+if [[ -f "$SETTINGS_FILE" ]]; then+ echo "⚙️ Settings.json options:"+ echo " 1) Remove statusLine configuration (keep other settings)"+ echo " 2) Restore from backup (if available)"+ echo " 3) Leave settings.json unchanged"+ echo ""+ read -p "Choose option [1-3]: " choice++ case $choice in+ 1)+ echo "Removing statusLine from settings.json..."+ jq 'del(.statusLine)' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"+ echo " StatusLine configuration removed"+ ;;+ 2)+ if [[ -n "$LATEST_SETTINGS_BACKUP" ]]; then+ echo "Restoring from backup: $LATEST_SETTINGS_BACKUP"+ cp "$LATEST_SETTINGS_BACKUP" "$SETTINGS_FILE"+ echo " Settings restored"+ else+ echo "❌ No backup found. Removing statusLine configuration instead..."+ jq 'del(.statusLine)' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"+ fi+ ;;+ 3)+ echo "Leaving settings.json unchanged"+ ;;+ *)+ echo "Invalid option. Leaving settings.json unchanged"+ ;;+ esac+fi++echo ""++# Ask about backups+if [[ -n "$LATEST_BACKUP" ]] || [[ -n "$LATEST_SETTINGS_BACKUP" ]]; then+ echo "📦 Backup files found:"+ [[ -n "$LATEST_BACKUP" ]] && echo " • $LATEST_BACKUP"+ [[ -n "$LATEST_SETTINGS_BACKUP" ]] && echo " • $LATEST_SETTINGS_BACKUP"+ echo ""+ read -p "Delete backup files? [y/N]: " delete_backups++ if [[ "$delete_backups" =~ ^[Yy]$ ]]; then+ [[ -n "$LATEST_BACKUP" ]] && rm "${INSTALL_PATH}.backup-"* 2>/dev/null && echo " Removed script backups"+ [[ -n "$LATEST_SETTINGS_BACKUP" ]] && rm "${SETTINGS_FILE}.backup-"* 2>/dev/null && echo " Removed settings backups"+ else+ echo " Backups preserved"+ fi+fi++echo ""+echo "✅ Uninstallation complete!"+echo ""+echo "🔄 Restart Claude Code for changes to take effect"+echo ""+echo "ℹ️ To reinstall: ./install.sh"