@@ -2,15 +2,20 @@ import { describe, expect, it } from "@effect/vitest";
22import * as Effect from "effect/Effect" ;
33import * as Sink from "effect/Sink" ;
44import * as Stream from "effect/Stream" ;
5+ import type * as ChildProcess from "effect/process/ChildProcess" ;
56import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner" ;
67
78import { discoverGrokSkills } from "./skills.ts" ;
89
910const inspectPayload = ( skills : ReadonlyArray < unknown > ) => JSON . stringify ( { skills } ) ;
1011
11- const makeInspectSpawner = ( stdout : string , exitCode = 0 , spawnCwds ?: Array < string | undefined > ) =>
12+ const makeInspectSpawner = (
13+ stdout : string ,
14+ exitCode = 0 ,
15+ spawnOptions ?: Array < ChildProcess . CommandOptions | undefined > ,
16+ ) =>
1217 ChildProcessSpawner . make ( ( command ) => {
13- spawnCwds ?. push ( command . _tag === "StandardCommand" ? command . options . cwd : undefined ) ;
18+ spawnOptions ?. push ( command . _tag === "StandardCommand" ? command . options : undefined ) ;
1419 return Effect . succeed (
1520 ChildProcessSpawner . makeHandle ( {
1621 pid : ChildProcessSpawner . ProcessId ( 1 ) ,
@@ -142,7 +147,7 @@ describe("discoverGrokSkills", () => {
142147 ) ;
143148
144149 it . effect ( "spawns in the configured cwd and rejects a failed probe" , ( ) => {
145- const spawnCwds : Array < string | undefined > = [ ] ;
150+ const spawnOptions : Array < ChildProcess . CommandOptions | undefined > = [ ] ;
146151 const stdout = inspectPayload ( [
147152 {
148153 name : "kept" ,
@@ -154,11 +159,11 @@ describe("discoverGrokSkills", () => {
154159 const skills = yield * discoverGrokSkills ( { binaryPath : "grok" } , { } , "/workspaces/demo" ) . pipe (
155160 Effect . provideService (
156161 ChildProcessSpawner . ChildProcessSpawner ,
157- makeInspectSpawner ( stdout , 0 , spawnCwds ) ,
162+ makeInspectSpawner ( stdout , 0 , spawnOptions ) ,
158163 ) ,
159164 ) ;
160165
161- expect ( spawnCwds ) . toEqual ( [ "/workspaces/demo" ] ) ;
166+ expect ( spawnOptions . map ( ( options ) => options ?. cwd ) ) . toEqual ( [ "/workspaces/demo" ] ) ;
162167 expect ( skills . map ( ( skill ) => skill . name ) ) . toEqual ( [ "kept" ] ) ;
163168
164169 const failed = yield * discoverGrokSkills ( { binaryPath : "grok" } ) . pipe (
@@ -171,4 +176,26 @@ describe("discoverGrokSkills", () => {
171176 expect ( failed . _tag ) . toBe ( "Failure" ) ;
172177 } ) ;
173178 } ) ;
179+
180+ // Workspace skill probes run on their own from the driver, outside the
181+ // status check, so they must suppress Grok's launch-time updater themselves.
182+ it . effect ( "disables Grok's updater for the probe without touching the caller's env" , ( ) => {
183+ const spawnOptions : Array < ChildProcess . CommandOptions | undefined > = [ ] ;
184+ const environment = { GROK_DISABLE_AUTOUPDATER : "0" , GROK_HOME : "/home/dev/.grok" } ;
185+
186+ return Effect . gen ( function * ( ) {
187+ yield * discoverGrokSkills ( { binaryPath : "grok" } , environment , "/workspaces/demo" ) . pipe (
188+ Effect . provideService (
189+ ChildProcessSpawner . ChildProcessSpawner ,
190+ makeInspectSpawner ( inspectPayload ( [ ] ) , 0 , spawnOptions ) ,
191+ ) ,
192+ ) ;
193+
194+ expect ( spawnOptions [ 0 ] ?. env ) . toEqual ( {
195+ GROK_DISABLE_AUTOUPDATER : "1" ,
196+ GROK_HOME : "/home/dev/.grok" ,
197+ } ) ;
198+ expect ( environment . GROK_DISABLE_AUTOUPDATER ) . toBe ( "0" ) ;
199+ } ) ;
200+ } ) ;
174201} ) ;
0 commit comments