refactor(core): refine layer node replacements (#34377)

This commit is contained in:
James Long 2026-06-28 23:48:18 -04:00 committed by GitHub
commit 84336e4f91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 346 additions and 341 deletions

View file

@ -1,7 +1,6 @@
import { describe, expect } from "bun:test"
import { Effect, Layer } from "effect"
import * as TestClock from "effect/testing/TestClock"
import { makeLocationNode } from "@opencode-ai/core/effect/app-node"
import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
import { Location } from "@opencode-ai/core/location"
@ -28,14 +27,12 @@ const locationLayer = Layer.succeed(
),
),
)
const locationNode = makeLocationNode({ service: Location.Service, layer: locationLayer, deps: [] })
const builtInsNode = LayerNode.bind(
LayerNode.group([SystemContextBuiltIns.node, SystemContextRegistry.node]),
Location.node,
locationNode,
)
const builtInsNode = LayerNode.group([SystemContextBuiltIns.node, SystemContextRegistry.node])
const it = testEffect(
AppNodeBuilder.build(builtInsNode, [LayerNode.replace(Global.layer, Global.layerWith({ config: "/global" }))]),
AppNodeBuilder.build(builtInsNode, [
[Location.node, locationLayer],
[Global.node, Global.layerWith({ config: "/global" })],
]),
)
const instructionFS = Layer.effect(
FSUtil.Service,
@ -51,8 +48,9 @@ const instructionFS = Layer.effect(
).pipe(Layer.provide(LayerNode.compile(FSUtil.node)))
const itWithInstructions = testEffect(
AppNodeBuilder.build(builtInsNode, [
LayerNode.replace(FSUtil.layer, instructionFS),
LayerNode.replace(Global.layer, Global.layerWith({ config: "/global" })),
[Location.node, locationLayer],
[FSUtil.node, instructionFS],
[Global.node, Global.layerWith({ config: "/global" })],
]),
)