pi-bro 0.5.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -68
- package/THIRD_PARTY_NOTICES.md +13 -0
- package/bro.ts +645 -90
- package/package.json +13 -2
package/README.md
CHANGED
|
@@ -1,26 +1,102 @@
|
|
|
1
1
|
# pi-bro
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
adding
|
|
3
|
+
Turn a dense AI reply, pasted text, local document, or public webpage into a
|
|
4
|
+
plain-language explanation without adding anything to your main agent's context.
|
|
5
5
|
|
|
6
|
-
`pi-bro` is
|
|
7
|
-
|
|
6
|
+
`pi-bro` is an extension for [Earendil Pi](https://github.com/earendil-works/pi).
|
|
7
|
+
It opens explanations in a separate modal and uses the
|
|
8
8
|
[Google Antigravity CLI](https://antigravity.google/docs/cli-install) (`agy`)
|
|
9
|
-
|
|
9
|
+
with your selected model.
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
You need Earendil Pi `>=0.78.1 <1`, Node.js `>=22.19.0`, and `agy >=1.1.11`
|
|
14
|
+
installed and available on your `PATH`. Run `agy` once in your terminal to sign
|
|
15
|
+
in, then install Bro:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pi install npm:pi-bro
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Restart Pi or run `/reload`, then try:
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
/bro
|
|
25
|
+
/bro simplify Paste text here
|
|
26
|
+
/bro file docs/report.pdf
|
|
27
|
+
/bro url https://example.com/article
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Run `/bro doctor` after installation or whenever Bro is not working.
|
|
31
|
+
|
|
32
|
+
To install from GitHub instead, use
|
|
33
|
+
`pi install git:github.com/tranhoangnguyen03/pi-bro`. To try Bro without
|
|
34
|
+
installing it, use `pi -e npm:pi-bro`.
|
|
35
|
+
|
|
36
|
+
## What Bro can explain
|
|
37
|
+
|
|
38
|
+
| Source | Command | What Bro does |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| Latest assistant reply | `/bro` | Explains the latest completed reply without adding the result to the conversation. |
|
|
41
|
+
| Pasted text | `/bro simplify <text>` | Explains text supplied directly in the command. |
|
|
42
|
+
| Local document | `/bro file <path>` | Extracts text from a workspace-local Markdown, text, PDF, or DOCX file. |
|
|
43
|
+
| Public webpage | `/bro url <url>` | Fetches one public HTML page and extracts its main readable content. |
|
|
44
|
+
|
|
45
|
+
Pressing **R** simplifies the captured source again. These commands capture a
|
|
46
|
+
new source: `/bro simplify`, `/bro file`, and `/bro url`.
|
|
47
|
+
|
|
48
|
+
## Commands
|
|
49
|
+
|
|
50
|
+
| Command | Description |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `/bro` or `/bro simplify` | Explain the latest completed assistant response. |
|
|
53
|
+
| `/bro simplify <text>` | Explain pasted text. |
|
|
54
|
+
| `/bro file <path>` | Explain a workspace-local `.md`, `.markdown`, `.txt`, `.pdf`, or `.docx` file. |
|
|
55
|
+
| `/bro url <url>` | Explain one public, text-based webpage. |
|
|
56
|
+
| `/bro open` | Reopen the latest explanation without calling the simplifier again. |
|
|
57
|
+
| `/bro doctor` | Check Bro's settings, Agy installation, account, model, and effort. |
|
|
58
|
+
| `/bro usage [--provider agy]` | Show current Agy resource limits. |
|
|
59
|
+
| `/bro model [id]` | View or choose the Agy model. |
|
|
60
|
+
| `/bro effort [low\|medium\|high]` | View or choose the supported reasoning effort. |
|
|
61
|
+
| `/bro help` | Open the built-in quick reference. |
|
|
62
|
+
|
|
63
|
+
### Modal controls
|
|
64
|
+
|
|
65
|
+
- **Mouse wheel / trackpad**: Scroll in regular or fullscreen mode
|
|
66
|
+
- **↑ / ↓**: Scroll in any mode
|
|
67
|
+
- **C**: Copy the complete explanation
|
|
68
|
+
- **R**: Simplify the captured source or run the current Doctor check again
|
|
69
|
+
- **Esc**: Close the modal, or cancel while Bro is working
|
|
70
|
+
|
|
71
|
+
Bro temporarily captures mouse input while its modal is open. Native mouse
|
|
72
|
+
selection may be unavailable or visually extend outside the modal depending on
|
|
73
|
+
your terminal mode; press **C** to copy the complete explanation reliably.
|
|
10
74
|
|
|
11
75
|
## Bro in action
|
|
12
76
|
|
|
13
|
-
|
|
77
|
+
### Assistant response
|
|
78
|
+
|
|
79
|
+
**Before `/bro`: the original agent response**
|
|
80
|
+
|
|
81
|
+
[](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-response-before.png)
|
|
82
|
+
|
|
83
|
+
**After `/bro`: the plain-language explanation**
|
|
84
|
+
|
|
85
|
+
[](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-response-after.png)
|
|
86
|
+
|
|
87
|
+
### Local document
|
|
14
88
|
|
|
15
|
-
|
|
89
|
+
**Before: a complex PDF**
|
|
16
90
|
|
|
17
|
-
|
|
91
|
+
[](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-file-before.png)
|
|
18
92
|
|
|
19
|
-
|
|
93
|
+
**After `/bro file <path>`**
|
|
20
94
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
95
|
+
[](https://raw.githubusercontent.com/tranhoangnguyen03/pi-bro/main/docs/images/bro-file-after.png)
|
|
96
|
+
|
|
97
|
+
Bro optimizes for understanding, not simply for fewer words. The written
|
|
98
|
+
examples below are synthetic and were run through Bro's default prompt. Click
|
|
99
|
+
a screenshot to see it at full size.
|
|
24
100
|
|
|
25
101
|
<details>
|
|
26
102
|
<summary><strong>Short:</strong> TypeScript says a value is <code>never</code></summary>
|
|
@@ -261,62 +337,66 @@ cached files, not your source code or dependencies.
|
|
|
261
337
|
|
|
262
338
|
</details>
|
|
263
339
|
|
|
264
|
-
##
|
|
340
|
+
## Explain pasted text
|
|
341
|
+
|
|
342
|
+
Paste text directly after the command:
|
|
265
343
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
- Pi's interactive terminal UI
|
|
344
|
+
```text
|
|
345
|
+
/bro simplify OAuth refresh tokens are rotated after every successful use.
|
|
346
|
+
```
|
|
270
347
|
|
|
271
|
-
|
|
348
|
+
Bro explains the pasted text instead of the latest assistant reply. With no text
|
|
349
|
+
after `/bro simplify`, it falls back to the latest completed reply. Press **R**
|
|
350
|
+
to simplify the same captured text again.
|
|
272
351
|
|
|
273
|
-
##
|
|
352
|
+
## Explain a document
|
|
274
353
|
|
|
275
|
-
|
|
354
|
+
Use a path relative to Pi's current workspace, or an absolute path inside it:
|
|
276
355
|
|
|
277
|
-
```
|
|
278
|
-
|
|
356
|
+
```text
|
|
357
|
+
/bro file docs/incident review.pdf
|
|
279
358
|
```
|
|
280
359
|
|
|
281
|
-
|
|
360
|
+
Paths may contain spaces; matching single or double quotes are also accepted.
|
|
361
|
+
Bro extracts text locally, then sends that text through the same explanation
|
|
362
|
+
flow used by `/bro`. Pressing **R** retries the extracted snapshot; running a
|
|
363
|
+
new `/bro file <path>` command reads the file again.
|
|
282
364
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
```
|
|
365
|
+
Files are limited to 10 MiB and 100,000 extracted characters. Scanned PDFs are
|
|
366
|
+
not supported because Bro does not perform OCR.
|
|
286
367
|
|
|
287
|
-
|
|
368
|
+
## Explain a webpage
|
|
288
369
|
|
|
289
|
-
|
|
370
|
+
Pass one public HTTP or HTTPS page:
|
|
290
371
|
|
|
291
|
-
```
|
|
292
|
-
|
|
372
|
+
```text
|
|
373
|
+
/bro url https://example.com/complicated-article
|
|
293
374
|
```
|
|
294
375
|
|
|
295
|
-
|
|
376
|
+
Bro fetches the page, extracts its main readable text locally, and sends only
|
|
377
|
+
that text through the existing explanation flow. The completed modal shows the
|
|
378
|
+
final website and page title. Pressing **R** retries the captured page without
|
|
379
|
+
fetching again; running a new `/bro url <url>` command fetches a fresh copy.
|
|
296
380
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
| `/bro open` | Reopen the latest explanation without calling the simplifier again. |
|
|
302
|
-
| `/bro usage` | Show current Agy resource limits. |
|
|
303
|
-
| `/bro usage --provider agy` | Same as `/bro usage`, with the provider stated explicitly. |
|
|
304
|
-
| `/bro model` | Choose from the models currently available through Agy. |
|
|
305
|
-
| `/bro model <id>` | Set an available Agy model directly. |
|
|
306
|
-
| `/bro effort` | Choose an effort supported by the current model. |
|
|
307
|
-
| `/bro effort <low\|medium\|high>` | Set a supported reasoning effort directly. |
|
|
308
|
-
| `/bro help` | Open the built-in guide. |
|
|
381
|
+
The first version is intentionally limited to one public, text-based page. It
|
|
382
|
+
does not use browser cookies, sign in, run page JavaScript, bypass paywalls or
|
|
383
|
+
bot protection, load complete discussion threads, follow pagination, or
|
|
384
|
+
understand images and video. Pages that depend on those features may fail.
|
|
309
385
|
|
|
310
|
-
|
|
386
|
+
If Bro cannot read a page, copy its content into a `.txt` or `.md` file, or save
|
|
387
|
+
it as a PDF, then use `/bro file <path>`.
|
|
388
|
+
|
|
389
|
+
## Check your setup
|
|
311
390
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
- **Esc**: Close the window, or cancel while Bro is running
|
|
391
|
+
Run `/bro doctor` when Bro is newly installed or something is not working. It
|
|
392
|
+
checks Bro's settings and prompt, the installed Agy version, account access,
|
|
393
|
+
available models, and the selected reasoning effort. Failed checks explain what
|
|
394
|
+
to fix.
|
|
317
395
|
|
|
318
|
-
|
|
319
|
-
|
|
396
|
+
Doctor contacts Agy for its model catalog and account usage. It does not send an
|
|
397
|
+
assistant response or run a model completion, so it does not consume a model
|
|
398
|
+
turn. A successful check confirms the setup, but cannot guarantee that a later
|
|
399
|
+
provider request will succeed.
|
|
320
400
|
|
|
321
401
|
## Settings
|
|
322
402
|
|
|
@@ -361,44 +441,68 @@ Your prompt must include `{{response}}` exactly once. For example:
|
|
|
361
441
|
Explain this in plain English in no more than 200 words.
|
|
362
442
|
Keep important warnings and next steps.
|
|
363
443
|
|
|
364
|
-
|
|
444
|
+
Text to explain:
|
|
365
445
|
{{response}}
|
|
366
446
|
```
|
|
367
447
|
|
|
368
448
|
Bro re-reads this file every time you simplify, so your edits take effect
|
|
369
449
|
immediately without reloading Pi. Bro never creates or modifies this file.
|
|
370
450
|
|
|
371
|
-
## Privacy and
|
|
451
|
+
## Privacy and safety
|
|
372
452
|
|
|
373
|
-
- **External requests**: Bro sends the latest completed assistant response
|
|
374
|
-
Agy and its
|
|
453
|
+
- **External requests**: Bro sends the latest completed assistant response,
|
|
454
|
+
pasted text, extracted document text, or extracted webpage text to Agy and its
|
|
455
|
+
configured model provider.
|
|
375
456
|
- **Usage checks**: `/bro usage` checks your authenticated Agy limits without
|
|
376
457
|
sending an assistant response or running a model turn.
|
|
458
|
+
- **Setup checks**: `/bro doctor` checks Agy account and model availability
|
|
459
|
+
without sending an assistant response or running a model turn.
|
|
377
460
|
- **Context isolation**: Bro does not add explanations to Pi's conversation
|
|
378
461
|
history, session files, or main-agent context.
|
|
379
462
|
- **Memory cache**: The latest explanation is stored only in process memory for
|
|
380
463
|
`/bro open`. It clears when you switch Pi sessions, reload extensions, or quit
|
|
381
464
|
Pi.
|
|
382
|
-
- **File safety**:
|
|
383
|
-
|
|
384
|
-
not
|
|
385
|
-
|
|
465
|
+
- **File safety**: `/bro file` reads only regular files whose resolved path is
|
|
466
|
+
inside Pi's current workspace, including after resolving symlinks. Bro does
|
|
467
|
+
not modify them. It runs Agy in sandbox mode inside a temporary empty folder.
|
|
468
|
+
This reduces project access, but it is not a security boundary. Bro only
|
|
469
|
+
writes its own user settings file described above.
|
|
470
|
+
- **Web requests**: `/bro url` connects directly to the target website. The site
|
|
471
|
+
sees your IP address and Bro's user agent. Bro sends no browser cookies,
|
|
472
|
+
authorization, or referrer information, and it refuses local, private, and
|
|
473
|
+
reserved network destinations, including redirects. Avoid private or signed
|
|
474
|
+
URLs whose query string contains secrets.
|
|
475
|
+
- **Web extraction**: Bro parses downloaded HTML locally without executing page
|
|
476
|
+
scripts or loading page subresources. It sends the extracted readable text,
|
|
477
|
+
including links preserved in that text, to Agy; it does not separately send
|
|
478
|
+
the requested URL or raw page HTML. The URL, captured text, and explanation
|
|
479
|
+
remain in process memory only and clear with the existing `/bro open` cache.
|
|
386
480
|
- **Provider data**: Agy and your model provider may retain logs and request data
|
|
387
481
|
according to their own settings and privacy policies.
|
|
388
482
|
- **Clipboard**: Pressing **C** copies the text to your system clipboard, where
|
|
389
483
|
your operating system or clipboard manager may retain it.
|
|
390
484
|
|
|
391
|
-
##
|
|
485
|
+
## Troubleshooting and current limits
|
|
486
|
+
|
|
487
|
+
If an explanation fails, run `/bro doctor` first. If a webpage cannot be
|
|
488
|
+
extracted, copy its content into a supported text file or save it as a PDF and
|
|
489
|
+
use `/bro file`. If a PDF contains only scanned images, run OCR with another
|
|
490
|
+
tool before giving it to Bro.
|
|
392
491
|
|
|
393
492
|
- Uses Agy as its only provider.
|
|
493
|
+
- Document input supports `.md`, `.markdown`, `.txt`, `.pdf`, and `.docx` only;
|
|
494
|
+
it does not perform OCR.
|
|
495
|
+
- Webpage input supports one public HTML page, up to 5 MiB downloaded and
|
|
496
|
+
100,000 extracted characters. JavaScript-only, authenticated, paywalled,
|
|
497
|
+
blocked, paginated, and media-first pages are not supported.
|
|
498
|
+
- Direct webpage fetching does not currently use `HTTP_PROXY`, `HTTPS_PROXY`,
|
|
499
|
+
or other proxy environment variables.
|
|
394
500
|
- Keeps only the latest explanation in memory.
|
|
395
501
|
- Does not store history or export directly to files.
|
|
396
|
-
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
- In fullscreen mode, mouse text selection may visually extend outside the Bro
|
|
401
|
-
window. Press **C** to copy the full explanation instead.
|
|
502
|
+
- Bro temporarily captures mouse input while its modal is open so mouse-wheel
|
|
503
|
+
and trackpad scrolling work in regular and fullscreen modes. Native mouse
|
|
504
|
+
selection may be unavailable or visually extend outside the Bro window;
|
|
505
|
+
press **C** to copy the full explanation instead.
|
|
402
506
|
|
|
403
507
|
## Development
|
|
404
508
|
|
|
@@ -409,8 +513,9 @@ pi --tui-mode fullscreen -e ./bro.ts
|
|
|
409
513
|
```
|
|
410
514
|
|
|
411
515
|
The smoke test uses a fake `agy`, so it does not call an external model. It
|
|
412
|
-
verifies command routing,
|
|
413
|
-
|
|
516
|
+
verifies command routing, document and URL safety boundaries, HTML extraction,
|
|
517
|
+
healthy and broken setup handling, settings, custom prompt handling, and
|
|
518
|
+
context isolation.
|
|
414
519
|
|
|
415
520
|
## License
|
|
416
521
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -25,3 +25,16 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
25
25
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
26
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
27
|
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
## Defuddle
|
|
30
|
+
|
|
31
|
+
Webpage content extraction uses
|
|
32
|
+
[Defuddle](https://github.com/kepano/defuddle), copyright (c) 2025 Steph Ango
|
|
33
|
+
(@kepano), licensed under the MIT License. Its complete license is distributed
|
|
34
|
+
with the Defuddle npm package.
|
|
35
|
+
|
|
36
|
+
## LinkeDOM
|
|
37
|
+
|
|
38
|
+
HTML parsing uses [LinkeDOM](https://github.com/WebReflection/linkedom),
|
|
39
|
+
copyright (c) 2021 Andrea Giammarchi (@WebReflection), licensed under the ISC
|
|
40
|
+
License. Its complete license is distributed with the LinkeDOM npm package.
|