always show org slash command

This commit is contained in:
Nate 2025-07-19 21:14:35 -07:00
parent 7eb1e007eb
commit ddd3201720
4 changed files with 40 additions and 47 deletions

View file

@ -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<SlashCommand[]> {
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<SystemCommand[]> {
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,
})) || [];
}
export function getAssistantSlashCommands(
assistant: AssistantConfig
): SlashCommand[] {
return (
assistant.prompts?.map((prompt) => ({
name: prompt?.name || "",
description: prompt?.description || "",
category: "assistant" as const,
})) || []
);
}

View file

@ -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("");
}
}

View file

@ -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;
}
}

View file

@ -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<SlashCommandUIProps> = ({
const [allCommands, setAllCommands] = useState<SlashCommand[]>([]);
useEffect(() => {
getAllSlashCommands(assistant).then(setAllCommands);
setAllCommands(getAllSlashCommands(assistant));
}, [assistant]);
// Filter commands based on the current filter
@ -67,4 +70,4 @@ const SlashCommandUI: React.FC<SlashCommandUIProps> = ({
);
};
export default SlashCommandUI;
export default SlashCommandUI;