pi-subagent-manager 0.22.0 → 0.23.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/README.md +2 -1
- package/docs/custom-agents.md +1 -1
- package/docs/settings.md +50 -10
- package/package.json +1 -1
- package/src/prefs/settings.ts +127 -55
- package/src/ui/agent-loader.ts +40 -5
- package/src/ui/cost-footer.ts +3 -3
- package/src/ui/live-agent-view.ts +1 -5
- package/src/ui/model-picker.ts +30 -8
- package/src/ui/settings-ui.ts +90 -26
- package/src/ui/status-ui.ts +0 -1
- package/src/ui/ui.ts +3 -6
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/pi-subagent-manager)
|
|
4
4
|
[](https://www.npmjs.com/package/pi-subagent-manager)
|
|
5
|
+
[](https://github.com/championswimmer/pi-subagent-manager/stargazers)
|
|
5
6
|
[](https://github.com/championswimmer/pi-subagent-manager/actions/workflows/tests.yml)
|
|
6
7
|
[](https://codecov.io/gh/championswimmer/pi-subagent-manager)
|
|
7
8
|
|
|
@@ -81,7 +82,7 @@ A live **Agents** widget sits above the input box. Choose **Full** (the existing
|
|
|
81
82
|
- **`npm:pi-footer`:** with the default status-key mode, add **Extension Status** through `/footer` and select **`subagent_cost`**. Event mode instead requires a **Pi Event Value** widget with **Widget ID** entered manually and **Raw value only** enabled; event IDs are not listed in the status selector.
|
|
82
83
|
- Values publish at session start and immediately on subagent startup, including `💵 $0.0000`, then after settlement/settings changes. Total cost includes the main session plus settled subagents. The icon picker offers three Nerd Font choices when the labs toggle is on, otherwise three emoji choices. Status modes leave your footer untouched; event mode retains a fallback showing the selected value/icon when no extension provides `/footer`. See [Cost display settings](docs/settings.md#labs-cost-display-costdisplay) and the [pi-footer setup guide with exact snippets](docs/pi-footer.md).
|
|
83
84
|
|
|
84
|
-
Experimental features are marked **[labs]** in settings. Enable **[labs] Nerd Font icons** in `/agents` to show role-specific icons beside agent names (off by default; requires a Nerd Font in your terminal). Loaders appear **before**, never instead of, the role icon. Choose
|
|
85
|
+
Experimental features are marked **[labs]** in settings. Enable **[labs] Nerd Font icons** in `/agents` to show role-specific icons beside agent names (off by default; requires a Nerd Font in your terminal). Loaders appear **before**, never instead of, the role icon. Choose Braille, ASCII (`| / - \`), ASCII Star (`+ x *`), or ASCII Pulse (`= * -`) with Nerd Fonts off; enabling Nerd Fonts also unlocks Circle and Hourglass under **[labs] Loader style**, with previews of every animation frame and each family's completed, paused, failed, and stopped icons. Custom agent types can set an optional `icon` or use **[labs] Icon** in `/agents types`. See [icon setup](docs/settings.md#labs-nerd-font-icons-nerdfonticons).
|
|
85
86
|
|
|
86
87
|
Enable **[labs] Enable subagent extensions** in `/agents settings` to reload configured user and trusted-project extension hooks in each subagent’s separate session. It is off by default and experimental: hooks that assume main-session state can cause bugs or unintended consequences. This is configured-file discovery, **not exact main-session inheritance**; CLI-only, inline, and built-in extensions are not reloaded. See [subagent extension settings](docs/settings.md#labs-enable-subagent-extensions-subagentextensions) and read the [limitations](docs/subagent-extension-limitations.md) before enabling.
|
|
87
88
|
|
package/docs/custom-agents.md
CHANGED
|
@@ -143,7 +143,7 @@ In `/agents types`, select **[labs] Icon** and paste the glyph, then save the ag
|
|
|
143
143
|
| Ctrl+S | Save (or apply a multiline field to the draft) |
|
|
144
144
|
| Esc | Discard draft |
|
|
145
145
|
|
|
146
|
-
The model picker lists selected models first, in fallback order. **Enter** toggles a model
|
|
146
|
+
The model picker lists selected models first, in fallback order. **Enter** toggles a model; **w/s** moves a selected model up/down in browse mode. **/** or **Tab** enters search, where typing (including w/s) filters; **Tab** returns to browsing while keeping the filter. Other typed letters also start search. Unselected models are ranked by fuzzy match against `modelSuggestions`, scoped models first.
|
|
147
147
|
|
|
148
148
|
**External editor** opens the whole Markdown definition in `$VISUAL`, `$EDITOR`,
|
|
149
149
|
or `vi` in fork mode. For an overlay, edit its YAML file directly and reload.
|
package/docs/settings.md
CHANGED
|
@@ -62,17 +62,28 @@ Minimal mode groups starting agents with running agents and excludes the main co
|
|
|
62
62
|
|
|
63
63
|
## [labs] Nerd Font icons (`nerdFontIcons`)
|
|
64
64
|
|
|
65
|
-
Experimental features are tagged **[labs]** in
|
|
65
|
+
Experimental features are tagged **[labs]** in the selected setting's help. Row labels omit that prefix to leave room for provenance dots. **[labs] Nerd Font icons** is an on/off toggle, **off by default**. Enable it in `/agents` and save with **Ctrl+S**, or set `"nerdFontIcons": true` in your settings file. Configure a [Nerd Font](https://www.nerdfonts.com/) in your terminal first; unsupported fonts may show boxes or incorrect glyphs. The extension does not install or detect fonts.
|
|
66
66
|
|
|
67
|
-
When enabled, an agent type’s optional `icon` appears before its readable name in the full widget, thread browsers, live watcher header, and type picker. Starting/running agents show the selected loader **before the original role icon**, never replacing it. Completed, paused, failed, and stopped agents show that loader family's corresponding static state icon before the role icon. Agents without a configured role icon still show their loader/state indicator. The one-line minimal widget uses the same family's indicators for aggregate status counts. Turning the setting off
|
|
67
|
+
When enabled, an agent type’s optional `icon` appears before its readable name in the full widget, thread browsers, live watcher header, and type picker. Starting/running agents show the selected loader **before the original role icon**, never replacing it. Completed, paused, failed, and stopped agents show that loader family's corresponding static state icon before the role icon. Agents without a configured role icon still show their loader/state indicator. The one-line minimal widget uses the same family's indicators for aggregate status counts. Turning the setting off hides role icons without removing configured icons; portable loaders remain visible; RPC output keeps state indicators static. Saved settings apply immediately to newly rendered widgets and dialogs.
|
|
68
68
|
|
|
69
69
|
All six bundled agents have [role-specific icons](default-agents.md#nerd-font-icons). Add or change an icon with **[labs] Icon** in `/agents types`, or the optional `icon` frontmatter field in [your own agent](custom-agents.md#icons-labs). Retained threads keep the icon from their saved agent definition.
|
|
70
70
|
|
|
71
71
|
## [labs] Loader style (`loaderStyle`)
|
|
72
72
|
|
|
73
|
-
Choose
|
|
73
|
+
Choose a loader in `/agents` settings and save with **Ctrl+S**, or set `loaderStyle` in your settings file:
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
| Style | Setting | Running frames | Requires Nerd Font |
|
|
76
|
+
| --- | --- | --- | --- |
|
|
77
|
+
| Circle | `circle` (saved default) | Circle slices | Yes |
|
|
78
|
+
| Braille | `braille` | ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ | No (standard Unicode, not ASCII) |
|
|
79
|
+
| Hourglass | `hourglass` | Hourglass stages | Yes |
|
|
80
|
+
| ASCII | `ascii` | `\| / - \\` | No |
|
|
81
|
+
| ASCII Star | `ascii-star` | `+ x *` | No |
|
|
82
|
+
| ASCII Pulse | `ascii-pulse` | `= * -` | No |
|
|
83
|
+
|
|
84
|
+
With **[labs] Nerd Font icons** off, the picker shows only Braille and ASCII palettes. With it on, all palettes are available. Saved Circle/Hourglass preferences render as ASCII while Nerd Fonts are off, without changing the saved preference. ASCII palettes use `+`, `=`, `!`, and `#` for completed, paused, failed, and stopped states. The compact ASCII animations are inspired by [cli-spinners](https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json) (`line`, `star2`, and `toggle13`).
|
|
85
|
+
|
|
86
|
+
The Labs preview shows every family's running animation frames and completed, paused, failed, and stopped icons, so you can compare all states before choosing. Starting uses the running animation. State indicators precede the role icon when role icons are enabled; the selected family also applies to the minimal widget's counts. In non-animated output, active agents use the family's first frame.
|
|
76
87
|
|
|
77
88
|
## [labs] Cost display (`costDisplay`)
|
|
78
89
|
|
|
@@ -173,9 +184,38 @@ Lower it to keep the tree tidy. Raise it for long sessions with many agents. Whe
|
|
|
173
184
|
|
|
174
185
|
## Scope
|
|
175
186
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
187
|
+
Settings are read in order: **built-in defaults → Global → trusted Current Project**.
|
|
188
|
+
All keys are optional. The dialog saves only values different from the lower layer,
|
|
189
|
+
so unchanged settings continue inheriting future global changes. Restoring defaults
|
|
190
|
+
is a draft edit; in Project scope it can explicitly override non-default global values.
|
|
191
|
+
|
|
192
|
+
Colored dots before each setting describe saved changes: an **accent dot** means
|
|
193
|
+
changed in Global relative to defaults; a **warning dot** means changed in Current
|
|
194
|
+
Project relative to effective global settings. Both dots appear when both layers
|
|
195
|
+
change that setting, even when the project restores the built-in default. Equal
|
|
196
|
+
values are not changes. Unsaved edits do not change the dots. Footer display groups
|
|
197
|
+
the provenance of its three settings; its submenu shows each separately.
|
|
198
|
+
|
|
199
|
+
The save scope is **Global** when no project settings file exists and **Current
|
|
200
|
+
Project** when one exists. It is determined independently for each project; the old
|
|
201
|
+
cross-project `ui-state.json` preference is no longer used by this dialog.
|
|
202
|
+
Untrusted projects always read and save Global only.
|
|
203
|
+
|
|
204
|
+
Changing scope opens a confirmation screen with **Cancel selected by default**:
|
|
205
|
+
|
|
206
|
+
- **Global → Current Project:** Confirm creates the project settings file as an
|
|
207
|
+
empty object (inheriting global). Unsaved edits are kept; Save and apply writes
|
|
208
|
+
them to Project. Future edits in this project use Project scope.
|
|
209
|
+
- **Current Project → Global:** Confirm deletes only this manager's project
|
|
210
|
+
settings file, discards unsaved edits, reloads global/default values immediately,
|
|
211
|
+
and routes future saves to Global. Project values are not copied into Global.
|
|
212
|
+
- **Cancel / Esc:** no files, values, or scope are changed.
|
|
213
|
+
|
|
214
|
+
Confirmed scope changes happen **immediately** and survive cancelling the outer
|
|
215
|
+
settings screen. Ordinary value edits still require **Save and apply**. Running
|
|
216
|
+
agents and retained threads are kept.
|
|
217
|
+
|
|
218
|
+
The dialog warns about invalid settings layers. Project saves are blocked until an
|
|
219
|
+
invalid Global layer is fixed, rather than persisting a default-based snapshot.
|
|
220
|
+
If settings layers change while the dialog is open, Save and scope transitions
|
|
221
|
+
refuse the stale draft: reopen settings to load the new values before editing.
|
package/package.json
CHANGED
package/src/prefs/settings.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
closeSync,
|
|
4
4
|
constants,
|
|
5
5
|
fchmodSync,
|
|
6
|
+
linkSync,
|
|
6
7
|
lstatSync,
|
|
7
8
|
mkdirSync,
|
|
8
9
|
openSync,
|
|
@@ -28,7 +29,7 @@ export type CostValue = (typeof COST_VALUES)[number];
|
|
|
28
29
|
export const COST_ICONS = ["money", "coins", "wallet"] as const;
|
|
29
30
|
export type CostIcon = (typeof COST_ICONS)[number];
|
|
30
31
|
|
|
31
|
-
export const LOADER_STYLES = ["circle", "braille", "hourglass"] as const;
|
|
32
|
+
export const LOADER_STYLES = ["circle", "braille", "hourglass", "ascii", "ascii-star", "ascii-pulse"] as const;
|
|
32
33
|
export type LoaderStyle = (typeof LOADER_STYLES)[number];
|
|
33
34
|
|
|
34
35
|
export const TOOL_FILTERING_MODES = ["allowed", "all-except-blocked", "all"] as const;
|
|
@@ -120,7 +121,7 @@ function requirement(key: (typeof KEYS)[number]): string {
|
|
|
120
121
|
if (key === "costDisplay") return "costDisplay must be pi-footer-event, pi-footer-status or pi-status";
|
|
121
122
|
if (key === "costValue") return "costValue must be subagents or total";
|
|
122
123
|
if (key === "costIcon") return "costIcon must be money, coins or wallet";
|
|
123
|
-
if (key === "loaderStyle") return
|
|
124
|
+
if (key === "loaderStyle") return `loaderStyle must be one of: ${LOADER_STYLES.join(", ")}`;
|
|
124
125
|
if (key === "toolFiltering") return "toolFiltering must be allowed, all-except-blocked or all";
|
|
125
126
|
if (key === "modelSelection")
|
|
126
127
|
return "modelSelection must be pick-first-available, pick-first-scoped or use-current";
|
|
@@ -222,82 +223,74 @@ function layer(base: string, segments: string[]): SettingsLayer {
|
|
|
222
223
|
return { filePath: join(current, "settings.json"), directories };
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
function
|
|
226
|
+
function settingsFileExists(entry: SettingsLayer): boolean {
|
|
226
227
|
for (const directory of entry.directories) {
|
|
227
228
|
const stat = assertNotSymlinkPath(directory);
|
|
228
|
-
if (!stat) return
|
|
229
|
+
if (!stat) return false;
|
|
229
230
|
if (!stat.isDirectory())
|
|
230
231
|
throw new Error(`Settings directory must be a directory: ${directory}`);
|
|
231
232
|
}
|
|
232
233
|
const stat = assertNotSymlinkPath(entry.filePath);
|
|
233
|
-
if (!stat) return
|
|
234
|
+
if (!stat) return false;
|
|
234
235
|
if (!stat.isFile())
|
|
235
236
|
throw new Error(`Settings must be a regular file: ${entry.filePath}`);
|
|
236
|
-
return
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
function readLayer(entry: SettingsLayer): Partial<ManagerSettings> | undefined {
|
|
240
|
-
const content = readLayerContent(entry);
|
|
241
|
-
return content === undefined ? undefined : parseSettings(content);
|
|
237
|
+
return true;
|
|
242
238
|
}
|
|
243
239
|
|
|
244
240
|
export type ManagerSaveScope = "user" | "project";
|
|
245
241
|
|
|
246
|
-
function
|
|
247
|
-
|
|
248
|
-
return { ...entry, filePath: join(dirname(entry.filePath), "ui-state.json") };
|
|
242
|
+
function detail(error: unknown): string {
|
|
243
|
+
return error instanceof Error ? error.message : String(error);
|
|
249
244
|
}
|
|
250
245
|
|
|
251
|
-
|
|
252
|
-
|
|
246
|
+
export interface ManagerSettingsOptions {
|
|
247
|
+
cwd: string;
|
|
253
248
|
agentDir: string;
|
|
254
249
|
includeProject: boolean;
|
|
255
|
-
}): ManagerSaveScope {
|
|
256
|
-
if (!options.includeProject) return "user";
|
|
257
|
-
try {
|
|
258
|
-
const content = readLayerContent(uiStateLayer(options.agentDir));
|
|
259
|
-
if (content !== undefined) {
|
|
260
|
-
const state: unknown = JSON.parse(content);
|
|
261
|
-
if (
|
|
262
|
-
state && typeof state === "object" && !Array.isArray(state) &&
|
|
263
|
-
"saveScope" in state && state.saveScope === "user"
|
|
264
|
-
) return "user";
|
|
265
|
-
}
|
|
266
|
-
} catch {
|
|
267
|
-
// Missing, invalid or unsafe UI state must not prevent opening settings.
|
|
268
|
-
}
|
|
269
|
-
return "project";
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
export function saveManagerSaveScope(agentDir: string, scope: ManagerSaveScope): void {
|
|
273
|
-
if (scope !== "user" && scope !== "project") throw new Error("Invalid settings scope");
|
|
274
|
-
const entry = uiStateLayer(agentDir);
|
|
275
|
-
ensureScopeDirectories(entry.directories);
|
|
276
|
-
writeAtomically(entry, `${JSON.stringify({ saveScope: scope }, null, 2)}\n`);
|
|
277
250
|
}
|
|
278
251
|
|
|
279
|
-
|
|
280
|
-
|
|
252
|
+
export interface ManagerSettingsLayers {
|
|
253
|
+
settings: ManagerSettings;
|
|
254
|
+
diagnostics: string[];
|
|
255
|
+
global: Partial<ManagerSettings>;
|
|
256
|
+
project: Partial<ManagerSettings>;
|
|
257
|
+
scope: ManagerSaveScope;
|
|
281
258
|
}
|
|
282
259
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
260
|
+
/** Validated layers retain provenance; save scope belongs to the current project. */
|
|
261
|
+
export function loadManagerSettingsLayers(options: ManagerSettingsOptions): ManagerSettingsLayers {
|
|
262
|
+
const result: ManagerSettingsLayers = {
|
|
263
|
+
settings: { ...DEFAULT_MANAGER_SETTINGS },
|
|
264
|
+
diagnostics: [],
|
|
265
|
+
global: {},
|
|
266
|
+
project: {},
|
|
267
|
+
scope: "user",
|
|
268
|
+
};
|
|
269
|
+
const layers: ["global" | "project", SettingsLayer][] = [
|
|
270
|
+
["global", layer(options.agentDir, ["subagent-manager"])],
|
|
271
|
+
];
|
|
291
272
|
if (options.includeProject)
|
|
292
|
-
layers.push(layer(options.cwd, [".pi", "agent", "subagent-manager"]));
|
|
293
|
-
for (const entry of layers) {
|
|
273
|
+
layers.push(["project", layer(options.cwd, [".pi", "agent", "subagent-manager"])]);
|
|
274
|
+
for (const [scope, entry] of layers) {
|
|
294
275
|
try {
|
|
295
|
-
|
|
296
|
-
|
|
276
|
+
if (!settingsFileExists(entry)) continue;
|
|
277
|
+
// Malformed/unreadable regular project files still represent a save destination.
|
|
278
|
+
if (scope === "project") result.scope = "project";
|
|
279
|
+
const parsed = parseSettings(readFileSync(entry.filePath, "utf8"));
|
|
280
|
+
result[scope] = parsed;
|
|
281
|
+
Object.assign(result.settings, parsed);
|
|
297
282
|
} catch (error) {
|
|
298
|
-
diagnostics.push(`${entry.filePath}: ${detail(error)}`);
|
|
283
|
+
result.diagnostics.push(`${entry.filePath}: ${detail(error)}`);
|
|
299
284
|
}
|
|
300
285
|
}
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function loadManagerSettings(options: ManagerSettingsOptions): {
|
|
290
|
+
settings: ManagerSettings;
|
|
291
|
+
diagnostics: string[];
|
|
292
|
+
} {
|
|
293
|
+
const { settings, diagnostics } = loadManagerSettingsLayers(options);
|
|
301
294
|
return { settings, diagnostics };
|
|
302
295
|
}
|
|
303
296
|
|
|
@@ -360,7 +353,7 @@ function exclusiveCreateFlags(): number {
|
|
|
360
353
|
return constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW || 0);
|
|
361
354
|
}
|
|
362
355
|
|
|
363
|
-
function writeAtomically(entry: SettingsLayer, content: string): void {
|
|
356
|
+
function writeAtomically(entry: SettingsLayer, content: string, overwrite = true): void {
|
|
364
357
|
const filePath = entry.filePath;
|
|
365
358
|
const temporary = join(dirname(filePath), `.settings.${randomUUID()}.tmp`);
|
|
366
359
|
let created = false;
|
|
@@ -380,7 +373,17 @@ function writeAtomically(entry: SettingsLayer, content: string): void {
|
|
|
380
373
|
const tempStat = assertNotSymlinkPath(temporary);
|
|
381
374
|
if (!tempStat?.isFile())
|
|
382
375
|
throw new Error(`Settings must be a regular file: ${temporary}`);
|
|
383
|
-
renameSync(temporary, filePath);
|
|
376
|
+
if (overwrite) renameSync(temporary, filePath);
|
|
377
|
+
else {
|
|
378
|
+
try {
|
|
379
|
+
// Linking a completed temporary file creates the destination without clobbering
|
|
380
|
+
// a settings file that appeared after the initial absence check.
|
|
381
|
+
linkSync(temporary, filePath);
|
|
382
|
+
} catch (error) {
|
|
383
|
+
if (errorCode(error) !== "EEXIST") throw error;
|
|
384
|
+
assertRegularFileOrAbsent(filePath);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
384
387
|
} finally {
|
|
385
388
|
if (created) {
|
|
386
389
|
try {
|
|
@@ -414,3 +417,72 @@ export function saveManagerSettings(options: {
|
|
|
414
417
|
writeAtomically(entry, content);
|
|
415
418
|
return entry.filePath;
|
|
416
419
|
}
|
|
420
|
+
|
|
421
|
+
function assertExpectedLayers(current: ManagerSettingsLayers, expected: ManagerSettingsLayers): void {
|
|
422
|
+
if (
|
|
423
|
+
current.scope !== expected.scope ||
|
|
424
|
+
KEYS.some((key) => current.global[key] !== expected.global[key] ||
|
|
425
|
+
current.project[key] !== expected.project[key]) ||
|
|
426
|
+
current.diagnostics.length !== expected.diagnostics.length ||
|
|
427
|
+
current.diagnostics.some((diagnostic, index) => diagnostic !== expected.diagnostics[index])
|
|
428
|
+
) {
|
|
429
|
+
throw new Error("Settings changed on disk. Reopen settings before saving or switching scope to avoid stale inherited values.");
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Persist only values that change the selected scope's inherited settings. */
|
|
434
|
+
export function saveManagerOverrides(options: ManagerSettingsOptions & {
|
|
435
|
+
scope: ManagerSaveScope;
|
|
436
|
+
settings: ManagerSettings;
|
|
437
|
+
expectedLayers?: ManagerSettingsLayers;
|
|
438
|
+
}): string {
|
|
439
|
+
if (options.scope !== "user" && options.scope !== "project")
|
|
440
|
+
throw new Error("Invalid settings scope");
|
|
441
|
+
if (options.scope === "project" && !options.includeProject)
|
|
442
|
+
throw new Error("Project settings are not enabled/trusted");
|
|
443
|
+
// Validate the complete draft before creating directories or modifying files.
|
|
444
|
+
const parsed = parseSettings(serializedSettings(options.settings));
|
|
445
|
+
const current = loadManagerSettingsLayers(options);
|
|
446
|
+
if (options.expectedLayers) assertExpectedLayers(current, options.expectedLayers);
|
|
447
|
+
if (options.scope === "project") {
|
|
448
|
+
const globalPath = layer(options.agentDir, ["subagent-manager"]).filePath;
|
|
449
|
+
const globalDiagnostics = current.diagnostics.filter((diagnostic) => diagnostic.startsWith(`${globalPath}:`));
|
|
450
|
+
if (globalDiagnostics.length > 0)
|
|
451
|
+
throw new Error(`Cannot save project overrides while global settings are invalid. Fix global settings and reopen settings. ${globalDiagnostics.join("; ")}`);
|
|
452
|
+
}
|
|
453
|
+
const inherited = options.scope === "user"
|
|
454
|
+
? DEFAULT_MANAGER_SETTINGS
|
|
455
|
+
: { ...DEFAULT_MANAGER_SETTINGS, ...current.global };
|
|
456
|
+
const overrides = Object.fromEntries(
|
|
457
|
+
KEYS.filter((key) => parsed[key] !== inherited[key]).map((key) => [key, parsed[key]]),
|
|
458
|
+
);
|
|
459
|
+
const entry = options.scope === "user"
|
|
460
|
+
? layer(options.agentDir, ["subagent-manager"])
|
|
461
|
+
: layer(options.cwd, [".pi", "agent", "subagent-manager"]);
|
|
462
|
+
ensureScopeDirectories(entry.directories);
|
|
463
|
+
writeAtomically(entry, `${JSON.stringify(overrides, null, 2)}\n`);
|
|
464
|
+
return entry.filePath;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/** Confirmed scope transition: create an empty project layer or remove only its file. */
|
|
468
|
+
export function setManagerProjectSettings(options: ManagerSettingsOptions & {
|
|
469
|
+
enabled: boolean;
|
|
470
|
+
expectedLayers?: ManagerSettingsLayers;
|
|
471
|
+
}): string {
|
|
472
|
+
if (!options.includeProject) throw new Error("Project settings are not enabled/trusted");
|
|
473
|
+
if (typeof options.enabled !== "boolean") throw new Error("Invalid project settings state");
|
|
474
|
+
if (options.expectedLayers)
|
|
475
|
+
assertExpectedLayers(loadManagerSettingsLayers(options), options.expectedLayers);
|
|
476
|
+
const entry = layer(options.cwd, [".pi", "agent", "subagent-manager"]);
|
|
477
|
+
const present = settingsFileExists(entry);
|
|
478
|
+
if (options.enabled) {
|
|
479
|
+
if (!present) {
|
|
480
|
+
ensureScopeDirectories(entry.directories);
|
|
481
|
+
writeAtomically(entry, "{}\n", false);
|
|
482
|
+
}
|
|
483
|
+
} else if (present) {
|
|
484
|
+
// Recheck owned paths immediately before deletion; malformed JSON is removable.
|
|
485
|
+
if (settingsFileExists(entry)) unlinkSync(entry.filePath);
|
|
486
|
+
}
|
|
487
|
+
return entry.filePath;
|
|
488
|
+
}
|
package/src/ui/agent-loader.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { LOADER_STYLES, type LoaderStyle } from "../prefs/settings.ts";
|
|
2
2
|
import type { ThreadView } from "../types.ts";
|
|
3
3
|
|
|
4
4
|
export const AGENT_PROGRESS_INTERVAL = 180;
|
|
@@ -10,12 +10,14 @@ export const AGENT_LOADERS: Record<
|
|
|
10
10
|
LoaderStyle,
|
|
11
11
|
{
|
|
12
12
|
label: string;
|
|
13
|
+
requiresNerdFont: boolean;
|
|
13
14
|
frames: readonly string[];
|
|
14
15
|
states: Record<SettledState, string>;
|
|
15
16
|
}
|
|
16
17
|
> = {
|
|
17
18
|
circle: {
|
|
18
19
|
label: "Circle",
|
|
20
|
+
requiresNerdFont: true,
|
|
19
21
|
// Nerd Fonts md-circle-slice-1..8, check-circle, pause-circle, close-circle, stop-circle.
|
|
20
22
|
frames: Array.from({ length: 8 }, (_, index) => String.fromCodePoint(0xf0a9e + index)),
|
|
21
23
|
states: {
|
|
@@ -27,17 +29,49 @@ export const AGENT_LOADERS: Record<
|
|
|
27
29
|
},
|
|
28
30
|
braille: {
|
|
29
31
|
label: "Braille",
|
|
32
|
+
requiresNerdFont: false,
|
|
30
33
|
frames: Array.from("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"),
|
|
31
34
|
states: { completed: "✓", paused: "Ⅱ", failed: "×", stopped: "■" },
|
|
32
35
|
},
|
|
33
36
|
hourglass: {
|
|
34
37
|
label: "Hourglass",
|
|
38
|
+
requiresNerdFont: true,
|
|
35
39
|
// Nerd Fonts fa-hourglass-start/half/end, check-square, pause, times-circle, stop.
|
|
36
40
|
frames: ["\uf251", "\uf252", "\uf253"],
|
|
37
41
|
states: { completed: "\uf14a", paused: "\uf04c", failed: "\uf057", stopped: "\uf04d" },
|
|
38
42
|
},
|
|
43
|
+
// Compact ASCII palettes inspired by cli-spinners line, star2 and toggle13.
|
|
44
|
+
// https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json
|
|
45
|
+
ascii: {
|
|
46
|
+
label: "ASCII",
|
|
47
|
+
requiresNerdFont: false,
|
|
48
|
+
frames: ["|", "/", "-", "\\"],
|
|
49
|
+
states: { completed: "+", paused: "=", failed: "!", stopped: "#" },
|
|
50
|
+
},
|
|
51
|
+
"ascii-star": {
|
|
52
|
+
label: "ASCII Star",
|
|
53
|
+
requiresNerdFont: false,
|
|
54
|
+
frames: ["+", "x", "*"],
|
|
55
|
+
states: { completed: "+", paused: "=", failed: "!", stopped: "#" },
|
|
56
|
+
},
|
|
57
|
+
"ascii-pulse": {
|
|
58
|
+
label: "ASCII Pulse",
|
|
59
|
+
requiresNerdFont: false,
|
|
60
|
+
frames: ["=", "*", "-"],
|
|
61
|
+
states: { completed: "+", paused: "=", failed: "!", stopped: "#" },
|
|
62
|
+
},
|
|
39
63
|
};
|
|
40
64
|
|
|
65
|
+
/** Filter the picker without exposing private-use glyphs to ordinary fonts. */
|
|
66
|
+
export function availableLoaderStyles(nerdFontIcons: boolean): LoaderStyle[] {
|
|
67
|
+
return LOADER_STYLES.filter((style) => nerdFontIcons || !AGENT_LOADERS[style].requiresNerdFont);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Preserve saved preferences, but render a portable fallback when Nerd Fonts are off. */
|
|
71
|
+
export function effectiveLoaderStyle(style: LoaderStyle, nerdFontIcons: boolean): LoaderStyle {
|
|
72
|
+
return !nerdFontIcons && AGENT_LOADERS[style].requiresNerdFont ? "ascii" : style;
|
|
73
|
+
}
|
|
74
|
+
|
|
41
75
|
/** RPC/non-animated hosts use the first running frame and all settled indicators. */
|
|
42
76
|
export function agentProgressIcon(
|
|
43
77
|
thread: Pick<ThreadView, "state">,
|
|
@@ -46,8 +80,7 @@ export function agentProgressIcon(
|
|
|
46
80
|
animate = true,
|
|
47
81
|
loaderStyle: LoaderStyle = "circle",
|
|
48
82
|
): string | undefined {
|
|
49
|
-
|
|
50
|
-
const loader = AGENT_LOADERS[loaderStyle];
|
|
83
|
+
const loader = AGENT_LOADERS[effectiveLoaderStyle(loaderStyle, nerdFontIcons)];
|
|
51
84
|
if (thread.state === "starting" || thread.state === "running") {
|
|
52
85
|
const index = animate ? Math.floor(Math.max(0, now) / AGENT_PROGRESS_INTERVAL) : 0;
|
|
53
86
|
return loader.frames[index % loader.frames.length];
|
|
@@ -56,8 +89,10 @@ export function agentProgressIcon(
|
|
|
56
89
|
}
|
|
57
90
|
|
|
58
91
|
/** Restrict the separate label prefix to trusted, single built-in loader glyphs. */
|
|
59
|
-
export function isAgentLoaderGlyph(glyph: string): boolean {
|
|
92
|
+
export function isAgentLoaderGlyph(glyph: string, nerdFontIcons = true): boolean {
|
|
60
93
|
return Object.values(AGENT_LOADERS).some(
|
|
61
|
-
(loader) =>
|
|
94
|
+
(loader) =>
|
|
95
|
+
(nerdFontIcons || !loader.requiresNerdFont) &&
|
|
96
|
+
(loader.frames.includes(glyph) || Object.values(loader.states).includes(glyph)),
|
|
62
97
|
);
|
|
63
98
|
}
|
package/src/ui/cost-footer.ts
CHANGED
|
@@ -30,13 +30,13 @@ export function footerUsage(entries: readonly SessionEntry[]) {
|
|
|
30
30
|
}
|
|
31
31
|
export const COST_WIDGET_ID = "subagent_cost";
|
|
32
32
|
export const COST_WIDGET_EVENT = "pi-footer:update-widget";
|
|
33
|
-
export const COST_ICON = "\uf0d6";
|
|
33
|
+
export const COST_ICON = "\uf0d6"; // nf-fa-money_bill
|
|
34
34
|
|
|
35
35
|
export function costIconGlyph(icon: CostIcon, nerdFontIcons: boolean): string {
|
|
36
36
|
const glyphs = {
|
|
37
37
|
money: { emoji: "💵", nerd: COST_ICON },
|
|
38
|
-
coins: { emoji: "🪙", nerd: "\
|
|
39
|
-
wallet: { emoji: "👛", nerd: "\
|
|
38
|
+
coins: { emoji: "🪙", nerd: "\uede8" }, // nf-fa-coins
|
|
39
|
+
wallet: { emoji: "👛", nerd: "\uee1e" }, // nf-fa-wallet
|
|
40
40
|
};
|
|
41
41
|
return glyphs[icon][nerdFontIcons ? "nerd" : "emoji"];
|
|
42
42
|
}
|
|
@@ -210,11 +210,7 @@ export class LiveAgentView {
|
|
|
210
210
|
|
|
211
211
|
private syncProgress(): void {
|
|
212
212
|
const state = this.snapshot?.thread?.state;
|
|
213
|
-
const active =
|
|
214
|
-
this.nerdFontIcons &&
|
|
215
|
-
!this.disposed &&
|
|
216
|
-
!this.error &&
|
|
217
|
-
(state === "starting" || state === "running");
|
|
213
|
+
const active = !this.disposed && !this.error && (state === "starting" || state === "running");
|
|
218
214
|
if (!active) {
|
|
219
215
|
if (this.progressTimer !== undefined) clearInterval(this.progressTimer);
|
|
220
216
|
this.progressTimer = undefined;
|
package/src/ui/model-picker.ts
CHANGED
|
@@ -102,6 +102,7 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
102
102
|
private readonly searchInput = new Input({ placeholder: "Search models" });
|
|
103
103
|
private draft: string[];
|
|
104
104
|
private pickerQuery = "";
|
|
105
|
+
private searching = false;
|
|
105
106
|
private currentItems: ModelSelectItem[] = [];
|
|
106
107
|
private selectList = new SelectList([], 1, getSelectListTheme(), MODEL_EDITOR_LAYOUT);
|
|
107
108
|
private _focused = false;
|
|
@@ -133,14 +134,12 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
133
134
|
"muted",
|
|
134
135
|
this.withScopeWarning(
|
|
135
136
|
this.suggestedScores.size
|
|
136
|
-
? "Selected first; suggested matches scoped first, then other models; the rest A–Z.
|
|
137
|
-
: "Selected first.
|
|
137
|
+
? "Selected first; suggested matches scoped first, then other models; the rest A–Z. / to search."
|
|
138
|
+
: "Selected first. / to search by provider/id or model name; other models A–Z.",
|
|
138
139
|
),
|
|
139
140
|
),
|
|
140
141
|
);
|
|
141
|
-
this.
|
|
142
|
-
this.theme.fg("dim", "↑↓ select · Enter toggle · Ctrl+↑↓ reorder · Ctrl+S done · Esc cancel"),
|
|
143
|
-
);
|
|
142
|
+
this.updateFooter();
|
|
144
143
|
this.addChild(this.searchInput);
|
|
145
144
|
this.refreshPickerList();
|
|
146
145
|
}
|
|
@@ -151,7 +150,7 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
151
150
|
|
|
152
151
|
set focused(value: boolean) {
|
|
153
152
|
this._focused = value;
|
|
154
|
-
this.searchInput.focused = value;
|
|
153
|
+
this.searchInput.focused = value && this.searching;
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
getMode(): "picker" {
|
|
@@ -235,8 +234,13 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
235
234
|
this.onDone([...this.draft]);
|
|
236
235
|
return;
|
|
237
236
|
}
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
if (matchesKey(keyData, Key.tab) || (!this.searching && keyData === "/")) {
|
|
238
|
+
this.setSearching(!this.searching);
|
|
239
|
+
this.tui.requestRender();
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const earlier = !this.searching && keyData === "w";
|
|
243
|
+
const later = !this.searching && keyData === "s";
|
|
240
244
|
if (earlier || later) {
|
|
241
245
|
const selected = this.selectList.getSelectedItem()?.value;
|
|
242
246
|
const index = selected === undefined ? -1 : this.draft.indexOf(selected);
|
|
@@ -261,6 +265,7 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
261
265
|
this.searchInput.handleInput(keyData);
|
|
262
266
|
const nextQuery = this.searchInput.getValue();
|
|
263
267
|
if (nextQuery !== this.pickerQuery) {
|
|
268
|
+
this.setSearching(true);
|
|
264
269
|
this.pickerQuery = nextQuery;
|
|
265
270
|
// Keep selected preferences visible, but focus the first search result
|
|
266
271
|
// so typing a query and pressing Enter still adds the matching model.
|
|
@@ -270,6 +275,23 @@ export class OrderedModelEditorComponent extends Container {
|
|
|
270
275
|
this.tui.requestRender();
|
|
271
276
|
}
|
|
272
277
|
|
|
278
|
+
private setSearching(value: boolean): void {
|
|
279
|
+
this.searching = value;
|
|
280
|
+
this.searchInput.focused = this._focused && value;
|
|
281
|
+
this.updateFooter();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private updateFooter(): void {
|
|
285
|
+
this.footerText.setText(
|
|
286
|
+
this.theme.fg(
|
|
287
|
+
"dim",
|
|
288
|
+
this.searching
|
|
289
|
+
? "↑↓ select · Enter toggle · Tab browse · Ctrl+S done · Esc cancel"
|
|
290
|
+
: "↑↓ select · Enter toggle · w/s reorder · / search · Ctrl+S done · Esc cancel",
|
|
291
|
+
),
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
273
295
|
private refreshPickerList(selectedValue?: string, focusSearchResult = false): void {
|
|
274
296
|
const previousIndex = this.currentItems.findIndex(
|
|
275
297
|
(item) => item.value === this.selectList.getSelectedItem()?.value,
|
package/src/ui/settings-ui.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
dialogInput,
|
|
6
6
|
dialogMenu,
|
|
7
7
|
withDialogSession,
|
|
8
|
+
type DialogRow,
|
|
8
9
|
} from "./dialog.ts";
|
|
9
10
|
import {
|
|
10
11
|
DEFAULT_MANAGER_SETTINGS,
|
|
@@ -14,9 +15,9 @@ import {
|
|
|
14
15
|
type CostValue,
|
|
15
16
|
LOADER_STYLES,
|
|
16
17
|
type LoaderStyle,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
loadManagerSettingsLayers,
|
|
19
|
+
saveManagerOverrides,
|
|
20
|
+
setManagerProjectSettings,
|
|
20
21
|
type ManagerSettings,
|
|
21
22
|
type ModelSelectionMode,
|
|
22
23
|
type SubagentMode,
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
} from "../prefs/settings.ts";
|
|
26
27
|
import { editAgentTypes } from "./ui.ts";
|
|
27
28
|
import type { ToolEditorOptions } from "./tool-picker.ts";
|
|
28
|
-
import { AGENT_LOADERS } from "./agent-loader.ts";
|
|
29
|
+
import { AGENT_LOADERS, availableLoaderStyles, effectiveLoaderStyle } from "./agent-loader.ts";
|
|
29
30
|
import { costIconGlyph } from "./cost-footer.ts";
|
|
30
31
|
|
|
31
32
|
const LOADER_OPTIONS = LOADER_STYLES.map((id) => {
|
|
@@ -34,7 +35,7 @@ const LOADER_OPTIONS = LOADER_STYLES.map((id) => {
|
|
|
34
35
|
id,
|
|
35
36
|
label: loader.label,
|
|
36
37
|
value: `${loader.frames.join(" ")} · ${Object.values(loader.states).join(" ")}`,
|
|
37
|
-
help: `Each row: all starting/running frames · completed, paused, failed, stopped.\nStarting/running: ${loader.frames.join(" ")}\nCompleted: ${loader.states.completed} · Paused: ${loader.states.paused}\nFailed: ${loader.states.failed} · Stopped: ${loader.states.stopped}\
|
|
38
|
+
help: `Each row: all starting/running frames · completed, paused, failed, stopped.\nStarting/running: ${loader.frames.join(" ")}\nCompleted: ${loader.states.completed} · Paused: ${loader.states.paused}\nFailed: ${loader.states.failed} · Stopped: ${loader.states.stopped}\n${loader.requiresNerdFont ? "Requires [labs] Nerd Font icons On." : id === "braille" ? "Standard Unicode Braille; no Nerd Font needed." : "ASCII only; no special font needed."} The loader appears before the role icon when enabled.`,
|
|
38
39
|
};
|
|
39
40
|
});
|
|
40
41
|
|
|
@@ -149,11 +150,28 @@ const COST_VALUE_OPTIONS = [
|
|
|
149
150
|
|
|
150
151
|
const COST_ICON_LABELS = { money: "Money", coins: "Coins", wallet: "Wallet" } as const;
|
|
151
152
|
|
|
153
|
+
type SettingsLayers = ReturnType<typeof loadManagerSettingsLayers>;
|
|
154
|
+
|
|
155
|
+
/** Persisted changes, not unsaved draft values; theme styling is computed on render. */
|
|
156
|
+
function withProvenance(row: DialogRow, keys: (keyof ManagerSettings)[], layers: SettingsLayers): DialogRow {
|
|
157
|
+
const globalChanged = keys.some((key) => layers.global[key] !== undefined &&
|
|
158
|
+
layers.global[key] !== DEFAULT_MANAGER_SETTINGS[key]);
|
|
159
|
+
const projectChanged = keys.some((key) => layers.project[key] !== undefined &&
|
|
160
|
+
layers.project[key] !== (layers.global[key] ?? DEFAULT_MANAGER_SETTINGS[key]));
|
|
161
|
+
return {
|
|
162
|
+
...row,
|
|
163
|
+
renderLabel: (label, theme) =>
|
|
164
|
+
(globalChanged ? theme.fg("accent", "●") + " " : "") +
|
|
165
|
+
(projectChanged ? theme.fg("warning", "●") + " " : "") + label.replace(/^\[labs\] /, ""),
|
|
166
|
+
help: `${row.label}\n${row.help ?? ""}\nDots (saved): accent ● Global; warning ● Current Project; both ● ● changed in both.`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
152
170
|
/** Edits the shared draft; only the outer settings screen saves or applies it. */
|
|
153
|
-
async function configureFooterDisplay(ctx: ExtensionCommandContext, draft: ManagerSettings): Promise<void> {
|
|
171
|
+
async function configureFooterDisplay(ctx: ExtensionCommandContext, draft: ManagerSettings, layers: SettingsLayers): Promise<void> {
|
|
154
172
|
let selectedId: string | undefined;
|
|
155
173
|
while (true) {
|
|
156
|
-
const action = await dialogMenu(ctx, "[labs] Footer display", [
|
|
174
|
+
const action = await dialogMenu(ctx, "[labs] Footer display", ([
|
|
157
175
|
{
|
|
158
176
|
id: "location",
|
|
159
177
|
label: "Location",
|
|
@@ -173,7 +191,10 @@ async function configureFooterDisplay(ctx: ExtensionCommandContext, draft: Manag
|
|
|
173
191
|
help: `Choose a money-related ${draft.nerdFontIcons ? "Nerd Font" : "emoji"} icon. The family follows [labs] Nerd Font icons.`,
|
|
174
192
|
},
|
|
175
193
|
{ id: "back", label: "Back", help: "Return to settings. Save and apply there to commit these changes." },
|
|
176
|
-
]
|
|
194
|
+
] as DialogRow[]).map((row) => {
|
|
195
|
+
const key = ({ location: "costDisplay", value: "costValue", icon: "costIcon" } as Record<string, keyof ManagerSettings>)[row.id];
|
|
196
|
+
return key ? withProvenance(row, [key], layers) : row;
|
|
197
|
+
}), { selectedId, footer: "↑↓/Tab navigate · Enter edit · Esc back" });
|
|
177
198
|
if (!action || action === "back") return;
|
|
178
199
|
selectedId = action;
|
|
179
200
|
if (action === "location") {
|
|
@@ -244,18 +265,26 @@ async function configureAgentsDialog(
|
|
|
244
265
|
apply(): void;
|
|
245
266
|
},
|
|
246
267
|
): Promise<void> {
|
|
247
|
-
|
|
248
|
-
|
|
268
|
+
const readLayers = () => loadManagerSettingsLayers({
|
|
269
|
+
cwd: ctx.cwd,
|
|
249
270
|
agentDir: options.agentDir,
|
|
250
271
|
includeProject: ctx.isProjectTrusted(),
|
|
251
272
|
});
|
|
273
|
+
let layers = readLayers();
|
|
274
|
+
const reportDiagnostics = () => {
|
|
275
|
+
for (const diagnostic of layers.diagnostics) ctx.ui.notify(diagnostic, "warning");
|
|
276
|
+
};
|
|
277
|
+
reportDiagnostics();
|
|
278
|
+
let baseline = { ...layers.settings };
|
|
279
|
+
let draft = { ...baseline };
|
|
280
|
+
let scope = layers.scope;
|
|
252
281
|
let selectedId: string | undefined;
|
|
253
282
|
while (true) {
|
|
254
|
-
const dirty = JSON.stringify(draft) !== JSON.stringify(
|
|
283
|
+
const dirty = JSON.stringify(draft) !== JSON.stringify(baseline);
|
|
255
284
|
const action = await dialogMenu(
|
|
256
285
|
ctx,
|
|
257
286
|
`Agents settings${dirty ? " · unsaved" : ""}`,
|
|
258
|
-
[
|
|
287
|
+
([
|
|
259
288
|
{
|
|
260
289
|
id: "subagentMode",
|
|
261
290
|
label: "Subagent Mode",
|
|
@@ -294,13 +323,13 @@ async function configureAgentsDialog(
|
|
|
294
323
|
id: "nerdFontIcons",
|
|
295
324
|
label: "[labs] Nerd Font icons",
|
|
296
325
|
value: draft.nerdFontIcons ? "On" : "Off",
|
|
297
|
-
help: "Experimental: display each agent type’s optional icon
|
|
326
|
+
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.",
|
|
298
327
|
},
|
|
299
328
|
{
|
|
300
329
|
id: "loaderStyle",
|
|
301
330
|
label: "[labs] Loader style",
|
|
302
|
-
value: AGENT_LOADERS[draft.loaderStyle].label,
|
|
303
|
-
help: "
|
|
331
|
+
value: AGENT_LOADERS[effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons)].label,
|
|
332
|
+
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.",
|
|
304
333
|
},
|
|
305
334
|
{
|
|
306
335
|
id: "subagentExtensions",
|
|
@@ -318,7 +347,7 @@ async function configureAgentsDialog(
|
|
|
318
347
|
id: "scope",
|
|
319
348
|
label: "Save scope",
|
|
320
349
|
value: scope === "user" ? "Global" : "Current Project",
|
|
321
|
-
help: "Global: save
|
|
350
|
+
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.",
|
|
322
351
|
},
|
|
323
352
|
{
|
|
324
353
|
id: "types",
|
|
@@ -336,14 +365,19 @@ async function configureAgentsDialog(
|
|
|
336
365
|
label: "Save and apply",
|
|
337
366
|
value: dirty ? "(changes)" : undefined,
|
|
338
367
|
valueColor: dirty ? "warning" as const : undefined,
|
|
339
|
-
help: "Save
|
|
368
|
+
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.",
|
|
340
369
|
},
|
|
341
370
|
{
|
|
342
371
|
id: "cancel",
|
|
343
372
|
label: "Cancel",
|
|
344
373
|
help: "Close without saving manager settings.",
|
|
345
374
|
},
|
|
346
|
-
]
|
|
375
|
+
] as DialogRow[]).map((row) => {
|
|
376
|
+
const keys = row.id === "costDisplay"
|
|
377
|
+
? ["costDisplay", "costValue", "costIcon"] as (keyof ManagerSettings)[]
|
|
378
|
+
: row.id in DEFAULT_MANAGER_SETTINGS ? [row.id as keyof ManagerSettings] : [];
|
|
379
|
+
return keys.length ? withProvenance(row, keys, layers) : row;
|
|
380
|
+
}),
|
|
347
381
|
{
|
|
348
382
|
selectedId,
|
|
349
383
|
saveId: "save",
|
|
@@ -396,14 +430,18 @@ async function configureAgentsDialog(
|
|
|
396
430
|
if (WIDGET_MODE_OPTIONS.some((option) => option.id === mode))
|
|
397
431
|
draft.widgetMode = mode as WidgetMode;
|
|
398
432
|
} else if (action === "costDisplay") {
|
|
399
|
-
await configureFooterDisplay(ctx, draft);
|
|
433
|
+
await configureFooterDisplay(ctx, draft, layers);
|
|
400
434
|
} else if (action === "nerdFontIcons") {
|
|
401
435
|
draft.nerdFontIcons = !draft.nerdFontIcons;
|
|
402
436
|
} else if (action === "loaderStyle") {
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
437
|
+
const styles = availableLoaderStyles(draft.nerdFontIcons);
|
|
438
|
+
const style = await dialogMenu(
|
|
439
|
+
ctx,
|
|
440
|
+
"[labs] Loader style",
|
|
441
|
+
LOADER_OPTIONS.filter((option) => styles.includes(option.id)),
|
|
442
|
+
{ selectedId: effectiveLoaderStyle(draft.loaderStyle, draft.nerdFontIcons) },
|
|
443
|
+
);
|
|
444
|
+
if (styles.includes(style as LoaderStyle)) draft.loaderStyle = style as LoaderStyle;
|
|
407
445
|
} else if (action === "subagentExtensions") {
|
|
408
446
|
draft.subagentExtensions = !draft.subagentExtensions;
|
|
409
447
|
} else if (action === "finalRecap") {
|
|
@@ -416,8 +454,33 @@ async function configureAgentsDialog(
|
|
|
416
454
|
);
|
|
417
455
|
else {
|
|
418
456
|
const nextScope = scope === "user" ? "project" : "user";
|
|
419
|
-
|
|
457
|
+
const message = nextScope === "project"
|
|
458
|
+
? "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."
|
|
459
|
+
: "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.";
|
|
460
|
+
const confirmation = await dialogMenu(ctx,
|
|
461
|
+
nextScope === "project" ? "Enable project settings?" : "Clear project settings and use Global?",
|
|
462
|
+
[
|
|
463
|
+
{ id: "confirm", label: "Confirm", help: message },
|
|
464
|
+
{ id: "cancel", label: "Cancel", help: message + "\nCancel leaves files, scope and unsaved edits unchanged." },
|
|
465
|
+
],
|
|
466
|
+
{ selectedId: "cancel", footer: "↑↓/Tab choose · Enter select · Esc cancel" },
|
|
467
|
+
);
|
|
468
|
+
if (confirmation !== "confirm") continue;
|
|
469
|
+
setManagerProjectSettings({
|
|
470
|
+
cwd: ctx.cwd,
|
|
471
|
+
agentDir: options.agentDir,
|
|
472
|
+
includeProject: ctx.isProjectTrusted(),
|
|
473
|
+
enabled: nextScope === "project",
|
|
474
|
+
expectedLayers: layers,
|
|
475
|
+
});
|
|
476
|
+
layers = readLayers();
|
|
477
|
+
reportDiagnostics();
|
|
420
478
|
scope = nextScope;
|
|
479
|
+
if (scope === "user") {
|
|
480
|
+
baseline = { ...layers.settings };
|
|
481
|
+
draft = { ...baseline };
|
|
482
|
+
options.apply();
|
|
483
|
+
}
|
|
421
484
|
}
|
|
422
485
|
} else if (action === "defaults") draft = { ...DEFAULT_MANAGER_SETTINGS };
|
|
423
486
|
else if (action === "types") {
|
|
@@ -427,16 +490,17 @@ async function configureAgentsDialog(
|
|
|
427
490
|
});
|
|
428
491
|
options.store.reload();
|
|
429
492
|
} else if (action === "save") {
|
|
430
|
-
const file =
|
|
493
|
+
const file = saveManagerOverrides({
|
|
431
494
|
cwd: ctx.cwd,
|
|
432
495
|
agentDir: options.agentDir,
|
|
433
496
|
includeProject: ctx.isProjectTrusted(),
|
|
434
497
|
scope,
|
|
435
498
|
settings: draft,
|
|
499
|
+
expectedLayers: layers,
|
|
436
500
|
});
|
|
437
501
|
options.apply();
|
|
438
502
|
ctx.ui.notify(
|
|
439
|
-
`Saved ${file}. Settings reloaded;
|
|
503
|
+
`Saved ${file}. Settings reloaded; unchanged values inherit from the lower layer.`,
|
|
440
504
|
"info",
|
|
441
505
|
);
|
|
442
506
|
return;
|
package/src/ui/status-ui.ts
CHANGED
package/src/ui/ui.ts
CHANGED
|
@@ -92,7 +92,7 @@ export function agentTypeLabel(
|
|
|
92
92
|
const role =
|
|
93
93
|
nerdFontIcons && typeof icon === "string" && /^\p{Co}$/u.test(icon) ? `${icon} ` : "";
|
|
94
94
|
const progress =
|
|
95
|
-
|
|
95
|
+
loaderIcon && isAgentLoaderGlyph(loaderIcon, nerdFontIcons) ? `${loaderIcon} ` : "";
|
|
96
96
|
return `${progress}${role}${sanitizeText(type)}`;
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -460,11 +460,8 @@ export function updateWidget(
|
|
|
460
460
|
"pi-subagent",
|
|
461
461
|
(tui) => {
|
|
462
462
|
let timer: ReturnType<typeof setInterval> | undefined;
|
|
463
|
-
if (snapshot.some(isLive)
|
|
464
|
-
timer = setInterval(
|
|
465
|
-
() => tui.requestRender(),
|
|
466
|
-
nerdFontIcons ? AGENT_PROGRESS_INTERVAL : 1000,
|
|
467
|
-
);
|
|
463
|
+
if (snapshot.some(isLive)) {
|
|
464
|
+
timer = setInterval(() => tui.requestRender(), AGENT_PROGRESS_INTERVAL);
|
|
468
465
|
timer.unref();
|
|
469
466
|
}
|
|
470
467
|
return {
|