@@ -27,6 +27,10 @@ import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
2727
2828it ( "only probes a locally configured OpenCode server's installed CLI" , ( ) => {
2929 assert . isTrue ( isLocalOpenCodeServerUrl ( "http://127.0.0.1:35768" ) ) ;
30+ assert . isTrue ( isLocalOpenCodeServerUrl ( "http://127.0.0.2:4096" ) ) ;
31+ assert . isTrue ( isLocalOpenCodeServerUrl ( "http://127.255.255.254:4096" ) ) ;
32+ assert . isFalse ( isLocalOpenCodeServerUrl ( "http://127.example.com:4096" ) ) ;
33+ assert . isFalse ( isLocalOpenCodeServerUrl ( "http://128.0.0.1:4096" ) ) ;
3034 assert . isTrue ( isLocalOpenCodeServerUrl ( "http://localhost:4096" ) ) ;
3135 assert . isTrue ( isLocalOpenCodeServerUrl ( "http://[::1]:4096" ) ) ;
3236 assert . isFalse ( isLocalOpenCodeServerUrl ( "https://remote.example.com:4096" ) ) ;
@@ -64,12 +68,12 @@ const layer = Layer.mergeAll(
6468 Layer . succeed ( OpenCodeRuntime . OpenCodeRuntime , openCode2Runtime ) ,
6569) . pipe ( Layer . provideMerge ( NodeServices . layer ) ) ;
6670
67- const create = ( config : Partial < OpenCodeSettings > , http : HttpClient . HttpClient ) =>
71+ const create = ( config : Partial < OpenCodeSettings > , http : HttpClient . HttpClient , enabled = true ) =>
6872 OpenCodeDriver . create ( {
6973 instanceId : ProviderInstanceId . make ( "opencode-test" ) ,
7074 displayName : undefined ,
7175 environment : [ ] ,
72- enabled : true ,
76+ enabled,
7377 config : { ...OpenCodeDriver . defaultConfig ( ) , ...config } ,
7478 } ) . pipe ( Effect . provideService ( HttpClient . HttpClient , http ) ) ;
7579
@@ -109,6 +113,27 @@ it.layer(layer)("OpenCodeDriver runtime selection", (it) => {
109113 } ) . pipe ( Effect . scoped ) ,
110114 ) ;
111115
116+ it . effect ( "skips the installed CLI probe when a localhost provider is disabled" , ( ) =>
117+ Effect . gen ( function * ( ) {
118+ const probed : string [ ] = [ ] ;
119+ const runtime = {
120+ ...openCode2Runtime ,
121+ runOpenCodeCommand : ( ) =>
122+ Effect . sync ( ( ) => {
123+ probed . push ( "--version" ) ;
124+ return { stdout : "opencode v2.1.2\n" , stderr : "" , code : 0 } ;
125+ } ) ,
126+ } as OpenCodeRuntime . OpenCodeRuntime [ "Service" ] ;
127+ const instance = yield * create ( { serverUrl : "http://127.0.0.1:4096" } , noHttp , false ) . pipe (
128+ Effect . provideService ( OpenCodeRuntime . OpenCodeRuntime , runtime ) ,
129+ ) ;
130+
131+ const snapshot = yield * instance . snapshot . refresh ;
132+ assert . isFalse ( snapshot . enabled ) ;
133+ assert . deepStrictEqual ( probed , [ ] ) ;
134+ } ) . pipe ( Effect . scoped ) ,
135+ ) ;
136+
112137 it . effect ( "answers capability reads without waiting on an unreachable server" , ( ) =>
113138 Effect . gen ( function * ( ) {
114139 const hang = HttpClient . make ( ( ) => Effect . never ) ;
0 commit comments