feat(ai-code-review): 支援 Antigravity CLI
This commit is contained in:
+19
-2
@@ -31,13 +31,13 @@ async function installFakeCLI(command = 'codex') {
|
||||
const script = join(tempDir, command);
|
||||
await writeFile(script, `#!/bin/sh
|
||||
if [ -n "$FAKE_AI_ARGS_PATH" ]; then printf '%s\\n' "$*" > "$FAKE_AI_ARGS_PATH"; fi
|
||||
if [ -n "$FAKE_AI_STDIN_PATH" ]; then cat > "$FAKE_AI_STDIN_PATH"; else cat >/dev/null; fi
|
||||
if [ -n "$FAKE_AI_STDIN_PATH" ]; then /bin/cat > "$FAKE_AI_STDIN_PATH"; else /bin/cat >/dev/null; fi
|
||||
if [ -n "$FAKE_AI_STDERR" ]; then printf '%s' "$FAKE_AI_STDERR" >&2; fi
|
||||
if [ -n "$FAKE_AI_STDOUT" ]; then printf '%s' "$FAKE_AI_STDOUT"; fi
|
||||
exit "\${FAKE_AI_EXIT:-0}"
|
||||
`);
|
||||
await chmod(script, 0o755);
|
||||
process.env.PATH = `${tempDir}:${saved.PATH || ''}`;
|
||||
process.env.PATH = tempDir;
|
||||
return { stdinPath: join(tempDir, 'stdin.txt'), argsPath: join(tempDir, 'args.txt') };
|
||||
}
|
||||
|
||||
@@ -73,6 +73,23 @@ describe('chat - assistant CLI', async () => {
|
||||
assert.match(await readFile(argsPath, 'utf8'), /run --model google\/gemini-2.5-pro/);
|
||||
});
|
||||
|
||||
it('runs Antigravity through agy with MODEL and prompt argument', async () => {
|
||||
const { stdinPath, argsPath } = await installFakeCLI('agy');
|
||||
process.env.AI_ASSISTANT_CLI = 'agy';
|
||||
process.env.MODEL = 'gemini-2.5-pro';
|
||||
process.env.FAKE_AI_STDOUT = 'antigravity response';
|
||||
process.env.FAKE_AI_STDIN_PATH = stdinPath;
|
||||
process.env.FAKE_AI_ARGS_PATH = argsPath;
|
||||
|
||||
const result = await chat('sys', 'user');
|
||||
|
||||
assert.equal(result, 'antigravity response');
|
||||
const args = await readFile(argsPath, 'utf8');
|
||||
assert.match(args, /-p .*--model gemini-2.5-pro/s);
|
||||
assert.match(args, /<system>\nsys\n<\/system>/);
|
||||
assert.equal(await readFile(stdinPath, 'utf8'), '');
|
||||
});
|
||||
|
||||
it('throws an error when the CLI fails instead of exiting the process', async () => {
|
||||
await installFakeCLI('codex');
|
||||
process.env.FAKE_AI_EXIT = '2';
|
||||
|
||||
Reference in New Issue
Block a user