pi-bro 0.38.1 → 0.40.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/src/backend.ts CHANGED
@@ -3,18 +3,15 @@ import { executeClaude } from "./backends/claude.ts";
3
3
  import { DEFAULT_KILL_ESCALATION_MS } from "./backends/cli-process.ts";
4
4
  import { executeCodex } from "./backends/codex.ts";
5
5
  import {
6
- CLAUDE_EFFORTS, CODEX_EFFORTS, GROK_EFFORTS, MUSE_EFFORTS, PI_EFFORTS,
6
+ CLAUDE_EFFORTS, CODEX_EFFORTS, PI_EFFORTS,
7
7
  type BackendAccess, type BackendExecuteOptions, type BackendFeature, type BackendOnProgress,
8
8
  type BackendOutcome, type BackendProgress, type BackendRequest, type BackendSelection,
9
9
  } from "./backends/contract.ts";
10
- import { executeGrok } from "./backends/grok.ts";
11
- import { executeMuse } from "./backends/muse.ts";
12
10
  import { executePi, getPiHostContext, type PiHostContext } from "./backends/pi.ts";
13
11
 
14
12
  export * from "./backends/contract.ts";
15
13
  export { agyFailureMessage, agySelection, advisorFlagErrorHint, parseBtwAgyLine } from "./backends/agy.ts";
16
14
  export { beginAttempt, frameStdoutLines, MAX_STDOUT_LINE_CHARS } from "./backends/cli-process.ts";
17
- export { GROK_RESTRICTED_PREFIX } from "./backends/grok.ts";
18
15
  export {
19
16
  bridgePiRuntimeForCatalog, getPiHostContext, piEffectiveEffort, piPhysicalModel,
20
17
  piScopedThinkingLevel, piToolAllowlist, setPiHostContext, splitPiModel,
@@ -24,20 +21,20 @@ export { verifyCliSubscription } from "./cli-auth.ts";
24
21
 
25
22
  // Shared internal execution boundary for explain, show, btw, advisor, and review.
26
23
  // This implements docs/plans/2026-09-22-shared-backend-design.md across all supported backends
27
- // (Agy, Claude Code, Grok, Codex, Muse, and the in-process Pi SDK): it owns model selection, process
24
+ // (Agy, Claude Code, Codex, and the in-process Pi SDK): it owns model selection, process
28
25
  // (or session) invocation, progress/outcome normalization, continuation, and single-attempt cleanup.
29
26
  // Feature code keeps retries, UI, source/session capture and settings.
30
- // For Guided Review (`feature: "review"`), Claude, Muse, and Pi enforce strict file-only inspection;
31
- // Agy, Grok, and Codex run inside their own sandbox with shell available, and the UI owns telling
27
+ // For Guided Review (`feature: "review"`), Claude and Pi enforce strict file-only inspection;
28
+ // Agy and Codex run inside their own sandbox with shell available, and the UI owns telling
32
29
  // the user via `reviewBackendNotice`.
33
30
 
34
- // Per-backend truth, not one shared sentence: Codex and Grok have a read-only sandbox, Agy's
31
+ // Per-backend truth, not one shared sentence: Codex has a read-only sandbox, Agy's
35
32
  // sandbox only restricts terminal commands and still lets it write inside the project. Kept short
36
33
  // enough that the whole notice fits the review window's advisory rows on a narrow terminal.
37
- export function reviewBackendNotice(backend: "agy" | "claude" | "grok" | "codex" | "muse" | "pi"): string | undefined {
38
- if (backend === "claude" || backend === "muse" || backend === "pi") return undefined;
34
+ export function reviewBackendNotice(backend: "agy" | "claude" | "codex" | "pi"): string | undefined {
35
+ if (backend === "claude" || backend === "pi") return undefined;
39
36
  const sandbox = backend === "agy" ? "sandboxed shell (project writes allowed)" : "sandboxed shell in a read-only sandbox";
40
- return `Guided Review on ${backend} uses ${sandbox}, not strict file-only inspection. Claude, Muse, or Pi is recommended for untrusted PRs.`;
37
+ return `Guided Review on ${backend} uses ${sandbox}, not strict file-only inspection. Claude or Pi is recommended for untrusted PRs.`;
41
38
  }
42
39
  // One default deadline table for every adapter: workspace-full, Guided Review and the advisor get
43
40
  // the long bound; btw the middle one; explain/show the short one.
@@ -76,12 +73,12 @@ async function executeOnce(
76
73
  ) return { status: "failure", message: "Unsupported execution request: check feature access, workspace cwd and continuation." };
77
74
  const backend = (selection as { backend?: unknown }).backend;
78
75
  // An explicit tag guard: a stale or corrupt runtime tag must fail, never fall through to Agy.
79
- if (backend !== undefined && backend !== "agy" && backend !== "claude" && backend !== "grok" && backend !== "codex" && backend !== "muse" && backend !== "pi") {
80
- return { status: "failure", message: `Unknown backend ${JSON.stringify(backend)}: pick Agy, Claude, Grok, Codex, Muse or Pi in \`/bro config\`.` };
76
+ if (backend !== undefined && backend !== "agy" && backend !== "claude" && backend !== "codex" && backend !== "pi") {
77
+ return { status: "failure", message: `Unknown backend ${JSON.stringify(backend)}: pick Agy, Claude, Codex or Pi in \`/bro config\`.` };
81
78
  }
82
79
  // Review requires cwd above; restricted BTW also keeps native external sessions in the caller's workspace.
83
80
  if (request.feature === "btw" && !request.cwd?.trim() &&
84
- (backend === "codex" || backend === "muse" || backend === "grok" || backend === "claude")) {
81
+ (backend === "codex" || backend === "claude")) {
85
82
  return { status: "failure", message: "Unsupported execution request: check feature access, workspace cwd and continuation." };
86
83
  }
87
84
  const killEscalationMs = options?.killEscalationMs ?? DEFAULT_KILL_ESCALATION_MS;
@@ -98,26 +95,10 @@ async function executeOnce(
98
95
  // Codex btw always runs (and resumes) in the caller's workspace, even restricted.
99
96
 
100
97
  if (invalidModelEffortSelection(selection, CODEX_EFFORTS)) {
101
- return { status: "failure", message: "Unsupported Codex selection: check the model and effort (low, medium, high or xhigh)." };
98
+ return { status: "failure", message: "Unsupported Codex selection: check the model and effort (low, medium, high, xhigh or max)." };
102
99
  }
103
100
  return executeCodex(request, selection, signal, onProgress, killEscalationMs, deadlineMs);
104
101
  }
105
- if (selection.backend === "muse") {
106
- // Muse btw always runs (and resumes) in the caller's workspace, even restricted.
107
-
108
- if (invalidModelEffortSelection(selection, MUSE_EFFORTS)) {
109
- return { status: "failure", message: "Unsupported Muse selection: check the model and effort (minimal, low, medium, high, xhigh or max)." };
110
- }
111
- return executeMuse(request, selection, signal, onProgress, killEscalationMs, deadlineMs);
112
- }
113
- if (selection.backend === "grok") {
114
- // Grok btw always runs (and resumes) in the caller's workspace, even restricted.
115
-
116
- if (invalidModelEffortSelection(selection, GROK_EFFORTS)) {
117
- return { status: "failure", message: "Unsupported Grok selection: check the model and effort (low, medium, high or xhigh)." };
118
- }
119
- return executeGrok(request, selection, signal, onProgress, killEscalationMs, deadlineMs);
120
- }
121
102
  if (selection.backend === "claude") {
122
103
  // Claude btw always runs (and resumes) in the caller's workspace, even restricted.
123
104
 
@@ -3,7 +3,7 @@ import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { withDoctor } from "../util.ts";
5
5
  import { finishCliAttempt, startCliAttempt, stoppedCliOutcome } from "./cli-process.ts";
6
- import { btwToolName, type AgySelection, type BackendOnProgress, type BackendOutcome, type BackendRequest } from "./contract.ts";
6
+ import { AGY_EFFORTS, btwToolName, type AgySelection, type BackendOnProgress, type BackendOutcome, type BackendRequest } from "./contract.ts";
7
7
 
8
8
  export function agyFailureMessage(action: string, result: { code: number; killed: boolean; stderr: string }): string {
9
9
  if (result.killed) return `Agy timed out while trying to ${action}. Run \`/bro doctor\` for setup help.`;
@@ -12,11 +12,11 @@ export function agyFailureMessage(action: string, result: { code: number; killed
12
12
  return `Agy could not ${action}. Make sure Agy is installed and signed in, then run \`/bro doctor\`.`;
13
13
  }
14
14
 
15
- // Strips a "-low/-medium/-high" suffix from a stored model id and separates it back into a plain
15
+ // Strips an effort suffix from a stored model id and separates it back into a plain
16
16
  // Agy `--model`/`--effort` pair; a "default" effort omits --effort entirely (Agy's own default).
17
- export function agySelection(pair: { model: string; effort: "default" | "low" | "medium" | "high" }): AgySelection {
17
+ export function agySelection(pair: { model: string; effort: "default" | (typeof AGY_EFFORTS)[number] }): AgySelection {
18
18
  if (pair.effort === "default") return { model: pair.model };
19
- const suffix = (["low", "medium", "high"] as const).find((effort) => pair.model.endsWith(`-${effort}`));
19
+ const suffix = AGY_EFFORTS.find((effort) => pair.model.endsWith(`-${effort}`));
20
20
  return {
21
21
  model: suffix ? pair.model.slice(0, -suffix.length - 1) : pair.model,
22
22
  effort: pair.effort,
@@ -6,13 +6,9 @@ export function processStartMessage(processError: NodeJS.ErrnoException, cli = "
6
6
  if (processError.code === "ENOENT") {
7
7
  return cli === "Agy"
8
8
  ? "Agy could not start. Make sure Agy is installed and on PATH, then run `/bro doctor`."
9
- : cli === "Grok"
10
- ? "Grok could not start. Make sure `grok` is installed and on PATH, then run `/bro doctor`."
11
- : cli === "Codex"
12
- ? "Codex could not start. Make sure `codex` is installed and on PATH, then run `/bro doctor`."
13
- : cli === "Muse"
14
- ? "Muse could not start. Make sure `muse` is installed and on PATH, then run `/bro doctor`."
15
- : "Claude Code could not start. Make sure `claude` is installed and on PATH, then run `/bro doctor`.";
9
+ : cli === "Codex"
10
+ ? "Codex could not start. Make sure `codex` is installed and on PATH, then run `/bro doctor`."
11
+ : "Claude Code could not start. Make sure `claude` is installed and on PATH, then run `/bro doctor`.";
16
12
  }
17
13
  return `${cli} could not start: ${processError.message}\n\nRun \`/bro doctor\` for setup help.`;
18
14
  }
@@ -222,7 +218,7 @@ export function stoppedCliOutcome(
222
218
 
223
219
  /** Session continuity is a shared BTW promise, even though CLIs report IDs differently. */
224
220
  export function checkedBtwContinuation(
225
- name: "Claude" | "Grok" | "Codex" | "Muse",
221
+ name: "Claude" | "Codex",
226
222
  requested: BackendContinuation | undefined,
227
223
  observed: { id?: string; init?: string; result?: string },
228
224
  ): BackendContinuation | { error: string } {
@@ -234,14 +230,12 @@ export function checkedBtwContinuation(
234
230
  }
235
231
 
236
232
  /** Exit diagnostics share framing, while each backend still owns its prompt and protocol. */
237
- export function cliExitFailure(name: "Claude" | "Grok" | "Codex" | "Muse", action: string, stderr: string): string {
233
+ export function cliExitFailure(name: "Claude" | "Codex", action: string, stderr: string): string {
238
234
  const detail = stderr.trim();
239
235
  if (detail) return `${name} could not ${action}: ${detail}\n\nRun \`/bro doctor\` for setup help.`;
240
236
  const installation = {
241
237
  Claude: "Claude Code",
242
- Grok: "`grok`",
243
238
  Codex: "`codex`",
244
- Muse: "`muse`",
245
239
  }[name];
246
240
  return `${name} could not ${action}. Make sure ${installation} is installed and signed in, then run \`/bro doctor\`.`;
247
241
  }
@@ -4,25 +4,22 @@ import type { createAgentSession } from "@earendil-works/pi-coding-agent";
4
4
  export type BackendFeature = "explain" | "show" | "btw" | "advisor" | "review";
5
5
  export type BackendAccess = "restricted" | "workspace-full";
6
6
 
7
- export type AgySelection = { model: string; effort?: "low" | "medium" | "high" };
7
+ export const AGY_EFFORTS = ["low", "medium", "high", "xhigh", "max"] as const;
8
+ export type AgySelection = { model: string; effort?: (typeof AGY_EFFORTS)[number] };
8
9
  export const CLAUDE_EFFORTS = ["low", "medium", "high", "xhigh", "max"] as const;
9
- export const GROK_EFFORTS = ["low", "medium", "high", "xhigh"] as const;
10
- export const CODEX_EFFORTS = ["low", "medium", "high", "xhigh"] as const;
11
- export const MUSE_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"] as const;
10
+ export const CODEX_EFFORTS = ["low", "medium", "high", "xhigh", "max"] as const;
12
11
  export const PI_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"] as const;
13
12
  export type BackendSelection =
14
13
  | ({ backend?: "agy" } & AgySelection)
15
14
  | { backend: "claude"; model: string; effort?: (typeof CLAUDE_EFFORTS)[number] }
16
- | { backend: "grok"; model: string; effort?: (typeof GROK_EFFORTS)[number] }
17
15
  | { backend: "codex"; model: string; effort?: (typeof CODEX_EFFORTS)[number] }
18
- | { backend: "muse"; model: string; effort?: (typeof MUSE_EFFORTS)[number] }
19
16
  | { backend: "pi"; model: string; effort?: (typeof PI_EFFORTS)[number] };
20
17
  export type BackendContinuation = { id: string };
21
18
  export type BackendProgress = { kind: "text"; text: string } | { kind: "activity"; label: string; timestamp: number; tool?: string };
22
19
  export type BackendOnProgress = (progress: BackendProgress) => void;
23
20
 
24
21
  /** BTW reports a tool name/type, not a command, argument, or assistant message.
25
- * All six adapters use this extraction before events cross into the UI. */
22
+ * All four adapters use this extraction before events cross into the UI. */
26
23
  export function btwToolName(value: unknown): string | undefined {
27
24
  if (typeof value !== "string") return undefined;
28
25
  // Restrict to the initial identifier. Agy may supply "Read /path" (or
package/src/bro.ts CHANGED
@@ -74,7 +74,7 @@ const COMMANDS = [
74
74
  { value: "elevate", label: "elevate", description: "Have an assignment for Pi? Get an improved request to copy and send" },
75
75
  { value: "remember-me", label: "remember-me", description: "Want Pi to remember your preferences? Save approved memories for about_user" },
76
76
  { value: "grill-me", label: "grill-me", description: "Facing a decision? Get focused challenges and an optional decision brief" },
77
- { value: "overthink", label: "overthink", description: "Want a quiet second look after big work? Get private notes from the active model" },
77
+ { value: "overthink", label: "overthink", description: "Want a quiet second look? One actionable check from the active model" },
78
78
  { value: "config", label: "config", description: "Global defaults, diagnostics and feature settings" },
79
79
  { value: "advisor", label: "advisor", description: "Check whether the executor's advisor tool is available right now" },
80
80
  { value: "advisor-steer", label: "advisor-steer", description: "Want to shape future advice? Save priorities for the advisor" },
package/src/btw.ts CHANGED
@@ -71,7 +71,7 @@ export function toggleBtwMode(thread: BtwThread): void {
71
71
  thread.full = !thread.full;
72
72
  }
73
73
 
74
- // Claude, Grok, Codex, and Muse run btw in the workspace for both modes and resume one native session across
74
+ // Claude and Codex run btw in the workspace for both modes and resume one native session across
75
75
  // /mode switches. An Agy conversation stays bound to the workspace it started in (a sandbox scratch
76
76
  // dir vs. the repo), so an access change drops it; the next turn reseeds a fresh native session
77
77
  // with the main-session context and the whole thread. Pi behaves like Agy here: its restricted mode
@@ -16,7 +16,6 @@ const rowsFor=(screen:ConfigNavScreen, automatic:boolean):readonly MenuItem[]=>{
16
16
  if(screen==="global")return CONFIG_GLOBAL;
17
17
  if(screen==="features")return CONFIG_FEATURES;
18
18
  if(screen==="overthink")return [
19
- {value:"overthink-defaults",label:"Default questions — edit starting set"},
20
19
  {value:"overthink-toggle",label:"Automatic checks — "+(automatic?"On":"Off")+" (Enter to toggle)"},
21
20
  ];
22
21
  if(screen==="advisor")return [
@@ -65,7 +64,6 @@ export function createConfigNavigationModal(
65
64
  if(value==="explain"||value==="show"||value==="btw"||value==="review")return finish({kind:"settings",page:value});
66
65
  }
67
66
  if(state.screen==="overthink"){
68
- if(value==="overthink-defaults")return finish({kind:"overthink-defaults"});
69
67
  if(value==="overthink-toggle")return finish({kind:"overthink-toggle"});
70
68
  }
71
69
  if(state.screen==="advisor"){
@@ -8,7 +8,7 @@ export type ConfigNavScreen = "root" | "global" | "features" | "advisor" | "inhe
8
8
  export type ConfigNavState = { screen: ConfigNavScreen; inherited?: "elevate"|"grill-me"|"remember-me"|"architecture" };
9
9
  export type ConfigNavAction =
10
10
  | {kind:"settings";page:ConfigSettingsPage}
11
- | {kind:"preferences"|"doctor"|"advisor-steer"|"overthink-defaults"|"overthink-toggle"|"close"};
11
+ | {kind:"preferences"|"doctor"|"advisor-steer"|"overthink-toggle"|"close"};
12
12
 
13
13
  export const CONFIG_ROOT = [
14
14
  {value:"global",label:"Global — shared defaults, preferences and Doctor"},
@@ -28,7 +28,7 @@ export const CONFIG_FEATURES = [
28
28
  {value:"elevate",label:"Elevate — inherits BTW"},
29
29
  {value:"grill-me",label:"Grill Me — inherits BTW"},
30
30
  {value:"remember-me",label:"Remember Me — inherits BTW"},
31
- {value:"overthink",label:"Overthink — automatic checks and default questions"},
31
+ {value:"overthink",label:"Overthink — automatic second-look checks"},
32
32
  {value:"architecture",label:"Architecture Docs — inherits BTW"},
33
33
  ] as const;
34
34
 
@@ -57,18 +57,15 @@ export function configFeatureAccessNote(settings: BroSettings, feature: "btw" |
57
57
  const notes: Record<typeof backend,string> = {
58
58
  agy:"Agy's conversation-only path uses a temporary directory and sandboxed shell; the sandbox is not a no-write guarantee.",
59
59
  claude:"Claude disables tools in conversation-only mode.",
60
- grok:"Grok's conversation-only limit is prompt guidance only: its sandbox stays off and permissions are bypassed.",
61
60
  codex:"Codex allows workspace reads and sandboxed commands under its read-only sandbox; it is not tool-free.",
62
- muse:"Muse disables shell, write and approvals in conversation-only mode, but other tools can remain available.",
63
61
  pi:"Pi's conversation-only session has no tools, extensions or context files.",
64
62
  };
65
63
  return "BTW: /mode in the BTW modal toggles conversation-only and full workspace access; full mode bypasses backend permission checks. "+notes[backend];
66
64
  }
67
65
  const existing=reviewBackendNotice(backend);
68
66
  if(existing)return existing;
69
- const strict: Record<"claude"|"muse"|"pi",string>={
67
+ const strict: Record<"claude"|"pi",string>={
70
68
  claude:"Claude uses Read/Grep/Glob file-inspection tools only in the captured checkout; no shell.",
71
- muse:"Muse disables shell, writes and web access in the captured checkout; reads remain available.",
72
69
  pi:"Pi permits only read/grep/find/ls in the captured checkout; no shell or workspace writes.",
73
70
  };
74
71
  return "Guided Review: "+strict[backend as keyof typeof strict]+
package/src/config-ui.ts CHANGED
@@ -15,8 +15,10 @@ import {
15
15
  type BackendName,
16
16
  type BroSettings,
17
17
  type Capability,
18
+ type CodexModelChoice,
18
19
  type ExternalBackend,
19
20
  type PiModelChoice,
21
+ AGY_EFFORTS,
20
22
  CAPABILITIES,
21
23
  CAPABILITY_LABELS,
22
24
  EXTERNAL_BACKENDS,
@@ -45,9 +47,7 @@ const SHOW_TURNS_PRESETS = [1, 2, 3, 5, 8];
45
47
  const BACKEND_CHOICES: readonly { value: BackendName; label: string }[] = [
46
48
  { value: "agy", label: "Agy" },
47
49
  { value: "claude", label: "Claude" },
48
- { value: "grok", label: "Grok" },
49
50
  { value: "codex", label: "Codex" },
50
- { value: "muse", label: "Muse" },
51
51
  { value: "pi", label: "Pi" },
52
52
  ] as const;
53
53
 
@@ -67,6 +67,7 @@ export function createConfigModal(
67
67
  persistSettings: (settings: BroSettings) => Promise<void>,
68
68
  piModels: PiModelChoice[] = [],
69
69
  page: ConfigSettingsPage | "all" = "all",
70
+ codexModels: CodexModelChoice[] = [],
70
71
  ): (tui: TuiLike, theme: Theme, keybindings: unknown, done: (value?: void) => void) => Component & { dispose?(): void } {
71
72
  return (tui, theme, _keybindings, done) => {
72
73
  // Size the host list once, then stop interaction if a later resize cannot show the whole
@@ -118,13 +119,20 @@ export function createConfigModal(
118
119
 
119
120
  const buildModelOptions = (backend: BackendName): SelectItem[] => {
120
121
  if (backend === "agy") {
121
- return families.map((family) => ({
122
- value: family.id,
123
- label: `${family.label}${family.efforts.length ? "" : " · fixed effort"}`,
124
- }));
122
+ return [
123
+ ...families.map((family) => ({
124
+ value: family.id,
125
+ label: `${family.label}${family.efforts.length ? "" : " · fixed effort"}`,
126
+ })),
127
+ { value: "__agy_custom__", label: "Agy · custom model ID…" },
128
+ ];
125
129
  }
126
130
  const meta = EXTERNAL_BACKENDS[backend];
127
- const models = backend === "pi" ? piModels.map((choice) => ({ id: choice.value, label: choice.label })) : meta.models;
131
+ const models = backend === "pi"
132
+ ? piModels.map((choice) => ({ id: choice.value, label: choice.label }))
133
+ : backend === "codex"
134
+ ? codexModels.map((choice) => ({ id: choice.value, label: choice.label }))
135
+ : meta.models;
128
136
  return [
129
137
  ...models.map((model) => ({ value: `${meta.prefix}${model.id}`, label: model.label })),
130
138
  { value: `__${backend}_custom__`, label: `${meta.label} · custom model ID…` },
@@ -141,7 +149,7 @@ export function createConfigModal(
141
149
  const prefix = chosenBackend && chosenBackend !== "agy" ? EXTERNAL_BACKENDS[chosenBackend].prefix : "";
142
150
  modelSelectList.setSelectedIndex(Math.max(0, items.findIndex((option) => option.value === current || option.value === `${prefix}${current}`)));
143
151
  modelSelectList.onSelect = (item) => {
144
- if (chosenBackend && chosenBackend !== "agy" && item.value === `__${chosenBackend}_custom__`) {
152
+ if (chosenBackend && item.value === `__${chosenBackend}_custom__`) {
145
153
  step = "custom";
146
154
  customError = undefined;
147
155
  tui.requestRender();
@@ -178,12 +186,18 @@ export function createConfigModal(
178
186
  picker.onCancel = () => pickerDone();
179
187
 
180
188
  input.onSubmit = (value) => {
181
- if (!value.trim() || !chosenBackend || chosenBackend === "agy") return;
189
+ const trimmed = value.trim();
190
+ if (!trimmed || !chosenBackend) return;
191
+ if (chosenBackend === "agy") {
192
+ customError = undefined;
193
+ pickerDone(trimmed);
194
+ return;
195
+ }
182
196
  // Validate before leaving the step so a malformed ID (Pi needs "<provider>/<id>") shows an
183
197
  // inline hint and leaves the field open, instead of throwing out of the input handler.
184
- const choice = `${EXTERNAL_BACKENDS[chosenBackend].prefix}${value.trim()}`;
198
+ const choice = `${EXTERNAL_BACKENDS[chosenBackend].prefix}${trimmed}`;
185
199
  try {
186
- EXTERNAL_BACKENDS[chosenBackend].resolveModel(value.trim());
200
+ EXTERNAL_BACKENDS[chosenBackend].resolveModel(trimmed);
187
201
  } catch (error) {
188
202
  customError = errorMessage(error);
189
203
  tui.requestRender();
@@ -196,9 +210,10 @@ export function createConfigModal(
196
210
  return {
197
211
  // SettingsList draws an open submenu instead of its own list and hints, so the picker brings its own.
198
212
  render: (width: number) => {
199
- if (step === "custom" && chosenBackend && chosenBackend !== "agy") {
213
+ if (step === "custom" && chosenBackend) {
214
+ const label = chosenBackend === "agy" ? "Agy" : EXTERNAL_BACKENDS[chosenBackend].label;
200
215
  return [
201
- `${EXTERNAL_BACKENDS[chosenBackend].label} model ID:${chosenBackend === "pi" ? " <provider>/<id>" : ""}`,
216
+ `${label} model ID:${chosenBackend === "pi" ? " <provider>/<id>" : ""}`,
202
217
  ...input.render(width),
203
218
  ...(customError ? [truncateToWidth(theme.fg("warning", ` ${customError}`), width)] : []),
204
219
  "",
@@ -269,9 +284,9 @@ export function createConfigModal(
269
284
  effortItem.currentValue = effortDisplay(def, defaultBackend);
270
285
  effortItem.values = isExternalBackend(defaultBackend)
271
286
  ? ["default", ...EXTERNAL_BACKENDS[defaultBackend].efforts]
272
- : def.family?.efforts.length
273
- ? [...def.family.efforts]
274
- : undefined;
287
+ : def.family
288
+ ? (def.family.efforts.length ? [...def.family.efforts] : undefined)
289
+ : ["default", ...AGY_EFFORTS];
275
290
  modeItem.currentValue = settings.mode;
276
291
  showTurnsItem.currentValue = String(settings.showTurns);
277
292
  showTurnsItem.values = showTurnsValues(settings.showTurns);
@@ -290,9 +305,9 @@ export function createConfigModal(
290
305
  rows.effort.values =
291
306
  backend in EXTERNAL_BACKENDS
292
307
  ? ["default", ...EXTERNAL_BACKENDS[backend as ExternalBackend].efforts]
293
- : resolved.family?.efforts.length
294
- ? [...resolved.family.efforts]
295
- : undefined;
308
+ : resolved.family
309
+ ? (resolved.family.efforts.length ? [...resolved.family.efforts] : undefined)
310
+ : ["default", ...AGY_EFFORTS];
296
311
  }
297
312
  }
298
313
  refresh();
package/src/doctor.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { mkdtemp, rm } from "node:fs/promises";
2
- import { tmpdir } from "node:os";
1
+ import { mkdtemp, readFile, rm } from "node:fs/promises";
2
+ import { homedir, tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import {
5
5
  getAgentDir,
@@ -23,14 +23,15 @@ import { createConfigNavigationModal } from "./config-navigation-ui.ts";
23
23
  import { type ConfigNavAction, type ConfigNavState } from "./config-navigation.ts";
24
24
  import { showBroModal, showPreferencesModal, showAdvisorSteerModal } from "./explain-modal.ts";
25
25
  import { openBroOverlay } from "./modal-kit.ts";
26
- import { openOverthinkDefaults } from "./overthink.ts";
27
26
  import { readAutomaticChecks, writeAutomaticChecks } from "./overthink-state.ts";
28
27
  import {
29
28
  type AgyEffort,
30
29
  type AgyModelFamily,
31
30
  type BackendName,
32
31
  type BroSettings,
32
+ type CodexModelChoice,
33
33
  type PiModelChoice,
34
+ AGY_EFFORTS,
34
35
  CAPABILITIES,
35
36
  CAPABILITY_LABELS,
36
37
  EFFORTS,
@@ -41,6 +42,7 @@ import {
41
42
  capabilityPair,
42
43
  readPreferences,
43
44
  readSettings,
45
+ readSettingsForConfig,
44
46
  resolveCapabilitySettings,
45
47
  resolveModelEffort,
46
48
  toPiModelChoices,
@@ -71,20 +73,22 @@ export function formatAgyUsage(value: unknown): string {
71
73
  }
72
74
 
73
75
  export function parseAgyModels(output: string): AgyModelFamily[] {
74
- // ponytail: Agy 1.1.13 exposes a tab-separated variant list; use structured catalog data when available here.
76
+ // ponytail: Agy exposes a tab-separated variant list; group dynamically by effort suffix without hard-coding model names.
75
77
  const families = new Map<string, AgyModelFamily>();
76
78
  for (const line of output.split(/\r?\n/)) {
77
79
  const [rawId, ...rawLabel] = line.split("\t");
78
80
  if (!rawId?.trim() || !rawLabel.length) continue;
79
81
  const id = rawId.trim();
80
82
  const label = rawLabel.join(" ").trim();
81
- const effort = (["low", "medium", "high"] as const).find(
82
- (value) => id.endsWith(`-${value}`) && label.endsWith(`(${value[0].toUpperCase()}${value.slice(1)})`),
83
- );
83
+ const effortMatch = /\s+\((Low|Medium|High|XHigh|Max)\)$/i.exec(label);
84
+ const matchedEffort = effortMatch?.[1]?.toLowerCase() as AgyEffort | undefined;
85
+ const effort = matchedEffort && AGY_EFFORTS.includes(matchedEffort) && id.endsWith(`-${matchedEffort}`)
86
+ ? matchedEffort
87
+ : undefined;
84
88
  const familyId = effort ? id.slice(0, -effort.length - 1) : id;
85
89
  const family = families.get(familyId) ?? {
86
90
  id: familyId,
87
- label: effort ? label.replace(/\s+\((Low|Medium|High)\)$/, "") : label,
91
+ label: effort ? label.replace(/\s+\((Low|Medium|High|XHigh|Max)\)$/i, "") : label,
88
92
  efforts: [],
89
93
  variants: [],
90
94
  };
@@ -109,6 +113,43 @@ export async function listAgyModels(pi: ExtensionAPI, signal?: AbortSignal): Pro
109
113
  }
110
114
  }
111
115
 
116
+ export function parseCodexModelsCache(raw: string): CodexModelChoice[] {
117
+ const data = JSON.parse(raw) as unknown;
118
+ if (!data || typeof data !== "object" || !Array.isArray((data as { models?: unknown }).models)) {
119
+ throw new Error("Unexpected Codex models_cache.json format.");
120
+ }
121
+ const seen = new Set<string>();
122
+ const models: CodexModelChoice[] = [];
123
+ for (const item of (data as { models: unknown[] }).models) {
124
+ if (!item || typeof item !== "object") continue;
125
+ const record = item as { slug?: unknown; display_name?: unknown; visibility?: unknown };
126
+ if (record.visibility === "hide") continue;
127
+ if (typeof record.slug !== "string" || !record.slug.trim()) continue;
128
+ const value = record.slug.trim();
129
+ if (seen.has(value)) continue;
130
+ seen.add(value);
131
+ const label = typeof record.display_name === "string" && record.display_name.trim()
132
+ ? record.display_name.trim()
133
+ : value;
134
+ models.push({ value, label });
135
+ }
136
+ return models;
137
+ }
138
+
139
+ /** Reads Codex's local models_cache.json (respecting CODEX_HOME). Returns [] when absent so custom model IDs still work. */
140
+ export async function listCodexModels(codexHome?: string): Promise<CodexModelChoice[]> {
141
+ const base = codexHome ?? process.env.CODEX_HOME ?? join(homedir(), ".codex");
142
+ const file = join(base, "models_cache.json");
143
+ let raw: string;
144
+ try {
145
+ raw = await readFile(file, "utf8");
146
+ } catch (error) {
147
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
148
+ throw error;
149
+ }
150
+ return parseCodexModelsCache(raw);
151
+ }
152
+
112
153
  // The Pi backend's selectable models: the configured scoped models (enabledModels) when present,
113
154
  // else every model with configured auth. Physical models only -- a virtual model routes elsewhere
114
155
  // and cannot be driven as a standalone in-process session. This never makes a model request.
@@ -305,7 +346,7 @@ export async function doctorReport(pi: ExtensionAPI, ctx: ExtensionCommandContex
305
346
  fail("Preferences", error);
306
347
  }
307
348
 
308
- // Probe only the backends some feature actually selects: a Claude/Grok/Codex/Muse-only setup never
349
+ // Probe only the backends some feature actually selects: a Claude/Codex-only setup never
309
350
  // requires Agy to be installed, and vice versa.
310
351
  const backendInUse = (backend: BackendName) => settings
311
352
  ? CAPABILITIES.some(capability => capabilityBackend(settings, capability) === backend)
@@ -345,9 +386,8 @@ export async function doctorReport(pi: ExtensionAPI, ctx: ExtensionCommandContex
345
386
  pass("Agy", "not probed — no feature selects the Agy backend");
346
387
  }
347
388
 
348
- // These CLIs share a version probe; only Claude and Codex have a supported auth probe.
349
- // Grok and Muse must still say "unverified" rather than implying login or connectivity.
350
- for (const backend of ["claude", "grok", "codex", "muse"] as const) {
389
+ // Claude and Codex share a version probe and each has a supported auth probe.
390
+ for (const backend of ["claude", "codex"] as const) {
351
391
  const label = EXTERNAL_BACKENDS[backend].label;
352
392
  if (!backendInUse(backend)) {
353
393
  pass(label, `not probed — no feature selects the ${label} backend`);
@@ -359,15 +399,11 @@ export async function doctorReport(pi: ExtensionAPI, ctx: ExtensionCommandContex
359
399
  if (signal.aborted) throw error;
360
400
  fail(label, error);
361
401
  }
362
- if (backend === "claude" || backend === "codex") {
363
- try {
364
- pass(`${label} auth`, await (backend === "claude" ? checkClaudeAuth(pi, signal) : checkCodexAuth(pi, signal, ctx.cwd)));
365
- } catch (error) {
366
- if (signal.aborted) throw error;
367
- fail(`${label} auth`, error);
368
- }
369
- } else {
370
- pass(`${label} auth`, "unverified — no auth probe exists (version does not imply auth or connectivity)");
402
+ try {
403
+ pass(`${label} auth`, await (backend === "claude" ? checkClaudeAuth(pi, signal) : checkCodexAuth(pi, signal, ctx.cwd)));
404
+ } catch (error) {
405
+ if (signal.aborted) throw error;
406
+ fail(`${label} auth`, error);
371
407
  }
372
408
  }
373
409
 
@@ -516,12 +552,8 @@ export async function doctorReport(pi: ExtensionAPI, ctx: ExtensionCommandContex
516
552
  }
517
553
  if (settings && capabilityBackend(settings, "advisor") === "claude") {
518
554
  pass("Advisor compatibility", "Claude backend — no Agy version floor applies");
519
- } else if (settings && capabilityBackend(settings, "advisor") === "grok") {
520
- pass("Advisor compatibility", "Grok backend — no Agy version floor applies; auth/connectivity unverified (no probe)");
521
555
  } else if (settings && capabilityBackend(settings, "advisor") === "codex") {
522
556
  pass("Advisor compatibility", "Codex backend — no Agy version floor applies");
523
- } else if (settings && capabilityBackend(settings, "advisor") === "muse") {
524
- pass("Advisor compatibility", "Muse backend — no Agy version floor applies; auth/connectivity unverified (no probe)");
525
557
  } else if (settings && capabilityBackend(settings, "advisor") === "pi") {
526
558
  pass("Advisor compatibility", "Pi backend — runs in-process; no Agy version floor or CLI probe applies");
527
559
  } else if (agyVersion && advisorAgyCompatible(agyVersion)) pass("Advisor compatibility", ADVISOR_COMPATIBILITY);
@@ -530,7 +562,7 @@ export async function doctorReport(pi: ExtensionAPI, ctx: ExtensionCommandContex
530
562
  return `# Bro doctor\n\n${lines.join("\n")}\n\n**${failed ? "Bro needs attention." : "Bro is ready."}**\n\n${
531
563
  failed
532
564
  ? "Fix the failed items, then press **R** to check again."
533
- : "No assistant response was sent and no model turn was run. Version/auth checks do not imply connectivity (Grok and Muse auth are unverified — no probe exists)."
565
+ : "No assistant response was sent and no model turn was run. Version/auth checks do not imply connectivity."
534
566
  }`;
535
567
  }
536
568
 
@@ -545,7 +577,7 @@ export async function showBroConfigModal(ctx: ExtensionCommandContext, pi: Exten
545
577
  // Even invalid settings must not prevent access to Doctor. The placeholder is navigation-only:
546
578
  // every editable page re-reads the actual settings and refuses to edit on failure.
547
579
  let current: BroSettings;
548
- try { current = await readSettings(); }
580
+ try { current = (await readSettingsForConfig()).settings; }
549
581
  catch (error) {
550
582
  ctx.ui.notify("Settings unavailable: "+errorMessage(error)+". Global > Doctor can diagnose.", "warning");
551
583
  current = { backend:"agy",model:"(unavailable)",effort:"default",mode:"balanced",showTurns:1,overrides:{} };
@@ -573,11 +605,6 @@ export async function showBroConfigModal(ctx: ExtensionCommandContext, pi: Exten
573
605
  } catch (error) { ctx.ui.notify("Overthink automatic checks: " + errorMessage(error), "error"); }
574
606
  continue;
575
607
  }
576
- if (selected.kind === "overthink-defaults") {
577
- try { await openOverthinkDefaults(ctx); }
578
- catch (error) { ctx.ui.notify("Overthink defaults: " + errorMessage(error), "error"); }
579
- continue;
580
- }
581
608
  if (selected.kind === "doctor") {
582
609
  await showBroModal(ctx,{
583
610
  loadingText:"Checking Bro setup…",
@@ -591,7 +618,11 @@ export async function showBroConfigModal(ctx: ExtensionCommandContext, pi: Exten
591
618
  // Catalog discovery is needed only when an editable settings page is opened, not on
592
619
  // every navigation or diagnostic visit. Keep independent Agy/Pi failure handling.
593
620
  let settings:BroSettings;
594
- try { settings = await readSettings(); }
621
+ try {
622
+ const loaded = await readSettingsForConfig();
623
+ settings = loaded.settings;
624
+ if (loaded.notice) ctx.ui.notify(loaded.notice, "warning");
625
+ }
595
626
  catch (error) { ctx.ui.notify(withDoctor(error),"error"); continue; }
596
627
  let families:AgyModelFamily[]=[];
597
628
  try { families=await listAgyModels(pi); }
@@ -602,8 +633,11 @@ export async function showBroConfigModal(ctx: ExtensionCommandContext, pi: Exten
602
633
  piModels=catalog.models;
603
634
  for(const diagnostic of catalog.diagnostics) ctx.ui.notify("Pi scoped models: "+diagnostic,"warning");
604
635
  } catch(error) { ctx.ui.notify("Pi catalog unavailable: "+errorMessage(error),"warning"); }
636
+ let codexModels:CodexModelChoice[]=[];
637
+ try { codexModels=await listCodexModels(); }
638
+ catch(error) { ctx.ui.notify("Codex catalog unavailable: "+errorMessage(error),"warning"); }
605
639
  await openBroOverlay<void>(
606
- ctx,createConfigModal(settings,families,writeSettings,piModels,selected.page),{mouse:true}
640
+ ctx,createConfigModal(settings,families,writeSettings,piModels,selected.page,codexModels),{mouse:true}
607
641
  );
608
642
  }
609
643
  }
@@ -395,7 +395,7 @@ These are needs, not modes. Copied text does not enter Pi until you paste and su
395
395
  - \`/bro guided-review <PR number or URL>\` — assess captured PR code in local interactive Pi (requires Git and authenticated gh).
396
396
  - 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.
397
397
  - 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.
398
- - 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/features/guided-review.md.
398
+ - Copy finding goes to the clipboard, not GitHub. Regenerate reuses captured source. For untrusted PRs, choose file-only Claude/Pi; Codex offers sandboxed shell, while Agy may write captured files. Bro warns when shell is allowed. See docs/features/guided-review.md.
399
399
 
400
400
  ## Elevate
401
401
 
@@ -409,7 +409,7 @@ These are needs, not modes. Copied text does not enter Pi until you paste and su
409
409
 
410
410
  ## Overthink
411
411
 
412
- - \`/bro overthink\` — view private second-look notes without a model call. Ctrl+R checks now; Ctrl+E edits session questions; Ctrl+C copies. Enable automatic checks in \`/bro config\` → Features → Overthink. See docs/features/overthink.md.
412
+ - \`/bro overthink\` — view the latest private second look and evidence without a model call. Ctrl+R checks now; U shows usage; Ctrl+C copies. Enable automatic checks in \`/bro config\` → Features → Overthink. See docs/features/overthink.md.
413
413
 
414
414
  ## Side conversation
415
415
 
package/src/grill.ts CHANGED
@@ -45,7 +45,7 @@ export async function openGrillModal(
45
45
  return [conversation, ending].filter(Boolean).join("\n\n---\n\n")
46
46
  || "Tell Bro what you want to be grilled on. It can be a proposal or an open question.";
47
47
  };
48
- const refreshHeader = () => modal.setCustomMode(`${thread.depth} · ${thread.fullAccess ? "FULL (prompt-only no-edits)" : activeBackend === "agy" ? "Agy (writes possible)" : ["claude", "muse", "pi"].includes(activeBackend) ? "File-only tools" : "Read-only sandbox"}`);
48
+ const refreshHeader = () => modal.setCustomMode(`${thread.depth} · ${thread.fullAccess ? "FULL (prompt-only no-edits)" : activeBackend === "agy" ? "Agy (writes possible)" : ["claude", "pi"].includes(activeBackend) ? "File-only tools" : "Read-only sandbox"}`);
49
49
  const saveDraft = () => {
50
50
  const draft = modal.getComposerText();
51
51
  if (draft.trim()) thread.draft = draft;