Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b8d7944
Prepare Reviewed CodeCaps Release Sources (1/6)
swu-codex[bot] Nov 3, 2026
c4d9e66
Prepare Reviewed CodeCaps Release Sources (2/6)
swu-codex[bot] Nov 3, 2026
70cd5be
Prepare Reviewed CodeCaps Release Sources (3/6)
swu-codex[bot] Nov 3, 2026
1efbc7c
Prepare Reviewed CodeCaps Release Sources (4/6)
swu-codex[bot] Nov 3, 2026
4fdf430
Prepare Reviewed CodeCaps Release Sources (5/6)
swu-codex[bot] Nov 3, 2026
6685568
Prepare Reviewed CodeCaps Release Sources (6/6)
swu-codex[bot] Nov 3, 2026
3b1c8c6
Record Exact Runtime Key Validation Scanner False Positive
swu-codex[bot] Nov 3, 2026
9e0007f
Tighten quota-reset evidence.
swu-codex[bot] Nov 3, 2026
630a2c0
Pin the MiniMax stale-weekly regression.
swu-codex[bot] Nov 3, 2026
b472d10
Hide only managed windows when keeping running.
swu-codex[bot] Nov 3, 2026
d401a87
Select only managed content windows.
swu-codex[bot] Nov 3, 2026
4600429
Test keep-running window selection.
swu-codex[bot] Nov 3, 2026
47c64ec
Suppress false vendor resets while preserving valid refills
swu-codex[bot] Nov 3, 2026
d9e058a
Cover weekly deadline nudges and small full restores
swu-codex[bot] Nov 3, 2026
63a62d7
Confine Muse bridge delivery state to the main actor
swu-codex[bot] Nov 3, 2026
294d697
Cancel SMS delivery tasks when setup changes
swu-codex[bot] Nov 3, 2026
6fb29cf
Honor cancellation before sending reserved SMS
swu-codex[bot] Nov 3, 2026
afb2a70
Test that Forget cancels in-flight SMS delivery
swu-codex[bot] Nov 3, 2026
a7c5cb9
Match provider window labels exactly
swu-codex[bot] Nov 3, 2026
e0d429f
Test exact canonical provider window labels
swu-codex[bot] Nov 3, 2026
0a40ff2
Resolve symlinked task lanes before version planning
swu-codex[bot] Nov 3, 2026
7521629
Cover symlinked release version planning
swu-codex[bot] Nov 3, 2026
90bada8
Fix exact Antigravity quota labels
swu-codex[bot] Nov 3, 2026
5f4b4aa
Refresh Cursor quota timestamps after fetching
swu-codex[bot] Nov 3, 2026
a8a4fa0
Expire obsolete CodeCaps builds and App Store versions
swu-codex[bot] Nov 3, 2026
cf68042
Align release contract test with 0.1.0
swu-codex[bot] Nov 3, 2026
05527c4
Merge branch 'main' into codex/cc-205-release-ready
jaywedgeworth22 Nov 5, 2026
e442df4
Add Release Readiness Follow-Up Missing From PR 357 (#361)
jaywedgeworth22 Nov 6, 2026
c541753
Fix non-optional binding in the fresh-period check
jaywedgeworth22 Nov 8, 2026
29625ad
Merge origin/main (release versioning #359)
jaywedgeworth22 Nov 8, 2026
0011aad
Merge origin/main (one meter-pair rule #360)
jaywedgeworth22 Nov 8, 2026
f1c69a8
test: give the unresolved-reference probe a service token
jaywedgeworth22 Nov 8, 2026
25f6ca7
fix: keep the cursor cloud boot script at its main revision
jaywedgeworth22 Nov 8, 2026
b85a326
fix: take main’s synthetic-fixture version of the ASC staging test
jaywedgeworth22 Nov 8, 2026
b7a6638
Merge branch 'main' into codex/cc-205-release-ready
jaywedgeworth22 Nov 8, 2026
23b56a0
fix: the sentry reason stays empty when a CodeCaps token wins
jaywedgeworth22 Nov 8, 2026
a4499ae
fix: take main’s stage-asc-key reader
jaywedgeworth22 Nov 8, 2026
f8427d7
fix: take main's release contract to settle the mac-release gate
jaywedgeworth22 Nov 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@
# other rule stays active, and a real credential in this repository is still
# caught.
053e42631eaf6389365bbb37dedb2d67143ca2f6:scripts/install-release-secrets-tooling.sh:generic-api-key:38

# The flagged line validates a runtime-supplied secret and contains no secret value.  This exception pins only its commit, path, rule, and line.
0aeb73d1c51baabd9a26fa13d807b10bb22cc693:Sources/QuotaCore/TwilioSMSClient.swift:generic-api-key:76

# The copied release-branch history flags the same runtime validation, without a literal credential.
70cd5be758bfe4664ca8fa25e569db40bbf53006:Sources/QuotaCore/TwilioSMSClient.swift:generic-api-key:76
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Hosting and routing (apexes, hostnames, hosts, deploy paths): see [`Fleet-OPS/do
CodeCaps is a macOS menu-bar Swift app for **centralized monitoring and
alerting of every AI subscription plan on your Mac** — usage, quotas, and
caps across Claude, Codex, Cursor, Antigravity, Grok, MiniMax, and the
other AI CLIs already signed in. No provider API key is entered; CodeCaps
other AI CLIs already signed in.  Optional Z.ai coding-plan keys stay in Keychain; CodeCaps
uses existing local sign-ins to query supported provider quotas and local
helpers. Reading a credential file is not a passive quota-file refresh. The
same readings can be pushed to an endpoint you run and pulled back into the
Expand Down
66 changes: 36 additions & 30 deletions INFISICAL.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ A macOS menu bar app for supported AI plan usage and quota windows. It can shar

## Why This Exists

CodeCaps reads available usage and quota windows from supported AI apps and CLIs already signed in on this Mac — no provider API key is entered into CodeCaps. Optional push and pull connections can show readings from other configured Macs in one Glance popover.
CodeCaps reads available usage and quota windows from supported AI apps and CLIs already signed in on this Mac.  Optional Z.ai coding-plan quota checks use a key saved in this build's Keychain.  Optional push and pull connections can show readings from other configured Macs in one Glance popover.

CodeCaps keeps local readings visible in the menu bar. If you run a collector, it can also bring multiple Macs into one view.

Expand All @@ -18,7 +18,7 @@ Engineered with the proactive safeguards you'll come to rely on:
- **Visual Usage History & Trend Graphs**: Dive into rich local usage history graphs. Inspect how your quota drains over time, evaluate burn pacing, and see anomaly alert markers directly on your timeline.
- **Low-Quota Picture-in-Picture (PiP)**: Keep high-priority quotas visible in an on-top floating micro-HUD. Set PiP to open automatically whenever any provider's quota runs low, so you're never caught off-guard mid-prompt.
- **Dual-Window Cadence & Smart Reset Alarms**: Monitor 5-hour rapid windows alongside weekly/monthly plan allowances. Reset alarms alert you on major period rollovers, and notify on short windows only when you're actually near the cap.
- **Zero API Keys**: Reads local CLI and application sessions directly on your Mac. No provider API key is ever entered into CodeCaps (provider CLIs keep their own credentials), and CodeCaps never exports provider sign-in tokens.
- **Local Sign-Ins And Optional Keys**: Reads supported CLI and application sessions directly on your Mac.  Z.ai coding-plan checks offer an explicit API key stored in Keychain; CodeCaps never exports provider sign-in tokens.

## What It Shows

Expand Down Expand Up @@ -210,7 +210,7 @@ Console's sidebar has eight Settings pages.

## Privacy

- Never asks for a provider API key; each CLI's own credential file, Keychain item, or session database is reused as-is.
- Reuses supported local CLI credentials and session stores.  Optional Z.ai coding-plan keys stay in a separate build-scoped Keychain item.
- Nothing leaves this Mac until you turn on push or pull and enter an endpoint yourself; fields are empty by default.
- The Push Token and Read Token are the only two secrets stored, both in the Keychain.
- Endpoints are validated as above (HTTPS, loopback-only HTTP, no embedded credentials/query/fragment).
Expand Down
79 changes: 67 additions & 12 deletions Sources/CodeCaps/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AppKit
import Combine
import Carbon
import QuotaCore
import SwiftUI
import UserNotifications
Expand Down Expand Up @@ -57,6 +58,8 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe
let model = MonitorModel()
let consoleState = ConsoleState()
private var statusItem: NSStatusItem?
private var keepsMenuBarAccessAfterBackgroundChoice = false
private var userConfirmedQuit = false
private var planWarningCycle = PlanWarningCycle()
private var navigatingPlanWarning = false
private var planWarningCheckPending = false
Expand Down Expand Up @@ -237,11 +240,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe
// Install persisted configuration synchronously on the main actor.
// A delayed startup task must never restore A after Dashboard saved B.
let settings = InfisicalSettings.shared
guard let identity = InfisicalIdentityStore.load() else {
guard let configuration = InfisicalIdentityStore.loadSetup()?.configuration else {
settings.clearConfiguration()
return
}
settings.configure(identity.configuration)
settings.configure(configuration)
refreshInfisicalSettings()
}

Expand Down Expand Up @@ -366,12 +369,56 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe
private let snapshotTerminationDrain = SnapshotTerminationDrain()

func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
// This app has no cancelled-quit/resume path: every request replies true.
let systemTerminationReason = NSAppleEventManager.shared().currentAppleEvent?
.paramDescriptor(forKeyword: kAEQuitReason)?.typeCodeValue
if !userConfirmedQuit && QuitConfirmationPolicy.shouldConfirm(
systemTerminationReason: systemTerminationReason,
automaticInstallInProgress: AppUpdater.shared.isAutomaticInstallInProgress) {
switch confirmQuitChoice() {
case .closeAndKeepRunning:
closeWindowsAndKeepRunning()
return .terminateCancel
case .quit:
userConfirmedQuit = true
case .cancel:
return .terminateCancel
}
}
beginTerminationDrain(replyTo: sender)
return .terminateLater
}

private func confirmQuitChoice() -> QuitConfirmationChoice {
let alert = NSAlert()
alert.messageText = "Quit CodeCaps?"
alert.informativeText = "Close the windows and keep CodeCaps running in the menu bar so quota checks and alerts continue."
alert.alertStyle = .informational
alert.addButton(withTitle: "Close Window And Keep Running")
alert.addButton(withTitle: "Quit CodeCaps")
alert.addButton(withTitle: "Cancel")
alert.buttons.first?.keyEquivalent = "\r"
alert.buttons.last?.keyEquivalent = "\u{1b}"
NSApp.activate(ignoringOtherApps: true)
return QuitConfirmationChoice(response: alert.runModal())
}

private func closeWindowsAndKeepRunning() {
keepsMenuBarAccessAfterBackgroundChoice = true
ensureStatusItem()
updateStatus()
popover.performClose(nil)
lowerConsole()
for window in QuitConfirmationPolicy.windowsToHide(managed: [consoleWindow, floatingGlance]) {
window.orderOut(nil)
}
applyActivationPolicy()
}
Comment thread
swu-codex[bot] marked this conversation as resolved.
Resolved

private func beginTerminationDrain(replyTo sender: NSApplication) {
snapshotTerminationDrain.request(
stop: { model.stop() },
flush: { [self] in await model.flushSnapshotWrites() },
reply: { sender.reply(toApplicationShouldTerminate: true) })
return .terminateLater
}

func applicationWillTerminate(_ notification: Notification) { model.stop() }
Expand All @@ -384,24 +431,32 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate, NSMe

private func apply(_ mode: DisplayMode) {
// AppKit owns only activation and status-item lifetime; content remains SwiftUI.
if mode != .dock && statusItem == nil {
let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
item.button?.target = self
item.button?.action = #selector(statusItemClicked)
item.button?.sendAction(on: [.leftMouseUp, .rightMouseUp])
statusItem = item
if QuitConfirmationPolicy.shouldShowStatusItem(displayMode: mode,
keepRunningOverride: keepsMenuBarAccessAfterBackgroundChoice) {
ensureStatusItem()
}
NSApp.setActivationPolicy(mode == .menuBar ? .accessory : .regular)
if mode == .menuBar { consoleWindow?.orderOut(nil) }
if mode == .dock {
popover.performClose(nil)
if let item = statusItem { NSStatusBar.system.removeStatusItem(item) }
statusItem = nil
if !keepsMenuBarAccessAfterBackgroundChoice {
if let item = statusItem { NSStatusBar.system.removeStatusItem(item) }
statusItem = nil
}
showConsole(page: nil)
}
updateStatus()
}

private func ensureStatusItem() {
guard statusItem == nil else { return }
let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
item.button?.target = self
item.button?.action = #selector(statusItemClicked)
item.button?.sendAction(on: [.leftMouseUp, .rightMouseUp])
statusItem = item
}

/// Keeps the warning window in step with the model. Called on every
/// publish; the controller is a no-op unless the popup is actually showing.
private func updateExhaustionPopup() {
Expand Down
8 changes: 8 additions & 0 deletions Sources/CodeCaps/AutoUpdate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ final class AppUpdater: NSObject, ObservableObject, SPUUpdaterDelegate {
private var canCheckObservation: NSKeyValueObservation?
private var resignActiveObserver: NSObjectProtocol?
private var pendingInstall: (() -> Void)?
private var becameActiveObserver: NSObjectProtocol?
private(set) var isAutomaticInstallInProgress = false

private override init() {
availability = AutoUpdateAvailability.evaluate(info: Bundle.main.infoDictionary,
Expand All @@ -125,6 +127,11 @@ final class AppUpdater: NSObject, ObservableObject, SPUUpdaterDelegate {
) { [weak self] _ in
MainActor.assumeIsolated { self?.installPendingUpdateIfIdle() }
}
becameActiveObserver = NotificationCenter.default.addObserver(
forName: NSApplication.didBecomeActiveNotification, object: nil, queue: .main
) { [weak self] _ in
MainActor.assumeIsolated { self?.isAutomaticInstallInProgress = false }
}
}

/// The "Check For Updates…" command. An accessory app is never frontmost
Expand All @@ -150,6 +157,7 @@ final class AppUpdater: NSObject, ObservableObject, SPUUpdaterDelegate {
guard let install = pendingInstall, !NSApp.isActive else { return }
pendingInstall = nil
UpdateRelaunchMarker().mark()
isAutomaticInstallInProgress = true
install()
}
}
69 changes: 69 additions & 0 deletions Sources/CodeCaps/CodeCapsAlertChannels.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import Foundation
import QuotaCore

/// One alert occurrence on its way to a delivery channel.
///
/// Every event carries its stable `UsageAlertKind` identifier, so channels
/// select by kind — never by which producer emitted the event — and a
/// future per-kind channel opt-in needs no producer changes.
public struct CodeCapsAlertEvent: Equatable, Sendable {
public let kind: UsageAlertKind
public let title: String
public let body: String
public let identifier: String
public let occurredAt: Date

public init(kind: UsageAlertKind, title: String, body: String,
identifier: String, occurredAt: Date) {
self.kind = kind
self.title = title
self.body = body
self.identifier = identifier
self.occurredAt = occurredAt
}
}

/// A delivery channel for app-level alert events.
///
/// The seam is deliberately at the app level, not inside any plugin: a new
/// channel registers once with the dispatcher and receives every producer's
/// events. The planned Twilio SMS channel is the expected second channel —
/// app-level, selecting a deliberately small set of kinds — and it slots in
/// here without reworking any monitor.
@MainActor
public protocol CodeCapsAlertChannel: AnyObject {
func deliver(_ event: CodeCapsAlertEvent)
}

/// App-level fan-out for alert events. Producers emit here, never to a
/// channel directly.
@MainActor
public final class CodeCapsAlertDispatcher {
private var channels: [CodeCapsAlertChannel] = []

public init() {}

public func register(_ channel: CodeCapsAlertChannel) {
channels.append(channel)
}

public func emit(_ event: CodeCapsAlertEvent) {
for channel in channels { channel.deliver(event) }
}
}

/// The only channel today: CodeCaps' own alert surface, through the same
/// per-kind preferences and delivery path as every other usage alert.
@MainActor
public final class LocalAlertChannel: CodeCapsAlertChannel {
private weak var manager: ResetAlarmManager?

public init(manager: ResetAlarmManager) {
self.manager = manager
}

public func deliver(_ event: CodeCapsAlertEvent) {
manager?.deliverUsageAlert(kind: event.kind, title: event.title,
body: event.body, identifier: event.identifier)
}
}
47 changes: 46 additions & 1 deletion Sources/CodeCaps/ConsoleViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum ConsolePage: Hashable {
case allPlatforms
case platform(String)
case runawayAlerts
case plugin(String)
case settingsMenuBar
case settingsPlatforms
case settingsLogoStyle
Expand All @@ -19,7 +20,7 @@ enum ConsolePage: Hashable {

var isSettings: Bool {
switch self {
case .allPlatforms, .platform, .runawayAlerts: return false
case .allPlatforms, .platform, .runawayAlerts, .plugin: return false
default: return true
}
}
Expand All @@ -29,6 +30,7 @@ enum ConsolePage: Hashable {
case .allPlatforms: return "allPlatforms"
case .platform(let providerKey): return "platform:" + providerKey
case .runawayAlerts: return "runawayAlerts"
case .plugin(let pluginId): return "plugin:" + pluginId
case .settingsMenuBar: return "settingsMenuBar"
case .settingsPlatforms: return "settingsPlatforms"
case .settingsLogoStyle: return "settingsLogoStyle"
Expand All @@ -53,6 +55,9 @@ enum ConsolePage: Hashable {
case "settingsInfisical": return .settingsInfisical
case "settingsAbout": return .settingsAbout
default:
if value.hasPrefix("plugin:") {
return .plugin(String(value.dropFirst(7)))
}
guard value.hasPrefix("platform:") else { return nil }
return .platform(String(value.dropFirst(9)))
}
Expand All @@ -63,6 +68,7 @@ enum ConsolePage: Hashable {
switch self {
case .allPlatforms: return "All Platforms"
case .runawayAlerts: return "Runaway Alerts"
case .plugin(let pluginId): return CodeCapsPlugin.named(pluginId)?.title ?? "Plugin"
case .settingsMenuBar: return "Menu Bar & PiP"
case .settingsPlatforms: return "Platforms"
case .settingsLogoStyle: return "Logo Style"
Expand All @@ -79,6 +85,7 @@ enum ConsolePage: Hashable {
switch self {
case .allPlatforms: return "square.grid.2x2"
case .runawayAlerts: return "flame.fill"
case .plugin(let pluginId): return CodeCapsPlugin.named(pluginId)?.symbol ?? "puzzlepiece.extension"
case .settingsMenuBar: return "menubar.rectangle"
case .settingsPlatforms: return "square.grid.2x2"
case .settingsLogoStyle: return "photo.on.rectangle.angled"
Expand All @@ -94,6 +101,8 @@ enum ConsolePage: Hashable {
static let settingsPages: [ConsolePage] = [
.settingsMenuBar, .settingsPlatforms, .settingsLogoStyle, .settingsSourcesFleet, .settingsNotifications, .settingsAppearance, .settingsInfisical, .settingsAbout,
]

static let pluginPages: [ConsolePage] = CodeCapsPlugin.allCases.map { .plugin($0.id) }
}

struct AlertNavigation: Equatable {
Expand Down Expand Up @@ -192,6 +201,13 @@ final class ConsoleState: ObservableObject {
awaitingInitialSelection = false
return
}
if case .plugin = page {
// A plugin page is local: it never waits on a quota read, and no
// source disappearing can invalidate it.
pendingStoredKey = nil
awaitingInitialSelection = false
return
}
if page.isSettings && !awaitingInitialSelection { return }
if sections.isEmpty && !readCompleted { return }
isReconciling = true
Expand Down Expand Up @@ -335,6 +351,9 @@ struct ConsoleView: View {
case .runawayAlerts:
RunawayAlertsPage(model: model, state: state)
.padding(Metrics.pagePadding)
case .plugin(let pluginId):
MuseCodePluginPage(model: model, pluginId: pluginId)
.padding(Metrics.pagePadding)
case .platform(let key):
PlatformDetailPage(model: model, state: state, providerKey: key)
.padding(Metrics.pagePadding)
Expand Down Expand Up @@ -482,6 +501,7 @@ struct ConsoleSidebar: View {
private var allPages: [ConsolePage] {
var pages: [ConsolePage] = [.allPlatforms, .runawayAlerts]
pages.append(contentsOf: model.displaySections.map { .platform($0.id) })
pages.append(contentsOf: ConsolePage.pluginPages)
pages.append(contentsOf: ConsolePage.settingsPages)
return pages
}
Expand Down Expand Up @@ -539,6 +559,31 @@ struct ConsoleSidebar: View {
} header: {
Eyebrow("QUOTAS")
}
Section {
ForEach(ConsolePage.pluginPages, id: \.self) { page in
sidebarRow(page: page) {
HStack(spacing: 8) {
Image(systemName: page.symbol)
.font(.system(size: 13))
.foregroundStyle(model.museCodeBurnAlert == nil ? Theme.ink : Theme.warning)
.frame(width: 18)
Text(page.settingsTitle)
.font(.system(size: 13, weight: .medium))
Spacer(minLength: 4)
if model.museCodeBurnAlert != nil {
Text("1")
.font(.system(size: 10, weight: .bold))
.foregroundStyle(.white)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(Theme.warning, in: Capsule())
}
}
}
}
} header: {
Eyebrow("PLUGINS")
}
Section {
ForEach(ConsolePage.settingsPages, id: \.self) { page in
sidebarRow(page: page) {
Expand Down
Loading
Loading