# pi-coderabbit

Manual CodeRabbit reviews inside Pi.

`pi-coderabbit` adds a `/coderabbit` slash command that shells out to the official CodeRabbit CLI and posts the review back into the current Pi conversation.

It is intentionally manual-only. It never runs automatically after edits, tests, commits, or fixes.

## Requirements

- Pi
- Git repository
- Official CodeRabbit CLI available as `coderabbit`
- CodeRabbit authentication

```sh
coderabbit --version
coderabbit auth login
# or, if the CLI asks for agent-oriented auth:
coderabbit auth login --agent
```

## Install

From npm:

```sh
pi install npm:pi-coderabbit
```

Try without installing permanently:

```sh
pi -e npm:pi-coderabbit
```

From a local checkout:

```sh
pi install /absolute/path/to/pi-coderabbit
```

## Usage

Run from inside a git repository.

```text
/coderabbit
```

By default this reviews the latest commit only, to avoid accidentally spending CodeRabbit usage on a broad repo review.

## Commands

```text
/coderabbit         # same as /coderabbit commit
/coderabbit commit  # latest commit
/coderabbit diff    # uncommitted changes
/coderabbit repo    # broad CodeRabbit review of local repo changes
```

The package runs:

```sh
coderabbit review --type committed --base-commit HEAD~1 --agent  # /coderabbit, /coderabbit commit
coderabbit review --type uncommitted --agent                     # /coderabbit diff
coderabbit review --agent                                        # /coderabbit repo
```

## Flags

```text
/coderabbit --plain       # use CodeRabbit plain text output
/coderabbit --raw         # show raw CLI output, including agent JSON events
/coderabbit diff --plain
/coderabbit repo --raw
```

Without `--raw`, agent JSON status events are formatted for humans. A clean review shows `No findings.` instead of raw JSON.

## Output

```md
## CodeRabbit Review

Reviewed commit:
<git log -1 --oneline>

Working tree:
<git status --short>

Review:
<CodeRabbit review output>
```

## Example workflow

```text
AI makes changes

git add .
git commit

/coderabbit

Review findings

Create follow-up commit(s)

Repeat only when you explicitly run /coderabbit again
```

## Notes

- This package uses the official CodeRabbit CLI. It does not call or reimplement the CodeRabbit API.
- GitHub CodeRabbit PR reviews complement this package but are independent of it.
- `/coderabbit repo` may be broader and more expensive than `/coderabbit commit`; use it deliberately.
