|
|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
import type { SlashCommand } from "@mariozechner/pi-tui";
|
|
|
|
|
import { listChatCommands, listChatCommandsForConfig } from "../auto-reply/commands-registry.js";
|
|
|
|
|
import { formatThinkingLevels, listThinkingLevelLabels } from "../auto-reply/thinking.js";
|
|
|
|
|
import type { ClawdbotConfig } from "../config/types.js";
|
|
|
|
|
|
|
|
|
|
const VERBOSE_LEVELS = ["on", "off"];
|
|
|
|
|
const REASONING_LEVELS = ["on", "off"];
|
|
|
|
|
@ -13,6 +15,7 @@ export type ParsedCommand = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type SlashCommandOptions = {
|
|
|
|
|
cfg?: ClawdbotConfig;
|
|
|
|
|
provider?: string;
|
|
|
|
|
model?: string;
|
|
|
|
|
};
|
|
|
|
|
@ -34,7 +37,7 @@ export function parseCommand(input: string): ParsedCommand {
|
|
|
|
|
|
|
|
|
|
export function getSlashCommands(options: SlashCommandOptions = {}): SlashCommand[] {
|
|
|
|
|
const thinkLevels = listThinkingLevelLabels(options.provider, options.model);
|
|
|
|
|
return [
|
|
|
|
|
const commands: SlashCommand[] = [
|
|
|
|
|
{ name: "help", description: "Show slash command help" },
|
|
|
|
|
{ name: "status", description: "Show gateway status summary" },
|
|
|
|
|
{ name: "agent", description: "Switch agent (or open picker)" },
|
|
|
|
|
@ -115,6 +118,20 @@ export function getSlashCommands(options: SlashCommandOptions = {}): SlashComman
|
|
|
|
|
{ name: "exit", description: "Exit the TUI" },
|
|
|
|
|
{ name: "quit", description: "Exit the TUI" },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const seen = new Set(commands.map((command) => command.name));
|
|
|
|
|
const gatewayCommands = options.cfg ? listChatCommandsForConfig(options.cfg) : listChatCommands();
|
|
|
|
|
for (const command of gatewayCommands) {
|
|
|
|
|
const aliases = command.textAliases.length > 0 ? command.textAliases : [`/${command.key}`];
|
|
|
|
|
for (const alias of aliases) {
|
|
|
|
|
const name = alias.replace(/^\//, "").trim();
|
|
|
|
|
if (!name || seen.has(name)) continue;
|
|
|
|
|
seen.add(name);
|
|
|
|
|
commands.push({ name, description: command.description });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return commands;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function helpText(options: SlashCommandOptions = {}): string {
|
|
|
|
|
@ -122,6 +139,7 @@ export function helpText(options: SlashCommandOptions = {}): string {
|
|
|
|
|
return [
|
|
|
|
|
"Slash commands:",
|
|
|
|
|
"/help",
|
|
|
|
|
"/commands",
|
|
|
|
|
"/status",
|
|
|
|
|
"/agent <id> (or /agents)",
|
|
|
|
|
"/session <key> (or /sessions)",
|
|
|
|
|
|