Skip to content

OpenCode reinstall can alter user files and lose managed skill ownership #1913

Closed

Description

@22nsuk

Problem

Reproduced against main at 00d0a5bbf1300b2138b65ce724b325dd4dff77ba (3.33.1) using temporary fixtures on Linux, Bun 1.4.2. Three gaps in the CLI's OpenCode install/reinstall path violate file preservation or prevent updates.

  1. Nested user symlinks. Install a workflows:review command, then replace commands/workflows with a symlink to a user directory containing review.md. Reinstalling with that command removed deletes the user's file; reinstalling with the command retained writes through the link. The store-root guard added in fix(targets): guard writers against ancestor-symlink traversal on install #1100 checks commands, while the leaf check sees a regular review.md; neither catches the intervening directory link. The skipped paths should remain untouched and unowned by the new install manifest.
  2. Failed config backup. With malformed opencode.json, a writable existing file, and a parent directory that cannot create backup files, backupFile() returns null and the writer overwrites the original. The operation succeeds and prints user settings preserved, although there is no backup. If an existing config cannot be backed up, the install should fail before replacing it or removing existing artifacts. Normal config merging and the existing backed-up malformed-config recovery should keep working.
  3. Overlapping component paths. A valid manifest declaring skills: ["./skills"] loads the default skill directory twice. The second copy treats the just-installed directory as unmanaged, so the manifest records skills: []. A subsequent install leaves the old SKILL.md unchanged. Collect each source component file once while preserving genuinely distinct default/custom components.

Scope

Preserve user files and correct ownership across OpenCode installs. Reuse the existing realpath-containment and ownership mechanisms, stop on an unavailable config backup, and deduplicate component-file collection at the parser boundary. Add regression coverage through the existing writer/parser tests, including first install followed by update/removal.

This follows the existing preservation work in #1094/#1100 and config-preservation report #125; those changes are already merged/closed. I did not find an open issue or PR covering these specific reproductions. No new platform, CLI flag, manifest format, or release-version changes are proposed. Native OpenCode package loading is a separate path and is not changed here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions