Skip to content

Commit 363c947

Browse files
mInrOzclaude
andcommitted
fix(grok): run the skills probe in the configured server cwd
The inspect spawn inherited the server process cwd, so a configured ServerConfig cwd (the directory the Claude skill scan already uses) was ignored and project-scope skills could be missed. The driver now passes ServerConfig.cwd through checkGrokProviderStatus to the `grok inspect --json` spawn, mirroring ClaudeDriver. Regression test asserts the spawn receives the configured cwd. Built with Claude Code (Claude Fable 5). Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 1f28c79 commit 363c947

4 files changed

Lines changed: 54 additions & 3 deletions

File tree

‎apps/server/src/provider/Drivers/GrokDriver.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv> = {
8888
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
8989
const httpClient = yield* HttpClient.HttpClient;
9090
const serverSettings = yield* ServerSettingsService;
91+
const { cwd } = yield* ServerConfig;
9192
const eventLoggers = yield* ProviderEventLoggers;
9293
const processEnv = mergeProviderInstanceEnvironment(environment);
9394
const continuationIdentity = defaultProviderContinuationIdentity({
@@ -113,7 +114,7 @@ export const GrokDriver: ProviderDriver<GrokSettings, GrokDriverEnv> = {
113114
});
114115
const textGeneration = yield* makeGrokTextGeneration(effectiveConfig, processEnv);
115116

116-
const checkProvider = checkGrokProviderStatus(effectiveConfig, processEnv).pipe(
117+
const checkProvider = checkGrokProviderStatus(effectiveConfig, processEnv, cwd).pipe(
117118
Effect.map(stampIdentity),
118119
Effect.provideService(Crypto.Crypto, crypto),
119120
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),

‎apps/server/src/provider/Drivers/GrokSkills.test.ts‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { describe, expect, it } from "@effect/vitest";
2+
import * as Effect from "effect/Effect";
3+
import * as Layer from "effect/Layer";
4+
import * as Sink from "effect/Sink";
5+
import * as Stream from "effect/Stream";
6+
import { ChildProcessSpawner } from "effect/unstable/process";
27

3-
import { parseGrokInspectSkills } from "./GrokSkills.ts";
8+
import { discoverGrokSkills, parseGrokInspectSkills } from "./GrokSkills.ts";
49

510
const inspectPayload = (skills: ReadonlyArray<unknown>) => JSON.stringify({ skills });
611

@@ -86,3 +91,45 @@ describe("parseGrokInspectSkills", () => {
8691
expect(parseGrokInspectSkills(JSON.stringify({}))).toEqual([]);
8792
});
8893
});
94+
95+
describe("discoverGrokSkills", () => {
96+
it.effect("spawns the inspect probe in the configured cwd", () => {
97+
const spawnCwds: Array<string | undefined> = [];
98+
const spawner = ChildProcessSpawner.make((command) => {
99+
spawnCwds.push(command._tag === "StandardCommand" ? command.options.cwd : undefined);
100+
return Effect.succeed(
101+
ChildProcessSpawner.makeHandle({
102+
pid: ChildProcessSpawner.ProcessId(1),
103+
exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(0)),
104+
isRunning: Effect.succeed(false),
105+
kill: () => Effect.void,
106+
unref: Effect.succeed(Effect.void),
107+
stdin: Sink.drain,
108+
stdout: Stream.encodeText(
109+
Stream.make(
110+
inspectPayload([
111+
{
112+
name: "kept",
113+
source: { type: "project", path: "/workspaces/demo/.grok/skills/kept/SKILL.md" },
114+
},
115+
]),
116+
),
117+
),
118+
stderr: Stream.empty,
119+
all: Stream.empty,
120+
getInputFd: () => Sink.drain,
121+
getOutputFd: () => Stream.empty,
122+
}),
123+
);
124+
});
125+
126+
return Effect.gen(function* () {
127+
const skills = yield* discoverGrokSkills({ binaryPath: "grok" }, {}, "/workspaces/demo").pipe(
128+
Effect.provide(Layer.succeed(ChildProcessSpawner.ChildProcessSpawner, spawner)),
129+
);
130+
131+
expect(spawnCwds).toEqual(["/workspaces/demo"]);
132+
expect(skills.map((skill) => skill.name)).toEqual(["kept"]);
133+
});
134+
});
135+
});

‎apps/server/src/provider/Drivers/GrokSkills.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function parseGrokInspectSkills(stdout: string): ReadonlyArray<ServerProv
8383
export const discoverGrokSkills = Effect.fn("discoverGrokSkills")(function* (
8484
grokSettings: Pick<GrokSettings, "binaryPath">,
8585
environment: NodeJS.ProcessEnv = process.env,
86+
cwd?: string,
8687
): Effect.fn.Return<
8788
ReadonlyArray<ServerProviderSkill>,
8889
never,
@@ -96,6 +97,7 @@ export const discoverGrokSkills = Effect.fn("discoverGrokSkills")(function* (
9697
return yield* spawnAndCollect(
9798
command,
9899
ChildProcess.make(spawnCommand.command, spawnCommand.args, {
100+
...(cwd ? { cwd } : {}),
99101
env: environment,
100102
shell: spawnCommand.shell,
101103
}),

‎apps/server/src/provider/Layers/GrokProvider.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ const runGrokVersionCommand = (
162162
export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(function* (
163163
grokSettings: GrokSettings,
164164
environment: NodeJS.ProcessEnv = process.env,
165+
cwd?: string,
165166
): Effect.fn.Return<
166167
ServerProviderDraft,
167168
never,
@@ -252,7 +253,7 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
252253
});
253254
}
254255

255-
const skills = yield* discoverGrokSkills(grokSettings, environment);
256+
const skills = yield* discoverGrokSkills(grokSettings, environment, cwd);
256257

257258
const discoveryExit = yield* discoverGrokModelsViaAcp(grokSettings, environment).pipe(
258259
Effect.timeoutOption(GROK_ACP_MODEL_DISCOVERY_TIMEOUT_MS),

0 commit comments

Comments
 (0)