feat(ai-commit-msg): support XDG_CONFIG_HOME config files#287
feat(ai-commit-msg): support XDG_CONFIG_HOME config files#287stephansama wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
There was a problem hiding this comment.
Code Review
This pull request adds support for TOML configuration files and XDG-compliant global configuration paths using smol-toml and xdg-app-paths. The review identifies a critical issue where including absolute XDG paths in the cosmiconfig search list disrupts the configuration hierarchy, potentially allowing global settings to override local ones. Further improvements are suggested regarding the use of standard XDG file naming conventions and extending TOML support to project-local configuration files for better consistency.
| `${xdgConfigDirectory}.json`, | ||
| `${xdgConfigDirectory}.yaml`, | ||
| `${xdgConfigDirectory}.yml`, | ||
| `${xdgConfigDirectory}.toml`, |
There was a problem hiding this comment.
Including absolute paths in searchPlaces breaks the configuration hierarchy. cosmiconfig searches all searchPlaces for every directory it traverses upwards. Because these XDG paths are absolute, they will be matched during the search of the current working directory, effectively overriding any project-local configuration files located in parent directories (e.g., a .ai-commit-msgrc in the project root would be ignored if a global XDG config exists).
To correctly implement a global fallback while maintaining the expected priority (local > parent > global), you should remove these absolute paths from searchPlaces and instead attempt to load them manually in loadConfig only if explorer.search() returns null.
| `.config/.${moduleName}rc.json`, | ||
| `.config/.${moduleName}rc.yaml`, | ||
| `.config/.${moduleName}rc.yml`, | ||
| `.config/.${moduleName}rc`, |
There was a problem hiding this comment.
These search places use a "double-hidden" pattern (a hidden file inside a hidden directory, e.g., .config/.ai-commit-msgrc). This is unconventional for XDG-style configuration. Standard practice is to use non-hidden filenames within the .config directory (e.g., .config/ai-commit-msgrc), which cosmiconfig's getDefaultSearchPlaces already covers. If the intention was to support a dedicated subdirectory, a pattern like .config/${moduleName}/config.json would be more standard.
| `${xdgConfigDirectory}.json`, | ||
| `${xdgConfigDirectory}.yaml`, | ||
| `${xdgConfigDirectory}.yml`, | ||
| `${xdgConfigDirectory}.toml`, |
There was a problem hiding this comment.
The TOML loader is currently only utilized for the XDG configuration path. For consistency and to support users who prefer TOML for project-specific settings, you should also add TOML variants to the project-local search places (e.g., .${moduleName}rc.toml and .config/${moduleName}rc.toml).
`${xdgConfigDirectory}.toml`,
`.${moduleName}rc.toml`,
`.config/${moduleName}rc.toml`,
Closes STE-39
Extends cosmiconfig searchPlaces in
core/ai-commit-msg/src/config.tsto include XDG base-directory paths ($XDG_CONFIG_HOME/ai-commit-msg/config.{json,yaml,yml,toml}, fallback$HOME/.config/ai-commit-msg/). Adds a smol-toml cosmiconfig loader so .toml configs at the XDG path round-trip correctly. Project-local config files still take precedence over XDG-sourced ones.Acceptance criteria
~/.config/ai-commit-msg/config.jsonis discovered and loaded$XDG_CONFIG_HOME/ai-commit-msg/config.yamlis discovered whenXDG_CONFIG_HOMEis set