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

Function build

packages/core/src/effect/app-node-builder.ts:6–17  ·  view source on GitHub ↗
(root: LayerNode.Node<A, E, any>, replacements: LayerNode.Replacements = [])

Source from the content-addressed store, hash-verified

4import { makeGlobalNode } from "./app-node"
5
6export function build<A, E>(root: LayerNode.Node<A, E, any>, replacements: LayerNode.Replacements = []) {
7 let allReplacements = replacements
8
9 // Only build the location service map if it's actually needed
10 if (LayerNode.hasUnbound(root, LocationServiceMap.node) && !hasReplacement(replacements, LocationServiceMap.node)) {
11 const locationMap = buildLocationServiceMap(replacements)
12 const locationMapNode = makeGlobalNode({ service: LocationServiceMap.Service, layer: locationMap, deps: [] })
13 allReplacements = replacements.concat([[LocationServiceMap.node, locationMapNode]])
14 }
15
16 return LayerNode.compile(root, allReplacements)
17}
18
19function hasReplacement(replacements: LayerNode.Replacements, node: LayerNode.Node<unknown, unknown, any>) {
20 return replacements.some(([source]) => source.name === node.name)

Callers

nothing calls this directly

Calls 2

buildLocationServiceMapFunction · 0.90
hasReplacementFunction · 0.85

Tested by

no test coverage detected