pi-bro 0.24.0 → 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.
@@ -1,1015 +1,165 @@
1
1
  # pi-bro user guide
2
2
 
3
- The full reference for every Bro command. Start with the
4
- [README](../README.md) for requirements, install and a quick tour; come back
5
- here for details.
6
-
7
- **Contents:**
8
- [What Bro can explain](#what-bro-can-explain) ·
9
- [Commands](#commands) ·
10
- [Explanation modes](#explanation-modes) ·
11
- [Guided Review](#guided-review) ·
12
- [Bro btw](#bro-btw-side-conversation) ·
13
- [Bro advisor](#bro-advisor) ·
14
- [Bro show](#bro-show) ·
15
- [Examples](#bro-in-action) ·
16
- [Pasted text](#explain-pasted-text) ·
17
- [Documents](#explain-a-document) ·
18
- [Webpages](#explain-a-webpage) ·
19
- [Doctor](#check-your-setup) ·
20
- [Settings](#settings) ·
21
- [Backends: access and retention](#backends-access-and-retention) ·
22
- [Preferences](#preferences) ·
23
- [Privacy and safety](#privacy-and-safety) ·
24
- [Troubleshooting and limits](#troubleshooting-and-current-limits)
3
+ Find help by goal at the [docs home](README.md).
25
4
 
26
- ## What Bro can explain
5
+ - [Getting started](getting-started.md) — install and a first working example.
6
+ - [Command reference](reference/commands.md) — complete commands and controls.
7
+ - [Model settings and preferences](reference/settings.md).
8
+ - [Backend access, privacy and retention](reference/data-and-permissions.md).
9
+ - [Troubleshooting](reference/troubleshooting.md).
10
+
11
+ The sections below retain previous guide anchors so existing links and bookmarks still lead to the right task page. Detailed instructions have moved, not been removed.
27
12
 
28
- | Source | Command | What Bro does |
29
- | --- | --- | --- |
30
- | Latest assistant reply | `/bro` | Explains the latest completed reply without adding the result to the conversation. |
31
- | Pasted text | `/bro text <text>` | Explains text supplied directly in the command. |
32
- | Local document | `/bro file <path>` | Extracts text from a workspace-local Markdown, text, PDF, or DOCX file. |
33
- | Public webpage | `/bro url <url>` | Fetches one public HTML page and extracts its main readable content. |
34
- | 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). |
35
- | 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. |
13
+ ## What Bro can explain
36
14
 
37
- Pressing **R** simplifies the captured source again in the mode shown, and
38
- **M** re-simplifies it in the next mode. These commands capture a
39
- new source: `/bro text`, `/bro file`, `/bro url`, and `/bro show`. Giving `/bro` a URL, path, or
40
- text directly captures a new source the same way.
15
+ See [What Bro can explain](reference/commands.md#what-bro-can-explain).
41
16
 
42
17
  ## Commands
43
18
 
44
- | Command | Description |
45
- | --- | --- |
46
- | `/bro`, `/bro simplify`, or `/bro text` | Explain the latest completed assistant response. |
47
- | `/bro text <text>` | Explain pasted text. |
48
- | `/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. |
49
- | `/bro file <path>` | Explain a workspace-local `.md`, `.markdown`, `.txt`, `.pdf`, or `.docx` file. |
50
- | `/bro url <url>` | Explain one public, text-based webpage. |
51
- | `/bro open` | Reopen the latest explanation without calling the simplifier again. |
52
- | `/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. |
53
- | `/bro doctor` | Check Bro's settings, preferences, and each selected backend, with the effective backend/model/effort per feature. |
54
- | `/bro mode [brief\|balanced\|faithful]` | View or choose the explanation mode. |
55
- | `/bro preferences` | View or edit what Bro knows about you and how you like answers; see [Preferences](#preferences). |
56
- | `/bro config` | Open settings for the shared backend/model/effort, explain mode, show turns, and per-capability (explain/show/btw/advisor/review) overrides. |
57
- | `/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. |
58
- | `/bro guided-review` | List saved reviews; `resume` is an alias. |
59
- | `/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. |
60
- | `/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`. |
61
- | `/bro advisor-steer` | View, edit, save, or clear the one persistent steering brief the advisor always sees. |
62
- | `/bro help` | Open the built-in quick reference. |
63
-
64
- Giving `/bro` the input directly works the same way:
65
-
66
- ```text
67
- /bro https://example.com/article
68
- /bro docs/report.pdf
69
- /bro any other text is explained as pasted text
70
- ```
19
+ See [Commands](reference/commands.md#commands).
71
20
 
72
21
  ## Explanation modes
73
22
 
74
- Bro treats the source as data, rejects embedded instructions, preserves its
75
- language (unless your [preferences](#preferences) name another), and avoids
76
- adding facts, advice, or conclusions in every mode. Choose
77
- a persistent mode with `/bro mode`, or press **M** in an explanation to try the
78
- next mode without saving it:
79
-
80
- - **`brief`**: Uses the original audience-led ELI-simpleton prompt with no fixed
81
- word target.
82
- - **`balanced`**: The default. Keeps important details, conditions, warnings,
83
- context, code, and formatting while trimming fluff and repetition.
84
- - **`faithful`**: Simplifies the language while preserving every claim,
85
- qualification, warning, number, command, code block, and formatting choice.
23
+ See [Explanation modes](features/explain.md#explanation-modes).
86
24
 
87
25
  ### Modal controls
88
26
 
89
- - **Mouse wheel / trackpad**: Scroll in regular or fullscreen mode
90
- - **↑ / ↓**: Scroll in any mode
91
- - **PgUp / PgDn**: Scroll a page at a time (also in btw)
92
- - **C**: Copy the complete explanation
93
- - **R**: Simplify the captured source again in the mode shown, or run the
94
- current Doctor check again
95
- - **M**: Re-simplify the captured source in the next mode (brief → balanced →
96
- faithful → brief). It applies to this explanation only and does not change
97
- the mode saved by `/bro mode`; pressing it again while Bro is working skips
98
- ahead
99
- - **O**: Open the diagram (an HTML layout or a rendered sequence diagram) when a show reply contains one
100
- - **Esc**: Close the modal, or cancel while Bro is working
101
-
102
- The modal header shows the model and reasoning effort the explanation or
103
- drawing used (`default` when the model's own effort applies), followed by the
104
- explanation mode, and `prefs` when your [preferences](#preferences) shaped the
105
- result; `/bro open` keeps the original labels, mode, and tag.
106
-
107
- Bro temporarily captures mouse input while its modal is open. Native mouse
108
- selection may be unavailable or visually extend outside the modal depending on
109
- your terminal mode; press **C** to copy the complete explanation reliably.
110
-
27
+ See [Explanation modes](features/explain.md#explanation-modes).
111
28
 
112
29
  ## Guided Review
113
30
 
114
- **Open a PR → read and investigate → leave when satisfied.** Bro automatically
115
- prepares an explanation and quality assessment with captured code, ranked
116
- findings and suggested fixes/checks. Asking private questions is optional.
117
- Nothing is automatically applied or posted to GitHub.
118
-
119
- ```text
120
- /bro guided-review https://github.com/OWNER/REPO/pull/123
121
- ```
122
-
123
- Local Pi interactive mode, Git, authenticated `gh`, and a configured review backend
124
- (Claude or Muse is recommended for untrusted PRs). A new review makes a model call
125
- using that backend's account.
126
- Opening the same PR restores its saved review without another model call.
127
- Bare `/bro guided-review` lists saved reviews (`resume` is an alias).
128
-
129
- Contents holds Overview, topics, Findings, Coverage, Changed files and Your
130
- questions. Enter opens an item or focuses contextual actions; Enter on a
131
- highlighted action activates it. Tab changes focus. Esc goes back, then closes
132
- from Contents. Your work is saved automatically; **Close** leaves normally,
133
- and **Stop and close** cancels active work before saving and leaving.
134
-
135
- Optional conveniences:
136
- - **Copy finding** copies its text to the system clipboard; nothing is submitted.
137
- - **Regenerate guide** makes a confirmed model call about the **same captured
138
- revision**. Success replaces the guide while retaining original private
139
- discussion context; failure keeps it. It does not fetch later commits.
140
-
141
- Reopening also keeps the captured revision, even after the author pushes.
142
- Findings are model suggestions, not approval; citations show real locations,
143
- not proof of the conclusion. Claude and Muse use strict file-only inspection
144
- (shell, writes and web tools disabled). Codex and Grok use a read-only sandbox;
145
- Agy's sandbox only restricts terminal commands and still allows writes inside
146
- the project. All three run shell commands, and an advisory says so.
147
- Claude or Muse is recommended for untrusted PRs; choose a review override in
148
- `/bro config`. Saved reviews remain readable with any selection. Repository
149
- text can still mislead the model; sandboxing and tool restrictions are not
150
- proof of its conclusions.
151
- The wheel scrolls the pane under the pointer in regular and fullscreen mode.
152
-
153
- See the [Guided Review guide](guided-review.md) for controls, calls and
154
- costs, source freshness, access/privacy, local storage, recovery and current
155
- scope. Notes, examination tracking, branch/update review and feedback delivery
156
- are not implemented.
31
+ See [Guided Review](guided-review.md#guided-review).
32
+
33
+ ## Bro Elevate — improve a task before sending it
34
+
35
+ See [Elevate: Discover → Select → Upgrade](elevate.md). Elevate does not execute a task or send it to the main agent. It helps find gaps, lets you approve suggestions, then offers a revised request. In the terminal, insertion can replace your unchanged original draft; see the [editor-safety rules](elevate.md#what-happens-to-the-original-editor-draft).
157
36
 
158
37
  ## Bro btw (side conversation)
159
38
 
160
- `/bro btw` opens a separate multi-turn conversation in a modal, so you can ask
161
- a quick side question while the main agent keeps working. It runs through the
162
- selected backend and never adds anything to Pi's conversation unless you
163
- explicitly insert it into the editor. Bro writes for a tired reader: the point
164
- first, in plain words, at a length that fits the question, in the language you
165
- asked in.
166
-
167
- - `/bro btw <question>` asks immediately; `/bro btw` opens an empty thread.
168
- Reopening keeps the thread and its mode.
169
- - **Two modes, toggled with `/mode`**: a new thread starts
170
- **conversation-only**; type `/mode` in the modal to switch to **full
171
- permission** (read and edit the workspace, run commands) and again to switch
172
- back. The conversation is kept across switches. How conversation-only is
173
- enforced depends on the backend — see
174
- [Backends: access and retention](#backends-access-and-retention).
175
- - Every new or cleared thread is seeded with up to the last 8 turns of
176
- main-session user/assistant conversation text (40,000 characters max, with a
177
- truncation notice). Later turns continue the backend's native session; in
178
- full permission mode the side agent can also read the repo itself.
179
- - **In the modal**: type a question and press Enter (empty Enter re-asks the
180
- last question). Composer actions trigger only on these exact commands:
181
- - `/mode`: toggles conversation-only / full permission, keeping the thread
182
- - `/copy`: copies the latest answer to the system clipboard
183
- - `/copy-all`: copies the full thread to the system clipboard
184
- - `/insert`: inserts the latest answer into the main editor without submitting
185
- - `/insert-all`: inserts the full thread into the main editor without submitting
186
- - `/retry`: re-asks the last question (empty Enter does the same)
187
- - `/clear`: resets the thread
188
-
189
- `/insert` and `/insert-all` never replace an existing main-editor draft:
190
- edit or clear it first. Any other text, including other slash-prefixed input
191
- such as `/send`, is sent as a question. Esc closes the modal and stops a
192
- running turn; the thread is kept. The view follows the newest text while you
193
- are at the bottom; scroll up to read earlier turns. The header shows the model and reasoning effort the latest
194
- turn used (`default` when the model's own effort applies) and the current
195
- mode.
196
- - A turn is capped at 2 minutes in conversation-only mode and 10 minutes in
197
- full permission mode.
198
- - Bro's thread lives in memory only — it clears when you switch Pi sessions,
199
- reload extensions, or quit Pi. Changing the BTW backend starts a fresh
200
- thread; native session IDs never cross backends.
39
+ See [Bro btw (side conversation)](features/btw.md#bro-btw-side-conversation).
201
40
 
202
41
  ## Bro advisor
203
42
 
204
- `bro_advisor` is a tool the **executor agent** — not you — can voluntarily
205
- call mid-task for a second opinion. Unlike `/bro btw`, which is a side
206
- conversation for you, `bro_advisor` is a tool for the model you're working
207
- with; it shows up as a normal tool call/result in the transcript, not a
208
- modal. It is registered like any other tool when the extension loads and has
209
- no on/off switch of its own — whether the executor can actually call it
210
- depends entirely on this host's own tool restrictions.
211
-
212
- `/bro advisor` is a quick notice of whether `bro_advisor` is available right
213
- now, pointing at `/bro config`, `/bro advisor-steer`, and `/bro doctor`.
214
- `/bro doctor` has the full diagnostic: whether this host exposes and
215
- activates `bro_advisor`, its resolved backend/model/effort, steering
216
- presence, and backend compatibility (for Agy, a minimum CLI version with an
217
- `agy update` action when it is too old).
218
-
219
- - **Automatic context, no prep needed**: the executor does not need to assemble
220
- a summary. Bro captures a harness-neutral snapshot — the executor's system
221
- instructions, its active tools, and the conversation so far including tool
222
- calls and results — and sends it, along with an optional `question` the
223
- executor may pass, to a **fresh, standalone process of the selected
224
- backend** for every consultation. Nothing is resumed or reused across calls,
225
- including retries.
226
- - **Instructed to investigate, not implement**: the advisor process has real
227
- tool access in the workspace with permissions auto-approved — there is no
228
- enforced read-only isolation. It is instructed to verify claims itself and
229
- return advice, leaving edits to the executor, but that boundary is a
230
- behavioral prompt instruction rather than an enforced sandbox constraint, so
231
- treat its findings as advice to verify, not a guaranteed hands-off review.
232
- - **Steering**: The advisor reads standing priorities from `~/.pi/agent/bro-advisor.md`
233
- and session-specific priorities from `/bro advisor-steer`.
234
- `/bro advisor-steer` opens an editor for one session steering brief — e.g. "quick
235
- prototype; keep A and B careful, everything else minimal". Session steering takes
236
- precedence over durable standing defaults where they conflict.
237
- **Ctrl+S** saves and keeps the editor open; **Enter** or **Shift+Enter** inserts
238
- a newline; **Ctrl+K** clears both the saved session brief and draft while staying open;
239
- **Ctrl+C** copies the entire current draft, including unsaved edits; and **Esc**
240
- closes without saving unsaved edits. Neither steering source is **ever added to Pi's
241
- conversation or sent to the main model** — the advisor is the only thing that reads them.
242
- - **Persistence**: standing defaults persist across all sessions in `~/.pi/agent/bro-advisor.md`.
243
- The session steering brief persists with the Pi session as custom extension data in the
244
- session file (`bro-advisor-steering`) and is restored on resume or reload. Forking a
245
- session inherits session steering; edits made after the fork are independent of the
246
- original branch. Clearing session steering leaves durable steering intact.
247
- - **Retries**: on an invocation failure (not a completed answer — "I need
248
- more evidence" is a normal result, not a failure), Bro retries with the
249
- identical snapshot, steering, and question: once after 5 seconds, once more
250
- after 10 seconds, then returns the backend's own diagnostic — including a
251
- context-length error, verbatim — as the failure. Host-imposed deadlines and
252
- cancellation are terminal: neither starts another attempt or a backoff wait.
253
- The advisor CLI is asked to stop at 10 minutes; Bro's host deadline is 610
254
- seconds plus bounded process cleanup. A CLI-reported error before that host
255
- deadline remains an invocation failure and can be retried.
256
- Cancelling the tool call skips any pending retry wait.
257
- - **Progress and provenance**: while an attempt is running, Bro shows the last
258
- thing the advisor actually reported — a tool name or a user-facing response
259
- line, never hidden reasoning — and how long ago it arrived, e.g. `last
260
- reported: Read src/app.ts (2s ago)`, or "awaiting first activity" before
261
- anything arrives. Expanding a running consultation shows up to the last 4
262
- reported activity lines; each retry starts the trail over. The returned
263
- answer starts with backend, model, effort, attempt count, duration,
264
- workspace, steering presence, snapshot size, and known omission/compaction
265
- notes; the advisor's complete answer follows unchanged.
266
- - **Model/effort**: resolved the same way as explain/show/btw, through
267
- `/bro config` (shared default or per-capability override).
43
+ See [Bro advisor](features/advisor.md#bro-advisor).
268
44
 
269
45
  ## Bro show
270
46
 
271
- Where the explanation modes rewrite dense prose in simpler words, `/bro show`
272
- changes the form: it draws what you and the assistant said in the last few
273
- session turns as a shape instead of paragraphs. Capture keeps only user and
274
- assistant conversation text, including every intermediate assistant message in
275
- a turn — tool calls, tool results, reasoning, and images never leave the
276
- session. It runs the same backend-specific model call and shows the result
277
- in the same modal, never touching your conversation. `/bro show` uses its own
278
- draw prompt; the explanation modes do not affect it. Your
279
- [preferences](#preferences) can change only its wording and language, never
280
- which shapes it draws or its rules.
281
-
282
- Because the draw model only ever sees conversation text, its shapes reflect
283
- what was *reported* in the conversation — what the assistant said it did or
284
- found — not an independent check against the actual code or system state.
285
-
286
- Shapes are terminal-first: pseudocode, call trees, file trees, component
287
- trees, diffs, and types and signatures. Bro picks the shape from what
288
- happened in the session; there is no flag to request a specific one. When the source has no code structure
289
- to draw, Bro falls back to a plain outline instead of forcing a diagram. A
290
- reply that ends in one self-contained HTML block — layout, a state comparison,
291
- anything where position itself carries meaning — is written to a file and
292
- opened with **O**.
293
-
294
- When the turns describe messages passing among three or more participants in
295
- a set order (for example browser → API → database), a reply can instead end in
296
- one Mermaid `sequenceDiagram`. The modal keeps its source visible with
297
- `[Diagram saved — press O to render]`; **O** opens a page that draws it with
298
- the Mermaid copy bundled in Bro. Any other Mermaid stays plain text.
299
-
300
- Pressing **R** redraws the same captured turns; running `/bro show` again
301
- captures the latest turns afresh. `/bro show <n-turns>` overrides the default turn
302
- count for a single run.
303
-
304
- Add a query to steer what the shapes focus on, either after a turn count or on
305
- its own: `/bro show what changed in the auth flow`, or `/bro show 3 what
306
- changed in the auth flow`. The query is used as a lens on the captured turns,
307
- not as additional evidence, and its casing is preserved as typed. Pressing
308
- **R** retries with the same turn count and query.
309
-
310
- Any leading whitespace-delimited word that looks like a number is treated as the
311
- requested turn count: for example, `/bro show 3 what changed` captures 3 turns
312
- and steers on "what changed", while `/bro show 404 handler` parses "404" as the
313
- turn count and "handler" as the steering query. To steer on a phrase that starts
314
- with digits while choosing a turn count, specify the turn count explicitly
315
- first: `/bro show 1 404 handler` captures 1 turn and steers on "404 handler".
316
- If the first word is not a number, the whole input is treated as the steering
317
- query using the saved `showTurns` default.
47
+ See [Bro show](features/show.md#bro-show).
318
48
 
319
49
  ### A slow session-create, traced
320
50
 
321
- The agent followed a two-second delay from the handler down to the worker.
322
- `/bro show` drew the chain:
323
-
324
- ```text
325
- handleCreateSession(req)
326
- ├── validateRequest(req)
327
- ├── SessionStore.insert(req.body)
328
- └── publish('session.created')
329
- └── AgentWorker.run(sessionId)
330
- ├── loadContext(sessionId)
331
- ├── callModel(context)
332
- └── persistResult(sessionId, result)
333
- ```
51
+ See [Bro show](features/show.md#bro-show).
334
52
 
335
53
  ### The shape of code before it exists
336
54
 
337
- A design discussion agreed on the data model ahead of implementation. `/bro
338
- show` kept just the shape:
339
-
340
- ```typescript
341
- interface Item { id: ItemId; parentId: ItemId | null }
342
- interface Cursor { position: ItemId; direction: 'up' | 'down' }
343
- function resolveTarget(items: Item[], cursor: Cursor): ItemId | null
344
- ```
55
+ See [Bro show](features/show.md#bro-show).
345
56
 
346
57
  ### A layout that collapses at narrow widths
347
58
 
348
- Text can't show a before/after layout change at a glance, so Bro ends with one
349
- self-contained HTML block and **O** opens it (the terminal first shows
350
- `[HTML diagram saved — press O to open]`):
351
-
352
- <p align="center">
353
- <a href="https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-show-layout.png">
354
- <img alt="A before/after dashboard grid" src="https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-show-layout.png" width="720">
355
- </a>
356
- </p>
357
-
358
- <details>
359
- <summary><strong>More shapes</strong></summary>
360
-
361
- **Diff** — what changed in the save handler:
362
-
363
- ```diff
364
- on(save)
365
- - write content
366
- + if content is unchanged
367
- + return cached result
368
- + write new content
369
- + invalidate cache
370
- ```
371
-
372
- **File layout** — where everything lives, for a refactor:
373
-
374
- ```text
375
- src/
376
- ├── commands/ # user intents
377
- │ ├── registry.ts
378
- │ └── show-me.ts
379
- ├── sessions/ # state and lifecycle
380
- │ ├── events.ts
381
- │ ├── store.ts
382
- │ └── worker.ts
383
- ├── transport/ # API
384
- │ ├── client.ts
385
- │ └── stream.ts
386
- └── config.ts # root config
387
- ```
388
-
389
- **Component tree** — what the session page renders:
390
-
391
- ```text
392
- SessionPage (apps/example/src/routes/session.tsx)
393
- ├── [hook] useSessionEvents
394
- ├── SessionToolbar (packages/ui)
395
- │ └── RunSkillButton
396
- └── SessionTimeline (packages/ui)
397
- └── SkillResultCard
398
- ```
399
-
400
- **Pseudocode** — how scroll capture and restore work:
401
-
402
- ```text
403
- capture(blocks, targetRect, scrollRect) -> Snapshot:
404
- target = focusedBlock ?? firstBlockIntersectingViewportTop(blocks)
405
- anchor = wholeBlockAnchor(blocks, target)
406
- offset = targetRect.top - scrollRect.top
407
- return { anchor, offset, scrollTop, revision + 1 }
408
-
409
- restore(snapshot, blocks) -> number:
410
- placement = resolveAnchor(blocks, snapshot.anchor)
411
- if placement: return scrollRect.top + targetRect.top - snapshot.offset
412
- return snapshot.scrollTop
413
- ```
414
-
415
- </details>
416
-
417
- Prose in, outline out: a purely conversational session with no code to draw
418
- degrades to a plain outline of the discussion — never a forced diagram.
59
+ See [Bro show](features/show.md#bro-show).
419
60
 
420
61
  ## Bro in action
421
62
 
422
- ### Assistant response
423
-
424
- **Before `/bro`: the original agent response**
63
+ See [Bro in action](examples.md#bro-in-action).
425
64
 
426
- [![A dense assistant response before Bro](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-response-before.png)](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-response-before.png)
427
-
428
- **After `/bro`: the plain-language explanation**
65
+ ### Assistant response
429
66
 
430
- [![The assistant response explained in the Bro modal](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-response-after.png)](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-response-after.png)
67
+ See [Bro in action](examples.md#bro-in-action).
431
68
 
432
69
  ### Local document
433
70
 
434
- **Before: a complex PDF**
435
-
436
- [![A complex PDF before Bro](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-file-before.png)](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-file-before.png)
437
-
438
- **After `/bro file <path>`**
439
-
440
- [![The PDF explained in the Bro modal](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-file-after.png)](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-file-after.png)
441
-
442
- Bro optimizes for understanding, not simply for fewer words. The written
443
- examples below are synthetic and were run through Bro's default prompt. Click
444
- a screenshot to see it at full size.
445
-
446
- <details>
447
- <summary><strong>Short:</strong> TypeScript says a value is <code>never</code></summary>
71
+ See [Bro in action](examples.md#bro-in-action).
448
72
 
449
73
  ### Before
450
74
 
451
- > The diagnostic is not evidence that `result` is intrinsically uninhabitable; it is an artifact of TypeScript's intraprocedural control-flow graph. Because `result` is initialized to `null` and only assigned inside the `forEach` callback, the outer scope does not model that callback as definitely executing. After `if (!result) return`, the remaining branch therefore collapses to `never`, producing the property-access error. Replace the callback-driven mutation with a control-flow-visible loop: `for (const item of items) { if (matches(item)) { result = item; break; } }`. Alternatively, derive the value expressionally with `const result = items.find(matches);` and guard `if (!result) return;` before dereferencing it. Avoid an `as Result` assertion; it suppresses the symptom while preserving the unsound state transition that caused the narrowing anomaly.
75
+ See [the first example's walkthrough](examples.md#bro-in-action).
452
76
 
453
77
  ### After `/bro`
454
78
 
455
79
  #### What happened
456
80
 
457
- TypeScript showed an error saying your variable `result` cannot be used or
458
- accessed.
459
-
460
- This happened because `result` was set to `null` outside a `forEach` loop and
461
- then modified inside the loop's helper function (callback). TypeScript tracks
462
- code line by line. It cannot guarantee that code inside a `forEach` callback
463
- will actually run.
81
+ See [What happened](examples.md#what-happened).
464
82
 
465
83
  #### What it means
466
84
 
467
- Because TypeScript assumes the loop's callback might not run:
468
-
469
- 1. It believes `result` might still be `null`.
470
- 2. When you check `if (!result) return`, TypeScript thinks `result` can never
471
- hold a valid value after that check.
472
- 3. It sets the type of `result` to `never` (a special type meaning "impossible
473
- value") and blocks you from reading its properties.
474
-
475
- The error is a limitation in how TypeScript analyzes loops with callbacks.
85
+ See [What it means](examples.md#what-it-means).
476
86
 
477
87
  #### What you should do next
478
88
 
479
- Choose one of these two fixes:
480
-
481
- **Option 1: Use a standard `for...of` loop**
482
-
483
- ```ts
484
- for (const item of items) {
485
- if (matches(item)) {
486
- result = item;
487
- break;
488
- }
489
- }
490
- ```
491
-
492
- **Option 2: Use `Array.prototype.find`**
493
-
494
- ```ts
495
- const result = items.find(matches);
496
- if (!result) return;
497
- ```
498
-
499
- Avoid using a type assertion like `as Result`. It only hides the warning
500
- without fixing the underlying tracking issue.
501
-
502
- </details>
503
-
504
- <details>
505
- <summary><strong>Medium:</strong> Login succeeds, but the user is still logged out</summary>
89
+ See [What you should do next](examples.md#what-you-should-do-next).
506
90
 
507
91
  ### Before
508
92
 
509
- > What you're observing is almost certainly not an authentication failure in the credential-validation layer; it is a post-authentication session persistence failure caused by an environment-dependent mismatch between Express's transport-security inference and the TLS termination topology in production.
510
- >
511
- > Locally, Express sees the request as plain HTTP and your development cookie configuration probably permits a non-secure session cookie. In production, however, the browser connects over HTTPS to Nginx, a load balancer, or an ingress controller, which terminates TLS and forwards the request to Node over HTTP. Unless Express trusts that intermediary, `req.secure` remains `false`, even when the proxy sends `X-Forwarded-Proto: https`. With `cookie.secure: true`, `express-session` can consequently decline to emit the cookie because it believes the originating request was insecure. The login route may still return `200`, making the credentials appear accepted, but the next request has no session identifier and is treated as anonymous.
512
- >
513
- > Configure proxy trust before registering session middleware, and make the cookie policy reflect whether the frontend and API are same-site or genuinely cross-site:
514
- >
515
- > ```js
516
- > app.set("trust proxy", 1);
517
- >
518
- > app.use(session({
519
- > secret: process.env.SESSION_SECRET,
520
- > resave: false,
521
- > saveUninitialized: false,
522
- > proxy: true,
523
- > cookie: {
524
- > httpOnly: true,
525
- > secure: true,
526
- > sameSite: "lax",
527
- > maxAge: 1000 * 60 * 60 * 24
528
- > }
529
- > }));
530
- > ```
531
- >
532
- > Use `sameSite: "none"` instead of `"lax"` only when the browser must send the cookie in a cross-site context, such as a frontend and API on unrelated registrable domains. Browsers require `Secure` when `SameSite=None`, so that combination must remain HTTPS-only. Separate subdomains such as `app.example.com` and `api.example.com` are usually same-site, though they are still cross-origin.
533
- >
534
- > Also verify that the proxy explicitly forwards `X-Forwarded-Proto`, that the browser receives a `Set-Cookie` response header, and that frontend requests use `credentials: "include"` when crossing origins. If CORS is involved, the server must return the exact allowed origin plus `Access-Control-Allow-Credentials: true`; a wildcard origin is incompatible with credentialed requests.
535
- >
536
- > Avoid setting a cookie `domain` unless sharing across subdomains is intentional. A host-only cookie is safer and eliminates another production-only failure mode.
93
+ See [the second example](examples.md#bro-in-action).
537
94
 
538
95
  ### After `/bro`
539
96
 
540
97
  #### What happened
541
98
 
542
- Your username and password check succeeded, and the login route returned `200
543
- OK`. However, the browser did not receive or return a usable session cookie in
544
- production.
99
+ See [What happened](examples.md#what-happened-1).
545
100
 
546
101
  #### What it means
547
102
 
548
- In production, secure web traffic (HTTPS) hits an intermediary, such as a load
549
- balancer or Nginx, before reaching your Node/Express app as plain HTTP.
550
-
551
- Because your session cookie requires HTTPS (`secure: true`), Express may withhold
552
- it when it does not trust the proxy forwarding the request. The exact trust
553
- setting must match your deployment's proxy topology.
103
+ See [What it means](examples.md#what-it-means-1).
554
104
 
555
105
  #### What you should do next
556
106
 
557
- 1. Configure Express to trust only your actual proxy topology. Put this before
558
- the session setup. For example, use `1` only when there is exactly one trusted
559
- proxy hop:
560
-
561
- ```js
562
- app.set("trust proxy", 1);
563
-
564
- app.use(session({
565
- secret: process.env.SESSION_SECRET,
566
- resave: false,
567
- saveUninitialized: false,
568
- cookie: {
569
- httpOnly: true,
570
- secure: true,
571
- sameSite: "lax",
572
- maxAge: 1000 * 60 * 60 * 24
573
- }
574
- }));
575
- ```
576
-
577
- 2. Check your cookie settings:
578
- - Keep `sameSite: "lax"` if your frontend and backend share the same main
579
- domain, such as `app.example.com` and `api.example.com`.
580
- - Use `sameSite: "none"` only when the cookie must be sent cross-site.
581
- Browsers require `secure: true` with this setting.
582
- - Avoid defining a custom cookie `domain` unless you deliberately need to
583
- share cookies across subdomains.
584
-
585
- 3. Verify the proxy, browser, and CORS settings:
586
- - Ensure the proxy forwards the `X-Forwarded-Proto` header.
587
- - Check that the response contains a `Set-Cookie` header.
588
- - Include `credentials: "include"` in cross-origin frontend requests.
589
- - Return the exact allowed origin with
590
- `Access-Control-Allow-Credentials: true`. Do not use a wildcard (`*`) for
591
- credentialed requests.
592
-
593
- </details>
594
-
595
- <details>
596
- <summary><strong>Long:</strong> A CI build fails only when its cache is restored</summary>
107
+ See [What you should do next](examples.md#what-you-should-do-next-1).
597
108
 
598
109
  ### Before
599
110
 
600
- > The failure is not a nondeterministic pnpm installation problem, despite the misleading first error being emitted from the test runner immediately after dependency hydration. It is a state-contamination problem at the intersection of the repository cache, the package export map, and an incorrectly scoped cache key. The decisive observation is that the same commit succeeds in a clean checkout and in CI when cache restoration is disabled, but fails when the pre-build workspace cache is restored. That isolates the variable to files materialized outside Git rather than source, Node, or runner image drift.
601
- >
602
- > The affected package, `@acme/config`, was recently migrated from a dual CommonJS/ESM build to an ESM-oriented TypeScript output. Its root `package.json` declares `"type": "module"` and maps the `import` condition to `./dist/index.js`, while the legacy `require` condition still maps to `./dist/index.cjs`. The current compiler emits `index.js` but does not remove the previous build directory first. An older cached `dist` directory therefore contributes two files that no longer belong to the current build graph: `dist/index.cjs` and `dist/package.json`, the latter declaring `"type": "commonjs"`. The new compiler overlays `dist/index.js` but leaves both obsolete files intact. Because nested package boundaries override the root package type, Node interprets the newly emitted ESM `index.js` as CommonJS in that restored workspace and reports `Unexpected token 'export'`. Test processes entering through `require()` instead resolve the obsolete `index.cjs`, which references a removed chunk and can instead produce `MODULE_NOT_FOUND`. These apparently different errors are two projections of the same dirty-output condition.
603
- >
604
- > The cache configuration makes that contaminated state persistent. The workflow computes the key with `hashFiles('packages/**/pnpm-lock.yaml')`, but this workspace has only the root-level `pnpm-lock.yaml`. GitHub Actions consequently evaluates the hash expression to an empty value, yielding a key equivalent to `Linux-node20-workspace-`. A broad restore key then permits an archive produced before the module-format migration to satisfy the lookup. That archive combines the pnpm content-addressable store, Turborepo metadata, and every package's `dist` directory. Those data classes do not share valid invalidation semantics: pnpm store entries are immutable by content, Turborepo artifacts are task-hash addressed, and arbitrary build directories are mutable snapshots whose correctness depends on complete deletion or exact provenance. Treating them as one cache effectively elevates obsolete untracked files into undeclared build inputs.
605
- >
606
- > The evidence is visible by comparing the restored and clean workspaces before compilation. In the failing job, `packages/config/dist/package.json` exists with `"type":"commonjs"` and `packages/config/dist/index.cjs` has a timestamp and checksum predating the current commit. Neither file appears after `git clean -ffdx` followed by installation and build. The Actions cache log also shows the truncated key without a lockfile digest, while `git diff` remains empty because the problematic files are ignored. Finally, deleting only `packages/config/dist` before rerunning the unchanged test command converts the failure to a pass, which excludes dependency resolution and network variability as primary causes.
607
- >
608
- > The minimal durable remediation has three parts. First, stop caching package output directories. Cache the pnpm store separately, using a key that includes the actual root lockfile:
609
- >
610
- > ```yaml
611
- > key: ${{ runner.os }}-node20-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
612
- > restore-keys: |
613
- > ${{ runner.os }}-node20-pnpm-
614
- > ```
615
- >
616
- > A broad fallback is acceptable for the pnpm store because pnpm validates content-addressed entries; it is not acceptable for mutable `dist` snapshots. If remote or local Turborepo caching is retained, cache only `.turbo` and allow Turbo's task hash to govern artifact reuse rather than wrapping raw workspace outputs in a generic archive.
617
- >
618
- > Second, make every package build replace, rather than merge into, its output directory. `@acme/config` should delete `dist` before invoking `tsc`, `tsup`, or the existing bundler. The CI workflow should also run the repository's recursive clean target before the first build as a defense against future cache or runner reuse. This is not a substitute for fixing cache scope, but it restores the invariant that generated output is a function of the checked-out sources and declared toolchain.
619
- >
620
- > Third, make the export contract agree with emitted files. If `@acme/config` is intentionally ESM-only, remove the `require` condition and the obsolete CommonJS metadata. If CommonJS consumers remain supported, restore an explicit CJS build that deterministically emits `dist/index.cjs`; do not let a historical artifact impersonate that support. In either case, package publication should reject export targets that do not exist.
621
- >
622
- > Verification should exercise both cache states and both module entry paths. Run the full pipeline once with no cache, save only the corrected caches, and rerun the identical commit expecting a cache hit and the same result. Inspect the built package to confirm the nested CommonJS `package.json` and legacy chunks are absent unless intentionally generated. Add a lightweight smoke check using dynamic `import('@acme/config')`; if CommonJS remains supported, add a second check through `createRequire`. Finally, change the root lockfile and confirm the logged cache key changes. That matrix validates clean-build reproducibility, restored-cache reproducibility, export-map coherence, and dependency-cache invalidation independently rather than relying on a single green run.
111
+ See [the third example](examples.md#bro-in-action).
623
112
 
624
113
  ### After `/bro`
625
114
 
626
115
  #### What happened
627
116
 
628
- Your build failed because old files were left behind by a broken cache (a saved
629
- snapshot of previous build files).
630
-
631
- The package `@acme/config` recently switched its module format to modern
632
- JavaScript (ESM). However, the build process did not delete the old output
633
- folder (`dist`) before creating new files.
634
-
635
- Because the GitHub Actions setting searches the wrong path
636
- (`hashFiles('packages/**/pnpm-lock.yaml')`), GitHub could not find the root
637
- `pnpm-lock.yaml`. It restored an outdated cache containing `dist/index.cjs` and
638
- a `dist/package.json` configured for older JavaScript (CommonJS). The new build
639
- wrote some files but left the old ones behind, confusing Node and causing errors
640
- such as `Unexpected token 'export'` and `MODULE_NOT_FOUND`.
641
-
642
- A clean checkout without the cache succeeds. This proves the problem is old
643
- cached files, not your source code or dependencies.
117
+ See [What happened](examples.md#what-happened-2).
644
118
 
645
119
  #### What it means
646
120
 
647
- - **Cache contamination:** The CI workflow restores mutable `dist` folders
648
- alongside package-manager files, mixing obsolete files into new builds.
649
- - **Mismatched module settings:** The package says it supports both modern
650
- (`import`) and legacy (`require`) formats, but it only builds the modern one
651
- while relying on leftover cached files for the legacy one.
121
+ See [What it means](examples.md#what-it-means-2).
652
122
 
653
123
  #### What you should do next
654
124
 
655
- 1. **Fix the GitHub Actions cache:** Stop caching `dist` folders. Cache only the
656
- pnpm store, using the root lockfile:
657
-
658
- ```yaml
659
- key: ${{ runner.os }}-node20-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
660
- restore-keys: |
661
- ${{ runner.os }}-node20-pnpm-
662
- ```
663
-
664
- If you use Turborepo, cache only `.turbo`.
665
-
666
- 2. **Clean output folders before building:** Make `@acme/config` delete `dist`
667
- before running `tsc`, `tsup`, or the bundler. Run the repository's recursive
668
- clean command before CI builds.
669
-
670
- 3. **Update the package exports:**
671
- - If `@acme/config` is ESM-only, remove the `require` entry and old CommonJS
672
- metadata.
673
- - If CommonJS is still needed, add a real build step for `dist/index.cjs`.
674
-
675
- 4. **Verify the fix:**
676
- - Delete the generated `packages/config/dist` folder, then run a clean build.
677
- Do not use `git clean -ffdx` in a working copy with files you need.
678
- - Run the workflow without a cache, save the new cache, and rerun the same
679
- commit to verify that a cache hit also passes.
680
- - Test `import('@acme/config')`, and test `createRequire` if CommonJS is
681
- supported.
682
-
683
- </details>
125
+ See [What you should do next](examples.md#what-you-should-do-next-2).
684
126
 
685
127
  ## Explain pasted text
686
128
 
687
- Paste text directly after the command:
688
-
689
- ```text
690
- /bro text OAuth refresh tokens are rotated after every successful use.
691
- ```
692
-
693
- Bro explains the pasted text instead of the latest assistant reply. With no text
694
- after `/bro text`, it falls back to the latest completed reply. Press **R**
695
- to simplify the same captured text again.
129
+ See [Explain pasted text](features/explain.md#explain-pasted-text).
696
130
 
697
131
  ## Explain a document
698
132
 
699
- Use a path relative to Pi's current workspace, or an absolute path inside it:
700
-
701
- ```text
702
- /bro file "docs/incident review.pdf"
703
- ```
704
-
705
- Paths may contain spaces; matching single or double quotes are also accepted.
706
- Bro extracts text locally, then sends that text through the same explanation
707
- flow used by `/bro`. Pressing **R** retries the extracted snapshot; running a
708
- new `/bro file <path>` command reads the file again.
709
-
710
- Files are limited to 10 MiB and 100,000 extracted characters. Scanned PDFs are
711
- not supported because Bro does not perform OCR.
133
+ See [Explain a document](features/explain.md#explain-a-document).
712
134
 
713
135
  ## Explain a webpage
714
136
 
715
- Pass one public HTTP or HTTPS page:
716
-
717
- ```text
718
- /bro url https://example.com/complicated-article
719
- ```
720
-
721
- Bro fetches the page, extracts its main readable text locally, and sends only
722
- that text through the existing explanation flow. The completed modal shows the
723
- final website and page title. Pressing **R** retries the captured page without
724
- fetching again; running a new `/bro url <url>` command fetches a fresh copy.
725
-
726
- The first version is intentionally limited to one public, text-based page. It
727
- does not use browser cookies, sign in, run page JavaScript, bypass paywalls or
728
- bot protection, load complete discussion threads, follow pagination, or
729
- understand images and video. Pages that depend on those features may fail.
730
-
731
- If Bro cannot read a page, copy its content into a `.txt` or `.md` file, or save
732
- it as a PDF, then use `/bro file <path>`.
733
-
137
+ See [Explain a webpage](features/explain.md#explain-a-webpage).
734
138
 
735
139
  ## Check your setup
736
140
 
737
- Run `/bro doctor` when Bro is newly installed or something is not working. It
738
- checks Bro's settings and preferences, then probes only the backends some feature
739
- actually selects, and reports the effective backend/model/effort for each
740
- feature. Failed checks explain what to fix.
741
-
742
- - **Agy**: installed version, model catalog, and account access.
743
- - **Claude Code**: installed version and configured authentication.
744
- - **Grok**: installed version only; authentication and connectivity are not
745
- verified.
746
- - **Codex**: installed version and configured authentication.
747
- - **Muse**: installed version only; authentication and connectivity are not
748
- verified.
749
-
750
- Doctor never sends source text or runs a model completion. A successful check
751
- confirms the setup but cannot guarantee that a later provider request will
752
- succeed.
141
+ See [Check your setup](reference/troubleshooting.md#check-your-setup).
753
142
 
754
143
  ## Settings
755
144
 
756
- Use `/bro config` to review or change the shared default backend/model/effort
757
- and any per-capability (explain/show/btw/advisor/review) overrides, the explanation
758
- mode, and the default show turn count. Changes save immediately. Esc inside a
759
- picker cancels that pick; Esc on the settings screen closes it, keeping
760
- whatever was already saved. If the terminal becomes too small, config blocks
761
- hidden actions; Esc closes config even if a picker was open, after pending saves
762
- finish. A failed save cancels that close and shows its error inline; if the error
763
- alone makes config too small, any other key clears it so you can try again. `/bro mode` changes the mode directly (**M** in an explanation
764
- tries another mode without saving it), and `/bro help` shows the active settings
765
- and file path.
766
-
767
- Settings live in this user-editable file, created when the extension loads
768
- (under `$PI_CODING_AGENT_DIR` instead when that is set):
769
-
770
- ```text
771
- ~/.pi/agent/bro-settings.json
772
- ```
773
-
774
- ```json
775
- {
776
- "version": 2,
777
- "default": { "backend": "agy", "model": "gemini-3.7-flash", "effort": "low" },
778
- "mode": "balanced",
779
- "showTurns": 1,
780
- "overrides": {
781
- "explain": { "backend": "claude", "model": "sonnet", "effort": "medium" },
782
- "advisor": { "backend": "grok", "model": "grok-4.7", "effort": "high" }
783
- }
784
- }
785
- ```
786
-
787
- Bro reads the file again before each request, so manual edits apply next time.
788
-
789
- - Each selection is one atomic backend/model/effort choice. An override pins
790
- its own complete selection and ignores the shared default, even when it
791
- happens to match it; select **Default** in `/bro config` to inherit again.
792
- Omitted overrides inherit `default`.
793
- - `effort` must be one the backend offers (`default` omits it and lets the
794
- model decide). Agy selections are normalized against Agy's installed model
795
- catalog. Claude, Grok, Codex, and Muse accept seeded or custom model IDs; a model/effort
796
- combination the account does not support fails with the backend's own error
797
- instead of silently falling back.
798
- - `mode` is `brief`, `balanced` (the default), or `faithful`. `showTurns` is
799
- the default number of turns `/bro show` draws (default 1); `/bro show
800
- <n-turns>` overrides it for one run.
801
- - `PI_BRO_MODEL` picks the initial Agy model only when Bro creates a missing
802
- settings file, for example `PI_BRO_MODEL=gemini-3.7-flash-low pi`.
803
- - Older flat settings files (root `model`/`effort`) still load and mean Agy.
145
+ See [Settings](reference/settings.md#settings).
804
146
 
805
147
  ## Backends: access and retention
806
148
 
807
- Bro uses each CLI's own account and billing route, never Pi provider
808
- credentials, and does not copy credentials or rewrite backend configuration.
809
- Each backend and your model provider may retain sessions, logs, and request
810
- data under their own settings and policies.
811
-
812
- | | Explain / show | BTW conversation-only | BTW full permission | Advisor | Guided Review |
813
- | --- | --- | --- | --- | --- | --- |
814
- | **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) |
815
- | **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 |
816
- | **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) |
817
- | **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) |
818
- | **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 |
819
-
820
- - Grok always runs explain, show, btw and the advisor with its sandbox off and
821
- permissions bypassed; its tools, hooks, skills, plugins, and MCP may remain
822
- available. "Answer only from the supplied context" is a request, not an
823
- enforced restriction. Guided Review is the exception: it runs with
824
- `--sandbox read-only --permission-mode dontAsk` but still executes shell
825
- commands inside that sandbox.
826
- - Codex's read-only sandbox is not a tool-free mode: workspace reads and
827
- sandboxed commands remain available, including for Guided Review. Bro does
828
- not disable configured MCP servers or web search; their access is governed
829
- by Codex configuration.
830
- - Agy's Guided Review runs under `--sandbox`, which restricts terminal
831
- commands but still permits writes inside the project; it has no file-only
832
- tool filter.
833
- - Muse's restricted mode disables write and shell tools and approval prompts,
834
- not all tools: workspace reads and web tools remain available without approval.
835
- It is not a tool-free or network-isolated mode.
836
- - Claude's restrictions are tool/configuration settings (with safe mode), not
837
- an OS sandbox; built-in and managed Claude behavior can remain. Running a
838
- permission-bypassing mode as root may be rejected by Claude.
839
- - BTW continues natively: Agy by conversation ID, Claude and Grok by
840
- `--resume`, Codex by `resume`, and Muse by `--session-id` of the same session,
841
- including across `/mode` switches. An Agy conversation stays bound to the
842
- workspace it started in, so after a `/mode` switch — or whenever a thread
843
- has turns but no native session ID — Bro starts a fresh native session
844
- seeded with the main-session context and every earlier turn.
845
- - Cancellation, deadlines, and invalid output streams stop the backend's
846
- process group on POSIX, escalating after a five-second grace period. On
847
- Windows only the direct child is targeted. Detached shell work or external
848
- services a backend started are not contained. Bro removes its private
849
- temporary prompt files.
149
+ See [Backends: access and retention](reference/data-and-permissions.md#backends-access-and-retention).
850
150
 
851
151
  ### Configuration precedence
852
152
 
853
- When resolving backend, model, and reasoning effort:
854
- 1. **Per-capability override**: `overrides.<capability>` (`explain`, `show`, `btw`, `advisor`, or `review`) pins that capability's complete selection.
855
- 2. **Shared default**: otherwise the capability inherits `default` (root `model`/`effort` in older flat files).
856
- 3. **Agy catalog normalization**: for Agy selections, Bro maps suffixed variant IDs and handles fixed-effort models.
857
- 4. **Initial file creation only**: `PI_BRO_MODEL` has no effect once the settings file exists.
858
-
859
- When resolving turn count for `/bro show`:
860
- 1. **Command argument**: an explicit count like `/bro show 3` or `/bro show 1 query` overrides for that run.
861
- 2. **Saved setting**: `showTurns` (defaults to 1).
862
-
863
- When shaping an answer, each part has one owner:
864
-
865
- | Part | Decided by |
866
- | --- | --- |
867
- | Bro's source rules: quoted source treated as data, no added facts, Show's traceability rules, BTW access mode | Built in; nothing overrides them |
868
- | How much of the source an explanation keeps | The mode: **M** for one explanation, otherwise the saved `mode` |
869
- | What a Show drawing focuses on | The steering query |
870
- | Who the answer is for: wording, tone, depth, and answer language | Your [preferences](#preferences), otherwise Bro's built-in defaults |
153
+ See [Backends: access and retention](reference/data-and-permissions.md#backends-access-and-retention).
871
154
 
872
155
  ## Preferences
873
156
 
874
- Tell Bro about yourself and how you like answers. Bro adds what you write to
875
- every explain, `/bro show`, `/bro btw`, and Guided Review prompt as a labelled section,
876
- alongside its own instructions. It never replaces them: modes, **M**, and the
877
- source rules keep working. The advisor never receives your preferences; use
878
- `/bro advisor-steer` for it.
879
-
880
- Run `/bro preferences` to edit them: **Ctrl+S** saves, **Ctrl+K** deletes the
881
- file, **Ctrl+C** copies, and **Esc** closes without saving. The first time,
882
- the editor opens with this starter text, which is not saved until you press
883
- **Ctrl+S**:
884
-
885
- ```md
886
- ## About me
887
- I'm an overworked white-collar worker, and so are my colleagues. By the end of a
888
- hard day our brains are fried and we can only handle simple language, no matter
889
- how sharp we are at our best.
890
-
891
- ## How I like answers
892
- - Explain it like I'm a simpleton: plain, everyday words.
893
- - Go easy on analogies. No forced ones.
894
- ```
895
-
896
- You can also edit the file directly (under `$PI_CODING_AGENT_DIR` instead when
897
- that is set):
898
-
899
- ```text
900
- ~/.pi/agent/bro-preferences.md
901
- ```
902
-
903
- - **Free-form**: no placeholder or structure is required. Bro re-reads the
904
- file on every request, so edits apply next time. A missing or empty file
905
- means no preferences, and Bro's prompts are then exactly the built-in ones.
906
- - **What preferences can change**: wording, tone, technical depth, length in
907
- BTW, and the answer language. If you name a language, code, commands, paths,
908
- names, and numbers still stay exactly as written. In `/bro show`,
909
- preferences only change wording and language. Guided Review also receives preferences for explanation/answer wording; they do not override its evidence or review rules. A per-run choice (the mode,
910
- **M**, a Show steering query, or what a BTW/review question asks for) wins over a
911
- standing preference.
912
- - **Limit**: 4,000 characters, because the text goes with every request. A
913
- longer file stops explain, Show, BTW, and Guided Review with an error until you trim it;
914
- Bro never cuts it silently. `/bro doctor` reports the problem, and the
915
- editor still opens the file so you can fix it.
916
- - **BTW threads**: when your preferences change, the next side question starts
917
- a fresh backend session that is caught up on the thread, so old preferences
918
- don't linger.
919
-
920
- `bro-prompt.md`, the full prompt template from earlier versions, is no longer
921
- read. Move what you want to keep into `/bro preferences`, and choose
922
- `/bro mode brief` for the original ELI-simpleton instruction.
923
-
157
+ See [Preferences](reference/settings.md#preferences).
924
158
 
925
159
  ## Privacy and safety
926
160
 
927
- - **External requests**: Bro sends the latest completed assistant response,
928
- pasted text, extracted document text, extracted webpage text, or recent
929
- session conversation text (tool calls, tool results, reasoning, and images
930
- omitted) to the selected backend and its configured model provider.
931
- - **Side conversation requests**: `/bro btw` sends your side questions and the
932
- seeded main-session conversation text (plus earlier turns when a native
933
- session is reseeded) to the selected backend. In full permission mode the
934
- side agent can additionally read and edit the workspace.
935
- - **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).
936
- - **Preferences**: `bro-preferences.md` is sent with every explain, Show,
937
- BTW, and Guided Review request to the selected backend. It is never sent to the advisor or
938
- to Pi's main model.
939
- - **Advisor requests**: `bro_advisor` sends the executor agent's system
940
- instructions, active tool list (excluding `bro_advisor`), ordered
941
- conversation history including tool calls and tool results (unlike Show,
942
- which omits them), your steering brief, and the executor's optional question
943
- to the selected backend. Reasoning and image bodies are omitted with explicit
944
- markers (`[reasoning omitted]`, `[image omitted]`). The advisor process runs
945
- in your workspace with auto-approved permissions; its instruction to only
946
- advise is behavioral, not an enforced boundary.
947
- - **Access enforcement** differs by backend; see
948
- [Backends: access and retention](#backends-access-and-retention). Prompt
949
- instructions are not access enforcement.
950
- - **Context isolation**: Bro does not add explanations, BTW answers, or the
951
- steering brief to Pi's conversation history or main-agent context. BTW text
952
- reaches the main editor only through `/insert` or `/insert-all`, and advisor
953
- results appear as normal tool results in the executor's transcript.
954
- - **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).
955
- - **Memory**: the latest explanation (for `/bro open`) and the BTW thread live
956
- only in process memory and clear when you switch Pi sessions, reload
957
- extensions, or quit Pi. Backend-native sessions can persist independently.
958
- Standing advisor priorities are stored in `~/.pi/agent/bro-advisor.md`, and
959
- the session steering brief is stored as session-scoped extension data
960
- (`bro-advisor-steering`) in the session file.
961
- - **File safety**: `/bro file` reads only regular files whose resolved path is
962
- inside Pi's current workspace, including after resolving symlinks. Bro's
963
- extractor does not modify them.
964
- - **Web requests**: `/bro url` connects directly to the target website. The site
965
- sees your IP address and Bro's user agent. Bro sends no browser cookies,
966
- authorization, or referrer information, and it refuses local, private, and
967
- reserved network destinations, including redirects. Avoid private or signed
968
- URLs whose query string contains secrets.
969
- - **Web extraction**: Bro parses downloaded HTML locally without executing page
970
- scripts or loading page subresources. It sends the extracted readable text,
971
- including links preserved in that text, to the selected backend; it does not
972
- separately send the requested URL or raw page HTML.
973
- - **Show diagrams**: When a show reply ends in one self-contained HTML block
974
- or one Mermaid sequence diagram, Bro writes a page to
975
- `pi-bro-<uid>/bro-show-<hash>.html` in your system temp folder with a
976
- restrictive Content-Security-Policy, and opens it in your browser only when
977
- you press **O**. HTML pages run no scripts. Sequence-diagram pages run only
978
- Bro's bundled Mermaid and its fixed setup script; the model's diagram text is
979
- inserted as escaped text and nothing is loaded from the network. **C**
980
- copies the full reply, including the diagram source.
981
- - **Clipboard**: **C**, `/copy`, `/copy-all`, and Guided Review's Copy finding copy text to your system
982
- clipboard, where your operating system or clipboard manager may retain it.
161
+ See [Privacy and safety](reference/data-and-permissions.md#privacy-and-safety).
983
162
 
984
163
  ## Troubleshooting and current limits
985
164
 
986
- If an explanation fails, run `/bro doctor` first. If a webpage cannot be
987
- extracted, copy its content into a supported text file or save it as a PDF and
988
- use `/bro file`. If a PDF contains only scanned images, run OCR with another
989
- tool before giving it to Bro.
990
-
991
- - An unsupported model, effort, or missing backend fails with that backend's
992
- diagnostic; Bro never falls back to another backend.
993
- - Document input supports `.md`, `.markdown`, `.txt`, `.pdf`, and `.docx` only;
994
- it does not perform OCR.
995
- - Webpage input supports one public HTML page, up to 5 MiB downloaded and
996
- 100,000 extracted characters. JavaScript-only, authenticated, paywalled,
997
- blocked, paginated, and media-first pages are not supported.
998
- - Direct webpage fetching does not currently use `HTTP_PROXY`, `HTTPS_PROXY`,
999
- or other proxy environment variables.
1000
- - `/bro btw` threads are memory-only and do not survive reloads or restarts.
1001
- - The Agy advisor requires Agy CLI `>=1.1.15`.
1002
- - Show captures only the conversation text of what already happened in the
1003
- current session — the last few turns' user and assistant messages, with
1004
- tool calls, tool results, reasoning, and images always omitted; its shapes
1005
- reflect what was reported in the conversation, not independent verification.
1006
- - Diagrams open in your default browser; pressing **O** on a remote or
1007
- headless session with no display reports the failure instead of opening
1008
- anything.
1009
- - Explain keeps only the latest result in memory and does not export directly to files. Guided Review separately persists review records and captured source.
1010
- - Guided Review is local-Pi interactive only, keeps its captured revision on reopen, and does not publish, review a branch or fetch later PR changes. See [review recovery and limits](guided-review.md#if-something-goes-wrong).
1011
- - Bro temporarily captures mouse input while its modal is open so mouse-wheel
1012
- and trackpad scrolling work in regular and fullscreen modes. Native mouse
1013
- selection may be unavailable or visually extend outside the Bro window;
1014
- press **C** to copy the full explanation instead.
1015
-
165
+ See [Troubleshooting and current limits](reference/troubleshooting.md#troubleshooting-and-current-limits).