Elffuss BraidHub

kikocis/continue public

494a780fdb25 · 3.0 KiBRawPermalink
1import { type AssistantConfig } from "@continuedev/sdk";
2
3// Export command functions
4export { chat } from "./chat.js";
5export { login } from "./login.js";
6export { logout } from "./logout.js";
7export { remote } from "./remote.js";
8export { serve } from "./serve.js";
9export { listSessionsCommand } from "./ls.js";
10
11export interface SlashCommand {
12 name: string;
13 description: string;
14 category: "system" | "assistant";
15}
16
17export interface SystemCommand extends SlashCommand {
18 category: "system";
19}
20
21// Central definition of all system slash commands
22export const SYSTEM_SLASH_COMMANDS: SystemCommand[] = [
23 {
24 name: "help",
25 description: "Show help message",
26 category: "system",
27 },
28 {
29 name: "clear",
30 description: "Clear the chat history",
31 category: "system",
32 },
33 {
34 name: "login",
35 description: "Authenticate with your account",
36 category: "system",
37 },
38 {
39 name: "logout",
40 description: "Sign out of your current session",
41 category: "system",
42 },
43 {
44 name: "whoami",
45 description: "Check who you're currently logged in as",
46 category: "system",
47 },
48 {
49 name: "model",
50 description: "Switch between available chat models",
51 category: "system",
52 },
53 {
54 name: "config",
55 description: "Switch configuration or organization",
56 category: "system",
57 },
58 {
59 name: "mcp",
60 description: "Manage MCP server connections",
61 category: "system",
62 },
63
64 {
65 name: "compact",
66 description: "Summarize chat history into a compact form",
67 category: "system",
68 },
69 {
70 name: "resume",
71 description: "Resume a previous chat session",
72 category: "system",
73 },
74 {
75 name: "exit",
76 description: "Exit the chat",
77 category: "system",
78 },
79];
80
81// Remote mode specific commands
82export const REMOTE_MODE_SLASH_COMMANDS: SlashCommand[] = [
83 {
84 name: "exit",
85 description: "Exit the remote environment",
86 category: "system",
87 },
88];
89
90/**
91 * Get all available slash commands including system commands and assistant prompts
92 */
93export function getAllSlashCommands(
94 assistant: AssistantConfig,
95 options: { isRemoteMode?: boolean } = {},
96): SlashCommand[] {
97 const { isRemoteMode = false } = options;
98
99 // In remote mode, only show the exit command
100 if (isRemoteMode) {
101 return REMOTE_MODE_SLASH_COMMANDS;
102 }
103
104 // All system commands are available
105 const systemCommands = SYSTEM_SLASH_COMMANDS;
106
107 // Get assistant prompt commands
108 const assistantCommands: SlashCommand[] =
109 assistant?.prompts?.map((prompt) => ({
110 name: prompt?.name || "",
111 description: prompt?.description || "",
112 category: "assistant" as const,
113 })) || [];
114
115 return [...systemCommands, ...assistantCommands];
116}
117
118/**
119 * Get assistant prompt commands only
120 */
121export function getAssistantSlashCommands(
122 assistant: AssistantConfig,
123): SlashCommand[] {
124 return (
125 assistant?.prompts?.map((prompt) => ({
126 name: prompt?.name || "",
127 description: prompt?.description || "",
128 category: "assistant" as const,
129 })) || []
130 );
131}