mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat: support Codex goal slash command
This commit is contained in:
@@ -5,6 +5,7 @@ import type { EnhancedMode } from '../loop';
|
||||
import type { SlashCommand } from '@/modules/common/slashCommands';
|
||||
|
||||
const REASONING_EFFORTS = new Set<ReasoningEffort>(['none', 'minimal', 'low', 'medium', 'high', 'xhigh']);
|
||||
export const MAX_CODEX_GOAL_OBJECTIVE_CHARS = 4_000;
|
||||
|
||||
const UNSUPPORTED_CODEX_BUILTIN_COMMANDS = new Set([
|
||||
'compat',
|
||||
@@ -43,6 +44,12 @@ export type CodexSlashResolution =
|
||||
model?: string | null;
|
||||
modelReasoningEffort?: ReasoningEffort | null;
|
||||
};
|
||||
}
|
||||
| {
|
||||
kind: 'goal';
|
||||
action: 'show' | 'set' | 'pause' | 'resume' | 'clear';
|
||||
objective?: string;
|
||||
message?: string;
|
||||
};
|
||||
|
||||
export function resolveCodexSlashCommand(
|
||||
@@ -97,6 +104,40 @@ export function resolveCodexSlashCommand(
|
||||
};
|
||||
}
|
||||
|
||||
if (command === 'goal') {
|
||||
const lowerRest = rest.toLowerCase();
|
||||
if (!rest) {
|
||||
return { kind: 'goal', action: 'show' };
|
||||
}
|
||||
if (lowerRest === 'clear') {
|
||||
return { kind: 'goal', action: 'clear' };
|
||||
}
|
||||
if (lowerRest === 'pause') {
|
||||
return { kind: 'goal', action: 'pause' };
|
||||
}
|
||||
if (lowerRest === 'resume') {
|
||||
return { kind: 'goal', action: 'resume' };
|
||||
}
|
||||
const objective = rest.trim();
|
||||
if (!objective) {
|
||||
return {
|
||||
kind: 'handled',
|
||||
message: 'Goal objective must not be empty.'
|
||||
};
|
||||
}
|
||||
if ([...objective].length > MAX_CODEX_GOAL_OBJECTIVE_CHARS) {
|
||||
return {
|
||||
kind: 'handled',
|
||||
message: `Goal objective must be at most ${MAX_CODEX_GOAL_OBJECTIVE_CHARS} characters.`
|
||||
};
|
||||
}
|
||||
return {
|
||||
kind: 'goal',
|
||||
action: 'set',
|
||||
objective
|
||||
};
|
||||
}
|
||||
|
||||
if (command === 'default' || command === 'execute') {
|
||||
return {
|
||||
kind: 'handled',
|
||||
@@ -178,6 +219,8 @@ export function resolveCodexSlashCommand(
|
||||
'Supported Codex slash commands:',
|
||||
'/plan [prompt] — enable plan mode, optionally send prompt',
|
||||
'/plan off — return to default mode',
|
||||
'/goal [objective] — set or view the persistent goal',
|
||||
'/goal pause|resume|clear — update the current goal',
|
||||
'/clear — reset current Codex thread context',
|
||||
'/compact — compact current Codex thread context',
|
||||
'/status — show current Codex session config',
|
||||
|
||||
Reference in New Issue
Block a user