pi-redline 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/extensions/session-diff.ts +1298 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pi-redline contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# pi-redline
|
|
2
|
+
|
|
3
|
+
> Redline your pi sessions. An overlay TUI for [pi](https://github.com/badlogic/pi-mono) that shows every file the agent changed in the current session, with syntax-highlighted full-file diffs, line numbers, per-line selection, fix/explain annotations, and a one-key flow to send the marked-up review back to the session as a prompt.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
You just had pi edit ten files across three repos in one session. Now you want to **walk every change, leave a few notes on lines that need follow-up, and have pi act on those notes** β all without leaving the terminal, without opening a PR, and without losing your scroll position.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- π **Session-scoped file list** grouped by repo. Tracks every successful `edit`/`write`/`multiedit` tool result, retroactively on `/reload` too. Handles multiple repos and worktrees in one session.
|
|
14
|
+
- π **Syntax-highlighted full-file diffs** (not just hunks) using pi's own highlighter, with line numbers and red/green gutters for added/removed lines.
|
|
15
|
+
- β **Per-line annotations** β `v` to enter select mode, space to drop an anchor, ββ to extend, then `a` for a fix note or `x` to ask pi to explain. Yellow gutter marker on annotated lines.
|
|
16
|
+
- π **Cross-file review pane** (`A`) lists every annotation across every file with kind badges (`fix` / `explain`), jump-to-line, and per-row delete.
|
|
17
|
+
- π **One-key submit** (`S`) sends a single markdown-formatted prompt back to the session with all annotations grouped by kind β pi gets a clean review packet with diff snippets and your notes.
|
|
18
|
+
- πͺ **True overlay** β your pi session stays visible behind the panel.
|
|
19
|
+
- β¨οΈ Two-step esc, persistent annotations across overlay open/close, and a footer that surfaces the right hotkeys per mode.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pi install npm:pi-redline
|
|
25
|
+
# /reload (or restart pi)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
/session-diff
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Keys
|
|
35
|
+
|
|
36
|
+
| Mode | Key | Action |
|
|
37
|
+
| :-------- | :------- | :------------------------------------------------ |
|
|
38
|
+
| Left pane | `ββ` | navigate repos / files |
|
|
39
|
+
| | `β / β` | focus diff pane |
|
|
40
|
+
| | `β` | collapse repo / jump to repo header |
|
|
41
|
+
| Diff pane | `ββ/jk` | scroll |
|
|
42
|
+
| | `space` | page down Β· `Ctrl+B` page up |
|
|
43
|
+
| | `β` | return focus to file list |
|
|
44
|
+
| | `v` | enter SELECT mode |
|
|
45
|
+
| | `A` | open review pane |
|
|
46
|
+
| | `S` | submit annotations as prompt |
|
|
47
|
+
| SELECT | `ββ` | move cursor; extends selection once anchor set |
|
|
48
|
+
| | `space` | first press drops anchor, second press β annotate |
|
|
49
|
+
| | `o` | swap cursor and anchor |
|
|
50
|
+
| | `a / β` | annotate as **fix** (note required) |
|
|
51
|
+
| | `x` | annotate as **explain** (note optional) |
|
|
52
|
+
| | `esc` | drop in-progress range / exit SELECT |
|
|
53
|
+
| Review | `ββ` | navigate annotations |
|
|
54
|
+
| | `β` | jump to annotated line |
|
|
55
|
+
| | `d` | delete annotation |
|
|
56
|
+
| | `S` | submit |
|
|
57
|
+
| Anywhere | `q / esc` | close overlay (annotations persist) |
|
|
58
|
+
|
|
59
|
+
### Submission
|
|
60
|
+
|
|
61
|
+
`S` builds a markdown prompt and sends it via `pi.sendUserMessage()`. It groups annotations by kind:
|
|
62
|
+
|
|
63
|
+
~~~markdown
|
|
64
|
+
I'm reviewing the changes you made in this session...
|
|
65
|
+
|
|
66
|
+
## Fixes requested
|
|
67
|
+
### src/handler.py (repo: ~/git/kms-cross-account)
|
|
68
|
+
|
|
69
|
+
**L45-48** β handle the case where the role chain returns no creds
|
|
70
|
+
```diff
|
|
71
|
+
def assume_role(arn):
|
|
72
|
+
+ session = boto3.Session()
|
|
73
|
+
...
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Explanations requested
|
|
77
|
+
### src/util.py
|
|
78
|
+
**L12** β what does this regex actually match?
|
|
79
|
+
~~~
|
|
80
|
+
|
|
81
|
+
The agent picks it up as your next user turn.
|
|
82
|
+
|
|
83
|
+
## Walkthrough
|
|
84
|
+
|
|
85
|
+
### 1. Mark a line range as a fix
|
|
86
|
+
|
|
87
|
+
Press `v` in the diff to enter SELECT mode, `space` to drop an anchor, `ββ` to extend, then `a` to attach a note. The yellow `fix` badge means βI want the agent to change something hereβ.
|
|
88
|
+
|
|
89
|
+

|
|
90
|
+
|
|
91
|
+
### 2. Review every annotation across every file
|
|
92
|
+
|
|
93
|
+
`A` opens the review pane. Each row shows the kind badge, file, line range, and note. `β` jumps to the line, `d` deletes, `S` submits.
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
|
|
97
|
+
### 3. Submit β the agent receives the review and acts on it
|
|
98
|
+
|
|
99
|
+
`S` closes the overlay and sends a single markdown prompt back to the session. The fix turns into a real edit the agent applies immediately.
|
|
100
|
+
|
|
101
|
+

|
|
102
|
+
|
|
103
|
+
### 4. Or ask the agent to *explain* a region instead
|
|
104
|
+
|
|
105
|
+
In SELECT mode press `x` instead of `a`. The note is optional β leave it blank and the agent is asked to explain the snippet on its own terms. The badge turns sapphire.
|
|
106
|
+
|
|
107
|
+

|
|
108
|
+
|
|
109
|
+
### 5. The agent walks the code for you
|
|
110
|
+
|
|
111
|
+
Explain annotations submit as a separate section of the prompt with an explicit βdo not modifyβ instruction, so the agent narrates the code without touching it.
|
|
112
|
+
|
|
113
|
+

|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
## How it works
|
|
117
|
+
|
|
118
|
+
- **Tracking**: subscribes to `pi.on('tool_result')` for successful `edit`/`write`/`multiedit` tools and absolutizes the path against `ctx.cwd`. Persists each new path as a custom session entry (`customType: "session-diff:touched"`) so it survives `/reload`. On `session_start`, also scans historical `toolResult` entries paired with their preceding `AssistantMessage.toolCall.arguments` to rebuild the touched-file map retroactively (useful when installed mid-session).
|
|
119
|
+
- **Repo grouping**: walks each touched file up to its `.git` root. For worktrees uses `git rev-parse --git-common-dir` to resolve the canonical project name so siblings of one repo group under a single header. Files outside any git repo are diffed via `git diff --no-index /dev/null <file>`.
|
|
120
|
+
- **Full-file diffs**: every diff is computed with `git diff --unified=999999` so the entire file is shown, not just hunks β context lines stay neutral, only `+`/`-` lines are colored.
|
|
121
|
+
- **Syntax highlighting**: pi exposes `getLanguageFromPath()` and `highlightCode()` from its theme module; context lines are fully highlighted, `+`/`-` lines keep the highlight + a dark green/red background tint.
|
|
122
|
+
- **Overlay rendering**: uses `ctx.ui.custom(factory, { overlay: true, overlayOptions: { width: '90%', maxHeight: '85%', anchor: 'center' } })` so the live pi session is visible behind the panel.
|
|
123
|
+
|
|
124
|
+
## Requirements
|
|
125
|
+
|
|
126
|
+
- pi β₯ 0.74 (uses `ctx.ui.custom` overlay options and the syntax-highlighting helpers)
|
|
127
|
+
- Node β₯ 20
|
|
128
|
+
- `git` on `$PATH`
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT β see [LICENSE](./LICENSE).
|