Skip to content

fix(cli): detect machine-level agent tools, not just project-local (BUG-1156)#783

Merged
xarmian merged 1 commit into
mainfrom
fix/bug-1156-machine-level-agent-detection
Jul 3, 2026
Merged

fix(cli): detect machine-level agent tools, not just project-local (BUG-1156)#783
xarmian merged 1 commit into
mainfrom
fix/bug-1156-machine-level-agent-detection

Conversation

@xarmian

@xarmian xarmian commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

pad init on a machine with codex installed only ever set up the Claude skill: cli.DetectTools() looked exclusively at project-local directories (.codex, .cursor, …), which don't exist in a fresh project even when the tool is installed machine-wide (~/.codex, codex on PATH). Fixes BUG-1156.

DetectTools() now ORs three signals per tool:

  • project-local directory (existing behavior, unchanged)
  • home-relative directory — new AgentTool.DetectHomeDirs
  • binary on PATH via exec.LookPath — new AgentTool.DetectBinaries

Machine-level signals are populated conservatively: only claude (~/.claude, claude) and agents (~/.codex/.cursor/.windsurf/.agents; codex/cursor/windsurf). Copilot, Amazon Q, and Junie keep project-local-only detection — gh/q binaries are too ambiguous as install signals.

Plus

  • Install destinations are untouched — skills still land project-locally; only detection widened.
  • DetectTools() no longer returns nil on os.Getwd() failure; it degrades to home/PATH signals.
  • All six call sites audited (ensureSkills, offerSkillInstall, pad agent install/--all/list): each only widens which tools get project-local installs, which is the intended fix. pad agent update gates on existing project-local files and is unaffected.

Observable behavior changes

  • pad init / pad workspace init on a machine with codex (or cursor/windsurf) installed now also writes .agents/skills/pad/SKILL.md.
  • pad agent install --list marks machine-installed tools as (detected).

Test plan

  • go test ./... full suite green (includes 7 new TestDetectTools subtests: home-dir hit, PATH-binary hit, no-signal miss, project-local regression, dedup)
  • Tests isolated from host machine state via t.Setenv(HOME/PATH) + t.Chdir temp dirs (this dev box has ~/.codex — naive tests would false-pass)
  • golangci-lint run clean on touched packages (repo-wide make lint fails on pre-existing internal/models/workspace.go gofmt drift, identical on unmodified main)
  • Manual repro: fake $HOME containing only .codex, empty project dir → pad agent install --list shows Codex/Cursor/Windsurf (detected)
  • 2 codex review rounds (plain + adversarial framing), both CLEAN

Refs: BUG-1156

https://claude.ai/code/session_01CL1pBjNpPUX6SWkuAuYXHS

…UG-1156)

DetectTools() only checked project-local dirs (.codex, .claude, etc.), so a
machine with Codex installed but no project-local dirs was invisible to
`pad init` — only the force-included Claude skill got installed. Widen
detection to OR three signals per tool: project-local dir (existing), a
home-relative dir, and a binary on PATH. Machine-level signals are only
populated for claude and agents (codex/cursor/windsurf); copilot/amazon-q/
junie keep project-local-only detection since their binaries/dirs are too
ambiguous to trust as machine-wide signals.
@xarmian

xarmian commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

CI note: the Go job failure is the pre-existing gofmt drift on internal/models/workspace.go:6 — red on main since at least Jul 1 (#780#782 all failed identically). Nothing in this PR touches that file; Web, E2E, and Go (PostgreSQL) are green. Merging over it per recent repo practice; follow-up PR to restore the Go job incoming.

@xarmian
xarmian merged commit e32bf92 into main Jul 3, 2026
3 of 4 checks passed
@xarmian
xarmian deleted the fix/bug-1156-machine-level-agent-detection branch July 3, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant