cost-bubble 0.1.2 → 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,63 +1,72 @@
1
1
  # Cost Bubble
2
2
 
3
- See the estimated cost of the chat you have open in Codex, Claude Code or Antigravity on macOS. One native floating pill sits beside the active app’s sidebar. The arrow marks the open chat. Up to two other recent chats appear beneath it when they have a positive recorded cost in the last five minutes, largest recent spend first. Each row shows its selected-period estimate. Claude Code uses the current signed-in desktop catalog, which can include chats from different working directories. Hover to see recent chats, or click a title to switch to it.
3
+ **Live session cost and context monitoring for Codex, Claude Code, and Antigravity on macOS.**
4
4
 
5
- ![Current chat and another chat with recent spend](docs/compact.png)
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
- ## Install on macOS 14 or later
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
- With Node.js 22.15 or later and Apple’s Command Line Tools installed, run the [npm installer](https://www.npmjs.com/package/cost-bubble) in Terminal:
11
+ ## What It Shows
10
12
 
11
- ```sh
12
- npx cost-bubble@latest install
13
- ```
13
+ - **Live session pulse** — Automatically follows your open chat (`▸`) in **Codex**, **Claude Code**, or **Antigravity Desktop**, plus up to two other chats with spend in the last 5 minutes.
14
+ - **Context-window gauge** — Four cyan signal bars show how much of the model’s context window the latest request used. 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, switch between today and lifetime totals, sort by recency, cost, or activity, 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
- This installs the Cost Bubble app, its CodeBurn pricing reader and its login item for your Mac account. Once it launches, enable **Cost Bubble** under **System Settings → Privacy & Security → Accessibility** and open a supported chat.
19
+ ---
16
20
 
17
- Prefer a globally installed command? Run `npm install --global cost-bubble`, then `cost-bubble install`.
21
+ ## Install
18
22
 
19
- You can also install the pinned GitHub release with `npx --allow-git=root github:anopows/cost-bubble#v0.1.2 install`.
23
+ Requires **macOS 14+**, **Node.js 18+**, and **Python 3.8+**.
20
24
 
21
- If you need the prerequisites, [install Node.js](https://nodejs.org/), then run `xcode-select --install` and let it finish. The installer builds and signs the app locally. To install from source, download and extract the [release archive](https://github.com/anopows/cost-bubble/releases), then run `./install.sh --with-codeburn` in the extracted folder.
22
-
23
- ## Enable Accessibility
25
+ ```sh
26
+ npx cost-bubble@latest install
27
+ ```
24
28
 
25
- 1. Click the gauge in the macOS menu bar and choose **Open Accessibility Settings…**. You can also open **System Settings → Privacy & Security → Accessibility**. Some macOS versions label this pane **Device Control and Data Access**.
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
- Accessibility lets the app identify the focused chat, measure the sidebar and open a chat you click. If a rebuild stops recognizing chats even though the switch is on, remove its old entry with **−**, then add the installed app again. Restart the helper from Terminal if needed.
31
+ ### Enable Accessibility
30
32
 
31
- ```sh
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
- ## Use the pill
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
- | Action | What you see |
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. 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
- ![Cost expansion showing ordinary subagents and automatic reviews separately](docs/cost-detail.png)
41
+ ## Using the Pill
47
42
 
48
- ![Example session list with the current chat first and estimates beside each title](docs/preview.png)
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
+ | **Click the total** | Toggles row prices between **Today** and **Lifetime** estimates for the listed chats. |
50
+ | **Click `⇅`** | Cycles row order between **Recent**, **Cost**, and **Activity** (last 5 minutes). |
51
+ | **Drag, 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
- ## How estimates work
53
+ ---
51
54
 
52
- Cost Bubble matches the selected chat to local session metadata and looks up that session’s estimate in [CodeBurn](https://github.com/getagentseal/codeburn). A dash means pricing is unavailable. A ≥ amount is the priced portion of a session with incomplete cost data. When a refresh fails, the HUD keeps its last successful reading and continues to age recent spend out of the five-minute window. Subscription invoices and API bills can differ from the estimate. The cost expansion shows recorded spend in the last five minutes and hour. A session’s average, peak and latest amounts use Claude turns or individual Codex and Antigravity requests. Purple dots represent ordinary subagents (up to four dots). Automatic reviewers appear only in the cost expansion. Their usage contributes to the estimate where the provider prices it. A dash beside a group means some of its pricing is unavailable. The HUD identifies automatic reviewers from recorded roles and models. If a provider omits request-level prices or timestamps, that usage cannot qualify a chat for a recent-spend row.
55
+ ## How Estimates Work
53
56
 
54
- The Swift app uses the same rows, gestures, sorting and cost expansion across all three apps. Local readers normalize desktop records and transcripts. Codex reviewer metadata is cached by file identity so older compressed rollouts are read only when they change. The installer preserves custom `CODEX_HOME`, `CLAUDE_CONFIG_DIR` and `CODEBURN_CACHE_DIR` paths set in your shell. Desktop updates that change local storage or sidebar navigation can affect detection.
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; a **`≥`** amount reflects the priced portion of a session with incomplete cost data. Estimates may differ from subscription invoices or API bills.
58
+ - **Context-window bars:** Measures the latest request’s input tokens (including cached input) against the recorded context window (read from matching local generation records for Antigravity Desktop). Bars stay gray when the provider omits the limit; hover still shows the recorded token count.
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
- ## Update or remove
63
+ ---
57
64
 
58
- If you previously used Desktop Session HUD, install Cost Bubble and grant it Accessibility. Once you see the new pill, unload the earlier login agent with `launchctl bootout "gui/$(id -u)/local.costhud.desktop"`. Move the earlier agent plist out of `~/Library/LaunchAgents/` to prevent a second pill at the next login. You can keep the earlier app as a backup. The new app has its own saved positions and zoom setting.
65
+ ## Update & Uninstall
59
66
 
60
- To update, run the new release’s installer. To stop the helper for this login, use its menu bar **Quit** command. To remove it, unload the login agent with the following command, then use Finder’s **Go → Go to Folder…** to locate and move the listed items to the Trash.
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/Application Support/Cost Bubble/` (the pricing reader installed by the npm command)
77
+ - `~/Library/Caches/io.github.anopows.cost-bubble/` *(optional pricing and scan cache)*
69
78
 
70
- You can also remove the Accessibility entry in System Settings.
79
+ ---
71
80
 
72
81
  ## Development
73
82
 
74
- Run `/usr/bin/python3 -B -m unittest -v` for session-reader tests. Use `./build.sh /absolute/path/Cost Bubble.app` to build without installing. Run the resulting app’s `Contents/MacOS/SessionHUD --check-bundle` to verify that its bundled reader loads. Released under the [MIT License](LICENSE).
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).
@@ -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
- const result = spawnSync('/bin/bash', [installer, '--with-codeburn'], { stdio: 'inherit' });
9
- if (result.error) console.error(result.error.message);
10
- process.exitCode = result.status ?? 1;
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, its pricing reader and its login agent for your account.');
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. All installation paths belong to the current user.
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
- if ! xcrun --find swiftc >/dev/null 2>&1 || ! /usr/bin/python3 -c 'import sqlite3, plistlib' >/dev/null 2>&1; then
17
- echo "Install Apple's Command Line Tools with xcode-select --install, then run this installer again." >&2
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
- node="$(command -v node || true)"
21
- if [[ "$node" != /* ]]; then
22
- echo "Install Node.js 22.15 or later, then run this installer again." >&2
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
- "$node" -e 'const [major, minor] = process.versions.node.split(".").map(Number); process.exit(major > 22 || major === 22 && minor >= 15 ? 0 : 1)' ||
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
- ./build.sh "$stage/$name.app"
86
- /usr/bin/python3 - "$stage/agent.plist" "$label" "$app" "$codeburn" "$node" <<'PY'
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, codeburn, node = sys.argv[1:]
90
- bins = [str(Path(node).parent), str(Path(codeburn).parent), "/opt/homebrew/bin", "/usr/local/bin", "/usr/bin", "/bin"]
91
- env = {"PATH": os.pathsep.join(dict.fromkeys(bins)), "CODEBURN_BIN": codeburn}
92
- for key in ("CODEX_HOME", "CLAUDE_CONFIG_DIR", "CODEBURN_CACHE_DIR"):
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.1.2",
3
+ "version": "0.2.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": ">=22.15.0"
15
+ "node": ">=18.0.0"
16
16
  },
17
17
  "bin": {
18
18
  "cost-bubble": "bin/cost-bubble.cjs"
@@ -20,14 +20,14 @@
20
20
  "files": [
21
21
  "bin/",
22
22
  "install.sh",
23
- "build.sh",
24
- "Info.plist",
25
- "Sources/",
26
- "session_cost.py",
27
- "codex_sessions.py",
28
- "usage_activity.py",
29
- "reviewer_records.py",
30
- "local_database.py",
31
- "docs/*.png"
32
- ]
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
+ }
33
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
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "teamID": "4YJ6CF8CRP",
4
+ "sha256": "2630324e30a25fa5da2ba325aaa3e6ce9c13481924c9386f536ecda12c4bced8"
5
+ }
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.2</string>
17
- <key>CFBundleVersion</key>
18
- <string>3</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>
@@ -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
- }