From 1af82883a23277e42bfd659ec912bd4d6bd46949 Mon Sep 17 00:00:00 2001 From: Griffin Suparto Date: Wed, 4 Feb 2026 17:08:17 -0500 Subject: [PATCH 1/2] Allow auto source on Linux --- .../CodexBarCore/Providers/ProviderFetchPlan.swift | 2 +- Tests/CodexBarTests/CLIEntryTests.swift | 9 +++++++++ docs/kimi.md | 12 +++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift b/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift index cadbdc81..924d5791 100644 --- a/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift +++ b/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift @@ -13,7 +13,7 @@ public enum ProviderSourceMode: String, CaseIterable, Sendable, Codable { case api public var usesWeb: Bool { - self == .auto || self == .web + self == .web } } diff --git a/Tests/CodexBarTests/CLIEntryTests.swift b/Tests/CodexBarTests/CLIEntryTests.swift index 67dd4556..7852d59a 100644 --- a/Tests/CodexBarTests/CLIEntryTests.swift +++ b/Tests/CodexBarTests/CLIEntryTests.swift @@ -124,4 +124,13 @@ struct CLIEntryTests { #expect(!CodexBarCLI.shouldUseColor(noColor: true, format: .text)) #expect(!CodexBarCLI.shouldUseColor(noColor: false, format: .json)) } + + #if !os(macOS) + @Test + func sourceModeUsesWebOnlyForWeb() { + #expect(ProviderSourceMode.web.usesWeb) + #expect(!ProviderSourceMode.auto.usesWeb) + #expect(!ProviderSourceMode.api.usesWeb) + } + #endif } diff --git a/docs/kimi.md b/docs/kimi.md index 4a3650e4..62a52fa7 100644 --- a/docs/kimi.md +++ b/docs/kimi.md @@ -16,10 +16,11 @@ Tracks usage for [Kimi For Coding](https://www.kimi.com/code) in CodexBar. - Shows current 5-hour rate limit usage - Automatic and manual authentication methods - Automatic refresh countdown +- Headless-friendly auth via env var (no GUI required) ## Setup -Choose one of two authentication methods: +Choose one of the authentication methods: ### Method 1: Automatic Browser Import (Recommended) @@ -52,6 +53,15 @@ Alternatively, set the `KIMI_AUTH_TOKEN` environment variable: export KIMI_AUTH_TOKEN="jwt-token-here" ``` +This is the recommended approach for CLI/headless usage. + +With `KIMI_AUTH_TOKEN` set, the default `codexbar usage --provider kimi` (`--source auto`) will fetch usage via Kimi's HTTP endpoint. + +```bash +export KIMI_AUTH_TOKEN="" +codexbar usage --provider kimi +``` + ## Authentication Priority When multiple sources are available, CodexBar uses this order: From 65a361375406c84cb88f60f6f327d6d1b8c95dea Mon Sep 17 00:00:00 2001 From: Griffin Suparto Date: Wed, 4 Feb 2026 17:13:25 -0500 Subject: [PATCH 2/2] Gate web source explicitly on Linux --- Sources/CodexBarCLI/CLIUsageCommand.swift | 4 ++-- Sources/CodexBarCore/Providers/ProviderFetchPlan.swift | 2 +- Tests/CodexBarTests/CLIEntryTests.swift | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/CodexBarCLI/CLIUsageCommand.swift b/Sources/CodexBarCLI/CLIUsageCommand.swift index d0ab5dfe..009c7ae1 100644 --- a/Sources/CodexBarCLI/CLIUsageCommand.swift +++ b/Sources/CodexBarCLI/CLIUsageCommand.swift @@ -95,7 +95,7 @@ extension CodexBarCLI { } #if !os(macOS) - if parsedSourceMode?.usesWeb == true { + if parsedSourceMode == .web { Self.exit( code: .failure, message: "Error: --source web/auto is only supported on macOS.", @@ -243,7 +243,7 @@ extension CodexBarCLI { account: account) #if !os(macOS) - if effectiveSourceMode.usesWeb { + if effectiveSourceMode == .web { return Self.webSourceUnsupportedOutput( provider: provider, account: account, diff --git a/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift b/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift index 924d5791..cadbdc81 100644 --- a/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift +++ b/Sources/CodexBarCore/Providers/ProviderFetchPlan.swift @@ -13,7 +13,7 @@ public enum ProviderSourceMode: String, CaseIterable, Sendable, Codable { case api public var usesWeb: Bool { - self == .web + self == .auto || self == .web } } diff --git a/Tests/CodexBarTests/CLIEntryTests.swift b/Tests/CodexBarTests/CLIEntryTests.swift index 7852d59a..c039266f 100644 --- a/Tests/CodexBarTests/CLIEntryTests.swift +++ b/Tests/CodexBarTests/CLIEntryTests.swift @@ -127,9 +127,9 @@ struct CLIEntryTests { #if !os(macOS) @Test - func sourceModeUsesWebOnlyForWeb() { + func sourceModeUsesWebIncludesAuto() { #expect(ProviderSourceMode.web.usesWeb) - #expect(!ProviderSourceMode.auto.usesWeb) + #expect(ProviderSourceMode.auto.usesWeb) #expect(!ProviderSourceMode.api.usesWeb) } #endif