@henryqw/pi-subagent 27.10.2 → 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/dist/direct-herdr.d.ts +0 -5
- package/dist/direct-herdr.js +0 -15
- package/dist/git-runtime.d.ts +2 -2
- package/dist/runner.d.ts +6 -8
- 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`.
|
package/dist/direct-herdr.d.ts
CHANGED
|
@@ -39,11 +39,6 @@ export interface DirectToolActivity {
|
|
|
39
39
|
durationMs?: number;
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
export declare function directSessionUsage(jsonl: string, prompt: string): DirectUsage & {
|
|
43
|
-
activity?: DirectToolActivity;
|
|
44
|
-
};
|
|
45
|
-
/** The last `maxChars` of assistant text in the exact prompt's turn; ignores a partial trailing entry. */
|
|
46
|
-
export declare function directPartialText(jsonl: string, prompt: string, maxChars: number): string | undefined;
|
|
47
42
|
/** One reader per handle; only complete, valid lines advance the byte offset. */
|
|
48
43
|
export declare function createDirectSessionReader(sessionFile: string, prompt: string): Pick<DirectHandle, "usage" | "partialText" | "activity">;
|
|
49
44
|
/** `turn` is the prompt's random turn identity; it proves which session turn a record owns.
|
package/dist/direct-herdr.js
CHANGED
|
@@ -216,21 +216,6 @@ class DirectSessionState {
|
|
|
216
216
|
return chars.length <= maxChars ? chars.join("") : `…${chars.slice(-maxChars).join("")}`;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
function parseDirectSession(jsonl, prompt) {
|
|
220
|
-
const state = new DirectSessionState(prompt);
|
|
221
|
-
for (const line of jsonl.split("\n"))
|
|
222
|
-
if (!state.consume(line))
|
|
223
|
-
break;
|
|
224
|
-
return state;
|
|
225
|
-
}
|
|
226
|
-
// Ignore a partial trailing JSONL entry while the child is writing it.
|
|
227
|
-
export function directSessionUsage(jsonl, prompt) {
|
|
228
|
-
return parseDirectSession(jsonl, prompt).usage();
|
|
229
|
-
}
|
|
230
|
-
/** The last `maxChars` of assistant text in the exact prompt's turn; ignores a partial trailing entry. */
|
|
231
|
-
export function directPartialText(jsonl, prompt, maxChars) {
|
|
232
|
-
return parseDirectSession(jsonl, prompt).partialText(maxChars);
|
|
233
|
-
}
|
|
234
219
|
/** One reader per handle; only complete, valid lines advance the byte offset. */
|
|
235
220
|
export function createDirectSessionReader(sessionFile, prompt) {
|
|
236
221
|
let offset = 0;
|
package/dist/git-runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CheckCommand, type ReviewEvidence, type TaskAttempt, type TaskRequest, type WorktreeAllocationIntent, type WorktreeAllocationPlan, type WorkspaceIdentity } from "./schema.ts";
|
|
2
|
-
import { type AllocationReconciliation, type CheckRunResult, type GitRuntime, type InFlightTaskCandidateInspection, type InFlightTaskCandidateInspector, type
|
|
2
|
+
import { type AllocationReconciliation, type CheckRunResult, type GitRuntime, type InFlightTaskCandidateInspection, type InFlightTaskCandidateInspector, type OperationContext, type ReviewResult, type TransientLaunchHandle, type WorktreeAllocationResult, type VerifiedLaunch } from "./runner.ts";
|
|
3
3
|
type ProcessResult = {
|
|
4
4
|
code: number;
|
|
5
5
|
killed: boolean;
|
|
@@ -33,7 +33,7 @@ export interface CheckedGitRuntimeOptions {
|
|
|
33
33
|
runProcess?: DirectProcessRunner;
|
|
34
34
|
executeReview?: ExactReviewExecutor;
|
|
35
35
|
}
|
|
36
|
-
export declare class CheckedGitRuntime implements GitRuntime,
|
|
36
|
+
export declare class CheckedGitRuntime implements GitRuntime, InFlightTaskCandidateInspector {
|
|
37
37
|
private readonly execute;
|
|
38
38
|
private readonly executeReview?;
|
|
39
39
|
private readonly mainOperationTails;
|
package/dist/runner.d.ts
CHANGED
|
@@ -199,13 +199,6 @@ export interface HostRuntime {
|
|
|
199
199
|
failure: string;
|
|
200
200
|
}>;
|
|
201
201
|
}
|
|
202
|
-
export interface TaskCandidateInspector {
|
|
203
|
-
inspectTaskCandidate(input: {
|
|
204
|
-
root: string;
|
|
205
|
-
task: TaskRequest;
|
|
206
|
-
attempt: TaskAttempt;
|
|
207
|
-
}, context: OperationContext): Promise<WorkspaceIdentity>;
|
|
208
|
-
}
|
|
209
202
|
export interface InFlightTaskCandidateInspection {
|
|
210
203
|
candidate: WorkspaceIdentity;
|
|
211
204
|
clean: boolean;
|
|
@@ -219,6 +212,11 @@ export interface InFlightTaskCandidateInspector {
|
|
|
219
212
|
}, context: OperationContext): Promise<InFlightTaskCandidateInspection>;
|
|
220
213
|
}
|
|
221
214
|
export interface GitRuntime {
|
|
215
|
+
inspectTaskCandidate(input: {
|
|
216
|
+
root: string;
|
|
217
|
+
task: TaskRequest;
|
|
218
|
+
attempt: TaskAttempt;
|
|
219
|
+
}, context: OperationContext): Promise<WorkspaceIdentity>;
|
|
222
220
|
inspectMain(input: {
|
|
223
221
|
root: string;
|
|
224
222
|
}, context: OperationContext): Promise<WorkspaceIdentity>;
|
|
@@ -315,7 +313,7 @@ export declare class IsolatedRunner {
|
|
|
315
313
|
private readonly currentPolicy;
|
|
316
314
|
private readonly productiveLifecycles;
|
|
317
315
|
private readonly followupControls;
|
|
318
|
-
constructor(coordinatorRuntime: CoordinatorRuntime, hostRuntime: HostRuntime, gitRuntime: GitRuntime
|
|
316
|
+
constructor(coordinatorRuntime: CoordinatorRuntime, hostRuntime: HostRuntime, gitRuntime: GitRuntime, store: FileRunStore | undefined, textExecutor: EphemeralSubagentExecutor, policy?: ExecutionPolicySnapshot, currentPolicy?: () => ExecutionPolicySnapshot, integrationGit?: IntegrationGit);
|
|
319
317
|
listRequests(root: string): Promise<{
|
|
320
318
|
requests: Array<{
|
|
321
319
|
id: string;
|
|
@@ -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();
|