| 1 | import { type AssistantConfig } from "@continuedev/sdk"; |
| 2 | |
| 3 | // Export command functions |
| 4 | export { chat } from "./chat.js"; |
| 5 | export { login } from "./login.js"; |
| 6 | export { logout } from "./logout.js"; |
| 7 | export { listSessionsCommand } from "./ls.js"; |
| 8 | export { remote } from "./remote.js"; |
| 9 | export { serve } from "./serve.js"; |
| 10 | |
| 11 | export interface SlashCommand { |
| 12 | name: string; |
| 13 | description: string; |
| 14 | category: "system" | "assistant"; |
| 15 | } |
| 16 | |
| 17 | export interface SystemCommand extends SlashCommand { |
| 18 | category: "system"; |
| 19 | } |
| 20 | |
| 21 | // Central definition of all system slash commands |
| 22 | export 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: "title", |
| 95 | description: "Set the title for the current session", |
| 96 | category: "system", |
| 97 | }, |
| 98 | { |
| 99 | name: "exit", |
| 100 | description: "Exit the chat", |
| 101 | category: "system", |
| 102 | }, |
| 103 | ]; |
| 104 | |
| 105 | // Remote mode specific commands |
| 106 | export const REMOTE_MODE_SLASH_COMMANDS: SlashCommand[] = [ |
| 107 | { |
| 108 | name: "exit", |
| 109 | description: "Exit the remote environment", |
| 110 | category: "system", |
| 111 | }, |
| 112 | { |
| 113 | name: "diff", |
| 114 | description: "Show the current diff from the remote environment", |
| 115 | category: "system", |
| 116 | }, |
| 117 | { |
| 118 | name: "apply", |
| 119 | description: "Apply the current diff to the local working tree", |
| 120 | category: "system", |
| 121 | }, |
| 122 | ]; |
| 123 | |
| 124 | /** |
| 125 | * Get all available slash commands including system commands and assistant prompts |
| 126 | */ |
| 127 | export function getAllSlashCommands( |
| 128 | assistant: AssistantConfig, |
| 129 | options: { isRemoteMode?: boolean } = {}, |
| 130 | ): SlashCommand[] { |
| 131 | const { isRemoteMode = false } = options; |
| 132 | |
| 133 | // In remote mode, only show the exit command |
| 134 | if (isRemoteMode) { |
| 135 | return REMOTE_MODE_SLASH_COMMANDS; |
| 136 | } |
| 137 | |
| 138 | // All system commands are available |
| 139 | const systemCommands = SYSTEM_SLASH_COMMANDS; |
| 140 | |
| 141 | // Get assistant prompt commands |
| 142 | const assistantCommands: SlashCommand[] = |
| 143 | assistant?.prompts?.map((prompt) => ({ |
| 144 | name: prompt?.name || "", |
| 145 | description: prompt?.description || "", |
| 146 | category: "assistant" as const, |
| 147 | })) || []; |
| 148 | |
| 149 | return [...systemCommands, ...assistantCommands]; |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Get assistant prompt commands only |
| 154 | */ |
| 155 | export function getAssistantSlashCommands( |
| 156 | assistant: AssistantConfig, |
| 157 | ): SlashCommand[] { |
| 158 | return ( |
| 159 | assistant?.prompts?.map((prompt) => ({ |
| 160 | name: prompt?.name || "", |
| 161 | description: prompt?.description || "", |
| 162 | category: "assistant" as const, |
| 163 | })) || [] |
| 164 | ); |
| 165 | } |