MCPcopy Index your code
hub / github.com/anomalyco/opencode / resolvePluginId

Function resolvePluginId

packages/opencode/src/plugin/shared.ts:306–323  ·  view source on GitHub ↗
(
  source: PluginSource,
  spec: string,
  target: string,
  id: string | undefined,
  pkg?: PluginPackage,
)

Source from the content-addressed store, hash-verified

304}
305
306export async function resolvePluginId(
307 source: PluginSource,
308 spec: string,
309 target: string,
310 id: string | undefined,
311 pkg?: PluginPackage,
312) {
313 if (source === "file") {
314 if (id) return id
315 throw new TypeError(`Path plugin ${spec} must export id`)
316 }
317 if (id) return id
318 const hit = pkg ?? (await readPluginPackage(target))
319 if (typeof hit.json.name !== "string" || !hit.json.name.trim()) {
320 throw new TypeError(`Plugin package ${hit.pkg} is missing name`)
321 }
322 return hit.json.name.trim()
323}

Callers 2

applyPluginFunction · 0.90
resolveExternalPluginsFunction · 0.90

Calls 1

readPluginPackageFunction · 0.85

Tested by

no test coverage detected