Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions packages/opencode/src/altimate/review/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,28 @@ export async function loadReviewPolicy(opts: {
"(a PR that repairs it is reviewed under the broken base file, so merge it with an admin bypass).",
)
}
const headText = await readFirst((rel) => fs.readFile(path.join(opts.cwd, rel), "utf8").catch(() => undefined))
let changedInPr: string[] = []
if (headText !== baseText) {
try {
const head = headText === undefined ? structuredClone(DEFAULT_REVIEW_CONFIG) : parseReviewConfig(headText)
changedInPr = policyChanges(config, head)
} catch {
changedInPr = ["(the PR's .altimate/review file does not parse)"]
}
}
const changedInPr = await headPolicyChanges(opts.cwd, config, baseText)
return { config, source: baseText === undefined ? "default" : "base", hash: policyHash(config), changedInPr }
}

/**
* Settings the PR's `.altimate/review` file in `dir` (the working tree) changes
* relative to `applied`. `appliedText` is the applied file's text when it lives
* in `dir` too: an identical file is then no change, and a missing one reverts
* to the defaults. Without it, a missing file changes nothing (the applied
* policy is inherited from another directory).
*/
export async function headPolicyChanges(dir: string, applied: ReviewConfig, appliedText?: string): Promise<string[]> {
const headText = await readFirst((rel) => fs.readFile(path.join(dir, rel), "utf8").catch(() => undefined))
if (headText === appliedText) return []
try {
const head = headText === undefined ? structuredClone(DEFAULT_REVIEW_CONFIG) : parseReviewConfig(headText)
return policyChanges(applied, head)
} catch {
return ["(the PR's .altimate/review file does not parse)"]
}
}

/**
* Load `.altimate/review.{yml,yaml,json}` from a project directory. Returns the
* defaults when no config file is present. Throws on a malformed/invalid file
Expand Down
2 changes: 2 additions & 0 deletions packages/opencode/src/altimate/review/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export function renderSummary(env: VerdictEnvelope, opts: RenderOptions = {}): s
return ""

const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
const projects = env.scope?.projects ?? []
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The project list is unbounded even though this renderer promises a character budget for the posted comment. With enough touched projects, this line alone can exceed 5,000 characters and the later finding-budget loop cannot trim it; cap the displayed roots and retain the full list in scope.projects.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/review/format.ts, line 76:

<comment>The project list is unbounded even though this renderer promises a character budget for the posted comment. With enough touched projects, this line alone can exceed 5,000 characters and the later finding-budget loop cannot trim it; cap the displayed roots and retain the full list in `scope.projects`.</comment>

<file context>
@@ -72,6 +72,8 @@ export function renderSummary(env: VerdictEnvelope, opts: RenderOptions = {}): s
 
   const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
+  const projects = env.scope?.projects ?? []
+  if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")
 
   if (env.summary.degraded) {
</file context>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: low priority, tracked. We'll cap it at RENDER_CAP with "+N more".

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Project roots are repository-controlled strings, but this line inserts them raw into Markdown. A project directory containing a backtick or newline can break the summary's formatting or inject content; render each root with codeSpan (or otherwise escape Markdown) before joining them.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/review/format.ts, line 76:

<comment>Project roots are repository-controlled strings, but this line inserts them raw into Markdown. A project directory containing a backtick or newline can break the summary's formatting or inject content; render each root with `codeSpan` (or otherwise escape Markdown) before joining them.</comment>

<file context>
@@ -72,6 +72,8 @@ export function renderSummary(env: VerdictEnvelope, opts: RenderOptions = {}): s
 
   const lines: string[] = [REVIEW_MARKER, "", `## ${verdictHeadline(env)}`, ""]
+  const projects = env.scope?.projects ?? []
+  if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")
 
   if (env.summary.degraded) {
</file context>
Suggested change
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => p.root || ".").join(", ")}`, "")
if (projects.length > 1) lines.push(`Reviewed ${projects.length} dbt projects: ${projects.map((p) => codeSpan(p.root || ".")).join(", ")}`, "")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: low priority, tracked (codeSpan).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: The project list is unbounded, unlike the other multi-entry renders (RENDER_CAP = 8 at line 96, LEDGER_MAX_PATHS = 30 at line 283).

On a monorepo with many (or long-named) projects this single fixed line can consume most of SUMMARY_BUDGET_CHARS (5,000), after which fit drops every finding bullet into the "N more finding(s)" notice. Cap the roots shown and append (+N more var); wrapping/escaping the roots like the rest of the renderer (codeSpan, ledger escaping) would also be safer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as r4626966319; tracked.


if (env.summary.degraded) {
lines.push(
Expand Down
9 changes: 5 additions & 4 deletions packages/opencode/src/altimate/review/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ export async function gitRepoRoot(cwd: string): Promise<string | undefined> {
/** Every tracked file at `ref` (default HEAD), repo-root relative; undefined when git can't list it. */
export async function listFilesAt(cwd: string, ref?: string): Promise<string[] | undefined> {
try {
const out = await git(["ls-tree", "-r", "--full-tree", "--name-only", ref || "HEAD"], cwd)
return out.split("\n").filter(Boolean)
// -z: paths verbatim (no C-quoting of non-ASCII or special characters).
const out = await git(["ls-tree", "-r", "-z", "--full-tree", "--name-only", ref || "HEAD"], cwd)
return out.split("\0").filter(Boolean)
} catch {
return undefined
}
Expand All @@ -186,8 +187,8 @@ export async function listFilesAt(cwd: string, ref?: string): Promise<string[] |
/** Files in the index plus untracked, non-ignored files (the working tree), repo-root relative; undefined when git fails. */
export async function listWorkingTreeFiles(cwd: string): Promise<string[] | undefined> {
try {
const out = await git(["ls-files", "--full-name", "--cached", "--others", "--exclude-standard", "--", ":(top)"], cwd)
return out.split("\n").filter(Boolean)
const out = await git(["ls-files", "-z", "--full-name", "--cached", "--others", "--exclude-standard", "--", ":(top)"], cwd)
return out.split("\0").filter(Boolean)
} catch {
return undefined
}
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/altimate/review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export * from "./format"
export * from "./git"
export * from "./runner"
export * from "./run"
export * from "./multi-project"
export * from "./post-github"
export * from "./schema-context"
export * from "./dbt-patterns"
Expand Down
365 changes: 365 additions & 0 deletions packages/opencode/src/altimate/review/multi-project.ts

Large diffs are not rendered by default.

47 changes: 34 additions & 13 deletions packages/opencode/src/altimate/review/post-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,31 @@ export function runCompleted(env: VerdictEnvelope): boolean {
const BOT_REVIEW_RE = /(Approved|Reviewed with comments|Changes requested)\b.*\((trivial|lite|full) tier/
/** Hidden marker in the body of every review this bot posts; reviews of a
* dbt project below the repository root also name it (`project=<dir>`,
* URI-encoded so a directory with spaces stays one token). */
const BOT_REVIEW_MARKER_RE = /<!-- altimate-code-review:verdict(?: project=(\S+))? -->/
* URI-encoded so a directory with spaces stays one token). An `--all-projects`
* review names every project it covers (`projects=<dir>,<dir>`, each
* URI-component-encoded, "." for the repository root). */
const BOT_REVIEW_MARKER_RE = /<!-- altimate-code-review:verdict(?: project=(\S+)| projects=(\S+))? -->/

function botReviewMarker(projectRoot: string | undefined): string {
function botReviewMarker(projectRoot: string | undefined, coveredProjects: string[] | undefined): string {
if (coveredProjects?.length)
return `<!-- altimate-code-review:verdict projects=${coveredProjects.map((r) => encodeURIComponent(r || ".")).join(",")} -->`
return projectRoot
? `<!-- altimate-code-review:verdict project=${encodeURI(projectRoot)} -->`
: "<!-- altimate-code-review:verdict -->"
}

function markerProjects(encoded: string): string[] {
return encoded.split(",").map((e) => {
let r = e
try {
r = decodeURIComponent(e)
} catch {
/* keep as written */
}
return r === "." ? "" : r
})
}

function markerProject(encoded: string | undefined): string {
if (!encoded) return ""
try {
Expand All @@ -107,20 +123,23 @@ function markerProject(encoded: string | undefined): string {

type ReviewLike = { body?: string | null; user?: { type?: string; login?: string } | null }

/** A review this bot posted for this dbt project. The author must be a bot
* (GitHub App / `github-actions[bot]`) or the token's own login: a human
* review that quotes the bot's body, marker included, is never the bot's.
* The marker then scopes it to a project, so in a monorepo one project's run
* never touches another project's review. A bot review without the marker
* (posted before it existed) matches every project. */
function isBotReview(r: ReviewLike, projectRoot: string | undefined, selfLogin: string | undefined): boolean {
/** A review this bot posted for the projects this run covers. The author must
* be a bot (GitHub App / `github-actions[bot]`) or the token's own login: a
* human review that quotes the bot's body, marker included, is never the bot's.
* The marker then scopes it to projects, so in a monorepo one project's run
* never touches another project's review: it is this run's only when every
* project it names is in `covered` (one project's root, or every project an
* `--all-projects` run covers). A bot review without the marker (posted
* before it existed) matches every project. */
function isBotReview(r: ReviewLike, covered: Set<string>, selfLogin: string | undefined): boolean {
const body = r.body ?? ""
if (!BOT_REVIEW_RE.test(body)) return false
const byBot = r.user?.type === "Bot" || (!!selfLogin && r.user?.login === selfLogin)
if (!byBot) return false
const marker = BOT_REVIEW_MARKER_RE.exec(body)
if (!marker) return true
return markerProject(marker[1]) === (projectRoot ?? "")
const named = marker[2] !== undefined ? markerProjects(marker[2]) : [markerProject(marker[1])]
return named.every((p) => covered.has(p))
}

/** True only when the run is known to have reviewed the PR's current head:
Expand Down Expand Up @@ -160,6 +179,8 @@ export async function postGitHubReview(
const { owner, repo, prNumber } = target
const result: PostResult = { inlineFellBack: false }
const projectRoot = env.scope?.projectRoot || undefined
const coveredProjects = env.scope?.coveredProjects
const covered = new Set(coveredProjects?.length ? coveredProjects : [projectRoot ?? ""])

// 1. Read what is already on the PR. Rerun dedup: a finding already
// commented inline (same fingerprint, which ignores line numbers) is not
Expand Down Expand Up @@ -223,7 +244,7 @@ export async function postGitHubReview(
!botLogin && reviews.some((r) => r.user?.type !== "Bot" && BOT_REVIEW_MARKER_RE.test(r.body ?? ""))
const selfLogin = botLogin ?? (needsLogin ? await tokenLogin(octo) : undefined)
const botReviews = reviews.filter(
(r) => isBotReview(r, projectRoot, selfLogin) && (!botLogin || r.user?.login === botLogin),
(r) => isBotReview(r, covered, selfLogin) && (!botLogin || r.user?.login === botLogin),
)
const lastBotHeadline = botLogin ? botReviews.at(-1)?.body?.replace(BOT_REVIEW_MARKER_RE, "").trim() : undefined
const staleBlocking = botReviews.filter((r) => r.state === "CHANGES_REQUESTED").map((r) => r.id)
Expand All @@ -234,7 +255,7 @@ export async function postGitHubReview(
// COMMENT event — the bot must never submit a formal GitHub approval.
const event = VCS_EVENT[env.verdict]
const headline = verdictHeadline(env)
const reviewBody = `${headline}\n\n${botReviewMarker(projectRoot)}`
const reviewBody = `${headline}\n\n${botReviewMarker(projectRoot, coveredProjects)}`
const { comments } = inlineComments(env, posted, commentable)
const posting = postingPolicy(env)
result.inlineSkippedAsPosted = env.findings.filter(
Expand Down
52 changes: 38 additions & 14 deletions packages/opencode/src/altimate/review/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "node:path"
import { readFile, realpath, stat, access, readdir } from "node:fs/promises"
import YAML from "yaml"
import { Installation } from "../../installation"
import { loadReviewPolicy, policyHash, resolveRubric } from "./config"
import { headPolicyChanges, loadReviewPolicy, policyHash, resolveRubric } from "./config"
import { SEVERITY_ORDER, type Severity } from "./finding"
import {
collectChangedFiles,
Expand Down Expand Up @@ -47,6 +47,9 @@ export interface ReviewPullRequestOptions {
head?: string
/** Override the manifest path from config. */
manifestPath?: string
/** Directories whose `.altimate/review` policy applies, in order, when `cwd` has none
* (`--all-projects`: the ancestors of `cwd` up to the repository root, nearest first). */
policyFallbackDirs?: string[]
/** Override the review mode from config. */
mode?: ReviewMode
/** Override the minimum severity to surface. */
Expand All @@ -72,6 +75,10 @@ export interface ReviewPullRequestOptions {
/** G2 — [EXPERIMENTAL] bypass the tier classifier with the supplied tier.
* Envelope carries `tierForced: true` when used. Debug / bench only. */
forceTier?: "trivial" | "lite" | "full"
/** Every file the PR changes, when `changedFiles` is a subset of it (multi-project review). */
prFiles?: string[]
/** Every rename the PR makes (new → old path), when `changedFiles` is a subset of it. */
prRenames?: Array<[string, string]>
}

/** dbt adapter_type → core SQL dialect. Mostly identity; a few aliases. */
Expand Down Expand Up @@ -256,14 +263,29 @@ export async function reviewPullRequest(opts: ReviewPullRequestOptions): Promise

// The policy (.altimate/review.yml) comes from the BASE commit, so the PR
// under review cannot relax its own rules; what it would change is listed.
const cwdRel = await repoRelative(gitRoot, opts.cwd, true)
const policy = await loadReviewPolicy({
cwd: opts.cwd,
readBase:
resolved && cwdRel !== undefined
? (rel) => showAtRef(opts.cwd, resolved.sha, path.posix.join(cwdRel, rel))
: undefined,
})
// The first of cwd and `policyFallbackDirs` that has a policy file wins.
const policyAt = async (dir: string) => {
const dirRel = await repoRelative(gitRoot, dir, true)
return loadReviewPolicy({
cwd: dir,
readBase:
resolved && dirRel !== undefined ? (rel) => showAtRef(opts.cwd, resolved.sha, path.posix.join(dirRel, rel)) : undefined,
})
}
const policyHere = await policyAt(opts.cwd)
let policy = policyHere
for (const dir of opts.policyFallbackDirs ?? []) {
if (policy.source !== "default") break
policy = await policyAt(dir)
}
if (policy !== policyHere) {
// A policy file the PR adds in cwd replaces the inherited one once merged: list
// what it changes relative to the policy applied (relative to the defaults when
// no directory has one on the base branch).
const addedHere =
policy.source === "base" ? await headPolicyChanges(opts.cwd, policy.config) : policyHere.changedInPr
policy.changedInPr = [...new Set([...policy.changedInPr, ...addedHere])]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: A PR-added policy file in a non-project ancestor directory is never reported in policy.changedInPr.

The fallback walk visits every ancestor between the reviewed project and the repo root, but each policyAt(dir) result is discarded unless it is the last non-default one. Scenario: project dbt/a has no policy of its own and the base root policy is mode: gate; the PR adds dbt/.altimate/review.yml with mode: comment. policyAt(<root>/dbt) returns source: "default" with changedInPr: ["mode"], the loop continues to the root, and this block only unions headPolicyChanges(opts.cwd, policy.config) (i.e. dbt/a's own file), so the dbt file's change is dropped. That file is not assigned to any project either (only dbt/a is a project root), so the merged envelope has no changedInPr, the "This PR changes the review policy" note is missing, and the file only shows up in the not-reviewed ledger — yet after merge it is exactly the file --all-projects resolution applies to dbt/a.

Diff the nearest visited directory that has a head-side policy file against the applied policy (not only opts.cwd), or union the changedInPr of every visited directory that has one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MINOR] A policy file the PR adds in a directory between the project and the applied ancestor is not reported in changedInPr

const addedHere =
  policy.source === "base" ? await headPolicyChanges(opts.cwd, policy.config) : policyHere.changedInPr
policy.changedInPr = [...new Set([...policy.changedInPr, ...addedHere])]

While the fallback loop walks up, policy is replaced by each ancestor's result, which discards the intermediate directory's changedInPr; headPolicyChanges is then called only for opts.cwd. Reproduced by Claude and Codex on fresh repos: base root policy mode: gate, projects at services/proj_a and services/proj_b, the PR adds services/.altimate/review.yml with mode: comment. Both projects correctly stay gated, but changedInPr is absent (no stderr notice, nothing in the envelope), although once merged the added file silently turns gating off for both. Same when no base policy exists and the PR adds services/.altimate/review.yml. Editing an existing intermediate policy is reported correctly. This is not an enforcement bypass (the base policy still applies), only the audit trail from the earlier finding, one directory higher.

Fix: for every directory skipped on the way up ([cwd, ...policyFallbackDirs] before the applied one) add headPolicyChanges(dir, policy.config), or resolve the effective head policy across the whole ancestor chain and diff it against the applied one. Add a regression test with a PR-added services/.altimate/review.yml.

}
const config = policy.config
if (policy.changedInPr.length) {
process.stderr.write(
Expand Down Expand Up @@ -349,10 +371,12 @@ export async function reviewPullRequest(opts: ReviewPullRequestOptions): Promise
}
// Map renamed files → their old path so getContent resolves the "old" side
// from where the file lived at `base`: in-scope files as scoped (a rename into
// the project is scoped as added), files outside the project as collected.
const prRenames = new Map(
collected.filter((f) => f.status === "renamed" && f.oldPath).map((f) => [f.path, f.oldPath as string]),
)
// the project is scoped as added), files outside the project as collected or,
// when `changedFiles` is a subset, as the whole PR renamed them.
const prRenames = new Map([
...(opts.prRenames ?? []),
...collected.filter((f) => f.status === "renamed" && f.oldPath).map((f) => [f.path, f.oldPath as string] as const),
])
const inScopePaths = new Set(changedFiles.map((f) => f.path))
const renames = new Map([...prRenames].filter(([p]) => !inScopePaths.has(p)))
for (const f of changedFiles) if (f.status === "renamed" && f.oldPath) renames.set(f.path, f.oldPath)
Expand Down Expand Up @@ -470,7 +494,7 @@ export async function reviewPullRequest(opts: ReviewPullRequestOptions): Promise
const specs = projectGrepSpecs(projectRootRel, dirs, glob)
return specs ? grepFixedAt(gitRoot, opts.head, pattern, specs) : Promise.resolve(undefined)
},
prFiles: collected.map((f) => f.path),
prFiles: opts.prFiles ?? collected.map((f) => f.path),
prRenames,
prTitle: opts.prTitle,
prBody: opts.prBody,
Expand Down
33 changes: 32 additions & 1 deletion packages/opencode/src/altimate/review/verdict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@ export const ReviewScope = z.object({
* project, moved, not a dbt file, no check at this tier, no manifest), with
* the reason; also repeats the `unverified` entries. */
notReviewed: z.array(z.object({ path: z.string(), reason: z.string() })).default([]),
/** Multi-project review (`--all-projects`): every dbt project root the review
* speaks for (the projects the PR does not touch have nothing to flag). The
* poster treats earlier bot reviews of these projects as this review's own. */
coveredProjects: z.array(z.string()).optional(),
/** Multi-project review (`--all-projects`): each dbt project reviewed, its
* changed-file count and its own verdict. */
projects: z
.array(
z.object({
root: z.string(),
files: z.number().int().nonnegative(),
verdict: Verdict,
mode: ReviewMode.optional(),
/** The project's own manifest and policy (the top level keeps one only when all agree). */
manifestHash: z.string().optional(),
policyHash: z.string().optional(),
}),
)
.optional(),
})
export type ReviewScope = z.infer<typeof ReviewScope>

Expand Down Expand Up @@ -233,6 +252,17 @@ export const VerdictEnvelope = z.object({
/** Estimated USD cost from the model's price table. */
cost: z.number().nonnegative().optional(),
calls: z.number().int().nonnegative().optional(),
/** Multi-project review (`--all-projects`): each project's AI lane state. */
projects: z
.array(
z.object({
root: z.string(),
state: z.string(),
reason: z.string().optional(),
calls: z.number().int().nonnegative().optional(),
}),
)
.optional(),
/** Generator findings replayed from an earlier envelope: tokens, cost and calls are that run's. */
replayed: z.boolean().optional(),
/** The replayed envelope did not list every generator finding. */
Expand Down Expand Up @@ -390,7 +420,8 @@ export interface BuildEnvelopeInput {
engineErrors?: VerdictEnvelope["engineErrors"]
}

function summarize(findings: Finding[], degraded: boolean): VerdictEnvelope["summary"] {
/** Severity tally of `findings` for the envelope summary. */
export function summarize(findings: Finding[], degraded: boolean): VerdictEnvelope["summary"] {
const tally: Record<Severity, number> = { critical: 0, warning: 0, suggestion: 0 }
for (const f of findings) tally[f.severity]++
return { critical: tally.critical, warning: tally.warning, suggestion: tally.suggestion, degraded }
Expand Down
11 changes: 10 additions & 1 deletion packages/opencode/src/cli/cmd/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { cmd } from "./cmd"
import { bootstrap } from "../bootstrap"
import { Installation } from "../../installation"
import { prContextFromEnv, reviewPullRequest } from "../../altimate/review/run"
import { reviewAllProjects } from "../../altimate/review/multi-project"
import { renderSummary } from "../../altimate/review/format"
import { postGitHubReview, resolveGitHubTarget } from "../../altimate/review/post-github"
// altimate_change — review feature telemetry
Expand Down Expand Up @@ -70,6 +71,13 @@ export const ReviewCommand = cmd({
type: "string",
describe: "provider/model for the advisory AI lane (default: the configured default model)",
})
.option("all-projects", {
type: "boolean",
default: false,
describe:
"review every dbt project the PR changes (mono-repo) and emit one merged verdict / one comment; " +
"--manifest then applies only to the project that contains it",
})
.option("cwd", { type: "string", describe: "project directory (default: current dir)" }),
async handler(args) {
const cwd = (args.cwd as string) || process.cwd()
Expand Down Expand Up @@ -100,7 +108,8 @@ export const ReviewCommand = cmd({
const prContext = await prContextFromEnv()
let env
try {
env = await reviewPullRequest({
const review = args.allProjects === true ? reviewAllProjects : reviewPullRequest

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: --all-projects can silently skip a dbt project deleted by the PR because discovery only scans the head tree. Discover projects from both head and merge-base, or retain base roots that own deleted paths.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/cli/cmd/review.ts, line 111:

<comment>`--all-projects` can silently skip a dbt project deleted by the PR because discovery only scans the head tree. Discover projects from both head and merge-base, or retain base roots that own deleted paths.</comment>

<file context>
@@ -100,7 +108,8 @@ export const ReviewCommand = cmd({
       let env
       try {
-        env = await reviewPullRequest({
+        const review = args.allProjects === true ? reviewAllProjects : reviewPullRequest
+        env = await review({
           ...prContext,
</file context>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: low priority, tracked. Discovering roots at the merge-base as well would cover it.

env = await review({
...prContext,
aiModel: args.aiModel as string | undefined,
cwd,
Expand Down
Loading
Loading