Xdg config path - #126
Merged
Merged
Conversation
Credentials were saved to a cwd-relative `.kagi.toml`, so the file location depended on where `kagi` was invoked from and a key saved in one directory was invisible from another. Resolve the config path in this order instead: 1. `$KAGI_CONFIG` (explicit full file path override) 2. `$XDG_CONFIG_HOME/kagi-cli/config.toml` 3. `$HOME/.config/kagi-cli/config.toml` The atomic writer now creates the config directory on first run, and the file keeps its 0600 permissions. Help text and the auth wizard no longer reference `.kagi.toml` by name. BREAKING CHANGE: existing credentials in a cwd-relative `.kagi.toml` are no longer read. Re-run `kagi auth set` (or the wizard) once to migrate. The `KAGI_API_KEY`/`KAGI_SESSION_TOKEN` env vars are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update all references from the cwd-relative ./.kagi.toml to ~/.config/kagi-cli/config.toml, document the resolution order ($KAGI_CONFIG -> $XDG_CONFIG_HOME/kagi-cli/config.toml -> ~/.config/...), add `mkdir -p` to config-write snippets, fix the obsolete .gitignore guidance, and add a CHANGELOG entry plus migration notes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Microck
approved these changes
Jun 19, 2026
Microck
left a comment
Owner
There was a problem hiding this comment.
LGTM. XDG config path is the right default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I made it use XDG config file locations (~/.config/kagi-cli/config.toml) instead of ./.kagi.toml for storing api keys. IDK if there's a specific rationale for using the cwd (individual per-project tokens?), but having to re-paste the token each time was annoying, so.
Verification
cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningscargo test -qDocs