From c4490425a6228d531daf2917005b15b4161aa74d Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 09:05:26 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 12 +++++++++ README.md | 3 +++ commands/spending-get.md | 32 +++++++++++++++++++++++ commands/spending-reset.md | 45 ++++++++++++++++++++++++++++++++ commands/spending-stats.md | 46 +++++++++++++++++++++++++++++++++ plugin.lock.json | 53 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 191 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/spending-get.md create mode 100644 commands/spending-reset.md create mode 100644 commands/spending-stats.md create mode 100644 plugin.lock.json diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..fe0b9a4 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "spending-tracker", + "description": "Track Claude Code API spending with daily and hourly breakdowns", + "version": "1.0.0", + "author": { + "name": "Fucheng Warren Zhu", + "email": "wzhu@college.harvard.edu" + }, + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..11a26a4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# spending-tracker + +Track Claude Code API spending with daily and hourly breakdowns diff --git a/commands/spending-get.md b/commands/spending-get.md new file mode 100644 index 0000000..f8aaa56 --- /dev/null +++ b/commands/spending-get.md @@ -0,0 +1,32 @@ +--- +description: Get current spending totals (daily, weekly, and hourly) +--- + +# Get Spending Totals + +Display current spending totals for today, this week, and the current hour. + +## Instructions + +1. **Execute command**: + - Run: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/track_spending.py --data-dir ${CLAUDE_PLUGIN_ROOT}/spending_data get --format text` + - Display the daily, weekly, and hourly spending totals + +2. **Format output**: + - Show daily total with date + - Show weekly total with week number + - Show hourly total with time period + - Use clear formatting for easy reading + +## Example Output + +``` +Daily: $5.25 +Weekly: $32.40 +Hourly: $1.32 +``` + +## Notes + +- No confirmation needed (read-only operation) +- Data is read from `${CLAUDE_PLUGIN_ROOT}/spending_data/` diff --git a/commands/spending-reset.md b/commands/spending-reset.md new file mode 100644 index 0000000..6e4d655 --- /dev/null +++ b/commands/spending-reset.md @@ -0,0 +1,45 @@ +--- +description: Reset all spending tracking data +--- + +# Reset Spending Data + +Reset all spending tracking data (daily, weekly, and hourly). This operation is destructive and cannot be undone. + +## Arguments + +Input: `$ARGUMENTS` + +## Instructions + +1. **Parse arguments**: + - Check if `--confirm` or `-f` flag is present in `$ARGUMENTS` + +2. **Ask for confirmation** (UNLESS `--confirm` or `-f` flag is present): + - Warn user: "⚠️ This will delete ALL spending tracking data (daily, weekly, and hourly). This cannot be undone." + - Show affected files: + - `${CLAUDE_PLUGIN_ROOT}/spending_data/daily.json` + - `${CLAUDE_PLUGIN_ROOT}/spending_data/weekly.json` + - `${CLAUDE_PLUGIN_ROOT}/spending_data/hourly.json` + - `${CLAUDE_PLUGIN_ROOT}/spending_data/session_state.json` + - Ask: "Are you sure you want to proceed? (yes/no)" + - If user responds "no" or anything other than "yes", abort + - If user responds "yes", proceed + +3. **Execute reset**: + - Run: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/track_spending.py --data-dir ${CLAUDE_PLUGIN_ROOT}/spending_data reset --confirm` + - Display success message + +## Example Usage + +``` +/spending-reset +/spending-reset --confirm +/spending-reset -f +``` + +## Notes + +- ALWAYS ask for confirmation unless `--confirm` or `-f` is provided +- This operation is irreversible +- Session state will also be cleared diff --git a/commands/spending-stats.md b/commands/spending-stats.md new file mode 100644 index 0000000..483d85f --- /dev/null +++ b/commands/spending-stats.md @@ -0,0 +1,46 @@ +--- +description: Show detailed spending statistics +--- + +# Spending Statistics + +Display detailed statistics about your Claude Code API spending, including historical data and averages. + +## Instructions + +1. **Execute command**: + - Run: `python3 ${CLAUDE_PLUGIN_ROOT}/scripts/track_spending.py --data-dir ${CLAUDE_PLUGIN_ROOT}/spending_data stats` + - Display the full statistics output + +2. **Show information**: + - Total days tracked + - Total spending across all days + - Average spending per day + - Total hours tracked + - Average spending per hour + - Current day and hour totals + +## Example Output + +``` +=== Spending Statistics === + +Daily Tracking: + Total days tracked: 15 + Total across all days: $123.45 + Average per day: $8.23 + +Hourly Tracking: + Total hours tracked: 89 + Total across all hours: $123.45 + Average per hour: $1.39 + +Current Period: + Today (2025-10-10): $12.34 + This hour (2025-10-10T12:00): $2.45 +``` + +## Notes + +- No confirmation needed (read-only operation) +- Historical data is kept for 30 days by default diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..c946893 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,53 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:WarrenZhu050413/Warren-Claude-Code-Plugin-Marketplace:spending-tracker-plugin", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "5dc8bd366bf018f4ec1d6ba5bf12a3705ebde996", + "treeHash": "c2e3baed87f7eb93773a37c1225ab67cf5fd7054acf56ca13b94e1c1a53dc5ed", + "generatedAt": "2025-11-28T10:12:56.509103Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "spending-tracker", + "description": "Track Claude Code API spending with daily and hourly breakdowns", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "f018f2f880c820dfc40edd506620a14ed570f6d0cb8367a7f8869e3f041324ab" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "29d9cac8174ab8434fd15c3ba7d61cdcbaa41ca3170fd1ee1db330f924c3c45a" + }, + { + "path": "commands/spending-get.md", + "sha256": "75e44ab5729f7ea55dbc3a2db344602f5a96b9d1e6c653585080d688c668face" + }, + { + "path": "commands/spending-reset.md", + "sha256": "b8a848ba22519c0e3a67cb89d61aec97b912d5a1ea2c33637bcc3515fad4336d" + }, + { + "path": "commands/spending-stats.md", + "sha256": "f0d1abde72233cb2003926f5f9ea39f6ac265532f5bb39f3be274c5c0ca73171" + } + ], + "dirSha256": "c2e3baed87f7eb93773a37c1225ab67cf5fd7054acf56ca13b94e1c1a53dc5ed" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file