tally-menubar 0.0.0-stage → 1.3.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 +36 -2
- package/bin/tally.js +186 -0
- package/package.json +15 -4
- package/release.json +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PratikRai0101
|
|
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,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# tally-menubar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Installs [Tally](https://github.com/PratikRai0101/tally), a macOS menu bar app that shows how much of each AI coding plan (Claude, Codex, OpenCode Go) you have left, when it resets, and what your usage would cost at API prices.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx tally-menubar
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
That downloads the Tally release from GitHub, checks it against the SHA-256 shipped in this package, installs it to `~/Applications` and opens it. Requires macOS 14 or later and Node 18 or later.
|
|
10
|
+
|
|
11
|
+
| Command | What it does |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `npx tally-menubar` | Install Tally and open it |
|
|
14
|
+
| `npx tally-menubar@latest update` | Update to the newest version |
|
|
15
|
+
| `npx tally-menubar usage` | Print spend, tokens and limits in the terminal |
|
|
16
|
+
| `npx tally-menubar uninstall` | Remove Tally (`--purge` also removes its settings) |
|
|
17
|
+
| `npx tally-menubar version` | Show the package and installed versions |
|
|
18
|
+
|
|
19
|
+
Options: `--no-open` skips launching after install, `--force` reinstalls.
|
|
20
|
+
|
|
21
|
+
If Tally is already in `/Applications`, it is updated there. Set `TALLY_INSTALL_DIR` to install somewhere else.
|
|
22
|
+
|
|
23
|
+
## Why use this instead of the .zip
|
|
24
|
+
|
|
25
|
+
Tally isn't signed with an Apple Developer ID yet, so a copy downloaded in a browser is blocked with "Apple could not verify Tally". Files downloaded by Node aren't flagged by macOS that way, so this install opens normally. The checksum check makes sure you get exactly the published release.
|
|
26
|
+
|
|
27
|
+
After an update, macOS may ask once more to let Tally read your Claude login from the Keychain. Choose **Always Allow**.
|
|
28
|
+
|
|
29
|
+
## Releasing (maintainers)
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm run pin -- v1.4 # writes release.json from the GitHub release
|
|
33
|
+
# set "version" in package.json to 1.4.0
|
|
34
|
+
npm publish
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
MIT licence.
|
package/bin/tally.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Installs, updates and removes Tally.app, and prints usage from the terminal.
|
|
3
|
+
// No dependencies: Node's fetch, plus macOS's own ditto, codesign, plutil and open.
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const crypto = require("crypto");
|
|
10
|
+
const { execFileSync, spawnSync } = require("child_process");
|
|
11
|
+
|
|
12
|
+
const RELEASE = require("../release.json");
|
|
13
|
+
const PKG = require("../package.json");
|
|
14
|
+
const BUNDLE_ID = "local.tally.menubar";
|
|
15
|
+
|
|
16
|
+
const args = process.argv.slice(2);
|
|
17
|
+
const flags = new Set(args.filter((a) => a.startsWith("-")));
|
|
18
|
+
const cmd = args.find((a) => !a.startsWith("-")) || "install";
|
|
19
|
+
|
|
20
|
+
const say = (s = "") => process.stdout.write(s + "\n");
|
|
21
|
+
class Fail extends Error {}
|
|
22
|
+
const fail = (s) => { throw new Fail(s); }; // thrown, so cleanup in finally blocks still runs
|
|
23
|
+
const run = (bin, argv, opts = {}) => execFileSync(bin, argv, { stdio: ["ignore", "pipe", "pipe"], ...opts }).toString().trim();
|
|
24
|
+
const tryRun = (bin, argv) => { try { return run(bin, argv); } catch { return null; } };
|
|
25
|
+
|
|
26
|
+
// ---------- where Tally lives ----------
|
|
27
|
+
|
|
28
|
+
function appPath() {
|
|
29
|
+
if (process.env.TALLY_INSTALL_DIR) return path.join(path.resolve(process.env.TALLY_INSTALL_DIR), "Tally.app");
|
|
30
|
+
const system = "/Applications/Tally.app";
|
|
31
|
+
if (fs.existsSync(system) && bundleId(system) === BUNDLE_ID) return system;
|
|
32
|
+
return path.join(os.homedir(), "Applications", "Tally.app");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const plist = (app, key) => tryRun("/usr/bin/plutil", ["-extract", key, "raw", path.join(app, "Contents", "Info.plist")]);
|
|
36
|
+
const bundleId = (app) => plist(app, "CFBundleIdentifier");
|
|
37
|
+
const appVersion = (app) => plist(app, "CFBundleShortVersionString");
|
|
38
|
+
|
|
39
|
+
// ---------- checks ----------
|
|
40
|
+
|
|
41
|
+
function checkMac() {
|
|
42
|
+
if (process.platform !== "darwin") fail("Tally is a macOS app; this machine is " + process.platform + ".");
|
|
43
|
+
const darwin = parseInt(os.release().split(".")[0], 10);
|
|
44
|
+
if (darwin < 23) fail("Tally needs macOS 14 (Sonoma) or later.");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Never overwrite some other app that happens to be called Tally.
|
|
48
|
+
function checkOwnership(app) {
|
|
49
|
+
if (!fs.existsSync(app)) return;
|
|
50
|
+
const id = bundleId(app);
|
|
51
|
+
if (id !== BUNDLE_ID && !flags.has("--force")) {
|
|
52
|
+
fail(`${app} is a different app (${id || "unknown bundle id"}). Move it away, or pass --force to replace it.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ---------- running copies ----------
|
|
57
|
+
|
|
58
|
+
function runningPids(app) {
|
|
59
|
+
const out = tryRun("/usr/bin/pgrep", ["-x", "Tally"]);
|
|
60
|
+
if (!out) return [];
|
|
61
|
+
const exe = path.join(app, "Contents", "MacOS", "Tally");
|
|
62
|
+
return out.split("\n").map(Number).filter((pid) => tryRun("/bin/ps", ["-o", "comm=", "-p", String(pid)]) === exe);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function quit(app) {
|
|
66
|
+
const pids = runningPids(app);
|
|
67
|
+
if (!pids.length) return false;
|
|
68
|
+
for (const pid of pids) { try { process.kill(pid, "SIGTERM"); } catch {} }
|
|
69
|
+
const until = Date.now() + 3000;
|
|
70
|
+
while (Date.now() < until && runningPids(app).length) spawnSync("/bin/sleep", ["0.1"]);
|
|
71
|
+
for (const pid of runningPids(app)) { try { process.kill(pid, "SIGKILL"); } catch {} }
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ---------- commands ----------
|
|
76
|
+
|
|
77
|
+
async function install() {
|
|
78
|
+
checkMac();
|
|
79
|
+
const app = appPath();
|
|
80
|
+
checkOwnership(app);
|
|
81
|
+
|
|
82
|
+
const have = fs.existsSync(app) ? appVersion(app) : null;
|
|
83
|
+
if (have === RELEASE.version && !flags.has("--force")) {
|
|
84
|
+
say(`Tally ${have} is already installed at ${app}.`);
|
|
85
|
+
say(`For a newer version: npx tally-menubar@latest update`);
|
|
86
|
+
if (!flags.has("--no-open")) run("/usr/bin/open", [app]);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
say(have ? `Updating Tally ${have} → ${RELEASE.version}` : `Installing Tally ${RELEASE.version}`);
|
|
91
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "tally-"));
|
|
92
|
+
try {
|
|
93
|
+
// 1. download
|
|
94
|
+
const res = await fetch(RELEASE.url, { signal: AbortSignal.timeout(120000) });
|
|
95
|
+
if (!res.ok) fail(`download failed: HTTP ${res.status} from ${RELEASE.url}`);
|
|
96
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
97
|
+
say(` downloaded ${(buf.length / 1e6).toFixed(1)} MB`);
|
|
98
|
+
|
|
99
|
+
// 2. verify against the checksum shipped inside this package
|
|
100
|
+
const sum = crypto.createHash("sha256").update(buf).digest("hex");
|
|
101
|
+
if (sum !== RELEASE.sha256) fail(`checksum mismatch, refusing to install.\n expected ${RELEASE.sha256}\n got ${sum}`);
|
|
102
|
+
say(" checksum ok");
|
|
103
|
+
|
|
104
|
+
// 3. unpack and sanity-check the bundle
|
|
105
|
+
const zip = path.join(tmp, "Tally.zip");
|
|
106
|
+
fs.writeFileSync(zip, buf);
|
|
107
|
+
run("/usr/bin/ditto", ["-x", "-k", zip, path.join(tmp, "out")]);
|
|
108
|
+
const fresh = path.join(tmp, "out", "Tally.app");
|
|
109
|
+
if (!fs.existsSync(fresh) || bundleId(fresh) !== BUNDLE_ID) fail("the download did not contain Tally.app.");
|
|
110
|
+
try { run("/usr/bin/codesign", ["--verify", "--deep", "--strict", fresh]); } catch { fail("Tally.app failed its code-signature integrity check."); }
|
|
111
|
+
|
|
112
|
+
// 4. swap it in: copy beside the target, then two renames
|
|
113
|
+
fs.mkdirSync(path.dirname(app), { recursive: true });
|
|
114
|
+
const staged = app + ".new", old = app + ".old";
|
|
115
|
+
fs.rmSync(staged, { recursive: true, force: true });
|
|
116
|
+
fs.rmSync(old, { recursive: true, force: true });
|
|
117
|
+
run("/usr/bin/ditto", [fresh, staged]);
|
|
118
|
+
const wasRunning = quit(app);
|
|
119
|
+
if (fs.existsSync(app)) fs.renameSync(app, old);
|
|
120
|
+
fs.renameSync(staged, app);
|
|
121
|
+
fs.rmSync(old, { recursive: true, force: true });
|
|
122
|
+
tryRun("/usr/bin/xattr", ["-dr", "com.apple.quarantine", app]); // normally absent: Node downloads aren't quarantined
|
|
123
|
+
say(` installed ${app}`);
|
|
124
|
+
|
|
125
|
+
if (!flags.has("--no-open")) {
|
|
126
|
+
run("/usr/bin/open", [app]);
|
|
127
|
+
say(wasRunning ? " restarted Tally" : " opened Tally: look for it in the menu bar");
|
|
128
|
+
}
|
|
129
|
+
if (have) say("\nmacOS may ask once more to let Tally read your Claude login from the Keychain; choose Always Allow.");
|
|
130
|
+
} finally {
|
|
131
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function usage() {
|
|
136
|
+
checkMac();
|
|
137
|
+
const app = appPath();
|
|
138
|
+
if (!fs.existsSync(app)) fail("Tally isn't installed. Run: npx tally-menubar");
|
|
139
|
+
const r = spawnSync(path.join(app, "Contents", "MacOS", "Tally"), ["--dump"], { stdio: "inherit" });
|
|
140
|
+
process.exit(r.status ?? 1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function uninstall() {
|
|
144
|
+
checkMac();
|
|
145
|
+
const app = appPath();
|
|
146
|
+
if (!fs.existsSync(app)) { say("Tally isn't installed."); return; }
|
|
147
|
+
checkOwnership(app);
|
|
148
|
+
quit(app);
|
|
149
|
+
fs.rmSync(app, { recursive: true, force: true });
|
|
150
|
+
say(`Removed ${app}`);
|
|
151
|
+
if (flags.has("--purge")) {
|
|
152
|
+
tryRun("/usr/bin/defaults", ["delete", BUNDLE_ID]);
|
|
153
|
+
say("Removed Tally's settings");
|
|
154
|
+
} else {
|
|
155
|
+
say("Settings were kept; add --purge to remove them too.");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function help() {
|
|
160
|
+
say(`tally-menubar ${PKG.version}: installs Tally ${RELEASE.version}, AI plan limits in your macOS menu bar
|
|
161
|
+
|
|
162
|
+
npx tally-menubar install Tally and open it
|
|
163
|
+
npx tally-menubar@latest update update to the newest version
|
|
164
|
+
npx tally-menubar usage print spend, tokens and limits in the terminal
|
|
165
|
+
npx tally-menubar uninstall remove Tally (--purge also removes its settings)
|
|
166
|
+
npx tally-menubar version show versions
|
|
167
|
+
|
|
168
|
+
Options: --no-open (don't launch after installing), --force (reinstall)
|
|
169
|
+
Installs to ~/Applications, or /Applications if Tally is already there.
|
|
170
|
+
https://github.com/PratikRai0101/tally`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function version() {
|
|
174
|
+
const app = appPath();
|
|
175
|
+
say(`tally-menubar ${PKG.version} (installs Tally ${RELEASE.version})`);
|
|
176
|
+
say(fs.existsSync(app) ? `installed: Tally ${appVersion(app)} at ${app}` : "installed: none");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const commands = { install, update: install, usage, uninstall, version, help };
|
|
180
|
+
if (flags.has("--help") || flags.has("-h")) help();
|
|
181
|
+
else if (flags.has("--version") || flags.has("-v")) version();
|
|
182
|
+
else if (!commands[cmd]) { help(); process.exit(1); }
|
|
183
|
+
else (async () => commands[cmd]())().catch((e) => {
|
|
184
|
+
process.stderr.write("tally-menubar: " + e.message + "\n");
|
|
185
|
+
process.exit(1);
|
|
186
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tally-menubar",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Install Tally, the macOS menu bar app that shows your AI coding plan limits, resets and spend (Claude, Codex, OpenCode).",
|
|
5
|
+
"keywords": ["macos", "menubar", "claude", "codex", "opencode", "usage", "limits", "ai"],
|
|
6
|
+
"homepage": "https://github.com/PratikRai0101/tally",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/PratikRai0101/tally.git", "directory": "npm" },
|
|
8
|
+
"bugs": "https://github.com/PratikRai0101/tally/issues",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"bin": { "tally-menubar": "bin/tally.js" },
|
|
11
|
+
"files": ["bin", "release.json", "LICENSE"],
|
|
12
|
+
"os": ["darwin"],
|
|
13
|
+
"engines": { "node": ">=18" },
|
|
14
|
+
"scripts": {
|
|
15
|
+
"pin": "node scripts/pin-release.mjs"
|
|
16
|
+
}
|
|
17
|
+
}
|