# pi-show-diff

Pi extension for local development: open a visual Diff2Html view of what your current branch would contribute to `main`.

It is not a sharing service. It does not upload diffs. It writes a temporary local HTML file and opens it in your browser.

Repository: https://gitlab.com/mjfuertesf/pi-show-diff

## Screenshots

Line-by-line:

![pi-show-diff line-by-line screenshot](./docs/pi-show-diff-line-by-line.png)

Side-by-side:

![pi-show-diff side-by-side screenshot](./docs/pi-show-diff-side-by-side.png)

## Install

```bash
pi install git:gitlab.com/mjfuertesf/pi-show-diff
pi install npm:@mjfuertesf/pi-show-diff
```


## Usage

```text
/show-diff
```

Without arguments, diffs against the remote tracking branch: `origin/main`, then `origin/master`. Falls back to the local branch only if no remote ref is found.

Pass an explicit ref to use it literally:

```text
/show-diff develop          # local branch "develop"
/show-diff origin/develop   # remote tracking branch
/show-diff abc123           # specific commit
```

## What it does

- Runs a PR-style diff: `git diff <base>...HEAD`
- Renders it with Diff2Html
- Opens a local browser preview
- Warns if the working tree is dirty
- Includes committed branch changes only

## Pi tool

Also registers:

```ts
show_review_diff({ base?: string })
```

Useful when a Pi skill or agent should open the same local review preview.

## Development

```bash
npm test
npm pack --dry-run
```

## Credits

Built with [CodeMirror 6](https://codemirror.net/) by Marijn Haverbeke and contributors.

## License

MIT
