Elffuss BraidHub

kikocis/continue public

71aa83e1fc3b · 3.3 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 name: "init",
70 description: "Create an AGENTS.md file",
71 category: "system",
72 },
73 {
74 name: "compact",
75 description: "Summarize chat history into a compact form",
76 category: "system",
77 },
78 {
79 name: "resume",
80 description: "Resume a previous chat session",
81 category: "system",
82 },
83 {
84 name: "fork",
85 description: "Start a forked chat session from the current history",
86 category: "system",
87 },
88 {
89 name: "exit",
90 description: "Exit the chat",
91 category: "system",
92 },
93];
94
95// Remote mode specific commands
96export const REMOTE_MODE_SLASH_COMMANDS: SlashCommand[] = [
97 {
98 name: "exit",
99 description: "Exit the remote environment",
100 category: "system",
101 },
102];
103
104/**
105 * Get all available slash commands including system commands and assistant prompts
106 */
107export function getAllSlashCommands(
108 assistant: AssistantConfig,
109 options: { isRemoteMode?: boolean } = {},
110): SlashCommand[] {
111 const { isRemoteMode = false } = options;
112
113 // In remote mode, only show the exit command
114 if (isRemoteMode) {
115 return REMOTE_MODE_SLASH_COMMANDS;
116 }
117
118 // All system commands are available
119 const systemCommands = SYSTEM_SLASH_COMMANDS;
120
121 // Get assistant prompt commands
122 const assistantCommands: SlashCommand[] =
123 assistant?.prompts?.map((prompt) => ({
124 name: prompt?.name || "",
125 description: prompt?.description || "",
126 category: "assistant" as const,
127 })) || [];
128
129 return [...systemCommands, ...assistantCommands];
130}
131
132/**
133 * Get assistant prompt commands only
134 */
135export function getAssistantSlashCommands(
136 assistant: AssistantConfig,
137): SlashCommand[] {
138 return (
139 assistant?.prompts?.map((prompt) => ({
140 name: prompt?.name || "",
141 description: prompt?.description || "",
142 category: "assistant" as const,
143 })) || []
144 );
145}