anomalyco / anomalyco/opencode

Npm.install reify drops user dependencies from .opencode/package.json on Desktop start

Open
#47,131 0 comments 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Sep 3, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

On OpenCode Desktop 1.18.27 (Linux), starting the app can silently remove user dependencies from a project's .opencode/package.json, breaking plugins (e.g. opencode-rag-plugin — RAG tools stop being registered without any error).

Root cause

In packages/core/src/npm.ts, Npm.install calls reify({ add, dir }) when:

  1. node_modules is missing, or
  2. package-lock.json does not cover all deps declared in package.json (checkDirty).

reify() runs arborist.reify({ add, save: true, saveType: "prod" }) where add contains only @opencode-ai/plugin@<version>. Arborist rewrites package.json/node_modules from the add list — any user dependency not in add is dropped. Verified: after a Desktop start, .opencode/package.json was rewritten to contain only @opencode-ai/plugin, and opencode-rag-plugin disappeared from node_modules; RAG tools (search_semantic, find_usages, ...) silently vanished from sessions.

Repro
  1. cd <project>/.opencode && npm i opencode-rag-plugin (creates package.json with both deps).
  2. Start Desktop 1.18.27 (or any build calling Npm.install on the .opencode dir) with node_modules missing or stale lockfile.
  3. Check .opencode/package.jsonopencode-rag-plugin is gone.
Expected

reify must preserve existing dependencies from package.json (all four sections: dependencies, devDependencies, peerDependencies, optionalDependencies) when rebuilding the tree.

Fix

Prepared in PR #47130 (commit "fix(npm): preserve existing dependencies on reify") — merges existing deps into the add list before reify, deduped by package name.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.