pi-subagent-manager 1.10.0 → 1.11.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/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +836 -0
- package/dist/index.js.map +1 -0
- package/dist/orch/checklist-integration.d.ts +48 -0
- package/dist/orch/checklist-integration.d.ts.map +1 -0
- package/dist/orch/checklist-integration.js +204 -0
- package/dist/orch/checklist-integration.js.map +1 -0
- package/dist/orch/context-entries.d.ts +8 -0
- package/dist/orch/context-entries.d.ts.map +1 -0
- package/dist/orch/context-entries.js +8 -0
- package/dist/orch/context-entries.js.map +1 -0
- package/dist/orch/cost-ledger.d.ts +16 -0
- package/dist/orch/cost-ledger.d.ts.map +1 -0
- package/dist/orch/cost-ledger.js +43 -0
- package/dist/orch/cost-ledger.js.map +1 -0
- package/dist/orch/diagnostics.d.ts +13 -0
- package/dist/orch/diagnostics.d.ts.map +1 -0
- package/dist/orch/diagnostics.js +95 -0
- package/dist/orch/diagnostics.js.map +1 -0
- package/dist/orch/extensions.d.ts +15 -0
- package/dist/orch/extensions.d.ts.map +1 -0
- package/dist/orch/extensions.js +80 -0
- package/dist/orch/extensions.js.map +1 -0
- package/dist/orch/housekeeping-usage.d.ts +14 -0
- package/dist/orch/housekeeping-usage.d.ts.map +1 -0
- package/dist/orch/housekeeping-usage.js +27 -0
- package/dist/orch/housekeeping-usage.js.map +1 -0
- package/dist/orch/housekeeping.d.ts +89 -0
- package/dist/orch/housekeeping.d.ts.map +1 -0
- package/dist/orch/housekeeping.js +281 -0
- package/dist/orch/housekeeping.js.map +1 -0
- package/dist/orch/inherited-tools.d.ts +18 -0
- package/dist/orch/inherited-tools.d.ts.map +1 -0
- package/dist/orch/inherited-tools.js +71 -0
- package/dist/orch/inherited-tools.js.map +1 -0
- package/dist/orch/mailbox.d.ts +59 -0
- package/dist/orch/mailbox.d.ts.map +1 -0
- package/dist/orch/mailbox.js +196 -0
- package/dist/orch/mailbox.js.map +1 -0
- package/dist/orch/manager.d.ts +82 -0
- package/dist/orch/manager.d.ts.map +1 -0
- package/dist/orch/manager.js +1010 -0
- package/dist/orch/manager.js.map +1 -0
- package/dist/orch/paths.d.ts +7 -0
- package/dist/orch/paths.d.ts.map +1 -0
- package/dist/orch/paths.js +73 -0
- package/dist/orch/paths.js.map +1 -0
- package/dist/orch/prompt.d.ts +7 -0
- package/dist/orch/prompt.d.ts.map +1 -0
- package/dist/orch/prompt.js +34 -0
- package/dist/orch/prompt.js.map +1 -0
- package/dist/orch/registry.d.ts +49 -0
- package/dist/orch/registry.d.ts.map +1 -0
- package/dist/orch/registry.js +134 -0
- package/dist/orch/registry.js.map +1 -0
- package/dist/orch/runtime.d.ts +11 -0
- package/dist/orch/runtime.d.ts.map +1 -0
- package/dist/orch/runtime.js +882 -0
- package/dist/orch/runtime.js.map +1 -0
- package/dist/orch/tools.d.ts +6 -0
- package/dist/orch/tools.d.ts.map +1 -0
- package/dist/orch/tools.js +114 -0
- package/dist/orch/tools.js.map +1 -0
- package/dist/orch/transcript.d.ts +28 -0
- package/dist/orch/transcript.d.ts.map +1 -0
- package/dist/orch/transcript.js +176 -0
- package/dist/orch/transcript.js.map +1 -0
- package/dist/prefs/agent-import.d.ts +37 -0
- package/dist/prefs/agent-import.d.ts.map +1 -0
- package/dist/prefs/agent-import.js +196 -0
- package/dist/prefs/agent-import.js.map +1 -0
- package/dist/prefs/config.d.ts +108 -0
- package/dist/prefs/config.d.ts.map +1 -0
- package/dist/prefs/config.js +926 -0
- package/dist/prefs/config.js.map +1 -0
- package/dist/prefs/import-discovery.d.ts +28 -0
- package/dist/prefs/import-discovery.d.ts.map +1 -0
- package/dist/prefs/import-discovery.js +562 -0
- package/dist/prefs/import-discovery.js.map +1 -0
- package/dist/prefs/import-instructions.d.ts +3 -0
- package/dist/prefs/import-instructions.d.ts.map +1 -0
- package/{src/prefs/import-instructions.ts → dist/prefs/import-instructions.js} +1 -0
- package/dist/prefs/import-instructions.js.map +1 -0
- package/dist/prefs/models.d.ts +24 -0
- package/dist/prefs/models.d.ts.map +1 -0
- package/dist/prefs/models.js +57 -0
- package/dist/prefs/models.js.map +1 -0
- package/dist/prefs/settings.d.ts +89 -0
- package/dist/prefs/settings.d.ts.map +1 -0
- package/dist/prefs/settings.js +505 -0
- package/dist/prefs/settings.js.map +1 -0
- package/dist/types.d.ts +293 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/agent-loader.d.ts +21 -0
- package/dist/ui/agent-loader.d.ts.map +1 -0
- package/dist/ui/agent-loader.js +73 -0
- package/dist/ui/agent-loader.js.map +1 -0
- package/dist/ui/agent-navigation-editor.d.ts +46 -0
- package/dist/ui/agent-navigation-editor.d.ts.map +1 -0
- package/dist/ui/agent-navigation-editor.js +189 -0
- package/dist/ui/agent-navigation-editor.js.map +1 -0
- package/dist/ui/cost-footer.d.ts +37 -0
- package/dist/ui/cost-footer.d.ts.map +1 -0
- package/dist/ui/cost-footer.js +215 -0
- package/dist/ui/cost-footer.js.map +1 -0
- package/dist/ui/dialog.d.ts +135 -0
- package/dist/ui/dialog.d.ts.map +1 -0
- package/dist/ui/dialog.js +533 -0
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/import-picker.d.ts +38 -0
- package/dist/ui/import-picker.d.ts.map +1 -0
- package/dist/ui/import-picker.js +211 -0
- package/dist/ui/import-picker.js.map +1 -0
- package/dist/ui/live-agent-view.d.ts +82 -0
- package/dist/ui/live-agent-view.d.ts.map +1 -0
- package/dist/ui/live-agent-view.js +546 -0
- package/dist/ui/live-agent-view.js.map +1 -0
- package/dist/ui/model-picker.d.ts +109 -0
- package/dist/ui/model-picker.d.ts.map +1 -0
- package/dist/ui/model-picker.js +549 -0
- package/dist/ui/model-picker.js.map +1 -0
- package/dist/ui/settings-ui.d.ts +17 -0
- package/dist/ui/settings-ui.d.ts.map +1 -0
- package/dist/ui/settings-ui.js +679 -0
- package/dist/ui/settings-ui.js.map +1 -0
- package/dist/ui/status-ui.d.ts +67 -0
- package/dist/ui/status-ui.d.ts.map +1 -0
- package/dist/ui/status-ui.js +487 -0
- package/dist/ui/status-ui.js.map +1 -0
- package/dist/ui/thread-tree.d.ts +22 -0
- package/dist/ui/thread-tree.d.ts.map +1 -0
- package/dist/ui/thread-tree.js +153 -0
- package/dist/ui/thread-tree.js.map +1 -0
- package/dist/ui/tool-picker.d.ts +46 -0
- package/dist/ui/tool-picker.d.ts.map +1 -0
- package/dist/ui/tool-picker.js +334 -0
- package/dist/ui/tool-picker.js.map +1 -0
- package/dist/ui/transcript-tool.d.ts +2 -0
- package/dist/ui/transcript-tool.d.ts.map +1 -0
- package/dist/ui/transcript-tool.js +100 -0
- package/dist/ui/transcript-tool.js.map +1 -0
- package/dist/ui/ui.d.ts +41 -0
- package/dist/ui/ui.d.ts.map +1 -0
- package/dist/ui/ui.js +1047 -0
- package/dist/ui/ui.js.map +1 -0
- package/docs/development.md +2 -1
- package/package.json +16 -4
- package/src/index.ts +0 -920
- package/src/orch/checklist-integration.ts +0 -230
- package/src/orch/context-entries.ts +0 -15
- package/src/orch/cost-ledger.ts +0 -56
- package/src/orch/diagnostics.ts +0 -95
- package/src/orch/extensions.ts +0 -83
- package/src/orch/housekeeping-usage.ts +0 -47
- package/src/orch/housekeeping.ts +0 -348
- package/src/orch/inherited-tools.ts +0 -84
- package/src/orch/mailbox.ts +0 -261
- package/src/orch/manager.ts +0 -1084
- package/src/orch/paths.ts +0 -73
- package/src/orch/prompt.ts +0 -39
- package/src/orch/registry.ts +0 -168
- package/src/orch/runtime.ts +0 -1041
- package/src/orch/tools.ts +0 -190
- package/src/orch/transcript.ts +0 -186
- package/src/prefs/agent-import.ts +0 -245
- package/src/prefs/config.ts +0 -1017
- package/src/prefs/import-discovery.ts +0 -643
- package/src/prefs/models.ts +0 -74
- package/src/prefs/settings.ts +0 -614
- package/src/types.ts +0 -271
- package/src/ui/agent-loader.ts +0 -98
- package/src/ui/agent-navigation-editor.ts +0 -233
- package/src/ui/cost-footer.ts +0 -230
- package/src/ui/dialog.ts +0 -678
- package/src/ui/import-picker.ts +0 -231
- package/src/ui/live-agent-view.ts +0 -600
- package/src/ui/model-picker.ts +0 -701
- package/src/ui/settings-ui.ts +0 -830
- package/src/ui/status-ui.ts +0 -628
- package/src/ui/thread-tree.ts +0 -173
- package/src/ui/tool-picker.ts +0 -398
- package/src/ui/transcript-tool.ts +0 -142
- package/src/ui/ui.ts +0 -1407
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import { CURSOR_MARKER, Editor, getKeybindings, Input, Key, matchesKey, stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
2
|
+
export const DIALOG_OPTIONS = {
|
|
3
|
+
overlay: true,
|
|
4
|
+
overlayOptions: {
|
|
5
|
+
anchor: "center",
|
|
6
|
+
width: "90%",
|
|
7
|
+
maxHeight: "90%",
|
|
8
|
+
margin: 1,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export function dialogText(text) {
|
|
12
|
+
return stripTerminalSequences(text).replace(/[\x00-\x1f\x7f-\x9f]/g, " ");
|
|
13
|
+
}
|
|
14
|
+
/** Match Pi's overlay height calculation; maxHeight alone would clip the bottom border. */
|
|
15
|
+
export function dialogHeight(host) {
|
|
16
|
+
const rows = host.terminal?.rows ?? 24;
|
|
17
|
+
return Math.max(1, Math.min(rows - 2, Math.floor(rows * 0.9)));
|
|
18
|
+
}
|
|
19
|
+
export function frameDialog(theme, width, height, title, body, footer) {
|
|
20
|
+
if (width <= 0 || height <= 0)
|
|
21
|
+
return [];
|
|
22
|
+
const fit = (text, columns) => {
|
|
23
|
+
const clipped = truncateToWidth(text, Math.max(0, columns), "", true);
|
|
24
|
+
return clipped + " ".repeat(Math.max(0, columns - visibleWidth(clipped)));
|
|
25
|
+
};
|
|
26
|
+
if (width < 4 || height < 4)
|
|
27
|
+
return [fit(theme.fg("muted", dialogText(title)), width)];
|
|
28
|
+
const inner = width - 2;
|
|
29
|
+
const line = (text) => theme.fg("border", "│") + fit(text, inner) + theme.fg("border", "│");
|
|
30
|
+
const heading = truncateToWidth(` ${dialogText(title)} `, inner, "");
|
|
31
|
+
const top = theme.fg("border", "╭" + heading + "─".repeat(Math.max(0, inner - visibleWidth(heading))) + "╮");
|
|
32
|
+
// Pad to the full frame so centered overlays keep the same bounds between views.
|
|
33
|
+
const budget = height - 4;
|
|
34
|
+
const padded = body.slice(0, budget);
|
|
35
|
+
while (padded.length < budget)
|
|
36
|
+
padded.push("");
|
|
37
|
+
const content = padded.map(line);
|
|
38
|
+
return [
|
|
39
|
+
top,
|
|
40
|
+
...content,
|
|
41
|
+
theme.fg("border", "├" + "─".repeat(inner) + "┤"),
|
|
42
|
+
line(theme.fg("dim", dialogText(footer))),
|
|
43
|
+
theme.fg("border", "╰" + "─".repeat(inner) + "╯"),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
/** A multiline editor inside the same bounded shell as the surrounding form. */
|
|
47
|
+
export class DialogEditor {
|
|
48
|
+
host;
|
|
49
|
+
theme;
|
|
50
|
+
title;
|
|
51
|
+
prefill;
|
|
52
|
+
done;
|
|
53
|
+
editor;
|
|
54
|
+
initialText;
|
|
55
|
+
constructor(host, theme, title, prefill, done) {
|
|
56
|
+
this.host = host;
|
|
57
|
+
this.theme = theme;
|
|
58
|
+
this.title = title;
|
|
59
|
+
this.prefill = prefill;
|
|
60
|
+
this.done = done;
|
|
61
|
+
this.editor = new Editor(host, {
|
|
62
|
+
borderColor: (text) => theme.fg("border", text),
|
|
63
|
+
selectList: {
|
|
64
|
+
selectedPrefix: (text) => theme.fg("accent", text),
|
|
65
|
+
selectedText: (text) => theme.fg("accent", text),
|
|
66
|
+
description: (text) => theme.fg("muted", text),
|
|
67
|
+
scrollInfo: (text) => theme.fg("dim", text),
|
|
68
|
+
noMatch: (text) => theme.fg("warning", text),
|
|
69
|
+
},
|
|
70
|
+
}, { paddingX: 0 });
|
|
71
|
+
this.editor.setText(stripTerminalSequences(prefill)
|
|
72
|
+
.replace(/\r\n?/g, "\n")
|
|
73
|
+
.replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, ""));
|
|
74
|
+
this.initialText = this.editor.getText();
|
|
75
|
+
this.editor.disableSubmit = true;
|
|
76
|
+
}
|
|
77
|
+
getEditor() {
|
|
78
|
+
return this.editor;
|
|
79
|
+
}
|
|
80
|
+
get focused() {
|
|
81
|
+
return this.editor.focused;
|
|
82
|
+
}
|
|
83
|
+
set focused(value) {
|
|
84
|
+
this.editor.focused = value;
|
|
85
|
+
}
|
|
86
|
+
handleInput(data) {
|
|
87
|
+
if (matchesKey(data, Key.escape))
|
|
88
|
+
return this.done(undefined);
|
|
89
|
+
if (matchesKey(data, Key.ctrl("s"))) {
|
|
90
|
+
const value = this.editor.getText();
|
|
91
|
+
return this.done(value === this.initialText ? this.prefill : value);
|
|
92
|
+
}
|
|
93
|
+
this.editor.handleInput(data);
|
|
94
|
+
this.host.requestRender();
|
|
95
|
+
}
|
|
96
|
+
invalidate() {
|
|
97
|
+
this.editor.invalidate();
|
|
98
|
+
}
|
|
99
|
+
render(width) {
|
|
100
|
+
const height = dialogHeight(this.host);
|
|
101
|
+
const rows = this.editor.render(Math.max(1, width - 4)).slice(1, -1);
|
|
102
|
+
const budget = Math.max(0, height - 4);
|
|
103
|
+
const cursor = rows.findIndex((line) => line.includes(CURSOR_MARKER));
|
|
104
|
+
const start = cursor >= budget ? cursor - budget + 1 : 0;
|
|
105
|
+
return frameDialog(this.theme, width, height, this.title, rows.slice(start, start + budget).map((line) => ` ${line}`), "Enter newline · Ctrl+S apply · Esc cancel");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function dialogEditor(ctx, title, prefill) {
|
|
109
|
+
return ctx.ui.custom((host, theme, _keys, done) => new DialogEditor(host, theme, title, prefill, done), DIALOG_OPTIONS);
|
|
110
|
+
}
|
|
111
|
+
/** Bounded menu with an optional indicator column, shared by settings and agent definitions. */
|
|
112
|
+
export class DialogMenu {
|
|
113
|
+
host;
|
|
114
|
+
theme;
|
|
115
|
+
title;
|
|
116
|
+
rows;
|
|
117
|
+
done;
|
|
118
|
+
footer;
|
|
119
|
+
saveId;
|
|
120
|
+
renderLegend;
|
|
121
|
+
spaceSelect;
|
|
122
|
+
selected = 0;
|
|
123
|
+
viewport = 1;
|
|
124
|
+
constructor(host, theme, title, rows, done, selectedId, footer = "↑↓ navigate · Enter select · Esc close", saveId, renderLegend, spaceSelect = false) {
|
|
125
|
+
this.host = host;
|
|
126
|
+
this.theme = theme;
|
|
127
|
+
this.title = title;
|
|
128
|
+
this.rows = rows;
|
|
129
|
+
this.done = done;
|
|
130
|
+
this.footer = footer;
|
|
131
|
+
this.saveId = saveId;
|
|
132
|
+
this.renderLegend = renderLegend;
|
|
133
|
+
this.spaceSelect = spaceSelect;
|
|
134
|
+
const index = rows.findIndex((row) => row.id === selectedId);
|
|
135
|
+
if (index >= 0)
|
|
136
|
+
this.selected = index;
|
|
137
|
+
}
|
|
138
|
+
getSelectedId() {
|
|
139
|
+
return this.rows[this.selected]?.id;
|
|
140
|
+
}
|
|
141
|
+
handleInput(data) {
|
|
142
|
+
const keys = getKeybindings();
|
|
143
|
+
if (keys.matches(data, "tui.select.cancel"))
|
|
144
|
+
return this.done(undefined);
|
|
145
|
+
if (keys.matches(data, "tui.select.confirm") ||
|
|
146
|
+
(this.spaceSelect && matchesKey(data, Key.space)))
|
|
147
|
+
return this.done(this.getSelectedId());
|
|
148
|
+
if (this.saveId && matchesKey(data, Key.ctrl("s")))
|
|
149
|
+
return this.done(this.saveId);
|
|
150
|
+
let offset = 0;
|
|
151
|
+
if (keys.matches(data, "tui.select.up"))
|
|
152
|
+
offset = -1;
|
|
153
|
+
else if (keys.matches(data, "tui.select.down") || matchesKey(data, Key.tab))
|
|
154
|
+
offset = 1;
|
|
155
|
+
else if (matchesKey(data, Key.pageUp))
|
|
156
|
+
offset = -this.viewport;
|
|
157
|
+
else if (matchesKey(data, Key.pageDown))
|
|
158
|
+
offset = this.viewport;
|
|
159
|
+
else if (matchesKey(data, Key.home))
|
|
160
|
+
this.selected = 0;
|
|
161
|
+
else if (matchesKey(data, Key.end))
|
|
162
|
+
this.selected = Math.max(0, this.rows.length - 1);
|
|
163
|
+
this.selected = Math.max(0, Math.min(this.rows.length - 1, this.selected + offset));
|
|
164
|
+
this.host.requestRender();
|
|
165
|
+
}
|
|
166
|
+
invalidate() { }
|
|
167
|
+
render(width) {
|
|
168
|
+
const height = dialogHeight(this.host);
|
|
169
|
+
const inner = Math.max(0, width - 4);
|
|
170
|
+
const legend = this.renderLegend
|
|
171
|
+
? wrapTextWithAnsi(this.renderLegend(this.theme), Math.max(1, inner - 1))
|
|
172
|
+
.slice(0, Math.max(0, height - 8))
|
|
173
|
+
.map((line) => ` ${line}`)
|
|
174
|
+
: [];
|
|
175
|
+
const help = (this.rows[this.selected]?.help ?? "")
|
|
176
|
+
.split(/\r\n?|\n/)
|
|
177
|
+
.flatMap((line) => wrapTextWithAnsi(dialogText(line), Math.max(1, inner - 1)))
|
|
178
|
+
.slice(0, Math.max(1, height - 7 - legend.length));
|
|
179
|
+
const rowHeight = this.rows.some((row) => row.valueDetail !== undefined) ? 2 : 1;
|
|
180
|
+
this.viewport = Math.max(1, Math.floor((height - 6 - help.length - legend.length) / rowHeight));
|
|
181
|
+
const start = Math.max(0, Math.min(this.selected - this.viewport + 1, this.rows.length - this.viewport));
|
|
182
|
+
const hasIndicators = this.rows.some((row) => row.renderIndicators);
|
|
183
|
+
const indicatorWidth = 3;
|
|
184
|
+
const labelWidth = Math.min(28, Math.max(8, Math.floor(inner * 0.35)),
|
|
185
|
+
// Reserve prefix, separators, indicators and at least one value cell at narrow widths.
|
|
186
|
+
hasIndicators ? Math.max(0, inner - 2 - 6 - indicatorWidth - 1) : Infinity);
|
|
187
|
+
const body = [
|
|
188
|
+
this.theme.fg("dim", ` ${this.rows.length ? this.selected + 1 : 0}/${this.rows.length} · Field / ${hasIndicators ? "Saved / " : ""}Value`),
|
|
189
|
+
...this.rows.slice(start, start + this.viewport).flatMap((row, i) => {
|
|
190
|
+
const selected = start + i === this.selected;
|
|
191
|
+
const color = (text) => (selected ? this.theme.fg("accent", text) : text);
|
|
192
|
+
const plainLabel = dialogText(row.label);
|
|
193
|
+
const label = truncateToWidth(row.renderLabel ? row.renderLabel(plainLabel, this.theme) : plainLabel, labelWidth, "", true);
|
|
194
|
+
const padding = " ".repeat(Math.max(0, labelWidth - visibleWidth(label)));
|
|
195
|
+
const indicators = truncateToWidth(row.renderIndicators?.(this.theme) ?? "", indicatorWidth, "", true);
|
|
196
|
+
const indicatorPadding = " ".repeat(Math.max(0, indicatorWidth - visibleWidth(indicators)));
|
|
197
|
+
const value = dialogText(row.value ?? "");
|
|
198
|
+
const primary = color(`${selected ? "›" : " "} `) +
|
|
199
|
+
(row.renderLabel ? label : color(label)) +
|
|
200
|
+
color(`${padding} │ `) +
|
|
201
|
+
(hasIndicators ? indicators + color(`${indicatorPadding} │ `) : "") +
|
|
202
|
+
(row.valueColor ? this.theme.fg(row.valueColor, value) : color(value));
|
|
203
|
+
if (rowHeight === 1)
|
|
204
|
+
return [primary];
|
|
205
|
+
const valueStart = 2 + labelWidth + 3 + (hasIndicators ? indicatorWidth + 3 : 0);
|
|
206
|
+
const detail = truncateToWidth(dialogText(row.valueDetail ?? ""), Math.max(0, inner - valueStart));
|
|
207
|
+
return [primary, " ".repeat(valueStart) + this.theme.fg("muted", detail)];
|
|
208
|
+
}),
|
|
209
|
+
"",
|
|
210
|
+
...help.map((line) => this.theme.fg("muted", ` ${line}`)),
|
|
211
|
+
];
|
|
212
|
+
if (legend.length) {
|
|
213
|
+
const budget = Math.max(0, height - 4 - legend.length);
|
|
214
|
+
body.length = Math.min(body.length, budget);
|
|
215
|
+
while (body.length < budget)
|
|
216
|
+
body.push("");
|
|
217
|
+
body.push(...legend);
|
|
218
|
+
}
|
|
219
|
+
return frameDialog(this.theme, width, height, this.title, body, this.footer);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
export function canOpenDialog(ctx) {
|
|
223
|
+
if (!ctx.hasUI)
|
|
224
|
+
return false;
|
|
225
|
+
if (ctx.mode && ctx.mode !== "tui") {
|
|
226
|
+
ctx.ui.notify("Agents dialogs require interactive TUI mode.", "warning");
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
export async function dialogMenu(ctx, title, rows, options = {}) {
|
|
232
|
+
return ctx.ui.custom((host, theme, _keys, done) => new DialogMenu(host, theme, title, rows, done, options.selectedId, options.footer, options.saveId, options.renderLegend, options.spaceSelect), DIALOG_OPTIONS);
|
|
233
|
+
}
|
|
234
|
+
export async function dialogInput(ctx, title, initial, help) {
|
|
235
|
+
return ctx.ui.custom((host, theme, _keys, done) => {
|
|
236
|
+
const input = new Input();
|
|
237
|
+
input.setValue(dialogText(initial));
|
|
238
|
+
input.onSubmit = done;
|
|
239
|
+
input.onEscape = () => done(undefined);
|
|
240
|
+
return {
|
|
241
|
+
get focused() {
|
|
242
|
+
return input.focused;
|
|
243
|
+
},
|
|
244
|
+
set focused(value) {
|
|
245
|
+
input.focused = value;
|
|
246
|
+
},
|
|
247
|
+
handleInput: (data) => {
|
|
248
|
+
input.handleInput(data);
|
|
249
|
+
host.requestRender();
|
|
250
|
+
},
|
|
251
|
+
invalidate: () => input.invalidate(),
|
|
252
|
+
render: (width) => frameDialog(theme, width, dialogHeight(host), title, [
|
|
253
|
+
"",
|
|
254
|
+
...input.render(Math.max(1, width - 4)).map((line) => ` ${line}`),
|
|
255
|
+
"",
|
|
256
|
+
...help
|
|
257
|
+
.split(/\r\n?|\n/)
|
|
258
|
+
.flatMap((line) => wrapTextWithAnsi(dialogText(line), Math.max(1, width - 5)))
|
|
259
|
+
.map((line) => theme.fg("muted", ` ${line}`)),
|
|
260
|
+
], "Enter apply · Esc cancel"),
|
|
261
|
+
};
|
|
262
|
+
}, DIALOG_OPTIONS);
|
|
263
|
+
}
|
|
264
|
+
const dialogScopes = new WeakSet();
|
|
265
|
+
function isPromise(value) {
|
|
266
|
+
return (typeof value === "object" && value !== null && typeof value.then === "function");
|
|
267
|
+
}
|
|
268
|
+
function safeDispose(component) {
|
|
269
|
+
if (!component?.dispose)
|
|
270
|
+
return;
|
|
271
|
+
try {
|
|
272
|
+
component.dispose();
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
// A view that fails to dispose must not reject the session promise.
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/** One overlay for a multi-step dialog. Child views swap without closing it. */
|
|
279
|
+
export class DialogSession {
|
|
280
|
+
host;
|
|
281
|
+
theme;
|
|
282
|
+
keys;
|
|
283
|
+
child;
|
|
284
|
+
focusedState = false;
|
|
285
|
+
inputLocked = true;
|
|
286
|
+
closed = false;
|
|
287
|
+
disposed = false;
|
|
288
|
+
generation = 0;
|
|
289
|
+
pending;
|
|
290
|
+
outerDone;
|
|
291
|
+
constructor(host, theme, keys, done) {
|
|
292
|
+
this.host = host;
|
|
293
|
+
this.theme = theme;
|
|
294
|
+
this.keys = keys;
|
|
295
|
+
this.outerDone = done;
|
|
296
|
+
}
|
|
297
|
+
/** Current or last held child. Tests drive the active editor through this. */
|
|
298
|
+
getComponent() {
|
|
299
|
+
return this.child;
|
|
300
|
+
}
|
|
301
|
+
restoreFocus() {
|
|
302
|
+
if (this.closed)
|
|
303
|
+
return;
|
|
304
|
+
// Non-overlay custom views restore Pi's normal editor when they finish.
|
|
305
|
+
this.host.setFocus(this);
|
|
306
|
+
this.host.requestRender();
|
|
307
|
+
}
|
|
308
|
+
get focused() {
|
|
309
|
+
return this.focusedState;
|
|
310
|
+
}
|
|
311
|
+
set focused(value) {
|
|
312
|
+
this.focusedState = value;
|
|
313
|
+
this.forwardFocus();
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Mount an overlay factory into this session. The returned promise settles
|
|
317
|
+
* from the per-view done callback and does not complete the outer overlay.
|
|
318
|
+
*/
|
|
319
|
+
mount(factory) {
|
|
320
|
+
if (this.closed)
|
|
321
|
+
return Promise.resolve(undefined);
|
|
322
|
+
const generation = ++this.generation;
|
|
323
|
+
this.inputLocked = true;
|
|
324
|
+
this.resolvePending();
|
|
325
|
+
return new Promise((resolve, reject) => {
|
|
326
|
+
let settled = false;
|
|
327
|
+
const resolveOnce = (value) => {
|
|
328
|
+
if (settled)
|
|
329
|
+
return;
|
|
330
|
+
settled = true;
|
|
331
|
+
if (this.pending?.generation === generation)
|
|
332
|
+
this.pending.settled = true;
|
|
333
|
+
resolve(value);
|
|
334
|
+
};
|
|
335
|
+
const rejectOnce = (error) => {
|
|
336
|
+
if (settled)
|
|
337
|
+
return;
|
|
338
|
+
settled = true;
|
|
339
|
+
this.inputLocked = true;
|
|
340
|
+
if (this.pending?.generation === generation)
|
|
341
|
+
this.pending.settled = true;
|
|
342
|
+
reject(error);
|
|
343
|
+
};
|
|
344
|
+
this.pending = {
|
|
345
|
+
generation,
|
|
346
|
+
settled: false,
|
|
347
|
+
resolve: (value) => resolveOnce(value),
|
|
348
|
+
};
|
|
349
|
+
const finish = (value) => {
|
|
350
|
+
if (this.closed || generation !== this.generation)
|
|
351
|
+
return;
|
|
352
|
+
this.inputLocked = true;
|
|
353
|
+
resolveOnce(value);
|
|
354
|
+
};
|
|
355
|
+
const adopt = (component) => {
|
|
356
|
+
try {
|
|
357
|
+
this.install(generation, component);
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
rejectOnce(error);
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
try {
|
|
364
|
+
const produced = factory(this.host, this.theme, this.keys, finish);
|
|
365
|
+
if (isPromise(produced)) {
|
|
366
|
+
void produced.then((component) => adopt(component), (error) => {
|
|
367
|
+
if (settled || this.closed || generation !== this.generation)
|
|
368
|
+
return;
|
|
369
|
+
rejectOnce(error);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
adopt(produced);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
// done() may already have resolved; don't reject a settled view or leave a throw unhandled.
|
|
378
|
+
rejectOnce(error);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
handleInput(data) {
|
|
383
|
+
if (this.closed || this.inputLocked)
|
|
384
|
+
return;
|
|
385
|
+
this.child?.handleInput?.(data);
|
|
386
|
+
}
|
|
387
|
+
/** Fullscreen mouse events reach the overlay, so forward them to the active child view. */
|
|
388
|
+
handleMouse(event) {
|
|
389
|
+
if (this.closed || this.inputLocked)
|
|
390
|
+
return undefined;
|
|
391
|
+
return this.child?.handleMouse?.(event);
|
|
392
|
+
}
|
|
393
|
+
invalidate() {
|
|
394
|
+
this.child?.invalidate();
|
|
395
|
+
}
|
|
396
|
+
render(width) {
|
|
397
|
+
return this.child?.render(width) ?? [];
|
|
398
|
+
}
|
|
399
|
+
dispose() {
|
|
400
|
+
if (this.disposed)
|
|
401
|
+
return;
|
|
402
|
+
this.disposed = true;
|
|
403
|
+
this.closed = true;
|
|
404
|
+
this.inputLocked = true;
|
|
405
|
+
this.resolvePending();
|
|
406
|
+
const child = this.child;
|
|
407
|
+
this.child = undefined;
|
|
408
|
+
safeDispose(child);
|
|
409
|
+
}
|
|
410
|
+
/** Complete the outer overlay once. Safe to call after the host already closed. */
|
|
411
|
+
close() {
|
|
412
|
+
if (this.closed)
|
|
413
|
+
return;
|
|
414
|
+
this.closed = true;
|
|
415
|
+
this.inputLocked = true;
|
|
416
|
+
this.resolvePending();
|
|
417
|
+
const done = this.outerDone;
|
|
418
|
+
this.outerDone = undefined;
|
|
419
|
+
try {
|
|
420
|
+
done?.();
|
|
421
|
+
}
|
|
422
|
+
finally {
|
|
423
|
+
this.dispose();
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
install(generation, component) {
|
|
427
|
+
if (this.closed || generation !== this.generation) {
|
|
428
|
+
safeDispose(component);
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
this.replaceChild(component);
|
|
432
|
+
this.inputLocked = this.pending?.generation === generation ? this.pending.settled : true;
|
|
433
|
+
this.host.requestRender();
|
|
434
|
+
}
|
|
435
|
+
replaceChild(next) {
|
|
436
|
+
const previous = this.child;
|
|
437
|
+
this.child = next;
|
|
438
|
+
this.forwardFocus();
|
|
439
|
+
if (!previous || previous === next)
|
|
440
|
+
return;
|
|
441
|
+
if ("focused" in previous)
|
|
442
|
+
previous.focused = false;
|
|
443
|
+
safeDispose(previous);
|
|
444
|
+
}
|
|
445
|
+
forwardFocus() {
|
|
446
|
+
const child = this.child;
|
|
447
|
+
if (!child || !("focused" in child))
|
|
448
|
+
return;
|
|
449
|
+
// Read the setter's latest value; the first view can mount before showOverlay focuses us.
|
|
450
|
+
child.focused = this.focused;
|
|
451
|
+
}
|
|
452
|
+
resolvePending() {
|
|
453
|
+
const pending = this.pending;
|
|
454
|
+
if (!pending || pending.settled)
|
|
455
|
+
return;
|
|
456
|
+
pending.settled = true;
|
|
457
|
+
pending.resolve(undefined);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
export function scopeDialogContext(ctx, session) {
|
|
461
|
+
const source = ctx.ui;
|
|
462
|
+
const originalCustom = source.custom.bind(source);
|
|
463
|
+
const ui = Object.create(source);
|
|
464
|
+
ui.custom = ((factory, options) => {
|
|
465
|
+
if (options?.overlay)
|
|
466
|
+
return session.mount(factory);
|
|
467
|
+
return originalCustom(factory, options).finally(() => session.restoreFocus());
|
|
468
|
+
});
|
|
469
|
+
// Pi exposes ctx.ui as a getter; assignment cannot shadow an inherited accessor.
|
|
470
|
+
// Define an own property while keeping the remaining context getters live.
|
|
471
|
+
return Object.create(ctx, {
|
|
472
|
+
ui: { value: ui, writable: true, enumerable: true, configurable: true },
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Run a dialog workflow inside one ctx.ui.custom overlay.
|
|
477
|
+
* Nested calls on the scoped context reuse that overlay instead of opening another.
|
|
478
|
+
*/
|
|
479
|
+
export async function withDialogSession(ctx, run) {
|
|
480
|
+
if (dialogScopes.has(ctx)) {
|
|
481
|
+
await run(ctx);
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
let failure;
|
|
485
|
+
let failed = false;
|
|
486
|
+
let session;
|
|
487
|
+
try {
|
|
488
|
+
await ctx.ui.custom((host, theme, keys, done) => {
|
|
489
|
+
session = new DialogSession(host, theme, keys, done);
|
|
490
|
+
const scoped = scopeDialogContext(ctx, session);
|
|
491
|
+
dialogScopes.add(scoped);
|
|
492
|
+
// Pi mounts the returned component in a Promise continuation. Defer the
|
|
493
|
+
// workflow so even an immediate return/throw closes after that mount.
|
|
494
|
+
const task = Promise.resolve().then(() => run(scoped));
|
|
495
|
+
void task.then(() => {
|
|
496
|
+
try {
|
|
497
|
+
session?.close();
|
|
498
|
+
}
|
|
499
|
+
catch (error) {
|
|
500
|
+
if (!failed) {
|
|
501
|
+
failed = true;
|
|
502
|
+
failure = error;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}, (error) => {
|
|
506
|
+
failed = true;
|
|
507
|
+
failure = error;
|
|
508
|
+
try {
|
|
509
|
+
session?.close();
|
|
510
|
+
}
|
|
511
|
+
catch (closeError) {
|
|
512
|
+
failure ??= closeError;
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
return session;
|
|
516
|
+
}, DIALOG_OPTIONS);
|
|
517
|
+
}
|
|
518
|
+
catch (error) {
|
|
519
|
+
try {
|
|
520
|
+
session?.close();
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
// The original custom rejection is the one that must propagate.
|
|
524
|
+
}
|
|
525
|
+
if (!failed) {
|
|
526
|
+
failed = true;
|
|
527
|
+
failure = error;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
if (failed)
|
|
531
|
+
throw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AC;oBACpB,OAAO,KAAK,UAAU,CAAC;gBACzB,CAAC;YACH,CAAC,CACF,CAAC;YACF,OAAO,OAAO,CAAC;QACjB,CAAC,EAAE,cAAc,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC;YACH,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,gEAAgE;QAClE,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,CAAC;YACd,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC;IACH,CAAC;IACD,IAAI,MAAM;QAAE,MAAM,OAAO,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ExtensionContext, Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { type DialogHost } from "./dialog.ts";
|
|
3
|
+
export interface ImportPickerItem {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
detail: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Checkbox dialog for choosing external agents to migrate.
|
|
10
|
+
* Selection only — the caller imports; this does not read or write agent files.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ImportPicker {
|
|
13
|
+
private host;
|
|
14
|
+
private theme;
|
|
15
|
+
private readonly items;
|
|
16
|
+
private done;
|
|
17
|
+
private cursor;
|
|
18
|
+
private viewport;
|
|
19
|
+
private readonly checked;
|
|
20
|
+
constructor(host: DialogHost, theme: Theme, items: readonly ImportPickerItem[], done: (ids: string[] | undefined) => void);
|
|
21
|
+
/** Selected ids in source order. Empty until the user toggles a row. */
|
|
22
|
+
getSelectedIds(): string[];
|
|
23
|
+
getCursorIndex(): number;
|
|
24
|
+
invalidate(): void;
|
|
25
|
+
handleInput(data: string): void;
|
|
26
|
+
render(width: number): string[];
|
|
27
|
+
private countLine;
|
|
28
|
+
/** ▲/▼ counts when the checkbox list is scrolled. Omitted when every row fits. */
|
|
29
|
+
private scrollHint;
|
|
30
|
+
private row;
|
|
31
|
+
private windowStart;
|
|
32
|
+
private move;
|
|
33
|
+
private toggleCursor;
|
|
34
|
+
private toggleAll;
|
|
35
|
+
}
|
|
36
|
+
/** Open the import checkbox dialog. Returns ids, [] to skip, or undefined if cancelled. */
|
|
37
|
+
export declare function selectImportAgents(ctx: ExtensionContext, items: readonly ImportPickerItem[]): Promise<string[] | undefined>;
|
|
38
|
+
//# sourceMappingURL=import-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-picker.d.ts","sourceRoot":"","sources":["../../src/ui/import-picker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAS/E,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA+CD;;;GAGG;AACH,qBAAa,YAAY;IAMrB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,IAAI;IARd,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAGnC,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,KAAK,EACH,KAAK,EAAE,SAAS,gBAAgB,EAAE,EAC3C,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,KAAK,IAAI;IAGnD,wEAAwE;IACxE,cAAc,IAAI,MAAM,EAAE;IAW1B,cAAc,IAAI,MAAM;IAIxB,UAAU,IAAI,IAAI;IAElB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,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