Elffuss BraidHub

kikocis/continue public

dd35e28818ae · 3.2 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 { listSessionsCommand } from "./ls.js";
8export { remote } from "./remote.js";
9export { serve } from "./serve.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: "info",
50 description: "Show session information",
51 category: "system",
52 },
53 {
54 name: "model",
55 description: "Switch between available chat models",
56 category: "system",
57 },
58 {
59 name: "config",
60 description: "Switch configuration or organization",
61 category: "system",
62 },
63 {
64 name: "mcp",
65 description: "Manage MCP server connections",
66 category: "system",
67 },
68
69 {
70 name: "compact",
71 description: "Summarize chat history into a compact form",
72 category: "system",
73 },
74 {
75 name: "resume",
76 description: "Resume a previous chat session",
77 category: "system",
78 },
79 {
80 name: "fork",
81 description: "Start a forked chat session from the current history",
82 category: "system",
83 },
84 {
85 name: "exit",
86 description: "Exit the chat",
87 category: "system",
88 },
89];
90
91// Remote mode specific commands
92export const REMOTE_MODE_SLASH_COMMANDS: SlashCommand[] = [
93 {
94 name: "exit",
95 description: "Exit the remote environment",
96 category: "system",
97 },
98];
99
100/**
101 * Get all available slash commands including system commands and assistant prompts
102 */
103export function getAllSlashCommands(
104 assistant: AssistantConfig,
105 options: { isRemoteMode?: boolean } = {},
106): SlashCommand[] {
107 const { isRemoteMode = false } = options;
108
109 // In remote mode, only show the exit command
110 if (isRemoteMode) {
111 return REMOTE_MODE_SLASH_COMMANDS;
112 }
113
114 // All system commands are available
115 const systemCommands = SYSTEM_SLASH_COMMANDS;
116
117 // Get assistant prompt commands
118 const assistantCommands: SlashCommand[] =
119 assistant?.prompts?.map((prompt) => ({
120 name: prompt?.name || "",
121 description: prompt?.description || "",
122 category: "assistant" as const,
123 })) || [];
124
125 return [...systemCommands, ...assistantCommands];
126}
127
128/**
129 * Get assistant prompt commands only
130 */
131export function getAssistantSlashCommands(
132 assistant: AssistantConfig,
133): SlashCommand[] {
134 return (
135 assistant?.prompts?.map((prompt) => ({
136 name: prompt?.name || "",
137 description: prompt?.description || "",
138 category: "assistant" as const,
139 })) || []
140 );
141}