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:
@@ -1,9 +1,16 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { findUnsupportedCodexBuiltinSlashCommand, getBuiltinSlashCommands } from './codexSlashCommands'
|
||||
import {
|
||||
findCodexCustomPromptExpansion,
|
||||
findUnsupportedCodexBuiltinSlashCommand,
|
||||
getBuiltinSlashCommands,
|
||||
mergeSlashCommands
|
||||
} from './codexSlashCommands'
|
||||
|
||||
describe('getBuiltinSlashCommands', () => {
|
||||
it('exposes HAPI-supported codex built-ins in remote web mode', () => {
|
||||
expect(getBuiltinSlashCommands('codex').map((command) => command.name)).toEqual(expect.arrayContaining([
|
||||
'clear',
|
||||
'compact',
|
||||
'plan',
|
||||
'status',
|
||||
'execute',
|
||||
@@ -13,6 +20,41 @@ describe('getBuiltinSlashCommands', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('mergeSlashCommands', () => {
|
||||
it('lets custom commands override same-name built-ins', () => {
|
||||
const commands = mergeSlashCommands([
|
||||
{ name: 'clear', source: 'builtin' },
|
||||
{ name: 'compact', source: 'builtin' },
|
||||
{ name: 'clear', source: 'project', content: 'project clear prompt' }
|
||||
])
|
||||
|
||||
expect(commands).toEqual([
|
||||
{ name: 'compact', source: 'builtin' },
|
||||
{ name: 'clear', source: 'project', content: 'project clear prompt' }
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe('findCodexCustomPromptExpansion', () => {
|
||||
it('expands exact custom codex prompt commands', () => {
|
||||
expect(findCodexCustomPromptExpansion(' /clear ', [
|
||||
{ name: 'clear', source: 'builtin' },
|
||||
{ name: 'clear', source: 'project', content: 'custom clear prompt' }
|
||||
])).toBe('custom clear prompt')
|
||||
})
|
||||
|
||||
it('ignores built-ins and commands with arguments', () => {
|
||||
const commands = [
|
||||
{ name: 'compact', source: 'project', content: 'custom compact prompt' }
|
||||
] as const
|
||||
|
||||
expect(findCodexCustomPromptExpansion('/compact now', commands)).toBeNull()
|
||||
expect(findCodexCustomPromptExpansion('/clear', [
|
||||
{ name: 'clear', source: 'builtin' }
|
||||
])).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('findUnsupportedCodexBuiltinSlashCommand', () => {
|
||||
it('detects unsupported codex built-ins', () => {
|
||||
expect(findUnsupportedCodexBuiltinSlashCommand(' /diff ', [])).toBe('diff')
|
||||
|
||||
Reference in New Issue
Block a user