@maol-1997/ai-usage
v1.0.3
Published
Upload local Claude Code and Codex usage to a private ingestion endpoint
Downloads
385
Readme
@maol-1997/ai-usage
Uploads local Claude Code and Codex token usage to a private ingestion endpoint without installing SwiftCode. The endpoint URL is required on every upload and is not built into this package.
It scans the official local history locations:
- Claude Code:
$CLAUDE_CONFIG_DIR/projects, or~/.claude/projectsby default. - Codex:
$CODEX_HOME/sessions, or~/.codex/sessionsby default.
On native Windows, ~ is %USERPROFILE%, so the defaults become %USERPROFILE%\.claude\projects and %USERPROFILE%\.codex\sessions. Linux and WSL use the current Linux user's home. When running inside WSL to scan data created by a native Windows installation, pass the mounted homes explicitly with --claude-home and --codex-home.
The CLI sends only token counts, model, timestamp, local day, cost, source, a deduplication hash, and the machine name. It never uploads prompts, responses, files, project paths, or session IDs.
Run
macOS and Linux:
AI_USAGE_TOKEN="your-token" npx @maol-1997/ai-usage --url "https://your-endpoint.example/ingest"Windows PowerShell:
$env:AI_USAGE_TOKEN="your-token"
npx @maol-1997/ai-usage --url "https://your-endpoint.example/ingest"Every run scans and resends all available local history, independently of SwiftCode's upload cursor. The endpoint deduplicates entries, so rerunning the command is safe. Use --dry-run to inspect how many entries would be sent. This scans the provider JSONL files, not SwiftCode's SQLite database, and does not upload plan reports.
npx @maol-1997/ai-usage@latest --dry-run
npx @maol-1997/ai-usage --url "https://your-endpoint.example/ingest" --source codex
npx @maol-1997/ai-usage --helpRequires Node.js 20 or newer.
Current release
Version 1.0.3 includes the current model pricing snapshot (including Claude Haiku 5.5), long-prompt rates for models that charge more past a prompt length, Priority/Fast pricing, applied Codex model and service-tier settings, and deduplication of repeated cumulative Codex token notifications. It sends usage revision 3 so the endpoint can correct older matching entries without duplicating history. Pricing is refreshed when the package is built for publication; installed releases use their bundled snapshot.
Path defaults follow the Claude Code application data documentation and Codex's official CODEX_HOME configuration.
