clawdie-ai/setup/agent-cli-check.ts
Sam & Pi e1d4fd4441
Some checks failed
CI / ci (pull_request) Has been cancelled
chore(freebsd): align host baseline with Python 3.12 (Sam & Pi)
---
Build: FAIL | Tests: FAIL
2026-06-17 14:57:19 +02:00

55 lines
1.6 KiB
TypeScript

/**
* setup/agent-cli-check.ts — Detect agent CLIs available on PATH.
*
* Clawdie's controlplane harness uses Aider+Pi as the primary driver.
* At least one agent CLI must be resolvable on PATH for onboarding to
* succeed. This mirrors the standard per-adapter command-resolvable
* pattern, but as a single fail-fast check at the top of `setup onboard`.
*
* No "hello probe" yet — `command -v` is enough.
*/
import { commandExists } from './platform.js';
export interface AgentCli {
name: string;
command: string;
present: boolean;
}
export const AGENT_CLIS: ReadonlyArray<{ name: string; command: string }> = [
{ name: 'pi', command: 'pi' },
{ name: 'aider', command: 'aider' },
{ name: 'claude', command: 'claude' },
{ name: 'codex', command: 'codex' },
{ name: 'gemini', command: 'gemini' },
];
export function detectAgentClis(): AgentCli[] {
return AGENT_CLIS.map(({ name, command }) => ({
name,
command,
present: commandExists(command),
}));
}
export class NoAgentCliError extends Error {
constructor() {
super(
[
'No agent CLI found on PATH.',
'Clawdie needs pi and aider for the Aider+Pi controlplane harness.',
'Install via the ISO bundle or: npm install -g @earendil-works/pi-coding-agent; install Aider in a Python 3.12 venv if needed.',
'Alternative CLIs (claude, codex, gemini) are also accepted.',
].join(' '),
);
this.name = 'NoAgentCliError';
}
}
export function requireAtLeastOneAgentCli(): AgentCli[] {
const clis = detectAgentClis();
if (!clis.some((c) => c.present)) {
throw new NoAgentCliError();
}
return clis;
}