Skip to content

fix: find opencode in its installer's folder on check again - #36707

Open
bolichen97 wants to merge 1 commit into
mainfrom
fix/36375-opencode-default-dir
Open

bolichen97 wants to merge 1 commit into
mainfrom
fix/36375-opencode-default-dir

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Check again in Settings → Agent Harness finds an OpenCode that its own installer put in place while the gateway was running, with no restart.

On a running gateway, installing OpenCode with its official installer (curl -fsSL https://opencode.ai/install | bash) leaves the OpenCode card at Not installed. Pressing Check again changes nothing, and Use OpenCode stays disabled until the gateway restarts.

Why it matters

The card tells a new user to install OpenCode and then press Check again. Anyone who follows that advice with OpenCode's own installer, on Linux or Windows, sees the button do nothing, so they conclude the install failed or Kiro Crew is broken. The only way out today is a restart that nothing on the page mentions.

Not a goal

  • Re-reading the user's login-shell PATH or watching shell startup files.
  • Changing the card's wording, including "Which agents appear here is decided when the gateway starts." That sentence is about which harnesses are listed, which this does not change.
  • Install folders for other harnesses: their installers already put the binary in folders the gateway searches.
  • Making opencode resolve for agent shell commands or MCP servers. This is about the OpenCode harness itself.

What changed (motivation → approach → change)

OpenCode installed by its own installer is now found by Check again, and by the next session, without a restart.

The installer puts the binary in ~/.opencode/bin and adds that folder to PATH only for shells started afterwards. The gateway's install check and its session spawn search the PATH the gateway started with plus a fixed list of well-known folders. That folder was in neither, so the binary stayed invisible.

A self-served harness's launch record (SelfServedLaunch in agent_sdk/backends_launch.py) can now name the folders its own installer uses (install_dirs). The shared resolver (_resolve_self_served_bin in acp/launch.py) searches them after PATH, so a binary on PATH or under mise still wins. Only OpenCode names one: ~/.opencode/bin, which is under %USERPROFILE% on Windows. The harness-onboarding spec and the local-models guide say so.

Backwards compatibility

Compatible: the folder is searched only after everything searched today, so an OpenCode that resolves now keeps resolving to the same binary, and every other harness searches exactly what it did.

Removes nothing: the change only adds one folder to one harness's search.

Tests

test/test_agent_backend_recheck_e2e.py::TestRecheckOverHttp::test_opencode_from_its_own_installer_is_found_on_recheck drives the real routes over HTTP. OpenCode first reads missing; an executable then appears in <home>/.opencode/bin while PATH and mise find nothing; the re-check reports it installed with no restart needed.

Red before, green after: with only this test file copied onto the base, the test fails with AssertionError: assert 'missing' == 'installed'; on this change it passes. Determinism: 20/20 runs at -n0; 10/10 runs at -n 4 --dist loadgroup together with test/test_agent_sdk_backend_install.py and test/test_acp_opencode_backend.py (266 passed each); the file's 10 tests in a shuffled order (seed 1842874382): 10 passed.

Proof: PROVEN test/test_agent_backend_recheck_e2e.py::TestRecheckOverHttp::test_opencode_from_its_own_installer_is_found_on_recheck (head a5b9ba2e420d)

prove.py ran on a5b9ba2e420d, which has the same code and tests as this head; only one test docstring line and one spec table cell differ.

Manual verification

Run on a fresh Ubuntu 24.04.5 LTS machine (x86_64, Python 3.12.3) against a real gateway: an isolated KIROCREW_HOME, a fresh HOME, and a gateway PATH without ~/.opencode/bin, exactly as a user who installs OpenCode after starting Kiro Crew. OpenCode was installed while the gateway ran, with its official installer (curl -fsSL https://opencode.ai/install | bash, OpenCode 1.19.5 into $HOME/.opencode/bin).

On the base (c22557cd8), both re-checks 30 s apart still say missing:

GET  /api/acp-backends              -> {"id": "opencode", "installed": "missing", "missing_components": ["opencode"], ...}
POST /api/acp-backends/recheck (1)  -> {"id": "opencode", "installed": "missing", ...}
POST /api/acp-backends/recheck (2)  -> {"id": "opencode", "installed": "missing", ...}

With this change, same steps, first re-check:

GET  /api/acp-backends              -> {"id": "opencode", "installed": "missing", ...}
POST /api/acp-backends/recheck (1)  -> {"id": "opencode", "installed": "installed", "missing_components": [], "restart_required": false}
GET  /api/acp-backends              -> {"id": "opencode", "installed": "installed", "restart_required": false}
POST /api/acp-backends/recheck {"backend": "deepseek"} -> {"id": "deepseek", "installed": "missing", "missing_components": ["dsh"], ...}
resolve_self_served_launch("opencode") -> ('<home>/.opencode/bin/opencode', ['<home>/.opencode/bin/opencode', 'acp'], 'opencode acp', 'opencode')

The last line is the session spawn finding the same binary the card reports.

Gates, on the same machine: every static gate in the project's gate list (black, isort, flake8, mypy src/kiro_crew/, comment history, brand name, harness parity, sync I/O in async, loop-bound locks, docs lint, vendor manifest and the rest) exits 0 on this head's tree, as does semgrep on the diff (0 findings) and the flake-pattern ratchet. The backend related-test set: 24754 passed, plus 2 teardown errors in test/test_live_target_pointer_visibility.py and test/test_sandbox_mount_pinned_target.py that the base shows identically. No frontend file changes; the frontend gates that were red (render-time i18n, the Electron test, the bundle-size build, the frontend related set) are red the same way on the base.

Screenshots / video

Settings → Agent Harness on the same fresh Ubuntu machine, after OpenCode was installed with its official installer while the gateway ran and Check again was pressed. No dashboard code changed; these show the card's verdict.

Before (base): OpenCode still Not installed, Use OpenCode disabled.

OpenCode card on the base after Check again: Not installed

After (this change): OpenCode Installed, Use OpenCode enabled.

OpenCode card with this change after Check again: Installed

Related Issues

Closes #36375

Sibling sweep

Swept: git grep -nE "install_command=" -- src/kiro_crew/agent_sdk/backends_launch.py
Sibling: src/kiro_crew/agent_sdk/backends_launch.py:233 -- changed here
Sibling: src/kiro_crew/acp/harness/goose.py -- not affected -- goose's download_cli.sh installs into ~/.local/bin, which the gateway already searches
Sibling: src/kiro_crew/acp/harness/deepseek.py -- not affected -- installed with npm i -g, whose global bin folder the gateway already searches
Sibling: src/kiro_crew/acp/harness/copilot.py -- not affected -- installed with npm i -g, whose global bin folder the gateway already searches
Sibling: src/kiro_crew/acp/harness/strands.py -- not affected -- installed with npm i -g, whose global bin folder the gateway already searches
Sibling: src/kiro_crew/acp/harness/mimocode.py -- not affected -- installed with npm i -g, whose global bin folder the gateway already searches

Pattern harvest

Not generalizable: where a harness's own installer puts its binary is a fact about that one harness, and it now lives on that harness's launch record.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 7c7629bf4d87d1a174cc34993fc5dc012a949885 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 7c7629bf4d87d1a174cc34993fc5dc012a949885 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: a small, additive search rung on one harness's own launch record. It is searched after PATH and mise, so no binary that resolves today changes.

Notes

  • If ~/.opencode/bin is also on PATH, the install check reports the PATH copy, and so does a session started afterwards, because both use the same _resolve_self_served_bin. That is the precedence the PR intends. It is noted only so nobody later "fixes" it by searching the install folders first.

[DESIGN-REVIEWED] 7c7629b

Description read

[DESCRIPTION-READ] 884e127d1bfe619f3af9951a760296944a01266f5c406b537e6525efc84ebf26

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 7c7629bf4d87d1a174cc34993fc5dc012a949885 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7c7629b

Verdict parsed from the review's SHA-scoped output markers for commit 7c7629bf4d87d1a174cc34993fc5dc012a949885.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7c7629bf4d87d1a174cc34993fc5dc012a949885 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 7c7629bf4d87d1a174cc34993fc5dc012a949885 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks: the fix makes the existing resolver search one folder (~/.opencode/bin) for one harness. Linked issue #36375 and a test that fails on base back the defect.

Notes

  • Item 2 — one consumer, generalized: install_dirs: tuple[str, ...] = () has one reader (_resolve_self_served_bin) and one populated value (("{home}/.opencode/bin",)). Subtraction: shrink it to install_dir: str | None = None until a second installer folder exists.

What this change ships

Inventory (4 items) — 3 justified

Intent: let a user who installs OpenCode with its own installer while the gateway runs press Check again and use it with no restart. FIX.

  1. Check again and the next session find OpenCode in ~/.opencode/bin, searched after PATH and mise — justified
  2. Each self-served harness launch record gets an install_dirs field, set only for OpenCode — one consumer, generalized
  3. Harness-onboarding spec, host-contract table and local-models guide name the new folder — justified
  4. An HTTP end-to-end test shows Check again turning OpenCode from missing to installed — justified

[FIRST-PRINCIPLES-REVIEWED] 7c7629b

Description read

[DESCRIPTION-READ] 6df931f5c1dfbce4f56d0e9b0bdafc4b0abc34f089e562bacfc834e1d50536f4

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7c7629bf4d87d1a174cc34993fc5dc012a949885 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7c7629b

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7c7629bf4d87d1a174cc34993fc5dc012a949885 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates an 8% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

Adds install_dirs (only OpenCode's ~/.opencode/bin) to the self-served launch record and searches it after override, mise and the augmented PATH in the shared _resolve_self_served_bin. The install probe and the session spawn both use that one resolver, so Check again and the next session agree. The new folder is searched last, so existing installs still resolve to the same binary. The path is validated as absolute, the trust level matches the home folders already on the augmented PATH (e.g. ~/.local/bin), and agent file-edit tools are already blocked from writing under .opencode/. A new HTTP e2e test covers the missing → installed transition with restart_required false. Docs match the code.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 631f2a0adb · 80 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 15:50
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The four red checks on this head are main's, not this PR's.

Backend Tests (3.12, 7) ended with "The self-hosted runner lost communication with the server" while Run tests (shard 7/8) was still running, at 31 minutes against 24-28 for the other seven shards: https://github.com/kirodotdev/KiroCrew/actions/runs/43452606626/job/131983024995. No test node id failed. Coverage Gate then failed closed on "Require upstream coverage jobs to have succeeded", the AWS CodeBuild us-east-1 Linux runner check is the same lost build seen from the CodeBuild side, and PR Readiness folds all three in.

main's own push run in the same window failed in exactly the same two jobs with the same signature: https://github.com/kirodotdev/KiroCrew/actions/runs/43458639790 (main, head 6a357581ca, 16:02Z).

The shard-7 runner pressure behind it is tracked in #36261, and #36653 is the open fix that cuts that shard's memory. This PR carries no fix for it and is neither pushing nor overriding for this red: the occurrence is recorded on #36261 and the failed jobs get their one rerun. Every other check on this head passes, every review lane is PASS or no-blocking-findings, and no review thread is open.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 14, 2026
OpenCode's official installer puts the binary in ~/.opencode/bin and
adds that folder to PATH only for new shells. A gateway started before
the install never saw it, so Settings > Agent Harness kept showing
OpenCode as not installed and Check again changed nothing until the
gateway restarted.

A self-served harness's launch record can now name the folders its own
installer uses; the shared resolver searches them after PATH. OpenCode
names ~/.opencode/bin, so the install probe and the spawn both find it
without a restart. Other harnesses are unchanged.
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto current main to resolve the merge conflict in docs/guides/local-and-hosted-models.md and docs/system-specs/modules/agent-host-contract.md.

@bolichen97
bolichen97 force-pushed the fix/36375-opencode-default-dir branch from 631f2a0 to 7c7629b Compare November 17, 2026 20:25
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent Harness: Check again doesn't find OpenCode installed after the gateway started

2 participants