pi-bro 0.24.0 → 0.25.1
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 +36 -0
- package/README.md +29 -15
- package/docs/README.md +32 -14
- package/docs/elevate.md +125 -0
- package/docs/examples.md +268 -0
- package/docs/features/advisor.md +65 -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/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 +50 -900
- package/package.json +12 -3
- package/src/advisor.ts +72 -144
- package/src/backend.ts +4 -5
- package/src/bro.ts +25 -0
- package/src/elevate-engine.ts +214 -0
- package/src/elevate.ts +597 -0
- package/src/explain-modal.ts +12 -6
- package/src/modal-kit.ts +35 -2
- package/src/prompt.ts +3 -3
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
- **Snapshot first, workspace tools when needed**: the advisor process has real
|
|
29
|
+
tool access in the workspace with permissions auto-approved — there is no
|
|
30
|
+
enforced read-only isolation. It is instructed to rely on the captured
|
|
31
|
+
snapshot (including its tool calls and results) first, inspect the workspace
|
|
32
|
+
only when something is missing or a key claim is in doubt, and return advice
|
|
33
|
+
while leaving edits to the executor. That boundary is a behavioral prompt
|
|
34
|
+
instruction rather than an enforced sandbox constraint, so treat its findings
|
|
35
|
+
as advice to verify, not a guaranteed hands-off review.
|
|
36
|
+
- **Steering**: The advisor reads standing priorities from `~/.pi/agent/bro-advisor.md`
|
|
37
|
+
and session-specific priorities from `/bro advisor-steer`.
|
|
38
|
+
`/bro advisor-steer` opens an editor for one session steering brief — e.g. "quick
|
|
39
|
+
prototype; keep A and B careful, everything else minimal". Session steering takes
|
|
40
|
+
precedence over durable standing defaults where they conflict.
|
|
41
|
+
**Ctrl+S** saves and keeps the editor open; **Enter** or **Shift+Enter** inserts
|
|
42
|
+
a newline; **Ctrl+K** clears both the saved session brief and draft while staying open;
|
|
43
|
+
**Ctrl+C** copies the entire current draft, including unsaved edits; and **Esc**
|
|
44
|
+
closes without saving unsaved edits. Neither steering source is **ever added to Pi's
|
|
45
|
+
conversation or sent to the main model** — the advisor is the only thing that reads them.
|
|
46
|
+
- **Persistence**: standing defaults persist across all sessions in `~/.pi/agent/bro-advisor.md`.
|
|
47
|
+
The session steering brief persists with the Pi session as custom extension data in the
|
|
48
|
+
session file (`bro-advisor-steering`) and is restored on resume or reload. Forking a
|
|
49
|
+
session inherits session steering; edits made after the fork are independent of the
|
|
50
|
+
original branch. Clearing session steering leaves durable steering intact.
|
|
51
|
+
- **Single attempt, no automatic retries**: each consultation runs once (the
|
|
52
|
+
advisor CLI is asked to stop at 10 minutes; Bro's host deadline is 610
|
|
53
|
+
seconds plus bounded process cleanup). Any backend failure, timeout, or
|
|
54
|
+
cancellation is returned immediately — including a context-length error,
|
|
55
|
+
verbatim — without waiting or restarting the consultation from scratch.
|
|
56
|
+
- **Progress and provenance**: while a consultation is running, Bro shows the last
|
|
57
|
+
thing the advisor actually reported — a tool name or a user-facing response
|
|
58
|
+
line, never hidden reasoning — and how long ago it arrived, e.g. `last
|
|
59
|
+
reported: Read src/app.ts (2s ago)`, or "awaiting first activity" before
|
|
60
|
+
anything arrives. Expanding a running consultation shows up to the last 4
|
|
61
|
+
reported activity lines. The returned answer starts with backend, model,
|
|
62
|
+
effort, duration, workspace, steering presence, snapshot size, and known
|
|
63
|
+
omission/compaction notes; the advisor's complete answer follows unchanged.
|
|
64
|
+
- **Model/effort**: resolved the same way as explain/show/btw, through
|
|
65
|
+
`/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.
|
|
@@ -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
|
+
```
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Backend access, privacy and retention
|
|
2
|
+
|
|
3
|
+
[Docs home](../README.md) · [All commands](commands.md) · [Safety and permissions](data-and-permissions.md)
|
|
4
|
+
|
|
5
|
+
## Backends: access and retention
|
|
6
|
+
|
|
7
|
+
Bro uses each CLI's own account and billing route, never Pi provider
|
|
8
|
+
credentials, and does not copy credentials or rewrite backend configuration.
|
|
9
|
+
Each backend and your model provider may retain sessions, logs, and request
|
|
10
|
+
data under their own settings and policies.
|
|
11
|
+
|
|
12
|
+
| | Explain / show | BTW conversation-only | BTW full permission | Advisor | Guided Review |
|
|
13
|
+
| --- | --- | --- | --- | --- | --- |
|
|
14
|
+
| **Agy** | Temporary directory, Agy sandbox | Temporary directory, Agy sandbox | Workspace, permissions bypassed | Fresh workspace process, permissions bypassed | Captured checkout, Agy sandbox (shell and in-project writes allowed; advisory) |
|
|
15
|
+
| **Claude Code** | Scratch directory, tools/MCP/skills disabled, no session persistence | Workspace, tools disabled | Workspace, permissions bypassed | Fresh workspace process, permissions bypassed | Restricted Read/Grep/Glob only; confined checkout, no persistence |
|
|
16
|
+
| **Grok** | Temporary directory, **prompt instruction only** | Workspace, **prompt instruction only** | Workspace, permissions bypassed | Fresh workspace process, permissions bypassed | Captured checkout, read-only sandbox (shell-enabled; advisory) |
|
|
17
|
+
| **Codex** | Scratch directory, read-only sandbox, ephemeral session | Workspace, read-only sandbox | Workspace, approvals and sandbox bypassed | Fresh workspace process, approvals and sandbox bypassed | Captured checkout, read-only sandbox, ephemeral (shell-enabled; advisory) |
|
|
18
|
+
| **Muse** | Scratch directory, approval/write/shell disabled, no session log | Workspace, approval/write/shell disabled | Workspace, permissions bypassed (`--yolo`) | Fresh workspace process, permissions bypassed (`--yolo`) | Captured checkout; writes/shell/web disabled, no session log |
|
|
19
|
+
|
|
20
|
+
- Grok always runs explain, show, btw and the advisor with its sandbox off and
|
|
21
|
+
permissions bypassed; its tools, hooks, skills, plugins, and MCP may remain
|
|
22
|
+
available. "Answer only from the supplied context" is a request, not an
|
|
23
|
+
enforced restriction. Guided Review is the exception: it runs with
|
|
24
|
+
`--sandbox read-only --permission-mode dontAsk` but still executes shell
|
|
25
|
+
commands inside that sandbox.
|
|
26
|
+
- Codex's read-only sandbox is not a tool-free mode: workspace reads and
|
|
27
|
+
sandboxed commands remain available, including for Guided Review. Bro does
|
|
28
|
+
not disable configured MCP servers or web search; their access is governed
|
|
29
|
+
by Codex configuration.
|
|
30
|
+
- Agy's Guided Review runs under `--sandbox`, which restricts terminal
|
|
31
|
+
commands but still permits writes inside the project; it has no file-only
|
|
32
|
+
tool filter.
|
|
33
|
+
- Muse's restricted mode disables write and shell tools and approval prompts,
|
|
34
|
+
not all tools: workspace reads and web tools remain available without approval.
|
|
35
|
+
It is not a tool-free or network-isolated mode.
|
|
36
|
+
- Claude's restrictions are tool/configuration settings (with safe mode), not
|
|
37
|
+
an OS sandbox; built-in and managed Claude behavior can remain. Running a
|
|
38
|
+
permission-bypassing mode as root may be rejected by Claude.
|
|
39
|
+
- BTW continues natively: Agy by conversation ID, Claude and Grok by
|
|
40
|
+
`--resume`, Codex by `resume`, and Muse by `--session-id` of the same session,
|
|
41
|
+
including across `/mode` switches. An Agy conversation stays bound to the
|
|
42
|
+
workspace it started in, so after a `/mode` switch — or whenever a thread
|
|
43
|
+
has turns but no native session ID — Bro starts a fresh native session
|
|
44
|
+
seeded with the main-session context and every earlier turn.
|
|
45
|
+
- Cancellation, deadlines, and invalid output streams stop the backend's
|
|
46
|
+
process group on POSIX, escalating after a five-second grace period. On
|
|
47
|
+
Windows only the direct child is targeted. Detached shell work or external
|
|
48
|
+
services a backend started are not contained. Bro removes its private
|
|
49
|
+
temporary prompt files.
|
|
50
|
+
|
|
51
|
+
### Configuration precedence
|
|
52
|
+
|
|
53
|
+
When resolving backend, model, and reasoning effort:
|
|
54
|
+
1. **Per-capability override**: `overrides.<capability>` (`explain`, `show`, `btw`, `advisor`, or `review`) pins that capability's complete selection.
|
|
55
|
+
2. **Shared default**: otherwise the capability inherits `default` (root `model`/`effort` in older flat files).
|
|
56
|
+
3. **Agy catalog normalization**: for Agy selections, Bro maps suffixed variant IDs and handles fixed-effort models.
|
|
57
|
+
4. **Initial file creation only**: `PI_BRO_MODEL` has no effect once the settings file exists.
|
|
58
|
+
|
|
59
|
+
When resolving turn count for `/bro show`:
|
|
60
|
+
1. **Command argument**: an explicit count like `/bro show 3` or `/bro show 1 query` overrides for that run.
|
|
61
|
+
2. **Saved setting**: `showTurns` (defaults to 1).
|
|
62
|
+
|
|
63
|
+
When shaping an answer, each part has one owner:
|
|
64
|
+
|
|
65
|
+
| Part | Decided by |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| Bro's source rules: quoted source treated as data, no added facts, Show's traceability rules, BTW access mode | Built in; nothing overrides them |
|
|
68
|
+
| How much of the source an explanation keeps | The mode: **M** for one explanation, otherwise the saved `mode` |
|
|
69
|
+
| What a Show drawing focuses on | The steering query |
|
|
70
|
+
| Who the answer is for: wording, tone, depth, and answer language | Your [preferences](settings.md#preferences), otherwise Bro's built-in defaults |
|
|
71
|
+
|
|
72
|
+
## Privacy and safety
|
|
73
|
+
|
|
74
|
+
- **External requests**: Bro sends the latest completed assistant response,
|
|
75
|
+
pasted text, extracted document text, extracted webpage text, or recent
|
|
76
|
+
session conversation text (tool calls, tool results, reasoning, and images
|
|
77
|
+
omitted) to the selected backend and its configured model provider.
|
|
78
|
+
- **Elevate requests**: `/bro elevate` sends your objective, preferences, and all user/assistant text on the current branch by default, without a fixed history cap. Its visible Context switch can include tool-call arguments and text results (Full), potentially including sensitive file contents or command output. Both modes exclude hidden reasoning and image binaries. Only explicit Retry after a context-overload error trims older history; the UI discloses reduced context. Its optional rewrite call includes only approved findings. It makes fresh restricted calls through the BTW model setting, but a backend's restricted mode is not a universal file/network sandbox (Grok restrictions are prompt-only). It does not insert or submit anything to Pi unless you approve insertion. In the terminal, insertion can replace the draft Elevate was opened on, if it is unchanged; an explicit `/bro elevate <request>` requires an empty editor. See the [Elevate guide](../elevate.md).
|
|
79
|
+
- **Side conversation requests**: `/bro btw` sends your side questions and the
|
|
80
|
+
seeded main-session conversation text (plus earlier turns when a native
|
|
81
|
+
session is reseeded) to the selected backend. In full permission mode the
|
|
82
|
+
side agent can additionally read and edit the workspace.
|
|
83
|
+
- **Guided Review requests**: PR identity/description, captured diff, relevant private discussion and preferences go to the selected backend, which can inspect captured files. Main-session context is not attached. Claude (`--restricted`, file tools only) and Muse (write/shell/web disabled) use strict file-only inspection and are recommended for untrusted PRs. Codex and Grok inspect the captured checkout under a read-only sandbox; Agy's `--sandbox` still allows in-project writes. All three run shell commands and show an advisory. Prompt injection can still corrupt conclusions or reveal captured content to the provider; this is not a general confidentiality guarantee. See [Guided Review access and storage](../guided-review.md#access-privacy-and-storage).
|
|
84
|
+
- **Preferences**: `bro-preferences.md` is sent with every explain, Show,
|
|
85
|
+
BTW, Elevate, and Guided Review request to the selected backend. It is never sent to the advisor or
|
|
86
|
+
to Pi's main model.
|
|
87
|
+
- **Advisor requests**: `bro_advisor` sends the executor agent's system
|
|
88
|
+
instructions, active tool list (excluding `bro_advisor`), ordered
|
|
89
|
+
conversation history including tool calls and tool results (unlike Show,
|
|
90
|
+
which omits them), your steering brief, and the executor's optional question
|
|
91
|
+
to the selected backend. Reasoning and image bodies are omitted with explicit
|
|
92
|
+
markers (`[reasoning omitted]`, `[image omitted]`). The advisor process runs
|
|
93
|
+
in your workspace with auto-approved permissions; its instruction to only
|
|
94
|
+
advise is behavioral, not an enforced boundary.
|
|
95
|
+
- **Access enforcement** differs by backend; see
|
|
96
|
+
[Backends: access and retention](data-and-permissions.md#backends-access-and-retention). Prompt
|
|
97
|
+
instructions are not access enforcement.
|
|
98
|
+
- **Context isolation**: Bro does not add explanations, BTW answers, or the
|
|
99
|
+
steering brief to Pi's conversation history or main-agent context. BTW text
|
|
100
|
+
reaches the main editor only through `/insert` or `/insert-all`, and advisor
|
|
101
|
+
results appear as normal tool results in the executor's transcript.
|
|
102
|
+
- **Saved reviews**: Guided Review records, questions, drafts and captured Git source persist under the host's `getAgentDir()/bro-reviews/`. No automatic cleanup or sync is provided; see [storage and removal](../guided-review.md#access-privacy-and-storage).
|
|
103
|
+
- **Memory**: the latest explanation (for `/bro open`) and the BTW thread live
|
|
104
|
+
only in process memory and clear when you switch Pi sessions, reload
|
|
105
|
+
extensions, or quit Pi. Backend-native sessions can persist independently.
|
|
106
|
+
Standing advisor priorities are stored in `~/.pi/agent/bro-advisor.md`, and
|
|
107
|
+
the session steering brief is stored as session-scoped extension data
|
|
108
|
+
(`bro-advisor-steering`) in the session file.
|
|
109
|
+
- **File safety**: `/bro file` reads only regular files whose resolved path is
|
|
110
|
+
inside Pi's current workspace, including after resolving symlinks. Bro's
|
|
111
|
+
extractor does not modify them.
|
|
112
|
+
- **Web requests**: `/bro url` connects directly to the target website. The site
|
|
113
|
+
sees your IP address and Bro's user agent. Bro sends no browser cookies,
|
|
114
|
+
authorization, or referrer information, and it refuses local, private, and
|
|
115
|
+
reserved network destinations, including redirects. Avoid private or signed
|
|
116
|
+
URLs whose query string contains secrets.
|
|
117
|
+
- **Web extraction**: Bro parses downloaded HTML locally without executing page
|
|
118
|
+
scripts or loading page subresources. It sends the extracted readable text,
|
|
119
|
+
including links preserved in that text, to the selected backend; it does not
|
|
120
|
+
separately send the requested URL or raw page HTML.
|
|
121
|
+
- **Show diagrams**: When a show reply ends in one self-contained HTML block
|
|
122
|
+
or one Mermaid sequence diagram, Bro writes a page to
|
|
123
|
+
`pi-bro-<uid>/bro-show-<hash>.html` in your system temp folder with a
|
|
124
|
+
restrictive Content-Security-Policy, and opens it in your browser only when
|
|
125
|
+
you press **O**. HTML pages run no scripts. Sequence-diagram pages run only
|
|
126
|
+
Bro's bundled Mermaid and its fixed setup script; the model's diagram text is
|
|
127
|
+
inserted as escaped text and nothing is loaded from the network. **C**
|
|
128
|
+
copies the full reply, including the diagram source.
|
|
129
|
+
- **Clipboard**: **C**, `/copy`, `/copy-all`, and Guided Review's Copy finding copy text to your system
|
|
130
|
+
clipboard, where your operating system or clipboard manager may retain it.
|