Oyo

repository·main·Indexed 43 days ago

https://github.com/ahkohd/oyo

A code review tool for teams and AI agents featuring a TUI for diff viewing and code review. It supports Git and Jujutsu (jj) integration, provides a CLI for managing review comments, and includes a specialized pi-oyo package for AI agent skill integration.

Tokens
61.7K
Snippets
196
Records
292
Agent score
55%

What's inside Oyo

  1. What is Oyo?

    main

    Oyo is a terminal-native, CLI-driven code-review tool and diff viewer. It is designed to serve both human developers and coding agents by providing a shared review surface directly in the terminal, eliminating the need to switch to a web browser for pull request reviews.

    The primary binary is oy.

  2. Select a review target in Git or jj

    main

    Oyo scopes reviews to your current Git worktree or jj workspace. You can use the -t or --target flag to explicitly select which diff or branch you are reviewing. If no target is specified, Oyo prefers the current branch's local PR review, falling back to the working tree.

    Git Targets

    • Working Tree: oy or oy review status -t @
    • Staged Changes: oy --staged or oy --staged review status
    • Branch/Feature: oy feature or oy review status -t feature
    • Pull Request (Range): oy --range main...feature or oy review status -t main...feature
    • Specific Commit: oy HEAD

    jj (Jujutsu) Targets

    • Default/Current Change: oy or oy @
    • Bookmark Stack: oy feature
    • Current Stack: oy 'trunk()..@'
    • Specific Revset Review: oy review comment '@-..@'
    # Git examples
    oy review status -t @
    oy --staged review status
    oy review status -t main...feature
    
    # jj examples
    oy @
    oy review status @
    oy review comment '@-..@'
  3. Interpret oy-profile output metrics

    main

    When reviewing reports from oy-profile, keep the following in mind:

    • CPU%: This value is calculated per-thread (threadCPUDelta / thread lifetime). It is not a representation of whole-system CPU usage.
    • Short-lived threads: Threads that exist for a very short duration may report near-100% CPU usage even if they only contributed a few samples.
    • Missing data: If threadCPUDelta or timing data is absent from the profile, the CPU% column will be omitted from the report.
  4. How Find in files mode works

    main

    Find in files uses typo-tolerant fuzzy matching over files in the review. It shows one row for each match and keeps rows from the same file together.

    Scopes:

    • All scope: Searches the complete current content of reviewed files.
    • Changes scope: Searches added and deleted lines, plus the context shown around each change. Deleted files use their old content in both scopes.

    Oyo remembers your last scope for the session and only searches files within the current review.

  5. How the agent uses Oyo skills via pi-oyo

    main

    When pi-oyo is enabled (/oyo on), the agent receives specific routing instructions in its system prompt. This allows the agent to drive the oy CLI itself using the following patterns:

    • Code reviews and comments: The agent uses oy skill path.
    • Guided walkthroughs: The agent uses oy skill path walkthrough.
    • Live TUI control: The agent uses oy skill path control
  6. Handle queued commands and synchronization

    main

    Some oy control commands (like play, target reloads, or animated movement) are asynchronous and return before the TUI has finished applying them. These commands return a response containing queued: true and a seq (sequence number).

    How to synchronize:

    1. Capture the seq from the command response.
    2. Poll the current state using oy control where --session <name> --json.
    3. Inspect the lastAppliedSeq field in the JSON output.
    4. Wait until lastAppliedSeq is greater than or equal to the returned seq.

    Stopping queued work: If you need to stop pending commands or motion immediately, use:

    oy control cancel --session <name>

    User Intervention: If a user interacts with the TUI (typing or clicking), Oyo will automatically stop any queued agent work.

    # Example polling loop logic
    oy control target --session review-a feature-branch
    # ... wait for 'seq' ...
    oy control where --session review-a --json
    # ... check lastAppliedSeq >= seq ...
  7. Configure walkthrough modes and comment authorship

    main

    Before navigating to the first file, you must confirm the walkthrough mode with the user:

    • Conversational Mode: The walkthrough is purely verbal/textual; no durable notes are added.
    • Comment Mode: Durable Oyo comments are added as the walkthrough progresses.

    If Comment Mode is selected, you must also confirm:

    1. Authorship: Whether comments should be human or agent authored.
    2. Destination: Whether comments are local-only or intended to be published to a provider.

    Important: Never silently impersonate the user. Use an agent identity for agent-authored feedback, and only use the user's identity if explicitly requested.

  8. Understand the Debug View Log format

    main

    The log consists of a snapshot header followed by per-line entries.

    Snapshot Header

    Each snapshot begins with a header containing metadata about the current view state, such as pane, file, mode, window_start, and visible_render_range.

    Per-line Entries

    Each line in the render is logged with specific attributes. When debugging, focus on these fields:

    FieldMeaning
    dispDisplay index range in the current render window
    gdispGlobal display index range, with the window offset applied
    hHunk index, or - when there is none
    scopeWhether the line is inside the current hunk scope
    showWhether ViewLine.show_hunk_extent is set
    kindLine type (e.g., context, added, or deleted)
    changesWhether the line contains actual changes
    old and newOld and new line numbers, when present

    Note: In split mode, logs show old and new display indices instead of a single disp value.

    OYO_VIEW_DEBUG ts_ms=... pane=unified file_index=0 file="path/to/file"
    mode=UnifiedPane stepping=false line_wrap=false diff_status=Ready placeholder=false view_len=1234 windowed=true window_start=0 window_total=5000 viewport_h=40 viewport_w=120 scroll_global=200 render_scroll=200
    state current_hunk=3 total_hunks=8 last_nav_was_hunk=true cursor_change=512 show_extent_step=false scope_hunk=3 scope_from_cursor=true step_direction=None animation_phase=Idle
    visible_render_range=200..239 context=2
    
    L raw=210 disp=200-200 gdisp=200-200 h=3 scope=true show=true kind=Context changes=false old=100 new=100 act=false prim=false id=512 wrap=1 txt="..."
  9. Key syntax and formatting rules

    main

    When defining keys in config.toml, follow these syntax rules:

    • Sequences: Use spaces to separate keys in a sequence (e.g., g g, g b).
    • Modifiers: Use hyphens to connect modifiers to keys (e.g., ctrl-p, ctrl-shift-p, alt-x, cmd-p).
    • Named Keys: Supported named keys include:
      • esc, enter, tab, backtab, space
      • up, down, left, right, home, end
      • pagedown, pageup, backspace, delete

    Note on Terminal Compatibility: Oyo requires enhanced keyboard reporting to distinguish between keys like ctrl-shift-p and ctrl-p. If your terminal does not support this, use alternative sequences like g f for files or g c for comments.

  10. How UI and syntax themes work in Oyo

    main

    Oyo uses two distinct types of themes to control its appearance:

    1. UI themes: Control the 'chrome' (interface elements), diff markers, and background colors.
    2. Syntax themes: Control the colors of code tokens (syntax highlighting).

    These can be configured independently. If you do not explicitly set a syntax theme, Oyo attempts to use the name of your active UI theme. If that fails, it falls back to ansi colors.

  11. Understand Unified, Split, and Evolution diff views

    main

    Oyo provides three primary ways to visualize changes:

    1. Unified View

    Shows a single stream of code. The file changes dynamically as you step through it.

    • Modified lines: Shows Old text $\rightarrow$ Mixed old/new inline text (on step) $\rightarrow$ New text (after step).
    • Insertions: Hidden $\rightarrow$ New text, active $\rightarrow$ New text.
    • Deletions: Old text $\rightarrow$ Old text, active $\rightarrow$ Hidden.

    2. Split View

    Shows the old file on the left and the new file on the right.

    • Modified lines: Left shows Old text, Right shows New text. On step, both show the active state.
    • Insertions: The right pane shows New text.
    • Deletions: The left pane shows Old text with deletion styling.

    3. Evolution View

    Shows the file changing over time. Deleted lines and markers are hidden. Syntax highlighting is controlled by ui.evo.syntax.

    • context: Syntax only on non-diff lines.
    • full: Syntax on diff and context lines (active line keeps diff colors).
    • Toggle setting with E.
  12. Handle blocking behavior and errors

    main

    How Oyo handles command execution depends on the blocking setting:

    • blocking = true: Oyo waits for the command to finish. If the command exits with a non-zero status or hits the timeout_ms limit, Oyo reports the error after the terminal UI exits.
    • blocking = false: Oyo starts the command and returns immediately (fire-and-forget). Oyo does not report the exit status or errors for non-blocking commands.

    Note: Oyo hides the stdout and stderr of hooks and actions. If you need to debug, consider writing the output to a file or using a script that redirects output.