This guide covers deploying the AIUsage server and connecting devices. For AI-assisted deployment, see the skills/ directory — each skill is in its own folder with YAML frontmatter.
AIUsage has two components to set up:
- Server — A Cloudflare Worker + D1 database that receives data and hosts the dashboard
- Controller — A CLI tool installed on each device that scans AI tool logs and syncs data
Device 01 ──sync──▶ Cloudflare Worker ──▶ Dashboard
Device 02 ──sync──▶ + D1 DB
Device 03 ──sync──▶
- Node.js >= 18
- pnpm
- A Cloudflare account (free tier is enough)
git clone https://github.com/ennann/aiusage.git
cd aiusage
pnpm install
npx wrangler login
pnpm setupThe setup wizard will:
- Check prerequisites
- Ask for Worker name, database name, and other options
- Generate all required secrets (SITE_ID, ENROLL_TOKEN, etc.)
- Create the D1 database and run migrations
- Build the Dashboard and Worker
- Deploy to Cloudflare Workers
After completion, you'll see:
- Dashboard URL — your public dashboard
- SITE_ID — your deployment identifier
- ENROLL_TOKEN — the secret for registering devices
Save these values. The wizard also writes them to .credentials in the repo root.
Click to expand manual steps
git clone https://github.com/ennann/aiusage.git
cd aiusage
pnpm installnpx wrangler loginnpx wrangler d1 create aiusage-dbCopy the database_id from the output.
Copy the template and fill in your database ID:
cp packages/worker/wrangler.jsonc.example packages/worker/wrangler.jsoncEdit packages/worker/wrangler.jsonc:
- Replace
your-worker-namewith your preferred name - Replace
your-d1-database-idwith the UUID from step 3
cd packages/worker
npx wrangler secret put SITE_ID # e.g., site_a1b2c3d4
npx wrangler secret put ENROLL_TOKEN # any strong random string
npx wrangler secret put DEVICE_TOKEN_SECRET # a long random string (64+ chars)
npx wrangler secret put PROJECT_NAME_SALT # any random stringnpx wrangler d1 migrations apply aiusage-db --remotecd <repo-root>
pnpm build
cd packages/worker
npx wrangler deploynpm install -g @aiusage/cliaiusage enroll \
--server https://your-worker.example.com \
--site-id <SITE_ID> \
--enroll-token <ENROLL_TOKEN> \
--device-name "My MacBook"aiusage sync --todayaiusage schedule # default: every 5 minutes
aiusage schedule on --every 1h # custom intervalaiusage doctorRepeat on every machine you want to track.
| Command | Description |
|---|---|
aiusage report [--tool TOOL] [--range 7d|1m|3m|6m|all] [--json] |
Local usage report with cost estimates |
aiusage scan [--tool TOOL] [--date YYYY-MM-DD|--range 6m] [--json] |
Scan one tool, date, or range |
aiusage trae sync [--edition cn|intl|all] [--since 180] |
Cache Trae CN local or international account usage |
aiusage sync [--today] [--lookback N] [--date YYYY-MM-DD] |
Upload data to server |
aiusage schedule [on|off|status] [--every 5m] |
Manage auto-sync |
aiusage enroll --server URL --site-id ID --enroll-token TOKEN |
Register device |
aiusage init --server URL --site-id ID |
Initialize local config |
aiusage health |
Test server connectivity |
aiusage doctor |
Run diagnostic checks |
aiusage config set <key> <value> |
Update local settings |
| Key | Example | Description |
|---|---|---|
device.alias |
"MacBook Pro" |
Device display name |
privacy.projectVisibility |
masked |
masked / hidden / plain |
project.alias <path> <name> |
/path/to/proj MyProj |
Map path to readable name |
Only aggregated token counts are uploaded — never conversation content.
Project names on the public dashboard support three modes:
| Mode | Behavior |
|---|---|
masked (default) |
Stable pseudonyms like Project A1F4 via HMAC |
hidden |
Project dimension not shown |
plain |
Real project names (private deployments only) |
Configure at two levels:
- Server-wide:
PUBLIC_PROJECT_VISIBILITYinwrangler.jsonc - Per-device:
aiusage config set privacy.projectVisibility <mode>
| Method | Path | Description |
|---|---|---|
| GET | /api/v1/health |
Connectivity check |
| POST | /api/v1/enroll |
Register a new device |
| POST | /api/v1/ingest/daily |
Upload daily usage data |
| Method | Path | Description |
|---|---|---|
| GET | /api/v1/public/overview?range=7d |
Summary and daily trend |
| GET | /api/v1/public/breakdowns?range=7d&limit=50 |
Detailed breakdowns |
The controller automatically detects and scans all installed tools:
| Tool | Provider | Usage Source |
|---|---|---|
| Claude Code | Anthropic / compatible wrappers | ~/.config/claude/projects/, ~/.claude/projects/ |
| Codex CLI | OpenAI | ~/.codex/sessions/, ~/.codex/archived_sessions/ |
| Cursor | Cursor | Local state.vscdb credential + Cursor usage CSV API |
| Copilot CLI | GitHub | ~/.copilot/otel/, ~/.copilot/session-state/ |
| Copilot for VS Code | GitHub | VS Code logs and User/workspaceStorage/**/chatSessions/*.{json,jsonl} |
| Gemini CLI | ~/.gemini/tmp/ |
|
| Antigravity | ~/.gemini/antigravity/ interaction metadata |
|
| Amp | Model provider (Sourcegraph product) | ~/.local/share/amp/threads/ |
| Kimi Code | Moonshot | $KIMI_CODE_HOME/sessions/ (default ~/.kimi-code/sessions/) |
| Kimi CLI (legacy) | Moonshot | ~/.kimi/sessions/ |
| Trae CN | Trae / underlying model provider | aiusage trae sync --edition cn → ~/.aiusage/trae-cache/sessions/ (official local ai-agent RPC) |
| Trae / Trae Solo (international) | Trae / underlying model provider | aiusage trae sync --edition intl --since 180 → ~/.aiusage/trae-cache/intl/sessions/ (official account API); tokscale caches remain compatible |
| Qwen Code | Alibaba | ~/.qwen/projects/, legacy ~/.qwen/tmp/ |
| Droid | Factory | ~/.factory/sessions/*.settings.json |
| OpenCode | OpenCode / underlying model provider | $XDG_DATA_HOME/opencode/opencode*.db (v1 message + v2 session_message), legacy storage/message/; supports OPENCODE_DB and configured extra paths |
| Pi / Oh My Pi | Multiple | ~/.pi/agent/sessions/, ~/.omp/agent/sessions/ |
The scanner implementations are compatibility-audited against the overlapping MIT-licensed tokscale parsers. Some legacy IDE artifacts expose interaction timestamps but no reliable token counters; AIUsage keeps those as zero-token activity instead of estimating billable usage from conversation content.