Skip to content

fix: detect opencode Desktop app installs, not just the CLI#439

Merged
rhuanbarreto merged 1 commit into
mainfrom
fix/opencode-desktop-detection
Jul 1, 2026
Merged

fix: detect opencode Desktop app installs, not just the CLI#439
rhuanbarreto merged 1 commit into
mainfrom
fix/opencode-desktop-detection

Conversation

@rhuanbarreto

Copy link
Copy Markdown
Contributor

Summary

  • isOpencodeCliAvailable() only checked whether the opencode binary was on PATH, so the Electron-based opencode Desktop app — which ships no CLI binary at all — was never detected as an installed editor, even though it reads/writes the same user-scope config directory (~/.config/opencode/) as the CLI.
  • Added isOpencodeAvailable() in src/helpers/plugin-install.ts, which returns true if either the CLI is on PATH or opencodeConfigDir() already exists on disk (a reliable signal shared by both distributions).
  • Switched all three call sites that gated opencode detection/install to the broader check: src/helpers/editor-detect.ts (the archgate init editor-selection prompt), src/helpers/init-project.ts (tryInstallPlugin), and src/commands/plugin/install.ts (archgate plugin install --editor opencode).
  • Renamed the internal "cli-not-found" sentinel (passed between init-project.ts and commands/init.ts) to "not-found" since it's no longer CLI-specific, and updated the associated warning message text in both files.
  • Updated/added tests in the three affected test files, including a new isOpencodeAvailable unit-test suite in tests/helpers/plugin-install.test.ts covering the CLI-present, Desktop-only (config dir present, no CLI), and neither-present cases.
  • Documented the pattern in CLAUDE.md's "Adding a New Editor Target" section for future editor integrations that may ship a GUI-only distribution.

Why

A user with only the opencode Desktop app installed (no CLI) found that archgate init never marked opencode as detected, and archgate plugin install --editor opencode skipped the install with a "CLI not found" message — even though the Desktop app was fully installed and configured.

Test plan

  • bun run validate passes (lint, typecheck, format, 1313 tests, ADR check 39/39, knip, build check)
  • Verified live on a machine with opencode Desktop installed but no CLI on PATH: isOpencodeCliAvailable()false, isOpencodeAvailable()true
  • 5 parallel ADR-compliance sub-agent reviews (Architecture, Distribution, General, Legal, General/Process) all returned PASS with 0 violations/warnings

isOpencodeCliAvailable() only checked PATH for the `opencode` binary,
so the Electron-based opencode Desktop app (which ships no CLI at all)
was invisible to editor detection and the plugin-install gate — even
though it reads/writes the same user-scope config directory as the CLI.

Add isOpencodeAvailable(), which OR's the existing CLI check with a
check for opencodeConfigDir() already existing on disk, and switch all
three opencode call sites (editor-detect, init-project, plugin/install)
to use it. Rename the "cli-not-found" sentinel to "not-found" to match
the broader check, and update the associated user-facing messages.

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 279fbe9c-62c2-417d-9d32-3bb4c81fb9ff

📥 Commits

Reviewing files that changed from the base of the PR and between 66a828c and d4299ea.

📒 Files selected for processing (9)
  • CLAUDE.md
  • src/commands/init.ts
  • src/commands/plugin/install.ts
  • src/helpers/editor-detect.ts
  • src/helpers/init-project.ts
  • src/helpers/plugin-install.ts
  • tests/commands/plugin/install.test.ts
  • tests/helpers/init-project.test.ts
  • tests/helpers/plugin-install.test.ts
 _____________________________________________
< Preventing Skynet from becoming self-aware. >
 ---------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: d4299ea
Status: ✅  Deploy successful!
Preview URL: https://ec9548f2.archgate-cli.pages.dev
Branch Preview URL: https://fix-opencode-desktop-detecti.archgate-cli.pages.dev

View logs

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approving: the Cursor Bugbot check passed, but the expected Cursor[bot] review comment (<!-- BUGBOT_REVIEW -->) was not found on this PR. Human review is needed once that signal is available; no additional reviewers were assigned because the author is the sole CODEOWNER and contributor.

Open in Web View Automation 

Sent by Cursor Approval Agent: Archgate CLI Approver

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Metric Value
Lines 90.0% (6936 / 7709)
Threshold 90% minimum — met
Platforms Linux + Windows

Full HTML report available in workflow artifacts.

Per-directory breakdown
Directory Coverage Lines
src/commands/ 88.1% 1874 / 2128
src/engine/ 90.9% 1463 / 1610
src/formats/ 100.0% 142 / 142
src/helpers/ 90.3% 3457 / 3829

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@rhuanbarreto rhuanbarreto merged commit ed92b2b into main Jul 1, 2026
21 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/opencode-desktop-detection branch July 1, 2026 14:02
@archgatebot archgatebot Bot mentioned this pull request Jul 1, 2026
rhuanbarreto added a commit that referenced this pull request Jul 1, 2026
## Summary

- Fixes the `hooks.WorktreeCreate` command in `.claude/settings.json`,
which only ran `bun install`. Once a `WorktreeCreate` hook is
configured, the Claude Code harness defers the **entire** worktree
creation to it and expects only the resulting absolute path on stdout —
the old hook did neither, so `EnterWorktree` failed with errors like
`path contains control characters` or an `ENOENT` chdir into stray `bun
install` output. (21 stale empty directories under `.claude/worktrees/`
plus orphaned `claude/*` branches were leftover evidence of this having
been broken for a while.)
- The fixed hook parses the requested worktree name from the stdin JSON
payload, runs `git worktree add`, installs deps silently, and echoes
only the resulting path. Verified end-to-end via
`EnterWorktree`/`ExitWorktree` — worktree created with full content +
`node_modules`, session cwd matched, clean removal.
- Documents the hook contract in `CLAUDE.md` so it doesn't regress back
to a bare `bun install`.
- Adds `APPROVAL_POLICY.md`, read by this repo's "Archgate CLI Approver"
Cursor Automation (confirmed via its own PR comments — it's custom logic
in that automation's prompt, not a documented Cursor platform feature).
Per [Cursor's Bugbot docs](https://cursor.com/docs/bugbot), a `success`
check conclusion already means "no issues found, and no unresolved
comments" — Bugbot does not always leave a review comment. The
automation's prior fallback logic treated a clean pass with no comment
as an unverified signal and withheld approval (see [PR
#439](#439)). The policy clarifies
that the check's own conclusion is sufficient on its own, while still
requiring human review when the check is missing/pending/failed or
Bugbot left unresolved comments.
- Session findings captured in agent memory
(`.claude/agent-memory/archgate-developer/`) for future reference.

## Test plan

- [x] `bun run src/cli.ts check` — 39/39 ADR rules pass
- [x] `bun run validate` — full pipeline (lint, typecheck, format, 1310
tests, ADR check, knip, build check) passes
- [x] `oxfmt --check .` — clean
- [x] `@reviewer` skill — APPROVED, 0 violations/warnings across
General/Process, Distribution, and General domains
- [x] Live end-to-end verification of the fixed `WorktreeCreate` hook
via `EnterWorktree`/`ExitWorktree`
- [ ] Watch this PR's own "Archgate CLI Approver" comment to confirm it
now picks up `APPROVAL_POLICY.md` (unverified — the automation's
policy-file lookup is self-reported, not independently confirmed)

---------

Signed-off-by: Rhuan Barreto <rhuan@barreto.work>
rhuanbarreto pushed a commit that referenced this pull request Jul 3, 2026
# archgate

## [0.46.0](v0.45.7...v0.46.0)
(2026-07-02)

### ⚠ BREAKING CHANGES

* **session-context:** per-editor list/show subcommands; remove --skip
and its false premise (#446)

### Features

* **session-context:** per-editor list/show subcommands; remove --skip
and its false premise
([#446](#446))
([dd96230](dd96230))

### Bug Fixes

* **ci:** read POSTHOG_PROJECT_ID from secrets, not vars, in release
annotation ([#443](#443))
([a53b305](a53b305))
* detect opencode Desktop app installs, not just the CLI
([#439](#439))
([ed92b2b](ed92b2b))
* **hooks:** force bash shell for WorktreeCreate hook on Windows
([#442](#442))
([9da86cf](9da86cf))
* **release:** cap breaking-change bumps to minor while pre-1.0
([#447](#447))
([3df6c91](3df6c91)),
closes [#446](#446)
[#440](#440)
[#440](#440)
[#440](#440)
* repair broken WorktreeCreate hook and add PR approval policy
([#441](#441))
([de5e97d](de5e97d))
* **session-context:** select top-level opencode sessions, add --root
flag ([#445](#445))
([29b13f4](29b13f4))

---
This PR was generated with
[simple-release](https://github.com/TrigenSoftware/simple-release).

<details>
<summary>📄 Cheatsheet</summary>
<br>



You can configure the bot's behavior through a pull request comment
using the `!simple-release/set-options` command.

### Command Format

````md
!simple-release/set-options

```json
{
  "bump": {},
  "publish": {}
}
```
````

### Useful Parameters

#### Bump

| Parameter | Type | Description |
|-----------|------|-------------|
| `version` | `string` | Force set specific version |
| `as` | `'major' \| 'minor' \| 'patch' \| 'prerelease'` | Release type
|
| `prerelease` | `string` | Pre-release identifier (e.g., "alpha",
"beta") |
| `firstRelease` | `boolean` | Whether this is the first release |
| `skip` | `boolean` | Skip version bump |
| `byProject` | `Record<string, object>` | Per-project bump options for
monorepos |

#### Publish

| Parameter | Type | Description |
|-----------|------|-------------|
| `skip` | `boolean` | Skip publishing |
| `access` | `'public' \| 'restricted'` | Package access level |
| `tag` | `string` | Tag for npm publication |

### Usage Examples

#### Force specific version

````md
!simple-release/set-options

```json
{
  "bump": {
    "version": "2.0.0"
  }
}
```
````

#### Force major bump

````md
!simple-release/set-options

```json
{
  "bump": {
    "as": "major"
  }
}
```
````

#### Create alpha pre-release

````md
!simple-release/set-options

```json
{
  "bump": {
    "prerelease": "alpha"
  }
}
```
````

#### Publish with specific access and tag

````md
!simple-release/set-options

```json
{
  "bump": {
    "prerelease": "beta"
  },
  "publish": {
    "access": "public",
    "tag": "beta"
  }
}
```
````

### Access Restrictions

The command can only be used by users with permissions:
- repository owner
- organization member
- collaborator

### Notes

- The last comment with `!simple-release/set-options` command takes
priority
- JSON must be valid, otherwise the command will be ignored
- Parameters apply only to the current release execution
- The command can be updated by editing the comment or adding a new one


</details>

<!--
  Please do not edit this comment.
  simple-release-pull-request: true
  simple-release-branch-from: release
  simple-release-branch-to: main
-->

Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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