diff options
| author | Dax Raad <[email protected]> | 2026-04-18 20:02:24 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2026-04-18 20:02:24 -0400 |
| commit | f27eb8f09ef0d9071ebb4d1b11625b27f49a8939 (patch) | |
| tree | 7828c11ba21ae1d4c4064834fb633fe61566c89d | |
| parent | ad0545335a9ac5c371f4bd51674cd6da2414e2e9 (diff) | |
| download | opencode-f27eb8f09ef0d9071ebb4d1b11625b27f49a8939.tar.gz opencode-f27eb8f09ef0d9071ebb4d1b11625b27f49a8939.zip | |
fix plugins reinstalling too often
| -rw-r--r-- | packages/opencode/src/npm/index.ts | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/opencode/src/npm/index.ts b/packages/opencode/src/npm/index.ts index 0760e768b..477e99e06 100644 --- a/packages/opencode/src/npm/index.ts +++ b/packages/opencode/src/npm/index.ts @@ -1,6 +1,7 @@ export * as Npm from "." import path from "path" +import npa from "npm-package-arg" import semver from "semver" import { Effect, Schema, Context, Layer, Option, FileSystem } from "effect" import { NodeFileSystem } from "@effect/platform-node" @@ -135,6 +136,17 @@ export const layer = Layer.effect( const add = Effect.fn("Npm.add")(function* (pkg: string) { const dir = directory(pkg) + const name = (() => { + try { + return npa(pkg).name ?? pkg + } catch { + return pkg + } + })() + + if (yield* afs.existsSafe(dir)) { + return resolveEntryPoint(name, path.join(dir, "node_modules", name)) + } const tree = yield* reify({ dir, add: [pkg] }) const first = tree.edgesOut.values().next().value?.to |
