@henryqw/pi-subagent 27.10.3 → 27.10.4
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 -0
- package/extensions/subagent-command.ts +40 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,6 +163,8 @@ The extension sends follow-ups when a candidate becomes ready, a worker needs at
|
|
|
163
163
|
|
|
164
164
|
Open `/subagent` to browse direct work on this session branch and isolated requests in the current canonical Git checkout, including other sessions. The menu groups rows under **Direct**, **Isolated**, and **Orphaned** headers. Each isolated row shows the request ID, the status, and a short goal summary. **Refresh** or a header reloads saved status without recovery or mutation. Invalid state IDs stay preserved with a warning. Direct recovery remains available outside Git or without isolated inventory.
|
|
165
165
|
|
|
166
|
+
In the terminal, use the Up and Down arrow keys to scroll through menu rows. Enter selects a row; Escape cancels the menu. The list fits the terminal height and keeps the current row visible when you resize the terminal. The menu shows your configured selection keys. In multiple-choice menus, the menu keeps the current row in view after you mark or clear it. Scroll to **Select all**, **Clear**, **Continue**, or **Cancel** below the work rows.
|
|
167
|
+
|
|
166
168
|
Before the menu opens, and after each **Refresh**, a **Current subagent work** report shows which subagents are working. The extension calculates it from local and saved evidence without a model call. Without interactive UI, `/subagent` sends this report before the request list.
|
|
167
169
|
|
|
168
170
|
A direct workflow is working only when this Pi process owns it and has a running worker. Direct work with a delivered result shows its outcome under **Completed / history** and is not in the report. Other recorded-only direct work shows as unverified. An isolated request is working only when its status is active and a live run holds the repository lease. Without a live lease, an active request shows as interrupted; run `/subagent recover`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getMarkdownTheme, type ExtensionAPI, type ExtensionContext, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Box, Markdown, Spacer, Text } from "@earendil-works/pi-tui";
|
|
1
|
+
import { getMarkdownTheme, getSelectListTheme, keyHint, keyText, type ExtensionAPI, type ExtensionContext, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Box, Markdown, SelectList, Spacer, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
import type { DiscardPlan } from "../dist/discard.js";
|
|
4
4
|
import type { PruneItem } from "../dist/prune.js";
|
|
5
5
|
import { TERMINAL_RUN_STATUSES } from "../dist/schema.js";
|
|
@@ -331,28 +331,59 @@ export function workingReport(direct: readonly DirectTask[], inventory: Isolated
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
type Choice<T> = { label: string; value: T };
|
|
334
|
-
async function choose<T>(ctx: ExtensionContext, title: string, items: readonly Choice<T>[]): Promise<T | undefined> {
|
|
334
|
+
async function choose<T>(ctx: ExtensionContext, title: string, items: readonly Choice<T>[], selectedIndex = 0): Promise<T | undefined> {
|
|
335
335
|
// Numeric suffixes only tell duplicate labels apart. Never parse display text into an identity.
|
|
336
336
|
const clipped = items.map((item) => clean(item.label, 145));
|
|
337
337
|
const labels = clipped.map((label, index) => clipped.indexOf(label) === clipped.lastIndexOf(label) ? label : `${label} [${index + 1}]`);
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
if (ctx.mode !== "tui") {
|
|
339
|
+
const selected = await ctx.ui.select(title, labels);
|
|
340
|
+
const index = labels.indexOf(selected ?? "");
|
|
341
|
+
return index < 0 ? undefined : items[index]!.value;
|
|
342
|
+
}
|
|
343
|
+
return ctx.ui.custom<T | undefined>((tui, theme, _keys, done) => {
|
|
344
|
+
const rows = labels.map((label, index) => ({ label, value: String(index) }));
|
|
345
|
+
const createList = () => {
|
|
346
|
+
// Reserve title, key hints, and the native scroll indicator. Very short terminals show only the list.
|
|
347
|
+
const height = tui.terminal.rows;
|
|
348
|
+
const list = new SelectList(rows, Math.max(1, height - (height >= 4 ? 3 : 1)), getSelectListTheme());
|
|
349
|
+
list.setSelectedIndex(selectedIndex);
|
|
350
|
+
list.onSelectionChange = ({ value }) => { selectedIndex = Number(value); };
|
|
351
|
+
list.onSelect = ({ value }) => done(items[Number(value)]!.value);
|
|
352
|
+
list.onCancel = () => done(undefined);
|
|
353
|
+
return list;
|
|
354
|
+
};
|
|
355
|
+
let list = createList();
|
|
356
|
+
return {
|
|
357
|
+
render(width) {
|
|
358
|
+
list = createList();
|
|
359
|
+
const lines = list.render(width);
|
|
360
|
+
if (tui.terminal.rows < 4) return lines.slice(0, tui.terminal.rows);
|
|
361
|
+
return [truncateToWidth(theme.fg("accent", title), width), ...lines,
|
|
362
|
+
truncateToWidth([`${keyText("tui.select.up")}/${keyText("tui.select.down")} scroll`,
|
|
363
|
+
keyHint("tui.select.confirm", "select"), keyHint("tui.select.cancel", "cancel")].join(" · "), width)];
|
|
364
|
+
},
|
|
365
|
+
handleInput(data) { list.handleInput(data); tui.requestRender(); },
|
|
366
|
+
invalidate() { list.invalidate(); },
|
|
367
|
+
};
|
|
368
|
+
}, { overlay: true, overlayOptions: { width: "100%", maxHeight: "100%", margin: 0 } });
|
|
341
369
|
}
|
|
342
370
|
|
|
343
|
-
/** Multi-select on single-choice
|
|
371
|
+
/** Multi-select on single-choice menus: each pick toggles one row until Continue. Returns chosen values in
|
|
344
372
|
* item order, or undefined on Cancel or a changed session. Only selectable rows are offered. */
|
|
345
373
|
async function chooseMany<T>(ctx: ExtensionContext, title: string, items: readonly Choice<T>[], preselected: readonly T[],
|
|
346
374
|
valid: () => boolean): Promise<T[] | undefined> {
|
|
347
375
|
type Pick = { kind: "toggle"; value: T } | { kind: "all" } | { kind: "clear" } | { kind: "continue" } | { kind: "cancel" };
|
|
348
376
|
const chosen = new Set(preselected);
|
|
377
|
+
let selectedIndex = 0;
|
|
349
378
|
for (;;) {
|
|
350
|
-
const
|
|
379
|
+
const choices: Choice<Pick>[] = [
|
|
351
380
|
...items.map((item) => ({ label: `${chosen.has(item.value) ? "[x]" : "[ ]"} ${item.label}`, value: { kind: "toggle" as const, value: item.value } })),
|
|
352
381
|
{ label: "Select all", value: { kind: "all" } }, { label: "Clear", value: { kind: "clear" } },
|
|
353
382
|
{ label: `Continue (${chosen.size} selected)`, value: { kind: "continue" } }, { label: "Cancel", value: { kind: "cancel" } },
|
|
354
|
-
]
|
|
383
|
+
];
|
|
384
|
+
const picked = await choose(ctx, title, choices, selectedIndex);
|
|
355
385
|
if (!valid() || !picked || picked.kind === "cancel") return undefined;
|
|
386
|
+
selectedIndex = choices.findIndex(({ value }) => value === picked);
|
|
356
387
|
if (picked.kind === "continue") return items.map(({ value }) => value).filter((value) => chosen.has(value));
|
|
357
388
|
if (picked.kind === "all") for (const { value } of items) chosen.add(value);
|
|
358
389
|
else if (picked.kind === "clear") chosen.clear();
|