Add OpenCode execute regression test#1903
Add OpenCode execute regression test#1903Utkarshbhimte wants to merge 2 commits intopaperclipai:masterfrom
Conversation
This reproduces the headless external_directory failure seen when AGENT_HOME sits outside cwd and verifies that execute() injects a temporary runtime config with permission.external_directory=allow, preserves existing OpenCode config, and cleans up the temp config after the run. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> Co-Authored-By: Paperclip <noreply@paperclip.ing>
Greptile SummaryThis PR adds a single integration-level regression test for the Confidence Score: 5/5Safe to merge — the only change is a new test file with no production code impact. The PR adds a single test file with no modifications to production code. The one flagged issue (the No files require special attention beyond the single minor suggestion on line 171 of the new test file. Important Files Changed
Prompt To Fix All With AIThis is a comment left during a code review.
Path: server/src/__tests__/opencode-local-execute.test.ts
Line: 171
Comment:
**Null fallback masks assertion intent**
If `capture.xdgConfigHome` is `null` (e.g., because the fake script ran without a set `XDG_CONFIG_HOME`), the expression resolves to `fs.access("")`, which throws `ENOENT` for the wrong reason — making the assertion pass vacuously.
Consider explicitly asserting that `xdgConfigHome` is a non-null string first, and then checking that the path no longer exists:
```suggestion
expect(capture.xdgConfigHome).not.toBeNull();
await expect(fs.access(capture.xdgConfigHome!)).rejects.toThrow();
```
This separates the "was a temp dir actually created?" check from the "was it cleaned up?" check, giving a clearer failure message if either invariant is violated.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Add OpenCode execute regression test" | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Summary
AGENT_HOMElives outside the projectcwdexecute()passes a temporary runtime config withpermission.external_directory=allowinto the spawned OpenCode processProblem observed
In a real Paperclip heartbeat run, an
opencode_localagent failed with repeated auto-rejections forexternal_directoryreads againstAGENT_HOMEfiles likeHEARTBEAT.md,SOUL.md, andTOOLS.md.The failing shape was:
/paperclip/.../projects/.../_defaultAGENT_HOMEunder/paperclip/.../workspaces/<agent-id>Skip permissionsenabledThat produced logs like:
permission requested: external_directory (...); auto-rejectingWhy this PR
The current
masterbranch already contains the runtime-config behavior foropencode_local, but there was no execute-path regression test covering the exact failure mode above. This test locks in that behavior so the headless permission plumbing does not regress silently.Verification
pnpm test:run server/src/__tests__/opencode-local-execute.test.tspnpm -r typecheck(fails on pre-existing unrelated UI Lexical issues on current upstream master)pnpm test:run(fails on the same pre-existing UI Lexical module issues on current upstream master)pnpm build(fails on the same pre-existing UI Lexical module issues on current upstream master)