@kolisachint/hoocode-agent 0.4.23 → 0.4.25

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cli/args.d.ts +2 -0
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +13 -4
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/core/agent-session.d.ts.map +1 -1
  7. package/dist/core/agent-session.js +41 -3
  8. package/dist/core/agent-session.js.map +1 -1
  9. package/dist/core/extensions/types.d.ts +2 -0
  10. package/dist/core/extensions/types.d.ts.map +1 -1
  11. package/dist/core/extensions/types.js.map +1 -1
  12. package/dist/core/prompt-templates.d.ts +23 -0
  13. package/dist/core/prompt-templates.d.ts.map +1 -1
  14. package/dist/core/prompt-templates.js +48 -11
  15. package/dist/core/prompt-templates.js.map +1 -1
  16. package/dist/core/provider-health.d.ts +36 -0
  17. package/dist/core/provider-health.d.ts.map +1 -0
  18. package/dist/core/provider-health.js +54 -0
  19. package/dist/core/provider-health.js.map +1 -0
  20. package/dist/core/resource-loader.d.ts +5 -0
  21. package/dist/core/resource-loader.d.ts.map +1 -1
  22. package/dist/core/resource-loader.js +40 -5
  23. package/dist/core/resource-loader.js.map +1 -1
  24. package/dist/core/settings-defaults.d.ts +1 -0
  25. package/dist/core/settings-defaults.d.ts.map +1 -1
  26. package/dist/core/settings-defaults.js +1 -0
  27. package/dist/core/settings-defaults.js.map +1 -1
  28. package/dist/core/settings-manager.d.ts +4 -0
  29. package/dist/core/settings-manager.d.ts.map +1 -1
  30. package/dist/core/settings-manager.js +14 -0
  31. package/dist/core/settings-manager.js.map +1 -1
  32. package/dist/core/subagent-pool.d.ts +6 -0
  33. package/dist/core/subagent-pool.d.ts.map +1 -1
  34. package/dist/core/subagent-pool.js +28 -0
  35. package/dist/core/subagent-pool.js.map +1 -1
  36. package/dist/core/subagent-result.d.ts.map +1 -1
  37. package/dist/core/subagent-result.js +32 -2
  38. package/dist/core/subagent-result.js.map +1 -1
  39. package/dist/core/tools/edit.d.ts.map +1 -1
  40. package/dist/core/tools/edit.js +1 -1
  41. package/dist/core/tools/edit.js.map +1 -1
  42. package/dist/core/tools/subagent.d.ts +1 -1
  43. package/dist/core/tools/subagent.d.ts.map +1 -1
  44. package/dist/core/tools/subagent.js +27 -1
  45. package/dist/core/tools/subagent.js.map +1 -1
  46. package/dist/extensions/core/hoo-core.d.ts.map +1 -1
  47. package/dist/extensions/core/hoo-core.js +4 -1
  48. package/dist/extensions/core/hoo-core.js.map +1 -1
  49. package/dist/init-templates.generated.d.ts.map +1 -1
  50. package/dist/init-templates.generated.js +1 -1
  51. package/dist/init-templates.generated.js.map +1 -1
  52. package/dist/main.d.ts.map +1 -1
  53. package/dist/main.js +4 -1
  54. package/dist/main.js.map +1 -1
  55. package/dist/modes/interactive/command-executor.d.ts +64 -0
  56. package/dist/modes/interactive/command-executor.d.ts.map +1 -0
  57. package/dist/modes/interactive/command-executor.js +547 -0
  58. package/dist/modes/interactive/command-executor.js.map +1 -0
  59. package/dist/modes/interactive/components/ask-options.d.ts.map +1 -1
  60. package/dist/modes/interactive/components/ask-options.js +2 -0
  61. package/dist/modes/interactive/components/ask-options.js.map +1 -1
  62. package/dist/modes/interactive/interactive-mode.d.ts +9 -20
  63. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  64. package/dist/modes/interactive/interactive-mode.js +86 -552
  65. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  66. package/docs/prompt-templates.md +34 -2
  67. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  68. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  69. package/examples/extensions/sandbox/package.json +1 -1
  70. package/examples/extensions/with-deps/package.json +1 -1
  71. package/examples/sdk/08-prompt-templates.ts +1 -0
  72. package/package.json +4 -4
  73. package/templates/agents/general-purpose.md +1 -0
@@ -0,0 +1,547 @@
1
+ /**
2
+ * Extracted command handlers from InteractiveMode.
3
+ * All methods receive dependencies via CommandContext rather than
4
+ * reaching back into the parent class.
5
+ */
6
+ import * as fs from "node:fs";
7
+ import * as os from "node:os";
8
+ import * as path from "node:path";
9
+ import { Markdown, Spacer, Text, visibleWidth } from "@kolisachint/hoocode-tui";
10
+ import { spawn, spawnSync } from "child_process";
11
+ import { getDebugLogPath, getShareViewerUrl } from "../../config.js";
12
+ import { loadAgentRegistry } from "../../core/agent-registry.js";
13
+ import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
14
+ import { MissingSessionCwdError } from "../../core/session-cwd.js";
15
+ import { getSubagentPool } from "../../core/subagent-pool-instance.js";
16
+ import { getChangelogPath, parseChangelog } from "../../utils/changelog.js";
17
+ import { copyToClipboard } from "../../utils/clipboard.js";
18
+ import { ArminComponent } from "./components/armin.js";
19
+ import { BorderedLoader } from "./components/bordered-loader.js";
20
+ import { DynamicBorder } from "./components/dynamic-border.js";
21
+ import { formatKeyText, keyDisplayText } from "./components/keybinding-hints.js";
22
+ import { theme } from "./theme/theme.js";
23
+ export class CommandExecutor {
24
+ ctx;
25
+ constructor(ctx) {
26
+ this.ctx = ctx;
27
+ }
28
+ // =========================================================================
29
+ // Slash command handlers
30
+ // =========================================================================
31
+ async handleModel(searchTerm) {
32
+ if (!searchTerm) {
33
+ this.ctx.showModelSelector();
34
+ return;
35
+ }
36
+ const model = await this.ctx.findExactModelMatch(searchTerm);
37
+ if (model) {
38
+ try {
39
+ await this.ctx.session.setModel(model);
40
+ this.ctx.footer.invalidate();
41
+ this.ctx.updateEditorBorderColor();
42
+ this.ctx.showStatus(`Model: ${model.id}`);
43
+ void this.ctx.maybeWarnAboutAnthropicSubscriptionAuth(model);
44
+ this.ctx.checkDaxnutsEasterEgg(model);
45
+ }
46
+ catch (error) {
47
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
48
+ }
49
+ return;
50
+ }
51
+ this.ctx.showModelSelector(searchTerm);
52
+ }
53
+ async handleClone() {
54
+ const leafId = this.ctx.sessionManager.getLeafId();
55
+ if (!leafId) {
56
+ this.ctx.showStatus("Nothing to clone yet");
57
+ return;
58
+ }
59
+ try {
60
+ const result = await this.ctx.runtimeHost.fork(leafId, { position: "at" });
61
+ if (result.cancelled) {
62
+ this.ctx.ui.requestRender();
63
+ return;
64
+ }
65
+ this.ctx.renderCurrentSessionState();
66
+ this.ctx.editor.setText("");
67
+ this.ctx.showStatus("Cloned to new session");
68
+ }
69
+ catch (error) {
70
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
71
+ }
72
+ }
73
+ async handleSubagent(text) {
74
+ const prefix = "/subagent ";
75
+ const args = text.startsWith(prefix) ? text.slice(prefix.length).trim() : "";
76
+ if (!args) {
77
+ this.ctx.showStatus("Usage: /subagent <mode> <task>");
78
+ return;
79
+ }
80
+ const firstSpace = args.indexOf(" ");
81
+ if (firstSpace === -1) {
82
+ this.ctx.showStatus("Usage: /subagent <mode> <task>");
83
+ return;
84
+ }
85
+ const mode = args.slice(0, firstSpace).trim();
86
+ const task = args.slice(firstSpace + 1).trim();
87
+ if (!task) {
88
+ this.ctx.showStatus("Usage: /subagent <mode> <task>");
89
+ return;
90
+ }
91
+ const validModes = loadAgentRegistry({ cwd: this.ctx.sessionManager.getCwd() })
92
+ .list()
93
+ .map((a) => a.name);
94
+ if (!validModes.includes(mode)) {
95
+ this.ctx.showStatus(`Unknown subagent_type: ${mode}. Available: ${validModes.join(", ")}`);
96
+ return;
97
+ }
98
+ this.ctx.showStatus(`Spawning ${mode} subagent...`);
99
+ try {
100
+ const pool = getSubagentPool(this.ctx.sessionManager.getCwd());
101
+ const dispatchResult = await pool.dispatch(task, {
102
+ forceAgent: mode,
103
+ model: this.ctx.session.model?.id,
104
+ provider: this.ctx.session.model?.provider,
105
+ });
106
+ const result = dispatchResult.result;
107
+ const resultData = result?.result_data;
108
+ if (result?.ok) {
109
+ this.ctx.showStatus(`${mode} subagent completed`);
110
+ // Inject the subagent answer as a custom message so the user can see it in the chat
111
+ this.ctx.sessionManager.appendMessage({
112
+ role: "custom",
113
+ customType: "subagent",
114
+ content: resultData?.summary || "(no output)",
115
+ display: true,
116
+ timestamp: Date.now(),
117
+ });
118
+ }
119
+ else {
120
+ this.ctx.showError(`Subagent (${mode}) failed: ${result?.error ?? "unknown error"}`);
121
+ }
122
+ }
123
+ catch (error) {
124
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
125
+ }
126
+ }
127
+ async handleExport(text) {
128
+ const outputPath = this.getPathArgument(text, "/export");
129
+ try {
130
+ if (outputPath?.endsWith(".jsonl")) {
131
+ const filePath = this.ctx.session.exportToJsonl(outputPath);
132
+ this.ctx.showStatus(`Session exported to: ${filePath}`);
133
+ }
134
+ else {
135
+ const filePath = await this.ctx.session.exportToHtml(outputPath);
136
+ this.ctx.showStatus(`Session exported to: ${filePath}`);
137
+ }
138
+ }
139
+ catch (error) {
140
+ this.ctx.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
141
+ }
142
+ }
143
+ getPathArgument(text, command) {
144
+ if (text === command) {
145
+ return undefined;
146
+ }
147
+ if (!text.startsWith(`${command} `)) {
148
+ return undefined;
149
+ }
150
+ const argsString = text.slice(command.length + 1).trimStart();
151
+ if (!argsString) {
152
+ return undefined;
153
+ }
154
+ const firstChar = argsString[0];
155
+ if (firstChar === '"' || firstChar === "'") {
156
+ const closingQuoteIndex = argsString.indexOf(firstChar, 1);
157
+ if (closingQuoteIndex < 0) {
158
+ return undefined;
159
+ }
160
+ return argsString.slice(1, closingQuoteIndex);
161
+ }
162
+ const firstWhitespaceIndex = argsString.search(/\s/);
163
+ if (firstWhitespaceIndex < 0) {
164
+ return argsString;
165
+ }
166
+ return argsString.slice(0, firstWhitespaceIndex);
167
+ }
168
+ async handleImport(text) {
169
+ const inputPath = this.getPathArgument(text, "/import");
170
+ if (!inputPath) {
171
+ this.ctx.showError("Usage: /import <path.jsonl>");
172
+ return;
173
+ }
174
+ const confirmed = await this.ctx.showExtensionConfirm("Import session", `Replace current session with ${inputPath}?`);
175
+ if (!confirmed) {
176
+ this.ctx.showStatus("Import cancelled");
177
+ return;
178
+ }
179
+ try {
180
+ this.ctx.stopLoadingAnimation();
181
+ this.ctx.statusContainer.clear();
182
+ const result = await this.ctx.runtimeHost.importFromJsonl(inputPath);
183
+ if (result.cancelled) {
184
+ this.ctx.showStatus("Import cancelled");
185
+ return;
186
+ }
187
+ this.ctx.renderCurrentSessionState();
188
+ this.ctx.showStatus(`Session imported from: ${inputPath}`);
189
+ }
190
+ catch (error) {
191
+ if (error instanceof MissingSessionCwdError) {
192
+ const selectedCwd = await this.ctx.promptForMissingSessionCwd(error);
193
+ if (!selectedCwd) {
194
+ this.ctx.showStatus("Import cancelled");
195
+ return;
196
+ }
197
+ const result = await this.ctx.runtimeHost.importFromJsonl(inputPath, selectedCwd);
198
+ if (result.cancelled) {
199
+ this.ctx.showStatus("Import cancelled");
200
+ return;
201
+ }
202
+ this.ctx.renderCurrentSessionState();
203
+ this.ctx.showStatus(`Session imported from: ${inputPath}`);
204
+ return;
205
+ }
206
+ if (error instanceof SessionImportFileNotFoundError) {
207
+ this.ctx.showError(`Failed to import session: ${error.message}`);
208
+ return;
209
+ }
210
+ await this.ctx.handleFatalRuntimeError("Failed to import session", error);
211
+ }
212
+ }
213
+ async handleShare() {
214
+ // Check if gh is available and logged in
215
+ try {
216
+ const authResult = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" });
217
+ if (authResult.status !== 0) {
218
+ this.ctx.showError("GitHub CLI is not logged in. Run 'gh auth login' first.");
219
+ return;
220
+ }
221
+ }
222
+ catch {
223
+ this.ctx.showError("GitHub CLI (gh) is not installed. Install it from https://cli.github.com/");
224
+ return;
225
+ }
226
+ // Export to a temp file
227
+ const tmpFile = path.join(os.tmpdir(), "session.html");
228
+ try {
229
+ await this.ctx.session.exportToHtml(tmpFile);
230
+ }
231
+ catch (error) {
232
+ this.ctx.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
233
+ return;
234
+ }
235
+ // Show cancellable loader, replacing the editor
236
+ const loader = new BorderedLoader(this.ctx.ui, theme, "Creating gist...");
237
+ this.ctx.editorContainer.clear();
238
+ this.ctx.editorContainer.addChild(loader);
239
+ this.ctx.ui.setFocus(loader);
240
+ this.ctx.ui.requestRender();
241
+ const restoreEditor = () => {
242
+ loader.dispose();
243
+ this.ctx.editorContainer.clear();
244
+ this.ctx.editorContainer.addChild(this.ctx.editor);
245
+ this.ctx.ui.setFocus(this.ctx.editor);
246
+ try {
247
+ fs.unlinkSync(tmpFile);
248
+ }
249
+ catch {
250
+ // Ignore cleanup errors
251
+ }
252
+ };
253
+ // Create a secret gist asynchronously
254
+ let proc = null;
255
+ loader.onAbort = () => {
256
+ proc?.kill();
257
+ restoreEditor();
258
+ this.ctx.showStatus("Share cancelled");
259
+ };
260
+ try {
261
+ const result = await new Promise((resolve) => {
262
+ proc = spawn("gh", ["gist", "create", "--public=false", tmpFile]);
263
+ let stdout = "";
264
+ let stderr = "";
265
+ proc.stdout?.on("data", (data) => {
266
+ stdout += data.toString();
267
+ });
268
+ proc.stderr?.on("data", (data) => {
269
+ stderr += data.toString();
270
+ });
271
+ proc.on("close", (code) => resolve({ stdout, stderr, code }));
272
+ });
273
+ if (loader.signal.aborted)
274
+ return;
275
+ restoreEditor();
276
+ if (result.code !== 0) {
277
+ const errorMsg = result.stderr?.trim() || "Unknown error";
278
+ this.ctx.showError(`Failed to create gist: ${errorMsg}`);
279
+ return;
280
+ }
281
+ // Extract gist ID from the URL returned by gh
282
+ // gh returns something like: https://gist.github.com/username/GIST_ID
283
+ const gistUrl = result.stdout?.trim();
284
+ const gistId = gistUrl?.split("/").pop();
285
+ if (!gistId) {
286
+ this.ctx.showError("Failed to parse gist ID from gh output");
287
+ return;
288
+ }
289
+ // Create the preview URL
290
+ const previewUrl = getShareViewerUrl(gistId);
291
+ this.ctx.showStatus(`Share URL: ${previewUrl}\nGist: ${gistUrl}`);
292
+ }
293
+ catch (error) {
294
+ if (!loader.signal.aborted) {
295
+ restoreEditor();
296
+ this.ctx.showError(`Failed to create gist: ${error instanceof Error ? error.message : "Unknown error"}`);
297
+ }
298
+ }
299
+ }
300
+ async handleCopy() {
301
+ const text = this.ctx.session.getLastAssistantText();
302
+ if (!text) {
303
+ this.ctx.showError("No agent messages to copy yet.");
304
+ return;
305
+ }
306
+ try {
307
+ await copyToClipboard(text);
308
+ this.ctx.showStatus("Copied last agent message to clipboard");
309
+ }
310
+ catch (error) {
311
+ this.ctx.showError(error instanceof Error ? error.message : String(error));
312
+ }
313
+ }
314
+ handleName(text) {
315
+ const name = text.replace(/^\/name\s*/, "").trim();
316
+ if (!name) {
317
+ const currentName = this.ctx.sessionManager.getSessionName();
318
+ if (currentName) {
319
+ this.ctx.chatContainer.addChild(new Spacer(1));
320
+ this.ctx.chatContainer.addChild(new Text(theme.fg("dim", `Session name: ${currentName}`), 1, 0));
321
+ }
322
+ else {
323
+ this.ctx.showWarning("Usage: /name <name>");
324
+ }
325
+ this.ctx.ui.requestRender();
326
+ return;
327
+ }
328
+ this.ctx.session.setSessionName(name);
329
+ this.ctx.chatContainer.addChild(new Spacer(1));
330
+ this.ctx.chatContainer.addChild(new Text(theme.fg("dim", `Session name set: ${name}`), 1, 0));
331
+ this.ctx.ui.requestRender();
332
+ }
333
+ handleSession() {
334
+ const stats = this.ctx.session.getSessionStats();
335
+ const sessionName = this.ctx.sessionManager.getSessionName();
336
+ let info = `${theme.bold("Session Info")}\n\n`;
337
+ if (sessionName) {
338
+ info += `${theme.fg("dim", "Name:")} ${sessionName}\n`;
339
+ }
340
+ info += `${theme.fg("dim", "File:")} ${stats.sessionFile ?? "In-memory"}\n`;
341
+ info += `${theme.fg("dim", "ID:")} ${stats.sessionId}\n\n`;
342
+ info += `${theme.bold("Messages")}\n`;
343
+ info += `${theme.fg("dim", "User:")} ${stats.userMessages}\n`;
344
+ info += `${theme.fg("dim", "Assistant:")} ${stats.assistantMessages}\n`;
345
+ info += `${theme.fg("dim", "Tool Calls:")} ${stats.toolCalls}\n`;
346
+ info += `${theme.fg("dim", "Tool Results:")} ${stats.toolResults}\n`;
347
+ info += `${theme.fg("dim", "Total:")} ${stats.totalMessages}\n\n`;
348
+ info += `${theme.bold("Tokens")}\n`;
349
+ info += `${theme.fg("dim", "Input:")} ${stats.tokens.input.toLocaleString()}\n`;
350
+ info += `${theme.fg("dim", "Output:")} ${stats.tokens.output.toLocaleString()}\n`;
351
+ if (stats.tokens.cacheRead > 0) {
352
+ info += `${theme.fg("dim", "Cache Read:")} ${stats.tokens.cacheRead.toLocaleString()}\n`;
353
+ }
354
+ if (stats.tokens.cacheWrite > 0) {
355
+ info += `${theme.fg("dim", "Cache Write:")} ${stats.tokens.cacheWrite.toLocaleString()}\n`;
356
+ }
357
+ info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}\n`;
358
+ if (stats.cost > 0) {
359
+ info += `\n${theme.bold("Cost")}\n`;
360
+ info += `${theme.fg("dim", "Total:")} ${stats.cost.toFixed(4)}`;
361
+ }
362
+ this.ctx.chatContainer.addChild(new Spacer(1));
363
+ this.ctx.chatContainer.addChild(new Text(info, 1, 0));
364
+ this.ctx.ui.requestRender();
365
+ }
366
+ handleChangelog() {
367
+ const changelogPath = getChangelogPath();
368
+ const allEntries = parseChangelog(changelogPath);
369
+ if (allEntries.length === 0) {
370
+ this.ctx.chatContainer.addChild(new Spacer(1));
371
+ this.ctx.chatContainer.addChild(new Text(theme.fg("dim", "No changelog entries found."), 1, 0));
372
+ this.ctx.ui.requestRender();
373
+ return;
374
+ }
375
+ const changelogMarkdown = allEntries
376
+ .slice()
377
+ .reverse()
378
+ .map((e) => e.content)
379
+ .join("\n\n");
380
+ this.ctx.chatContainer.addChild(new Spacer(1));
381
+ this.ctx.chatContainer.addChild(new DynamicBorder());
382
+ this.ctx.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
383
+ this.ctx.chatContainer.addChild(new Spacer(1));
384
+ this.ctx.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, this.ctx.getMarkdownThemeWithSettings()));
385
+ this.ctx.chatContainer.addChild(new DynamicBorder());
386
+ this.ctx.ui.requestRender();
387
+ }
388
+ handleHotkeys() {
389
+ // Navigation keybindings
390
+ const cursorUp = keyDisplayText("tui.editor.cursorUp");
391
+ const cursorDown = keyDisplayText("tui.editor.cursorDown");
392
+ const cursorLeft = keyDisplayText("tui.editor.cursorLeft");
393
+ const cursorRight = keyDisplayText("tui.editor.cursorRight");
394
+ const cursorWordLeft = keyDisplayText("tui.editor.cursorWordLeft");
395
+ const cursorWordRight = keyDisplayText("tui.editor.cursorWordRight");
396
+ const cursorLineStart = keyDisplayText("tui.editor.cursorLineStart");
397
+ const cursorLineEnd = keyDisplayText("tui.editor.cursorLineEnd");
398
+ const jumpForward = keyDisplayText("tui.editor.jumpForward");
399
+ const jumpBackward = keyDisplayText("tui.editor.jumpBackward");
400
+ const pageUp = keyDisplayText("tui.editor.pageUp");
401
+ const pageDown = keyDisplayText("tui.editor.pageDown");
402
+ // Editing keybindings
403
+ const submit = keyDisplayText("tui.input.submit");
404
+ const newLine = keyDisplayText("tui.input.newLine");
405
+ const deleteWordBackward = keyDisplayText("tui.editor.deleteWordBackward");
406
+ const deleteWordForward = keyDisplayText("tui.editor.deleteWordForward");
407
+ const deleteToLineStart = keyDisplayText("tui.editor.deleteToLineStart");
408
+ const deleteToLineEnd = keyDisplayText("tui.editor.deleteToLineEnd");
409
+ const yank = keyDisplayText("tui.editor.yank");
410
+ const yankPop = keyDisplayText("tui.editor.yankPop");
411
+ const undo = keyDisplayText("tui.editor.undo");
412
+ const tab = keyDisplayText("tui.input.tab");
413
+ // App keybindings
414
+ const interrupt = keyDisplayText("app.interrupt");
415
+ const clear = keyDisplayText("app.clear");
416
+ const exit = keyDisplayText("app.exit");
417
+ const suspend = keyDisplayText("app.suspend");
418
+ const cycleThinkingLevel = keyDisplayText("app.thinking.cycle");
419
+ const cycleModelForward = keyDisplayText("app.model.cycleForward");
420
+ const selectModel = keyDisplayText("app.model.select");
421
+ const expandTools = keyDisplayText("app.tools.expand");
422
+ const toggleThinking = keyDisplayText("app.thinking.toggle");
423
+ const externalEditor = keyDisplayText("app.editor.external");
424
+ const cycleModelBackward = keyDisplayText("app.model.cycleBackward");
425
+ const followUp = keyDisplayText("app.message.followUp");
426
+ const dequeue = keyDisplayText("app.message.dequeue");
427
+ const pasteImage = keyDisplayText("app.clipboard.pasteImage");
428
+ let hotkeys = `
429
+ **Navigation**
430
+ | Key | Action |
431
+ |-----|--------|
432
+ | \`${cursorUp}\` / \`${cursorDown}\` / \`${cursorLeft}\` / \`${cursorRight}\` | Move cursor / browse history (Up when empty) |
433
+ | \`${cursorWordLeft}\` / \`${cursorWordRight}\` | Move by word |
434
+ | \`${cursorLineStart}\` | Start of line |
435
+ | \`${cursorLineEnd}\` | End of line |
436
+ | \`${jumpForward}\` | Jump forward to character |
437
+ | \`${jumpBackward}\` | Jump backward to character |
438
+ | \`${pageUp}\` / \`${pageDown}\` | Scroll by page |
439
+
440
+ **Editing**
441
+ | Key | Action |
442
+ |-----|--------|
443
+ | \`${submit}\` | Send message |
444
+ | \`${newLine}\` | New line${process.platform === "win32" ? " (Ctrl+Enter on Windows Terminal)" : ""} |
445
+ | \`${deleteWordBackward}\` | Delete word backwards |
446
+ | \`${deleteWordForward}\` | Delete word forwards |
447
+ | \`${deleteToLineStart}\` | Delete to start of line |
448
+ | \`${deleteToLineEnd}\` | Delete to end of line |
449
+ | \`${yank}\` | Paste the most-recently-deleted text |
450
+ | \`${yankPop}\` | Cycle through the deleted text after pasting |
451
+ | \`${undo}\` | Undo |
452
+
453
+ **Other**
454
+ | Key | Action |
455
+ |-----|--------|
456
+ | \`${tab}\` | Path completion / accept autocomplete |
457
+ | \`${interrupt}\` | Cancel autocomplete / abort streaming |
458
+ | \`${clear}\` | Clear editor (first) / exit (second) |
459
+ | \`${exit}\` | Exit (when editor is empty) |
460
+ | \`${suspend}\` | Suspend to background |
461
+ | \`${cycleThinkingLevel}\` | Cycle thinking level |
462
+ | \`${cycleModelForward}\` / \`${cycleModelBackward}\` | Cycle models |
463
+ | \`${selectModel}\` | Open model selector |
464
+ | \`${expandTools}\` | Toggle tool output expansion |
465
+ | \`${toggleThinking}\` | Toggle thinking block visibility |
466
+ | \`${externalEditor}\` | Edit message in external editor |
467
+ | \`${followUp}\` | Queue follow-up message |
468
+ | \`${dequeue}\` | Restore queued messages |
469
+ | \`${pasteImage}\` | Paste image from clipboard |
470
+ | \`/\` | Slash commands |
471
+ | \`!\` | Run bash command |
472
+ | \`!!\` | Run bash command (excluded from context) |
473
+ `;
474
+ // Add extension-registered shortcuts
475
+ const extensionRunner = this.ctx.session.extensionRunner;
476
+ const shortcuts = extensionRunner.getShortcuts(this.ctx.keybindings.getEffectiveConfig());
477
+ if (shortcuts.size > 0) {
478
+ hotkeys += `
479
+ **Extensions**
480
+ | Key | Action |
481
+ |-----|--------|
482
+ `;
483
+ for (const [key, shortcut] of shortcuts) {
484
+ const description = shortcut.description ?? shortcut.extensionPath;
485
+ const keyDisplay = formatKeyText(key, { capitalize: true });
486
+ hotkeys += `| \`${keyDisplay}\` | ${description} |\n`;
487
+ }
488
+ }
489
+ this.ctx.chatContainer.addChild(new Spacer(1));
490
+ this.ctx.chatContainer.addChild(new DynamicBorder());
491
+ this.ctx.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "Keyboard Shortcuts")), 1, 0));
492
+ this.ctx.chatContainer.addChild(new Spacer(1));
493
+ this.ctx.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, this.ctx.getMarkdownThemeWithSettings()));
494
+ this.ctx.chatContainer.addChild(new DynamicBorder());
495
+ this.ctx.ui.requestRender();
496
+ }
497
+ async handleClear() {
498
+ this.ctx.stopLoadingAnimation();
499
+ this.ctx.statusContainer.clear();
500
+ try {
501
+ const result = await this.ctx.runtimeHost.newSession();
502
+ if (result.cancelled) {
503
+ return;
504
+ }
505
+ this.ctx.renderCurrentSessionState();
506
+ this.ctx.chatContainer.addChild(new Spacer(1));
507
+ this.ctx.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ New session started")}`, 1, 1));
508
+ this.ctx.ui.requestRender();
509
+ }
510
+ catch (error) {
511
+ await this.ctx.handleFatalRuntimeError("Failed to create session", error);
512
+ }
513
+ }
514
+ handleDebug() {
515
+ const width = this.ctx.ui.terminal.columns;
516
+ const height = this.ctx.ui.terminal.rows;
517
+ const allLines = this.ctx.ui.render(width);
518
+ const debugLogPath = getDebugLogPath();
519
+ const debugData = [
520
+ `Debug output at ${new Date().toISOString()}`,
521
+ `Terminal: ${width}x${height}`,
522
+ `Total lines: ${allLines.length}`,
523
+ "",
524
+ "=== All rendered lines with visible widths ===",
525
+ ...allLines.map((line, idx) => {
526
+ const vw = visibleWidth(line);
527
+ const escaped = JSON.stringify(line);
528
+ return `[${idx}] (w=${vw}) ${escaped}`;
529
+ }),
530
+ "",
531
+ "=== Agent messages (JSONL) ===",
532
+ ...this.ctx.session.messages.map((msg) => JSON.stringify(msg)),
533
+ "",
534
+ ].join("\n");
535
+ fs.mkdirSync(path.dirname(debugLogPath), { recursive: true });
536
+ fs.writeFileSync(debugLogPath, debugData);
537
+ this.ctx.chatContainer.addChild(new Spacer(1));
538
+ this.ctx.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ Debug log written")}\n${theme.fg("muted", debugLogPath)}`, 1, 1));
539
+ this.ctx.ui.requestRender();
540
+ }
541
+ handleArminSaysHi() {
542
+ this.ctx.chatContainer.addChild(new Spacer(1));
543
+ this.ctx.chatContainer.addChild(new ArminComponent(this.ctx.ui));
544
+ this.ctx.ui.requestRender();
545
+ }
546
+ }
547
+ //# sourceMappingURL=command-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-executor.js","sourceRoot":"","sources":["../../../src/modes/interactive/command-executor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO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AC,CAAC,CAAC;QACjE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;IAAA,CAC5B;CACD","sourcesContent":["/**\n * Extracted command handlers from InteractiveMode.\n * All methods receive dependencies via CommandContext rather than\n * reaching back into the parent class.\n */\n\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport type { Model } from \"@kolisachint/hoocode-ai\";\nimport type { EditorComponent, MarkdownTheme, TUI } from \"@kolisachint/hoocode-tui\";\nimport { type Container, Markdown, Spacer, Text, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport { spawn, spawnSync } from \"child_process\";\nimport { getDebugLogPath, getShareViewerUrl } from \"../../config.js\";\nimport { loadAgentRegistry } from \"../../core/agent-registry.js\";\nimport type { AgentSession } from \"../../core/agent-session.js\";\nimport type { AgentSessionRuntime } from \"../../core/agent-session-runtime.js\";\nimport { SessionImportFileNotFoundError } from \"../../core/agent-session-runtime.js\";\nimport type { KeybindingsManager } from \"../../core/keybindings.js\";\nimport { MissingSessionCwdError } from \"../../core/session-cwd.js\";\nimport type { SessionManager } from \"../../core/session-manager.js\";\nimport { getSubagentPool } from \"../../core/subagent-pool-instance.js\";\nimport type { SubagentResultFile } from \"../../core/subagent-result.js\";\nimport { getChangelogPath, parseChangelog } from \"../../utils/changelog.js\";\nimport { copyToClipboard } from \"../../utils/clipboard.js\";\nimport { ArminComponent } from \"./components/armin.js\";\nimport { BorderedLoader } from \"./components/bordered-loader.js\";\nimport { DynamicBorder } from \"./components/dynamic-border.js\";\nimport type { FooterComponent } from \"./components/footer.js\";\nimport { formatKeyText, keyDisplayText } from \"./components/keybinding-hints.js\";\nimport { theme } from \"./theme/theme.js\";\n\nexport interface CommandContext {\n\t// Core dependencies\n\tsession: AgentSession;\n\tsessionManager: SessionManager;\n\truntimeHost: AgentSessionRuntime;\n\tui: TUI;\n\teditor: EditorComponent;\n\teditorContainer: Container;\n\tchatContainer: Container;\n\tstatusContainer: Container;\n\tfooter: FooterComponent;\n\tkeybindings: KeybindingsManager;\n\n\t// UI callbacks\n\tshowStatus: (message: string) => void;\n\tshowError: (message: string) => void;\n\tshowWarning: (message: string) => void;\n\tupdateEditorBorderColor: () => void;\n\trenderCurrentSessionState: () => void;\n\trebuildChatFromMessages: () => void;\n\tgetMarkdownThemeWithSettings: () => MarkdownTheme;\n\tstopLoadingAnimation: () => void;\n\n\t// Auth/model helpers\n\tfindExactModelMatch: (searchTerm: string) => Promise<Model<any> | undefined>;\n\tmaybeWarnAboutAnthropicSubscriptionAuth: (model?: Model<any>) => Promise<void>;\n\tcheckDaxnutsEasterEgg: (model: { provider: string; id: string }) => void;\n\n\t// Dialog callbacks\n\tshowModelSelector: (searchTerm?: string) => void;\n\tshowExtensionConfirm: (title: string, message: string) => Promise<boolean>;\n\tpromptForMissingSessionCwd: (error: MissingSessionCwdError) => Promise<string | undefined>;\n\n\t// Fatal error handler\n\thandleFatalRuntimeError: (prefix: string, error: unknown) => Promise<never>;\n}\n\nexport class CommandExecutor {\n\tconstructor(private readonly ctx: CommandContext) {}\n\n\t// =========================================================================\n\t// Slash command handlers\n\t// =========================================================================\n\n\tasync handleModel(searchTerm?: string): Promise<void> {\n\t\tif (!searchTerm) {\n\t\t\tthis.ctx.showModelSelector();\n\t\t\treturn;\n\t\t}\n\n\t\tconst model = await this.ctx.findExactModelMatch(searchTerm);\n\t\tif (model) {\n\t\t\ttry {\n\t\t\t\tawait this.ctx.session.setModel(model);\n\t\t\t\tthis.ctx.footer.invalidate();\n\t\t\t\tthis.ctx.updateEditorBorderColor();\n\t\t\t\tthis.ctx.showStatus(`Model: ${model.id}`);\n\t\t\t\tvoid this.ctx.maybeWarnAboutAnthropicSubscriptionAuth(model);\n\t\t\t\tthis.ctx.checkDaxnutsEasterEgg(model);\n\t\t\t} catch (error) {\n\t\t\t\tthis.ctx.showError(error instanceof Error ? error.message : String(error));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tthis.ctx.showModelSelector(searchTerm);\n\t}\n\n\tasync handleClone(): Promise<void> {\n\t\tconst leafId = this.ctx.sessionManager.getLeafId();\n\t\tif (!leafId) {\n\t\t\tthis.ctx.showStatus(\"Nothing to clone yet\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = await this.ctx.runtimeHost.fork(leafId, { position: \"at\" });\n\t\t\tif (result.cancelled) {\n\t\t\t\tthis.ctx.ui.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.ctx.renderCurrentSessionState();\n\t\t\tthis.ctx.editor.setText(\"\");\n\t\t\tthis.ctx.showStatus(\"Cloned to new session\");\n\t\t} catch (error: unknown) {\n\t\t\tthis.ctx.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n\n\tasync handleSubagent(text: string): Promise<void> {\n\t\tconst prefix = \"/subagent \";\n\t\tconst args = text.startsWith(prefix) ? text.slice(prefix.length).trim() : \"\";\n\t\tif (!args) {\n\t\t\tthis.ctx.showStatus(\"Usage: /subagent <mode> <task>\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst firstSpace = args.indexOf(\" \");\n\t\tif (firstSpace === -1) {\n\t\t\tthis.ctx.showStatus(\"Usage: /subagent <mode> <task>\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst mode = args.slice(0, firstSpace).trim();\n\t\tconst task = args.slice(firstSpace + 1).trim();\n\t\tif (!task) {\n\t\t\tthis.ctx.showStatus(\"Usage: /subagent <mode> <task>\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst validModes = loadAgentRegistry({ cwd: this.ctx.sessionManager.getCwd() })\n\t\t\t.list()\n\t\t\t.map((a) => a.name);\n\t\tif (!validModes.includes(mode)) {\n\t\t\tthis.ctx.showStatus(`Unknown subagent_type: ${mode}. Available: ${validModes.join(\", \")}`);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.ctx.showStatus(`Spawning ${mode} subagent...`);\n\t\ttry {\n\t\t\tconst pool = getSubagentPool(this.ctx.sessionManager.getCwd());\n\t\t\tconst dispatchResult = await pool.dispatch(task, {\n\t\t\t\tforceAgent: mode,\n\t\t\t\tmodel: this.ctx.session.model?.id,\n\t\t\t\tprovider: this.ctx.session.model?.provider,\n\t\t\t});\n\t\t\tconst result = dispatchResult.result;\n\t\t\tconst resultData = result?.result_data as SubagentResultFile | undefined;\n\t\t\tif (result?.ok) {\n\t\t\t\tthis.ctx.showStatus(`${mode} subagent completed`);\n\t\t\t\t// Inject the subagent answer as a custom message so the user can see it in the chat\n\t\t\t\tthis.ctx.sessionManager.appendMessage({\n\t\t\t\t\trole: \"custom\",\n\t\t\t\t\tcustomType: \"subagent\",\n\t\t\t\t\tcontent: resultData?.summary || \"(no output)\",\n\t\t\t\t\tdisplay: true,\n\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tthis.ctx.showError(`Subagent (${mode}) failed: ${result?.error ?? \"unknown error\"}`);\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tthis.ctx.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n\n\tasync handleExport(text: string): Promise<void> {\n\t\tconst outputPath = this.getPathArgument(text, \"/export\");\n\n\t\ttry {\n\t\t\tif (outputPath?.endsWith(\".jsonl\")) {\n\t\t\t\tconst filePath = this.ctx.session.exportToJsonl(outputPath);\n\t\t\t\tthis.ctx.showStatus(`Session exported to: ${filePath}`);\n\t\t\t} else {\n\t\t\t\tconst filePath = await this.ctx.session.exportToHtml(outputPath);\n\t\t\t\tthis.ctx.showStatus(`Session exported to: ${filePath}`);\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tthis.ctx.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t}\n\t}\n\n\tprivate getPathArgument(text: string, command: \"/export\" | \"/import\"): string | undefined {\n\t\tif (text === command) {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (!text.startsWith(`${command} `)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst argsString = text.slice(command.length + 1).trimStart();\n\t\tif (!argsString) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst firstChar = argsString[0];\n\t\tif (firstChar === '\"' || firstChar === \"'\") {\n\t\t\tconst closingQuoteIndex = argsString.indexOf(firstChar, 1);\n\t\t\tif (closingQuoteIndex < 0) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn argsString.slice(1, closingQuoteIndex);\n\t\t}\n\n\t\tconst firstWhitespaceIndex = argsString.search(/\\s/);\n\t\tif (firstWhitespaceIndex < 0) {\n\t\t\treturn argsString;\n\t\t}\n\t\treturn argsString.slice(0, firstWhitespaceIndex);\n\t}\n\n\tasync handleImport(text: string): Promise<void> {\n\t\tconst inputPath = this.getPathArgument(text, \"/import\");\n\t\tif (!inputPath) {\n\t\t\tthis.ctx.showError(\"Usage: /import <path.jsonl>\");\n\t\t\treturn;\n\t\t}\n\n\t\tconst confirmed = await this.ctx.showExtensionConfirm(\n\t\t\t\"Import session\",\n\t\t\t`Replace current session with ${inputPath}?`,\n\t\t);\n\t\tif (!confirmed) {\n\t\t\tthis.ctx.showStatus(\"Import cancelled\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tthis.ctx.stopLoadingAnimation();\n\t\t\tthis.ctx.statusContainer.clear();\n\t\t\tconst result = await this.ctx.runtimeHost.importFromJsonl(inputPath);\n\t\t\tif (result.cancelled) {\n\t\t\t\tthis.ctx.showStatus(\"Import cancelled\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.ctx.renderCurrentSessionState();\n\t\t\tthis.ctx.showStatus(`Session imported from: ${inputPath}`);\n\t\t} catch (error: unknown) {\n\t\t\tif (error instanceof MissingSessionCwdError) {\n\t\t\t\tconst selectedCwd = await this.ctx.promptForMissingSessionCwd(error);\n\t\t\t\tif (!selectedCwd) {\n\t\t\t\t\tthis.ctx.showStatus(\"Import cancelled\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst result = await this.ctx.runtimeHost.importFromJsonl(inputPath, selectedCwd);\n\t\t\t\tif (result.cancelled) {\n\t\t\t\t\tthis.ctx.showStatus(\"Import cancelled\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.ctx.renderCurrentSessionState();\n\t\t\t\tthis.ctx.showStatus(`Session imported from: ${inputPath}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (error instanceof SessionImportFileNotFoundError) {\n\t\t\t\tthis.ctx.showError(`Failed to import session: ${error.message}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait this.ctx.handleFatalRuntimeError(\"Failed to import session\", error);\n\t\t}\n\t}\n\n\tasync handleShare(): Promise<void> {\n\t\t// Check if gh is available and logged in\n\t\ttry {\n\t\t\tconst authResult = spawnSync(\"gh\", [\"auth\", \"status\"], { encoding: \"utf-8\" });\n\t\t\tif (authResult.status !== 0) {\n\t\t\t\tthis.ctx.showError(\"GitHub CLI is not logged in. Run 'gh auth login' first.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t} catch {\n\t\t\tthis.ctx.showError(\"GitHub CLI (gh) is not installed. Install it from https://cli.github.com/\");\n\t\t\treturn;\n\t\t}\n\n\t\t// Export to a temp file\n\t\tconst tmpFile = path.join(os.tmpdir(), \"session.html\");\n\t\ttry {\n\t\t\tawait this.ctx.session.exportToHtml(tmpFile);\n\t\t} catch (error: unknown) {\n\t\t\tthis.ctx.showError(`Failed to export session: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Show cancellable loader, replacing the editor\n\t\tconst loader = new BorderedLoader(this.ctx.ui, theme, \"Creating gist...\");\n\t\tthis.ctx.editorContainer.clear();\n\t\tthis.ctx.editorContainer.addChild(loader);\n\t\tthis.ctx.ui.setFocus(loader);\n\t\tthis.ctx.ui.requestRender();\n\n\t\tconst restoreEditor = () => {\n\t\t\tloader.dispose();\n\t\t\tthis.ctx.editorContainer.clear();\n\t\t\tthis.ctx.editorContainer.addChild(this.ctx.editor);\n\t\t\tthis.ctx.ui.setFocus(this.ctx.editor);\n\t\t\ttry {\n\t\t\t\tfs.unlinkSync(tmpFile);\n\t\t\t} catch {\n\t\t\t\t// Ignore cleanup errors\n\t\t\t}\n\t\t};\n\n\t\t// Create a secret gist asynchronously\n\t\tlet proc: ReturnType<typeof spawn> | null = null;\n\n\t\tloader.onAbort = () => {\n\t\t\tproc?.kill();\n\t\t\trestoreEditor();\n\t\t\tthis.ctx.showStatus(\"Share cancelled\");\n\t\t};\n\n\t\ttry {\n\t\t\tconst result = await new Promise<{ stdout: string; stderr: string; code: number | null }>((resolve) => {\n\t\t\t\tproc = spawn(\"gh\", [\"gist\", \"create\", \"--public=false\", tmpFile]);\n\t\t\t\tlet stdout = \"\";\n\t\t\t\tlet stderr = \"\";\n\t\t\t\tproc.stdout?.on(\"data\", (data) => {\n\t\t\t\t\tstdout += data.toString();\n\t\t\t\t});\n\t\t\t\tproc.stderr?.on(\"data\", (data) => {\n\t\t\t\t\tstderr += data.toString();\n\t\t\t\t});\n\t\t\t\tproc.on(\"close\", (code) => resolve({ stdout, stderr, code }));\n\t\t\t});\n\n\t\t\tif (loader.signal.aborted) return;\n\n\t\t\trestoreEditor();\n\n\t\t\tif (result.code !== 0) {\n\t\t\t\tconst errorMsg = result.stderr?.trim() || \"Unknown error\";\n\t\t\t\tthis.ctx.showError(`Failed to create gist: ${errorMsg}`);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Extract gist ID from the URL returned by gh\n\t\t\t// gh returns something like: https://gist.github.com/username/GIST_ID\n\t\t\tconst gistUrl = result.stdout?.trim();\n\t\t\tconst gistId = gistUrl?.split(\"/\").pop();\n\t\t\tif (!gistId) {\n\t\t\t\tthis.ctx.showError(\"Failed to parse gist ID from gh output\");\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Create the preview URL\n\t\t\tconst previewUrl = getShareViewerUrl(gistId);\n\t\t\tthis.ctx.showStatus(`Share URL: ${previewUrl}\\nGist: ${gistUrl}`);\n\t\t} catch (error: unknown) {\n\t\t\tif (!loader.signal.aborted) {\n\t\t\t\trestoreEditor();\n\t\t\t\tthis.ctx.showError(`Failed to create gist: ${error instanceof Error ? error.message : \"Unknown error\"}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync handleCopy(): Promise<void> {\n\t\tconst text = this.ctx.session.getLastAssistantText();\n\t\tif (!text) {\n\t\t\tthis.ctx.showError(\"No agent messages to copy yet.\");\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait copyToClipboard(text);\n\t\t\tthis.ctx.showStatus(\"Copied last agent message to clipboard\");\n\t\t} catch (error) {\n\t\t\tthis.ctx.showError(error instanceof Error ? error.message : String(error));\n\t\t}\n\t}\n\n\thandleName(text: string): void {\n\t\tconst name = text.replace(/^\\/name\\s*/, \"\").trim();\n\t\tif (!name) {\n\t\t\tconst currentName = this.ctx.sessionManager.getSessionName();\n\t\t\tif (currentName) {\n\t\t\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\t\t\tthis.ctx.chatContainer.addChild(new Text(theme.fg(\"dim\", `Session name: ${currentName}`), 1, 0));\n\t\t\t} else {\n\t\t\t\tthis.ctx.showWarning(\"Usage: /name <name>\");\n\t\t\t}\n\t\t\tthis.ctx.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\tthis.ctx.session.setSessionName(name);\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(new Text(theme.fg(\"dim\", `Session name set: ${name}`), 1, 0));\n\t\tthis.ctx.ui.requestRender();\n\t}\n\n\thandleSession(): void {\n\t\tconst stats = this.ctx.session.getSessionStats();\n\t\tconst sessionName = this.ctx.sessionManager.getSessionName();\n\n\t\tlet info = `${theme.bold(\"Session Info\")}\\n\\n`;\n\t\tif (sessionName) {\n\t\t\tinfo += `${theme.fg(\"dim\", \"Name:\")} ${sessionName}\\n`;\n\t\t}\n\t\tinfo += `${theme.fg(\"dim\", \"File:\")} ${stats.sessionFile ?? \"In-memory\"}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"ID:\")} ${stats.sessionId}\\n\\n`;\n\t\tinfo += `${theme.bold(\"Messages\")}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"User:\")} ${stats.userMessages}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"Assistant:\")} ${stats.assistantMessages}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"Tool Calls:\")} ${stats.toolCalls}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"Tool Results:\")} ${stats.toolResults}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.totalMessages}\\n\\n`;\n\t\tinfo += `${theme.bold(\"Tokens\")}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"Input:\")} ${stats.tokens.input.toLocaleString()}\\n`;\n\t\tinfo += `${theme.fg(\"dim\", \"Output:\")} ${stats.tokens.output.toLocaleString()}\\n`;\n\t\tif (stats.tokens.cacheRead > 0) {\n\t\t\tinfo += `${theme.fg(\"dim\", \"Cache Read:\")} ${stats.tokens.cacheRead.toLocaleString()}\\n`;\n\t\t}\n\t\tif (stats.tokens.cacheWrite > 0) {\n\t\t\tinfo += `${theme.fg(\"dim\", \"Cache Write:\")} ${stats.tokens.cacheWrite.toLocaleString()}\\n`;\n\t\t}\n\t\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.tokens.total.toLocaleString()}\\n`;\n\n\t\tif (stats.cost > 0) {\n\t\t\tinfo += `\\n${theme.bold(\"Cost\")}\\n`;\n\t\t\tinfo += `${theme.fg(\"dim\", \"Total:\")} ${stats.cost.toFixed(4)}`;\n\t\t}\n\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(new Text(info, 1, 0));\n\t\tthis.ctx.ui.requestRender();\n\t}\n\n\thandleChangelog(): void {\n\t\tconst changelogPath = getChangelogPath();\n\t\tconst allEntries = parseChangelog(changelogPath);\n\n\t\tif (allEntries.length === 0) {\n\t\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\t\tthis.ctx.chatContainer.addChild(new Text(theme.fg(\"dim\", \"No changelog entries found.\"), 1, 0));\n\t\t\tthis.ctx.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\n\t\tconst changelogMarkdown = allEntries\n\t\t\t.slice()\n\t\t\t.reverse()\n\t\t\t.map((e) => e.content)\n\t\t\t.join(\"\\n\\n\");\n\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(new DynamicBorder());\n\t\tthis.ctx.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"What's New\")), 1, 0));\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, this.ctx.getMarkdownThemeWithSettings()));\n\t\tthis.ctx.chatContainer.addChild(new DynamicBorder());\n\t\tthis.ctx.ui.requestRender();\n\t}\n\n\thandleHotkeys(): void {\n\t\t// Navigation keybindings\n\t\tconst cursorUp = keyDisplayText(\"tui.editor.cursorUp\");\n\t\tconst cursorDown = keyDisplayText(\"tui.editor.cursorDown\");\n\t\tconst cursorLeft = keyDisplayText(\"tui.editor.cursorLeft\");\n\t\tconst cursorRight = keyDisplayText(\"tui.editor.cursorRight\");\n\t\tconst cursorWordLeft = keyDisplayText(\"tui.editor.cursorWordLeft\");\n\t\tconst cursorWordRight = keyDisplayText(\"tui.editor.cursorWordRight\");\n\t\tconst cursorLineStart = keyDisplayText(\"tui.editor.cursorLineStart\");\n\t\tconst cursorLineEnd = keyDisplayText(\"tui.editor.cursorLineEnd\");\n\t\tconst jumpForward = keyDisplayText(\"tui.editor.jumpForward\");\n\t\tconst jumpBackward = keyDisplayText(\"tui.editor.jumpBackward\");\n\t\tconst pageUp = keyDisplayText(\"tui.editor.pageUp\");\n\t\tconst pageDown = keyDisplayText(\"tui.editor.pageDown\");\n\n\t\t// Editing keybindings\n\t\tconst submit = keyDisplayText(\"tui.input.submit\");\n\t\tconst newLine = keyDisplayText(\"tui.input.newLine\");\n\t\tconst deleteWordBackward = keyDisplayText(\"tui.editor.deleteWordBackward\");\n\t\tconst deleteWordForward = keyDisplayText(\"tui.editor.deleteWordForward\");\n\t\tconst deleteToLineStart = keyDisplayText(\"tui.editor.deleteToLineStart\");\n\t\tconst deleteToLineEnd = keyDisplayText(\"tui.editor.deleteToLineEnd\");\n\t\tconst yank = keyDisplayText(\"tui.editor.yank\");\n\t\tconst yankPop = keyDisplayText(\"tui.editor.yankPop\");\n\t\tconst undo = keyDisplayText(\"tui.editor.undo\");\n\t\tconst tab = keyDisplayText(\"tui.input.tab\");\n\n\t\t// App keybindings\n\t\tconst interrupt = keyDisplayText(\"app.interrupt\");\n\t\tconst clear = keyDisplayText(\"app.clear\");\n\t\tconst exit = keyDisplayText(\"app.exit\");\n\t\tconst suspend = keyDisplayText(\"app.suspend\");\n\t\tconst cycleThinkingLevel = keyDisplayText(\"app.thinking.cycle\");\n\t\tconst cycleModelForward = keyDisplayText(\"app.model.cycleForward\");\n\t\tconst selectModel = keyDisplayText(\"app.model.select\");\n\t\tconst expandTools = keyDisplayText(\"app.tools.expand\");\n\t\tconst toggleThinking = keyDisplayText(\"app.thinking.toggle\");\n\t\tconst externalEditor = keyDisplayText(\"app.editor.external\");\n\t\tconst cycleModelBackward = keyDisplayText(\"app.model.cycleBackward\");\n\t\tconst followUp = keyDisplayText(\"app.message.followUp\");\n\t\tconst dequeue = keyDisplayText(\"app.message.dequeue\");\n\t\tconst pasteImage = keyDisplayText(\"app.clipboard.pasteImage\");\n\n\t\tlet hotkeys = `\n**Navigation**\n| Key | Action |\n|-----|--------|\n| \\`${cursorUp}\\` / \\`${cursorDown}\\` / \\`${cursorLeft}\\` / \\`${cursorRight}\\` | Move cursor / browse history (Up when empty) |\n| \\`${cursorWordLeft}\\` / \\`${cursorWordRight}\\` | Move by word |\n| \\`${cursorLineStart}\\` | Start of line |\n| \\`${cursorLineEnd}\\` | End of line |\n| \\`${jumpForward}\\` | Jump forward to character |\n| \\`${jumpBackward}\\` | Jump backward to character |\n| \\`${pageUp}\\` / \\`${pageDown}\\` | Scroll by page |\n\n**Editing**\n| Key | Action |\n|-----|--------|\n| \\`${submit}\\` | Send message |\n| \\`${newLine}\\` | New line${process.platform === \"win32\" ? \" (Ctrl+Enter on Windows Terminal)\" : \"\"} |\n| \\`${deleteWordBackward}\\` | Delete word backwards |\n| \\`${deleteWordForward}\\` | Delete word forwards |\n| \\`${deleteToLineStart}\\` | Delete to start of line |\n| \\`${deleteToLineEnd}\\` | Delete to end of line |\n| \\`${yank}\\` | Paste the most-recently-deleted text |\n| \\`${yankPop}\\` | Cycle through the deleted text after pasting |\n| \\`${undo}\\` | Undo |\n\n**Other**\n| Key | Action |\n|-----|--------|\n| \\`${tab}\\` | Path completion / accept autocomplete |\n| \\`${interrupt}\\` | Cancel autocomplete / abort streaming |\n| \\`${clear}\\` | Clear editor (first) / exit (second) |\n| \\`${exit}\\` | Exit (when editor is empty) |\n| \\`${suspend}\\` | Suspend to background |\n| \\`${cycleThinkingLevel}\\` | Cycle thinking level |\n| \\`${cycleModelForward}\\` / \\`${cycleModelBackward}\\` | Cycle models |\n| \\`${selectModel}\\` | Open model selector |\n| \\`${expandTools}\\` | Toggle tool output expansion |\n| \\`${toggleThinking}\\` | Toggle thinking block visibility |\n| \\`${externalEditor}\\` | Edit message in external editor |\n| \\`${followUp}\\` | Queue follow-up message |\n| \\`${dequeue}\\` | Restore queued messages |\n| \\`${pasteImage}\\` | Paste image from clipboard |\n| \\`/\\` | Slash commands |\n| \\`!\\` | Run bash command |\n| \\`!!\\` | Run bash command (excluded from context) |\n`;\n\n\t\t// Add extension-registered shortcuts\n\t\tconst extensionRunner = this.ctx.session.extensionRunner;\n\t\tconst shortcuts = extensionRunner.getShortcuts(this.ctx.keybindings.getEffectiveConfig());\n\t\tif (shortcuts.size > 0) {\n\t\t\thotkeys += `\n**Extensions**\n| Key | Action |\n|-----|--------|\n`;\n\t\t\tfor (const [key, shortcut] of shortcuts) {\n\t\t\t\tconst description = shortcut.description ?? shortcut.extensionPath;\n\t\t\t\tconst keyDisplay = formatKeyText(key, { capitalize: true });\n\t\t\t\thotkeys += `| \\`${keyDisplay}\\` | ${description} |\\n`;\n\t\t\t}\n\t\t}\n\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(new DynamicBorder());\n\t\tthis.ctx.chatContainer.addChild(new Text(theme.bold(theme.fg(\"accent\", \"Keyboard Shortcuts\")), 1, 0));\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, this.ctx.getMarkdownThemeWithSettings()));\n\t\tthis.ctx.chatContainer.addChild(new DynamicBorder());\n\t\tthis.ctx.ui.requestRender();\n\t}\n\n\tasync handleClear(): Promise<void> {\n\t\tthis.ctx.stopLoadingAnimation();\n\t\tthis.ctx.statusContainer.clear();\n\t\ttry {\n\t\t\tconst result = await this.ctx.runtimeHost.newSession();\n\t\t\tif (result.cancelled) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.ctx.renderCurrentSessionState();\n\t\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\t\tthis.ctx.chatContainer.addChild(new Text(`${theme.fg(\"accent\", \"✓ New session started\")}`, 1, 1));\n\t\t\tthis.ctx.ui.requestRender();\n\t\t} catch (error: unknown) {\n\t\t\tawait this.ctx.handleFatalRuntimeError(\"Failed to create session\", error);\n\t\t}\n\t}\n\n\thandleDebug(): void {\n\t\tconst width = this.ctx.ui.terminal.columns;\n\t\tconst height = this.ctx.ui.terminal.rows;\n\t\tconst allLines = this.ctx.ui.render(width);\n\n\t\tconst debugLogPath = getDebugLogPath();\n\t\tconst debugData = [\n\t\t\t`Debug output at ${new Date().toISOString()}`,\n\t\t\t`Terminal: ${width}x${height}`,\n\t\t\t`Total lines: ${allLines.length}`,\n\t\t\t\"\",\n\t\t\t\"=== All rendered lines with visible widths ===\",\n\t\t\t...allLines.map((line, idx) => {\n\t\t\t\tconst vw = visibleWidth(line);\n\t\t\t\tconst escaped = JSON.stringify(line);\n\t\t\t\treturn `[${idx}] (w=${vw}) ${escaped}`;\n\t\t\t}),\n\t\t\t\"\",\n\t\t\t\"=== Agent messages (JSONL) ===\",\n\t\t\t...this.ctx.session.messages.map((msg) => JSON.stringify(msg)),\n\t\t\t\"\",\n\t\t].join(\"\\n\");\n\n\t\tfs.mkdirSync(path.dirname(debugLogPath), { recursive: true });\n\t\tfs.writeFileSync(debugLogPath, debugData);\n\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(\n\t\t\tnew Text(`${theme.fg(\"accent\", \"✓ Debug log written\")}\\n${theme.fg(\"muted\", debugLogPath)}`, 1, 1),\n\t\t);\n\t\tthis.ctx.ui.requestRender();\n\t}\n\n\thandleArminSaysHi(): void {\n\t\tthis.ctx.chatContainer.addChild(new Spacer(1));\n\t\tthis.ctx.chatContainer.addChild(new ArminComponent(this.ctx.ui));\n\t\tthis.ctx.ui.requestRender();\n\t}\n}\n"]}