@thedevdavid/sage 0.1.6 → 0.1.8
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 +6 -3
- package/package.json +1 -1
- package/src/subscriptions/index.js +28 -1
- package/src/subscriptions/kimi.js +4 -11
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ billing cycle and spend/balance for **OpenAI**, **Anthropic (Claude)**, and
|
|
|
7
7
|
**Kimi (Moonshot)** API keys. No signup, no server, no database, no telemetry —
|
|
8
8
|
everything lives in `~/.sage/` on your machine.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Four pieces, one shared local store (the website is just this product's page):
|
|
11
11
|
|
|
12
12
|
| Piece | What it is |
|
|
13
13
|
| --- | --- |
|
|
@@ -89,8 +89,6 @@ sage skill install [--project] install the agent skill
|
|
|
89
89
|
the CLI and the menu bar app (you can add keys from either).
|
|
90
90
|
- `~/.sage/cache.json` — last successful fetch per provider, so the menu bar
|
|
91
91
|
app and offline runs still show something (marked as cached).
|
|
92
|
-
- The web tool stores the same data in your browser's `localStorage` instead
|
|
93
|
-
(`sage:config` / `sage:cache`) — it never touches the filesystem.
|
|
94
92
|
|
|
95
93
|
## macOS menu bar app
|
|
96
94
|
|
|
@@ -121,6 +119,11 @@ about API spend or cycle status — without ever reading your keys.
|
|
|
121
119
|
build it. If Xcode offers to upgrade the project format, decline — a newer
|
|
122
120
|
format makes the release workflow fail to open the project.
|
|
123
121
|
- Site: `python3 -m http.server 8080 -d site` — one static `index.html`, no build step.
|
|
122
|
+
- Screenshots: `scripts/build-capture-window.sh` once, then
|
|
123
|
+
`build/capture-window.app/Contents/MacOS/capture-window out.png --app-name sage`
|
|
124
|
+
captures the menu bar popover programmatically (ScreenCaptureKit; it opens the
|
|
125
|
+
popover itself). Needs one-time Screen Recording + Accessibility permission for
|
|
126
|
+
the `capture-window` app.
|
|
124
127
|
|
|
125
128
|
## Releasing
|
|
126
129
|
|
package/package.json
CHANGED
|
@@ -24,6 +24,33 @@ export function windowRank(label) {
|
|
|
24
24
|
return 2;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// The Claude usage API reports its primary buckets twice — as five_hour /
|
|
28
|
+
// seven_day and again in a limits list under raw kinds (session, weekly_all) —
|
|
29
|
+
// and older app versions wrote those aliases into the shared cache. Collapse
|
|
30
|
+
// the aliases so each limit displays once, whatever the source.
|
|
31
|
+
const BUCKET_ALIASES = new Map([
|
|
32
|
+
['session', 'session'],
|
|
33
|
+
['five_hour', 'session'],
|
|
34
|
+
['session (5h)', 'session'],
|
|
35
|
+
['weekly', 'weekly'],
|
|
36
|
+
['weekly_all', 'weekly'],
|
|
37
|
+
['seven_day', 'weekly'],
|
|
38
|
+
['weekly (all models)', 'weekly'],
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
function bucketKey(label) {
|
|
42
|
+
const l = String(label).toLowerCase();
|
|
43
|
+
return BUCKET_ALIASES.get(l) ?? l;
|
|
44
|
+
}
|
|
45
|
+
|
|
27
46
|
export function sortWindows(windows) {
|
|
28
|
-
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
return [...(windows ?? [])]
|
|
49
|
+
.filter((w) => {
|
|
50
|
+
const key = `${w?.category ?? ''}:${bucketKey(w?.label)}`;
|
|
51
|
+
if (seen.has(key)) return false;
|
|
52
|
+
seen.add(key);
|
|
53
|
+
return true;
|
|
54
|
+
})
|
|
55
|
+
.sort((a, b) => windowRank(a.label) - windowRank(b.label));
|
|
29
56
|
}
|
|
@@ -81,17 +81,10 @@ function parseKimiUsage(usage, me) {
|
|
|
81
81
|
|
|
82
82
|
async function fetchUsage(creds) {
|
|
83
83
|
const headers = { Authorization: `Bearer ${creds.token}`, Accept: 'application/json' };
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
httpJson(`${BASE}/usages`, { headers }),
|
|
89
|
-
httpJson(`${BASE}/me`, { headers }).catch(() => null),
|
|
90
|
-
]);
|
|
91
|
-
} catch (err) {
|
|
92
|
-
if (err.status === 401) throw err;
|
|
93
|
-
throw err;
|
|
94
|
-
}
|
|
84
|
+
const [usage, me] = await Promise.all([
|
|
85
|
+
httpJson(`${BASE}/usages`, { headers }),
|
|
86
|
+
httpJson(`${BASE}/me`, { headers }).catch(() => null),
|
|
87
|
+
]);
|
|
95
88
|
return parseKimiUsage(usage, me);
|
|
96
89
|
}
|
|
97
90
|
|