Skip to content

fix: prevent path transformation for standard global install location#326

Open
rafaelsnv wants to merge 2 commits into
darrenhinde:mainfrom
rafaelsnv:path-transformation-issue
Open

fix: prevent path transformation for standard global install location#326
rafaelsnv wants to merge 2 commits into
darrenhinde:mainfrom
rafaelsnv:path-transformation-issue

Conversation

@rafaelsnv

@rafaelsnv rafaelsnv commented Jun 9, 2026

Copy link
Copy Markdown

What

Fixes #321 and resolves #310 where /add-context and /add-context --global resolved to the same directory.

Why

The install script was incorrectly applying path transformation to standard global installs (~/.config/opencode), causing context paths to resolve to the same location regardless of the --global flag. This broke the local/global path separation documented in context-paths.md.

How

Modified the path transformation condition in install.sh to skip transformation for standard locations:

  • .opencode/ (local relative) - no transformation needed
  • */.opencode/ (local in subdirectory) - no transformation needed
  • ~/.config/opencode (global standard) - FIX: now skipped
  • Custom paths (/opt/opencode) - transformation still applied

Before fix: All paths transformed to install dir, local/global collapsed
After fix: Standard paths preserved, only custom paths transformed

Testing

  • Created scripts/tests/test-path-transformation.sh - 9/9 tests passed
  • Verified local installs skip transformation
  • Verified global standard skips transformation
  • Verified custom paths still get transformation
  • Compared old vs new behavior confirming fix

Files changed:

  • install.sh - 27 lines changed (20 insertions, 7 deletions)
  • scripts/tests/test-path-transformation.sh - new test file added

rafaelsnv added 2 commits June 3, 2026 11:32
Path transformation was incorrectly triggered for standard global installs
(~/.config/opencode), replacing .opencode/context/ references with absolute
user-specific paths. This caused:
- Corruption of local edits on reinstall
- Hardcoded paths breaking portability

Now transformation only applies to non-standard locations (e.g., /opt/opencode)
@rafaelsnv rafaelsnv marked this pull request as draft June 9, 2026 19:40
@rafaelsnv rafaelsnv marked this pull request as ready for review June 9, 2026 19:40
@rafaelsnv rafaelsnv marked this pull request as draft June 9, 2026 19:40
@rafaelsnv rafaelsnv closed this Jun 9, 2026
@rafaelsnv rafaelsnv reopened this Jun 9, 2026
@rafaelsnv rafaelsnv marked this pull request as ready for review June 9, 2026 19:52
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.

/add-context writes to global path instead of project-local by default ContextScout No .opencode/context/ directory exists

1 participant