refactor(core): refine layer node replacements (#34377)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { describe, expect } from "bun:test"
|
||||
import path from "path"
|
||||
import { Cause, Effect, Exit, Fiber, Layer, Option } from "effect"
|
||||
import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
|
||||
import { LayerNode } from "@opencode-ai/core/effect/layer-node"
|
||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||
import { Global } from "@opencode-ai/core/global"
|
||||
import { Config } from "@opencode-ai/core/config"
|
||||
@@ -28,14 +30,14 @@ const withStore = <A, E, R>(
|
||||
}),
|
||||
)
|
||||
: Layer.empty
|
||||
const store = ToolOutputStore.layer.pipe(
|
||||
Layer.provide(FSUtil.defaultLayer),
|
||||
Layer.provide(global),
|
||||
Layer.provide(configured),
|
||||
)
|
||||
|
||||
const store = AppNodeBuilder.build(LayerNode.group([ToolOutputStore.node, FSUtil.node]), [
|
||||
[Global.node, global],
|
||||
[Config.node, configured],
|
||||
])
|
||||
return Effect.gen(function* () {
|
||||
return yield* body({ root: tmp.path, store: yield* ToolOutputStore.Service, fs: yield* FSUtil.Service })
|
||||
}).pipe(Effect.provide(Layer.mergeAll(store, FSUtil.defaultLayer)))
|
||||
}).pipe(Effect.provide(store))
|
||||
},
|
||||
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
|
||||
)
|
||||
@@ -185,11 +187,11 @@ describe("ToolOutputStore", () => {
|
||||
writeFileString: () => Effect.never,
|
||||
})
|
||||
}),
|
||||
).pipe(Layer.provide(FSUtil.defaultLayer))
|
||||
const store = ToolOutputStore.layer.pipe(
|
||||
Layer.provide(blockedFilesystem),
|
||||
Layer.provide(Global.layerWith({ data: root.path })),
|
||||
)
|
||||
).pipe(Layer.provide(LayerNode.compile(FSUtil.node)))
|
||||
const store = AppNodeBuilder.build(ToolOutputStore.nodeWithoutConfig, [
|
||||
[Global.node, Global.layerWith({ data: root.path })],
|
||||
[FSUtil.node, blockedFilesystem],
|
||||
])
|
||||
const exit = yield* Effect.gen(function* () {
|
||||
const service = yield* ToolOutputStore.Service
|
||||
const fiber = yield* service
|
||||
|
||||
Reference in New Issue
Block a user