@bismawy/pi-arnative 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +52 -67
- package/extensions/animations.ts +11 -26
- package/extensions/arnative.ts +253 -380
- package/extensions/autocompact.ts +5 -12
- package/extensions/budget.ts +87 -136
- package/extensions/footer.ts +27 -45
- package/extensions/render-cache.ts +5 -11
- package/extensions/section-headers.ts +4 -8
- package/extensions/todos.ts +83 -33
- package/extensions/tools.ts +13 -30
- package/extensions/usage-export.ts +3 -12
- package/lib/compat.ts +117 -17
- package/lib/list-picker.ts +5 -5
- package/lib/model-heal.ts +4 -8
- package/lib/preset-store.ts +63 -16
- package/lib/provider.ts +131 -17
- package/lib/spinner.ts +1 -1
- package/lib/usage-store.ts +11 -20
- package/package.json +1 -1
package/extensions/arnative.ts
CHANGED
|
@@ -26,9 +26,9 @@ import {
|
|
|
26
26
|
} from "./animations.ts";
|
|
27
27
|
import { CHATBOX_DIALOG_KEY, CHATBOX_PRESET_KEY, CHATBOX_PROMPT_KEY, EDIT_DIFF_KEY, FOOTER_COST_KEY, FOOTER_PRESET_KEY, HEADER_PRESET_KEY, BUDGET_DAY_KEY, BUDGET_ENFORCE_KEY, BUDGET_MONTH_KEY, PAYLOAD_LIMIT_KEY, RENDER_CACHE_KEY, ensureChoices } from "../lib/preset-store.ts";
|
|
28
28
|
import { EDIT_DIFF_CHOICES, activeEditDiff, setEditDiff, type EditDiffMode } from "./tools.ts";
|
|
29
|
-
import { CHATBOX_DIALOGS, CHATBOX_PRESETS, CHATBOX_PROMPTS, DEFAULT_CHATBOX_DIALOG, FOOTER_PRESETS, activeChatboxDialog, activeChatboxPreset, activeChatboxPrompt, activeFooterCost, activeFooterPreset, nextChatboxDialog, nextChatboxPrompt, setChatboxDialog, setChatboxPreset, setChatboxPrompt, setFooterCost, setFooterPreset, type ChatboxPreset
|
|
29
|
+
import { CHATBOX_DIALOGS, CHATBOX_PRESETS, CHATBOX_PROMPTS, DEFAULT_CHATBOX_DIALOG, FOOTER_PRESETS, activeChatboxDialog, activeChatboxPreset, activeChatboxPrompt, activeFooterCost, activeFooterPreset, nextChatboxDialog, nextChatboxPrompt, setChatboxDialog, setChatboxPreset, setChatboxPrompt, setFooterCost, setFooterPreset, type ChatboxPreset } from "./footer.ts";
|
|
30
30
|
import { activeBudgetDay, activeBudgetEnforce, activeBudgetMonth, openBudget } from "./budget.ts";
|
|
31
|
-
import { HEADER_PRESETS, activeHeaderPreset, setHeaderPreset
|
|
31
|
+
import { HEADER_PRESETS, activeHeaderPreset, setHeaderPreset } from "./section-headers.ts";
|
|
32
32
|
import {
|
|
33
33
|
AUTO_COMPACT_CHOICES,
|
|
34
34
|
AUTO_COMPACT_KEY,
|
|
@@ -54,7 +54,6 @@ import {
|
|
|
54
54
|
type RenderCacheChoice,
|
|
55
55
|
} from "./render-cache.ts";
|
|
56
56
|
import { INPUT_LEGEND, InputPicker, LIST_LEGEND_LIVE, LIST_LEGEND_MOVE, LIST_LEGEND_ROOT, ListPicker, nameRows, rowText, type ListPickerText, type ListRow } from "../lib/list-picker.ts";
|
|
57
|
-
import { BACK_KEY_LABEL } from "../lib/shortcuts.ts";
|
|
58
57
|
import { openProviders } from "../lib/provider.ts";
|
|
59
58
|
import { openUsage } from "./usage.ts";
|
|
60
59
|
import { SHORTCUT_OPEN_ARNATIVE } from "../lib/shortcuts.ts";
|
|
@@ -103,161 +102,201 @@ const THEMES_PICKER_TEXT: ListPickerText = {
|
|
|
103
102
|
legend: LIST_LEGEND_LIVE,
|
|
104
103
|
};
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) =>
|
|
130
|
-
new ListPicker(theme, nameRows(names), current, {
|
|
131
|
-
preview: (name) => {
|
|
132
|
-
const result = ctx.ui.setTheme(name);
|
|
133
|
-
if (!result.success) ctx.ui.notify(`[arnative] ${result.error ?? `failed to apply ${name}`}`, "error");
|
|
134
|
-
},
|
|
135
|
-
revert: () => {
|
|
136
|
-
if (current) ctx.ui.setTheme(current);
|
|
137
|
-
},
|
|
138
|
-
done: () => {
|
|
139
|
-
const applied = ctx.ui.theme.name;
|
|
140
|
-
announce(ctx.ui, applied ? `Theme: ${applied}.` : "Theme changed.");
|
|
141
|
-
done(false);
|
|
142
|
-
},
|
|
143
|
-
back: () => {
|
|
144
|
-
// Back drops the live preview, then reports upward so the menu reopens.
|
|
145
|
-
// Guarded like `revert`: `theme.name` is optional, and `setTheme(undefined)`
|
|
146
|
-
// would reach pi's unguarded loader path.
|
|
147
|
-
if (current && ctx.ui.theme.name !== current) ctx.ui.setTheme(current);
|
|
148
|
-
done(true);
|
|
149
|
-
},
|
|
150
|
-
requestRender: () => tui.requestRender(),
|
|
151
|
-
}, THEMES_PICKER_TEXT, true, ctx.thinkingLevel),
|
|
152
|
-
);
|
|
153
|
-
return goBack === true;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
/** The Footers screen copy. The legend states the cost switch's live value, like the
|
|
157
|
-
* Animations screen does for the gradient — a constant legend would advertise the value
|
|
158
|
-
* the screen opened with. */
|
|
159
|
-
const footersPickerText = (): ListPickerText => ({
|
|
160
|
-
title: screenTitle("Footers"),
|
|
161
|
-
description: "Selection applies live — custom footer or built-in.",
|
|
162
|
-
legend: `[↑↓] Preview [c] Cost ${activeFooterCost() ? "on" : "off"} [Enter] Select [Esc] Back`,
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const openFooters = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
166
|
-
const opened = activeFooterPreset();
|
|
105
|
+
interface LivePickerSpec<T extends string> {
|
|
106
|
+
choices: readonly T[];
|
|
107
|
+
rows?: ListRow[];
|
|
108
|
+
opened: T | undefined;
|
|
109
|
+
text: ListPickerText | (() => ListPickerText);
|
|
110
|
+
apply: (value: T) => void;
|
|
111
|
+
current: () => T | undefined;
|
|
112
|
+
label: string;
|
|
113
|
+
headlessLabels?: string[];
|
|
114
|
+
onSelectHeadless?: (value: T) => void;
|
|
115
|
+
onDone?: () => void;
|
|
116
|
+
onRevert?: () => void;
|
|
117
|
+
onBack?: () => void;
|
|
118
|
+
cancel?: boolean;
|
|
119
|
+
press?: (keyData: string, requestRender: () => void) => void;
|
|
120
|
+
toggleGradient?: (requestRender: () => void) => void;
|
|
121
|
+
summary?: (theme: { fg(c: string, t: string): string }) => string[];
|
|
122
|
+
note?: (label: string) => string | undefined;
|
|
123
|
+
tickMs?: number;
|
|
124
|
+
}
|
|
167
125
|
|
|
126
|
+
/** Shared live-preview picker: ↑↓ previews immediately, Enter keeps, Esc/← reverts. */
|
|
127
|
+
async function openLivePicker<T extends string>(ctx: ExtensionCommandContext, spec: LivePickerSpec<T>): Promise<boolean | void> {
|
|
128
|
+
const getText = typeof spec.text === "function" ? spec.text : () => spec.text as ListPickerText;
|
|
168
129
|
if (ctx.mode !== "tui") {
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
const pick = await ctx.ui.select(footersPickerText().title, labels);
|
|
130
|
+
const labels = spec.headlessLabels ?? markedLabels(spec.choices, spec.opened);
|
|
131
|
+
const pick = await ctx.ui.select(getText().title, labels);
|
|
172
132
|
if (pick === undefined) return;
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
133
|
+
const chosen = spec.choices[labels.indexOf(pick)]!;
|
|
134
|
+
if (spec.onSelectHeadless) spec.onSelectHeadless(chosen);
|
|
135
|
+
else {
|
|
136
|
+
spec.apply(chosen);
|
|
137
|
+
ctx.ui.notify(`[arnative] ${spec.label}: ${chosen}`, "info");
|
|
138
|
+
}
|
|
176
139
|
return;
|
|
177
140
|
}
|
|
178
|
-
|
|
179
141
|
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) =>
|
|
180
142
|
new ListPicker(
|
|
181
143
|
theme,
|
|
182
|
-
nameRows(
|
|
183
|
-
opened,
|
|
144
|
+
spec.rows ?? nameRows(spec.choices),
|
|
145
|
+
spec.opened,
|
|
184
146
|
{
|
|
185
|
-
preview: (name) =>
|
|
186
|
-
revert: () =>
|
|
147
|
+
preview: (name) => spec.apply(name as T),
|
|
148
|
+
revert: () => {
|
|
149
|
+
if (spec.onRevert) spec.onRevert();
|
|
150
|
+
else if (spec.opened !== undefined) spec.apply(spec.opened);
|
|
151
|
+
},
|
|
187
152
|
done: () => {
|
|
188
|
-
|
|
153
|
+
if (spec.onDone) spec.onDone();
|
|
154
|
+
else announce(ctx.ui, `${spec.label}: ${spec.current()}.`);
|
|
189
155
|
done(false);
|
|
190
156
|
},
|
|
157
|
+
...(spec.cancel ? { cancel: () => done(false) } : {}),
|
|
191
158
|
back: () => {
|
|
192
|
-
|
|
193
|
-
if (
|
|
159
|
+
if (spec.onBack) spec.onBack();
|
|
160
|
+
else if (spec.opened !== undefined && spec.current() !== spec.opened) spec.apply(spec.opened);
|
|
194
161
|
done(true);
|
|
195
162
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
},
|
|
203
|
-
legend: () => footersPickerText().legend,
|
|
163
|
+
...(spec.press ? { press: (k) => spec.press!(k, () => tui.requestRender()) } : {}),
|
|
164
|
+
...(spec.toggleGradient ? { toggleGradient: () => spec.toggleGradient!(() => tui.requestRender()) } : {}),
|
|
165
|
+
...(spec.summary ? { summary: () => spec.summary!(theme) } : {}),
|
|
166
|
+
...(spec.note ? { note: spec.note } : {}),
|
|
167
|
+
...(typeof spec.text === "function" ? { legend: () => getText().legend } : {}),
|
|
168
|
+
...(spec.tickMs !== undefined ? { tickMs: spec.tickMs } : {}),
|
|
204
169
|
requestRender: () => tui.requestRender(),
|
|
205
170
|
},
|
|
206
|
-
|
|
171
|
+
getText(),
|
|
207
172
|
true,
|
|
208
173
|
ctx.thinkingLevel,
|
|
209
174
|
),
|
|
210
175
|
);
|
|
211
176
|
return goBack === true;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const HEADERS_PICKER_TEXT: ListPickerText = {
|
|
215
|
-
title: screenTitle("Headers"),
|
|
216
|
-
description: "Selection applies live — custom header or built-in.",
|
|
217
|
-
legend: LIST_LEGEND_LIVE,
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const openHeaders = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
221
|
-
const opened = activeHeaderPreset();
|
|
177
|
+
}
|
|
222
178
|
|
|
179
|
+
/** Shared non-live choice picker: Enter commits the highlighted row, Esc/← leaves untouched. */
|
|
180
|
+
async function openChoicePicker<T extends string>(
|
|
181
|
+
ctx: ExtensionCommandContext,
|
|
182
|
+
spec: {
|
|
183
|
+
choices: readonly T[];
|
|
184
|
+
rows: ListRow[];
|
|
185
|
+
opened: T;
|
|
186
|
+
text: ListPickerText;
|
|
187
|
+
onCommit: (index: number, isTui: boolean) => void | Promise<void>;
|
|
188
|
+
},
|
|
189
|
+
): Promise<boolean | void> {
|
|
223
190
|
if (ctx.mode !== "tui") {
|
|
224
|
-
|
|
225
|
-
const
|
|
226
|
-
const pick = await ctx.ui.select(HEADERS_PICKER_TEXT.title, labels);
|
|
191
|
+
const labels = spec.choices.map((c) => (c === spec.opened ? `${c} ✓` : c));
|
|
192
|
+
const pick = await ctx.ui.select(spec.text.title, labels);
|
|
227
193
|
if (pick === undefined) return;
|
|
228
|
-
|
|
229
|
-
setHeaderPreset(name, ctx);
|
|
230
|
-
ctx.ui.notify(`[arnative] Header: ${name}`, "info");
|
|
194
|
+
await spec.onCommit(labels.indexOf(pick), false);
|
|
231
195
|
return;
|
|
232
196
|
}
|
|
233
|
-
|
|
234
|
-
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) =>
|
|
235
|
-
new ListPicker(
|
|
197
|
+
let committed: number | undefined;
|
|
198
|
+
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) => {
|
|
199
|
+
const picker = new ListPicker(
|
|
236
200
|
theme,
|
|
237
|
-
|
|
238
|
-
opened,
|
|
201
|
+
spec.rows,
|
|
202
|
+
spec.opened,
|
|
239
203
|
{
|
|
240
|
-
preview: (
|
|
241
|
-
revert: () =>
|
|
204
|
+
preview: () => {},
|
|
205
|
+
revert: () => {},
|
|
242
206
|
done: () => {
|
|
243
|
-
|
|
207
|
+
committed = picker.index;
|
|
244
208
|
done(false);
|
|
245
209
|
},
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (activeHeaderPreset() !== opened) setHeaderPreset(opened, ctx);
|
|
249
|
-
done(true);
|
|
250
|
-
},
|
|
210
|
+
cancel: () => done(false),
|
|
211
|
+
back: () => done(true),
|
|
251
212
|
requestRender: () => tui.requestRender(),
|
|
252
213
|
},
|
|
253
|
-
|
|
254
|
-
|
|
214
|
+
spec.text,
|
|
215
|
+
false,
|
|
255
216
|
ctx.thinkingLevel,
|
|
256
|
-
)
|
|
257
|
-
|
|
217
|
+
);
|
|
218
|
+
return picker;
|
|
219
|
+
});
|
|
220
|
+
if (committed !== undefined) await spec.onCommit(committed, true);
|
|
258
221
|
return goBack === true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const openThemes = async (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
225
|
+
// Only this package's family (`arnative`, `arnative-<variant>`): the picker brands itself
|
|
226
|
+
// arnative, so pi's own themes and the user's belong in /settings → Theme, not here.
|
|
227
|
+
const names = ctx.ui.getAllThemes().map((t) => t.name).filter(isArnativeThemeName);
|
|
228
|
+
if (names.length === 0) {
|
|
229
|
+
ctx.ui.notify("[arnative] No arnative themes found. Reinstall pi-arnative, or pick any theme in /settings → Theme.", "warning");
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const current = ctx.ui.theme.name;
|
|
233
|
+
return openLivePicker(ctx, {
|
|
234
|
+
choices: names,
|
|
235
|
+
opened: current,
|
|
236
|
+
text: THEMES_PICKER_TEXT,
|
|
237
|
+
label: "Theme",
|
|
238
|
+
current: () => ctx.ui.theme.name,
|
|
239
|
+
apply: (name) => {
|
|
240
|
+
const result = ctx.ui.setTheme(name);
|
|
241
|
+
if (!result.success) ctx.ui.notify(`[arnative] ${result.error ?? `failed to apply ${name}`}`, "error");
|
|
242
|
+
},
|
|
243
|
+
onSelectHeadless: (name) => {
|
|
244
|
+
const result = ctx.ui.setTheme(name);
|
|
245
|
+
ctx.ui.notify(result.success ? `[arnative] Theme: ${name}` : `[arnative] ${result.error ?? "failed"}`, result.success ? "info" : "error");
|
|
246
|
+
},
|
|
247
|
+
onRevert: () => {
|
|
248
|
+
if (current) ctx.ui.setTheme(current);
|
|
249
|
+
},
|
|
250
|
+
onBack: () => {
|
|
251
|
+
if (current && ctx.ui.theme.name !== current) ctx.ui.setTheme(current);
|
|
252
|
+
},
|
|
253
|
+
onDone: () => {
|
|
254
|
+
const applied = ctx.ui.theme.name;
|
|
255
|
+
announce(ctx.ui, applied ? `Theme: ${applied}.` : "Theme changed.");
|
|
256
|
+
},
|
|
257
|
+
});
|
|
259
258
|
};
|
|
260
259
|
|
|
260
|
+
/** The Footers screen copy. The legend states the cost switch's live value, like the
|
|
261
|
+
* Animations screen does for the gradient — a constant legend would advertise the value
|
|
262
|
+
* the screen opened with. */
|
|
263
|
+
const footersPickerText = (): ListPickerText => ({
|
|
264
|
+
title: screenTitle("Footers"),
|
|
265
|
+
description: "Selection applies live — custom footer or built-in.",
|
|
266
|
+
legend: `[↑↓] Preview [c] Cost ${activeFooterCost() ? "on" : "off"} [Enter] Select [Esc] Back`,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const openFooters = (ctx: ExtensionCommandContext): Promise<boolean | void> =>
|
|
270
|
+
openLivePicker(ctx, {
|
|
271
|
+
choices: FOOTER_PRESETS,
|
|
272
|
+
opened: activeFooterPreset(),
|
|
273
|
+
text: footersPickerText,
|
|
274
|
+
label: "Footer",
|
|
275
|
+
current: activeFooterPreset,
|
|
276
|
+
apply: (name) => setFooterPreset(name, ctx),
|
|
277
|
+
press: (keyData, requestRender) => {
|
|
278
|
+
if (!matchesKey(keyData, "c")) return;
|
|
279
|
+
setFooterCost(!activeFooterCost());
|
|
280
|
+
requestRender();
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
const HEADERS_PICKER_TEXT: ListPickerText = {
|
|
285
|
+
title: screenTitle("Headers"),
|
|
286
|
+
description: "Selection applies live — custom header or built-in.",
|
|
287
|
+
legend: LIST_LEGEND_LIVE,
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const openHeaders = (ctx: ExtensionCommandContext): Promise<boolean | void> =>
|
|
291
|
+
openLivePicker(ctx, {
|
|
292
|
+
choices: HEADER_PRESETS,
|
|
293
|
+
opened: activeHeaderPreset(),
|
|
294
|
+
text: HEADERS_PICKER_TEXT,
|
|
295
|
+
label: "Header",
|
|
296
|
+
current: activeHeaderPreset,
|
|
297
|
+
apply: (name) => setHeaderPreset(name, ctx),
|
|
298
|
+
});
|
|
299
|
+
|
|
261
300
|
const CHATBOX_PICKER_TEXT: ListPickerText = {
|
|
262
301
|
title: screenTitle("Chatbox"),
|
|
263
302
|
description: "Selection applies when confirmed — rounded arnative box or built-in editor.",
|
|
@@ -286,114 +325,48 @@ export const chatboxSummary = (theme: { fg(c: string, t: string): string }): str
|
|
|
286
325
|
];
|
|
287
326
|
};
|
|
288
327
|
|
|
289
|
-
const openChatbox =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
setChatboxPreset
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
announce(ctx.ui, `Chatbox: ${activeChatboxPreset()}.`);
|
|
312
|
-
done(false);
|
|
313
|
-
},
|
|
314
|
-
back: () => {
|
|
315
|
-
if (activeChatboxPreset() !== opened) setChatboxPreset(opened);
|
|
316
|
-
done(true);
|
|
317
|
-
},
|
|
318
|
-
press: (keyData) => {
|
|
319
|
-
if (matchesKey(keyData, "i") || keyData === "I") {
|
|
320
|
-
setChatboxPrompt(nextChatboxPrompt());
|
|
321
|
-
tui.requestRender();
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
if (matchesKey(keyData, "d") || keyData === "D") {
|
|
325
|
-
setChatboxDialog(nextChatboxDialog());
|
|
326
|
-
tui.requestRender();
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
summary: () => chatboxSummary(theme),
|
|
330
|
-
requestRender: () => tui.requestRender(),
|
|
331
|
-
},
|
|
332
|
-
CHATBOX_PICKER_TEXT,
|
|
333
|
-
true,
|
|
334
|
-
ctx.thinkingLevel,
|
|
335
|
-
),
|
|
336
|
-
);
|
|
337
|
-
return goBack === true;
|
|
338
|
-
};
|
|
328
|
+
const openChatbox = (ctx: ExtensionCommandContext): Promise<boolean | void> =>
|
|
329
|
+
openLivePicker(ctx, {
|
|
330
|
+
choices: CHATBOX_PRESETS,
|
|
331
|
+
rows: chatboxRows(),
|
|
332
|
+
opened: activeChatboxPreset(),
|
|
333
|
+
text: CHATBOX_PICKER_TEXT,
|
|
334
|
+
label: "Chatbox",
|
|
335
|
+
current: activeChatboxPreset,
|
|
336
|
+
apply: setChatboxPreset,
|
|
337
|
+
summary: chatboxSummary,
|
|
338
|
+
press: (keyData, requestRender) => {
|
|
339
|
+
if (matchesKey(keyData, "i") || keyData === "I") {
|
|
340
|
+
setChatboxPrompt(nextChatboxPrompt());
|
|
341
|
+
requestRender();
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (matchesKey(keyData, "d") || keyData === "D") {
|
|
345
|
+
setChatboxDialog(nextChatboxDialog());
|
|
346
|
+
requestRender();
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
});
|
|
339
350
|
|
|
340
351
|
/** Animations picker. Unlike Themes/Headers/Footers the choice has a visible effect only
|
|
341
352
|
* while a tool runs, so there is nothing to preview live on the screen itself — the row
|
|
342
353
|
* previews the frames instead, and Enter installs the preset for the next run. */
|
|
343
|
-
const openAnimations =
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) =>
|
|
361
|
-
new ListPicker(
|
|
362
|
-
theme,
|
|
363
|
-
rows,
|
|
364
|
-
opened,
|
|
365
|
-
{
|
|
366
|
-
preview: (name) => setSpinnerPreset(name as SpinnerPreset),
|
|
367
|
-
revert: () => setSpinnerPreset(opened),
|
|
368
|
-
done: () => {
|
|
369
|
-
announce(ctx.ui, `Animation: ${activeSpinnerPreset()}.`);
|
|
370
|
-
done(false);
|
|
371
|
-
},
|
|
372
|
-
back: () => {
|
|
373
|
-
// Back restores the preset it opened with, then reports upward.
|
|
374
|
-
if (activeSpinnerPreset() !== opened) setSpinnerPreset(opened);
|
|
375
|
-
done(true);
|
|
376
|
-
},
|
|
377
|
-
// `[g]` is a switch, not a preview: it is a command the user asked for and the legend
|
|
378
|
-
// states its state, so Esc and `←` leave it on. Only the preset preview reverts.
|
|
379
|
-
toggleGradient: () => {
|
|
380
|
-
setSpinnerGradient(!activeSpinnerGradient());
|
|
381
|
-
tui.requestRender();
|
|
382
|
-
},
|
|
383
|
-
legend: () => animationsPickerText().legend,
|
|
384
|
-
// The row animates: its note is re-read each tick and the frame comes from the
|
|
385
|
-
// clock, so the picker shows motion instead of a static glyph list.
|
|
386
|
-
note: (label) => animationRowNote(label as SpinnerPreset),
|
|
387
|
-
tickMs: PREVIEW_TICK_MS,
|
|
388
|
-
requestRender: () => tui.requestRender(),
|
|
389
|
-
},
|
|
390
|
-
animationsPickerText(),
|
|
391
|
-
true,
|
|
392
|
-
ctx.thinkingLevel,
|
|
393
|
-
),
|
|
394
|
-
);
|
|
395
|
-
return goBack === true;
|
|
396
|
-
};
|
|
354
|
+
const openAnimations = (ctx: ExtensionCommandContext): Promise<boolean | void> =>
|
|
355
|
+
openLivePicker(ctx, {
|
|
356
|
+
choices: SPINNER_PRESETS,
|
|
357
|
+
rows: animationRows(),
|
|
358
|
+
opened: activeSpinnerPreset(),
|
|
359
|
+
text: animationsPickerText,
|
|
360
|
+
label: "Animation",
|
|
361
|
+
current: activeSpinnerPreset,
|
|
362
|
+
apply: setSpinnerPreset,
|
|
363
|
+
toggleGradient: (requestRender) => {
|
|
364
|
+
setSpinnerGradient(!activeSpinnerGradient());
|
|
365
|
+
requestRender();
|
|
366
|
+
},
|
|
367
|
+
note: (label) => animationRowNote(label as SpinnerPreset),
|
|
368
|
+
tickMs: PREVIEW_TICK_MS,
|
|
369
|
+
});
|
|
397
370
|
|
|
398
371
|
const AUTOCOMPACT_PICKER_TEXT: ListPickerText = {
|
|
399
372
|
title: screenTitle("Auto-compact"),
|
|
@@ -425,46 +398,25 @@ export function autoCompactRows(opened: AutoCompactChoice): ListRow[] {
|
|
|
425
398
|
|
|
426
399
|
/** A plain (non-live) picker: the choice is committed by Enter, nothing previews. The
|
|
427
400
|
* trigger itself lives in `extensions/autocompact.ts` and fires on the next settle. */
|
|
428
|
-
const openAutoCompact =
|
|
401
|
+
const openAutoCompact = (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
429
402
|
const opened = activeAutoCompact();
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
theme,
|
|
447
|
-
autoCompactRows(opened),
|
|
448
|
-
opened,
|
|
449
|
-
{
|
|
450
|
-
preview: () => {},
|
|
451
|
-
revert: () => {},
|
|
452
|
-
done: () => {
|
|
453
|
-
setAutoCompact(AUTO_COMPACT_CHOICES[picker.index]!);
|
|
454
|
-
announce(ctx.ui, `Auto-compact: ${AUTO_COMPACT_CHOICES[picker.index]}.`);
|
|
455
|
-
done(false);
|
|
456
|
-
},
|
|
457
|
-
cancel: () => done(false),
|
|
458
|
-
back: () => done(true),
|
|
459
|
-
requestRender: () => tui.requestRender(),
|
|
460
|
-
},
|
|
461
|
-
AUTOCOMPACT_PICKER_TEXT,
|
|
462
|
-
false,
|
|
463
|
-
ctx.thinkingLevel,
|
|
464
|
-
);
|
|
465
|
-
return picker;
|
|
403
|
+
return openChoicePicker(ctx, {
|
|
404
|
+
choices: AUTO_COMPACT_CHOICES,
|
|
405
|
+
rows: autoCompactRows(opened),
|
|
406
|
+
opened,
|
|
407
|
+
text: AUTOCOMPACT_PICKER_TEXT,
|
|
408
|
+
onCommit: (index, isTui) => {
|
|
409
|
+
const choice = AUTO_COMPACT_CHOICES[index]!;
|
|
410
|
+
setAutoCompact(choice);
|
|
411
|
+
if (isTui) announce(ctx.ui, `Auto-compact: ${choice}.`);
|
|
412
|
+
else {
|
|
413
|
+
ctx.ui.notify(
|
|
414
|
+
`[arnative] Auto-compact: ${choice === "Off" ? "off" : choice === "Smart" ? "smart (tiered by context window)" : `above ${choice} tokens of context`}`,
|
|
415
|
+
"info",
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
},
|
|
466
419
|
});
|
|
467
|
-
return goBack === true;
|
|
468
420
|
};
|
|
469
421
|
|
|
470
422
|
const MODEL_HEAL_PICKER_TEXT: ListPickerText = {
|
|
@@ -490,53 +442,24 @@ export function modelHealRows(opened: ModelHealChoice): ListRow[] {
|
|
|
490
442
|
];
|
|
491
443
|
}
|
|
492
444
|
|
|
493
|
-
const openModelHeal =
|
|
445
|
+
const openModelHeal = (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
494
446
|
const opened = activeModelHeal();
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
let runNow = false;
|
|
511
|
-
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) => {
|
|
512
|
-
const picker = new ListPicker(
|
|
513
|
-
theme,
|
|
514
|
-
modelHealRows(opened),
|
|
515
|
-
opened,
|
|
516
|
-
{
|
|
517
|
-
preview: () => {},
|
|
518
|
-
revert: () => {},
|
|
519
|
-
done: () => {
|
|
520
|
-
if (picker.index === MODEL_HEAL_CHOICES.length) runNow = true;
|
|
521
|
-
else {
|
|
522
|
-
setModelHeal(MODEL_HEAL_CHOICES[picker.index]!);
|
|
523
|
-
announce(ctx.ui, `Model heal: ${MODEL_HEAL_CHOICES[picker.index]}.`);
|
|
524
|
-
}
|
|
525
|
-
done(false);
|
|
526
|
-
},
|
|
527
|
-
cancel: () => done(false),
|
|
528
|
-
back: () => done(true),
|
|
529
|
-
requestRender: () => tui.requestRender(),
|
|
530
|
-
},
|
|
531
|
-
MODEL_HEAL_PICKER_TEXT,
|
|
532
|
-
false,
|
|
533
|
-
ctx.thinkingLevel,
|
|
534
|
-
);
|
|
535
|
-
return picker;
|
|
447
|
+
return openChoicePicker(ctx, {
|
|
448
|
+
choices: [...MODEL_HEAL_CHOICES, MODEL_HEAL_RUN_NOW],
|
|
449
|
+
rows: modelHealRows(opened),
|
|
450
|
+
opened,
|
|
451
|
+
text: MODEL_HEAL_PICKER_TEXT,
|
|
452
|
+
onCommit: async (index, isTui) => {
|
|
453
|
+
if (index === MODEL_HEAL_CHOICES.length) {
|
|
454
|
+
await healNow(ctx);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const choice = MODEL_HEAL_CHOICES[index]!;
|
|
458
|
+
setModelHeal(choice);
|
|
459
|
+
if (isTui) announce(ctx.ui, `Model heal: ${choice}.`);
|
|
460
|
+
else ctx.ui.notify(`[arnative] Model heal: ${choice}`, "info");
|
|
461
|
+
},
|
|
536
462
|
});
|
|
537
|
-
// After the picker closed: the run notifies, and a notice under an open overlay is lost.
|
|
538
|
-
if (runNow) await healNow(ctx);
|
|
539
|
-
return goBack === true;
|
|
540
463
|
};
|
|
541
464
|
|
|
542
465
|
const RENDER_CACHE_PICKER_TEXT: ListPickerText = {
|
|
@@ -574,85 +497,35 @@ export function diffRows(): ListRow[] {
|
|
|
574
497
|
}));
|
|
575
498
|
}
|
|
576
499
|
|
|
577
|
-
const openDiffs =
|
|
500
|
+
const openDiffs = (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
578
501
|
const opened = activeEditDiff();
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) => {
|
|
591
|
-
const picker = new ListPicker(
|
|
592
|
-
theme,
|
|
593
|
-
diffRows(),
|
|
594
|
-
opened,
|
|
595
|
-
{
|
|
596
|
-
preview: (name) => setEditDiff(name as EditDiffMode),
|
|
597
|
-
revert: () => setEditDiff(opened),
|
|
598
|
-
done: () => {
|
|
599
|
-
announce(ctx.ui, `Diffs: ${activeEditDiff()}.`);
|
|
600
|
-
done(false);
|
|
601
|
-
},
|
|
602
|
-
cancel: () => done(false),
|
|
603
|
-
back: () => {
|
|
604
|
-
if (activeEditDiff() !== opened) setEditDiff(opened);
|
|
605
|
-
done(true);
|
|
606
|
-
},
|
|
607
|
-
requestRender: () => tui.requestRender(),
|
|
608
|
-
},
|
|
609
|
-
DIFFS_PICKER_TEXT,
|
|
610
|
-
true,
|
|
611
|
-
ctx.thinkingLevel,
|
|
612
|
-
);
|
|
613
|
-
return picker;
|
|
502
|
+
return openLivePicker(ctx, {
|
|
503
|
+
choices: EDIT_DIFF_CHOICES,
|
|
504
|
+
rows: diffRows(),
|
|
505
|
+
opened,
|
|
506
|
+
text: DIFFS_PICKER_TEXT,
|
|
507
|
+
label: "Diffs",
|
|
508
|
+
current: activeEditDiff,
|
|
509
|
+
apply: setEditDiff,
|
|
510
|
+
headlessLabels: EDIT_DIFF_CHOICES.map((c) => (c === opened ? `${c} ✓` : c)),
|
|
511
|
+
cancel: true,
|
|
614
512
|
});
|
|
615
|
-
return goBack === true;
|
|
616
513
|
};
|
|
617
514
|
|
|
618
|
-
const openRenderCache =
|
|
515
|
+
const openRenderCache = (ctx: ExtensionCommandContext): Promise<boolean | void> => {
|
|
619
516
|
const opened = activeRenderCache();
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
const goBack = await ctx.ui.custom<boolean>((tui, theme, _kb, done) => {
|
|
632
|
-
const picker = new ListPicker(
|
|
633
|
-
theme,
|
|
634
|
-
renderCacheRows(opened),
|
|
635
|
-
opened,
|
|
636
|
-
{
|
|
637
|
-
preview: () => {},
|
|
638
|
-
revert: () => {},
|
|
639
|
-
done: () => {
|
|
640
|
-
const choice = RENDER_CACHE_CHOICES[picker.index]!;
|
|
641
|
-
setRenderCache(choice);
|
|
642
|
-
announce(ctx.ui, `Render cache: ${choice}.`);
|
|
643
|
-
done(false);
|
|
644
|
-
},
|
|
645
|
-
cancel: () => done(false),
|
|
646
|
-
back: () => done(true),
|
|
647
|
-
requestRender: () => tui.requestRender(),
|
|
648
|
-
},
|
|
649
|
-
RENDER_CACHE_PICKER_TEXT,
|
|
650
|
-
false,
|
|
651
|
-
ctx.thinkingLevel,
|
|
652
|
-
);
|
|
653
|
-
return picker;
|
|
517
|
+
return openChoicePicker(ctx, {
|
|
518
|
+
choices: RENDER_CACHE_CHOICES,
|
|
519
|
+
rows: renderCacheRows(opened),
|
|
520
|
+
opened,
|
|
521
|
+
text: RENDER_CACHE_PICKER_TEXT,
|
|
522
|
+
onCommit: (index, isTui) => {
|
|
523
|
+
const choice = RENDER_CACHE_CHOICES[index]!;
|
|
524
|
+
setRenderCache(choice);
|
|
525
|
+
if (isTui) announce(ctx.ui, `Render cache: ${choice}.`);
|
|
526
|
+
else ctx.ui.notify(`[arnative] Render cache: ${choice}`, "info");
|
|
527
|
+
},
|
|
654
528
|
});
|
|
655
|
-
return goBack === true;
|
|
656
529
|
};
|
|
657
530
|
|
|
658
531
|
const PAYLOAD_CUSTOM_LABEL = "Custom";
|