anomalyco / anomalyco/opencode
Npm.install reify drops user dependencies from .opencode/package.json on Desktop start
@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:
node_modulesis missing, orpackage-lock.jsondoes not cover all deps declared inpackage.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
cd <project>/.opencode && npm i opencode-rag-plugin(creates package.json with both deps).- Start Desktop 1.18.27 (or any build calling
Npm.installon the.opencodedir) withnode_modulesmissing or stale lockfile. - Check
.opencode/package.json—opencode-rag-pluginis 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.