pi-bro 0.23.1 → 0.25.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/CHANGELOG.md +39 -0
- package/README.md +40 -25
- package/docs/README.md +32 -14
- package/docs/elevate.md +125 -0
- package/docs/examples.md +268 -0
- package/docs/features/advisor.md +70 -0
- package/docs/features/btw.md +51 -0
- package/docs/features/explain.md +92 -0
- package/docs/features/show.md +154 -0
- package/docs/getting-started.md +47 -0
- package/docs/guided-review.md +8 -12
- package/docs/pig-compatibility.md +1 -0
- package/docs/reference/commands.md +50 -0
- package/docs/reference/data-and-permissions.md +130 -0
- package/docs/reference/settings.md +108 -0
- package/docs/reference/troubleshooting.md +55 -0
- package/docs/user-guide.md +49 -881
- package/package.json +13 -3
- package/src/advisor.ts +3 -3
- package/src/backend.ts +65 -42
- package/src/bro.ts +25 -0
- package/src/btw.ts +100 -116
- package/src/config-ui.ts +71 -44
- package/src/doctor.ts +21 -24
- package/src/elevate-engine.ts +214 -0
- package/src/elevate.ts +597 -0
- package/src/explain-modal.ts +199 -174
- package/src/modal-kit.ts +291 -0
- package/src/review-modal.ts +95 -48
- package/src/review-ui.ts +52 -46
- package/src/ui-capabilities.ts +13 -6
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Agent second opinions (Advisor)
|
|
2
|
+
|
|
3
|
+
[Docs home](../README.md) · [All commands](../reference/commands.md) · [Safety and permissions](../reference/data-and-permissions.md)
|
|
4
|
+
|
|
5
|
+
## Bro advisor
|
|
6
|
+
|
|
7
|
+
`bro_advisor` is a tool the **executor agent** — not you — can voluntarily
|
|
8
|
+
call mid-task for a second opinion. Unlike `/bro btw`, which is a side
|
|
9
|
+
conversation for you, `bro_advisor` is a tool for the model you're working
|
|
10
|
+
with; it shows up as a normal tool call/result in the transcript, not a
|
|
11
|
+
modal. It is registered like any other tool when the extension loads and has
|
|
12
|
+
no on/off switch of its own — whether the executor can actually call it
|
|
13
|
+
depends entirely on this host's own tool restrictions.
|
|
14
|
+
|
|
15
|
+
`/bro advisor` is a quick notice of whether `bro_advisor` is available right
|
|
16
|
+
now, pointing at `/bro config`, `/bro advisor-steer`, and `/bro doctor`.
|
|
17
|
+
`/bro doctor` has the full diagnostic: whether this host exposes and
|
|
18
|
+
activates `bro_advisor`, its resolved backend/model/effort, steering
|
|
19
|
+
presence, and backend compatibility (for Agy, a minimum CLI version with an
|
|
20
|
+
`agy update` action when it is too old).
|
|
21
|
+
|
|
22
|
+
- **Automatic context, no prep needed**: the executor does not need to assemble
|
|
23
|
+
a summary. Bro captures a harness-neutral snapshot — the executor's system
|
|
24
|
+
instructions, its active tools, and the conversation so far including tool
|
|
25
|
+
calls and results — and sends it, along with an optional `question` the
|
|
26
|
+
executor may pass, to a **fresh, standalone process of the selected
|
|
27
|
+
backend** for every consultation. Nothing is resumed or reused across calls,
|
|
28
|
+
including retries.
|
|
29
|
+
- **Instructed to investigate, not implement**: the advisor process has real
|
|
30
|
+
tool access in the workspace with permissions auto-approved — there is no
|
|
31
|
+
enforced read-only isolation. It is instructed to verify claims itself and
|
|
32
|
+
return advice, leaving edits to the executor, but that boundary is a
|
|
33
|
+
behavioral prompt instruction rather than an enforced sandbox constraint, so
|
|
34
|
+
treat its findings as advice to verify, not a guaranteed hands-off review.
|
|
35
|
+
- **Steering**: The advisor reads standing priorities from `~/.pi/agent/bro-advisor.md`
|
|
36
|
+
and session-specific priorities from `/bro advisor-steer`.
|
|
37
|
+
`/bro advisor-steer` opens an editor for one session steering brief — e.g. "quick
|
|
38
|
+
prototype; keep A and B careful, everything else minimal". Session steering takes
|
|
39
|
+
precedence over durable standing defaults where they conflict.
|
|
40
|
+
**Ctrl+S** saves and keeps the editor open; **Enter** or **Shift+Enter** inserts
|
|
41
|
+
a newline; **Ctrl+K** clears both the saved session brief and draft while staying open;
|
|
42
|
+
**Ctrl+C** copies the entire current draft, including unsaved edits; and **Esc**
|
|
43
|
+
closes without saving unsaved edits. Neither steering source is **ever added to Pi's
|
|
44
|
+
conversation or sent to the main model** — the advisor is the only thing that reads them.
|
|
45
|
+
- **Persistence**: standing defaults persist across all sessions in `~/.pi/agent/bro-advisor.md`.
|
|
46
|
+
The session steering brief persists with the Pi session as custom extension data in the
|
|
47
|
+
session file (`bro-advisor-steering`) and is restored on resume or reload. Forking a
|
|
48
|
+
session inherits session steering; edits made after the fork are independent of the
|
|
49
|
+
original branch. Clearing session steering leaves durable steering intact.
|
|
50
|
+
- **Retries**: on an invocation failure (not a completed answer — "I need
|
|
51
|
+
more evidence" is a normal result, not a failure), Bro retries with the
|
|
52
|
+
identical snapshot, steering, and question: once after 5 seconds, once more
|
|
53
|
+
after 10 seconds, then returns the backend's own diagnostic — including a
|
|
54
|
+
context-length error, verbatim — as the failure. Host-imposed deadlines and
|
|
55
|
+
cancellation are terminal: neither starts another attempt or a backoff wait.
|
|
56
|
+
The advisor CLI is asked to stop at 10 minutes; Bro's host deadline is 610
|
|
57
|
+
seconds plus bounded process cleanup. A CLI-reported error before that host
|
|
58
|
+
deadline remains an invocation failure and can be retried.
|
|
59
|
+
Cancelling the tool call skips any pending retry wait.
|
|
60
|
+
- **Progress and provenance**: while an attempt is running, Bro shows the last
|
|
61
|
+
thing the advisor actually reported — a tool name or a user-facing response
|
|
62
|
+
line, never hidden reasoning — and how long ago it arrived, e.g. `last
|
|
63
|
+
reported: Read src/app.ts (2s ago)`, or "awaiting first activity" before
|
|
64
|
+
anything arrives. Expanding a running consultation shows up to the last 4
|
|
65
|
+
reported activity lines; each retry starts the trail over. The returned
|
|
66
|
+
answer starts with backend, model, effort, attempt count, duration,
|
|
67
|
+
workspace, steering presence, snapshot size, and known omission/compaction
|
|
68
|
+
notes; the advisor's complete answer follows unchanged.
|
|
69
|
+
- **Model/effort**: resolved the same way as explain/show/btw, through
|
|
70
|
+
`/bro config` (shared default or per-capability override).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Side questions (BTW)
|
|
2
|
+
|
|
3
|
+
[Docs home](../README.md) · [All commands](../reference/commands.md) · [Safety and permissions](../reference/data-and-permissions.md)
|
|
4
|
+
|
|
5
|
+
## Bro btw (side conversation)
|
|
6
|
+
|
|
7
|
+
`/bro btw` opens a separate multi-turn conversation in a modal, so you can ask
|
|
8
|
+
a quick side question while the main agent keeps working. It runs through the
|
|
9
|
+
selected backend and never adds anything to Pi's conversation unless you
|
|
10
|
+
explicitly insert it into the editor. Bro writes for a tired reader: the point
|
|
11
|
+
first, in plain words, at a length that fits the question, in the language you
|
|
12
|
+
asked in.
|
|
13
|
+
|
|
14
|
+
- `/bro btw <question>` asks immediately; `/bro btw` opens an empty thread.
|
|
15
|
+
Reopening keeps the thread and its mode.
|
|
16
|
+
- **Two modes, toggled with `/mode`**: a new thread starts
|
|
17
|
+
**conversation-only**; type `/mode` in the modal to switch to **full
|
|
18
|
+
permission** (read and edit the workspace, run commands) and again to switch
|
|
19
|
+
back. The conversation is kept across switches. How conversation-only is
|
|
20
|
+
enforced depends on the backend — see
|
|
21
|
+
[Backends: access and retention](../reference/data-and-permissions.md#backends-access-and-retention).
|
|
22
|
+
**Conversation-only does not mean a hard sandbox on every backend:** Grok
|
|
23
|
+
relies on an instruction; Codex and Muse can retain some read, shell, or
|
|
24
|
+
network abilities under their own restricted settings. Do not send secrets
|
|
25
|
+
on the assumption that the model cannot access anything else.
|
|
26
|
+
- Every new or cleared thread is seeded with up to the last 8 turns of
|
|
27
|
+
main-session user/assistant conversation text (40,000 characters max, with a
|
|
28
|
+
truncation notice). Later turns continue the backend's native session; in
|
|
29
|
+
full permission mode the side agent can also read the repo itself.
|
|
30
|
+
- **In the modal**: type a question and press Enter (empty Enter re-asks the
|
|
31
|
+
last question). Composer actions trigger only on these exact commands:
|
|
32
|
+
- `/mode`: toggles conversation-only / full permission, keeping the thread
|
|
33
|
+
- `/copy`: copies the latest answer to the system clipboard
|
|
34
|
+
- `/copy-all`: copies the full thread to the system clipboard
|
|
35
|
+
- `/insert`: inserts the latest answer into the main editor without submitting
|
|
36
|
+
- `/insert-all`: inserts the full thread into the main editor without submitting
|
|
37
|
+
- `/retry`: re-asks the last question (empty Enter does the same)
|
|
38
|
+
- `/clear`: resets the thread
|
|
39
|
+
|
|
40
|
+
`/insert` and `/insert-all` never replace an existing main-editor draft:
|
|
41
|
+
edit or clear it first. Any other text, including other slash-prefixed input
|
|
42
|
+
such as `/send`, is sent as a question. Esc closes the modal and stops a
|
|
43
|
+
running turn; the thread is kept. The view follows the newest text while you
|
|
44
|
+
are at the bottom; scroll up to read earlier turns. The header shows the model and reasoning effort the latest
|
|
45
|
+
turn used (`default` when the model's own effort applies) and the current
|
|
46
|
+
mode.
|
|
47
|
+
- A turn is capped at 2 minutes in conversation-only mode and 10 minutes in
|
|
48
|
+
full permission mode.
|
|
49
|
+
- Bro's thread lives in memory only — it clears when you switch Pi sessions,
|
|
50
|
+
reload extensions, or quit Pi. Changing the BTW backend starts a fresh
|
|
51
|
+
thread; native session IDs never cross backends.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Explain text, files and webpages
|
|
2
|
+
|
|
3
|
+
[Docs home](../README.md) · [All commands](../reference/commands.md) · [Safety and permissions](../reference/data-and-permissions.md)
|
|
4
|
+
|
|
5
|
+
## Explanation modes
|
|
6
|
+
|
|
7
|
+
Bro treats quoted source as data and asks the model to ignore embedded
|
|
8
|
+
instructions found in it. This is a prompt instruction, not an enforced security
|
|
9
|
+
boundary. Bro preserves the source's language (unless your [preferences](../reference/settings.md#preferences) name another), and avoids
|
|
10
|
+
adding facts, advice, or conclusions in every mode. Choose
|
|
11
|
+
a persistent mode with `/bro mode`, or press **M** in an explanation to try the
|
|
12
|
+
next mode without saving it:
|
|
13
|
+
|
|
14
|
+
- **`brief`**: Uses the original audience-led ELI-simpleton prompt with no fixed
|
|
15
|
+
word target.
|
|
16
|
+
- **`balanced`**: The default. Keeps important details, conditions, warnings,
|
|
17
|
+
context, code, and formatting while trimming fluff and repetition.
|
|
18
|
+
- **`faithful`**: Simplifies the language while preserving every claim,
|
|
19
|
+
qualification, warning, number, command, code block, and formatting choice.
|
|
20
|
+
|
|
21
|
+
### Modal controls
|
|
22
|
+
|
|
23
|
+
- **Mouse wheel / trackpad**: Scroll in regular or fullscreen mode
|
|
24
|
+
- **↑ / ↓**: Scroll in any mode
|
|
25
|
+
- **PgUp / PgDn**: Scroll a page at a time (also in btw)
|
|
26
|
+
- **C**: Copy the complete explanation
|
|
27
|
+
- **R**: Simplify the captured source again in the mode shown, or run the
|
|
28
|
+
current Doctor check again
|
|
29
|
+
- **M**: Re-simplify the captured source in the next mode (brief → balanced →
|
|
30
|
+
faithful → brief). It applies to this explanation only and does not change
|
|
31
|
+
the mode saved by `/bro mode`; pressing it again while Bro is working skips
|
|
32
|
+
ahead
|
|
33
|
+
- **O**: Open the diagram (an HTML layout or a rendered sequence diagram) when a show reply contains one
|
|
34
|
+
- **Esc**: Close the modal, or cancel while Bro is working
|
|
35
|
+
|
|
36
|
+
The modal header shows the model and reasoning effort the explanation or
|
|
37
|
+
drawing used (`default` when the model's own effort applies), followed by the
|
|
38
|
+
explanation mode, and `prefs` when your [preferences](../reference/settings.md#preferences) shaped the
|
|
39
|
+
result; `/bro open` keeps the original labels, mode, and tag.
|
|
40
|
+
|
|
41
|
+
Bro temporarily captures mouse input while its modal is open. Native mouse
|
|
42
|
+
selection may be unavailable or visually extend outside the modal depending on
|
|
43
|
+
your terminal mode; press **C** to copy the complete explanation reliably.
|
|
44
|
+
|
|
45
|
+
## Explain pasted text
|
|
46
|
+
|
|
47
|
+
Paste text directly after the command:
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
/bro text OAuth refresh tokens are rotated after every successful use.
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Bro explains the pasted text instead of the latest assistant reply. With no text
|
|
54
|
+
after `/bro text`, it falls back to the latest completed reply. Press **R**
|
|
55
|
+
to simplify the same captured text again.
|
|
56
|
+
|
|
57
|
+
## Explain a document
|
|
58
|
+
|
|
59
|
+
Use a path relative to Pi's current workspace, or an absolute path inside it:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
/bro file "docs/incident review.pdf"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Paths may contain spaces; matching single or double quotes are also accepted.
|
|
66
|
+
Bro extracts text locally, then sends that text through the same explanation
|
|
67
|
+
flow used by `/bro`. Pressing **R** retries the extracted snapshot; running a
|
|
68
|
+
new `/bro file <path>` command reads the file again.
|
|
69
|
+
|
|
70
|
+
Files are limited to 10 MiB and 100,000 extracted characters. Scanned PDFs are
|
|
71
|
+
not supported because Bro does not perform OCR.
|
|
72
|
+
|
|
73
|
+
## Explain a webpage
|
|
74
|
+
|
|
75
|
+
Pass one public HTTP or HTTPS page:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
/bro url https://example.com/complicated-article
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Bro fetches the page, extracts its main readable text locally, and sends only
|
|
82
|
+
that text through the existing explanation flow. The completed modal shows the
|
|
83
|
+
final website and page title. Pressing **R** retries the captured page without
|
|
84
|
+
fetching again; running a new `/bro url <url>` command fetches a fresh copy.
|
|
85
|
+
|
|
86
|
+
The first version is intentionally limited to one public, text-based page. It
|
|
87
|
+
does not use browser cookies, sign in, run page JavaScript, bypass paywalls or
|
|
88
|
+
bot protection, load complete discussion threads, follow pagination, or
|
|
89
|
+
understand images and video. Pages that depend on those features may fail.
|
|
90
|
+
|
|
91
|
+
If Bro cannot read a page, copy its content into a `.txt` or `.md` file, or save
|
|
92
|
+
it as a PDF, then use `/bro file <path>`.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Visualize a session (Show)
|
|
2
|
+
|
|
3
|
+
[Docs home](../README.md) · [All commands](../reference/commands.md) · [Safety and permissions](../reference/data-and-permissions.md)
|
|
4
|
+
|
|
5
|
+
## Bro show
|
|
6
|
+
|
|
7
|
+
Where the explanation modes rewrite dense prose in simpler words, `/bro show`
|
|
8
|
+
changes the form: it draws what you and the assistant said in the last few
|
|
9
|
+
session turns as a shape instead of paragraphs. Capture keeps only user and
|
|
10
|
+
assistant conversation text, including every intermediate assistant message in
|
|
11
|
+
a turn — tool calls, tool results, reasoning, and images never leave the
|
|
12
|
+
session. It runs the same backend-specific model call and shows the result
|
|
13
|
+
in the same modal, never touching your conversation. `/bro show` uses its own
|
|
14
|
+
draw prompt; the explanation modes do not affect it. Your
|
|
15
|
+
[preferences](../reference/settings.md#preferences) can change only its wording and language, never
|
|
16
|
+
which shapes it draws or its rules.
|
|
17
|
+
|
|
18
|
+
Because the draw model only ever sees conversation text, its shapes reflect
|
|
19
|
+
what was *reported* in the conversation — what the assistant said it did or
|
|
20
|
+
found — not an independent check against the actual code or system state.
|
|
21
|
+
|
|
22
|
+
Shapes are terminal-first: pseudocode, call trees, file trees, component
|
|
23
|
+
trees, diffs, and types and signatures. Bro picks the shape from what
|
|
24
|
+
happened in the session; there is no flag to request a specific one. When the source has no code structure
|
|
25
|
+
to draw, Bro falls back to a plain outline instead of forcing a diagram. A
|
|
26
|
+
reply that ends in one self-contained HTML block — layout, a state comparison,
|
|
27
|
+
anything where position itself carries meaning — is written to a file and
|
|
28
|
+
opened with **O**.
|
|
29
|
+
|
|
30
|
+
When the turns describe messages passing among three or more participants in
|
|
31
|
+
a set order (for example browser → API → database), a reply can instead end in
|
|
32
|
+
one Mermaid `sequenceDiagram`. The modal keeps its source visible with
|
|
33
|
+
`[Diagram saved — press O to render]`; **O** opens a page that draws it with
|
|
34
|
+
the Mermaid copy bundled in Bro. Any other Mermaid stays plain text.
|
|
35
|
+
|
|
36
|
+
Pressing **R** redraws the same captured turns; running `/bro show` again
|
|
37
|
+
captures the latest turns afresh. `/bro show <n-turns>` overrides the default turn
|
|
38
|
+
count for a single run.
|
|
39
|
+
|
|
40
|
+
Add a query to steer what the shapes focus on, either after a turn count or on
|
|
41
|
+
its own: `/bro show what changed in the auth flow`, or `/bro show 3 what
|
|
42
|
+
changed in the auth flow`. The query is used as a lens on the captured turns,
|
|
43
|
+
not as additional evidence, and its casing is preserved as typed. Pressing
|
|
44
|
+
**R** retries with the same turn count and query.
|
|
45
|
+
|
|
46
|
+
Any leading whitespace-delimited word that looks like a number is treated as the
|
|
47
|
+
requested turn count: for example, `/bro show 3 what changed` captures 3 turns
|
|
48
|
+
and steers on "what changed", while `/bro show 404 handler` parses "404" as the
|
|
49
|
+
turn count and "handler" as the steering query. To steer on a phrase that starts
|
|
50
|
+
with digits while choosing a turn count, specify the turn count explicitly
|
|
51
|
+
first: `/bro show 1 404 handler` captures 1 turn and steers on "404 handler".
|
|
52
|
+
If the first word is not a number, the whole input is treated as the steering
|
|
53
|
+
query using the saved `showTurns` default.
|
|
54
|
+
|
|
55
|
+
### A slow session-create, traced
|
|
56
|
+
|
|
57
|
+
The agent followed a two-second delay from the handler down to the worker.
|
|
58
|
+
`/bro show` drew the chain:
|
|
59
|
+
|
|
60
|
+
```text
|
|
61
|
+
handleCreateSession(req)
|
|
62
|
+
├── validateRequest(req)
|
|
63
|
+
├── SessionStore.insert(req.body)
|
|
64
|
+
└── publish('session.created')
|
|
65
|
+
└── AgentWorker.run(sessionId)
|
|
66
|
+
├── loadContext(sessionId)
|
|
67
|
+
├── callModel(context)
|
|
68
|
+
└── persistResult(sessionId, result)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### The shape of code before it exists
|
|
72
|
+
|
|
73
|
+
A design discussion agreed on the data model ahead of implementation. `/bro
|
|
74
|
+
show` kept just the shape:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
interface Item { id: ItemId; parentId: ItemId | null }
|
|
78
|
+
interface Cursor { position: ItemId; direction: 'up' | 'down' }
|
|
79
|
+
function resolveTarget(items: Item[], cursor: Cursor): ItemId | null
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### A layout that collapses at narrow widths
|
|
83
|
+
|
|
84
|
+
Text can't show a before/after layout change at a glance, so Bro ends with one
|
|
85
|
+
self-contained HTML block and **O** opens it (the terminal first shows
|
|
86
|
+
`[HTML diagram saved — press O to open]`):
|
|
87
|
+
|
|
88
|
+
<p align="center">
|
|
89
|
+
<a href="https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-show-layout.png">
|
|
90
|
+
<img alt="A before/after dashboard grid" src="https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-show-layout.png" width="720">
|
|
91
|
+
</a>
|
|
92
|
+
</p>
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary><strong>More shapes</strong></summary>
|
|
96
|
+
|
|
97
|
+
**Diff** — what changed in the save handler:
|
|
98
|
+
|
|
99
|
+
```diff
|
|
100
|
+
on(save)
|
|
101
|
+
- write content
|
|
102
|
+
+ if content is unchanged
|
|
103
|
+
+ return cached result
|
|
104
|
+
+ write new content
|
|
105
|
+
+ invalidate cache
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**File layout** — where everything lives, for a refactor:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
src/
|
|
112
|
+
├── commands/ # user intents
|
|
113
|
+
│ ├── registry.ts
|
|
114
|
+
│ └── show-me.ts
|
|
115
|
+
├── sessions/ # state and lifecycle
|
|
116
|
+
│ ├── events.ts
|
|
117
|
+
│ ├── store.ts
|
|
118
|
+
│ └── worker.ts
|
|
119
|
+
├── transport/ # API
|
|
120
|
+
│ ├── client.ts
|
|
121
|
+
│ └── stream.ts
|
|
122
|
+
└── config.ts # root config
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Component tree** — what the session page renders:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
SessionPage (apps/example/src/routes/session.tsx)
|
|
129
|
+
├── [hook] useSessionEvents
|
|
130
|
+
├── SessionToolbar (packages/ui)
|
|
131
|
+
│ └── RunSkillButton
|
|
132
|
+
└── SessionTimeline (packages/ui)
|
|
133
|
+
└── SkillResultCard
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Pseudocode** — how scroll capture and restore work:
|
|
137
|
+
|
|
138
|
+
```text
|
|
139
|
+
capture(blocks, targetRect, scrollRect) -> Snapshot:
|
|
140
|
+
target = focusedBlock ?? firstBlockIntersectingViewportTop(blocks)
|
|
141
|
+
anchor = wholeBlockAnchor(blocks, target)
|
|
142
|
+
offset = targetRect.top - scrollRect.top
|
|
143
|
+
return { anchor, offset, scrollTop, revision + 1 }
|
|
144
|
+
|
|
145
|
+
restore(snapshot, blocks) -> number:
|
|
146
|
+
placement = resolveAnchor(blocks, snapshot.anchor)
|
|
147
|
+
if placement: return scrollRect.top + targetRect.top - snapshot.offset
|
|
148
|
+
return snapshot.scrollTop
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
</details>
|
|
152
|
+
|
|
153
|
+
Prose in, outline out: a purely conversational session with no code to draw
|
|
154
|
+
degrades to a plain outline of the discussion — never a forced diagram.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Getting started with Pi-bro
|
|
2
|
+
|
|
3
|
+
Pi-bro helps you understand agent replies, ask side questions, and review work without filling your main Pi conversation.
|
|
4
|
+
|
|
5
|
+
## 1. Install
|
|
6
|
+
|
|
7
|
+
You need **Pi**, Node.js 22.19.0 or later, and one supported backend CLI already installed and signed in (Agy, Claude, Grok, Codex, or Muse). See [requirements](../README.md#requirements).
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pi install npm:pi-bro
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Restart Pi (or run `/reload`). Then run:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
/bro doctor
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Expected:** A diagnostic view shows your selected backend, model, and any setup problems. This check does not prove that a live provider request will succeed. If it fails, [check your setup](reference/troubleshooting.md#check-your-setup).
|
|
20
|
+
|
|
21
|
+
## 2. Get your first result
|
|
22
|
+
|
|
23
|
+
Copy this complete command into Pi:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
/bro text A request limit means a service allows only a certain number of calls in a given time.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Expected:** A Bro window opens and explains the sentence in simpler words. The exact answer depends on the backend. Use the arrow keys to scroll, **C** to copy, or **Esc** to close. Bro doesn't insert this result into your main agent's context.
|
|
30
|
+
|
|
31
|
+
This step makes a **real model call**, which may use your backend account's quota or incur charges.
|
|
32
|
+
|
|
33
|
+
## 3. Try the next useful command
|
|
34
|
+
|
|
35
|
+
| I want to… | Command |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| Understand the last agent answer | `/bro` (after the main agent has replied) |
|
|
38
|
+
| Ask a side question | `/bro btw What is a race condition?` |
|
|
39
|
+
| Visualize what we discussed | `/bro show` (after at least one user turn) |
|
|
40
|
+
| Explain a file in my workspace | `/bro file docs/my-report.md` (**replace with an existing path**) |
|
|
41
|
+
| Explain an actual public webpage | `/bro url https://your-public-page.example` (**replace with a real URL**) |
|
|
42
|
+
|
|
43
|
+
See the [docs home](README.md) for detailed workflows.
|
|
44
|
+
|
|
45
|
+
## Data and access before you use Bro at work
|
|
46
|
+
|
|
47
|
+
Bro sends your selected text and some context to the backend CLI and model provider you configure. BTW and the advisor have different access rules; some modes can read or change local files. Read [What leaves your machine](../README.md#what-leaves-your-machine) and the [backend access matrix](reference/data-and-permissions.md#backends-access-and-retention) before using private data. A model prompt saying 'do not access' is not a security boundary.
|
package/docs/guided-review.md
CHANGED
|
@@ -6,7 +6,7 @@ The normal journey is: **open a PR → read and investigate → leave when satis
|
|
|
6
6
|
|
|
7
7
|
## Open a review
|
|
8
8
|
|
|
9
|
-
Requirements: local Pi interactive mode, Git, authenticated GitHub CLI (`gh`), and Claude or Muse
|
|
9
|
+
Requirements: local Pi interactive mode, Git, authenticated GitHub CLI (`gh`), and a configured review backend (Claude or Muse is recommended for untrusted PRs). Run `gh auth status` to check GitHub authentication; `/bro doctor` checks Bro's selected backend setup and shows an advisory when the review backend uses a shell-capable sandbox, without proving GitHub access or model connectivity.
|
|
10
10
|
|
|
11
11
|
```text
|
|
12
12
|
/bro guided-review https://github.com/OWNER/REPO/pull/123
|
|
@@ -20,12 +20,6 @@ A URL works even when your current workspace belongs to a different repository.
|
|
|
20
20
|
|
|
21
21
|
A **new** review captures the PR's base/head commits outside your working tree and automatically makes one model request. Subsequent questions each make another request. Calls use your selected backend CLI's account and billing—not Pi's model account. Bro does not automatically retry a failed generation or switch backends.
|
|
22
22
|
|
|
23
|
-
For fullscreen mouse scrolling, start Pi with:
|
|
24
|
-
|
|
25
|
-
```sh
|
|
26
|
-
pi --tui-mode fullscreen
|
|
27
|
-
```
|
|
28
|
-
|
|
29
23
|
Opening the **same PR again** restores its saved review without another model call. Bare `/bro guided-review` lists saved reviews; `/bro guided-review resume` remains an alias for that list.
|
|
30
24
|
|
|
31
25
|
**Reopening keeps the captured code.** It does not fetch a new comparison when the author pushes commits. Opening by URL/number checks current metadata and reports newer source, but continues the saved capture. The saved-review picker does not check freshness. Reviewing newer revisions is not implemented.
|
|
@@ -63,7 +57,7 @@ The generation header shows observable application stages and elapsed time—not
|
|
|
63
57
|
| Close | Save automatically and leave |
|
|
64
58
|
| Stop and close | Stop active work, await cancellation, save partial work, then leave |
|
|
65
59
|
|
|
66
|
-
|
|
60
|
+
The wheel scrolls the pane under the pointer without moving its list selection or keyboard focus, in regular and fullscreen mode. Reading an active answer pauses following; deliberately returning to the bottom resumes it. In regular terminal mode, Bro captures the mouse while the review is open (as its other windows do), so terminal scrollback and mouse text selection return when you close it; use the copy actions meanwhile.
|
|
67
61
|
|
|
68
62
|
## Ask privately, if needed
|
|
69
63
|
|
|
@@ -89,13 +83,15 @@ Use Overview → Regenerate guide only when you want a fresh explanation/assessm
|
|
|
89
83
|
|
|
90
84
|
## Access, privacy and storage
|
|
91
85
|
|
|
92
|
-
Review
|
|
86
|
+
Review never runs with full-access or bypass flags. **Claude and Muse provide strict file-only inspection** and are recommended for untrusted PRs: Claude runs with `--restricted`, Read/Grep/Glob only, `dontAsk`, safe mode and no MCP; Muse disables write, shell and web tools, foreign personal context and native session logs, without trusting repository rules. No model-run project tests, commands, Git or network tools are available on Claude or Muse.
|
|
87
|
+
|
|
88
|
+
**Codex, Grok and Agy run with shell available inside their own sandbox**, and each sandbox is different: Codex and Grok apply a read-only sandbox (`codex exec --sandbox read-only --ephemeral`, `grok --sandbox read-only --permission-mode dontAsk`), while Agy's `--sandbox` only restricts terminal commands and still lets them write inside the project. All three inspect the captured checkout with a 10-minute review deadline, and **none is shell-free**. When one of these backends is selected for review, Bro shows an advisory during acquisition, in the live review workspace, and in `/bro doctor` (as a non-fatal informational note). Set the **review** override to Claude or Muse in `/bro config` for untrusted PRs; saved reviews remain readable with any backend. Unsupported/older CLI flags fail visibly; there is no bypass fallback.
|
|
93
89
|
|
|
94
|
-
|
|
90
|
+
Captured evidence is read from pinned Git blobs, so a shell-capable backend that writes inside the checkout cannot alter the code shown as evidence — but it can still change what it later reads, so treat very large changes with suspicion when using Agy.
|
|
95
91
|
|
|
96
92
|
These controls reduce malicious-code execution/write risk, but repository content can still manipulate the model's conclusions. Captured content, questions and answers go to the provider; do not use review as a secrets boundary or approval certificate. CLI enforcement and managed host policies remain the backend's responsibility.
|
|
97
93
|
|
|
98
|
-
PR identity/description, diff, relevant saved discussion and your Bro preferences are sent to the selected backend. It can
|
|
94
|
+
PR identity/description, diff, relevant saved discussion and your Bro preferences are sent to the selected backend. It can inspect the captured source. Main-session conversation is not automatically attached. Each request reconstructs context; review does not resume BTW/native sessions. Claude, Muse and Codex disable native session persistence where their CLIs support it; backend/provider retention policies still apply.
|
|
99
95
|
|
|
100
96
|
Records, private text and captured source remain under:
|
|
101
97
|
|
|
@@ -112,7 +108,7 @@ One open writer per review is supported within a Pi process. Concurrent editing
|
|
|
112
108
|
| Problem | What to do |
|
|
113
109
|
| --- | --- |
|
|
114
110
|
| GitHub unavailable when reopening | Use bare `/bro guided-review` to choose a saved review; the picker does not fetch |
|
|
115
|
-
|
|
|
111
|
+
| Sandboxed shell review backend (Codex, Grok, Agy) | Advisory shown; choose Claude or Muse in `/bro config` for strict file-only inspection on untrusted PRs |
|
|
116
112
|
| Git/gh authentication or fetch error | Read the acquisition error; check Git/`gh auth status`; retry explicitly |
|
|
117
113
|
| Invalid/failed preparation | Changed files remain available; use Prepare guide to retry when ready for another call |
|
|
118
114
|
| Failed regeneration | Current guide is kept; retry only if you want another call |
|
|
@@ -22,6 +22,7 @@ Bro follows the host's `getAgentDir()`: normally `~/.pi/agent` on Pi and `~/.pig
|
|
|
22
22
|
|
|
23
23
|
- **PiG 0.3.0 RPC does not enforce `--exclude-tools`.** Excluded tools may remain active and reach provider requests. This is not a sandbox boundary. Use an explicit `--tools` allowlist instead; do not rely on `/bro doctor` to prove exclusion. Bro does not mask this defect by falsely reporting an active tool as unavailable.
|
|
24
24
|
- The smoke suite retains Pi's strict exclusion assertion. The PiG lane has an explicit version-specific expected failure; a changed result fails the lane so the exception must be reviewed/removed.
|
|
25
|
+
- Elevate is not yet qualified end-to-end on PiG. Interactive behavior, keyboard shortcut delivery and guarded editor insertion must be checked on PiG before claiming support.
|
|
25
26
|
- Guided Review currently targets local Pi interactive mode. Its capture/reading/question/regeneration journey is not qualified on PiG or RPC/Desktop; existing Bro PiG checks do not establish review support. See [current review scope](guided-review.md#not-available-yet).
|
|
26
27
|
- Mouse-wheel forwarding is not qualified; use keyboard scrolling.
|
|
27
28
|
- Remote/SSH OSC 52 clipboard forwarding is not qualified. Local clipboard behavior depends on the host and installed platform utilities.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Command reference
|
|
2
|
+
|
|
3
|
+
[Docs home](../README.md) · [All commands](commands.md) · [Safety and permissions](data-and-permissions.md)
|
|
4
|
+
|
|
5
|
+
## What Bro can explain
|
|
6
|
+
|
|
7
|
+
| Source | Command | What Bro does |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Latest assistant reply | `/bro` | Explains the latest completed reply without adding the result to the conversation. |
|
|
10
|
+
| Pasted text | `/bro text <text>` | Explains text supplied directly in the command. |
|
|
11
|
+
| Local document | `/bro file <path>` | Extracts text from a workspace-local Markdown, text, PDF, or DOCX file. |
|
|
12
|
+
| Public webpage | `/bro url <url>` | Fetches one public HTML page and extracts its main readable content. |
|
|
13
|
+
| Recent session turns | `/bro show` | Draws the last turns' conversation text as shapes instead of prose (tool calls, tool results, reasoning, and images are omitted). |
|
|
14
|
+
| Any of the above, auto-detected | `/bro <input>` | Routes a lone URL to the webpage reader, an existing workspace file with a supported extension to the document reader, and anything else to pasted text. |
|
|
15
|
+
|
|
16
|
+
Pressing **R** simplifies the captured source again in the mode shown, and
|
|
17
|
+
**M** re-simplifies it in the next mode. These commands capture a
|
|
18
|
+
new source: `/bro text`, `/bro file`, `/bro url`, and `/bro show`. Giving `/bro` a URL, path, or
|
|
19
|
+
text directly captures a new source the same way.
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
| Command | Description |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `/bro`, `/bro simplify`, or `/bro text` | Explain the latest completed assistant response. |
|
|
26
|
+
| `/bro text <text>` | Explain pasted text. |
|
|
27
|
+
| `/bro <input>` | Explain it directly: a lone URL runs the webpage reader, an existing workspace file with a supported extension runs the document reader, and anything else is pasted text. A quoted path with spaces is routed too when the file exists. |
|
|
28
|
+
| `/bro file <path>` | Explain a workspace-local `.md`, `.markdown`, `.txt`, `.pdf`, or `.docx` file. |
|
|
29
|
+
| `/bro url <url>` | Explain one public, text-based webpage. |
|
|
30
|
+
| `/bro open` | Reopen the latest explanation without calling the simplifier again. |
|
|
31
|
+
| `/bro show [n-turns] [query]` | Draw recent session turns (default last 1) as shapes instead of prose, from user and assistant conversation text only — tool calls, tool results, reasoning, and images are omitted. An optional query steers what the shapes focus on, with or without a leading turn count. |
|
|
32
|
+
| `/bro doctor` | Check Bro's settings, preferences, and each selected backend, with the effective backend/model/effort per feature. |
|
|
33
|
+
| `/bro mode [brief\|balanced\|faithful]` | View or choose the explanation mode. |
|
|
34
|
+
| `/bro preferences` | View or edit what Bro knows about you and how you like answers; see [Preferences](settings.md#preferences). |
|
|
35
|
+
| `/bro config` | Open settings for the shared backend/model/effort, explain mode, show turns, and per-capability (explain/show/btw/advisor/review) overrides. |
|
|
36
|
+
| `/bro guided-review <PR number or URL>` | Automatically explain and assess a captured PR in local Pi, with source evidence and optional private questions. Opening the same PR restores its saved review. |
|
|
37
|
+
| `/bro guided-review` | List saved reviews; `resume` is an alias. |
|
|
38
|
+
| `/bro elevate [request]` | Improve an assignment before execution. Discover up to five gaps, choose useful findings, and insert a revised request without submitting it. **Ctrl+Shift+E** can use your unsent draft. See [Elevate](../elevate.md). |
|
|
39
|
+
| `/bro btw [question]` | Open a side conversation in a modal, seeded with recent main-session context. Starts conversation-only; type `/mode` inside to toggle full permission (read and edit the workspace) without losing the thread. |
|
|
40
|
+
| `/bro advisor` | Quick notice of whether the executor's `bro_advisor` tool is available right now, pointing at `/bro config`, `/bro advisor-steer`, and `/bro doctor`. |
|
|
41
|
+
| `/bro advisor-steer` | View, edit, save, or clear the one persistent steering brief the advisor always sees. |
|
|
42
|
+
| `/bro help` | Open the built-in quick reference. |
|
|
43
|
+
|
|
44
|
+
Giving `/bro` the input directly works the same way:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
/bro https://example.com/article
|
|
48
|
+
/bro docs/report.pdf
|
|
49
|
+
/bro any other text is explained as pasted text
|
|
50
|
+
```
|