pi-bro 0.32.0 → 0.34.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 +20 -0
- package/README.md +5 -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/guided-review.md +25 -2
- package/docs/pig-compatibility.md +1 -1
- package/docs/reference/commands.md +4 -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 +18 -10
- package/src/grill-engine.ts +4 -3
- package/src/grill.ts +12 -16
- package/src/review-modal.ts +3 -0
- package/src/review-ui.ts +128 -22
- package/src/review.ts +9 -0
- package/src/ui-capabilities.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to pi-bro are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.34.0] - 2026-11-07
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Guided Review can delete a saved PR review, its notes and captured source through a confirmed picker, offline PR target, or Overview action.
|
|
10
|
+
- Deletion by PR target uses local records instead of GitHub; ambiguous bare PR numbers require a full URL. Resume and delete share the same picker and preserve saved titles.
|
|
11
|
+
- Active in-process reviews block command deletion. Overview deletion holds the active lock, settles pending saves and cannot recreate the record on teardown. The storage helper validates review IDs and leaves sibling reviews and Pi settings untouched.
|
|
12
|
+
- Offline storage and picker tests plus a manual test journey for confirmation, active writers and cleanup.
|
|
13
|
+
- No automatic cleanup, new storage engine, live backend call or GitHub mutation.
|
|
14
|
+
|
|
15
|
+
## [0.33.0] - 2026-11-07
|
|
16
|
+
|
|
17
|
+
### Highlights
|
|
18
|
+
|
|
19
|
+
- Feature discovery now starts from four human needs: understand what exists, explore what could exist, assess existing work, and guide the agent.
|
|
20
|
+
- 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.
|
|
21
|
+
- Elevate copies the revised assignment without replacing the unsent main-editor draft. Obsolete insertion code and its tests are removed.
|
|
22
|
+
- Built-in help, command completion, feature guides and developer checks align around common interaction meanings while retaining each feature's special actions.
|
|
23
|
+
- 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.
|
|
24
|
+
|
|
5
25
|
## [0.32.0] - 2026-11-07
|
|
6
26
|
|
|
7
27
|
### Highlights
|
package/README.md
CHANGED
|
@@ -66,14 +66,15 @@ 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
|
+
| `/bro guided-review delete [PR]` | Choose a saved review and explicitly delete its record, questions and captured source after confirmation. No automatic cleanup. |
|
|
72
73
|
| `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
74
|
| `/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
75
|
|
|
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
|
|
76
|
+
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.
|
|
77
|
+
**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
78
|
|
|
78
79
|
Guided Review has its own [guide](docs/guided-review.md).
|
|
79
80
|
|
|
@@ -123,7 +124,7 @@ external CLI's provider credentials, but a CLI signs in its own way, which can
|
|
|
123
124
|
include API keys set in your environment. The built-in **Pi** backend is the
|
|
124
125
|
exception: it runs in-process, so it reads your Pi `auth.json` and reuses your
|
|
125
126
|
Pi provider credentials for the model you select. Nothing Bro produces enters
|
|
126
|
-
Pi's conversation unless you
|
|
127
|
+
Pi's conversation unless you paste and submit it, except advisor answers, which return to
|
|
127
128
|
the agent as tool results.
|
|
128
129
|
|
|
129
130
|
> [!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
|
|
package/docs/guided-review.md
CHANGED
|
@@ -81,6 +81,23 @@ Copy finding copies a finding's text, evidence references and suggested fix/chec
|
|
|
81
81
|
|
|
82
82
|
Use Overview → Regenerate guide only when you want a fresh explanation/assessment. Confirmation identifies the captured revision and the model call. **It reuses the same captured source; it is not an update fetch.** Successful output replaces one current guide. Failure/cancellation keeps the current guide. Questions and nonempty drafts retain their original context under Your questions; there is no guide-version picker. A replacement that fails to save remains in memory with retry controls.
|
|
83
83
|
|
|
84
|
+
### Delete a saved review
|
|
85
|
+
|
|
86
|
+
Use **Overview → Delete review** inside a saved review, or run
|
|
87
|
+
`/bro guided-review delete` to choose from your saved reviews. For a specific
|
|
88
|
+
record, use `/bro guided-review delete <PR number or URL>`. Deletion reads
|
|
89
|
+
only local saved records: no GitHub access or model call is required. A bare
|
|
90
|
+
PR number must match exactly one saved review across all repositories, regardless
|
|
91
|
+
of your current working directory. In contrast, opening a PR by number uses
|
|
92
|
+
the current repository. Use the full PR URL if multiple saved reviews share
|
|
93
|
+
that number. If none are saved, Bro says there is nothing to delete.
|
|
94
|
+
Pressing Esc cancels silently.
|
|
95
|
+
Bro shows the target and asks for confirmation before removing its JSON record,
|
|
96
|
+
private questions/drafts and captured Git source. Closing the picker or declining
|
|
97
|
+
the confirmation changes nothing. Close an open review first; an active writer
|
|
98
|
+
blocks deletion. This affects only the selected review, not your main working tree.
|
|
99
|
+
Deletion cannot be undone. There is no automatic cleanup.
|
|
100
|
+
|
|
84
101
|
## Access, privacy and storage
|
|
85
102
|
|
|
86
103
|
Review never runs with full-access or bypass flags. **Claude, Muse, and Pi provide strict file-only inspection** and are recommended for untrusted PRs: Claude runs with `--restricted`, Read/Grep/Glob only, `dontAsk`, safe mode and no MCP; Muse disables write, shell and web tools, foreign personal context and native session logs, without trusting repository rules; Pi runs in-process with `read/grep/find/ls` only, no shell, and an isolated session. No model-run project tests, commands, Git or network tools are available on Claude, Muse, or Pi.
|
|
@@ -99,7 +116,13 @@ Records, private text and captured source remain under:
|
|
|
99
116
|
${PI_CODING_AGENT_DIR:-$HOME/.pi/agent}/bro-reviews/
|
|
100
117
|
```
|
|
101
118
|
|
|
102
|
-
The implementation uses the host's `getAgentDir()`. Records are
|
|
119
|
+
The implementation uses the host's `getAgentDir()`. Records are
|
|
120
|
+
`<review-id>.json`, captured source lives under `source/<review-id>/`,
|
|
121
|
+
including preserved incomplete recovery directories. Failed/corrupt records are
|
|
122
|
+
reported without overwriting them. There is no cross-machine sync or automatic
|
|
123
|
+
cleanup. Use the explicit deletion picker rather than editing these files by hand.
|
|
124
|
+
Cross-process writers are not locked, so close the same review in every Pi process
|
|
125
|
+
before deletion.
|
|
103
126
|
|
|
104
127
|
One open writer per review is supported within a Pi process. Concurrent editing of the same review from separate processes is unsupported.
|
|
105
128
|
|
|
@@ -107,7 +130,7 @@ One open writer per review is supported within a Pi process. Concurrent editing
|
|
|
107
130
|
|
|
108
131
|
| Problem | What to do |
|
|
109
132
|
| --- | --- |
|
|
110
|
-
| GitHub unavailable when reopening | Use bare `/bro guided-review` to choose a saved review;
|
|
133
|
+
| GitHub unavailable when reopening | Use bare `/bro guided-review` to choose a saved review; resume and deletion from local records do not fetch |
|
|
111
134
|
| Sandboxed shell review backend (Codex, Grok, Agy) | Advisory shown; choose Claude, Muse, or Pi in `/bro config` for strict file-only inspection on untrusted PRs |
|
|
112
135
|
| Git/gh authentication or fetch error | Read the acquisition error; check Git/`gh auth status`; retry explicitly |
|
|
113
136
|
| Invalid/failed preparation | Changed files remain available; use Prepare guide to retry when ready for another call |
|
|
@@ -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.
|
|
@@ -41,11 +41,12 @@ Typing `/bro ` displays ten task-level suggestions: `simplify`, `show`, `btw`, `
|
|
|
41
41
|
| `/bro architecture [focus]` | Read the current project and create or refresh `docs/architecture/` with Markdown, an editable graph and offline HTML. Inherits BTW backend settings. [Guide](../features/architecture.md). |
|
|
42
42
|
| `/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. |
|
|
43
43
|
| `/bro guided-review` | List saved reviews; `resume` is an alias. |
|
|
44
|
+
| `/bro guided-review delete [PR number or URL]` | Choose and confirm deletion of a saved review and its captured source. Without a target, opens the saved-review picker. |
|
|
44
45
|
| `/bro remember-me [thought]` | Start a private memory-writing conversation, browse and expand memories, and approve saves explicitly. [Guide](../remember-me.md). |
|
|
45
46
|
| `/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;
|
|
47
|
+
| `/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). |
|
|
48
|
+
| `/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). |
|
|
49
|
+
| `/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
50
|
| `/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
51
|
| `/bro advisor-steer` | View, edit, save, or clear the one persistent steering brief the advisor always sees. |
|
|
51
52
|
| `/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.34.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
|
|
@@ -395,14 +404,14 @@ Quick reference. Full user guide: https://github.com/tranhoangnguyen03/pi-bro/bl
|
|
|
395
404
|
|
|
396
405
|
## Architecture documentation
|
|
397
406
|
|
|
398
|
-
- \`/bro architecture [focus]\` —
|
|
407
|
+
- \`/bro architecture [focus]\` — create source-backed docs and an offline map in \`docs/architecture/\` using the BTW model. See docs/features/architecture.md.
|
|
399
408
|
|
|
400
409
|
## Guided Review
|
|
401
410
|
|
|
402
|
-
- \`/bro guided-review <PR number or URL>\` —
|
|
403
|
-
- Reviews save automatically. Reopen
|
|
411
|
+
- \`/bro guided-review <PR number or URL>\` — assess captured PR code in local interactive Pi (requires Git and authenticated gh).
|
|
412
|
+
- Reviews save automatically. Reopen without a model call; bare \`/bro guided-review\` lists saved reviews.\n- \`/bro guided-review delete [PR number or URL]\` — delete one local saved review with confirmation; Overview also offers Delete review.
|
|
404
413
|
- Enter opens items or activates focused actions. Tab changes focus; Esc goes back, then closes from Contents. Close saves; Stop and close cancels active work first.
|
|
405
|
-
- Copy finding
|
|
414
|
+
- Copy finding goes to the clipboard, not GitHub. Regenerate reuses captured source. For untrusted PRs, choose file-only Claude/Muse/Pi; Codex/Grok offer sandboxed shell, while Agy may write captured files. Bro warns when shell is allowed. See docs/guided-review.md.
|
|
406
415
|
|
|
407
416
|
## Elevate
|
|
408
417
|
|
|
@@ -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
|
|
|
@@ -434,7 +442,7 @@ Quick reference. Full user guide: https://github.com/tranhoangnguyen03/pi-bro/bl
|
|
|
434
442
|
## Configure and check
|
|
435
443
|
|
|
436
444
|
- \`/bro preferences\` — tell Bro about yourself and how you like answers; added to explain, show, btw, Elevate and Guided Review prompts, never the advisor (**Ctrl+S** save, **Ctrl+K** delete, **Ctrl+C** copy, **Esc** close)
|
|
437
|
-
- \`/bro config\` —
|
|
445
|
+
- \`/bro config\` — shared defaults, per-feature models, preferences, Doctor and Overthink. Esc backs out.
|
|
438
446
|
- \`/bro mode [brief|balanced|faithful]\` — view or choose the explanation mode
|
|
439
447
|
- \`/bro doctor\` — check settings, preferences, and every selected backend without running a model turn
|
|
440
448
|
|
|
@@ -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/review-modal.ts
CHANGED
|
@@ -49,6 +49,7 @@ export type ReviewControls = {
|
|
|
49
49
|
ask(target: string, question: string): void;
|
|
50
50
|
prepare(): void;
|
|
51
51
|
regenerate(): void;
|
|
52
|
+
deleteReview(): void;
|
|
52
53
|
retrySave(): void;
|
|
53
54
|
stop(): void;
|
|
54
55
|
close(): void;
|
|
@@ -297,6 +298,7 @@ export class ReviewModal {
|
|
|
297
298
|
...(!this.record.guide && !this.busy ? ["Prepare guide"] : []),
|
|
298
299
|
...ask,
|
|
299
300
|
...(this.busy ? stop : this.record.guide ? ["Regenerate guide"] : []),
|
|
301
|
+
...(!this.busy && this.view.selected === "overview" ? ["Delete review"] : []),
|
|
300
302
|
];
|
|
301
303
|
}
|
|
302
304
|
private changed() {
|
|
@@ -421,6 +423,7 @@ export class ReviewModal {
|
|
|
421
423
|
} else if (action === this.stopLabel) this.controls.stop();
|
|
422
424
|
else if (action === "Prepare guide") this.controls.prepare();
|
|
423
425
|
else if (action === "Regenerate guide") this.controls.regenerate();
|
|
426
|
+
else if (action === "Delete review") this.controls.deleteReview();
|
|
424
427
|
else if (action === "Retry saving") this.controls.retrySave();
|
|
425
428
|
else if (action === "Back" || action === "Back to files") this.back();
|
|
426
429
|
this.action = 0;
|
package/src/review-ui.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
replaceGuide,
|
|
15
15
|
guideEvidence,
|
|
16
16
|
buildReviewPrompt,
|
|
17
|
+
deleteReview,
|
|
17
18
|
listReviews,
|
|
18
19
|
loadReview,
|
|
19
20
|
parseGuide,
|
|
@@ -39,6 +40,62 @@ export function stopGuidedReviews(): void {
|
|
|
39
40
|
for (const controller of activeReviews.values()) controller?.abort();
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/** Same picker for resume and delete. Presentation and ordering have one owner. */
|
|
44
|
+
export function savedReviewLabel(item: ReviewRecord): string {
|
|
45
|
+
const target = item.snapshot.target;
|
|
46
|
+
const title = safeReviewText(target.title ?? "").replace(/[\r\n\t]/g, " ");
|
|
47
|
+
const readiness = item.guide ? (item.guide.assessment ? "review ready" : "guide ready") : "not prepared";
|
|
48
|
+
return `${target.repository} #${target.number} · ${title} · ${readiness} · ${target.head.slice(0, 8)}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function savedReviews(ctx: ExtensionCommandContext, root: string): Promise<ReviewRecord[]> {
|
|
52
|
+
const records = await listReviews(root, (file, error) =>
|
|
53
|
+
ctx.ui.notify(`Cannot load ${file}: ${String(error)}. Original file left untouched.`, "warning"));
|
|
54
|
+
return records.sort((a, b) =>
|
|
55
|
+
a.snapshot.target.repository.localeCompare(b.snapshot.target.repository) ||
|
|
56
|
+
b.snapshot.target.number - a.snapshot.target.number);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function pickSavedReview(
|
|
60
|
+
ctx: ExtensionCommandContext, root: string, title: string, emptyMessage: string,
|
|
61
|
+
): Promise<ReviewRecord | undefined> {
|
|
62
|
+
const records = await savedReviews(ctx, root);
|
|
63
|
+
if (!records.length) {
|
|
64
|
+
ctx.ui.notify(emptyMessage, "info");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const labels = records.map(savedReviewLabel);
|
|
68
|
+
const picked = await ctx.ui.select(title, labels);
|
|
69
|
+
return picked ? records[labels.indexOf(picked)] : undefined;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Resolve stored PR identity offline; a bare number is allowed only if unambiguous. */
|
|
73
|
+
export function matchSavedReview(
|
|
74
|
+
records: readonly ReviewRecord[], requested: string,
|
|
75
|
+
): { selected?: ReviewRecord; error?: string } {
|
|
76
|
+
const input = requested.trim();
|
|
77
|
+
if (/^[1-9]\d*$/.test(input)) {
|
|
78
|
+
const matches = records.filter(item => item.snapshot.target.number === Number(input));
|
|
79
|
+
if (matches.length > 1) return { error: "Multiple saved reviews have that PR number. Use its full PR URL." };
|
|
80
|
+
return { selected: matches[0] };
|
|
81
|
+
}
|
|
82
|
+
let url: URL;
|
|
83
|
+
try { url = new URL(input); }
|
|
84
|
+
catch { return { error: "Use a saved PR number or GitHub PR URL." }; }
|
|
85
|
+
const match = /^\/([^/]+)\/([^/]+)\/pull\/([1-9]\d*)(?:\/(?:files|commits|checks))?\/?$/.exec(url.pathname);
|
|
86
|
+
if (url.protocol !== "https:" || !match || url.username || url.password) {
|
|
87
|
+
return { error: "Use a saved PR number or GitHub PR URL." };
|
|
88
|
+
}
|
|
89
|
+
const [, owner, repo, number] = match;
|
|
90
|
+
const matches = records.filter(item => {
|
|
91
|
+
const target = item.snapshot.target;
|
|
92
|
+
return (target.host ?? "github.com").toLowerCase() === url.hostname.toLowerCase() &&
|
|
93
|
+
target.repository.toLowerCase() === `${owner}/${repo}`.toLowerCase() &&
|
|
94
|
+
target.number === Number(number);
|
|
95
|
+
});
|
|
96
|
+
return { selected: matches[0] };
|
|
97
|
+
}
|
|
98
|
+
|
|
42
99
|
export async function openGuidedReview(
|
|
43
100
|
ctx: ExtensionCommandContext,
|
|
44
101
|
value: string,
|
|
@@ -49,31 +106,52 @@ export async function openGuidedReview(
|
|
|
49
106
|
return;
|
|
50
107
|
}
|
|
51
108
|
const root = join(getAgentDir(), "bro-reviews");
|
|
109
|
+
|
|
110
|
+
if (value === "delete" || value.startsWith("delete ")) {
|
|
111
|
+
const requested = value.slice("delete".length).trim();
|
|
112
|
+
let selected: ReviewRecord | undefined;
|
|
113
|
+
if (!requested) {
|
|
114
|
+
selected = await pickSavedReview(ctx, root, "Delete saved review", "There are no saved reviews to delete.");
|
|
115
|
+
if (!selected) return; // Esc is cancellation, not a failed target lookup.
|
|
116
|
+
} else {
|
|
117
|
+
const match = matchSavedReview(await savedReviews(ctx, root), requested);
|
|
118
|
+
if (match.error) {
|
|
119
|
+
ctx.ui.notify(match.error, "warning");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
selected = match.selected;
|
|
123
|
+
}
|
|
124
|
+
if (!selected) {
|
|
125
|
+
ctx.ui.notify("No saved review matches that target.", "info");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const id = selected.id;
|
|
129
|
+
if (activeReviews.has(id)) {
|
|
130
|
+
ctx.ui.notify("That review is currently open or being prepared. Close it before deleting.", "warning");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const title = `${selected.snapshot.target.repository} #${selected.snapshot.target.number}`;
|
|
134
|
+
const approved = await ctx.ui.confirm("Delete saved review?", `Permanently remove ${title}, its notes, unsent drafts and all captured Git source? This cannot be undone.`);
|
|
135
|
+
if (!approved) return;
|
|
136
|
+
if (activeReviews.has(id)) {
|
|
137
|
+
ctx.ui.notify("That review became active. Close it and retry deletion.", "warning");
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Reserve this identity while deletion runs so a new review cannot start writing it.
|
|
141
|
+
activeReviews.set(id, undefined);
|
|
142
|
+
try {
|
|
143
|
+
await deleteReview(root, id);
|
|
144
|
+
ctx.ui.notify(`Deleted saved review ${title} and its captured source.`, "info");
|
|
145
|
+
} finally {
|
|
146
|
+
activeReviews.delete(id);
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
52
150
|
let record: ReviewRecord | undefined;
|
|
53
151
|
let fresh = false;
|
|
54
152
|
if (value === "resume" || !value) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
`Cannot load ${file}: ${String(error)}. Original file left untouched.`,
|
|
58
|
-
"warning",
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
if (!records.length) {
|
|
62
|
-
ctx.ui.notify("Start with /bro guided-review <PR number or URL>.", "info");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
records.sort(
|
|
66
|
-
(a, b) =>
|
|
67
|
-
a.snapshot.target.repository.localeCompare(b.snapshot.target.repository) ||
|
|
68
|
-
b.snapshot.target.number - a.snapshot.target.number,
|
|
69
|
-
);
|
|
70
|
-
const labels = records.map(
|
|
71
|
-
(item) =>
|
|
72
|
-
`${item.snapshot.target.repository} #${item.snapshot.target.number} · ${safeReviewText(item.snapshot.target.title ?? "").replace(/[\r\n\t]/g, " ")} · ${item.guide ? (item.guide.assessment ? "review ready" : "guide ready") : "not prepared"} · ${item.snapshot.target.head.slice(0, 8)}`,
|
|
73
|
-
);
|
|
74
|
-
const picked = await ctx.ui.select("Resume guided review", labels);
|
|
75
|
-
if (!picked) return;
|
|
76
|
-
record = records[labels.indexOf(picked)];
|
|
153
|
+
record = await pickSavedReview(ctx, root, "Resume guided review", "Start with /bro guided-review <PR number or URL>.");
|
|
154
|
+
if (!record) return;
|
|
77
155
|
} else {
|
|
78
156
|
record = await openBroOverlay<ReviewRecord | undefined>(
|
|
79
157
|
ctx,
|
|
@@ -427,6 +505,34 @@ export async function openGuidedReview(
|
|
|
427
505
|
retrySave() {
|
|
428
506
|
void persist().catch(() => {});
|
|
429
507
|
},
|
|
508
|
+
deleteReview() {
|
|
509
|
+
if (confirming || controller || closing || closed || panel.busy) return;
|
|
510
|
+
confirming = true;
|
|
511
|
+
overlayHandle?.setHidden(true);
|
|
512
|
+
const target = state.snapshot.target;
|
|
513
|
+
const title = `${target.repository} #${target.number}`;
|
|
514
|
+
void ctx.ui.confirm(
|
|
515
|
+
"Delete this saved review?",
|
|
516
|
+
`Permanently delete ${title}, all private questions and drafts, and its captured Git source? This cannot be undone.`,
|
|
517
|
+
).then(async (approved) => {
|
|
518
|
+
if (!approved || closed || closing || controller) return;
|
|
519
|
+
closing = true;
|
|
520
|
+
// Do not let a delayed save recreate the record after deletion.
|
|
521
|
+
if (saveTimer) { clearTimeout(saveTimer); saveTimer = undefined; }
|
|
522
|
+
await running;
|
|
523
|
+
await queue;
|
|
524
|
+
await deleteReview(root, state.id);
|
|
525
|
+
closed = true;
|
|
526
|
+
ctx.ui.notify(`Deleted saved review ${title} and its captured source.`, "info");
|
|
527
|
+
done();
|
|
528
|
+
}).catch((error) => {
|
|
529
|
+
closing = false;
|
|
530
|
+
panel.notice = `Deletion failed: ${String(error)}. Review remains open; retry when ready.`;
|
|
531
|
+
}).finally(() => {
|
|
532
|
+
confirming = false;
|
|
533
|
+
if (!closed) { overlayHandle?.setHidden(false); tui.requestRender(); }
|
|
534
|
+
});
|
|
535
|
+
},
|
|
430
536
|
regenerate() {
|
|
431
537
|
if (confirming || controller || closing || closed) return;
|
|
432
538
|
confirming = true;
|
package/src/review.ts
CHANGED
|
@@ -150,6 +150,15 @@ function recordPath(root: string, id: string): string {
|
|
|
150
150
|
if (!/^[a-f0-9]{64}$/.test(id)) throw Error("Invalid review identity.");
|
|
151
151
|
return join(root, id + ".json");
|
|
152
152
|
}
|
|
153
|
+
/** Remove one validated saved record and its captured source, never other reviews.
|
|
154
|
+
* The controller owns the active-review lock; deletion is not atomic across files.
|
|
155
|
+
*/
|
|
156
|
+
export async function deleteReview(root: string, id: string): Promise<void> {
|
|
157
|
+
const record = recordPath(root, id); // validates the 64-character hex boundary
|
|
158
|
+
await rm(join(root, "source", id), { recursive: true, force: true });
|
|
159
|
+
await rm(record, { force: true });
|
|
160
|
+
}
|
|
161
|
+
|
|
153
162
|
export async function saveReview(root: string, record: ReviewRecord): Promise<void> {
|
|
154
163
|
const path = recordPath(root, record.id);
|
|
155
164
|
await mkdir(root, { recursive: true, mode: 0o700 });
|
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
|
|