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

Function resolveExternalPlugins

packages/opencode/src/plugin/tui/runtime.ts:676–774  ·  view source on GitHub ↗
(list: ConfigPlugin.Origin[], wait: () => Promise<void>)

Source from the content-addressed store, hash-verified

674}
675
676async function resolveExternalPlugins(list: ConfigPlugin.Origin[], wait: () => Promise<void>) {
677 return PluginLoader.loadExternal({
678 items: list,
679 kind: "tui",
680 wait: async () => {
681 await wait().catch(() => {})
682 },
683 finish: async (loaded, origin, retry) => {
684 const mod = await Promise.resolve()
685 .then(() => readV1Plugin(loaded.mod as Record<string, unknown>, loaded.spec, "tui") as TuiPluginModule)
686 .catch((error) => {
687 fail("failed to load tui plugin", {
688 path: loaded.spec,
689 target: loaded.entry,
690 retry,
691 error,
692 })
693 return
694 })
695 if (!mod) return
696
697 const id = await resolvePluginId(
698 loaded.source,
699 loaded.spec,
700 loaded.target,
701 readPluginId(mod.id, loaded.spec),
702 loaded.pkg,
703 ).catch((error) => {
704 fail("failed to load tui plugin", { path: loaded.spec, target: loaded.target, retry, error })
705 return
706 })
707 if (!id) return
708
709 const theme_files = await readThemeFiles(loaded.spec, loaded.pkg)
710
711 return {
712 options: loaded.options,
713 spec: loaded.spec,
714 target: loaded.target,
715 retry,
716 source: loaded.source,
717 id,
718 module: mod,
719 origin,
720 plugin_root: loaded.pkg?.dir ?? resolveRoot(loaded.target),
721 theme_files,
722 }
723 },
724 missing: async (loaded, origin, retry) => {
725 const theme_files = await readThemeFiles(loaded.spec, loaded.pkg)
726 if (!theme_files.length) return
727
728 const name =
729 typeof loaded.pkg?.json.name === "string" && loaded.pkg.json.name.trim().length > 0
730 ? loaded.pkg.json.name.trim()
731 : undefined
732 const id = await resolvePluginId(loaded.source, loaded.spec, loaded.target, name, loaded.pkg).catch((error) => {
733 fail("failed to load tui plugin", { path: loaded.spec, target: loaded.target, retry, error })

Callers 2

addPluginBySpecFunction · 0.85
loadFunction · 0.85

Calls 7

readV1PluginFunction · 0.90
resolvePluginIdFunction · 0.90
readPluginIdFunction · 0.90
readThemeFilesFunction · 0.85
resolveRootFunction · 0.85
failFunction · 0.70
waitFunction · 0.50

Tested by

no test coverage detected