@aiusage/cli 0.2.0
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/LICENSE +21 -0
- package/README.md +138 -0
- package/dist/cli.js +1959 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AIUsage
|
|
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
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# @aiusage/cli
|
|
2
|
+
|
|
3
|
+
`@aiusage/cli` is the AIUsage command-line tool for:
|
|
4
|
+
|
|
5
|
+
- scanning local Claude Code and Codex token usage
|
|
6
|
+
- printing local usage summaries for the last 7 days, 30 days, 90 days, or all history
|
|
7
|
+
- scheduling automatic sync to an AIUsage Worker
|
|
8
|
+
- diagnosing configuration and connectivity issues
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @aiusage/cli
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or run it directly with `npx`:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npx @aiusage/cli --help
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
After installation:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
aiusage --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
### report
|
|
31
|
+
|
|
32
|
+
Local usage report. No cloud upload required.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
aiusage report --range 7d
|
|
36
|
+
aiusage report --range 1m
|
|
37
|
+
aiusage report --range 3m
|
|
38
|
+
aiusage report --range all
|
|
39
|
+
aiusage report --range 7d --json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Reads data from `~/.claude/projects` (Claude Code) and `~/.codex` (Codex).
|
|
43
|
+
|
|
44
|
+
The report includes events, token breakdowns (input / cache read / cache write / output / reasoning), grouped totals by source, daily trend, top models, and estimated USD cost based on public pricing.
|
|
45
|
+
|
|
46
|
+
### scan
|
|
47
|
+
|
|
48
|
+
Scan a single day and print the breakdown.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
aiusage scan --date 2026-03-31
|
|
52
|
+
aiusage scan --date 2026-03-31 --json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Defaults to yesterday when `--date` is omitted.
|
|
56
|
+
|
|
57
|
+
### init
|
|
58
|
+
|
|
59
|
+
Initialize local configuration.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
aiusage init --server https://your-worker.example.com --site-id your-site-id
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### health
|
|
66
|
+
|
|
67
|
+
Test connectivity to the Worker.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
aiusage health
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### enroll
|
|
74
|
+
|
|
75
|
+
Register this device with the Worker.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
aiusage enroll \
|
|
79
|
+
--server https://your-worker.example.com \
|
|
80
|
+
--site-id your-site-id \
|
|
81
|
+
--enroll-token your-enroll-token \
|
|
82
|
+
--device-name "MacBook Pro"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### sync
|
|
86
|
+
|
|
87
|
+
Upload usage data to the Worker. Covers the last 7 closed days by default.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
aiusage sync
|
|
91
|
+
aiusage sync --today # include today's live data
|
|
92
|
+
aiusage sync --date 2026-03-31
|
|
93
|
+
aiusage sync --lookback 14
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Use `--today` to upload the current (incomplete) day. The server upserts, so partial data is updated on next sync.
|
|
97
|
+
|
|
98
|
+
### schedule
|
|
99
|
+
|
|
100
|
+
Manage automatic sync. Uses `launchd` on macOS and `cron` on Linux.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
aiusage schedule # enable, default every 5 minutes
|
|
104
|
+
aiusage schedule on # same as above
|
|
105
|
+
aiusage schedule on --every 30m
|
|
106
|
+
aiusage schedule off # disable
|
|
107
|
+
aiusage schedule status # show current status
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Supported intervals: `5m` – `1d`. Scheduled sync always includes today's live data (`--today`), so your dashboard stays current.
|
|
111
|
+
|
|
112
|
+
### doctor
|
|
113
|
+
|
|
114
|
+
Run diagnostic checks on configuration, server connectivity, scanner directories, and schedule status.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
aiusage doctor
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### config set
|
|
121
|
+
|
|
122
|
+
Manage local settings.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
aiusage config set device.alias "MacBook Pro 工作机"
|
|
126
|
+
aiusage config set privacy.projectVisibility masked
|
|
127
|
+
aiusage config set project.alias /Users/me/Projects/MyApp MyApp
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Configuration
|
|
131
|
+
|
|
132
|
+
Config file: `~/.aiusage/config.json`
|
|
133
|
+
|
|
134
|
+
Sync log (when scheduled): `~/.aiusage/sync.log`
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|