Skip to content

Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.

tools/statusline-npm: moved to jezweb/contextbricks

Jeremy Dawesdf4207f061e5
diff --git a/tools/statusline-npm/LICENSE b/tools/statusline-npm/LICENSE
deleted file mode 100644
index 6ea2e76c..00000000
--- a/tools/statusline-npm/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-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.md
index d1319a0c..e19d7a34 100644
--- a/tools/statusline-npm/README.md
+++ b/tools/statusline-npm/README.md
@@ -1,69 +1,7 @@
-# Context Bricks
+# ContextBricks has moved
-Git-aware statusline for Claude Code CLI with context brick visualisation.
+The ContextBricks status line (npm package `contextbricks`) now lives in its own repo, with its full history:
-## Install
+https://github.com/jezweb/contextbricks
-```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
-
-MIT
+Issues and releases are there.
diff --git a/tools/statusline-npm/bin/cli.js b/tools/statusline-npm/bin/cli.js
deleted file mode 100755
index f486cb1d..00000000
--- a/tools/statusline-npm/bin/cli.js
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/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.json
deleted file mode 100644
index 71603362..00000000
--- a/tools/statusline-npm/package.json
+++ /dev/null
@@ -1,43 +0,0 @@
-{
- "name": "contextbricks",
- "version": "4.1.1",
- "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/context-hook.sh b/tools/statusline-npm/scripts/context-hook.sh
deleted file mode 100755
index 52893830..00000000
--- a/tools/statusline-npm/scripts/context-hook.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/bash
-# Context awareness hook for Claude Code
-# Reads context level from statusline's persisted file and injects a note
-# when crossing 100k thresholds.
-#
-# Install as a UserPromptSubmit hook in settings.json:
-# "hooks": { "UserPromptSubmit": [{ "matcher": "", "hooks": [
-# { "type": "command", "command": "bash ~/.claude/context-hook.sh" }
-# ]}]}
-
-CONTEXT_FILE="$HOME/.claude/context-level.json"
-LAST_THRESHOLD_FILE="$HOME/.claude/context-last-threshold"
-
-# Read stdin (required by hook protocol)
-cat > /dev/null
-
-# Check if context file exists and is recent (< 60 seconds old)
-if [[ ! -f "$CONTEXT_FILE" ]]; then
- exit 0
-fi
-
-# Parse the JSON
-FREE_100K=$(python3 -c "import json; print(json.load(open('$CONTEXT_FILE'))['free100k'])" 2>/dev/null)
-USAGE_PCT=$(python3 -c "import json; print(json.load(open('$CONTEXT_FILE'))['usagePct'])" 2>/dev/null)
-TOTAL_K=$(python3 -c "import json; print(json.load(open('$CONTEXT_FILE'))['totalK'])" 2>/dev/null)
-
-if [[ -z "$FREE_100K" ]]; then
- exit 0
-fi
-
-# Read last reported threshold
-LAST_THRESHOLD=""
-if [[ -f "$LAST_THRESHOLD_FILE" ]]; then
- LAST_THRESHOLD=$(cat "$LAST_THRESHOLD_FILE")
-fi
-
-# Only inject when crossing a new 100k boundary (or first time)
-if [[ "$FREE_100K" == "$LAST_THRESHOLD" ]]; then
- exit 0
-fi
-
-# Save current threshold
-echo "$FREE_100K" > "$LAST_THRESHOLD_FILE"
-
-# Build the message based on how much is left
-if [[ "$FREE_100K" -ge 700 ]]; then
- echo "<context-status>Context: ~${FREE_100K}k tokens remaining (${USAGE_PCT}% used of ${TOTAL_K}k). Plenty of room — work freely.</context-status>"
-elif [[ "$FREE_100K" -ge 400 ]]; then
- echo "<context-status>Context: ~${FREE_100K}k tokens remaining (${USAGE_PCT}% used of ${TOTAL_K}k). Comfortable — continue normally.</context-status>"
-elif [[ "$FREE_100K" -ge 200 ]]; then
- echo "<context-status>Context: ~${FREE_100K}k tokens remaining (${USAGE_PCT}% used of ${TOTAL_K}k). Getting fuller — consider delegating heavy reads to sub-agents.</context-status>"
-elif [[ "$FREE_100K" -ge 100 ]]; then
- echo "<context-status>Context: ~${FREE_100K}k tokens remaining (${USAGE_PCT}% used of ${TOTAL_K}k). Running low — be surgical with file reads, delegate to sub-agents, checkpoint progress.</context-status>"
-else
- echo "<context-status>Context: ~${FREE_100K}k tokens remaining (${USAGE_PCT}% used of ${TOTAL_K}k). Critical — wrap up current task, save learnings, prepare for compaction.</context-status>"
-fi
-
-exit 0
diff --git a/tools/statusline-npm/scripts/install.sh b/tools/statusline-npm/scripts/install.sh
deleted file mode 100755
index f09ee220..00000000
--- a/tools/statusline-npm/scripts/install.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/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"
-
-# Copy context awareness hook
-HOOK_SCRIPT="$SCRIPT_DIR/context-hook.sh"
-HOOK_INSTALL_PATH="$HOME/.claude/context-hook.sh"
-if [[ -f "$HOOK_SCRIPT" ]]; then
- cp "$HOOK_SCRIPT" "$HOOK_INSTALL_PATH"
- chmod +x "$HOOK_INSTALL_PATH"
- echo " Installed: $HOOK_INSTALL_PATH"
-fi
-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 "Context awareness hook installed at ~/.claude/context-hook.sh"
-echo "To enable it, add to your ~/.claude/settings.json:"
-echo ' "hooks": { "UserPromptSubmit": [{ "matcher": "", "hooks": ['
-echo ' { "type": "command", "command": "bash ~/.claude/context-hook.sh" }'
-echo ' ]}]}'
-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.js
deleted file mode 100755
index df381d1e..00000000
--- a/tools/statusline-npm/scripts/statusline.js
+++ /dev/null
@@ -1,258 +0,0 @@
-#!/usr/bin/env node
-
-// Claude Code Custom Status Line — Context Bricks
-// v4.1.1 - Rate limits, git caching, context awareness hook
-//
-// Line 1: [Model:style] repo:branch status | @agent | wt
-// Line 2: [commit] message | +lines/-lines
-// Line 3: [■■■■□□□□] 73%! | 52k free | 2h15m | $12.50 | 5h:23% 7d:41%
-
-const { execFileSync } = require('child_process');
-const fs = require('fs');
-const path = require('path');
-
-// 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',
-};
-
-// ── Git caching (5-second stale pattern from Claude Code docs) ──
-
-const GIT_CACHE_FILE = '/tmp/contextbricks-git-cache.json';
-const GIT_CACHE_MAX_AGE = 5; // seconds
-
-function gitCacheIsStale() {
- try {
- if (!fs.existsSync(GIT_CACHE_FILE)) return true;
- const age = (Date.now() / 1000) - fs.statSync(GIT_CACHE_FILE).mtimeMs / 1000;
- return age > GIT_CACHE_MAX_AGE;
- } catch {
- return true;
- }
-}
-
-// Safe git command execution
-function git(...args) {
- try {
- return execFileSync('git', args, { encoding: 'utf8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'] }).trim();
- } catch {
- return '';
- }
-}
-
-function getGitInfo(currentDir) {
- // Check cache first
- if (!gitCacheIsStale()) {
- try {
- const cached = JSON.parse(fs.readFileSync(GIT_CACHE_FILE, 'utf8'));
- // Only use cache if same directory
- if (cached.dir === currentDir) return cached;
- } catch { /* cache corrupt, refresh */ }
- }
-
- // Fresh git data
- const isGit = git('rev-parse', '--git-dir') !== '';
- const info = { dir: currentDir, isGit, repoName: '', branch: '', commitShort: '', commitMsg: '', gitStatus: '', inWorktree: false };
-
- if (!isGit) {
- try { fs.writeFileSync(GIT_CACHE_FILE, JSON.stringify(info)); } catch {}
- return info;
- }
-
- const toplevel = git('rev-parse', '--show-toplevel');
- info.repoName = toplevel ? toplevel.split('/').pop().split('\\').pop() : '';
- info.branch = git('branch', '--show-current') || 'detached';
- info.commitShort = git('rev-parse', '--short', 'HEAD');
- info.commitMsg = git('log', '-1', '--pretty=%s').slice(0, 50);
-
- // Worktree detection
- const gitDir = git('rev-parse', '--git-dir');
- info.inWorktree = gitDir.includes('/worktrees/') || gitDir.includes('\\worktrees\\');
-
- // Status
- const porcelain = git('status', '--porcelain');
- if (porcelain) info.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) info.gitStatus += `\u2191${ahead}`;
- if (behind > 0) info.gitStatus += `\u2193${behind}`;
- }
-
- // Cache it
- try { fs.writeFileSync(GIT_CACHE_FILE, JSON.stringify(info)); } catch {}
-
- return info;
-}
-
-function main(data) {
- // Parse Claude data
- const model = (data.model?.display_name || 'Claude').replace('Claude ', '');
- // Prefer project_dir (launch dir) over cwd (which can change)
- const projectDir = data.workspace?.project_dir || data.workspace?.current_dir || process.env.PWD || process.cwd();
- 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.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 for git commands
- try { process.chdir(currentDir); } catch { /* stay where we are */ }
-
- // Git info (cached)
- const gi = getGitInfo(currentDir);
-
- // ── Line 1: Session identity ──────────────────────────────
- let line1 = '';
- line1 += styleAbbrev
- ? `${c.cyan}[${model}:${styleAbbrev}]${c.reset}`
- : `${c.cyan}[${model}]${c.reset}`;
-
- if (gi.repoName) {
- line1 += ` ${c.green}${gi.repoName}${c.reset}`;
- if (gi.branch) line1 += `:${c.blue}${gi.branch}${c.reset}`;
- }
-
- if (gi.gitStatus) line1 += ` ${c.red}${gi.gitStatus}${c.reset}`;
- if (agentName) line1 += ` | ${c.magenta}@${agentName}${c.reset}`;
- if (gi.inWorktree) line1 += ` | ${c.yellow}wt${c.reset}`;
-
- // ── Line 2: Git state ─────────────────────────────────────
- let line2 = '';
- if (gi.commitShort) {
- line2 += `${c.dim}[${c.reset}${c.yellowDim}${gi.commitShort}${c.reset}${c.dim}]${c.reset}`;
- if (gi.commitMsg) line2 += ` ${gi.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);
- // remaining_percentage can be absent while used_percentage is set; derive it rather than showing 0k free
- const remainingPct = Math.floor(remainingPctRaw != null ? remainingPctRaw : 100 - usedPctRaw);
- 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}`;
- }
-
- // Rate limits (Pro/Max subscribers)
- const rl5h = data.rate_limits?.five_hour?.used_percentage;
- const rl7d = data.rate_limits?.seven_day?.used_percentage;
- if (rl5h != null || rl7d != null) {
- let rlParts = [];
- if (rl5h != null) {
- const rlColor = rl5h >= 80 ? c.red : rl5h >= 50 ? c.yellowDim : c.dim;
- rlParts.push(`${rlColor}5h:${Math.round(rl5h)}%${c.reset}`);
- }
- if (rl7d != null) {
- const rlColor = rl7d >= 80 ? c.red : rl7d >= 50 ? c.yellowDim : c.dim;
- rlParts.push(`${rlColor}7d:${Math.round(rl7d)}%${c.reset}`);
- }
- line3 += ` | ${rlParts.join(' ')}`;
- }
-
- // Persist context level for hooks (rounded to nearest 100k)
- try {
- const contextFile = path.join(process.env.HOME || '', '.claude', 'context-level.json');
- const free100k = Math.floor(freeTokens / 100000) * 100; // e.g. 700 for 760k
- fs.writeFileSync(contextFile, JSON.stringify({
- freeK: freeK,
- free100k: free100k,
- usagePct: usagePct,
- totalK: Math.floor(totalTokens / 1000),
- ts: Date.now()
- }));
- } catch { /* non-critical — don't break the statusline */ }
-
- // 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.sh
deleted file mode 100755
index b7af6413..00000000
--- a/tools/statusline-npm/scripts/statusline.sh
+++ /dev/null
@@ -1,215 +0,0 @@
-#!/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.sh
deleted file mode 100755
index 6db23dbe..00000000
--- a/tools/statusline-npm/scripts/uninstall.sh
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/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"