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

Function readPluginManifest

packages/opencode/src/plugin/install.ts:283–331  ·  view source on GitHub ↗
(target: string)

Source from the content-addressed store, hash-verified

281}
282
283export async function readPluginManifest(target: string): Promise<ManifestResult> {
284 const pkg = await readPluginPackage(target).then(
285 (item) => ({
286 ok: true as const,
287 item,
288 }),
289 (error: unknown) => ({
290 ok: false as const,
291 error,
292 }),
293 )
294 if (!pkg.ok) {
295 return {
296 ok: false,
297 code: "manifest_read_failed",
298 file: target,
299 error: pkg.error,
300 }
301 }
302
303 const targets = await Promise.resolve()
304 .then(() => packageTargets(pkg.item))
305 .then(
306 (item) => ({ ok: true as const, item }),
307 (error: unknown) => ({ ok: false as const, error }),
308 )
309
310 if (!targets.ok) {
311 return {
312 ok: false,
313 code: "manifest_read_failed",
314 file: pkg.item.pkg,
315 error: targets.error,
316 }
317 }
318
319 if (!targets.item.length) {
320 return {
321 ok: false,
322 code: "manifest_no_targets",
323 file: pkg.item.pkg,
324 }
325 }
326
327 return {
328 ok: true,
329 targets: targets.item,
330 }
331}
332
333function patchDir(input: PatchInput) {
334 if (input.global) return input.config ?? Global.Path.config

Callers 2

installPluginBySpecFunction · 0.90
createPlugTaskFunction · 0.90

Calls 2

readPluginPackageFunction · 0.90
packageTargetsFunction · 0.85

Tested by

no test coverage detected