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

Function load

packages/opencode/src/project/instance-store.ts:108–124  ·  view source on GitHub ↗
(input: LoadInput)

Source from the content-addressed store, hash-verified

106 })
107
108 const load = (input: LoadInput): Effect.Effect<InstanceContext> => {
109 const directory = FSUtil.resolve(input.directory)
110 return Effect.uninterruptibleMask((restore) =>
111 Effect.gen(function* () {
112 const existing = cache.get(directory)
113 if (existing) return yield* restore(Deferred.await(existing.deferred))
114
115 const entry: Entry = { deferred: Deferred.makeUnsafe<InstanceContext>() }
116 cache.set(directory, entry)
117 yield* Effect.gen(function* () {
118 yield* Effect.logInfo("creating instance", { directory: directory })
119 yield* completeLoad(directory, input, entry)
120 }).pipe(Effect.forkIn(scope, { startImmediately: true }))
121 return yield* restore(Deferred.await(entry.deferred))
122 }),
123 ).pipe(Effect.withSpan("InstanceStore.load"))
124 }
125
126 const reload = (input: LoadInput): Effect.Effect<InstanceContext> => {
127 const directory = FSUtil.resolve(input.directory)

Callers 1

provideFunction · 0.70

Calls 4

completeLoadFunction · 0.85
getMethod · 0.65
restoreFunction · 0.50
setMethod · 0.45

Tested by

no test coverage detected