aiblueprint-cli 1.1.4 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +496 -41
- package/claude-code-config/agents/action.md +36 -0
- package/claude-code-config/agents/explore-codebase.md +6 -0
- package/claude-code-config/agents/explore-docs.md +88 -0
- package/claude-code-config/agents/fix-grammar.md +49 -0
- package/claude-code-config/agents/snipper.md +2 -0
- package/claude-code-config/agents/websearch.md +1 -0
- package/claude-code-config/commands/commit.md +1 -1
- package/claude-code-config/commands/debug.md +91 -0
- package/claude-code-config/commands/epct/code.md +171 -0
- package/claude-code-config/commands/epct/deploy.md +116 -0
- package/claude-code-config/commands/epct/explore.md +97 -0
- package/claude-code-config/commands/epct/plan.md +132 -0
- package/claude-code-config/commands/epct/tasks.md +206 -0
- package/claude-code-config/commands/explore.md +45 -0
- package/claude-code-config/commands/melvynx-plugin.md +1 -0
- package/claude-code-config/commands/oneshot.md +57 -0
- package/claude-code-config/hooks/hooks.json +15 -0
- package/claude-code-config/scripts/statusline/CLAUDE.md +178 -0
- package/claude-code-config/scripts/statusline/README.md +105 -0
- package/claude-code-config/scripts/statusline/biome.json +34 -0
- package/claude-code-config/scripts/statusline/bun.lockb +0 -0
- package/claude-code-config/scripts/statusline/data/.gitignore +5 -0
- package/claude-code-config/scripts/statusline/fixtures/test-input.json +25 -0
- package/claude-code-config/scripts/statusline/package.json +21 -0
- package/claude-code-config/scripts/statusline/src/commands/CLAUDE.md +3 -0
- package/claude-code-config/scripts/statusline/src/commands/spend-month.ts +60 -0
- package/claude-code-config/scripts/statusline/src/commands/spend-today.ts +42 -0
- package/claude-code-config/scripts/statusline/src/index.ts +141 -0
- package/claude-code-config/scripts/statusline/src/lib/context.ts +103 -0
- package/claude-code-config/scripts/statusline/src/lib/formatters.ts +218 -0
- package/claude-code-config/scripts/statusline/src/lib/git.ts +100 -0
- package/claude-code-config/scripts/statusline/src/lib/spend.ts +119 -0
- package/claude-code-config/scripts/statusline/src/lib/types.ts +25 -0
- package/claude-code-config/scripts/statusline/src/lib/usage-limits.ts +147 -0
- package/claude-code-config/scripts/statusline/statusline.config.ts +122 -0
- package/claude-code-config/scripts/statusline/test.ts +20 -0
- package/claude-code-config/scripts/statusline/tsconfig.json +27 -0
- package/dist/cli.js +722 -256
- package/package.json +1 -2
- package/claude-code-config/output-styles/assistant.md +0 -15
- package/claude-code-config/output-styles/honnest.md +0 -9
- package/claude-code-config/output-styles/senior-dev.md +0 -14
- package/claude-code-config/scripts/statusline-ccusage.sh +0 -188
- package/claude-code-config/scripts/statusline.readme.md +0 -194
- /package/claude-code-config/{hooks → scripts}/hook-post-file.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiblueprint-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "AIBlueprint CLI for setting up Claude Code configurations",
|
|
5
5
|
"author": "AIBlueprint",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
"keywords": [
|
|
48
48
|
"claude",
|
|
49
49
|
"claude-code",
|
|
50
|
-
"cli",
|
|
51
50
|
"aiblueprint",
|
|
52
51
|
"developer-tools"
|
|
53
52
|
]
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Assistant
|
|
3
|
-
description: Helpful assistant that help me work on my todos, my week planing, my tasks
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
You are a professional assistant name "Bob".
|
|
7
|
-
|
|
8
|
-
Communicate like you're talking to an old friend.
|
|
9
|
-
|
|
10
|
-
- Always be honest and don't be afraid to hurt me.
|
|
11
|
-
- Schedule my week like a professional assistant by doing what I ask you.
|
|
12
|
-
- Challenge my organization if you see something wrong.
|
|
13
|
-
- Always try to optimize my tasks.
|
|
14
|
-
- Write in a friendly style, like you're talking to a friend.
|
|
15
|
-
- Don't use emojis.
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Honest Friend
|
|
3
|
-
description: You are my childhood friend who is now a successful businessman
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
- You are a really good friend of mine
|
|
7
|
-
- You are honest with me; when something is not good, you can tell me without feeling bad
|
|
8
|
-
- You don't need to be friendly with me; honesty is more important because you know me well
|
|
9
|
-
- You write like we are in Whats'app messages
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: senior-dev
|
|
3
|
-
description: Casual, direct communication like talking with senior engineering teammates
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Communicate like you're talking with a senior engineering team member:
|
|
7
|
-
|
|
8
|
-
- Keep it casual and conversational - no formal language or corporate speak
|
|
9
|
-
- Be direct and straight to the point - no long explanations unless absolutely needed
|
|
10
|
-
- Don't use uppercase for emphasis - just normal sentence case.
|
|
11
|
-
- IMPORTANT : Never use Uppercase, write in lowercase.
|
|
12
|
-
- IMPORTANT : Never use emojis. Write straight.
|
|
13
|
-
- Assume the person knows their stuff - don't over-explain basic concepts
|
|
14
|
-
- When something is wrong, just say it's wrong - no need to soften it
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# ANSI color codes
|
|
4
|
-
GREEN='\033[0;32m'
|
|
5
|
-
RED='\033[0;31m'
|
|
6
|
-
PURPLE='\033[0;35m'
|
|
7
|
-
GRAY='\033[0;90m'
|
|
8
|
-
LIGHT_GRAY='\033[0;37m'
|
|
9
|
-
RESET='\033[0m'
|
|
10
|
-
|
|
11
|
-
# Read JSON input from stdin
|
|
12
|
-
input=$(cat)
|
|
13
|
-
|
|
14
|
-
# Extract current session ID and model info from Claude Code input
|
|
15
|
-
session_id=$(echo "$input" | jq -r '.session_id // empty')
|
|
16
|
-
model_name=$(echo "$input" | jq -r '.model.display_name // empty')
|
|
17
|
-
current_dir=$(echo "$input" | jq -r '.workspace.current_dir // empty')
|
|
18
|
-
cwd=$(echo "$input" | jq -r '.cwd // empty')
|
|
19
|
-
output_style=$(echo "$input" | jq -r '.output_style.name // empty')
|
|
20
|
-
|
|
21
|
-
# Extract cost data from Claude Code Status hook
|
|
22
|
-
session_cost_usd=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
|
|
23
|
-
session_duration_ms=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')
|
|
24
|
-
|
|
25
|
-
# Get current git branch with error handling
|
|
26
|
-
if git rev-parse --git-dir >/dev/null 2>&1; then
|
|
27
|
-
branch=$(git branch --show-current 2>/dev/null || echo "detached")
|
|
28
|
-
if [ -z "$branch" ]; then
|
|
29
|
-
branch="detached"
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
# Check for pending changes (staged or unstaged)
|
|
33
|
-
if ! git diff-index --quiet HEAD -- 2>/dev/null || ! git diff-index --quiet --cached HEAD -- 2>/dev/null; then
|
|
34
|
-
# Get line changes for unstaged and staged changes
|
|
35
|
-
unstaged_stats=$(git diff --numstat 2>/dev/null | awk '{added+=$1; deleted+=$2} END {print added+0, deleted+0}')
|
|
36
|
-
staged_stats=$(git diff --cached --numstat 2>/dev/null | awk '{added+=$1; deleted+=$2} END {print added+0, deleted+0}')
|
|
37
|
-
|
|
38
|
-
# Parse the stats
|
|
39
|
-
unstaged_added=$(echo $unstaged_stats | cut -d' ' -f1)
|
|
40
|
-
unstaged_deleted=$(echo $unstaged_stats | cut -d' ' -f2)
|
|
41
|
-
staged_added=$(echo $staged_stats | cut -d' ' -f1)
|
|
42
|
-
staged_deleted=$(echo $staged_stats | cut -d' ' -f2)
|
|
43
|
-
|
|
44
|
-
# Total changes
|
|
45
|
-
total_added=$((unstaged_added + staged_added))
|
|
46
|
-
total_deleted=$((unstaged_deleted + staged_deleted))
|
|
47
|
-
|
|
48
|
-
# Build the branch display with changes (with colors)
|
|
49
|
-
changes=""
|
|
50
|
-
if [ $total_added -gt 0 ]; then
|
|
51
|
-
changes="${GREEN}+$total_added${RESET}"
|
|
52
|
-
fi
|
|
53
|
-
if [ $total_deleted -gt 0 ]; then
|
|
54
|
-
if [ -n "$changes" ]; then
|
|
55
|
-
changes="$changes ${RED}-$total_deleted${RESET}"
|
|
56
|
-
else
|
|
57
|
-
changes="${RED}-$total_deleted${RESET}"
|
|
58
|
-
fi
|
|
59
|
-
fi
|
|
60
|
-
|
|
61
|
-
if [ -n "$changes" ]; then
|
|
62
|
-
branch="$branch${PURPLE}*${RESET} ($changes)"
|
|
63
|
-
else
|
|
64
|
-
branch="$branch${PURPLE}*${RESET}"
|
|
65
|
-
fi
|
|
66
|
-
fi
|
|
67
|
-
else
|
|
68
|
-
branch="no-git"
|
|
69
|
-
fi
|
|
70
|
-
|
|
71
|
-
# Use full path but replace home directory with ~
|
|
72
|
-
dir_path="$current_dir"
|
|
73
|
-
if [[ "$dir_path" == "$HOME"* ]]; then
|
|
74
|
-
dir_path="~${dir_path#$HOME}"
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
# Get today's date in YYYYMMDD format
|
|
78
|
-
today=$(date +%Y%m%d)
|
|
79
|
-
|
|
80
|
-
# Function to format numbers
|
|
81
|
-
format_cost() {
|
|
82
|
-
printf "%.2f" "$1"
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
format_tokens() {
|
|
86
|
-
local tokens=$1
|
|
87
|
-
if [ "$tokens" -ge 1000000 ]; then
|
|
88
|
-
printf "%.1fM" "$(echo "scale=1; $tokens / 1000000" | bc -l)"
|
|
89
|
-
elif [ "$tokens" -ge 1000 ]; then
|
|
90
|
-
printf "%.1fK" "$(echo "scale=1; $tokens / 1000" | bc -l)"
|
|
91
|
-
else
|
|
92
|
-
printf "%d" "$tokens"
|
|
93
|
-
fi
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
format_time() {
|
|
97
|
-
local minutes=$1
|
|
98
|
-
local hours=$((minutes / 60))
|
|
99
|
-
local mins=$((minutes % 60))
|
|
100
|
-
if [ "$hours" -gt 0 ]; then
|
|
101
|
-
printf "%dh %dm" "$hours" "$mins"
|
|
102
|
-
else
|
|
103
|
-
printf "%dm" "$mins"
|
|
104
|
-
fi
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
format_duration_ms() {
|
|
108
|
-
local ms=$1
|
|
109
|
-
local minutes=$((ms / 60000))
|
|
110
|
-
format_time "$minutes"
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
# Initialize variables with defaults
|
|
114
|
-
session_cost="0.00"
|
|
115
|
-
session_tokens=0
|
|
116
|
-
daily_cost="0.00"
|
|
117
|
-
block_cost="0.00"
|
|
118
|
-
remaining_time="N/A"
|
|
119
|
-
session_duration=""
|
|
120
|
-
|
|
121
|
-
# Use Claude Code cost data if available, otherwise fallback to ccusage
|
|
122
|
-
if [ "$session_cost_usd" != "0" ] && [ "$session_cost_usd" != "null" ]; then
|
|
123
|
-
session_cost="$session_cost_usd"
|
|
124
|
-
if [ "$session_duration_ms" != "0" ] && [ "$session_duration_ms" != "null" ]; then
|
|
125
|
-
session_duration=$(format_duration_ms "$session_duration_ms")
|
|
126
|
-
fi
|
|
127
|
-
fi
|
|
128
|
-
|
|
129
|
-
# Always get session tokens from ccusage when session_id is available
|
|
130
|
-
if command -v ccusage >/dev/null 2>&1 && [ -n "$session_id" ] && [ "$session_id" != "empty" ]; then
|
|
131
|
-
# Use the new ccusage session --id functionality to get session data
|
|
132
|
-
session_data=$(ccusage session --id "$session_id" --json 2>/dev/null)
|
|
133
|
-
|
|
134
|
-
if [ $? -eq 0 ] && [ -n "$session_data" ] && [ "$session_data" != "null" ]; then
|
|
135
|
-
# If we don't have cost from Claude Code, get it from ccusage
|
|
136
|
-
if [ "$session_cost" = "0.00" ] || [ "$session_cost" = "0" ]; then
|
|
137
|
-
session_cost=$(echo "$session_data" | jq -r '.totalCost // 0')
|
|
138
|
-
fi
|
|
139
|
-
# Calculate only input + output tokens (exclude cache tokens for meaningful display)
|
|
140
|
-
session_tokens=$(echo "$session_data" | jq -r '.entries | map(.inputTokens + .outputTokens) | add // 0')
|
|
141
|
-
fi
|
|
142
|
-
fi
|
|
143
|
-
|
|
144
|
-
if command -v ccusage >/dev/null 2>&1; then
|
|
145
|
-
# Get daily data
|
|
146
|
-
daily_data=$(ccusage daily --json --since "$today" 2>/dev/null)
|
|
147
|
-
if [ $? -eq 0 ] && [ -n "$daily_data" ]; then
|
|
148
|
-
daily_cost=$(echo "$daily_data" | jq -r '.totals.totalCost // 0')
|
|
149
|
-
fi
|
|
150
|
-
|
|
151
|
-
# Get active block data
|
|
152
|
-
block_data=$(ccusage blocks --active --json 2>/dev/null)
|
|
153
|
-
if [ $? -eq 0 ] && [ -n "$block_data" ]; then
|
|
154
|
-
active_block=$(echo "$block_data" | jq -r '.blocks[] | select(.isActive == true) // empty')
|
|
155
|
-
if [ -n "$active_block" ] && [ "$active_block" != "null" ]; then
|
|
156
|
-
block_cost=$(echo "$active_block" | jq -r '.costUSD // 0')
|
|
157
|
-
remaining_minutes=$(echo "$active_block" | jq -r '.projection.remainingMinutes // 0')
|
|
158
|
-
if [ "$remaining_minutes" != "0" ] && [ "$remaining_minutes" != "null" ]; then
|
|
159
|
-
remaining_time=$(format_time "$remaining_minutes")
|
|
160
|
-
fi
|
|
161
|
-
fi
|
|
162
|
-
fi
|
|
163
|
-
fi
|
|
164
|
-
|
|
165
|
-
# Format the output
|
|
166
|
-
formatted_session_cost=$(format_cost "$session_cost")
|
|
167
|
-
formatted_daily_cost=$(format_cost "$daily_cost")
|
|
168
|
-
formatted_block_cost=$(format_cost "$block_cost")
|
|
169
|
-
formatted_tokens=$(format_tokens "$session_tokens")
|
|
170
|
-
|
|
171
|
-
# Build the first line: branch / style / folder / model
|
|
172
|
-
first_line="${LIGHT_GRAY}🌿 $branch ${GRAY}|${LIGHT_GRAY} 💄 $output_style ${GRAY}|${LIGHT_GRAY} 📁 $dir_path ${GRAY}|${LIGHT_GRAY} 🤖 $model_name${RESET}"
|
|
173
|
-
|
|
174
|
-
# Build the second line: pricing and tokens
|
|
175
|
-
session_cost_display="\$$formatted_session_cost"
|
|
176
|
-
if [ -n "$session_duration" ]; then
|
|
177
|
-
session_cost_display="$session_cost_display ${GRAY}($session_duration)${LIGHT_GRAY}"
|
|
178
|
-
fi
|
|
179
|
-
|
|
180
|
-
second_line="${LIGHT_GRAY}💰 $session_cost_display ${GRAY}|${LIGHT_GRAY} 📅 \$$formatted_daily_cost ${GRAY}|${LIGHT_GRAY} 🧊 \$$formatted_block_cost"
|
|
181
|
-
|
|
182
|
-
if [ "$remaining_time" != "N/A" ]; then
|
|
183
|
-
second_line="$second_line ($remaining_time left)"
|
|
184
|
-
fi
|
|
185
|
-
|
|
186
|
-
second_line="$second_line ${GRAY}|${LIGHT_GRAY} 🧩 ${formatted_tokens} ${GRAY}tokens${RESET}"
|
|
187
|
-
|
|
188
|
-
printf "%b\n%b\n" "$first_line" "$second_line"
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
# Claude Code Statusline with ccusage Integration
|
|
2
|
-
|
|
3
|
-
A custom statusline script that integrates with [ccusage](https://github.com/ryoppippi/ccusage) to display real-time Claude Code usage statistics, including session costs, daily usage, and token counts.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🌿 **Git branch status** with change indicators (+/-)
|
|
8
|
-
- 📁 **Current directory** name
|
|
9
|
-
- 🤖 **Claude model** being used
|
|
10
|
-
- 💰 **Session cost** for current conversation
|
|
11
|
-
- 📅 **Daily cost** total
|
|
12
|
-
- 🧊 **Block cost** with remaining time
|
|
13
|
-
- 🧩 **Token count** for current session (input + output only)
|
|
14
|
-
|
|
15
|
-
## Requirements
|
|
16
|
-
|
|
17
|
-
- [ccusage](https://github.com/ryoppippi/ccusage) v15.9.4 or later (for `--id` support)
|
|
18
|
-
- `jq` for JSON parsing
|
|
19
|
-
- `git` for repository information
|
|
20
|
-
|
|
21
|
-
## Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
# Install ccusage
|
|
25
|
-
npm install -g ccusage
|
|
26
|
-
|
|
27
|
-
# Make script executable
|
|
28
|
-
chmod +x statusline-ccusage.sh
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
32
|
-
|
|
33
|
-
The script expects Claude Code input format via stdin:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
echo '{"session_id":"your-session-id","model":{"display_name":"Claude 3.5 Sonnet"},"workspace":{"current_dir":"/path/to/project"}}' | ./statusline-ccusage.sh
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## How It Works
|
|
40
|
-
|
|
41
|
-
### Session Data Retrieval
|
|
42
|
-
|
|
43
|
-
The script uses the new `ccusage session --id` functionality (added in ccusage v15.9.4) to fetch session data:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
ccusage session --id "$session_id" --json
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
This returns detailed session information including:
|
|
50
|
-
- Total cost for the session
|
|
51
|
-
- Individual message entries with token counts
|
|
52
|
-
- Cache usage statistics
|
|
53
|
-
|
|
54
|
-
### Token Calculation
|
|
55
|
-
|
|
56
|
-
**Important**: The script calculates only meaningful conversation tokens:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
# Only input + output tokens (excludes cache tokens)
|
|
60
|
-
session_tokens=$(echo "$session_data" | jq -r '.entries | map(.inputTokens + .outputTokens) | add // 0')
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**Why exclude cache tokens?**
|
|
64
|
-
- Cache tokens represent context being stored/reused internally
|
|
65
|
-
- They don't represent the actual conversation size
|
|
66
|
-
- Including them inflates counts (e.g., 433K vs 2.7K tokens)
|
|
67
|
-
- For statusline display, conversation tokens are more meaningful
|
|
68
|
-
|
|
69
|
-
## Finding Your Claude Code Session ID
|
|
70
|
-
|
|
71
|
-
### Method 1: From Session Files
|
|
72
|
-
|
|
73
|
-
Session IDs are stored as `.jsonl` files in your Claude directory:
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
# Find recent session files
|
|
77
|
-
find ~/.claude -name "*.jsonl" | head -5
|
|
78
|
-
|
|
79
|
-
# Example output:
|
|
80
|
-
# /Users/user/.claude/projects/project-name/428e9ec6-86f3-43c1-a0cd-9a3986d82229.jsonl
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
The session ID is the UUID part: `428e9ec6-86f3-43c1-a0cd-9a3986d82229`
|
|
84
|
-
|
|
85
|
-
### Method 2: From ccusage Session List
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
# List all sessions to see available IDs
|
|
89
|
-
ccusage session
|
|
90
|
-
|
|
91
|
-
# The session names in the first column can sometimes be used as IDs
|
|
92
|
-
# But UUID-based IDs are more reliable
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Method 3: Test with Known Session
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
# Test if a session ID works
|
|
99
|
-
ccusage session --id "your-session-id" --json
|
|
100
|
-
|
|
101
|
-
# Returns session data if valid, or null if not found
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Testing the Script
|
|
105
|
-
|
|
106
|
-
### 1. Test with a Real Session ID
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
# Find a session ID
|
|
110
|
-
SESSION_ID=$(find ~/.claude -name "*.jsonl" | head -1 | xargs basename -s .jsonl)
|
|
111
|
-
|
|
112
|
-
# Test the script
|
|
113
|
-
echo "{\"session_id\":\"$SESSION_ID\",\"model\":{\"display_name\":\"Claude 3.5 Sonnet\"},\"workspace\":{\"current_dir\":\"$(pwd)\"}}" | ./statusline-ccusage.sh
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### 2. Test Individual Components
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
# Test session data retrieval
|
|
120
|
-
ccusage session --id "your-session-id" --json
|
|
121
|
-
|
|
122
|
-
# Test token calculation
|
|
123
|
-
ccusage session --id "your-session-id" --json | jq '.entries | map(.inputTokens + .outputTokens) | add'
|
|
124
|
-
|
|
125
|
-
# Test daily usage
|
|
126
|
-
ccusage daily --json --since "$(date +%Y%m%d)"
|
|
127
|
-
|
|
128
|
-
# Test active blocks
|
|
129
|
-
ccusage blocks --active --json
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### 3. Expected Output
|
|
133
|
-
|
|
134
|
-
The statusline should display something like:
|
|
135
|
-
```
|
|
136
|
-
🌿 main* (+15 -3) | 📁 project-name | 🤖 Claude 3.5 Sonnet | 💰 $0.26 / 📅 $8.03 / 🧊 $8.03 (2h 45m left) | 🧩 2.7K tokens
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
## Troubleshooting
|
|
140
|
-
|
|
141
|
-
### ccusage Version Issues
|
|
142
|
-
|
|
143
|
-
Ensure you have the latest version with `--id` support:
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
# Check version (needs 15.9.4+)
|
|
147
|
-
ccusage --version
|
|
148
|
-
|
|
149
|
-
# Update if needed
|
|
150
|
-
npm update -g ccusage
|
|
151
|
-
|
|
152
|
-
# Verify --id option exists
|
|
153
|
-
ccusage session --help | grep -A5 -B5 "id"
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Session ID Not Found
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
# Returns null - session doesn't exist
|
|
160
|
-
ccusage session --id "invalid-id" --json
|
|
161
|
-
|
|
162
|
-
# Check if session files exist
|
|
163
|
-
ls ~/.claude/projects/*/your-session-id.jsonl
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
### Permission Issues
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
# Make script executable
|
|
170
|
-
chmod +x statusline-ccusage.sh
|
|
171
|
-
|
|
172
|
-
# Check file permissions
|
|
173
|
-
ls -la statusline-ccusage.sh
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Integration with Claude Code
|
|
177
|
-
|
|
178
|
-
This script is designed to work with Claude Code's statusline feature. Configure it in your Claude Code settings to display real-time usage information during your coding sessions.
|
|
179
|
-
|
|
180
|
-
## What We Improved
|
|
181
|
-
|
|
182
|
-
### Before (Custom Logic)
|
|
183
|
-
- 50+ lines of complex session file parsing
|
|
184
|
-
- Manual JSONL file searching and parsing
|
|
185
|
-
- Inconsistent cost calculations
|
|
186
|
-
- Included cache tokens (inflated counts)
|
|
187
|
-
|
|
188
|
-
### After (ccusage Integration)
|
|
189
|
-
- ~10 lines using official ccusage API
|
|
190
|
-
- Reliable session data via `ccusage session --id`
|
|
191
|
-
- Consistent cost calculations matching ccusage
|
|
192
|
-
- Only meaningful conversation tokens displayed
|
|
193
|
-
|
|
194
|
-
The new approach is more maintainable, accurate, and leverages the official ccusage functionality instead of duplicating complex logic.
|
|
File without changes
|