Repository navigation
fix(opencode): keep version probes from leaving folders in home - #1892
tridev-tej wants to merge 1 commit into
Conversation
… home opencode makes its data, cache and state folders on every start, --version included. probe the version with those xdg homes in a temp dir that gets removed, for the confined judge probes and opencodeMajorVersion.
|
No findings in the specified diff. The PR description satisfies the real-CLI verification requirement: it records Review was read-only; no PR code was run, built, or installed. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Approving at 3c8e6db.
What I checked
- Red on main, green here. With main's
exec.ts,confined.ts,opencode-version.tsandconfined-launch.ts, the two new cases fail: "leaves nothing in the member's home…" and "probes a judge tool's version without leaving OpenCode's folders…". With this head,opencode-version.test.tsandtool-launch-confined.test.tspass (31 tests), and typecheck passes. - Real CLI on POSIX, as a pair, with OpenCode on the world's PATH. Each fresh world ran
teamai init --agent opencode,teamai pullandteamai doctor:- main (d1b2528): FAILED.
~/.cache/opencode,~/.local/share/opencodeand~/.local/state/opencodewere left in the world's HOME. - this head (3c8e6db): VERIFIED. None of the three exist afterwards. Doctor's OpenCode checks are the same on both builds ("installed", "skills directory is usable", "reads the skills teamai writes"), so the version still reads.
- Uninstall check. The only thing left behind is
home/.teamai/team-hooks, and main's world leaves the same, as you say.
- main (d1b2528): FAILED.
- Cleanup. The temp directory is removed in a
finally, so a failing probe doesn't leave it either. The probe adds no process, only amkdtemp/rmpair.
[P2 non-blocking]
-
Moving the XDG homes can break a probe through a version-manager shim.
probeVersionnow pointsXDG_DATA_HOME,XDG_CACHE_HOMEandXDG_STATE_HOMEat a temp directory, for every confined tool's probe and foropencodeMajorVersion. A tool installed through a shim that keeps its installs under$XDG_DATA_HOMEwon't find them there. mise, for example, defaults its data directory to$XDG_DATA_HOME/mise. The probe then returns an empty version, and teamai falls back to the assumed OpenCode major and best-effort isolation. Two ways to avoid it:- leave the environment alone, note which of OpenCode's three folders are missing before the probe, and remove only those afterwards;
- redirect only for the
opencodefamily, the one that creates them.
I couldn't run a shim install here, so this is from mise's documented defaults, not a run.
CI review. No findings. We agree, apart from the P2 above.
Merge risk. Low. Only the version probe's environment changes, and the probe's output is read as before.
Thanks for this. A correction to my approval: #1888 names four sites that read OpenCode's version, and this PR covers three. The OpenCode session adapter's #1895 adds the same helper and covers all four, so it is the one that should land for #1888. Once it merges, this PR is superseded and can be closed. |
opencode makes its data, cache and state folders on every start,
--versionincluded, so the confined judge probes andopencodeMajorVersionleft~/.local/share/opencode,~/.local/state/opencodeand~/.cache/opencodein home. newprobeVersionmoves those xdg homes into a temp dir it removes. session adapter probe unchanged: it only runs before an opencode session command. real cli, opencode 1.19.5,teamai doctorin a world: main leaves the three folders, this none. ledger 1 leak (~/.teamai/team-hooks), same on main.Fixes #1888