Skip to content

feat(ai-commit-msg): support XDG_CONFIG_HOME config files#287

Open
stephansama wants to merge 1 commit into
mainfrom
stephansama/ste-39-allow-ai-commit-msg-to-use-xdg_config_home-configuration
Open

feat(ai-commit-msg): support XDG_CONFIG_HOME config files#287
stephansama wants to merge 1 commit into
mainfrom
stephansama/ste-39-allow-ai-commit-msg-to-use-xdg_config_home-configuration

Conversation

@stephansama

Copy link
Copy Markdown
Owner

Closes STE-39

Extends cosmiconfig searchPlaces in core/ai-commit-msg/src/config.ts to 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

  • A config at ~/.config/ai-commit-msg/config.json is discovered and loaded
  • A config at $XDG_CONFIG_HOME/ai-commit-msg/config.yaml is discovered when XDG_CONFIG_HOME is set
  • TOML config files at the XDG path are parsed correctly
  • Local project config still takes precedence over XDG config
  • No regression in existing cosmiconfig search behaviour

@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
packages Ready Ready Preview, Comment May 18, 2026 2:30am

@changeset-bot

changeset-bot Bot commented May 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2a5099f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@stephansama has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 9 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3fe0cb67-dac7-42c5-afe7-519b7d186226

📥 Commits

Reviewing files that changed from the base of the PR and between 9a84b42 and 2a5099f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • core/ai-commit-msg/package.json
  • core/ai-commit-msg/src/config.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stephansama/ste-39-allow-ai-commit-msg-to-use-xdg_config_home-configuration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
251 1 250 0
View the top 1 failed test(s) by shortest run time
core/ai-commit-msg/test/config.test.ts > test/config.test.ts
Stack Traces | 0s run time
Error: [vitest] No "defaultLoaders" export is defined on the "cosmiconfig" mock. Did you forget to return it from "vi.mock"?
If you need to partially mock a module, you can use "importOriginal" helper inside:

vi.mock(import("cosmiconfig"), async (importOriginal) => {
  const actual = await importOriginal()
  return {
    ...actual,
    // your mocked methods
  }
})

 ❯ src/config.ts:20:5
 ❯ test/config.test.ts:6:1

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +53 to +56
`${xdgConfigDirectory}.json`,
`${xdgConfigDirectory}.yaml`,
`${xdgConfigDirectory}.yml`,
`${xdgConfigDirectory}.toml`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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.

Comment on lines 49 to 52
`.config/.${moduleName}rc.json`,
`.config/.${moduleName}rc.yaml`,
`.config/.${moduleName}rc.yml`,
`.config/.${moduleName}rc`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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`,

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.

1 participant