@draht/coding-agent 2026.4.5 → 2026.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.
- package/CHANGELOG.md +792 -625
- package/README.md +24 -15
- package/dist/cli/args.d.ts +7 -10
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +44 -46
- package/dist/cli/args.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +53 -106
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +116 -147
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +86 -0
- package/dist/core/agent-session-services.d.ts.map +1 -0
- package/dist/core/agent-session-services.js +116 -0
- package/dist/core/agent-session-services.js.map +1 -0
- package/dist/core/agent-session.d.ts +8 -12
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +134 -45
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +19 -7
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +18 -17
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +7 -7
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +4 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +15 -14
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybindings.d.ts +14 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +13 -14
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +31 -1
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/package-manager.d.ts +21 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +108 -43
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +22 -21
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts +0 -2
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +26 -8
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -2
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/session-manager.d.ts +5 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +16 -8
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -4
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +5 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +3 -3
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +6 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/timings.d.ts +1 -0
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js +6 -0
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +19 -9
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +23 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +150 -57
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts +13 -11
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +55 -77
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +4 -4
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/index.d.ts +9 -6
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +252 -451
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts +3 -3
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +25 -5
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +3 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +14 -3
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -0
- package/dist/modes/interactive/components/earendil-announcement.js +40 -0
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +1 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +0 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +2 -7
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +4 -2
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +48 -15
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +12 -3
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +237 -125
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +8 -5
- package/dist/modes/interactive/theme/light.json +8 -5
- package/dist/modes/interactive/theme/theme-schema.json +6 -1
- package/dist/modes/interactive/theme/theme.d.ts +2 -2
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +13 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts +4 -4
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +6 -2
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +1 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +2 -2
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +26 -15
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +234 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/prompts/commands/atomic-commit.md +17 -0
- package/dist/prompts/commands/discuss-phase.md +15 -0
- package/dist/prompts/commands/execute-phase.md +14 -0
- package/dist/prompts/commands/fix.md +14 -0
- package/dist/prompts/commands/init-project.md +16 -0
- package/dist/prompts/commands/map-codebase.md +16 -0
- package/dist/prompts/commands/new-project.md +16 -0
- package/dist/prompts/commands/next-milestone.md +16 -0
- package/dist/prompts/commands/orchestrate.md +57 -0
- package/dist/prompts/commands/pause-work.md +13 -0
- package/dist/prompts/commands/plan-phase.md +15 -0
- package/dist/prompts/commands/progress.md +13 -0
- package/dist/prompts/commands/quick.md +14 -0
- package/dist/prompts/commands/resume-work.md +13 -0
- package/dist/prompts/commands/review.md +15 -0
- package/dist/prompts/commands/verify-work.md +15 -0
- package/dist/utils/paths.d.ts +7 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +19 -0
- package/dist/utils/paths.js.map +1 -0
- package/docs/compaction.md +5 -3
- package/docs/custom-provider.md +1 -1
- package/docs/development.md +3 -1
- package/docs/extensions.md +150 -54
- package/docs/json.md +5 -2
- package/docs/keybindings.md +2 -0
- package/docs/models.md +55 -4
- package/docs/rpc.md +21 -7
- package/docs/sdk.md +116 -48
- package/docs/session.md +3 -3
- package/docs/settings.md +12 -0
- package/docs/skills.md +3 -2
- package/docs/tree.md +5 -2
- package/examples/README.md +1 -1
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/antigravity-image-gen.ts +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
- package/examples/extensions/doom-overlay/doom/build.sh +2 -2
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/overlay-qa-tests.ts +2 -2
- package/examples/extensions/sandbox/index.ts +8 -4
- package/examples/extensions/subagent/index.ts +5 -5
- package/examples/extensions/trigger-compact.ts +11 -1
- package/examples/sdk/13-session-runtime.ts +30 -12
- package/examples/sdk/README.md +4 -2
- package/package.json +7 -8
- package/prompts/commands/atomic-commit.md +17 -0
- package/prompts/commands/discuss-phase.md +15 -0
- package/prompts/commands/execute-phase.md +14 -0
- package/prompts/commands/fix.md +14 -0
- package/prompts/commands/init-project.md +16 -0
- package/prompts/commands/map-codebase.md +16 -0
- package/prompts/commands/new-project.md +16 -0
- package/prompts/commands/next-milestone.md +16 -0
- package/prompts/commands/orchestrate.md +57 -0
- package/prompts/commands/pause-work.md +13 -0
- package/prompts/commands/plan-phase.md +15 -0
- package/prompts/commands/progress.md +13 -0
- package/prompts/commands/quick.md +14 -0
- package/prompts/commands/resume-work.md +13 -0
- package/prompts/commands/review.md +15 -0
- package/prompts/commands/verify-work.md +15 -0
|
@@ -15,6 +15,7 @@ import { KeybindingsManager } from "../../core/keybindings.js";
|
|
|
15
15
|
import { createCompactionSummaryMessage } from "../../core/messages.js";
|
|
16
16
|
import { findExactModelReferenceMatch, resolveModelScope } from "../../core/model-resolver.js";
|
|
17
17
|
import { DefaultPackageManager } from "../../core/package-manager.js";
|
|
18
|
+
import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
|
|
18
19
|
import { SessionManager } from "../../core/session-manager.js";
|
|
19
20
|
import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
|
|
20
21
|
import { getChangelogPath, getNewEntries, parseChangelog } from "../../utils/changelog.js";
|
|
@@ -32,6 +33,7 @@ import { CustomEditor } from "./components/custom-editor.js";
|
|
|
32
33
|
import { CustomMessageComponent } from "./components/custom-message.js";
|
|
33
34
|
import { DaxnutsComponent } from "./components/daxnuts.js";
|
|
34
35
|
import { DynamicBorder } from "./components/dynamic-border.js";
|
|
36
|
+
import { EarendilAnnouncementComponent } from "./components/earendil-announcement.js";
|
|
35
37
|
import { ExtensionEditorComponent } from "./components/extension-editor.js";
|
|
36
38
|
import { ExtensionInputComponent } from "./components/extension-input.js";
|
|
37
39
|
import { ExtensionSelectorComponent } from "./components/extension-selector.js";
|
|
@@ -48,10 +50,14 @@ import { ToolExecutionComponent } from "./components/tool-execution.js";
|
|
|
48
50
|
import { TreeSelectorComponent } from "./components/tree-selector.js";
|
|
49
51
|
import { UserMessageComponent } from "./components/user-message.js";
|
|
50
52
|
import { UserMessageSelectorComponent } from "./components/user-message-selector.js";
|
|
51
|
-
import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, initTheme, onThemeChange, setRegisteredThemes, setTheme, setThemeInstance, Theme, theme, } from "./theme/theme.js";
|
|
53
|
+
import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, initTheme, onThemeChange, setRegisteredThemes, setTheme, setThemeInstance, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
|
|
52
54
|
function isExpandable(obj) {
|
|
53
55
|
return typeof obj === "object" && obj !== null && "setExpanded" in obj && typeof obj.setExpanded === "function";
|
|
54
56
|
}
|
|
57
|
+
const ANTHROPIC_SUBSCRIPTION_AUTH_WARNING = "Anthropic subscription auth is active. Third-party usage now draws from extra usage and is billed per token, not your Claude plan limits. Manage extra usage at https://claude.ai/settings/usage.";
|
|
58
|
+
function isAnthropicSubscriptionAuthKey(apiKey) {
|
|
59
|
+
return typeof apiKey === "string" && apiKey.startsWith("sk-ant-oat");
|
|
60
|
+
}
|
|
55
61
|
export class InteractiveMode {
|
|
56
62
|
options;
|
|
57
63
|
runtimeHost;
|
|
@@ -74,9 +80,13 @@ export class InteractiveMode {
|
|
|
74
80
|
loadingAnimation = undefined;
|
|
75
81
|
pendingWorkingMessage = undefined;
|
|
76
82
|
defaultWorkingMessage = "Working...";
|
|
83
|
+
defaultHiddenThinkingLabel = "Thinking...";
|
|
84
|
+
hiddenThinkingLabel = this.defaultHiddenThinkingLabel;
|
|
77
85
|
lastSigintTime = 0;
|
|
78
86
|
lastEscapeTime = 0;
|
|
79
87
|
changelogMarkdown = undefined;
|
|
88
|
+
startupNoticesShown = false;
|
|
89
|
+
anthropicSubscriptionWarningShown = false;
|
|
80
90
|
// Status line tracking (for mutating immediately-sequential status updates)
|
|
81
91
|
lastStatusSpacer = undefined;
|
|
82
92
|
lastStatusText = undefined;
|
|
@@ -278,6 +288,32 @@ export class InteractiveMode {
|
|
|
278
288
|
this.editor.setAutocompleteProvider?.(this.autocompleteProvider);
|
|
279
289
|
}
|
|
280
290
|
}
|
|
291
|
+
showStartupNoticesIfNeeded() {
|
|
292
|
+
if (this.startupNoticesShown) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
this.startupNoticesShown = true;
|
|
296
|
+
if (!this.changelogMarkdown) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (this.chatContainer.children.length > 0) {
|
|
300
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
301
|
+
}
|
|
302
|
+
this.chatContainer.addChild(new DynamicBorder());
|
|
303
|
+
if (this.settingsManager.getCollapseChangelog()) {
|
|
304
|
+
const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
|
|
305
|
+
const latestVersion = versionMatch ? versionMatch[1] : this.version;
|
|
306
|
+
const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
|
|
307
|
+
this.chatContainer.addChild(new Text(condensedText, 1, 0));
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
this.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
|
311
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
312
|
+
this.chatContainer.addChild(new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()));
|
|
313
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
314
|
+
}
|
|
315
|
+
this.chatContainer.addChild(new DynamicBorder());
|
|
316
|
+
}
|
|
281
317
|
async init() {
|
|
282
318
|
if (this.isInitialized)
|
|
283
319
|
return;
|
|
@@ -291,7 +327,19 @@ export class InteractiveMode {
|
|
|
291
327
|
this.ui.addChild(this.headerContainer);
|
|
292
328
|
// Add header with keybindings from config (unless silenced)
|
|
293
329
|
if (this.options.verbose || !this.settingsManager.getQuietStartup()) {
|
|
294
|
-
const
|
|
330
|
+
const asciiArt = [
|
|
331
|
+
" ╭─╮",
|
|
332
|
+
" ╰─┼──────────╮",
|
|
333
|
+
" │ ┌──────╮ │",
|
|
334
|
+
" │ │ │ │",
|
|
335
|
+
" │ │ │ │",
|
|
336
|
+
" └─┼──────╯ │",
|
|
337
|
+
" └────────╯",
|
|
338
|
+
]
|
|
339
|
+
.map((line) => theme.fg("border", line))
|
|
340
|
+
.join("\n");
|
|
341
|
+
const wordmark = theme.bold(theme.fg("accent", APP_NAME)) + theme.fg("dim", ` v${this.version} · /dʁaːt/`);
|
|
342
|
+
const logo = `${asciiArt}\n${wordmark}`;
|
|
295
343
|
// Build startup instructions using keybinding hint helpers
|
|
296
344
|
const hint = (keybinding, description) => keyHint(keybinding, description);
|
|
297
345
|
const instructions = [
|
|
@@ -315,41 +363,17 @@ export class InteractiveMode {
|
|
|
315
363
|
hint("app.clipboard.pasteImage", "to paste image"),
|
|
316
364
|
rawKeyHint("drop files", "to attach"),
|
|
317
365
|
].join("\n");
|
|
318
|
-
|
|
366
|
+
const onboarding = theme.fg("dim", `Draht can explain its own features and look up its docs. Ask it how to use or extend draht.`);
|
|
367
|
+
this.builtInHeader = new Text(`${logo}\n${instructions}\n\n${onboarding}`, 1, 0);
|
|
319
368
|
// Setup UI layout
|
|
320
369
|
this.headerContainer.addChild(new Spacer(1));
|
|
321
370
|
this.headerContainer.addChild(this.builtInHeader);
|
|
322
371
|
this.headerContainer.addChild(new Spacer(1));
|
|
323
|
-
// Add changelog if provided
|
|
324
|
-
if (this.changelogMarkdown) {
|
|
325
|
-
this.headerContainer.addChild(new DynamicBorder());
|
|
326
|
-
if (this.settingsManager.getCollapseChangelog()) {
|
|
327
|
-
const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
|
|
328
|
-
const latestVersion = versionMatch ? versionMatch[1] : this.version;
|
|
329
|
-
const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
|
|
330
|
-
this.headerContainer.addChild(new Text(condensedText, 1, 0));
|
|
331
|
-
}
|
|
332
|
-
else {
|
|
333
|
-
this.headerContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
|
334
|
-
this.headerContainer.addChild(new Spacer(1));
|
|
335
|
-
this.headerContainer.addChild(new Markdown(this.changelogMarkdown.trim(), 1, 0, this.getMarkdownThemeWithSettings()));
|
|
336
|
-
this.headerContainer.addChild(new Spacer(1));
|
|
337
|
-
}
|
|
338
|
-
this.headerContainer.addChild(new DynamicBorder());
|
|
339
|
-
}
|
|
340
372
|
}
|
|
341
373
|
else {
|
|
342
374
|
// Minimal header when silenced
|
|
343
375
|
this.builtInHeader = new Text("", 0, 0);
|
|
344
376
|
this.headerContainer.addChild(this.builtInHeader);
|
|
345
|
-
if (this.changelogMarkdown) {
|
|
346
|
-
// Still show changelog notification even in silent mode
|
|
347
|
-
this.headerContainer.addChild(new Spacer(1));
|
|
348
|
-
const versionMatch = this.changelogMarkdown.match(/##\s+\[?(\d+\.\d+\.\d+)\]?/);
|
|
349
|
-
const latestVersion = versionMatch ? versionMatch[1] : this.version;
|
|
350
|
-
const condensedText = `Updated to v${latestVersion}. Use ${theme.bold("/changelog")} to view full changelog.`;
|
|
351
|
-
this.headerContainer.addChild(new Text(condensedText, 1, 0));
|
|
352
|
-
}
|
|
353
377
|
}
|
|
354
378
|
this.ui.addChild(this.chatContainer);
|
|
355
379
|
this.ui.addChild(this.pendingMessagesContainer);
|
|
@@ -393,10 +417,10 @@ export class InteractiveMode {
|
|
|
393
417
|
const cwdBasename = path.basename(this.sessionManager.getCwd());
|
|
394
418
|
const sessionName = this.sessionManager.getSessionName();
|
|
395
419
|
if (sessionName) {
|
|
396
|
-
this.ui.terminal.setTitle(
|
|
420
|
+
this.ui.terminal.setTitle(`π - ${sessionName} - ${cwdBasename}`);
|
|
397
421
|
}
|
|
398
422
|
else {
|
|
399
|
-
this.ui.terminal.setTitle(
|
|
423
|
+
this.ui.terminal.setTitle(`π - ${cwdBasename}`);
|
|
400
424
|
}
|
|
401
425
|
}
|
|
402
426
|
/**
|
|
@@ -435,6 +459,7 @@ export class InteractiveMode {
|
|
|
435
459
|
if (modelFallbackMessage) {
|
|
436
460
|
this.showWarning(modelFallbackMessage);
|
|
437
461
|
}
|
|
462
|
+
void this.maybeWarnAboutAnthropicSubscriptionAuth();
|
|
438
463
|
// Process initial messages
|
|
439
464
|
if (initialMessage) {
|
|
440
465
|
try {
|
|
@@ -558,6 +583,10 @@ export class InteractiveMode {
|
|
|
558
583
|
if (this.session.state.messages.length > 0) {
|
|
559
584
|
return undefined;
|
|
560
585
|
}
|
|
586
|
+
// Skip changelog in dev mode — "dev" parses as 0.0.0 and would surface every entry.
|
|
587
|
+
if (VERSION === "dev") {
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
561
590
|
const lastVersion = this.settingsManager.getLastChangelogVersion();
|
|
562
591
|
const changelogPath = getChangelogPath();
|
|
563
592
|
const entries = parseChangelog(changelogPath);
|
|
@@ -897,23 +926,33 @@ export class InteractiveMode {
|
|
|
897
926
|
this.loadingAnimation = undefined;
|
|
898
927
|
}
|
|
899
928
|
this.statusContainer.clear();
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
929
|
+
try {
|
|
930
|
+
const result = await this.runtimeHost.newSession(options);
|
|
931
|
+
if (!result.cancelled) {
|
|
932
|
+
await this.handleRuntimeSessionChange();
|
|
933
|
+
this.renderCurrentSessionState();
|
|
934
|
+
this.ui.requestRender();
|
|
935
|
+
}
|
|
936
|
+
return result;
|
|
937
|
+
}
|
|
938
|
+
catch (error) {
|
|
939
|
+
return this.handleFatalRuntimeError("Failed to create session", error);
|
|
905
940
|
}
|
|
906
|
-
return result;
|
|
907
941
|
},
|
|
908
942
|
fork: async (entryId) => {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
943
|
+
try {
|
|
944
|
+
const result = await this.runtimeHost.fork(entryId);
|
|
945
|
+
if (!result.cancelled) {
|
|
946
|
+
await this.handleRuntimeSessionChange();
|
|
947
|
+
this.renderCurrentSessionState();
|
|
948
|
+
this.editor.setText(result.selectedText ?? "");
|
|
949
|
+
this.showStatus("Forked to new session");
|
|
950
|
+
}
|
|
951
|
+
return { cancelled: result.cancelled };
|
|
952
|
+
}
|
|
953
|
+
catch (error) {
|
|
954
|
+
return this.handleFatalRuntimeError("Failed to fork session", error);
|
|
915
955
|
}
|
|
916
|
-
return { cancelled: result.cancelled };
|
|
917
956
|
},
|
|
918
957
|
navigateTree: async (targetId, options) => {
|
|
919
958
|
const result = await this.session.navigateTree(targetId, {
|
|
@@ -956,10 +995,12 @@ export class InteractiveMode {
|
|
|
956
995
|
const extensionRunner = this.session.extensionRunner;
|
|
957
996
|
if (!extensionRunner) {
|
|
958
997
|
this.showLoadedResources({ extensions: [], force: false });
|
|
998
|
+
this.showStartupNoticesIfNeeded();
|
|
959
999
|
return;
|
|
960
1000
|
}
|
|
961
1001
|
this.setupExtensionShortcuts(extensionRunner);
|
|
962
1002
|
this.showLoadedResources({ force: false });
|
|
1003
|
+
this.showStartupNoticesIfNeeded();
|
|
963
1004
|
}
|
|
964
1005
|
applyRuntimeSettings() {
|
|
965
1006
|
this.footer.setSession(this.session);
|
|
@@ -988,6 +1029,13 @@ export class InteractiveMode {
|
|
|
988
1029
|
this.updateEditorBorderColor();
|
|
989
1030
|
this.updateTerminalTitle();
|
|
990
1031
|
}
|
|
1032
|
+
async handleFatalRuntimeError(prefix, error) {
|
|
1033
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1034
|
+
this.showError(`${prefix}: ${message}`);
|
|
1035
|
+
stopThemeWatcher();
|
|
1036
|
+
this.stop();
|
|
1037
|
+
process.exit(1);
|
|
1038
|
+
}
|
|
991
1039
|
renderCurrentSessionState() {
|
|
992
1040
|
this.chatContainer.clear();
|
|
993
1041
|
this.pendingMessagesContainer.clear();
|
|
@@ -1019,6 +1067,7 @@ export class InteractiveMode {
|
|
|
1019
1067
|
modelRegistry: this.session.modelRegistry,
|
|
1020
1068
|
model: this.session.model,
|
|
1021
1069
|
isIdle: () => !this.session.isStreaming,
|
|
1070
|
+
signal: this.session.agent.signal,
|
|
1022
1071
|
abort: () => this.session.abort(),
|
|
1023
1072
|
hasPendingMessages: () => this.session.pendingMessageCount > 0,
|
|
1024
1073
|
shutdown: () => {
|
|
@@ -1028,10 +1077,8 @@ export class InteractiveMode {
|
|
|
1028
1077
|
compact: (options) => {
|
|
1029
1078
|
void (async () => {
|
|
1030
1079
|
try {
|
|
1031
|
-
const result = await this.
|
|
1032
|
-
|
|
1033
|
-
options?.onComplete?.(result);
|
|
1034
|
-
}
|
|
1080
|
+
const result = await this.session.compact(options?.customInstructions);
|
|
1081
|
+
options?.onComplete?.(result);
|
|
1035
1082
|
}
|
|
1036
1083
|
catch (error) {
|
|
1037
1084
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
@@ -1063,6 +1110,18 @@ export class InteractiveMode {
|
|
|
1063
1110
|
this.footerDataProvider.setExtensionStatus(key, text);
|
|
1064
1111
|
this.ui.requestRender();
|
|
1065
1112
|
}
|
|
1113
|
+
setHiddenThinkingLabel(label) {
|
|
1114
|
+
this.hiddenThinkingLabel = label ?? this.defaultHiddenThinkingLabel;
|
|
1115
|
+
for (const child of this.chatContainer.children) {
|
|
1116
|
+
if (child instanceof AssistantMessageComponent) {
|
|
1117
|
+
child.setHiddenThinkingLabel(this.hiddenThinkingLabel);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if (this.streamingComponent) {
|
|
1121
|
+
this.streamingComponent.setHiddenThinkingLabel(this.hiddenThinkingLabel);
|
|
1122
|
+
}
|
|
1123
|
+
this.ui.requestRender();
|
|
1124
|
+
}
|
|
1066
1125
|
/**
|
|
1067
1126
|
* Set an extension widget (string array or custom component).
|
|
1068
1127
|
*/
|
|
@@ -1134,6 +1193,7 @@ export class InteractiveMode {
|
|
|
1134
1193
|
if (this.loadingAnimation) {
|
|
1135
1194
|
this.loadingAnimation.setMessage(`${this.defaultWorkingMessage} (${keyText("app.interrupt")} to interrupt)`);
|
|
1136
1195
|
}
|
|
1196
|
+
this.setHiddenThinkingLabel();
|
|
1137
1197
|
}
|
|
1138
1198
|
// Maximum total widget lines to prevent viewport overflow
|
|
1139
1199
|
static MAX_WIDGET_LINES = 10;
|
|
@@ -1263,6 +1323,7 @@ export class InteractiveMode {
|
|
|
1263
1323
|
this.pendingWorkingMessage = message;
|
|
1264
1324
|
}
|
|
1265
1325
|
},
|
|
1326
|
+
setHiddenThinkingLabel: (label) => this.setHiddenThinkingLabel(label),
|
|
1266
1327
|
setWidget: (key, content, options) => this.setExtensionWidget(key, content, options),
|
|
1267
1328
|
setFooter: (factory) => this.setExtensionFooter(factory),
|
|
1268
1329
|
setHeader: (factory) => this.setExtensionHeader(factory),
|
|
@@ -1344,6 +1405,10 @@ export class InteractiveMode {
|
|
|
1344
1405
|
const result = await this.showExtensionSelector(`${title}\n${message}`, ["Yes", "No"], opts);
|
|
1345
1406
|
return result === "Yes";
|
|
1346
1407
|
}
|
|
1408
|
+
async promptForMissingSessionCwd(error) {
|
|
1409
|
+
const confirmed = await this.showExtensionConfirm("Session cwd not found", formatMissingSessionCwdPrompt(error.issue));
|
|
1410
|
+
return confirmed ? error.issue.fallbackCwd : undefined;
|
|
1411
|
+
}
|
|
1347
1412
|
/**
|
|
1348
1413
|
* Show a text input for extensions.
|
|
1349
1414
|
*/
|
|
@@ -1771,6 +1836,11 @@ export class InteractiveMode {
|
|
|
1771
1836
|
this.editor.setText("");
|
|
1772
1837
|
return;
|
|
1773
1838
|
}
|
|
1839
|
+
if (text === "/dementedelves") {
|
|
1840
|
+
this.handleDementedDelves();
|
|
1841
|
+
this.editor.setText("");
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1774
1844
|
if (text === "/resume") {
|
|
1775
1845
|
this.showSessionSelector();
|
|
1776
1846
|
this.editor.setText("");
|
|
@@ -1866,6 +1936,10 @@ export class InteractiveMode {
|
|
|
1866
1936
|
}
|
|
1867
1937
|
this.ui.requestRender();
|
|
1868
1938
|
break;
|
|
1939
|
+
case "queue_update":
|
|
1940
|
+
this.updatePendingMessagesDisplay();
|
|
1941
|
+
this.ui.requestRender();
|
|
1942
|
+
break;
|
|
1869
1943
|
case "message_start":
|
|
1870
1944
|
if (event.message.role === "custom") {
|
|
1871
1945
|
this.addMessageToChat(event.message);
|
|
@@ -1877,7 +1951,7 @@ export class InteractiveMode {
|
|
|
1877
1951
|
this.ui.requestRender();
|
|
1878
1952
|
}
|
|
1879
1953
|
else if (event.message.role === "assistant") {
|
|
1880
|
-
this.streamingComponent = new AssistantMessageComponent(undefined, this.hideThinkingBlock, this.getMarkdownThemeWithSettings());
|
|
1954
|
+
this.streamingComponent = new AssistantMessageComponent(undefined, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel);
|
|
1881
1955
|
this.streamingMessage = event.message;
|
|
1882
1956
|
this.chatContainer.addChild(this.streamingComponent);
|
|
1883
1957
|
this.streamingComponent.updateContent(this.streamingMessage);
|
|
@@ -1994,54 +2068,54 @@ export class InteractiveMode {
|
|
|
1994
2068
|
await this.checkShutdownRequested();
|
|
1995
2069
|
this.ui.requestRender();
|
|
1996
2070
|
break;
|
|
1997
|
-
case "
|
|
2071
|
+
case "compaction_start": {
|
|
1998
2072
|
// Keep editor active; submissions are queued during compaction.
|
|
1999
|
-
// Set up escape to abort auto-compaction
|
|
2000
2073
|
this.autoCompactionEscapeHandler = this.defaultEditor.onEscape;
|
|
2001
2074
|
this.defaultEditor.onEscape = () => {
|
|
2002
2075
|
this.session.abortCompaction();
|
|
2003
2076
|
};
|
|
2004
|
-
// Show compacting indicator with reason
|
|
2005
2077
|
this.statusContainer.clear();
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2078
|
+
const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
|
|
2079
|
+
const label = event.reason === "manual"
|
|
2080
|
+
? `Compacting context... ${cancelHint}`
|
|
2081
|
+
: `${event.reason === "overflow" ? "Context overflow detected, " : ""}Auto-compacting... ${cancelHint}`;
|
|
2082
|
+
this.autoCompactionLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
|
|
2008
2083
|
this.statusContainer.addChild(this.autoCompactionLoader);
|
|
2009
2084
|
this.ui.requestRender();
|
|
2010
2085
|
break;
|
|
2011
2086
|
}
|
|
2012
|
-
case "
|
|
2013
|
-
// Restore escape handler
|
|
2087
|
+
case "compaction_end": {
|
|
2014
2088
|
if (this.autoCompactionEscapeHandler) {
|
|
2015
2089
|
this.defaultEditor.onEscape = this.autoCompactionEscapeHandler;
|
|
2016
2090
|
this.autoCompactionEscapeHandler = undefined;
|
|
2017
2091
|
}
|
|
2018
|
-
// Stop loader
|
|
2019
2092
|
if (this.autoCompactionLoader) {
|
|
2020
2093
|
this.autoCompactionLoader.stop();
|
|
2021
2094
|
this.autoCompactionLoader = undefined;
|
|
2022
2095
|
this.statusContainer.clear();
|
|
2023
2096
|
}
|
|
2024
|
-
// Handle result
|
|
2025
2097
|
if (event.aborted) {
|
|
2026
|
-
|
|
2098
|
+
if (event.reason === "manual") {
|
|
2099
|
+
this.showError("Compaction cancelled");
|
|
2100
|
+
}
|
|
2101
|
+
else {
|
|
2102
|
+
this.showStatus("Auto-compaction cancelled");
|
|
2103
|
+
}
|
|
2027
2104
|
}
|
|
2028
2105
|
else if (event.result) {
|
|
2029
|
-
// Rebuild chat to show compacted state
|
|
2030
2106
|
this.chatContainer.clear();
|
|
2031
2107
|
this.rebuildChatFromMessages();
|
|
2032
|
-
|
|
2033
|
-
this.addMessageToChat({
|
|
2034
|
-
role: "compactionSummary",
|
|
2035
|
-
tokensBefore: event.result.tokensBefore,
|
|
2036
|
-
summary: event.result.summary,
|
|
2037
|
-
timestamp: Date.now(),
|
|
2038
|
-
});
|
|
2108
|
+
this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
|
|
2039
2109
|
this.footer.invalidate();
|
|
2040
2110
|
}
|
|
2041
2111
|
else if (event.errorMessage) {
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2112
|
+
if (event.reason === "manual") {
|
|
2113
|
+
this.showError(event.errorMessage);
|
|
2114
|
+
}
|
|
2115
|
+
else {
|
|
2116
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
2117
|
+
this.chatContainer.addChild(new Text(theme.fg("error", event.errorMessage), 1, 0));
|
|
2118
|
+
}
|
|
2045
2119
|
}
|
|
2046
2120
|
void this.flushCompactionQueue({ willRetry: event.willRetry });
|
|
2047
2121
|
this.ui.requestRender();
|
|
@@ -2175,7 +2249,7 @@ export class InteractiveMode {
|
|
|
2175
2249
|
break;
|
|
2176
2250
|
}
|
|
2177
2251
|
case "assistant": {
|
|
2178
|
-
const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings());
|
|
2252
|
+
const assistantComponent = new AssistantMessageComponent(message, this.hideThinkingBlock, this.getMarkdownThemeWithSettings(), this.hiddenThinkingLabel);
|
|
2179
2253
|
this.chatContainer.addChild(assistantComponent);
|
|
2180
2254
|
break;
|
|
2181
2255
|
}
|
|
@@ -2418,6 +2492,7 @@ export class InteractiveMode {
|
|
|
2418
2492
|
this.updateEditorBorderColor();
|
|
2419
2493
|
const thinkingStr = result.model.reasoning && result.thinkingLevel !== "off" ? ` (thinking: ${result.thinkingLevel})` : "";
|
|
2420
2494
|
this.showStatus(`Switched to ${result.model.name || result.model.id}${thinkingStr}`);
|
|
2495
|
+
void this.maybeWarnAboutAnthropicSubscriptionAuth(result.model);
|
|
2421
2496
|
}
|
|
2422
2497
|
}
|
|
2423
2498
|
catch (error) {
|
|
@@ -2770,7 +2845,7 @@ export class InteractiveMode {
|
|
|
2770
2845
|
},
|
|
2771
2846
|
onTransportChange: (transport) => {
|
|
2772
2847
|
this.settingsManager.setTransport(transport);
|
|
2773
|
-
this.session.agent.
|
|
2848
|
+
this.session.agent.transport = transport;
|
|
2774
2849
|
},
|
|
2775
2850
|
onThinkingLevelChange: (level) => {
|
|
2776
2851
|
this.session.setThinkingLevel(level);
|
|
@@ -2857,6 +2932,7 @@ export class InteractiveMode {
|
|
|
2857
2932
|
this.footer.invalidate();
|
|
2858
2933
|
this.updateEditorBorderColor();
|
|
2859
2934
|
this.showStatus(`Model: ${model.id}`);
|
|
2935
|
+
void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
|
|
2860
2936
|
this.checkDaxnutsEasterEgg(model);
|
|
2861
2937
|
}
|
|
2862
2938
|
catch (error) {
|
|
@@ -2888,6 +2964,31 @@ export class InteractiveMode {
|
|
|
2888
2964
|
const uniqueProviders = new Set(models.map((m) => m.provider));
|
|
2889
2965
|
this.footerDataProvider.setAvailableProviderCount(uniqueProviders.size);
|
|
2890
2966
|
}
|
|
2967
|
+
async maybeWarnAboutAnthropicSubscriptionAuth(model = this.session.model) {
|
|
2968
|
+
if (this.anthropicSubscriptionWarningShown) {
|
|
2969
|
+
return;
|
|
2970
|
+
}
|
|
2971
|
+
if (!model || model.provider !== "anthropic") {
|
|
2972
|
+
return;
|
|
2973
|
+
}
|
|
2974
|
+
const storedCredential = this.session.modelRegistry.authStorage.get("anthropic");
|
|
2975
|
+
if (storedCredential?.type === "oauth") {
|
|
2976
|
+
this.anthropicSubscriptionWarningShown = true;
|
|
2977
|
+
this.showWarning(ANTHROPIC_SUBSCRIPTION_AUTH_WARNING);
|
|
2978
|
+
return;
|
|
2979
|
+
}
|
|
2980
|
+
try {
|
|
2981
|
+
const apiKey = await this.session.modelRegistry.getApiKeyForProvider(model.provider);
|
|
2982
|
+
if (!isAnthropicSubscriptionAuthKey(apiKey)) {
|
|
2983
|
+
return;
|
|
2984
|
+
}
|
|
2985
|
+
this.anthropicSubscriptionWarningShown = true;
|
|
2986
|
+
this.showWarning(ANTHROPIC_SUBSCRIPTION_AUTH_WARNING);
|
|
2987
|
+
}
|
|
2988
|
+
catch {
|
|
2989
|
+
// Ignore auth lookup failures for warning-only checks.
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2891
2992
|
showModelSelector(initialSearchInput) {
|
|
2892
2993
|
this.showSelector((done) => {
|
|
2893
2994
|
const selector = new ModelSelectorComponent(this.ui, this.session.model, this.settingsManager, this.session.modelRegistry, this.session.scopedModels, async (model) => {
|
|
@@ -2897,6 +2998,7 @@ export class InteractiveMode {
|
|
|
2897
2998
|
this.updateEditorBorderColor();
|
|
2898
2999
|
done();
|
|
2899
3000
|
this.showStatus(`Model: ${model.id}`);
|
|
3001
|
+
void this.maybeWarnAboutAnthropicSubscriptionAuth(model);
|
|
2900
3002
|
this.checkDaxnutsEasterEgg(model);
|
|
2901
3003
|
}
|
|
2902
3004
|
catch (error) {
|
|
@@ -3175,13 +3277,33 @@ export class InteractiveMode {
|
|
|
3175
3277
|
this.loadingAnimation = undefined;
|
|
3176
3278
|
}
|
|
3177
3279
|
this.statusContainer.clear();
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3280
|
+
try {
|
|
3281
|
+
const result = await this.runtimeHost.switchSession(sessionPath);
|
|
3282
|
+
if (result.cancelled) {
|
|
3283
|
+
return;
|
|
3284
|
+
}
|
|
3285
|
+
await this.handleRuntimeSessionChange();
|
|
3286
|
+
this.renderCurrentSessionState();
|
|
3287
|
+
this.showStatus("Resumed session");
|
|
3288
|
+
}
|
|
3289
|
+
catch (error) {
|
|
3290
|
+
if (error instanceof MissingSessionCwdError) {
|
|
3291
|
+
const selectedCwd = await this.promptForMissingSessionCwd(error);
|
|
3292
|
+
if (!selectedCwd) {
|
|
3293
|
+
this.showStatus("Resume cancelled");
|
|
3294
|
+
return;
|
|
3295
|
+
}
|
|
3296
|
+
const result = await this.runtimeHost.switchSession(sessionPath, selectedCwd);
|
|
3297
|
+
if (result.cancelled) {
|
|
3298
|
+
return;
|
|
3299
|
+
}
|
|
3300
|
+
await this.handleRuntimeSessionChange();
|
|
3301
|
+
this.renderCurrentSessionState();
|
|
3302
|
+
this.showStatus("Resumed session in current cwd");
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
await this.handleFatalRuntimeError("Failed to resume session", error);
|
|
3181
3306
|
}
|
|
3182
|
-
await this.handleRuntimeSessionChange();
|
|
3183
|
-
this.renderCurrentSessionState();
|
|
3184
|
-
this.showStatus("Resumed session");
|
|
3185
3307
|
}
|
|
3186
3308
|
async showOAuthSelector(mode) {
|
|
3187
3309
|
if (mode === "logout") {
|
|
@@ -3414,7 +3536,23 @@ export class InteractiveMode {
|
|
|
3414
3536
|
this.showStatus(`Session imported from: ${inputPath}`);
|
|
3415
3537
|
}
|
|
3416
3538
|
catch (error) {
|
|
3417
|
-
|
|
3539
|
+
if (error instanceof MissingSessionCwdError) {
|
|
3540
|
+
const selectedCwd = await this.promptForMissingSessionCwd(error);
|
|
3541
|
+
if (!selectedCwd) {
|
|
3542
|
+
this.showStatus("Import cancelled");
|
|
3543
|
+
return;
|
|
3544
|
+
}
|
|
3545
|
+
const result = await this.runtimeHost.importFromJsonl(inputPath, selectedCwd);
|
|
3546
|
+
if (result.cancelled) {
|
|
3547
|
+
this.showStatus("Import cancelled");
|
|
3548
|
+
return;
|
|
3549
|
+
}
|
|
3550
|
+
await this.handleRuntimeSessionChange();
|
|
3551
|
+
this.renderCurrentSessionState();
|
|
3552
|
+
this.showStatus(`Session imported from: ${inputPath}`);
|
|
3553
|
+
return;
|
|
3554
|
+
}
|
|
3555
|
+
await this.handleFatalRuntimeError("Failed to import session", error);
|
|
3418
3556
|
}
|
|
3419
3557
|
}
|
|
3420
3558
|
async handleShareCommand() {
|
|
@@ -3729,15 +3867,20 @@ export class InteractiveMode {
|
|
|
3729
3867
|
this.loadingAnimation = undefined;
|
|
3730
3868
|
}
|
|
3731
3869
|
this.statusContainer.clear();
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3870
|
+
try {
|
|
3871
|
+
const result = await this.runtimeHost.newSession();
|
|
3872
|
+
if (result.cancelled) {
|
|
3873
|
+
return;
|
|
3874
|
+
}
|
|
3875
|
+
await this.handleRuntimeSessionChange();
|
|
3876
|
+
this.renderCurrentSessionState();
|
|
3877
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3878
|
+
this.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ New session started")}`, 1, 1));
|
|
3879
|
+
this.ui.requestRender();
|
|
3880
|
+
}
|
|
3881
|
+
catch (error) {
|
|
3882
|
+
await this.handleFatalRuntimeError("Failed to create session", error);
|
|
3735
3883
|
}
|
|
3736
|
-
await this.handleRuntimeSessionChange();
|
|
3737
|
-
this.renderCurrentSessionState();
|
|
3738
|
-
this.chatContainer.addChild(new Spacer(1));
|
|
3739
|
-
this.chatContainer.addChild(new Text(`${theme.fg("accent", "✓ New session started")}`, 1, 1));
|
|
3740
|
-
this.ui.requestRender();
|
|
3741
3884
|
}
|
|
3742
3885
|
handleDebugCommand() {
|
|
3743
3886
|
const width = this.ui.terminal.columns;
|
|
@@ -3771,6 +3914,11 @@ export class InteractiveMode {
|
|
|
3771
3914
|
this.chatContainer.addChild(new ArminComponent(this.ui));
|
|
3772
3915
|
this.ui.requestRender();
|
|
3773
3916
|
}
|
|
3917
|
+
handleDementedDelves() {
|
|
3918
|
+
this.chatContainer.addChild(new Spacer(1));
|
|
3919
|
+
this.chatContainer.addChild(new EarendilAnnouncementComponent());
|
|
3920
|
+
this.ui.requestRender();
|
|
3921
|
+
}
|
|
3774
3922
|
handleDaxnuts() {
|
|
3775
3923
|
this.chatContainer.addChild(new Spacer(1));
|
|
3776
3924
|
this.chatContainer.addChild(new DaxnutsComponent(this.ui));
|
|
@@ -3855,53 +4003,17 @@ export class InteractiveMode {
|
|
|
3855
4003
|
this.showWarning("Nothing to compact (no messages yet)");
|
|
3856
4004
|
return;
|
|
3857
4005
|
}
|
|
3858
|
-
await this.executeCompaction(customInstructions, false);
|
|
3859
|
-
}
|
|
3860
|
-
async executeCompaction(customInstructions, isAuto = false) {
|
|
3861
|
-
// Stop loading animation
|
|
3862
4006
|
if (this.loadingAnimation) {
|
|
3863
4007
|
this.loadingAnimation.stop();
|
|
3864
4008
|
this.loadingAnimation = undefined;
|
|
3865
4009
|
}
|
|
3866
4010
|
this.statusContainer.clear();
|
|
3867
|
-
// Set up escape handler during compaction
|
|
3868
|
-
const originalOnEscape = this.defaultEditor.onEscape;
|
|
3869
|
-
this.defaultEditor.onEscape = () => {
|
|
3870
|
-
this.session.abortCompaction();
|
|
3871
|
-
};
|
|
3872
|
-
// Show compacting status
|
|
3873
|
-
this.chatContainer.addChild(new Spacer(1));
|
|
3874
|
-
const cancelHint = `(${keyText("app.interrupt")} to cancel)`;
|
|
3875
|
-
const label = isAuto ? `Auto-compacting context... ${cancelHint}` : `Compacting context... ${cancelHint}`;
|
|
3876
|
-
const compactingLoader = new Loader(this.ui, (spinner) => theme.fg("accent", spinner), (text) => theme.fg("muted", text), label);
|
|
3877
|
-
this.statusContainer.addChild(compactingLoader);
|
|
3878
|
-
this.ui.requestRender();
|
|
3879
|
-
let result;
|
|
3880
4011
|
try {
|
|
3881
|
-
|
|
3882
|
-
// Rebuild UI
|
|
3883
|
-
this.rebuildChatFromMessages();
|
|
3884
|
-
// Add compaction component at bottom so user sees it without scrolling
|
|
3885
|
-
const msg = createCompactionSummaryMessage(result.summary, result.tokensBefore, new Date().toISOString());
|
|
3886
|
-
this.addMessageToChat(msg);
|
|
3887
|
-
this.footer.invalidate();
|
|
4012
|
+
await this.session.compact(customInstructions);
|
|
3888
4013
|
}
|
|
3889
|
-
catch
|
|
3890
|
-
|
|
3891
|
-
if (message === "Compaction cancelled" || (error instanceof Error && error.name === "AbortError")) {
|
|
3892
|
-
this.showError("Compaction cancelled");
|
|
3893
|
-
}
|
|
3894
|
-
else {
|
|
3895
|
-
this.showError(`Compaction failed: ${message}`);
|
|
3896
|
-
}
|
|
3897
|
-
}
|
|
3898
|
-
finally {
|
|
3899
|
-
compactingLoader.stop();
|
|
3900
|
-
this.statusContainer.clear();
|
|
3901
|
-
this.defaultEditor.onEscape = originalOnEscape;
|
|
4014
|
+
catch {
|
|
4015
|
+
// Ignore, will be emitted as an event
|
|
3902
4016
|
}
|
|
3903
|
-
void this.flushCompactionQueue({ willRetry: false });
|
|
3904
|
-
return result;
|
|
3905
4017
|
}
|
|
3906
4018
|
stop() {
|
|
3907
4019
|
if (this.loadingAnimation) {
|