pi-bro 0.32.0 → 0.33.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/CHANGELOG.md +10 -0
- package/README.md +4 -4
- package/docs/README.md +1 -0
- package/docs/elevate.md +6 -11
- package/docs/features/btw.md +5 -6
- package/docs/grill-me.md +4 -4
- package/docs/pig-compatibility.md +1 -1
- package/docs/reference/commands.md +3 -3
- package/docs/reference/data-and-permissions.md +2 -2
- package/docs/user-guide.md +1 -1
- package/package.json +1 -1
- package/src/bro.ts +9 -9
- package/src/btw.ts +9 -28
- package/src/elevate-engine.ts +0 -12
- package/src/elevate.ts +4 -38
- package/src/explain-modal.ts +13 -5
- package/src/grill-engine.ts +4 -3
- package/src/grill.ts +12 -16
- package/src/ui-capabilities.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to pi-bro are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.33.0] - 2026-11-07
|
|
6
|
+
|
|
7
|
+
### Highlights
|
|
8
|
+
|
|
9
|
+
- Feature discovery now starts from four human needs: understand what exists, explore what could exist, assess existing work, and guide the agent.
|
|
10
|
+
- BTW and Grill Me use clipboard-only manual handoff. The old Insert commands no longer modify the main Pi editor; they point users to Copy instead.
|
|
11
|
+
- Elevate copies the revised assignment without replacing the unsent main-editor draft. Obsolete insertion code and its tests are removed.
|
|
12
|
+
- Built-in help, command completion, feature guides and developer checks align around common interaction meanings while retaining each feature's special actions.
|
|
13
|
+
- The read-only `about_user` agent tool and `bro_advisor` tool are unchanged. Session recovery, Guided Review lifecycle, and Overthink/Architecture PRs remain separate work.
|
|
14
|
+
|
|
5
15
|
## [0.32.0] - 2026-11-07
|
|
6
16
|
|
|
7
17
|
### Highlights
|
package/README.md
CHANGED
|
@@ -66,14 +66,14 @@ File and webpage examples need your own real path or URL; see [how to explain th
|
|
|
66
66
|
| `/bro elevate` or **Ctrl+Shift+E** | **[Elevate](docs/elevate.md).** Discover missing expert considerations, select useful improvements, and rewrite your task without submitting it. Shares BTW backend settings. |
|
|
67
67
|
| `/bro remember-me [thought]` | **[Remember Me](docs/remember-me.md).** Privately clarify and approve short personal memories with unfoldable background. Agents can call `about_user` to read summaries and expand IDs. |
|
|
68
68
|
| `/bro overthink` | **[Overthink](docs/overthink.md).** Quietly checks meaningful work with the active Pi model, using editable global/session questions and a private notes modal. Automatic checks can be switched off in config. No separate backend. |
|
|
69
|
-
| `/bro grill-me` | **[Grill Me](docs/grill-me.md) (experimental).** A private, opinionated decision interview: light, balanced or exhaustive; one question per round; `/consolidate` drafts a brief without ending the interview; `/
|
|
69
|
+
| `/bro grill-me` | **[Grill Me](docs/grill-me.md) (experimental).** A private, opinionated decision interview: light, balanced or exhaustive; one question per round; `/consolidate` drafts a brief without ending the interview; `/copy` returns the latest reply or decision brief to the clipboard. Uses BTW model settings; read-only restrictions vary by backend. |
|
|
70
70
|
| `/bro btw` | **[Side questions](docs/features/btw.md#bro-btw-side-conversation).** A separate conversation seeded with recent context, so you can ask without interrupting the agent. ⚠️ [Full-permission mode](#what-leaves-your-machine) can edit files. |
|
|
71
71
|
| `/bro guided-review <PR>` | **[Guided Review](docs/guided-review.md).** An explanation and quality assessment of a GitHub PR, with ranked findings, source evidence and private questions. Claude, Muse, or Pi is recommended for untrusted PRs. |
|
|
72
72
|
| `bro_advisor` tool | **[Second opinion](docs/features/advisor.md#bro-advisor).** A tool your agent can call mid-task; a fresh backend process reviews the session snapshot, can inspect the workspace when needed, and returns advice to the agent. ⚠️ [Runs with permissions bypassed](#what-leaves-your-machine). |
|
|
73
73
|
| `/bro config`, `/bro preferences` | **[Settings](docs/reference/settings.md#settings) and [preferences](docs/user-guide.md#preferences).** Pick the backend, model and effort per feature, and tell Bro how you like answers. |
|
|
74
74
|
|
|
75
|
-
For help by task, start
|
|
76
|
-
**Elevate, in practice:** Bro points out expert questions or tests you may have missed before you ask Pi to do the work. Review the suggestions, approve only what matters, then edit or submit the resulting request yourself. See the [walkthrough](docs/elevate.md) for limits, privacy, and
|
|
75
|
+
For help by task, start with the **[four human-intent states](docs/feature-map.md)** or the **[docs home](docs/README.md)**; see the [command reference](docs/reference/commands.md) for syntax.
|
|
76
|
+
**Elevate, in practice:** Bro points out expert questions or tests you may have missed before you ask Pi to do the work. Review the suggestions, approve only what matters, then edit or submit the resulting request yourself. See the [walkthrough](docs/elevate.md) for limits, privacy, and copy-only handoff.
|
|
77
77
|
|
|
78
78
|
Guided Review has its own [guide](docs/guided-review.md).
|
|
79
79
|
|
|
@@ -123,7 +123,7 @@ external CLI's provider credentials, but a CLI signs in its own way, which can
|
|
|
123
123
|
include API keys set in your environment. The built-in **Pi** backend is the
|
|
124
124
|
exception: it runs in-process, so it reads your Pi `auth.json` and reuses your
|
|
125
125
|
Pi provider credentials for the model you select. Nothing Bro produces enters
|
|
126
|
-
Pi's conversation unless you
|
|
126
|
+
Pi's conversation unless you paste and submit it, except advisor answers, which return to
|
|
127
127
|
the agent as tool results.
|
|
128
128
|
|
|
129
129
|
> [!WARNING]
|
package/docs/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Start with what you want to do. The [README](../README.md) explains the product,
|
|
|
5
5
|
## I'm new
|
|
6
6
|
|
|
7
7
|
- [Getting started](getting-started.md) — install, check your backend, and complete a working first example.
|
|
8
|
+
- [Choose by your current need](feature-map.md) — four intent states, expected results, and handoff rules.
|
|
8
9
|
- [Command lookup](reference/commands.md#commands) — find the right command.
|
|
9
10
|
|
|
10
11
|
## I want to do something
|
package/docs/elevate.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Elevate is useful before a design, research task, implementation, plan, or important decision. It is not a way to turn every small request into a large project. Sometimes the best result is: *Your original request is good enough.*
|
|
6
6
|
|
|
7
|
-
Elevate works inside Pi's **separate Bro modal**. It does not post its discussion to the main agent or execute the revised assignment.
|
|
7
|
+
Elevate works inside Pi's **separate Bro modal**. It does not post its discussion to the main agent or execute the revised assignment. Copy and paste the revised assignment when you choose; Elevate never edits or submits Pi's main draft.
|
|
8
8
|
|
|
9
9
|
## Start here (one minute)
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ Elevate works inside Pi's **separate Bro modal**. It does not post its discussio
|
|
|
24
24
|
|
|
25
25
|
If the main editor contains a draft, Bro pre-fills the objective with that draft. Elevate always opens Compose first so you can choose context before any model call. Otherwise, it shows a multi-line objective field: type or paste the objective and choose **Ctrl+S** (or `Ctrl+Enter` on terminals that send it, or the `[Discover gaps]` button). `Enter` adds a new line, so a pasted multi-line task keeps its structure.
|
|
26
26
|
|
|
27
|
-
When both an explicit `/bro elevate <request>` argument and a draft exist, the **explicit argument takes priority**. The main editor
|
|
27
|
+
When both an explicit `/bro elevate <request>` argument and a draft exist, the **explicit argument takes priority**. The main editor stays untouched throughout.
|
|
28
28
|
|
|
29
29
|
## Conversation context and retry
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ The **Context: Messages** button toggles to **Context: Full**. Use Tab to focus
|
|
|
41
41
|
1. **Discover:** “Given my objective, what would a skilled expert know, question, investigate, or test that I haven't accounted for?” Bro looks across **altitude** (right problem), **depth** (evidence, methods, tests), and **range** (useful ideas from other fields). It offers up to **five** non-overlapping suggestions, with a reason and an expert action for each. It can also report **zero** suggestions.
|
|
42
42
|
2. **Upgrade:** “Rewrite my request using only the insights I approve. Keep my outcome, constraints, and scope. Improve the quality of the work, not the amount of work.” Bro returns the improved assignment for **you to review**.
|
|
43
43
|
|
|
44
|
-
The flow is **Discover → Select → Upgrade →
|
|
44
|
+
The flow is **Discover → Select → Upgrade → Copy**. It typically makes **two model calls** (discovery and rewrite); if Bro finds no useful changes, it makes only the discovery call and keeps the original request.
|
|
45
45
|
|
|
46
46
|
## Example: before and after
|
|
47
47
|
|
|
@@ -67,7 +67,7 @@ Bro has **not designed the system** here. It has improved the assignment you can
|
|
|
67
67
|
|
|
68
68
|
## Controls in the modal
|
|
69
69
|
|
|
70
|
-
Every consequential action is a **button** on the action row. `Tab` / `Shift+Tab` move between the text/list area and the buttons, `←`/`→` move between buttons, and `Enter` activates the focused one. The focused button is marked with `›`. Nothing
|
|
70
|
+
Every consequential action is a **button** on the action row. `Tab` / `Shift+Tab` move between the text/list area and the buttons, `←`/`→` move between buttons, and `Enter` activates the focused one. The focused button is marked with `›`. Nothing changes your main Pi editor or sends a request.
|
|
71
71
|
|
|
72
72
|
| Screen | Key | Effect |
|
|
73
73
|
| --- | --- | --- |
|
|
@@ -78,7 +78,6 @@ Every consequential action is a **button** on the action row. `Tab` / `Shift+Tab
|
|
|
78
78
|
| Review discoveries | `Tab` | Move focus to the buttons. |
|
|
79
79
|
| Review discoveries | `[Rewrite with N selected]` | Generate a revised request using only the ticked findings. With nothing ticked it explains why instead of proceeding. |
|
|
80
80
|
| Review discoveries | `[Select all]` / `[Select none]` | Change every tick at once. |
|
|
81
|
-
| Revised request | `[Insert into editor]` | Insert the revised request into Pi's main editor, **without sending it**. See editor behavior below. |
|
|
82
81
|
| Revised request | `[Copy]` | Copy the revised request to the system clipboard. |
|
|
83
82
|
| Revised request | `[Back]` | Return to the findings and change your choices. |
|
|
84
83
|
| Failed step | `[Retry]` | Repeat **the step that failed**: a failed rewrite retries the rewrite with the same approved findings, so your choices are not lost. |
|
|
@@ -86,14 +85,11 @@ Every consequential action is a **button** on the action row. `Tab` / `Shift+Tab
|
|
|
86
85
|
| Any screen | `Esc` | Cancel/close. A running backend request is asked to stop. |
|
|
87
86
|
| Read long content | `↑`/`↓`, Page Up/Down, wheel | Scroll. In the findings list, `↑`/`↓` move the highlight and Page Up/Down scroll. |
|
|
88
87
|
|
|
89
|
-
If there are **no material findings**, the revised-request screen displays your original text unchanged. You may copy
|
|
88
|
+
If there are **no material findings**, the revised-request screen displays your original text unchanged. You may copy or close it; no rewrite model call is made.
|
|
90
89
|
|
|
91
90
|
### What happens to the original editor draft?
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
- **In Pi terminal (TUI):** The `[Insert into editor]` button replaces the editor text with the revised request. It only replaces the draft Elevate was opened on, and only if that text has not changed since it opened; if you opened Elevate with an explicit request, the editor must be empty. Otherwise insertion is refused and you can copy instead. There is no built-in undo of this replacement in Elevate—copy the original first if you want to keep both versions.
|
|
95
|
-
- **In compatible Pi Desktop/RPC:** The adapter only inserts when the editor is empty and confirms atomic insertion support. If the editor contains a draft or insertion isn't supported, use `[Copy]` and paste manually. It does **not** replace a Desktop draft.
|
|
96
|
-
- **After insertion:** The new text remains editable. **Nothing is sent to Pi's main agent** until *you* submit it.
|
|
92
|
+
Elevate never writes to Pi's editor. It may use the unsent draft as its starting objective, but Copy only writes to the clipboard. Paste the revised request yourself and submit when ready. If you have an unsent draft, it stays unchanged.
|
|
97
93
|
|
|
98
94
|
## What Elevate can and cannot do
|
|
99
95
|
|
|
@@ -116,7 +112,6 @@ If there are **no material findings**, the revised-request screen displays your
|
|
|
116
112
|
| Nothing to work on | Type the objective into the modal and choose `[Discover gaps]`, or pass it with `/bro elevate <request>`. |
|
|
117
113
|
| “Invalid discovery JSON” | The model didn't follow the required response format. Choose `[Retry]` to repeat the step; consider a different BTW model in `/bro config`. |
|
|
118
114
|
| Backend/model/effort fails | Run `/bro doctor`; Elevate does not silently switch models. |
|
|
119
|
-
| If `[Insert into editor]` is refused | Your editor changed while Elevate was open, or Desktop can't safely insert into a non-empty editor. Use `[Copy]`, then paste. |
|
|
120
115
|
| The rewrite added unwanted scope | Use `[Back]` to approve fewer findings, or `Esc` to keep your original request. |
|
|
121
116
|
| You need source-backed research | Ask the main agent to investigate after you submit the improved request. Elevate's discovery alone does not verify source facts. |
|
|
122
117
|
|
package/docs/features/btw.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
`/bro btw` opens a separate multi-turn conversation in a modal, so you can ask
|
|
8
8
|
a quick side question while the main agent keeps working. It runs through the
|
|
9
9
|
selected backend and never adds anything to Pi's conversation unless you
|
|
10
|
-
|
|
10
|
+
copy it, paste it and send it yourself. Bro writes for a tired reader: the point
|
|
11
11
|
first, in plain words, at a length that fits the question, in the language you
|
|
12
12
|
asked in.
|
|
13
13
|
|
|
@@ -32,14 +32,13 @@ asked in.
|
|
|
32
32
|
- `/mode`: toggles conversation-only / full permission, keeping the thread
|
|
33
33
|
- `/copy`: copies the latest answer to the system clipboard
|
|
34
34
|
- `/copy-all`: copies the full thread to the system clipboard
|
|
35
|
-
- `/insert`: inserts the latest answer into the main editor without submitting
|
|
36
|
-
- `/insert-all`: inserts the full thread into the main editor without submitting
|
|
37
35
|
- `/retry`: re-asks the last question (empty Enter does the same)
|
|
36
|
+
- `/help`: shows available controls
|
|
38
37
|
- `/clear`: resets the thread
|
|
39
38
|
|
|
40
|
-
`/insert` and `/insert-all`
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
`/insert` and `/insert-all` are retired: Bro points you to `/copy` or `/copy-all`
|
|
40
|
+
instead. Any other text, including other slash-prefixed input such as `/send`,
|
|
41
|
+
is sent as a question. Esc closes the modal and stops a
|
|
43
42
|
running turn; the thread is kept. The view follows the newest text while you
|
|
44
43
|
are at the bottom; scroll up to read earlier turns. The header shows the model and reasoning effort the latest
|
|
45
44
|
turn used (`default` when the model's own effort applies) and the current
|
package/docs/grill-me.md
CHANGED
|
@@ -28,11 +28,11 @@ This takes inspiration from the context-rich **Elephant** in Google's [Elephant
|
|
|
28
28
|
| Command inside the modal | Effect |
|
|
29
29
|
| --- | --- |
|
|
30
30
|
| `/consolidate` | Generate a current decision brief. Does not end the interview or insert anything. |
|
|
31
|
-
| `/
|
|
31
|
+
| `/copy` | Copy the latest reply or consolidated brief to the clipboard. No model call or editor changes. |
|
|
32
32
|
| `/depth light` | Quick, focused questioning |
|
|
33
33
|
| `/depth balanced` | Default: material assumptions and trade-offs |
|
|
34
34
|
| `/depth exhaustive` | Deeper alternatives, evidence and failure cases |
|
|
35
|
-
| `/retry` | Retry the failed/cancelled operation, otherwise regenerate the latest reply. Never repeats
|
|
35
|
+
| `/retry` | Retry the failed/cancelled operation, otherwise regenerate the latest reply. Never repeats copying. |
|
|
36
36
|
| `/new <topic>` | Start over after confirmation. Resets depth to balanced and access to inspection. |
|
|
37
37
|
| `/access inspect` | Request inspection tools; enforcement depends on backend |
|
|
38
38
|
| `/access full` | Request full permissions; requires typing `yes` after a warning |
|
|
@@ -41,9 +41,9 @@ This takes inspiration from the context-rich **Elephant** in Google's [Elephant
|
|
|
41
41
|
|
|
42
42
|
Type `/` to see matching commands; keep typing to narrow suggestions and press **Tab** to complete the first match. Completion never submits. From help, Esc returns to the discussion; a second Esc closes the modal.
|
|
43
43
|
|
|
44
|
-
For confirmation prompts, type `yes` to proceed; anything else cancels. Depth can change between replies without losing the discussion. There are no question quotas or finished/locked states. Consolidate whenever useful, inspect the brief, then
|
|
44
|
+
For confirmation prompts, type `yes` to proceed; anything else cancels. Depth can change between replies without losing the discussion. There are no question quotas or finished/locked states. Consolidate whenever useful, inspect the brief, then copy it or continue talking. The brief includes the current position, reasons, objections, unresolved questions and next actions. Copy never edits or submits the Pi draft.
|
|
45
45
|
|
|
46
|
-
The old `/finish`, `/copy
|
|
46
|
+
The old `/finish`, `/copy-all`, `/insert`, `/insert-all`, `/insert-last-message`, `/clear`, and entry depth flags are not supported. Use `/copy` for the latest reply or brief; paste it where you choose. BTW also uses copy-only handoffs.
|
|
47
47
|
|
|
48
48
|
Grill Me uses the **BTW model/backend/effort** selection from `/bro config`, but has its own independent thread. The header shows depth and effective access; `/help` keeps the footer short. Full access and Agy write risks remain visible in the header even when another notice is shown.
|
|
49
49
|
|
|
@@ -22,7 +22,7 @@ Bro follows the host's `getAgentDir()`: normally `~/.pi/agent` on Pi and `~/.pig
|
|
|
22
22
|
|
|
23
23
|
- **PiG 0.3.0 RPC does not enforce `--exclude-tools`.** Excluded tools may remain active and reach provider requests. This is not a sandbox boundary. Use an explicit `--tools` allowlist instead; do not rely on `/bro doctor` to prove exclusion. Bro does not mask this defect by falsely reporting an active tool as unavailable.
|
|
24
24
|
- The smoke suite retains Pi's strict exclusion assertion. The PiG lane has an explicit version-specific expected failure; a changed result fails the lane so the exception must be reviewed/removed.
|
|
25
|
-
- Elevate is not yet qualified end-to-end on PiG. Interactive behavior, keyboard shortcut delivery and
|
|
25
|
+
- Elevate is not yet qualified end-to-end on PiG. Interactive behavior, keyboard shortcut delivery and clipboard Copy must be checked on PiG before claiming support.
|
|
26
26
|
- Guided Review currently targets local Pi interactive mode. Its capture/reading/question/regeneration journey is not qualified on PiG or RPC/Desktop; existing Bro PiG checks do not establish review support. See [current review scope](guided-review.md#not-available-yet).
|
|
27
27
|
- Mouse-wheel forwarding is not qualified; use keyboard scrolling.
|
|
28
28
|
- Remote/SSH OSC 52 clipboard forwarding is not qualified. Local clipboard behavior depends on the host and installed platform utilities.
|
|
@@ -43,9 +43,9 @@ Typing `/bro ` displays ten task-level suggestions: `simplify`, `show`, `btw`, `
|
|
|
43
43
|
| `/bro guided-review` | List saved reviews; `resume` is an alias. |
|
|
44
44
|
| `/bro remember-me [thought]` | Start a private memory-writing conversation, browse and expand memories, and approve saves explicitly. [Guide](../remember-me.md). |
|
|
45
45
|
| `/bro overthink` | View the latest private automatic second-look notes, without a model call. Ctrl+R retry, Ctrl+E edit session questions, ? help, Ctrl+C copy. [Guide](../overthink.md). |
|
|
46
|
-
| `/bro grill-me [topic]` | Private one-question-at-a-time decision interview. Supply a topic to start fresh; omit it to resume. `/consolidate` drafts a brief; `/
|
|
47
|
-
| `/bro elevate [request]` | Improve an assignment before execution. Discover up to five gaps, choose useful findings, and
|
|
48
|
-
| `/bro btw [question]` | Open a side conversation in a modal, seeded with recent main-session context. Starts conversation-only;
|
|
46
|
+
| `/bro grill-me [topic]` | Private one-question-at-a-time decision interview. Supply a topic to start fresh; omit it to resume. `/consolidate` drafts a brief; `/copy` copies the latest reply or brief; Pi's editor stays untouched. `/help` lists modal controls. [Guide](../grill-me.md). |
|
|
47
|
+
| `/bro elevate [request]` | Improve an assignment before execution. Discover up to five gaps, choose useful findings, and copy the revised request. Pi's editor is never changed. **Ctrl+Shift+E** can use your unsent draft. See [Elevate](../elevate.md). |
|
|
48
|
+
| `/bro btw [question]` | Open a side conversation in a modal, seeded with recent main-session context. Starts conversation-only; `/mode` toggles full workspace access; `/copy` and `/copy-all` copy the latest answer or full thread. |
|
|
49
49
|
| `/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`. |
|
|
50
50
|
| `/bro advisor-steer` | View, edit, save, or clear the one persistent steering brief the advisor always sees. |
|
|
51
51
|
| `/bro help` | Open the built-in quick reference. |
|
|
@@ -100,7 +100,7 @@ See [feature guide](../features/architecture.md).
|
|
|
100
100
|
pasted text, extracted document text, extracted webpage text, or recent
|
|
101
101
|
session conversation text (tool calls, tool results, reasoning, and images
|
|
102
102
|
omitted) to the selected backend and its configured model provider.
|
|
103
|
-
- **Elevate requests**: `/bro elevate` sends your objective, preferences, and all user/assistant text on the current branch by default, without a fixed history cap. Its visible Context switch can include tool-call arguments and text results (Full), potentially including sensitive file contents or command output. Both modes exclude hidden reasoning and image binaries. Only explicit Retry after a context-overload error trims older history; the UI discloses reduced context. Its optional rewrite call includes only approved findings. It makes fresh restricted calls through the BTW model setting, but a backend's restricted mode is not a universal file/network sandbox (Grok restrictions are prompt-only).
|
|
103
|
+
- **Elevate requests**: `/bro elevate` sends your objective, preferences, and all user/assistant text on the current branch by default, without a fixed history cap. Its visible Context switch can include tool-call arguments and text results (Full), potentially including sensitive file contents or command output. Both modes exclude hidden reasoning and image binaries. Only explicit Retry after a context-overload error trims older history; the UI discloses reduced context. Its optional rewrite call includes only approved findings. It makes fresh restricted calls through the BTW model setting, but a backend's restricted mode is not a universal file/network sandbox (Grok restrictions are prompt-only). Elevate never edits or submits Pi's main draft. The user may copy the revision and paste it manually. See the [Elevate guide](../elevate.md).
|
|
104
104
|
- **Side conversation requests**: `/bro btw` sends your side questions and the
|
|
105
105
|
seeded main-session conversation text (plus earlier turns when a native
|
|
106
106
|
session is reseeded) to the selected backend. In full permission mode the
|
|
@@ -123,7 +123,7 @@ See [feature guide](../features/architecture.md).
|
|
|
123
123
|
instructions are not access enforcement.
|
|
124
124
|
- **Context isolation**: Bro does not add explanations, BTW answers, or the
|
|
125
125
|
steering brief to Pi's conversation history or main-agent context. BTW text
|
|
126
|
-
reaches the main
|
|
126
|
+
reaches the main conversation only after the user copies, pastes, and submits it, and advisor
|
|
127
127
|
results appear as normal tool results in the executor's transcript.
|
|
128
128
|
- **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).
|
|
129
129
|
- **Private session continuity**: completed BTW and Grill Me turns, modes, drafts, the latest Simplify state and the last Show result are saved as Pi `custom` entries inside the current session file. They survive normal reload/restart and are never added to the main model or Advisor snapshot. A fork initially inherits earlier entries; later updates stay on its own branch. This is local disk storage, not a global memory store or an abrupt-crash guarantee. Backend-native sessions may persist independently.
|
package/docs/user-guide.md
CHANGED
|
@@ -32,7 +32,7 @@ See [Guided Review](guided-review.md#guided-review).
|
|
|
32
32
|
|
|
33
33
|
## Bro Elevate — improve a task before sending it
|
|
34
34
|
|
|
35
|
-
See [Elevate: Discover → Select → Upgrade](elevate.md). Elevate does not execute a task or send it to the main agent. It helps find gaps, lets you approve suggestions, then offers a revised request.
|
|
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. Elevate never edits your Pi draft; copy and paste the revision if you wish.
|
|
36
36
|
|
|
37
37
|
## Bro btw (side conversation)
|
|
38
38
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-bro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "A sidekick for you and your Pi agent: plain-language explanations, side questions, diagrams, PR review and second opinions, without cluttering the agent's context.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/bro.ts
CHANGED
|
@@ -82,18 +82,18 @@ const COMMANDS = [
|
|
|
82
82
|
{ value: "url", label: "url", description: "Explain a public webpage" },
|
|
83
83
|
{ value: "open", label: "open", description: "Reopen the last explanation" },
|
|
84
84
|
{ value: "doctor", label: "doctor", description: "Check whether Bro is ready" },
|
|
85
|
-
{ value: "show", label: "show", description: "
|
|
85
|
+
{ value: "show", label: "show", description: "Need to see how recent turns fit together? Get a visual outline or diagram" },
|
|
86
86
|
{ value: "mode", label: "mode", description: "View or choose explanation mode (brief, balanced, faithful)" },
|
|
87
|
-
{ value: "preferences", label: "preferences", description: "
|
|
88
|
-
{ value: "guided-review", label: "guided-review", description: "
|
|
89
|
-
{ value: "btw", label: "btw", description: "
|
|
90
|
-
{ value: "elevate", label: "elevate", description: "
|
|
91
|
-
{ value: "remember-me", label: "remember-me", description: "
|
|
92
|
-
{ value: "grill-me", label: "grill-me", description: "
|
|
93
|
-
{ value: "overthink", label: "overthink", description: "
|
|
87
|
+
{ value: "preferences", label: "preferences", description: "Want Bro to follow your style? Edit saved response preferences" },
|
|
88
|
+
{ value: "guided-review", label: "guided-review", description: "Need to assess a PR? Get source-backed findings and saved private questions" },
|
|
89
|
+
{ value: "btw", label: "btw", description: "Want to explore a side question? Get a private conversation" },
|
|
90
|
+
{ value: "elevate", label: "elevate", description: "Have an assignment for Pi? Get an improved request to copy and send" },
|
|
91
|
+
{ value: "remember-me", label: "remember-me", description: "Want Pi to remember your preferences? Save approved memories for about_user" },
|
|
92
|
+
{ value: "grill-me", label: "grill-me", description: "Facing a decision? Get focused challenges and an optional decision brief" },
|
|
93
|
+
{ value: "overthink", label: "overthink", description: "Want a quiet second look after big work? Get private notes from the active model" },
|
|
94
94
|
{ value: "config", label: "config", description: "Global defaults, diagnostics and feature settings" },
|
|
95
95
|
{ value: "advisor", label: "advisor", description: "Check whether the executor's advisor tool is available right now" },
|
|
96
|
-
{ value: "advisor-steer", label: "advisor-steer", description: "
|
|
96
|
+
{ value: "advisor-steer", label: "advisor-steer", description: "Want to shape future advice? Save priorities for the advisor" },
|
|
97
97
|
{ value: "help", label: "help", description: "Learn what Bro does and what it can access" },
|
|
98
98
|
];
|
|
99
99
|
const KNOWN_ACTIONS = new Set(COMMANDS.map((command) => command.value));
|
package/src/btw.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./settings.ts";
|
|
15
15
|
import { captureShowTranscript } from "./show.ts";
|
|
16
16
|
import { BRO_OVERLAY, broOverlayArea, formatNotice, modalHeight, openBroOverlay, renderFrame, Scroller, type Area, type NoticeTone, type Theme, type TuiLike } from "./modal-kit.ts";
|
|
17
|
-
import {
|
|
17
|
+
import { type BroMouseEvent, type BroMouseResult } from "./ui-capabilities.ts";
|
|
18
18
|
import { errorMessage } from "./util.ts";
|
|
19
19
|
|
|
20
20
|
export const BTW_CONTEXT_TURNS = 8;
|
|
@@ -109,7 +109,7 @@ export type BtwComposerAction =
|
|
|
109
109
|
| { kind: "mode" }
|
|
110
110
|
| { kind: "retry" }
|
|
111
111
|
| { kind: "clipboard"; all: boolean }
|
|
112
|
-
| { kind: "
|
|
112
|
+
| { kind: "help" }
|
|
113
113
|
| { kind: "removed"; command: string }
|
|
114
114
|
| { kind: "question"; text: string };
|
|
115
115
|
|
|
@@ -121,8 +121,8 @@ export function parseBtwComposerCommand(value: string): BtwComposerAction {
|
|
|
121
121
|
if (command === "/copy" || command === "/copy-all") {
|
|
122
122
|
return { kind: "clipboard", all: command === "/copy-all" };
|
|
123
123
|
}
|
|
124
|
-
if (command === "/
|
|
125
|
-
if (
|
|
124
|
+
if (command === "/help") return { kind: "help" };
|
|
125
|
+
if (["/insert", "/insert-all", "/insert!", "/insert-all!"].includes(command)) return { kind: "removed", command };
|
|
126
126
|
return { kind: "question", text: command };
|
|
127
127
|
}
|
|
128
128
|
|
|
@@ -330,7 +330,7 @@ export class BtwModal implements Focusable {
|
|
|
330
330
|
body: (rows, innerWidth) => this.scroller.view(this.markdown.render(innerWidth), rows),
|
|
331
331
|
// The frame drops lines from the top when space runs out, so the composer goes last.
|
|
332
332
|
footer: [
|
|
333
|
-
...(this.appearance.commands === "" ? [] : wrapTextWithAnsi(this.appearance.commands ?? "Commands: /mode · /copy · /copy-all · /
|
|
333
|
+
...(this.appearance.commands === "" ? [] : wrapTextWithAnsi(this.appearance.commands ?? "Commands: /mode · /copy · /copy-all · /clear · /retry · /help", inner)),
|
|
334
334
|
...(this.suggestions ? wrapTextWithAnsi(this.theme.fg("accent", this.suggestions), inner) : []),
|
|
335
335
|
this.theme.fg("accent", this.theme.bold(this.appearance.inputLabel ?? "Your message to Bro")),
|
|
336
336
|
this.input.render(inner)[0] ?? "",
|
|
@@ -567,25 +567,6 @@ export async function openBtwModal(
|
|
|
567
567
|
}
|
|
568
568
|
};
|
|
569
569
|
|
|
570
|
-
const insert = async (all: boolean) => {
|
|
571
|
-
const text = all ? transcript() : (thread.turns.at(-1)?.answer ?? "");
|
|
572
|
-
if (!text.trim()) {
|
|
573
|
-
modal.setNotice("Nothing to insert yet.", "warning");
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
if (!canBroInsertIntoEditor(ctx)) {
|
|
577
|
-
const result = await insertBroDesktopText(ctx, text);
|
|
578
|
-
modal.setNotice(result === "inserted" ? "Inserted into the main editor. Review it before sending." : result === "not_empty" ? "Main editor has a draft or attachment. Clear it first, then insert again." : "Could not confirm insertion. Check the main editor before trying again.", result === "inserted" ? "success" : result === "not_empty" ? "warning" : "error");
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
if (ctx.ui.getEditorText().trim()) {
|
|
582
|
-
modal.setNotice("Main editor has a draft. Edit or clear it first, then insert again.", "warning");
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
ctx.ui.setEditorText(text);
|
|
586
|
-
modal.setNotice(all ? "Inserted the full thread into the main editor." : "Inserted the latest answer into the main editor.", "success");
|
|
587
|
-
};
|
|
588
|
-
|
|
589
570
|
function submit(value: string): void {
|
|
590
571
|
const action = parseBtwComposerCommand(value);
|
|
591
572
|
if (action.kind === "clear") {
|
|
@@ -603,14 +584,14 @@ export async function openBtwModal(
|
|
|
603
584
|
void copyOut(action.all);
|
|
604
585
|
return;
|
|
605
586
|
}
|
|
606
|
-
if (action.kind === "
|
|
587
|
+
if (action.kind === "removed") {
|
|
607
588
|
modal.clearComposer();
|
|
608
|
-
|
|
589
|
+
modal.setNotice(`${action.command} was removed. Use /copy or /copy-all, then paste where you want it.`, "warning");
|
|
609
590
|
return;
|
|
610
591
|
}
|
|
611
|
-
if (action.kind === "
|
|
592
|
+
if (action.kind === "help") {
|
|
612
593
|
modal.clearComposer();
|
|
613
|
-
modal.setNotice(
|
|
594
|
+
modal.setNotice("Commands: /mode, /copy, /copy-all, /clear, /retry, /help. Esc closes; completed turns stay private.");
|
|
614
595
|
return;
|
|
615
596
|
}
|
|
616
597
|
if (action.kind === "retry") {
|
package/src/elevate-engine.ts
CHANGED
|
@@ -71,18 +71,6 @@ export function stripElevateFence(value: string): string {
|
|
|
71
71
|
return fence ? fence[1]!.trim() : raw;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
/**
|
|
75
|
-
* The one rule that protects unsent work: insertion may replace the editor draft Elevate was
|
|
76
|
-
* opened on, and may fill an empty editor, but must never overwrite an unrelated draft.
|
|
77
|
-
*/
|
|
78
|
-
export function elevateInsertAllowed(
|
|
79
|
-
elevatingEditorDraft: boolean,
|
|
80
|
-
initialEditor: string,
|
|
81
|
-
currentEditor: string,
|
|
82
|
-
): boolean {
|
|
83
|
-
return elevatingEditorDraft ? currentEditor === initialEditor : !currentEditor.trim();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
74
|
/** Deliberately strict: invalid model output must not create an unchecked selection. */
|
|
87
75
|
export function parseElevateDiscovery(response: string): ElevateDiscovery {
|
|
88
76
|
// Take the only discovery payload in the reply. Choosing between several would mean guessing
|
package/src/elevate.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { Editor, Markdown, matchesKey, wrapTextWithAnsi, type EditorTheme, type
|
|
|
4
4
|
import { runBackendText } from "./backend.ts";
|
|
5
5
|
import {
|
|
6
6
|
buildElevateDiscoveryPrompt, buildElevateUpgradePrompt, parseElevateDiscovery,
|
|
7
|
-
selectedFindings, stripElevateFence,
|
|
7
|
+
selectedFindings, stripElevateFence, captureElevateContext, isElevateContextOverflow,
|
|
8
8
|
reduceElevateContext, elevateDisplayText, type ElevateContextMode, type ElevateDiscovery, type ElevateInput,
|
|
9
9
|
} from "./elevate-engine.ts";
|
|
10
10
|
import { BRO_OVERLAY, broOverlayArea, buttonLabels, delegateMouse, formatNotice, modalHeight, openBroOverlay, renderFrame, Scroller, wrapButtons, type Area, type Theme, type TuiLike } from "./modal-kit.ts";
|
|
11
11
|
import { readPreferences, readSettings, selectionForCapability, selectionLabel } from "./settings.ts";
|
|
12
|
-
import {
|
|
12
|
+
import { type BroMouseEvent, type BroMouseResult } from "./ui-capabilities.ts";
|
|
13
13
|
import { errorMessage } from "./util.ts";
|
|
14
14
|
|
|
15
15
|
type Stage = "compose" | "discovering" | "review" | "upgrading" | "ready" | "failed";
|
|
@@ -65,7 +65,6 @@ export class ElevateModal implements Focusable {
|
|
|
65
65
|
private readonly onClose: () => void,
|
|
66
66
|
private readonly onDiscover: (objective: string) => void,
|
|
67
67
|
private readonly onUpgrade: (indexes: ReadonlySet<number>) => void,
|
|
68
|
-
private readonly onInsert: (text: string) => void,
|
|
69
68
|
private readonly onRetry: () => void,
|
|
70
69
|
private readonly onDispose: () => void,
|
|
71
70
|
private readonly onContextChange: (mode: ElevateContextMode) => void = () => {},
|
|
@@ -169,7 +168,7 @@ export class ElevateModal implements Focusable {
|
|
|
169
168
|
// the checklist itself, which is the part the user acts on.
|
|
170
169
|
text = this.discovery.assessment;
|
|
171
170
|
} else if (this.stage === "upgrading") text = "## Upgrading your request\n\nPreserving your outcome and constraints. Incorporating only the ideas you approved…";
|
|
172
|
-
else if (this.stage === "ready") text = `## Revised request\n\n${this.revised}\n\n*
|
|
171
|
+
else if (this.stage === "ready") text = `## Revised request\n\n${this.revised}\n\n*Copy and paste where you want it. Nothing has been submitted to Pi.*`;
|
|
173
172
|
else if (this.stage === "failed") text = "## Elevate stopped\n\nYour original request has not changed. Retry, or close this window.";
|
|
174
173
|
this.markdown.setText(text);
|
|
175
174
|
this.tui.requestRender();
|
|
@@ -211,7 +210,6 @@ export class ElevateModal implements Focusable {
|
|
|
211
210
|
];
|
|
212
211
|
}
|
|
213
212
|
if (this.stage === "ready") return [
|
|
214
|
-
{ label: "Insert into editor", short: "Insert", run: () => this.onInsert(this.revised) },
|
|
215
213
|
{ label: "Copy", short: "Copy", run: () => void this.copy(this.revised, "Copied revised request.") },
|
|
216
214
|
contextButton,
|
|
217
215
|
// Back to the findings with the approvals intact, so a rewrite can be reconsidered without
|
|
@@ -455,13 +453,10 @@ export class ElevateModal implements Focusable {
|
|
|
455
453
|
export async function openElevateModal(ctx: ExtensionCommandContext, request = ""): Promise<void> {
|
|
456
454
|
const initialEditor = ctx.ui.getEditorText();
|
|
457
455
|
const initialObjective = request.trim() || initialEditor.trim();
|
|
458
|
-
// Whether the editor draft is the thing being elevated. Only then may insertion replace it.
|
|
459
|
-
const elevatingEditorDraft = !request.trim() && !!initialEditor.trim();
|
|
460
456
|
const branch = ctx.sessionManager.getBranch();
|
|
461
457
|
await openBroOverlay<void>(ctx, (tui, theme, _keybindings, done) => {
|
|
462
458
|
let closed = false;
|
|
463
459
|
let controller: AbortController | undefined;
|
|
464
|
-
let inserting = false;
|
|
465
460
|
let original = initialObjective;
|
|
466
461
|
let contextMessages = captureElevateContext(branch, "messages");
|
|
467
462
|
let reduced = false;
|
|
@@ -477,7 +472,7 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
|
|
|
477
472
|
done(undefined);
|
|
478
473
|
};
|
|
479
474
|
|
|
480
|
-
const modal = new ElevateModal(tui, theme, close, discover, upgrade,
|
|
475
|
+
const modal = new ElevateModal(tui, theme, close, discover, upgrade, retryStage, close, (mode) => {
|
|
481
476
|
contextMessages = captureElevateContext(branch, mode);
|
|
482
477
|
reduced = false;
|
|
483
478
|
reduceOnRetry = false;
|
|
@@ -562,35 +557,6 @@ export async function openElevateModal(ctx: ExtensionCommandContext, request = "
|
|
|
562
557
|
else void discover(original);
|
|
563
558
|
}
|
|
564
559
|
|
|
565
|
-
async function insert(text: string): Promise<void> {
|
|
566
|
-
if (closed || inserting) return;
|
|
567
|
-
if (canBroInsertIntoEditor(ctx)) {
|
|
568
|
-
const current = ctx.ui.getEditorText();
|
|
569
|
-
if (!elevateInsertAllowed(elevatingEditorDraft, initialEditor, current)) {
|
|
570
|
-
modal.setNotice(elevatingEditorDraft
|
|
571
|
-
? "Main editor changed. Copy instead; your draft was not overwritten."
|
|
572
|
-
: "Main editor has a draft. Clear it first, or press Copy instead.");
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
ctx.ui.setEditorText(text);
|
|
576
|
-
close();
|
|
577
|
-
ctx.ui.notify("Elevate inserted the revised request. Review it before submitting.", "info");
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
// Desktop has an atomic empty-editor insertion API. Never overwrite a draft there.
|
|
581
|
-
inserting = true;
|
|
582
|
-
let result: Awaited<ReturnType<typeof insertBroDesktopText>>;
|
|
583
|
-
try { result = await insertBroDesktopText(ctx, text); }
|
|
584
|
-
finally { inserting = false; }
|
|
585
|
-
if (closed) return;
|
|
586
|
-
modal.setNotice(result === "inserted"
|
|
587
|
-
? "Inserted into the main editor. Review it before submitting."
|
|
588
|
-
: result === "not_empty"
|
|
589
|
-
? "Desktop editor has a draft; copy the revised request instead."
|
|
590
|
-
: "Desktop cannot insert here; copy the revised request instead.");
|
|
591
|
-
if (result === "inserted") close();
|
|
592
|
-
}
|
|
593
|
-
|
|
594
560
|
modal.setCompose(initialObjective);
|
|
595
561
|
return modal;
|
|
596
562
|
}, { mouse: true });
|
package/src/explain-modal.ts
CHANGED
|
@@ -382,6 +382,15 @@ export function helpText(settings?: BroSettings, settingsError?: string, prefere
|
|
|
382
382
|
|
|
383
383
|
Quick reference. Full user guide: https://github.com/tranhoangnguyen03/pi-bro/blob/main/docs/user-guide.md
|
|
384
384
|
|
|
385
|
+
## Pick by need
|
|
386
|
+
|
|
387
|
+
- **Understand what already exists:** Simplify and Show; Architecture for this repository.
|
|
388
|
+
- **Explore what could exist:** BTW for side questions; Grill Me for decisions.
|
|
389
|
+
- **Get advice on existing work:** Guided Review; Overthink for automatic second looks; agent-facing Advisor.
|
|
390
|
+
- **Guide the agent:** Elevate for assignments; Remember Me for approved context (about_user); Advisor Steering for priorities.
|
|
391
|
+
|
|
392
|
+
These are needs, not modes. Copied text does not enter Pi until you paste and submit it.
|
|
393
|
+
|
|
385
394
|
## Explain and show
|
|
386
395
|
|
|
387
396
|
- \`/bro\` — open Simplify and explain the latest completed assistant reply
|
|
@@ -412,17 +421,16 @@ Quick reference. Full user guide: https://github.com/tranhoangnguyen03/pi-bro/bl
|
|
|
412
421
|
|
|
413
422
|
## Grill Me (experimental)
|
|
414
423
|
|
|
415
|
-
- \`/bro grill-me [topic]\` — private decision interview. Use /consolidate, /
|
|
424
|
+
- \`/bro grill-me [topic]\` — private decision interview. Use /consolidate, /copy or /help. Full-access risk: docs/grill-me.md.
|
|
416
425
|
|
|
417
426
|
## Overthink
|
|
418
427
|
|
|
419
|
-
- \`/bro overthink\` — view private automatic second-look notes without
|
|
420
|
-
- \`/bro config\` → Features → Overthink provides automatic on/off and editable global starting questions; session edits stay with their Pi session. See docs/overthink.md.
|
|
428
|
+
- \`/bro overthink\` — view private automatic second-look notes without a model call. Ctrl+R retries; Ctrl+E edits session questions; Ctrl+C copies. Uses the active Pi model. Turn off or edit defaults in \`/bro config\` → Features → Overthink. See docs/overthink.md.
|
|
421
429
|
|
|
422
430
|
## Side conversation
|
|
423
431
|
|
|
424
432
|
- \`/bro btw [question]\` — open a side conversation seeded with recent main-session context. It starts conversation-only; reopening keeps the thread and its mode.
|
|
425
|
-
- Enter asks; empty Enter or \`/retry\` re-asks. \`/mode\` toggles conversation-only/full workspace access, retaining the thread. \`/copy\`, \`/copy-all\` copy
|
|
433
|
+
- Enter asks; empty Enter or \`/retry\` re-asks. \`/mode\` toggles conversation-only/full workspace access, retaining the thread. \`/copy\`, \`/copy-all\` copy. \`/clear\` resets; \`/help\` shows controls; Esc closes.
|
|
426
434
|
|
|
427
435
|
## Advisor
|
|
428
436
|
|
|
@@ -466,7 +474,7 @@ The mode decides how much of the source to keep; your preferences decide who it'
|
|
|
466
474
|
|
|
467
475
|
## Privacy
|
|
468
476
|
|
|
469
|
-
Bro sends the captured source (or, for the advisor, the executor's instructions, tools, and conversation) to the selected backend and its model provider, which may retain it under their own policies. Your preferences go with every explain, show, btw, and Guided Review request. Guided Review sends PR data/diff and relevant private questions; records/source remain locally under getAgentDir()/bro-reviews. Copy finding goes to the system clipboard, not GitHub. Nothing is added to Pi's conversation unless you
|
|
477
|
+
Bro sends the captured source (or, for the advisor, the executor's instructions, tools, and conversation) to the selected backend and its model provider, which may retain it under their own policies. Your preferences go with every explain, show, btw, and Guided Review request. Guided Review sends PR data/diff and relevant private questions; records/source remain locally under getAgentDir()/bro-reviews. Copy finding goes to the system clipboard, not GitHub. Nothing is added to Pi's conversation unless you paste and send it, except advisor answers and approved memories read through about_user, which return to the agent as tool results. Access controls differ by backend; see the user guide.`;
|
|
470
478
|
}
|
|
471
479
|
|
|
472
480
|
// The overlay framing pattern is adapted from pi-btw (MIT); see THIRD_PARTY_NOTICES.md.
|
package/src/grill-engine.ts
CHANGED
|
@@ -24,7 +24,7 @@ export function parseGrillArguments(raw: string): { topic: string; depth: GrillD
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const GRILL_COMMANDS = [
|
|
27
|
-
"/consolidate", "/
|
|
27
|
+
"/consolidate", "/copy", "/depth light", "/depth balanced",
|
|
28
28
|
"/depth exhaustive", "/retry", "/new ", "/access inspect", "/access full", "/help",
|
|
29
29
|
] as const;
|
|
30
30
|
|
|
@@ -36,7 +36,7 @@ export type GrillAction =
|
|
|
36
36
|
| { kind: "message"; text: string }
|
|
37
37
|
| { kind: "depth"; value: GrillDepth }
|
|
38
38
|
| { kind: "access"; value: "inspect" | "full" }
|
|
39
|
-
| { kind: "consolidate" | "
|
|
39
|
+
| { kind: "consolidate" | "copy" | "help" | "retry" | "empty" }
|
|
40
40
|
| { kind: "new"; topic: string }
|
|
41
41
|
| { kind: "invalid"; message: string };
|
|
42
42
|
|
|
@@ -47,7 +47,8 @@ export function parseGrillCommand(value: string): GrillAction {
|
|
|
47
47
|
if (text === "/help") return { kind: "help" };
|
|
48
48
|
if (text.startsWith("/new ") && text.slice(5).trim()) return { kind: "new", topic: text.slice(5).trim() };
|
|
49
49
|
if (text === "/retry") return { kind: "retry" };
|
|
50
|
-
if (text === "/
|
|
50
|
+
if (text === "/copy") return { kind: "copy" };
|
|
51
|
+
if (text === "/insert-last-message") return { kind: "invalid", message: "/insert-last-message was removed. Use /copy, then paste the result where you want it." };
|
|
51
52
|
if (text.startsWith("/depth")) {
|
|
52
53
|
const tokens = text.split(/\s+/);
|
|
53
54
|
return tokens.length === 2 && GRILL_DEPTHS.some((v) => v === tokens[1])
|
package/src/grill.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { matchesKey } from "@earendil-works/pi-tui";
|
|
2
|
-
import type
|
|
2
|
+
import { copyToClipboard, type ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { execute as executeBackend } from "./backend.ts";
|
|
4
4
|
import { BtwModal, BTW_CONTEXT_MAX, BTW_CONTEXT_TURNS, formatBtwTranscript } from "./btw.ts";
|
|
5
5
|
import {
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import { readPreferences, readSettings, selectionForCapability, selectionLabel, capabilityBackend } from "./settings.ts";
|
|
10
10
|
import { captureShowTranscript } from "./show.ts";
|
|
11
11
|
import { openBroOverlay } from "./modal-kit.ts";
|
|
12
|
-
import { canBroInsertIntoEditor, insertBroDesktopText } from "./ui-capabilities.ts";
|
|
13
12
|
import { errorMessage } from "./util.ts";
|
|
14
13
|
|
|
15
14
|
/**
|
|
@@ -20,7 +19,7 @@ import { errorMessage } from "./util.ts";
|
|
|
20
19
|
export async function openGrillModal(
|
|
21
20
|
ctx: ExtensionCommandContext,
|
|
22
21
|
thread: GrillThread,
|
|
23
|
-
options: { start?: boolean; onChange?: () => void } = {},
|
|
22
|
+
options: { start?: boolean; onChange?: () => void; copy?: (text: string) => Promise<void> } = {},
|
|
24
23
|
): Promise<void> {
|
|
25
24
|
const openingBackend = capabilityBackend(await readSettings(), "btw");
|
|
26
25
|
await openBroOverlay<void>(
|
|
@@ -35,7 +34,7 @@ export async function openGrillModal(
|
|
|
35
34
|
let activeBackend = openingBackend;
|
|
36
35
|
let showingHelp = false;
|
|
37
36
|
let confirmation: "full" | string | undefined;
|
|
38
|
-
const help = "## Commands\n\n- /consolidate — draft a decision brief; keep talking afterward\n- /
|
|
37
|
+
const help = "## Commands\n\n- /consolidate — draft a decision brief; keep talking afterward\n- /copy — copy the latest Bro reply or consolidated brief to the clipboard\n- /depth light|balanced|exhaustive — change depth\n- /retry — retry a failed operation or regenerate the latest reply\n- /new <topic> — start over (confirmation required)\n- /access inspect|full — choose access (full requires confirmation)\n- /help — show this list\n\nAnswer with a letter or your own words. Esc returns to the interview. Type / and use Tab to complete a command.";
|
|
39
38
|
|
|
40
39
|
const transcript = () => {
|
|
41
40
|
const conversation = formatBtwTranscript(pendingTurn ? [...thread.turns, pendingTurn] : thread.turns);
|
|
@@ -193,7 +192,7 @@ export async function openGrillModal(
|
|
|
193
192
|
if (replace) thread.turns.pop();
|
|
194
193
|
thread.turns.push({ question: "/consolidate", answer: outcome.text });
|
|
195
194
|
delete thread.retry;
|
|
196
|
-
modal.setNotice("Brief ready. Keep talking or /
|
|
195
|
+
modal.setNotice("Brief ready. Keep talking or use /copy.", "success");
|
|
197
196
|
} catch (error) {
|
|
198
197
|
if (!closed && !attempt.signal.aborted) modal.setNotice(errorMessage(error), "error");
|
|
199
198
|
} finally {
|
|
@@ -203,18 +202,15 @@ export async function openGrillModal(
|
|
|
203
202
|
}
|
|
204
203
|
};
|
|
205
204
|
|
|
206
|
-
const
|
|
205
|
+
const copy = async () => {
|
|
207
206
|
const text = thread.turns.at(-1)?.answer || "";
|
|
208
|
-
if (!
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
modal.setNotice(
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
if (!text.trim()) { modal.setNotice("Nothing to copy yet.", "warning"); return; }
|
|
208
|
+
try {
|
|
209
|
+
await (options.copy ?? copyToClipboard)(text);
|
|
210
|
+
if (!closed) modal.setNotice("Copied the latest reply to the clipboard.", "success");
|
|
211
|
+
} catch (error) {
|
|
212
|
+
if (!closed) modal.setNotice(`Copy failed: ${errorMessage(error)}`, "error");
|
|
214
213
|
}
|
|
215
|
-
if (ctx.ui.getEditorText().trim()) { modal.setNotice("Main editor has a draft. Clear it first.", "warning"); return; }
|
|
216
|
-
ctx.ui.setEditorText(text);
|
|
217
|
-
modal.setNotice("Inserted into main editor without sending.", "success");
|
|
218
214
|
};
|
|
219
215
|
const clear = (topic: string) => {
|
|
220
216
|
thread.topic = topic;
|
|
@@ -281,7 +277,7 @@ export async function openGrillModal(
|
|
|
281
277
|
} else clear(action.topic);
|
|
282
278
|
return;
|
|
283
279
|
}
|
|
284
|
-
if (action.kind === "
|
|
280
|
+
if (action.kind === "copy") { modal.clearComposer(); void copy(); return; }
|
|
285
281
|
if (action.kind === "consolidate") { modal.clearComposer(); void consolidate(); return; }
|
|
286
282
|
if (action.kind === "retry") {
|
|
287
283
|
modal.clearComposer();
|
package/src/ui-capabilities.ts
CHANGED
|
@@ -22,18 +22,6 @@ export function broModalRows(tui: unknown, terminalRows: number | undefined): nu
|
|
|
22
22
|
return typeof candidate === "number" && Number.isFinite(candidate) && candidate > 0 ? Math.floor(candidate) : 30;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export async function insertBroDesktopText(ctx: UiContext, text: string): Promise<"inserted" | "not_empty" | "unavailable"> {
|
|
26
|
-
if (!hasBroCustomUi(ctx) || ctx.mode !== "rpc") return "unavailable";
|
|
27
|
-
const ui = ctx.ui as DesktopUi & { insertEditorTextIfEmpty?: (text: string) => Promise<"inserted" | "not_empty" | "unavailable"> };
|
|
28
|
-
try {
|
|
29
|
-
const caps = ui.getDesktopUiCapabilities?.() as { atomicEditorInsert?: boolean } | undefined;
|
|
30
|
-
return caps?.atomicEditorInsert === true && ui.insertEditorTextIfEmpty ? await ui.insertEditorTextIfEmpty(text) : "unavailable";
|
|
31
|
-
} catch { return "unavailable"; }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Only terminal mode uses synchronous insertion; Desktop uses insertBroDesktopText instead. */
|
|
35
|
-
export function canBroInsertIntoEditor(ctx: UiContext): boolean { return ctx.mode === "tui"; }
|
|
36
|
-
|
|
37
25
|
/** Any raw SGR mouse report; regular-mode reporting delivers these to handleInput. */
|
|
38
26
|
export const SGR_MOUSE = /^\x1b\[<(\d+);(\d+);(\d+)[Mm]$/;
|
|
39
27
|
|