gsd-pi 2.34.0-dev.bbb5216 → 2.34.0-dev.ed0bfbf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/resources/extensions/mcp-client/index.js +2 -1
- package/package.json +1 -1
- package/packages/native/dist/native.d.ts +0 -2
- package/packages/native/dist/native.js +0 -2
- package/packages/native/src/native.ts +0 -3
- package/packages/pi-agent-core/dist/proxy.d.ts +1 -25
- package/packages/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/packages/pi-agent-core/dist/proxy.js +1 -1
- package/packages/pi-agent-core/dist/proxy.js.map +1 -1
- package/packages/pi-agent-core/src/proxy.ts +1 -1
- package/packages/pi-ai/dist/api-registry.d.ts +0 -2
- package/packages/pi-ai/dist/api-registry.d.ts.map +1 -1
- package/packages/pi-ai/dist/api-registry.js +0 -10
- package/packages/pi-ai/dist/api-registry.js.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts +0 -8
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts +0 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.js +1 -1
- package/packages/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts +1 -43
- package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-gemini-cli.js +2 -2
- package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.d.ts +0 -4
- package/packages/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js +1 -1
- package/packages/pi-ai/dist/providers/google-shared.js.map +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.d.ts +0 -1
- package/packages/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.js +1 -1
- package/packages/pi-ai/dist/providers/register-builtins.js.map +1 -1
- package/packages/pi-ai/dist/utils/event-stream.d.ts +0 -2
- package/packages/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/event-stream.js +0 -4
- package/packages/pi-ai/dist/utils/event-stream.js.map +1 -1
- package/packages/pi-ai/dist/utils/overflow.d.ts +0 -4
- package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/overflow.js +0 -6
- package/packages/pi-ai/dist/utils/overflow.js.map +1 -1
- package/packages/pi-ai/dist/utils/validation.d.ts +0 -8
- package/packages/pi-ai/dist/utils/validation.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/validation.js +0 -14
- package/packages/pi-ai/dist/utils/validation.js.map +1 -1
- package/packages/pi-ai/src/api-registry.ts +0 -12
- package/packages/pi-ai/src/providers/anthropic.ts +1 -1
- package/packages/pi-ai/src/providers/github-copilot-headers.ts +1 -1
- package/packages/pi-ai/src/providers/google-gemini-cli.ts +2 -2
- package/packages/pi-ai/src/providers/google-shared.ts +1 -1
- package/packages/pi-ai/src/providers/register-builtins.ts +1 -1
- package/packages/pi-ai/src/utils/event-stream.ts +0 -5
- package/packages/pi-ai/src/utils/overflow.ts +1 -8
- package/packages/pi-ai/src/utils/validation.ts +0 -15
- package/packages/pi-coding-agent/dist/config.d.ts +0 -9
- package/packages/pi-coding-agent/dist/config.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/config.js +4 -8
- package/packages/pi-coding-agent/dist/config.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts +0 -4
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js +1 -1
- package/packages/pi-coding-agent/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts +0 -5
- package/packages/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/extensions/runner.js +0 -13
- package/packages/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts +0 -8
- package/packages/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/keybindings.js +2 -2
- package/packages/pi-coding-agent/dist/core/keybindings.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts +0 -17
- package/packages/pi-coding-agent/dist/core/lsp/client.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/client.js +3 -62
- package/packages/pi-coding-agent/dist/core/lsp/client.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts +0 -2
- package/packages/pi-coding-agent/dist/core/lsp/config.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/config.js +0 -7
- package/packages/pi-coding-agent/dist/core/lsp/config.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts +0 -5
- package/packages/pi-coding-agent/dist/core/lsp/edits.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/edits.js +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/edits.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts +0 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.js +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/lspmux.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts +1 -6
- package/packages/pi-coding-agent/dist/core/lsp/utils.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/lsp/utils.js +1 -28
- package/packages/pi-coding-agent/dist/core/lsp/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.d.ts +0 -8
- package/packages/pi-coding-agent/dist/core/messages.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/messages.js +5 -5
- package/packages/pi-coding-agent/dist/core/messages.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts +0 -3
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +1 -3
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts +1 -26
- package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-resolver.js +3 -59
- package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts +0 -17
- package/packages/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/prompt-templates.js +2 -2
- package/packages/pi-coding-agent/dist/core/prompt-templates.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts +0 -4
- package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/session-manager.js +2 -4
- package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +0 -12
- package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +2 -2
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/migrations.d.ts +0 -16
- package/packages/pi-coding-agent/dist/migrations.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/migrations.js +2 -2
- package/packages/pi-coding-agent/dist/migrations.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +0 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js +2 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +1 -24
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +50 -512
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts +71 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js +514 -0
- package/packages/pi-coding-agent/dist/modes/interactive/slash-command-handlers.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +0 -4
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +0 -7
- package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts +0 -4
- package/packages/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/changelog.js +1 -1
- package/packages/pi-coding-agent/dist/utils/changelog.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts +0 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js +1 -1
- package/packages/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/photon.d.ts +0 -19
- package/packages/pi-coding-agent/dist/utils/photon.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/photon.js +1 -120
- package/packages/pi-coding-agent/dist/utils/photon.js.map +1 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts +0 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.js +1 -1
- package/packages/pi-coding-agent/dist/utils/tools-manager.js.map +1 -1
- package/packages/pi-coding-agent/src/config.ts +5 -10
- package/packages/pi-coding-agent/src/core/export-html/ansi-to-html.ts +1 -1
- package/packages/pi-coding-agent/src/core/extensions/runner.ts +0 -13
- package/packages/pi-coding-agent/src/core/keybindings.ts +2 -2
- package/packages/pi-coding-agent/src/core/lsp/client.ts +3 -73
- package/packages/pi-coding-agent/src/core/lsp/config.ts +0 -11
- package/packages/pi-coding-agent/src/core/lsp/edits.ts +1 -1
- package/packages/pi-coding-agent/src/core/lsp/lspmux.ts +1 -1
- package/packages/pi-coding-agent/src/core/lsp/utils.ts +1 -33
- package/packages/pi-coding-agent/src/core/messages.ts +5 -5
- package/packages/pi-coding-agent/src/core/model-registry.ts +0 -2
- package/packages/pi-coding-agent/src/core/model-resolver.ts +3 -77
- package/packages/pi-coding-agent/src/core/prompt-templates.ts +2 -2
- package/packages/pi-coding-agent/src/core/session-manager.ts +2 -4
- package/packages/pi-coding-agent/src/core/settings-manager.ts +2 -2
- package/packages/pi-coding-agent/src/migrations.ts +2 -2
- package/packages/pi-coding-agent/src/modes/interactive/components/session-selector-search.ts +2 -2
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +50 -561
- package/packages/pi-coding-agent/src/modes/interactive/slash-command-handlers.ts +653 -0
- package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +0 -8
- package/packages/pi-coding-agent/src/utils/changelog.ts +1 -1
- package/packages/pi-coding-agent/src/utils/clipboard-image.ts +1 -1
- package/packages/pi-coding-agent/src/utils/photon.ts +0 -137
- package/packages/pi-coding-agent/src/utils/tools-manager.ts +1 -1
- package/packages/pi-tui/dist/components/editor.d.ts +0 -10
- package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
- package/packages/pi-tui/dist/components/editor.js +1 -1
- package/packages/pi-tui/dist/components/editor.js.map +1 -1
- package/packages/pi-tui/dist/overlay-layout.d.ts +55 -0
- package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -0
- package/packages/pi-tui/dist/overlay-layout.js +288 -0
- package/packages/pi-tui/dist/overlay-layout.js.map +1 -0
- package/packages/pi-tui/dist/tui.d.ts +0 -22
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +6 -272
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/dist/utils.d.ts +0 -7
- package/packages/pi-tui/dist/utils.d.ts.map +1 -1
- package/packages/pi-tui/dist/utils.js +0 -44
- package/packages/pi-tui/dist/utils.js.map +1 -1
- package/packages/pi-tui/src/components/editor.ts +1 -1
- package/packages/pi-tui/src/overlay-layout.ts +372 -0
- package/packages/pi-tui/src/tui.ts +11 -312
- package/packages/pi-tui/src/utils.ts +0 -43
- package/pkg/dist/core/export-html/ansi-to-html.d.ts +0 -4
- package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/pkg/dist/core/export-html/ansi-to-html.js +1 -1
- package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.d.ts +0 -4
- package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/pkg/dist/modes/interactive/theme/theme.js +0 -7
- package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
- package/src/resources/extensions/mcp-client/index.ts +2 -1
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash command dispatch and handler implementations extracted from InteractiveMode.
|
|
3
|
+
*
|
|
4
|
+
* The `dispatchSlashCommand` function contains the dispatch logic (routing text
|
|
5
|
+
* to handlers), and individual handler functions implement each command.
|
|
6
|
+
*
|
|
7
|
+
* Handlers that are also invoked from keybindings or other subsystems remain on
|
|
8
|
+
* InteractiveMode and are called through the `SlashCommandContext` interface.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as fs from "node:fs";
|
|
12
|
+
import * as os from "node:os";
|
|
13
|
+
import * as path from "node:path";
|
|
14
|
+
import type { ThinkingLevel } from "@gsd/pi-agent-core";
|
|
15
|
+
import type {
|
|
16
|
+
EditorAction,
|
|
17
|
+
EditorComponent,
|
|
18
|
+
MarkdownTheme,
|
|
19
|
+
} from "@gsd/pi-tui";
|
|
20
|
+
import {
|
|
21
|
+
type Component,
|
|
22
|
+
Container,
|
|
23
|
+
Markdown,
|
|
24
|
+
Spacer,
|
|
25
|
+
Text,
|
|
26
|
+
} from "@gsd/pi-tui";
|
|
27
|
+
import { spawn, spawnSync } from "child_process";
|
|
28
|
+
import {
|
|
29
|
+
getShareViewerUrl,
|
|
30
|
+
} from "../../config.js";
|
|
31
|
+
import type { AgentSession } from "../../core/agent-session.js";
|
|
32
|
+
import type { AppAction, KeybindingsManager } from "../../core/keybindings.js";
|
|
33
|
+
import type { SessionManager } from "../../core/session-manager.js";
|
|
34
|
+
import type { SettingsManager } from "../../core/settings-manager.js";
|
|
35
|
+
import { copyToClipboard } from "../../utils/clipboard.js";
|
|
36
|
+
import { getChangelogPath, parseChangelog } from "../../utils/changelog.js";
|
|
37
|
+
import { ArminComponent } from "./components/armin.js";
|
|
38
|
+
import { BorderedLoader } from "./components/bordered-loader.js";
|
|
39
|
+
import { DynamicBorder } from "./components/dynamic-border.js";
|
|
40
|
+
import { appKey, editorKey, formatKeyForDisplay } from "./components/keybinding-hints.js";
|
|
41
|
+
import { SelectSubmenu, THINKING_DESCRIPTIONS } from "./components/settings-selector.js";
|
|
42
|
+
import { theme } from "./theme/theme.js";
|
|
43
|
+
|
|
44
|
+
import type { TUI } from "@gsd/pi-tui";
|
|
45
|
+
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Context interface — the subset of InteractiveMode needed by slash commands
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Provides slash command handlers with access to the parts of InteractiveMode
|
|
52
|
+
* they need without coupling them to the entire class.
|
|
53
|
+
*/
|
|
54
|
+
export interface SlashCommandContext {
|
|
55
|
+
// Core objects
|
|
56
|
+
readonly session: AgentSession;
|
|
57
|
+
readonly ui: TUI;
|
|
58
|
+
readonly keybindings: KeybindingsManager;
|
|
59
|
+
|
|
60
|
+
// Containers
|
|
61
|
+
readonly chatContainer: Container;
|
|
62
|
+
readonly statusContainer: Container;
|
|
63
|
+
readonly editorContainer: Container;
|
|
64
|
+
readonly headerContainer: Container;
|
|
65
|
+
readonly pendingMessagesContainer: Container;
|
|
66
|
+
|
|
67
|
+
// Editor
|
|
68
|
+
readonly editor: EditorComponent;
|
|
69
|
+
readonly defaultEditor: EditorComponent & {
|
|
70
|
+
onEscape?: () => void;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Accessors
|
|
74
|
+
readonly sessionManager: SessionManager;
|
|
75
|
+
readonly settingsManager: SettingsManager;
|
|
76
|
+
|
|
77
|
+
// Footer
|
|
78
|
+
invalidateFooter(): void;
|
|
79
|
+
|
|
80
|
+
// UI helpers
|
|
81
|
+
showStatus(message: string): void;
|
|
82
|
+
showError(message: string): void;
|
|
83
|
+
showWarning(message: string): void;
|
|
84
|
+
showSelector(create: (done: () => void) => { component: Component; focus: Component }): void;
|
|
85
|
+
updateEditorBorderColor(): void;
|
|
86
|
+
getMarkdownThemeWithSettings(): MarkdownTheme;
|
|
87
|
+
requestRender(): void;
|
|
88
|
+
|
|
89
|
+
updateTerminalTitle(): void;
|
|
90
|
+
|
|
91
|
+
// Methods that stay on InteractiveMode (called from both dispatch and keybindings/events)
|
|
92
|
+
showSettingsSelector(): void;
|
|
93
|
+
showModelsSelector(): Promise<void>;
|
|
94
|
+
handleModelCommand(searchTerm?: string): Promise<void>;
|
|
95
|
+
showUserMessageSelector(): void;
|
|
96
|
+
showTreeSelector(): void;
|
|
97
|
+
showProviderManager(): void;
|
|
98
|
+
showOAuthSelector(mode: "login" | "logout"): Promise<void>;
|
|
99
|
+
showSessionSelector(): void;
|
|
100
|
+
handleClearCommand(): Promise<void>;
|
|
101
|
+
handleReloadCommand(): Promise<void>;
|
|
102
|
+
handleDebugCommand(): void;
|
|
103
|
+
shutdown(): Promise<void>;
|
|
104
|
+
|
|
105
|
+
// For compaction
|
|
106
|
+
executeCompaction(customInstructions?: string, isAuto?: boolean): Promise<unknown>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Dispatch
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Routes a slash command string to the appropriate handler.
|
|
115
|
+
*
|
|
116
|
+
* @returns `true` if the text was handled as a slash command (caller should
|
|
117
|
+
* not process it further), `false` otherwise.
|
|
118
|
+
*/
|
|
119
|
+
export async function dispatchSlashCommand(
|
|
120
|
+
text: string,
|
|
121
|
+
ctx: SlashCommandContext,
|
|
122
|
+
): Promise<boolean> {
|
|
123
|
+
if (text === "/settings") {
|
|
124
|
+
ctx.showSettingsSelector();
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
if (text === "/scoped-models") {
|
|
128
|
+
await ctx.showModelsSelector();
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
if (text === "/model" || text.startsWith("/model ")) {
|
|
132
|
+
const searchTerm = text.startsWith("/model ") ? text.slice(7).trim() : undefined;
|
|
133
|
+
await ctx.handleModelCommand(searchTerm);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
if (text.startsWith("/export")) {
|
|
137
|
+
await handleExportCommand(text, ctx);
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
if (text === "/share") {
|
|
141
|
+
await handleShareCommand(ctx);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (text === "/copy") {
|
|
145
|
+
handleCopyCommand(ctx);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
if (text === "/name" || text.startsWith("/name ")) {
|
|
149
|
+
handleNameCommand(text, ctx);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (text === "/session") {
|
|
153
|
+
handleSessionCommand(ctx);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
if (text === "/changelog") {
|
|
157
|
+
handleChangelogCommand(ctx);
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (text === "/hotkeys") {
|
|
161
|
+
handleHotkeysCommand(ctx);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
if (text === "/fork") {
|
|
165
|
+
ctx.showUserMessageSelector();
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (text === "/tree") {
|
|
169
|
+
ctx.showTreeSelector();
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
if (text === "/provider") {
|
|
173
|
+
ctx.showProviderManager();
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
if (text === "/login") {
|
|
177
|
+
await ctx.showOAuthSelector("login");
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
if (text === "/logout") {
|
|
181
|
+
await ctx.showOAuthSelector("logout");
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
if (text === "/new") {
|
|
185
|
+
await ctx.handleClearCommand();
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
if (text === "/compact" || text.startsWith("/compact ")) {
|
|
189
|
+
const customInstructions = text.startsWith("/compact ") ? text.slice(9).trim() : undefined;
|
|
190
|
+
await handleCompactCommand(customInstructions, ctx);
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
if (text === "/reload") {
|
|
194
|
+
await ctx.handleReloadCommand();
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
if (text === "/thinking" || text.startsWith("/thinking ")) {
|
|
198
|
+
const arg = text.startsWith("/thinking ") ? text.slice(10).trim() : undefined;
|
|
199
|
+
handleThinkingCommand(arg, ctx);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
if (text === "/edit-mode" || text.startsWith("/edit-mode ")) {
|
|
203
|
+
const arg = text.startsWith("/edit-mode ") ? text.slice(11).trim() : undefined;
|
|
204
|
+
handleEditModeCommand(arg, ctx);
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
if (text === "/debug") {
|
|
208
|
+
ctx.handleDebugCommand();
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
if (text === "/arminsayshi") {
|
|
212
|
+
handleArminSaysHi(ctx);
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
if (text === "/resume") {
|
|
216
|
+
ctx.showSessionSelector();
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
if (text === "/quit") {
|
|
220
|
+
await ctx.shutdown();
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ---------------------------------------------------------------------------
|
|
228
|
+
// Individual command handlers
|
|
229
|
+
// ---------------------------------------------------------------------------
|
|
230
|
+
|
|
231
|
+
async function handleExportCommand(text: string, ctx: SlashCommandContext): Promise<void> {
|
|
232
|
+
const parts = text.split(/\s+/);
|
|
233
|
+
const outputPath = parts.length > 1 ? parts[1] : undefined;
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
const filePath = await ctx.session.exportToHtml(outputPath);
|
|
237
|
+
ctx.showStatus(`Session exported to: ${filePath}`);
|
|
238
|
+
} catch (error: unknown) {
|
|
239
|
+
ctx.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function handleShareCommand(ctx: SlashCommandContext): Promise<void> {
|
|
244
|
+
// Check if gh is available and logged in
|
|
245
|
+
try {
|
|
246
|
+
const authResult = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" });
|
|
247
|
+
if (authResult.status !== 0) {
|
|
248
|
+
ctx.showError("GitHub CLI is not logged in. Run 'gh auth login' first.");
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
} catch {
|
|
252
|
+
ctx.showError("GitHub CLI (gh) is not installed. Install it from https://cli.github.com/");
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Export to a temp file
|
|
257
|
+
const tmpFile = path.join(os.tmpdir(), "session.html");
|
|
258
|
+
try {
|
|
259
|
+
await ctx.session.exportToHtml(tmpFile);
|
|
260
|
+
} catch (error: unknown) {
|
|
261
|
+
ctx.showError(`Failed to export session: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Show cancellable loader, replacing the editor
|
|
266
|
+
const loader = new BorderedLoader(ctx.ui, theme, "Creating gist...");
|
|
267
|
+
ctx.editorContainer.clear();
|
|
268
|
+
ctx.editorContainer.addChild(loader);
|
|
269
|
+
ctx.ui.setFocus(loader);
|
|
270
|
+
ctx.requestRender();
|
|
271
|
+
|
|
272
|
+
const restoreEditor = () => {
|
|
273
|
+
loader.dispose();
|
|
274
|
+
ctx.editorContainer.clear();
|
|
275
|
+
ctx.editorContainer.addChild(ctx.editor);
|
|
276
|
+
ctx.ui.setFocus(ctx.editor);
|
|
277
|
+
try {
|
|
278
|
+
fs.unlinkSync(tmpFile);
|
|
279
|
+
} catch {
|
|
280
|
+
// Ignore cleanup errors
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// Create a secret gist asynchronously
|
|
285
|
+
let proc: ReturnType<typeof spawn> | null = null;
|
|
286
|
+
|
|
287
|
+
loader.onAbort = () => {
|
|
288
|
+
proc?.kill();
|
|
289
|
+
restoreEditor();
|
|
290
|
+
ctx.showStatus("Share cancelled");
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
try {
|
|
294
|
+
const result = await new Promise<{ stdout: string; stderr: string; code: number | null }>((resolve) => {
|
|
295
|
+
proc = spawn("gh", ["gist", "create", "--public=false", tmpFile]);
|
|
296
|
+
let stdout = "";
|
|
297
|
+
let stderr = "";
|
|
298
|
+
proc.stdout?.on("data", (data) => {
|
|
299
|
+
stdout += data.toString();
|
|
300
|
+
});
|
|
301
|
+
proc.stderr?.on("data", (data) => {
|
|
302
|
+
stderr += data.toString();
|
|
303
|
+
});
|
|
304
|
+
proc.on("close", (code) => resolve({ stdout, stderr, code }));
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
if (loader.signal.aborted) return;
|
|
308
|
+
|
|
309
|
+
restoreEditor();
|
|
310
|
+
|
|
311
|
+
if (result.code !== 0) {
|
|
312
|
+
const errorMsg = result.stderr?.trim() || "Unknown error";
|
|
313
|
+
ctx.showError(`Failed to create gist: ${errorMsg}`);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Extract gist ID from the URL returned by gh
|
|
318
|
+
// gh returns something like: https://gist.github.com/username/GIST_ID
|
|
319
|
+
const gistUrl = result.stdout?.trim();
|
|
320
|
+
const gistId = gistUrl?.split("/").pop();
|
|
321
|
+
if (!gistId) {
|
|
322
|
+
ctx.showError("Failed to parse gist ID from gh output");
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// Create the preview URL
|
|
327
|
+
const previewUrl = getShareViewerUrl(gistId);
|
|
328
|
+
ctx.showStatus(`Share URL: ${previewUrl}\nGist: ${gistUrl}`);
|
|
329
|
+
} catch (error: unknown) {
|
|
330
|
+
if (!loader.signal.aborted) {
|
|
331
|
+
restoreEditor();
|
|
332
|
+
ctx.showError(`Failed to create gist: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function handleCopyCommand(ctx: SlashCommandContext): void {
|
|
338
|
+
const text = ctx.session.getLastAssistantText();
|
|
339
|
+
if (!text) {
|
|
340
|
+
ctx.showError("No agent messages to copy yet.");
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
try {
|
|
345
|
+
copyToClipboard(text);
|
|
346
|
+
ctx.showStatus("Copied last agent message to clipboard");
|
|
347
|
+
} catch (error) {
|
|
348
|
+
ctx.showError(error instanceof Error ? error.message : String(error));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function handleNameCommand(text: string, ctx: SlashCommandContext): void {
|
|
353
|
+
const name = text.replace(/^\/name\s*/, "").trim();
|
|
354
|
+
if (!name) {
|
|
355
|
+
const currentName = ctx.sessionManager.getSessionName();
|
|
356
|
+
if (currentName) {
|
|
357
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
358
|
+
ctx.chatContainer.addChild(new Text(theme.fg("dim", `Session name: ${currentName}`), 1, 0));
|
|
359
|
+
} else {
|
|
360
|
+
ctx.showWarning("Usage: /name <name>");
|
|
361
|
+
}
|
|
362
|
+
ctx.requestRender();
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
ctx.sessionManager.appendSessionInfo(name);
|
|
367
|
+
ctx.updateTerminalTitle();
|
|
368
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
369
|
+
ctx.chatContainer.addChild(new Text(theme.fg("dim", `Session name set: ${name}`), 1, 0));
|
|
370
|
+
ctx.requestRender();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function handleSessionCommand(ctx: SlashCommandContext): void {
|
|
374
|
+
const stats = ctx.session.getSessionStats();
|
|
375
|
+
const sessionName = ctx.sessionManager.getSessionName();
|
|
376
|
+
|
|
377
|
+
let info = `${theme.bold("Session Info")}\n\n`;
|
|
378
|
+
if (sessionName) {
|
|
379
|
+
info += `${theme.fg("dim", "Name:")} ${sessionName}\n`;
|
|
380
|
+
}
|
|
381
|
+
info += `${theme.fg("dim", "File:")} ${stats.sessionFile ?? "In-memory"}\n`;
|
|
382
|
+
info += `${theme.fg("dim", "ID:")} ${stats.sessionId}\n\n`;
|
|
383
|
+
info += `${theme.bold("Messages")}\n`;
|
|
384
|
+
info += `${theme.fg("dim", "User:")} ${stats.userMessages}\n`;
|
|
385
|
+
info += `${theme.fg("dim", "Assistant:")} ${stats.assistantMessages}\n`;
|
|
386
|
+
info += `${theme.fg("dim", "Tool Calls:")} ${stats.toolCalls}\n`;
|
|
387
|
+
info += `${theme.fg("dim", "Tool Results:")} ${stats.toolResults}\n`;
|
|
388
|
+
info += `${theme.fg("dim", "Total:")} ${stats.totalMessages}\n\n`;
|
|
389
|
+
info += `${theme.bold("Tokens")}\n`;
|
|
390
|
+
info += `${theme.fg("dim", "Input:")} ${stats.tokens.input.toLocaleString()}\n`;
|
|
391
|
+
info += `${theme.fg("dim", "Output:")} ${stats.tokens.output.toLocaleString()}\n`;
|
|
392
|
+
if (stats.tokens.cacheRead > 0) {
|
|
393
|
+
info += `${theme.fg("dim", "Cache Read:")} ${stats.tokens.cacheRead.toLocaleString()}\n`;
|
|
394
|
+
}
|
|
395
|
+
if (stats.tokens.cacheWrite > 0) {
|
|
396
|
+
info += `${theme.fg("dim", "Cache Write:")} ${stats.tokens.cacheWrite.toLocaleString()}\n`;
|
|
397
|
+
}
|
|
398
|
+
info += `${theme.fg("dim", "Total:")} ${stats.tokens.total.toLocaleString()}\n`;
|
|
399
|
+
|
|
400
|
+
if (stats.cost > 0) {
|
|
401
|
+
info += `\n${theme.bold("Cost")}\n`;
|
|
402
|
+
info += `${theme.fg("dim", "Total:")} ${stats.cost.toFixed(4)}`;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
406
|
+
ctx.chatContainer.addChild(new Text(info, 1, 0));
|
|
407
|
+
ctx.requestRender();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function handleChangelogCommand(ctx: SlashCommandContext): void {
|
|
411
|
+
const changelogPath = getChangelogPath();
|
|
412
|
+
const allEntries = parseChangelog(changelogPath);
|
|
413
|
+
|
|
414
|
+
const changelogMarkdown =
|
|
415
|
+
allEntries.length > 0
|
|
416
|
+
? allEntries
|
|
417
|
+
.reverse()
|
|
418
|
+
.map((e) => e.content)
|
|
419
|
+
.join("\n\n")
|
|
420
|
+
: "No changelog entries found.";
|
|
421
|
+
|
|
422
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
423
|
+
ctx.chatContainer.addChild(new DynamicBorder());
|
|
424
|
+
ctx.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "What's New")), 1, 0));
|
|
425
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
426
|
+
ctx.chatContainer.addChild(new Markdown(changelogMarkdown, 1, 1, ctx.getMarkdownThemeWithSettings()));
|
|
427
|
+
ctx.chatContainer.addChild(new DynamicBorder());
|
|
428
|
+
ctx.requestRender();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// ---------------------------------------------------------------------------
|
|
432
|
+
// /hotkeys helpers
|
|
433
|
+
// ---------------------------------------------------------------------------
|
|
434
|
+
|
|
435
|
+
export function capitalizeKey(key: string): string {
|
|
436
|
+
return key
|
|
437
|
+
.split("/")
|
|
438
|
+
.map((k) =>
|
|
439
|
+
k
|
|
440
|
+
.split("+")
|
|
441
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
442
|
+
.join("+"),
|
|
443
|
+
)
|
|
444
|
+
.join("/");
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export function getAppKeyDisplay(keybindings: KeybindingsManager, action: AppAction): string {
|
|
448
|
+
return capitalizeKey(appKey(keybindings, action));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function getEditorKeyDisplay(action: EditorAction): string {
|
|
452
|
+
return capitalizeKey(editorKey(action));
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function handleHotkeysCommand(ctx: SlashCommandContext): void {
|
|
456
|
+
// Navigation keybindings
|
|
457
|
+
const cursorWordLeft = getEditorKeyDisplay("cursorWordLeft");
|
|
458
|
+
const cursorWordRight = getEditorKeyDisplay("cursorWordRight");
|
|
459
|
+
const cursorLineStart = getEditorKeyDisplay("cursorLineStart");
|
|
460
|
+
const cursorLineEnd = getEditorKeyDisplay("cursorLineEnd");
|
|
461
|
+
const jumpForward = getEditorKeyDisplay("jumpForward");
|
|
462
|
+
const jumpBackward = getEditorKeyDisplay("jumpBackward");
|
|
463
|
+
const pageUp = getEditorKeyDisplay("pageUp");
|
|
464
|
+
const pageDown = getEditorKeyDisplay("pageDown");
|
|
465
|
+
|
|
466
|
+
// Editing keybindings
|
|
467
|
+
const submit = getEditorKeyDisplay("submit");
|
|
468
|
+
const newLine = getEditorKeyDisplay("newLine");
|
|
469
|
+
const deleteWordBackward = getEditorKeyDisplay("deleteWordBackward");
|
|
470
|
+
const deleteWordForward = getEditorKeyDisplay("deleteWordForward");
|
|
471
|
+
const deleteToLineStart = getEditorKeyDisplay("deleteToLineStart");
|
|
472
|
+
const deleteToLineEnd = getEditorKeyDisplay("deleteToLineEnd");
|
|
473
|
+
const yank = getEditorKeyDisplay("yank");
|
|
474
|
+
const yankPop = getEditorKeyDisplay("yankPop");
|
|
475
|
+
const undo = getEditorKeyDisplay("undo");
|
|
476
|
+
const tab = getEditorKeyDisplay("tab");
|
|
477
|
+
|
|
478
|
+
// App keybindings
|
|
479
|
+
const interrupt = getAppKeyDisplay(ctx.keybindings, "interrupt");
|
|
480
|
+
const clear = getAppKeyDisplay(ctx.keybindings, "clear");
|
|
481
|
+
const exit = getAppKeyDisplay(ctx.keybindings, "exit");
|
|
482
|
+
const suspend = getAppKeyDisplay(ctx.keybindings, "suspend");
|
|
483
|
+
const cycleThinkingLevel = getAppKeyDisplay(ctx.keybindings, "cycleThinkingLevel");
|
|
484
|
+
const cycleModelForward = getAppKeyDisplay(ctx.keybindings, "cycleModelForward");
|
|
485
|
+
const selectModel = getAppKeyDisplay(ctx.keybindings, "selectModel");
|
|
486
|
+
const expandTools = getAppKeyDisplay(ctx.keybindings, "expandTools");
|
|
487
|
+
const toggleThinking = getAppKeyDisplay(ctx.keybindings, "toggleThinking");
|
|
488
|
+
const externalEditor = getAppKeyDisplay(ctx.keybindings, "externalEditor");
|
|
489
|
+
const followUp = getAppKeyDisplay(ctx.keybindings, "followUp");
|
|
490
|
+
const dequeue = getAppKeyDisplay(ctx.keybindings, "dequeue");
|
|
491
|
+
|
|
492
|
+
let hotkeys = `
|
|
493
|
+
**Navigation**
|
|
494
|
+
| Key | Action |
|
|
495
|
+
|-----|--------|
|
|
496
|
+
| \`Arrow keys\` | Move cursor / browse history (Up when empty) |
|
|
497
|
+
| \`${cursorWordLeft}\` / \`${cursorWordRight}\` | Move by word |
|
|
498
|
+
| \`${cursorLineStart}\` | Start of line |
|
|
499
|
+
| \`${cursorLineEnd}\` | End of line |
|
|
500
|
+
| \`${jumpForward}\` | Jump forward to character |
|
|
501
|
+
| \`${jumpBackward}\` | Jump backward to character |
|
|
502
|
+
| \`${pageUp}\` / \`${pageDown}\` | Scroll by page |
|
|
503
|
+
|
|
504
|
+
**Editing**
|
|
505
|
+
| Key | Action |
|
|
506
|
+
|-----|--------|
|
|
507
|
+
| \`${submit}\` | Send message |
|
|
508
|
+
| \`${newLine}\` | New line${process.platform === "win32" ? " (Ctrl+Enter on Windows Terminal)" : ""} |
|
|
509
|
+
| \`${deleteWordBackward}\` | Delete word backwards |
|
|
510
|
+
| \`${deleteWordForward}\` | Delete word forwards |
|
|
511
|
+
| \`${deleteToLineStart}\` | Delete to start of line |
|
|
512
|
+
| \`${deleteToLineEnd}\` | Delete to end of line |
|
|
513
|
+
| \`${yank}\` | Paste the most-recently-deleted text |
|
|
514
|
+
| \`${yankPop}\` | Cycle through the deleted text after pasting |
|
|
515
|
+
| \`${undo}\` | Undo |
|
|
516
|
+
|
|
517
|
+
**Other**
|
|
518
|
+
| Key | Action |
|
|
519
|
+
|-----|--------|
|
|
520
|
+
| \`${tab}\` | Path completion / accept autocomplete |
|
|
521
|
+
| \`${interrupt}\` | Cancel autocomplete / abort streaming |
|
|
522
|
+
| \`${clear}\` | Clear editor (first) / exit (second) |
|
|
523
|
+
| \`${exit}\` | Exit (when editor is empty) |
|
|
524
|
+
| \`${suspend}\` | Suspend to background |
|
|
525
|
+
| \`${cycleThinkingLevel}\` | Cycle thinking level |
|
|
526
|
+
| \`${cycleModelForward}\` | Cycle models |
|
|
527
|
+
| \`${selectModel}\` | Open model selector |
|
|
528
|
+
| \`${expandTools}\` | Toggle tool output expansion |
|
|
529
|
+
| \`${toggleThinking}\` | Toggle thinking block visibility |
|
|
530
|
+
| \`${externalEditor}\` | Edit message in external editor |
|
|
531
|
+
| \`${followUp}\` | Queue follow-up message |
|
|
532
|
+
| \`${dequeue}\` | Restore queued messages |
|
|
533
|
+
| \`Ctrl+V\` | Paste image from clipboard |
|
|
534
|
+
| \`/\` | Slash commands |
|
|
535
|
+
| \`!\` | Run bash command |
|
|
536
|
+
| \`!!\` | Run bash command (excluded from context) |
|
|
537
|
+
`;
|
|
538
|
+
|
|
539
|
+
// Add extension-registered shortcuts
|
|
540
|
+
const extensionRunner = ctx.session.extensionRunner;
|
|
541
|
+
if (extensionRunner) {
|
|
542
|
+
const shortcuts = extensionRunner.getShortcuts(ctx.keybindings.getEffectiveConfig());
|
|
543
|
+
if (shortcuts.size > 0) {
|
|
544
|
+
hotkeys += `
|
|
545
|
+
**Extensions**
|
|
546
|
+
| Key | Action |
|
|
547
|
+
|-----|--------|
|
|
548
|
+
`;
|
|
549
|
+
for (const [key, shortcut] of shortcuts) {
|
|
550
|
+
const description = shortcut.description ?? shortcut.extensionPath;
|
|
551
|
+
const keyDisplay = formatKeyForDisplay(key).replace(/\b\w/g, (c) => c.toUpperCase());
|
|
552
|
+
hotkeys += `| \`${keyDisplay}\` | ${description} |\n`;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
558
|
+
ctx.chatContainer.addChild(new DynamicBorder());
|
|
559
|
+
ctx.chatContainer.addChild(new Text(theme.bold(theme.fg("accent", "Keyboard Shortcuts")), 1, 0));
|
|
560
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
561
|
+
ctx.chatContainer.addChild(new Markdown(hotkeys.trim(), 1, 1, ctx.getMarkdownThemeWithSettings()));
|
|
562
|
+
ctx.chatContainer.addChild(new DynamicBorder());
|
|
563
|
+
ctx.requestRender();
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
async function handleCompactCommand(customInstructions: string | undefined, ctx: SlashCommandContext): Promise<void> {
|
|
567
|
+
const entries = ctx.sessionManager.getEntries();
|
|
568
|
+
const messageCount = entries.filter((e) => e.type === "message").length;
|
|
569
|
+
|
|
570
|
+
if (messageCount < 2) {
|
|
571
|
+
ctx.showWarning("Nothing to compact (no messages yet)");
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
await ctx.executeCompaction(customInstructions, false);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function handleThinkingCommand(arg: string | undefined, ctx: SlashCommandContext): void {
|
|
579
|
+
if (!ctx.session.supportsThinking()) {
|
|
580
|
+
ctx.showStatus("Current model does not support thinking");
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
const availableLevels = ctx.session.getAvailableThinkingLevels();
|
|
585
|
+
|
|
586
|
+
if (arg) {
|
|
587
|
+
const level = arg.toLowerCase();
|
|
588
|
+
if (!availableLevels.includes(level as ThinkingLevel)) {
|
|
589
|
+
ctx.showStatus(`Invalid thinking level "${arg}". Available: ${availableLevels.join(", ")}`);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
ctx.session.setThinkingLevel(level as ThinkingLevel);
|
|
593
|
+
ctx.invalidateFooter();
|
|
594
|
+
ctx.updateEditorBorderColor();
|
|
595
|
+
ctx.showStatus(`Thinking level: ${level}`);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
showThinkingSelector(ctx, availableLevels);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function showThinkingSelector(ctx: SlashCommandContext, availableLevels: readonly ThinkingLevel[]): void {
|
|
603
|
+
ctx.showSelector((done) => {
|
|
604
|
+
const selector = new SelectSubmenu(
|
|
605
|
+
"Thinking Level",
|
|
606
|
+
"Select reasoning depth for thinking-capable models",
|
|
607
|
+
availableLevels.map((level) => ({
|
|
608
|
+
value: level,
|
|
609
|
+
label: level,
|
|
610
|
+
description: THINKING_DESCRIPTIONS[level],
|
|
611
|
+
})),
|
|
612
|
+
ctx.session.thinkingLevel,
|
|
613
|
+
(value) => {
|
|
614
|
+
ctx.session.setThinkingLevel(value as ThinkingLevel);
|
|
615
|
+
ctx.invalidateFooter();
|
|
616
|
+
ctx.updateEditorBorderColor();
|
|
617
|
+
done();
|
|
618
|
+
ctx.showStatus(`Thinking level: ${value}`);
|
|
619
|
+
},
|
|
620
|
+
() => {
|
|
621
|
+
done();
|
|
622
|
+
},
|
|
623
|
+
);
|
|
624
|
+
return { component: selector, focus: selector };
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function handleEditModeCommand(arg: string | undefined, ctx: SlashCommandContext): void {
|
|
629
|
+
const modes = ["standard", "hashline"] as const;
|
|
630
|
+
|
|
631
|
+
if (arg) {
|
|
632
|
+
const mode = arg.toLowerCase();
|
|
633
|
+
if (!modes.includes(mode as typeof modes[number])) {
|
|
634
|
+
ctx.showStatus(`Invalid edit mode "${arg}". Available: standard, hashline`);
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
ctx.session.setEditMode(mode as "standard" | "hashline");
|
|
638
|
+
ctx.showStatus(`Edit mode: ${mode}${mode === "hashline" ? " (LINE#ID anchored edits)" : " (text-match edits)"}`);
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// Toggle
|
|
643
|
+
const current = ctx.session.editMode;
|
|
644
|
+
const next = current === "standard" ? "hashline" : "standard";
|
|
645
|
+
ctx.session.setEditMode(next);
|
|
646
|
+
ctx.showStatus(`Edit mode: ${next}${next === "hashline" ? " (LINE#ID anchored edits)" : " (text-match edits)"}`);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function handleArminSaysHi(ctx: SlashCommandContext): void {
|
|
650
|
+
ctx.chatContainer.addChild(new Spacer(1));
|
|
651
|
+
ctx.chatContainer.addChild(new ArminComponent(ctx.ui));
|
|
652
|
+
ctx.requestRender();
|
|
653
|
+
}
|
|
@@ -880,14 +880,6 @@ export function getResolvedThemeColors(themeName?: string): Record<string, strin
|
|
|
880
880
|
return cssColors;
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
-
/**
|
|
884
|
-
* Check if a theme is a "light" theme (for CSS that needs light/dark variants).
|
|
885
|
-
*/
|
|
886
|
-
export function isLightTheme(themeName?: string): boolean {
|
|
887
|
-
// Currently just check the name - could be extended to analyze colors
|
|
888
|
-
return themeName === "light";
|
|
889
|
-
}
|
|
890
|
-
|
|
891
883
|
/**
|
|
892
884
|
* Get explicit export colors from theme JSON, if specified.
|
|
893
885
|
* Returns undefined for each color that isn't explicitly set.
|
|
@@ -73,7 +73,7 @@ export function parseChangelog(changelogPath: string): ChangelogEntry[] {
|
|
|
73
73
|
/**
|
|
74
74
|
* Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2
|
|
75
75
|
*/
|
|
76
|
-
|
|
76
|
+
function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry): number {
|
|
77
77
|
if (v1.major !== v2.major) return v1.major - v2.major;
|
|
78
78
|
if (v1.minor !== v2.minor) return v1.minor - v2.minor;
|
|
79
79
|
return v1.patch - v2.patch;
|
|
@@ -14,7 +14,7 @@ const DEFAULT_LIST_TIMEOUT_MS = 1000;
|
|
|
14
14
|
const DEFAULT_READ_TIMEOUT_MS = 3000;
|
|
15
15
|
const DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {
|
|
18
18
|
return Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === "wayland";
|
|
19
19
|
}
|
|
20
20
|
|