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

Function withTool

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

Source from the content-addressed store, hash-verified

87).pipe(Layer.provide(LayerNode.compile(FSUtil.node)))
88
89const withTool = <A, E, R>(directory: string, body: (registry: ToolRegistry.Interface) => Effect.Effect<A, E, R>) => {
90 const activeLocation = Layer.succeed(
91 Location.Service,
92 Location.Service.of(location({ directory: AbsolutePath.make(directory) })),
93 )
94 return Effect.gen(function* () {
95 return yield* body(yield* ToolRegistry.Service)
96 }).pipe(
97 Effect.provide(
98 AppNodeBuilder.build(
99 LayerNode.group([
100 ToolRegistry.node,
101 ToolRegistry.toolsNode,
102 LocationMutation.node,
103 FileMutation.node,
104 ApplyPatchTool.node,
105 ]),
106 [
107 [FSUtil.node, filesystem],
108 [Location.node, activeLocation],
109 [PermissionV2.node, permission],
110 [ToolOutputStore.node, ToolOutputStore.nodeWithoutConfig],
111 ],
112 ),
113 ),
114 )
115}
116
117const call = (patchText: string, id = "call-apply-patch") => ({
118 sessionID,

Callers 1

Calls 3

locationFunction · 0.90
bodyFunction · 0.50
makeMethod · 0.45

Tested by

no test coverage detected