Skip to content

Xdg config path - #126

Merged
Microck merged 2 commits into
Microck:mainfrom
nshepperd:xdg-config-path
Jun 19, 2026
Merged

Xdg config path#126
Microck merged 2 commits into
Microck:mainfrom
nshepperd:xdg-config-path

Conversation

@nshepperd

Copy link
Copy Markdown
Contributor

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

  • [o] cargo fmt --check
  • [o] cargo clippy --all-targets --all-features -- -D warnings
  • [o] cargo test -q

Docs

  • [o] README updated if user-facing behavior changed
  • [o] CHANGELOG updated for notable user-facing changes

nshepperd and others added 2 commits June 19, 2026 19:20
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>
@nshepperd
nshepperd requested a review from Microck as a code owner June 19, 2026 09:40

@Microck Microck left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. XDG config path is the right default.

@Microck
Microck merged commit d81e813 into Microck:main Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants