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/Tests/CodexBarTests/CLIEntryTests.swift b/Tests/CodexBarTests/CLIEntryTests.swift index 67dd4556..c039266f 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 sourceModeUsesWebIncludesAuto() { + #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: