@ferris1225/pi-subagents 5.0.6 → 6.0.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/CHANGELOG.md +89 -0
- package/README.md +187 -97
- package/index.ts +1 -1
- package/package.json +4 -9
- package/src/configuration/role-migration.ts +2 -2
- package/src/configuration/setup.ts +4 -2
- package/src/configuration/ui.ts +144 -132
- package/src/delegation/agents.ts +15 -22
- package/src/delegation/dispatch.ts +17 -122
- package/src/delegation/prompt.ts +13 -12
- package/src/execution/cli-run.ts +112 -39
- package/src/execution/process-tree.ts +12 -8
- package/src/execution/run-control.ts +11 -3
- package/src/execution/spawn.ts +24 -7
- package/src/isolation/cleanup.ts +31 -12
- package/src/isolation/managed-paths.ts +6 -4
- package/src/isolation/manifest-mutation.ts +89 -0
- package/src/isolation/recovery.ts +33 -29
- package/src/isolation/temp-hygiene.ts +1 -1
- package/src/lifecycle/await-results.ts +114 -0
- package/src/lifecycle/dispatch-core.ts +7 -1
- package/src/lifecycle/durable.ts +83 -39
- package/src/lifecycle/runtime.ts +12 -4
- package/src/lifecycle/stop.ts +2 -2
- package/src/lifecycle/thread-lifecycle.ts +10 -5
- package/src/lifecycle/thread-restore.ts +26 -25
- package/src/lifecycle/thread-shared.ts +15 -3
- package/src/lifecycle/tools.ts +90 -33
- package/src/presentation/announcements.ts +8 -2
- package/src/presentation/monitor.ts +5 -3
- package/src/presentation/widget.ts +157 -113
- package/src/workflow/acceptance.ts +67 -0
- package/src/workflow/durable.ts +34 -14
- package/src/workflow/engine.ts +161 -51
- package/src/workflow/plan.ts +25 -4
- package/src/workflow/state.ts +6 -0
- package/src/workflow/templates.ts +156 -0
- package/src/workflow/tool.ts +65 -109
- package/skills/workflow/SKILL.md +0 -268
- package/src/workflow/files.ts +0 -236
- package/workflows/code-review.md +0 -38
- package/workflows/migration.md +0 -42
- package/workflows/research.md +0 -48
package/src/configuration/ui.ts
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
/** Searchable pickers and the /subagents-setup role
|
|
1
|
+
/** Searchable pickers and the /subagents-setup role register. */
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
Input,
|
|
5
|
-
|
|
6
|
-
matchesKey,
|
|
7
|
-
truncateToWidth,
|
|
8
|
-
visibleWidth,
|
|
9
|
-
wrapTextWithAnsi,
|
|
10
|
-
type Component,
|
|
11
|
-
type Focusable,
|
|
12
|
-
type KeybindingsManager,
|
|
13
|
-
type SelectItem,
|
|
14
|
-
type TUI,
|
|
4
|
+
Input, fuzzyFilter, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi,
|
|
5
|
+
type Component, type Focusable, type KeybindingsManager, type SelectItem, type TUI,
|
|
15
6
|
} from "@earendil-works/pi-tui";
|
|
16
7
|
import type { ExtensionCommandContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
17
8
|
|
|
18
9
|
type PickerContext = Pick<ExtensionCommandContext, "mode" | "ui">;
|
|
19
10
|
const PAGE_SIZE = 8;
|
|
20
11
|
|
|
12
|
+
/** Leave room for the ten-line widget, its leading spacer, the two-line
|
|
13
|
+
* host footer and one transcript row. Tiny terminals retain an input slot. */
|
|
14
|
+
function setupHeight(tui: TUI): number {
|
|
15
|
+
return Math.max(3, (tui.terminal?.rows ?? 28) - 14);
|
|
16
|
+
}
|
|
17
|
+
|
|
21
18
|
interface PickerOptions {
|
|
22
19
|
title: string;
|
|
23
20
|
hint: string;
|
|
24
21
|
initialValue?: string;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
24
|
+
/** Input owns Unicode editing, paste, horizontal scrolling and the IME cursor.
|
|
25
|
+
* Selection and paging use the host's configurable keybindings. */
|
|
29
26
|
class Picker implements Component, Focusable {
|
|
30
27
|
private _focused = false;
|
|
31
28
|
private cursor = 0;
|
|
29
|
+
private pageRows = PAGE_SIZE;
|
|
32
30
|
private filtered: SelectItem[];
|
|
33
31
|
private readonly search = new Input({ prompt: "Search: ", placeholder: "type to filter" });
|
|
34
32
|
|
|
@@ -40,12 +38,8 @@ class Picker implements Component, Focusable {
|
|
|
40
38
|
private readonly done: (value: string | undefined) => void;
|
|
41
39
|
|
|
42
40
|
constructor(
|
|
43
|
-
items: SelectItem[],
|
|
44
|
-
|
|
45
|
-
tui: TUI,
|
|
46
|
-
theme: Theme,
|
|
47
|
-
keybindings: KeybindingsManager,
|
|
48
|
-
done: (value: string | undefined) => void,
|
|
41
|
+
items: SelectItem[], options: PickerOptions, tui: TUI, theme: Theme,
|
|
42
|
+
keybindings: KeybindingsManager, done: (value: string | undefined) => void,
|
|
49
43
|
) {
|
|
50
44
|
this.items = items;
|
|
51
45
|
this.options = options;
|
|
@@ -59,46 +53,43 @@ class Picker implements Component, Focusable {
|
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
get focused(): boolean { return this._focused; }
|
|
62
|
-
set focused(value: boolean) {
|
|
63
|
-
this._focused = value;
|
|
64
|
-
this.search.focused = value;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private pageSize(): number {
|
|
68
|
-
// Leave room for headings, help, and the selected item's details.
|
|
69
|
-
return Math.max(1, Math.min(PAGE_SIZE, (this.tui.terminal?.rows ?? 28) - 13));
|
|
70
|
-
}
|
|
56
|
+
set focused(value: boolean) { this._focused = value; this.search.focused = value; }
|
|
71
57
|
|
|
72
58
|
render(width: number): string[] {
|
|
73
|
-
if (width <= 0) return [
|
|
59
|
+
if (width <= 0) return [];
|
|
74
60
|
const theme = this.theme;
|
|
75
61
|
const dim = (text: string) => theme.fg("dim", text);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (!visible.length) lines.push("", theme.fg("warning", " No matches. Change or clear the search."));
|
|
84
|
-
for (const [index, item] of visible.entries()) {
|
|
85
|
-
const selected = start + index === this.cursor;
|
|
86
|
-
const prefix = selected ? theme.fg("accent", "› ") : " ";
|
|
87
|
-
const label = selected ? theme.fg("accent", theme.bold(item.label)) : item.label;
|
|
88
|
-
lines.push(prefix + label);
|
|
62
|
+
const height = setupHeight(this.tui);
|
|
63
|
+
if (height < 8) {
|
|
64
|
+
this.pageRows = 1;
|
|
65
|
+
const item = this.filtered[this.cursor];
|
|
66
|
+
return [theme.bold(this.options.title), ...this.search.render(width),
|
|
67
|
+
item ? theme.fg("accent", "› ") + theme.underline(item.label) : "No matches. Clear or change the search."]
|
|
68
|
+
.map((line) => truncateToWidth(line, width, "…"));
|
|
89
69
|
}
|
|
70
|
+
const lines = [theme.bold("Subagents · " + this.options.title)];
|
|
71
|
+
if (this.options.hint && height >= 16) lines.push(...wrapTextWithAnsi(this.options.hint, width).slice(0, 2).map(dim));
|
|
72
|
+
lines.push(...this.search.render(width), "");
|
|
73
|
+
const footer = [dim("↑/↓ move · PgUp/PgDn page"), dim("Enter select · Esc back")];
|
|
90
74
|
const item = this.filtered[this.cursor];
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
75
|
+
// The complete selected identity lives beside its capabilities, even when
|
|
76
|
+
// a long provider/model id was truncated in the list above.
|
|
77
|
+
const details = item ? ["", ...wrapTextWithAnsi(item.label, width).slice(0, 2),
|
|
78
|
+
...wrapTextWithAnsi(item.description ?? "", width).slice(0, 3).map(dim)] : [];
|
|
79
|
+
const detailBudget = Math.max(0, Math.min(details.length, height - lines.length - footer.length - 2));
|
|
80
|
+
const visibleDetails = details.slice(0, detailBudget);
|
|
81
|
+
this.pageRows = Math.max(1, Math.min(PAGE_SIZE, height - lines.length - footer.length - visibleDetails.length - 1));
|
|
82
|
+
const start = Math.max(0, Math.min(this.cursor - Math.floor(this.pageRows / 2), this.filtered.length - this.pageRows));
|
|
83
|
+
const visible = this.filtered.slice(start, start + this.pageRows);
|
|
84
|
+
if (!visible.length) lines.push(dim(this.search.getValue() ? "No matches. Clear or change the search." : "No choices available."));
|
|
85
|
+
for (const [index, choice] of visible.entries()) {
|
|
86
|
+
const selected = start + index === this.cursor;
|
|
87
|
+
const label = truncateToWidth(choice.label, Math.max(0, width - 2), "…");
|
|
88
|
+
lines.push(selected ? theme.fg("accent", "› ") + theme.underline(theme.bold(label)) : " " + label);
|
|
99
89
|
}
|
|
100
|
-
lines.push(dim("
|
|
101
|
-
|
|
90
|
+
if (item) lines.push(dim((this.cursor + 1) + "/" + this.filtered.length + " matches"));
|
|
91
|
+
lines.push(...visibleDetails, ...footer);
|
|
92
|
+
return lines.map((line) => truncateToWidth(line, width, "…"));
|
|
102
93
|
}
|
|
103
94
|
|
|
104
95
|
handleInput(data: string): void {
|
|
@@ -109,9 +100,9 @@ class Picker implements Component, Focusable {
|
|
|
109
100
|
} else if (kb.matches(data, "tui.select.down")) {
|
|
110
101
|
if (count) this.cursor = (this.cursor + 1) % count;
|
|
111
102
|
} else if (kb.matches(data, "tui.select.pageUp")) {
|
|
112
|
-
this.cursor = Math.max(0, this.cursor - this.
|
|
103
|
+
this.cursor = Math.max(0, this.cursor - this.pageRows);
|
|
113
104
|
} else if (kb.matches(data, "tui.select.pageDown")) {
|
|
114
|
-
this.cursor = Math.max(0, Math.min(count - 1, this.cursor + this.
|
|
105
|
+
this.cursor = Math.max(0, Math.min(count - 1, this.cursor + this.pageRows));
|
|
115
106
|
} else if (kb.matches(data, "tui.select.confirm")) {
|
|
116
107
|
const item = this.filtered[this.cursor];
|
|
117
108
|
if (item) this.done(item.value);
|
|
@@ -124,8 +115,7 @@ class Picker implements Component, Focusable {
|
|
|
124
115
|
this.search.handleInput(data);
|
|
125
116
|
if (before !== this.search.getValue()) {
|
|
126
117
|
const query = this.search.getValue().trim();
|
|
127
|
-
this.filtered = query ? fuzzyFilter(this.items, query,
|
|
128
|
-
(item) => [item.value, item.label, item.description].join(" ")) : this.items;
|
|
118
|
+
this.filtered = query ? fuzzyFilter(this.items, query, (item) => [item.value, item.label, item.description].join(" ")) : this.items;
|
|
129
119
|
this.cursor = 0;
|
|
130
120
|
}
|
|
131
121
|
}
|
|
@@ -137,11 +127,7 @@ class Picker implements Component, Focusable {
|
|
|
137
127
|
|
|
138
128
|
/** Single-select with fuzzy search and paging. Esc returns without a change. */
|
|
139
129
|
export function promptSelectOne(
|
|
140
|
-
ctx: PickerContext,
|
|
141
|
-
title: string,
|
|
142
|
-
hint: string,
|
|
143
|
-
items: SelectItem[],
|
|
144
|
-
initialValue?: string,
|
|
130
|
+
ctx: PickerContext, title: string, hint: string, items: SelectItem[], initialValue?: string,
|
|
145
131
|
): Promise<string | undefined> {
|
|
146
132
|
if (ctx.mode !== "tui") {
|
|
147
133
|
ctx.ui.notify("/subagents-setup requires Pi's interactive TUI.", "error");
|
|
@@ -151,37 +137,29 @@ export function promptSelectOne(
|
|
|
151
137
|
new Picker(items, { title, hint, initialValue }, tui, theme, keybindings, done));
|
|
152
138
|
}
|
|
153
139
|
|
|
154
|
-
/** One role per row, with Model, Thinking and Reset side by side: the whole
|
|
155
|
-
* configuration is visible at once, so a model choice and its clamped thinking
|
|
156
|
-
* level are compared in place instead of through nested screens. */
|
|
157
140
|
export interface RoleGridRow {
|
|
158
141
|
role: string;
|
|
159
142
|
model: string;
|
|
143
|
+
/** Effective level, optionally followed by the requested level when clamped. */
|
|
160
144
|
thinking: string;
|
|
161
|
-
/** Whether the thinking level is a user override (shown with a marker). */
|
|
162
145
|
thinkingOverridden?: boolean;
|
|
163
|
-
/** Why this row matters; shown for the focused row only. */
|
|
164
146
|
description: string;
|
|
165
147
|
}
|
|
166
|
-
|
|
167
|
-
export interface RoleGridFocus {
|
|
168
|
-
row?: number;
|
|
169
|
-
column?: number;
|
|
170
|
-
}
|
|
171
|
-
|
|
148
|
+
export interface RoleGridFocus { row?: number; column?: number; }
|
|
172
149
|
const GRID_COLUMNS = ["model", "thinking", "reset"] as const;
|
|
173
150
|
export type RoleGridColumn = (typeof GRID_COLUMNS)[number];
|
|
151
|
+
export interface RoleGridChoice { row: number; column: number; role: string; field: RoleGridColumn; }
|
|
174
152
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
column: number;
|
|
178
|
-
role: string;
|
|
179
|
-
field: RoleGridColumn;
|
|
180
|
-
}
|
|
181
|
-
|
|
153
|
+
/** A role register beside the selected role's settings; narrow terminals stack
|
|
154
|
+
* the same regions. Full effective values are never squeezed into grid cells. */
|
|
182
155
|
class RoleGrid implements Component {
|
|
183
156
|
private row: number;
|
|
184
157
|
private column: number;
|
|
158
|
+
private scrollTop = 0;
|
|
159
|
+
private pageRows = 1;
|
|
160
|
+
private viewport = "";
|
|
161
|
+
private revealField = true;
|
|
162
|
+
|
|
185
163
|
private readonly rows: RoleGridRow[];
|
|
186
164
|
private readonly status: string;
|
|
187
165
|
private readonly tui: TUI;
|
|
@@ -190,13 +168,8 @@ class RoleGrid implements Component {
|
|
|
190
168
|
private readonly done: (choice: RoleGridChoice | undefined) => void;
|
|
191
169
|
|
|
192
170
|
constructor(
|
|
193
|
-
rows: RoleGridRow[],
|
|
194
|
-
|
|
195
|
-
focus: RoleGridFocus,
|
|
196
|
-
tui: TUI,
|
|
197
|
-
theme: Theme,
|
|
198
|
-
keybindings: KeybindingsManager,
|
|
199
|
-
done: (choice: RoleGridChoice | undefined) => void,
|
|
171
|
+
rows: RoleGridRow[], status: string, focus: RoleGridFocus, tui: TUI, theme: Theme,
|
|
172
|
+
keybindings: KeybindingsManager, done: (choice: RoleGridChoice | undefined) => void,
|
|
200
173
|
) {
|
|
201
174
|
this.rows = rows;
|
|
202
175
|
this.status = status;
|
|
@@ -208,56 +181,99 @@ class RoleGrid implements Component {
|
|
|
208
181
|
this.column = Math.min(Math.max(0, focus.column ?? 0), GRID_COLUMNS.length - 1);
|
|
209
182
|
}
|
|
210
183
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
const
|
|
221
|
-
|
|
184
|
+
private settings(width: number): { lines: string[]; start: number; end: number } {
|
|
185
|
+
const focused = this.rows[this.row];
|
|
186
|
+
if (!focused) return { lines: [this.theme.fg("dim", "No roles configured.")], start: 0, end: 1 };
|
|
187
|
+
const theme = this.theme;
|
|
188
|
+
const dim = (text: string) => theme.fg("dim", text);
|
|
189
|
+
const field = GRID_COLUMNS[this.column]!;
|
|
190
|
+
const label = field === "thinking" ? "Thinking (reasoning effort)" : field === "reset" ? "Reset" : "Model";
|
|
191
|
+
const lines = [theme.bold(focused.role + " · " + label), ""];
|
|
192
|
+
const starts: number[] = [];
|
|
193
|
+
const setting = (column: number, name: string, hint: string): void => {
|
|
194
|
+
starts.push(lines.length);
|
|
195
|
+
const active = this.column === column;
|
|
196
|
+
lines.push((active ? theme.fg("accent", "› ") : " ") + (active ? theme.underline(theme.bold(name)) : name) + dim(" · " + hint));
|
|
197
|
+
};
|
|
198
|
+
const value = (text: string): void => {
|
|
199
|
+
lines.push(...wrapTextWithAnsi(text, Math.max(1, width - 2)).map((line) => " " + line));
|
|
200
|
+
};
|
|
201
|
+
setting(0, "Model", "Enter edit");
|
|
202
|
+
value(focused.model);
|
|
203
|
+
setting(1, "Thinking", "effective");
|
|
204
|
+
value(focused.thinking);
|
|
205
|
+
lines.push(dim(" Source: " + (focused.thinkingOverridden ? "override *" : "role default")));
|
|
206
|
+
setting(2, "Reset", "Enter restore defaults");
|
|
207
|
+
const end = lines.length;
|
|
208
|
+
lines.push("", ...wrapTextWithAnsi(focused.description, width).map(dim));
|
|
209
|
+
return { lines, start: starts[this.column]!, end: starts[this.column + 1] ?? end };
|
|
222
210
|
}
|
|
223
211
|
|
|
224
212
|
render(width: number): string[] {
|
|
225
|
-
if (width <= 0) return [
|
|
213
|
+
if (width <= 0) return [];
|
|
226
214
|
const theme = this.theme;
|
|
227
215
|
const dim = (text: string) => theme.fg("dim", text);
|
|
228
|
-
const [
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
const header = ["Role", "Model", "Thinking", ""]
|
|
236
|
-
.map((title, index) => cell(title, [roleWidth, modelWidth, thinkingWidth, resetWidth][index]!, false))
|
|
237
|
-
.join(" ");
|
|
238
|
-
lines.push(" " + dim(header));
|
|
239
|
-
for (const [index, row] of this.rows.entries()) {
|
|
216
|
+
const lines = [theme.bold("Subagents · Roles"), dim(this.status), ""];
|
|
217
|
+
const height = setupHeight(this.tui);
|
|
218
|
+
const wide = width >= 88;
|
|
219
|
+
// The two panes close exactly: roleWidth + 3-column gutter + detailWidth = width.
|
|
220
|
+
const roleWidth = wide ? Math.min(24, Math.floor(width * 0.24)) : width;
|
|
221
|
+
const roles: string[] = [];
|
|
222
|
+
for (const [index, role] of this.rows.entries()) {
|
|
240
223
|
const selected = index === this.row;
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
|
|
224
|
+
const name = selected ? theme.bold(role.role) : role.role;
|
|
225
|
+
roles.push((selected ? "› " : " ") + name);
|
|
226
|
+
if (wide) roles.push(dim(" " + truncateToWidth(role.model, roleWidth - 2, "…")));
|
|
244
227
|
}
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
228
|
+
const details = this.settings(wide ? width - roleWidth - 3 : width);
|
|
229
|
+
const detailOffset = wide ? 0 : roles.length + 1;
|
|
230
|
+
const body: string[] = [];
|
|
231
|
+
if (wide) {
|
|
232
|
+
for (let i = 0; i < Math.max(roles.length, details.lines.length); i++) {
|
|
233
|
+
const left = truncateToWidth(roles[i] ?? "", roleWidth, "…");
|
|
234
|
+
body.push(left + " ".repeat(roleWidth - visibleWidth(left) + 3) + (details.lines[i] ?? ""));
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
body.push(...roles, "", ...details.lines);
|
|
252
238
|
}
|
|
253
|
-
|
|
254
|
-
|
|
239
|
+
const footer = [dim("↑/↓ role · ←/→ field"), dim("Enter edit · Esc close")];
|
|
240
|
+
if (lines.length + body.length + footer.length + 1 <= height) {
|
|
241
|
+
this.scrollTop = 0;
|
|
242
|
+
this.revealField = true;
|
|
243
|
+
return [...lines, ...body, "", ...footer].map((line) => truncateToWidth(line, width, "…"));
|
|
244
|
+
}
|
|
245
|
+
// Pin the selected identity while scrolling the existing pane content.
|
|
246
|
+
// The field's complete value and provenance remain reachable by paging.
|
|
247
|
+
const compact = height < 8;
|
|
248
|
+
const header = compact ? [details.lines[0]!] : [...lines.slice(0, 2), details.lines[0]!];
|
|
249
|
+
const controls = compact ? [dim("PgUp/Dn scroll · Enter edit · Esc")]
|
|
250
|
+
: [footer[0]!, dim("PgUp/Dn scroll · Enter edit · Esc")];
|
|
251
|
+
this.pageRows = Math.max(1, height - header.length - controls.length);
|
|
252
|
+
const viewport = width + ":" + this.pageRows;
|
|
253
|
+
if (this.revealField || this.viewport !== viewport) {
|
|
254
|
+
const start = detailOffset + details.start;
|
|
255
|
+
const end = detailOffset + details.end;
|
|
256
|
+
// One-line viewports show the value rather than repeating its label.
|
|
257
|
+
this.scrollTop = end - start > this.pageRows ? start + Number(this.pageRows === 1 && end > start + 1)
|
|
258
|
+
: Math.max(0, end - this.pageRows);
|
|
259
|
+
}
|
|
260
|
+
this.viewport = viewport;
|
|
261
|
+
this.revealField = false;
|
|
262
|
+
this.scrollTop = Math.max(0, Math.min(this.scrollTop, body.length - this.pageRows));
|
|
263
|
+
return [...header, ...body.slice(this.scrollTop, this.scrollTop + this.pageRows), ...controls]
|
|
264
|
+
.map((line) => truncateToWidth(line, width, "…"));
|
|
255
265
|
}
|
|
256
266
|
|
|
257
267
|
handleInput(data: string): void {
|
|
258
268
|
const kb = this.keybindings;
|
|
259
269
|
const rows = this.rows.length;
|
|
260
|
-
|
|
270
|
+
const previousRow = this.row;
|
|
271
|
+
const previousColumn = this.column;
|
|
272
|
+
if (kb.matches(data, "tui.select.pageUp")) {
|
|
273
|
+
this.scrollTop -= this.pageRows;
|
|
274
|
+
} else if (kb.matches(data, "tui.select.pageDown")) {
|
|
275
|
+
this.scrollTop += this.pageRows;
|
|
276
|
+
} else if (kb.matches(data, "tui.select.up")) {
|
|
261
277
|
if (rows) this.row = (this.row - 1 + rows) % rows;
|
|
262
278
|
} else if (kb.matches(data, "tui.select.down")) {
|
|
263
279
|
if (rows) this.row = (this.row + 1) % rows;
|
|
@@ -274,21 +290,17 @@ class RoleGrid implements Component {
|
|
|
274
290
|
} else if (kb.matches(data, "tui.select.cancel")) {
|
|
275
291
|
this.done(undefined);
|
|
276
292
|
return;
|
|
277
|
-
} else
|
|
278
|
-
|
|
279
|
-
}
|
|
293
|
+
} else return;
|
|
294
|
+
if (this.row !== previousRow || this.column !== previousColumn) this.revealField = true;
|
|
280
295
|
this.tui.requestRender();
|
|
281
296
|
}
|
|
282
297
|
|
|
283
298
|
invalidate(): void {}
|
|
284
299
|
}
|
|
285
300
|
|
|
286
|
-
/** Role × setting
|
|
301
|
+
/** Role × setting navigation. Esc closes without a change. */
|
|
287
302
|
export function promptRoleGrid(
|
|
288
|
-
ctx: PickerContext,
|
|
289
|
-
rows: RoleGridRow[],
|
|
290
|
-
focus: RoleGridFocus = {},
|
|
291
|
-
status = "Changes save immediately",
|
|
303
|
+
ctx: PickerContext, rows: RoleGridRow[], focus: RoleGridFocus = {}, status = "Changes save immediately",
|
|
292
304
|
): Promise<RoleGridChoice | undefined> {
|
|
293
305
|
if (ctx.mode !== "tui") {
|
|
294
306
|
ctx.ui.notify("/subagents-setup requires Pi's interactive TUI.", "error");
|
package/src/delegation/agents.ts
CHANGED
|
@@ -40,8 +40,7 @@ export type ToolMetadata = Pick<ToolInfo, "name" | "annotations" | "reachesTools
|
|
|
40
40
|
exposure?: ToolInfo["exposure"];
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
/** Exposures
|
|
44
|
-
* The session can call these, so a child can be given them directly. */
|
|
43
|
+
/** Exposures callable through a script or `tool_search` without activation. */
|
|
45
44
|
const INDIRECT_EXPOSURES: ReadonlySet<string> = new Set(["codemode", "deferred"]);
|
|
46
45
|
/** Live tool metadata keyed by name. Read-only and write capability come from it
|
|
47
46
|
* instead of a maintained list of extension or MCP tool names. */
|
|
@@ -66,11 +65,9 @@ function isReadOnlyToolName(name: string, index: ToolInfoIndex): boolean {
|
|
|
66
65
|
return info ? isReadOnlyTool(info) : BUILTIN_READ_ONLY_TOOL_SET.has(name);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
/** Resolve a child against the parent's
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* without being named anywhere. pi-subagents controls are always removed so
|
|
73
|
-
* children stay leaves. */
|
|
68
|
+
/** Resolve a child against the parent's active and callable indirect tools.
|
|
69
|
+
* Inactive direct tools stay excluded. Scout promotes only tools marked
|
|
70
|
+
* read-only; pi-subagents controls are removed so children stay leaves. */
|
|
74
71
|
export function resolveAgentTools(
|
|
75
72
|
agent: AgentConfig,
|
|
76
73
|
activeToolNames: readonly string[],
|
|
@@ -78,23 +75,19 @@ export function resolveAgentTools(
|
|
|
78
75
|
): AgentConfig {
|
|
79
76
|
const active = [...new Set(activeToolNames)].filter((tool) => !SUBAGENT_TOOL_NAME_SET.has(tool));
|
|
80
77
|
const toolIndex = indexToolInfos(toolInfos);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
const indirect = [...toolIndex.values()]
|
|
79
|
+
.filter((tool) => tool.exposure && INDIRECT_EXPOSURES.has(tool.exposure) && !SUBAGENT_TOOL_NAME_SET.has(tool.name))
|
|
80
|
+
.map((tool) => tool.name)
|
|
81
|
+
.filter((name) => !active.includes(name))
|
|
82
|
+
.sort();
|
|
83
|
+
if (agent.name !== "scout") return { ...agent, tools: [...active, ...indirect] };
|
|
84
|
+
// Scout uses the live catalog's read-only classification. Codemode and
|
|
85
|
+
// tool_search are excluded because they can reach tools outside that set.
|
|
86
86
|
const tools = active.filter((tool) => isReadOnlyToolName(tool, toolIndex));
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
// Declaring it is the only way to give scout an MCP server it cannot
|
|
90
|
-
// reconfigure, without also giving it a tool that reaches a writer.
|
|
87
|
+
// The child explicitly activates these after registration, without giving
|
|
88
|
+
// scout an orchestrating tool that could also reach writers.
|
|
91
89
|
if (active.some((tool) => toolIndex.get(tool)?.reachesTools)) {
|
|
92
|
-
|
|
93
|
-
.filter((tool) => typeof tool.exposure === "string" && INDIRECT_EXPOSURES.has(tool.exposure) && isReadOnlyTool(tool))
|
|
94
|
-
.map((tool) => tool.name)
|
|
95
|
-
.filter((name) => !tools.includes(name))
|
|
96
|
-
.sort();
|
|
97
|
-
tools.push(...indirect);
|
|
90
|
+
tools.push(...indirect.filter((name) => isReadOnlyToolName(name, toolIndex)));
|
|
98
91
|
}
|
|
99
92
|
return { ...agent, tools };
|
|
100
93
|
}
|