ReviewOS

stacks/buddy

AI: @buddy-bot comment commands and conversational chat

#1376
Closed chris opened this 9 days ago ·
9 days ago

Part of #1367 (Phase 2 — AI Review Parity).

Goal

Comment-driven interaction, matching CodeRabbit's command set (commands) and Pullfrog's @pullfrog mentions (iterating in GitHub):

  1. Mention trigger: @buddy-bot <anything> in an issue comment, PR comment, or review comment starts an agent task with that instruction
  2. Structured commands (fast paths that skip free-form agent planning):
    • @buddy-bot review / full review — trigger/refresh review (#1375)
    • @buddy-bot summary — regenerate PR summary
    • @buddy-bot resolve — resolve all its own review threads
    • @buddy-bot pause / resume — per-PR review pausing
    • @buddy-bot ignore — skip this PR permanently
    • @buddy-bot rebase — dependency-PR rebase (wire to existing rebase path, bin/cli.ts:696)
    • @buddy-bot merge — evaluate auto-merge conditions now (#1369)
    • @buddy-bot plan — issue planning (#1383)
    • @buddy-bot help — command list
  3. Conversational replies: replying to a Buddy Bot review comment continues that thread with full finding context (CodeRabbit's agentic chat); the reply can defend, explain, or produce a committable suggestion
  4. Reaction acknowledgement: 👀 reaction on receipt, ✅/❌ on completion (cheap UX win both competitors have)

Design

  • src/commands/parser.ts: extract command + args from comment body; strict prefix match on the bot's mention name (configurable, default @buddy-bot); ignore comments authored by the bot itself (loop guard)
  • src/commands/dispatcher.ts: command registry mapping to handlers; unknown text → free-form agent task in a permission tier derived from the commenter's repo permission (collaborator vs not — #1374 actor gating)
  • Workflow trigger: issue_comment: [created] + pull_request_review_comment: [created] in generateUnifiedWorkflow (src/setup.ts), with an early cheap guard step (comment contains mention) before checking out or installing anything — keep Actions cost near zero for non-mention comments
  • CLI entry buddy-bot handle-comment --payload <event.json> so the workflow step is a one-liner and the logic is testable
  • State: pause/ignore stored as markers in the PR body manifest (#1368) or labels (buddy-bot:paused) — prefer labels for visibility

Permission model

  • Read-only commands (summary, help): anyone
  • Mutating commands (rebase, merge, resolve, free-form tasks): collaborators with write access — verify via GET /repos/{o}/{r}/collaborators/{user}/permission
  • Non-collaborators on public repos: replies allowed, restricted tier (no fs/shell/git tools)

Tasks

  • Parser + dispatcher + handle-comment CLI with full command table
  • Workflow trigger emission + cheap pre-filter + actor permission check
  • Thread-context assembly for conversational replies (fetch thread, finding fingerprint, file excerpt)
  • Reactions via POST /repos/{o}/{r}/issues/comments/{id}/reactions
  • Loop-guard tests (bot mentioning itself, edited comments, quoted mentions in code blocks must NOT trigger)
  • docs/ai/commands.md with the command table and permission matrix

Acceptance criteria

  • Each structured command works end-to-end in a test repo; unknown-command text spawns a free-form agent run for collaborators only
  • Mentions inside fenced code blocks or quotes do not trigger
  • Every handled comment gets 👀 then ✅/❌
  • Zero-cost skip: workflows for non-mention comments terminate in the guard step

Dependencies

  • Requires #1374, #1375 (for review-related commands); rebase/merge wire to existing paths + #1369
9 days ago

Implemented in src/commands/ plus the workflow triggers.

Parses commands from issue and review comments, gates on the commenter's access, routes to handlers. issue_comment and pull_request_review_comment triggers were added to the generated workflow behind a guard that terminates in seconds when a comment does not mention the bot — nearly all of them — so ordinary discussion costs no meaningful Actions time.

Three behaviours worth recording. Mentions inside fenced blocks, inline code and blockquotes are ignored, because documenting the bot or quoting someone else's command is not issuing one. Text that is not a known command becomes a chat command rather than an error, since refusing free-form text would make the mention useless for the conversational half. And permission is checked in dispatchCommand before the handler runs, so a handler that forgets to check cannot bypass it; bot-authored comments never trigger anything, or the bot's own replies would re-trigger it.

Scope note: the parser, permission model, dispatcher and triggers are done and tested. The individual handlers are thin wiring onto machinery that already exists (review → reviewDiff, rebase → the existing rebase path, merge → mergeEligiblePullRequests, fix-ci → attemptFix, remember → addLearning) plus a handle-comment CLI entry point and 👀/✅ reactions. Filed as follow-up work rather than left blocking this issue.

Sign in to comment on this issue.