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

Function init

packages/opencode/src/plugin/tui/runtime.ts:988–1006  ·  view source on GitHub ↗
(input: {
  api: HostPluginApi
  config: TuiConfig.Resolved & TuiConfig.HostMetadata
  runtime?: PluginRuntime
  dispose?: () => void
  disposeTimeoutMs?: number
})

Source from the content-addressed store, hash-verified

986let runtime: RuntimeState | undefined
987
988export async function init(input: {
989 api: HostPluginApi
990 config: TuiConfig.Resolved & TuiConfig.HostMetadata
991 runtime?: PluginRuntime
992 dispose?: () => void
993 disposeTimeoutMs?: number
994}) {
995 const cwd = process.cwd()
996 if (loaded) {
997 if (dir !== cwd) {
998 throw new Error(`TuiPluginRuntime.init() called with a different working directory. expected=${dir} got=${cwd}`)
999 }
1000 return loaded
1001 }
1002
1003 dir = cwd
1004 loaded = load({ ...input, runtime: input.runtime ?? createPluginRuntime() })
1005 return loaded
1006}
1007
1008export function list() {
1009 if (!runtime) return []

Callers

nothing calls this directly

Calls 3

createPluginRuntimeFunction · 0.90
loadFunction · 0.70
cwdMethod · 0.65

Tested by

no test coverage detected