pi-bro 0.23.1 → 0.25.0

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