Skip to content

fix(installer): always use .config/opencode for CLI on Windows (#2502)#2546

Merged
acamq merged 3 commits intocode-yeongyu:devfrom
acamq:fix/installer-paths
Mar 15, 2026
Merged

fix(installer): always use .config/opencode for CLI on Windows (#2502)#2546
acamq merged 3 commits intocode-yeongyu:devfrom
acamq:fix/installer-paths

Conversation

@acamq
Copy link
Copy Markdown
Collaborator

@acamq acamq commented Mar 12, 2026

Summary

Fixes #2502 - On Windows, the oh-my-opencode installer was incorrectly checking for existing configs in AppData and potentially targeting that directory. OpenCode CLI always reads from ~/.config/opencode, so the installer should always write there.

Changes

  • src/shared/opencode-config-dir.ts: Simplified getCliConfigDir() Windows block to always return ~/.config/opencode, removing the AppData fallback logic
  • src/shared/opencode-config-dir.test.ts: Added regression test verifying Windows CLI ignores APPDATA env var

Test Plan

bun test src/shared/opencode-config-dir.test.ts  # 25 tests pass
bun run typecheck                                # 0 errors

@acamq acamq marked this pull request as draft March 12, 2026 23:43
Copy link
Copy Markdown

@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.

1 issue found across 3 files

Confidence score: 4/5

  • This PR is likely safe to merge, with minimal risk centered on test behavior rather than runtime production code.
  • The main issue is in src/shared/opencode-config-dir-windows-appdata-bug.test.ts: directly mutating fs.existsSync may not mock ESM named imports in Bun, which can cause flaky or ineffective test interception.
  • Given the moderate severity (5/10) and high confidence, the impact is mainly reduced test reliability and potential false confidence in coverage for this Windows AppData path behavior.
  • Pay close attention to src/shared/opencode-config-dir-windows-appdata-bug.test.ts - switch to mock.module("node:fs", ...) at file scope so Bun reliably intercepts existsSync.
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="src/shared/opencode-config-dir-windows-appdata-bug.test.ts">

<violation number="1" location="src/shared/opencode-config-dir-windows-appdata-bug.test.ts:37">
P2: Mutating `fs.existsSync` directly fails to intercept ESM named imports in Bun. Use `mock.module("node:fs", () => ({ existsSync: ... }))` from `bun:test` at the file level instead.</violation>
</file>

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

Comment thread src/shared/opencode-config-dir-windows-appdata-bug.test.ts Outdated
@acamq acamq force-pushed the fix/installer-paths branch from c49902e to 6b2da3c Compare March 12, 2026 23:47
@acamq acamq changed the title test(config-dir): add Windows AppData bug regression test fix(installer): always use .config/opencode for CLI on Windows (#2502) Mar 12, 2026
@acamq
Copy link
Copy Markdown
Collaborator Author

acamq commented Mar 12, 2026

@cubic-dev-ai review

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai bot commented Mar 12, 2026

@cubic-dev-ai review

@acamq I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown

@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.

1 issue found across 2 files

Confidence score: 3/5

  • There is a concrete compatibility regression risk in src/shared/opencode-config-dir.ts: hardcoding ~/.config/opencode on Windows can ignore XDG_CONFIG_HOME, changing where config is discovered for users who rely on that env var.
  • Given the issue’s high severity/confidence (7/10, 10/10) and user-visible behavior impact, this carries some merge risk even though the change scope appears small.
  • Pay close attention to src/shared/opencode-config-dir.ts - restore XDG_CONFIG_HOME-aware resolution on Windows to avoid breaking existing OpenCode CLI config lookup behavior.
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="src/shared/opencode-config-dir.ts">

<violation number="1" location="src/shared/opencode-config-dir.ts:52">
P1: Custom agent: **Opencode Compatibility**

Hardcoding `~/.config/opencode` for Windows drops support for the `XDG_CONFIG_HOME` environment variable, which the OpenCode CLI naturally supports via `xdg-basedir` on all OS platforms. This discrepancy means the installer will check the wrong directory for Windows users who override `XDG_CONFIG_HOME`. Remove the entire `win32` platform check and let Windows fall through to the XDG fallback below it.</violation>
</file>

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

Comment thread src/shared/opencode-config-dir.ts Outdated
@acamq
Copy link
Copy Markdown
Collaborator Author

acamq commented Mar 15, 2026

@cubic-dev-ai review

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai bot commented Mar 15, 2026

@cubic-dev-ai review

@acamq I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown

@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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Removing the Win32-specific block causes the installer to respect XDG_CONFIG_HOME on Windows, which may diverge from the CLI's behavior if it strictly uses ~/.config/opencode.

@acamq acamq marked this pull request as ready for review March 15, 2026 21:08
Copy link
Copy Markdown

@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.

1 issue found across 2 files

Confidence score: 4/5

  • This PR is likely safe to merge, with only a small test-stability risk rather than a production behavior change.
  • In src/shared/opencode-config-dir.test.ts, not clearing process.env.XDG_CONFIG_HOME can make the test fail depending on the runner’s environment, which may cause intermittent CI noise.
  • The issue is moderate-low severity (4/10) and highly certain, so it’s worth fixing soon but does not look merge-blocking for runtime functionality.
  • Pay close attention to src/shared/opencode-config-dir.test.ts - ensure process.env.XDG_CONFIG_HOME is deleted/reset to keep the test deterministic.
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="src/shared/opencode-config-dir.test.ts">

<violation number="1" location="src/shared/opencode-config-dir.test.ts:200">
P2: Delete `process.env.XDG_CONFIG_HOME` to prevent environment variables from causing this test to fail.</violation>
</file>

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

Comment thread src/shared/opencode-config-dir.test.ts
Windows CLI tests were not deleting XDG_CONFIG_HOME, making them
fragile in environments where this variable is set. getCliConfigDir()
reads XDG_CONFIG_HOME on all platforms, not just Linux.
Copy link
Copy Markdown

@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.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

@acamq
Copy link
Copy Markdown
Collaborator Author

acamq commented Mar 15, 2026

@cubic-dev-ai review

@cubic-dev-ai
Copy link
Copy Markdown

cubic-dev-ai bot commented Mar 15, 2026

@cubic-dev-ai review

@acamq I have started the AI code review. It will take a few minutes to complete.

Copy link
Copy Markdown

@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.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Aligns Windows config directory with CLI behavior by removing incorrect AppData fallback and simplifying the shared logic. Includes regression tests.

@acamq acamq merged commit 14d7043 into code-yeongyu:dev Mar 15, 2026
7 of 8 checks passed
@acamq acamq deleted the fix/installer-paths branch March 17, 2026 15:11
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.

[Bug]: omo doesn't activate after installation on windows

1 participant