openusage 1.0.6
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/README.md +55 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# openuse
|
|
2
|
+
|
|
3
|
+
`openuse` is a small CLI that reads your local OpenCode SQLite history, matches models against the OpenRouter model catalog, and prints a readable usage + cost report.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
- Reads usage rows from your OpenCode database (`part` + `message` tables).
|
|
8
|
+
- Fetches live model pricing from `https://openrouter.ai/api/v1/models`.
|
|
9
|
+
- Matches local model names to OpenRouter model IDs with fuzzy matching.
|
|
10
|
+
- Calculates estimated USD cost per model per day.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Use it directly from npm (no cloning/building needed):
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npx openuse
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install globally:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm i -g openuse
|
|
24
|
+
openuse
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Run with default database path:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx openuse
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You can also pass your database file as the first CLI argument, or set `OPENCODE_DB_PATH`.
|
|
36
|
+
|
|
37
|
+
Default DB path if no argument/env is provided:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
~/.local/share/opencode/opencode.db
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Output
|
|
44
|
+
|
|
45
|
+
The CLI prints three tables:
|
|
46
|
+
|
|
47
|
+
- `Daily Usage/Model`: token usage and estimated cost by date + model.
|
|
48
|
+
- `Daily Usage/Provider`: token usage and estimated cost by date + provider.
|
|
49
|
+
- `Daily Total Usage`: models used, token totals, and total cost by date.
|
|
50
|
+
|
|
51
|
+
## Requirements
|
|
52
|
+
|
|
53
|
+
- Node.js 18+
|
|
54
|
+
- Access to your OpenCode SQLite database
|
|
55
|
+
- Network access to OpenRouter models endpoint
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openusage",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "bun test",
|
|
7
|
+
"lint": "eslint .",
|
|
8
|
+
"fix": "eslint . --fix",
|
|
9
|
+
"tc": "tsc --noEmit --watch",
|
|
10
|
+
"build": "tsdown --config ./tsdown.config.ts",
|
|
11
|
+
"dev": "concurrently --names \"R,T\" --prefix-colors \"blue.dim,magenta.dim\" \"tsdown --config ./tsdown.config.ts --watch\" \"tsc --noEmit --watch\"",
|
|
12
|
+
"start": "tsx --watch ./src/index.ts"
|
|
13
|
+
},
|
|
14
|
+
"bin": "./dist/index.js",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@eslint/compat": "^1.4.0",
|
|
17
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
18
|
+
"@eslint/js": "^9.38.0",
|
|
19
|
+
"@types/bun": "^1.3.0",
|
|
20
|
+
"@types/node": "^24.9.1",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^8.46.1",
|
|
22
|
+
"@typescript-eslint/parser": "^8.46.1",
|
|
23
|
+
"chalk": "^5.6.2",
|
|
24
|
+
"concurrently": "^9.2.1",
|
|
25
|
+
"eslint": "^9.38.0",
|
|
26
|
+
"eslint-config-prettier": "^10.1.8",
|
|
27
|
+
"eslint-plugin-check-file": "^3.3.0",
|
|
28
|
+
"eslint-plugin-import": "^2.32.0",
|
|
29
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
30
|
+
"husky": "^9.1.7",
|
|
31
|
+
"noarg": "^3.1.9",
|
|
32
|
+
"prettier": "^3.6.2",
|
|
33
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
34
|
+
"rolldown": "1.0.0-rc.13",
|
|
35
|
+
"table": "^6.9.0",
|
|
36
|
+
"tsdown": "^0.15.9",
|
|
37
|
+
"tslib": "^2.8.1",
|
|
38
|
+
"tsx": "^4.20.6",
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"typescript-eslint": "^8.46.2"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"sqlite3": "^6.0.1"
|
|
44
|
+
}
|
|
45
|
+
}
|