Skip to content

Conversation

@AamiRobin
Copy link

@AamiRobin AamiRobin commented Jan 24, 2026

Summary

Add support for completely isolated configuration directories so users can run plain OpenCode and oh-my-opencode side-by-side without config conflicts.

Problem Statement

Currently oh-my-opencode shares the same ~/.config/opencode/ directory with plain OpenCode. This creates conflicts because:

  1. The installer adds "oh-my-opencode" to the plugin array in opencode.json, which affects all OpenCode sessions
  2. Both plain OpenCode and oh-my-opencode write to the same config files
  3. Users cannot easily switch between a "plain" OpenCode setup and an "oh-my-opencode" setup

Solution

1. Environment Variable Support

Added OH_MY_OPENCODE_CONFIG_DIR environment variable with priority:

  1. OH_MY_OPENCODE_CONFIG_DIR (highest - isolated mode)
  2. OPENCODE_CONFIG_DIR (generic opencode override)
  3. Platform-specific default path

2. New ohmyoc Command

Created bin/ohmyoc.js - a convenience wrapper that automatically uses isolated mode:

  • Automatically sets OH_MY_OPENCODE_CONFIG_DIR=~/.config/oh-my-opencode/ before spawning
  • Passes all arguments through to the opencode binary
  • Handles platform detection, libc detection (Linux), and binary resolution
  • Provides proper exit codes and error handling

3. CLI Flag

Added --isolated flag to install command:

bunx oh-my-opencode install --isolated

This sets the isolated config directory before installation proceeds.

4. TUI Prompt

Added configuration mode selection in interactive installer:

  • Shared (default) - Use ~/.config/opencode/
  • Isolated - Use ~/.config/oh-my-opencode/

Usage After Installation

After installing with isolated mode, users have two commands available:

Command Config Path Plugin
opencode ~/.config/opencode/ Plain OpenCode (vanilla)
ohmyoc ~/.config/oh-my-opencode/ oh-my-opencode enabled
# Plain OpenCode - no oh-my-opencode features
opencode "Help me write code"

# oh-my-opencode - full features (agents, delegation, etc.)
ohmyoc "ulw Build a REST API"

Implementation Details

Config Path Resolution

Modified src/shared/opencode-config-dir.ts:

  • Added getOmoDefaultIsolatedDir() function
  • Added getOmoIsolatedConfigDir() function
  • Modified getCliConfigDir() to check OH_MY_OPENCODE_CONFIG_DIR first
  • Modified detectExistingConfigDir() to include isolated directory in search

Install Flow

Modified src/cli/install.ts:

  • Added config mode selection in TUI (lines 188-215)
  • Added --isolated flag handling in non-TUI mode (lines 333-338)
  • Both modes set OH_MY_OPENCODE_CONFIG_DIR and reset config context

CLI Changes

Modified src/cli/index.ts:

  • Added --isolated option to install command
  • Updated help text and examples

Documentation Updates

  • docs/configurations.md: Added isolated config mode section with priority order and paths
  • docs/cli-guide.md: Added ohmyoc command documentation
  • docs/guide/installation.md: Added config mode step to installation guide

Testing

Added comprehensive test coverage:

src/shared/opencode-config-dir-isolated.test.ts (255 lines, 15 tests)

  • Environment variable priority tests
  • Empty/whitespace env var handling
  • Relative path resolution
  • Platform-specific behavior
  • Fallback behavior

src/cli/install.test.ts (4 new tests in isolated mode section)

  • Non-TUI mode with isolated flag
  • Non-TUI mode without isolated flag (uses OPENCODE_CONFIG_DIR)
  • Isolated mode ignores custom OH_MY_OPENCODE_CONFIG_DIR path in non-TUI mode
  • Handles empty OH_MY_OPENCODE_CONFIG_DIR correctly

All 22 tests pass across both files.

Bug Fixes

  1. Fixed hardcoded error path in src/cli/config-manager.ts:473

    • Changed from ~/.config/opencode to dynamic getConfigDir()
    • Error message now shows actual config directory for isolated mode
  2. Added documentation note about desktop app limitation

    • Isolated mode only applies to CLI, not opencode-desktop
    • Desktop app uses its own config directory

File Changes

 bin/ohmyoc.js                                   |  83 ++++++++
 docs/cli-guide.md                               |  15 ++
 docs/configurations.md                          |  34 ++++
 docs/guide/installation.md                      |  41 +++-
 package.json                                    |   3 +-
 src/cli/config-manager.ts                       |   3 +-
 src/cli/index.ts                                |  11 +-
 src/cli/install.test.ts                         | 232 ++++++++++++++++++++-
 src/cli/install.ts                              |  57 +++++-
 src/cli/types.ts                                |   3 +
 src/shared/opencode-config-dir-isolated.test.ts | 255 ++++++++++++++++++++++++
 src/shared/opencode-config-dir.ts               |  29 +++
 12 files changed, 765 insertions(+), 20 deletions(-)

Breaking Changes

None. This is a purely additive feature.

  • Default behavior (shared mode) remains unchanged
  • Users must explicitly use --isolated flag or ohmyoc command to use isolated mode
  • Existing installations continue to work as before

Related Issues

Closes #685


Summary by cubic

Add isolated configuration mode so oh-my-opencode can run side-by-side with plain OpenCode without shared config conflicts. Includes a new ohmyoc wrapper that auto-uses isolated mode, plus an installer flag and TUI option.

  • New Features

    • Isolated config via OH_MY_OPENCODE_CONFIG_DIR (highest priority), defaulting to ~/.config/oh-my-opencode/.
    • New ohmyoc command that sets the isolated dir, forwards all args, and handles platform/libc and exit codes.
    • Installer updates: --isolated flag and TUI choice (shared vs isolated), with config detection/resolution updated to include the isolated dir.
    • Docs updated (usage, priority order, wrapper); tests added for env precedence, non-TUI flows, and isolated behavior.
  • Migration

    • To use isolated mode: run ohmyoc install, or bunx oh-my-opencode install --isolated.
    • After install: opencode uses ~/.config/opencode (vanilla), ohmyoc uses ~/.config/oh-my-opencode (oh-my-opencode enabled).
    • Isolated mode applies to the CLI only; the desktop app keeps its own config directory.

Written for commit def7cab. Summary will update on new commits.

Adds OH_MY_OPENCODE_CONFIG_DIR environment variable support for running
oh-my-opencode in isolated mode without conflicts with plain OpenCode
installations.

Changes:
- Add OH_MY_OPENCODE_CONFIG_DIR env var (highest priority)
- Add --isolated flag to install command
- Add TUI prompt for config mode selection (shared/isolated)
- Add ohmyoc convenience binary wrapper for auto-isolated mode
- Add isolated field to InstallArgs, InstallConfig, DetectedConfig
- Update config summary to display active config mode
- Update documentation with isolated mode usage

Closes code-yeongyu#685
docs(configurations): clarify isolated config mode behavior for CLI
fix(config-manager): use dynamic config directory in error message
@github-actions
Copy link
Contributor

github-actions bot commented Jan 24, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

@AamiRobin
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Jan 24, 2026
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.

1 issue found across 13 files

Confidence score: 4/5

  • The only noted issue is documentation-related, so overall merge risk looks low and this PR feels safe to merge.
  • In docs/guide/installation.md, the instructions always force --isolated, which could confuse users after the Shared vs Isolated mode choice.
  • Pay close attention to docs/guide/installation.md - resolve the mode/flag inconsistency in the installation steps.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="docs/guide/installation.md">

<violation number="1" location="docs/guide/installation.md:94">
P2: Installation instructions always force `--isolated`, contradicting the earlier Shared vs Isolated mode choice.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

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.

1 issue found across 13 files

Confidence score: 4/5

  • This PR looks safe to merge overall; the only noted issue is a moderate-risk assumption in the sandbox script.
  • test-sandbox/run-test.sh relies on pwd and a relative src/cli/index.ts, so running the script from non-repo-root directories may fail.
  • Pay close attention to test-sandbox/run-test.sh - path assumptions can break execution outside the repo root.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="test-sandbox/run-test.sh">

<violation number="1" location="test-sandbox/run-test.sh:5">
P2: Sandbox script assumes it is run from repo root; using `pwd` and relative `src/cli/index.ts` breaks when executed from other directories.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

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.

1 issue found across 13 files

Confidence score: 4/5

  • Moderate risk: test-sandbox/run-test.sh can report success even when bun run ... install fails, which could mask install/test failures in CI.
  • Impact is limited to test/installer signaling rather than runtime behavior, so this looks safe to merge with a small fix.
  • Pay close attention to test-sandbox/run-test.sh - ensure installer failures propagate correctly.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="test-sandbox/run-test.sh">

<violation number="1" location="test-sandbox/run-test.sh:17">
P2: Installer failure isn’t propagated; the script exits success even if `bun run ... install` fails.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

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.

2 issues found across 13 files

Confidence score: 4/5

  • The main risk is test behavior: src/cli/install.test.ts writes to and deletes the real ~/.config/oh-my-opencode, which could cause data loss and makes tests environment-dependent.
  • src/shared/opencode-config-dir-isolated.test.ts can fail if OPENCODE_CONFIG_DIR is set externally, so default-path tests are flaky but not production-impacting.
  • These are test-only issues and don’t imply runtime regressions, so this looks safe to merge with minor cleanup needed.
  • Pay close attention to src/cli/install.test.ts, src/shared/opencode-config-dir-isolated.test.ts - environment-dependent test behavior and potential data loss.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/cli/install.test.ts">

<violation number="1" location="src/cli/install.test.ts:202">
P2: Isolated-mode tests write to and delete the real `~/.config/oh-my-opencode` directory, risking data loss and making tests environment-dependent.</violation>
</file>

<file name="src/shared/opencode-config-dir-isolated.test.ts">

<violation number="1" location="src/shared/opencode-config-dir-isolated.test.ts:95">
P2: Default-path tests are environment-dependent because OPENCODE_CONFIG_DIR is not cleared; if it’s set externally, getOpenCodeConfigDir will return that path instead of the default and the test will fail.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

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.

No issues found across 13 files

Confidence score: 5/5

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

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.

[Feature]: Add isolated config mode / Separate config directory support

1 participant