mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
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
This commit is contained in:
@@ -114,6 +114,8 @@ describe('listSlashCommands', () => {
|
||||
const commands = await listSlashCommands('codex', projectDir)
|
||||
|
||||
expect(commands.map((command) => command.name)).toEqual(expect.arrayContaining([
|
||||
'clear',
|
||||
'compact',
|
||||
'plan',
|
||||
'status',
|
||||
'model',
|
||||
@@ -122,6 +124,21 @@ describe('listSlashCommands', () => {
|
||||
]))
|
||||
})
|
||||
|
||||
it('lets project codex prompts override same-name built-ins', async () => {
|
||||
await writeFile(
|
||||
join(projectDir, '.codex', 'prompts', 'clear.md'),
|
||||
['---', 'description: Project clear', '---', '', 'Project clear prompt'].join('\n')
|
||||
)
|
||||
|
||||
const commands = await listSlashCommands('codex', projectDir)
|
||||
const clearCommands = commands.filter(cmd => cmd.name === 'clear')
|
||||
|
||||
expect(clearCommands).toHaveLength(1)
|
||||
expect(clearCommands[0]?.source).toBe('project')
|
||||
expect(clearCommands[0]?.description).toBe('Project clear')
|
||||
expect(clearCommands[0]?.content).toBe('Project clear prompt')
|
||||
})
|
||||
|
||||
it('loads Codex global and project prompts', async () => {
|
||||
await writeFile(
|
||||
join(codexHome, 'prompts', 'global-prompt.md'),
|
||||
|
||||
@@ -33,6 +33,8 @@ const BUILTIN_COMMANDS: Record<string, SlashCommand[]> = {
|
||||
{ name: 'plan', description: 'Toggle plan mode', source: 'builtin' },
|
||||
],
|
||||
codex: [
|
||||
{ name: 'clear', description: 'Clear current Codex thread context', source: 'builtin' },
|
||||
{ name: 'compact', description: 'Compact current Codex thread context', 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' },
|
||||
|
||||
Reference in New Issue
Block a user