Skip to content

fix(opencode): preserve user files and skill ownership on reinstall - #1914

Merged
tmchow merged 4 commits into
EveryInc:mainfrom
22nsuk:codex/fix-opencode-install-preservation
Oct 28, 2026
Merged

tmchow merged 4 commits into
EveryInc:mainfrom
22nsuk:codex/fix-opencode-install-preservation

Conversation

@22nsuk

@22nsuk 22nsuk commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1913.

OpenCode reinstalls can currently modify files through a nested user symlink, replace an existing config after its backup failed, or stop updating a skill whose source directory was loaded twice. This fixes the three ownership/preservation gaps in the existing CLI install path:

  • Check each artifact's resolved location before updating or removing it, using the existing containment predicate. Preserved paths stay out of the new manifest. A relocated config root still works, and names such as ..review are distinguished from a .. traversal segment.
  • Require a successful backup of an existing opencode.json before cleanup or replacement. Keep normal merging and recovery from a backed-up malformed config; remove the unconditional user settings preserved message.
  • Collect identical component-file paths once, in first-seen order, so a repeated/default-overlapping skills path cannot erase ownership from the manifest. This correction belongs in the shared parser; distinct component files remain distinct for all converters.

The changes follow the preservation contract in #1094/#1100 and the config-preservation intent of #125. They do not change the native OpenCode loader or the install-manifest format.

Validation

  • GitHub CI: all six jobs passed for f8d4990f, including Linux tests/typecheck, Windows, macOS, acpx contracts, docs audit, and PR title. The separate docs build also passed.
  • Regression cases were run against their unfixed paths: nested command create/update/remove, failed backups of valid and malformed configs, the false preservation message, overlapping component collection, and first-install ownership all failed as expected. The dot-prefixed-name update also caught the containment predicate's prefix/segment distinction.
  • Final bun run test: passed through the repository's built-in timeout recovery. First pass: 4,713 passed, 10 skipped, one TimeoutError in ce-work-workspace-harness; its fresh-process rerun passed all 10 tests. Skips are the nine opt-in acpx contract cases and the unavailable omp CLI.
  • bun run typecheck, bun run release:validate, strict marketplace/plugin validation with the CI-pinned Claude Code 2.1.220, and git diff --check: passed.
  • Native Windows Bun 1.4.2 at c49122a4 (runtime code unchanged at the final head), from a local NTFS copy: all writer/component-path cases passed (32 passed, 5 skipped: two POSIX-permission cases and three file-symlink cases unavailable in this Windows environment). The broader two-file run had 46 passes, 5 skips, and one existing repository-tree assertion failure: it expects / where Windows Bun.Glob returns \\. Replacing all five changed files with upstream 00d0a5bb reproduces the same failure. An earlier run over the WSL share also timed out in two existing cases; the local-copy run completed without those timeouts. These results do not claim a fully passing native Windows suite.

Security Disclosure

Extends the existing realpath containment checks to individual artifact mutations and stops OpenCode config replacement when its backup is unavailable. The tests use temporary user-file fixtures and real directory symlinks/junctions. No permission or dependency changes.

Agent Disclosure

  • Model: Codex desktop · GPT-6

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T04:26:31.060255Z c49122a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tmchow
tmchow merged commit e857b20 into EveryInc:main Oct 28, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 28, 2026
tmchow added a commit to Quinnod345/compound-engineering-plugin that referenced this pull request Oct 28, 2026
…-1916

Resolves the conflict with EveryInc#1914 in src/targets/opencode.ts: config is
backed up (and a failed backup still throws) only when the merged config
differs from the file on disk, and command files are backed up and
rewritten only when their content changed.
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.

OpenCode reinstall can alter user files and lose managed skill ownership

2 participants