Files
hapi/cli/src/codex/codexSpecialCommands.ts
T
NightWatcher314andGitHub a612be50d6 Add Codex clear and compact slash commands (#541)
* Add Codex clear and compact slash commands

* Stabilize queued thinking event test

* Interrupt active Codex turn before slash commands
2026-04-29 14:15:44 +08:00

30 lines
846 B
TypeScript

export type CodexSpecialCommand =
| { type: 'clear' | 'compact' }
| { type: 'invalid'; command: 'clear' | 'compact'; message: string }
| { type: null };
export function parseCodexSpecialCommand(message: string): CodexSpecialCommand {
const trimmed = message.trim();
if (trimmed === '/clear') {
return { type: 'clear' };
}
if (trimmed === '/compact') {
return { type: 'compact' };
}
if (trimmed.startsWith('/clear ')) {
return {
type: 'invalid',
command: 'clear',
message: '/clear does not accept arguments'
};
}
if (trimmed.startsWith('/compact ')) {
return {
type: 'invalid',
command: 'compact',
message: '/compact does not accept arguments'
};
}
return { type: null };
}