fix(link): add pi and cursor to agent auto-detection#3309
fix(link): add pi and cursor to agent auto-detection#3309
Conversation
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: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Adds pi and cursor to spawn link auto-detection so users no longer need to pass --agent pi/cursor manually on remote servers.
CI: All 6 checks pass (Biome, ShellCheck, Unit Tests, Mock Tests, macOS Compatibility, membership).
Code quality:
The implementation is correct and the manifest confirms both binary names:
pi: manifestlaunch="pi"→command -v piis the right check; added to ps grep sincepiisn't ambiguous.cursor: manifestlaunch="agent"→AGENT_BINARYcorrectly mapscursor → "agent"; intentionally excluded from ps grep sinceagentis too generic (comment explains this clearly atlink.ts:92–93).
The agentBinary() helper at link.ts:85–87 is a clean, zero-footprint abstraction — the Partial<Record<KnownAgent, string>> type ensures exhaustive safety at the call site.
No injection risk: agentBinary(agent) is bounded by the KNOWN_AGENTS const tuple.
One observation (non-blocking): command -v agent (run when checking cursor) could match any host binary named agent unrelated to Cursor. In practice the risk is low — cursor is checked last in KNOWN_AGENTS order, so any earlier-installed agent wins first. Worth keeping in mind if false positives surface in the wild; a follow-up heuristic (e.g. checking ~/.cursor existence) could disambiguate.
Missing tests (non-blocking): agentBinary() and the cursor/pi detection paths have no dedicated unit tests. The existing SSH_DETECT_AGENT_VIA_WHICH fixture in cmd-link-cov.test.ts:44 only covers the command -v claude path. Worth adding command -v agent → cursor and command -v pi → pi branches in a follow-up.
✅ LGTM — fix is correct, well-scoped, and ready to ship.
Why:
spawn linkcannot auto-detect Pi or Cursor CLI agents on remote servers — users must manually specify--agent pior--agent cursor. This is becauseKNOWN_AGENTSinlink.tswas never updated when these agents were added.Changes
"pi"and"cursor"toKNOWN_AGENTSarrayAGENT_BINARYmapping for cursor (agentbinary) socommand -vchecks the correct binary nameps auxgrep pattern to includepi(cursor'sagentbinary is intentionally excluded from ps grep — too generic)-- refactor/code-health