trissue 0.1.0 → 0.2.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/README.md +18 -4
- package/dist/cli-g9sxmkeh.js +168 -0
- package/dist/cli.js +7 -2676
- package/dist/run-0f63mpr8.js +2474 -0
- package/package.json +8 -16
package/dist/cli.js
CHANGED
|
@@ -1,2680 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
// @bun
|
|
1
|
+
#!/usr/bin/env node
|
|
3
2
|
|
|
4
|
-
// src/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { createCliRenderer } from "@opentui/core";
|
|
10
|
-
import { render } from "@opentui/solid";
|
|
11
|
-
import { buildLink as buildLink2, copyIssue as copyIssue2, detectHarnesses, fileGitHubIssue as fileGitHubIssue2, formatIssue as formatIssue2, openUrl as openUrl2, resolveSource, runTriage } from "trissue-embedded";
|
|
12
|
-
|
|
13
|
-
// src/tui/app.tsx
|
|
14
|
-
import { effect as _$effect7 } from "@opentui/solid";
|
|
15
|
-
import { insertNode as _$insertNode7 } from "@opentui/solid";
|
|
16
|
-
import { insert as _$insert7 } from "@opentui/solid";
|
|
17
|
-
import { createComponent as _$createComponent7 } from "@opentui/solid";
|
|
18
|
-
import { setProp as _$setProp7 } from "@opentui/solid";
|
|
19
|
-
import { createElement as _$createElement7 } from "@opentui/solid";
|
|
20
|
-
import { useKeyboard as useKeyboard6 } from "@opentui/solid";
|
|
21
|
-
import { createMemo as createMemo5, Match as Match4, Show as Show6, Switch as Switch4 } from "solid-js";
|
|
22
|
-
|
|
23
|
-
// src/tui/components.tsx
|
|
24
|
-
import { createComponent as _$createComponent } from "@opentui/solid";
|
|
25
|
-
import { effect as _$effect } from "@opentui/solid";
|
|
26
|
-
import { createTextNode as _$createTextNode } from "@opentui/solid";
|
|
27
|
-
import { insertNode as _$insertNode } from "@opentui/solid";
|
|
28
|
-
import { insert as _$insert } from "@opentui/solid";
|
|
29
|
-
import { setProp as _$setProp } from "@opentui/solid";
|
|
30
|
-
import { createElement as _$createElement } from "@opentui/solid";
|
|
31
|
-
import { TextAttributes } from "@opentui/core";
|
|
32
|
-
import { For, Show } from "solid-js";
|
|
33
|
-
|
|
34
|
-
// src/tui/theme.ts
|
|
35
|
-
function parseHex(hex) {
|
|
36
|
-
let value = hex.replace("#", "");
|
|
37
|
-
if (value.length === 3)
|
|
38
|
-
value = [...value].map((char) => char + char).join("");
|
|
39
|
-
const number = Number.parseInt(value.slice(0, 6), 16);
|
|
40
|
-
return [number >> 16 & 255, number >> 8 & 255, number & 255];
|
|
41
|
-
}
|
|
42
|
-
function toHex([r, g, b]) {
|
|
43
|
-
return `#${[r, g, b].map((channel) => Math.round(channel).toString(16).padStart(2, "0")).join("")}`;
|
|
44
|
-
}
|
|
45
|
-
function mix(from, to, amount) {
|
|
46
|
-
const a = parseHex(from);
|
|
47
|
-
const b = parseHex(to);
|
|
48
|
-
return toHex([0, 1, 2].map((index) => a[index] + (b[index] - a[index]) * amount));
|
|
49
|
-
}
|
|
50
|
-
function gradientAt(stops, position) {
|
|
51
|
-
if (stops.length === 1)
|
|
52
|
-
return stops[0];
|
|
53
|
-
const scaled = Math.min(Math.max(position, 0), 1) * (stops.length - 1);
|
|
54
|
-
const index = Math.min(Math.floor(scaled), stops.length - 2);
|
|
55
|
-
return mix(stops[index], stops[index + 1], scaled - index);
|
|
56
|
-
}
|
|
57
|
-
var BASE_THEME = {
|
|
58
|
-
background: "#000000",
|
|
59
|
-
text: "#FFFFFF",
|
|
60
|
-
muted: "#9A9A9A",
|
|
61
|
-
faint: "#5C5C5C",
|
|
62
|
-
border: "#FFFFFF",
|
|
63
|
-
danger: "#FF4545",
|
|
64
|
-
success: "#3DDC84",
|
|
65
|
-
check: "#3DDC84",
|
|
66
|
-
product: "#FFFFFF",
|
|
67
|
-
scrim: "#000000B3",
|
|
68
|
-
focus: "#FFFFFF"
|
|
69
|
-
};
|
|
70
|
-
function themeFor(config, overrides = {}) {
|
|
71
|
-
const background = overrides.background ?? config?.background ?? BASE_THEME.background;
|
|
72
|
-
const light = luminance(background) > 0.5;
|
|
73
|
-
const text = light ? "#000000" : "#FFFFFF";
|
|
74
|
-
return {
|
|
75
|
-
...BASE_THEME,
|
|
76
|
-
background,
|
|
77
|
-
text,
|
|
78
|
-
border: text,
|
|
79
|
-
focus: text,
|
|
80
|
-
muted: mix(text, background, 0.4),
|
|
81
|
-
faint: mix(text, background, 0.65),
|
|
82
|
-
scrim: `${light ? "#FFFFFF" : "#000000"}B3`,
|
|
83
|
-
check: config?.checkmark === "monochrome" ? text : BASE_THEME.check,
|
|
84
|
-
product: config?.product?.color ?? text
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function luminance(hex) {
|
|
88
|
-
const [r, g, b] = parseHex(hex).map((channel) => channel / 255);
|
|
89
|
-
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// src/tui/components.tsx
|
|
93
|
-
var BOLD = TextAttributes.BOLD;
|
|
94
|
-
var DIM = TextAttributes.DIM;
|
|
95
|
-
var ITALIC = TextAttributes.ITALIC;
|
|
96
|
-
function Header(props) {
|
|
97
|
-
return (() => {
|
|
98
|
-
var _el$ = _$createElement("box"), _el$2 = _$createElement("text"), _el$3 = _$createElement("span"), _el$4 = _$createElement("span"), _el$6 = _$createElement("text");
|
|
99
|
-
_$insertNode(_el$, _el$2);
|
|
100
|
-
_$insertNode(_el$, _el$6);
|
|
101
|
-
_$setProp(_el$, "flexDirection", "row");
|
|
102
|
-
_$setProp(_el$, "justifyContent", "space-between");
|
|
103
|
-
_$setProp(_el$, "height", 1);
|
|
104
|
-
_$setProp(_el$, "flexShrink", 0);
|
|
105
|
-
_$insertNode(_el$2, _el$3);
|
|
106
|
-
_$insertNode(_el$2, _el$4);
|
|
107
|
-
_$insert(_el$3, () => props.product);
|
|
108
|
-
_$insertNode(_el$4, _$createTextNode(` Triage`));
|
|
109
|
-
_$insert(_el$6, () => props.detail);
|
|
110
|
-
_$effect((_p$) => {
|
|
111
|
-
var _v$ = {
|
|
112
|
-
fg: props.theme.product,
|
|
113
|
-
bold: true
|
|
114
|
-
}, _v$2 = {
|
|
115
|
-
fg: props.theme.text
|
|
116
|
-
}, _v$3 = props.theme.muted;
|
|
117
|
-
_v$ !== _p$.e && (_p$.e = _$setProp(_el$3, "style", _v$, _p$.e));
|
|
118
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$4, "style", _v$2, _p$.t));
|
|
119
|
-
_v$3 !== _p$.a && (_p$.a = _$setProp(_el$6, "fg", _v$3, _p$.a));
|
|
120
|
-
return _p$;
|
|
121
|
-
}, {
|
|
122
|
-
e: undefined,
|
|
123
|
-
t: undefined,
|
|
124
|
-
a: undefined
|
|
125
|
-
});
|
|
126
|
-
return _el$;
|
|
127
|
-
})();
|
|
128
|
-
}
|
|
129
|
-
function Hints(props) {
|
|
130
|
-
return (() => {
|
|
131
|
-
var _el$7 = _$createElement("text");
|
|
132
|
-
_$setProp(_el$7, "flexShrink", 0);
|
|
133
|
-
_$insert(_el$7, _$createComponent(For, {
|
|
134
|
-
get each() {
|
|
135
|
-
return props.hints;
|
|
136
|
-
},
|
|
137
|
-
children: ([key, label], index) => [_$createComponent(Show, {
|
|
138
|
-
get when() {
|
|
139
|
-
return index() > 0;
|
|
140
|
-
},
|
|
141
|
-
get children() {
|
|
142
|
-
var _el$8 = _$createElement("span");
|
|
143
|
-
_$insertNode(_el$8, _$createTextNode(` \xB7 `));
|
|
144
|
-
_$effect((_$p) => _$setProp(_el$8, "style", {
|
|
145
|
-
fg: props.theme.faint
|
|
146
|
-
}, _$p));
|
|
147
|
-
return _el$8;
|
|
148
|
-
}
|
|
149
|
-
}), (() => {
|
|
150
|
-
var _el$0 = _$createElement("span");
|
|
151
|
-
_$insert(_el$0, key);
|
|
152
|
-
_$effect((_$p) => _$setProp(_el$0, "style", {
|
|
153
|
-
fg: props.theme.text
|
|
154
|
-
}, _$p));
|
|
155
|
-
return _el$0;
|
|
156
|
-
})(), (() => {
|
|
157
|
-
var _el$1 = _$createElement("span"), _el$10 = _$createTextNode(` `);
|
|
158
|
-
_$insertNode(_el$1, _el$10);
|
|
159
|
-
_$insert(_el$1, label, null);
|
|
160
|
-
_$effect((_$p) => _$setProp(_el$1, "style", {
|
|
161
|
-
fg: props.theme.muted
|
|
162
|
-
}, _$p));
|
|
163
|
-
return _el$1;
|
|
164
|
-
})()]
|
|
165
|
-
}));
|
|
166
|
-
return _el$7;
|
|
167
|
-
})();
|
|
168
|
-
}
|
|
169
|
-
function BrandLabel(props) {
|
|
170
|
-
const label = () => ` ${props.name} `;
|
|
171
|
-
const colors = () => props.brand?.color ?? [props.theme.text];
|
|
172
|
-
const selectedText = () => props.brand?.selectedText ?? props.theme.background;
|
|
173
|
-
return (() => {
|
|
174
|
-
var _el$11 = _$createElement("text");
|
|
175
|
-
_$insert(_el$11, _$createComponent(For, {
|
|
176
|
-
get each() {
|
|
177
|
-
return [...label()];
|
|
178
|
-
},
|
|
179
|
-
children: (char, index) => {
|
|
180
|
-
const color = () => gradientAt(colors(), label().length > 1 ? index() / (label().length - 1) : 0);
|
|
181
|
-
return (() => {
|
|
182
|
-
var _el$12 = _$createElement("span");
|
|
183
|
-
_$insert(_el$12, char);
|
|
184
|
-
_$effect((_$p) => _$setProp(_el$12, "style", props.selected ? {
|
|
185
|
-
fg: selectedText(),
|
|
186
|
-
bg: color(),
|
|
187
|
-
bold: true
|
|
188
|
-
} : {
|
|
189
|
-
fg: color()
|
|
190
|
-
}, _$p));
|
|
191
|
-
return _el$12;
|
|
192
|
-
})();
|
|
193
|
-
}
|
|
194
|
-
}));
|
|
195
|
-
return _el$11;
|
|
196
|
-
})();
|
|
197
|
-
}
|
|
198
|
-
function ButtonRow(props) {
|
|
199
|
-
return (() => {
|
|
200
|
-
var _el$13 = _$createElement("box");
|
|
201
|
-
_$setProp(_el$13, "flexDirection", "row");
|
|
202
|
-
_$setProp(_el$13, "flexWrap", "wrap");
|
|
203
|
-
_$setProp(_el$13, "columnGap", 2);
|
|
204
|
-
_$setProp(_el$13, "flexShrink", 0);
|
|
205
|
-
_$insert(_el$13, _$createComponent(For, {
|
|
206
|
-
get each() {
|
|
207
|
-
return props.items;
|
|
208
|
-
},
|
|
209
|
-
children: (item, index) => {
|
|
210
|
-
const active = () => props.focused && index() === props.index;
|
|
211
|
-
return (() => {
|
|
212
|
-
var _el$14 = _$createElement("text"), _el$15 = _$createElement("span"), _el$17 = _$createElement("span"), _el$18 = _$createTextNode(` `);
|
|
213
|
-
_$insertNode(_el$14, _el$15);
|
|
214
|
-
_$insertNode(_el$14, _el$17);
|
|
215
|
-
_$insertNode(_el$15, _$createTextNode(` `));
|
|
216
|
-
_$insert(_el$14, _$createComponent(Show, {
|
|
217
|
-
get when() {
|
|
218
|
-
return item.prefix;
|
|
219
|
-
},
|
|
220
|
-
children: (prefix) => (() => {
|
|
221
|
-
var _el$19 = _$createElement("span"), _el$20 = _$createTextNode(` `);
|
|
222
|
-
_$insertNode(_el$19, _el$20);
|
|
223
|
-
_$insert(_el$19, () => prefix().text, _el$20);
|
|
224
|
-
_$effect((_$p) => _$setProp(_el$19, "style", active() ? {
|
|
225
|
-
fg: props.theme.background,
|
|
226
|
-
bg: props.theme.focus,
|
|
227
|
-
bold: true
|
|
228
|
-
} : {
|
|
229
|
-
fg: prefix().color,
|
|
230
|
-
bold: true
|
|
231
|
-
}, _$p));
|
|
232
|
-
return _el$19;
|
|
233
|
-
})()
|
|
234
|
-
}), _el$17);
|
|
235
|
-
_$insertNode(_el$17, _el$18);
|
|
236
|
-
_$insert(_el$17, () => item.label, _el$18);
|
|
237
|
-
_$effect((_p$) => {
|
|
238
|
-
var _v$4 = active() ? {
|
|
239
|
-
fg: props.theme.background,
|
|
240
|
-
bg: props.theme.focus
|
|
241
|
-
} : {
|
|
242
|
-
fg: props.theme.text
|
|
243
|
-
}, _v$5 = active() ? {
|
|
244
|
-
fg: props.theme.background,
|
|
245
|
-
bg: props.theme.focus,
|
|
246
|
-
bold: true
|
|
247
|
-
} : {
|
|
248
|
-
fg: props.theme.text
|
|
249
|
-
};
|
|
250
|
-
_v$4 !== _p$.e && (_p$.e = _$setProp(_el$15, "style", _v$4, _p$.e));
|
|
251
|
-
_v$5 !== _p$.t && (_p$.t = _$setProp(_el$17, "style", _v$5, _p$.t));
|
|
252
|
-
return _p$;
|
|
253
|
-
}, {
|
|
254
|
-
e: undefined,
|
|
255
|
-
t: undefined
|
|
256
|
-
});
|
|
257
|
-
return _el$14;
|
|
258
|
-
})();
|
|
259
|
-
}
|
|
260
|
-
}));
|
|
261
|
-
return _el$13;
|
|
262
|
-
})();
|
|
263
|
-
}
|
|
264
|
-
function Modal(props) {
|
|
265
|
-
return (() => {
|
|
266
|
-
var _el$21 = _$createElement("box"), _el$22 = _$createElement("box"), _el$23 = _$createElement("text");
|
|
267
|
-
_$insertNode(_el$21, _el$22);
|
|
268
|
-
_$setProp(_el$21, "position", "absolute");
|
|
269
|
-
_$setProp(_el$21, "left", 0);
|
|
270
|
-
_$setProp(_el$21, "top", 0);
|
|
271
|
-
_$setProp(_el$21, "width", "100%");
|
|
272
|
-
_$setProp(_el$21, "height", "100%");
|
|
273
|
-
_$setProp(_el$21, "zIndex", 100);
|
|
274
|
-
_$setProp(_el$21, "alignItems", "center");
|
|
275
|
-
_$setProp(_el$21, "justifyContent", "center");
|
|
276
|
-
_$insertNode(_el$22, _el$23);
|
|
277
|
-
_$setProp(_el$22, "maxWidth", "90%");
|
|
278
|
-
_$setProp(_el$22, "border", true);
|
|
279
|
-
_$setProp(_el$22, "borderStyle", "single");
|
|
280
|
-
_$setProp(_el$22, "paddingX", 2);
|
|
281
|
-
_$setProp(_el$22, "paddingY", 1);
|
|
282
|
-
_$setProp(_el$22, "flexDirection", "column");
|
|
283
|
-
_$setProp(_el$22, "gap", 1);
|
|
284
|
-
_$setProp(_el$23, "attributes", BOLD);
|
|
285
|
-
_$insert(_el$23, () => props.title);
|
|
286
|
-
_$insert(_el$22, () => props.children, null);
|
|
287
|
-
_$effect((_p$) => {
|
|
288
|
-
var _v$6 = props.theme.scrim, _v$7 = props.width ?? 64, _v$8 = props.theme.border, _v$9 = props.theme.background, _v$0 = props.theme.text;
|
|
289
|
-
_v$6 !== _p$.e && (_p$.e = _$setProp(_el$21, "backgroundColor", _v$6, _p$.e));
|
|
290
|
-
_v$7 !== _p$.t && (_p$.t = _$setProp(_el$22, "width", _v$7, _p$.t));
|
|
291
|
-
_v$8 !== _p$.a && (_p$.a = _$setProp(_el$22, "borderColor", _v$8, _p$.a));
|
|
292
|
-
_v$9 !== _p$.o && (_p$.o = _$setProp(_el$22, "backgroundColor", _v$9, _p$.o));
|
|
293
|
-
_v$0 !== _p$.i && (_p$.i = _$setProp(_el$23, "fg", _v$0, _p$.i));
|
|
294
|
-
return _p$;
|
|
295
|
-
}, {
|
|
296
|
-
e: undefined,
|
|
297
|
-
t: undefined,
|
|
298
|
-
a: undefined,
|
|
299
|
-
o: undefined,
|
|
300
|
-
i: undefined
|
|
301
|
-
});
|
|
302
|
-
return _el$21;
|
|
303
|
-
})();
|
|
304
|
-
}
|
|
305
|
-
function Spinner(props) {
|
|
306
|
-
const frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
307
|
-
return (() => {
|
|
308
|
-
var _el$24 = _$createElement("text"), _el$25 = _$createElement("span"), _el$26 = _$createTextNode(` `), _el$27 = _$createElement("span");
|
|
309
|
-
_$insertNode(_el$24, _el$25);
|
|
310
|
-
_$insertNode(_el$24, _el$27);
|
|
311
|
-
_$insertNode(_el$25, _el$26);
|
|
312
|
-
_$insert(_el$25, () => frames[props.frame % frames.length], _el$26);
|
|
313
|
-
_$insert(_el$27, () => props.label);
|
|
314
|
-
_$effect((_p$) => {
|
|
315
|
-
var _v$1 = {
|
|
316
|
-
fg: props.theme.text
|
|
317
|
-
}, _v$10 = {
|
|
318
|
-
fg: props.theme.muted
|
|
319
|
-
};
|
|
320
|
-
_v$1 !== _p$.e && (_p$.e = _$setProp(_el$25, "style", _v$1, _p$.e));
|
|
321
|
-
_v$10 !== _p$.t && (_p$.t = _$setProp(_el$27, "style", _v$10, _p$.t));
|
|
322
|
-
return _p$;
|
|
323
|
-
}, {
|
|
324
|
-
e: undefined,
|
|
325
|
-
t: undefined
|
|
326
|
-
});
|
|
327
|
-
return _el$24;
|
|
328
|
-
})();
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// src/tui/modals.tsx
|
|
332
|
-
import { memo as _$memo } from "@opentui/solid";
|
|
333
|
-
import { createComponent as _$createComponent2 } from "@opentui/solid";
|
|
334
|
-
import { setProp as _$setProp2 } from "@opentui/solid";
|
|
335
|
-
import { effect as _$effect2 } from "@opentui/solid";
|
|
336
|
-
import { insert as _$insert2 } from "@opentui/solid";
|
|
337
|
-
import { createTextNode as _$createTextNode2 } from "@opentui/solid";
|
|
338
|
-
import { insertNode as _$insertNode2 } from "@opentui/solid";
|
|
339
|
-
import { createElement as _$createElement2 } from "@opentui/solid";
|
|
340
|
-
import { useKeyboard } from "@opentui/solid";
|
|
341
|
-
import { createMemo, createSignal, For as For2, Match, Show as Show2, Switch } from "solid-js";
|
|
342
|
-
import { linkIncludesIssue } from "trissue-embedded";
|
|
343
|
-
var LIST_ROWS = 8;
|
|
344
|
-
function ModelPicker(props) {
|
|
345
|
-
const c = props.controller;
|
|
346
|
-
const [query, setQuery] = createSignal("");
|
|
347
|
-
const [index, setIndex] = createSignal(0);
|
|
348
|
-
const session = () => {
|
|
349
|
-
const state = c.sessionState();
|
|
350
|
-
return state.status === "ready" ? state.session : null;
|
|
351
|
-
};
|
|
352
|
-
const allowed = createMemo(() => {
|
|
353
|
-
const ready = session();
|
|
354
|
-
return ready ? c.allowedModels(ready) : [];
|
|
355
|
-
});
|
|
356
|
-
const matches = createMemo(() => {
|
|
357
|
-
const words = query().toLowerCase().split(/\s+/).filter(Boolean);
|
|
358
|
-
return allowed().filter((model) => words.every((word) => `${model.name} ${model.id}`.toLowerCase().includes(word)));
|
|
359
|
-
});
|
|
360
|
-
const windowStart = () => Math.min(Math.max(index() - LIST_ROWS + 1, 0), Math.max(matches().length - LIST_ROWS, 0));
|
|
361
|
-
useKeyboard((key) => {
|
|
362
|
-
if (key.name === "escape") {
|
|
363
|
-
key.preventDefault();
|
|
364
|
-
c.setModal(null);
|
|
365
|
-
} else if (key.name === "up")
|
|
366
|
-
setIndex((value) => Math.max(value - 1, 0));
|
|
367
|
-
else if (key.name === "down")
|
|
368
|
-
setIndex((value) => Math.min(value + 1, Math.max(matches().length - 1, 0)));
|
|
369
|
-
else if (key.name === "return") {
|
|
370
|
-
const model = matches()[index()];
|
|
371
|
-
if (model)
|
|
372
|
-
c.start(model.id);
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
const harnessName = () => c.harness()?.name ?? "The agent";
|
|
376
|
-
const filter = () => c.config()?.models;
|
|
377
|
-
return _$createComponent2(Modal, {
|
|
378
|
-
get theme() {
|
|
379
|
-
return props.theme;
|
|
380
|
-
},
|
|
381
|
-
title: "Select model",
|
|
382
|
-
width: 60,
|
|
383
|
-
get children() {
|
|
384
|
-
return [_$createComponent2(Switch, {
|
|
385
|
-
get children() {
|
|
386
|
-
return [_$createComponent2(Match, {
|
|
387
|
-
get when() {
|
|
388
|
-
return c.sessionState().status === "starting";
|
|
389
|
-
},
|
|
390
|
-
get children() {
|
|
391
|
-
var _el$ = _$createElement2("text"), _el$2 = _$createTextNode2(`Starting `), _el$3 = _$createTextNode2(`\u2026`);
|
|
392
|
-
_$insertNode2(_el$, _el$2);
|
|
393
|
-
_$insertNode2(_el$, _el$3);
|
|
394
|
-
_$insert2(_el$, harnessName, _el$3);
|
|
395
|
-
_$effect2((_$p) => _$setProp2(_el$, "fg", props.theme.muted, _$p));
|
|
396
|
-
return _el$;
|
|
397
|
-
}
|
|
398
|
-
}), _$createComponent2(Match, {
|
|
399
|
-
get when() {
|
|
400
|
-
const state = c.sessionState();
|
|
401
|
-
return state.status === "failed" ? state.error : null;
|
|
402
|
-
},
|
|
403
|
-
children: (error) => (() => {
|
|
404
|
-
var _el$18 = _$createElement2("text");
|
|
405
|
-
_$insert2(_el$18, error);
|
|
406
|
-
_$effect2((_$p) => _$setProp2(_el$18, "fg", props.theme.danger, _$p));
|
|
407
|
-
return _el$18;
|
|
408
|
-
})()
|
|
409
|
-
}), _$createComponent2(Match, {
|
|
410
|
-
get when() {
|
|
411
|
-
return _$memo(() => !!session())() && session().models.length === 0;
|
|
412
|
-
},
|
|
413
|
-
get children() {
|
|
414
|
-
var _el$4 = _$createElement2("text"), _el$5 = _$createTextNode2(` doesn't list its models. Use its default model instead.`);
|
|
415
|
-
_$insertNode2(_el$4, _el$5);
|
|
416
|
-
_$insert2(_el$4, harnessName, _el$5);
|
|
417
|
-
_$effect2((_$p) => _$setProp2(_el$4, "fg", props.theme.text, _$p));
|
|
418
|
-
return _el$4;
|
|
419
|
-
}
|
|
420
|
-
}), _$createComponent2(Match, {
|
|
421
|
-
get when() {
|
|
422
|
-
return _$memo(() => !!session())() && allowed().length === 0;
|
|
423
|
-
},
|
|
424
|
-
get children() {
|
|
425
|
-
var _el$6 = _$createElement2("box"), _el$7 = _$createElement2("text"), _el$9 = _$createElement2("text"), _el$0 = _$createTextNode2(`This repo doesn't allow any of `), _el$1 = _$createTextNode2(`'s models. Choose another agent.`);
|
|
426
|
-
_$insertNode2(_el$6, _el$7);
|
|
427
|
-
_$insertNode2(_el$6, _el$9);
|
|
428
|
-
_$setProp2(_el$6, "flexDirection", "column");
|
|
429
|
-
_$setProp2(_el$6, "gap", 1);
|
|
430
|
-
_$insertNode2(_el$7, _$createTextNode2(`No models are available`));
|
|
431
|
-
_$setProp2(_el$7, "attributes", BOLD);
|
|
432
|
-
_$insertNode2(_el$9, _el$0);
|
|
433
|
-
_$insertNode2(_el$9, _el$1);
|
|
434
|
-
_$insert2(_el$9, harnessName, _el$1);
|
|
435
|
-
_$insert2(_el$6, _$createComponent2(Show2, {
|
|
436
|
-
get when() {
|
|
437
|
-
return filter()?.allow?.length;
|
|
438
|
-
},
|
|
439
|
-
get children() {
|
|
440
|
-
var _el$10 = _$createElement2("text"), _el$11 = _$createTextNode2(`Allowed: `);
|
|
441
|
-
_$insertNode2(_el$10, _el$11);
|
|
442
|
-
_$insert2(_el$10, () => filter().allow.join(", "), null);
|
|
443
|
-
_$effect2((_$p) => _$setProp2(_el$10, "fg", props.theme.muted, _$p));
|
|
444
|
-
return _el$10;
|
|
445
|
-
}
|
|
446
|
-
}), null);
|
|
447
|
-
_$insert2(_el$6, _$createComponent2(Show2, {
|
|
448
|
-
get when() {
|
|
449
|
-
return filter()?.block?.length;
|
|
450
|
-
},
|
|
451
|
-
get children() {
|
|
452
|
-
var _el$12 = _$createElement2("text"), _el$13 = _$createTextNode2(`Blocked: `);
|
|
453
|
-
_$insertNode2(_el$12, _el$13);
|
|
454
|
-
_$insert2(_el$12, () => filter().block.join(", "), null);
|
|
455
|
-
_$effect2((_$p) => _$setProp2(_el$12, "fg", props.theme.muted, _$p));
|
|
456
|
-
return _el$12;
|
|
457
|
-
}
|
|
458
|
-
}), null);
|
|
459
|
-
_$effect2((_p$) => {
|
|
460
|
-
var _v$ = props.theme.danger, _v$2 = props.theme.text;
|
|
461
|
-
_v$ !== _p$.e && (_p$.e = _$setProp2(_el$7, "fg", _v$, _p$.e));
|
|
462
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp2(_el$9, "fg", _v$2, _p$.t));
|
|
463
|
-
return _p$;
|
|
464
|
-
}, {
|
|
465
|
-
e: undefined,
|
|
466
|
-
t: undefined
|
|
467
|
-
});
|
|
468
|
-
return _el$6;
|
|
469
|
-
}
|
|
470
|
-
}), _$createComponent2(Match, {
|
|
471
|
-
get when() {
|
|
472
|
-
return session();
|
|
473
|
-
},
|
|
474
|
-
get children() {
|
|
475
|
-
var _el$14 = _$createElement2("box"), _el$15 = _$createElement2("box"), _el$16 = _$createElement2("input"), _el$17 = _$createElement2("box");
|
|
476
|
-
_$insertNode2(_el$14, _el$15);
|
|
477
|
-
_$insertNode2(_el$14, _el$17);
|
|
478
|
-
_$setProp2(_el$14, "flexDirection", "column");
|
|
479
|
-
_$setProp2(_el$14, "gap", 1);
|
|
480
|
-
_$insertNode2(_el$15, _el$16);
|
|
481
|
-
_$setProp2(_el$15, "border", true);
|
|
482
|
-
_$setProp2(_el$15, "borderStyle", "single");
|
|
483
|
-
_$setProp2(_el$15, "paddingX", 1);
|
|
484
|
-
_$setProp2(_el$15, "height", 3);
|
|
485
|
-
_$setProp2(_el$16, "focused", true);
|
|
486
|
-
_$setProp2(_el$16, "placeholder", "Search");
|
|
487
|
-
_$setProp2(_el$16, "onInput", (value) => {
|
|
488
|
-
setQuery(value);
|
|
489
|
-
setIndex(0);
|
|
490
|
-
});
|
|
491
|
-
_$setProp2(_el$17, "flexDirection", "column");
|
|
492
|
-
_$setProp2(_el$17, "height", 8);
|
|
493
|
-
_$insert2(_el$17, _$createComponent2(Show2, {
|
|
494
|
-
get when() {
|
|
495
|
-
return matches().length > 0;
|
|
496
|
-
},
|
|
497
|
-
get fallback() {
|
|
498
|
-
return (() => {
|
|
499
|
-
var _el$19 = _$createElement2("text"), _el$20 = _$createTextNode2(`No models match "`), _el$21 = _$createTextNode2(`".`);
|
|
500
|
-
_$insertNode2(_el$19, _el$20);
|
|
501
|
-
_$insertNode2(_el$19, _el$21);
|
|
502
|
-
_$insert2(_el$19, query, _el$21);
|
|
503
|
-
_$effect2((_$p) => _$setProp2(_el$19, "fg", props.theme.muted, _$p));
|
|
504
|
-
return _el$19;
|
|
505
|
-
})();
|
|
506
|
-
},
|
|
507
|
-
get children() {
|
|
508
|
-
return _$createComponent2(For2, {
|
|
509
|
-
get each() {
|
|
510
|
-
return matches().slice(windowStart(), windowStart() + LIST_ROWS);
|
|
511
|
-
},
|
|
512
|
-
children: (model, offset) => {
|
|
513
|
-
const active = () => windowStart() + offset() === index();
|
|
514
|
-
const isDefault = () => model.id === session()?.currentModel?.id;
|
|
515
|
-
return (() => {
|
|
516
|
-
var _el$22 = _$createElement2("box"), _el$23 = _$createElement2("text"), _el$24 = _$createElement2("text");
|
|
517
|
-
_$insertNode2(_el$22, _el$23);
|
|
518
|
-
_$insertNode2(_el$22, _el$24);
|
|
519
|
-
_$setProp2(_el$22, "flexDirection", "row");
|
|
520
|
-
_$setProp2(_el$22, "justifyContent", "space-between");
|
|
521
|
-
_$setProp2(_el$22, "paddingX", 1);
|
|
522
|
-
_$insert2(_el$23, () => model.name);
|
|
523
|
-
_$insert2(_el$24, (() => {
|
|
524
|
-
var _c$ = _$memo(() => !!isDefault());
|
|
525
|
-
return () => _c$() ? "default" : model.id;
|
|
526
|
-
})());
|
|
527
|
-
_$effect2((_p$) => {
|
|
528
|
-
var _v$0 = active() ? props.theme.focus : props.theme.background, _v$1 = active() ? props.theme.background : props.theme.text, _v$10 = active() ? BOLD : 0, _v$11 = active() ? props.theme.background : props.theme.faint;
|
|
529
|
-
_v$0 !== _p$.e && (_p$.e = _$setProp2(_el$22, "backgroundColor", _v$0, _p$.e));
|
|
530
|
-
_v$1 !== _p$.t && (_p$.t = _$setProp2(_el$23, "fg", _v$1, _p$.t));
|
|
531
|
-
_v$10 !== _p$.a && (_p$.a = _$setProp2(_el$23, "attributes", _v$10, _p$.a));
|
|
532
|
-
_v$11 !== _p$.o && (_p$.o = _$setProp2(_el$24, "fg", _v$11, _p$.o));
|
|
533
|
-
return _p$;
|
|
534
|
-
}, {
|
|
535
|
-
e: undefined,
|
|
536
|
-
t: undefined,
|
|
537
|
-
a: undefined,
|
|
538
|
-
o: undefined
|
|
539
|
-
});
|
|
540
|
-
return _el$22;
|
|
541
|
-
})();
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
}));
|
|
546
|
-
_$effect2((_p$) => {
|
|
547
|
-
var _v$3 = props.theme.border, _v$4 = props.theme.faint, _v$5 = props.theme.text, _v$6 = props.theme.text, _v$7 = props.theme.background, _v$8 = props.theme.background, _v$9 = props.theme.text;
|
|
548
|
-
_v$3 !== _p$.e && (_p$.e = _$setProp2(_el$15, "borderColor", _v$3, _p$.e));
|
|
549
|
-
_v$4 !== _p$.t && (_p$.t = _$setProp2(_el$16, "placeholderColor", _v$4, _p$.t));
|
|
550
|
-
_v$5 !== _p$.a && (_p$.a = _$setProp2(_el$16, "textColor", _v$5, _p$.a));
|
|
551
|
-
_v$6 !== _p$.o && (_p$.o = _$setProp2(_el$16, "focusedTextColor", _v$6, _p$.o));
|
|
552
|
-
_v$7 !== _p$.i && (_p$.i = _$setProp2(_el$16, "backgroundColor", _v$7, _p$.i));
|
|
553
|
-
_v$8 !== _p$.n && (_p$.n = _$setProp2(_el$16, "focusedBackgroundColor", _v$8, _p$.n));
|
|
554
|
-
_v$9 !== _p$.s && (_p$.s = _$setProp2(_el$16, "cursorColor", _v$9, _p$.s));
|
|
555
|
-
return _p$;
|
|
556
|
-
}, {
|
|
557
|
-
e: undefined,
|
|
558
|
-
t: undefined,
|
|
559
|
-
a: undefined,
|
|
560
|
-
o: undefined,
|
|
561
|
-
i: undefined,
|
|
562
|
-
n: undefined,
|
|
563
|
-
s: undefined
|
|
564
|
-
});
|
|
565
|
-
return _el$14;
|
|
566
|
-
}
|
|
567
|
-
})];
|
|
568
|
-
}
|
|
569
|
-
}), _$createComponent2(Hints, {
|
|
570
|
-
get theme() {
|
|
571
|
-
return props.theme;
|
|
572
|
-
},
|
|
573
|
-
get hints() {
|
|
574
|
-
return session() && allowed().length ? [["\u2191\u2193", "choose"], ["enter", "start"], ["esc", "close"]] : [["esc", "close"]];
|
|
575
|
-
}
|
|
576
|
-
})];
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
function Confirm(props) {
|
|
581
|
-
const [index, setIndex] = createSignal(0);
|
|
582
|
-
useKeyboard((key) => {
|
|
583
|
-
if (key.name === "escape") {
|
|
584
|
-
key.preventDefault();
|
|
585
|
-
props.onClose();
|
|
586
|
-
} else if (key.name === "left")
|
|
587
|
-
setIndex((value) => Math.max(value - 1, 0));
|
|
588
|
-
else if (key.name === "right" || key.name === "tab")
|
|
589
|
-
setIndex((value) => Math.min(value + 1, props.buttons.length - 1));
|
|
590
|
-
else if (key.name === "return")
|
|
591
|
-
props.buttons[index()]?.run();
|
|
592
|
-
});
|
|
593
|
-
return _$createComponent2(Modal, {
|
|
594
|
-
get theme() {
|
|
595
|
-
return props.theme;
|
|
596
|
-
},
|
|
597
|
-
get title() {
|
|
598
|
-
return props.title;
|
|
599
|
-
},
|
|
600
|
-
get children() {
|
|
601
|
-
return [(() => {
|
|
602
|
-
var _el$25 = _$createElement2("box");
|
|
603
|
-
_$setProp2(_el$25, "flexDirection", "column");
|
|
604
|
-
_$setProp2(_el$25, "gap", 1);
|
|
605
|
-
_$insert2(_el$25, () => props.children);
|
|
606
|
-
return _el$25;
|
|
607
|
-
})(), _$createComponent2(ButtonRow, {
|
|
608
|
-
get theme() {
|
|
609
|
-
return props.theme;
|
|
610
|
-
},
|
|
611
|
-
focused: true,
|
|
612
|
-
get index() {
|
|
613
|
-
return index();
|
|
614
|
-
},
|
|
615
|
-
get items() {
|
|
616
|
-
return props.buttons.map((button) => ({
|
|
617
|
-
label: button.label
|
|
618
|
-
}));
|
|
619
|
-
}
|
|
620
|
-
})];
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
function shorten(url, max = 120) {
|
|
625
|
-
return url.length > max ? `${url.slice(0, max - 1)}\u2026` : url;
|
|
626
|
-
}
|
|
627
|
-
function Modals(props) {
|
|
628
|
-
const c = props.controller;
|
|
629
|
-
const close = () => c.setModal(null);
|
|
630
|
-
const is = (name) => {
|
|
631
|
-
const modal = c.modal();
|
|
632
|
-
return modal?.name === name ? modal : null;
|
|
633
|
-
};
|
|
634
|
-
return _$createComponent2(Switch, {
|
|
635
|
-
get children() {
|
|
636
|
-
return [_$createComponent2(Match, {
|
|
637
|
-
get when() {
|
|
638
|
-
return is("models");
|
|
639
|
-
},
|
|
640
|
-
get children() {
|
|
641
|
-
return _$createComponent2(ModelPicker, {
|
|
642
|
-
controller: c,
|
|
643
|
-
get theme() {
|
|
644
|
-
return props.theme;
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
}), _$createComponent2(Match, {
|
|
649
|
-
get when() {
|
|
650
|
-
return is("github-confirm");
|
|
651
|
-
},
|
|
652
|
-
children: (modal) => _$createComponent2(Confirm, {
|
|
653
|
-
get theme() {
|
|
654
|
-
return props.theme;
|
|
655
|
-
},
|
|
656
|
-
title: "File an issue on GitHub?",
|
|
657
|
-
onClose: close,
|
|
658
|
-
buttons: [{
|
|
659
|
-
label: "File issue",
|
|
660
|
-
run: () => void c.fileOnGitHub(modal().repo)
|
|
661
|
-
}, {
|
|
662
|
-
label: "Cancel",
|
|
663
|
-
run: close
|
|
664
|
-
}],
|
|
665
|
-
get children() {
|
|
666
|
-
return [(() => {
|
|
667
|
-
var _el$28 = _$createElement2("text"), _el$29 = _$createTextNode2(`This runs `), _el$30 = _$createElement2("span"), _el$32 = _$createTextNode2(` and posts the issue to `), _el$34 = _$createElement2("span"), _el$35 = _$createTextNode2(` as `), _el$36 = _$createElement2("span"), _el$37 = _$createTextNode2(`@`), _el$38 = _$createTextNode2(`.`);
|
|
668
|
-
_$insertNode2(_el$28, _el$29);
|
|
669
|
-
_$insertNode2(_el$28, _el$30);
|
|
670
|
-
_$insertNode2(_el$28, _el$32);
|
|
671
|
-
_$insertNode2(_el$28, _el$34);
|
|
672
|
-
_$insertNode2(_el$28, _el$35);
|
|
673
|
-
_$insertNode2(_el$28, _el$36);
|
|
674
|
-
_$insertNode2(_el$28, _el$38);
|
|
675
|
-
_$insertNode2(_el$30, _$createTextNode2(`gh issue create`));
|
|
676
|
-
_$setProp2(_el$30, "style", {
|
|
677
|
-
bold: true
|
|
678
|
-
});
|
|
679
|
-
_$setProp2(_el$34, "style", {
|
|
680
|
-
bold: true
|
|
681
|
-
});
|
|
682
|
-
_$insert2(_el$34, () => modal().repo);
|
|
683
|
-
_$insertNode2(_el$36, _el$37);
|
|
684
|
-
_$setProp2(_el$36, "style", {
|
|
685
|
-
bold: true
|
|
686
|
-
});
|
|
687
|
-
_$insert2(_el$36, () => modal().login, null);
|
|
688
|
-
_$effect2((_$p) => _$setProp2(_el$28, "fg", props.theme.text, _$p));
|
|
689
|
-
return _el$28;
|
|
690
|
-
})(), (() => {
|
|
691
|
-
var _el$39 = _$createElement2("text");
|
|
692
|
-
_$insertNode2(_el$39, _$createTextNode2(`Issues on public repos can be read by anyone.`));
|
|
693
|
-
_$effect2((_$p) => _$setProp2(_el$39, "fg", props.theme.muted, _$p));
|
|
694
|
-
return _el$39;
|
|
695
|
-
})()];
|
|
696
|
-
}
|
|
697
|
-
})
|
|
698
|
-
}), _$createComponent2(Match, {
|
|
699
|
-
get when() {
|
|
700
|
-
return is("github-signin");
|
|
701
|
-
},
|
|
702
|
-
children: (modal) => _$createComponent2(Confirm, {
|
|
703
|
-
get theme() {
|
|
704
|
-
return props.theme;
|
|
705
|
-
},
|
|
706
|
-
title: "Sign in to GitHub",
|
|
707
|
-
onClose: close,
|
|
708
|
-
buttons: [{
|
|
709
|
-
label: "Sign in",
|
|
710
|
-
run: () => void c.signInToGitHub()
|
|
711
|
-
}, {
|
|
712
|
-
label: "Cancel",
|
|
713
|
-
run: close
|
|
714
|
-
}],
|
|
715
|
-
get children() {
|
|
716
|
-
return [(() => {
|
|
717
|
-
var _el$41 = _$createElement2("text");
|
|
718
|
-
_$insertNode2(_el$41, _$createTextNode2(`Filing an issue needs the GitHub CLI signed in.`));
|
|
719
|
-
_$effect2((_$p) => _$setProp2(_el$41, "fg", props.theme.text, _$p));
|
|
720
|
-
return _el$41;
|
|
721
|
-
})(), (() => {
|
|
722
|
-
var _el$43 = _$createElement2("text"), _el$44 = _$createTextNode2(`Sign in hands this terminal to `), _el$45 = _$createElement2("span"), _el$47 = _$createTextNode2(`, which opens GitHub in your browser. You come back here when it's done.`);
|
|
723
|
-
_$insertNode2(_el$43, _el$44);
|
|
724
|
-
_$insertNode2(_el$43, _el$45);
|
|
725
|
-
_$insertNode2(_el$43, _el$47);
|
|
726
|
-
_$insertNode2(_el$45, _$createTextNode2(`gh auth login`));
|
|
727
|
-
_$effect2((_p$) => {
|
|
728
|
-
var _v$12 = props.theme.muted, _v$13 = {
|
|
729
|
-
fg: props.theme.text
|
|
730
|
-
};
|
|
731
|
-
_v$12 !== _p$.e && (_p$.e = _$setProp2(_el$43, "fg", _v$12, _p$.e));
|
|
732
|
-
_v$13 !== _p$.t && (_p$.t = _$setProp2(_el$45, "style", _v$13, _p$.t));
|
|
733
|
-
return _p$;
|
|
734
|
-
}, {
|
|
735
|
-
e: undefined,
|
|
736
|
-
t: undefined
|
|
737
|
-
});
|
|
738
|
-
return _el$43;
|
|
739
|
-
})()];
|
|
740
|
-
}
|
|
741
|
-
})
|
|
742
|
-
}), _$createComponent2(Match, {
|
|
743
|
-
get when() {
|
|
744
|
-
return is("github-missing");
|
|
745
|
-
},
|
|
746
|
-
get children() {
|
|
747
|
-
return _$createComponent2(Confirm, {
|
|
748
|
-
get theme() {
|
|
749
|
-
return props.theme;
|
|
750
|
-
},
|
|
751
|
-
title: "The GitHub CLI isn't installed",
|
|
752
|
-
onClose: close,
|
|
753
|
-
buttons: [{
|
|
754
|
-
label: "Open cli.github.com",
|
|
755
|
-
run: () => void c.open("https://cli.github.com")
|
|
756
|
-
}, {
|
|
757
|
-
label: "Close",
|
|
758
|
-
run: close
|
|
759
|
-
}],
|
|
760
|
-
get children() {
|
|
761
|
-
var _el$26 = _$createElement2("text");
|
|
762
|
-
_$insertNode2(_el$26, _$createTextNode2(`Filing an issue uses the GitHub CLI (gh). Install it, then choose File an issue on GitHub again.`));
|
|
763
|
-
_$effect2((_$p) => _$setProp2(_el$26, "fg", props.theme.text, _$p));
|
|
764
|
-
return _el$26;
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
}), _$createComponent2(Match, {
|
|
769
|
-
get when() {
|
|
770
|
-
return is("filed");
|
|
771
|
-
},
|
|
772
|
-
children: (modal) => _$createComponent2(Confirm, {
|
|
773
|
-
get theme() {
|
|
774
|
-
return props.theme;
|
|
775
|
-
},
|
|
776
|
-
title: "Issue filed",
|
|
777
|
-
onClose: close,
|
|
778
|
-
buttons: [{
|
|
779
|
-
label: "Open issue",
|
|
780
|
-
run: () => void c.open(modal().url)
|
|
781
|
-
}, {
|
|
782
|
-
label: "Done",
|
|
783
|
-
run: close
|
|
784
|
-
}],
|
|
785
|
-
get children() {
|
|
786
|
-
var _el$48 = _$createElement2("text");
|
|
787
|
-
_$insert2(_el$48, () => modal().url);
|
|
788
|
-
_$effect2((_$p) => _$setProp2(_el$48, "fg", props.theme.text, _$p));
|
|
789
|
-
return _el$48;
|
|
790
|
-
}
|
|
791
|
-
})
|
|
792
|
-
}), _$createComponent2(Match, {
|
|
793
|
-
get when() {
|
|
794
|
-
return is("link");
|
|
795
|
-
},
|
|
796
|
-
children: (modal) => _$createComponent2(Confirm, {
|
|
797
|
-
get theme() {
|
|
798
|
-
return props.theme;
|
|
799
|
-
},
|
|
800
|
-
get title() {
|
|
801
|
-
return `Open ${modal().link.label}?`;
|
|
802
|
-
},
|
|
803
|
-
onClose: close,
|
|
804
|
-
buttons: [{
|
|
805
|
-
label: "Open link",
|
|
806
|
-
run: () => void c.open(modal().url)
|
|
807
|
-
}, {
|
|
808
|
-
label: "Cancel",
|
|
809
|
-
run: close
|
|
810
|
-
}],
|
|
811
|
-
get children() {
|
|
812
|
-
return [_$createComponent2(Show2, {
|
|
813
|
-
get when() {
|
|
814
|
-
return modal().link.description;
|
|
815
|
-
},
|
|
816
|
-
get children() {
|
|
817
|
-
var _el$49 = _$createElement2("text");
|
|
818
|
-
_$insert2(_el$49, () => modal().link.description);
|
|
819
|
-
_$effect2((_$p) => _$setProp2(_el$49, "fg", props.theme.text, _$p));
|
|
820
|
-
return _el$49;
|
|
821
|
-
}
|
|
822
|
-
}), (() => {
|
|
823
|
-
var _el$50 = _$createElement2("text");
|
|
824
|
-
_$insert2(_el$50, () => linkIncludesIssue(modal().link) ? "The link includes the issue's title and text." : "The link doesn't include the issue. Copy it first if you want to paste it there.");
|
|
825
|
-
_$effect2((_$p) => _$setProp2(_el$50, "fg", props.theme.text, _$p));
|
|
826
|
-
return _el$50;
|
|
827
|
-
})(), (() => {
|
|
828
|
-
var _el$51 = _$createElement2("text");
|
|
829
|
-
_$insert2(_el$51, () => shorten(modal().url));
|
|
830
|
-
_$effect2((_$p) => _$setProp2(_el$51, "fg", props.theme.muted, _$p));
|
|
831
|
-
return _el$51;
|
|
832
|
-
})()];
|
|
833
|
-
}
|
|
834
|
-
})
|
|
835
|
-
})];
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
// src/tui/screens/compose.tsx
|
|
841
|
-
import { effect as _$effect3 } from "@opentui/solid";
|
|
842
|
-
import { createTextNode as _$createTextNode3 } from "@opentui/solid";
|
|
843
|
-
import { insertNode as _$insertNode3 } from "@opentui/solid";
|
|
844
|
-
import { use as _$use } from "@opentui/solid";
|
|
845
|
-
import { insert as _$insert3 } from "@opentui/solid";
|
|
846
|
-
import { memo as _$memo2 } from "@opentui/solid";
|
|
847
|
-
import { createComponent as _$createComponent3 } from "@opentui/solid";
|
|
848
|
-
import { setProp as _$setProp3 } from "@opentui/solid";
|
|
849
|
-
import { createElement as _$createElement3 } from "@opentui/solid";
|
|
850
|
-
import { useKeyboard as useKeyboard2, useTerminalDimensions } from "@opentui/solid";
|
|
851
|
-
import { createMemo as createMemo2, createSignal as createSignal2, For as For3, Match as Match2, Show as Show3, Switch as Switch2 } from "solid-js";
|
|
852
|
-
var ZONES = ["input", "agents", "model"];
|
|
853
|
-
var MAX_ROWS = 3;
|
|
854
|
-
var CHIP_GAP = 1;
|
|
855
|
-
var ISSUE_KEYBINDINGS = [{
|
|
856
|
-
name: "z",
|
|
857
|
-
ctrl: true,
|
|
858
|
-
action: "undo"
|
|
859
|
-
}, {
|
|
860
|
-
name: "y",
|
|
861
|
-
ctrl: true,
|
|
862
|
-
action: "redo"
|
|
863
|
-
}, {
|
|
864
|
-
name: "z",
|
|
865
|
-
ctrl: true,
|
|
866
|
-
shift: true,
|
|
867
|
-
action: "redo"
|
|
868
|
-
}];
|
|
869
|
-
function ComposeScreen(props) {
|
|
870
|
-
const c = props.controller;
|
|
871
|
-
const dims = useTerminalDimensions();
|
|
872
|
-
const [zone, setZone] = createSignal2("input");
|
|
873
|
-
const [modelIndex, setModelIndex] = createSignal2(0);
|
|
874
|
-
let textarea;
|
|
875
|
-
const rows = createMemo2(() => {
|
|
876
|
-
const width = Math.max(dims().width - props.inset, 10);
|
|
877
|
-
const out = [];
|
|
878
|
-
let row = [];
|
|
879
|
-
let used = 0;
|
|
880
|
-
c.harnesses.forEach((harness, index) => {
|
|
881
|
-
const chip = harness.name.length + 2;
|
|
882
|
-
if (row.length && used + CHIP_GAP + chip > width) {
|
|
883
|
-
out.push(row);
|
|
884
|
-
row = [];
|
|
885
|
-
used = 0;
|
|
886
|
-
}
|
|
887
|
-
used += (row.length ? CHIP_GAP : 0) + chip;
|
|
888
|
-
row.push(index);
|
|
889
|
-
});
|
|
890
|
-
if (row.length)
|
|
891
|
-
out.push(row);
|
|
892
|
-
return out;
|
|
893
|
-
});
|
|
894
|
-
const rowOf = (index) => rows().findIndex((row) => row.includes(index));
|
|
895
|
-
const visibleRows = createMemo2(() => {
|
|
896
|
-
const all = rows();
|
|
897
|
-
const current = Math.max(rowOf(c.harnessIndex()), 0);
|
|
898
|
-
const first = Math.min(Math.max(current - MAX_ROWS + 1, 0), Math.max(all.length - MAX_ROWS, 0));
|
|
899
|
-
return {
|
|
900
|
-
first,
|
|
901
|
-
rows: all.slice(first, first + MAX_ROWS),
|
|
902
|
-
hidden: all.length - Math.min(all.length, MAX_ROWS)
|
|
903
|
-
};
|
|
904
|
-
});
|
|
905
|
-
function moveZone(step) {
|
|
906
|
-
const available = c.harnesses.length ? ZONES : ["input"];
|
|
907
|
-
const next = available[(available.indexOf(zone()) + step + available.length) % available.length];
|
|
908
|
-
setZone(next);
|
|
909
|
-
if (next === "model")
|
|
910
|
-
c.prepareSession();
|
|
911
|
-
}
|
|
912
|
-
function moveHarness(dx, dy) {
|
|
913
|
-
const all = rows();
|
|
914
|
-
const current = c.harnessIndex();
|
|
915
|
-
if (dx) {
|
|
916
|
-
c.selectHarness(Math.min(Math.max(current + dx, 0), c.harnesses.length - 1));
|
|
917
|
-
return;
|
|
918
|
-
}
|
|
919
|
-
const rowIndex = rowOf(current);
|
|
920
|
-
const target = all[rowIndex + dy];
|
|
921
|
-
if (!target)
|
|
922
|
-
return;
|
|
923
|
-
const column = all[rowIndex].indexOf(current);
|
|
924
|
-
c.selectHarness(target[Math.min(column, target.length - 1)]);
|
|
925
|
-
}
|
|
926
|
-
async function chooseModelOption() {
|
|
927
|
-
if (modelIndex() === 0) {
|
|
928
|
-
await c.start(null);
|
|
929
|
-
return;
|
|
930
|
-
}
|
|
931
|
-
c.setModal({
|
|
932
|
-
name: "models"
|
|
933
|
-
});
|
|
934
|
-
c.prepareSession();
|
|
935
|
-
}
|
|
936
|
-
useKeyboard2((key) => {
|
|
937
|
-
if (c.modal() || c.screen() !== "compose")
|
|
938
|
-
return;
|
|
939
|
-
if (key.name === "tab") {
|
|
940
|
-
key.preventDefault();
|
|
941
|
-
moveZone(key.shift ? -1 : 1);
|
|
942
|
-
return;
|
|
943
|
-
}
|
|
944
|
-
if (zone() === "agents") {
|
|
945
|
-
if (key.name === "left")
|
|
946
|
-
moveHarness(-1, 0);
|
|
947
|
-
else if (key.name === "right")
|
|
948
|
-
moveHarness(1, 0);
|
|
949
|
-
else if (key.name === "up")
|
|
950
|
-
moveHarness(0, -1);
|
|
951
|
-
else if (key.name === "down")
|
|
952
|
-
moveHarness(0, 1);
|
|
953
|
-
else if (key.name === "return")
|
|
954
|
-
moveZone(1);
|
|
955
|
-
} else if (zone() === "model") {
|
|
956
|
-
if (key.name === "left" || key.name === "right")
|
|
957
|
-
setModelIndex(key.name === "left" ? 0 : 1);
|
|
958
|
-
else if (key.name === "return")
|
|
959
|
-
chooseModelOption();
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
const sessionLine = () => {
|
|
963
|
-
const state = c.sessionState();
|
|
964
|
-
const harness = c.harness();
|
|
965
|
-
if (!harness || state.status === "idle")
|
|
966
|
-
return null;
|
|
967
|
-
if (state.status === "starting")
|
|
968
|
-
return {
|
|
969
|
-
text: `Starting ${harness.name}\u2026`,
|
|
970
|
-
color: props.theme.muted
|
|
971
|
-
};
|
|
972
|
-
if (state.status === "failed")
|
|
973
|
-
return {
|
|
974
|
-
text: state.error,
|
|
975
|
-
color: props.theme.danger
|
|
976
|
-
};
|
|
977
|
-
const model = state.session.currentModel;
|
|
978
|
-
return {
|
|
979
|
-
text: model ? `${harness.name} is ready. Its default model is ${model.name}.` : `${harness.name} is ready.`,
|
|
980
|
-
color: props.theme.muted
|
|
981
|
-
};
|
|
982
|
-
};
|
|
983
|
-
const hints = () => {
|
|
984
|
-
if (zone() === "input")
|
|
985
|
-
return [["tab", "next"], ["enter", "new line"], ["ctrl+c", "quit"]];
|
|
986
|
-
if (zone() === "agents")
|
|
987
|
-
return [["\u2190\u2192\u2191\u2193", "choose agent"], ["tab", "next"], ["shift+tab", "back"], ["ctrl+c", "quit"]];
|
|
988
|
-
return [["\u2190\u2192", "choose"], ["enter", modelIndex() === 0 ? "start" : "select model"], ["shift+tab", "back"], ["ctrl+c", "quit"]];
|
|
989
|
-
};
|
|
990
|
-
return (() => {
|
|
991
|
-
var _el$ = _$createElement3("box"), _el$2 = _$createElement3("box"), _el$3 = _$createElement3("text"), _el$4 = _$createElement3("box"), _el$5 = _$createElement3("textarea"), _el$6 = _$createElement3("box"), _el$7 = _$createElement3("text"), _el$16 = _$createElement3("box");
|
|
992
|
-
_$insertNode3(_el$, _el$2);
|
|
993
|
-
_$insertNode3(_el$, _el$6);
|
|
994
|
-
_$insertNode3(_el$, _el$16);
|
|
995
|
-
_$setProp3(_el$, "flexDirection", "column");
|
|
996
|
-
_$setProp3(_el$, "flexGrow", 1);
|
|
997
|
-
_$setProp3(_el$, "gap", 1);
|
|
998
|
-
_$insert3(_el$, _$createComponent3(Header, {
|
|
999
|
-
get theme() {
|
|
1000
|
-
return props.theme;
|
|
1001
|
-
},
|
|
1002
|
-
get product() {
|
|
1003
|
-
return props.product;
|
|
1004
|
-
},
|
|
1005
|
-
get detail() {
|
|
1006
|
-
return props.detail;
|
|
1007
|
-
}
|
|
1008
|
-
}), _el$2);
|
|
1009
|
-
_$insertNode3(_el$2, _el$3);
|
|
1010
|
-
_$insertNode3(_el$2, _el$4);
|
|
1011
|
-
_$setProp3(_el$2, "flexDirection", "column");
|
|
1012
|
-
_$setProp3(_el$2, "flexGrow", 1);
|
|
1013
|
-
_$setProp3(_el$2, "maxHeight", 14);
|
|
1014
|
-
_$setProp3(_el$2, "minHeight", 5);
|
|
1015
|
-
_$setProp3(_el$3, "attributes", BOLD);
|
|
1016
|
-
_$setProp3(_el$3, "flexShrink", 0);
|
|
1017
|
-
_$insert3(_el$3, () => c.config()?.prompt ?? "Explain the issue you're experiencing");
|
|
1018
|
-
_$insertNode3(_el$4, _el$5);
|
|
1019
|
-
_$setProp3(_el$4, "border", true);
|
|
1020
|
-
_$setProp3(_el$4, "borderStyle", "single");
|
|
1021
|
-
_$setProp3(_el$4, "flexGrow", 1);
|
|
1022
|
-
_$setProp3(_el$4, "paddingX", 1);
|
|
1023
|
-
_$setProp3(_el$4, "marginTop", 1);
|
|
1024
|
-
_$use((element) => {
|
|
1025
|
-
textarea = element;
|
|
1026
|
-
if (c.issueText())
|
|
1027
|
-
element.setText(c.issueText());
|
|
1028
|
-
}, _el$5);
|
|
1029
|
-
_$setProp3(_el$5, "flexGrow", 1);
|
|
1030
|
-
_$setProp3(_el$5, "wrapMode", "word");
|
|
1031
|
-
_$setProp3(_el$5, "placeholder", "What went wrong, and what did you expect to happen?");
|
|
1032
|
-
_$setProp3(_el$5, "keyBindings", ISSUE_KEYBINDINGS);
|
|
1033
|
-
_$setProp3(_el$5, "onContentChange", () => c.setIssueText(textarea?.plainText ?? ""));
|
|
1034
|
-
_$insertNode3(_el$6, _el$7);
|
|
1035
|
-
_$setProp3(_el$6, "flexDirection", "column");
|
|
1036
|
-
_$setProp3(_el$6, "flexShrink", 0);
|
|
1037
|
-
_$insertNode3(_el$7, _$createTextNode3(`Agent`));
|
|
1038
|
-
_$setProp3(_el$7, "attributes", BOLD);
|
|
1039
|
-
_$insert3(_el$6, _$createComponent3(Switch2, {
|
|
1040
|
-
get children() {
|
|
1041
|
-
return [_$createComponent3(Match2, {
|
|
1042
|
-
get when() {
|
|
1043
|
-
return c.harnesses.length === 0;
|
|
1044
|
-
},
|
|
1045
|
-
get children() {
|
|
1046
|
-
var _el$9 = _$createElement3("text");
|
|
1047
|
-
_$insertNode3(_el$9, _$createTextNode3(`No coding agents are installed. Install Claude Code, Codex, Cursor, Grok, OpenCode, or another ACP agent, then run this again.`));
|
|
1048
|
-
_$effect3((_$p) => _$setProp3(_el$9, "fg", props.theme.danger, _$p));
|
|
1049
|
-
return _el$9;
|
|
1050
|
-
}
|
|
1051
|
-
}), _$createComponent3(Match2, {
|
|
1052
|
-
get when() {
|
|
1053
|
-
return c.harnesses.length > 0;
|
|
1054
|
-
},
|
|
1055
|
-
get children() {
|
|
1056
|
-
var _el$1 = _$createElement3("box");
|
|
1057
|
-
_$setProp3(_el$1, "flexDirection", "column");
|
|
1058
|
-
_$setProp3(_el$1, "marginTop", 1);
|
|
1059
|
-
_$insert3(_el$1, _$createComponent3(For3, {
|
|
1060
|
-
get each() {
|
|
1061
|
-
return visibleRows().rows;
|
|
1062
|
-
},
|
|
1063
|
-
children: (row) => (() => {
|
|
1064
|
-
var _el$17 = _$createElement3("box");
|
|
1065
|
-
_$setProp3(_el$17, "flexDirection", "row");
|
|
1066
|
-
_$setProp3(_el$17, "columnGap", 1);
|
|
1067
|
-
_$insert3(_el$17, _$createComponent3(For3, {
|
|
1068
|
-
each: row,
|
|
1069
|
-
children: (index) => _$createComponent3(BrandLabel, {
|
|
1070
|
-
get name() {
|
|
1071
|
-
return c.harnesses[index].name;
|
|
1072
|
-
},
|
|
1073
|
-
get brand() {
|
|
1074
|
-
return c.harnesses[index].brand;
|
|
1075
|
-
},
|
|
1076
|
-
get selected() {
|
|
1077
|
-
return index === c.harnessIndex();
|
|
1078
|
-
},
|
|
1079
|
-
get theme() {
|
|
1080
|
-
return props.theme;
|
|
1081
|
-
}
|
|
1082
|
-
})
|
|
1083
|
-
}));
|
|
1084
|
-
return _el$17;
|
|
1085
|
-
})()
|
|
1086
|
-
}), null);
|
|
1087
|
-
_$insert3(_el$1, _$createComponent3(Show3, {
|
|
1088
|
-
get when() {
|
|
1089
|
-
return visibleRows().hidden > 0;
|
|
1090
|
-
},
|
|
1091
|
-
get children() {
|
|
1092
|
-
var _el$10 = _$createElement3("text"), _el$11 = _$createTextNode3(`more agents`);
|
|
1093
|
-
_$insertNode3(_el$10, _el$11);
|
|
1094
|
-
_$insert3(_el$10, () => visibleRows().first > 0 ? "\u2191 " : "", _el$11);
|
|
1095
|
-
_$insert3(_el$10, () => visibleRows().first + MAX_ROWS < rows().length ? "\u2193 " : "", _el$11);
|
|
1096
|
-
_$effect3((_$p) => _$setProp3(_el$10, "fg", props.theme.faint, _$p));
|
|
1097
|
-
return _el$10;
|
|
1098
|
-
}
|
|
1099
|
-
}), null);
|
|
1100
|
-
return _el$1;
|
|
1101
|
-
}
|
|
1102
|
-
})];
|
|
1103
|
-
}
|
|
1104
|
-
}), null);
|
|
1105
|
-
_$insert3(_el$, _$createComponent3(Show3, {
|
|
1106
|
-
get when() {
|
|
1107
|
-
return c.harnesses.length > 0;
|
|
1108
|
-
},
|
|
1109
|
-
get children() {
|
|
1110
|
-
var _el$12 = _$createElement3("box"), _el$13 = _$createElement3("text"), _el$15 = _$createElement3("box");
|
|
1111
|
-
_$insertNode3(_el$12, _el$13);
|
|
1112
|
-
_$insertNode3(_el$12, _el$15);
|
|
1113
|
-
_$setProp3(_el$12, "flexDirection", "column");
|
|
1114
|
-
_$setProp3(_el$12, "flexShrink", 0);
|
|
1115
|
-
_$insertNode3(_el$13, _$createTextNode3(`Model`));
|
|
1116
|
-
_$setProp3(_el$13, "attributes", BOLD);
|
|
1117
|
-
_$setProp3(_el$15, "marginTop", 1);
|
|
1118
|
-
_$insert3(_el$15, _$createComponent3(ButtonRow, {
|
|
1119
|
-
get theme() {
|
|
1120
|
-
return props.theme;
|
|
1121
|
-
},
|
|
1122
|
-
get focused() {
|
|
1123
|
-
return _$memo2(() => zone() === "model")() && !c.modal();
|
|
1124
|
-
},
|
|
1125
|
-
get index() {
|
|
1126
|
-
return modelIndex();
|
|
1127
|
-
},
|
|
1128
|
-
get items() {
|
|
1129
|
-
return [{
|
|
1130
|
-
label: "Use default model",
|
|
1131
|
-
prefix: {
|
|
1132
|
-
text: "\u2713",
|
|
1133
|
-
color: props.theme.check
|
|
1134
|
-
}
|
|
1135
|
-
}, {
|
|
1136
|
-
label: "Select model"
|
|
1137
|
-
}];
|
|
1138
|
-
}
|
|
1139
|
-
}));
|
|
1140
|
-
_$insert3(_el$12, _$createComponent3(Show3, {
|
|
1141
|
-
get when() {
|
|
1142
|
-
return sessionLine();
|
|
1143
|
-
},
|
|
1144
|
-
children: (line) => (() => {
|
|
1145
|
-
var _el$18 = _$createElement3("text");
|
|
1146
|
-
_$setProp3(_el$18, "marginTop", 1);
|
|
1147
|
-
_$insert3(_el$18, () => line().text);
|
|
1148
|
-
_$effect3((_$p) => _$setProp3(_el$18, "fg", line().color, _$p));
|
|
1149
|
-
return _el$18;
|
|
1150
|
-
})()
|
|
1151
|
-
}), null);
|
|
1152
|
-
_$effect3((_$p) => _$setProp3(_el$13, "fg", zone() === "model" ? props.theme.text : props.theme.muted, _$p));
|
|
1153
|
-
return _el$12;
|
|
1154
|
-
}
|
|
1155
|
-
}), _el$16);
|
|
1156
|
-
_$setProp3(_el$16, "flexGrow", 1);
|
|
1157
|
-
_$setProp3(_el$16, "flexDirection", "column");
|
|
1158
|
-
_$setProp3(_el$16, "justifyContent", "flex-end");
|
|
1159
|
-
_$insert3(_el$16, _$createComponent3(Hints, {
|
|
1160
|
-
get theme() {
|
|
1161
|
-
return props.theme;
|
|
1162
|
-
},
|
|
1163
|
-
get hints() {
|
|
1164
|
-
return hints();
|
|
1165
|
-
}
|
|
1166
|
-
}));
|
|
1167
|
-
_$effect3((_p$) => {
|
|
1168
|
-
var _v$ = props.theme.text, _v$2 = zone() === "input" ? props.theme.border : props.theme.faint, _v$3 = zone() === "input" && !c.modal(), _v$4 = props.theme.faint, _v$5 = props.theme.text, _v$6 = props.theme.text, _v$7 = props.theme.background, _v$8 = props.theme.background, _v$9 = props.theme.text, _v$0 = zone() === "agents" ? props.theme.text : props.theme.muted;
|
|
1169
|
-
_v$ !== _p$.e && (_p$.e = _$setProp3(_el$3, "fg", _v$, _p$.e));
|
|
1170
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp3(_el$4, "borderColor", _v$2, _p$.t));
|
|
1171
|
-
_v$3 !== _p$.a && (_p$.a = _$setProp3(_el$5, "focused", _v$3, _p$.a));
|
|
1172
|
-
_v$4 !== _p$.o && (_p$.o = _$setProp3(_el$5, "placeholderColor", _v$4, _p$.o));
|
|
1173
|
-
_v$5 !== _p$.i && (_p$.i = _$setProp3(_el$5, "textColor", _v$5, _p$.i));
|
|
1174
|
-
_v$6 !== _p$.n && (_p$.n = _$setProp3(_el$5, "focusedTextColor", _v$6, _p$.n));
|
|
1175
|
-
_v$7 !== _p$.s && (_p$.s = _$setProp3(_el$5, "backgroundColor", _v$7, _p$.s));
|
|
1176
|
-
_v$8 !== _p$.h && (_p$.h = _$setProp3(_el$5, "focusedBackgroundColor", _v$8, _p$.h));
|
|
1177
|
-
_v$9 !== _p$.r && (_p$.r = _$setProp3(_el$5, "cursorColor", _v$9, _p$.r));
|
|
1178
|
-
_v$0 !== _p$.d && (_p$.d = _$setProp3(_el$7, "fg", _v$0, _p$.d));
|
|
1179
|
-
return _p$;
|
|
1180
|
-
}, {
|
|
1181
|
-
e: undefined,
|
|
1182
|
-
t: undefined,
|
|
1183
|
-
a: undefined,
|
|
1184
|
-
o: undefined,
|
|
1185
|
-
i: undefined,
|
|
1186
|
-
n: undefined,
|
|
1187
|
-
s: undefined,
|
|
1188
|
-
h: undefined,
|
|
1189
|
-
r: undefined,
|
|
1190
|
-
d: undefined
|
|
1191
|
-
});
|
|
1192
|
-
return _el$;
|
|
1193
|
-
})();
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
// src/tui/screens/result.tsx
|
|
1197
|
-
import { memo as _$memo3 } from "@opentui/solid";
|
|
1198
|
-
import { effect as _$effect4 } from "@opentui/solid";
|
|
1199
|
-
import { insert as _$insert4 } from "@opentui/solid";
|
|
1200
|
-
import { use as _$use2 } from "@opentui/solid";
|
|
1201
|
-
import { createTextNode as _$createTextNode4 } from "@opentui/solid";
|
|
1202
|
-
import { insertNode as _$insertNode4 } from "@opentui/solid";
|
|
1203
|
-
import { createComponent as _$createComponent4 } from "@opentui/solid";
|
|
1204
|
-
import { setProp as _$setProp4 } from "@opentui/solid";
|
|
1205
|
-
import { createElement as _$createElement4 } from "@opentui/solid";
|
|
1206
|
-
import { SyntaxStyle } from "@opentui/core";
|
|
1207
|
-
import { useKeyboard as useKeyboard3, useRenderer } from "@opentui/solid";
|
|
1208
|
-
import { createMemo as createMemo3, createSignal as createSignal3, onCleanup, Show as Show4 } from "solid-js";
|
|
1209
|
-
function markdownStyle(theme, owner) {
|
|
1210
|
-
const text = {
|
|
1211
|
-
fg: theme.text
|
|
1212
|
-
};
|
|
1213
|
-
return SyntaxStyle.fromStyles({
|
|
1214
|
-
default: text,
|
|
1215
|
-
conceal: {
|
|
1216
|
-
fg: theme.faint
|
|
1217
|
-
},
|
|
1218
|
-
"markup.heading": {
|
|
1219
|
-
fg: theme.text,
|
|
1220
|
-
bold: true
|
|
1221
|
-
},
|
|
1222
|
-
"markup.heading.1": {
|
|
1223
|
-
fg: theme.text,
|
|
1224
|
-
bold: true
|
|
1225
|
-
},
|
|
1226
|
-
"markup.heading.2": {
|
|
1227
|
-
fg: theme.text,
|
|
1228
|
-
bold: true
|
|
1229
|
-
},
|
|
1230
|
-
"markup.heading.3": {
|
|
1231
|
-
fg: theme.text,
|
|
1232
|
-
bold: true
|
|
1233
|
-
},
|
|
1234
|
-
"markup.strong": {
|
|
1235
|
-
fg: theme.text,
|
|
1236
|
-
bold: true
|
|
1237
|
-
},
|
|
1238
|
-
"markup.italic": {
|
|
1239
|
-
fg: theme.text,
|
|
1240
|
-
italic: true
|
|
1241
|
-
},
|
|
1242
|
-
"markup.strikethrough": {
|
|
1243
|
-
fg: theme.muted,
|
|
1244
|
-
dim: true
|
|
1245
|
-
},
|
|
1246
|
-
"markup.raw": {
|
|
1247
|
-
fg: theme.product === theme.text ? theme.muted : theme.product
|
|
1248
|
-
},
|
|
1249
|
-
"markup.raw.block": {
|
|
1250
|
-
fg: theme.muted
|
|
1251
|
-
},
|
|
1252
|
-
"markup.link": {
|
|
1253
|
-
fg: theme.muted,
|
|
1254
|
-
underline: true
|
|
1255
|
-
},
|
|
1256
|
-
"markup.link.url": {
|
|
1257
|
-
fg: theme.muted,
|
|
1258
|
-
underline: true
|
|
1259
|
-
},
|
|
1260
|
-
"markup.link.label": {
|
|
1261
|
-
fg: theme.text,
|
|
1262
|
-
underline: true
|
|
1263
|
-
},
|
|
1264
|
-
"markup.list": {
|
|
1265
|
-
fg: theme.muted
|
|
1266
|
-
},
|
|
1267
|
-
"markup.quote": {
|
|
1268
|
-
fg: theme.muted,
|
|
1269
|
-
italic: true
|
|
1270
|
-
},
|
|
1271
|
-
"punctuation.special": {
|
|
1272
|
-
fg: theme.faint
|
|
1273
|
-
}
|
|
1274
|
-
}, owner);
|
|
1275
|
-
}
|
|
1276
|
-
function ResultScreen(props) {
|
|
1277
|
-
const c = props.controller;
|
|
1278
|
-
const renderer = useRenderer();
|
|
1279
|
-
const style = markdownStyle(props.theme, renderer.nativeScene);
|
|
1280
|
-
onCleanup(() => style.destroy?.());
|
|
1281
|
-
const [index, setIndex] = createSignal3(0);
|
|
1282
|
-
let scroll;
|
|
1283
|
-
const actions = createMemo3(() => {
|
|
1284
|
-
const list = [];
|
|
1285
|
-
if (c.githubRepo())
|
|
1286
|
-
list.push({
|
|
1287
|
-
label: "File an issue on GitHub",
|
|
1288
|
-
run: () => void c.beginGitHub()
|
|
1289
|
-
});
|
|
1290
|
-
list.push({
|
|
1291
|
-
label: "Copy issue",
|
|
1292
|
-
run: () => void c.copy()
|
|
1293
|
-
});
|
|
1294
|
-
for (const link of c.config()?.links ?? [])
|
|
1295
|
-
list.push({
|
|
1296
|
-
label: link.label,
|
|
1297
|
-
run: () => c.chooseLink(link)
|
|
1298
|
-
});
|
|
1299
|
-
list.push({
|
|
1300
|
-
label: "Quit",
|
|
1301
|
-
run: props.onQuit
|
|
1302
|
-
});
|
|
1303
|
-
return list;
|
|
1304
|
-
});
|
|
1305
|
-
useKeyboard3((key) => {
|
|
1306
|
-
if (c.modal() || c.screen() !== "result" || c.busy())
|
|
1307
|
-
return;
|
|
1308
|
-
if (key.name === "left")
|
|
1309
|
-
setIndex((value) => Math.max(value - 1, 0));
|
|
1310
|
-
else if (key.name === "right" || key.name === "tab")
|
|
1311
|
-
setIndex((value) => Math.min(value + 1, actions().length - 1));
|
|
1312
|
-
else if (key.name === "up")
|
|
1313
|
-
scroll?.scrollBy(-1);
|
|
1314
|
-
else if (key.name === "down")
|
|
1315
|
-
scroll?.scrollBy(1);
|
|
1316
|
-
else if (key.name === "pageup")
|
|
1317
|
-
scroll?.scrollBy(-(scroll.height - 2));
|
|
1318
|
-
else if (key.name === "pagedown" || key.name === "space")
|
|
1319
|
-
scroll?.scrollBy(scroll.height - 2);
|
|
1320
|
-
else if (key.name === "return")
|
|
1321
|
-
actions()[index()]?.run();
|
|
1322
|
-
});
|
|
1323
|
-
return (() => {
|
|
1324
|
-
var _el$ = _$createElement4("box"), _el$2 = _$createElement4("text"), _el$4 = _$createElement4("box"), _el$5 = _$createElement4("scrollbox"), _el$6 = _$createElement4("text"), _el$7 = _$createElement4("markdown");
|
|
1325
|
-
_$insertNode4(_el$, _el$2);
|
|
1326
|
-
_$insertNode4(_el$, _el$4);
|
|
1327
|
-
_$setProp4(_el$, "flexDirection", "column");
|
|
1328
|
-
_$setProp4(_el$, "flexGrow", 1);
|
|
1329
|
-
_$setProp4(_el$, "gap", 1);
|
|
1330
|
-
_$insert4(_el$, _$createComponent4(Header, {
|
|
1331
|
-
get theme() {
|
|
1332
|
-
return props.theme;
|
|
1333
|
-
},
|
|
1334
|
-
get product() {
|
|
1335
|
-
return props.product;
|
|
1336
|
-
},
|
|
1337
|
-
get detail() {
|
|
1338
|
-
return props.detail;
|
|
1339
|
-
}
|
|
1340
|
-
}), _el$2);
|
|
1341
|
-
_$insertNode4(_el$2, _$createTextNode4(`\u2713 Issue ready`));
|
|
1342
|
-
_$setProp4(_el$2, "attributes", BOLD);
|
|
1343
|
-
_$insertNode4(_el$4, _el$5);
|
|
1344
|
-
_$setProp4(_el$4, "border", true);
|
|
1345
|
-
_$setProp4(_el$4, "borderStyle", "single");
|
|
1346
|
-
_$setProp4(_el$4, "flexGrow", 1);
|
|
1347
|
-
_$setProp4(_el$4, "paddingX", 2);
|
|
1348
|
-
_$setProp4(_el$4, "paddingY", 1);
|
|
1349
|
-
_$insertNode4(_el$5, _el$6);
|
|
1350
|
-
_$insertNode4(_el$5, _el$7);
|
|
1351
|
-
_$use2((element) => scroll = element, _el$5);
|
|
1352
|
-
_$setProp4(_el$5, "flexGrow", 1);
|
|
1353
|
-
_$setProp4(_el$5, "scrollY", true);
|
|
1354
|
-
_$setProp4(_el$5, "stickyScroll", false);
|
|
1355
|
-
_$setProp4(_el$5, "verticalScrollbarOptions", {
|
|
1356
|
-
visible: false
|
|
1357
|
-
});
|
|
1358
|
-
_$setProp4(_el$6, "attributes", BOLD);
|
|
1359
|
-
_$setProp4(_el$6, "marginBottom", 1);
|
|
1360
|
-
_$insert4(_el$6, () => c.issue()?.title);
|
|
1361
|
-
_$setProp4(_el$7, "syntaxStyle", style);
|
|
1362
|
-
_$setProp4(_el$7, "conceal", true);
|
|
1363
|
-
_$insert4(_el$, _$createComponent4(ButtonRow, {
|
|
1364
|
-
get theme() {
|
|
1365
|
-
return props.theme;
|
|
1366
|
-
},
|
|
1367
|
-
get focused() {
|
|
1368
|
-
return !c.modal();
|
|
1369
|
-
},
|
|
1370
|
-
get index() {
|
|
1371
|
-
return index();
|
|
1372
|
-
},
|
|
1373
|
-
get items() {
|
|
1374
|
-
return actions().map((action) => ({
|
|
1375
|
-
label: action.label
|
|
1376
|
-
}));
|
|
1377
|
-
}
|
|
1378
|
-
}), null);
|
|
1379
|
-
_$insert4(_el$, _$createComponent4(Show4, {
|
|
1380
|
-
get when() {
|
|
1381
|
-
return c.busy();
|
|
1382
|
-
},
|
|
1383
|
-
get fallback() {
|
|
1384
|
-
return _$createComponent4(Hints, {
|
|
1385
|
-
get theme() {
|
|
1386
|
-
return props.theme;
|
|
1387
|
-
},
|
|
1388
|
-
hints: [["\u2190\u2192", "choose"], ["enter", "select"], ["\u2191\u2193", "scroll"], ["ctrl+c", "quit"]]
|
|
1389
|
-
});
|
|
1390
|
-
},
|
|
1391
|
-
children: (busy) => (() => {
|
|
1392
|
-
var _el$8 = _$createElement4("text");
|
|
1393
|
-
_$insert4(_el$8, busy);
|
|
1394
|
-
_$effect4((_$p) => _$setProp4(_el$8, "fg", props.theme.muted, _$p));
|
|
1395
|
-
return _el$8;
|
|
1396
|
-
})()
|
|
1397
|
-
}), null);
|
|
1398
|
-
_$effect4((_p$) => {
|
|
1399
|
-
var _v$ = props.theme.success, _v$2 = props.theme.faint, _v$3 = props.theme.text, _v$4 = c.issue()?.body ?? "", _v$5 = props.theme.text;
|
|
1400
|
-
_v$ !== _p$.e && (_p$.e = _$setProp4(_el$2, "fg", _v$, _p$.e));
|
|
1401
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp4(_el$4, "borderColor", _v$2, _p$.t));
|
|
1402
|
-
_v$3 !== _p$.a && (_p$.a = _$setProp4(_el$6, "fg", _v$3, _p$.a));
|
|
1403
|
-
_v$4 !== _p$.o && (_p$.o = _$setProp4(_el$7, "content", _v$4, _p$.o));
|
|
1404
|
-
_v$5 !== _p$.i && (_p$.i = _$setProp4(_el$7, "fg", _v$5, _p$.i));
|
|
1405
|
-
return _p$;
|
|
1406
|
-
}, {
|
|
1407
|
-
e: undefined,
|
|
1408
|
-
t: undefined,
|
|
1409
|
-
a: undefined,
|
|
1410
|
-
o: undefined,
|
|
1411
|
-
i: undefined
|
|
1412
|
-
});
|
|
1413
|
-
return _el$;
|
|
1414
|
-
})();
|
|
1415
|
-
}
|
|
1416
|
-
function ErrorScreen(props) {
|
|
1417
|
-
const c = props.controller;
|
|
1418
|
-
const [index, setIndex] = createSignal3(0);
|
|
1419
|
-
const actions = [{
|
|
1420
|
-
label: "Try again",
|
|
1421
|
-
run: () => c.tryAgain()
|
|
1422
|
-
}, {
|
|
1423
|
-
label: "Quit",
|
|
1424
|
-
run: props.onQuit
|
|
1425
|
-
}];
|
|
1426
|
-
useKeyboard3((key) => {
|
|
1427
|
-
if (c.modal() || c.screen() !== "error")
|
|
1428
|
-
return;
|
|
1429
|
-
if (key.name === "left")
|
|
1430
|
-
setIndex(0);
|
|
1431
|
-
else if (key.name === "right" || key.name === "tab")
|
|
1432
|
-
setIndex(1);
|
|
1433
|
-
else if (key.name === "return")
|
|
1434
|
-
actions[index()].run();
|
|
1435
|
-
});
|
|
1436
|
-
return (() => {
|
|
1437
|
-
var _el$9 = _$createElement4("box"), _el$0 = _$createElement4("box"), _el$1 = _$createElement4("text"), _el$10 = _$createTextNode4(`\u26A0 `), _el$11 = _$createElement4("text");
|
|
1438
|
-
_$insertNode4(_el$9, _el$0);
|
|
1439
|
-
_$setProp4(_el$9, "flexDirection", "column");
|
|
1440
|
-
_$setProp4(_el$9, "flexGrow", 1);
|
|
1441
|
-
_$setProp4(_el$9, "gap", 1);
|
|
1442
|
-
_$insert4(_el$9, _$createComponent4(Header, {
|
|
1443
|
-
get theme() {
|
|
1444
|
-
return props.theme;
|
|
1445
|
-
},
|
|
1446
|
-
get product() {
|
|
1447
|
-
return props.product;
|
|
1448
|
-
},
|
|
1449
|
-
get detail() {
|
|
1450
|
-
return props.detail;
|
|
1451
|
-
}
|
|
1452
|
-
}), _el$0);
|
|
1453
|
-
_$insertNode4(_el$0, _el$1);
|
|
1454
|
-
_$insertNode4(_el$0, _el$11);
|
|
1455
|
-
_$setProp4(_el$0, "flexDirection", "column");
|
|
1456
|
-
_$setProp4(_el$0, "flexGrow", 1);
|
|
1457
|
-
_$setProp4(_el$0, "gap", 1);
|
|
1458
|
-
_$insertNode4(_el$1, _el$10);
|
|
1459
|
-
_$setProp4(_el$1, "attributes", BOLD);
|
|
1460
|
-
_$insert4(_el$1, () => c.error()?.title ?? "Error", null);
|
|
1461
|
-
_$insert4(_el$11, () => c.error()?.message);
|
|
1462
|
-
_$insert4(_el$9, _$createComponent4(ButtonRow, {
|
|
1463
|
-
get theme() {
|
|
1464
|
-
return props.theme;
|
|
1465
|
-
},
|
|
1466
|
-
focused: true,
|
|
1467
|
-
get index() {
|
|
1468
|
-
return index();
|
|
1469
|
-
},
|
|
1470
|
-
get items() {
|
|
1471
|
-
return actions.map((action) => ({
|
|
1472
|
-
label: action.label
|
|
1473
|
-
}));
|
|
1474
|
-
}
|
|
1475
|
-
}), null);
|
|
1476
|
-
_$insert4(_el$9, _$createComponent4(Hints, {
|
|
1477
|
-
get theme() {
|
|
1478
|
-
return props.theme;
|
|
1479
|
-
},
|
|
1480
|
-
hints: [["\u2190\u2192", "choose"], ["enter", "select"], ["ctrl+c", "quit"]]
|
|
1481
|
-
}), null);
|
|
1482
|
-
_$effect4((_p$) => {
|
|
1483
|
-
var _v$6 = props.theme.danger, _v$7 = props.theme.text;
|
|
1484
|
-
_v$6 !== _p$.e && (_p$.e = _$setProp4(_el$1, "fg", _v$6, _p$.e));
|
|
1485
|
-
_v$7 !== _p$.t && (_p$.t = _$setProp4(_el$11, "fg", _v$7, _p$.t));
|
|
1486
|
-
return _p$;
|
|
1487
|
-
}, {
|
|
1488
|
-
e: undefined,
|
|
1489
|
-
t: undefined
|
|
1490
|
-
});
|
|
1491
|
-
return _el$9;
|
|
1492
|
-
})();
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
// src/tui/screens/running.tsx
|
|
1496
|
-
import { memo as _$memo4 } from "@opentui/solid";
|
|
1497
|
-
import { effect as _$effect5 } from "@opentui/solid";
|
|
1498
|
-
import { insertNode as _$insertNode5 } from "@opentui/solid";
|
|
1499
|
-
import { insert as _$insert5 } from "@opentui/solid";
|
|
1500
|
-
import { use as _$use3 } from "@opentui/solid";
|
|
1501
|
-
import { createComponent as _$createComponent5 } from "@opentui/solid";
|
|
1502
|
-
import { setProp as _$setProp5 } from "@opentui/solid";
|
|
1503
|
-
import { createElement as _$createElement5 } from "@opentui/solid";
|
|
1504
|
-
import { useKeyboard as useKeyboard4 } from "@opentui/solid";
|
|
1505
|
-
import { createMemo as createMemo4, createSignal as createSignal4, For as For4, onCleanup as onCleanup2 } from "solid-js";
|
|
1506
|
-
|
|
1507
|
-
// src/tui/wrap.ts
|
|
1508
|
-
import stringWidth from "string-width";
|
|
1509
|
-
function wrap(text, width) {
|
|
1510
|
-
const out = [];
|
|
1511
|
-
const limit = Math.max(width, 1);
|
|
1512
|
-
for (const paragraph of text.split(`
|
|
1513
|
-
`)) {
|
|
1514
|
-
if (paragraph === "") {
|
|
1515
|
-
out.push("");
|
|
1516
|
-
continue;
|
|
1517
|
-
}
|
|
1518
|
-
let line = "";
|
|
1519
|
-
let lineWidth = 0;
|
|
1520
|
-
for (const word of paragraph.split(/(\s+)/)) {
|
|
1521
|
-
if (word === "")
|
|
1522
|
-
continue;
|
|
1523
|
-
const wordWidth = stringWidth(word);
|
|
1524
|
-
if (lineWidth + wordWidth <= limit) {
|
|
1525
|
-
line += word;
|
|
1526
|
-
lineWidth += wordWidth;
|
|
1527
|
-
continue;
|
|
1528
|
-
}
|
|
1529
|
-
if (/^\s+$/.test(word)) {
|
|
1530
|
-
out.push(line);
|
|
1531
|
-
line = "";
|
|
1532
|
-
lineWidth = 0;
|
|
1533
|
-
continue;
|
|
1534
|
-
}
|
|
1535
|
-
if (line.trim())
|
|
1536
|
-
out.push(line.trimEnd());
|
|
1537
|
-
line = "";
|
|
1538
|
-
lineWidth = 0;
|
|
1539
|
-
let rest = word;
|
|
1540
|
-
while (stringWidth(rest) > limit) {
|
|
1541
|
-
let cut = "";
|
|
1542
|
-
for (const char of rest) {
|
|
1543
|
-
if (stringWidth(cut + char) > limit)
|
|
1544
|
-
break;
|
|
1545
|
-
cut += char;
|
|
1546
|
-
}
|
|
1547
|
-
out.push(cut);
|
|
1548
|
-
rest = rest.slice(cut.length);
|
|
1549
|
-
}
|
|
1550
|
-
line = rest;
|
|
1551
|
-
lineWidth = stringWidth(rest);
|
|
1552
|
-
}
|
|
1553
|
-
out.push(line.trimEnd());
|
|
1554
|
-
}
|
|
1555
|
-
return out;
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
// src/tui/screens/running.tsx
|
|
1559
|
-
var ISSUE_MARKER = /<trissue-(issue|rejected)>[\s\S]*$/;
|
|
1560
|
-
var BRIGHT_SHARE = 0.35;
|
|
1561
|
-
var TOP_BRIGHTNESS = 0.18;
|
|
1562
|
-
function entryLines(entry, width, theme) {
|
|
1563
|
-
switch (entry.kind) {
|
|
1564
|
-
case "thought":
|
|
1565
|
-
return wrap(entry.text.trim(), width - 2).map((line) => [{
|
|
1566
|
-
text: ` ${line}`,
|
|
1567
|
-
color: theme.muted,
|
|
1568
|
-
attributes: ITALIC
|
|
1569
|
-
}]);
|
|
1570
|
-
case "message": {
|
|
1571
|
-
const visible = entry.text.replace(ISSUE_MARKER, "").trim();
|
|
1572
|
-
const lines = visible ? wrap(visible, width).map((line) => [{
|
|
1573
|
-
text: line,
|
|
1574
|
-
color: theme.text
|
|
1575
|
-
}]) : [];
|
|
1576
|
-
if (ISSUE_MARKER.test(entry.text))
|
|
1577
|
-
lines.push([{
|
|
1578
|
-
text: "Writing the issue\u2026",
|
|
1579
|
-
color: theme.text,
|
|
1580
|
-
attributes: BOLD
|
|
1581
|
-
}]);
|
|
1582
|
-
return lines;
|
|
1583
|
-
}
|
|
1584
|
-
case "tool": {
|
|
1585
|
-
const glyph = entry.status === "completed" ? "\u2713" : entry.status === "failed" ? "\u2717" : "\u203A";
|
|
1586
|
-
const glyphColor = entry.status === "completed" ? theme.success : entry.status === "failed" ? theme.danger : theme.muted;
|
|
1587
|
-
return wrap(entry.text, width - 2).map((line, index) => [{
|
|
1588
|
-
text: index === 0 ? `${glyph} ` : " ",
|
|
1589
|
-
color: glyphColor
|
|
1590
|
-
}, {
|
|
1591
|
-
text: line,
|
|
1592
|
-
color: theme.muted
|
|
1593
|
-
}]);
|
|
1594
|
-
}
|
|
1595
|
-
case "blocked":
|
|
1596
|
-
return wrap(entry.text, width - 10).map((line, index) => [{
|
|
1597
|
-
text: index === 0 ? "\u2298 Blocked " : " ",
|
|
1598
|
-
color: theme.danger,
|
|
1599
|
-
attributes: BOLD
|
|
1600
|
-
}, {
|
|
1601
|
-
text: line,
|
|
1602
|
-
color: theme.muted
|
|
1603
|
-
}]);
|
|
1604
|
-
case "steer":
|
|
1605
|
-
return wrap(entry.text, width - 6).map((line, index) => [{
|
|
1606
|
-
text: index === 0 ? "You \u203A " : " ",
|
|
1607
|
-
color: theme.product,
|
|
1608
|
-
attributes: BOLD
|
|
1609
|
-
}, {
|
|
1610
|
-
text: line,
|
|
1611
|
-
color: theme.text
|
|
1612
|
-
}]);
|
|
1613
|
-
case "notice":
|
|
1614
|
-
return wrap(entry.text, width).map((line) => [{
|
|
1615
|
-
text: line,
|
|
1616
|
-
color: theme.muted
|
|
1617
|
-
}]);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
function transcriptLines(entries, width, theme) {
|
|
1621
|
-
const lines = [];
|
|
1622
|
-
let previous;
|
|
1623
|
-
for (const entry of entries) {
|
|
1624
|
-
const next = entryLines(entry, width, theme);
|
|
1625
|
-
if (!next.length)
|
|
1626
|
-
continue;
|
|
1627
|
-
const together = previous && (previous.kind === "tool" || previous.kind === "blocked") && (entry.kind === "tool" || entry.kind === "blocked");
|
|
1628
|
-
if (previous && !together)
|
|
1629
|
-
lines.push([]);
|
|
1630
|
-
lines.push(...next);
|
|
1631
|
-
previous = entry;
|
|
1632
|
-
}
|
|
1633
|
-
return lines;
|
|
1634
|
-
}
|
|
1635
|
-
function formatElapsed(ms) {
|
|
1636
|
-
const seconds = Math.floor(ms / 1000);
|
|
1637
|
-
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
|
|
1638
|
-
}
|
|
1639
|
-
function RunningScreen(props) {
|
|
1640
|
-
const c = props.controller;
|
|
1641
|
-
const [size, setSize] = createSignal4({
|
|
1642
|
-
width: 80,
|
|
1643
|
-
height: 10
|
|
1644
|
-
});
|
|
1645
|
-
const [frame, setFrame] = createSignal4(0);
|
|
1646
|
-
const [now, setNow] = createSignal4(Date.now());
|
|
1647
|
-
let steerBox;
|
|
1648
|
-
const timer = setInterval(() => {
|
|
1649
|
-
setFrame((value) => value + 1);
|
|
1650
|
-
setNow(Date.now());
|
|
1651
|
-
}, 80);
|
|
1652
|
-
onCleanup2(() => clearInterval(timer));
|
|
1653
|
-
useKeyboard4((key) => {
|
|
1654
|
-
if (c.screen() !== "running")
|
|
1655
|
-
return;
|
|
1656
|
-
if (key.name === "escape") {
|
|
1657
|
-
key.preventDefault();
|
|
1658
|
-
c.stop();
|
|
1659
|
-
}
|
|
1660
|
-
});
|
|
1661
|
-
const visible = createMemo4(() => {
|
|
1662
|
-
const {
|
|
1663
|
-
width,
|
|
1664
|
-
height
|
|
1665
|
-
} = size();
|
|
1666
|
-
const lines = transcriptLines(c.entries(), width, props.theme).slice(-height);
|
|
1667
|
-
const bright = Math.ceil(height * BRIGHT_SHARE);
|
|
1668
|
-
return lines.map((line, index) => {
|
|
1669
|
-
const fromBottom = lines.length - 1 - index;
|
|
1670
|
-
const fade = fromBottom < bright ? 1 : Math.max(TOP_BRIGHTNESS, 1 - (fromBottom - bright) / Math.max(height - bright, 1) * (1 - TOP_BRIGHTNESS));
|
|
1671
|
-
return line.map((segment) => ({
|
|
1672
|
-
...segment,
|
|
1673
|
-
color: mix(props.theme.background, segment.color, fade)
|
|
1674
|
-
}));
|
|
1675
|
-
});
|
|
1676
|
-
});
|
|
1677
|
-
const status = () => {
|
|
1678
|
-
const state = c.sessionState();
|
|
1679
|
-
const name = state.status === "ready" ? state.session.harness.name : c.harness()?.name ?? "The agent";
|
|
1680
|
-
const model = state.status === "ready" ? state.session.currentModel?.name : undefined;
|
|
1681
|
-
return `${name}${model ? ` \xB7 ${model}` : ""} is investigating \xB7 ${formatElapsed(now() - c.startedAt())}`;
|
|
1682
|
-
};
|
|
1683
|
-
return (() => {
|
|
1684
|
-
var _el$ = _$createElement5("box"), _el$2 = _$createElement5("box"), _el$3 = _$createElement5("box"), _el$4 = _$createElement5("box"), _el$5 = _$createElement5("textarea");
|
|
1685
|
-
_$insertNode5(_el$, _el$2);
|
|
1686
|
-
_$insertNode5(_el$, _el$3);
|
|
1687
|
-
_$setProp5(_el$, "flexDirection", "column");
|
|
1688
|
-
_$setProp5(_el$, "flexGrow", 1);
|
|
1689
|
-
_$setProp5(_el$, "gap", 1);
|
|
1690
|
-
_$insert5(_el$, _$createComponent5(Header, {
|
|
1691
|
-
get theme() {
|
|
1692
|
-
return props.theme;
|
|
1693
|
-
},
|
|
1694
|
-
get product() {
|
|
1695
|
-
return props.product;
|
|
1696
|
-
},
|
|
1697
|
-
get detail() {
|
|
1698
|
-
return props.detail;
|
|
1699
|
-
}
|
|
1700
|
-
}), _el$2);
|
|
1701
|
-
_$use3((element) => {
|
|
1702
|
-
const measure = () => setSize({
|
|
1703
|
-
width: Math.max(element.width, 10),
|
|
1704
|
-
height: Math.max(element.height, 1)
|
|
1705
|
-
});
|
|
1706
|
-
element.onSizeChange = measure;
|
|
1707
|
-
queueMicrotask(measure);
|
|
1708
|
-
}, _el$2);
|
|
1709
|
-
_$setProp5(_el$2, "flexGrow", 1);
|
|
1710
|
-
_$setProp5(_el$2, "flexDirection", "column");
|
|
1711
|
-
_$setProp5(_el$2, "justifyContent", "flex-end");
|
|
1712
|
-
_$setProp5(_el$2, "overflow", "hidden");
|
|
1713
|
-
_$insert5(_el$2, _$createComponent5(For4, {
|
|
1714
|
-
get each() {
|
|
1715
|
-
return visible();
|
|
1716
|
-
},
|
|
1717
|
-
children: (line) => (() => {
|
|
1718
|
-
var _el$6 = _$createElement5("text");
|
|
1719
|
-
_$setProp5(_el$6, "height", 1);
|
|
1720
|
-
_$setProp5(_el$6, "flexShrink", 0);
|
|
1721
|
-
_$insert5(_el$6, () => line.length === 0 ? " " : "", null);
|
|
1722
|
-
_$insert5(_el$6, _$createComponent5(For4, {
|
|
1723
|
-
each: line,
|
|
1724
|
-
children: (segment) => (() => {
|
|
1725
|
-
var _el$7 = _$createElement5("span");
|
|
1726
|
-
_$insert5(_el$7, () => segment.text);
|
|
1727
|
-
_$effect5((_$p) => _$setProp5(_el$7, "style", {
|
|
1728
|
-
fg: segment.color,
|
|
1729
|
-
bold: Boolean((segment.attributes ?? 0) & BOLD),
|
|
1730
|
-
italic: Boolean((segment.attributes ?? 0) & ITALIC)
|
|
1731
|
-
}, _$p));
|
|
1732
|
-
return _el$7;
|
|
1733
|
-
})()
|
|
1734
|
-
}), null);
|
|
1735
|
-
return _el$6;
|
|
1736
|
-
})()
|
|
1737
|
-
}));
|
|
1738
|
-
_$insertNode5(_el$3, _el$4);
|
|
1739
|
-
_$setProp5(_el$3, "flexDirection", "column");
|
|
1740
|
-
_$setProp5(_el$3, "flexShrink", 0);
|
|
1741
|
-
_$insert5(_el$3, _$createComponent5(Spinner, {
|
|
1742
|
-
get theme() {
|
|
1743
|
-
return props.theme;
|
|
1744
|
-
},
|
|
1745
|
-
get frame() {
|
|
1746
|
-
return frame();
|
|
1747
|
-
},
|
|
1748
|
-
get label() {
|
|
1749
|
-
return status();
|
|
1750
|
-
}
|
|
1751
|
-
}), _el$4);
|
|
1752
|
-
_$insertNode5(_el$4, _el$5);
|
|
1753
|
-
_$setProp5(_el$4, "border", true);
|
|
1754
|
-
_$setProp5(_el$4, "borderStyle", "single");
|
|
1755
|
-
_$setProp5(_el$4, "paddingX", 1);
|
|
1756
|
-
_$setProp5(_el$4, "marginTop", 1);
|
|
1757
|
-
_$setProp5(_el$4, "height", 3);
|
|
1758
|
-
_$use3((element) => steerBox = element, _el$5);
|
|
1759
|
-
_$setProp5(_el$5, "height", 1);
|
|
1760
|
-
_$setProp5(_el$5, "wrapMode", "none");
|
|
1761
|
-
_$setProp5(_el$5, "placeholder", "Steer the model or press esc to stop...");
|
|
1762
|
-
_$setProp5(_el$5, "keyBindings", [{
|
|
1763
|
-
name: "return",
|
|
1764
|
-
action: "submit"
|
|
1765
|
-
}, {
|
|
1766
|
-
name: "return",
|
|
1767
|
-
shift: true,
|
|
1768
|
-
action: "newline"
|
|
1769
|
-
}]);
|
|
1770
|
-
_$setProp5(_el$5, "onSubmit", () => {
|
|
1771
|
-
const text = steerBox?.plainText ?? "";
|
|
1772
|
-
if (!text.trim())
|
|
1773
|
-
return;
|
|
1774
|
-
c.steer(text);
|
|
1775
|
-
steerBox?.setText("");
|
|
1776
|
-
});
|
|
1777
|
-
_$insert5(_el$, _$createComponent5(Hints, {
|
|
1778
|
-
get theme() {
|
|
1779
|
-
return props.theme;
|
|
1780
|
-
},
|
|
1781
|
-
hints: [["enter", "steer"], ["esc", "stop"]]
|
|
1782
|
-
}), null);
|
|
1783
|
-
_$effect5((_p$) => {
|
|
1784
|
-
var _v$ = props.theme.border, _v$2 = !c.modal(), _v$3 = props.theme.faint, _v$4 = props.theme.text, _v$5 = props.theme.text, _v$6 = props.theme.background, _v$7 = props.theme.background, _v$8 = props.theme.text;
|
|
1785
|
-
_v$ !== _p$.e && (_p$.e = _$setProp5(_el$4, "borderColor", _v$, _p$.e));
|
|
1786
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp5(_el$5, "focused", _v$2, _p$.t));
|
|
1787
|
-
_v$3 !== _p$.a && (_p$.a = _$setProp5(_el$5, "placeholderColor", _v$3, _p$.a));
|
|
1788
|
-
_v$4 !== _p$.o && (_p$.o = _$setProp5(_el$5, "textColor", _v$4, _p$.o));
|
|
1789
|
-
_v$5 !== _p$.i && (_p$.i = _$setProp5(_el$5, "focusedTextColor", _v$5, _p$.i));
|
|
1790
|
-
_v$6 !== _p$.n && (_p$.n = _$setProp5(_el$5, "backgroundColor", _v$6, _p$.n));
|
|
1791
|
-
_v$7 !== _p$.s && (_p$.s = _$setProp5(_el$5, "focusedBackgroundColor", _v$7, _p$.s));
|
|
1792
|
-
_v$8 !== _p$.h && (_p$.h = _$setProp5(_el$5, "cursorColor", _v$8, _p$.h));
|
|
1793
|
-
return _p$;
|
|
1794
|
-
}, {
|
|
1795
|
-
e: undefined,
|
|
1796
|
-
t: undefined,
|
|
1797
|
-
a: undefined,
|
|
1798
|
-
o: undefined,
|
|
1799
|
-
i: undefined,
|
|
1800
|
-
n: undefined,
|
|
1801
|
-
s: undefined,
|
|
1802
|
-
h: undefined
|
|
1803
|
-
});
|
|
1804
|
-
return _el$;
|
|
1805
|
-
})();
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
// src/tui/screens/trust.tsx
|
|
1809
|
-
import { createComponent as _$createComponent6 } from "@opentui/solid";
|
|
1810
|
-
import { setProp as _$setProp6 } from "@opentui/solid";
|
|
1811
|
-
import { effect as _$effect6 } from "@opentui/solid";
|
|
1812
|
-
import { createTextNode as _$createTextNode5 } from "@opentui/solid";
|
|
1813
|
-
import { insertNode as _$insertNode6 } from "@opentui/solid";
|
|
1814
|
-
import { insert as _$insert6 } from "@opentui/solid";
|
|
1815
|
-
import { createElement as _$createElement6 } from "@opentui/solid";
|
|
1816
|
-
import { useKeyboard as useKeyboard5 } from "@opentui/solid";
|
|
1817
|
-
import { Match as Match3, Show as Show5, Switch as Switch3 } from "solid-js";
|
|
1818
|
-
import { CONFIG_FILE } from "trissue-embedded";
|
|
1819
|
-
function TrustScreen(props) {
|
|
1820
|
-
const theme = BASE_THEME;
|
|
1821
|
-
const source = props.controller.options.source;
|
|
1822
|
-
const ready = () => props.controller.fetched() !== null;
|
|
1823
|
-
useKeyboard5((key) => {
|
|
1824
|
-
if (key.name === "escape" || key.name === "q")
|
|
1825
|
-
props.onQuit();
|
|
1826
|
-
else if (key.name === "return" && ready())
|
|
1827
|
-
props.controller.setScreen("compose");
|
|
1828
|
-
});
|
|
1829
|
-
const row = (label, value) => (() => {
|
|
1830
|
-
var _el$ = _$createElement6("text"), _el$2 = _$createElement6("span"), _el$3 = _$createTextNode5(`: `), _el$4 = _$createElement6("span");
|
|
1831
|
-
_$insertNode6(_el$, _el$2);
|
|
1832
|
-
_$insertNode6(_el$, _el$4);
|
|
1833
|
-
_$insertNode6(_el$2, _el$3);
|
|
1834
|
-
_$insert6(_el$2, label, _el$3);
|
|
1835
|
-
_$insert6(_el$4, value);
|
|
1836
|
-
_$effect6((_p$) => {
|
|
1837
|
-
var _v$ = {
|
|
1838
|
-
fg: theme.text,
|
|
1839
|
-
bold: true
|
|
1840
|
-
}, _v$2 = {
|
|
1841
|
-
fg: theme.text
|
|
1842
|
-
};
|
|
1843
|
-
_v$ !== _p$.e && (_p$.e = _$setProp6(_el$2, "style", _v$, _p$.e));
|
|
1844
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp6(_el$4, "style", _v$2, _p$.t));
|
|
1845
|
-
return _p$;
|
|
1846
|
-
}, {
|
|
1847
|
-
e: undefined,
|
|
1848
|
-
t: undefined
|
|
1849
|
-
});
|
|
1850
|
-
return _el$;
|
|
1851
|
-
})();
|
|
1852
|
-
return (() => {
|
|
1853
|
-
var _el$5 = _$createElement6("box"), _el$6 = _$createElement6("box"), _el$7 = _$createElement6("text"), _el$9 = _$createElement6("box");
|
|
1854
|
-
_$insertNode6(_el$5, _el$6);
|
|
1855
|
-
_$setProp6(_el$5, "flexDirection", "column");
|
|
1856
|
-
_$setProp6(_el$5, "flexGrow", 1);
|
|
1857
|
-
_$setProp6(_el$5, "justifyContent", "space-between");
|
|
1858
|
-
_$insertNode6(_el$6, _el$7);
|
|
1859
|
-
_$insertNode6(_el$6, _el$9);
|
|
1860
|
-
_$setProp6(_el$6, "flexDirection", "column");
|
|
1861
|
-
_$setProp6(_el$6, "gap", 1);
|
|
1862
|
-
_$insertNode6(_el$7, _$createTextNode5(`This command can prompt an AI agent on your computer. Be sure you trust this repo before running this command.`));
|
|
1863
|
-
_$setProp6(_el$7, "attributes", BOLD);
|
|
1864
|
-
_$setProp6(_el$9, "flexDirection", "column");
|
|
1865
|
-
_$insert6(_el$9, () => row("Repo Organization", source.org || "None"), null);
|
|
1866
|
-
_$insert6(_el$9, () => row("Repo Name", source.name), null);
|
|
1867
|
-
_$insert6(_el$9, () => row(source.kind === "local" ? "Opened From" : "Downloaded From", source.kind === "local" ? `${source.origin} (${source.url})` : source.origin), null);
|
|
1868
|
-
_$insert6(_el$6, _$createComponent6(Switch3, {
|
|
1869
|
-
get children() {
|
|
1870
|
-
return [_$createComponent6(Match3, {
|
|
1871
|
-
get when() {
|
|
1872
|
-
return props.controller.fetchError();
|
|
1873
|
-
},
|
|
1874
|
-
children: (error) => (() => {
|
|
1875
|
-
var _el$15 = _$createElement6("text");
|
|
1876
|
-
_$insert6(_el$15, error);
|
|
1877
|
-
_$effect6((_$p) => _$setProp6(_el$15, "fg", theme.danger, _$p));
|
|
1878
|
-
return _el$15;
|
|
1879
|
-
})()
|
|
1880
|
-
}), _$createComponent6(Match3, {
|
|
1881
|
-
get when() {
|
|
1882
|
-
return !ready();
|
|
1883
|
-
},
|
|
1884
|
-
get children() {
|
|
1885
|
-
var _el$0 = _$createElement6("text");
|
|
1886
|
-
_$insertNode6(_el$0, _$createTextNode5(`Downloading the repo\u2026`));
|
|
1887
|
-
_$effect6((_$p) => _$setProp6(_el$0, "fg", theme.muted, _$p));
|
|
1888
|
-
return _el$0;
|
|
1889
|
-
}
|
|
1890
|
-
}), _$createComponent6(Match3, {
|
|
1891
|
-
get when() {
|
|
1892
|
-
return props.controller.config();
|
|
1893
|
-
},
|
|
1894
|
-
get children() {
|
|
1895
|
-
var _el$10 = _$createElement6("text"), _el$11 = _$createTextNode5(`This repo has a `), _el$12 = _$createTextNode5(`. Its instructions go to the agent, which checks them for anything malicious before following them.`);
|
|
1896
|
-
_$insertNode6(_el$10, _el$11);
|
|
1897
|
-
_$insertNode6(_el$10, _el$12);
|
|
1898
|
-
_$insert6(_el$10, CONFIG_FILE, _el$12);
|
|
1899
|
-
_$effect6((_$p) => _$setProp6(_el$10, "fg", theme.muted, _$p));
|
|
1900
|
-
return _el$10;
|
|
1901
|
-
}
|
|
1902
|
-
}), _$createComponent6(Match3, {
|
|
1903
|
-
get when() {
|
|
1904
|
-
return ready();
|
|
1905
|
-
},
|
|
1906
|
-
get children() {
|
|
1907
|
-
var _el$13 = _$createElement6("text");
|
|
1908
|
-
_$insertNode6(_el$13, _$createTextNode5(`This repo has no trissue configuration, so the defaults are used. Only continue if you trust it.`));
|
|
1909
|
-
_$effect6((_$p) => _$setProp6(_el$13, "fg", theme.muted, _$p));
|
|
1910
|
-
return _el$13;
|
|
1911
|
-
}
|
|
1912
|
-
})];
|
|
1913
|
-
}
|
|
1914
|
-
}), null);
|
|
1915
|
-
_$insert6(_el$5, _$createComponent6(Show5, {
|
|
1916
|
-
get when() {
|
|
1917
|
-
return ready();
|
|
1918
|
-
},
|
|
1919
|
-
get fallback() {
|
|
1920
|
-
return _$createComponent6(Hints, {
|
|
1921
|
-
theme,
|
|
1922
|
-
hints: [["esc", "quit"]]
|
|
1923
|
-
});
|
|
1924
|
-
},
|
|
1925
|
-
get children() {
|
|
1926
|
-
return _$createComponent6(Hints, {
|
|
1927
|
-
theme,
|
|
1928
|
-
hints: [["enter", "continue"], ["esc", "quit"]]
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
}), null);
|
|
1932
|
-
_$effect6((_$p) => _$setProp6(_el$7, "fg", theme.danger, _$p));
|
|
1933
|
-
return _el$5;
|
|
1934
|
-
})();
|
|
1935
|
-
}
|
|
1936
|
-
|
|
1937
|
-
// src/tui/app.tsx
|
|
1938
|
-
var FRAME_INSET = 2 + 4;
|
|
1939
|
-
function App(props) {
|
|
1940
|
-
const c = props.controller;
|
|
1941
|
-
const trusted = () => c.screen() !== "trust";
|
|
1942
|
-
const theme = createMemo5(() => trusted() ? themeFor(c.config(), {
|
|
1943
|
-
background: c.options.background
|
|
1944
|
-
}) : BASE_THEME);
|
|
1945
|
-
const product = () => c.config()?.product?.name ?? c.options.source.name;
|
|
1946
|
-
const detail = () => {
|
|
1947
|
-
const source = c.options.source;
|
|
1948
|
-
return source.org ? `${source.org}/${source.name}` : source.name;
|
|
1949
|
-
};
|
|
1950
|
-
useKeyboard6((key) => {
|
|
1951
|
-
if (key.ctrl && key.name === "c") {
|
|
1952
|
-
key.preventDefault();
|
|
1953
|
-
props.onQuit();
|
|
1954
|
-
}
|
|
1955
|
-
});
|
|
1956
|
-
return (() => {
|
|
1957
|
-
var _el$ = _$createElement7("box"), _el$2 = _$createElement7("box");
|
|
1958
|
-
_$insertNode7(_el$, _el$2);
|
|
1959
|
-
_$setProp7(_el$, "width", "100%");
|
|
1960
|
-
_$setProp7(_el$, "height", "100%");
|
|
1961
|
-
_$setProp7(_el$2, "width", "100%");
|
|
1962
|
-
_$setProp7(_el$2, "height", "100%");
|
|
1963
|
-
_$setProp7(_el$2, "border", true);
|
|
1964
|
-
_$setProp7(_el$2, "borderStyle", "single");
|
|
1965
|
-
_$setProp7(_el$2, "paddingX", 2);
|
|
1966
|
-
_$setProp7(_el$2, "paddingY", 1);
|
|
1967
|
-
_$setProp7(_el$2, "flexDirection", "column");
|
|
1968
|
-
_$insert7(_el$2, _$createComponent7(Switch4, {
|
|
1969
|
-
get children() {
|
|
1970
|
-
return [_$createComponent7(Match4, {
|
|
1971
|
-
get when() {
|
|
1972
|
-
return c.screen() === "trust";
|
|
1973
|
-
},
|
|
1974
|
-
get children() {
|
|
1975
|
-
return _$createComponent7(TrustScreen, {
|
|
1976
|
-
controller: c,
|
|
1977
|
-
get onQuit() {
|
|
1978
|
-
return props.onQuit;
|
|
1979
|
-
}
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
}), _$createComponent7(Match4, {
|
|
1983
|
-
get when() {
|
|
1984
|
-
return c.screen() === "compose";
|
|
1985
|
-
},
|
|
1986
|
-
get children() {
|
|
1987
|
-
return _$createComponent7(ComposeScreen, {
|
|
1988
|
-
controller: c,
|
|
1989
|
-
get theme() {
|
|
1990
|
-
return theme();
|
|
1991
|
-
},
|
|
1992
|
-
get product() {
|
|
1993
|
-
return product();
|
|
1994
|
-
},
|
|
1995
|
-
get detail() {
|
|
1996
|
-
return detail();
|
|
1997
|
-
},
|
|
1998
|
-
inset: FRAME_INSET
|
|
1999
|
-
});
|
|
2000
|
-
}
|
|
2001
|
-
}), _$createComponent7(Match4, {
|
|
2002
|
-
get when() {
|
|
2003
|
-
return c.screen() === "running";
|
|
2004
|
-
},
|
|
2005
|
-
get children() {
|
|
2006
|
-
return _$createComponent7(RunningScreen, {
|
|
2007
|
-
controller: c,
|
|
2008
|
-
get theme() {
|
|
2009
|
-
return theme();
|
|
2010
|
-
},
|
|
2011
|
-
get product() {
|
|
2012
|
-
return product();
|
|
2013
|
-
},
|
|
2014
|
-
get detail() {
|
|
2015
|
-
return detail();
|
|
2016
|
-
}
|
|
2017
|
-
});
|
|
2018
|
-
}
|
|
2019
|
-
}), _$createComponent7(Match4, {
|
|
2020
|
-
get when() {
|
|
2021
|
-
return c.screen() === "result";
|
|
2022
|
-
},
|
|
2023
|
-
get children() {
|
|
2024
|
-
return _$createComponent7(ResultScreen, {
|
|
2025
|
-
controller: c,
|
|
2026
|
-
get theme() {
|
|
2027
|
-
return theme();
|
|
2028
|
-
},
|
|
2029
|
-
get product() {
|
|
2030
|
-
return product();
|
|
2031
|
-
},
|
|
2032
|
-
get detail() {
|
|
2033
|
-
return detail();
|
|
2034
|
-
},
|
|
2035
|
-
get onQuit() {
|
|
2036
|
-
return props.onQuit;
|
|
2037
|
-
}
|
|
2038
|
-
});
|
|
2039
|
-
}
|
|
2040
|
-
}), _$createComponent7(Match4, {
|
|
2041
|
-
get when() {
|
|
2042
|
-
return c.screen() === "error";
|
|
2043
|
-
},
|
|
2044
|
-
get children() {
|
|
2045
|
-
return _$createComponent7(ErrorScreen, {
|
|
2046
|
-
controller: c,
|
|
2047
|
-
get theme() {
|
|
2048
|
-
return theme();
|
|
2049
|
-
},
|
|
2050
|
-
get product() {
|
|
2051
|
-
return product();
|
|
2052
|
-
},
|
|
2053
|
-
get detail() {
|
|
2054
|
-
return detail();
|
|
2055
|
-
},
|
|
2056
|
-
get onQuit() {
|
|
2057
|
-
return props.onQuit;
|
|
2058
|
-
}
|
|
2059
|
-
});
|
|
2060
|
-
}
|
|
2061
|
-
})];
|
|
2062
|
-
}
|
|
2063
|
-
}));
|
|
2064
|
-
_$insert7(_el$, _$createComponent7(Show6, {
|
|
2065
|
-
get when() {
|
|
2066
|
-
return c.toast();
|
|
2067
|
-
},
|
|
2068
|
-
children: (toast) => (() => {
|
|
2069
|
-
var _el$3 = _$createElement7("box"), _el$4 = _$createElement7("text");
|
|
2070
|
-
_$insertNode7(_el$3, _el$4);
|
|
2071
|
-
_$setProp7(_el$3, "position", "absolute");
|
|
2072
|
-
_$setProp7(_el$3, "bottom", 0);
|
|
2073
|
-
_$setProp7(_el$3, "right", 3);
|
|
2074
|
-
_$setProp7(_el$3, "maxWidth", "70%");
|
|
2075
|
-
_$setProp7(_el$3, "zIndex", 50);
|
|
2076
|
-
_$setProp7(_el$3, "paddingX", 1);
|
|
2077
|
-
_$setProp7(_el$4, "attributes", BOLD);
|
|
2078
|
-
_$insert7(_el$4, () => `${toast().tone === "danger" ? "\u26A0" : "\u2713"} ${toast().text}`);
|
|
2079
|
-
_$effect7((_p$) => {
|
|
2080
|
-
var _v$4 = toast().tone === "danger" ? theme().danger : theme().success, _v$5 = theme().background;
|
|
2081
|
-
_v$4 !== _p$.e && (_p$.e = _$setProp7(_el$3, "backgroundColor", _v$4, _p$.e));
|
|
2082
|
-
_v$5 !== _p$.t && (_p$.t = _$setProp7(_el$4, "fg", _v$5, _p$.t));
|
|
2083
|
-
return _p$;
|
|
2084
|
-
}, {
|
|
2085
|
-
e: undefined,
|
|
2086
|
-
t: undefined
|
|
2087
|
-
});
|
|
2088
|
-
return _el$3;
|
|
2089
|
-
})()
|
|
2090
|
-
}), null);
|
|
2091
|
-
_$insert7(_el$, _$createComponent7(Show6, {
|
|
2092
|
-
get when() {
|
|
2093
|
-
return c.modal();
|
|
2094
|
-
},
|
|
2095
|
-
get children() {
|
|
2096
|
-
return _$createComponent7(Modals, {
|
|
2097
|
-
controller: c,
|
|
2098
|
-
get theme() {
|
|
2099
|
-
return theme();
|
|
2100
|
-
}
|
|
2101
|
-
});
|
|
2102
|
-
}
|
|
2103
|
-
}), null);
|
|
2104
|
-
_$effect7((_p$) => {
|
|
2105
|
-
var _v$ = theme().background, _v$2 = theme().border, _v$3 = theme().background;
|
|
2106
|
-
_v$ !== _p$.e && (_p$.e = _$setProp7(_el$, "backgroundColor", _v$, _p$.e));
|
|
2107
|
-
_v$2 !== _p$.t && (_p$.t = _$setProp7(_el$2, "borderColor", _v$2, _p$.t));
|
|
2108
|
-
_v$3 !== _p$.a && (_p$.a = _$setProp7(_el$2, "backgroundColor", _v$3, _p$.a));
|
|
2109
|
-
return _p$;
|
|
2110
|
-
}, {
|
|
2111
|
-
e: undefined,
|
|
2112
|
-
t: undefined,
|
|
2113
|
-
a: undefined
|
|
2114
|
-
});
|
|
2115
|
-
return _el$;
|
|
2116
|
-
})();
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
// src/version.ts
|
|
2120
|
-
var VERSION = "0.1.0";
|
|
2121
|
-
|
|
2122
|
-
// src/tui/controller.ts
|
|
2123
|
-
import { batch, createSignal as createSignal5 } from "solid-js";
|
|
2124
|
-
import {
|
|
2125
|
-
startAgent,
|
|
2126
|
-
GITHUB_LOGIN_ARGS,
|
|
2127
|
-
RejectedError,
|
|
2128
|
-
StoppedError,
|
|
2129
|
-
Transcript,
|
|
2130
|
-
buildLink,
|
|
2131
|
-
buildPrompt,
|
|
2132
|
-
copyIssue,
|
|
2133
|
-
fetchSource,
|
|
2134
|
-
fileGitHubIssue,
|
|
2135
|
-
filterModels,
|
|
2136
|
-
formatIssue,
|
|
2137
|
-
gitHubStatus,
|
|
2138
|
-
hasModelFilter,
|
|
2139
|
-
isModelAllowed,
|
|
2140
|
-
loadConfig,
|
|
2141
|
-
openUrl,
|
|
2142
|
-
parseIssue
|
|
2143
|
-
} from "trissue-embedded";
|
|
2144
|
-
function createController(options) {
|
|
2145
|
-
const [screen, setScreen] = createSignal5("trust");
|
|
2146
|
-
const [modal, setModal] = createSignal5(null);
|
|
2147
|
-
const [toast, setToastSignal] = createSignal5(null);
|
|
2148
|
-
const [fetched, setFetched] = createSignal5(options.fetched ?? null);
|
|
2149
|
-
const [fetchError, setFetchError] = createSignal5(null);
|
|
2150
|
-
const [config, setConfig] = createSignal5(options.config ?? null);
|
|
2151
|
-
const [issueText, setIssueText] = createSignal5("");
|
|
2152
|
-
const [harnessIndex, setHarnessIndex] = createSignal5(0);
|
|
2153
|
-
const [modelId, setModelId] = createSignal5(null);
|
|
2154
|
-
const [sessionState, setSessionState] = createSignal5({ status: "idle" });
|
|
2155
|
-
const [entries, setEntries] = createSignal5([], { equals: false });
|
|
2156
|
-
const [startedAt, setStartedAt] = createSignal5(0);
|
|
2157
|
-
const [issue, setIssue] = createSignal5(null);
|
|
2158
|
-
const [error, setError] = createSignal5(null);
|
|
2159
|
-
const [busy, setBusy] = createSignal5(null);
|
|
2160
|
-
let toastTimer;
|
|
2161
|
-
function showToast(text, tone = "success") {
|
|
2162
|
-
clearTimeout(toastTimer);
|
|
2163
|
-
setToastSignal({ text, tone });
|
|
2164
|
-
toastTimer = setTimeout(() => setToastSignal(null), 3500);
|
|
2165
|
-
}
|
|
2166
|
-
if (!options.fetched) {
|
|
2167
|
-
(async () => {
|
|
2168
|
-
try {
|
|
2169
|
-
const source = await fetchSource(options.source);
|
|
2170
|
-
const loaded = await loadConfig(source.dir).catch(async (error) => {
|
|
2171
|
-
await source.dispose();
|
|
2172
|
-
throw error;
|
|
2173
|
-
});
|
|
2174
|
-
batch(() => {
|
|
2175
|
-
setFetched(source);
|
|
2176
|
-
setConfig(loaded);
|
|
2177
|
-
});
|
|
2178
|
-
} catch (error) {
|
|
2179
|
-
setFetchError(error.message);
|
|
2180
|
-
}
|
|
2181
|
-
})();
|
|
2182
|
-
}
|
|
2183
|
-
const harness = () => options.harnesses[harnessIndex()];
|
|
2184
|
-
let sessionToken = 0;
|
|
2185
|
-
function closeSession() {
|
|
2186
|
-
sessionToken++;
|
|
2187
|
-
const state = sessionState();
|
|
2188
|
-
if (state.status === "ready")
|
|
2189
|
-
state.session.close();
|
|
2190
|
-
setSessionState({ status: "idle" });
|
|
2191
|
-
}
|
|
2192
|
-
function selectHarness(index) {
|
|
2193
|
-
if (index === harnessIndex())
|
|
2194
|
-
return;
|
|
2195
|
-
batch(() => {
|
|
2196
|
-
closeSession();
|
|
2197
|
-
setHarnessIndex(index);
|
|
2198
|
-
setModelId(null);
|
|
2199
|
-
});
|
|
2200
|
-
}
|
|
2201
|
-
async function prepareSession() {
|
|
2202
|
-
const chosen = harness();
|
|
2203
|
-
const source = fetched();
|
|
2204
|
-
if (!chosen || !source)
|
|
2205
|
-
return null;
|
|
2206
|
-
const state = sessionState();
|
|
2207
|
-
if (state.status === "ready" && state.harnessId === chosen.id)
|
|
2208
|
-
return state.session;
|
|
2209
|
-
if (state.status === "starting" && state.harnessId === chosen.id)
|
|
2210
|
-
return waitForSession(chosen.id);
|
|
2211
|
-
const token = ++sessionToken;
|
|
2212
|
-
setSessionState({ status: "starting", harnessId: chosen.id });
|
|
2213
|
-
try {
|
|
2214
|
-
const session = await startAgent({ harness: chosen, cwd: source.dir, onEvent: onAgentEvent });
|
|
2215
|
-
if (token !== sessionToken) {
|
|
2216
|
-
session.close();
|
|
2217
|
-
return null;
|
|
2218
|
-
}
|
|
2219
|
-
setSessionState({ status: "ready", harnessId: chosen.id, session });
|
|
2220
|
-
return session;
|
|
2221
|
-
} catch (error) {
|
|
2222
|
-
if (token === sessionToken)
|
|
2223
|
-
setSessionState({ status: "failed", harnessId: chosen.id, error: error.message });
|
|
2224
|
-
return null;
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
function waitForSession(harnessId) {
|
|
2228
|
-
return new Promise((resolve) => {
|
|
2229
|
-
const check = () => {
|
|
2230
|
-
const state = sessionState();
|
|
2231
|
-
if (state.status === "ready" && state.harnessId === harnessId)
|
|
2232
|
-
resolve(state.session);
|
|
2233
|
-
else if (state.status !== "starting" || state.harnessId !== harnessId)
|
|
2234
|
-
resolve(null);
|
|
2235
|
-
else
|
|
2236
|
-
setTimeout(check, 50);
|
|
2237
|
-
};
|
|
2238
|
-
check();
|
|
2239
|
-
});
|
|
2240
|
-
}
|
|
2241
|
-
let transcript = new Transcript;
|
|
2242
|
-
let flushQueued = false;
|
|
2243
|
-
function onAgentEvent(event) {
|
|
2244
|
-
if (screen() !== "running")
|
|
2245
|
-
return;
|
|
2246
|
-
transcript.apply(event);
|
|
2247
|
-
if (flushQueued)
|
|
2248
|
-
return;
|
|
2249
|
-
flushQueued = true;
|
|
2250
|
-
setTimeout(() => {
|
|
2251
|
-
flushQueued = false;
|
|
2252
|
-
setEntries(transcript.entries);
|
|
2253
|
-
}, 33);
|
|
2254
|
-
}
|
|
2255
|
-
function allowedModels(session) {
|
|
2256
|
-
return filterModels(config()?.models, session.harness.id, session.models);
|
|
2257
|
-
}
|
|
2258
|
-
function modelProblem(session, id) {
|
|
2259
|
-
const filter = config()?.models;
|
|
2260
|
-
if (id)
|
|
2261
|
-
return isModelAllowed(filter, session.harness.id, id) ? null : `This repo doesn't allow ${id}.`;
|
|
2262
|
-
if (!hasModelFilter(filter))
|
|
2263
|
-
return null;
|
|
2264
|
-
const current = session.currentModel;
|
|
2265
|
-
if (!current)
|
|
2266
|
-
return `This repo only allows some models, and ${session.harness.name} doesn't say which model it uses by default.`;
|
|
2267
|
-
return isModelAllowed(filter, session.harness.id, current.id) ? null : `This repo doesn't allow ${current.name}, ${session.harness.name}'s default. Pick another model.`;
|
|
2268
|
-
}
|
|
2269
|
-
async function start(id) {
|
|
2270
|
-
if (!issueText().trim()) {
|
|
2271
|
-
showToast("Explain the issue first.", "danger");
|
|
2272
|
-
return false;
|
|
2273
|
-
}
|
|
2274
|
-
const session = await prepareSession();
|
|
2275
|
-
if (!session) {
|
|
2276
|
-
const state = sessionState();
|
|
2277
|
-
if (state.status === "failed")
|
|
2278
|
-
showToast(state.error, "danger");
|
|
2279
|
-
return false;
|
|
2280
|
-
}
|
|
2281
|
-
const problem = modelProblem(session, id);
|
|
2282
|
-
if (problem) {
|
|
2283
|
-
showToast(problem, "danger");
|
|
2284
|
-
setModal({ name: "models" });
|
|
2285
|
-
return false;
|
|
2286
|
-
}
|
|
2287
|
-
try {
|
|
2288
|
-
if (id)
|
|
2289
|
-
await session.setModel(id);
|
|
2290
|
-
} catch (error) {
|
|
2291
|
-
showToast(error.message, "danger");
|
|
2292
|
-
return false;
|
|
2293
|
-
}
|
|
2294
|
-
const source = fetched();
|
|
2295
|
-
const chosen = id ?? session.currentModel?.id ?? null;
|
|
2296
|
-
transcript = new Transcript;
|
|
2297
|
-
batch(() => {
|
|
2298
|
-
setModelId(chosen);
|
|
2299
|
-
setModal(null);
|
|
2300
|
-
setEntries([]);
|
|
2301
|
-
setStartedAt(Date.now());
|
|
2302
|
-
setScreen("running");
|
|
2303
|
-
});
|
|
2304
|
-
const modelName = session.models.find((model) => model.id === chosen)?.name ?? chosen ?? undefined;
|
|
2305
|
-
try {
|
|
2306
|
-
const text = await session.run(buildPrompt({ issue: issueText(), source, instructions: config()?.instructions, harnessName: session.harness.name, modelName }));
|
|
2307
|
-
const parsed = parseIssue(text);
|
|
2308
|
-
batch(() => {
|
|
2309
|
-
setIssue(parsed);
|
|
2310
|
-
setScreen("result");
|
|
2311
|
-
});
|
|
2312
|
-
} catch (error) {
|
|
2313
|
-
const title = error instanceof StoppedError ? "Stopped" : error instanceof RejectedError ? "The agent rejected this task" : "Error";
|
|
2314
|
-
batch(() => {
|
|
2315
|
-
setError({ title, message: error.message });
|
|
2316
|
-
setScreen("error");
|
|
2317
|
-
});
|
|
2318
|
-
} finally {
|
|
2319
|
-
closeSession();
|
|
2320
|
-
}
|
|
2321
|
-
return true;
|
|
2322
|
-
}
|
|
2323
|
-
function steer(text) {
|
|
2324
|
-
const state = sessionState();
|
|
2325
|
-
if (state.status === "ready")
|
|
2326
|
-
state.session.steer(text);
|
|
2327
|
-
}
|
|
2328
|
-
function stop() {
|
|
2329
|
-
const state = sessionState();
|
|
2330
|
-
if (state.status === "ready")
|
|
2331
|
-
state.session.stop();
|
|
2332
|
-
}
|
|
2333
|
-
function tryAgain() {
|
|
2334
|
-
batch(() => {
|
|
2335
|
-
setError(null);
|
|
2336
|
-
setIssue(null);
|
|
2337
|
-
setScreen("compose");
|
|
2338
|
-
});
|
|
2339
|
-
}
|
|
2340
|
-
const githubRepo = () => {
|
|
2341
|
-
const configured = config()?.github;
|
|
2342
|
-
if (configured === false)
|
|
2343
|
-
return null;
|
|
2344
|
-
return configured ?? fetched()?.github ?? null;
|
|
2345
|
-
};
|
|
2346
|
-
async function beginGitHub() {
|
|
2347
|
-
const repo = githubRepo();
|
|
2348
|
-
if (!repo)
|
|
2349
|
-
return;
|
|
2350
|
-
setBusy("Checking GitHub sign-in\u2026");
|
|
2351
|
-
try {
|
|
2352
|
-
const status = await gitHubStatus();
|
|
2353
|
-
if (status.state === "missing")
|
|
2354
|
-
setModal({ name: "github-missing" });
|
|
2355
|
-
else if (status.state === "signed-out")
|
|
2356
|
-
setModal({ name: "github-signin", repo });
|
|
2357
|
-
else
|
|
2358
|
-
setModal({ name: "github-confirm", repo, login: status.login });
|
|
2359
|
-
} catch (error) {
|
|
2360
|
-
showToast(`Couldn't check GitHub sign-in: ${error.message}`, "danger");
|
|
2361
|
-
} finally {
|
|
2362
|
-
setBusy(null);
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
async function signInToGitHub() {
|
|
2366
|
-
setModal(null);
|
|
2367
|
-
if (!options.runInTerminal) {
|
|
2368
|
-
showToast("Sign in with `gh auth login`, then try again.", "danger");
|
|
2369
|
-
return;
|
|
2370
|
-
}
|
|
2371
|
-
const code = await options.runInTerminal("gh", GITHUB_LOGIN_ARGS);
|
|
2372
|
-
if (code !== 0) {
|
|
2373
|
-
showToast("GitHub sign-in didn't finish.", "danger");
|
|
2374
|
-
return;
|
|
2375
|
-
}
|
|
2376
|
-
await beginGitHub();
|
|
2377
|
-
}
|
|
2378
|
-
async function fileOnGitHub(repo) {
|
|
2379
|
-
const current = issue();
|
|
2380
|
-
if (!current)
|
|
2381
|
-
return;
|
|
2382
|
-
setModal(null);
|
|
2383
|
-
setBusy("Filing the issue\u2026");
|
|
2384
|
-
try {
|
|
2385
|
-
const url = await fileGitHubIssue(repo, current, config()?.labels ?? []);
|
|
2386
|
-
setModal({ name: "filed", url });
|
|
2387
|
-
} catch (error) {
|
|
2388
|
-
showToast(`Couldn't file the issue: ${error.message}`, "danger");
|
|
2389
|
-
} finally {
|
|
2390
|
-
setBusy(null);
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
async function copy() {
|
|
2394
|
-
const current = issue();
|
|
2395
|
-
if (!current)
|
|
2396
|
-
return;
|
|
2397
|
-
try {
|
|
2398
|
-
await copyIssue(current);
|
|
2399
|
-
showToast("Copied the issue.");
|
|
2400
|
-
} catch (error) {
|
|
2401
|
-
if (options.copyFallback?.(formatIssue(current)))
|
|
2402
|
-
showToast("Copied the issue through your terminal.");
|
|
2403
|
-
else
|
|
2404
|
-
showToast(error.message, "danger");
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
function chooseLink(link) {
|
|
2408
|
-
const current = issue();
|
|
2409
|
-
if (!current)
|
|
2410
|
-
return;
|
|
2411
|
-
setModal({ name: "link", link, url: buildLink(link, current) });
|
|
2412
|
-
}
|
|
2413
|
-
async function open(url) {
|
|
2414
|
-
try {
|
|
2415
|
-
await openUrl(url);
|
|
2416
|
-
setModal(null);
|
|
2417
|
-
} catch (error) {
|
|
2418
|
-
showToast(error.message, "danger");
|
|
2419
|
-
}
|
|
2420
|
-
}
|
|
2421
|
-
function dispose() {
|
|
2422
|
-
closeSession();
|
|
2423
|
-
clearTimeout(toastTimer);
|
|
2424
|
-
return fetched()?.dispose();
|
|
2425
|
-
}
|
|
2426
|
-
return {
|
|
2427
|
-
options,
|
|
2428
|
-
screen,
|
|
2429
|
-
setScreen,
|
|
2430
|
-
modal,
|
|
2431
|
-
setModal,
|
|
2432
|
-
toast,
|
|
2433
|
-
showToast,
|
|
2434
|
-
fetched,
|
|
2435
|
-
fetchError,
|
|
2436
|
-
config,
|
|
2437
|
-
issueText,
|
|
2438
|
-
setIssueText,
|
|
2439
|
-
harnesses: options.harnesses,
|
|
2440
|
-
harness,
|
|
2441
|
-
harnessIndex,
|
|
2442
|
-
selectHarness,
|
|
2443
|
-
modelId,
|
|
2444
|
-
sessionState,
|
|
2445
|
-
prepareSession,
|
|
2446
|
-
allowedModels,
|
|
2447
|
-
entries,
|
|
2448
|
-
startedAt,
|
|
2449
|
-
issue,
|
|
2450
|
-
error,
|
|
2451
|
-
busy,
|
|
2452
|
-
start,
|
|
2453
|
-
steer,
|
|
2454
|
-
stop,
|
|
2455
|
-
tryAgain,
|
|
2456
|
-
githubRepo,
|
|
2457
|
-
beginGitHub,
|
|
2458
|
-
signInToGitHub,
|
|
2459
|
-
fileOnGitHub,
|
|
2460
|
-
copy,
|
|
2461
|
-
chooseLink,
|
|
2462
|
-
open,
|
|
2463
|
-
dispose,
|
|
2464
|
-
debug: { setEntries, setIssue, setError, setStartedAt, setSessionState, setModelId }
|
|
2465
|
-
};
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
// src/cli.tsx
|
|
2469
|
-
var HELP = `trissue: have a coding agent find the source of an issue and write it up.
|
|
2470
|
-
|
|
2471
|
-
Usage
|
|
2472
|
-
trissue [repo] [options]
|
|
2473
|
-
|
|
2474
|
-
repo owner/repo (GitHub), a clone URL, or a folder. Defaults to this folder.
|
|
2475
|
-
|
|
2476
|
-
Options
|
|
2477
|
-
--ref <ref> Branch, tag or commit to download
|
|
2478
|
-
--background <hex> Background color of the interface
|
|
2479
|
-
--list-agents List the coding agents installed on this computer
|
|
2480
|
-
-h, --help Show this help
|
|
2481
|
-
-v, --version Show the version
|
|
2482
|
-
|
|
2483
|
-
Without the interface (all set from arguments)
|
|
2484
|
-
--issue <text> What's wrong. "-" reads it from stdin
|
|
2485
|
-
--agent <id> Agent to use, like claude or codex. Defaults to the first installed
|
|
2486
|
-
--model <id> Model to use. Defaults to the agent's default
|
|
2487
|
-
--send <how> print (default), json, copy, github, or link:<label>
|
|
2488
|
-
--yes Required with --send github: confirms filing a public issue
|
|
2489
|
-
`;
|
|
2490
|
-
function fail(message) {
|
|
2491
|
-
process.stderr.write(`trissue: ${message}
|
|
3
|
+
// src/bin.ts
|
|
4
|
+
var MIN_NODE = 20;
|
|
5
|
+
var major = Number(process.versions.node.split(".")[0]);
|
|
6
|
+
if (!process.versions.bun && major < MIN_NODE) {
|
|
7
|
+
process.stderr.write(`trissue: needs Node ${MIN_NODE} or newer, or Bun. This is Node ${process.versions.node}.
|
|
2492
8
|
`);
|
|
2493
9
|
process.exit(1);
|
|
2494
10
|
}
|
|
2495
|
-
|
|
2496
|
-
values,
|
|
2497
|
-
positionals
|
|
2498
|
-
} = parseArgs({
|
|
2499
|
-
allowPositionals: true,
|
|
2500
|
-
options: {
|
|
2501
|
-
ref: {
|
|
2502
|
-
type: "string"
|
|
2503
|
-
},
|
|
2504
|
-
background: {
|
|
2505
|
-
type: "string"
|
|
2506
|
-
},
|
|
2507
|
-
"list-agents": {
|
|
2508
|
-
type: "boolean"
|
|
2509
|
-
},
|
|
2510
|
-
issue: {
|
|
2511
|
-
type: "string"
|
|
2512
|
-
},
|
|
2513
|
-
agent: {
|
|
2514
|
-
type: "string"
|
|
2515
|
-
},
|
|
2516
|
-
model: {
|
|
2517
|
-
type: "string"
|
|
2518
|
-
},
|
|
2519
|
-
send: {
|
|
2520
|
-
type: "string"
|
|
2521
|
-
},
|
|
2522
|
-
yes: {
|
|
2523
|
-
type: "boolean"
|
|
2524
|
-
},
|
|
2525
|
-
help: {
|
|
2526
|
-
type: "boolean",
|
|
2527
|
-
short: "h"
|
|
2528
|
-
},
|
|
2529
|
-
version: {
|
|
2530
|
-
type: "boolean",
|
|
2531
|
-
short: "v"
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
|
-
});
|
|
2535
|
-
if (values.help) {
|
|
2536
|
-
process.stdout.write(HELP);
|
|
2537
|
-
process.exit(0);
|
|
2538
|
-
}
|
|
2539
|
-
if (values.version) {
|
|
2540
|
-
process.stdout.write(`${VERSION}
|
|
2541
|
-
`);
|
|
2542
|
-
process.exit(0);
|
|
2543
|
-
}
|
|
2544
|
-
if (values.background && !/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(values.background))
|
|
2545
|
-
fail("--background must be a hex color like #101010.");
|
|
2546
|
-
if (positionals.length > 1)
|
|
2547
|
-
fail("Give one repo at most.");
|
|
2548
|
-
if (values["list-agents"]) {
|
|
2549
|
-
const harnesses = detectHarnesses();
|
|
2550
|
-
if (!harnesses.length)
|
|
2551
|
-
fail("No coding agents are installed.");
|
|
2552
|
-
for (const harness of harnesses)
|
|
2553
|
-
process.stdout.write(`${harness.id.padEnd(16)} ${harness.name.padEnd(20)} ${harness.executable}
|
|
2554
|
-
`);
|
|
2555
|
-
process.exit(0);
|
|
2556
|
-
}
|
|
2557
|
-
var repo = positionals[0];
|
|
2558
|
-
if (values.issue !== undefined) {
|
|
2559
|
-
await headless();
|
|
2560
|
-
} else {
|
|
2561
|
-
if (values.agent || values.model || values.send || values.yes)
|
|
2562
|
-
fail("--agent, --model, --send and --yes need --issue.");
|
|
2563
|
-
await interactive();
|
|
2564
|
-
}
|
|
2565
|
-
async function headless() {
|
|
2566
|
-
const issueText = values.issue === "-" ? readFileSync(0, "utf8") : values.issue;
|
|
2567
|
-
const send = values.send ?? "print";
|
|
2568
|
-
if (!/^(print|json|copy|github|link:.+)$/.test(send))
|
|
2569
|
-
fail(`--send must be print, json, copy, github, or link:<label>, not "${send}".`);
|
|
2570
|
-
if (send === "github" && !values.yes)
|
|
2571
|
-
fail("--send github posts a public issue. Add --yes to confirm.");
|
|
2572
|
-
const controller = new AbortController;
|
|
2573
|
-
process.once("SIGINT", () => controller.abort());
|
|
2574
|
-
let result;
|
|
2575
|
-
try {
|
|
2576
|
-
result = await runTriage({
|
|
2577
|
-
issue: issueText,
|
|
2578
|
-
repo,
|
|
2579
|
-
ref: values.ref,
|
|
2580
|
-
harness: values.agent,
|
|
2581
|
-
model: values.model,
|
|
2582
|
-
signal: controller.signal,
|
|
2583
|
-
onEvent: (event) => {
|
|
2584
|
-
if (event.type === "tool") {
|
|
2585
|
-
if (event.title && event.status !== "completed")
|
|
2586
|
-
process.stderr.write(`\u203A ${event.title}
|
|
2587
|
-
`);
|
|
2588
|
-
} else if (event.type === "blocked")
|
|
2589
|
-
process.stderr.write(`\u2298 Blocked ${event.title}
|
|
2590
|
-
`);
|
|
2591
|
-
}
|
|
2592
|
-
});
|
|
2593
|
-
} catch (error) {
|
|
2594
|
-
fail(error.message);
|
|
2595
|
-
}
|
|
2596
|
-
try {
|
|
2597
|
-
const {
|
|
2598
|
-
issue,
|
|
2599
|
-
config,
|
|
2600
|
-
source
|
|
2601
|
-
} = result;
|
|
2602
|
-
if (send === "print")
|
|
2603
|
-
process.stdout.write(`${formatIssue2(issue)}
|
|
2604
|
-
`);
|
|
2605
|
-
else if (send === "json")
|
|
2606
|
-
process.stdout.write(`${JSON.stringify(issue, null, 2)}
|
|
2607
|
-
`);
|
|
2608
|
-
else if (send === "copy") {
|
|
2609
|
-
await copyIssue2(issue);
|
|
2610
|
-
process.stderr.write(`Copied the issue.
|
|
2611
|
-
`);
|
|
2612
|
-
} else if (send === "github") {
|
|
2613
|
-
const target = config?.github === false ? null : config?.github ?? source.github;
|
|
2614
|
-
if (!target)
|
|
2615
|
-
fail("This repo has no GitHub repository to file on.");
|
|
2616
|
-
process.stdout.write(`${await fileGitHubIssue2(target, issue, config?.labels ?? [])}
|
|
2617
|
-
`);
|
|
2618
|
-
} else {
|
|
2619
|
-
const label = send.slice("link:".length);
|
|
2620
|
-
const link = config?.links?.find((candidate) => candidate.label.toLowerCase() === label.toLowerCase());
|
|
2621
|
-
if (!link)
|
|
2622
|
-
fail(`This repo has no link called "${label}".`);
|
|
2623
|
-
const url = buildLink2(link, issue);
|
|
2624
|
-
await openUrl2(url);
|
|
2625
|
-
process.stdout.write(`${url}
|
|
2626
|
-
`);
|
|
2627
|
-
}
|
|
2628
|
-
} finally {
|
|
2629
|
-
await result.source.dispose();
|
|
2630
|
-
}
|
|
2631
|
-
process.exit(0);
|
|
2632
|
-
}
|
|
2633
|
-
async function interactive() {
|
|
2634
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
|
2635
|
-
fail("The interface needs a terminal. Use --issue to run without it.");
|
|
2636
|
-
let source;
|
|
2637
|
-
try {
|
|
2638
|
-
source = await resolveSource(repo, values.ref);
|
|
2639
|
-
} catch (error) {
|
|
2640
|
-
fail(error.message);
|
|
2641
|
-
}
|
|
2642
|
-
const renderer = await createCliRenderer({
|
|
2643
|
-
exitOnCtrlC: false,
|
|
2644
|
-
backgroundColor: values.background ?? "#000000"
|
|
2645
|
-
});
|
|
2646
|
-
const controller = createController({
|
|
2647
|
-
source,
|
|
2648
|
-
harnesses: detectHarnesses(),
|
|
2649
|
-
background: values.background,
|
|
2650
|
-
runInTerminal: async (command, args) => {
|
|
2651
|
-
await renderer.suspend();
|
|
2652
|
-
try {
|
|
2653
|
-
const result = spawnSync(command, args, {
|
|
2654
|
-
stdio: "inherit"
|
|
2655
|
-
});
|
|
2656
|
-
return result.status ?? 1;
|
|
2657
|
-
} finally {
|
|
2658
|
-
await renderer.resume();
|
|
2659
|
-
}
|
|
2660
|
-
},
|
|
2661
|
-
copyFallback: (text) => renderer.copyToClipboardOSC52(text)
|
|
2662
|
-
});
|
|
2663
|
-
let quitting = false;
|
|
2664
|
-
const quit = async () => {
|
|
2665
|
-
if (quitting)
|
|
2666
|
-
return;
|
|
2667
|
-
quitting = true;
|
|
2668
|
-
try {
|
|
2669
|
-
await controller.dispose();
|
|
2670
|
-
} finally {
|
|
2671
|
-
renderer.destroy();
|
|
2672
|
-
process.exit(0);
|
|
2673
|
-
}
|
|
2674
|
-
};
|
|
2675
|
-
process.once("SIGTERM", () => void quit());
|
|
2676
|
-
await render(() => _$createComponent8(App, {
|
|
2677
|
-
controller,
|
|
2678
|
-
onQuit: () => void quit()
|
|
2679
|
-
}), renderer);
|
|
2680
|
-
}
|
|
11
|
+
await import("./cli-g9sxmkeh.js");
|