Skip to content

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

Open

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)

Activity

  1. johnnyhuy commented on Nov 9, 2026

    @johnnyhuy
    ContributorAuthor

    agent claim: agent/issue-17-opencode-discovery @ b01234d. Scope this run: app side only - OpenCode discovery plugin under src/opencode-plugin/ plus cache-aware discoverInstalled in src/main/installer/. CLI parity stays a separate PR (independent release flow).

  2. johnnyhuy commented on Nov 9, 2026

    @johnnyhuy
    ContributorAuthor

    App-side slice up in #53 (plugin + cache-aware discoverInstalled, ci:app green, mocked-layout proof on the PR). CLI parity in cli/src/lib/harnesses.ts remains for a separate CLI PR, so this issue stays open.

  3. johnnyhuy commented on Nov 9, 2026

    @johnnyhuy
    ContributorAuthor

    App-side slice merged in #53 (merge commit 141783e on main) after a rebase over #48, #50 and #52. What remains on this issue is CLI parity only - cli/src/lib/harnesses.ts reading the same ~/.cache/hoist/discovery.json before its probe, as a separate CLI PR under the independent CLI release flow. The agent label stays on, but there is no open agent branch behind it now, so the next run can claim the CLI slice fresh.

  4. johnnyhuy commented on Nov 10, 2026

    @johnnyhuy
    ContributorAuthor

    agent claim: ao/hoist-development/agent-issue-17-cli-discovery @ 141783e. Remaining CLI-only slice: read the existing OpenCode discovery cache before PATH/npm probes, preserve fallback behaviour and prove it with fixture-backed tests and a built CLI transcript. App and release flows stay unchanged.

  5. johnnyhuy commented on Nov 10, 2026

    @johnnyhuy
    ContributorAuthor

    Remaining CLI slice is pushed in #54 (7d91d20). Fresh plugin cache now feeds CLI discovery, stale/invalid entries retain PATH/npm fallback, and installs read the live version. mise run ci:cli passed with 25 tests; the PR includes a compiled-binary fixture transcript proving cache hits launch no tools and stale/absent cache falls back. This is the current open agent PR; leave #17 open until its Closes #17 merges.

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

    agentclaimed by the Hoist work loop

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions