pi-bro 0.36.3 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +13 -15
- package/docs/README.md +7 -7
- package/docs/elevate.md +10 -93
- package/docs/feature-map.md +34 -0
- package/docs/features/architecture.md +1 -1
- package/docs/features/elevate.md +122 -0
- package/docs/features/explain.md +4 -2
- 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/getting-started.md +3 -3
- 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 +2 -2
- package/docs/pig-compatibility.md +1 -1
- package/docs/reference/commands.md +11 -11
- package/docs/reference/data-and-permissions.md +8 -8
- package/docs/reference/settings.md +5 -5
- package/docs/reference/troubleshooting.md +2 -2
- package/docs/remember-me.md +6 -75
- package/docs/user-guide.md +3 -3
- package/package.json +5 -4
- package/src/advisor.ts +1 -1
- package/src/backend.ts +1 -0
- package/src/bro.ts +11 -16
- package/src/btw.ts +6 -0
- package/src/explain-modal.ts +6 -6
- package/src/overthink-state.ts +3 -3
- package/src/overthink.ts +2 -2
- package/src/settings.ts +11 -3
- package/src/simplify-engine.ts +2 -2
- package/src/simplify-ui.ts +19 -8
- package/src/sources.ts +2 -14
package/src/overthink-state.ts
CHANGED
|
@@ -121,13 +121,13 @@ export function globalQuestionsFile(dir = getAgentDir()): string {
|
|
|
121
121
|
return join(dir, OVERTHINK_DEFAULTS_FILE);
|
|
122
122
|
}
|
|
123
123
|
export type OverthinkGlobal = { questions: string[]; automatic: boolean };
|
|
124
|
-
/**
|
|
124
|
+
/** Only an explicitly saved true enables automatic requests. */
|
|
125
125
|
export async function readGlobalOverthink(dir = getAgentDir()): Promise<OverthinkGlobal> {
|
|
126
126
|
const file = globalQuestionsFile(dir);
|
|
127
127
|
let info;
|
|
128
128
|
try { info = await lstat(file); }
|
|
129
129
|
catch (error) {
|
|
130
|
-
if ((error as NodeJS.ErrnoException).code === "ENOENT") return { questions: [...FACTORY_QUESTIONS], automatic:
|
|
130
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") return { questions: [...FACTORY_QUESTIONS], automatic: false };
|
|
131
131
|
throw error;
|
|
132
132
|
}
|
|
133
133
|
if (!info.isFile() || info.isSymbolicLink() || info.size > 32768) throw new Error("Unsafe or oversized Overthink defaults file: " + file);
|
|
@@ -136,7 +136,7 @@ export async function readGlobalOverthink(dir = getAgentDir()): Promise<Overthin
|
|
|
136
136
|
(data.automatic !== undefined && typeof data.automatic !== "boolean")) {
|
|
137
137
|
throw new Error("Unsupported Overthink defaults format: " + file);
|
|
138
138
|
}
|
|
139
|
-
return { questions: checkQuestions(data.questions), automatic: data.automatic ??
|
|
139
|
+
return { questions: checkQuestions(data.questions), automatic: data.automatic ?? false };
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
export async function readGlobalQuestions(dir = getAgentDir()): Promise<string[]> {
|
package/src/overthink.ts
CHANGED
|
@@ -133,7 +133,7 @@ export function createOverthinkViewer(
|
|
|
133
133
|
};
|
|
134
134
|
if (help) {
|
|
135
135
|
[
|
|
136
|
-
"Overthink checks
|
|
136
|
+
"Overthink uses the active Pi model. Enable automatic checks in /bro config → Features → Overthink.",
|
|
137
137
|
"It stays private and only notifies about consequential new concerns.",
|
|
138
138
|
"",
|
|
139
139
|
"Ctrl+R Retry with the current session",
|
|
@@ -154,7 +154,7 @@ export function createOverthinkViewer(
|
|
|
154
154
|
if (busy) {
|
|
155
155
|
add("Checking the current Pi session…");
|
|
156
156
|
} else if (!note) {
|
|
157
|
-
add("No assessment yet.
|
|
157
|
+
add("No assessment yet. Ctrl+R checks now.");
|
|
158
158
|
} else if (!note.text) {
|
|
159
159
|
add("No material concerns found in the last check.");
|
|
160
160
|
} else if (note.assessment) {
|
package/src/settings.ts
CHANGED
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
type BackendSelection,
|
|
7
7
|
agySelection,
|
|
8
8
|
CLAUDE_EFFORTS,
|
|
9
|
+
getPiHostContext,
|
|
9
10
|
GROK_EFFORTS,
|
|
10
11
|
CODEX_EFFORTS,
|
|
11
12
|
MUSE_EFFORTS,
|
|
12
13
|
PI_EFFORTS,
|
|
14
|
+
piPhysicalModel,
|
|
13
15
|
} from "./backend.ts";
|
|
14
16
|
import { type BroMode, DEFAULT_BRO_MODE, MAX_PREFERENCES_CHARS, parseBroMode } from "./prompt.ts";
|
|
15
17
|
import { errorMessage, isRecord } from "./util.ts";
|
|
@@ -507,10 +509,16 @@ export async function ensureSettingsFile(): Promise<void> {
|
|
|
507
509
|
await mkdir(getAgentDir(), { recursive: true });
|
|
508
510
|
try {
|
|
509
511
|
const envModel = process.env.PI_BRO_MODEL?.trim();
|
|
510
|
-
const
|
|
512
|
+
const host = getPiHostContext();
|
|
513
|
+
const active = host?.model;
|
|
514
|
+
// PiG can report a placeholder when no model is configured; only bootstrap from a catalog model.
|
|
515
|
+
const pair: ModelEffortPair = envModel
|
|
516
|
+
? { model: envModel, effort: "default" }
|
|
517
|
+
: active && piPhysicalModel(host?.modelRegistry, active.provider, active.id)
|
|
518
|
+
? { backend: "pi", model: piModelValue(active.provider, active.id), effort: "default" }
|
|
519
|
+
: { model: "gemini-3.7-flash", effort: "low" };
|
|
511
520
|
const initial: BroSettings = {
|
|
512
|
-
|
|
513
|
-
effort: envModel ? "default" : "low",
|
|
521
|
+
...pair,
|
|
514
522
|
mode: DEFAULT_BRO_MODE,
|
|
515
523
|
showTurns: DEFAULT_SHOW_TURNS,
|
|
516
524
|
overrides: {},
|
package/src/simplify-engine.ts
CHANGED
|
@@ -28,10 +28,10 @@ export const SIMPLIFY_MODAL_HELP = [
|
|
|
28
28
|
"- \`/simplify\` — explain the latest completed assistant reply",
|
|
29
29
|
"- \`/url <url>\` — explain a public webpage",
|
|
30
30
|
"- \`/text <text>\` — explain pasted text",
|
|
31
|
-
"- \`/file <path>\` — explain a
|
|
31
|
+
"- \`/file <path>\` — explain a local document (any readable path)",
|
|
32
32
|
"- \`/copy\` — copy the current explanation",
|
|
33
33
|
"- \`/clear\` — clear the explanation and source",
|
|
34
34
|
"- \`/help\` — show these commands",
|
|
35
35
|
"",
|
|
36
|
-
"With an empty composer, **M** changes explanation mode and re-explains the captured source; **R** retries. Both keep the backend configured for Explain. **Esc**
|
|
36
|
+
"With an empty composer, **M** changes explanation mode and re-explains the captured source; **R** retries. Both keep the backend configured for Explain. **Esc** returns from help to your saved explanation; if there is none, or you are already reading it, **Esc** closes. /bro simplify reopens this view in the current Pi session.",
|
|
37
37
|
].join("\n");
|
package/src/simplify-ui.ts
CHANGED
|
@@ -58,29 +58,37 @@ export async function openSimplifyWorkflow(
|
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
if (initial.kind === "resume") {
|
|
62
|
+
state.view = state.result ? "result" : "help";
|
|
63
|
+
if (!state.draft?.trim()) state.error = undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
61
66
|
await openBroOverlay<void>(ctx,(tui,theme,_keys,done)=>{
|
|
62
67
|
let closed=false;
|
|
63
68
|
let controller:AbortController|undefined;
|
|
64
69
|
let stopProgress:(()=>void)|undefined;
|
|
65
70
|
let running=false;
|
|
66
|
-
const
|
|
71
|
+
const syncDraft=()=>{const draft=modal.getComposerText();state.draft=draft;if(!draft.trim())state.error=undefined;};
|
|
72
|
+
const close=()=>{if(closed)return; closed=true;syncDraft();stopProgress?.();controller?.abort();done(undefined);};
|
|
67
73
|
const modal=new BtwModal(tui,theme,close,submit,()=>{
|
|
68
|
-
closed=true;
|
|
74
|
+
if(!closed){closed=true;syncDraft();stopProgress?.();controller?.abort();}
|
|
69
75
|
},{
|
|
70
76
|
title:"Bro · simplify",
|
|
71
77
|
commands:"",
|
|
72
|
-
inputLabel:"Simplify command",
|
|
73
|
-
idleHint:"Enter run · M change mode · R retry · /copy · /help · Esc close",
|
|
78
|
+
inputLabel:"Simplify command · /simplify runs again on the latest reply",
|
|
79
|
+
idleHint:"Enter run · M change mode · R retry · /copy · /help · Esc back from help / close",
|
|
74
80
|
});
|
|
75
81
|
const display=()=>{
|
|
76
82
|
modal.setCustomMode(state.result?.mode ? state.result.mode+(state.result.preferences ? " · prefs" : "") : "one source · one explanation");
|
|
77
83
|
modal.setModel(state.result?.model ?? "");
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
modal.setText(
|
|
85
|
+
state.view==="result"&&state.result
|
|
86
|
+
? (state.result.source.label ? "**Source:** "+stripVTControlCharacters(state.result.source.label).replace(/[\r\n]/g," ")+"\n\n---\n\n" : "")+state.result.text
|
|
87
|
+
: SIMPLIFY_MODAL_HELP,
|
|
88
|
+
);
|
|
81
89
|
// Notices describe the currently shown state, not an earlier request.
|
|
82
90
|
modal.setNotice(state.error ?? "",state.error ? "error" : "info");
|
|
83
|
-
modal.
|
|
91
|
+
modal.scrollToStart();
|
|
84
92
|
};
|
|
85
93
|
const run=async (request:SimplifyStart|SimplifyAction, retained?:BroSource, mode?:BroMode, submitted?:string)=>{
|
|
86
94
|
if(running||closed)return;
|
|
@@ -154,6 +162,9 @@ export async function openSimplifyWorkflow(
|
|
|
154
162
|
void run(action,undefined,undefined,raw);
|
|
155
163
|
}
|
|
156
164
|
modal.onKey=(data:string)=>{
|
|
165
|
+
if(!running && state.view==="help" && state.result && matchesKey(data,"escape")){
|
|
166
|
+
state.view="result";state.error=undefined;display();return true;
|
|
167
|
+
}
|
|
157
168
|
if(running||modal.getComposerText().trim())return false;
|
|
158
169
|
if(matchesKey(data,"m")||matchesKey(data,"shift+m")){retry(true);return Boolean(state.result);}
|
|
159
170
|
if(matchesKey(data,"r")||matchesKey(data,"shift+r")){retry();return Boolean(state.result);}
|
package/src/sources.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, stat, realpath } from "node:fs/promises";
|
|
2
|
-
import {
|
|
2
|
+
import { resolve, extname } from "node:path";
|
|
3
3
|
import { request as httpRequest, type IncomingMessage, type ClientRequest } from "node:http";
|
|
4
4
|
import { request as httpsRequest } from "node:https";
|
|
5
5
|
import { lookup } from "node:dns/promises";
|
|
@@ -28,20 +28,13 @@ export async function extractDocumentText(input: string, cwd: string, signal?: A
|
|
|
28
28
|
if (!requested) throw new Error("Use /bro file <path>.");
|
|
29
29
|
if (signal?.aborted) throw new Error("Canceled.");
|
|
30
30
|
|
|
31
|
-
let root: string;
|
|
32
31
|
let path: string;
|
|
33
32
|
try {
|
|
34
|
-
root = await realpath(cwd);
|
|
35
33
|
path = await realpath(resolve(cwd, requested));
|
|
36
34
|
} catch (error) {
|
|
37
35
|
throw fileError(requested, error);
|
|
38
36
|
}
|
|
39
37
|
|
|
40
|
-
const fromRoot = relative(root, path);
|
|
41
|
-
if (fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
|
|
42
|
-
throw new Error("Bro can read only files inside the current workspace.");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
38
|
let info;
|
|
46
39
|
try {
|
|
47
40
|
info = await stat(path);
|
|
@@ -86,14 +79,9 @@ export async function extractDocumentText(input: string, cwd: string, signal?: A
|
|
|
86
79
|
return text;
|
|
87
80
|
}
|
|
88
81
|
|
|
89
|
-
export async function
|
|
90
|
-
// ponytail: duplicates extractDocumentText's workspace guard rather than sharing its error semantics.
|
|
82
|
+
export async function isDocumentFile(input: string, cwd: string): Promise<boolean> {
|
|
91
83
|
try {
|
|
92
84
|
const path = await realpath(resolve(cwd, input));
|
|
93
|
-
const fromRoot = relative(await realpath(cwd), path);
|
|
94
|
-
if (fromRoot === ".." || fromRoot.startsWith(`..${sep}`) || isAbsolute(fromRoot)) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
85
|
const info = await stat(path);
|
|
98
86
|
return info.isFile() && SNIFFABLE_FILE_EXTENSIONS.has(extname(path).toLowerCase());
|
|
99
87
|
} catch {
|