MCPcopy Create free account
hub / github.com/anomalyco/opencode / compileNode

Function compileNode

packages/core/src/effect/layer-node.ts:256–268  ·  view source on GitHub ↗
(node: AnyNode)

Source from the content-addressed store, hash-verified

254 const replacementMap = replacementMapFrom(replacements)
255 const cache = new Map<AnyNode, RuntimeLayer>()
256 const compileNode = (node: AnyNode) =>
257 walk<RuntimeLayer>(
258 node,
259 (node, context) => {
260 if (node.kind === "unbound") throw new Error(`Unbound layer node: ${node.name}`)
261 const dependencies = node.dependencies.flatMap(flatten).map(context.visit)
262 const implementation = node.implementation! as RuntimeLayer
263 return dependencies.length === 0
264 ? implementation
265 : implementation.pipe(Layer.provide(dependencies as [RuntimeLayer, ...RuntimeLayer[]]))
266 },
267 { cache, resolve: (node) => replacementMap.get(node.name) ?? node },
268 )
269 const layers = flatten(root).map((node) => compileNode(node))
270 const layer = layers.reduce<RuntimeLayer>((result, layer) => layer.pipe(Layer.provideMerge(result)), Layer.empty)
271 return layer as Layer.Layer<A, E>

Callers 1

compileFunction · 0.85

Calls 2

walkFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected