Skip to content

Commit 70d232f

Browse files
committed
fix(server): resolve the Antigravity CLI with the shared command resolver
1 parent 29da082 commit 70d232f

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

‎apps/server/src/provider/AntigravityInstallation.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,34 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => {
761761
}),
762762
);
763763

764+
it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32")(
765+
"names the Antigravity CLI when only the CLI is on PATH",
766+
() =>
767+
Effect.gen(function* () {
768+
const fs = yield* FileSystem.FileSystem;
769+
const path = yield* Path.Path;
770+
const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-agy-cli-test-" });
771+
const cliDirectory = path.join(baseDir, "cli");
772+
const emptyDirectory = path.join(baseDir, "empty");
773+
yield* fs.makeDirectory(cliDirectory);
774+
yield* fs.makeDirectory(emptyDirectory);
775+
yield* fs.writeFileString(path.join(cliDirectory, "agy"), "cli", { mode: 0o755 });
776+
const { installation } = yield* makeHarness({ baseDir });
777+
expect(
778+
yield* installation.resolve(undefined, { PATH: emptyDirectory }).pipe(Effect.flip),
779+
).toMatchObject({
780+
detail:
781+
"Antigravity is not installed. Install it in this environment or set a custom executable path.",
782+
});
783+
expect(
784+
yield* installation.resolve(undefined, { PATH: cliDirectory }).pipe(Effect.flip),
785+
).toMatchObject({
786+
detail:
787+
"The Antigravity CLI is installed, but T3 Code runs the separate Antigravity ACP agent. Install it in this environment or set a custom executable path.",
788+
});
789+
}),
790+
);
791+
764792
it.effect("keeps leased releases available while new sessions resolve the new release", () =>
765793
Effect.gen(function* () {
766794
const { installation, fs, stagingReleased } = yield* makeHarness({ previous: true });

‎apps/server/src/provider/AntigravityInstallation.ts‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
HostProcessEnvironment,
77
HostProcessPlatform,
88
} from "@t3tools/shared/hostProcess";
9+
import { isCommandAvailable } from "@t3tools/shared/shell";
910
import * as Clock from "effect/Clock";
1011
import * as Cause from "effect/Cause";
1112
import * as Context from "effect/Context";
@@ -400,16 +401,12 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
400401
.map((directory) => path.resolve(directory, binary));
401402
};
402403

403-
const cliOnPath = Effect.fn("AntigravityInstallation.cliOnPath")(function* (
404-
processEnvironment?: NodeJS.ProcessEnv,
405-
) {
406-
for (const name of platform === "win32" ? ["agy.exe", "agy.cmd"] : ["agy"]) {
407-
for (const candidate of pathCandidates(name, processEnvironment)) {
408-
if (yield* executableFile(candidate)) return true;
409-
}
410-
}
411-
return false;
412-
});
404+
const cliOnPath = (processEnvironment = environment) =>
405+
isCommandAvailable("agy", { env: processEnvironment }).pipe(
406+
Effect.provideService(HostProcessPlatform, platform),
407+
Effect.provideService(FileSystem.FileSystem, fs),
408+
Effect.provideService(Path.Path, path),
409+
);
413410

414411
const resolve: AntigravityInstallationService["resolve"] = Effect.fn(
415412
"AntigravityInstallation.resolve",

0 commit comments

Comments
 (0)