Elffuss BraidHub

kikocis/continue public

60acd6c5ca13 · 3.1 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: "exit",
81 description: "Exit the chat",
82 category: "system",
83 },
84];
85
86// Remote mode specific commands
87export const REMOTE_MODE_SLASH_COMMANDS: SlashCommand[] = [
88 {
89 name: "exit",
90 description: "Exit the remote environment",
91 category: "system",
92 },
93];
94
95/**
96 * Get all available slash commands including system commands and assistant prompts
97 */
98export function getAllSlashCommands(
99 assistant: AssistantConfig,
100 options: { isRemoteMode?: boolean } = {},
101): SlashCommand[] {
102 const { isRemoteMode = false } = options;
103
104 // In remote mode, only show the exit command
105 if (isRemoteMode) {
106 return REMOTE_MODE_SLASH_COMMANDS;
107 }
108
109 // All system commands are available
110 const systemCommands = SYSTEM_SLASH_COMMANDS;
111
112 // Get assistant prompt commands
113 const assistantCommands: SlashCommand[] =
114 assistant?.prompts?.map((prompt) => ({
115 name: prompt?.name || "",
116 description: prompt?.description || "",
117 category: "assistant" as const,
118 })) || [];
119
120 return [...systemCommands, ...assistantCommands];
121}
122
123/**
124 * Get assistant prompt commands only
125 */
126export function getAssistantSlashCommands(
127 assistant: AssistantConfig,
128): SlashCommand[] {
129 return (
130 assistant?.prompts?.map((prompt) => ({
131 name: prompt?.name || "",
132 description: prompt?.description || "",
133 category: "assistant" as const,
134 })) || []
135 );
136}