Skip to content

feat(settings): honor XDG base directories for config and data on Linux (#226) - #284

Open
innocarpe wants to merge 2 commits into
lessweb:mainfrom
innocarpe:feat/226-xdg-paths
Open

feat(settings): honor XDG base directories for config and data on Linux (#226)#284
innocarpe wants to merge 2 commits into
lessweb:mainfrom
innocarpe:feat/226-xdg-paths

Conversation

@innocarpe

Copy link
Copy Markdown

Summary

  • On Linux, Deep Code now honors the XDG base directory spec when $XDG_CONFIG_HOME / $XDG_DATA_HOME are set:
    • config → $XDG_CONFIG_HOME/deepcode (settings.json)
    • data → $XDG_DATA_HOME/deepcode (projects, logs, machine-id, skills, update state, user AGENTS.md)
  • Without the env vars (or on other platforms), everything stays at ~/.deepcode — existing setups are unaffected.

Why

Issue #226: Linux users who follow the XDG spec expect config in ~/.config and data in ~/.local/share, not a hidden ~/.deepcode directory. This also makes config/data portable and respects common backup/cleanup tooling.

Changes

  • packages/core/src/settings.ts: add getUserConfigDir() / getUserDataDir() and route getUserSettingsPath() through the config dir.
  • packages/core/src/index.ts: export the new helpers.
  • Routed data-path consumers through getUserDataDir(): session.ts (projects, user skills, user AGENTS.md), openai-client.ts (machine-id), error-logger.ts / debug-logger.ts (logs), cli.tsx (sessions-index), update-check.ts (state).
  • packages/vscode-ide-companion/src/extension.ts: use getUserSettingsPath().
  • packages/core/src/tests/settings-and-notify.test.ts: test for XDG env handling + fallback.

Validation

  • npm run typecheck
  • npm test — new XDG tests pass ✅

Closes #226

…ux (lessweb#226)

When XDG_CONFIG_HOME/XDG_DATA_HOME are set on Linux, settings.json lives in $XDG_CONFIG_HOME/deepcode and data (projects, logs, machine-id, skills, update state, AGENTS.md) in $XDG_DATA_HOME/deepcode. Falls back to ~/.deepcode otherwise, so existing setups are unaffected.

(cherry picked from commit ada7144231c26a7b1fdac5beeba0543d40b581b1)
(cherry picked from commit 13ddf8a6fd2cc05f8dbf494e6441d897d3147bf7)
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.

建议在Linux下把配置文件可选地放在$XDG_CONFIG_DIRS/deepcode,数据文件放在$XDG_DATA_DIRS/deepcode

1 participant