From ddd320172097d58aae874592391d598c618f8cca Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 19 Jul 2025 21:14:35 -0700 Subject: [PATCH] always show org slash command --- src/commands/commands.ts | 58 ++++++++++++++++----------------------- src/intro.ts | 12 ++++---- src/slashCommands.ts | 8 +++--- src/ui/SlashCommandUI.tsx | 9 ++++-- 4 files changed, 40 insertions(+), 47 deletions(-) diff --git a/src/commands/commands.ts b/src/commands/commands.ts index 458434493..918bb631a 100644 --- a/src/commands/commands.ts +++ b/src/commands/commands.ts @@ -1,5 +1,4 @@ import { type AssistantConfig } from "@continuedev/sdk"; -import { hasMultipleOrganizations } from "../auth/workos.js"; export interface SlashCommand { name: string; @@ -20,13 +19,13 @@ export const SYSTEM_SLASH_COMMANDS: SystemCommand[] = [ category: "system", }, { - name: "clear", + name: "clear", description: "Clear the chat history", category: "system", }, { name: "exit", - description: "Exit the chat", + description: "Exit the chat", category: "system", }, { @@ -35,7 +34,7 @@ export const SYSTEM_SLASH_COMMANDS: SystemCommand[] = [ category: "system", }, { - name: "logout", + name: "logout", description: "Sign out of your current session", category: "system", }, @@ -60,42 +59,33 @@ export const SYSTEM_SLASH_COMMANDS: SystemCommand[] = [ /** * Get all available slash commands including system commands and assistant prompts */ -export async function getAllSlashCommands(assistant: AssistantConfig): Promise { - const hasMultipleOrgs = await hasMultipleOrganizations(); - +export function getAllSlashCommands( + assistant: AssistantConfig +): SlashCommand[] { // Filter system commands based on requirements - const systemCommands = SYSTEM_SLASH_COMMANDS.filter(command => - !command.requiresMultipleOrgs || hasMultipleOrgs - ); - + const systemCommands = SYSTEM_SLASH_COMMANDS; // Get assistant prompt commands - const assistantCommands: SlashCommand[] = assistant.prompts?.map((prompt) => ({ - name: prompt?.name || "", - description: prompt?.description || "", - category: "assistant" as const, - })) || []; + const assistantCommands: SlashCommand[] = + assistant.prompts?.map((prompt) => ({ + name: prompt?.name || "", + description: prompt?.description || "", + category: "assistant" as const, + })) || []; return [...systemCommands, ...assistantCommands]; } -/** - * Get system slash commands only - */ -export async function getSystemSlashCommands(): Promise { - const hasMultipleOrgs = await hasMultipleOrganizations(); - - return SYSTEM_SLASH_COMMANDS.filter(command => - !command.requiresMultipleOrgs || hasMultipleOrgs - ); -} - /** * Get assistant prompt commands only */ -export function getAssistantSlashCommands(assistant: AssistantConfig): SlashCommand[] { - return assistant.prompts?.map((prompt) => ({ - name: prompt?.name || "", - description: prompt?.description || "", - category: "assistant" as const, - })) || []; -} \ No newline at end of file +export function getAssistantSlashCommands( + assistant: AssistantConfig +): SlashCommand[] { + return ( + assistant.prompts?.map((prompt) => ({ + name: prompt?.name || "", + description: prompt?.description || "", + category: "assistant" as const, + })) || [] + ); +} diff --git a/src/intro.ts b/src/intro.ts index 525a9327c..cc8c331fc 100644 --- a/src/intro.ts +++ b/src/intro.ts @@ -1,9 +1,9 @@ import { AssistantUnrolled } from "@continuedev/config-yaml"; import { type AssistantConfig } from "@continuedev/sdk"; import chalk from "chalk"; +import { getAllSlashCommands } from "./commands/commands.js"; import { MCPService } from "./mcp.js"; import { BUILTIN_TOOLS } from "./tools/index.js"; -import { getAllSlashCommands } from "./commands/commands.js"; export function loadSystemMessage( assistant: AssistantConfig @@ -21,9 +21,9 @@ export async function introMessage( ) { const mcpTools = mcpService.getTools() ?? []; const mcpPrompts = mcpService.getPrompts() ?? []; - + // Get all slash commands from central definition - const allCommands = await getAllSlashCommands(config); + const allCommands = getAllSlashCommands(config); console.info(`\n${chalk.bold.yellow(`Agent: ${config.name}\n`)}`); console.info(`${chalk.blue("Model:")} ${modelName.split("/").pop()}\n`); @@ -37,14 +37,14 @@ export async function introMessage( console.info(""); console.info(chalk.blue("Slash commands:")); - + // Display all commands from central definition for (const command of allCommands) { console.info( `- ${chalk.white("/" + command.name)}: ${chalk.dim(command.description)}` ); } - + // Display MCP prompts separately since they're not part of our central definition for (const prompt of mcpPrompts) { console.info( @@ -64,4 +64,4 @@ export async function introMessage( }); } console.info(""); -} \ No newline at end of file +} diff --git a/src/slashCommands.ts b/src/slashCommands.ts index ae238a8ee..40fb81541 100644 --- a/src/slashCommands.ts +++ b/src/slashCommands.ts @@ -26,10 +26,10 @@ export async function handleSlashCommands( const [command, ...args] = input.slice(1).split(" "); switch (command) { case "help": - const allCommands = await getAllSlashCommands(assistant); + const allCommands = getAllSlashCommands(assistant); const helpMessage = [ "Available commands:", - ...allCommands.map(cmd => `/${cmd.name} - ${cmd.description}`) + ...allCommands.map((cmd) => `/${cmd.name} - ${cmd.description}`), ].join("\n"); return { output: helpMessage }; case "clear": @@ -50,7 +50,7 @@ export async function handleSlashCommands( } else { console.info(chalk.green(`\nLogged in successfully`)); } - + // Reload everything after successful login if (onReload) { await onReload(); @@ -104,4 +104,4 @@ export async function handleSlashCommands( } } return null; -} \ No newline at end of file +} diff --git a/src/ui/SlashCommandUI.tsx b/src/ui/SlashCommandUI.tsx index d9b518fc1..c940c9133 100644 --- a/src/ui/SlashCommandUI.tsx +++ b/src/ui/SlashCommandUI.tsx @@ -1,7 +1,10 @@ import { type AssistantConfig } from "@continuedev/sdk"; import { Box, Text } from "ink"; import React, { useEffect, useState } from "react"; -import { getAllSlashCommands, type SlashCommand } from "../commands/commands.js"; +import { + getAllSlashCommands, + type SlashCommand, +} from "../commands/commands.js"; interface SlashCommandUIProps { assistant: AssistantConfig; @@ -19,7 +22,7 @@ const SlashCommandUI: React.FC = ({ const [allCommands, setAllCommands] = useState([]); useEffect(() => { - getAllSlashCommands(assistant).then(setAllCommands); + setAllCommands(getAllSlashCommands(assistant)); }, [assistant]); // Filter commands based on the current filter @@ -67,4 +70,4 @@ const SlashCommandUI: React.FC = ({ ); }; -export default SlashCommandUI; \ No newline at end of file +export default SlashCommandUI;