pi-bro 0.14.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +75 -17
  3. package/backend.ts +507 -0
  4. package/bro.ts +133 -491
  5. package/package.json +7 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to pi-bro are documented here.
4
4
 
5
+ ## [0.15.1] - 2026-09-22
6
+
7
+ ### Changed
8
+
9
+ - Explain, show, BTW and advisor now share an internal Agy execution boundary. Agy remains the only backend; existing settings, prompts, access modes, continuation and advisor retries are unchanged.
10
+
11
+ ### Fixed
12
+
13
+ - Cancellation, host deadlines and malformed execution streams use bounded subprocess cleanup, with POSIX process-group termination and escalation. Unexpected signal exits are reported as failures rather than mislabeled timeouts. Windows cleanup remains limited to the direct child.
14
+ - Offline RPC smoke checks wait for command acknowledgements instead of relying on fixed delays to prevent overlapping requests and premature shutdown.
15
+
16
+ ## [0.15.0] - 2026-09-22
17
+
18
+ ### Changed
19
+
20
+ - In the `/bro btw` modal, `/copy` and `/copy-all` now copy the latest answer or the full thread to the **system clipboard** instead of the main editor. New `/insert` and `/insert-all` commands (with `/insert!`/`/insert-all!` force variants to replace an existing main-editor draft) insert into the main editor without submitting. Removed the legacy `/send` aliases and the spaced `/copy all`/`/insert all` spellings.
21
+
5
22
  ## [0.14.0] - 2026-09-20
6
23
 
7
24
  ### Added
package/README.md CHANGED
@@ -31,6 +31,13 @@ Restart Pi or run `/reload`, then try:
31
31
 
32
32
  Run `/bro doctor` after installation or whenever Bro is not working.
33
33
 
34
+ Explain, show, BTW and advisor share an internal execution layer; Agy remains
35
+ its only backend and existing settings are unchanged. Cancellation, host deadlines
36
+ and invalid execution streams terminate the subprocess group on POSIX, escalating
37
+ after a five-second grace period. Windows cleanup targets the direct child only;
38
+ descendant termination is not guaranteed. Unexpected signal exits are reported as
39
+ failures, not timeouts.
40
+
34
41
  To install from GitHub instead, use
35
42
  `pi install git:github.com/tranhoangnguyen03/pi-bro`. To try Bro without
36
43
  installing it, use `pi -e npm:pi-bro`.
@@ -111,22 +118,28 @@ your terminal mode; press **C** to copy the complete explanation reliably.
111
118
  `/bro btw` opens a separate multi-turn conversation in a modal, so you can ask
112
119
  a quick side question while the main agent keeps working. It runs through Agy,
113
120
  the same backend as the rest of Bro, and never adds anything to Pi's
114
- conversation unless you explicitly copy it into the editor.
121
+ conversation unless you explicitly insert it into the editor.
115
122
 
116
123
  - **Sandboxed by default**: the side conversation is read-only (no project
117
124
  access). Add `--full` to let it read and edit the workspace.
118
125
  - `/bro btw <question>` asks immediately; `/bro btw` opens an empty thread.
119
126
  - `--fresh` starts a thread without seeding the main session's recent
120
- conversation text.
127
+ conversation text. Reopening without an access flag preserves the existing
128
+ thread's access mode, including `--full`. Use `--sandbox` to return to sandbox
129
+ mode; changing access mode starts a new thread. `--fresh` alone does not reset
130
+ the access mode.
121
131
  - The first turn is seeded with up to the last 8 turns of user/assistant
122
132
  conversation text (40,000 characters max, with a truncation notice); the
123
133
  side agent can also read the repo itself when running in `--full` mode.
124
134
  - **In the modal**: type a question and press Enter (empty Enter re-asks the
125
- last question). `/copy` copies the latest answer into the main editor
126
- without submitting (use `/copy!` to replace an existing draft); `/copy-all`
127
- copies the full thread; `/retry` re-asks
128
- the last question; `/clear` resets the thread; Esc closes. A visible
129
- `full · edits repo` badge shows whenever `--full` mode is active.
135
+ last question). Composer actions trigger only on these exact commands:
136
+ - `/copy`: copies the latest answer to the system clipboard
137
+ - `/copy-all`: copies the full thread to the system clipboard
138
+ - `/insert`: inserts the latest answer into the main editor without submitting (use `/insert!` to replace an existing editor draft)
139
+ - `/insert-all`: inserts the full thread into the main editor without submitting (use `/insert-all!` to replace an existing editor draft)
140
+ - `/retry`: re-asks the last question (empty Enter does the same)
141
+ - `/clear`: resets the thread
142
+ Any other text or slash-prefixed input (such as `/send` or `/copy!`) is not a composer command and is submitted directly as a question to the side conversation. Esc closes the modal. A visible `full · edits repo` badge shows whenever `--full` mode is active.
130
143
  - The thread lives in memory only — it clears when you switch Pi sessions,
131
144
  reload extensions, or quit Pi.
132
145
 
@@ -157,8 +170,9 @@ gives an `agy update` action when it is too old.
157
170
  tool access in the workspace with permissions auto-approved
158
171
  (`--dangerously-skip-permissions`) — there is no enforced read-only
159
172
  isolation. It is instructed to verify claims itself and return advice,
160
- leaving edits to the executor, but that instruction is not enforced, so
161
- treat its findings as advice to verify, not a guaranteed hands-off review.
173
+ leaving edits to the executor, but that boundary is a behavioral prompt
174
+ instruction rather than an enforced sandbox constraint, so treat its
175
+ findings as advice to verify, not a guaranteed hands-off review.
162
176
  - **Steering**: `/bro advisor-steer` opens an editor for one persistent
163
177
  steering brief — e.g. "quick prototype; keep A and B careful, everything
164
178
  else minimal" — that the advisor always reads. **Ctrl+S** saves and keeps
@@ -170,9 +184,10 @@ gives an `agy update` action when it is too old.
170
184
  conversation or sent to the main model** — the advisor is the only thing
171
185
  that reads it.
172
186
  - **Persistence**: the steering brief persists with the Pi session (not
173
- globally, not per project) and is restored on resume or reload. Forking a
174
- session inherits it; edits made after the fork are independent of the
175
- original branch.
187
+ globally, not per project) as custom extension data in the session file and
188
+ is restored on resume or reload. Forking a session inherits it; edits made
189
+ after the fork are independent of the original branch. The advisor tool has
190
+ no separate activation state persisted or toggled.
176
191
  - **Retries**: on an invocation failure (not a completed answer — "I need
177
192
  more evidence" is a normal result, not a failure), Bro retries with the
178
193
  identical snapshot, steering, and question: once after 5 seconds, once more
@@ -235,11 +250,14 @@ changed in the auth flow`. The query is used as a lens on the captured turns,
235
250
  not as additional evidence, and its casing is preserved as typed. Pressing
236
251
  **R** retries with the same turn count and query.
237
252
 
238
- Only the first word is ever read as the turn count — a query that starts with
239
- digits is not ambiguous. `/bro show 1 404 handler` captures 1 turn and steers
240
- on "404 handler"; `/bro show 404 handler` (no leading count) steers on the
241
- whole phrase "404 handler" using the default turn count, since "404" alone
242
- would be a count but "404 handler" is not.
253
+ Any leading whitespace-delimited word that looks like a number is treated as the
254
+ requested turn count: for example, `/bro show 3 what changed` captures 3 turns
255
+ and steers on "what changed", while `/bro show 404 handler` parses "404" as the
256
+ turn count and "handler" as the steering query. To steer on a phrase that starts
257
+ with digits while choosing a turn count, specify the turn count explicitly
258
+ first: `/bro show 1 404 handler` captures 1 turn and steers on "404 handler".
259
+ If the first word is not a number, the whole input is treated as the steering
260
+ query using the saved `showTurns` default.
243
261
 
244
262
  ### A slow session-create, traced
245
263
 
@@ -728,6 +746,23 @@ chooses the initial model only when Bro creates a missing settings file:
728
746
  PI_BRO_MODEL=gemini-3.7-flash-low pi
729
747
  ```
730
748
 
749
+ ### Configuration precedence
750
+
751
+ When resolving model and reasoning effort:
752
+ 1. **Per-capability override**: If configured under `overrides.<capability>` (`explain`, `show`, `btw`, or `advisor`) in `bro-settings.json`, that capability pins its own `{ "model": ..., "effort": ... }` pair and ignores the shared default.
753
+ 2. **Shared default**: If no override is set for that capability, it inherits the root `model` and `effort` in `bro-settings.json`.
754
+ 3. **Catalog normalization**: Bro normalizes the resolved `{ model, effort }` against Agy's installed model catalog (mapping suffixed variant IDs and handling fixed-effort models).
755
+ 4. **Initial file creation only**: `PI_BRO_MODEL` selects the initial default model only when Bro creates a missing `bro-settings.json` file. It has no effect once the file exists.
756
+
757
+ When resolving turn count for `/bro show`:
758
+ 1. **Command argument**: An explicit count like `/bro show 3` or `/bro show 1 query` overrides for that single execution.
759
+ 2. **Saved setting**: `showTurns` in `bro-settings.json` (defaults to 1; configurable interactively via `/bro config` or direct file edit).
760
+
761
+ When resolving explanation prompt (`explain` capability only):
762
+ 1. **Custom prompt**: `~/.pi/agent/bro-prompt.md` (or `$PI_CODING_AGENT_DIR/bro-prompt.md`), if present and valid (`{{response}}` exactly once), completely overrides all built-in modes.
763
+ 2. **Saved mode**: `mode` in `bro-settings.json` (`brief`, `balanced`, or `faithful`; defaults to `balanced`).
764
+ 3. Note: `bro-prompt.md` applies only to `/bro`, `/bro text`, `/bro file`, and `/bro url`; it does not affect `/bro show`, `/bro btw`, or `bro_advisor`.
765
+
731
766
  ## Custom prompt
732
767
 
733
768
  Bro uses a built-in prompt by default. To use your own, create:
@@ -806,6 +841,24 @@ run `/bro doctor` for the exact problem.
806
841
  according to their own settings and privacy policies.
807
842
  - **Clipboard**: Pressing **C** copies the text to your system clipboard, where
808
843
  your operating system or clipboard manager may retain it.
844
+ - **Advisor requests**: `bro_advisor` sends the executor agent's system
845
+ instructions, active tool list (excluding `bro_advisor`), ordered
846
+ conversation history including tool calls and tool results (unlike Show, which
847
+ omits them), human steering brief, and the executor's optional question to
848
+ Agy and your configured model provider. Reasoning and image bodies are
849
+ omitted with explicit markers (`[reasoning omitted]`, `[image omitted]`).
850
+ - **Advisor tool execution & safety boundary**: The advisor process runs
851
+ directly in your workspace (`cwd`) with auto-approved permissions
852
+ (`--dangerously-skip-permissions`). It has real tool access (file reading,
853
+ search, command execution). The directive to only advise and leave edits to
854
+ the executor is a **behavioral prompt instruction**, not an enforced sandbox
855
+ or security boundary. Treat its findings as advice to verify before applying.
856
+ - **Advisor steering persistence**: The steering brief is saved as
857
+ session-scoped custom extension data (`bro-advisor-steering`) in the session
858
+ file. It persists across session resume and reload, and is inherited on
859
+ session fork (post-fork edits on branches remain independent). It is never
860
+ sent to the main model or added to Pi's conversation. The advisor tool has
861
+ no separate activation state.
809
862
 
810
863
  ## Troubleshooting and current limits
811
864
 
@@ -825,6 +878,11 @@ tool before giving it to Bro.
825
878
  - `/bro btw` threads are memory-only and do not survive reloads or restarts.
826
879
  The side conversation needs Agy's `--conversation` resume support; sandbox
827
880
  mode caps a turn at 2 minutes and full mode at 10 minutes.
881
+ - `bro_advisor` requires Agy CLI `>=1.1.15` (for `--input-format stream-json`).
882
+ Consultations run directly in the workspace with auto-approved permissions
883
+ without enforced file-modification isolation; an attempt is capped at 10
884
+ minutes (`--print-timeout 10m`) and retries up to 2 times on invocation
885
+ failure (5-second, then 10-second backoff).
828
886
  - Show captures only the conversation text of what already happened in the
829
887
  current session — the last few turns' user and assistant messages, with
830
888
  tool calls, tool results, reasoning, and images always omitted; it cannot