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

Function activatePluginEntry

packages/opencode/src/plugin/tui/runtime.ts:516–556  ·  view source on GitHub ↗
(state: RuntimeState, plugin: PluginEntry, persist: boolean)

Source from the content-addressed store, hash-verified

514}
515
516async function activatePluginEntry(state: RuntimeState, plugin: PluginEntry, persist: boolean) {
517 plugin.enabled = true
518 if (persist) writePluginEnabledState(state.api, plugin.id, true)
519 if (plugin.scope) {
520 state.view.update({ status: listPluginStatus(state) })
521 return true
522 }
523
524 const scope = createPluginScope(plugin.load, plugin.id, state.dispose_timeout_ms)
525 const api = pluginApi(state, plugin, scope, plugin.id)
526 const ok = await Promise.resolve()
527 .then(async () => {
528 await syncPluginThemes(plugin)
529 await plugin.plugin(api, plugin.load.options, plugin.meta)
530 return true
531 })
532 .catch((error) => {
533 fail("failed to initialize tui plugin", {
534 path: plugin.load.spec,
535 id: plugin.id,
536 error,
537 })
538 return false
539 })
540
541 if (!ok) {
542 await scope.dispose()
543 state.view.update({ status: listPluginStatus(state) })
544 return false
545 }
546
547 if (!plugin.enabled) {
548 await scope.dispose()
549 state.view.update({ status: listPluginStatus(state) })
550 return true
551 }
552
553 plugin.scope = scope
554 state.view.update({ status: listPluginStatus(state) })
555 return true
556}
557
558async function activatePluginById(state: RuntimeState | undefined, id: string, persist: boolean) {
559 if (!state) return false

Callers 3

activatePluginByIdFunction · 0.85
addPluginBySpecFunction · 0.85
loadFunction · 0.85

Calls 8

writePluginEnabledStateFunction · 0.85
listPluginStatusFunction · 0.85
createPluginScopeFunction · 0.85
pluginApiFunction · 0.85
syncPluginThemesFunction · 0.85
failFunction · 0.70
updateMethod · 0.65
disposeMethod · 0.45

Tested by

no test coverage detected