pi-better-subagents 0.21.0 → 0.22.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 +3 -2
- package/catalog-schema.ts +1 -1
- package/config.json +1 -1
- package/config.ts +1 -1
- package/docs/agent-catalog.md +1 -1
- package/docs/usage.md +4 -3
- package/index.ts +5 -2
- package/package.json +1 -1
- package/roles/role.researcher.md +1 -1
- package/settings-page.ts +6 -2
- package/shared-navigator.ts +107 -10
package/README.md
CHANGED
|
@@ -39,10 +39,11 @@ Linux confinement requires a usable `bubblewrap` backend and Pi SDK 0.82.1 or ne
|
|
|
39
39
|
|
|
40
40
|
The user config sets `delegationMode` to `manual`, `adaptive` (default), or
|
|
41
41
|
`coordinator`. `/subagents settings` (or `/subagents`) opens a settings page
|
|
42
|
-
for delegation mode and the concurrent-subagent cap (default
|
|
42
|
+
for delegation mode and the concurrent-subagent cap (default 6). Edits apply to
|
|
43
43
|
this session and persist across reloads; Ctrl+S saves both as defaults, and
|
|
44
44
|
Reset to defaults clears
|
|
45
|
-
session overrides.
|
|
45
|
+
session overrides. Agents opens the same catalog as `/agents`.
|
|
46
|
+
`/subagents mode manual|adaptive|coordinator` and
|
|
46
47
|
`/subagents cap <number>` are command equivalents; `/subagents save` persists
|
|
47
48
|
both. Lowering the cap blocks new single and batch launches, including launches
|
|
48
49
|
still preparing, without stopping running work. Saved configuration changes are
|
package/catalog-schema.ts
CHANGED
|
@@ -72,7 +72,7 @@ export const PARSER_LIMITS = {
|
|
|
72
72
|
* runtime already uses. Tiers are catalog policy, not benchmark rankings.
|
|
73
73
|
*/
|
|
74
74
|
export const APPROVED_ROLE_DEFAULTS = [
|
|
75
|
-
{ id: "role.researcher", name: "Researcher", model: "openai/gpt-6.1-
|
|
75
|
+
{ id: "role.researcher", name: "Researcher", model: "openai/gpt-6.1-terra", effort: "medium", tier: "balanced" },
|
|
76
76
|
{ id: "role.explorer", name: "Explorer", model: "openai/gpt-6-luna", effort: "medium", tier: "efficient" },
|
|
77
77
|
{ id: "role.product-manager", name: "Product Manager", model: "openai/gpt-6.1-sol", effort: "medium", tier: "balanced" },
|
|
78
78
|
{ id: "role.developer", name: "Developer", model: "openai/gpt-6.1-sol", effort: "high", tier: "balanced" },
|
package/config.json
CHANGED
package/config.ts
CHANGED
|
@@ -73,7 +73,7 @@ export interface SubagentConfig extends TimingSettings {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/** Concurrency cap when config.json sets none. */
|
|
76
|
-
export const DEFAULT_MAX_CONCURRENT =
|
|
76
|
+
export const DEFAULT_MAX_CONCURRENT = 6;
|
|
77
77
|
|
|
78
78
|
export function isConcurrencyCap(value: unknown): value is number {
|
|
79
79
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
package/docs/agent-catalog.md
CHANGED
|
@@ -100,7 +100,7 @@ Model availability, same-tier fallback, and nearest-effort adjustment are not de
|
|
|
100
100
|
|
|
101
101
|
| Role | Stored id | Name | Model | Effort | Tier |
|
|
102
102
|
| --- | --- | --- | --- | --- | --- |
|
|
103
|
-
| `researcher` | `role.researcher` | Researcher | `openai/gpt-6.1-
|
|
103
|
+
| `researcher` | `role.researcher` | Researcher | `openai/gpt-6.1-terra` | medium | balanced |
|
|
104
104
|
| `explorer` | `role.explorer` | Explorer | `openai/gpt-6-luna` | medium | efficient |
|
|
105
105
|
| `product-manager` | `role.product-manager` | Product Manager | `openai/gpt-6.1-sol` | medium | balanced |
|
|
106
106
|
| `developer` | `role.developer` | Developer | `openai/gpt-6.1-sol` | high | balanced |
|
package/docs/usage.md
CHANGED
|
@@ -19,7 +19,8 @@ Set `delegationMode` in the user config described under
|
|
|
19
19
|
`coordinator` (default `adaptive`). This controls foreground delegation guidance,
|
|
20
20
|
not child permissions or catalog definitions. `/subagents settings` (or simply
|
|
21
21
|
`/subagents`) opens the terminal settings page with mode and concurrent-subagent
|
|
22
|
-
cap controls and Reset to defaults.
|
|
22
|
+
cap controls, an Agents shortcut to `/agents`, and Reset to defaults.
|
|
23
|
+
The page uses the same selected-row and
|
|
23
24
|
active-cell styling as `/sandbox`, with one editable value column.
|
|
24
25
|
Edits automatically persist for this session, including across reloads; Escape
|
|
25
26
|
closes the page without undoing them.
|
|
@@ -35,7 +36,7 @@ Command equivalents also work outside the terminal UI:
|
|
|
35
36
|
/subagents reset
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
The cap defaults to
|
|
39
|
+
The cap defaults to 6 and applies to both single and batch launches. Lowering it
|
|
39
40
|
below the running count leaves existing work untouched and blocks new admissions
|
|
40
41
|
until capacity becomes available. Slots already reserved by an in-flight launch
|
|
41
42
|
remain admitted. Settings apply to this parent Pi process, not
|
|
@@ -481,7 +482,7 @@ The effective config also sets:
|
|
|
481
482
|
- `delegationMode` — foreground policy (`manual`, `adaptive`, or `coordinator`;
|
|
482
483
|
default `adaptive`). `/subagents mode ...` changes only the current session.
|
|
483
484
|
`/subagents save` saves mode and cap together as config defaults.
|
|
484
|
-
- `maxConcurrent` — positive whole-number concurrency cap (**default
|
|
485
|
+
- `maxConcurrent` — positive whole-number concurrency cap (**default 6**).
|
|
485
486
|
`/subagents cap <number>` overrides it for this session. Both single and batch
|
|
486
487
|
admissions respect the cap; existing runs are never stopped by a cap change.
|
|
487
488
|
Use `/subagents settings` to edit both controls or `/subagents reset` to return
|
package/index.ts
CHANGED
|
@@ -2298,7 +2298,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2298
2298
|
});
|
|
2299
2299
|
const openSettings = async (ctx: ExtensionCommandContext): Promise<void> => {
|
|
2300
2300
|
if (ctx.mode === "tui" && ctx.hasUI && typeof ctx.ui.custom === "function") {
|
|
2301
|
-
await ctx.ui.custom<
|
|
2301
|
+
const next = await ctx.ui.custom<"agents" | undefined>((tui, theme, _kb, done) => createSubagentSettingsPage(theme, {
|
|
2302
2302
|
get: () => {
|
|
2303
2303
|
const settings = effectiveSettings();
|
|
2304
2304
|
return {
|
|
@@ -2310,7 +2310,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
2310
2310
|
};
|
|
2311
2311
|
},
|
|
2312
2312
|
changeMode, changeCap, save: saveSettings, reset: resetSettings,
|
|
2313
|
-
|
|
2313
|
+
// Close this page first; the catalog opens after ui.custom resolves.
|
|
2314
|
+
openAgents: () => done("agents"),
|
|
2315
|
+
}, () => { refreshBackgroundWorkNavigator(ctx); tui.requestRender(); }, () => done(undefined)));
|
|
2316
|
+
if (next === "agents") await agentOperations.openCatalog(ctx);
|
|
2314
2317
|
} else {
|
|
2315
2318
|
ctx.ui.notify(`Delegation mode: ${activeDelegationMode()}. Concurrent subagents: ${activeConcurrencyCap()}. Use /subagents mode <mode> or /subagents cap <number>; /subagents save persists both.`, "info");
|
|
2316
2319
|
}
|
package/package.json
CHANGED
package/roles/role.researcher.md
CHANGED
package/settings-page.ts
CHANGED
|
@@ -18,9 +18,11 @@ export interface SubagentSettingsHandlers {
|
|
|
18
18
|
changeCap(cap: number): void;
|
|
19
19
|
save(): { ok: boolean; message: string };
|
|
20
20
|
reset(): void;
|
|
21
|
+
/** Opens the same catalog as `/agents`. The caller closes this page first. */
|
|
22
|
+
openAgents?(): void;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
const labels = ["Delegation mode", "Concurrent subagents", "Reset to defaults"];
|
|
25
|
+
const labels = ["Delegation mode", "Concurrent subagents", "Agents", "Reset to defaults"];
|
|
24
26
|
|
|
25
27
|
function cell(text: string, width: number): string {
|
|
26
28
|
const clipped = Tui.truncateToWidth(text, width, "");
|
|
@@ -57,6 +59,8 @@ export function createSubagentSettingsPage(
|
|
|
57
59
|
input.handleInput("\x05");
|
|
58
60
|
input.focused = focused;
|
|
59
61
|
report("");
|
|
62
|
+
} else if (row === 2) {
|
|
63
|
+
handlers.openAgents?.();
|
|
60
64
|
} else {
|
|
61
65
|
handlers.reset();
|
|
62
66
|
report("Session settings reset to saved defaults.");
|
|
@@ -118,7 +122,7 @@ export function createSubagentSettingsPage(
|
|
|
118
122
|
const lines: string[] = [theme.fg("accent", theme.bold(" Subagent settings")), ""];
|
|
119
123
|
labels.forEach((label, index) => {
|
|
120
124
|
const selected = index === row;
|
|
121
|
-
if (index ===
|
|
125
|
+
if (index === labels.length - 1) lines.push("");
|
|
122
126
|
const title = theme.fg(selected ? "accent" : "text", marker(selected) + label);
|
|
123
127
|
if (index >= 2) {
|
|
124
128
|
lines.push(highlight(title, selected));
|
package/shared-navigator.ts
CHANGED
|
@@ -328,28 +328,92 @@ function themeFgFromTheme(theme: unknown): (color: string, value: string) => str
|
|
|
328
328
|
return (color, value) => maybeTheme?.fg ? maybeTheme.fg(color, value) : value;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
|
|
331
|
+
// Structural typing keeps keyboard-only Pi hosts (no mouse API) loading this widget unchanged.
|
|
332
|
+
type WidgetMouseEvent = {
|
|
333
|
+
type: string;
|
|
334
|
+
button: string;
|
|
335
|
+
/** Coordinates local to this component, zero-based. */
|
|
336
|
+
x: number;
|
|
337
|
+
y: number;
|
|
338
|
+
width: number;
|
|
339
|
+
shift?: boolean;
|
|
340
|
+
alt?: boolean;
|
|
341
|
+
ctrl?: boolean;
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
type WidgetMouseResult = { handled: true; render: boolean };
|
|
345
|
+
|
|
346
|
+
type MainListWidget = Component & {
|
|
347
|
+
dispose?(): void;
|
|
348
|
+
handleMouse(event: WidgetMouseEvent): WidgetMouseResult | undefined;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
function createMainListWidget(tui: { requestRender?(): void }, theme: unknown, deps: HostDeps): MainListWidget {
|
|
332
352
|
const requestRender = () => tui.requestRender?.();
|
|
333
353
|
state().mainListRequestRender = requestRender;
|
|
354
|
+
// navigatorId per rendered line, so a pointer row resolves by structure, never by row text.
|
|
355
|
+
let lineOwners: Array<string | undefined> = [];
|
|
356
|
+
let lineWidth = MAIN_LIST_FALLBACK_WIDTH;
|
|
357
|
+
// Pi synthesizes a click only for the component that handled the initial press.
|
|
358
|
+
let pressedRow: { navigatorId: string; y: number } | undefined;
|
|
359
|
+
const rowAt = (event: WidgetMouseEvent): string | undefined => {
|
|
360
|
+
const width = Number.isFinite(event.width) && event.width > 0 ? Math.floor(event.width) : lineWidth;
|
|
361
|
+
if (!Number.isFinite(event.x) || event.x < 0 || event.x >= width) return undefined;
|
|
362
|
+
if (!Number.isInteger(event.y) || event.y < 0 || event.y >= lineOwners.length) return undefined;
|
|
363
|
+
return lineOwners[event.y];
|
|
364
|
+
};
|
|
334
365
|
return {
|
|
335
366
|
render(width: number): string[] {
|
|
336
367
|
const rows = listRows();
|
|
337
368
|
syncMainListSelection(rows);
|
|
338
369
|
if (!rows.length) {
|
|
339
370
|
state().lastMainListLines = undefined;
|
|
371
|
+
lineOwners = [];
|
|
372
|
+
pressedRow = undefined;
|
|
340
373
|
return [];
|
|
341
374
|
}
|
|
342
|
-
const
|
|
375
|
+
const layout = buildMainListLayout(rows, renderWidth(width), deps.truncate, themeFgFromTheme(theme), {
|
|
343
376
|
selectedId: state().mainListFocused ? state().mainListSelectedId : undefined,
|
|
344
377
|
focused: state().mainListFocused === true,
|
|
345
|
-
})
|
|
378
|
+
});
|
|
379
|
+
lineWidth = renderWidth(width);
|
|
380
|
+
// The leading gap line belongs to the widget too, so its slot stays ownerless.
|
|
381
|
+
lineOwners = [undefined, ...layout.owners];
|
|
382
|
+
const lines = ["", ...layout.lines];
|
|
346
383
|
state().lastMainListLines = lines;
|
|
347
384
|
return lines;
|
|
348
385
|
},
|
|
349
|
-
|
|
386
|
+
handleMouse(event: WidgetMouseEvent): WidgetMouseResult | undefined {
|
|
387
|
+
// Only an unmodified left press is ours; every other gesture reaches the host untouched.
|
|
388
|
+
if (event.button !== "left" || event.shift === true || event.alt === true || event.ctrl === true) {
|
|
389
|
+
pressedRow = undefined;
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
if (event.type === "press") {
|
|
393
|
+
pressedRow = undefined;
|
|
394
|
+
const navigatorId = rowAt(event);
|
|
395
|
+
if (!navigatorId || !listRows().some((row) => row.navigatorId === navigatorId)) return undefined;
|
|
396
|
+
pressedRow = { navigatorId, y: event.y };
|
|
397
|
+
return { handled: true, render: false };
|
|
398
|
+
}
|
|
399
|
+
if (event.type !== "click") return undefined;
|
|
400
|
+
const pressed = pressedRow;
|
|
401
|
+
pressedRow = undefined;
|
|
402
|
+
// A click after another component's press, or after the layout moved, is not the row we claimed.
|
|
403
|
+
if (!pressed || pressed.y !== event.y || rowAt(event) !== pressed.navigatorId) return undefined;
|
|
404
|
+
if (!openNavigatorRow(pressed.navigatorId)) return undefined;
|
|
405
|
+
return { handled: true, render: true };
|
|
406
|
+
},
|
|
407
|
+
invalidate() {
|
|
408
|
+
state().lastMainListLines = undefined;
|
|
409
|
+
lineOwners = [];
|
|
410
|
+
pressedRow = undefined;
|
|
411
|
+
},
|
|
350
412
|
dispose() {
|
|
351
413
|
const s = state();
|
|
352
414
|
if (s.mainListRequestRender === requestRender) s.mainListRequestRender = undefined;
|
|
415
|
+
lineOwners = [];
|
|
416
|
+
pressedRow = undefined;
|
|
353
417
|
},
|
|
354
418
|
};
|
|
355
419
|
}
|
|
@@ -454,7 +518,26 @@ function buildMainListLines(
|
|
|
454
518
|
fg: (color: string, value: string) => string,
|
|
455
519
|
options: { selectedId?: string; focused?: boolean } = {},
|
|
456
520
|
): string[] {
|
|
521
|
+
return buildMainListLayout(rows, width, truncate, fg, options).lines;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* The list's lines plus the navigatorId each line shows, so pointer input maps a rendered row to its
|
|
526
|
+
* stable row identity. Headers, separators and the shortcut line keep an undefined owner.
|
|
527
|
+
*/
|
|
528
|
+
function buildMainListLayout(
|
|
529
|
+
rows: InternalRow[],
|
|
530
|
+
width: number,
|
|
531
|
+
truncate: (s: string, width: number) => string,
|
|
532
|
+
fg: (color: string, value: string) => string,
|
|
533
|
+
options: { selectedId?: string; focused?: boolean } = {},
|
|
534
|
+
): { lines: string[]; owners: Array<string | undefined> } {
|
|
457
535
|
const lines: string[] = [];
|
|
536
|
+
const owners: Array<string | undefined> = [];
|
|
537
|
+
const push = (line: string, owner?: string) => {
|
|
538
|
+
lines.push(line);
|
|
539
|
+
owners.push(owner);
|
|
540
|
+
};
|
|
458
541
|
const grouped = new Map<string, InternalRow[]>();
|
|
459
542
|
for (const row of rows) {
|
|
460
543
|
const existing = grouped.get(row.providerLabel) ?? [];
|
|
@@ -466,16 +549,16 @@ function buildMainListLines(
|
|
|
466
549
|
for (let i = 0; i < orderedLabels.length; i += 1) {
|
|
467
550
|
const label = orderedLabels[i]!;
|
|
468
551
|
const group = grouped.get(label)!;
|
|
469
|
-
if (i > 0)
|
|
470
|
-
|
|
552
|
+
if (i > 0) push("");
|
|
553
|
+
push(providerGroupLabel(label, fg));
|
|
471
554
|
for (const row of group) {
|
|
472
555
|
const selected = options.focused && row.navigatorId === options.selectedId;
|
|
473
|
-
|
|
556
|
+
push(formatMainListRow(row, selected === true, fg, width), row.navigatorId);
|
|
474
557
|
}
|
|
475
558
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
return lines.map((line) => safeTruncate(line, width, truncate));
|
|
559
|
+
push("");
|
|
560
|
+
push(shortcutsLine(options.focused === true, fg));
|
|
561
|
+
return { lines: lines.map((line) => safeTruncate(line, width, truncate)), owners };
|
|
479
562
|
}
|
|
480
563
|
|
|
481
564
|
function shortcutsLine(focused: boolean, fg: (color: string, value: string) => string): string {
|
|
@@ -766,6 +849,20 @@ function handleMainListCloseKey(): void {
|
|
|
766
849
|
refreshMainListWidget();
|
|
767
850
|
}
|
|
768
851
|
|
|
852
|
+
/**
|
|
853
|
+
* Open the shared detail overlay on the row a pointer chose. Setting the selection first keeps the
|
|
854
|
+
* keyboard path identical: Enter, x and the overlay's own keys then act on the clicked row.
|
|
855
|
+
*/
|
|
856
|
+
function openNavigatorRow(navigatorId: string): boolean {
|
|
857
|
+
const rows = listRows();
|
|
858
|
+
if (!rows.some((row) => row.navigatorId === navigatorId)) return false;
|
|
859
|
+
clearMainListCloseArm();
|
|
860
|
+
state().mainListSelectedId = navigatorId;
|
|
861
|
+
refreshMainListWidget();
|
|
862
|
+
openNavigator();
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
|
|
769
866
|
function openNavigator(): void {
|
|
770
867
|
const s = state();
|
|
771
868
|
const ctx = s.uiCtx;
|