Skip to content

llm: strengthen tool detection with binary presence check #5070

Closed

Description

@yrobla

Background

DetectedLLMGatewayClients() in pkg/client/llm_gateway.go currently detects an installed AI tool by checking whether the tool's settings directory exists on disk. This was flagged in PR #5065 review (JAORMX) as false-positive prone:

`/.claude` and `/.gemini` hang around from prior installs or unrelated tooling. Combine with `exec.LookPath("claude")` / `exec.LookPath("gemini")`.

Problem

A settings directory like ~/.claude or ~/.gemini can exist even when the tool is no longer installed (leftover from a prior install, created by unrelated tooling, or seeded by thv client register). In that case thv llm setup will attempt to patch settings.json for a tool the user doesn't actually have, producing a confusing no-op or stale config file.

Proposed fix

Extend clientAppConfig with an optional BinaryName string field. DetectedLLMGatewayClients() should require both conditions:

  1. Settings directory exists (os.Stat of filepath.Dir(settingsPath) succeeds) — current check.
  2. Binary is on $PATH (exec.LookPath(cfg.BinaryName) succeeds) — new check, skipped when BinaryName is empty.

Populate BinaryName for tools where a canonical binary name is well-known:

Client BinaryName
claude-code claude
gemini-cli gemini
cursor cursor
vscode code
xcode (skip — macOS app, not on PATH)

Note: IsClientInstalled() (MCP detection) has the same limitation. Fixing DetectedLLMGatewayClients first is the right scope for this issue; a follow-up can extend IsClientInstalled consistently.

References

Activity

  1. added
    enhancement
    on Apr 27, 2026
  2. added
    go
    on Apr 27, 2026
  3. added 4 commits that reference this issue on Apr 28, 2026
    00204d3
    590a899
    28f421d
    60c99c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgo

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions