MCPcopy
hub / github.com/anomalyco/opencode / withTool

Function withTool

packages/core/test/tool-edit.test.ts:79–105  ·  view source on GitHub ↗
(directory: string, body: (registry: ToolRegistry.Interface) => Effect.Effect<A, E, R>)

Source from the content-addressed store, hash-verified

77).pipe(Layer.provide(LayerNode.compile(FSUtil.node)))
78
79const withTool = <A, E, R>(directory: string, body: (registry: ToolRegistry.Interface) => Effect.Effect<A, E, R>) => {
80 const activeLocation = Layer.succeed(
81 Location.Service,
82 Location.Service.of(location({ directory: AbsolutePath.make(directory) })),
83 )
84 return Effect.gen(function* () {
85 return yield* body(yield* ToolRegistry.Service)
86 }).pipe(
87 Effect.provide(
88 AppNodeBuilder.build(
89 LayerNode.group([
90 ToolRegistry.node,
91 ToolRegistry.toolsNode,
92 LocationMutation.node,
93 FileMutation.node,
94 EditTool.node,
95 ]),
96 [
97 [FSUtil.node, filesystem],
98 [Location.node, activeLocation],
99 [PermissionV2.node, permission],
100 [ToolOutputStore.node, ToolOutputStore.nodeWithoutConfig],
101 ],
102 ),
103 ),
104 )
105}
106
107const call = (input: typeof EditTool.Input.Type, id = "call-edit") => ({
108 sessionID,

Callers 1

tool-edit.test.tsFile · 0.70

Calls 3

locationFunction · 0.90
bodyFunction · 0.50
makeMethod · 0.45

Tested by

no test coverage detected