fix(opencode): work in the task's workspace, not CodeFrame's own (#1007) - #1022
Conversation
Every SubprocessAdapter targets a workspace with cwd=workspace_path. opencode does not honour it — it resolves its project directory from the *parent* process, so a delegated task edits whatever directory CodeFrame is running from. Under `codeframe serve` that is the server's own checkout. require_file_changes does not catch it: the guard inspects the workspace, finds nothing and fails the run — correctly reporting failure while the edits have already landed elsewhere. build_command now passes --dir. Verified against opencode 1.17.13 by reading the project directory out of opencode's own session_start event, which it emits *before* contacting any model: with cwd= alone it reports the parent's directory, with --dir it reports the workspace. That makes the check independent of opencode's backend, which is returning UnknownError for every turn today — the same instability that stalled the issue's own investigation. Both directions are pinned: one test asserts the adapter's command resolves the workspace when the parent cwd is a *different* directory, and another pins the bug itself so nobody drops --dir believing cwd= is enough (it xfails, loudly, if opencode ever starts honouring cwd=). Also extends #915's contract tier with `help_subcommand`. It could only read top-level --help, and --dir appears only under `opencode run --help` — so the flags most likely to drift, the subcommand ones, were invisible to the tier that exists to catch exactly that. Caught while wiring this fix: adding --dir to the tier's expectations failed until the tier could see the subcommand. kilocode 7.x needs the same mechanism (#1015). Removes the xfail in test_opencode_smoke_913.py that tracked this.
|
Claude finished @frankbria's task in 2m 29s —— View job GLM precision review — complete ✅✅ No defects found. Scoped to concrete defects only (logic, error paths, security, races, contract breakage, resource leaks). Style/architecture/test-coverage are out of scope (covered by the general review).
Verified:
One note (not a defect): Full summary posted as a PR comment. |
|
✅ GLM review: no defects found. Verified against the checked-out code, not the diff alone:
Note (intended behavior, not a defect): with |
|
Claude finished @frankbria's task in 3m 41s —— View job GLM precision review — complete ✅✅ No defects found. Re-reviewed on the synced branch (
Verified against the checked-out code, not the diff alone:
One note (intended behavior, not a defect): Full summary posted as a PR comment. |
GLM precision review (re-review on synced branch) — ✅ no defects foundRe-ran on the Verified against the checked-out code, not the diff alone:
Note (intended behavior, not a defect): with |
Closes #1007.
The bug
Every
SubprocessAdaptertargets a task's workspace withcwd=workspace_path. opencode does not honour it — it resolves its project directory from the parent process, so a delegated task edits whatever directory CodeFRAME is running from. Undercodeframe serve, that is the server's own checkout.require_file_changesdoes not save us: the guard inspects the workspace, finds no changes and fails the run — correctly reporting failure while the edits have already landed somewhere else.Verification
The issue's own investigation stalled here: two
--dirattempts timed out at 240s and 280s, and a plainopencode runtimed out right afterwards, so--dircould not be confirmed. opencode's backend is still returningUnknownErrorfor every turn today.That turned out not to matter. opencode emits its resolved project directory in a
session_startevent before contacting any model, so the check needs no successful turn:Both directions are now pinned by binary-gated tests, and both genuinely run here (not skipped):
The second pins the bug, so nobody drops
--dirbelievingcwd=is enough — and it xfails loudly if opencode ever starts honouringcwd=.A gap this exposed in #915's contract tier
Adding
--dirto the tier's expectations for opencode failed:--dirappears only underopencode run --help, and the tier could only read top-level--help. So the flags most likely to drift — subcommand flags, which is where modern CLIs put everything — were invisible to the tier that exists to catch exactly that.Enginegainshelp_subcommand, and the opencode entry now pins--dir. kilocode 7.x needs the same mechanism (#1015), where--diralso lives underrun.Had I not checked, this would have broken the required
Engine CLI Contractcheck.Also
pytest.xfailintest_opencode_smoke_913.pythat tracked this issue.test_opencode.pytests that assert the exact command list.--helpto stderr, which the tier's_cli_helpalready handled and my first draft of the new test did not.Testing
tests/core/adapters/: 298 passed.ruffclean. Full gate re-running on the clean branch.