fix(grok): allow external-directory reads so the pr-reviewer can work

Live NAS run showed the Grok pr-reviewer claim the review and fetch the diff,
then write it to /tmp and FAIL to read it back: opencode auto-denied
"external_directory (/tmp/*)" — its file tools refuse paths outside the project
cwd, and in headless serve/run mode an "ask" permission auto-rejects (no human).

Add permission.external_directory (default "allow", env
ROBOCO_GROK_EXTERNAL_DIR_PERMISSION) to the generated opencode.json. The
container is the sandbox and secret-scrub still blocks credential-file reads, so
allowing in-container external-dir reads is safe and unblocks legitimate scratch
use (e.g. the pr-reviewer grepping a large diff in /tmp).

Verified live against grok-build-0.1: with external_directory:"allow" the Read
tool reads a file outside cwd and returns its contents (no auto-reject); the
plain-string form is accepted by opencode 1.17.8.

Needs a rebuild of roboco-agent-grok + a pr-reviewer re-run on the NAS to confirm.
This commit is contained in:
Renn F
2026-06-18 18:52:07 +02:00
parent 12f11a4996
commit 9ed84f051c
2 changed files with 32 additions and 3 deletions
+17
View File
@@ -103,6 +103,23 @@ def test_build_opencode_config_bash_permission_is_tunable() -> None:
assert cfg["permission"]["edit"] == "allow"
def test_build_opencode_config_allows_external_directory_by_default() -> None:
# opencode auto-denies an "ask" external-dir read in headless mode (the
# pr-reviewer couldn't read a diff it wrote to /tmp); default "allow".
cfg = build_opencode_config(_MCP, _TARGET, instruction_paths=[])
assert cfg["permission"]["external_directory"] == "allow"
def test_build_opencode_config_external_directory_is_tunable() -> None:
cfg = build_opencode_config(
{},
_TARGET,
instruction_paths=[],
guards=OpencodeGuards(external_directory_permission="ask"),
)
assert cfg["permission"]["external_directory"] == "ask"
def test_build_opencode_config_disables_subagent_task_tool_by_default() -> None:
# The subagent `task` tool must be hard-disabled: a RoboCo role never uses
# opencode-internal subagents, and one spawned on grok-build-0.1 hung the run.