[PR #2189] [CLOSED] fix(setup): honor empty XDG config home for OpenCode #5073

Closed
opened 2026-10-31 01:02:50 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2189
Author: @pcp-cmd
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: fix/opencode-empty-xdg-config-home


📝 Commits (1)

  • 8836610 fix(setup): honor empty XDG config home for OpenCode

📊 Changes

3 files changed (+24 additions, -11 deletions)

View changed files

📝 src/application/SupportedClients.ts (+6 -9)
📝 tests/boundary/cli/clientProfileLifecycle.test.ts (+16 -1)
📝 tests/boundary/cli/clientProfiles.test.ts (+2 -1)

📄 Description

Summary

Fixes #2168. With an empty XDG_CONFIG_HOME, OpenCode setup previously wrote
opencode/opencode.json under the working directory and reported readiness.
Resolve the default global directory once for both writing and reading, treating
an empty XDG value as unset. Explicit OpenCode and non-empty XDG overrides retain
their existing precedence.

Problem and expected behavior

An isolated CLI run on base 5190843f8f09ac17cbf79561bd1f708c509cda78 reproduced
the misplaced registration. The empty and unset cases now both write
HOME/.config/opencode/opencode.json; a non-empty XDG root still selects
XDG_CONFIG_HOME/opencode/opencode.json. All three workspaces remain empty.
This matches the XDG specification
and OpenCode 1.18.35's xdg-basedir 5.1.0 dependency.

Change and scope

  • Share OpenCode's default global-directory resolution between the write target
    and ordered configuration read sources.
  • Extend existing compiled CLI lifecycle coverage for empty and explicit XDG
    roots, including planning, setup, doctor, idempotence and uninstall.
  • Exercise the empty-XDG global layer together with a custom directory, including
    malformed-global preflight and preservation of unrelated registrations.

Contract and boundary impact

  • Semantic owner: SupportedClients.ts, OpenCode configuration-path resolution.
  • CLI/MCP schema, provider, target-format, Evidence and generated metadata: none.
  • Installation/cleanup: setup, doctor and uninstall agree on the default global
    source; existing approval, backup, preflight and owned-registration rules apply.

Evidence and regression coverage

  • Two modified CLI regressions failed on unmodified production source at the base
    revision (16 other tests passed), then passed with the fix.
  • Independent compiled CLI reproduction ran empty, unset and explicit XDG cases
    before and after the fix with separate temporary homes and working directories.
  • Final focused run: 106 tests passed across five existing CLI/filesystem files.
  • Native OpenCode loading/MCP handshake, macOS and Windows execution are unverified.

Validation performed

Linux x64, pinned Node 24.18.0 / npm 11.16.0:

  • npm run test:focused -- tests/boundary/cli/clientProfileLifecycle.test.ts tests/boundary/cli/clientProfiles.test.ts tests/boundary/filesystem/clientLifecycle.test.ts tests/boundary/filesystem/clientConfigurationDialects.test.ts tests/boundary/filesystem/clientRegistrationStatus.test.ts — 106 passed.
  • npm run check — passed all six tasks and architecture guards; 853 lint warnings,
    zero lint errors. The first attempt found one formatting issue, corrected with oxfmt.
  • npm run verify:test-discovery — all 915 test files discovered exactly once.
  • npm pack --dry-run --json — passed; 1,431 files.
  • git diff --check and pre-commit formatting/lint hooks — passed.
  • npm run verify:package — passed, including packaged CLI/MCP, 173 tools, setup/
    uninstall, exact-version update, backups, failure recovery, symlink lifecycle,
    Skills 1.7.2 repository discovery and verified cleanup with no remaining descendants.
    The first run was stopped after its local registry forwarding repeatedly returned
    HTTP 500: Node's upstream fetch failed with EAI_AGAIN. A probe using the existing
    environment proxy returned HTTP 200. The passing run used NODE_USE_ENV_PROXY=1
    with loopback destinations excluded from the proxy (NO_PROXY, no_proxy and
    npm_config_noproxy); no repository or network-policy change was needed.

Compatibility, safety, and release

No breaking changes, metadata change or version bump. The fix does not migrate an
already misplaced registration. No analysis provider behavior changed, so no real
Hopper/Ghidra run was performed. The full deterministic suite was not run locally.
CI run 38251100446 is
action_required; its page says it is awaiting approval from a maintainer.
No jobs have executed yet, so no remote test pass is claimed.

Review checklist

  • Concrete issue and focused Conventional Commit title.
  • Current issue, discussion, timeline and related PR searches checked.
  • Observable behavior and malformed-input/preservation paths covered.
  • Existing documentation contract remains valid; no generated files committed.
  • Before/after paths and executed verification distinguished from unavailable coverage.
  • Final diff checked for secrets, unrelated changes and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2189 **Author:** [@pcp-cmd](https://github.com/pcp-cmd) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/opencode-empty-xdg-config-home` --- ### 📝 Commits (1) - [`8836610`](https://github.com/morluto/rea/commit/88366102e7fbd723153d7744fd684646008140f0) fix(setup): honor empty XDG config home for OpenCode ### 📊 Changes **3 files changed** (+24 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/application/SupportedClients.ts` (+6 -9) 📝 `tests/boundary/cli/clientProfileLifecycle.test.ts` (+16 -1) 📝 `tests/boundary/cli/clientProfiles.test.ts` (+2 -1) </details> ### 📄 Description ## Summary Fixes #2168. With an empty `XDG_CONFIG_HOME`, OpenCode setup previously wrote `opencode/opencode.json` under the working directory and reported readiness. Resolve the default global directory once for both writing and reading, treating an empty XDG value as unset. Explicit OpenCode and non-empty XDG overrides retain their existing precedence. ## Problem and expected behavior An isolated CLI run on base `5190843f8f09ac17cbf79561bd1f708c509cda78` reproduced the misplaced registration. The empty and unset cases now both write `HOME/.config/opencode/opencode.json`; a non-empty XDG root still selects `XDG_CONFIG_HOME/opencode/opencode.json`. All three workspaces remain empty. This matches the [XDG specification](https://specifications.freedesktop.org/basedir/latest/) and OpenCode 1.18.35's `xdg-basedir` 5.1.0 dependency. ## Change and scope - Share OpenCode's default global-directory resolution between the write target and ordered configuration read sources. - Extend existing compiled CLI lifecycle coverage for empty and explicit XDG roots, including planning, setup, doctor, idempotence and uninstall. - Exercise the empty-XDG global layer together with a custom directory, including malformed-global preflight and preservation of unrelated registrations. ## Contract and boundary impact - Semantic owner: `SupportedClients.ts`, OpenCode configuration-path resolution. - CLI/MCP schema, provider, target-format, Evidence and generated metadata: none. - Installation/cleanup: setup, doctor and uninstall agree on the default global source; existing approval, backup, preflight and owned-registration rules apply. ## Evidence and regression coverage - Two modified CLI regressions failed on unmodified production source at the base revision (16 other tests passed), then passed with the fix. - Independent compiled CLI reproduction ran empty, unset and explicit XDG cases before and after the fix with separate temporary homes and working directories. - Final focused run: 106 tests passed across five existing CLI/filesystem files. - Native OpenCode loading/MCP handshake, macOS and Windows execution are unverified. ## Validation performed Linux x64, pinned Node 24.18.0 / npm 11.16.0: - `npm run test:focused -- tests/boundary/cli/clientProfileLifecycle.test.ts tests/boundary/cli/clientProfiles.test.ts tests/boundary/filesystem/clientLifecycle.test.ts tests/boundary/filesystem/clientConfigurationDialects.test.ts tests/boundary/filesystem/clientRegistrationStatus.test.ts` — 106 passed. - `npm run check` — passed all six tasks and architecture guards; 853 lint warnings, zero lint errors. The first attempt found one formatting issue, corrected with oxfmt. - `npm run verify:test-discovery` — all 915 test files discovered exactly once. - `npm pack --dry-run --json` — passed; 1,431 files. - `git diff --check` and pre-commit formatting/lint hooks — passed. - `npm run verify:package` — passed, including packaged CLI/MCP, 173 tools, setup/ uninstall, exact-version update, backups, failure recovery, symlink lifecycle, Skills 1.7.2 repository discovery and verified cleanup with no remaining descendants. The first run was stopped after its local registry forwarding repeatedly returned HTTP 500: Node's upstream fetch failed with `EAI_AGAIN`. A probe using the existing environment proxy returned HTTP 200. The passing run used `NODE_USE_ENV_PROXY=1` with loopback destinations excluded from the proxy (`NO_PROXY`, `no_proxy` and `npm_config_noproxy`); no repository or network-policy change was needed. ## Compatibility, safety, and release No breaking changes, metadata change or version bump. The fix does not migrate an already misplaced registration. No analysis provider behavior changed, so no real Hopper/Ghidra run was performed. The full deterministic suite was not run locally. [CI run 38251100446](https://github.com/morluto/rea/actions/runs/38251100446) is `action_required`; its page says it is awaiting approval from a maintainer. No jobs have executed yet, so no remote test pass is claimed. ## Review checklist - [x] Concrete issue and focused Conventional Commit title. - [x] Current issue, discussion, timeline and related PR searches checked. - [x] Observable behavior and malformed-input/preservation paths covered. - [x] Existing documentation contract remains valid; no generated files committed. - [x] Before/after paths and executed verification distinguished from unavailable coverage. - [x] Final diff checked for secrets, unrelated changes and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:02:50 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5073
No description provided.