@@ -7,6 +7,7 @@ import type { SessionInbox } from "@opencode/schema/session-inbox"
77import { makeLocationNode } from "@opencode/util/effect/app-node"
88import { Context , Effect , Layer , Schema } from "effect"
99import { Bus } from "./bus.js"
10+ import { Mcp } from "./mcp/index.js"
1011import { State } from "./state.js"
1112
1213export const Info = Command . Info
@@ -54,6 +55,7 @@ export const layer = Layer.effect(
5455 Service ,
5556 Effect . gen ( function * ( ) {
5657 const bus = yield * Bus . Service
58+ const mcp = yield * Mcp . Service
5759 const info = ( definition : Definition ) =>
5860 Info . make ( {
5961 name : definition . name ,
@@ -74,14 +76,17 @@ export const layer = Layer.effect(
7476 return Service . of ( {
7577 reload : state . reload ,
7678 transform : state . transform ,
77- get : Effect . fn ( "Command.get" ) ( ( name ) =>
78- Effect . sync ( ( ) => {
79- const definition = state . get ( ) . get ( name )
80- return definition ? info ( definition ) : undefined
81- } ) ,
82- ) ,
83- list : Effect . fn ( "Command.list" ) ( ( ) => Effect . sync ( ( ) => Array . from ( state . get ( ) . values ( ) , info ) ) ) ,
79+ get : Effect . fn ( "Command.get" ) ( function * ( name ) {
80+ yield * mcp . start ( )
81+ const definition = state . get ( ) . get ( name )
82+ return definition ? info ( definition ) : undefined
83+ } ) ,
84+ list : Effect . fn ( "Command.list" ) ( function * ( ) {
85+ yield * mcp . start ( )
86+ return Array . from ( state . get ( ) . values ( ) , info )
87+ } ) ,
8488 execute : Effect . fn ( "Command.execute" ) ( function * ( input ) {
89+ yield * mcp . start ( )
8590 const definition = state . get ( ) . get ( input . name )
8691 if ( ! definition )
8792 return yield * new NotFoundError ( { command : input . name , message : `Command not found: ${ input . name } ` } )
@@ -97,7 +102,7 @@ export const layer = Layer.effect(
97102export const node = makeLocationNode ( {
98103 service : Service ,
99104 layer,
100- deps : [ Bus . node ] ,
105+ deps : [ Bus . node , Mcp . node ] ,
101106} )
102107
103108function errorMessage ( error : unknown ) {
0 commit comments