pi-crew 0.1.41 → 0.1.44
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 +47 -0
- package/README.md +51 -0
- package/agents/analyst.md +11 -11
- package/agents/critic.md +11 -11
- package/agents/executor.md +11 -11
- package/agents/explorer.md +11 -11
- package/agents/planner.md +11 -11
- package/agents/reviewer.md +11 -11
- package/agents/security-reviewer.md +11 -11
- package/agents/test-engineer.md +11 -11
- package/agents/verifier.md +11 -11
- package/agents/writer.md +11 -11
- package/docs/refactor-tasks-phase3.md +394 -394
- package/docs/refactor-tasks-phase4.md +564 -564
- package/docs/refactor-tasks-phase5.md +402 -402
- package/docs/refactor-tasks-phase6.md +662 -662
- package/docs/research-extension-examples.md +297 -297
- package/docs/research-extension-system.md +324 -324
- package/docs/research-optimization-plan.md +548 -548
- package/docs/research-phase10-distillation.md +199 -0
- package/docs/research-phase11-distillation.md +201 -0
- package/docs/research-pi-coding-agent.md +357 -357
- package/docs/research-source-pi-crew-reference.md +174 -174
- package/docs/runtime-flow.md +148 -148
- package/docs/source-runtime-refactor-map.md +83 -83
- package/index.ts +6 -6
- package/package.json +1 -1
- package/src/agents/agent-serializer.ts +34 -34
- package/src/agents/discover-agents.ts +5 -4
- package/src/config/config.ts +28 -4
- package/src/extension/cross-extension-rpc.ts +82 -82
- package/src/extension/management.ts +37 -8
- package/src/extension/notification-router.ts +2 -2
- package/src/extension/register.ts +130 -8
- package/src/extension/registration/commands.ts +11 -9
- package/src/extension/registration/compaction-guard.ts +125 -125
- package/src/extension/registration/subagent-tools.ts +28 -19
- package/src/extension/registration/team-tool.ts +2 -1
- package/src/extension/result-watcher.ts +4 -4
- package/src/extension/run-bundle-schema.ts +8 -4
- package/src/extension/run-import.ts +4 -0
- package/src/extension/run-index.ts +23 -1
- package/src/extension/run-maintenance.ts +43 -24
- package/src/extension/team-tool/api.ts +2 -2
- package/src/extension/team-tool/cancel.ts +76 -4
- package/src/extension/team-tool/context.ts +1 -0
- package/src/extension/team-tool/doctor.ts +8 -1
- package/src/extension/team-tool/handle-settings.ts +188 -0
- package/src/extension/team-tool/inspect.ts +41 -41
- package/src/extension/team-tool/lifecycle-actions.ts +79 -79
- package/src/extension/team-tool/plan.ts +19 -19
- package/src/extension/team-tool/respond.ts +67 -0
- package/src/extension/team-tool/run.ts +6 -4
- package/src/extension/team-tool/status.ts +99 -93
- package/src/extension/team-tool-types.ts +4 -0
- package/src/extension/team-tool.ts +5 -1
- package/src/i18n.ts +184 -0
- package/src/observability/correlation.ts +2 -2
- package/src/observability/event-to-metric.ts +10 -3
- package/src/observability/exporters/adapter.ts +7 -1
- package/src/observability/exporters/otlp-exporter.ts +14 -2
- package/src/observability/exporters/prometheus-exporter.ts +9 -2
- package/src/observability/metric-registry.ts +18 -3
- package/src/observability/metric-retention.ts +11 -3
- package/src/observability/metric-sink.ts +9 -4
- package/src/observability/metrics-primitives.ts +4 -3
- package/src/prompt/prompt-runtime.ts +72 -68
- package/src/runtime/agent-control.ts +63 -63
- package/src/runtime/agent-memory.ts +72 -72
- package/src/runtime/agent-observability.ts +114 -114
- package/src/runtime/async-marker.ts +26 -26
- package/src/runtime/attention-events.ts +28 -23
- package/src/runtime/background-runner.ts +53 -53
- package/src/runtime/child-pi.ts +4 -4
- package/src/runtime/completion-guard.ts +95 -4
- package/src/runtime/concurrency.ts +1 -1
- package/src/runtime/crash-recovery.ts +32 -1
- package/src/runtime/crew-agent-runtime.ts +59 -58
- package/src/runtime/deadletter.ts +14 -4
- package/src/runtime/delivery-coordinator.ts +143 -0
- package/src/runtime/direct-run.ts +35 -35
- package/src/runtime/foreground-control.ts +82 -82
- package/src/runtime/green-contract.ts +46 -46
- package/src/runtime/group-join.ts +106 -106
- package/src/runtime/heartbeat-gradient.ts +28 -28
- package/src/runtime/heartbeat-watcher.ts +48 -4
- package/src/runtime/live-agent-control.ts +87 -87
- package/src/runtime/live-agent-manager.ts +85 -85
- package/src/runtime/live-control-realtime.ts +36 -36
- package/src/runtime/live-session-runtime.ts +305 -305
- package/src/runtime/manifest-cache.ts +2 -2
- package/src/runtime/model-fallback.ts +272 -261
- package/src/runtime/overflow-recovery.ts +157 -0
- package/src/runtime/parallel-research.ts +44 -44
- package/src/runtime/parallel-utils.ts +1 -1
- package/src/runtime/pi-json-output.ts +111 -111
- package/src/runtime/policy-engine.ts +79 -78
- package/src/runtime/post-exit-stdio-guard.ts +2 -2
- package/src/runtime/process-status.ts +56 -56
- package/src/runtime/progress-event-coalescer.ts +43 -43
- package/src/runtime/recovery-recipes.ts +74 -74
- package/src/runtime/retry-executor.ts +5 -0
- package/src/runtime/role-permission.ts +39 -39
- package/src/runtime/runtime-resolver.ts +1 -1
- package/src/runtime/session-resources.ts +25 -0
- package/src/runtime/session-snapshot.ts +59 -0
- package/src/runtime/session-usage.ts +79 -79
- package/src/runtime/sidechain-output.ts +29 -29
- package/src/runtime/stale-reconciler.ts +179 -0
- package/src/runtime/subagent-manager.ts +3 -3
- package/src/runtime/supervisor-contact.ts +59 -0
- package/src/runtime/task-display.ts +38 -38
- package/src/runtime/task-output-context.ts +127 -127
- package/src/runtime/task-runner/live-executor.ts +101 -101
- package/src/runtime/task-runner/progress.ts +119 -111
- package/src/runtime/task-runner/result-utils.ts +14 -14
- package/src/runtime/task-runner/state-helpers.ts +22 -22
- package/src/runtime/task-runner.ts +14 -0
- package/src/runtime/team-runner.ts +9 -10
- package/src/runtime/worker-heartbeat.ts +21 -21
- package/src/runtime/worker-startup.ts +57 -57
- package/src/schema/config-schema.ts +2 -1
- package/src/schema/team-tool-schema.ts +115 -109
- package/src/state/artifact-store.ts +4 -2
- package/src/state/atomic-write.ts +12 -4
- package/src/state/contracts.ts +109 -105
- package/src/state/event-log.ts +3 -4
- package/src/state/jsonl-writer.ts +4 -1
- package/src/state/locks.ts +9 -1
- package/src/state/task-claims.ts +44 -42
- package/src/state/usage.ts +29 -29
- package/src/subagents/async-entry.ts +1 -1
- package/src/subagents/index.ts +3 -3
- package/src/subagents/live/control.ts +1 -1
- package/src/subagents/live/manager.ts +1 -1
- package/src/subagents/live/realtime.ts +1 -1
- package/src/subagents/live/session-runtime.ts +1 -1
- package/src/subagents/manager.ts +1 -1
- package/src/subagents/spawn.ts +1 -1
- package/src/teams/discover-teams.ts +2 -2
- package/src/teams/team-serializer.ts +38 -38
- package/src/types/diff.d.ts +18 -18
- package/src/ui/crew-footer.ts +101 -101
- package/src/ui/crew-select-list.ts +111 -111
- package/src/ui/crew-widget.ts +5 -4
- package/src/ui/dashboard-panes/metrics-pane.ts +34 -34
- package/src/ui/dynamic-border.ts +25 -25
- package/src/ui/layout-primitives.ts +106 -106
- package/src/ui/live-run-sidebar.ts +1 -1
- package/src/ui/loaders.ts +158 -158
- package/src/ui/mascot.ts +3 -2
- package/src/ui/powerbar-publisher.ts +7 -6
- package/src/ui/render-diff.ts +119 -119
- package/src/ui/render-scheduler.ts +54 -14
- package/src/ui/run-dashboard.ts +39 -11
- package/src/ui/run-snapshot-cache.ts +336 -36
- package/src/ui/spinner.ts +17 -17
- package/src/ui/status-colors.ts +58 -54
- package/src/ui/syntax-highlight.ts +116 -116
- package/src/ui/theme-adapter.ts +1 -1
- package/src/ui/transcript-viewer.ts +7 -2
- package/src/utils/atomic-write.ts +33 -0
- package/src/utils/completion-dedupe.ts +63 -63
- package/src/utils/file-coalescer.ts +5 -3
- package/src/utils/frontmatter.ts +68 -36
- package/src/utils/git.ts +262 -262
- package/src/utils/ids.ts +12 -12
- package/src/utils/internal-error.ts +1 -1
- package/src/utils/names.ts +27 -26
- package/src/utils/paths.ts +1 -1
- package/src/utils/redaction.ts +44 -41
- package/src/utils/safe-paths.ts +47 -34
- package/src/utils/sleep.ts +2 -2
- package/src/utils/timings.ts +2 -0
- package/src/utils/visual.ts +9 -1
- package/src/workflows/discover-workflows.ts +4 -1
- package/src/workflows/validate-workflow.ts +40 -40
- package/src/worktree/branch-freshness.ts +45 -45
- package/src/worktree/worktree-manager.ts +6 -1
- package/teams/default.team.md +12 -12
- package/teams/fast-fix.team.md +11 -11
- package/teams/implementation.team.md +18 -18
- package/teams/parallel-research.team.md +14 -14
- package/teams/research.team.md +11 -11
- package/teams/review.team.md +12 -12
- package/workflows/default.workflow.md +29 -29
- package/workflows/fast-fix.workflow.md +22 -22
- package/workflows/implementation.workflow.md +38 -38
- package/workflows/parallel-research.workflow.md +46 -46
- package/workflows/research.workflow.md +22 -22
- package/workflows/review.workflow.md +30 -30
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
import { pad, truncate } from "../utils/visual.ts";
|
|
2
|
-
import type { CrewTheme } from "./theme-adapter.ts";
|
|
3
|
-
|
|
4
|
-
export interface CrewSelectItem<T = string> {
|
|
5
|
-
value: T;
|
|
6
|
-
label: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface CrewSelectListOptions<T = string> {
|
|
11
|
-
onSelect: (item: CrewSelectItem<T>) => void;
|
|
12
|
-
onCancel: () => void;
|
|
13
|
-
onPreview?: (item: CrewSelectItem<T>) => void;
|
|
14
|
-
maxHeight?: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class CrewSelectList<T = string> {
|
|
18
|
-
private readonly items: CrewSelectItem<T>[];
|
|
19
|
-
private readonly theme: CrewTheme;
|
|
20
|
-
private readonly options: CrewSelectListOptions<T>;
|
|
21
|
-
private selectedIndex = 0;
|
|
22
|
-
private scrollOffset = 0;
|
|
23
|
-
|
|
24
|
-
constructor(items: CrewSelectItem<T>[], theme: CrewTheme, options: CrewSelectListOptions<T>) {
|
|
25
|
-
this.items = [...items];
|
|
26
|
-
this.theme = theme;
|
|
27
|
-
this.options = options;
|
|
28
|
-
this.selectedIndex = this.items.length ? 0 : -1;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
invalidate(): void {}
|
|
32
|
-
|
|
33
|
-
getSelected(): CrewSelectItem<T> | undefined {
|
|
34
|
-
return this.selectedIndex >= 0 ? this.items[this.selectedIndex] : undefined;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
setSelectedIndex(index: number): void {
|
|
38
|
-
if (!this.items.length) {
|
|
39
|
-
this.selectedIndex = -1;
|
|
40
|
-
this.scrollOffset = 0;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const next = Math.min(this.items.length - 1, Math.max(0, index));
|
|
44
|
-
const changed = next !== this.selectedIndex;
|
|
45
|
-
this.selectedIndex = next;
|
|
46
|
-
this.ensureVisible();
|
|
47
|
-
if (changed) {
|
|
48
|
-
const selected = this.getSelected();
|
|
49
|
-
if (selected) this.options.onPreview?.(selected);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
handleInput(data: string): void {
|
|
54
|
-
if (data === "q" || data === "\u001b") {
|
|
55
|
-
this.options.onCancel();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (data === "j" || data === "\u001b[B") {
|
|
59
|
-
this.setSelectedIndex(this.selectedIndex + 1);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (data === "k" || data === "\u001b[A") {
|
|
63
|
-
this.setSelectedIndex(this.selectedIndex - 1);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (data === "\r" || data === "\n") {
|
|
67
|
-
const selected = this.getSelected();
|
|
68
|
-
if (selected) this.options.onSelect(selected);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
render(width: number): string[] {
|
|
73
|
-
if (!this.items.length) return [this.theme.fg("muted", "(no items)")];
|
|
74
|
-
const maxHeight = Math.max(1, Math.floor(this.options.maxHeight ?? this.items.length));
|
|
75
|
-
this.ensureVisible();
|
|
76
|
-
const hasTop = this.scrollOffset > 0;
|
|
77
|
-
const availableWithoutBottom = Math.max(1, maxHeight - (hasTop ? 1 : 0));
|
|
78
|
-
const hasBottom = this.scrollOffset + availableWithoutBottom < this.items.length;
|
|
79
|
-
const slots = this.visibleItemSlots(maxHeight, hasTop, hasBottom);
|
|
80
|
-
const visibleItems = this.items.slice(this.scrollOffset, this.scrollOffset + slots);
|
|
81
|
-
const lines: string[] = [];
|
|
82
|
-
if (hasTop) lines.push(this.theme.fg("muted", `↑ ${this.scrollOffset} more`));
|
|
83
|
-
for (const [offset, item] of visibleItems.entries()) {
|
|
84
|
-
const index = this.scrollOffset + offset;
|
|
85
|
-
const prefix = index === this.selectedIndex ? " → " : " ";
|
|
86
|
-
const suffix = item.description ? this.theme.fg("dim", ` — ${item.description}`) : "";
|
|
87
|
-
const raw = `${prefix}${item.label}${suffix}`;
|
|
88
|
-
const line = index === this.selectedIndex ? this.theme.inverse?.(raw) ?? raw : raw;
|
|
89
|
-
lines.push(pad(truncate(line, width, "..."), Math.max(1, width)));
|
|
90
|
-
}
|
|
91
|
-
if (hasBottom) lines.push(this.theme.fg("muted", `↓ ${this.items.length - (this.scrollOffset + slots)} more`));
|
|
92
|
-
return lines.slice(0, maxHeight);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private visibleItemSlots(maxHeight: number, hasTop: boolean, hasBottom: boolean): number {
|
|
96
|
-
return Math.max(1, maxHeight - (hasTop ? 1 : 0) - (hasBottom ? 1 : 0));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private ensureVisible(): void {
|
|
100
|
-
if (this.selectedIndex < 0) return;
|
|
101
|
-
const maxHeight = Math.max(1, Math.floor(this.options.maxHeight ?? this.items.length));
|
|
102
|
-
const reservedTop = this.scrollOffset > 0 ? 1 : 0;
|
|
103
|
-
const visibleSlots = Math.max(1, maxHeight - reservedTop - 1);
|
|
104
|
-
if (this.selectedIndex < this.scrollOffset) {
|
|
105
|
-
this.scrollOffset = this.selectedIndex;
|
|
106
|
-
} else if (this.selectedIndex >= this.scrollOffset + visibleSlots) {
|
|
107
|
-
this.scrollOffset = Math.max(0, this.selectedIndex - visibleSlots + 1);
|
|
108
|
-
}
|
|
109
|
-
this.scrollOffset = Math.min(this.scrollOffset, Math.max(0, this.items.length - 1));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
1
|
+
import { pad, truncate } from "../utils/visual.ts";
|
|
2
|
+
import type { CrewTheme } from "./theme-adapter.ts";
|
|
3
|
+
|
|
4
|
+
export interface CrewSelectItem<T = string> {
|
|
5
|
+
value: T;
|
|
6
|
+
label: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CrewSelectListOptions<T = string> {
|
|
11
|
+
onSelect: (item: CrewSelectItem<T>) => void;
|
|
12
|
+
onCancel: () => void;
|
|
13
|
+
onPreview?: (item: CrewSelectItem<T>) => void;
|
|
14
|
+
maxHeight?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class CrewSelectList<T = string> {
|
|
18
|
+
private readonly items: CrewSelectItem<T>[];
|
|
19
|
+
private readonly theme: CrewTheme;
|
|
20
|
+
private readonly options: CrewSelectListOptions<T>;
|
|
21
|
+
private selectedIndex = 0;
|
|
22
|
+
private scrollOffset = 0;
|
|
23
|
+
|
|
24
|
+
constructor(items: CrewSelectItem<T>[], theme: CrewTheme, options: CrewSelectListOptions<T>) {
|
|
25
|
+
this.items = [...items];
|
|
26
|
+
this.theme = theme;
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.selectedIndex = this.items.length ? 0 : -1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
invalidate(): void {}
|
|
32
|
+
|
|
33
|
+
getSelected(): CrewSelectItem<T> | undefined {
|
|
34
|
+
return this.selectedIndex >= 0 ? this.items[this.selectedIndex] : undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
setSelectedIndex(index: number): void {
|
|
38
|
+
if (!this.items.length) {
|
|
39
|
+
this.selectedIndex = -1;
|
|
40
|
+
this.scrollOffset = 0;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const next = Math.min(this.items.length - 1, Math.max(0, index));
|
|
44
|
+
const changed = next !== this.selectedIndex;
|
|
45
|
+
this.selectedIndex = next;
|
|
46
|
+
this.ensureVisible();
|
|
47
|
+
if (changed) {
|
|
48
|
+
const selected = this.getSelected();
|
|
49
|
+
if (selected) this.options.onPreview?.(selected);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
handleInput(data: string): void {
|
|
54
|
+
if (data === "q" || data === "\u001b") {
|
|
55
|
+
this.options.onCancel();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (data === "j" || data === "\u001b[B") {
|
|
59
|
+
this.setSelectedIndex(this.selectedIndex + 1);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (data === "k" || data === "\u001b[A") {
|
|
63
|
+
this.setSelectedIndex(this.selectedIndex - 1);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (data === "\r" || data === "\n") {
|
|
67
|
+
const selected = this.getSelected();
|
|
68
|
+
if (selected) this.options.onSelect(selected);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render(width: number): string[] {
|
|
73
|
+
if (!this.items.length) return [this.theme.fg("muted", "(no items)")];
|
|
74
|
+
const maxHeight = Math.max(1, Math.floor(this.options.maxHeight ?? this.items.length));
|
|
75
|
+
this.ensureVisible();
|
|
76
|
+
const hasTop = this.scrollOffset > 0;
|
|
77
|
+
const availableWithoutBottom = Math.max(1, maxHeight - (hasTop ? 1 : 0));
|
|
78
|
+
const hasBottom = this.scrollOffset + availableWithoutBottom < this.items.length;
|
|
79
|
+
const slots = this.visibleItemSlots(maxHeight, hasTop, hasBottom);
|
|
80
|
+
const visibleItems = this.items.slice(this.scrollOffset, this.scrollOffset + slots);
|
|
81
|
+
const lines: string[] = [];
|
|
82
|
+
if (hasTop) lines.push(this.theme.fg("muted", `↑ ${this.scrollOffset} more`));
|
|
83
|
+
for (const [offset, item] of visibleItems.entries()) {
|
|
84
|
+
const index = this.scrollOffset + offset;
|
|
85
|
+
const prefix = index === this.selectedIndex ? " → " : " ";
|
|
86
|
+
const suffix = item.description ? this.theme.fg("dim", ` — ${item.description}`) : "";
|
|
87
|
+
const raw = `${prefix}${item.label}${suffix}`;
|
|
88
|
+
const line = index === this.selectedIndex ? this.theme.inverse?.(raw) ?? raw : raw;
|
|
89
|
+
lines.push(pad(truncate(line, width, "..."), Math.max(1, width)));
|
|
90
|
+
}
|
|
91
|
+
if (hasBottom) lines.push(this.theme.fg("muted", `↓ ${this.items.length - (this.scrollOffset + slots)} more`));
|
|
92
|
+
return lines.slice(0, maxHeight);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private visibleItemSlots(maxHeight: number, hasTop: boolean, hasBottom: boolean): number {
|
|
96
|
+
return Math.max(1, maxHeight - (hasTop ? 1 : 0) - (hasBottom ? 1 : 0));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private ensureVisible(): void {
|
|
100
|
+
if (this.selectedIndex < 0) return;
|
|
101
|
+
const maxHeight = Math.max(1, Math.floor(this.options.maxHeight ?? this.items.length));
|
|
102
|
+
const reservedTop = this.scrollOffset > 0 ? 1 : 0;
|
|
103
|
+
const visibleSlots = Math.max(1, maxHeight - reservedTop - 1);
|
|
104
|
+
if (this.selectedIndex < this.scrollOffset) {
|
|
105
|
+
this.scrollOffset = this.selectedIndex;
|
|
106
|
+
} else if (this.selectedIndex >= this.scrollOffset + visibleSlots) {
|
|
107
|
+
this.scrollOffset = Math.max(0, this.selectedIndex - visibleSlots + 1);
|
|
108
|
+
}
|
|
109
|
+
this.scrollOffset = Math.min(this.scrollOffset, Math.max(0, this.items.length - 1));
|
|
110
|
+
}
|
|
111
|
+
}
|
package/src/ui/crew-widget.ts
CHANGED
|
@@ -100,12 +100,12 @@ function agentsFor(run: TeamRunManifest): CrewAgentRecord[] {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
export function activeWidgetRuns(cwd: string, manifestCache?: ManifestCache, snapshotCache?: RunSnapshotCache): WidgetRun[] {
|
|
104
|
-
const runs = manifestCache ? manifestCache.list(20) : listRecentRuns(cwd, 20);
|
|
103
|
+
export function activeWidgetRuns(cwd: string, manifestCache?: ManifestCache, snapshotCache?: RunSnapshotCache, preloadedManifests?: TeamRunManifest[]): WidgetRun[] {
|
|
104
|
+
const runs = preloadedManifests ?? (manifestCache ? manifestCache.list(20) : listRecentRuns(cwd, 20));
|
|
105
105
|
return runs
|
|
106
106
|
.map((run) => {
|
|
107
107
|
try {
|
|
108
|
-
const snapshot = snapshotCache?.refreshIfStale(run.runId);
|
|
108
|
+
const snapshot = snapshotCache?.get(run.runId) ?? snapshotCache?.refreshIfStale(run.runId);
|
|
109
109
|
return snapshot ? { run: snapshot.manifest, agents: snapshot.agents, snapshot } : { run, agents: agentsFor(run) };
|
|
110
110
|
} catch {
|
|
111
111
|
return { run, agents: agentsFor(run) };
|
|
@@ -279,11 +279,12 @@ export function updateCrewWidget(
|
|
|
279
279
|
config?: CrewUiConfig,
|
|
280
280
|
manifestCache?: ManifestCache,
|
|
281
281
|
snapshotCache?: RunSnapshotCache,
|
|
282
|
+
preloadedManifests?: TeamRunManifest[],
|
|
282
283
|
): void {
|
|
283
284
|
if (!ctx.hasUI) return;
|
|
284
285
|
state.frame += 1;
|
|
285
286
|
const maxLines = config?.widgetMaxLines ?? MAX_LINES_DEFAULT;
|
|
286
|
-
const runs = activeWidgetRuns(ctx.cwd, manifestCache, snapshotCache);
|
|
287
|
+
const runs = activeWidgetRuns(ctx.cwd, manifestCache, snapshotCache, preloadedManifests);
|
|
287
288
|
const lines = buildCrewWidgetLines(ctx.cwd, state.frame, maxLines, runs, state.notificationCount ?? 0);
|
|
288
289
|
const placement = config?.widgetPlacement ?? "aboveEditor";
|
|
289
290
|
ctx.ui.setStatus(STATUS_KEY, lines.length ? statusSummary(runs) : undefined);
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import type { MetricRegistry } from "../../observability/metric-registry.ts";
|
|
2
|
-
import type { HistogramPoint, MetricLabels, MetricPoint } from "../../observability/metrics-primitives.ts";
|
|
3
|
-
import type { RunUiSnapshot } from "../snapshot-types.ts";
|
|
4
|
-
|
|
5
|
-
export interface MetricsPaneOptions {
|
|
6
|
-
registry?: MetricRegistry;
|
|
7
|
-
maxCounters?: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function labelsText(labels: MetricLabels): string {
|
|
11
|
-
const entries = Object.entries(labels);
|
|
12
|
-
return entries.length ? `{${entries.map(([key, value]) => `${key}=${value}`).join(",")}}` : "";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function isHistogramPoint(point: MetricPoint | HistogramPoint): point is HistogramPoint {
|
|
16
|
-
return "quantiles" in point;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function renderMetricsPane(_snapshot: RunUiSnapshot | undefined, opts: MetricsPaneOptions = {}): string[] {
|
|
20
|
-
if (!opts.registry) return ["Metrics pane: registry unavailable"];
|
|
21
|
-
const snapshots = opts.registry.snapshot();
|
|
22
|
-
if (!snapshots.length) return ["Metrics pane: no metrics recorded"];
|
|
23
|
-
const lines = ["Metrics pane: top metrics"];
|
|
24
|
-
for (const snapshot of snapshots.slice(0, opts.maxCounters ?? 10)) {
|
|
25
|
-
const first = snapshot.values[0];
|
|
26
|
-
if (!first) {
|
|
27
|
-
lines.push(`${snapshot.name}: empty`);
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (isHistogramPoint(first)) lines.push(`${snapshot.name}${labelsText(first.labels)} count=${first.count} p95=${Number.isFinite(first.quantiles.p95) ? Math.round(first.quantiles.p95) : "n/a"}`);
|
|
31
|
-
else lines.push(`${snapshot.name}${labelsText(first.labels)} ${first.value}`);
|
|
32
|
-
}
|
|
33
|
-
return lines;
|
|
34
|
-
}
|
|
1
|
+
import type { MetricRegistry } from "../../observability/metric-registry.ts";
|
|
2
|
+
import type { HistogramPoint, MetricLabels, MetricPoint } from "../../observability/metrics-primitives.ts";
|
|
3
|
+
import type { RunUiSnapshot } from "../snapshot-types.ts";
|
|
4
|
+
|
|
5
|
+
export interface MetricsPaneOptions {
|
|
6
|
+
registry?: MetricRegistry;
|
|
7
|
+
maxCounters?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function labelsText(labels: MetricLabels): string {
|
|
11
|
+
const entries = Object.entries(labels);
|
|
12
|
+
return entries.length ? `{${entries.map(([key, value]) => `${key}=${value}`).join(",")}}` : "";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function isHistogramPoint(point: MetricPoint | HistogramPoint): point is HistogramPoint {
|
|
16
|
+
return "quantiles" in point;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function renderMetricsPane(_snapshot: RunUiSnapshot | undefined, opts: MetricsPaneOptions = {}): string[] {
|
|
20
|
+
if (!opts.registry) return ["Metrics pane: registry unavailable"];
|
|
21
|
+
const snapshots = opts.registry.snapshot();
|
|
22
|
+
if (!snapshots.length) return ["Metrics pane: no metrics recorded"];
|
|
23
|
+
const lines = ["Metrics pane: top metrics"];
|
|
24
|
+
for (const snapshot of snapshots.slice(0, opts.maxCounters ?? 10)) {
|
|
25
|
+
const first = snapshot.values[0];
|
|
26
|
+
if (!first) {
|
|
27
|
+
lines.push(`${snapshot.name}: empty`);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (isHistogramPoint(first)) lines.push(`${snapshot.name}${labelsText(first.labels)} count=${first.count} p95=${Number.isFinite(first.quantiles.p95) ? Math.round(first.quantiles.p95) : "n/a"}`);
|
|
31
|
+
else lines.push(`${snapshot.name}${labelsText(first.labels)} ${first.value}`);
|
|
32
|
+
}
|
|
33
|
+
return lines;
|
|
34
|
+
}
|
package/src/ui/dynamic-border.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { CrewTheme } from "./theme-adapter.ts";
|
|
2
|
-
|
|
3
|
-
export interface DynamicCrewBorderOptions {
|
|
4
|
-
color?: (value: string) => string;
|
|
5
|
-
char?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class DynamicCrewBorder {
|
|
9
|
-
private readonly theme: CrewTheme;
|
|
10
|
-
private readonly color?: (value: string) => string;
|
|
11
|
-
private readonly char: string;
|
|
12
|
-
|
|
13
|
-
constructor(theme: CrewTheme, options: DynamicCrewBorderOptions = {}) {
|
|
14
|
-
this.theme = theme;
|
|
15
|
-
this.color = options.color;
|
|
16
|
-
this.char = options.char && options.char.length > 0 ? options.char : "─";
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
render(width: number): string[] {
|
|
20
|
-
const line = this.char.repeat(Math.max(0, width));
|
|
21
|
-
return [this.color ? this.color(line) : this.theme.fg("border", line)];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
invalidate(): void {}
|
|
25
|
-
}
|
|
1
|
+
import type { CrewTheme } from "./theme-adapter.ts";
|
|
2
|
+
|
|
3
|
+
export interface DynamicCrewBorderOptions {
|
|
4
|
+
color?: (value: string) => string;
|
|
5
|
+
char?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class DynamicCrewBorder {
|
|
9
|
+
private readonly theme: CrewTheme;
|
|
10
|
+
private readonly color?: (value: string) => string;
|
|
11
|
+
private readonly char: string;
|
|
12
|
+
|
|
13
|
+
constructor(theme: CrewTheme, options: DynamicCrewBorderOptions = {}) {
|
|
14
|
+
this.theme = theme;
|
|
15
|
+
this.color = options.color;
|
|
16
|
+
this.char = options.char && options.char.length > 0 ? options.char : "─";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
render(width: number): string[] {
|
|
20
|
+
const line = this.char.repeat(Math.max(0, width));
|
|
21
|
+
return [this.color ? this.color(line) : this.theme.fg("border", line)];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
invalidate(): void {}
|
|
25
|
+
}
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { pad, wrapHard } from "../utils/visual.ts";
|
|
2
|
-
|
|
3
|
-
export interface RenderableComponent {
|
|
4
|
-
invalidate(): void;
|
|
5
|
-
render(width: number): string[];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class Container implements RenderableComponent {
|
|
9
|
-
private children: RenderableComponent[] = [];
|
|
10
|
-
|
|
11
|
-
addChild(child: RenderableComponent): void {
|
|
12
|
-
this.children.push(child);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
clear(): void {
|
|
16
|
-
this.children = [];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
invalidate(): void {
|
|
20
|
-
for (const child of this.children) {
|
|
21
|
-
child.invalidate();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
render(width: number): string[] {
|
|
26
|
-
const lines: string[] = [];
|
|
27
|
-
for (const child of this.children) {
|
|
28
|
-
lines.push(...child.render(width));
|
|
29
|
-
}
|
|
30
|
-
return lines;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class Box extends Container {
|
|
35
|
-
private readonly paddingX: number;
|
|
36
|
-
private readonly paddingY: number;
|
|
37
|
-
|
|
38
|
-
constructor(paddingX = 0, paddingY = 0) {
|
|
39
|
-
super();
|
|
40
|
-
this.paddingX = paddingX;
|
|
41
|
-
this.paddingY = paddingY;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
render(width: number): string[] {
|
|
45
|
-
const innerWidth = Math.max(1, width - this.paddingX * 2);
|
|
46
|
-
const rows = super.render(innerWidth);
|
|
47
|
-
const paddedRows: string[] = [];
|
|
48
|
-
const left = " ".repeat(this.paddingX);
|
|
49
|
-
const right = " ".repeat(this.paddingX);
|
|
50
|
-
for (const row of rows) {
|
|
51
|
-
paddedRows.push(pad(`${left}${row}${right}`, width));
|
|
52
|
-
}
|
|
53
|
-
const emptyRow = pad("", width);
|
|
54
|
-
if (this.paddingY <= 0) return paddedRows;
|
|
55
|
-
if (this.paddingY > 0) {
|
|
56
|
-
const topAndBottom = Array.from({ length: this.paddingY }, () => emptyRow);
|
|
57
|
-
return [...topAndBottom, ...paddedRows, ...topAndBottom];
|
|
58
|
-
}
|
|
59
|
-
return paddedRows;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export class Text implements RenderableComponent {
|
|
64
|
-
private text: string;
|
|
65
|
-
private cachedWidth = 0;
|
|
66
|
-
private cachedResult: string[] = [];
|
|
67
|
-
|
|
68
|
-
constructor(text = "") {
|
|
69
|
-
this.text = text;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
setText(text: string): void {
|
|
73
|
-
if (text === this.text) return;
|
|
74
|
-
this.text = text;
|
|
75
|
-
this.invalidate();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
invalidate(): void {
|
|
79
|
-
this.cachedWidth = 0;
|
|
80
|
-
this.cachedResult = [];
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
render(width: number): string[] {
|
|
84
|
-
if (this.cachedWidth === width) return this.cachedResult;
|
|
85
|
-
const wrapped = wrapHard(this.text, Math.max(1, width));
|
|
86
|
-
const lines = wrapped.length ? wrapped : [""];
|
|
87
|
-
this.cachedWidth = width;
|
|
88
|
-
this.cachedResult = lines.map((line) => pad(line, width));
|
|
89
|
-
return this.cachedResult;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export class Spacer implements RenderableComponent {
|
|
94
|
-
private readonly rows: number;
|
|
95
|
-
|
|
96
|
-
constructor(rows = 0) {
|
|
97
|
-
this.rows = rows;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
render(width: number): string[] {
|
|
101
|
-
if (this.rows <= 0) return [];
|
|
102
|
-
return Array.from({ length: Math.max(0, this.rows) }, () => pad("", width));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
invalidate(): void {}
|
|
106
|
-
}
|
|
1
|
+
import { pad, wrapHard } from "../utils/visual.ts";
|
|
2
|
+
|
|
3
|
+
export interface RenderableComponent {
|
|
4
|
+
invalidate(): void;
|
|
5
|
+
render(width: number): string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class Container implements RenderableComponent {
|
|
9
|
+
private children: RenderableComponent[] = [];
|
|
10
|
+
|
|
11
|
+
addChild(child: RenderableComponent): void {
|
|
12
|
+
this.children.push(child);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
clear(): void {
|
|
16
|
+
this.children = [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
invalidate(): void {
|
|
20
|
+
for (const child of this.children) {
|
|
21
|
+
child.invalidate();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
render(width: number): string[] {
|
|
26
|
+
const lines: string[] = [];
|
|
27
|
+
for (const child of this.children) {
|
|
28
|
+
lines.push(...child.render(width));
|
|
29
|
+
}
|
|
30
|
+
return lines;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class Box extends Container {
|
|
35
|
+
private readonly paddingX: number;
|
|
36
|
+
private readonly paddingY: number;
|
|
37
|
+
|
|
38
|
+
constructor(paddingX = 0, paddingY = 0) {
|
|
39
|
+
super();
|
|
40
|
+
this.paddingX = paddingX;
|
|
41
|
+
this.paddingY = paddingY;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
render(width: number): string[] {
|
|
45
|
+
const innerWidth = Math.max(1, width - this.paddingX * 2);
|
|
46
|
+
const rows = super.render(innerWidth);
|
|
47
|
+
const paddedRows: string[] = [];
|
|
48
|
+
const left = " ".repeat(this.paddingX);
|
|
49
|
+
const right = " ".repeat(this.paddingX);
|
|
50
|
+
for (const row of rows) {
|
|
51
|
+
paddedRows.push(pad(`${left}${row}${right}`, width));
|
|
52
|
+
}
|
|
53
|
+
const emptyRow = pad("", width);
|
|
54
|
+
if (this.paddingY <= 0) return paddedRows;
|
|
55
|
+
if (this.paddingY > 0) {
|
|
56
|
+
const topAndBottom = Array.from({ length: this.paddingY }, () => emptyRow);
|
|
57
|
+
return [...topAndBottom, ...paddedRows, ...topAndBottom];
|
|
58
|
+
}
|
|
59
|
+
return paddedRows;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class Text implements RenderableComponent {
|
|
64
|
+
private text: string;
|
|
65
|
+
private cachedWidth = 0;
|
|
66
|
+
private cachedResult: string[] = [];
|
|
67
|
+
|
|
68
|
+
constructor(text = "") {
|
|
69
|
+
this.text = text;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setText(text: string): void {
|
|
73
|
+
if (text === this.text) return;
|
|
74
|
+
this.text = text;
|
|
75
|
+
this.invalidate();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
invalidate(): void {
|
|
79
|
+
this.cachedWidth = 0;
|
|
80
|
+
this.cachedResult = [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
render(width: number): string[] {
|
|
84
|
+
if (this.cachedWidth === width) return this.cachedResult;
|
|
85
|
+
const wrapped = wrapHard(this.text, Math.max(1, width));
|
|
86
|
+
const lines = wrapped.length ? wrapped : [""];
|
|
87
|
+
this.cachedWidth = width;
|
|
88
|
+
this.cachedResult = lines.map((line) => pad(line, width));
|
|
89
|
+
return this.cachedResult;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class Spacer implements RenderableComponent {
|
|
94
|
+
private readonly rows: number;
|
|
95
|
+
|
|
96
|
+
constructor(rows = 0) {
|
|
97
|
+
this.rows = rows;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
render(width: number): string[] {
|
|
101
|
+
if (this.rows <= 0) return [];
|
|
102
|
+
return Array.from({ length: Math.max(0, this.rows) }, () => pad("", width));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
invalidate(): void {}
|
|
106
|
+
}
|
|
@@ -78,7 +78,7 @@ export class LiveRunSidebar {
|
|
|
78
78
|
const animation = agents.some((agent) => agent.status === "running") ? `:spin=${spinnerBucket()}` : "";
|
|
79
79
|
if (snapshot) return `${snapshot.signature}:${waitingCount}${animation}`;
|
|
80
80
|
const taskSig = tasks.map((task) => `${task.id}:${task.status}:${task.startedAt ?? ""}:${task.finishedAt ?? ""}:${task.agentProgress?.currentTool ?? ""}:${task.agentProgress?.toolCount ?? 0}:${task.agentProgress?.tokens ?? 0}:${task.usage ? JSON.stringify(task.usage) : ""}`).join("|");
|
|
81
|
-
const agentSig = agents.map((agent) => [agent.id, agent.status, agent.startedAt, agent.completedAt ?? "", agent.progress?.currentTool ?? "", agent.progress?.toolCount ?? 0, agent.progress?.tokens ?? 0, agent.progress?.turns ?? 0, agent.progress?.lastActivityAt ?? "", agent.progress?.recentOutput
|
|
81
|
+
const agentSig = agents.map((agent) => [agent.id, agent.status, agent.startedAt, agent.completedAt ?? "", agent.progress?.currentTool ?? "", agent.progress?.toolCount ?? 0, agent.progress?.tokens ?? 0, agent.progress?.turns ?? 0, agent.progress?.lastActivityAt ?? "", agent.progress?.recentOutput?.at(-1) ?? "", agent.toolUses ?? 0].join(":")).join("|");
|
|
82
82
|
return `${manifestStatus}|${agents.length}|${waitingCount}|${taskSig}|${agentSig}${animation}`;
|
|
83
83
|
}
|
|
84
84
|
|