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

Function provide

packages/cli/src/framework/runtime.ts:62–77  ·  view source on GitHub ↗
(node: Spec.Any, handlers: ReadonlyArray<LazyHandler>)

Source from the content-addressed store, hash-verified

60}
61
62function provide(node: Spec.Any, handlers: ReadonlyArray<LazyHandler>): ProvidedCommand {
63 const handler = handlers.find((handler) => handler.spec === node.spec)
64 const spec = handler
65 ? node.spec.pipe(
66 Command.withHandler((input) =>
67 Effect.gen(function* () {
68 yield* Effect.flatMap(Effect.promise(handler.load), (module) => module.default(input))
69 }),
70 ),
71 )
72 : node.spec
73 if (!Object.keys(node.commands).length) return spec as ProvidedCommand
74 return spec.pipe(
75 Command.withSubcommands(Object.values(node.commands).map((child) => provide(child, handlers))),
76 ) as ProvidedCommand
77}
78
79export * as Runtime from "./runtime"

Callers 1

runFunction · 0.70

Calls 3

defaultMethod · 0.80
findMethod · 0.65
valuesMethod · 0.45

Tested by

no test coverage detected