@xzzpig/pi-subagents 0.18.0 → 0.20.0
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 +129 -0
- package/README.md +1 -1
- package/docs/agents.md +32 -16
- package/docs/configuration.md +76 -9
- package/docs/extension-api.md +6 -5
- package/docs/missions.md +28 -14
- package/docs/models.md +8 -4
- package/docs/observability.md +10 -5
- package/docs/standalone-background.md +1 -1
- package/docs/tool-reference.md +90 -88
- package/docs/workflows.md +171 -173
- package/node_modules/@xzzpig/pi-components/package.json +4 -4
- package/package.json +6 -6
- package/prompts/review-loop.md +1 -1
- package/skills/council-mode/SKILL.md +1 -1
- package/skills/pi-subagents/SKILL.md +12 -5
- package/skills/pi-subagents/references/constraints-and-recipes.md +3 -3
- package/skills/pi-subagents/references/execution-controls.md +68 -67
- package/skills/pi-subagents/references/management-authoring-rpc.md +2 -2
- package/skills/pi-subagents/references/multi-lane-orchestration.md +1 -1
- package/skills/pi-subagents/references/prompting-and-roles.md +45 -48
- package/src/agents/advertised-agent-prompt.ts +21 -41
- package/src/agents/agent-management.ts +2 -2
- package/src/agents/agents.ts +66 -3
- package/src/api/preflight.ts +109 -63
- package/src/extension/config.ts +15 -4
- package/src/extension/control-notices.ts +3 -0
- package/src/extension/doctor.ts +1 -0
- package/src/extension/fanout-child.ts +12 -3
- package/src/extension/herdr-pi-bridge.ts +2 -0
- package/src/extension/index.ts +90 -174
- package/src/extension/public-execution.ts +72 -35
- package/src/extension/reply-workflow-script.ts +58 -0
- package/src/extension/rpc.ts +29 -10
- package/src/extension/schemas.ts +40 -135
- package/src/extension/tool-activation.ts +57 -108
- package/src/extension/tool-description.ts +62 -27
- package/src/extension/upgrade-notice.ts +40 -0
- package/src/integrations/herdr-status.ts +19 -3
- package/src/intercom/native-supervisor-channel.ts +4 -1
- package/src/missions/goal-driver.ts +44 -31
- package/src/missions/store.ts +10 -1
- package/src/profiles/profiles.ts +5 -2
- package/src/runs/background/async-execution.ts +146 -59
- package/src/runs/background/async-job-tracker.ts +66 -24
- package/src/runs/background/async-retention.ts +46 -16
- package/src/runs/background/await-async-run.ts +78 -0
- package/src/runs/background/chain-root-attachment.ts +4 -4
- package/src/runs/background/control-channel.ts +61 -2
- package/src/runs/background/notify.ts +5 -0
- package/src/runs/background/run-child-session.ts +17 -7
- package/src/runs/background/run-status.ts +6 -0
- package/src/runs/background/runner-aliases.ts +37 -6
- package/src/runs/background/runner-child-launch.ts +3 -0
- package/src/runs/background/scheduled-runs.ts +33 -18
- package/src/runs/background/stale-run-reconciler.ts +13 -2
- package/src/runs/background/subagent-runner.ts +58 -5
- package/src/runs/foreground/async-stop-action.ts +17 -3
- package/src/runs/foreground/command-action.ts +41 -0
- package/src/runs/foreground/execution.ts +145 -131
- package/src/runs/foreground/subagent-executor.ts +546 -296
- package/src/runs/shared/async-status-projection.ts +5 -0
- package/src/runs/shared/child-commands.ts +228 -0
- package/src/runs/shared/child-launch.ts +15 -2
- package/src/runs/shared/child-session.ts +184 -24
- package/src/runs/shared/child-tool-plan.ts +16 -4
- package/src/runs/shared/claude-code-adapter.ts +157 -2
- package/src/runs/shared/dynamic-fanout.ts +2 -2
- package/src/runs/shared/external-cli-preflight.ts +54 -6
- package/src/runs/shared/external-cli-runner.ts +5 -1
- package/src/runs/shared/mcp-config-sources.ts +2 -1
- package/src/runs/shared/mcp-direct-tool-allowlist.ts +104 -11
- package/src/runs/shared/model-resolution.ts +38 -10
- package/src/runs/shared/model-scope.ts +28 -9
- package/src/runs/shared/nested-events.ts +55 -55
- package/src/runs/shared/parallel-utils.ts +4 -0
- package/src/runs/shared/pi-spawn.ts +7 -95
- package/src/runs/shared/run-history.ts +87 -0
- package/src/runs/shared/subagent-control.ts +32 -17
- package/src/runs/shared/subagent-prompt-runtime.ts +14 -6
- package/src/runs/shared/worktree.ts +1 -1
- package/src/shared/disabled-features.ts +123 -0
- package/src/shared/extension-context.ts +13 -0
- package/src/shared/model-info.ts +9 -0
- package/src/shared/required-child-extensions.ts +39 -5
- package/src/shared/settings.ts +1 -1
- package/src/shared/types.ts +27 -1
- package/src/slash/prompt-template-bridge.ts +2 -2
- package/src/slash/slash-commands.ts +10 -5
- package/src/slash/subagent-cost.ts +9 -5
- package/src/slash/subagents-admin.ts +24 -24
- package/src/tui/fleet-status.ts +14 -6
- package/src/tui/fleet.ts +14 -2
- package/src/tui/render.ts +117 -56
- package/src/tui/running-tone.ts +28 -0
- package/src/watchdog/diff-tool.ts +23 -9
- package/src/watchdog/register-child.ts +3 -3
- package/src/watchdog/register-main.ts +3 -3
- package/src/watchdog/review.ts +2 -2
- package/src/watchdog/turn-delta.ts +1 -1
- package/src/workflows/chat-progress.ts +2 -2
- package/src/workflows/scripted-workflow.ts +117 -37
- package/src/workflows/structured-workflow-scripts.ts +177 -0
- package/src/workflows/workflow-checklist.ts +6 -0
- package/src/workflows/workflow-receipt.ts +10 -4
- package/src/workflows/workflow-resources.ts +44 -16
- package/src/workflows/workflow-reuse.ts +120 -0
- package/src/workflows/workflow-revival.ts +123 -0
package/src/tui/render.ts
CHANGED
|
@@ -34,6 +34,8 @@ import { formatNestedAggregate } from "../runs/shared/nested-render.ts";
|
|
|
34
34
|
import { aggregateStepStatus, formatActivityLabel, formatAgentRunningLabel, formatParallelOutcome } from "../shared/status-format.ts";
|
|
35
35
|
import { contextModeBadge, contextModePrefix } from "../runs/shared/context-mode.ts";
|
|
36
36
|
import { shouldSuppressSingleStep, stripRepeatedAgentPrefix, withDuplicateLabelDiscriminators } from "./render-helpers.ts";
|
|
37
|
+
import { runningTone } from "./running-tone.ts";
|
|
38
|
+
import { childThinkingLevel, type ThinkingLevel } from "../shared/model-info.ts";
|
|
37
39
|
import { buildWorkflowChatProgressRows, type WorkflowChatProgressRow } from "../workflows/chat-progress.ts";
|
|
38
40
|
import { formatWorkflowPreflight, formatWorkflowPreflightPlanSummary, formatWorkflowPreflightWarningSummary, formatWorkflowPreflightWarnings } from "../workflows/workflow-preflight.ts";
|
|
39
41
|
import { encodeAsyncStatusSnapshotWidget } from "../runs/background/async-status-snapshot.ts";
|
|
@@ -881,6 +883,8 @@ type ResultPresentation = {
|
|
|
881
883
|
glyph: string;
|
|
882
884
|
label: "running" | "detached" | "stopped" | "paused" | "failed" | "partial" | "completed";
|
|
883
885
|
tone: "accent" | "warning" | "error" | "success";
|
|
886
|
+
/** Recorded thinking level of the one child a running presentation stands for. */
|
|
887
|
+
thinking?: ThinkingLevel;
|
|
884
888
|
};
|
|
885
889
|
|
|
886
890
|
function semanticResultPresentation(input: {
|
|
@@ -893,10 +897,11 @@ function semanticResultPresentation(input: {
|
|
|
893
897
|
completedWithoutOutput?: boolean;
|
|
894
898
|
seed?: number;
|
|
895
899
|
frame?: number;
|
|
900
|
+
thinking?: ThinkingLevel;
|
|
896
901
|
}): ResultPresentation {
|
|
897
902
|
if (input.running) {
|
|
898
903
|
const glyph = input.frame !== undefined ? runningGlyph((input.seed ?? 0) + input.frame) : runningGlyph(input.seed);
|
|
899
|
-
return { glyph, label: "running", tone: "accent" };
|
|
904
|
+
return { glyph, label: "running", tone: "accent", ...(input.thinking ? { thinking: input.thinking } : {}) };
|
|
900
905
|
}
|
|
901
906
|
if (input.detached) return { glyph: "■", label: "detached", tone: "warning" };
|
|
902
907
|
if (input.stopped) return { glyph: "■", label: "stopped", tone: "warning" };
|
|
@@ -941,18 +946,24 @@ function resultPresentation(result: Details["results"][number], output: string,
|
|
|
941
946
|
completedWithoutOutput: hasEmptyTextOutputWithoutOutputTarget(result.task, output),
|
|
942
947
|
seed,
|
|
943
948
|
frame,
|
|
949
|
+
thinking: childThinkingLevel(result, result.progress),
|
|
944
950
|
});
|
|
945
951
|
}
|
|
946
952
|
|
|
953
|
+
function presentationTone(presentation: ResultPresentation, theme: Theme): (text: string) => string {
|
|
954
|
+
return presentation.label === "running" ? runningTone(theme, presentation.thinking) : (text) => theme.fg(presentation.tone, text);
|
|
955
|
+
}
|
|
956
|
+
|
|
947
957
|
function resultGlyph(result: Details["results"][number], output: string, theme: Theme, running = isResultRunning(result), seed = progressRunningSeed(result.progress ?? result.progressSummary), frame?: number): string {
|
|
948
958
|
const presentation = resultPresentation(result, output, running, seed, frame);
|
|
949
|
-
return
|
|
959
|
+
return presentationTone(presentation, theme)(presentation.glyph);
|
|
950
960
|
}
|
|
951
961
|
|
|
952
962
|
function styledResultPresentation(presentation: ResultPresentation, theme: Theme): { glyph: string; label: string } {
|
|
963
|
+
const tone = presentationTone(presentation, theme);
|
|
953
964
|
return {
|
|
954
|
-
glyph:
|
|
955
|
-
label:
|
|
965
|
+
glyph: tone(presentation.glyph),
|
|
966
|
+
label: tone(presentation.label),
|
|
956
967
|
};
|
|
957
968
|
}
|
|
958
969
|
|
|
@@ -1250,8 +1261,12 @@ function widgetJobsRunningSeed(jobs: AsyncJobState[]): number | undefined {
|
|
|
1250
1261
|
return seed;
|
|
1251
1262
|
}
|
|
1252
1263
|
|
|
1264
|
+
function activeHeaderTone(theme: Theme, hasActive: boolean): (text: string) => string {
|
|
1265
|
+
return hasActive ? runningTone(theme) : (text) => theme.fg("dim", text);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1253
1268
|
function widgetStatusGlyph(job: AsyncJobState, theme: Theme, frame?: number): string {
|
|
1254
|
-
if (job.status === "running") return theme.
|
|
1269
|
+
if (job.status === "running") return runningTone(theme, job.mode === "single" ? childThinkingLevel(job.steps?.[0]) : undefined)(runningGlyph(animatedSeed(widgetJobRunningSeed(job), frame)));
|
|
1255
1270
|
if (job.status === "queued") return theme.fg("muted", "◦");
|
|
1256
1271
|
if (job.status === "complete") return theme.fg("success", "✓");
|
|
1257
1272
|
if (job.status === "paused") return theme.fg("warning", "■");
|
|
@@ -1259,8 +1274,8 @@ function widgetStatusGlyph(job: AsyncJobState, theme: Theme, frame?: number): st
|
|
|
1259
1274
|
return theme.fg("error", "✗");
|
|
1260
1275
|
}
|
|
1261
1276
|
|
|
1262
|
-
function widgetStepGlyph(status: AsyncJobStep["status"], theme: Theme, seed?: number, frame?: number): string {
|
|
1263
|
-
if (status === "running") return theme
|
|
1277
|
+
function widgetStepGlyph(status: AsyncJobStep["status"], theme: Theme, seed?: number, frame?: number, thinking?: ThinkingLevel): string {
|
|
1278
|
+
if (status === "running") return runningTone(theme, thinking)(runningGlyph(animatedSeed(seed, frame)));
|
|
1264
1279
|
if (status === "complete" || status === "completed") return theme.fg("success", "✓");
|
|
1265
1280
|
if (status === "failed") return theme.fg("error", "✗");
|
|
1266
1281
|
if (status === "paused") return theme.fg("warning", "■");
|
|
@@ -1268,8 +1283,8 @@ function widgetStepGlyph(status: AsyncJobStep["status"], theme: Theme, seed?: nu
|
|
|
1268
1283
|
return theme.fg("muted", "◦");
|
|
1269
1284
|
}
|
|
1270
1285
|
|
|
1271
|
-
function widgetStepStatus(status: AsyncJobStep["status"], theme: Theme): string {
|
|
1272
|
-
if (status === "running") return theme
|
|
1286
|
+
function widgetStepStatus(status: AsyncJobStep["status"], theme: Theme, thinking?: ThinkingLevel): string {
|
|
1287
|
+
if (status === "running") return runningTone(theme, thinking)("running");
|
|
1273
1288
|
if (status === "complete" || status === "completed") return theme.fg("success", "complete");
|
|
1274
1289
|
if (status === "failed") return theme.fg("error", "failed");
|
|
1275
1290
|
if (status === "paused") return theme.fg("warning", "paused");
|
|
@@ -1283,8 +1298,8 @@ function workflowChecklistStateLabel(state: WorkflowChecklistState): string {
|
|
|
1283
1298
|
return state;
|
|
1284
1299
|
}
|
|
1285
1300
|
|
|
1286
|
-
function workflowChecklistGlyph(item: { state: WorkflowChecklistState; startedAt?: number; durationMs?: number; toolCount?: number; currentToolStartedAt?: number }, theme: Theme, frame?: number): string {
|
|
1287
|
-
if (item.state === "running") return theme.
|
|
1301
|
+
function workflowChecklistGlyph(item: { state: WorkflowChecklistState; startedAt?: number; durationMs?: number; toolCount?: number; currentToolStartedAt?: number; thinking?: ThinkingLevel }, theme: Theme, frame?: number): string {
|
|
1302
|
+
if (item.state === "running") return runningTone(theme, item.thinking)(runningGlyph(animatedSeed(runningSeed(item.startedAt, item.durationMs, item.toolCount, item.currentToolStartedAt), frame)));
|
|
1288
1303
|
if (item.state === "complete") return theme.fg("success", "✓");
|
|
1289
1304
|
if (item.state === "blocked") return theme.fg("error", "!");
|
|
1290
1305
|
if (item.state === "failed") return theme.fg("error", "✗");
|
|
@@ -1370,6 +1385,8 @@ function workflowChecklistWidgetLines(checklist: WorkflowChecklistProjection | u
|
|
|
1370
1385
|
interface CompactWorkflowLaneRow {
|
|
1371
1386
|
key: string;
|
|
1372
1387
|
state: WorkflowChecklistState;
|
|
1388
|
+
/** Recorded thinking level of the lane's child when the lane stands for exactly one. */
|
|
1389
|
+
thinking?: ThinkingLevel;
|
|
1373
1390
|
agent?: string;
|
|
1374
1391
|
mode?: string;
|
|
1375
1392
|
decision?: string;
|
|
@@ -1420,6 +1437,7 @@ function compactWorkflowLaneRow(key: string, items: readonly WorkflowChecklistIt
|
|
|
1420
1437
|
key: boundedLaneValue(key, 40) ?? key,
|
|
1421
1438
|
state,
|
|
1422
1439
|
agent: compactWorkflowLaneOwner(items),
|
|
1440
|
+
...(items.length === 1 && items[0]?.thinking ? { thinking: items[0].thinking } : {}),
|
|
1423
1441
|
...(lane?.mode ? { mode: lane.mode } : {}),
|
|
1424
1442
|
...(lane?.decision ? { decision: boundedLaneValue(lane.decision, 56) } : {}),
|
|
1425
1443
|
...(lane?.claims?.length ? { claims: boundedLaneValue(lane.claims.join(", "), 56) } : {}),
|
|
@@ -1493,7 +1511,7 @@ function compactWorkflowLaneLine(row: CompactWorkflowLaneRow, theme: Theme, inde
|
|
|
1493
1511
|
row.expectedOutput,
|
|
1494
1512
|
!row.mode && row.label ? row.label : undefined,
|
|
1495
1513
|
].filter((value): value is string => Boolean(value));
|
|
1496
|
-
return `${indent}${workflowChecklistGlyph({ state: row.state, durationMs: row.durationMs, toolCount: row.toolUses }, theme, frame)} ${theme.bold(row.key)}${owner ? ` ${theme.fg("dim", `· ${owner}`)}` : ""}${state ? ` ${theme.fg("dim", `· ${state}`)}` : ""}${intent.length ? ` ${theme.fg("dim", `· ${intent.join(" · ")}`)}` : ""}`;
|
|
1514
|
+
return `${indent}${workflowChecklistGlyph({ state: row.state, durationMs: row.durationMs, toolCount: row.toolUses, thinking: row.thinking }, theme, frame)} ${theme.bold(row.key)}${owner ? ` ${theme.fg("dim", `· ${owner}`)}` : ""}${state ? ` ${theme.fg("dim", `· ${state}`)}` : ""}${intent.length ? ` ${theme.fg("dim", `· ${intent.join(" · ")}`)}` : ""}`;
|
|
1497
1515
|
}
|
|
1498
1516
|
|
|
1499
1517
|
function compactWorkflowShortId(job: AsyncJobState): string {
|
|
@@ -1623,7 +1641,8 @@ function widgetParallelAgentDetails(job: AsyncJobState, theme: Theme, expanded =
|
|
|
1623
1641
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
1624
1642
|
const label = compactTaskText(step.description, step.label);
|
|
1625
1643
|
const display = step.sessionName?.trim() || (label ? `${label} (${step.agent})` : step.agent);
|
|
1626
|
-
|
|
1644
|
+
const thinking = childThinkingLevel(step);
|
|
1645
|
+
lines.push(` ${theme.fg("dim", `${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index), frame, thinking)} ${itemTitle} ${index + 1}/${total}: ${display} · ${widgetStepStatus(step.status, theme, thinking)}${modelDisplay}${activity ? ` · ${activity}` : ""}`)}`);
|
|
1627
1646
|
const lane = projectAsyncLane(job, step);
|
|
1628
1647
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
1629
1648
|
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, expanded, job.updatedAt, expanded ? 8 : 6)) lines.push(` ${nestedLine}`);
|
|
@@ -2155,8 +2174,8 @@ function nestedRunName(run: NestedRunSummary): string {
|
|
|
2155
2174
|
return run.id;
|
|
2156
2175
|
}
|
|
2157
2176
|
|
|
2158
|
-
function nestedStatusGlyph(state: NestedRunSummary["state"] | NestedStepSummary["status"], theme: Theme, seed?: number): string {
|
|
2159
|
-
if (state === "running") return theme
|
|
2177
|
+
function nestedStatusGlyph(state: NestedRunSummary["state"] | NestedStepSummary["status"], theme: Theme, seed?: number, thinking?: ThinkingLevel): string {
|
|
2178
|
+
if (state === "running") return runningTone(theme, thinking)(runningGlyph(seed));
|
|
2160
2179
|
if (state === "complete" || state === "completed") return theme.fg("success", "✓");
|
|
2161
2180
|
if (state === "failed") return theme.fg("error", "✗");
|
|
2162
2181
|
if (state === "partial") return theme.fg("warning", "■");
|
|
@@ -2235,7 +2254,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2235
2254
|
const name = "status" in step ? childDisplayName(step) : nestedRunName(step);
|
|
2236
2255
|
rows.push({
|
|
2237
2256
|
prefix,
|
|
2238
|
-
text: `${nestedTimestampPrefix(timestamp)}${nestedStatusGlyph(state, theme)} ${name} · ${state}${modelThinking ? ` · ${modelThinking}` : ""}${activity ? ` · ${activity}` : ""}${error}`,
|
|
2257
|
+
text: `${nestedTimestampPrefix(timestamp)}${nestedStatusGlyph(state, theme, undefined, childThinkingLevel(step))} ${name} · ${state}${modelThinking ? ` · ${modelThinking}` : ""}${activity ? ` · ${activity}` : ""}${error}`,
|
|
2239
2258
|
});
|
|
2240
2259
|
};
|
|
2241
2260
|
for (const child of children) {
|
|
@@ -2246,7 +2265,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2246
2265
|
const ownerError = child.error ? ` · ${child.error}` : "";
|
|
2247
2266
|
rows.push({
|
|
2248
2267
|
prefix: "↳ ",
|
|
2249
|
-
text: `OWNER ${nestedStatusGlyph(child.state, theme, nestedRunSeed(child))} ${nestedRunName(child)} · ${child.state}${ownerModelThinking ? ` · ${ownerModelThinking}` : ""}${ownerActivity ? ` · ${ownerActivity}` : ""}${ownerError}`,
|
|
2268
|
+
text: `OWNER ${nestedStatusGlyph(child.state, theme, nestedRunSeed(child), childThinkingLevel(child))} ${nestedRunName(child)} · ${child.state}${ownerModelThinking ? ` · ${ownerModelThinking}` : ""}${ownerActivity ? ` · ${ownerActivity}` : ""}${ownerError}`,
|
|
2250
2269
|
});
|
|
2251
2270
|
for (const step of steps) appendLeaf(step, "↳ │ ", child.lastUpdate);
|
|
2252
2271
|
} else {
|
|
@@ -2285,7 +2304,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2285
2304
|
const activity = nestedActivity(child, child.state, snapshotNow ?? child.lastUpdate);
|
|
2286
2305
|
const error = child.error ? ` · ${child.error}` : "";
|
|
2287
2306
|
const modelThinking = formatModelThinking(child.model, child.thinking);
|
|
2288
|
-
lines.push(theme.fg("dim", `${prefix}↳ ${nestedTimestampPrefix(formatClockTime(nestedRunEventTime(child)))}${nestedStatusGlyph(child.state, theme, nestedRunSeed(child))} ${nestedRunName(child)} · ${child.state}${modelThinking ? ` · ${modelThinking}` : ""} · ${activity}${error}`));
|
|
2307
|
+
lines.push(theme.fg("dim", `${prefix}↳ ${nestedTimestampPrefix(formatClockTime(nestedRunEventTime(child)))}${nestedStatusGlyph(child.state, theme, nestedRunSeed(child), childThinkingLevel(child))} ${nestedRunName(child)} · ${child.state}${modelThinking ? ` · ${modelThinking}` : ""} · ${activity}${error}`));
|
|
2289
2308
|
if (depth === maxDepth) {
|
|
2290
2309
|
const aggregate = formatNestedAggregate([...(child.steps?.flatMap((step) => step.children ?? []) ?? []), ...(child.children ?? [])]);
|
|
2291
2310
|
if (aggregate && lines.length < lineBudget) lines.push(theme.fg("dim", `${prefix} ↳ ${aggregate}`));
|
|
@@ -2294,7 +2313,7 @@ function formatNestedWidgetLines(children: NestedRunSummary[] | undefined, theme
|
|
|
2294
2313
|
for (const step of child.steps ?? []) {
|
|
2295
2314
|
if (lines.length >= lineBudget) return;
|
|
2296
2315
|
const modelThinking = formatModelThinking(step.model, step.thinking);
|
|
2297
|
-
lines.push(theme.fg("dim", `${prefix} ↳ ${nestedTimestampPrefix(nestedStepTimestamp(step, child.lastUpdate))}${nestedStatusGlyph(step.status, theme)} ${childDisplayName(step)} · ${step.status}${modelThinking ? ` · ${modelThinking}` : ""} · ${nestedActivity(step, step.status, snapshotNow ?? child.lastUpdate)}`));
|
|
2316
|
+
lines.push(theme.fg("dim", `${prefix} ↳ ${nestedTimestampPrefix(nestedStepTimestamp(step, child.lastUpdate))}${nestedStatusGlyph(step.status, theme, undefined, childThinkingLevel(step))} ${childDisplayName(step)} · ${step.status}${modelThinking ? ` · ${modelThinking}` : ""} · ${nestedActivity(step, step.status, snapshotNow ?? child.lastUpdate)}`));
|
|
2298
2317
|
append(step.children, depth + 1, `${prefix} `);
|
|
2299
2318
|
}
|
|
2300
2319
|
append(child.children, depth + 1, `${prefix} `);
|
|
@@ -2318,7 +2337,8 @@ function foregroundStyleWidgetStepLines(
|
|
|
2318
2337
|
): string[] {
|
|
2319
2338
|
const rowIndent = options?.rowIndent ?? " ";
|
|
2320
2339
|
const detailIndent = options?.detailIndent ?? " ";
|
|
2321
|
-
const
|
|
2340
|
+
const thinking = childThinkingLevel(step);
|
|
2341
|
+
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2322
2342
|
const stats = widgetStepStats(theme, step, job.updatedAt);
|
|
2323
2343
|
const modelDisplay = modelThinkingBadge(theme, step.model, step.thinking);
|
|
2324
2344
|
const collapseDetails = shouldCollapseSingleChildDetails(job, step);
|
|
@@ -2329,7 +2349,7 @@ function foregroundStyleWidgetStepLines(
|
|
|
2329
2349
|
const stageIdentity = stageName && stageName !== displayName ? `${stageName} (${displayName})` : stageName ?? displayName;
|
|
2330
2350
|
const rowLabel = collapseDetails ? displayName : (options?.rowLabel ?? `${itemTitle} ${index}/${total}: ${itemTitle === "Stage" ? stageIdentity : displayName}`);
|
|
2331
2351
|
const rowMarker = options?.rowMarker ? `${options.rowMarker} ` : "";
|
|
2332
|
-
const lines = [`${rowIndent}${rowMarker}${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1), frame)} ${themeBold(theme, rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`];
|
|
2352
|
+
const lines = [`${rowIndent}${rowMarker}${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, index - 1), frame, thinking)} ${themeBold(theme, rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${stats ? ` ${theme.fg("dim", "·")} ${stats}` : ""}`];
|
|
2333
2353
|
const lane = projectAsyncLane(job, step);
|
|
2334
2354
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, detailIndent));
|
|
2335
2355
|
const task = collapseDetails ? singleChildTask(job, step) : compactTaskText(step.description, step.label);
|
|
@@ -2473,7 +2493,8 @@ function compactSingleWidgetLines(job: AsyncJobState, theme: Theme, width: numbe
|
|
|
2473
2493
|
lines.push(parallelWidgetGroupHeader(group, theme, frame));
|
|
2474
2494
|
for (const [rowIndex, row] of rows.entries()) {
|
|
2475
2495
|
const step = row.step;
|
|
2476
|
-
const
|
|
2496
|
+
const thinking = childThinkingLevel(step);
|
|
2497
|
+
const status = widgetStepStatus(step.status, theme, thinking);
|
|
2477
2498
|
const activity = widgetStepActivityLine(step, width, false, job.updatedAt);
|
|
2478
2499
|
const stepStats = widgetStepStats(theme, step, job.updatedAt);
|
|
2479
2500
|
const activitySuffix = activity ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", activity)}` : "";
|
|
@@ -2481,7 +2502,7 @@ function compactSingleWidgetLines(job: AsyncJobState, theme: Theme, width: numbe
|
|
|
2481
2502
|
const task = compactTaskText(step.description, step.label);
|
|
2482
2503
|
const taskSuffix = task ? ` ${theme.fg("dim", "·")} ${theme.fg("dim", `task: ${task}`)}` : "";
|
|
2483
2504
|
const marker = rowIndex === rows.length - 1 && rowIndex >= group.total - 1 ? "└─" : "├─";
|
|
2484
|
-
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}`);
|
|
2505
|
+
lines.push(` ${marker} ${widgetStepGlyph(step.status, theme, widgetStepRunningSeed(step, row.index), frame, thinking)} ${themeBold(theme, row.rowLabel)}${contextModeBadge(theme, step.context)} ${theme.fg("dim", "·")} ${status}${modelDisplay}${taskSuffix}${activitySuffix}${stepStats ? ` ${theme.fg("dim", "·")} ${stepStats}` : ""}`);
|
|
2485
2506
|
const lane = projectAsyncLane(job, step);
|
|
2486
2507
|
if (lane) lines.push(...formatLaneProjectionLines(lane, theme, " "));
|
|
2487
2508
|
for (const nestedLine of formatNestedWidgetLines(step.children, theme, width, false, job.updatedAt, 6)) lines.push(` ${nestedLine}`);
|
|
@@ -2555,7 +2576,8 @@ function buildSingleLineWidgetLines(jobs: AsyncJobState[], theme: Theme, width:
|
|
|
2555
2576
|
if (count > 0) parts.push(`${count} ${status}`);
|
|
2556
2577
|
}
|
|
2557
2578
|
if (!hasActive && counts.complete.length > 0) parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2558
|
-
|
|
2579
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
2580
|
+
return [truncLine(`${tone(glyph)} ${tone("subagents")} (${parts.join(", ") || `${jobs.length} total`})`, width)];
|
|
2559
2581
|
}
|
|
2560
2582
|
|
|
2561
2583
|
function orderedWidgetJobs(jobs: AsyncJobState[]): AsyncJobState[] {
|
|
@@ -2607,12 +2629,29 @@ function selectProgressiveJobKeys(jobs: AsyncJobState[], previousKeys: string[],
|
|
|
2607
2629
|
return selected;
|
|
2608
2630
|
}
|
|
2609
2631
|
|
|
2610
|
-
|
|
2632
|
+
// Counts the leaf entries collectFleetStatusEntries (fleet-status.ts) makes for a running async job,
|
|
2633
|
+
// so this matches FleetView's "N active agents": a workflow counts only its loaded child runs;
|
|
2634
|
+
// another job counts its active steps, synthesized from `agents` when it has no steps.
|
|
2635
|
+
function runningLeafAgentCount(job: AsyncJobState, projectionFor: WorkflowWidgetProjectionLookup): number {
|
|
2636
|
+
if (job.mode === "workflow") return (projectionFor(job).children ?? []).reduce((total, child) => total + runningLeafAgentCount(child, projectionFor), 0);
|
|
2637
|
+
if (job.status !== "running") return 0;
|
|
2638
|
+
const sequential = job.mode === "chain" && !job.activeParallelGroup;
|
|
2639
|
+
const current = job.currentStep ?? 0;
|
|
2640
|
+
const steps = job.steps?.length
|
|
2641
|
+
? job.steps
|
|
2642
|
+
: job.agents?.map((_, index) => ({ index, status: sequential && index !== current ? "pending" : "running" }));
|
|
2643
|
+
if (!steps?.length) return 1;
|
|
2644
|
+
return steps.filter((step, offset) => ["running", "queued", "pending"].includes(step.status)
|
|
2645
|
+
&& !(step.status === "pending" && sequential && (step.index ?? offset) !== current)).length;
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
function progressiveHeaderLine(jobs: AsyncJobState[], theme: Theme, width: number, frame: number | undefined, projectionFor: WorkflowWidgetProjectionLookup): string {
|
|
2611
2649
|
const counts = widgetHeaderCounts(jobs);
|
|
2612
2650
|
const hasActive = counts.running.length > 0 || counts.queued.length > 0;
|
|
2613
2651
|
const glyph = counts.running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(counts.running), frame)) : hasActive ? "●" : "○";
|
|
2614
2652
|
const parts: string[] = [];
|
|
2615
|
-
|
|
2653
|
+
const runningAgents = jobs.reduce((total, job) => total + runningLeafAgentCount(job, projectionFor), 0);
|
|
2654
|
+
if (runningAgents > 0) parts.push(formatAgentRunningLabel(runningAgents));
|
|
2616
2655
|
if (counts.queued.length > 0) parts.push(`${counts.queued.length} queued`);
|
|
2617
2656
|
if (!hasActive) {
|
|
2618
2657
|
if (counts.failed.length > 0) parts.push(`${counts.failed.length} failed`);
|
|
@@ -2620,12 +2659,12 @@ function progressiveHeaderLine(jobs: AsyncJobState[], theme: Theme, width: numbe
|
|
|
2620
2659
|
if (counts.paused.length > 0) parts.push(`${counts.paused.length} paused`);
|
|
2621
2660
|
if (counts.complete.length > 0) parts.push(`${counts.complete.length}/${jobs.length} done`);
|
|
2622
2661
|
}
|
|
2623
|
-
|
|
2662
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
2663
|
+
return truncLine(`${tone(glyph)} ${tone("Async agents")} ${theme.fg("dim", "·")} ${theme.fg("dim", parts.join(", ") || `${jobs.length} total`)}`, width);
|
|
2624
2664
|
}
|
|
2625
2665
|
|
|
2626
|
-
function progressiveJobLine(job: AsyncJobState, theme: Theme, width: number, frame?: number, projection = buildWorkflowWidgetProjection(job)): string {
|
|
2666
|
+
function progressiveJobLine(job: AsyncJobState, theme: Theme, width: number, frame?: number, projection = buildWorkflowWidgetProjection(job), compactRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : undefined): string {
|
|
2627
2667
|
const compactWorkflow = job.mode === "workflow";
|
|
2628
|
-
const compactRows = compactWorkflow ? compactWorkflowLaneRows(job, projection.checklist) : undefined;
|
|
2629
2668
|
const stats = compactWorkflow ? compactWorkflowStats(job, compactRows ?? [], theme, projection) : widgetStats(job, theme, projection, true);
|
|
2630
2669
|
if (compactWorkflow) {
|
|
2631
2670
|
const bottleneck = compactWorkflowBottleneck(compactRows ?? [], job);
|
|
@@ -2662,9 +2701,9 @@ function progressiveHiddenLine(hiddenJobs: AsyncJobState[], theme: Theme, width:
|
|
|
2662
2701
|
return truncLine(theme.fg("dim", ` +${hiddenJobs.length} more${parts.length ? ` (${parts.join(", ")})` : ""}`), width);
|
|
2663
2702
|
}
|
|
2664
2703
|
|
|
2665
|
-
function buildProgressiveWidgetLines(jobs: AsyncJobState[], theme: Theme, width: number, lockedRows: number, previousKeys: string[], frame?: number, projectionFor: WorkflowWidgetProjectionLookup = workflowWidgetProjectionLookup()): { lines: string[]; visibleJobKeys: string[] } {
|
|
2704
|
+
function buildProgressiveWidgetLines(jobs: AsyncJobState[], theme: Theme, width: number, lockedRows: number, previousKeys: string[], frame?: number, projectionFor: WorkflowWidgetProjectionLookup = workflowWidgetProjectionLookup()): { lines: string[]; visibleJobKeys: string[]; contentRows: number } {
|
|
2666
2705
|
const rowCount = Math.max(1, lockedRows);
|
|
2667
|
-
if (rowCount === 1) return { lines: buildSingleLineWidgetLines(jobs, theme, width, frame), visibleJobKeys: [] };
|
|
2706
|
+
if (rowCount === 1) return { lines: buildSingleLineWidgetLines(jobs, theme, width, frame), visibleJobKeys: [], contentRows: 1 };
|
|
2668
2707
|
|
|
2669
2708
|
const bodyRows = rowCount - 1;
|
|
2670
2709
|
let visibleJobKeys = selectProgressiveJobKeys(jobs, previousKeys, bodyRows);
|
|
@@ -2679,13 +2718,22 @@ function buildProgressiveWidgetLines(jobs: AsyncJobState[], theme: Theme, width:
|
|
|
2679
2718
|
hiddenJobs = jobs.filter((job) => !visibleJobKeys.includes(progressiveJobKey(job)));
|
|
2680
2719
|
}
|
|
2681
2720
|
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2721
|
+
// Rows left after every visible job line show the visible workflows' lanes.
|
|
2722
|
+
let spareRows = rowCount - 1 - visibleJobs.length - (hiddenJobs.length > 0 ? 1 : 0);
|
|
2723
|
+
const lines = [progressiveHeaderLine(jobs, theme, width, frame, projectionFor)];
|
|
2724
|
+
for (const job of visibleJobs) {
|
|
2725
|
+
const projection = projectionFor(job);
|
|
2726
|
+
const laneRows = job.mode === "workflow" ? compactWorkflowLaneRows(job, projection.checklist) : undefined;
|
|
2727
|
+
lines.push(progressiveJobLine(job, theme, width, frame, projection, laneRows));
|
|
2728
|
+
if (!laneRows || projection.inlineFleetCovered) continue;
|
|
2729
|
+
const shownLanes = laneRows.slice(0, Math.max(0, spareRows));
|
|
2730
|
+
for (const row of shownLanes) lines.push(truncLine(compactWorkflowLaneLine(row, theme, " ", frame), width));
|
|
2731
|
+
spareRows -= shownLanes.length;
|
|
2732
|
+
}
|
|
2686
2733
|
if (hiddenJobs.length > 0 && lines.length < rowCount) lines.push(progressiveHiddenLine(hiddenJobs, theme, width));
|
|
2734
|
+
const contentRows = Math.min(lines.length, rowCount);
|
|
2687
2735
|
while (lines.length < rowCount) lines.push(" ");
|
|
2688
|
-
return { lines: lines.slice(0, rowCount), visibleJobKeys };
|
|
2736
|
+
return { lines: lines.slice(0, rowCount), visibleJobKeys, contentRows };
|
|
2689
2737
|
}
|
|
2690
2738
|
|
|
2691
2739
|
function collapsedWidgetLineBudget(rows: number): number {
|
|
@@ -2728,9 +2776,17 @@ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[
|
|
|
2728
2776
|
}
|
|
2729
2777
|
|
|
2730
2778
|
if (hasMatchingSession && widgetLayoutSession?.tier === "progressive" && widgetLayoutSession.lockedRows !== undefined) {
|
|
2731
|
-
const
|
|
2732
|
-
|
|
2733
|
-
|
|
2779
|
+
const session = widgetLayoutSession;
|
|
2780
|
+
const lockedRows = widgetLayoutSession.lockedRows;
|
|
2781
|
+
let rendered = buildProgressiveWidgetLines(jobs, theme, width, lockedRows, session.visibleJobKeys, frame, projectionFor);
|
|
2782
|
+
// A job that starts after a content-sized lock can be hidden while the cap has room: grow the lock, never shrink it.
|
|
2783
|
+
const capRows = Math.min(availableRows, collapsedWidgetLineBudget(rows));
|
|
2784
|
+
if (rendered.visibleJobKeys.length < jobs.length && lockedRows < capRows) {
|
|
2785
|
+
rendered = buildProgressiveWidgetLines(jobs, theme, width, capRows, session.visibleJobKeys, frame, projectionFor);
|
|
2786
|
+
session.lockedRows = Math.max(lockedRows, rendered.contentRows);
|
|
2787
|
+
}
|
|
2788
|
+
session.visibleJobKeys = rendered.visibleJobKeys;
|
|
2789
|
+
return rendered.lines.slice(0, session.lockedRows);
|
|
2734
2790
|
}
|
|
2735
2791
|
|
|
2736
2792
|
const lines = buildLines();
|
|
@@ -2748,10 +2804,11 @@ function fitAdaptiveWidgetLines(jobs: AsyncJobState[], buildLines: () => string[
|
|
|
2748
2804
|
return buildSingleLineWidgetLines(jobs, theme, width, frame);
|
|
2749
2805
|
}
|
|
2750
2806
|
|
|
2751
|
-
|
|
2752
|
-
const rendered = buildProgressiveWidgetLines(jobs, theme, width,
|
|
2807
|
+
// Lock to the rows the content fills so the fixed-height card has no blank padding.
|
|
2808
|
+
const rendered = buildProgressiveWidgetLines(jobs, theme, width, Math.min(availableRows, collapsedWidgetLineBudget(rows)), [], frame, projectionFor);
|
|
2809
|
+
const lockedRows = rendered.contentRows;
|
|
2753
2810
|
widgetLayoutSession = { expanded, rows, columns, tier: "progressive", lockedRows, visibleJobKeys: rendered.visibleJobKeys };
|
|
2754
|
-
return rendered.lines;
|
|
2811
|
+
return rendered.lines.slice(0, lockedRows);
|
|
2755
2812
|
}
|
|
2756
2813
|
|
|
2757
2814
|
const asyncWidgetUpdates = new WeakMap<ExtensionContext["ui"], (jobs: AsyncJobState[]) => void>();
|
|
@@ -2843,7 +2900,7 @@ function materializedWidgetChildLines(job: AsyncJobState, theme: Theme, width: n
|
|
|
2843
2900
|
return lines;
|
|
2844
2901
|
}
|
|
2845
2902
|
|
|
2846
|
-
function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"]): (tui: { requestRender(): void }, theme: Theme) => Component {
|
|
2903
|
+
function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"], initiallyCollapsed = false): (tui: { requestRender(): void }, theme: Theme) => Component {
|
|
2847
2904
|
return (tui, theme) => {
|
|
2848
2905
|
const container = new Container();
|
|
2849
2906
|
let cachedRenderWidth: number | undefined;
|
|
@@ -2851,7 +2908,7 @@ function buildWidgetComponent(jobs: AsyncJobState[], ui: ExtensionContext["ui"])
|
|
|
2851
2908
|
let cachedExpanded: boolean | undefined;
|
|
2852
2909
|
let cachedLines: string[] | undefined;
|
|
2853
2910
|
let cachedCoverage = "[]";
|
|
2854
|
-
let collapsed =
|
|
2911
|
+
let collapsed = initiallyCollapsed;
|
|
2855
2912
|
const invalidate = (): void => {
|
|
2856
2913
|
cachedLines = undefined;
|
|
2857
2914
|
resetWidgetLayoutSession();
|
|
@@ -2942,7 +2999,8 @@ function buildWidgetLinesWithProjection(jobs: AsyncJobState[], theme: Theme, wid
|
|
|
2942
2999
|
const lines: string[] = [];
|
|
2943
3000
|
const hasActive = running.length > 0 || queued.length > 0;
|
|
2944
3001
|
const headerGlyph = running.length > 0 ? runningGlyph(animatedSeed(widgetJobsRunningSeed(running), frame)) : hasActive ? "●" : "○";
|
|
2945
|
-
|
|
3002
|
+
const tone = activeHeaderTone(theme, hasActive);
|
|
3003
|
+
lines.push(truncLine(`${tone(headerGlyph)} ${tone("Async agents")} ${theme.fg("dim", "· background")}`, width));
|
|
2946
3004
|
|
|
2947
3005
|
const items: string[][] = [];
|
|
2948
3006
|
let hiddenRunning = 0;
|
|
@@ -3022,7 +3080,7 @@ export function buildWidgetLines(jobs: AsyncJobState[], theme: Theme, width = ge
|
|
|
3022
3080
|
/**
|
|
3023
3081
|
* Render the async jobs widget
|
|
3024
3082
|
*/
|
|
3025
|
-
export function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[]): void {
|
|
3083
|
+
export function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[], initiallyCollapsed = false): void {
|
|
3026
3084
|
if (jobs.length === 0) {
|
|
3027
3085
|
resetWidgetLayoutSession();
|
|
3028
3086
|
asyncWidgetUpdates.delete(ctx.ui);
|
|
@@ -3038,7 +3096,7 @@ export function renderWidget(ctx: ExtensionContext, jobs: AsyncJobState[]): void
|
|
|
3038
3096
|
// component instead so progress cannot move it past other extensions' widgets.
|
|
3039
3097
|
const update = asyncWidgetUpdates.get(ctx.ui);
|
|
3040
3098
|
if (update) update(jobs);
|
|
3041
|
-
else ctx.ui.setWidget(WIDGET_KEY, buildWidgetComponent(jobs, ctx.ui));
|
|
3099
|
+
else ctx.ui.setWidget(WIDGET_KEY, buildWidgetComponent(jobs, ctx.ui, initiallyCollapsed));
|
|
3042
3100
|
}
|
|
3043
3101
|
|
|
3044
3102
|
function renderSingleCompact(
|
|
@@ -3094,18 +3152,18 @@ function renderSingleCompact(
|
|
|
3094
3152
|
return c;
|
|
3095
3153
|
}
|
|
3096
3154
|
|
|
3097
|
-
function workflowRowGlyph(row: WorkflowChatProgressRow, theme: Theme, frame?: number): string {
|
|
3155
|
+
function workflowRowGlyph(row: WorkflowChatProgressRow, theme: Theme, frame?: number, thinking?: ThinkingLevel): string {
|
|
3098
3156
|
if (row.state === "planned") return theme.fg("muted", "◦");
|
|
3099
|
-
if (row.state === "running") return theme
|
|
3157
|
+
if (row.state === "running") return runningTone(theme, thinking)(runningGlyph(frame));
|
|
3100
3158
|
if (row.state === "complete") return theme.fg("success", "✓");
|
|
3101
3159
|
if (row.state === "detached" || row.state === "stopped") return theme.fg("warning", "■");
|
|
3102
3160
|
return theme.fg("error", "✗");
|
|
3103
3161
|
}
|
|
3104
3162
|
|
|
3105
|
-
function workflowRowStateLabel(row: WorkflowChatProgressRow, theme: Theme): string {
|
|
3163
|
+
function workflowRowStateLabel(row: WorkflowChatProgressRow, theme: Theme, thinking?: ThinkingLevel): string {
|
|
3106
3164
|
const label = (row.state === "complete" ? "complete" : row.state).padEnd(8);
|
|
3107
3165
|
if (row.state === "planned") return theme.fg("dim", label);
|
|
3108
|
-
if (row.state === "running") return theme
|
|
3166
|
+
if (row.state === "running") return runningTone(theme, thinking)(label);
|
|
3109
3167
|
if (row.state === "complete") return theme.fg("success", label);
|
|
3110
3168
|
if (row.state === "detached" || row.state === "stopped") return theme.fg("warning", label);
|
|
3111
3169
|
return theme.fg("error", label);
|
|
@@ -3144,6 +3202,7 @@ function foregroundWorkflowChecklist(details: Details): WorkflowChecklistProject
|
|
|
3144
3202
|
label: node?.label ?? workflowLabelForResult(details, resultIndex) ?? result.task ?? result.agent,
|
|
3145
3203
|
phase: node?.phase,
|
|
3146
3204
|
agent: result.agent,
|
|
3205
|
+
thinking: result.thinking ?? progress?.thinking,
|
|
3147
3206
|
status,
|
|
3148
3207
|
context: result.context,
|
|
3149
3208
|
activityState: progress?.activityState,
|
|
@@ -3179,7 +3238,7 @@ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>
|
|
|
3179
3238
|
const workflow = d.workflow;
|
|
3180
3239
|
const rows = workflow ? buildWorkflowChatProgressRows(workflow.trace, d.preflight) : d.preflight ? buildWorkflowChatProgressRows([], d.preflight) : [];
|
|
3181
3240
|
const state = workflowOverallState(rows, workflow?.value !== undefined, result.isError);
|
|
3182
|
-
const glyph = state === "running" ? theme
|
|
3241
|
+
const glyph = state === "running" ? runningTone(theme)(runningGlyph(frame)) : state === "complete" ? theme.fg("success", "✓") : state === "paused" ? theme.fg("warning", "■") : theme.fg("error", "✗");
|
|
3183
3242
|
const width = getTermWidth() - 4;
|
|
3184
3243
|
const runId = d.runId ? d.runId.slice(0, 12) : "workflow";
|
|
3185
3244
|
const repoLabel = d.chatProgress?.repoLabel ?? (d.chatProgress?.repoRelation === "same" ? "same repo" : "other repo");
|
|
@@ -3200,8 +3259,10 @@ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>
|
|
|
3200
3259
|
}
|
|
3201
3260
|
const visible = visibleWorkflowRows(rows);
|
|
3202
3261
|
if (visible.hiddenRows > 0) c.addChild(new Text(truncLine(theme.fg("dim", `${rowIndent}… ${visible.hiddenRows} older workflow rows hidden`), width), 0, 0));
|
|
3262
|
+
const childLevels = new Map((d.workflowChildren?.children ?? []).map((child) => [child.childId, childThinkingLevel(child)]));
|
|
3203
3263
|
for (const row of visible.rows) {
|
|
3204
|
-
const
|
|
3264
|
+
const thinking = childLevels.get(row.key);
|
|
3265
|
+
const status = workflowRowStateLabel(row, theme, thinking);
|
|
3205
3266
|
const label = row.label && row.label !== row.key ? ` ${oneLine(row.label)}` : "";
|
|
3206
3267
|
const duration = row.durationMs !== undefined ? ` ${theme.fg("dim", `· ${formatDuration(row.durationMs)}`)}` : "";
|
|
3207
3268
|
const run = row.runId ? ` ${theme.fg("dim", `[${row.runId.slice(0, 8)}]`)}` : "";
|
|
@@ -3213,7 +3274,7 @@ function renderWorkflowChatProgress(d: Details, result: AgentToolResult<Details>
|
|
|
3213
3274
|
row.preflight.expectedOutput ? `expected:${row.preflight.expectedOutput}` : undefined,
|
|
3214
3275
|
row.preflight.independence ? `independence:${row.preflight.independence}` : undefined,
|
|
3215
3276
|
].filter((value): value is string => Boolean(value)).join(" · ") : "";
|
|
3216
|
-
c.addChild(new Text(truncLine(`${rowIndent}${workflowRowGlyph(row, theme, frame)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}${hints ? ` ${theme.fg("dim", `· ${hints}`)}` : ""}`, width), 0, 0));
|
|
3277
|
+
c.addChild(new Text(truncLine(`${rowIndent}${workflowRowGlyph(row, theme, frame, thinking)} ${status} ${theme.bold(row.key)}${label}${run}${duration}${error}${hints ? ` ${theme.fg("dim", `· ${hints}`)}` : ""}`, width), 0, 0));
|
|
3217
3278
|
}
|
|
3218
3279
|
if (workflow?.preflightWarnings?.length) {
|
|
3219
3280
|
const warningLines = expanded
|
|
@@ -3265,7 +3326,7 @@ function renderMultiCompact(d: Details, theme: Theme, layout: MainWindowRenderLa
|
|
|
3265
3326
|
seed: runningSeed(progressRunningSeed(totalSummary), d.currentStepIndex),
|
|
3266
3327
|
frame,
|
|
3267
3328
|
});
|
|
3268
|
-
const glyph =
|
|
3329
|
+
const glyph = presentationTone(aggregatePresentation, theme)(aggregatePresentation.glyph);
|
|
3269
3330
|
const contextBadge = contextModeBadge(theme, d.context);
|
|
3270
3331
|
const c = new Container();
|
|
3271
3332
|
const width = getTermWidth() - 4;
|
|
@@ -3373,7 +3434,7 @@ export function renderSubagentSummary(
|
|
|
3373
3434
|
const partial = Boolean(details && workflowGraphHasStatus(details, ["partial"]));
|
|
3374
3435
|
const state = running ? "running" : failed ? "failed" : stopped ? "stopped" : paused ? "paused" : partial ? "partial" : "completed";
|
|
3375
3436
|
const glyph = state === "running"
|
|
3376
|
-
? theme.
|
|
3437
|
+
? runningTone(theme, details?.mode === "single" && results.length === 1 ? childThinkingLevel(results[0], results[0]?.progress) : undefined)(STATIC_RUNNING_GLYPH)
|
|
3377
3438
|
: state === "completed"
|
|
3378
3439
|
? theme.fg("success", "✓")
|
|
3379
3440
|
: state === "failed"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { ThinkingLevel } from "../shared/model-info.ts";
|
|
3
|
+
import { isStaleExtensionContextError, isUnboundExtensionRuntimeError } from "../shared/extension-context.ts";
|
|
4
|
+
|
|
5
|
+
type Theme = Pick<ExtensionContext["ui"]["theme"], "fg" | "getThinkingBorderColor">;
|
|
6
|
+
|
|
7
|
+
let mainThinkingLevelSource: () => ThinkingLevel | undefined = () => undefined;
|
|
8
|
+
|
|
9
|
+
/** Registers where the main session's current thinking level is read; glyphs that stand for several children take its color. */
|
|
10
|
+
export function setMainThinkingLevelSource(source: () => ThinkingLevel | undefined): void {
|
|
11
|
+
mainThinkingLevelSource = source;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Reads the main session's level through `read`; a stale or not-yet-bound Pi runtime has no level to show. */
|
|
15
|
+
export function readMainThinkingLevel(read: () => ThinkingLevel): ThinkingLevel | undefined {
|
|
16
|
+
try {
|
|
17
|
+
return read();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
if (isStaleExtensionContextError(error) || isUnboundExtensionRuntimeError(error)) return undefined;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The running tone of a glyph: Pi's prompt-box color for the recorded level of the one child it stands for, else for the main session's current level, else accent. */
|
|
25
|
+
export function runningTone(theme: Theme, childLevel?: ThinkingLevel): (text: string) => string {
|
|
26
|
+
const level = childLevel ?? mainThinkingLevelSource();
|
|
27
|
+
return level ? theme.getThinkingBorderColor(level) : (text) => theme.fg("accent", text);
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
1
|
+
import { execFile, spawnSync } from "node:child_process";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
4
4
|
import { Type, type Static } from "typebox";
|
|
@@ -25,17 +25,31 @@ function runGit(root: string, args: string[]): { ok: boolean; stdout: string; st
|
|
|
25
25
|
return { ok: result.status === 0, stdout: result.stdout ?? "", stderr: (result.stderr ?? "").trim() };
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const root =
|
|
35
|
-
const ref = head.stdout.trim();
|
|
28
|
+
const BASELINE_ARGS = ["rev-parse", "--show-toplevel", "HEAD"];
|
|
29
|
+
|
|
30
|
+
function parseBaseline(stdout: string): WatchdogDiffBaseline | undefined {
|
|
31
|
+
// HEAD is the last line; the repository path itself may contain newlines.
|
|
32
|
+
const lines = stdout.trim().split(/\r?\n/);
|
|
33
|
+
const ref = lines.pop();
|
|
34
|
+
const root = lines.join("\n");
|
|
36
35
|
return root && ref ? { root, ref } : undefined;
|
|
37
36
|
}
|
|
38
37
|
|
|
38
|
+
/** HEAD at reviewer launch, for tools that must be registered synchronously. */
|
|
39
|
+
export function captureWatchdogDiffBaseline(cwd: string): WatchdogDiffBaseline | undefined {
|
|
40
|
+
const result = runGit(cwd, BASELINE_ARGS);
|
|
41
|
+
return result.ok ? parseBaseline(result.stdout) : undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** HEAD at session start, so later child commits still show in the diff. Does not block the event loop. */
|
|
45
|
+
export function startWatchdogDiffBaselineCapture(cwd: string): Promise<WatchdogDiffBaseline | undefined> {
|
|
46
|
+
return new Promise((resolve) => {
|
|
47
|
+
execFile("git", ["-C", cwd, ...BASELINE_ARGS], { encoding: "utf-8", windowsHide: true }, (error, stdout) => {
|
|
48
|
+
resolve(error ? undefined : parseBaseline(stdout));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
function validatePath(value: string | undefined): string | undefined {
|
|
40
54
|
const trimmed = value?.trim();
|
|
41
55
|
if (!trimmed) return undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import {
|
|
2
|
+
import { startWatchdogDiffBaselineCapture, type WatchdogDiffBaseline } from "./diff-tool.ts";
|
|
3
3
|
import { MainWatchdogRuntime } from "./runtime.ts";
|
|
4
4
|
import { createMainWatchdogReview } from "./review.ts";
|
|
5
5
|
import { DEFAULT_WATCHDOG_CONFIG } from "./settings.ts";
|
|
@@ -57,7 +57,7 @@ export function registerChildWatchdog(
|
|
|
57
57
|
if (!childConfig) return undefined;
|
|
58
58
|
if (!writeStatus) throw new Error("Child watchdog status sink is missing; the host must pass ChildRuntimeConfig.watchdogStatus.");
|
|
59
59
|
let currentContext: ExtensionContext | undefined;
|
|
60
|
-
let diffBaseline: WatchdogDiffBaseline | undefined;
|
|
60
|
+
let diffBaseline: Promise<WatchdogDiffBaseline | undefined> | undefined;
|
|
61
61
|
let agentSettled = false;
|
|
62
62
|
let seq = 0;
|
|
63
63
|
const emitStatus = (phase: ChildWatchdogPhase, reason?: string, warning?: ChildWatchdogWarningSummary): void => {
|
|
@@ -98,7 +98,7 @@ export function registerChildWatchdog(
|
|
|
98
98
|
const onRuntimeEvent = pi.on as unknown as (event: string, handler: (event: unknown, ctx: ExtensionContext) => unknown) => void;
|
|
99
99
|
onRuntimeEvent("session_start", (_event, ctx) => {
|
|
100
100
|
rememberContext(ctx);
|
|
101
|
-
diffBaseline =
|
|
101
|
+
diffBaseline = startWatchdogDiffBaselineCapture(ctx.cwd);
|
|
102
102
|
runtime.bindSession(ctx);
|
|
103
103
|
emitStatus("idle");
|
|
104
104
|
});
|
|
@@ -2,7 +2,7 @@ import type { ExtensionAPI, ExtensionCommandContext, ExtensionContext } from "@e
|
|
|
2
2
|
import { Text } from "@earendil-works/pi-tui";
|
|
3
3
|
import { resolveEffectiveThinking, splitKnownThinkingSuffix, THINKING_LEVELS, type ThinkingLevel } from "../shared/model-info.ts";
|
|
4
4
|
import { SLASH_TEXT_RESULT_TYPE } from "../shared/types.ts";
|
|
5
|
-
import {
|
|
5
|
+
import { startWatchdogDiffBaselineCapture, type WatchdogDiffBaseline } from "./diff-tool.ts";
|
|
6
6
|
import { formatWatchdogRecommendation, recommendWatchdogModel, resolveWatchdogModelInput, parseWatchdogThinkingInput } from "./model-selection.ts";
|
|
7
7
|
import { renderWatchdogWarning } from "./render.ts";
|
|
8
8
|
import { createMainWatchdogReview } from "./review.ts";
|
|
@@ -372,7 +372,7 @@ async function handleWatchdogCommand(
|
|
|
372
372
|
|
|
373
373
|
export function registerMainWatchdog(pi: ExtensionAPI, options: RegisterMainWatchdogOptions = {}): MainWatchdogRuntime {
|
|
374
374
|
let currentContext: ExtensionContext | undefined;
|
|
375
|
-
let diffBaseline: WatchdogDiffBaseline | undefined;
|
|
375
|
+
let diffBaseline: Promise<WatchdogDiffBaseline | undefined> | undefined;
|
|
376
376
|
const rememberContext = (ctx: ExtensionContext) => {
|
|
377
377
|
currentContext = ctx;
|
|
378
378
|
};
|
|
@@ -412,7 +412,7 @@ export function registerMainWatchdog(pi: ExtensionAPI, options: RegisterMainWatc
|
|
|
412
412
|
|
|
413
413
|
pi.on("session_start", (_event, ctx) => {
|
|
414
414
|
rememberContext(ctx);
|
|
415
|
-
diffBaseline =
|
|
415
|
+
diffBaseline = startWatchdogDiffBaselineCapture(ctx.cwd);
|
|
416
416
|
runtime.bindSession(ctx);
|
|
417
417
|
});
|
|
418
418
|
pi.on("before_agent_start", (event, ctx) => {
|
package/src/watchdog/review.ts
CHANGED
|
@@ -56,7 +56,7 @@ export interface CreateMainWatchdogReviewOptions {
|
|
|
56
56
|
streamFn?: StreamFn;
|
|
57
57
|
createReadOnlyTools?: (cwd: string) => AgentTool[];
|
|
58
58
|
getThinkingLevel?: () => ThinkingLevel | undefined;
|
|
59
|
-
diffBaseline?: () => WatchdogDiffBaseline | undefined;
|
|
59
|
+
diffBaseline?: () => Promise<WatchdogDiffBaseline | undefined> | undefined;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function fullModelId(model: Pick<RegistryModel, "provider" | "id">): string {
|
|
@@ -290,7 +290,7 @@ async function runWatchdogAttempt(ctx: ExtensionContext, request: WatchdogReview
|
|
|
290
290
|
headers: { ...opencodeSessionHeaders(model, sessionId), ...(streamOptions?.headers ?? {}), ...(auth.headers ?? {}) },
|
|
291
291
|
});
|
|
292
292
|
};
|
|
293
|
-
const diffBaseline = options.diffBaseline?.();
|
|
293
|
+
const diffBaseline = await options.diffBaseline?.();
|
|
294
294
|
let clarification: { question: string; evidence: string } | undefined;
|
|
295
295
|
let warned = false;
|
|
296
296
|
let toolCount = 0;
|