Skip to content

Commit ab83ed5

Browse files
committed
fix: [#978] make reviewer mode usable — external reads prompt, bash asks, webfetch allowed
The reviewer agent's `*: deny` (last-match-wins) clobbered the defaults' `external_directory: ask`, so `read`/`grep`/`glob` on paths outside the project (sibling repos, `~/.claude/skills`) hard-failed instead of prompting. `bash: deny` also made reviewing a PR by URL impossible (`gh pr view` is the primary path). - `external_directory`: use `readonlyExternalDirectory` (ask + whitelisted dirs allow), same pattern as the `explore` agent - `bash`: `deny` → `ask` — every command still requires explicit user approval; DDL safety denials still win via `userWithSafety` - allow `webfetch`/`websearch`/`list` for read-only PR/issue review - update reviewer prompt tool list to match - regression test: external dir asks, gh pr view asks, DROP still denied, edit/sql_execute_write still denied
1 parent 555ac7f commit ab83ed5

3 files changed

Lines changed: 45 additions & 9 deletions

File tree

‎packages/opencode/src/agent/agent.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export const layer = Layer.effect(
310310
reviewer: {
311311
name: "reviewer",
312312
description:
313-
"dbt PR reviewer. Runs the dbt_pr_review verdict engine (lineage, equivalence, PII, grade) plus read-only analysis tools and posts findings. Edit/write tools are denied; bash is denied.",
313+
"dbt PR reviewer. Runs the dbt_pr_review verdict engine (lineage, equivalence, PII, grade) plus read-only analysis tools and posts findings. Edit/write tools are denied; bash prompts for approval.",
314314
prompt: PROMPT_REVIEWER,
315315
options: {},
316316
permission: Permission.merge(
@@ -335,14 +335,22 @@ export const layer = Layer.effect(
335335
read: "allow",
336336
grep: "allow",
337337
glob: "allow",
338+
list: "allow",
338339
tool_lookup: "allow",
339-
// Bash is DENIED. A string-prefix bash allowlist (e.g. `git log *`)
340-
// cannot safely bound argv: shell redirects ride inside the matched
341-
// command (`git log -p > ~/.ssh/authorized_keys`) and `cat *` reads
342-
// any file — both bypass the "read-only" intent and enable
343-
// write/exfil. The reviewer uses the structured read/grep/glob tools
344-
// and the verdict engine (which does its own diffing) instead.
345-
bash: "deny",
340+
// Reviews routinely span sibling repos and skill dirs; without this
341+
// the "*" deny above hard-fails read/grep/glob outside the project
342+
// (#978). "ask" keeps the user in the loop; whitelisted dirs stay
343+
// frictionless.
344+
external_directory: readonlyExternalDirectory,
345+
// Read-only web access so the reviewer can pull PR/issue URLs.
346+
webfetch: "allow",
347+
websearch: "allow",
348+
// Bash PROMPTS instead of hard-denying (#978: `gh pr view` is the
349+
// primary way to review a PR URL). A string-prefix allowlist can't
350+
// safely bound argv (redirects ride inside the matched command), so
351+
// every bash command requires explicit user approval here — the
352+
// reviewer still never runs shell commands silently.
353+
bash: "ask",
346354
}),
347355
userWithSafety,
348356
),

‎packages/opencode/src/altimate/prompts/reviewer.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ say it could not be proven and recommend a data-diff.
5151
- impact_analysis, lineage_check, altimate_core_column_lineage — lineage / blast radius
5252
- altimate_core_equivalence, altimate_core_compare — semantic equivalence
5353
- altimate_core_check, altimate_core_grade, sql_analyze, sql_diff — quality / PII / anti-patterns
54-
- read, grep, glob, and read-only git (`git diff/show/log/merge-base`)
54+
- read, grep, glob, list — file access; paths outside the project prompt the user for approval
55+
- webfetch / websearch — fetch PR or issue URLs and docs
56+
- bash — every command prompts the user for approval; use it for read-only git
57+
(`git diff/show/log/merge-base`) and `gh pr view/diff` when reviewing a PR by URL
5558

5659
You are designed to be the reviewer a data team can trust: every blocking verdict
5760
is backed by a deterministic proof, and the verdict is signed and replayable.

‎packages/opencode/test/agent/agent.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,31 @@ it.instance("build agent has correct default properties", () =>
7878
}),
7979
)
8080

81+
it.instance("reviewer agent is read-only but usable outside the project (#978)", () =>
82+
Effect.gen(function* () {
83+
const reviewer = yield* load((svc) => svc.get("reviewer"))
84+
expect(reviewer).toBeDefined()
85+
// Structured read tools allowed
86+
expect(evalPerm(reviewer, "read")).toBe("allow")
87+
expect(evalPerm(reviewer, "grep")).toBe("allow")
88+
expect(evalPerm(reviewer, "glob")).toBe("allow")
89+
expect(evalPerm(reviewer, "list")).toBe("allow")
90+
// #978: paths outside the project prompt instead of hard-failing on the "*" deny
91+
expect(Permission.evaluate("external_directory", "/some/sibling/repo", reviewer!.permission).action).toBe("ask")
92+
// #978: PR/issue URLs are reviewable
93+
expect(evalPerm(reviewer, "webfetch")).toBe("allow")
94+
// #978: bash prompts (e.g. `gh pr view`) instead of hard-denying
95+
expect(Permission.evaluate("bash", "gh pr view 66 --repo AltimateAI/.claude", reviewer!.permission).action).toBe(
96+
"ask",
97+
)
98+
// Safety denials still hold even though bash asks
99+
expect(Permission.evaluate("bash", "DROP DATABASE prod", reviewer!.permission).action).toBe("deny")
100+
// Review never mutates
101+
expect(evalPerm(reviewer, "edit")).toBe("deny")
102+
expect(evalPerm(reviewer, "sql_execute_write")).toBe("deny")
103+
}),
104+
)
105+
81106
it.instance("plan agent denies edits except .opencode/plans/*", () =>
82107
Effect.gen(function* () {
83108
const plan = yield* load((svc) => svc.get("plan"))

0 commit comments

Comments
 (0)