pi-subagent-manager 1.1.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.
- package/README.md +4 -4
- package/agents/architect.md +1 -1
- package/agents/coder.md +1 -1
- package/agents/researcher.md +1 -1
- package/agents/reviewer.md +1 -1
- package/agents/tasker.md +1 -1
- package/agents/writer.md +1 -1
- package/docs/default-agents.md +24 -24
- package/package.json +10 -5
- package/src/index.ts +17 -4
- package/src/orch/checklist-integration.ts +33 -9
- package/src/orch/diagnostics.ts +3 -1
- package/src/orch/housekeeping.ts +1 -4
- package/src/orch/inherited-tools.ts +2 -2
- package/src/orch/manager.ts +8 -3
- package/src/orch/prompt.ts +3 -1
- package/src/orch/runtime.ts +28 -15
- package/src/prefs/config.ts +47 -149
- package/src/prefs/models.ts +2 -5
- package/src/prefs/settings.ts +121 -55
- package/src/ui/agent-navigation-editor.ts +20 -10
- package/src/ui/cost-footer.ts +5 -2
- package/src/ui/dialog.ts +52 -59
- package/src/ui/model-picker.ts +17 -5
- package/src/ui/settings-ui.ts +364 -217
- package/src/ui/status-ui.ts +14 -11
- package/src/ui/ui.ts +51 -26
package/src/ui/settings-ui.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
type ToolFilteringMode,
|
|
30
30
|
type WidgetMode,
|
|
31
31
|
} from "../prefs/settings.ts";
|
|
32
|
-
import { editAgentTypes } from "./ui.ts";
|
|
32
|
+
import { editAgentTypes, type AgentEditorOptions } from "./ui.ts";
|
|
33
33
|
import { HOUSEKEEPING_PICKER_CANCEL, pickHousekeepingModel } from "./model-picker.ts";
|
|
34
34
|
import type { ToolEditorOptions } from "./tool-picker.ts";
|
|
35
35
|
import { AGENT_LOADERS, availableLoaderStyles, effectiveLoaderStyle } from "./agent-loader.ts";
|
|
@@ -151,8 +151,16 @@ const COST_DISPLAY_OPTIONS = [
|
|
|
151
151
|
] as const;
|
|
152
152
|
|
|
153
153
|
const COST_VALUE_OPTIONS = [
|
|
154
|
-
{
|
|
155
|
-
|
|
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(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
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({
|
|
190
|
-
|
|
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(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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(
|
|
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(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
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], {
|
|
246
|
-
|
|
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], {
|
|
249
|
-
|
|
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(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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(
|
|
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(
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -331,15 +429,14 @@ export async function configureAgents(
|
|
|
331
429
|
settings: ManagerSettings;
|
|
332
430
|
agentDir: string;
|
|
333
431
|
getAllTools?: ToolEditorOptions["getAllTools"];
|
|
432
|
+
resolveAgentSettings?: AgentEditorOptions["resolveAgentSettings"];
|
|
334
433
|
/** Live pi-checklist eligibility; absent means unavailable (fail closed). */
|
|
335
434
|
checklistStatus?: () => ChecklistStatus;
|
|
336
435
|
apply(): void;
|
|
337
436
|
},
|
|
338
437
|
): Promise<void> {
|
|
339
438
|
if (!canOpenDialog(ctx)) return;
|
|
340
|
-
await withDialogSession(ctx, (scoped) =>
|
|
341
|
-
configureAgentsDialog(scoped, options),
|
|
342
|
-
);
|
|
439
|
+
await withDialogSession(ctx, (scoped) => configureAgentsDialog(scoped, options));
|
|
343
440
|
}
|
|
344
441
|
|
|
345
442
|
/** Always shown; "disabled" (muted, guarded) unless pi-checklist prerequisites currently hold. */
|
|
@@ -368,6 +465,7 @@ async function configureAgentsDialog(
|
|
|
368
465
|
settings: ManagerSettings;
|
|
369
466
|
agentDir: string;
|
|
370
467
|
getAllTools?: ToolEditorOptions["getAllTools"];
|
|
468
|
+
resolveAgentSettings?: AgentEditorOptions["resolveAgentSettings"];
|
|
371
469
|
/** Live pi-checklist eligibility; absent means unavailable (fail closed). */
|
|
372
470
|
checklistStatus?: () => ChecklistStatus;
|
|
373
471
|
apply(): void;
|
|
@@ -375,16 +473,25 @@ async function configureAgentsDialog(
|
|
|
375
473
|
): Promise<void> {
|
|
376
474
|
const checklistStatus = (): ChecklistStatus => {
|
|
377
475
|
try {
|
|
378
|
-
return
|
|
476
|
+
return (
|
|
477
|
+
options.checklistStatus?.() ?? {
|
|
478
|
+
eligible: false,
|
|
479
|
+
reason: "pi-checklist status is unavailable",
|
|
480
|
+
}
|
|
481
|
+
);
|
|
379
482
|
} catch (error) {
|
|
380
|
-
return {
|
|
483
|
+
return {
|
|
484
|
+
eligible: false,
|
|
485
|
+
reason: `could not verify pi-checklist: ${error instanceof Error ? error.message : String(error)}`,
|
|
486
|
+
};
|
|
381
487
|
}
|
|
382
488
|
};
|
|
383
|
-
const readLayers = () =>
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
489
|
+
const readLayers = () =>
|
|
490
|
+
loadManagerSettingsLayers({
|
|
491
|
+
cwd: ctx.cwd,
|
|
492
|
+
agentDir: options.agentDir,
|
|
493
|
+
includeProject: ctx.isProjectTrusted(),
|
|
494
|
+
});
|
|
388
495
|
let layers = readLayers();
|
|
389
496
|
const reportDiagnostics = () => {
|
|
390
497
|
for (const diagnostic of layers.diagnostics) ctx.ui.notify(diagnostic, "warning");
|
|
@@ -399,108 +506,121 @@ async function configureAgentsDialog(
|
|
|
399
506
|
const action = await dialogMenu(
|
|
400
507
|
ctx,
|
|
401
508
|
`Agents settings${dirty ? " · unsaved" : ""}`,
|
|
402
|
-
(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
...field
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
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
|
+
: [];
|
|
504
624
|
return keys.length ? withProvenance(row, keys, layers) : row;
|
|
505
625
|
}),
|
|
506
626
|
{
|
|
@@ -515,12 +635,7 @@ async function configureAgentsDialog(
|
|
|
515
635
|
try {
|
|
516
636
|
const field = FIELDS.find((field) => field.id === action);
|
|
517
637
|
if (field) {
|
|
518
|
-
const value = await dialogInput(
|
|
519
|
-
ctx,
|
|
520
|
-
field.label,
|
|
521
|
-
String(draft[field.id]),
|
|
522
|
-
field.help,
|
|
523
|
-
);
|
|
638
|
+
const value = await dialogInput(ctx, field.label, String(draft[field.id]), field.help);
|
|
524
639
|
if (value === undefined) continue;
|
|
525
640
|
const number = Number(value.trim());
|
|
526
641
|
if (
|
|
@@ -576,26 +691,34 @@ async function configureAgentsDialog(
|
|
|
576
691
|
const status = checklistStatus();
|
|
577
692
|
// Turning Off is always allowed; turning On requires current eligibility.
|
|
578
693
|
if (!draft.checklistIntegration && !status.eligible)
|
|
579
|
-
ctx.ui.notify(
|
|
694
|
+
ctx.ui.notify(
|
|
695
|
+
`Checklist integration cannot be enabled: ${status.reason ?? "requirements not met"}. ${CHECKLIST_REQUIREMENTS}`,
|
|
696
|
+
"warning",
|
|
697
|
+
);
|
|
580
698
|
else draft.checklistIntegration = !draft.checklistIntegration;
|
|
581
699
|
} else if (action === "finalRecap") {
|
|
582
700
|
draft.finalRecap = !draft.finalRecap;
|
|
583
701
|
} else if (action === "scope") {
|
|
584
702
|
if (!ctx.isProjectTrusted())
|
|
585
|
-
ctx.ui.notify(
|
|
586
|
-
"Project settings require a trusted project; saving globally.",
|
|
587
|
-
"warning",
|
|
588
|
-
);
|
|
703
|
+
ctx.ui.notify("Project settings require a trusted project; saving globally.", "warning");
|
|
589
704
|
else {
|
|
590
705
|
const nextScope = scope === "user" ? "project" : "user";
|
|
591
|
-
const message =
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
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?",
|
|
596
715
|
[
|
|
597
716
|
{ id: "confirm", label: "Confirm", help: message },
|
|
598
|
-
{
|
|
717
|
+
{
|
|
718
|
+
id: "cancel",
|
|
719
|
+
label: "Cancel",
|
|
720
|
+
help: message + "\nCancel leaves files, scope and unsaved edits unchanged.",
|
|
721
|
+
},
|
|
599
722
|
],
|
|
600
723
|
{ selectedId: "cancel", footer: "↑↓/Tab choose · Enter select · Esc cancel" },
|
|
601
724
|
);
|
|
@@ -617,22 +740,45 @@ async function configureAgentsDialog(
|
|
|
617
740
|
}
|
|
618
741
|
}
|
|
619
742
|
} else if (action === "defaults") {
|
|
620
|
-
const target = {
|
|
743
|
+
const target = {
|
|
744
|
+
cwd: ctx.cwd,
|
|
745
|
+
agentDir: options.agentDir,
|
|
746
|
+
includeProject: ctx.isProjectTrusted(),
|
|
747
|
+
};
|
|
621
748
|
const globalPath = managerSettingsPath(target, "user");
|
|
622
|
-
const projectPath = target.includeProject
|
|
749
|
+
const projectPath = target.includeProject
|
|
750
|
+
? managerSettingsPath(target, "project")
|
|
751
|
+
: undefined;
|
|
623
752
|
const explain = (path: string) =>
|
|
624
753
|
`Deletes this file now (nothing is written):\n${path}\nIf it does not exist, nothing happens. Unsaved edits are discarded. No undo.`;
|
|
625
754
|
const rows: DialogRow[] = [
|
|
626
|
-
{
|
|
755
|
+
{
|
|
756
|
+
id: "user",
|
|
757
|
+
label: "Global",
|
|
758
|
+
value: "Restore global defaults",
|
|
759
|
+
help: explain(globalPath),
|
|
760
|
+
},
|
|
627
761
|
...(projectPath
|
|
628
|
-
? [
|
|
762
|
+
? [
|
|
763
|
+
{
|
|
764
|
+
id: "project",
|
|
765
|
+
label: "Project",
|
|
766
|
+
value: "Restore project defaults",
|
|
767
|
+
help: explain(projectPath),
|
|
768
|
+
},
|
|
769
|
+
]
|
|
629
770
|
: []),
|
|
630
771
|
{ id: "cancel", label: "Cancel", help: "Delete nothing." },
|
|
631
772
|
];
|
|
632
|
-
const choice = await dialogMenu(
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
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
|
+
);
|
|
636
782
|
if (choice === "user" || choice === "project") {
|
|
637
783
|
const { filePath, deleted } = deleteManagerSettings({ ...target, scope: choice });
|
|
638
784
|
layers = readLayers();
|
|
@@ -642,22 +788,26 @@ async function configureAgentsDialog(
|
|
|
642
788
|
scope = layers.scope;
|
|
643
789
|
options.apply();
|
|
644
790
|
ctx.ui.notify(
|
|
645
|
-
deleted
|
|
791
|
+
deleted
|
|
792
|
+
? `Deleted ${filePath}. Defaults restored.`
|
|
793
|
+
: `No settings file at ${filePath}; nothing to delete.`,
|
|
646
794
|
"info",
|
|
647
795
|
);
|
|
648
796
|
}
|
|
649
|
-
}
|
|
650
|
-
else if (action === "types") {
|
|
797
|
+
} else if (action === "types") {
|
|
651
798
|
await editAgentTypes(ctx, options.store, draft.nerdFontIcons, {
|
|
652
799
|
getAllTools: options.getAllTools ?? (() => []),
|
|
653
800
|
toolFiltering: draft.toolFiltering,
|
|
801
|
+
resolveAgentSettings: options.resolveAgentSettings,
|
|
654
802
|
});
|
|
655
803
|
options.store.reload();
|
|
656
804
|
} else if (action === "save") {
|
|
657
805
|
if (draft.checklistIntegration && !baseline.checklistIntegration) {
|
|
658
806
|
const status = checklistStatus();
|
|
659
807
|
if (!status.eligible)
|
|
660
|
-
throw new Error(
|
|
808
|
+
throw new Error(
|
|
809
|
+
`Checklist integration cannot be enabled: ${status.reason ?? "requirements not met"}. Turn it Off or satisfy: ${CHECKLIST_REQUIREMENTS}`,
|
|
810
|
+
);
|
|
661
811
|
}
|
|
662
812
|
const file = saveManagerOverrides({
|
|
663
813
|
cwd: ctx.cwd,
|
|
@@ -675,10 +825,7 @@ async function configureAgentsDialog(
|
|
|
675
825
|
return;
|
|
676
826
|
}
|
|
677
827
|
} catch (error) {
|
|
678
|
-
ctx.ui.notify(
|
|
679
|
-
error instanceof Error ? error.message : String(error),
|
|
680
|
-
"error",
|
|
681
|
-
);
|
|
828
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
|
|
682
829
|
}
|
|
683
830
|
}
|
|
684
831
|
}
|