@thedevdavid/sage 0.1.7 โ†’ 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/README.md CHANGED
@@ -1,36 +1,69 @@
1
1
  # ๐ŸŒฟ sage
2
2
 
3
- Know your LLM API billing cycle and usage. Nothing else.
3
+ Know your LLM usage at a glance. Nothing else.
4
4
 
5
- sage is a tiny, open-source, **local-only** toolkit that shows your current
6
- billing cycle and spend/balance for **OpenAI**, **Anthropic (Claude)**, and
5
+ sage is a tiny, open-source, **local-only** toolkit that shows what you have
6
+ left: **subscription** usage for Claude Max, ChatGPT (Codex), Kimi Code, and
7
+ Cursor โ€” plus billing-cycle spend/balance for **OpenAI**, **Anthropic**, and
7
8
  **Kimi (Moonshot)** API keys. No signup, no server, no database, no telemetry โ€”
8
9
  everything lives in `~/.sage/` on your machine.
9
10
 
10
- Three ways to use it, one shared local store:
11
+ Four pieces, one shared local store (the website is just this product's page):
11
12
 
12
13
  | Piece | What it is |
13
14
  | --- | --- |
14
- | **CLI** (`cli/`) | Zero-dependency CLI (runs on Bun or Node): `bunx @thedevdavid/sage status` |
15
- | **macOS app** (`sage/`) | Menu bar app built from the included Xcode project |
16
- | **Agent skill** (`cli/skill/sage/`) | Teaches coding agents to answer usage questions via the CLI |
15
+ | **CLI** (`cli/`) | Zero-dependency CLI (Bun or Node โ‰ฅ 18), on npm and Homebrew |
16
+ | **macOS app** (`sage/`) | Menu bar app, on Homebrew and GitHub releases |
17
+ | **Agent skill** (`skills/sage/`) | Teaches coding agents to answer usage questions via the CLI |
17
18
  | **Website** (`site/`) | This product's single-page static site |
18
19
 
20
+ ## Install
21
+
22
+ ```bash
23
+ brew install thedevdavid/tap/sage # CLI
24
+ brew install --cask thedevdavid/tap/sage # macOS menu bar app
25
+ ```
26
+
27
+ Or without Homebrew: run the CLI straight from npm
28
+ (`bunx @thedevdavid/sage status`), or grab `sage.app.zip` from
29
+ [GitHub releases](https://github.com/thedevdavid/sage/releases/latest).
30
+
19
31
  ## Quick start
20
32
 
21
33
  ```bash
22
- bunx @thedevdavid/sage add openai # or anthropic, kimi โ€” prompts securely for your key
23
- bunx @thedevdavid/sage status
34
+ sage add openai # or anthropic, kimi โ€” prompts securely for your key
35
+ sage status
24
36
  ```
25
37
 
26
38
  ```
27
- cycle: day 12/31 ยท resets 2026-09-01 (19d left)
28
- openai $14.20 spent this cycle
29
- anthropic key valid ยท admin key needed for spend
30
- kimi 38.44 CNY balance
39
+ โ— claude ยท Max (20x)
40
+ Weekly โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 52% left ยท 3d 4h
41
+ Session (5h) โ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 87% left ยท 2h 10m
42
+ โ— cursor ยท Pro
43
+ Monthly โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 34% left ยท 2026-08-06
44
+
45
+ API keys
46
+ openai $14.20 spent this cycle
47
+ kimi 38.44 CNY balance
48
+ cycle: day 12/31 ยท resets 2026-09-01 (19d left)
31
49
  ```
32
50
 
33
- ## What each provider can report
51
+ ## Subscription tracking
52
+
53
+ Nothing to configure: sage auto-detects local sessions from Claude Desktop
54
+ (its encrypted `Cookies` database and Keychain safe-storage item), Claude
55
+ Code, Codex, Kimi Code, or Cursor (its `state.vscdb`), and queries the same
56
+ backend endpoints those tools use. Claude Desktop's session is preferred when
57
+ present, so Claude Max does not require a separate Claude Code login. Expiring
58
+ Kimi Code access tokens are refreshed through Kimi Code's existing local OAuth
59
+ credential store; no tool or browser is opened. Env overrides:
60
+ `CLAUDE_CODE_OAUTH_TOKEN`, `CODEX_HOME`, `KIMI_CODE_API_KEY`.
61
+
62
+ You get plan name, usage windows (session/weekly/monthly), and reset times.
63
+ An expired session shows the provider's own recovery step instead of stale
64
+ numbers.
65
+
66
+ ## What each API provider can report
34
67
 
35
68
  sage never invents numbers โ€” provider APIs differ a lot:
36
69
 
@@ -47,38 +80,18 @@ cycle to a monthly reset day you choose:
47
80
  sage cycle --set-reset-day 15
48
81
  ```
49
82
 
50
- ## Subscription tracking
51
-
52
- Separate from API keys, sage tracks **subscription** usage โ€” Claude Max,
53
- ChatGPT (Codex), Kimi Code, and Cursor โ€” plan name, session/weekly/monthly
54
- usage windows, and reset times:
55
-
56
- ```
57
- โ— claude ยท Max (20x)
58
- Session (5h) โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 100% left
59
- Weekly โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 0% left ยท 11h 22m
60
- โ— cursor ยท Pro
61
- Monthly โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘ 3% left ยท 2026-08-06
62
- ```
63
-
64
- Nothing to configure: sage auto-detects local sessions from Claude Desktop
65
- (its encrypted `Cookies` database and Keychain safe-storage item), Claude
66
- Code, Codex, Kimi Code, or Cursor. It queries the same backend endpoints those
67
- tools use. Claude Desktop is preferred when it is running, so Claude Max does
68
- not require a separate Claude Code login. Expiring Kimi Code access tokens are
69
- refreshed through Kimi Code's existing local OAuth credential store; no tool or
70
- browser is opened. Env overrides: `CLAUDE_CODE_OAUTH_TOKEN`, `CODEX_HOME`,
71
- `KIMI_CODE_API_KEY`.
72
-
73
83
  ## CLI commands
74
84
 
75
85
  ```
76
- sage status [--json] cycle + usage for all providers
77
- sage add <provider> [--key K] [--admin-key K]
78
- sage remove <provider>
79
- sage usage [provider] [--json]
80
- sage cycle [--set-reset-day N]
86
+ sage status [--json] cycle + usage for keys and subscriptions (default)
87
+ sage add <provider> add an API key (openai, anthropic, kimi)
88
+ [--key K] [--admin-key K] prompts securely when flags are omitted
89
+ sage remove <provider> remove an API-key provider
90
+ sage usage [name] [--json] detailed usage for one source or all of them
91
+ sage cycle [--set-reset-day N] show billing cycle, or set the monthly reset day
81
92
  sage skill install [--project] install the agent skill
93
+ sage help show help
94
+ sage version show version
82
95
  ```
83
96
 
84
97
  `--json` output is stable and agent/script-friendly.
@@ -89,25 +102,29 @@ sage skill install [--project] install the agent skill
89
102
  the CLI and the menu bar app (you can add keys from either).
90
103
  - `~/.sage/cache.json` โ€” last successful fetch per provider, so the menu bar
91
104
  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
105
 
95
106
  ## macOS menu bar app
96
107
 
97
108
  ```bash
98
- open sage.xcodeproj # build & run (macOS 26+, Xcode 26+)
109
+ brew install --cask thedevdavid/tap/sage
99
110
  ```
100
111
 
101
- A leaf appears in your menu bar with cycle progress and per-provider usage.
102
- Add keys directly from the app ("Add key" โ†’ paste, validates on save) or from
103
- the CLI โ€” both share `~/.sage/`. It refreshes every 15 minutes, and the
112
+ A leaf appears in your menu bar with subscription windows and per-provider
113
+ usage. Add keys directly from the app (+ button โ†’ paste, validates on save) or
114
+ from the CLI โ€” both share `~/.sage/`. It refreshes every 15 minutes, and the
104
115
  **Refresh now** button forces an immediate pull from every detected source.
105
116
 
106
117
  ## Agent skill
107
118
 
108
119
  ```bash
109
- bunx @thedevdavid/sage skill install # โ†’ ~/.agents/skills/sage/SKILL.md
110
- bunx @thedevdavid/sage skill install --project # โ†’ ./.agents/skills/sage/SKILL.md
120
+ npx skills add thedevdavid/sage # via skills.sh, into your agent's skill dir
121
+ ```
122
+
123
+ Or via the CLI (same SKILL.md, copied to `~/.agents/skills/sage/`, or
124
+ `./.agents/skills/sage/` with `--project`):
125
+
126
+ ```bash
127
+ sage skill install [--project]
111
128
  ```
112
129
 
113
130
  Your coding agent then knows to run `sage status --json` when you ask
@@ -117,18 +134,24 @@ about API spend or cycle status โ€” without ever reading your keys.
117
134
 
118
135
  - CLI: `bun cli/bin/sage.js --help` (Bun or Node โ‰ฅ 18, no dependencies, no build step).
119
136
  - App: `xcodebuild -project sage.xcodeproj -scheme sage -destination 'platform=macOS' build`
120
- The project is kept at object format 77 (Xcode 16+) so hosted CI runners can
121
- build it. If Xcode offers to upgrade the project format, decline โ€” a newer
122
- format makes the release workflow fail to open the project.
137
+ (macOS 26+, Xcode 26+). The project is kept at object format 77 (Xcode 16+)
138
+ so hosted CI runners can build it. If Xcode offers to upgrade the project
139
+ format, decline โ€” a newer format makes the release workflow fail to open the
140
+ project.
123
141
  - Site: `python3 -m http.server 8080 -d site` โ€” one static `index.html`, no build step.
142
+ - Screenshots: `scripts/build-capture-window.sh` once, then
143
+ `build/capture-window.app/Contents/MacOS/capture-window out.png --app-name sage`
144
+ captures the menu bar popover programmatically (ScreenCaptureKit; it opens the
145
+ popover itself). Needs one-time Screen Recording + Accessibility permission for
146
+ the `capture-window` app.
124
147
 
125
148
  ## Releasing
126
149
 
127
150
  ```bash
128
- make release VERSION=0.1.5
151
+ make release VERSION=0.1.9
129
152
  ```
130
153
 
131
- That bumps `cli/package.json`, commits, tags `v0.1.5` and pushes. The tag
154
+ That bumps `cli/package.json`, commits, tags `v0.1.9` and pushes. The tag
132
155
  triggers `.github/workflows/release.yml`, which does the rest on a macOS
133
156
  runner: smoke-tests the CLI, builds and zips the app, creates the GitHub
134
157
  release, publishes to npm (trusted publishing โ€” no token stored), and commits
package/bin/sage.js CHANGED
@@ -400,8 +400,14 @@ const COMMANDS = {
400
400
 
401
401
  async skill({ positional, flags }) {
402
402
  if (positional[0] !== 'install') fail('usage: sage skill install [--project]');
403
- const source = join(ROOT, 'skill', 'sage', 'SKILL.md');
404
- if (!existsSync(source)) fail(`bundled skill not found at ${source}`);
403
+ // The npm package bundles the skill at cli/skill/; a repo checkout keeps
404
+ // the canonical copy at skills/ (where skills.sh discovery finds it).
405
+ const candidates = [
406
+ join(ROOT, 'skill', 'sage', 'SKILL.md'),
407
+ join(ROOT, '..', 'skills', 'sage', 'SKILL.md'),
408
+ ];
409
+ const source = candidates.find((p) => existsSync(p));
410
+ if (!source) fail(`bundled skill not found (looked in ${candidates.join(', ')})`);
405
411
  const targetDir = flags.project
406
412
  ? join(process.cwd(), '.agents', 'skills', 'sage')
407
413
  : join(homedir(), '.agents', 'skills', 'sage');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thedevdavid/sage",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "Local-only usage & billing-cycle tracker for LLM API keys and subscriptions (OpenAI, Anthropic/Claude, Kimi, Cursor).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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
- let usage;
85
- let me = null;
86
- try {
87
- [usage, me] = await Promise.all([
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