tmux-ide 1.2.1 → 2.0.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/bin/cli.js +4 -216
- package/bin/cli.ts +536 -0
- package/package.json +33 -14
- package/src/__tests__/support.ts +186 -0
- package/src/{attach.js → attach.ts} +7 -4
- package/src/cli.test.ts +314 -0
- package/src/command-center/discovery.test.ts +265 -0
- package/src/command-center/discovery.ts +296 -0
- package/src/command-center/index.ts +31 -0
- package/src/command-center/schemas.ts +57 -0
- package/src/command-center/server.test.ts +818 -0
- package/src/command-center/server.ts +1426 -0
- package/src/config-cli.test.ts +86 -0
- package/src/config.test.ts +205 -0
- package/src/config.ts +313 -0
- package/src/detect.test.ts +142 -0
- package/src/{detect.js → detect.ts} +31 -15
- package/src/dispatch.ts +102 -0
- package/src/doctor.test.ts +119 -0
- package/src/doctor.ts +167 -0
- package/src/init.test.ts +101 -0
- package/src/init.ts +144 -0
- package/src/inspect.test.ts +67 -0
- package/src/{inspect.js → inspect.ts} +95 -10
- package/src/integration.test.ts.skip +276 -0
- package/src/js-yaml.d.ts +10 -0
- package/src/launch.test.ts +222 -0
- package/src/launch.ts +494 -0
- package/src/lib/auth/auth-service.test.ts +178 -0
- package/src/lib/auth/auth-service.ts +227 -0
- package/src/lib/auth/middleware.test.ts +119 -0
- package/src/lib/auth/middleware.ts +56 -0
- package/src/lib/auth/types.ts +13 -0
- package/src/lib/authorship.test.ts +242 -0
- package/src/lib/authorship.ts +280 -0
- package/src/lib/cast/recorder.test.ts +127 -0
- package/src/lib/cast/recorder.ts +148 -0
- package/src/lib/daemon-watchdog.ts +102 -0
- package/src/lib/daemon.ts +417 -0
- package/src/lib/dot-path.test.ts +66 -0
- package/src/lib/dot-path.ts +17 -0
- package/src/lib/errors.ts +44 -0
- package/src/lib/event-log.test.ts +189 -0
- package/src/lib/event-log.ts +237 -0
- package/src/lib/github-pr.ts +182 -0
- package/src/lib/hq/client.test.ts +154 -0
- package/src/lib/hq/client.ts +142 -0
- package/src/lib/hq/mdns.test.ts +54 -0
- package/src/lib/hq/mdns.ts +88 -0
- package/src/lib/hq/registry.test.ts +237 -0
- package/src/lib/hq/registry.ts +145 -0
- package/src/lib/hq/types.ts +44 -0
- package/src/lib/ipc/socket-protocol.test.ts +126 -0
- package/src/lib/ipc/socket-protocol.ts +324 -0
- package/src/lib/launch-plan.test.ts +119 -0
- package/src/lib/launch-plan.ts +90 -0
- package/src/lib/log.test.ts +39 -0
- package/src/lib/log.ts +71 -0
- package/src/lib/metrics.test.ts +213 -0
- package/src/lib/metrics.ts +345 -0
- package/src/lib/orchestrator.test.ts +2358 -0
- package/src/lib/orchestrator.ts +1792 -0
- package/src/lib/{output.js → output.ts} +18 -10
- package/src/lib/plan-store.test.ts +148 -0
- package/src/lib/plan-store.ts +131 -0
- package/src/lib/research.test.ts +208 -0
- package/src/lib/research.ts +475 -0
- package/src/lib/round-trip.test.ts +341 -0
- package/src/lib/session-monitor.test.ts +152 -0
- package/src/lib/session-monitor.ts +282 -0
- package/src/lib/session-options.test.ts +146 -0
- package/src/lib/{session-options.js → session-options.ts} +11 -6
- package/src/lib/shell.test.ts +20 -0
- package/src/lib/shell.ts +8 -0
- package/src/lib/sizes.test.ts +73 -0
- package/src/lib/{sizes.js → sizes.ts} +4 -4
- package/src/lib/skill-registry.test.ts +134 -0
- package/src/lib/skill-registry.ts +86 -0
- package/src/lib/slugify.test.ts +35 -0
- package/src/lib/slugify.ts +10 -0
- package/src/lib/task-store.ts +352 -0
- package/src/lib/tmux.test.ts +500 -0
- package/src/lib/tmux.ts +372 -0
- package/src/lib/token-tracker.test.ts +102 -0
- package/src/lib/token-tracker.ts +70 -0
- package/src/lib/tunnels/cloudflare.test.ts +73 -0
- package/src/lib/tunnels/cloudflare.ts +254 -0
- package/src/lib/tunnels/manager.test.ts +63 -0
- package/src/lib/tunnels/manager.ts +132 -0
- package/src/lib/tunnels/ngrok.test.ts +94 -0
- package/src/lib/tunnels/ngrok.ts +261 -0
- package/src/lib/tunnels/tailscale.test.ts +103 -0
- package/src/lib/tunnels/tailscale.ts +1048 -0
- package/src/lib/tunnels/types.ts +44 -0
- package/src/lib/validation.test.ts +289 -0
- package/src/lib/validation.ts +123 -0
- package/src/lib/webhook.ts +51 -0
- package/src/lib/workflow-store.ts +209 -0
- package/src/lib/ws-v3/protocol.test.ts +127 -0
- package/src/lib/ws-v3/protocol.ts +160 -0
- package/src/lib/yaml-io.test.ts +125 -0
- package/src/lib/{yaml-io.js → yaml-io.ts} +5 -4
- package/src/ls.test.ts +76 -0
- package/src/{ls.js → ls.ts} +4 -4
- package/src/metrics-cli.ts +177 -0
- package/src/notify.ts +85 -0
- package/src/orchestrator-status.ts +228 -0
- package/src/plan.ts +117 -0
- package/src/postinstall.test.ts +79 -0
- package/src/remote.test.ts +115 -0
- package/src/remote.ts +148 -0
- package/src/restart.ts +24 -0
- package/src/schemas/domain.ts +422 -0
- package/src/schemas/ide-config.ts +148 -0
- package/src/schemas/index.ts +53 -0
- package/src/send.test.ts +70 -0
- package/src/send.ts +181 -0
- package/src/skill.test.ts +114 -0
- package/src/skill.ts +138 -0
- package/src/status.ts +66 -0
- package/src/stop.test.ts +176 -0
- package/src/stop.ts +47 -0
- package/src/task.test.ts +1466 -0
- package/src/task.ts +1143 -0
- package/src/tunnel.test.ts +80 -0
- package/src/tunnel.ts +133 -0
- package/src/types.ts +15 -0
- package/src/ui/index.ts +32 -0
- package/src/ui/terminal/index.ts +9 -0
- package/src/ui/types.ts +91 -0
- package/src/ui/web/base.css +80 -0
- package/src/ui/web/components/Box.tsx +59 -0
- package/src/ui/web/components/Input.tsx +32 -0
- package/src/ui/web/components/ScrollBox.tsx +60 -0
- package/src/ui/web/components/Text.tsx +28 -0
- package/src/ui/web/hooks.ts +106 -0
- package/src/ui/web/index.ts +27 -0
- package/src/ui/web/render.ts +77 -0
- package/src/ui/web/utils/color.test.ts +93 -0
- package/src/ui/web/utils/color.ts +27 -0
- package/src/validate.test.ts +385 -0
- package/src/validate.ts +217 -0
- package/src/widgets/changes/index.tsx +576 -0
- package/src/widgets/config/index.tsx +440 -0
- package/src/widgets/costs/index.tsx +216 -0
- package/src/widgets/explorer/breadcrumbs.tsx +77 -0
- package/src/widgets/explorer/footer.tsx +20 -0
- package/src/widgets/explorer/header.tsx +23 -0
- package/src/widgets/explorer/index.tsx +408 -0
- package/src/widgets/explorer/tree-model.test.ts +214 -0
- package/src/widgets/explorer/tree-model.ts +103 -0
- package/src/widgets/explorer/tree.tsx +156 -0
- package/src/widgets/lib/config-model.ts +116 -0
- package/src/widgets/lib/files.test.ts +103 -0
- package/src/widgets/lib/files.ts +88 -0
- package/src/widgets/lib/git.test.ts +151 -0
- package/src/widgets/lib/git.ts +88 -0
- package/src/widgets/lib/pane-comms.test.ts +178 -0
- package/src/widgets/lib/pane-comms.ts +192 -0
- package/src/widgets/lib/theme.ts +151 -0
- package/src/widgets/lib/watcher.ts +50 -0
- package/src/widgets/mission-control/activity-feed.tsx +59 -0
- package/src/widgets/mission-control/agent-panel.tsx +132 -0
- package/src/widgets/mission-control/command-bar.tsx +63 -0
- package/src/widgets/mission-control/index.tsx +751 -0
- package/src/widgets/mission-control/task-panel.tsx +238 -0
- package/src/widgets/preview/index.tsx +415 -0
- package/src/widgets/resolve.ts +40 -0
- package/src/widgets/setup/agent-naming.tsx +112 -0
- package/src/widgets/setup/config-tree.tsx +238 -0
- package/src/widgets/setup/detect-panel.tsx +72 -0
- package/src/widgets/setup/field-editor.tsx +265 -0
- package/src/widgets/setup/footer.tsx +107 -0
- package/src/widgets/setup/index.tsx +340 -0
- package/src/widgets/setup/layout-picker.tsx +96 -0
- package/src/widgets/setup/orchestrator-panel.tsx +200 -0
- package/src/widgets/setup/review-panel.tsx +140 -0
- package/src/widgets/setup/setup-model.test.ts +303 -0
- package/src/widgets/setup/setup-model.ts +188 -0
- package/src/widgets/tasks/index.tsx +129 -0
- package/src/widgets/tasks/task-detail.tsx +309 -0
- package/src/widgets/tasks/task-form.tsx +193 -0
- package/src/widgets/tasks/task-list.tsx +205 -0
- package/src/widgets/tasks/task-model.test.ts +473 -0
- package/src/widgets/tasks/task-model.ts +157 -0
- package/templates/AGENTS.md +20 -0
- package/templates/missions.yml +41 -0
- package/templates/skills/backend.md +30 -0
- package/templates/skills/frontend.md +30 -0
- package/templates/skills/general-worker.md +30 -0
- package/templates/skills/researcher.md +69 -0
- package/templates/skills/reviewer.md +30 -0
- package/src/config.js +0 -341
- package/src/doctor.js +0 -91
- package/src/init.js +0 -73
- package/src/launch.js +0 -245
- package/src/lib/dot-path.js +0 -16
- package/src/lib/errors.js +0 -35
- package/src/lib/launch-plan.js +0 -49
- package/src/lib/session-monitor.js +0 -179
- package/src/lib/tmux.js +0 -237
- package/src/restart.js +0 -16
- package/src/status.js +0 -35
- package/src/stop.js +0 -25
- package/src/validate.js +0 -154
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export type RGBA = { r: number; g: number; b: number; a: number };
|
|
2
|
+
|
|
3
|
+
export interface WidgetTheme {
|
|
4
|
+
bg: RGBA;
|
|
5
|
+
fg: RGBA;
|
|
6
|
+
fgMuted: RGBA;
|
|
7
|
+
accent: RGBA;
|
|
8
|
+
border: RGBA;
|
|
9
|
+
selected: RGBA;
|
|
10
|
+
selectedText: RGBA;
|
|
11
|
+
dirName: RGBA;
|
|
12
|
+
rowAlt: RGBA;
|
|
13
|
+
indentGuide: RGBA;
|
|
14
|
+
ignored: RGBA;
|
|
15
|
+
gitModified: RGBA;
|
|
16
|
+
gitAdded: RGBA;
|
|
17
|
+
gitDeleted: RGBA;
|
|
18
|
+
gitUntracked: RGBA;
|
|
19
|
+
diffAdded: RGBA;
|
|
20
|
+
diffAddedBg: RGBA;
|
|
21
|
+
diffRemoved: RGBA;
|
|
22
|
+
diffRemovedBg: RGBA;
|
|
23
|
+
diffContext: RGBA;
|
|
24
|
+
diffContextBg: RGBA;
|
|
25
|
+
diffHunk: RGBA;
|
|
26
|
+
diffLineNumber: RGBA;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function rgba(r: number, g: number, b: number, a = 255) {
|
|
30
|
+
return { r, g, b, a };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const DEFAULTS: WidgetTheme = {
|
|
34
|
+
bg: rgba(30, 30, 40),
|
|
35
|
+
fg: rgba(200, 200, 210),
|
|
36
|
+
fgMuted: rgba(120, 120, 140),
|
|
37
|
+
accent: rgba(130, 170, 255),
|
|
38
|
+
border: rgba(60, 60, 80),
|
|
39
|
+
selected: rgba(50, 50, 70),
|
|
40
|
+
selectedText: rgba(255, 255, 255),
|
|
41
|
+
dirName: rgba(100, 160, 255),
|
|
42
|
+
rowAlt: rgba(255, 255, 255, 5),
|
|
43
|
+
indentGuide: rgba(60, 60, 80),
|
|
44
|
+
ignored: rgba(80, 80, 100),
|
|
45
|
+
gitModified: rgba(230, 180, 80),
|
|
46
|
+
gitAdded: rgba(80, 200, 120),
|
|
47
|
+
gitDeleted: rgba(230, 80, 80),
|
|
48
|
+
gitUntracked: rgba(120, 120, 140),
|
|
49
|
+
diffAdded: rgba(80, 200, 120),
|
|
50
|
+
diffAddedBg: rgba(20, 60, 30),
|
|
51
|
+
diffRemoved: rgba(230, 80, 80),
|
|
52
|
+
diffRemovedBg: rgba(60, 20, 20),
|
|
53
|
+
diffContext: rgba(160, 160, 170),
|
|
54
|
+
diffContextBg: rgba(30, 30, 40),
|
|
55
|
+
diffHunk: rgba(100, 180, 220),
|
|
56
|
+
diffLineNumber: rgba(80, 80, 100),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Parse a tmux/CSS color string into RGBA.
|
|
61
|
+
* Supports: colourN / colorN (0-255), #rgb, #rrggbb.
|
|
62
|
+
*/
|
|
63
|
+
function parseColor(color: string): RGBA | null {
|
|
64
|
+
// tmux colour0–colour255
|
|
65
|
+
const tmuxMatch = color.match(/^colou?r(\d+)$/);
|
|
66
|
+
if (tmuxMatch) {
|
|
67
|
+
const rawIndex = tmuxMatch[1];
|
|
68
|
+
if (!rawIndex) return null;
|
|
69
|
+
const n = parseInt(rawIndex, 10);
|
|
70
|
+
if (n < 0 || n > 255) return null;
|
|
71
|
+
|
|
72
|
+
// Standard colors 0–15 (approximate to common terminal defaults)
|
|
73
|
+
const STANDARD: [number, number, number][] = [
|
|
74
|
+
[0, 0, 0],
|
|
75
|
+
[128, 0, 0],
|
|
76
|
+
[0, 128, 0],
|
|
77
|
+
[128, 128, 0],
|
|
78
|
+
[0, 0, 128],
|
|
79
|
+
[128, 0, 128],
|
|
80
|
+
[0, 128, 128],
|
|
81
|
+
[192, 192, 192],
|
|
82
|
+
[128, 128, 128],
|
|
83
|
+
[255, 0, 0],
|
|
84
|
+
[0, 255, 0],
|
|
85
|
+
[255, 255, 0],
|
|
86
|
+
[0, 0, 255],
|
|
87
|
+
[255, 0, 255],
|
|
88
|
+
[0, 255, 255],
|
|
89
|
+
[255, 255, 255],
|
|
90
|
+
];
|
|
91
|
+
if (n < 16) {
|
|
92
|
+
const standard = STANDARD[n];
|
|
93
|
+
if (!standard) return null;
|
|
94
|
+
return rgba(standard[0], standard[1], standard[2]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 6×6×6 color cube (16–231)
|
|
98
|
+
if (n < 232) {
|
|
99
|
+
const idx = n - 16;
|
|
100
|
+
const LEVELS: number[] = [0, 95, 135, 175, 215, 255];
|
|
101
|
+
const r = LEVELS[Math.floor(idx / 36)];
|
|
102
|
+
const g = LEVELS[Math.floor((idx % 36) / 6)];
|
|
103
|
+
const b = LEVELS[idx % 6];
|
|
104
|
+
if (r == null || g == null || b == null) return null;
|
|
105
|
+
return rgba(r, g, b);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Grayscale ramp (232–255)
|
|
109
|
+
const level = 8 + 10 * (n - 232);
|
|
110
|
+
return rgba(level, level, level);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Hex: #rgb or #rrggbb
|
|
114
|
+
const hexMatch = color.match(/^#([0-9a-fA-F]{3,6})$/);
|
|
115
|
+
if (hexMatch) {
|
|
116
|
+
let hex = hexMatch[1];
|
|
117
|
+
if (!hex) return null;
|
|
118
|
+
if (hex.length === 3) {
|
|
119
|
+
const [r, g, b] = hex.split("");
|
|
120
|
+
if (!r || !g || !b) return null;
|
|
121
|
+
hex = r + r + g + g + b + b;
|
|
122
|
+
}
|
|
123
|
+
if (hex.length !== 6) return null;
|
|
124
|
+
return rgba(
|
|
125
|
+
parseInt(hex.slice(0, 2), 16),
|
|
126
|
+
parseInt(hex.slice(2, 4), 16),
|
|
127
|
+
parseInt(hex.slice(4, 6), 16),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function createTheme(config?: Record<string, string>): WidgetTheme {
|
|
135
|
+
if (!config) return DEFAULTS;
|
|
136
|
+
const theme = { ...DEFAULTS };
|
|
137
|
+
const MAP: Record<string, keyof WidgetTheme> = {
|
|
138
|
+
accent: "accent",
|
|
139
|
+
border: "border",
|
|
140
|
+
bg: "bg",
|
|
141
|
+
fg: "fg",
|
|
142
|
+
};
|
|
143
|
+
for (const [key, prop] of Object.entries(MAP)) {
|
|
144
|
+
const val = config[key];
|
|
145
|
+
if (val) {
|
|
146
|
+
const parsed = parseColor(val);
|
|
147
|
+
if (parsed) theme[prop] = parsed;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return theme;
|
|
151
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as watcher from "@parcel/watcher";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
export interface WatchEvent {
|
|
5
|
+
type: "create" | "update" | "delete";
|
|
6
|
+
path: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function watchDirectory(
|
|
10
|
+
dir: string,
|
|
11
|
+
onChange: (events: WatchEvent[]) => void,
|
|
12
|
+
options?: { debounceMs?: number; ignore?: string[] },
|
|
13
|
+
): Promise<() => Promise<void>> {
|
|
14
|
+
const debounceMs = options?.debounceMs ?? 300;
|
|
15
|
+
let timeout: ReturnType<typeof setTimeout> | null = null;
|
|
16
|
+
|
|
17
|
+
const subscription = await watcher.subscribe(
|
|
18
|
+
dir,
|
|
19
|
+
(err, events) => {
|
|
20
|
+
if (err) return;
|
|
21
|
+
if (timeout) clearTimeout(timeout);
|
|
22
|
+
timeout = setTimeout(() => onChange(events as unknown as WatchEvent[]), debounceMs);
|
|
23
|
+
},
|
|
24
|
+
{ ignore: options?.ignore ?? ["node_modules", ".git", "dist", "build", ".next"] },
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return () => subscription.unsubscribe();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function watchGitHead(
|
|
31
|
+
dir: string,
|
|
32
|
+
onBranchChange: () => void,
|
|
33
|
+
): Promise<(() => Promise<void>) | null> {
|
|
34
|
+
const gitDir = join(dir, ".git");
|
|
35
|
+
try {
|
|
36
|
+
const subscription = await watcher.subscribe(
|
|
37
|
+
gitDir,
|
|
38
|
+
(err, events) => {
|
|
39
|
+
if (err) return;
|
|
40
|
+
if (events.some((e) => e.path.endsWith("HEAD"))) {
|
|
41
|
+
onBranchChange();
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{ ignore: ["objects", "pack", "refs", "logs"] },
|
|
45
|
+
);
|
|
46
|
+
return () => subscription.unsubscribe();
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { RGBA, TextAttributes } from "@opentui/core";
|
|
2
|
+
import type { OrchestratorEvent } from "../../lib/event-log.ts";
|
|
3
|
+
import type { WidgetTheme, RGBA as RGBAType } from "../lib/theme.ts";
|
|
4
|
+
|
|
5
|
+
function toRGBA(c: RGBAType): RGBA {
|
|
6
|
+
return RGBA.fromInts(c.r, c.g, c.b, c.a);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function formatRelative(iso: string): string {
|
|
10
|
+
const ms = Date.now() - new Date(iso).getTime();
|
|
11
|
+
if (ms < 60000) return `${Math.round(ms / 1000)}s`;
|
|
12
|
+
if (ms < 3600000) return `${Math.round(ms / 60000)}m`;
|
|
13
|
+
return `${(ms / 3600000).toFixed(1)}h`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function eventColor(type: string, theme: WidgetTheme): RGBAType {
|
|
17
|
+
switch (type) {
|
|
18
|
+
case "dispatch":
|
|
19
|
+
return theme.accent;
|
|
20
|
+
case "completion":
|
|
21
|
+
return theme.gitAdded;
|
|
22
|
+
case "error":
|
|
23
|
+
case "reconcile":
|
|
24
|
+
return theme.gitDeleted;
|
|
25
|
+
case "stall":
|
|
26
|
+
return theme.gitModified;
|
|
27
|
+
default:
|
|
28
|
+
return theme.fgMuted;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface ActivityFeedProps {
|
|
33
|
+
events: OrchestratorEvent[];
|
|
34
|
+
theme: WidgetTheme;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function ActivityFeed(props: ActivityFeedProps) {
|
|
38
|
+
return (
|
|
39
|
+
<box flexGrow={1}>
|
|
40
|
+
{props.events.length === 0 ? (
|
|
41
|
+
<text fg={toRGBA(props.theme.fgMuted)}>No recent activity</text>
|
|
42
|
+
) : (
|
|
43
|
+
props.events.map((evt) => (
|
|
44
|
+
<box flexShrink={0} flexDirection="row" gap={1}>
|
|
45
|
+
<text fg={toRGBA(props.theme.fgMuted)} wrapMode="none">
|
|
46
|
+
{formatRelative(evt.timestamp).padStart(4)}
|
|
47
|
+
</text>
|
|
48
|
+
<text fg={toRGBA(eventColor(evt.type, props.theme))} wrapMode="none">
|
|
49
|
+
{evt.type.padEnd(11)}
|
|
50
|
+
</text>
|
|
51
|
+
<text fg={toRGBA(props.theme.fg)} wrapMode="none">
|
|
52
|
+
{evt.message.slice(0, 40)}
|
|
53
|
+
</text>
|
|
54
|
+
</box>
|
|
55
|
+
))
|
|
56
|
+
)}
|
|
57
|
+
</box>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createSignal, For, Show } from "solid-js";
|
|
2
|
+
import { RGBA, TextAttributes } from "@opentui/core";
|
|
3
|
+
import { useKeyboard } from "@opentui/solid";
|
|
4
|
+
import type { WidgetTheme, RGBA as RGBAType } from "../lib/theme.ts";
|
|
5
|
+
|
|
6
|
+
function toRGBA(c: RGBAType): RGBA {
|
|
7
|
+
return RGBA.fromInts(c.r, c.g, c.b, c.a);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface AgentInfo {
|
|
11
|
+
name: string;
|
|
12
|
+
paneId: string;
|
|
13
|
+
state: "busy" | "idle" | "error";
|
|
14
|
+
role?: string;
|
|
15
|
+
currentTask: { id: string; title: string; elapsed: string } | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface AgentPanelProps {
|
|
19
|
+
agents: AgentInfo[];
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
theme: WidgetTheme;
|
|
22
|
+
onAddAgent: () => void;
|
|
23
|
+
onSelectAgent: (agent: AgentInfo) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function dotChar(state: AgentInfo["state"]): string {
|
|
27
|
+
return state === "error" ? "!" : state === "busy" ? "*" : "o";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function dotColor(state: AgentInfo["state"], theme: WidgetTheme): RGBAType {
|
|
31
|
+
switch (state) {
|
|
32
|
+
case "idle":
|
|
33
|
+
return theme.gitAdded;
|
|
34
|
+
case "busy":
|
|
35
|
+
return theme.gitModified;
|
|
36
|
+
case "error":
|
|
37
|
+
return theme.gitDeleted;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function AgentPanel(props: AgentPanelProps) {
|
|
42
|
+
const [selected, setSelected] = createSignal(0);
|
|
43
|
+
|
|
44
|
+
// Total rows = agents + 1 for the [+add] row
|
|
45
|
+
const rowCount = () => props.agents.length + 1;
|
|
46
|
+
|
|
47
|
+
useKeyboard((evt) => {
|
|
48
|
+
if (!props.isActive) return;
|
|
49
|
+
|
|
50
|
+
if (evt.name === "up" || evt.name === "k") {
|
|
51
|
+
setSelected((i) => Math.max(0, i - 1));
|
|
52
|
+
evt.preventDefault();
|
|
53
|
+
} else if (evt.name === "down" || evt.name === "j") {
|
|
54
|
+
setSelected((i) => Math.min(rowCount() - 1, i + 1));
|
|
55
|
+
evt.preventDefault();
|
|
56
|
+
} else if (evt.name === "return") {
|
|
57
|
+
if (selected() === props.agents.length) {
|
|
58
|
+
props.onAddAgent();
|
|
59
|
+
} else {
|
|
60
|
+
const agent = props.agents[selected()];
|
|
61
|
+
if (agent) props.onSelectAgent(agent);
|
|
62
|
+
}
|
|
63
|
+
evt.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<box flexGrow={1}>
|
|
69
|
+
<For each={props.agents}>
|
|
70
|
+
{(agent, i) => {
|
|
71
|
+
const isSel = () => props.isActive && selected() === i();
|
|
72
|
+
return (
|
|
73
|
+
<box
|
|
74
|
+
flexShrink={0}
|
|
75
|
+
flexDirection="row"
|
|
76
|
+
gap={1}
|
|
77
|
+
backgroundColor={isSel() ? toRGBA(props.theme.selected) : undefined}
|
|
78
|
+
onMouseDown={() => {
|
|
79
|
+
setSelected(i());
|
|
80
|
+
props.onSelectAgent(agent);
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
<text fg={toRGBA(dotColor(agent.state, props.theme))}>{dotChar(agent.state)}</text>
|
|
84
|
+
<text
|
|
85
|
+
fg={toRGBA(isSel() ? props.theme.selectedText : props.theme.fg)}
|
|
86
|
+
attributes={isSel() ? TextAttributes.BOLD : 0}
|
|
87
|
+
wrapMode="none"
|
|
88
|
+
>
|
|
89
|
+
{agent.name}
|
|
90
|
+
</text>
|
|
91
|
+
<Show when={agent.currentTask}>
|
|
92
|
+
{(task) => (
|
|
93
|
+
<text fg={toRGBA(props.theme.fgMuted)} wrapMode="none">
|
|
94
|
+
{task().title} {task().elapsed}
|
|
95
|
+
</text>
|
|
96
|
+
)}
|
|
97
|
+
</Show>
|
|
98
|
+
<Show when={!agent.currentTask}>
|
|
99
|
+
<text fg={toRGBA(props.theme.fgMuted)}>idle</text>
|
|
100
|
+
</Show>
|
|
101
|
+
</box>
|
|
102
|
+
);
|
|
103
|
+
}}
|
|
104
|
+
</For>
|
|
105
|
+
|
|
106
|
+
{/* Add agent row */}
|
|
107
|
+
<box
|
|
108
|
+
flexShrink={0}
|
|
109
|
+
flexDirection="row"
|
|
110
|
+
backgroundColor={
|
|
111
|
+
props.isActive && selected() === props.agents.length
|
|
112
|
+
? toRGBA(props.theme.selected)
|
|
113
|
+
: undefined
|
|
114
|
+
}
|
|
115
|
+
onMouseDown={() => {
|
|
116
|
+
setSelected(props.agents.length);
|
|
117
|
+
props.onAddAgent();
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
<text
|
|
121
|
+
fg={toRGBA(
|
|
122
|
+
props.isActive && selected() === props.agents.length
|
|
123
|
+
? props.theme.accent
|
|
124
|
+
: props.theme.fgMuted,
|
|
125
|
+
)}
|
|
126
|
+
>
|
|
127
|
+
[+add]
|
|
128
|
+
</text>
|
|
129
|
+
</box>
|
|
130
|
+
</box>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createSignal, onMount } from "solid-js";
|
|
2
|
+
import { RGBA, TextAttributes, type InputRenderable } from "@opentui/core";
|
|
3
|
+
import { useKeyboard } from "@opentui/solid";
|
|
4
|
+
import type { WidgetTheme, RGBA as RGBAType } from "../lib/theme.ts";
|
|
5
|
+
|
|
6
|
+
function toRGBA(c: RGBAType): RGBA {
|
|
7
|
+
return RGBA.fromInts(c.r, c.g, c.b, c.a);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface CommandBarProps {
|
|
11
|
+
value: string;
|
|
12
|
+
isActive: boolean;
|
|
13
|
+
theme: WidgetTheme;
|
|
14
|
+
onSubmit: (value: string) => void;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
onEscape: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function CommandBar(props: CommandBarProps) {
|
|
20
|
+
let inputRef: InputRenderable | undefined;
|
|
21
|
+
|
|
22
|
+
onMount(() => {
|
|
23
|
+
if (props.isActive) {
|
|
24
|
+
setTimeout(() => inputRef?.focus(), 50);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
useKeyboard((evt) => {
|
|
29
|
+
if (!props.isActive) return;
|
|
30
|
+
|
|
31
|
+
if (evt.name === "escape") {
|
|
32
|
+
props.onEscape();
|
|
33
|
+
evt.preventDefault();
|
|
34
|
+
} else if (evt.name === "return") {
|
|
35
|
+
if (props.value.trim()) {
|
|
36
|
+
props.onSubmit(props.value);
|
|
37
|
+
}
|
|
38
|
+
evt.preventDefault();
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<box flexDirection="row" gap={1}>
|
|
44
|
+
<text
|
|
45
|
+
fg={toRGBA(props.isActive ? props.theme.accent : props.theme.fgMuted)}
|
|
46
|
+
attributes={props.isActive ? TextAttributes.BOLD : 0}
|
|
47
|
+
>
|
|
48
|
+
{">"}
|
|
49
|
+
</text>
|
|
50
|
+
<input
|
|
51
|
+
value={props.value}
|
|
52
|
+
placeholder={props.isActive ? "task create, send, goal, add..." : "press / to type"}
|
|
53
|
+
onInput={(v: string) => props.onChange(v)}
|
|
54
|
+
focusedBackgroundColor={toRGBA(props.theme.selected)}
|
|
55
|
+
cursorColor={toRGBA(props.theme.accent)}
|
|
56
|
+
focusedTextColor={toRGBA(props.theme.fg)}
|
|
57
|
+
ref={(r: InputRenderable) => {
|
|
58
|
+
inputRef = r;
|
|
59
|
+
}}
|
|
60
|
+
/>
|
|
61
|
+
</box>
|
|
62
|
+
);
|
|
63
|
+
}
|