@herbertgao/pi-extensions 2026.11.9 → 2026.11.11
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 +21 -0
- package/README.md +6 -6
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +12 -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 +34 -10
- 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 +63 -7
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +3 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-io.ts +0 -5
- 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 +43 -4
- 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-impeccable/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-impeccable/README.md +2 -2
- package/node_modules/@herbertgao/pi-impeccable/package.json +4 -4
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/SKILL.md +3 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/adapt.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.md +12 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/audit.native.md +4 -0
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/critique.md +5 -5
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/documenter.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/degraded/finish-reviewer.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/distill.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/document.md +3 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/foundations.md +44 -0
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/live-setup.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/live.md +26 -12
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/new-work.md +10 -9
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/onboard.md +7 -6
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/overdrive.md +2 -2
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/quieter.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/reference/visualize.md +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/VERSION +1 -1
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/engine-checksums.txt +5 -5
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/impeccable +69 -16
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/impeccable.cmd +55 -7
- package/node_modules/@herbertgao/pi-impeccable/skills/impeccable/scripts/live-browser.js +34 -4
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +12 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +53 -26
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +12 -12
- package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +84 -8
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +51 -32
- package/node_modules/@herbertgao/pi-subagents/src/default-agents.ts +7 -0
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +369 -879
- package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +4 -1
- package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +13 -0
- package/node_modules/@herbertgao/pi-subagents/src/schedule-store.ts +18 -13
- package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +25 -5
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +225 -61
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +27 -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 +16 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/agents-menu.ts +705 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +211 -47
- package/node_modules/@herbertgao/pi-subagents/src/ui/settings-menu.ts +361 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/viewer-keys.ts +1 -1
- package/node_modules/pi-commandcode-provider/CHANGELOG.md +11 -1
- package/node_modules/pi-commandcode-provider/index.ts +2 -1
- package/node_modules/pi-commandcode-provider/package.json +5 -4
- package/node_modules/pi-commandcode-provider/src/pricing.ts +8 -1
- package/node_modules/pi-commandcode-provider/src/responses-compat.ts +137 -0
- package/package.json +5 -5
|
@@ -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)
|