Repository navigation
fix(agents): verify opencode 2.3.0 adapter against real CLI (#116) - #207
Falguni-105 wants to merge 4 commits into
Conversation
vsn411
left a comment
There was a problem hiding this comment.
Thanks, and welcome! This is the kind of verification #116 was written for. Real recordings turned up real drift:
--pureand--dirare rejected;- the v1 permission env vars are ignored, so a write actually happened;
- auth errors arrive on stdout.
Each fix comes with a recording that proves it. The recorder's refuse-to-save check and the replay tests are great, and the verification matrix is the format we want for every adapter.
Two things before we merge, both about users who aren't on 2.3.0:
-
opencode v1 is still the default install for many users. On npm,
opencode-ai(the package most guides install) is still on the v1 line, with 1.19.6 aslatest.@opencode/cliis the v2 line, with 2.4.2 as latest. This PR removesOPENCODE_CONFIG_CONTENT/OPENCODE_PERMISSIONand switches the argv to v2-only flags. On a v1 binary, the run would either fail on--standaloneor, if v1 ignores the unknown flag, run without the read-only policy. That's the same write-allowed state your recording caught for v2. Please make it fail closed. Either of these works:- Detect the version (
opencode --version, once per run). Use the v1 argv and env vars for 1.x and the v2 ones for 2.x, and refuse with a clear message for an unknown major. Keep the v1 env vars set in both cases: v2 ignores them, so it costs nothing. - Support v2 only: check the version and return
failedwith "secfoo needs opencode 2.x (npm install -g @opencode/cli)" for 1.x.
A recording against
[email protected]would prove whichever you choose. Your recorder makes that easy. - Detect the version (
-
Local paths in the fixtures. The recordings contain the recording machine's home directory (
C:\Users\<name>\...) about 200 times. That's personal data in a public repo, and it ties the fixtures to one machine. Couldrecord_agent.pyreplace the home directory (Path.home(), in both\and\\-escaped forms) with~before the secret check? Then re-record, or rewrite the five files with the same function.src/secfoo/report/evidence.py's_HOST_PATHSdoes the same thing for reports.
Small things:
- The matrix credits "Shruti Singh" as the verifier, and the PR is from @Falguni-105. If you worked on it together, that's fine; please just confirm the credit is what you both want.
- The
opencode.pydocstring says 2026-11-27, and the docs say 2026-11-28.
CI hasn't run yet because this is your first PR here. A maintainer will approve the workflow run.
|
A quick follow-up, since #214 (Copilot, still open) also adds its own When you pick this up again, could you re-record opencode with it? Together with the two points above (fail closed on opencode 1.x, and |
The recorder now replaces the operator's home directory with ~ in raw, JSON-escaped, and nested-JSONL forms before writing and before the credential check. Rewrite the four Copilot 1.0.117 recordings so public fixtures no longer contain the recording machine's username.
Check the installed opencode major once per run and launch only 2.x, with a clear install hint for 1.x or unreadable versions. Rewrite the five 2.3.0 recordings with the shared recorder's home scrub so local paths and usernames are not published, drop the duplicate recorder from this PR, credit Falguni-105 as verifier, and align the doc and adapter dates on 2026-11-28.
ed49f42 to
8fc3692
Compare
|
Addressed the requested changes:
Verification: I can't request a re-review through the API from a fork, so this is the nudge — please take another look when you have a moment. |
Covers one adapter for #116 (the issue notes one well-verified adapter is a complete PR).
Verified against
@opencode/cli 2.3.0(Windows x64, 2026-11-28) with a newscripts/record_agent.pythat captures real stdout/stderr/exit code and refuses to save a transcript containing a key-shaped value.What the recordings found and this PR fixes
--pureand--dir(flag_drift.jsonrecords the CLI'sUnrecognized flagerrors). The argv now uses--standalone, with the working directory supplied byPopen(cwd=...).OPENCODE_CONFIG_CONTENT/OPENCODE_PERMISSIONenv vars. With those alone, a write tool actually createdproof.txt. The PR ships a v2permissionsarray (read/glob/grep only) viaOPENCODE_CONFIG;permission_denied.jsonrecords the same write being refused.describe_failure()now surfaces the CLI's message.Recordings (
tests/fixtures/agents/opencode/2.3.0/, replayed by tests):success(secret-scanning --depth quick on examples/, 46675 input / 3382 output tokens, cost 0),auth_failure,timeout,permission_denied,flag_drift.Docs: added the opencode row and a verification matrix with CLI version, date, verifier, install/auth/run/timeout/cost checks.
Test note: on this machine
tests/test_agents/test_api.pyhas 15 pre-existing failures becauselanggraphis not installed. All new/affected tests andtests/test_docs_consistency.pypass.