pi-subagent-manager 1.2.0 → 1.2.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.
@@ -151,8 +151,16 @@ const COST_DISPLAY_OPTIONS = [
151
151
  ] as const;
152
152
 
153
153
  const COST_VALUE_OPTIONS = [
154
- { id: "subagents", label: "Only subagent cost", help: "Settled USD cost of all subagents; excludes the main session." },
155
- { id: "total", label: "Total cost", help: "Main session USD cost plus all settled subagent costs." },
154
+ {
155
+ id: "subagents",
156
+ label: "Only subagent cost",
157
+ help: "Settled USD cost of all subagents; excludes the main session.",
158
+ },
159
+ {
160
+ id: "total",
161
+ label: "Total cost",
162
+ help: "Main session USD cost plus all settled subagent costs.",
163
+ },
156
164
  ] as const;
157
165
 
158
166
  const COST_ICON_LABELS = { money: "Money", coins: "Coins", wallet: "Wallet" } as const;
@@ -160,15 +168,26 @@ const COST_ICON_LABELS = { money: "Money", coins: "Coins", wallet: "Wallet" } as
160
168
  type SettingsLayers = ReturnType<typeof loadManagerSettingsLayers>;
161
169
 
162
170
  /** Persisted changes, not unsaved draft values; theme styling is computed on render. */
163
- function withProvenance(row: DialogRow, keys: (keyof ManagerSettings)[], layers: SettingsLayers): DialogRow {
164
- const globalChanged = keys.some((key) => layers.global[key] !== undefined &&
165
- !settingsValueEqual(layers.global[key], DEFAULT_MANAGER_SETTINGS[key]));
166
- const projectChanged = keys.some((key) => layers.project[key] !== undefined &&
167
- !settingsValueEqual(layers.project[key], layers.global[key] ?? DEFAULT_MANAGER_SETTINGS[key]));
171
+ function withProvenance(
172
+ row: DialogRow,
173
+ keys: (keyof ManagerSettings)[],
174
+ layers: SettingsLayers,
175
+ ): DialogRow {
176
+ const globalChanged = keys.some(
177
+ (key) =>
178
+ layers.global[key] !== undefined &&
179
+ !settingsValueEqual(layers.global[key], DEFAULT_MANAGER_SETTINGS[key]),
180
+ );
181
+ const projectChanged = keys.some(
182
+ (key) =>
183
+ layers.project[key] !== undefined &&
184
+ !settingsValueEqual(layers.project[key], layers.global[key] ?? DEFAULT_MANAGER_SETTINGS[key]),
185
+ );
168
186
  return {
169
187
  ...row,
170
188
  renderIndicators: (theme) =>
171
- (globalChanged ? theme.fg("accent", "●") : " ") + " " +
189
+ (globalChanged ? theme.fg("accent", "●") : " ") +
190
+ " " +
172
191
  (projectChanged ? theme.fg("warning", "●") : " "),
173
192
  help: `${row.label}\n${row.help ?? ""}`,
174
193
  };
@@ -177,7 +196,10 @@ function withProvenance(row: DialogRow, keys: (keyof ManagerSettings)[], layers:
177
196
  function provenanceLegend(theme: Theme): string {
178
197
  const global = theme.fg("accent", "●");
179
198
  const project = theme.fg("warning", "●");
180
- return theme.fg("muted", "Saved: ") + `${global} Global · ${project} Current Project · ${global} ${project} Both`;
199
+ return (
200
+ theme.fg("muted", "Saved: ") +
201
+ `${global} Global · ${project} Current Project · ${global} ${project} Both`
202
+ );
181
203
  }
182
204
 
183
205
  /** Selection edits stay in the outer draft until Save and apply. */
@@ -186,21 +208,38 @@ async function configureSubagentExtensions(
186
208
  draft: ManagerSettings,
187
209
  agentDir: string,
188
210
  ): Promise<void> {
189
- const available = await discoverSubagentExtensions({ cwd: ctx.cwd, agentDir, projectTrusted: ctx.isProjectTrusted() });
190
- const selected = new Set(draft.subagentExtensions === true ? available : draft.subagentExtensions || []);
211
+ const available = await discoverSubagentExtensions({
212
+ cwd: ctx.cwd,
213
+ agentDir,
214
+ projectTrusted: ctx.isProjectTrusted(),
215
+ });
216
+ const selected = new Set(
217
+ draft.subagentExtensions === true ? available : draft.subagentExtensions || [],
218
+ );
191
219
  // Keep stale selections visible and removable; runtime still intersects with discovery.
192
220
  const files = [...new Set([...available, ...selected])].sort();
193
221
  let selectedId: string | undefined;
194
222
  while (true) {
195
- const action = await dialogMenu(ctx, "[lab] Subagent extensions", [
196
- ...files.map((file) => ({
197
- id: file,
198
- label: `${selected.has(file) ? "[x]" : "[ ]"} ${basename(file)}`,
199
- value: available.includes(file) ? (selected.has(file) ? "On" : "Off") : "Unavailable",
200
- help: `${file}\n${available.includes(file) ? "Reload this extension in newly opened subagent sessions." : "Not currently discoverable/trusted; will not load. Toggle Off to remove the saved selection."}\nSpace/Enter toggles. Changes are saved only with outer Save and apply.`,
201
- })),
202
- { id: "back", label: "Back", help: files.length ? "Return to settings; selection is not saved yet." : "No extensions available (configured or auto-discovered). CLI-only, inline, built-in extensions and this manager are excluded." },
203
- ], { selectedId, spaceSelect: true, footer: "↑↓/Tab navigate · Space/Enter toggle · Esc back" });
223
+ const action = await dialogMenu(
224
+ ctx,
225
+ "[lab] Subagent extensions",
226
+ [
227
+ ...files.map((file) => ({
228
+ id: file,
229
+ label: `${selected.has(file) ? "[x]" : "[ ]"} ${basename(file)}`,
230
+ value: available.includes(file) ? (selected.has(file) ? "On" : "Off") : "Unavailable",
231
+ help: `${file}\n${available.includes(file) ? "Reload this extension in newly opened subagent sessions." : "Not currently discoverable/trusted; will not load. Toggle Off to remove the saved selection."}\nSpace/Enter toggles. Changes are saved only with outer Save and apply.`,
232
+ })),
233
+ {
234
+ id: "back",
235
+ label: "Back",
236
+ help: files.length
237
+ ? "Return to settings; selection is not saved yet."
238
+ : "No extensions available (configured or auto-discovered). CLI-only, inline, built-in extensions and this manager are excluded.",
239
+ },
240
+ ],
241
+ { selectedId, spaceSelect: true, footer: "↑↓/Tab navigate · Space/Enter toggle · Esc back" },
242
+ );
204
243
  if (!action || action === "back") {
205
244
  draft.subagentExtensions = [...selected].sort();
206
245
  return;
@@ -212,48 +251,83 @@ async function configureSubagentExtensions(
212
251
  }
213
252
 
214
253
  /** Edits the shared draft; only the outer settings screen saves or applies it. */
215
- async function configureFooterDisplay(ctx: ExtensionCommandContext, draft: ManagerSettings, layers: SettingsLayers): Promise<void> {
254
+ async function configureFooterDisplay(
255
+ ctx: ExtensionCommandContext,
256
+ draft: ManagerSettings,
257
+ layers: SettingsLayers,
258
+ ): Promise<void> {
216
259
  let selectedId: string | undefined;
217
260
  while (true) {
218
- const action = await dialogMenu(ctx, "[lab] Footer display", ([
219
- {
220
- id: "location",
221
- label: "Location",
222
- value: COST_DISPLAY_OPTIONS.find((option) => option.id === draft.costDisplay)!.label,
223
- help: "Choose Pi status, a pi-footer status widget, or a pi-footer event. Integration IDs are shown in the location picker.",
224
- },
225
- {
226
- id: "value",
227
- label: "Display value",
228
- value: COST_VALUE_OPTIONS.find((option) => option.id === draft.costValue)!.label,
229
- help: "Show only settled subagent cost, or main session plus settled subagents. Applies to every location.",
230
- },
261
+ const action = await dialogMenu(
262
+ ctx,
263
+ "[lab] Footer display",
264
+ (
265
+ [
266
+ {
267
+ id: "location",
268
+ label: "Location",
269
+ value: COST_DISPLAY_OPTIONS.find((option) => option.id === draft.costDisplay)!.label,
270
+ help: "Choose Pi status, a pi-footer status widget, or a pi-footer event. Integration IDs are shown in the location picker.",
271
+ },
272
+ {
273
+ id: "value",
274
+ label: "Display value",
275
+ value: COST_VALUE_OPTIONS.find((option) => option.id === draft.costValue)!.label,
276
+ help: "Show only settled subagent cost, or main session plus settled subagents. Applies to every location.",
277
+ },
278
+ {
279
+ id: "icon",
280
+ label: "Icon",
281
+ value: `${costIconGlyph(draft.costIcon, draft.nerdFontIcons)} ${COST_ICON_LABELS[draft.costIcon]}`,
282
+ help: `Choose a money-related ${draft.nerdFontIcons ? "Nerd Font" : "emoji"} icon. The family follows [lab] Nerd Font icons.`,
283
+ },
284
+ {
285
+ id: "back",
286
+ label: "Back",
287
+ help: "Return to settings. Save and apply there to commit these changes.",
288
+ },
289
+ ] as DialogRow[]
290
+ ).map((row) => {
291
+ const key = (
292
+ { location: "costDisplay", value: "costValue", icon: "costIcon" } as Record<
293
+ string,
294
+ keyof ManagerSettings
295
+ >
296
+ )[row.id];
297
+ return key ? withProvenance(row, [key], layers) : row;
298
+ }),
231
299
  {
232
- id: "icon",
233
- label: "Icon",
234
- value: `${costIconGlyph(draft.costIcon, draft.nerdFontIcons)} ${COST_ICON_LABELS[draft.costIcon]}`,
235
- help: `Choose a money-related ${draft.nerdFontIcons ? "Nerd Font" : "emoji"} icon. The family follows [lab] Nerd Font icons.`,
300
+ selectedId,
301
+ renderLegend: provenanceLegend,
302
+ footer: "↑↓/Tab navigate · Enter edit · Esc back",
236
303
  },
237
- { id: "back", label: "Back", help: "Return to settings. Save and apply there to commit these changes." },
238
- ] as DialogRow[]).map((row) => {
239
- const key = ({ location: "costDisplay", value: "costValue", icon: "costIcon" } as Record<string, keyof ManagerSettings>)[row.id];
240
- return key ? withProvenance(row, [key], layers) : row;
241
- }), { selectedId, renderLegend: provenanceLegend, footer: "↑↓/Tab navigate · Enter edit · Esc back" });
304
+ );
242
305
  if (!action || action === "back") return;
243
306
  selectedId = action;
244
307
  if (action === "location") {
245
- const mode = await dialogMenu(ctx, "Footer location", [...COST_DISPLAY_OPTIONS], { selectedId: draft.costDisplay });
246
- if (COST_DISPLAY_OPTIONS.some((option) => option.id === mode)) draft.costDisplay = mode as CostDisplayMode;
308
+ const mode = await dialogMenu(ctx, "Footer location", [...COST_DISPLAY_OPTIONS], {
309
+ selectedId: draft.costDisplay,
310
+ });
311
+ if (COST_DISPLAY_OPTIONS.some((option) => option.id === mode))
312
+ draft.costDisplay = mode as CostDisplayMode;
247
313
  } else if (action === "value") {
248
- const value = await dialogMenu(ctx, "Footer display value", [...COST_VALUE_OPTIONS], { selectedId: draft.costValue });
249
- if (COST_VALUE_OPTIONS.some((option) => option.id === value)) draft.costValue = value as CostValue;
314
+ const value = await dialogMenu(ctx, "Footer display value", [...COST_VALUE_OPTIONS], {
315
+ selectedId: draft.costValue,
316
+ });
317
+ if (COST_VALUE_OPTIONS.some((option) => option.id === value))
318
+ draft.costValue = value as CostValue;
250
319
  } else if (action === "icon") {
251
- const icon = await dialogMenu(ctx, `Footer icon · ${draft.nerdFontIcons ? "Nerd Font" : "Emoji"}`, COST_ICONS.map((id) => ({
252
- id,
253
- label: COST_ICON_LABELS[id],
254
- value: costIconGlyph(id, draft.nerdFontIcons),
255
- help: `${costIconGlyph(id, draft.nerdFontIcons)} ${COST_ICON_LABELS[id]} · ${draft.nerdFontIcons ? "Requires a Nerd Font in your terminal." : "Emoji icon."}`,
256
- })), { selectedId: draft.costIcon });
320
+ const icon = await dialogMenu(
321
+ ctx,
322
+ `Footer icon · ${draft.nerdFontIcons ? "Nerd Font" : "Emoji"}`,
323
+ COST_ICONS.map((id) => ({
324
+ id,
325
+ label: COST_ICON_LABELS[id],
326
+ value: costIconGlyph(id, draft.nerdFontIcons),
327
+ help: `${costIconGlyph(id, draft.nerdFontIcons)} ${COST_ICON_LABELS[id]} · ${draft.nerdFontIcons ? "Requires a Nerd Font in your terminal." : "Emoji icon."}`,
328
+ })),
329
+ { selectedId: draft.costIcon },
330
+ );
257
331
  if (COST_ICONS.includes(icon as CostIcon)) draft.costIcon = icon as CostIcon;
258
332
  }
259
333
  }
@@ -268,28 +342,52 @@ const HOUSEKEEPING_HELP =
268
342
  "Experimental: a model you choose writes a one-line summary of each running agent's current work, shown in the tree and widget instead of raw tool-call status.\nSends the agent's task and recent tool names/arguments/text to the selected model, uses extra tokens, and is not included in subagent cost totals.\nOff by default. Any failure keeps the original status. Choose from available and scoped models.";
269
343
 
270
344
  /** Edits the shared draft; only the outer settings screen saves or applies it. */
271
- async function configureHousekeeping(ctx: ExtensionCommandContext, draft: ManagerSettings, layers: SettingsLayers): Promise<void> {
345
+ async function configureHousekeeping(
346
+ ctx: ExtensionCommandContext,
347
+ draft: ManagerSettings,
348
+ layers: SettingsLayers,
349
+ ): Promise<void> {
272
350
  let selectedId: string | undefined;
273
351
  while (true) {
274
- const action = await dialogMenu(ctx, "[lab] Housekeeping model", ([
275
- {
276
- id: "enabled",
277
- label: "Summaries",
278
- value: draft.housekeepingEnabled ? "On" : "Off",
279
- help: "Name each running agent's work in one line using the housekeeping model, replacing raw tool-call status in the tree and widget.\nInactive until a model is selected. Off by default.",
280
- },
352
+ const action = await dialogMenu(
353
+ ctx,
354
+ "[lab] Housekeeping model",
355
+ (
356
+ [
357
+ {
358
+ id: "enabled",
359
+ label: "Summaries",
360
+ value: draft.housekeepingEnabled ? "On" : "Off",
361
+ help: "Name each running agent's work in one line using the housekeeping model, replacing raw tool-call status in the tree and widget.\nInactive until a model is selected. Off by default.",
362
+ },
363
+ {
364
+ id: "model",
365
+ label: "Model",
366
+ value: draft.housekeepingModel || "Not selected",
367
+ valueColor: draft.housekeepingModel ? undefined : ("muted" as const),
368
+ help: "Pick any available model; scoped models are listed first. A small, fast, inexpensive model is usually enough.\nIf the model later becomes unavailable (no credentials, removed), summaries stay inactive and normal status shows.",
369
+ },
370
+ {
371
+ id: "back",
372
+ label: "Back",
373
+ help: "Return to settings. Save and apply there to commit these changes.",
374
+ },
375
+ ] as DialogRow[]
376
+ ).map((row) => {
377
+ const key = (
378
+ { enabled: "housekeepingEnabled", model: "housekeepingModel" } as Record<
379
+ string,
380
+ keyof ManagerSettings
381
+ >
382
+ )[row.id];
383
+ return key ? withProvenance(row, [key], layers) : row;
384
+ }),
281
385
  {
282
- id: "model",
283
- label: "Model",
284
- value: draft.housekeepingModel || "Not selected",
285
- valueColor: draft.housekeepingModel ? undefined : "muted" as const,
286
- help: "Pick any available model; scoped models are listed first. A small, fast, inexpensive model is usually enough.\nIf the model later becomes unavailable (no credentials, removed), summaries stay inactive and normal status shows.",
386
+ selectedId,
387
+ renderLegend: provenanceLegend,
388
+ footer: "↑↓/Tab navigate · Enter edit · Esc back",
287
389
  },
288
- { id: "back", label: "Back", help: "Return to settings. Save and apply there to commit these changes." },
289
- ] as DialogRow[]).map((row) => {
290
- const key = ({ enabled: "housekeepingEnabled", model: "housekeepingModel" } as Record<string, keyof ManagerSettings>)[row.id];
291
- return key ? withProvenance(row, [key], layers) : row;
292
- }), { selectedId, renderLegend: provenanceLegend, footer: "↑↓/Tab navigate · Enter edit · Esc back" });
390
+ );
293
391
  if (!action || action === "back") return;
294
392
  selectedId = action;
295
393
  if (action === "enabled") draft.housekeepingEnabled = !draft.housekeepingEnabled;
@@ -338,9 +436,7 @@ export async function configureAgents(
338
436
  },
339
437
  ): Promise<void> {
340
438
  if (!canOpenDialog(ctx)) return;
341
- await withDialogSession(ctx, (scoped) =>
342
- configureAgentsDialog(scoped, options),
343
- );
439
+ await withDialogSession(ctx, (scoped) => configureAgentsDialog(scoped, options));
344
440
  }
345
441
 
346
442
  /** Always shown; "disabled" (muted, guarded) unless pi-checklist prerequisites currently hold. */
@@ -377,16 +473,25 @@ async function configureAgentsDialog(
377
473
  ): Promise<void> {
378
474
  const checklistStatus = (): ChecklistStatus => {
379
475
  try {
380
- return options.checklistStatus?.() ?? { eligible: false, reason: "pi-checklist status is unavailable" };
476
+ return (
477
+ options.checklistStatus?.() ?? {
478
+ eligible: false,
479
+ reason: "pi-checklist status is unavailable",
480
+ }
481
+ );
381
482
  } catch (error) {
382
- return { eligible: false, reason: `could not verify pi-checklist: ${error instanceof Error ? error.message : String(error)}` };
483
+ return {
484
+ eligible: false,
485
+ reason: `could not verify pi-checklist: ${error instanceof Error ? error.message : String(error)}`,
486
+ };
383
487
  }
384
488
  };
385
- const readLayers = () => loadManagerSettingsLayers({
386
- cwd: ctx.cwd,
387
- agentDir: options.agentDir,
388
- includeProject: ctx.isProjectTrusted(),
389
- });
489
+ const readLayers = () =>
490
+ loadManagerSettingsLayers({
491
+ cwd: ctx.cwd,
492
+ agentDir: options.agentDir,
493
+ includeProject: ctx.isProjectTrusted(),
494
+ });
390
495
  let layers = readLayers();
391
496
  const reportDiagnostics = () => {
392
497
  for (const diagnostic of layers.diagnostics) ctx.ui.notify(diagnostic, "warning");
@@ -401,108 +506,121 @@ async function configureAgentsDialog(
401
506
  const action = await dialogMenu(
402
507
  ctx,
403
508
  `Agents settings${dirty ? " · unsaved" : ""}`,
404
- ([
405
- {
406
- id: "subagentMode",
407
- label: "Subagent Mode",
408
- value: MODE_OPTIONS.find((mode) => mode.id === draft.subagentMode)!.label,
409
- help: MODE_HELP,
410
- },
411
- {
412
- id: "toolFiltering",
413
- label: "Tool Filtering",
414
- value: TOOL_FILTERING_OPTIONS.find((mode) => mode.id === draft.toolFiltering)!.label,
415
- help: TOOL_FILTERING_HELP,
416
- },
417
- ...FIELDS.map((field) => ({
418
- ...field,
419
- value: String(draft[field.id]),
420
- })),
421
- {
422
- id: "modelSelection",
423
- label: "Model Picking",
424
- value: MODEL_SELECTION_OPTIONS.find((mode) => mode.id === draft.modelSelection)!.label,
425
- help: MODEL_SELECTION_HELP,
426
- },
427
- {
428
- id: "widgetMode",
429
- label: "Status Widget",
430
- value: WIDGET_MODE_OPTIONS.find((mode) => mode.id === draft.widgetMode)!.label,
431
- help: WIDGET_MODE_HELP,
432
- },
433
- {
434
- id: "costDisplay",
435
- label: "[lab] Footer display",
436
- value: COST_DISPLAY_OPTIONS.find((mode) => mode.id === draft.costDisplay)!.label,
437
- help: "Configure footer location, displayed cost, and money icon in a submenu. Save and apply to update immediately.",
438
- },
439
- {
440
- id: "housekeeping",
441
- label: "[lab] Housekeeping model",
442
- value: housekeepingValue(draft),
443
- valueColor: draft.housekeepingEnabled && !draft.housekeepingModel ? "warning" as const : undefined,
444
- help: HOUSEKEEPING_HELP,
445
- },
446
- {
447
- id: "nerdFontIcons",
448
- label: "[lab] Nerd Font icons",
449
- value: draft.nerdFontIcons ? "On" : "Off",
450
- help: "Experimental: display each agent type’s optional Nerd Font icon and unlock Nerd Font loader palettes.\nRequires a Nerd Font configured in your terminal; otherwise glyphs may appear as boxes.\nOff by default. Braille and ASCII loaders work with this Off. Save and apply to update immediately.",
451
- },
452
- {
453
- id: "loaderStyle",
454
- label: "[lab] Loader style",
455
- value: AGENT_LOADERS[effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons)].label,
456
- help: "Preview every animation frame and settled state.\nNerd Fonts Off: Braille (standard Unicode), ASCII, ASCII Star and ASCII Pulse. On: all palettes, including Circle and Hourglass.\nNerd-only saved styles fall back to ASCII while Nerd Fonts are off. Save and apply to update immediately.",
457
- },
458
- {
459
- id: "subagentExtensions",
460
- label: "[lab] Subagent extensions",
461
- value: Array.isArray(draft.subagentExtensions) ? `${draft.subagentExtensions.length} selected` : draft.subagentExtensions ? "All (legacy)" : "None",
462
- help: "Experimental: reload selected user/trusted-project extension hooks, including auto-discovered .ts/.js files and subdirectory entry points, in separate subagent sessions (not CLI-only or inline extensions). Bugs and unintended consequences may occur if hooks assume main-session state.\nRead limitations: https://github.com/championswimmer/pi-subagent-manager/blob/main/docs/subagent-extension-limitations.md\nSelect individual extensions in the submenu. None by default. Save and apply affects newly opened sessions, not already-open agents.",
463
- },
464
- checklistRow(draft.checklistIntegration, checklistStatus()),
465
- {
466
- id: "finalRecap",
467
- label: "[lab] Final Recap",
468
- value: draft.finalRecap ? "On" : "Off",
469
- help: "Experimental: when detached agents finish or fail and the main agent is idle, automatically ask the main agent to summarize their results.\nEnabling this may cause extra model turns and uses more tokens and context.\nOff by default. Subagent Mode Off suppresses automatic summaries.",
470
- },
471
- {
472
- id: "scope",
473
- label: "Save scope",
474
- value: scope === "user" ? "Global" : "Current Project",
475
- help: "Global: save overrides of built-in defaults for all projects.\nCurrent Project: save overrides of global settings for this trusted project.\nSwitching requires confirmation: enabling Project creates its settings file; switching to Global deletes it and discards unsaved edits. Confirmed scope changes happen immediately, even if you later cancel.",
476
- },
477
- {
478
- id: "types",
479
- label: "Agent definitions",
480
- value: `${options.store.list().length} types`,
481
- help: "Create or edit agent definitions.\nConfigure model preferences and tool policy for each agent type.",
482
- },
483
- {
484
- id: "defaults",
485
- label: "Restore defaults",
486
- help: "Pick Global or Project, then delete that scope's settings.json so its defaults apply again.\nThe file is removed, not rewritten; unsaved edits are discarded. This cannot be undone.",
487
- },
488
- {
489
- id: "save",
490
- label: "Save and apply",
491
- value: dirty ? "(changes)" : undefined,
492
- valueColor: dirty ? "warning" as const : undefined,
493
- help: "Save only overrides to the selected scope and reload settings now.\nUnchanged values inherit from the lower layer.\nRunning agents and retained sessions are kept.",
494
- },
495
- {
496
- id: "cancel",
497
- label: "Cancel",
498
- help: "Close without saving manager settings.",
499
- },
500
- ] as DialogRow[]).map((row) => {
501
- const keys = row.id === "costDisplay"
502
- ? ["costDisplay", "costValue", "costIcon"] as (keyof ManagerSettings)[]
503
- : row.id === "housekeeping"
504
- ? ["housekeepingEnabled", "housekeepingModel"] as (keyof ManagerSettings)[]
505
- : row.id in DEFAULT_MANAGER_SETTINGS ? [row.id as keyof ManagerSettings] : [];
509
+ (
510
+ [
511
+ {
512
+ id: "subagentMode",
513
+ label: "Subagent Mode",
514
+ value: MODE_OPTIONS.find((mode) => mode.id === draft.subagentMode)!.label,
515
+ help: MODE_HELP,
516
+ },
517
+ {
518
+ id: "toolFiltering",
519
+ label: "Tool Filtering",
520
+ value: TOOL_FILTERING_OPTIONS.find((mode) => mode.id === draft.toolFiltering)!.label,
521
+ help: TOOL_FILTERING_HELP,
522
+ },
523
+ ...FIELDS.map((field) => ({
524
+ ...field,
525
+ value: String(draft[field.id]),
526
+ })),
527
+ {
528
+ id: "modelSelection",
529
+ label: "Model Picking",
530
+ value: MODEL_SELECTION_OPTIONS.find((mode) => mode.id === draft.modelSelection)!.label,
531
+ help: MODEL_SELECTION_HELP,
532
+ },
533
+ {
534
+ id: "widgetMode",
535
+ label: "Status Widget",
536
+ value: WIDGET_MODE_OPTIONS.find((mode) => mode.id === draft.widgetMode)!.label,
537
+ help: WIDGET_MODE_HELP,
538
+ },
539
+ {
540
+ id: "costDisplay",
541
+ label: "[lab] Footer display",
542
+ value: COST_DISPLAY_OPTIONS.find((mode) => mode.id === draft.costDisplay)!.label,
543
+ help: "Configure footer location, displayed cost, and money icon in a submenu. Save and apply to update immediately.",
544
+ },
545
+ {
546
+ id: "housekeeping",
547
+ label: "[lab] Housekeeping model",
548
+ value: housekeepingValue(draft),
549
+ valueColor:
550
+ draft.housekeepingEnabled && !draft.housekeepingModel
551
+ ? ("warning" as const)
552
+ : undefined,
553
+ help: HOUSEKEEPING_HELP,
554
+ },
555
+ {
556
+ id: "nerdFontIcons",
557
+ label: "[lab] Nerd Font icons",
558
+ value: draft.nerdFontIcons ? "On" : "Off",
559
+ help: "Experimental: display each agent type’s optional Nerd Font icon and unlock Nerd Font loader palettes.\nRequires a Nerd Font configured in your terminal; otherwise glyphs may appear as boxes.\nOff by default. Braille and ASCII loaders work with this Off. Save and apply to update immediately.",
560
+ },
561
+ {
562
+ id: "loaderStyle",
563
+ label: "[lab] Loader style",
564
+ value:
565
+ AGENT_LOADERS[effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons)].label,
566
+ help: "Preview every animation frame and settled state.\nNerd Fonts Off: Braille (standard Unicode), ASCII, ASCII Star and ASCII Pulse. On: all palettes, including Circle and Hourglass.\nNerd-only saved styles fall back to ASCII while Nerd Fonts are off. Save and apply to update immediately.",
567
+ },
568
+ {
569
+ id: "subagentExtensions",
570
+ label: "[lab] Subagent extensions",
571
+ value: Array.isArray(draft.subagentExtensions)
572
+ ? `${draft.subagentExtensions.length} selected`
573
+ : draft.subagentExtensions
574
+ ? "All (legacy)"
575
+ : "None",
576
+ help: "Experimental: reload selected user/trusted-project extension hooks, including auto-discovered .ts/.js files and subdirectory entry points, in separate subagent sessions (not CLI-only or inline extensions). Bugs and unintended consequences may occur if hooks assume main-session state.\nRead limitations: https://github.com/championswimmer/pi-subagent-manager/blob/main/docs/subagent-extension-limitations.md\nSelect individual extensions in the submenu. None by default. Save and apply affects newly opened sessions, not already-open agents.",
577
+ },
578
+ checklistRow(draft.checklistIntegration, checklistStatus()),
579
+ {
580
+ id: "finalRecap",
581
+ label: "[lab] Final Recap",
582
+ value: draft.finalRecap ? "On" : "Off",
583
+ help: "Experimental: when detached agents finish or fail and the main agent is idle, automatically ask the main agent to summarize their results.\nEnabling this may cause extra model turns and uses more tokens and context.\nOff by default. Subagent Mode Off suppresses automatic summaries.",
584
+ },
585
+ {
586
+ id: "scope",
587
+ label: "Save scope",
588
+ value: scope === "user" ? "Global" : "Current Project",
589
+ help: "Global: save overrides of built-in defaults for all projects.\nCurrent Project: save overrides of global settings for this trusted project.\nSwitching requires confirmation: enabling Project creates its settings file; switching to Global deletes it and discards unsaved edits. Confirmed scope changes happen immediately, even if you later cancel.",
590
+ },
591
+ {
592
+ id: "types",
593
+ label: "Agent definitions",
594
+ value: `${options.store.list().length} types`,
595
+ help: "Create or edit agent definitions.\nConfigure model preferences and tool policy for each agent type.",
596
+ },
597
+ {
598
+ id: "defaults",
599
+ label: "Restore defaults",
600
+ help: "Pick Global or Project, then delete that scope's settings.json so its defaults apply again.\nThe file is removed, not rewritten; unsaved edits are discarded. This cannot be undone.",
601
+ },
602
+ {
603
+ id: "save",
604
+ label: "Save and apply",
605
+ value: dirty ? "(changes)" : undefined,
606
+ valueColor: dirty ? ("warning" as const) : undefined,
607
+ help: "Save only overrides to the selected scope and reload settings now.\nUnchanged values inherit from the lower layer.\nRunning agents and retained sessions are kept.",
608
+ },
609
+ {
610
+ id: "cancel",
611
+ label: "Cancel",
612
+ help: "Close without saving manager settings.",
613
+ },
614
+ ] as DialogRow[]
615
+ ).map((row) => {
616
+ const keys =
617
+ row.id === "costDisplay"
618
+ ? (["costDisplay", "costValue", "costIcon"] as (keyof ManagerSettings)[])
619
+ : row.id === "housekeeping"
620
+ ? (["housekeepingEnabled", "housekeepingModel"] as (keyof ManagerSettings)[])
621
+ : row.id in DEFAULT_MANAGER_SETTINGS
622
+ ? [row.id as keyof ManagerSettings]
623
+ : [];
506
624
  return keys.length ? withProvenance(row, keys, layers) : row;
507
625
  }),
508
626
  {
@@ -517,12 +635,7 @@ async function configureAgentsDialog(
517
635
  try {
518
636
  const field = FIELDS.find((field) => field.id === action);
519
637
  if (field) {
520
- const value = await dialogInput(
521
- ctx,
522
- field.label,
523
- String(draft[field.id]),
524
- field.help,
525
- );
638
+ const value = await dialogInput(ctx, field.label, String(draft[field.id]), field.help);
526
639
  if (value === undefined) continue;
527
640
  const number = Number(value.trim());
528
641
  if (
@@ -578,26 +691,34 @@ async function configureAgentsDialog(
578
691
  const status = checklistStatus();
579
692
  // Turning Off is always allowed; turning On requires current eligibility.
580
693
  if (!draft.checklistIntegration && !status.eligible)
581
- ctx.ui.notify(`Checklist integration cannot be enabled: ${status.reason ?? "requirements not met"}. ${CHECKLIST_REQUIREMENTS}`, "warning");
694
+ ctx.ui.notify(
695
+ `Checklist integration cannot be enabled: ${status.reason ?? "requirements not met"}. ${CHECKLIST_REQUIREMENTS}`,
696
+ "warning",
697
+ );
582
698
  else draft.checklistIntegration = !draft.checklistIntegration;
583
699
  } else if (action === "finalRecap") {
584
700
  draft.finalRecap = !draft.finalRecap;
585
701
  } else if (action === "scope") {
586
702
  if (!ctx.isProjectTrusted())
587
- ctx.ui.notify(
588
- "Project settings require a trusted project; saving globally.",
589
- "warning",
590
- );
703
+ ctx.ui.notify("Project settings require a trusted project; saving globally.", "warning");
591
704
  else {
592
705
  const nextScope = scope === "user" ? "project" : "user";
593
- const message = nextScope === "project"
594
- ? "Create project file now; outer Cancel cannot undo.\nThis will create this project's settings.json. Further changes will be saved there. Unsaved edits are kept until Save and apply."
595
- : "Delete project file now. Discard edits. No undo.\nUnsaved edits will be discarded. Outer Cancel cannot undo. We reload global settings; further changes are saved globally.";
596
- const confirmation = await dialogMenu(ctx,
597
- nextScope === "project" ? "Enable project settings?" : "Clear project settings and use Global?",
706
+ const message =
707
+ nextScope === "project"
708
+ ? "Create project file now; outer Cancel cannot undo.\nThis will create this project's settings.json. Further changes will be saved there. Unsaved edits are kept until Save and apply."
709
+ : "Delete project file now. Discard edits. No undo.\nUnsaved edits will be discarded. Outer Cancel cannot undo. We reload global settings; further changes are saved globally.";
710
+ const confirmation = await dialogMenu(
711
+ ctx,
712
+ nextScope === "project"
713
+ ? "Enable project settings?"
714
+ : "Clear project settings and use Global?",
598
715
  [
599
716
  { id: "confirm", label: "Confirm", help: message },
600
- { id: "cancel", label: "Cancel", help: message + "\nCancel leaves files, scope and unsaved edits unchanged." },
717
+ {
718
+ id: "cancel",
719
+ label: "Cancel",
720
+ help: message + "\nCancel leaves files, scope and unsaved edits unchanged.",
721
+ },
601
722
  ],
602
723
  { selectedId: "cancel", footer: "↑↓/Tab choose · Enter select · Esc cancel" },
603
724
  );
@@ -619,22 +740,45 @@ async function configureAgentsDialog(
619
740
  }
620
741
  }
621
742
  } else if (action === "defaults") {
622
- const target = { cwd: ctx.cwd, agentDir: options.agentDir, includeProject: ctx.isProjectTrusted() };
743
+ const target = {
744
+ cwd: ctx.cwd,
745
+ agentDir: options.agentDir,
746
+ includeProject: ctx.isProjectTrusted(),
747
+ };
623
748
  const globalPath = managerSettingsPath(target, "user");
624
- const projectPath = target.includeProject ? managerSettingsPath(target, "project") : undefined;
749
+ const projectPath = target.includeProject
750
+ ? managerSettingsPath(target, "project")
751
+ : undefined;
625
752
  const explain = (path: string) =>
626
753
  `Deletes this file now (nothing is written):\n${path}\nIf it does not exist, nothing happens. Unsaved edits are discarded. No undo.`;
627
754
  const rows: DialogRow[] = [
628
- { id: "user", label: "Global", value: "Restore global defaults", help: explain(globalPath) },
755
+ {
756
+ id: "user",
757
+ label: "Global",
758
+ value: "Restore global defaults",
759
+ help: explain(globalPath),
760
+ },
629
761
  ...(projectPath
630
- ? [{ id: "project", label: "Project", value: "Restore project defaults", help: explain(projectPath) }]
762
+ ? [
763
+ {
764
+ id: "project",
765
+ label: "Project",
766
+ value: "Restore project defaults",
767
+ help: explain(projectPath),
768
+ },
769
+ ]
631
770
  : []),
632
771
  { id: "cancel", label: "Cancel", help: "Delete nothing." },
633
772
  ];
634
- const choice = await dialogMenu(ctx, "Restore defaults: delete which settings file?", rows, {
635
- selectedId: "cancel",
636
- footer: "↑↓/Tab choose · Enter delete file · Esc cancel",
637
- });
773
+ const choice = await dialogMenu(
774
+ ctx,
775
+ "Restore defaults: delete which settings file?",
776
+ rows,
777
+ {
778
+ selectedId: "cancel",
779
+ footer: "↑↓/Tab choose · Enter delete file · Esc cancel",
780
+ },
781
+ );
638
782
  if (choice === "user" || choice === "project") {
639
783
  const { filePath, deleted } = deleteManagerSettings({ ...target, scope: choice });
640
784
  layers = readLayers();
@@ -644,12 +788,13 @@ async function configureAgentsDialog(
644
788
  scope = layers.scope;
645
789
  options.apply();
646
790
  ctx.ui.notify(
647
- deleted ? `Deleted ${filePath}. Defaults restored.` : `No settings file at ${filePath}; nothing to delete.`,
791
+ deleted
792
+ ? `Deleted ${filePath}. Defaults restored.`
793
+ : `No settings file at ${filePath}; nothing to delete.`,
648
794
  "info",
649
795
  );
650
796
  }
651
- }
652
- else if (action === "types") {
797
+ } else if (action === "types") {
653
798
  await editAgentTypes(ctx, options.store, draft.nerdFontIcons, {
654
799
  getAllTools: options.getAllTools ?? (() => []),
655
800
  toolFiltering: draft.toolFiltering,
@@ -660,7 +805,9 @@ async function configureAgentsDialog(
660
805
  if (draft.checklistIntegration && !baseline.checklistIntegration) {
661
806
  const status = checklistStatus();
662
807
  if (!status.eligible)
663
- throw new Error(`Checklist integration cannot be enabled: ${status.reason ?? "requirements not met"}. Turn it Off or satisfy: ${CHECKLIST_REQUIREMENTS}`);
808
+ throw new Error(
809
+ `Checklist integration cannot be enabled: ${status.reason ?? "requirements not met"}. Turn it Off or satisfy: ${CHECKLIST_REQUIREMENTS}`,
810
+ );
664
811
  }
665
812
  const file = saveManagerOverrides({
666
813
  cwd: ctx.cwd,
@@ -678,10 +825,7 @@ async function configureAgentsDialog(
678
825
  return;
679
826
  }
680
827
  } catch (error) {
681
- ctx.ui.notify(
682
- error instanceof Error ? error.message : String(error),
683
- "error",
684
- );
828
+ ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
685
829
  }
686
830
  }
687
831
  }