cost-bubble 0.1.3 → 0.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/README.md +71 -40
- package/bin/cost-bubble.cjs +11 -4
- package/docs/demo.gif +0 -0
- package/install.sh +42 -35
- package/package.json +12 -13
- package/scripts/signed-release.cjs +20 -0
- package/scripts/unpack-release.sh +15 -0
- package/scripts/verify-release-app.sh +16 -0
- package/signed-release.json +5 -0
- package/Info.plist +0 -26
- package/Sources/ChatLine.swift +0 -101
- package/Sources/CostBreakdown.swift +0 -170
- package/Sources/DesktopNavigation.swift +0 -134
- package/Sources/DesktopSurfaces.swift +0 -116
- package/Sources/HUDController.swift +0 -360
- package/Sources/HUDControls.swift +0 -100
- package/Sources/HUDGestures.swift +0 -81
- package/Sources/SessionData.swift +0 -99
- package/Sources/SessionPresentation.swift +0 -74
- package/Sources/SessionUpdates.swift +0 -182
- package/Sources/main.swift +0 -10
- package/antigravity_context.py +0 -83
- package/build.sh +0 -13
- package/codex_sessions.py +0 -146
- package/local_database.py +0 -37
- package/reviewer_records.py +0 -87
- package/session_cost.py +0 -402
- package/usage_activity.py +0 -189
package/README.md
CHANGED
|
@@ -1,63 +1,72 @@
|
|
|
1
1
|
# Cost Bubble
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Live session cost and context monitoring for Codex, Claude Code, and Antigravity on macOS.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Cost Bubble sits as a lightweight native floating pill right beside your AI coding app’s sidebar—keeping the open session’s estimated spend, context-window fill, and active background chats visible at a glance without breaking your flow.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="docs/demo.gif" alt="Cost Bubble following a Codex session switch, expanding on hover, inspecting token context and full cost breakdown, then minimizing on hover away" width="840" />
|
|
9
|
+
</p>
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## What It Shows
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
- **Live session pulse** — Automatically follows your open chat (`▸`) in **Codex**, **Claude Code**, or **Antigravity Desktop**, plus up to two other chats ranked by recent spend, weighted with a 150-second half-life.
|
|
14
|
+
- **Input token gauge** — Four bars show the latest request’s input size. Their color changes at 50k, 100k, 200k and 300k tokens. Purple dots underneath mark active subagents.
|
|
15
|
+
- **Instant cost breakdown** — Hover or click any price for last-5-minute, hourly, daily, and lifetime spend, input/output and cache token splits, per-request rates, and subagent / auto-review totals.
|
|
16
|
+
- **Recent sessions on hover** — Hover the pill to compare recent chats, see today’s spend, sort by recent activity, daily cost or recency, or click any title to switch chats.
|
|
17
|
+
- **Native & unobtrusive** — Built in Swift/AppKit. Drag or resize per app; hides automatically on home screens and ordinary non-Code Claude chats.
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
---
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
## Install
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
Requires **macOS 14+**, **Node.js 18+**, and **Python 3.8+**.
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
```sh
|
|
26
|
+
npx cost-bubble@latest install
|
|
27
|
+
```
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
2. Turn on **Cost Bubble**. If it is missing, click **+**, press **Command–Shift–G**, enter `~/Applications/Cost Bubble.app` and click **Open**. Authenticate if macOS asks.
|
|
27
|
-
3. Bring an existing chat to the front in Codex, the Code section of Claude Desktop, or Antigravity Desktop. Look for its title beside the sidebar. Home screens and ordinary Claude chats do not show a session estimate.
|
|
29
|
+
This installs **Cost Bubble.app** and enables its login item for your Mac account. No API keys or external pricing CLIs are required.
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
### Enable Accessibility
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
launchctl kickstart -k "gui/$(id -u)/io.github.anopows.cost-bubble"
|
|
33
|
-
```
|
|
33
|
+
Cost Bubble uses macOS Accessibility to detect the active chat, align beside the sidebar, and jump to a chat when clicked.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
1. Click the gauge icon in the macOS menu bar and choose **Open Accessibility Settings…** (or open **System Settings → Privacy & Security → Accessibility**).
|
|
36
|
+
2. Turn on **Cost Bubble**. If it isn’t listed, click **+**, press **⌘⇧G**, enter `~/Applications/Cost Bubble.app`, and click **Open**.
|
|
37
|
+
3. Open an existing chat in **Codex**, the **Code** section of **Claude Desktop**, or **Antigravity Desktop** to see the pill appear beside the sidebar.
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
| --- | --- |
|
|
39
|
-
| Hover over the pill | The arrow marks your open chat. The list initially includes other chats active today among the 12 most recent. |
|
|
40
|
-
| Click a chat title | Opens the chat in the same desktop app. Antigravity leaves the picker open if several titles match. |
|
|
41
|
-
| Hover over the token bars | Shows the latest request’s input tokens, including cached input. Bar fill shows the fraction of the reported context window used by those tokens. For Antigravity Desktop the limit comes from the matching request in the local conversation database. When the provider omits the limit, the bars stay gray and hover still shows the recorded count. |
|
|
42
|
-
| Hover over a price | Compares the last five minutes and hour, shows the input/output share, and separates cache reads and writes. The lifetime row compares the latest, average and peak request or turn. Click to keep the breakdown open. |
|
|
43
|
-
| Click the total | Switches between today and lifetime. The total covers listed chats with estimates. |
|
|
44
|
-
| Drag the pill or use − / + | Moves or resizes it. Each app remembers its own position. |
|
|
39
|
+
---
|
|
45
40
|
|
|
46
|
-
|
|
41
|
+
## Using the Pill
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
| Action | What happens |
|
|
44
|
+
| --- | --- |
|
|
45
|
+
| **Hover the pill** | Expands to show the current chat (`▸`) plus other chats active today (from your 12 most recent). |
|
|
46
|
+
| **Hover the signal bars** | Shows the latest request’s input tokens inline and its share of the model’s context window. **Click** to pin it open. |
|
|
47
|
+
| **Hover a price** | Opens the full cost breakdown: 5-min / 1-hr / today / lifetime spend, token & cache splits, per-request rates, and subagent / auto-review totals. **Click** to pin it open. |
|
|
48
|
+
| **Click a chat title** | Switches directly to that chat in the active desktop app. *(Antigravity leaves its picker open if multiple titles match.)* |
|
|
49
|
+
| **Read the header total** | Shows today’s combined spend across this app’s chats. Lifetime estimates appear in each chat’s price breakdown. |
|
|
50
|
+
| **Click `⇅`** | Cycles row order between **Decay**, **Cost**, and **Recent**. |
|
|
51
|
+
| **Drag the left edge, pinch, or `−` / `+`** | Moves or resizes the pill—each desktop app remembers its own position. Use **`≡`** for pin, auto-fit, 12-chat history, and reset options. |
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
---
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
## How Estimates Work
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
- **Direct local pricing:** Reads your local session logs directly and prices token usage against [LiteLLM](https://github.com/BerriAI/litellm)’s public pricing catalog (refreshed daily to a local cache, with a bundled offline fallback). A **`—`** means pricing is unavailable; sessions with incomplete pricing show the sum of their priced requests. Estimates may differ from subscription invoices or API bills.
|
|
58
|
+
- **Input token bars:** Mint, cyan, yellow, orange and red mark progressively larger input sizes including cached input. Hover for the exact token count and the context-window share when recorded.
|
|
59
|
+
- **Subagents & auto-reviewers:** Up to four purple dots underneath the signal bars indicate ordinary subagents. Automatic reviewers are separated into their own row in the cost breakdown and included in totals when priced.
|
|
60
|
+
- **Per-request vs. per-turn rates:** Latest, average, and peak figures measure individual requests in Codex and Antigravity, or turns in Claude Code. If a refresh fails, the pill retains its last successful reading and continues aging spend out of the 5-minute window.
|
|
61
|
+
- **Local-only readers:** All three apps share the same Swift UI, while lightweight Python readers normalize each app’s local storage with incremental file-identity caching. Custom `CODEX_HOME` and `CLAUDE_CONFIG_DIR` paths are preserved at install time.
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
---
|
|
57
64
|
|
|
58
|
-
|
|
65
|
+
## Update & Uninstall
|
|
59
66
|
|
|
60
|
-
|
|
67
|
+
- **Update:** Re-run `npx cost-bubble@latest install`.
|
|
68
|
+
- **Quit temporarily:** Click the menu bar gauge icon and choose **Quit Cost Bubble**.
|
|
69
|
+
- **Uninstall:** Unload the login agent, move the items below to the Trash, and optionally remove **Cost Bubble** from Accessibility Settings.
|
|
61
70
|
|
|
62
71
|
```sh
|
|
63
72
|
launchctl bootout "gui/$(id -u)/io.github.anopows.cost-bubble"
|
|
@@ -65,10 +74,32 @@ launchctl bootout "gui/$(id -u)/io.github.anopows.cost-bubble"
|
|
|
65
74
|
|
|
66
75
|
- `~/Applications/Cost Bubble.app`
|
|
67
76
|
- `~/Library/LaunchAgents/io.github.anopows.cost-bubble.plist`
|
|
68
|
-
- `~/Library/
|
|
77
|
+
- `~/Library/Caches/io.github.anopows.cost-bubble/` *(optional pricing and scan cache)*
|
|
69
78
|
|
|
70
|
-
|
|
79
|
+
---
|
|
71
80
|
|
|
72
81
|
## Development
|
|
73
82
|
|
|
74
|
-
|
|
83
|
+
Building from source requires **Apple Command Line Tools** (`xcode-select --install`).
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
# Install from a local checkout
|
|
87
|
+
./install.sh
|
|
88
|
+
|
|
89
|
+
# Build without installing and verify the bundled reader loads
|
|
90
|
+
./build.sh "/absolute/path/Cost Bubble.app"
|
|
91
|
+
"/absolute/path/Cost Bubble.app/Contents/MacOS/SessionHUD" --check-bundle
|
|
92
|
+
|
|
93
|
+
# Run session-reader unit tests
|
|
94
|
+
python3 -B -m unittest -v
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If a local rebuild stops recognizing chats while Accessibility is enabled, remove and re-add `~/Applications/Cost Bubble.app` in Accessibility Settings, then restart the helper if needed:
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
launchctl kickstart -k "gui/$(id -u)/io.github.anopows.cost-bubble"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
See [Publishing a signed macOS release](docs/signed-releases.md) for signing, notarization, npm packaging, and upgrade verification.
|
|
104
|
+
|
|
105
|
+
Released under the [MIT License](LICENSE).
|
package/bin/cost-bubble.cjs
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { spawnSync } = require('node:child_process');
|
|
3
3
|
const path = require('node:path');
|
|
4
|
+
const signedRelease = require('../scripts/signed-release.cjs');
|
|
4
5
|
|
|
5
6
|
const args = process.argv.slice(2);
|
|
6
7
|
if (args.length === 1 && args[0] === 'install') {
|
|
7
8
|
const installer = path.join(__dirname, '..', 'install.sh');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
try {
|
|
10
|
+
const {version, teamID, sha256} = signedRelease();
|
|
11
|
+
const result = spawnSync('/bin/bash', [installer, '--signed', version, teamID, sha256], { stdio: 'inherit' });
|
|
12
|
+
if (result.error) throw result.error;
|
|
13
|
+
process.exitCode = result.status ?? 1;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error(error.message);
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
}
|
|
11
18
|
} else {
|
|
12
19
|
console.log('Usage: cost-bubble install');
|
|
13
|
-
console.log('Installs the macOS app
|
|
20
|
+
console.log('Installs the macOS app and its login agent for your account.');
|
|
14
21
|
if (args.length && !(args.length === 1 && ['--help', '-h'].includes(args[0]))) process.exitCode = 1;
|
|
15
22
|
}
|
package/docs/demo.gif
ADDED
|
Binary file
|
package/install.sh
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# Run from a release checkout
|
|
2
|
+
# Run from a release checkout or via `npx cost-bubble install`. All paths belong to the current user.
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
cd "$(dirname "$0")"
|
|
5
5
|
name="Cost Bubble"
|
|
@@ -13,38 +13,32 @@ job="$domain/$label"
|
|
|
13
13
|
[[ "$(uname -s)" == Darwin ]] || { echo "This installer requires macOS." >&2; exit 1; }
|
|
14
14
|
major="$(sw_vers -productVersion | cut -d. -f1)"
|
|
15
15
|
(( major >= 14 )) || { echo "macOS 14 or later is required." >&2; exit 1; }
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
case "${1:-}" in
|
|
17
|
+
--signed|"") ;;
|
|
18
|
+
*) echo "Usage: ./install.sh" >&2; exit 1 ;;
|
|
19
|
+
esac
|
|
20
|
+
if [[ "${1:-}" != "--signed" ]] && ! xcrun --find swiftc >/dev/null 2>&1; then
|
|
21
|
+
echo "Building from source requires Apple's Command Line Tools (xcode-select --install)." >&2
|
|
18
22
|
exit 1
|
|
19
23
|
fi
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
python=""
|
|
25
|
+
clt_installed=0
|
|
26
|
+
if xcode-select -p >/dev/null 2>&1; then clt_installed=1; fi
|
|
27
|
+
for candidate in "${PYTHON_BIN:-}" /opt/homebrew/bin/python3 /usr/local/bin/python3 "$(command -v python3 || true)" /usr/bin/python3; do
|
|
28
|
+
if [[ "$candidate" == "/usr/bin/python3" && "$clt_installed" -eq 0 ]]; then continue; fi
|
|
29
|
+
if [[ "$candidate" == /* && -x "$candidate" ]]; then
|
|
30
|
+
resolved="$("$candidate" -c 'import plistlib, sqlite3, sys; assert sys.version_info >= (3, 8); print(sys.executable)' 2>/dev/null || true)"
|
|
31
|
+
if [[ "$resolved" == /* && -x "$resolved" ]]; then
|
|
32
|
+
python="$resolved"
|
|
33
|
+
break
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
done
|
|
37
|
+
if [[ -z "$python" ]]; then
|
|
38
|
+
echo "Python 3.8+ with sqlite3 is required (install via Homebrew or xcode-select --install), then run this installer again." >&2
|
|
23
39
|
exit 1
|
|
24
40
|
fi
|
|
25
|
-
|
|
26
|
-
{ echo "CodeBurn requires Node.js 22.15 or later." >&2; exit 1; }
|
|
27
|
-
case "${1:-}" in
|
|
28
|
-
--with-codeburn)
|
|
29
|
-
# The login agent must be able to run after npm's temporary cache is cleared.
|
|
30
|
-
version=0.9.28
|
|
31
|
-
runtime="$HOME/Library/Application Support/Cost Bubble/codeburn-$version"
|
|
32
|
-
codeburn="$runtime/node_modules/.bin/codeburn"
|
|
33
|
-
if [[ ! -x "$codeburn" ]] || ! "$codeburn" --version >/dev/null 2>&1; then
|
|
34
|
-
mkdir -p "$runtime"
|
|
35
|
-
npm install --prefix "$runtime" --global=false --no-save --package-lock=false --no-audit --no-fund "codeburn@$version"
|
|
36
|
-
fi
|
|
37
|
-
;;
|
|
38
|
-
"")
|
|
39
|
-
codeburn="$(command -v codeburn || true)"
|
|
40
|
-
if [[ "$codeburn" != /* ]]; then
|
|
41
|
-
echo "Run ./install.sh --with-codeburn to install the pricing reader too." >&2
|
|
42
|
-
exit 1
|
|
43
|
-
fi
|
|
44
|
-
;;
|
|
45
|
-
*) echo "Usage: ./install.sh [--with-codeburn]" >&2; exit 1 ;;
|
|
46
|
-
esac
|
|
47
|
-
"$codeburn" --version >/dev/null
|
|
41
|
+
export PYTHON_BIN="$python"
|
|
48
42
|
if [[ -e "$app" ]] && [[ "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$app/Contents/Info.plist" 2>/dev/null || true)" != "$label" ]]; then
|
|
49
43
|
echo "An unrelated app already exists at $app. Choose a different location for it first." >&2
|
|
50
44
|
exit 1
|
|
@@ -82,14 +76,27 @@ cleanup() {
|
|
|
82
76
|
}
|
|
83
77
|
trap cleanup EXIT
|
|
84
78
|
trap 'exit 1' HUP INT TERM
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
if [[ "${1:-}" == "--signed" ]]; then
|
|
80
|
+
version=${2:?Expected release version}
|
|
81
|
+
archive="$stage/release.zip"
|
|
82
|
+
/usr/bin/curl --fail --silent --show-error --location --retry 2 --proto '=https' --proto-redir '=https' \
|
|
83
|
+
"https://github.com/anopows/cost-bubble/releases/download/v$version/Cost-Bubble-macOS.zip" -o "$archive"
|
|
84
|
+
./scripts/unpack-release.sh "$archive" "$stage/unpacked" "$3" "$version" "$4"
|
|
85
|
+
mv "$stage/unpacked/$name.app" "$stage/$name.app"
|
|
86
|
+
else
|
|
87
|
+
./build.sh "$stage/$name.app"
|
|
88
|
+
fi
|
|
89
|
+
node_bin="$(command -v node || true)"
|
|
90
|
+
"$python" - "$stage/agent.plist" "$label" "$app" "$python" "$node_bin" <<'PY'
|
|
87
91
|
import os, plistlib, sys
|
|
88
92
|
from pathlib import Path
|
|
89
|
-
destination, label, app,
|
|
90
|
-
bins = [str(Path(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
destination, label, app, python, node_bin = sys.argv[1:]
|
|
94
|
+
bins = [str(Path(python).parent)]
|
|
95
|
+
if node_bin.startswith("/"):
|
|
96
|
+
bins.append(str(Path(node_bin).parent))
|
|
97
|
+
bins.extend(["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin"])
|
|
98
|
+
env = {"PATH": os.pathsep.join(dict.fromkeys(bins)), "PYTHON_BIN": python}
|
|
99
|
+
for key in ("CODEX_HOME", "CLAUDE_CONFIG_DIR"):
|
|
93
100
|
if os.environ.get(key):
|
|
94
101
|
env[key] = str(Path(os.environ[key]).expanduser().resolve())
|
|
95
102
|
with open(destination, "wb") as stream:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cost-bubble",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A macOS cost HUD for Codex, Claude Code and Antigravity.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"darwin"
|
|
13
13
|
],
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
15
|
+
"node": ">=18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"bin": {
|
|
18
18
|
"cost-bubble": "bin/cost-bubble.cjs"
|
|
@@ -20,15 +20,14 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"bin/",
|
|
22
22
|
"install.sh",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
]
|
|
23
|
+
"scripts/signed-release.cjs",
|
|
24
|
+
"scripts/unpack-release.sh",
|
|
25
|
+
"scripts/verify-release-app.sh",
|
|
26
|
+
"signed-release.json",
|
|
27
|
+
"docs/*.png",
|
|
28
|
+
"docs/demo.gif"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"prepack": "node scripts/signed-release.cjs"
|
|
32
|
+
}
|
|
34
33
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Validate release metadata before packing or installing. Only the publisher creates this file.
|
|
2
|
+
const fs = require('node:fs');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const {version} = require('../package.json');
|
|
5
|
+
|
|
6
|
+
function release() {
|
|
7
|
+
const file = path.join(__dirname, '..', 'signed-release.json');
|
|
8
|
+
if (!fs.existsSync(file)) throw new Error('This checkout has no signed release manifest.');
|
|
9
|
+
const data = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
10
|
+
if (!data || typeof data.teamID !== 'string' || typeof data.sha256 !== 'string' ||
|
|
11
|
+
data.version !== version || !/^\d+\.\d+\.\d+$/.test(version) ||
|
|
12
|
+
!/^[A-Z0-9]{10}$/.test(data.teamID) || !/^[a-f0-9]{64}$/.test(data.sha256)) {
|
|
13
|
+
throw new Error('The signed release manifest is invalid or belongs to a different version.');
|
|
14
|
+
}
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
module.exports = release;
|
|
18
|
+
if (require.main === module) {
|
|
19
|
+
try { release(); } catch (error) { console.error(error.message); process.exitCode = 1; }
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# The caller supplies a fresh staging directory. Verify before running any bundled code.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
archive=$1
|
|
5
|
+
destination=$2
|
|
6
|
+
team=$3
|
|
7
|
+
version=$4
|
|
8
|
+
digest=$5
|
|
9
|
+
actual=$(/usr/bin/shasum -a 256 "$archive")
|
|
10
|
+
[[ "${actual%% *}" == "$digest" ]] || { echo "The release archive checksum does not match." >&2; exit 1; }
|
|
11
|
+
/usr/bin/ditto -x -k "$archive" "$destination"
|
|
12
|
+
app="$destination/Cost Bubble.app"
|
|
13
|
+
"$(dirname "$0")/verify-release-app.sh" "$app" "$team" "$version"
|
|
14
|
+
/usr/sbin/spctl --assess --type execute "$app"
|
|
15
|
+
"$app/Contents/MacOS/SessionHUD" --check-bundle
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
app=${1:?Expected an app bundle}
|
|
4
|
+
team=${2:?Expected an Apple Team ID}
|
|
5
|
+
version=${3:?Expected a release version}
|
|
6
|
+
[[ "$team" =~ ^[A-Z0-9]{10}$ ]] || { echo "Invalid Apple Team ID." >&2; exit 1; }
|
|
7
|
+
# Require Apple's Developer ID intermediate and Application certificate extensions.
|
|
8
|
+
requirement="identifier \"io.github.anopows.cost-bubble\" and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] exists and certificate leaf[field.1.2.840.113635.100.6.1.13] exists and certificate leaf[subject.OU] = \"$team\""
|
|
9
|
+
/usr/bin/codesign --verify --strict --all-architectures -R "=$requirement" "$app"
|
|
10
|
+
[[ "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$app/Contents/Info.plist")" == "$version" ]] || {
|
|
11
|
+
echo "The signed app does not match the requested release version." >&2; exit 1;
|
|
12
|
+
}
|
|
13
|
+
arch_info=$(/usr/bin/file -b "$app/Contents/MacOS/SessionHUD")
|
|
14
|
+
[[ "$arch_info" == *"(for architecture arm64):"* && "$arch_info" == *"(for architecture x86_64):"* ]] || {
|
|
15
|
+
echo "The signed app is not a universal arm64/x86_64 binary." >&2; exit 1;
|
|
16
|
+
}
|
package/Info.plist
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>CFBundleDisplayName</key>
|
|
6
|
-
<string>Cost Bubble</string>
|
|
7
|
-
<key>CFBundleExecutable</key>
|
|
8
|
-
<string>SessionHUD</string>
|
|
9
|
-
<key>CFBundleIdentifier</key>
|
|
10
|
-
<string>io.github.anopows.cost-bubble</string>
|
|
11
|
-
<key>CFBundleName</key>
|
|
12
|
-
<string>Cost Bubble</string>
|
|
13
|
-
<key>CFBundlePackageType</key>
|
|
14
|
-
<string>APPL</string>
|
|
15
|
-
<key>CFBundleShortVersionString</key>
|
|
16
|
-
<string>0.1.3</string>
|
|
17
|
-
<key>CFBundleVersion</key>
|
|
18
|
-
<string>4</string>
|
|
19
|
-
<key>LSMinimumSystemVersion</key>
|
|
20
|
-
<string>14.0</string>
|
|
21
|
-
<key>LSUIElement</key>
|
|
22
|
-
<true/>
|
|
23
|
-
<key>NSAccessibilityUsageDescription</key>
|
|
24
|
-
<string>Identify the open desktop chat, position its cost pill, and open the conversation you click in the HUD.</string>
|
|
25
|
-
</dict>
|
|
26
|
-
</plist>
|
package/Sources/ChatLine.swift
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import AppKit
|
|
2
|
-
import ApplicationServices
|
|
3
|
-
|
|
4
|
-
final class SignalBars: NSView {
|
|
5
|
-
var agentCount = 0 { didSet { if oldValue != agentCount { needsDisplay = true } } }
|
|
6
|
-
var contextFraction: Double? { didSet { if oldValue != contextFraction { needsDisplay = true } } }
|
|
7
|
-
override func draw(_ dirtyRect: NSRect) {
|
|
8
|
-
let unit = bounds.width / 17
|
|
9
|
-
for index in 0..<4 {
|
|
10
|
-
let height = CGFloat(4 + index * 3) * unit
|
|
11
|
-
NSColor.white.withAlphaComponent(0.18).setFill()
|
|
12
|
-
let rect = NSRect(x: CGFloat(index) * 4.5 * unit, y: agentCount > 0 ? 4 * unit : unit, width: 2.8 * unit, height: agentCount > 0 ? height * 0.78 : height)
|
|
13
|
-
let shape = NSBezierPath(roundedRect: rect, xRadius: unit, yRadius: unit)
|
|
14
|
-
shape.fill()
|
|
15
|
-
let portion = min(1, max(0, (contextFraction ?? 0) * 4 - Double(index)))
|
|
16
|
-
if portion > 0 {
|
|
17
|
-
NSGraphicsContext.saveGraphicsState()
|
|
18
|
-
NSBezierPath(rect: NSRect(x: rect.minX, y: rect.minY, width: rect.width,
|
|
19
|
-
height: rect.height * CGFloat(portion))).addClip()
|
|
20
|
-
NSColor.systemCyan.setFill()
|
|
21
|
-
shape.fill()
|
|
22
|
-
NSGraphicsContext.restoreGraphicsState()
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
NSColor.systemPurple.setFill()
|
|
26
|
-
for index in 0..<min(4, agentCount) {
|
|
27
|
-
NSBezierPath(ovalIn: CGRect(x: CGFloat(index)*4.5*unit, y: 0, width: 2.8*unit, height: 2.8*unit)).fill()
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
final class SessionTitle: NSTextField {
|
|
33
|
-
var openSession: (() -> Void)?
|
|
34
|
-
override func accessibilityPerformPress() -> Bool {
|
|
35
|
-
guard let openSession else { return false }
|
|
36
|
-
openSession()
|
|
37
|
-
return true
|
|
38
|
-
}
|
|
39
|
-
override func resetCursorRects() {
|
|
40
|
-
super.resetCursorRects()
|
|
41
|
-
addCursorRect(bounds, cursor: .pointingHand)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
final class ChatLine: NSView {
|
|
46
|
-
let price = NSTextField(labelWithString: "")
|
|
47
|
-
let bars = SignalBars()
|
|
48
|
-
let tokenLabel = NSTextField(labelWithString: "")
|
|
49
|
-
let arrow = NSTextField(labelWithString: "▸")
|
|
50
|
-
let label = SessionTitle(labelWithString: "")
|
|
51
|
-
var zoom: CGFloat = 1
|
|
52
|
-
override init(frame: NSRect) {
|
|
53
|
-
super.init(frame: frame)
|
|
54
|
-
for view in [price, bars, tokenLabel, arrow, label] { addSubview(view) }
|
|
55
|
-
tokenLabel.textColor = .systemCyan
|
|
56
|
-
tokenLabel.isHidden = true
|
|
57
|
-
label.lineBreakMode = .byTruncatingTail
|
|
58
|
-
label.cell?.usesSingleLineMode = true
|
|
59
|
-
label.maximumNumberOfLines = 1
|
|
60
|
-
label.setAccessibilityRole(.button)
|
|
61
|
-
arrow.textColor = .systemCyan
|
|
62
|
-
}
|
|
63
|
-
required init?(coder: NSCoder) { nil }
|
|
64
|
-
|
|
65
|
-
func show(_ row: DisplayRow, zoom: CGFloat) {
|
|
66
|
-
self.zoom = zoom
|
|
67
|
-
price.stringValue = row.amount
|
|
68
|
-
price.font = .monospacedDigitSystemFont(ofSize: 15 * zoom, weight: .bold)
|
|
69
|
-
price.textColor = row.current ? .systemYellow : NSColor.white.withAlphaComponent(0.76)
|
|
70
|
-
price.toolTip = row.tooltip
|
|
71
|
-
label.stringValue = row.title.split(whereSeparator: \.isWhitespace).joined(separator: " ")
|
|
72
|
-
label.font = .systemFont(ofSize: 12.5 * zoom, weight: row.current ? .bold : .semibold)
|
|
73
|
-
label.textColor = row.current ? .white : NSColor.white.withAlphaComponent(0.73)
|
|
74
|
-
label.toolTip = row.title
|
|
75
|
-
bars.agentCount = row.agentCount
|
|
76
|
-
bars.contextFraction = row.contextFraction
|
|
77
|
-
bars.setAccessibilityLabel(row.agentCount == 0 ? "Session tokens" : "Session tokens, \(row.agentCount) subagents")
|
|
78
|
-
bars.setAccessibilityValue(row.contextFraction?.formatted(.percent) ?? "Context window unavailable")
|
|
79
|
-
bars.setAccessibilityElement(true)
|
|
80
|
-
tokenLabel.font = .monospacedDigitSystemFont(ofSize: 12*zoom, weight: .semibold)
|
|
81
|
-
arrow.isHidden = !row.current
|
|
82
|
-
arrow.font = .systemFont(ofSize: 9 * zoom, weight: .bold)
|
|
83
|
-
needsLayout = true
|
|
84
|
-
}
|
|
85
|
-
override func layout() {
|
|
86
|
-
super.layout()
|
|
87
|
-
func fit(_ field: NSTextField, at x: CGFloat, width: CGFloat? = nil) -> CGFloat {
|
|
88
|
-
let size = field.intrinsicContentSize
|
|
89
|
-
let height = min(bounds.height, size.height)
|
|
90
|
-
field.frame = CGRect(x: x, y: ((bounds.height-height)/2).rounded(),
|
|
91
|
-
width: width ?? ceil(size.width), height: height)
|
|
92
|
-
return field.frame.maxX
|
|
93
|
-
}
|
|
94
|
-
var x = fit(price, at: 0) + 9 * zoom
|
|
95
|
-
bars.frame = CGRect(x: x, y: (bounds.height - 15 * zoom)/2, width: 17 * zoom, height: 15 * zoom)
|
|
96
|
-
x = bars.frame.maxX + 7 * zoom
|
|
97
|
-
if !tokenLabel.isHidden { x = fit(tokenLabel, at: x, width: min(tokenLabel.intrinsicContentSize.width, bounds.width*0.46)) + 4*zoom }
|
|
98
|
-
if !arrow.isHidden { x = fit(arrow, at: x) }
|
|
99
|
-
_ = fit(label, at: x, width: max(0, bounds.width-x))
|
|
100
|
-
}
|
|
101
|
-
}
|