You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: --annotation flag to preload annotations (LLM review workflow) #153
A common step in my workflow — and in many other vibe-coders' workflows — is asking an LLM to do a code review. The result is a list of comments with references to specific files and lines. To judge whether those comments are actually meaningful, I need to look at the corresponding code in my editor, comment by comment. It would be much nicer to open revdiff with that list of comments already preloaded, where I can edit them, drop the ones that don't make sense, and add my own on top — all in the same view as the diff itself.
revdiff already has the perfect surface for this (annotation gutter, @ popup, filter-by-annotated tree, hunk navigation); it just has no way to seed annotations from an external source.
Proposal
Add a repeatable --annotation <json> flag that pre-populates the annotation store at startup with comments supplied inline as JSON. Each value is either a single annotation object or a JSON array of them:
agree, this would be useful. The LLM-review-into-revdiff loop is a real workflow and seeding the annotation store from outside is a clean way to support it.
one shape adjustment though. Instead of a repeatable --annotation '<json>', I'd lean a single --annotations=path that reads the same markdown format revdiff already emits in -o / stdout (the ## file:line (+) records with the comment body underneath). Reasons:
round-trips with our own output. revdiff -o notes.md HEAD~1, edit, then revdiff --annotations=notes.md HEAD~1 resumes the review. Same format both directions, no separate JSON layer to maintain.
one flag instead of N. An LLM review can easily be 20-30 comments and repeated --annotation gets hostile in a shell.
LLMs produce the format fine after one example, the ## file:line (+) headers are unambiguous.
the parser is the new piece (FormatOutput is currently write-only) but the format is well-defined and already covered by tests, so that part is mechanical.
on the output side: the existing format is enough, no special markers needed. Diffing the input file against the exit dump tells you what was kept, edited, or dropped.
if you want to take a PR, ping me for approach feedback first.
agreed on the shape — file path + reuse the existing format wins on round-trip and on shell ergonomics. before I open a PR, want to lock down a few parser/UX edges so we don't bikeshed in review:
1. Parser placement. New file app/annotation/parse.go next to store.go, exporting func Parse(r io.Reader) ([]Annotation, error). Caller in run() opens the file and feeds the reader.
2. Input scope.--annotations accepts the raw FormatOutput() payload only — pure record blocks. Not the history-file format (# Review / ## Annotations / ## Diff wrappers from history/history.go:58). If we ever want to feed a history file in, that's a separate unwrap step, not the parser's job.
3. Header grammar. Inverse of the three FormatOutput shapes (store.go:142-149):
Single regex over header lines, non-match = error (not silent skip) — easier to debug a hand-written file. OK?
4. Body capture + escape inversion. Body = lines between a header and the next ## (or EOF), trimmed of one trailing newline. Reverse the leading-space escape from escapeHeaderLines (store.go:160-171): any body line whose prefix is ## (space + ## ) loses exactly one leading space. Lossless round-trip.
5. Diff-mismatch policy. When a record references a file/line not in the resolved diff: warn on stderr + drop. Keeping orphans means they show in the @ popup but can't render inline (no matching diff row) and can't be jumped to — dead weight. Drop is honest.
6. Duplicate records in input. Last-write-wins per (file, line, type), including EndLine overwrite — i.e. exactly the existing Store.Add semantics (store.go:30-38), no extra logic. Worth being explicit since the format technically allows duplicates.
7. Empty input. Empty file = valid no-op (load nothing, proceed). Symmetric with the "no annotations" output case in FormatOutput. Bad bytes ≠ empty: only zero-length is a no-op.
8. Conflict with manual edits. None — same Store.Add last-write-wins covers preload-then-edit too.
9. CLI surface. Single Annotations string on options next to Stdin (config.go:38), no-ini:"true" since it's per-invocation. Singular file is simpler.
10. Tests. New parser tests (no goldens to reuse — store_test.go uses direct string assertions, not fixtures). Coverage: each header shape, multiline body, escaped ## body line, mixed file-level + ranged + single-line, missing-from-diff record (verifies warn+drop path), duplicate record, empty input. Plus a Parse(FormatOutput(s)) round-trip property test against a synthesized store.
11. Failure mode. Parse errors fail before Bubble Tea starts (stderr + non-zero exit), same as bad refs today. File-not-found = hard error.
If warn+drop / single-file / regex-strict / FormatOutput-only matches your taste, I'll start the PR on those lines.
two small things during implementation, neither changes the shape:
point 3: confirm the header regex accepts ( ) (literal space inside parens) for context-line type. FormatOutput emits ## file.go:42 ( ) for Type=" " annotations, easy to miss in the inverse. The four shapes that should match: (+), (-), ( ), (file-level).
point 5: the drop check has two flavors. File-level (Line=0) needs only file-in-diff. Line-scoped needs both file and line. Policy is fine, just the resolution split.
worth bundling alongside the parser in the same PR:
one example in README under run-configuration: revdiff --annotations=review.md HEAD~1
short reference in .claude-plugin/skills/revdiff/SKILL.md (and references/usage.md) so AI agents know the flag exists and the format is the same FormatOutput shape both directions
caller-side adoption (generating reviews, calling revdiff, diffing input vs output to extract kept/edited/dropped/added) is each caller's own work, out of scope here. The bidirectional format is the contract.
Activity
umputun commentedon Apr 26, 2026
agree, this would be useful. The LLM-review-into-revdiff loop is a real workflow and seeding the annotation store from outside is a clean way to support it.
one shape adjustment though. Instead of a repeatable
--annotation '<json>', I'd lean a single--annotations=paththat reads the same markdown format revdiff already emits in-o/ stdout (the## file:line (+)records with the comment body underneath). Reasons:revdiff -o notes.md HEAD~1, edit, thenrevdiff --annotations=notes.md HEAD~1resumes the review. Same format both directions, no separate JSON layer to maintain.--annotationgets hostile in a shell.## file:line (+)headers are unambiguous.the parser is the new piece (
FormatOutputis currently write-only) but the format is well-defined and already covered by tests, so that part is mechanical.on the output side: the existing format is enough, no special markers needed. Diffing the input file against the exit dump tells you what was kept, edited, or dropped.
if you want to take a PR, ping me for approach feedback first.
tushkanin commentedon Apr 26, 2026
agreed on the shape — file path + reuse the existing format wins on round-trip and on shell ergonomics. before I open a PR, want to lock down a few parser/UX edges so we don't bikeshed in review:
1. Parser placement. New file
app/annotation/parse.gonext tostore.go, exportingfunc Parse(r io.Reader) ([]Annotation, error). Caller inrun()opens the file and feeds the reader.2. Input scope.
--annotationsaccepts the rawFormatOutput()payload only — pure record blocks. Not the history-file format (# Review/## Annotations/## Diffwrappers fromhistory/history.go:58). If we ever want to feed a history file in, that's a separate unwrap step, not the parser's job.3. Header grammar. Inverse of the three
FormatOutputshapes (store.go:142-149):## <file> (file-level)→Line=0, EndLine=0, Type=""## <file>:<n> (<+|-| >)→ single line## <file>:<n>-<m> (<+|-| >)→ rangeSingle regex over header lines, non-match = error (not silent skip) — easier to debug a hand-written file. OK?
4. Body capture + escape inversion. Body = lines between a header and the next
##(or EOF), trimmed of one trailing newline. Reverse the leading-space escape fromescapeHeaderLines(store.go:160-171): any body line whose prefix is##(space +##) loses exactly one leading space. Lossless round-trip.5. Diff-mismatch policy. When a record references a file/line not in the resolved diff: warn on stderr + drop. Keeping orphans means they show in the
@popup but can't render inline (no matching diff row) and can't be jumped to — dead weight. Drop is honest.6. Duplicate records in input. Last-write-wins per
(file, line, type), includingEndLineoverwrite — i.e. exactly the existingStore.Addsemantics (store.go:30-38), no extra logic. Worth being explicit since the format technically allows duplicates.7. Empty input. Empty file = valid no-op (load nothing, proceed). Symmetric with the "no annotations" output case in
FormatOutput. Bad bytes ≠ empty: only zero-length is a no-op.8. Conflict with manual edits. None — same
Store.Addlast-write-wins covers preload-then-edit too.9. CLI surface. Single
Annotations stringonoptionsnext toStdin(config.go:38),no-ini:"true"since it's per-invocation. Singular file is simpler.10. Tests. New parser tests (no goldens to reuse —
store_test.gouses direct string assertions, not fixtures). Coverage: each header shape, multiline body, escaped##body line, mixed file-level + ranged + single-line, missing-from-diff record (verifies warn+drop path), duplicate record, empty input. Plus aParse(FormatOutput(s))round-trip property test against a synthesized store.11. Failure mode. Parse errors fail before Bubble Tea starts (stderr + non-zero exit), same as bad refs today. File-not-found = hard error.
If warn+drop / single-file / regex-strict /
FormatOutput-only matches your taste, I'll start the PR on those lines.umputun commentedon Apr 26, 2026
agreed on all 11. Go for it.
two small things during implementation, neither changes the shape:
point 3: confirm the header regex accepts
( )(literal space inside parens) for context-line type.FormatOutputemits## file.go:42 ( )forType=" "annotations, easy to miss in the inverse. The four shapes that should match:(+),(-),( ),(file-level).point 5: the drop check has two flavors. File-level (
Line=0) needs only file-in-diff. Line-scoped needs both file and line. Policy is fine, just the resolution split.worth bundling alongside the parser in the same PR:
revdiff --annotations=review.md HEAD~1.claude-plugin/skills/revdiff/SKILL.md(andreferences/usage.md) so AI agents know the flag exists and the format is the sameFormatOutputshape both directionscaller-side adoption (generating reviews, calling revdiff, diffing input vs output to extract kept/edited/dropped/added) is each caller's own work, out of scope here. The bidirectional format is the contract.