mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-04-28 06:59:37 +00:00
Introduces mac/ with a native SwiftUI menubar app that replaces the previous SwiftBar plugin entirely. Install via `npx codeburn menubar`, which downloads the .app from GitHub Releases, strips Gatekeeper quarantine, and drops it into ~/Applications. Highlights - mac/ SwiftUI app: agent tabs, Today/7/30/Month/All period switcher, Trend/Forecast/Pulse/Stats/Plan insights, activity + model breakdowns, optimize findings, CSV/JSON export, Star-on-GitHub banner, live 60s refresh, instant currency switching with offline FX cache. - Security: CodeburnCLI argv-based spawn (no shell interpretation), SafeFile symlink guards + O_NOFOLLOW writes, FX rate clamping to [0.0001, 1_000_000], keychain filtered to account == "default", removed byte-window credential log, in-flight refresh guard, POSIX flock on config.json writes, TerminalLauncher validates argv before AppleScript interpolation. - Performance: shared static NumberFormatter (thousands of allocations per popover redraw eliminated), concurrent pipe drain with 20 MB cap + 60s timeout in DataClient, Observation-tracked reactive UI, 5-min payload cache keyed on (period, provider). - CLI: new `codeburn menubar` subcommand that downloads + installs + launches the .app (no clone, no build). New `status --format menubar-json` payload builder. `export` rewritten to produce a folder of one-table-per-file CSVs with a `.codeburn-export` marker so arbitrary -o paths cannot be silently deleted. - Removed: src/menubar.ts (SwiftBar plugin generator), install-menubar / uninstall-menubar subcommands, `status --format menubar` directive output, tests/menubar.test.ts, tests/security/menubar-injection.test.ts. - Release: .github/workflows/release-menubar.yml builds universal binary, assembles .app, ad-hoc signs, zips, uploads on mac-v* tag push. Runs on the free macos-latest runner. Tests - 230 TypeScript tests pass - 10 Swift CapacityEstimator tests pass - TypeScript typecheck clean - Swift release build clean
46 lines
1.4 KiB
Swift
46 lines
1.4 KiB
Swift
import Foundation
|
|
|
|
struct SubscriptionUsage: Sendable, Equatable {
|
|
enum Tier: String, Sendable, Equatable {
|
|
case pro
|
|
case max5x
|
|
case max20x
|
|
case team
|
|
case enterprise
|
|
case unknown
|
|
|
|
var displayName: String {
|
|
switch self {
|
|
case .pro: "Pro"
|
|
case .max5x: "Max 5x"
|
|
case .max20x: "Max 20x"
|
|
case .team: "Team"
|
|
case .enterprise: "Enterprise"
|
|
case .unknown: "Subscription"
|
|
}
|
|
}
|
|
}
|
|
|
|
let tier: Tier
|
|
let rawTier: String?
|
|
let fiveHourPercent: Double?
|
|
let fiveHourResetsAt: Date?
|
|
let sevenDayPercent: Double?
|
|
let sevenDayResetsAt: Date?
|
|
let sevenDayOpusPercent: Double?
|
|
let sevenDayOpusResetsAt: Date?
|
|
let sevenDaySonnetPercent: Double?
|
|
let sevenDaySonnetResetsAt: Date?
|
|
let fetchedAt: Date
|
|
|
|
static func tier(from raw: String?) -> Tier {
|
|
guard let raw = raw?.lowercased() else { return .unknown }
|
|
if raw.contains("max_20x") || raw.contains("max20x") || raw.contains("max-20x") { return .max20x }
|
|
if raw.contains("max_5x") || raw.contains("max5x") || raw.contains("max-5x") { return .max5x }
|
|
if raw.contains("max") { return .max5x }
|
|
if raw.contains("pro") { return .pro }
|
|
if raw.contains("team") { return .team }
|
|
if raw.contains("enterprise") { return .enterprise }
|
|
return .unknown
|
|
}
|
|
}
|