Some checks failed
CI / build-check-test (push) Has been cancelled
Restructure local extensions into per-feature directories, split WebUI into backend modules with slash commands and systemd support, and track prompts/skills under .pi/agent for portable Gitea deployment. Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { BUILTIN_SLASH_COMMANDS } from "../../../../../../packages/coding-agent/src/core/slash-commands.ts";
|
|
import { filterWebUiSlashCommands, type SlashCommandEntry } from "../slash/dispatch.ts";
|
|
import type { SendCmd } from "../types/context.ts";
|
|
|
|
export async function listSlashCommands(sendCmd: SendCmd): Promise<SlashCommandEntry[]> {
|
|
const builtinNames = new Set(BUILTIN_SLASH_COMMANDS.map((command) => command.name));
|
|
const commands: SlashCommandEntry[] = BUILTIN_SLASH_COMMANDS.map((command) => ({
|
|
name: command.name,
|
|
description: command.description,
|
|
source: "builtin",
|
|
}));
|
|
|
|
const response = await sendCmd({ type: "get_commands" });
|
|
if (!response.success) throw new Error(response.error || "读取命令失败");
|
|
|
|
for (const command of response.data?.commands || []) {
|
|
const name = String(command?.name || "");
|
|
if (!name) continue;
|
|
|
|
const source = String(command?.source || "");
|
|
if (source === "extension" && builtinNames.has(name)) continue;
|
|
|
|
if (source === "prompt") {
|
|
commands.push({
|
|
name,
|
|
description: String(command.description || ""),
|
|
source: "prompt",
|
|
});
|
|
continue;
|
|
}
|
|
|
|
if (source === "skill") {
|
|
commands.push({
|
|
name,
|
|
description: String(command.description || ""),
|
|
source: "skill",
|
|
});
|
|
continue;
|
|
}
|
|
|
|
if (source === "extension") {
|
|
commands.push({
|
|
name,
|
|
description: String(command.description || ""),
|
|
source: "extension",
|
|
});
|
|
}
|
|
}
|
|
|
|
return filterWebUiSlashCommands(commands).sort((a, b) => a.name.localeCompare(b.name));
|
|
}
|