2026-08-04 12:59:40 +02:00
|
|
|
/**
|
|
|
|
|
* @fileoverview Resolve the Antigravity CLI (`agy`) binary across common install paths.
|
|
|
|
|
*
|
|
|
|
|
* Mirrors gemini-cli-resolver.ts. Google's installer (antigravity.google/cli/install.sh)
|
|
|
|
|
* places the binary at ~/.local/bin/agy; the other locations cover manual installs.
|
|
|
|
|
*
|
|
|
|
|
* @module utils/antigravity-cli-resolver
|
|
|
|
|
*/
|
|
|
|
|
|
2026-09-02 08:26:45 +08:00
|
|
|
import { getCli } from '../config/cli-registry/registry.js';
|
|
|
|
|
import { expandHome } from './cli-resolver.js';
|
2026-08-20 12:47:42 -04:00
|
|
|
import {
|
|
|
|
|
createCliExecutableResolver,
|
|
|
|
|
formatCliNotFoundMessage,
|
|
|
|
|
type CliResolverHost,
|
|
|
|
|
} from './cli-executable-resolver.js';
|
2026-08-04 12:59:40 +02:00
|
|
|
|
|
|
|
|
/** Common directories where the Antigravity CLI binary may be installed */
|
2026-09-02 08:26:45 +08:00
|
|
|
/**
|
|
|
|
|
* Directories probed after `which`, read from this CLI's registry entry so the spawn
|
|
|
|
|
* path, `codeman doctor` and this resolver cannot disagree about where to look.
|
|
|
|
|
* `~` is expanded by `expandHome`; nothing else is interpreted.
|
|
|
|
|
*/
|
|
|
|
|
const ANTIGRAVITY_SEARCH_DIRS = (): string[] => (getCli('antigravity')?.discovery.searchDirs ?? []).map(expandHome);
|
2026-08-04 12:59:40 +02:00
|
|
|
|
2026-08-20 12:47:42 -04:00
|
|
|
const ANTIGRAVITY_NOT_FOUND =
|
|
|
|
|
'Antigravity CLI not found. Install with: curl -fsSL https://antigravity.google/cli/install.sh | bash';
|
|
|
|
|
|
2026-08-21 02:33:01 +02:00
|
|
|
function createAntigravityResolver(host?: CliResolverHost, now?: () => number) {
|
|
|
|
|
return createCliExecutableResolver({ binary: 'agy', searchDirs: ANTIGRAVITY_SEARCH_DIRS, now }, host);
|
2026-08-20 12:47:42 -04:00
|
|
|
}
|
|
|
|
|
|
2026-08-21 02:33:01 +02:00
|
|
|
/** Creates an isolated Antigravity wrapper around an injected resolver host and clock. */
|
|
|
|
|
export function createAntigravityResolverForTest(host: CliResolverHost, now?: () => number) {
|
|
|
|
|
return createAntigravityResolver(host, now);
|
2026-08-20 12:47:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const antigravityResolver = createAntigravityResolver();
|
2026-08-04 12:59:40 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Finds the directory containing the `agy` binary.
|
|
|
|
|
* Checks `which agy` first, then falls back to common install locations.
|
|
|
|
|
*
|
|
|
|
|
* @returns Directory path, or null if not found
|
|
|
|
|
*/
|
|
|
|
|
export function resolveAntigravityDir(): string | null {
|
2026-08-20 12:47:42 -04:00
|
|
|
return antigravityResolver.resolve()?.directory ?? null;
|
2026-08-04 12:59:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the Antigravity CLI is available on the system.
|
|
|
|
|
*/
|
|
|
|
|
export function isAntigravityAvailable(): boolean {
|
|
|
|
|
return resolveAntigravityDir() !== null;
|
|
|
|
|
}
|
2026-08-20 12:47:42 -04:00
|
|
|
|
|
|
|
|
export function getAntigravityNotFoundMessage(): string {
|
|
|
|
|
return formatCliNotFoundMessage(ANTIGRAVITY_NOT_FOUND, antigravityResolver.diagnostics());
|
|
|
|
|
}
|