The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 07:15 UTC
feat(cli): allow Antigravity in terminal triage (#31761)
Shlok Sheth committed
Nov 18, 2026 at 22:59 UTC
21098689802ad81b7b5e034e892ff5894054761d
3 files changed
+153
-12
apps/server/src/cli/triage.test.ts
+121
-4
@@ -1,22 +1,139 @@
1
-// @effect-diagnostics nodeBuiltinImport:off - CLI integration spawns a fake agent from PATH.
1
+// @effect-diagnostics nodeBuiltinImport:off -- Exercise the CLI with isolated executable fixtures.
2
+import * as NodeChildProcess from "node:child_process";
3
import * as NodeFS from "node:fs";
4
+import * as NodeFSP from "node:fs/promises";
5
+import * as NodeOS from "node:os";
6
import * as NodePath from "node:path";
7
+import * as NodeURL from "node:url";
8
9
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
10
import * as NodeServices from "@effect/platform-node/NodeServices";
11
+import { assert, it } from "@effect/vitest";
12
import { TRIAGE_PROMPT_FILE_NAME } from "@t3tools/contracts";
13
+import * as HostProcess from "@t3tools/shared/HostProcess";
14
import * as NetService from "@t3tools/shared/Net";
9
-import { assert, it } from "@effect/vitest";
15
import * as Effect from "effect/Effect";
16
import * as FileSystem from "effect/FileSystem";
17
import * as Layer from "effect/Layer";
13
-import * as TestConsole from "effect/testing/TestConsole";
18
import { Command } from "effect/cli";
15
-import { vi } from "vite-plus/test";
19
+import * as TestConsole from "effect/testing/TestConsole";
20
+import { expect, vi } from "vite-plus/test";
21
22
import { cli } from "../binCli.ts";
23
import { buildTriageLaunchPrompt } from "../triage/triagePrompt.ts";
24
25
+const cliPath = NodeURL.fileURLToPath(new URL("../bin.ts", import.meta.url));
26
+
27
+async function fixture(commands: ReadonlyArray<string>) {
28
+ const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-triage-"));
29
+ const bin = NodePath.join(root, "bin");
30
+ const record = NodePath.join(root, "launch.json");
31
+ await NodeFSP.mkdir(bin);
32
+ const script = NodePath.join(root, "agent.cjs");
33
+ await NodeFSP.writeFile(
34
+ script,
35
+ `require("node:fs").writeFileSync(process.env.TRIAGE_TEST_RECORD, JSON.stringify({ command: process.argv[2], args: process.argv.slice(3), cwd: process.cwd() }));`,
36
+ );
37
+ for (const command of commands) {
38
+ const windows = HostProcess.Platform.defaultValue() === "win32";
39
+ const executable = NodePath.join(bin, windows ? `${command}.cmd` : command);
40
+ const quote = (value: string) => `'${value.replaceAll("'", "'\\''")}'`;
41
+ await NodeFSP.writeFile(
42
+ executable,
43
+ windows
44
+ ? `@"${process.execPath}" "${script}" ${command} %*\r\n`
45
+ : `#!/bin/sh\nexec ${quote(process.execPath)} ${quote(script)} ${quote(command)} "$@"\n`,
46
+ { mode: 0o755 },
47
+ );
48
+ }
49
+ return {
50
+ root,
51
+ record,
52
+ run: (args: ReadonlyArray<string>) =>
53
+ new Promise<{ code: number | null; stdout: string; stderr: string }>((resolve, reject) => {
54
+ const child = NodeChildProcess.spawn(
55
+ process.execPath,
56
+ [cliPath, "triage", "--base-dir", NodePath.join(root, "home with spaces"), ...args],
57
+ {
58
+ env: {
59
+ ...process.env,
60
+ PATH: bin,
61
+ TRIAGE_TEST_RECORD: record,
62
+ },
63
+ stdio: ["ignore", "pipe", "pipe"],
64
+ },
65
+ );
66
+ let stdout = "";
67
+ let stderr = "";
68
+ child.stdout.on("data", (data) => (stdout += String(data)));
69
+ child.stderr.on("data", (data) => (stderr += String(data)));
70
+ child.once("error", reject);
71
+ child.once("close", (code) => resolve({ code, stdout, stderr }));
72
+ }),
73
+ async [Symbol.asyncDispose]() {
74
+ await NodeFSP.rm(root, { recursive: true, force: true });
75
+ },
76
+ };
77
+}
78
+
79
+it.live.each([
80
+ { commands: ["agy", "codex"], agent: "antigravity", command: "agy", model: "test-model" },
81
+ { commands: ["agy"], agent: undefined, command: "agy", model: undefined },
82
+ { commands: ["agy", "codex"], agent: "codex", command: "codex", model: "test-model" },
83
+ { commands: ["agy", "codex", "claude"], agent: "claude", command: "claude", model: undefined },
84
+])(
85
+ "launches $command with the triage prompt (agent=$agent, model=$model)",
86
+ ({ commands, agent, command, model }) =>
87
+ Effect.promise(async () => {
88
+ await using setup = await fixture(commands);
89
+ const result = await setup.run([
90
+ ...(agent === undefined ? [] : ["--agent", agent]),
91
+ ...(model === undefined ? [] : ["--model", model]),
92
+ ]);
93
+ expect(result.code, result.stdout + result.stderr).toBe(0);
94
+ const launch = JSON.parse(await NodeFSP.readFile(setup.record, "utf8")) as {
95
+ command: string;
96
+ args: string[];
97
+ cwd: string;
98
+ };
99
+ expect(launch.command).toBe(command);
100
+ expect(launch.args.slice(0, -1)).toEqual([
101
+ ...(model === undefined ? [] : ["--model", model]),
102
+ ...(command === "agy" ? ["--prompt-interactive"] : []),
103
+ ]);
104
+ expect(launch.args.at(-1)).toContain(NodePath.join(launch.cwd, "triage-playbook.md"));
105
+ expect(
106
+ await NodeFSP.readFile(NodePath.join(launch.cwd, "triage-playbook.md"), "utf8"),
107
+ ).toContain("context.md");
108
+ }),
109
+);
110
+
111
+it.live(
112
+ "requires an explicit choice when Codex and Antigravity are installed without a terminal",
113
+ () =>
114
+ Effect.promise(async () => {
115
+ await using setup = await fixture(["agy", "codex"]);
116
+ const result = await setup.run([]);
117
+ expect(result.code).toBe(1);
118
+ expect(result.stdout + result.stderr).toContain("--agent antigravity");
119
+ expect(result.stdout + result.stderr).toContain("--agent codex");
120
+ expect(result.stdout + result.stderr).not.toContain("Starting");
121
+ await expect(NodeFSP.stat(setup.record)).rejects.toMatchObject({ code: "ENOENT" });
122
+ }),
123
+);
124
+
125
+it.live("reports the missing agy executable when Antigravity is explicitly requested", () =>
126
+ Effect.promise(async () => {
127
+ await using setup = await fixture(["codex"]);
128
+ const result = await setup.run(["--agent", "antigravity"]);
129
+ expect(result.code).toBe(1);
130
+ expect(result.stdout + result.stderr).toContain(
131
+ "`agy` is not installed or was not found on PATH.",
132
+ );
133
+ await expect(NodeFSP.stat(setup.record)).rejects.toMatchObject({ code: "ENOENT" });
134
+ }),
135
+);
136
+
137
const FAILING_AGENT_POSIX = `#!/bin/sh
138
echo "Error: There is not enough space on the disk. (os error 112)" >&2
139
exit 1
apps/server/src/cli/triage.ts
+19
-7
@@ -22,11 +22,12 @@ import { interactiveStdin } from "./consoleStdin.ts";
22
import { resolveCliCommand } from "./invocation.ts";
23
24
interface TriageAgent {
25
- readonly id: "claude" | "codex";
25
+ readonly id: "claude" | "codex" | "antigravity";
26
readonly command: string;
27
readonly label: string;
28
readonly stateDirEnv: string;
29
readonly defaultStateDir: string;
30
+ readonly promptArgs?: ReadonlyArray<string>;
31
}
32
33
const TRIAGE_AGENTS: ReadonlyArray<TriageAgent> = [
@@ -44,6 +45,14 @@ const TRIAGE_AGENTS: ReadonlyArray<TriageAgent> = [
45
stateDirEnv: "CODEX_HOME",
46
defaultStateDir: ".codex",
47
},
48
+ {
49
+ id: "antigravity",
50
+ command: "agy",
51
+ label: "Antigravity",
52
+ stateDirEnv: "GEMINI_HOME",
53
+ defaultStateDir: ".gemini",
54
+ promptArgs: ["--prompt-interactive"],
55
+ },
56
];
57
58
const resolveAgentStateDir = (agent: TriageAgent) =>
@@ -63,7 +72,7 @@ export class TriageAgentChoiceRequiredError extends Schema.TaggedError<TriageAge
72
{},
73
) {
74
override get message(): string {
66
- return "Both claude and codex are installed and there is no terminal to ask which to use. Re-run with --agent claude or --agent codex.";
75
+ return "Multiple supported agent CLIs are installed and there is no terminal to ask which to use. Re-run with --agent claude, --agent codex, or --agent antigravity.";
76
}
77
}
78
@@ -130,8 +139,8 @@ const describeTriageFiles = (session: {
139
` ${session.contextFilePath}`,
140
];
141
133
-const agentFlag = Flag.Literals("agent", ["claude", "codex"]).pipe(
134
- Flag.withDescription("Agent CLI to use. Default: ask when both are installed."),
142
+const agentFlag = Flag.Literals("agent", ["claude", "codex", "antigravity"]).pipe(
143
+ Flag.withDescription("Agent CLI to use. Default: ask when multiple are installed."),
144
Flag.optional,
145
);
146
@@ -146,7 +155,7 @@ export const triageCommand = Command.make("triage", {
155
model: modelFlag,
156
}).pipe(
157
Command.withDescription(
149
- "Investigate a T3 Code problem on this machine with claude or codex, and help file a good issue.",
158
+ "Investigate a T3 Code problem on this machine with Claude Code, Codex, or Antigravity, and help file a good issue.",
159
),
160
Command.withHandler((flags) =>
161
Effect.gen(function* () {
@@ -179,7 +188,9 @@ export const triageCommand = Command.make("triage", {
188
if (requested !== undefined) {
189
selected = installed.find((agent) => agent.id === requested);
190
if (selected === undefined) {
182
- return yield* new TriageAgentUnavailableError({ agent: requested });
191
+ return yield* new TriageAgentUnavailableError({
192
+ agent: TRIAGE_AGENTS.find((agent) => agent.id === requested)?.command ?? requested,
193
+ });
194
}
195
} else if (installed.length === 1) {
196
selected = installed[0];
@@ -197,7 +208,7 @@ export const triageCommand = Command.make("triage", {
208
if (selected === undefined) {
209
yield* Console.log(
210
[
200
- "No supported agent CLI (claude, codex) was found on this machine.",
211
+ "No supported agent CLI (claude, codex, agy) was found on this machine.",
212
"",
213
...describeTriageFiles(session),
214
"",
@@ -211,6 +222,7 @@ export const triageCommand = Command.make("triage", {
222
const launchPrompt = buildTriageLaunchPrompt(promptFilePath);
223
const spawnSpec = yield* resolveSpawnCommand(selected.command, [
224
...(model === undefined ? [] : ["--model", model]),
225
+ ...(selected.promptArgs ?? []),
226
launchPrompt,
227
]);
228
yield* Console.log(`Starting ${selected.label}. It will ask what went wrong.\n`);
docs/user/triage.md
+13
-1
@@ -27,4 +27,16 @@ If the app does not start, or triage does not work in the app, run:
27
npx t3 triage
28
```
29
30
-It starts Claude Code or Codex in your terminal with the same instructions.
30
+It starts Claude Code, Codex, or Antigravity in your terminal with the same
31
+instructions. If more than one is installed, it asks which to use. You can also
32
+choose explicitly:
33
+
34
+```sh
35
+npx t3 triage --agent antigravity
36
+npx t3 triage --agent codex
37
+```
38
+
39
+Antigravity needs Google's standalone `agy` CLI on your `PATH` and its own sign-in.
40
+The ACP runtime installed through T3 Code does not include this terminal CLI.
41
+Install it using [Google's CLI setup guide](https://antigravity.google/docs/cli-getting-started).
42
+Pass `--model <model-id>` to choose a model, or leave it out to use the CLI's default.