pi-bro 0.37.0 → 0.38.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 +21 -0
- package/README.md +18 -22
- package/docs/README.md +7 -7
- package/docs/elevate.md +10 -93
- package/docs/examples.md +1 -1
- package/docs/feature-map.md +33 -0
- package/docs/features/architecture.md +1 -1
- package/docs/features/elevate.md +122 -0
- package/docs/features/explain.md +16 -20
- package/docs/features/grill-me.md +65 -0
- package/docs/features/guided-review.md +150 -0
- package/docs/features/overthink.md +66 -0
- package/docs/features/remember-me.md +92 -0
- package/docs/features/show.md +9 -15
- package/docs/getting-started.md +5 -5
- package/docs/grill-me.md +5 -51
- package/docs/guided-review.md +14 -113
- package/docs/overthink.md +7 -46
- package/docs/piG-agent-shell-qualification.md +3 -3
- package/docs/pig-compatibility.md +1 -1
- package/docs/reference/commands.md +18 -33
- package/docs/reference/data-and-permissions.md +9 -9
- package/docs/reference/settings.md +8 -8
- package/docs/reference/troubleshooting.md +3 -3
- package/docs/remember-me.md +6 -75
- package/docs/user-guide.md +4 -4
- package/package.json +6 -4
- package/src/advisor.ts +1 -1
- package/src/architecture.ts +1 -1
- package/src/backend.ts +1 -0
- package/src/bro.ts +47 -189
- package/src/btw.ts +10 -199
- package/src/composer-modal.ts +197 -0
- package/src/explain-modal.ts +28 -79
- package/src/grill.ts +3 -2
- package/src/overthink-state.ts +3 -3
- package/src/overthink.ts +2 -2
- package/src/remember.ts +3 -2
- package/src/session-state.ts +46 -28
- package/src/settings.ts +11 -3
- package/src/simplify-engine.ts +50 -24
- package/src/simplify-ui.ts +165 -126
- package/src/sources.ts +3 -3
package/docs/remember-me.md
CHANGED
|
@@ -1,92 +1,23 @@
|
|
|
1
1
|
# Remember Me
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Use `/bro remember-me` to browse your approved personal memories, or `/bro remember-me <thought>` to start drafting from your words and recent Pi conversation.
|
|
3
|
+
This guide moved to [Remember Me](features/remember-me.md). The links below take you to the corresponding sections.
|
|
6
4
|
|
|
7
5
|
## Write through conversation
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
A proposed memory always has:
|
|
12
|
-
- **Subject:** a distinct topic, such as Testing or Delegation
|
|
13
|
-
- **Short statement:** active, clear and usable on its own; include qualifications that change its meaning
|
|
14
|
-
- **Expanded background:** context, explanations and original wording; optional scope, exceptions, source context, uncertainty and whether wording reflects a user statement or user-approved interpretation
|
|
15
|
-
|
|
16
|
-
Use the same vocabulary across related memories. Put useful distinguishing words first. Never convert “prefers lean tests” into “dislikes tests,” or “autonomy within an approved plan” into “unrestricted autonomy.” Summaries and expanded content must agree.
|
|
17
|
-
|
|
18
|
-
If the user hasn't resolved a conflict, don't pretend it is settled. Bro shows a potential conflict in the proposal. The user decides whether to revise it, update an existing memory or save a qualified entry.
|
|
7
|
+
[Write through conversation](features/remember-me.md#write-through-conversation)
|
|
19
8
|
|
|
20
9
|
## Controls
|
|
21
10
|
|
|
22
|
-
|
|
23
|
-
| --- | --- |
|
|
24
|
-
| Free text | Continue clarifying or refining |
|
|
25
|
-
| `/save` | Approve and persist the current proposal |
|
|
26
|
-
| `/list [page|all]` | Page through the current search (20 per page), or use `/list all` to return to all memories; preserve the proposal |
|
|
27
|
-
| `/search <words>` | Start a filtered search; `/list 2` continues its second page without dropping the proposal |
|
|
28
|
-
| `/expand <id>` | Show background, source, scope, exceptions and uncertainty |
|
|
29
|
-
| `/edit <id>` | Edit an existing memory while keeping its stable ID |
|
|
30
|
-
| `/delete <id>` | Delete after typing yes |
|
|
31
|
-
| `/context show|on|off` | See or omit the captured Pi context before transmitting |
|
|
32
|
-
| `/confirm-revision` | Approve after comparing a stale proposal with changed memories |
|
|
33
|
-
| `/new` | Discard the draft without changing saved memories |
|
|
34
|
-
| `/help` | Explain commands and boundaries |
|
|
35
|
-
|
|
36
|
-
Before the first model call, Bro identifies the selected model/backend, the captured main-session context, and that related saved memories and legacy style preferences will be sent. The initial thought is prefilled but not sent until the user presses Enter. Use `/context show` to inspect what was captured or `/context off` to omit it.
|
|
37
|
-
|
|
38
|
-
Browsing and failed saves preserve the proposal. If the store changed after the proposal was reviewed, `/save` compares the original and current target (and related entries) and **does not save**. An explicit `/confirm-revision` approves against that exact new revision; if it changes again, another review is required. Durable drafts across restarts are not implemented.
|
|
39
|
-
|
|
40
|
-
During a draft or revision, the footer shows the current stage and elapsed seconds even if the model is quiet. It does not show the raw draft JSON, and progress is not saved as a memory. Elapsed time means the call remains pending, not that the model has made progress.
|
|
41
|
-
|
|
42
|
-
Esc closes the modal and cancels an active model call. The draft conversation is not durable; **approved saved memories are durable**. Saved entries survive Pi restarts and project changes.
|
|
11
|
+
[Controls](features/remember-me.md#controls)
|
|
43
12
|
|
|
44
13
|
## Agent access
|
|
45
14
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
```text
|
|
49
|
-
about_user() → short statements and IDs
|
|
50
|
-
about_user({query:"testing"}) → matching summaries
|
|
51
|
-
about_user({offset:20,limit:20}) → next page of memories
|
|
52
|
-
about_user({expand:["m-..."]}) → approved background for an ID
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
The agent can scan a summary before deciding what to unfold. The reader performs no new model call. It does not mutate stored entries. The user's current request wins over a standing memory.
|
|
15
|
+
[Agent access](features/remember-me.md#agent-access)
|
|
56
16
|
|
|
57
17
|
## Boundaries
|
|
58
18
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
**Agent access is currently the registered main Pi tool only.** External CLIs and isolated Bro sessions do not receive it automatically. The existing `/bro preferences` file remains unchanged; no automatic migration or conflict reconciliation is claimed.
|
|
62
|
-
|
|
63
|
-
Remember Me uses **the backend and model selected for BTW**. Every valid BTW backend is supported through Bro's existing restricted **explain** execution path. It never silently changes provider or model. Restricted means different things across backends, not a universal promise of no tools or no side effects:
|
|
64
|
-
|
|
65
|
-
| Backend | Current restricted drafting behavior |
|
|
66
|
-
| --- | --- |
|
|
67
|
-
| Agy (default) | `--sandbox`, temporary working directory. Sandbox limits shell actions; it is **not** a no-tools or no-write guarantee. |
|
|
68
|
-
| Codex | `--sandbox read-only`, ephemeral execution and temporary working directory; read-only sandbox, **not** no-tools. |
|
|
69
|
-
| Claude | CLI tools disabled with `--tools ""`, strict empty MCP config, temporary working directory, no session persistence. |
|
|
70
|
-
| Pi | Fresh SDK session with no tools, extensions, skills, or project context files, using the **selected configured physical model**. |
|
|
71
|
-
| Muse | Write and shell disabled, approvals disabled, temporary working directory. Do not infer that all other abilities are disabled. |
|
|
72
|
-
| Grok | A restricted **prompt request**, but CLI sandbox off and permissions bypassed; it is **not** a technical tool/write boundary. |
|
|
73
|
-
|
|
74
|
-
The modal shows a backend-specific notice before sending data. Bro's `/save` gate controls **only writes to its approved memory store**. It does not prevent any action that the selected backend's own permissions might allow. See [execution configuration](reference/settings.md) for backend details.
|
|
75
|
-
|
|
76
|
-
Live model behavior and the actual backend installation are separate from controlled-response tests.
|
|
77
|
-
|
|
78
|
-
**Coexistence policy:** `/bro preferences` remains active as a legacy *answer-style* file for older Bro features. `about_user` reads only approved Remember Me memories. Current user instructions take precedence. If an approved memory conflicts with legacy preferences, the approved memory is the source for the personal fact or lasting rule; do not treat two conflicting stores as equally authoritative. Bro should surface the disagreement during drafting. There is no silent migration or overwrite; a reviewed migration remains a separate task.
|
|
19
|
+
[Boundaries](features/remember-me.md#boundaries)
|
|
79
20
|
|
|
80
21
|
## Examples
|
|
81
22
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
**Expanded:** The user values tests that protect meaningful behavior and rejects needless duplication. This does **not** mean the user dislikes tests. Scope: project test strategy. Source: explicit user preference.
|
|
85
|
-
|
|
86
|
-
**Short:** `Delegation: Allow agents to act independently within an approved coordination plan; reserve consequential scope changes for human approval.`
|
|
87
|
-
|
|
88
|
-
**Expanded:** The user wants strong initiative after authorizing the plan, not unrestricted delegation. An agent can coordinate approved subtasks but should return for approval when changing agreed goals or major commitments.
|
|
89
|
-
|
|
90
|
-
**Short:** `Answer length: Lead with a short answer; give enough detail for consequential design reviews. [Apparent tension: brevity versus depth depends on task.]`
|
|
91
|
-
|
|
92
|
-
**Expanded:** “Keep answers concise” and “go deep on important trade-offs” are not necessarily conflicting. Their scope differs: routine replies versus material design decisions. Preserve that distinction rather than deciding the user dislikes detailed work.
|
|
23
|
+
[Examples](features/remember-me.md#examples)
|
package/docs/user-guide.md
CHANGED
|
@@ -28,11 +28,11 @@ See [Explanation modes](features/explain.md#explanation-modes).
|
|
|
28
28
|
|
|
29
29
|
## Guided Review
|
|
30
30
|
|
|
31
|
-
See [Guided Review](guided-review.md#guided-review).
|
|
31
|
+
See [Guided Review](features/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. Elevate never edits your Pi draft; copy and paste the revision if you wish.
|
|
35
|
+
See [Elevate: Discover → Select → Upgrade](features/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
|
|
|
@@ -166,8 +166,8 @@ See [Troubleshooting and current limits](reference/troubleshooting.md#troublesho
|
|
|
166
166
|
|
|
167
167
|
## Simplify modal
|
|
168
168
|
|
|
169
|
-
`/bro` and `/bro simplify` open the
|
|
169
|
+
`/bro` and `/bro simplify` open the latest result or help without calling a model. Explain a source in plain words with `/simplify` (latest reply), `/text`, `/file` or `/url`. Draw recent conversation turns with `/show [n-turns] [query]` in the same window. `/copy`, `/clear` and `/help` work for both. With an empty composer, **R** retries the captured source, **M** changes the mode for this explanation only, and **O** opens a browser diagram when available. Only the latest result is saved, in private Pi session entries that stay out of the main model's context. See the [command reference](reference/commands.md#what-bro-can-explain) for direct and headless forms.
|
|
170
170
|
|
|
171
171
|
## Bro command discovery and Config navigation
|
|
172
172
|
|
|
173
|
-
The
|
|
173
|
+
The `/bro ` menu offers one `simplify` entry for both explanations and diagrams. Type `/bro simplify ` for source options or a prefix such as `/bro doc` to find other commands. `/bro config` starts with **Global** (default, Preferences editor, Doctor on demand) and **Features** (per-feature settings). Esc goes back.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-bro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.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",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"src/config-navigation.ts",
|
|
79
79
|
"src/ui-capabilities.ts",
|
|
80
80
|
"src/modal-kit.ts",
|
|
81
|
+
"src/composer-modal.ts",
|
|
81
82
|
"src/backend.ts",
|
|
82
83
|
"src/cli-auth.ts",
|
|
83
84
|
"src/prompt.ts",
|
|
@@ -91,9 +92,10 @@
|
|
|
91
92
|
"docs/user-guide.md",
|
|
92
93
|
"docs/pig-compatibility.md",
|
|
93
94
|
"docs/piG-agent-shell-qualification.md",
|
|
94
|
-
"docs/
|
|
95
|
+
"docs/feature-map.md",
|
|
95
96
|
"docs/elevate.md",
|
|
96
97
|
"docs/grill-me.md",
|
|
98
|
+
"docs/guided-review.md",
|
|
97
99
|
"docs/overthink.md",
|
|
98
100
|
"docs/remember-me.md",
|
|
99
101
|
"docs/examples.md",
|
|
@@ -108,9 +110,9 @@
|
|
|
108
110
|
"node": ">=22.19.0"
|
|
109
111
|
},
|
|
110
112
|
"scripts": {
|
|
111
|
-
"docs:check": "node scripts/check-docs.mjs
|
|
113
|
+
"docs:check": "node scripts/check-docs.mjs",
|
|
112
114
|
"typecheck": "tsc --noEmit",
|
|
113
|
-
"test": "npm run typecheck && npm run docs:check && node .github/scripts/release-utils.mjs selftest && node --experimental-transform-types --test --test-concurrency=2 test
|
|
115
|
+
"test": "npm run typecheck && npm run docs:check && node .github/scripts/release-utils.mjs selftest && node --experimental-transform-types --test --test-concurrency=2 \"test/**/*.test.{ts,mjs}\" \"benchmark/**/*.test.{ts,mjs}\" && sh ./test/smoke-test.sh",
|
|
114
116
|
"benchmark:dry-run": "node benchmark/run.ts dry-run",
|
|
115
117
|
"benchmark:run": "node benchmark/run.ts run",
|
|
116
118
|
"benchmark:report": "node benchmark/run.ts report",
|
package/src/advisor.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const ADVISOR_TOOL_NAME = "bro_advisor";
|
|
|
23
23
|
// setStatus() key for mirroring live advisor progress to the footer/status bar -- see the execute()
|
|
24
24
|
// handler below for why this fallback surface exists alongside onUpdate's tool-card renderResult.
|
|
25
25
|
export const ADVISOR_STATUS_BAR_KEY = "bro-advisor";
|
|
26
|
-
export const ADVISOR_COMPATIBILITY = "Pi >=
|
|
26
|
+
export const ADVISOR_COMPATIBILITY = "Pi >=1.3.0; Agy >=1.1.15";
|
|
27
27
|
export const ADVISOR_STEERING_FILE = join(getAgentDir(), "bro-advisor.md");
|
|
28
28
|
const MAX_ADVISOR_STEERING_FILE_BYTES = 64 * 1024;
|
|
29
29
|
|
package/src/architecture.ts
CHANGED
|
@@ -136,7 +136,7 @@ export async function openArchitectureDocs(ctx: ExtensionCommandContext, focus:
|
|
|
136
136
|
await showBroModal(ctx, {
|
|
137
137
|
loadingText: "Documenting the current project…",
|
|
138
138
|
retryLabel: "build docs again",
|
|
139
|
-
run: (signal,
|
|
139
|
+
run: (signal, progress) => {
|
|
140
140
|
running = generateArchitecture(ctx, focus, signal, progress);
|
|
141
141
|
return running;
|
|
142
142
|
},
|
package/src/backend.ts
CHANGED
|
@@ -1516,6 +1516,7 @@ async function executeMuse(
|
|
|
1516
1516
|
// pattern's thinking level, which createAgentSession cannot recover on its own, and
|
|
1517
1517
|
// `isProjectTrusted` decides whether the workspace's `.pi/settings.json` may apply.
|
|
1518
1518
|
export type PiHostContext = Pick<ExtensionContext, "modelRegistry" | "scopedModels"> & {
|
|
1519
|
+
model?: ExtensionContext["model"];
|
|
1519
1520
|
isProjectTrusted?: () => boolean;
|
|
1520
1521
|
};
|
|
1521
1522
|
|
package/src/bro.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
1
2
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import { ADVISOR_STEERING_FILE, ADVISOR_TOOL_NAME, registerAdvisorTool } from "./advisor.ts";
|
|
3
4
|
import {
|
|
@@ -16,42 +17,27 @@ import { openCopyModal } from "./copy.ts";
|
|
|
16
17
|
import { registerOverthink } from "./overthink.ts";
|
|
17
18
|
import { openRememberModal } from "./remember.ts";
|
|
18
19
|
import { openSimplifyWorkflow, type SimplifyState } from "./simplify-ui.ts";
|
|
20
|
+
import { parseSimplifyRequest, SIMPLIFY_INPUTS } from "./simplify-engine.ts";
|
|
19
21
|
import { registerAboutUserTool } from "./remember-tool.ts";
|
|
20
22
|
import { parseGrillArguments, type GrillThread } from "./grill-engine.ts";
|
|
21
23
|
import {
|
|
22
|
-
type BroResult,
|
|
23
|
-
type ModalResult,
|
|
24
24
|
helpText,
|
|
25
|
-
latestAssistant,
|
|
26
25
|
showAdvisorSteerModal,
|
|
27
26
|
showBroModal,
|
|
28
27
|
showPreferencesModal,
|
|
29
|
-
simplify,
|
|
30
28
|
} from "./explain-modal.ts";
|
|
31
|
-
import { BRO_MODES,
|
|
29
|
+
import { BRO_MODES, parseBroMode } from "./prompt.ts";
|
|
32
30
|
import { openGuidedReview, stopGuidedReviews } from "./review-ui.ts";
|
|
33
31
|
import {
|
|
34
32
|
type BroSettings,
|
|
35
33
|
capabilityBackend,
|
|
36
|
-
ensureSettingsFile,
|
|
37
34
|
readPreferences,
|
|
38
35
|
readSettings,
|
|
39
36
|
writeSettings,
|
|
40
37
|
} from "./settings.ts";
|
|
41
|
-
import {
|
|
42
|
-
captureShowTranscript,
|
|
43
|
-
parseShowArguments,
|
|
44
|
-
runShowExplanation,
|
|
45
|
-
showDiagramPath,
|
|
46
|
-
} from "./show.ts";
|
|
47
|
-
import {
|
|
48
|
-
type BroSource,
|
|
49
|
-
isDocumentFile,
|
|
50
|
-
looksLikeWebUrl,
|
|
51
|
-
} from "./sources.ts";
|
|
52
38
|
import { hasBroCustomUi } from "./ui-capabilities.ts";
|
|
53
|
-
import { errorMessage,
|
|
54
|
-
import { BTW_SESSION_ENTRY, GRILL_SESSION_ENTRY, SIMPLIFY_SESSION_ENTRY,
|
|
39
|
+
import { errorMessage, withDoctor } from "./util.ts";
|
|
40
|
+
import { BTW_SESSION_ENTRY, GRILL_SESSION_ENTRY, SIMPLIFY_SESSION_ENTRY, restorePrivateBroState } from "./session-state.ts";
|
|
55
41
|
|
|
56
42
|
export * from "./util.ts";
|
|
57
43
|
export * from "./ui-capabilities.ts";
|
|
@@ -78,14 +64,9 @@ export * from "./copy.ts";
|
|
|
78
64
|
|
|
79
65
|
const COMMANDS = [
|
|
80
66
|
{ value: "architecture", label: "architecture", description: "Document this repository in docs/architecture/ with diagrams and an offline map" },
|
|
81
|
-
{ value: "simplify", label: "simplify", description: "
|
|
67
|
+
{ value: "simplify", label: "simplify", description: "Understand one source in plain words or as a diagram" },
|
|
82
68
|
{ value: "copy", label: "copy", description: "Edit, preview and copy the last assistant reply as Markdown — no model call" },
|
|
83
|
-
{ value: "text", label: "text", description: "Explain pasted text, or the latest reply when text is omitted" },
|
|
84
|
-
{ value: "file", label: "file", description: "Explain a local document" },
|
|
85
|
-
{ value: "url", label: "url", description: "Explain a public webpage" },
|
|
86
|
-
{ value: "open", label: "open", description: "Reopen the last explanation" },
|
|
87
69
|
{ value: "doctor", label: "doctor", description: "Check whether Bro is ready" },
|
|
88
|
-
{ value: "show", label: "show", description: "Need to see how recent turns fit together? Get a visual outline or diagram" },
|
|
89
70
|
{ value: "mode", label: "mode", description: "View or choose explanation mode (brief, balanced, faithful)" },
|
|
90
71
|
{ value: "preferences", label: "preferences", description: "Want Bro to follow your style? Edit saved response preferences" },
|
|
91
72
|
{ value: "guided-review", label: "guided-review", description: "Need to assess a PR? Get source-backed findings and saved private questions" },
|
|
@@ -100,16 +81,14 @@ const COMMANDS = [
|
|
|
100
81
|
{ value: "help", label: "help", description: "Learn what Bro does and what it can access" },
|
|
101
82
|
];
|
|
102
83
|
const KNOWN_ACTIONS = new Set(COMMANDS.map((command) => command.value));
|
|
103
|
-
/**
|
|
84
|
+
/** Top-level discovery lists Simplify once, not each source command. */
|
|
104
85
|
export const FEATURED_BRO_COMMANDS = [
|
|
105
|
-
|
|
86
|
+
"simplify", "btw", "guided-review", "architecture", "elevate", "grill-me", "remember-me", "overthink", "config",
|
|
106
87
|
] as const;
|
|
107
88
|
const FEATURED_COMMANDS = new Set<string>(FEATURED_BRO_COMMANDS);
|
|
108
89
|
|
|
109
90
|
export default async function bro(pi: ExtensionAPI) {
|
|
110
|
-
let lastResult: ModalResult | undefined;
|
|
111
91
|
let simplifyState: SimplifyState = {};
|
|
112
|
-
let lastShowSteering: string | undefined;
|
|
113
92
|
let btwThread: BtwThread | undefined;
|
|
114
93
|
let grillThread: GrillThread | undefined;
|
|
115
94
|
let savedSnapshots = new Map<string, string>();
|
|
@@ -122,17 +101,6 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
122
101
|
pi.appendEntry(type, data);
|
|
123
102
|
savedSnapshots.set(type, serialized);
|
|
124
103
|
};
|
|
125
|
-
const remember = (result: ModalResult, showSteering?: string) => {
|
|
126
|
-
if (result.source) {
|
|
127
|
-
lastResult = result;
|
|
128
|
-
lastShowSteering = showSteering;
|
|
129
|
-
appendChanged(LAST_RESULT_SESSION_ENTRY, { result, steering: showSteering });
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const saveSimplify = () => {
|
|
133
|
-
if (!savedSnapshots.has(SIMPLIFY_SESSION_ENTRY) && !simplifyState.result && !simplifyState.draft) return;
|
|
134
|
-
appendChanged(SIMPLIFY_SESSION_ENTRY, { state: simplifyState });
|
|
135
|
-
};
|
|
136
104
|
const saveBtw = () => {
|
|
137
105
|
if (!btwThread) return;
|
|
138
106
|
// Visiting an empty BTW modal does not need a disk entry.
|
|
@@ -147,11 +115,8 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
147
115
|
appendChanged(GRILL_SESSION_ENTRY, { thread: grillThread });
|
|
148
116
|
};
|
|
149
117
|
const restore = (ctx: ExtensionContext) => {
|
|
150
|
-
|
|
151
|
-
const restored = restorePrivateBroState(
|
|
152
|
-
savedSnapshots = privateSessionEntrySnapshots(branch);
|
|
153
|
-
lastResult = restored.lastResult;
|
|
154
|
-
lastShowSteering = restored.lastShowSteering;
|
|
118
|
+
savedSnapshots = new Map();
|
|
119
|
+
const restored = restorePrivateBroState(ctx.sessionManager.getBranch(), savedSnapshots);
|
|
155
120
|
simplifyState = restored.simplify;
|
|
156
121
|
btwThread = restored.btw;
|
|
157
122
|
grillThread = restored.grill;
|
|
@@ -175,9 +140,14 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
175
140
|
pi.registerCommand("bro", {
|
|
176
141
|
description: "Explain text, documents, and webpages; draw session turns; open a side conversation; configure Bro and the executor's advisor tool",
|
|
177
142
|
getArgumentCompletions: (prefix) => {
|
|
178
|
-
const normalized = prefix.
|
|
179
|
-
const
|
|
180
|
-
|
|
143
|
+
const normalized = prefix.trimStart().toLowerCase();
|
|
144
|
+
const nested = /^simplify\s+(\S*)$/.exec(normalized);
|
|
145
|
+
if (nested) {
|
|
146
|
+
const matches = SIMPLIFY_INPUTS.filter(input => input.startsWith(nested[1]!));
|
|
147
|
+
return matches.length ? matches.map(input => ({ value: `simplify ${input}`, label: input })) : null;
|
|
148
|
+
}
|
|
149
|
+
const matches = COMMANDS.filter(command =>
|
|
150
|
+
normalized.trim() ? command.value.startsWith(normalized.trim()) : FEATURED_COMMANDS.has(command.value));
|
|
181
151
|
return matches.length ? matches : null;
|
|
182
152
|
},
|
|
183
153
|
handler: async (args, ctx) => {
|
|
@@ -186,49 +156,43 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
186
156
|
const raw = args.trim();
|
|
187
157
|
const normalized = raw.toLowerCase();
|
|
188
158
|
const parts = normalized ? normalized.split(/\s+/) : [];
|
|
189
|
-
|
|
190
|
-
|
|
159
|
+
const action = parts[0] ?? "";
|
|
160
|
+
const value = raw.slice(action.length).trim();
|
|
191
161
|
|
|
192
|
-
// Removed commands must never fall through to a paid text explanation.
|
|
193
162
|
if (action === "model" || action === "effort") {
|
|
194
|
-
ctx.ui.notify(`/bro ${action} was removed. Use /bro config to choose the shared default and per-capability ${action}
|
|
163
|
+
ctx.ui.notify(`/bro ${action} was removed. Use /bro config to choose the shared default and per-capability ${action}.`, "warning");
|
|
195
164
|
return;
|
|
196
165
|
}
|
|
197
|
-
|
|
198
|
-
// An unknown first word means the whole input is the source: route it by shape.
|
|
199
166
|
if (action && !KNOWN_ACTIONS.has(action)) {
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
?
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
value = raw;
|
|
167
|
+
const replacement = action === "open" ? "/bro simplify"
|
|
168
|
+
: action === "text" && !value ? "/bro simplify latest"
|
|
169
|
+
: action === "text" ? "/bro simplify text <text>"
|
|
170
|
+
: action === "file" ? "/bro simplify file <path>"
|
|
171
|
+
: action === "url" ? "/bro simplify url <url>"
|
|
172
|
+
: action === "show" ? "/bro simplify show [n-turns] [query]" : undefined;
|
|
173
|
+
ctx.ui.notify(replacement ? `/bro ${action} moved. Use ${replacement}.`
|
|
174
|
+
: "Unknown Bro command. Use /bro help, or /bro simplify text <text> to explain pasted text.", "warning");
|
|
175
|
+
return;
|
|
210
176
|
}
|
|
211
177
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if ((action === "file" || action === "url") && !value) {
|
|
220
|
-
ctx.ui.notify(`Use /bro ${action} <${action === "file" ? "path" : "url"}>.`, "warning");
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
const initial = !action || action === "simplify"
|
|
224
|
-
? {kind:"resume" as const}
|
|
225
|
-
: action === "text" && !value
|
|
226
|
-
? {kind:"latest" as const}
|
|
227
|
-
: {kind:action as "text" | "file" | "url", input:value};
|
|
178
|
+
if (!action || action === "simplify") {
|
|
179
|
+
const input = value.split(/\s+/, 1)[0] ?? "";
|
|
180
|
+
const initial = input ? parseSimplifyRequest(input.toLowerCase(), value.slice(input.length).trim()) : undefined;
|
|
181
|
+
if (initial?.kind === "invalid") { ctx.ui.notify(initial.message, "warning"); return; }
|
|
182
|
+
const state = simplifyState;
|
|
183
|
+
const hadResult = Boolean(state.result);
|
|
184
|
+
const headlessRun = initial && !hasBroCustomUi(ctx);
|
|
228
185
|
try {
|
|
229
|
-
await openSimplifyWorkflow(ctx,
|
|
230
|
-
|
|
231
|
-
|
|
186
|
+
await openSimplifyWorkflow(ctx, state, initial, initial ? (initial.kind === "latest" ? "/simplify" : `/${value}`) : undefined);
|
|
187
|
+
if (simplifyState === state && (savedSnapshots.has(SIMPLIFY_SESSION_ENTRY) || hadResult || state.result || state.draft)) {
|
|
188
|
+
appendChanged(SIMPLIFY_SESSION_ENTRY, { state });
|
|
189
|
+
if (headlessRun) {
|
|
190
|
+
const file = ctx.sessionManager.getSessionFile?.();
|
|
191
|
+
if (!file || !existsSync(file)) {
|
|
192
|
+
ctx.ui.notify("Simplify finished, but Pi has no saved session file. The result is only in memory. To keep headless results, reopen a saved Pi session before running Simplify.", "warning");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
232
196
|
} catch (error) { ctx.ui.notify(withDoctor(error), "error"); }
|
|
233
197
|
return;
|
|
234
198
|
}
|
|
@@ -240,44 +204,6 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
240
204
|
return;
|
|
241
205
|
}
|
|
242
206
|
|
|
243
|
-
if (action === "show") {
|
|
244
|
-
const { requested, steering, invalid } = parseShowArguments(value);
|
|
245
|
-
if (invalid) {
|
|
246
|
-
ctx.ui.notify("Use /bro show [n-turns] [query].", "warning");
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
const runShow = async (
|
|
250
|
-
signal: AbortSignal,
|
|
251
|
-
source?: BroSource,
|
|
252
|
-
onProgress?: (text: string) => void,
|
|
253
|
-
): Promise<ModalResult> => {
|
|
254
|
-
const captured =
|
|
255
|
-
source ?? captureShowTranscript(ctx, requested ? Number(requested) : (await readSettings()).showTurns);
|
|
256
|
-
if (!captured) {
|
|
257
|
-
return { text: "**Nothing to show yet**\n\nThis session has no conversation turns to draw. Run something first, then press **R**." };
|
|
258
|
-
}
|
|
259
|
-
let result: Awaited<ReturnType<typeof runShowExplanation>>;
|
|
260
|
-
try {
|
|
261
|
-
result = await runShowExplanation(captured.text, steering, signal, await readSettings(), onProgress);
|
|
262
|
-
} catch (error) {
|
|
263
|
-
throw new Error(withDoctor(error));
|
|
264
|
-
}
|
|
265
|
-
const htmlPath = await showDiagramPath(result.text, (message) => ctx.ui.notify(message, "warning"));
|
|
266
|
-
return { source: captured, ...result, ...(htmlPath ? { htmlPath } : {}) };
|
|
267
|
-
};
|
|
268
|
-
try {
|
|
269
|
-
await showBroModal(ctx, {
|
|
270
|
-
loadingText: "Drawing what happened…",
|
|
271
|
-
retryLabel: "show again",
|
|
272
|
-
run: runShow,
|
|
273
|
-
onResult: (result) => remember(result, steering),
|
|
274
|
-
});
|
|
275
|
-
} catch (error) {
|
|
276
|
-
ctx.ui.notify(withDoctor(error), "error");
|
|
277
|
-
}
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
207
|
if (action === "doctor") {
|
|
282
208
|
if (parts.length !== 1) {
|
|
283
209
|
ctx.ui.notify("Use /bro doctor.", "warning");
|
|
@@ -469,71 +395,6 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
469
395
|
await showBroModal(ctx, { text: helpText(settings, settingsError, preferences), kind: "help", copyable: true });
|
|
470
396
|
return;
|
|
471
397
|
}
|
|
472
|
-
|
|
473
|
-
const run = async (
|
|
474
|
-
signal: AbortSignal,
|
|
475
|
-
source?: BroSource,
|
|
476
|
-
onProgress?: (text: string) => void,
|
|
477
|
-
mode?: BroMode,
|
|
478
|
-
): Promise<BroResult> => {
|
|
479
|
-
let target = source ?? (action === "text" && value ? { text: value } : undefined);
|
|
480
|
-
if (!target) {
|
|
481
|
-
await ctx.waitForIdle();
|
|
482
|
-
target = latestAssistant(ctx);
|
|
483
|
-
}
|
|
484
|
-
if (!target) throw new Error("No completed assistant response found.");
|
|
485
|
-
try {
|
|
486
|
-
const settings = await readSettings();
|
|
487
|
-
return {
|
|
488
|
-
source: target,
|
|
489
|
-
...(await simplify(target.text, signal, settings, onProgress, mode)),
|
|
490
|
-
};
|
|
491
|
-
} catch (error) {
|
|
492
|
-
throw new Error(withDoctor(error));
|
|
493
|
-
}
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
if (action === "open") {
|
|
497
|
-
if (parts.length !== 1) {
|
|
498
|
-
ctx.ui.notify("Use /bro open.", "warning");
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
if (!lastResult) {
|
|
502
|
-
await showBroModal(ctx, {
|
|
503
|
-
text: "# Nothing to open yet\n\nUse `/bro text <text>`, run `/bro text` (or `/simplify` inside `/bro`) after an assistant response, use `/bro file <path>`, use `/bro url <url>`, or run `/bro show` to draw recent turns.",
|
|
504
|
-
kind: "empty",
|
|
505
|
-
});
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
const steering = lastShowSteering;
|
|
510
|
-
if (steering !== undefined) {
|
|
511
|
-
// Temp files may have been cleaned by the OS or another Bro session.
|
|
512
|
-
if (ctx.mode === "tui") lastResult.htmlPath = await showDiagramPath(lastResult.text, (message) => ctx.ui.notify(message, "warning"));
|
|
513
|
-
}
|
|
514
|
-
await showBroModal(ctx, {
|
|
515
|
-
result: lastResult,
|
|
516
|
-
loadingText: steering !== undefined ? "Drawing what happened…" : undefined,
|
|
517
|
-
retryLabel: steering !== undefined ? "show again" : undefined,
|
|
518
|
-
run: steering === undefined ? run : async (signal, source, onProgress) => {
|
|
519
|
-
if (!source) throw new Error("No captured Show source.");
|
|
520
|
-
const result = await runShowExplanation(source.text, steering, signal, await readSettings(), onProgress);
|
|
521
|
-
const htmlPath = await showDiagramPath(result.text, (message) => ctx.ui.notify(message, "warning"));
|
|
522
|
-
return { source, ...result, ...(htmlPath ? { htmlPath } : {}) };
|
|
523
|
-
},
|
|
524
|
-
onResult: (result) => remember(result, steering),
|
|
525
|
-
});
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
try {
|
|
530
|
-
await showBroModal(ctx, {
|
|
531
|
-
run,
|
|
532
|
-
onResult: remember,
|
|
533
|
-
});
|
|
534
|
-
} catch (error) {
|
|
535
|
-
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
536
|
-
}
|
|
537
398
|
},
|
|
538
399
|
});
|
|
539
400
|
|
|
@@ -552,7 +413,4 @@ export default async function bro(pi: ExtensionAPI) {
|
|
|
552
413
|
},
|
|
553
414
|
});
|
|
554
415
|
} catch { /* /bro still works; the command is the supported path to Elevate */ }
|
|
555
|
-
|
|
556
|
-
// Keep the command available even when Bro cannot create its settings file; Doctor can then explain the problem.
|
|
557
|
-
await ensureSettingsFile().catch(() => undefined);
|
|
558
416
|
}
|