@juliantanx/aiusage 1.3.0 → 1.3.2

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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -27
  3. package/dist/index.js +1051 -123
  4. package/dist/web/_app/immutable/assets/10.BfaLSE4e.css +1 -0
  5. package/dist/web/_app/immutable/assets/13.CxRLR3o7.css +1 -0
  6. package/dist/web/_app/immutable/assets/2.BLunjqo3.css +1 -0
  7. package/dist/web/_app/immutable/assets/5.8Efnpu8u.css +1 -0
  8. package/dist/web/_app/immutable/assets/7.BeGOLIpG.css +1 -0
  9. package/dist/web/_app/immutable/assets/8.DMukHCtv.css +1 -0
  10. package/dist/web/_app/immutable/assets/9.DpWloLoX.css +1 -0
  11. package/dist/web/_app/immutable/assets/_page.8Efnpu8u.css +1 -0
  12. package/dist/web/_app/immutable/assets/_page.BeGOLIpG.css +1 -0
  13. package/dist/web/_app/immutable/assets/_page.BfaLSE4e.css +1 -0
  14. package/dist/web/_app/immutable/assets/_page.CYETnzhl.css +1 -0
  15. package/dist/web/_app/immutable/assets/_page.CxRLR3o7.css +1 -0
  16. package/dist/web/_app/immutable/assets/_page.DDYvQrAf.css +1 -0
  17. package/dist/web/_app/immutable/assets/_page.DpWloLoX.css +1 -0
  18. package/dist/web/_app/immutable/chunks/ToolSelector.4cKBP-DC.js +2 -0
  19. package/dist/web/_app/immutable/chunks/api.BuM0qEja.js +1 -0
  20. package/dist/web/_app/immutable/chunks/entry.rSFvFffH.js +3 -0
  21. package/dist/web/_app/immutable/chunks/{index.wix8pgil.js → index.BmCbw0jM.js} +1 -1
  22. package/dist/web/_app/immutable/chunks/{stores.C3ZtRBEM.js → stores.Ce9c-jZZ.js} +1 -1
  23. package/dist/web/_app/immutable/entry/app.UR40BQ-u.js +2 -0
  24. package/dist/web/_app/immutable/entry/start.C0n6bEuf.js +1 -0
  25. package/dist/web/_app/immutable/nodes/0.btDtSa8k.js +1 -0
  26. package/dist/web/_app/immutable/nodes/{1.CNbcoUIj.js → 1.BAehr4TO.js} +1 -1
  27. package/dist/web/_app/immutable/nodes/10.CXxg0LZ5.js +1 -0
  28. package/dist/web/_app/immutable/nodes/11.D3gLypzx.js +1 -0
  29. package/dist/web/_app/immutable/nodes/12.BJYMQ3v1.js +1 -0
  30. package/dist/web/_app/immutable/nodes/13.uRTNTtbn.js +1 -0
  31. package/dist/web/_app/immutable/nodes/2.CdevLrEl.js +3 -0
  32. package/dist/web/_app/immutable/nodes/3.SOGeLIrs.js +1 -0
  33. package/dist/web/_app/immutable/nodes/4.B5ZJKhP_.js +1 -0
  34. package/dist/web/_app/immutable/nodes/5.D3sV9sQw.js +1 -0
  35. package/dist/web/_app/immutable/nodes/{7.bOnMUP4_.js → 6.DWlBNHmu.js} +2 -2
  36. package/dist/web/_app/immutable/nodes/7.BbLG55tv.js +1 -0
  37. package/dist/web/_app/immutable/nodes/8.BWHIAsQs.js +1 -0
  38. package/dist/web/_app/immutable/nodes/9.BXVXXU3Z.js +1 -0
  39. package/dist/web/_app/version.json +1 -1
  40. package/dist/web/index.html +7 -7
  41. package/package.json +8 -3
  42. package/dist/web/_app/immutable/assets/12.DAmfvZ5J.css +0 -1
  43. package/dist/web/_app/immutable/assets/2.G6nSchsK.css +0 -1
  44. package/dist/web/_app/immutable/assets/4.CnA4GaE5.css +0 -1
  45. package/dist/web/_app/immutable/assets/6.CrsKlz6Y.css +0 -1
  46. package/dist/web/_app/immutable/assets/8.DDodt1Wn.css +0 -1
  47. package/dist/web/_app/immutable/assets/9.ApFevNUr.css +0 -1
  48. package/dist/web/_app/immutable/assets/_page.ApFevNUr.css +0 -1
  49. package/dist/web/_app/immutable/assets/_page.CnA4GaE5.css +0 -1
  50. package/dist/web/_app/immutable/assets/_page.CrsKlz6Y.css +0 -1
  51. package/dist/web/_app/immutable/assets/_page.DAmfvZ5J.css +0 -1
  52. package/dist/web/_app/immutable/assets/_page.DDodt1Wn.css +0 -1
  53. package/dist/web/_app/immutable/assets/_page.DewAUGiJ.css +0 -1
  54. package/dist/web/_app/immutable/chunks/ToolSelector.CnQ-eszE.js +0 -2
  55. package/dist/web/_app/immutable/chunks/api.OwJBmtEN.js +0 -1
  56. package/dist/web/_app/immutable/chunks/entry.DWbp2XzC.js +0 -3
  57. package/dist/web/_app/immutable/chunks/i18n.BOq44pYI.js +0 -1
  58. package/dist/web/_app/immutable/entry/app.7Tmcb_qs.js +0 -2
  59. package/dist/web/_app/immutable/entry/start.CuMG7ijt.js +0 -1
  60. package/dist/web/_app/immutable/nodes/0.GiWuXD22.js +0 -1
  61. package/dist/web/_app/immutable/nodes/10.DgPr3L-S.js +0 -1
  62. package/dist/web/_app/immutable/nodes/11.TrX-RGQX.js +0 -1
  63. package/dist/web/_app/immutable/nodes/12.ZW7n1TLF.js +0 -1
  64. package/dist/web/_app/immutable/nodes/2.D0gEY9nh.js +0 -3
  65. package/dist/web/_app/immutable/nodes/3.CcnPu3DZ.js +0 -1
  66. package/dist/web/_app/immutable/nodes/4.CCaCZRNi.js +0 -13
  67. package/dist/web/_app/immutable/nodes/5.Bxx7TNGK.js +0 -1
  68. package/dist/web/_app/immutable/nodes/6.8zY9a_YX.js +0 -1
  69. package/dist/web/_app/immutable/nodes/8.01X9rJRT.js +0 -1
  70. package/dist/web/_app/immutable/nodes/9.DabFUxt3.js +0 -1
  71. /package/dist/web/_app/immutable/assets/{10.D4XIqeEN.css → 11.D4XIqeEN.css} +0 -0
  72. /package/dist/web/_app/immutable/assets/{11.CR85TxeS.css → 12.CR85TxeS.css} +0 -0
  73. /package/dist/web/_app/immutable/assets/{5.D4N7n6x9.css → 4.D4N7n6x9.css} +0 -0
  74. /package/dist/web/_app/immutable/assets/{7.CQvfgmQf.css → 6.CQvfgmQf.css} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 juliantanx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,42 +1,55 @@
1
- # aiusage
1
+ # aiusage — AI Coding Assistant Usage Tracker
2
2
 
3
- Track AI coding assistant usage, token consumption, cost, and tool calls in one place across Claude Code, Codex, OpenClaw, OpenCode, Hermes, and Qoder.
3
+ **Open-source CLI and dashboard to track token usage, cost, and sessions across Claude Code, Codex, OpenCode, Hermes, Qoder, and more.** Local-first, privacy-respecting, with an optional web dashboard and multi-machine sync.
4
4
 
5
- English | [中文](https://github.com/juliantanx/aiusage/blob/main/README_zh.md)
5
+ [![npm version](https://img.shields.io/npm/v/@juliantanx/aiusage)](https://www.npmjs.com/package/@juliantanx/aiusage)
6
+ [![CI](https://github.com/juliantanx/aiusage/actions/workflows/test.yml/badge.svg)](https://github.com/juliantanx/aiusage/actions/workflows/test.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
+ [![Node.js](https://img.shields.io/badge/Node.js-18%2B-green.svg)](https://nodejs.org/)
9
+ [![Website](https://img.shields.io/badge/Website-aiusage.jtanx.com-blue.svg)](https://aiusage.jtanx.com)
6
10
 
7
- ## Why aiusage
11
+ **aiusage** gives you one local-first place to understand how your AI coding tools are being used: tokens, cost, model mix, tool activity, projects, sessions, and multi-machine sync when you need it. Supports Claude Code, Codex, OpenClaw, OpenCode, Hermes, and Qoder.
8
12
 
9
- - Aggregate local session logs from multiple AI coding assistants into one view.
10
- - Analyze token usage, cost, model mix, and tool call activity.
11
- - Explore the data through a local dashboard with overview ranges from Today to All Time.
12
- - Sync usage data across multiple machines with GitHub, S3, or R2.
13
- - Keep everything local-first, with optional cloud sync when you need shared visibility.
13
+ English | [中文](https://github.com/juliantanx/aiusage/blob/main/README_zh.md)
14
14
 
15
15
  ## Quick Start
16
16
 
17
17
  **Prerequisites:** Node.js 18 or later
18
18
 
19
19
  ```bash
20
- # Install
21
20
  npm install -g @juliantanx/aiusage
22
-
23
- # Parse local session logs
24
21
  aiusage parse
25
-
26
- # Start the dashboard
27
22
  aiusage serve
28
- # Open http://localhost:3847
29
23
  ```
30
24
 
31
- Day-to-day usage is usually just:
25
+ Open `http://localhost:3847` to explore the dashboard.
32
26
 
33
- ```bash
34
- aiusage parse
35
- aiusage serve
36
- ```
27
+ If aiusage is useful, consider starring the repo to help more developers discover it.
37
28
 
38
29
  `aiusage` does not run a built-in background parser. If you want automatic imports, schedule `aiusage parse` with cron or Task Scheduler.
39
30
 
31
+ ### Running in Background (PM2)
32
+
33
+ `aiusage serve` runs in the foreground and stops when you close the terminal. To keep it running in the background on **Windows, macOS, and Linux**, use [PM2](https://pm2.keymetrics.io/):
34
+
35
+ ```bash
36
+ # Install PM2 (one-time)
37
+ npm install -g pm2
38
+
39
+ # Start aiusage as background services (generates config + starts PM2)
40
+ aiusage pm2-start
41
+
42
+ # Set auto-start on boot (Linux / macOS: run directly; Windows: run the output command as Administrator)
43
+ pm2 startup
44
+
45
+ # Common commands
46
+ pm2 list # View running status
47
+ pm2 logs # View logs
48
+ pm2 stop all # Stop all services
49
+ pm2 restart all # Restart all services
50
+ pm2 delete all # Remove all services
51
+ ```
52
+
40
53
  <details>
41
54
  <summary>Build from source</summary>
42
55
 
@@ -65,6 +78,39 @@ pnpm rebuild:sqlite
65
78
 
66
79
  </details>
67
80
 
81
+ ## Why aiusage
82
+
83
+ AI coding assistant usage is scattered by default: different tools, different local logs, different machines, and no shared view of tokens or cost.
84
+
85
+ aiusage brings that data into one local-first dashboard so you can:
86
+
87
+ - Track token usage, cost, model mix, and tool-call activity in one place.
88
+ - Aggregate usage across Claude Code, Codex, OpenClaw, OpenCode, Hermes, and Qoder.
89
+ - Understand usage over time through overview, token, cost, model, session, and project views.
90
+ - Sync across multiple machines with GitHub, S3, or R2 when shared visibility matters.
91
+ - Keep your data local by default, with optional sync only when you choose it.
92
+
93
+ ## Who is this for?
94
+
95
+ aiusage is built for:
96
+
97
+ - Developers using Claude Code, Codex, or other AI coding assistants every day.
98
+ - People who want visibility into token usage and spend over time.
99
+ - Multi-tool users who want one dashboard instead of multiple disconnected logs.
100
+ - Multi-machine workflows that need optional aggregation and sync.
101
+
102
+ ## Supported tools
103
+
104
+ aiusage currently supports:
105
+
106
+ - Claude Code
107
+ - Codex
108
+ - OpenClaw
109
+ - OpenCode
110
+ - Hermes
111
+ - Qoder
112
+ - Cursor
113
+
68
114
  ## Screenshots
69
115
 
70
116
  ![Homepage dashboard](https://cdn.jsdelivr.net/gh/juliantanx/aiusage@0ae8299/docs/assets/readme/home.png)
@@ -73,6 +119,16 @@ pnpm rebuild:sqlite
73
119
 
74
120
  ![Token usage page](https://cdn.jsdelivr.net/gh/juliantanx/aiusage@0ae8299/docs/assets/readme/token.png)
75
121
 
122
+ ## Common use cases
123
+
124
+ Use aiusage to:
125
+
126
+ - Track token and cost trends across AI coding assistants.
127
+ - Compare model usage and activity over time.
128
+ - Inspect tool-call volume and session-level behavior.
129
+ - Aggregate usage across multiple machines into one view.
130
+ - Run a local or Docker-hosted dashboard for ongoing visibility.
131
+
76
132
  ## CLI Reference
77
133
 
78
134
  ### `aiusage` (default)
@@ -85,7 +141,7 @@ Import newly appended local session data from discovered source paths.
85
141
 
86
142
  | Option | Description |
87
143
  |--------|-------------|
88
- | `--tool <tool>` | Only parse a specific tool: `claude-code`, `codex`, `openclaw`, `opencode`, `hermes`, `qoder` |
144
+ | `--tool <tool>` | Only parse a specific tool: `claude-code`, `codex`, `openclaw`, `opencode`, `hermes`, `qoder`, `cursor` |
89
145
  | `--progress` | Show real-time progress bar on stderr (TTY only, silent in pipes/CI) |
90
146
 
91
147
  ```bash
@@ -114,7 +170,7 @@ Print a usage summary in the terminal.
114
170
  | Option | Description |
115
171
  |--------|-------------|
116
172
  | `--device <id>` | Filter by device instance ID |
117
- | `--tool <tool>` | Filter by tool type |
173
+ | `--tool <tool>` | Filter by tool type (`claude-code`, `codex`, `openclaw`, `opencode`, `hermes`, `qoder`, `cursor`) |
118
174
 
119
175
  ```bash
120
176
  aiusage summary # All-time summary
@@ -452,6 +508,7 @@ docker build -t aiusage .
452
508
  | Hermes | `~/.hermes/state.db` | `~/.hermes/state.db` | `%USERPROFILE%\.hermes\state.db` |
453
509
  | Qoder (sessions) | `~/.qoder/logs/sessions/` | `~/.qoder/logs/sessions/` plus WSL-mounted Windows user homes | `%USERPROFILE%\.qoder\logs\sessions\` |
454
510
  | Qoder (SQLite) | `~/Library/Application Support/Qoder/SharedClientCache/cache/db/local.db` | `~/.local/share/Qoder/SharedClientCache/cache/db/local.db` | `%LOCALAPPDATA%\Qoder\SharedClientCache\cache\db\local.db` |
511
+ | Cursor | `~/Library/Application Support/Cursor/User/globalStorage/state.vscdb` | `~/.config/Cursor/User/globalStorage/state.vscdb` | `%APPDATA%\Cursor\User\globalStorage\state.vscdb` |
455
512
 
456
513
  Discovery behavior:
457
514
 
@@ -462,6 +519,7 @@ Discovery behavior:
462
519
  - **Hermes** — reads the SQLite database file (`state.db`) directly. Sessions without a recorded end time are still imported if they have token data (e.g. sessions from a force-quit).
463
520
  - **Qoder (sessions)** — recursively scans structured session segment logs (`logs/sessions/**/segments/*.jsonl`) and imports `model.response.completed` token events. On WSL, aiusage also checks mounted Windows user homes such as `/mnt/c/Users/<user>`, `/mnt/d/Users/<user>`, and `/mnt/e/Users/<user>` for the same Qoder session-log layout.
464
521
  - **Qoder (SQLite)** — reads the `local.db` SQLite database directly (`SharedClientCache/cache/db/local.db`) and imports assistant messages from the `chat_message` table, joined with `chat_record` for model information. This is the primary source on macOS and is tried alongside the sessions directory.
522
+ - **Cursor** — reads Cursor's `state.vscdb` SQLite database directly and imports composer conversations with token usage data.
465
523
 
466
524
  > On Linux, OpenCode respects `$XDG_DATA_HOME` if set.
467
525
 
@@ -480,7 +538,8 @@ If you installed a tool to a non-default location, override the paths in the **S
480
538
  "opencode": "/custom/path/opencode.db",
481
539
  "hermes": "/custom/path/.hermes/state.db",
482
540
  "qoder": "/custom/path/.qoder/logs/sessions",
483
- "qoder-db": "/custom/path/local.db"
541
+ "qoder-db": "/custom/path/local.db",
542
+ "cursor": "/custom/path/state.vscdb"
484
543
  }
485
544
  }
486
545
  ```
@@ -527,6 +586,28 @@ packages/
527
586
  web/ - SvelteKit web dashboard (SPA)
528
587
  ```
529
588
 
589
+ ## FAQ
590
+
591
+ ### Does aiusage upload my data?
592
+
593
+ No. aiusage is local-first. Your usage data stays on your machine unless you explicitly configure a sync backend.
594
+
595
+ ### Can I use aiusage across multiple machines?
596
+
597
+ Yes. You can sync usage data through GitHub, S3, or R2 and then view the combined result from any configured machine or Docker deployment.
598
+
599
+ ### Does aiusage run a background parser automatically?
600
+
601
+ No. By default, you run `aiusage parse` manually. You can automate parsing and syncing with cron, Task Scheduler, or your own scheduler.
602
+
603
+ ### Which assistants are supported?
604
+
605
+ aiusage currently supports Claude Code, Codex, OpenClaw, OpenCode, Hermes, and Qoder.
606
+
607
+ ### Can I inspect the raw database myself?
608
+
609
+ Yes. aiusage stores data in a local SQLite database, and the README already documents how to open it in tools like DBeaver, TablePlus, DataGrip, or DB Browser for SQLite.
610
+
530
611
  ## Friends
531
612
 
532
613
  [**linux.do**](https://linux.do/) — Thanks to the linux.do community for their support and inspiration during the development of this project.
@@ -535,12 +616,16 @@ packages/
535
616
 
536
617
  <a href="https://www.star-history.com/?repos=juliantanx%2Faiusage&type=date&logscale=&legend=top-left">
537
618
  <picture>
538
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=juliantanx/aiusage&type=date&theme=dark&legend=top-left&t=20260524" />
539
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=juliantanx/aiusage&type=date&legend=top-left&t=20260524" />
540
- <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=juliantanx/aiusage&type=date&legend=top-left&t=20260524" />
619
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=juliantanx/aiusage&type=date&theme=dark&legend=top-left&t=20260526" />
620
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=juliantanx/aiusage&type=date&legend=top-left&t=20260526" />
621
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=juliantanx/aiusage&type=date&legend=top-left&t=20260526" />
541
622
  </picture>
542
623
  </a>
543
624
 
625
+ ## Contributing
626
+
627
+ Contributions are welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for how to get started.
628
+
544
629
  ## License
545
630
 
546
- MIT
631
+ [MIT](./LICENSE)