Skip to content

feat(review): add support for patch/diff files - #1554

Open
soundvibe wants to merge 3 commits into
backnotprop:mainfrom
soundvibe:static-diff
Open

soundvibe wants to merge 3 commits into
backnotprop:mainfrom
soundvibe:static-diff

Conversation

@soundvibe

Copy link
Copy Markdown

Review static unified diffs without a repository (--patch-file)

Adds plannotator review --patch-file <path | -> — a way to open the code review UI against a caller-supplied unified diff, with no Git repo, no worktree, and no VCS detection. Useful for reviewing patches from emails, pastes, remote agents, CI artifacts, or anywhere a diff exists without a checkout.

  plannotator review --patch-file reading.diff                                                                                                                                                                                                                                                   
  curl -s https://example.com/change.diff | plannotator review --patch-file -                                                                                                                                                                                                                    

What it does

  • Serves the patch verbatim as the review content (diffType: "static-patch", snapshot-bound), with the patch path (or stdin patch) as the header label
  • No local VCS affordances: no git context, no refresh (there is no live tree to recompute against), no diff-type switching —the static patch is the session
  • Ask AI context carries the patch content, so questions about the changes work as usual

Supported surfaces

  • Direct CLI (plannotator review, incl. --patch-file - for stdin)
  • OpenCode bridge (opencode-review; stdin variant refused with a clear error since the bridge's stdin carries the input JSON)
  • Pi extension (/plannotator-review --patch-file, plus patchFile on the host-facing code-review event payload)

Validation (in parseReviewArgs, shared by all runtimes)

--patch-file wins over VCS detection entirely, so conflicting selectors are usage errors, not silently ignored flags:

  • with a PR/MR URL, --base, --diff-type, --git/--gitbutler, or an explicit --local → startup error naming the conflict
  • missing or duplicate flag value → startup error
  • empty/whitespace-only patch → startup error (both runtimes)

Tests

  • Parser: parse / missing / duplicate / each conflict combination
  • CLI help surface: --patch-file in top-level and review usage
  • Ask AI: patch used as context in static-patch mode
  • Verified end-to-end manually: server serves the patch with a :static-patch snapshot id and correct label

soundvibe and others added 3 commits September 16, 2026 22:42
Applies backnotprop#1331 onto 0.27.15: review-args gains
--patch-file with parse once-required path semantics folded into the
errors[] contract (hosts must surface rather than throw); the direct
`plannotator review` CLI reads a static unified diff from a file or `-`
(stdin) and opens a workspace-less session (diffType "static-patch").
Harness surfaces (pi command, opencode bridge) keep the PR's explicit
reject for now — generalized in the follow-up commit.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
Generalizes backnotprop#1331's CLI-only --patch-file to the in-process harnesses:

- pi: openCodeReview / startCodeReviewBrowserSession accept `patch`
  (inline unified diff), `patchFile` (path read at call time, resolved
  against the caller cwd), and `patchLabel`; static sessions open the
  same review server with diffType "static-patch" and no workspace /
  gitContext, so no repo is required. The shared `plannotator:request`
  bus forwards the three fields on the `code-review` action, and
  `/plannotator-review --patch-file <path>` now works inside pi instead
  of erroring. patch* and prUrl remain mutually exclusive.
- opencode: the OpenCode bridge (opencode-review entrypoint) reads
  `--patch-file <path>` itself — relative to PLANNOTATOR_CWD or the
  process cwd — and starts the review in static-patch mode. `-` (stdin)
  is rejected with guidance: the bridge's stdin carries the input JSON.
- docs: pi README documents the new code-review payload fields and the
  command flag.

Tests: `bun test apps/pi-extension` (276 pass; the same 2 config tests
fail on a clean tree — env-dependent baseline), `bun test
apps/opencode-plugin`, `bun test apps/hook/server`,
`tsc -p apps/pi-extension/tsconfig.json` all green.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
…drop unused options

- Move --patch-file conflict validation into parseReviewArgs (PR URL,
  --base, --diff-type, --git/--gitbutler, explicit --local) so all three
  runtimes reject in one place; delete the duplicated guards in the
  direct CLI and OpenCode bridge branches.
- Extract readStaticPatch() shared by both Bun review entry paths;
  reject empty patch content on the Bun path to match Pi.
- Remove the uncalled inline `patch` and `patchLabel` options from the
  Pi session/event API.
- Document --patch-file in the plannotator knowledge skill.

Co-Authored-By: Kimchi <noreply@kimchi.dev>
@soundvibe

Copy link
Copy Markdown
Author

@backnotprop could you TAL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant