Skip to content

fix: use ~/.config as the canonical macOS config path#81

Merged
jy-tan merged 4 commits intomainfrom
update-default-config-location
Mar 18, 2026
Merged

fix: use ~/.config as the canonical macOS config path#81
jy-tan merged 4 commits intomainfrom
update-default-config-location

Conversation

@jy-tan
Copy link
Contributor

@jy-tan jy-tan commented Mar 18, 2026

Summary

Make ~/.config/fence/fence.json the canonical config location on macOS so new configs go where users expect, while preserving reads from legacy macOS paths until a real canonical config file exists. Also tighten the docs so Linux path guidance matches XDG_CONFIG_HOME and library examples behave like the CLI.

Resolves #75.

Changes

  • Split config path handling into a canonical write path and a default load path with legacy fallback
  • Update the CLI to load via ResolveDefaultConfigPath() so existing legacy macOS configs are still honored during migration
  • Add resolver tests covering macOS canonical-path preference, legacy fallback, and Linux UserConfigDir behavior
  • Export and document ResolveDefaultConfigPath() in the public package API
  • Update library examples to use LoadConfigResolved() so relative extends paths resolve the same way as the CLI
  • Refresh help text and docs to describe Linux in terms of $XDG_CONFIG_HOME and macOS in terms of ~/.config/fence/fence.json

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="cmd/fence/main.go">

<violation number="1" location="cmd/fence/main.go:64">
P2: The new help text hardcodes `~/.config` on Linux, but the actual default follows `os.UserConfigDir()`/`XDG_CONFIG_HOME`, so it can document the wrong path.</violation>
</file>

<file name="internal/config/config.go">

<violation number="1" location="internal/config/config.go:175">
P2: Checking the canonical directory before legacy files can hide an existing legacy config. On macOS, an empty `~/.config/fence/` makes `DefaultConfigPath()` ignore `~/Library/Application Support/...` and `~/.fence.json` even when those files exist.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/library.md">

<violation number="1" location="docs/library.md:86">
P2: Use `LoadConfigResolved` here so relative `extends` entries work the same way as the CLI.</violation>

<violation number="2" location="docs/library.md:101">
P3: This sentence overstates the legacy fallback. `ResolveDefaultConfigPath()` still returns the canonical path once `~/.config/fence/` exists, even if a legacy config file exists.</violation>
</file>

<file name="cmd/fence/main.go">

<violation number="1" location="cmd/fence/main.go:199">
P2: This can skip an existing legacy macOS config whenever `~/.config/fence/` exists but `~/.config/fence/fence.json` does not.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@jy-tan jy-tan merged commit 89bbe92 into main Mar 18, 2026
5 checks passed
@jy-tan jy-tan deleted the update-default-config-location branch March 18, 2026 02:15
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.

Configuration file path on MacOS is surprising

1 participant