Skip to content

OpenCode native plugin for auto-discovery of installed harnesses #17

Description

@johnnyhuy

Why

src/main/installer/index.ts discovers harnesses via which() then falls back to the npm-global root. On macOS when the user installed via Homebrew the claude binary lives in /opt/homebrew/bin — already on PATH for most users but not in npm-global. On Linux with NVM-flipping users, the resolution gets fragile.

OpenCode reads ~/.config/opencode/opencode.json for everything: providers, plugins, MCP servers. It supports installing community plugins via the plugin[] array. A small OpenCode plugin installed via opencode plugin install @hoist/discover could run at OpenCode's startup and:

  1. Read /usr/bin/env + ~/.bashrc/~/.zshrc paths to discover installed harness binaries
  2. Compare against the hoist catalog (src/main/providers/harnesses.ts shape)
  3. Report back to hoist via a local Unix socket or ~/.cache/hoist/discovery.json

This is an OpenCode-side affordance, not hoist-side — but it's the cleanest way to feed accurate detection back into the GUI's "Installed · v2.1.204" cards.

Scope

  • New repo under packages/opencode-plugin-hoist/ (or just in src/opencode-plugin/ until we publish).
  • Small plugin with no deps: spawns which for each catalog binary, writes ~/.cache/hoist/discovery.json with { path, version } per tool.
  • installer/discoverInstalled() reads that file first (if newer than 5 minutes), then falls back to the current which + npm-global probe.
  • Renderer keeps showing the discovered status without a UI change.
  • CLI hoist install/hoist list picks it up via the same shared discoverInstalled.

Acceptance criteria

  • Installing the OpenCode plugin populates ~/.cache/hoist/discovery.json within 200 ms of OpenCode startup.
  • If plugin isn't installed, behavior is identical to today (which + npm-global).
  • discoverInstalled reads the cache file when present and fresh, otherwise falls back.
  • Plugin is small (< 200 lines of TS, no runtime deps).
  • Documented install path: opencode plugin install @hoist/discover (or equivalent local-path install during dev).

Non-goals

  • Real-time signalling (file mtime is fine for v1)
  • Auto-install from the plugin (that's hoist's job — keep the boundary clean)
  • Cross-platform notification (linux/macOS only for v1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions