Repository navigation
Install OpenCode hooks in the terminal's config directory - #25296
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Execution-home config resolution —
resolveOpenCodeConfigDirectorynow derives the install root fromHOME(POSIX) /USERPROFILE(Windows), falling back tohomedir(), whileXDG_CONFIG_HOMEstill takes precedence. - Shell-startup
XDG_CONFIG_HOME— the main host-env path and the relay both read a literalXDG_CONFIG_HOMEexport from the selected shell's startup files and use it as the install root. shellPathplumbing —BuildPtyHostEnvOptions.shellPathis threaded through the local, Codex, and daemon spawn paths so the startup read follows the selected shell rather than inheritedSHELL.- Tests — resolver unit tests plus main-path and relay-path tests for home / XDG / selected-shell roots, along with a disabled-hooks guard.
The default (no custom home) behavior is unchanged: homedir() already resolves to HOME/USERPROFILE in the normal case, and the install still lands in XDG_CONFIG_HOME when set. WSL correctly skips the host install, Windows reads nothing from POSIX startup files, and the Windows path shape (USERPROFILE/.config/opencode) matches existing repo knowledge in src/main/skills/skill-discovery-sources.ts. Focused suites (85 + 133 tests across the changed and adjacent files) pass.
ℹ️ App-start refresh does not cover alternate config roots
Because installs can now land in a non-default execution home, the startup refresh that pushes an updated plugin to an already-running OpenCode 2 service no longer sees those installs — they are only refreshed on the next pane spawn in that terminal.
Technical details
# Alternate-home installs are outside the refresh scan
## Affected sites
- `src/main/opencode/hook-service.ts:204` — `refreshInstalledPlugins` scans only `resolveOpenCodeConfigDirectory()` (the process/default home) plus the userData overlays.
- `src/relay/relay-agent-hook-runtime.ts:222` — the relay install-plugins handler refreshes only `process.env`/`homedir()` with `onlyIfInstalled: true`.
- `src/main/ipc/pty/host-env/opencode-config.ts:76` — the new install root is derived per pane from the execution env, so it can differ from the default home.
## Required outcome
None required for merge. The gap is bounded: `buildPtyEnv` rewrites the current plugin into the execution root on the next spawn, so a stale install self-heals. The only concrete fallout is a running OpenCode 2 service in an alternate-home config dir that keeps the old plugin until a pane in that terminal launches (or the app is restarted in a way that re-touches that root).
## Open questions for the human
- Is the delayed refresh acceptable, or should the app-start path track the alternate roots Orca has written into (for example persisting them alongside the overlay manifests) so `refreshInstalledPlugins` can reach them?deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughOpenCode plugin installation now selects its config root from execution environment values, including platform-specific home values and Priority: ➖ Normal Merge Risk: 🔵 Low · up to Users whose shell conditionally sets XDG_CONFIG_HOME may start OpenCode without the installed plugin. This is a bounded configuration case; correct the shared reader before relying on it in both launch paths. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Plugin placement now follows the terminal’s configuration while preserving explicit-directory handling and guest-owned installation. Risk is low, with remaining uncertainty around complex shell profiles and maintaining plugins in previously selected locations. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Ignore conditional XDG assignments when choosing the plugin root. · opencode-config.ts:75-80
src/main/ipc/pty/host-env/opencode-config.ts:75-80
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winIgnore conditional XDG assignments when choosing the plugin root.
When a multiline conditional in the selected shell’s startup file is false, its standalone
export XDG_CONFIG_HOME=...can still match the reader. If that literal differs from the inherited XDG value, the default plugin-install branch can write under<literal>/opencode/plugins, while OpenCode resolves a different config root and can miss the plugin. Make the shared reader return only values it can establish as unconditional; the relay callsite uses the same reader.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d2ddc04e-e792-4764-9bb6-cd343aca112f
📒 Files selected for processing (2)
src/main/ipc/pty-daemon-spawn-codex-auth.test.tssrc/main/ipc/pty-spawn-env-agent-overlays.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Following the prior pullfrog review at 3a9fd8c0, the only new commit (153131cd) is test-only:
- PTY fixture assertions for the consumer config root —
pty-daemon-spawn-codex-auth.test.tsandpty-spawn-env-agent-overlays.test.tsnow set an explicitXDG_CONFIG_HOMEin the pane env and assertbuildPtyEnvis called with the derived<XDG_CONFIG_HOME>/opencoderoot as its third argument, covering the mirror and no-source-dir cases plus the issue #1534 zsh startup-export case.
The added assertions depend on the new three-argument buildPtyEnv signature, so they fail against the prior two-argument call — real coverage, not theatre. No production lines changed in the delta; the prior review's findings stand unchanged.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Integrate ~2007 upstream commits, mostly OpenCode v2 integration maturity (status reporting per pane stablyai#23722/stablyai#24962, hook install in terminal config dir stablyai#25296, stop stale plugin from retired shared hooks dir stablyai#23500) plus @orca/process-host extraction, structured chat over ACP, and many agents. Fork conflicts resolved (6): minimax/zai catalog entries relocated to the new split agent-catalog-entries-secondary.ts; redraw shortcut moved to the new matches() helper; createLocalNestedRepoScanFilesystem updated to isGitRepoAsync; nestedReposPromise kept after upstream made timing a param; showNestedReposToast import kept, dead settingsForRepoOwner dropped. Added minimax/zai to the new Record<TuiAgent> maps (rest-signal, readiness lane) and switched the Activity wrapper-grouping types to TerminalAgent. Accepted upstream's deletion of the global-fetch audit test (stablyai#25791). typecheck clean; git-crypt, time-tracker, activity and shortcut-policy suites green (2305 tests).

ELI5
When a terminal uses a different home or config directory from Orca, OpenCode can miss Orca's plugin. Install the plugin where that terminal's OpenCode actually reads its configuration.
What Changed
Pass the execution environment's config directory to the existing installer. Read supported literal
XDG_CONFIG_HOMEexports from the selected shell's profile. Explicit directories retain their existing overlay path.Use
HOMEon macOS/Linux andUSERPROFILEon Windows. SSH uses the execution host's environment and shell; WSL delegates installation to the guest. Folder workspaces use the same path.Why
Installation previously used Orca's GUI environment. Reusing the resolver, installer, and static shell reader fixes that mismatch without starting a shell or redirecting the user's settings JSON.
Linked Issue
Continues #9192 and credits @inaemin for the original contribution. This addresses plugin placement; the original PR remains open for its broader OMO and per-agent configuration work.
Visual Proof
N/A — this changes plugin installation. The before/after evidence comes from the installed OpenCode config and plugin APIs.
Testing
Active Orca plugin counts changed from
[1, 0, 0, 0, 1]to[1, 1, 1, 1, 1], with exact plugin ID, local path, and active state required. All 15 read-only responses passed; all 15 child processes exited normally and five private endpoints closed.External settings JSON already loaded before the fix.
Build.modelremained absent, so effective per-agent OMO selection is unproved. The shell-export case used the static reader.162 tests passed across nine files. All three typechecks passed on integration
3a9fd8c0; changed-file lint, format, six gates, and official anti-slop passed on the qualified repair. Windows/WSL/SSH coverage is from source tests. Full build remains for CI.The test-only follow-up
153131cdpreserves those eleven files and updates five existing PTY test expectations to verify the terminal config directory. Both affected suites pass all 40 tests; scoped lint and formatting pass.Review
Independently reviewed source and runtime evidence, including execution-host ownership, explicit config precedence, and selected-shell propagation.
Agent skill upstream boundary
Notes
The private background test harness invokes the existing installer, not Orca's GUI or a real terminal. No provider turns or user settings writes.
Checklist