mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
Share slash command definitions
This commit is contained in:
@@ -1,39 +1,8 @@
|
||||
import type { SlashCommand } from '@/types/api'
|
||||
|
||||
const BUILTIN_COMMANDS: Record<string, SlashCommand[]> = {
|
||||
claude: [
|
||||
{ name: 'clear', description: 'Clear conversation history and free up context', source: 'builtin' },
|
||||
{ name: 'compact', description: 'Clear conversation history but keep a summary in context', source: 'builtin' },
|
||||
{ name: 'context', description: 'Visualize current context usage as a colored grid', source: 'builtin' },
|
||||
{ name: 'cost', description: 'Show the total cost and duration of the current session', source: 'builtin' },
|
||||
{ name: 'doctor', description: 'Diagnose and verify your Claude Code installation and settings', source: 'builtin' },
|
||||
{ name: 'plan', description: 'View or open the current session plan', source: 'builtin' },
|
||||
{ name: 'stats', description: 'Show your Claude Code usage statistics and activity', source: 'builtin' },
|
||||
{ name: 'status', description: 'Show Claude Code status including version, model, account, and API connectivity', source: 'builtin' },
|
||||
],
|
||||
codex: [
|
||||
{ name: 'clear', description: 'Clear current Codex thread context', source: 'builtin' },
|
||||
{ name: 'compact', description: 'Compact current Codex thread context', source: 'builtin' },
|
||||
{ name: 'goal', description: 'Set, view, pause, resume, or clear a persistent Codex goal', source: 'builtin' },
|
||||
{ name: 'help', description: 'Show supported HAPI Codex slash commands', source: 'builtin' },
|
||||
{ name: 'plan', description: 'Enable plan mode; use /plan off to return to default', source: 'builtin' },
|
||||
{ name: 'default', description: 'Return Codex collaboration mode to default', source: 'builtin' },
|
||||
{ name: 'execute', description: 'Return Codex collaboration mode to default', source: 'builtin' },
|
||||
{ name: 'status', description: 'Show current Codex session config', source: 'builtin' },
|
||||
{ name: 'model', description: 'Show or set Codex model, e.g. /model gpt-5.5', source: 'builtin' },
|
||||
{ name: 'reasoning', description: 'Show or set reasoning effort', source: 'builtin' },
|
||||
{ name: 'effort', description: 'Alias for /reasoning', source: 'builtin' },
|
||||
{ name: 'permissions', description: 'Show or set permission mode', source: 'builtin' },
|
||||
{ name: 'permission', description: 'Alias for /permissions', source: 'builtin' },
|
||||
],
|
||||
gemini: [
|
||||
{ name: 'about', description: 'Show version info', source: 'builtin' },
|
||||
{ name: 'clear', description: 'Clear the screen and conversation history', source: 'builtin' },
|
||||
{ name: 'compress', description: 'Compress the context by replacing it with a summary', source: 'builtin' },
|
||||
{ name: 'stats', description: 'Check session stats', source: 'builtin' },
|
||||
],
|
||||
opencode: [],
|
||||
}
|
||||
import {
|
||||
getBuiltinSlashCommands,
|
||||
mergeSlashCommands
|
||||
} from '@hapi/protocol/slashCommands'
|
||||
import type { SlashCommand } from '@hapi/protocol/apiTypes'
|
||||
|
||||
const UNSUPPORTED_CODEX_BUILTIN_COMMANDS = new Set([
|
||||
'review',
|
||||
@@ -43,21 +12,7 @@ const UNSUPPORTED_CODEX_BUILTIN_COMMANDS = new Set([
|
||||
'diff',
|
||||
])
|
||||
|
||||
export function getBuiltinSlashCommands(agentType: string): SlashCommand[] {
|
||||
return BUILTIN_COMMANDS[agentType] ?? BUILTIN_COMMANDS.claude ?? []
|
||||
}
|
||||
|
||||
export function mergeSlashCommands(commands: readonly SlashCommand[]): SlashCommand[] {
|
||||
const commandMap = new Map<string, SlashCommand>()
|
||||
for (const command of commands) {
|
||||
const key = command.name.toLowerCase()
|
||||
if (commandMap.has(key)) {
|
||||
commandMap.delete(key)
|
||||
}
|
||||
commandMap.set(key, command)
|
||||
}
|
||||
return Array.from(commandMap.values())
|
||||
}
|
||||
export { getBuiltinSlashCommands, mergeSlashCommands }
|
||||
|
||||
export function findCodexCustomPromptExpansion(
|
||||
text: string,
|
||||
|
||||
+2
-14
@@ -21,6 +21,8 @@ export type {
|
||||
OpencodeModelsResponse,
|
||||
OpencodeModelSummary,
|
||||
PathExistsResponse,
|
||||
SlashCommand,
|
||||
SlashCommandsResponse,
|
||||
UploadFileResponse
|
||||
} from '@hapi/protocol/apiTypes'
|
||||
|
||||
@@ -155,20 +157,6 @@ export type GitStatusFiles = {
|
||||
totalUnstaged: number
|
||||
}
|
||||
|
||||
export type SlashCommand = {
|
||||
name: string
|
||||
description?: string
|
||||
source: 'builtin' | 'user' | 'plugin' | 'project'
|
||||
content?: string // Expanded content for Codex user prompts
|
||||
pluginName?: string
|
||||
}
|
||||
|
||||
export type SlashCommandsResponse = {
|
||||
success: boolean
|
||||
commands?: SlashCommand[]
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type SkillSummary = {
|
||||
name: string
|
||||
description?: string
|
||||
|
||||
Reference in New Issue
Block a user