fix(#213): support antigravity 2.x config directory split (#217)

* fix(#213): support antigravity 2.x config directory split

* fix(#213): harden antigravity tests for windows parity
This commit is contained in:
Tom Boucher
2026-05-24 14:17:03 -04:00
committed by GitHub
parent aaba233f83
commit 5b3646d6c8
11 changed files with 257 additions and 38 deletions

View File

@@ -308,10 +308,18 @@ const RUNTIME_ENV_VARS = [
describe('getRuntimeConfigDir', () => {
const saved: Record<string, string | undefined> = {};
let savedHome: string | undefined;
let savedUserProfile: string | undefined;
beforeEach(() => {
savedHome = process.env.HOME;
savedUserProfile = process.env.USERPROFILE;
for (const k of RUNTIME_ENV_VARS) { saved[k] = process.env[k]; delete process.env[k]; }
});
afterEach(() => {
if (savedHome === undefined) delete process.env.HOME;
else process.env.HOME = savedHome;
if (savedUserProfile === undefined) delete process.env.USERPROFILE;
else process.env.USERPROFILE = savedUserProfile;
for (const k of RUNTIME_ENV_VARS) {
if (saved[k] === undefined) delete process.env[k];
else process.env[k] = saved[k];
@@ -380,6 +388,15 @@ describe('getRuntimeConfigDir', () => {
process.env.XDG_CONFIG_HOME = '/xdg';
expect(getRuntimeConfigDir('kilo')).toBe(join('/xdg', 'kilo'));
});
it('antigravity detects 2.x IDE dir when present and legacy dir is absent', async () => {
const home = await mkdtemp(join(tmpdir(), 'gsd-antigravity-sdk-'));
await mkdir(join(home, '.gemini', 'antigravity-ide'), { recursive: true });
process.env.HOME = home;
process.env.USERPROFILE = home;
expect(getRuntimeConfigDir('antigravity')).toBe(join(home, '.gemini', 'antigravity-ide'));
await rm(home, { recursive: true, force: true });
});
});
describe('detectRuntime', () => {

View File

@@ -35,6 +35,24 @@ function expandTilde(p: string): string {
return p.startsWith('~/') || p === '~' ? join(homedir(), p.slice(1)) : p;
}
function resolveAntigravityConfigDir(): string {
if (process.env.ANTIGRAVITY_CONFIG_DIR) {
return expandTilde(process.env.ANTIGRAVITY_CONFIG_DIR);
}
const home = homedir();
const base = join(home, '.gemini');
const candidates = [
join(base, 'antigravity'),
join(base, 'antigravity-ide'),
join(base, 'antigravity-cli'),
];
for (const candidate of candidates) {
if (existsSync(candidate)) return candidate;
}
return join(base, 'antigravity');
}
/**
* Resolve the per-runtime config directory, mirroring
* `bin/install.js:getGlobalDir()`. Agents live at `<configDir>/agents`.
@@ -62,7 +80,7 @@ export function getRuntimeConfigDir(runtime: Runtime): string {
case 'copilot':
return process.env.COPILOT_CONFIG_DIR ? expandTilde(process.env.COPILOT_CONFIG_DIR) : join(homedir(), '.copilot');
case 'antigravity':
return process.env.ANTIGRAVITY_CONFIG_DIR ? expandTilde(process.env.ANTIGRAVITY_CONFIG_DIR) : join(homedir(), '.gemini', 'antigravity');
return resolveAntigravityConfigDir();
case 'cursor':
return process.env.CURSOR_CONFIG_DIR ? expandTilde(process.env.CURSOR_CONFIG_DIR) : join(homedir(), '.cursor');
case 'windsurf':