Elffuss BraidHub

kikocis/continue public

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