@herbertgao/pi-extensions 2026.11.9 → 2026.11.10
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 +10 -0
- package/README.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +8 -6
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +8 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +12 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +36 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +4 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +7 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +115 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +47 -15
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/startup-header.ts +3 -18
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +27 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +6 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/markdown-enhance.ts +30 -17
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +4 -21
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +3 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/transcript-mode.ts +34 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/ansi-text.ts +25 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/keybindings.ts +75 -0
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +26 -17
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +1 -1
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +71 -8
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +83 -34
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +18 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +10 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-tree.ts +47 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +7 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +211 -47
- package/package.json +3 -3
|
@@ -37,6 +37,13 @@ export interface SubagentsSettings {
|
|
|
37
37
|
* several blocking resumes in one message can still exceed the limit.
|
|
38
38
|
*/
|
|
39
39
|
maxConcurrentForeground?: number
|
|
40
|
+
/**
|
|
41
|
+
* Cap on running nested children (outside workflows) — `0` = unlimited,
|
|
42
|
+
* default 10. A nested spawn over it is refused, not queued, and the parent
|
|
43
|
+
* is told to do the work itself (#352). Top-level and workflow agents neither
|
|
44
|
+
* count nor are refused.
|
|
45
|
+
*/
|
|
46
|
+
maxConcurrentNested?: number
|
|
40
47
|
/**
|
|
41
48
|
* 0 = unlimited — the extension's single source of truth for that convention:
|
|
42
49
|
* `normalizeMaxTurns()` in agent-runner.ts treats 0 → `undefined`, and the
|
|
@@ -351,6 +358,7 @@ export type ToolDescriptionMode = "full" | "compact" | "custom"
|
|
|
351
358
|
export interface SettingsAppliers {
|
|
352
359
|
setMaxConcurrent: (n: number) => void
|
|
353
360
|
setMaxConcurrentForeground: (n: number) => void
|
|
361
|
+
setMaxConcurrentNested: (n: number) => void
|
|
354
362
|
setDefaultMaxTurns: (n: number) => void
|
|
355
363
|
setGraceTurns: (n: number) => void
|
|
356
364
|
setDefaultJoinMode: (mode: JoinMode) => void
|
|
@@ -448,6 +456,14 @@ function sanitize(raw: unknown): SubagentsSettings {
|
|
|
448
456
|
) {
|
|
449
457
|
out.maxConcurrentForeground = r.maxConcurrentForeground as number
|
|
450
458
|
}
|
|
459
|
+
// Floor 0 for the same reason: 0 is the documented "unlimited".
|
|
460
|
+
if (
|
|
461
|
+
Number.isInteger(r.maxConcurrentNested) &&
|
|
462
|
+
(r.maxConcurrentNested as number) >= 0 &&
|
|
463
|
+
(r.maxConcurrentNested as number) <= MAX_CONCURRENT_CEILING
|
|
464
|
+
) {
|
|
465
|
+
out.maxConcurrentNested = r.maxConcurrentNested as number
|
|
466
|
+
}
|
|
451
467
|
if (
|
|
452
468
|
Number.isInteger(r.defaultMaxTurns) &&
|
|
453
469
|
(r.defaultMaxTurns as number) >= 0 &&
|
|
@@ -625,6 +641,8 @@ export function applySettings(
|
|
|
625
641
|
if (typeof s.maxConcurrentForeground === "number") {
|
|
626
642
|
appliers.setMaxConcurrentForeground(s.maxConcurrentForeground)
|
|
627
643
|
}
|
|
644
|
+
if (typeof s.maxConcurrentNested === "number")
|
|
645
|
+
appliers.setMaxConcurrentNested(s.maxConcurrentNested)
|
|
628
646
|
if (typeof s.defaultMaxTurns === "number")
|
|
629
647
|
appliers.setDefaultMaxTurns(s.defaultMaxTurns)
|
|
630
648
|
if (typeof s.graceTurns === "number") appliers.setGraceTurns(s.graceTurns)
|
|
@@ -265,8 +265,18 @@ export interface AgentRecord {
|
|
|
265
265
|
* Lifetime usage breakdown, accumulated via `message_end` events. Survives
|
|
266
266
|
* compaction. Total = input + output + cacheWrite (cacheRead deliberately
|
|
267
267
|
* excluded — see issue #38). Initialized to zeros at spawn.
|
|
268
|
+
*
|
|
269
|
+
* Includes every descendant's spend: `nested-tools.ts` folds a nested
|
|
270
|
+
* child's turns into all its ancestors, because the child itself is hidden
|
|
271
|
+
* from the surfaces that read this field.
|
|
268
272
|
*/
|
|
269
273
|
lifetimeUsage: LifetimeUsage
|
|
274
|
+
/**
|
|
275
|
+
* This agent's own turns only — `lifetimeUsage` minus its descendants. What
|
|
276
|
+
* the fleet list shows, since it gives nested children rows of their own and
|
|
277
|
+
* the rolled-up figure would count their spend twice.
|
|
278
|
+
*/
|
|
279
|
+
ownUsage: LifetimeUsage
|
|
270
280
|
/** Number of times this agent's session has compacted. Initialized to 0 at spawn. */
|
|
271
281
|
compactionCount: number
|
|
272
282
|
/**
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent-tree.ts — Nested subagents laid out under their parent.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the two surfaces that list nested children — FleetView and
|
|
5
|
+
* `/agents → Running agents` — so both draw the same tree. Every other
|
|
6
|
+
* user-facing surface filters on `isTopLevelAgent`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { AgentRecord } from "../types.js"
|
|
10
|
+
|
|
11
|
+
export interface AgentTreeRow {
|
|
12
|
+
record: AgentRecord
|
|
13
|
+
/** Tree glyphs before the row (`├ `, `└ `, `│ ` continuation); `""` at top level. */
|
|
14
|
+
prefix: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* `records` as a tree: each top-level record in the order given, then its
|
|
19
|
+
* children depth-first under it, siblings earliest-launched first. A child
|
|
20
|
+
* whose parent is not in `records` is dropped — it has no row to hang from.
|
|
21
|
+
*/
|
|
22
|
+
export function agentTree(records: readonly AgentRecord[]): AgentTreeRow[] {
|
|
23
|
+
const children = new Map<string, AgentRecord[]>()
|
|
24
|
+
for (const record of records) {
|
|
25
|
+
if (record.parentAgentId === undefined) continue
|
|
26
|
+
const siblings = children.get(record.parentAgentId)
|
|
27
|
+
if (siblings) siblings.push(record)
|
|
28
|
+
else children.set(record.parentAgentId, [record])
|
|
29
|
+
}
|
|
30
|
+
for (const siblings of children.values())
|
|
31
|
+
siblings.sort((a, b) => a.startedAt - b.startedAt)
|
|
32
|
+
|
|
33
|
+
const rows: AgentTreeRow[] = []
|
|
34
|
+
// `indent` is what a child's own children continue with: a rail under a
|
|
35
|
+
// `├`, blank under the last sibling's `└`.
|
|
36
|
+
const visit = (record: AgentRecord, prefix: string, indent: string): void => {
|
|
37
|
+
rows.push({ record, prefix })
|
|
38
|
+
const kids = children.get(record.id) ?? []
|
|
39
|
+
kids.forEach((kid, i) => {
|
|
40
|
+
const last = i === kids.length - 1
|
|
41
|
+
visit(kid, indent + (last ? "└ " : "├ "), indent + (last ? " " : "│ "))
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
for (const record of records)
|
|
45
|
+
if (record.parentAgentId === undefined) visit(record, "", "")
|
|
46
|
+
return rows
|
|
47
|
+
}
|
|
@@ -235,6 +235,7 @@ export function getPromptModeLabel(type: SubagentType): string | undefined {
|
|
|
235
235
|
export function buildInvocationTags(invocation: AgentInvocation | undefined): {
|
|
236
236
|
modelName?: string
|
|
237
237
|
modelId?: string
|
|
238
|
+
thinking?: string
|
|
238
239
|
tags: string[]
|
|
239
240
|
} {
|
|
240
241
|
const tags: string[] = []
|
|
@@ -257,6 +258,7 @@ export function buildInvocationTags(invocation: AgentInvocation | undefined): {
|
|
|
257
258
|
return {
|
|
258
259
|
modelName: asked(invocation.modelName, invocation.requestedModel),
|
|
259
260
|
modelId: asked(invocation.modelId, invocation.requestedModel),
|
|
261
|
+
thinking,
|
|
260
262
|
tags,
|
|
261
263
|
}
|
|
262
264
|
}
|
|
@@ -558,12 +560,12 @@ export class AgentWidget {
|
|
|
558
560
|
const parts: string[] = []
|
|
559
561
|
if (this.showModel()) {
|
|
560
562
|
// Leading, and paired: a thinking level means nothing without the model
|
|
561
|
-
// it applies to.
|
|
562
|
-
//
|
|
563
|
-
|
|
563
|
+
// it applies to. Both come from buildInvocationTags so the "(asked X)"
|
|
564
|
+
// annotation survives. The level is bare, not "thinking: high", as on
|
|
565
|
+
// the fleet row; the tag list keeps the label for the viewer and tool result.
|
|
566
|
+
const { modelName, thinking } = buildInvocationTags(a.invocation)
|
|
564
567
|
if (modelName) parts.push(modelName)
|
|
565
|
-
|
|
566
|
-
if (thinkingTag) parts.push(thinkingTag)
|
|
568
|
+
if (thinking) parts.push(thinking)
|
|
567
569
|
}
|
|
568
570
|
if (bg) parts.push(formatTurns(bg.turnCount, bg.maxTurns))
|
|
569
571
|
if (toolUses > 0)
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* fleet-list.ts — Claude Code-style "FleetView" list rendered below the editor.
|
|
3
3
|
*
|
|
4
|
-
* Shows `main` + each running/queued subagent as a navigable list
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Shows `main` + each running/queued subagent as a navigable list, nested
|
|
5
|
+
* subagents indented under their parent (`├`/`└`). Pressing ↓ (or ←) at an empty
|
|
6
|
+
* prompt activates the list; ↑/↓ move the `❯` cursor, Enter opens the selected
|
|
7
|
+
* agent's live conversation overlay, Esc returns to the prompt. `●` marks the view
|
|
8
|
+
* in front (`main`, or the open overlay's agent). In pi's fullscreen mode the mouse
|
|
9
|
+
* works too: hover moves the cursor, a click opens the row.
|
|
7
10
|
* A viewer stays open when its agent finishes; finished agents linger briefly in the list.
|
|
8
11
|
*
|
|
9
12
|
* Mechanics (see plan): the list is a `belowEditor` widget (render-only), and ALL key
|
|
@@ -16,14 +19,22 @@ import {
|
|
|
16
19
|
Key,
|
|
17
20
|
matchesKey,
|
|
18
21
|
type ScrollViewScrollbar,
|
|
22
|
+
type TuiMouseEvent,
|
|
23
|
+
type TuiMouseEventResult,
|
|
19
24
|
truncateToWidth,
|
|
20
25
|
visibleWidth,
|
|
21
26
|
} from "@earendil-works/pi-tui"
|
|
22
27
|
import { hasAgentBadge, renderAgentName } from "../agent-color.js"
|
|
23
|
-
import {
|
|
28
|
+
import type { AgentManager } from "../agent-manager.js"
|
|
24
29
|
import type { AgentRecord, ViewerMarkdownMode } from "../types.js"
|
|
25
30
|
import { getLifetimeCost, getLifetimeTotal } from "../usage.js"
|
|
26
|
-
import {
|
|
31
|
+
import { agentTree } from "./agent-tree.js"
|
|
32
|
+
import {
|
|
33
|
+
type AgentActivity,
|
|
34
|
+
buildInvocationTags,
|
|
35
|
+
formatCost,
|
|
36
|
+
type Theme,
|
|
37
|
+
} from "./agent-widget.js"
|
|
27
38
|
import {
|
|
28
39
|
ConversationViewer,
|
|
29
40
|
getConversationOverlayOptions,
|
|
@@ -52,6 +63,7 @@ export type FleetUICtx = {
|
|
|
52
63
|
render(width: number): string[]
|
|
53
64
|
invalidate(): void
|
|
54
65
|
dispose?(): void
|
|
66
|
+
handleMouse?(event: TuiMouseEvent): TuiMouseEventResult | undefined
|
|
55
67
|
}),
|
|
56
68
|
options?: { placement?: "aboveEditor" | "belowEditor" },
|
|
57
69
|
): void
|
|
@@ -100,10 +112,21 @@ export interface FleetWorkflow {
|
|
|
100
112
|
}
|
|
101
113
|
|
|
102
114
|
type MainEntry = { kind: "main" }
|
|
103
|
-
|
|
115
|
+
/** `prefix` is the tree glyphs before the dot: `""` at top level, `├ `/`└ ` (plus `│ ` continuations) below. */
|
|
116
|
+
type AgentEntry = { kind: "agent"; record: AgentRecord; prefix: string }
|
|
104
117
|
type WorkflowEntry = { kind: "workflow"; workflow: FleetWorkflow }
|
|
105
118
|
type FleetEntry = MainEntry | WorkflowEntry | AgentEntry
|
|
106
119
|
|
|
120
|
+
/** A roster row's identity across rebuilds. */
|
|
121
|
+
function entryKey(entry: FleetEntry | undefined): string | undefined {
|
|
122
|
+
if (!entry) return undefined
|
|
123
|
+
return entry.kind === "main"
|
|
124
|
+
? "main"
|
|
125
|
+
: entry.kind === "agent"
|
|
126
|
+
? `agent:${entry.record.id}`
|
|
127
|
+
: `workflow:${entry.workflow.id}`
|
|
128
|
+
}
|
|
129
|
+
|
|
107
130
|
/** `11s` — integer seconds, no decimal/suffix (matches Claude Code, unlike formatMs). */
|
|
108
131
|
export function formatFleetElapsed(ms: number): string {
|
|
109
132
|
return `${Math.max(0, Math.round(ms / 1000))}s`
|
|
@@ -143,6 +166,17 @@ export class FleetList {
|
|
|
143
166
|
private active = false
|
|
144
167
|
/** 0 = `main`, 1..N = subagents. */
|
|
145
168
|
private selectedIndex = 0
|
|
169
|
+
/** The row `selectedIndex` pointed at, and that index, as of the last `clampSelection`. */
|
|
170
|
+
private selectedKey: string | undefined
|
|
171
|
+
private selectedKeyIndex = 0
|
|
172
|
+
/**
|
|
173
|
+
* Roster index under the mouse pointer (fullscreen mode only), shown as the
|
|
174
|
+
* `❯` cursor while the keyboard is not navigating. The renderer sends no
|
|
175
|
+
* leave event, so it clears on a move over a non-row line or on any key.
|
|
176
|
+
*/
|
|
177
|
+
private hoverIndex: number | undefined
|
|
178
|
+
/** Roster index of each line the last render emitted; `undefined` for non-row lines. */
|
|
179
|
+
private lineRoster: (number | undefined)[] = []
|
|
146
180
|
/** Set while a conversation overlay is open; calling it closes the overlay. */
|
|
147
181
|
private viewerClose: (() => void) | undefined
|
|
148
182
|
private viewingAgentId: string | undefined
|
|
@@ -189,6 +223,14 @@ export class FleetList {
|
|
|
189
223
|
record: AgentRecord,
|
|
190
224
|
notify: (message: string) => void,
|
|
191
225
|
) => ViewerBackgroundAction,
|
|
226
|
+
/**
|
|
227
|
+
* Read live at render time, like `showCost`. Whether each row names the
|
|
228
|
+
* model driving the run and the thinking level it is running at. Defaults to
|
|
229
|
+
* off — the extension supplies the user's `showModel` setting — because the
|
|
230
|
+
* row is already dense and the same pair is shown unconditionally in the
|
|
231
|
+
* conversation viewer and the `Agent` tool result.
|
|
232
|
+
*/
|
|
233
|
+
private showModel: () => boolean = () => false,
|
|
192
234
|
) {}
|
|
193
235
|
|
|
194
236
|
// ---- Lifecycle ----
|
|
@@ -268,6 +310,7 @@ export class FleetList {
|
|
|
268
310
|
}
|
|
269
311
|
this.active = false
|
|
270
312
|
this.selectedIndex = 0
|
|
313
|
+
this.selectedKey = undefined
|
|
271
314
|
return
|
|
272
315
|
}
|
|
273
316
|
|
|
@@ -285,6 +328,7 @@ export class FleetList {
|
|
|
285
328
|
this.widgetRegistered = false
|
|
286
329
|
this.tui = undefined
|
|
287
330
|
},
|
|
331
|
+
handleMouse: (event: TuiMouseEvent) => this.handleMouse(event),
|
|
288
332
|
}
|
|
289
333
|
},
|
|
290
334
|
{ placement: "belowEditor" },
|
|
@@ -298,28 +342,47 @@ export class FleetList {
|
|
|
298
342
|
// ---- Roster ----
|
|
299
343
|
|
|
300
344
|
/**
|
|
301
|
-
* Agents shown in the list,
|
|
345
|
+
* Agents shown in the list, as a tree: each top-level agent, then its nested
|
|
346
|
+
* children depth-first under it, siblings earliest-launched first so the ones
|
|
302
347
|
* started sooner sit at the top. Every row is openable (has a session), so Enter
|
|
303
348
|
* never dead-ends. Included: running/queued, plus the agent currently being
|
|
304
349
|
* viewed, plus recently-finished ones (they linger briefly before dropping out).
|
|
305
350
|
* Pending agents with no session yet are hidden until they start.
|
|
306
351
|
* (`listAgents()` is newest-first, so we re-sort.)
|
|
352
|
+
*
|
|
353
|
+
* Nested children get rows of their own here (`agentTree`), as in Claude
|
|
354
|
+
* Code's FleetView, so each row shows its own usage rather than a rolled-up total.
|
|
355
|
+
* A child shows only under a visible parent. A workflow's agents stay out —
|
|
356
|
+
* the run's own row and inspector cover them.
|
|
307
357
|
*/
|
|
308
|
-
private
|
|
358
|
+
private agentEntries(): AgentEntry[] {
|
|
309
359
|
const now = Date.now()
|
|
310
|
-
|
|
311
|
-
|
|
360
|
+
const all = this.manager.listAgents()
|
|
361
|
+
// The viewed agent stays listed, and a nested one needs its ancestors to
|
|
362
|
+
// hang from: they settle together (a parent stops its children), so the
|
|
363
|
+
// parent would otherwise drop out first and take the viewed row with it.
|
|
364
|
+
const pinned = new Set<string>()
|
|
365
|
+
for (let id = this.viewingAgentId; id !== undefined && !pinned.has(id);) {
|
|
366
|
+
pinned.add(id)
|
|
367
|
+
id = all.find((a) => a.id === id)?.parentAgentId
|
|
368
|
+
}
|
|
369
|
+
const visible = all
|
|
312
370
|
.filter(
|
|
313
371
|
(a) =>
|
|
314
|
-
|
|
372
|
+
a.workflowId === undefined &&
|
|
315
373
|
a.session &&
|
|
316
374
|
(a.status === "running" ||
|
|
317
375
|
a.status === "queued" ||
|
|
318
|
-
a.id
|
|
376
|
+
pinned.has(a.id) ||
|
|
319
377
|
(a.completedAt != null &&
|
|
320
378
|
now - a.completedAt < FINISHED_LINGER_MS)),
|
|
321
379
|
)
|
|
322
380
|
.sort((a, b) => a.startedAt - b.startedAt)
|
|
381
|
+
return agentTree(visible).map(({ record, prefix }) => ({
|
|
382
|
+
kind: "agent",
|
|
383
|
+
record,
|
|
384
|
+
prefix,
|
|
385
|
+
}))
|
|
323
386
|
}
|
|
324
387
|
|
|
325
388
|
/**
|
|
@@ -365,17 +428,36 @@ export class FleetList {
|
|
|
365
428
|
kind: "workflow" as const,
|
|
366
429
|
workflow,
|
|
367
430
|
})),
|
|
368
|
-
...this.
|
|
369
|
-
kind: "agent" as const,
|
|
370
|
-
record,
|
|
371
|
-
})),
|
|
431
|
+
...this.agentEntries(),
|
|
372
432
|
]
|
|
373
433
|
}
|
|
374
434
|
|
|
435
|
+
/**
|
|
436
|
+
* Re-resolve the selection against the current roster. The cursor follows its
|
|
437
|
+
* row, not its slot: a nested spawn inserts a child mid-list, and a slot-based
|
|
438
|
+
* cursor would then sit on — and Enter open — a different agent. Following
|
|
439
|
+
* applies only while the index is where the last resolve left it; a key or a
|
|
440
|
+
* click since then is a deliberate move and wins. A row that is gone leaves
|
|
441
|
+
* the cursor at its position, clamped, so the next row takes the slot.
|
|
442
|
+
*/
|
|
375
443
|
private clampSelection(): void {
|
|
376
|
-
const
|
|
444
|
+
const roster = this.roster()
|
|
445
|
+
if (
|
|
446
|
+
this.selectedKey !== undefined &&
|
|
447
|
+
this.selectedIndex === this.selectedKeyIndex
|
|
448
|
+
) {
|
|
449
|
+
const idx = roster.findIndex(
|
|
450
|
+
(entry) => entryKey(entry) === this.selectedKey,
|
|
451
|
+
)
|
|
452
|
+
if (idx >= 0) this.selectedIndex = idx
|
|
453
|
+
}
|
|
454
|
+
const max = roster.length - 1
|
|
377
455
|
if (this.selectedIndex > max) this.selectedIndex = Math.max(0, max)
|
|
378
456
|
if (this.selectedIndex < 0) this.selectedIndex = 0
|
|
457
|
+
if (this.hoverIndex !== undefined && this.hoverIndex > max)
|
|
458
|
+
this.hoverIndex = undefined
|
|
459
|
+
this.selectedKey = entryKey(roster[this.selectedIndex])
|
|
460
|
+
this.selectedKeyIndex = this.selectedIndex
|
|
379
461
|
}
|
|
380
462
|
|
|
381
463
|
// ---- Key handling ----
|
|
@@ -391,6 +473,12 @@ export class FleetList {
|
|
|
391
473
|
// test below, which would otherwise read the dialog holding the keyboard as
|
|
392
474
|
// "the user left the list" and reset the selection out from under it.
|
|
393
475
|
if (this.viewerClose || this.viewingWorkflowId) return undefined
|
|
476
|
+
// A key means the user went back to the keyboard. While navigating, it acts
|
|
477
|
+
// on the row the `❯` is on, so take the hover over as the selection; either
|
|
478
|
+
// way drop it, or it would sit wherever the pointer last crossed the list.
|
|
479
|
+
if (this.active && this.hoverIndex !== undefined)
|
|
480
|
+
this.selectedIndex = this.hoverIndex
|
|
481
|
+
this.hoverIndex = undefined
|
|
394
482
|
// Input listeners fire BEFORE the focused component, and dialogs
|
|
395
483
|
// (ctx.ui.select/confirm/input, pi's own menus) swap the prompt editor out
|
|
396
484
|
// while getEditorText() still reads the detached — empty — editor. So when
|
|
@@ -419,7 +507,9 @@ export class FleetList {
|
|
|
419
507
|
return undefined
|
|
420
508
|
}
|
|
421
509
|
|
|
422
|
-
// Active — arrows navigate, Enter opens, Esc / Up-past-top exits.
|
|
510
|
+
// Active — arrows navigate, Enter opens, Esc / Up-past-top exits. Resolve
|
|
511
|
+
// first: the roster may have changed since the last tick's update().
|
|
512
|
+
this.clampSelection()
|
|
423
513
|
if (matchesKey(data, "down")) {
|
|
424
514
|
const max = this.roster().length - 1
|
|
425
515
|
this.selectedIndex = Math.min(max, this.selectedIndex + 1)
|
|
@@ -449,6 +539,37 @@ export class FleetList {
|
|
|
449
539
|
return undefined
|
|
450
540
|
}
|
|
451
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Hover and click on rows. Only reaches us in pi's fullscreen mode, where the
|
|
544
|
+
* renderer captures the mouse and routes an event to the below-editor widget
|
|
545
|
+
* under the pointer; `regular` mode sends none. Guarded like `handleKey`, so
|
|
546
|
+
* a click never acts behind an overlay or a dialog.
|
|
547
|
+
*/
|
|
548
|
+
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
549
|
+
if (!this.enabled || !this.ui) return undefined
|
|
550
|
+
if (this.viewerClose || this.viewingWorkflowId) return undefined
|
|
551
|
+
if (!this.editorHasFocus()) return undefined
|
|
552
|
+
const index = this.lineRoster[event.y]
|
|
553
|
+
if (event.type === "move") {
|
|
554
|
+
// Hover never moves `selectedIndex`: that re-windows a scrolled list,
|
|
555
|
+
// which would shift the rows under the pointer. A key adopts the hover.
|
|
556
|
+
if (index === this.hoverIndex) return undefined
|
|
557
|
+
this.hoverIndex = index
|
|
558
|
+
return { handled: true, render: true }
|
|
559
|
+
}
|
|
560
|
+
if (index === undefined || event.button !== "left") return undefined
|
|
561
|
+
// Claim the press: the renderer only sends `click` to the component that
|
|
562
|
+
// handled it, and otherwise starts a text selection.
|
|
563
|
+
if (event.type === "press") return { handled: true }
|
|
564
|
+
if (event.type === "click") {
|
|
565
|
+
this.hoverIndex = undefined
|
|
566
|
+
this.selectedIndex = index
|
|
567
|
+
this.openSelected()
|
|
568
|
+
return { handled: true }
|
|
569
|
+
}
|
|
570
|
+
return undefined
|
|
571
|
+
}
|
|
572
|
+
|
|
452
573
|
/**
|
|
453
574
|
* True when pi's prompt editor owns the keyboard. The editor is pluggable
|
|
454
575
|
* (ui.setEditorComponent) and need not extend `Editor` (#374), so match pi-tui's
|
|
@@ -569,18 +690,36 @@ export class FleetList {
|
|
|
569
690
|
|
|
570
691
|
private renderBar(width: number, theme: Theme): string[] {
|
|
571
692
|
const rows = this.roster().slice(1) as (WorkflowEntry | AgentEntry)[]
|
|
572
|
-
if (rows.length === 0)
|
|
693
|
+
if (rows.length === 0) {
|
|
694
|
+
this.lineRoster = []
|
|
695
|
+
return []
|
|
696
|
+
}
|
|
573
697
|
// Clamp locally so a render between a roster shrink and the next update()
|
|
574
698
|
// (e.g. on terminal resize) never loses the selection marker.
|
|
575
699
|
const sel = Math.min(this.selectedIndex, rows.length)
|
|
700
|
+
// The `❯` row: the hover, else the keyboard's selection while it navigates.
|
|
701
|
+
const cursor = this.hoverIndex ?? (this.active ? sel : undefined)
|
|
576
702
|
|
|
577
703
|
const hint = this.active
|
|
578
704
|
? "↑↓ select · enter view · esc back"
|
|
579
705
|
: "esc to interrupt · ← for agents · ↓ to manage"
|
|
580
706
|
const lines: string[] = []
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
707
|
+
const lineRoster: (number | undefined)[] = []
|
|
708
|
+
const push = (line: string, rosterIndex?: number): void => {
|
|
709
|
+
lines.push(line)
|
|
710
|
+
lineRoster.push(rosterIndex)
|
|
711
|
+
}
|
|
712
|
+
push(truncateToWidth(" " + theme.fg("dim", hint), width))
|
|
713
|
+
push("")
|
|
714
|
+
const mainInFront =
|
|
715
|
+
this.viewingAgentId === undefined && this.viewingWorkflowId === undefined
|
|
716
|
+
push(
|
|
717
|
+
truncateToWidth(
|
|
718
|
+
`${this.gutter(0, cursor, theme)}${this.dot(mainInFront, theme)} main`,
|
|
719
|
+
width,
|
|
720
|
+
),
|
|
721
|
+
0,
|
|
722
|
+
)
|
|
584
723
|
|
|
585
724
|
// Window the rows so the selected one stays visible.
|
|
586
725
|
const visible = Math.min(MAX_AGENT_ROWS, rows.length)
|
|
@@ -589,45 +728,59 @@ export class FleetList {
|
|
|
589
728
|
const hiddenBelow = rows.length - (start + visible)
|
|
590
729
|
|
|
591
730
|
if (start > 0)
|
|
592
|
-
|
|
731
|
+
push(rightAlign("", theme.fg("dim", `↑ ${start} more`), width))
|
|
593
732
|
for (let a = start; a < start + visible; a++) {
|
|
594
733
|
const row = rows[a]
|
|
595
|
-
|
|
734
|
+
push(
|
|
596
735
|
row.kind === "workflow"
|
|
597
|
-
? this.renderWorkflowRow(a + 1,
|
|
598
|
-
: this.renderAgentRow(a + 1,
|
|
736
|
+
? this.renderWorkflowRow(a + 1, cursor, row.workflow, width, theme)
|
|
737
|
+
: this.renderAgentRow(a + 1, cursor, row, width, theme),
|
|
738
|
+
a + 1,
|
|
599
739
|
)
|
|
600
740
|
}
|
|
601
741
|
if (hiddenBelow > 0)
|
|
602
|
-
|
|
603
|
-
rightAlign("", theme.fg("dim", `↓ ${hiddenBelow} more`), width),
|
|
604
|
-
)
|
|
742
|
+
push(rightAlign("", theme.fg("dim", `↓ ${hiddenBelow} more`), width))
|
|
605
743
|
// pi stacks below-editor widgets directly on its footer with no spacer (#351).
|
|
606
|
-
|
|
744
|
+
push("")
|
|
607
745
|
|
|
746
|
+
this.lineRoster = lineRoster
|
|
608
747
|
return lines
|
|
609
748
|
}
|
|
610
749
|
|
|
611
|
-
|
|
612
|
-
|
|
750
|
+
/**
|
|
751
|
+
* The two columns every row starts with: Claude Code's `❯` on the cursor row,
|
|
752
|
+
* blank elsewhere — so moving the cursor never shifts a row's width.
|
|
753
|
+
*/
|
|
754
|
+
private gutter(
|
|
755
|
+
rosterIndex: number,
|
|
756
|
+
cursor: number | undefined,
|
|
757
|
+
theme: Theme,
|
|
758
|
+
): string {
|
|
759
|
+
return rosterIndex === cursor ? `${theme.fg("accent", "❯")} ` : " "
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/** `●` on the view in front — `main`, or the row whose overlay is open — `○` elsewhere. */
|
|
763
|
+
private dot(inFront: boolean, theme: Theme): string {
|
|
764
|
+
return inFront ? theme.fg("accent", "●") : theme.fg("dim", "○")
|
|
613
765
|
}
|
|
614
766
|
|
|
615
767
|
/**
|
|
616
|
-
* A run's row. Shaped like an agent's —
|
|
617
|
-
* — so the two read as one list, with the agent count where an agent
|
|
618
|
-
* description and the same elapsed/token tail.
|
|
768
|
+
* A run's row. Shaped like an agent's — gutter, dot, kind, name, stats flush
|
|
769
|
+
* right — so the two read as one list, with the agent count where an agent
|
|
770
|
+
* has its description and the same elapsed/token tail.
|
|
619
771
|
*/
|
|
620
772
|
private renderWorkflowRow(
|
|
621
773
|
rosterIndex: number,
|
|
622
|
-
|
|
774
|
+
cursor: number | undefined,
|
|
623
775
|
workflow: FleetWorkflow,
|
|
624
776
|
width: number,
|
|
625
777
|
theme: Theme,
|
|
626
778
|
): string {
|
|
627
|
-
const selected = rosterIndex ===
|
|
779
|
+
const selected = rosterIndex === cursor
|
|
628
780
|
const kind = theme.fg(selected ? "text" : "muted", "workflow")
|
|
629
781
|
const name = selected ? theme.fg("text", workflow.name) : workflow.name
|
|
630
|
-
const
|
|
782
|
+
const dot = this.dot(workflow.id === this.viewingWorkflowId, theme)
|
|
783
|
+
const left = `${this.gutter(rosterIndex, cursor, theme)}${dot} ${kind} ${name}`
|
|
631
784
|
// Frozen once the run settles, exactly as an agent's clock is.
|
|
632
785
|
const elapsed = (workflow.completedAt ?? Date.now()) - workflow.startedAt
|
|
633
786
|
const agents = `${workflow.doneCount}/${workflow.totalCount} agent${workflow.totalCount === 1 ? "" : "s"}`
|
|
@@ -641,16 +794,17 @@ export class FleetList {
|
|
|
641
794
|
|
|
642
795
|
private renderAgentRow(
|
|
643
796
|
rosterIndex: number,
|
|
644
|
-
|
|
645
|
-
|
|
797
|
+
cursor: number | undefined,
|
|
798
|
+
entry: AgentEntry,
|
|
646
799
|
width: number,
|
|
647
800
|
theme: Theme,
|
|
648
801
|
): string {
|
|
802
|
+
const { record, prefix } = entry
|
|
649
803
|
// The selected row renders in the theme's primary text color so it reads as
|
|
650
804
|
// one selection (#230). A configured badge survives — Claude Code's FleetView
|
|
651
805
|
// keeps the agent color on the selected row too and only bolds it — which also
|
|
652
806
|
// keeps the row's width fixed as the selection moves.
|
|
653
|
-
const selected = rosterIndex ===
|
|
807
|
+
const selected = rosterIndex === cursor
|
|
654
808
|
const name = renderAgentName(
|
|
655
809
|
record.type,
|
|
656
810
|
theme,
|
|
@@ -662,14 +816,24 @@ export class FleetList {
|
|
|
662
816
|
const description = selected
|
|
663
817
|
? theme.fg("text", record.description)
|
|
664
818
|
: record.description
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
819
|
+
const tree = prefix ? theme.fg("dim", prefix) : ""
|
|
820
|
+
const dot = this.dot(record.id === this.viewingAgentId, theme)
|
|
821
|
+
let left = `${this.gutter(rosterIndex, cursor, theme)}${tree}${dot} ${name} ${description}`
|
|
822
|
+
if (this.showModel()) {
|
|
823
|
+
// After the description, not in the stats: rightAlign truncates only the
|
|
824
|
+
// left side, so here the model is cut first and the name survives. Bare
|
|
825
|
+
// level (`sonnet 4.6 · high`), matching the widget's running line.
|
|
826
|
+
const { modelName, thinking } = buildInvocationTags(record.invocation)
|
|
827
|
+
const model = [modelName, thinking].filter(Boolean).join(" · ")
|
|
828
|
+
if (model) left += theme.fg(selected ? "text" : "dim", ` · ${model}`)
|
|
829
|
+
}
|
|
830
|
+
// The record, not the activity tracker: only the record outlives the agent.
|
|
831
|
+
// Its OWN usage, not `lifetimeUsage` — that one folds in every descendant,
|
|
832
|
+
// and the descendants have rows of their own here.
|
|
833
|
+
const tokens = getLifetimeTotal(record.ownUsage)
|
|
670
834
|
const elapsedMs = (record.completedAt ?? Date.now()) - record.startedAt // freezes once finished
|
|
671
835
|
const cost = this.showCost()
|
|
672
|
-
? formatCost(getLifetimeCost(record.
|
|
836
|
+
? formatCost(getLifetimeCost(record.ownUsage))
|
|
673
837
|
: ""
|
|
674
838
|
const stats = `${formatFleetElapsed(elapsedMs)} · ${formatFleetTokens(tokens)}${cost ? ` · ${cost}` : ""}`
|
|
675
839
|
const right = selected ? theme.fg("text", stats) : theme.fg("dim", stats)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herbertgao/pi-extensions",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.10",
|
|
4
4
|
"description": "Aggregate installer for HerbertGao-maintained Pi extensions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"extensions",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@dietrichgebert/ponytail": "5.3.3",
|
|
42
42
|
"@herbertgao/pi-agency": "0.1.3",
|
|
43
43
|
"@herbertgao/pi-bark": "0.2.2",
|
|
44
|
-
"@herbertgao/pi-cc-extensions": "1.0.
|
|
44
|
+
"@herbertgao/pi-cc-extensions": "1.0.17-local.1",
|
|
45
45
|
"@herbertgao/pi-impeccable": "0.3.0",
|
|
46
|
-
"@herbertgao/pi-subagents": "0.
|
|
46
|
+
"@herbertgao/pi-subagents": "0.24.0-local.1",
|
|
47
47
|
"@herbertgao/sol-pi": "0.4.3",
|
|
48
48
|
"@juicesharp/rpiv-ask-user-question": "2.15.0",
|
|
49
49
|
"@juicesharp/rpiv-config": "^2.15.0",
|