fix(link): add pi and cursor to agent auto-detection (#3309)
Some checks are pending
CLI Release / Build and release CLI (push) Waiting to run
Lint / ShellCheck (push) Waiting to run
Lint / Biome Lint (push) Waiting to run
Lint / macOS Compatibility (push) Waiting to run

KNOWN_AGENTS was missing pi and cursor, so `spawn link` could not
auto-detect these agents on remote servers. Also adds a binary-name
mapping for cursor (whose CLI binary is `agent`).

Bump CLI to 1.0.14.

Agent: code-health

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-04-15 17:44:20 -07:00 committed by GitHub
parent a179fdbbab
commit 84331173fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "1.0.13",
"version": "1.0.14",
"type": "module",
"bin": {
"spawn": "cli.js"

View file

@ -71,14 +71,28 @@ const KNOWN_AGENTS = [
"kilocode",
"hermes",
"junie",
"pi",
"cursor",
] as const;
type KnownAgent = (typeof KNOWN_AGENTS)[number];
/** Map manifest agent key → CLI binary name (only where they differ). */
const AGENT_BINARY: Partial<Record<KnownAgent, string>> = {
cursor: "agent",
};
/** Get the CLI binary name for an agent (defaults to the agent key itself). */
function agentBinary(agent: KnownAgent): string {
return AGENT_BINARY[agent] ?? agent;
}
/** Auto-detect which agent is installed/running on the remote host. */
function detectAgent(host: string, user: string, keyOpts: string[], runCmd: SshCommandFn): string | null {
// First: check running processes
// Note: cursor's binary is "agent" which is too generic for ps grep, so it's
// detected only via the installed-binary check below.
const psCmd =
"ps aux 2>/dev/null | grep -oE 'claude(-code)?|openclaw|codex|opencode|kilocode|hermes|junie' | grep -v grep | head -1 || true";
"ps aux 2>/dev/null | grep -oE 'claude(-code)?|openclaw|codex|opencode|kilocode|hermes|junie|pi' | grep -v grep | head -1 || true";
const psOut = runCmd(host, user, keyOpts, psCmd);
if (psOut) {
const match = KNOWN_AGENTS.find((b: KnownAgent) => psOut.includes(b));
@ -89,7 +103,7 @@ function detectAgent(host: string, user: string, keyOpts: string[], runCmd: SshC
// Second: check installed binaries — one SSH call per agent to avoid shell injection
for (const agent of KNOWN_AGENTS) {
const whichOut = runCmd(host, user, keyOpts, `command -v ${agent}`);
const whichOut = runCmd(host, user, keyOpts, `command -v ${agentBinary(agent)}`);
if (whichOut) {
return agent;
}