mirror of
https://github.com/wu736139669/hapi.git
synced 2026-10-12 20:07:31 +00:00
* Add Codex clear and compact slash commands * Stabilize queued thinking event test * Interrupt active Codex turn before slash commands
30 lines
846 B
TypeScript
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 };
|
|
}
|