Files
Codeman/test/antigravity-mode.test.ts
T
Codeman maintainer 5559aa8294 fix(remote): start csh and tcsh login shells without -i -l
A remote host whose login shell is tcsh came up on 1.48.0, when the local
sh rewrote ${SHELL:-/bin/sh} to the Codeman host's shell. Since #770 the
launch reaches the far end verbatim and runs tcsh itself, and tcsh refuses
-i -l -c, -l -c and -i -l, so every stock launch left a dead pane.

The login flags are now picked on the far end, in the shape of
loginShellArgs(): set -- -i -l, cleared for csh and tcsh, then
exec "${SHELL:-/bin/sh}" "$@". The text is one brace group, so
cd <path> && { ...; } still starts nothing when the cd fails. bsd-csh takes
every flag combination, csh is listed because it is tcsh on macOS and the BSDs.

The version probe keeps its one statement: the login shell parses it, not
/bin/sh, so fish and tcsh refuse it either way, as they did on 1.48.0.

Measured with the real builder on a real sshd in a throwaway Debian container
(tcsh 6.24.07, bsd-csh, fish 3.6, bash) and through a fake sshd with
tcsh 6.24.10, fish, zsh, dash and bash, a real Codeman server on tcsh included.
The tcsh disclosure comes out of the docs and the changeset. They keep the two
limits 1.48.0 had too: tcsh has no export, so the PATH bootstrap only prints an
error, and the tmux probe needs a command executable, which Debian lacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 06:05:53 +01:00

128 lines
4.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { CreateSessionSchema, QuickStartSchema } from '../src/web/schemas.js';
import { buildSpawnCommand } from '../src/tmux-manager.js';
import { defaultDockerCommandForMode } from '../src/docker-hosts.js';
import { defaultRemoteCommandForMode } from '../src/remote-hosts.js';
import { isExternalCliMode, isAltScreenStripMode } from '../src/session.js';
describe('Antigravity mode schemas', () => {
it('accepts Antigravity session creation config', () => {
const parsed = CreateSessionSchema.parse({
workingDir: '/tmp',
mode: 'antigravity',
antigravityConfig: {
model: 'gemini-3-pro',
dangerouslySkipPermissions: true,
},
});
expect(parsed.mode).toBe('antigravity');
expect(parsed.antigravityConfig).toEqual({
model: 'gemini-3-pro',
dangerouslySkipPermissions: true,
});
});
it('accepts Antigravity quick-start config', () => {
const parsed = QuickStartSchema.parse({
caseName: 'antigravity-case',
mode: 'antigravity',
antigravityConfig: {
resumeConversationId: 'conv-1234abcd',
},
});
expect(parsed.mode).toBe('antigravity');
expect(parsed.antigravityConfig?.resumeConversationId).toBe('conv-1234abcd');
});
it('rejects unsafe Antigravity model strings', () => {
expect(() =>
CreateSessionSchema.parse({
workingDir: '/tmp',
mode: 'antigravity',
antigravityConfig: { model: 'agy; rm -rf /' },
})
).toThrow();
});
it('allows ANTIGRAVITY_* env overrides and still rejects unknown prefixes', () => {
const parsed = CreateSessionSchema.parse({
workingDir: '/tmp',
mode: 'antigravity',
envOverrides: { ANTIGRAVITY_LOG_LEVEL: 'debug' },
});
expect(parsed.envOverrides).toEqual({ ANTIGRAVITY_LOG_LEVEL: 'debug' });
expect(() =>
CreateSessionSchema.parse({
workingDir: '/tmp',
envOverrides: { RANDOM_PREFIX_KEY: 'x' },
})
).toThrow();
});
});
describe('Antigravity spawn command', () => {
it('builds a bare agy command when no config is sent (safe default, no bypass)', () => {
const cmd = buildSpawnCommand({ mode: 'antigravity', sessionId: 'abc12345' });
expect(cmd).toBe('agy');
});
it('adds --dangerously-skip-permissions only when explicitly requested', () => {
const cmd = buildSpawnCommand({
mode: 'antigravity',
sessionId: 'abc12345',
antigravityConfig: { dangerouslySkipPermissions: true, model: 'gemini-3-pro' },
});
expect(cmd).toBe('agy --dangerously-skip-permissions --model gemini-3-pro');
});
it('passes --conversation for resume and drops unsafe ids', () => {
expect(
buildSpawnCommand({
mode: 'antigravity',
sessionId: 'abc12345',
antigravityConfig: { resumeConversationId: 'conv-99' },
})
).toBe('agy --conversation conv-99');
expect(
buildSpawnCommand({
mode: 'antigravity',
sessionId: 'abc12345',
antigravityConfig: { resumeConversationId: 'x; rm -rf /' },
})
).toBe('agy');
});
it('drops unsafe model strings from the spawn command', () => {
expect(
buildSpawnCommand({
mode: 'antigravity',
sessionId: 'abc12345',
antigravityConfig: { model: 'a`b' },
})
).toBe('agy');
});
});
describe('Antigravity mode gates', () => {
it('is an external CLI mode (readiness/ralph/respawn gating)', () => {
expect(isExternalCliMode('antigravity')).toBe(true);
});
it('is NOT an alt-screen strip mode (unverified Go TUI, like opencode)', () => {
expect(isAltScreenStripMode('antigravity')).toBe(false);
});
it('has docker/remote default commands', () => {
expect(defaultDockerCommandForMode('antigravity')).toBe('exec agy');
// Routed through an interactive login shell so per-user PATH entries resolve —
// same fix as the other remote agent CLIs (see defaultRemoteCommandForMode).
expect(defaultRemoteCommandForMode('antigravity')).toBe(
'{ set -- -i -l; case ${SHELL##*/} in csh|tcsh) set --;; esac; exec "${SHELL:-/bin/sh}" "$@" -c \'agy\'; }'
);
});
});