mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
* fix(terminal): preserve preparation and discovery for delayed agent launches * refactor(agents): centralize launch intent recognition * refactor(agents): keep launch intent in one module apart from process recognition Move recognizeAgentLaunchCommand next to the sleep-prefix scanner so the strict process-table matcher is untouched, name the module away from the agent-launch funnel files, share one executable-name normalizer, and colocate the preparation tests with their modules.
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { isOpenCode2LaunchCommand, selectOpenCodeHookAgent } from './opencode-launch-command'
|
|
|
|
describe('isOpenCode2LaunchCommand', () => {
|
|
it.each(['opencode2', '/usr/local/bin/opencode2', 'opencode2.exe', 'opencode2.cmd'])(
|
|
'recognizes %s',
|
|
(command) => {
|
|
expect(isOpenCode2LaunchCommand(command)).toBe(true)
|
|
}
|
|
)
|
|
|
|
it.each(['opencode', 'echo opencode2', 'opencode2-helper'])('rejects %s', (command) => {
|
|
expect(isOpenCode2LaunchCommand(command)).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('OpenCode hook selection', () => {
|
|
it.each([
|
|
'opencode --session fixture',
|
|
'"C:\\tools\\opencode.exe" --session fixture',
|
|
'/usr/local/bin/opencode'
|
|
])('preserves disabled v1 identity for %s', (command) => {
|
|
expect(selectOpenCodeHookAgent(undefined, command, (agent) => agent === 'opencode2')).toBeNull()
|
|
})
|
|
it('trusts the supplied identity for wrapped or renamed commands', () => {
|
|
expect(selectOpenCodeHookAgent('opencode', 'opencode2', () => true)).toBe('opencode')
|
|
expect(
|
|
selectOpenCodeHookAgent('opencode2', 'my-wrapper', (agent) => agent === 'opencode2')
|
|
).toBe('opencode2')
|
|
})
|
|
})
|
|
|
|
describe('selectOpenCodeHookAgent after a sleep prefix', () => {
|
|
it('selects OpenCode 2 hooks instead of the v1 fallback', () => {
|
|
expect(selectOpenCodeHookAgent(undefined, 'sleep 30 && opencode2', () => true)).toBe(
|
|
'opencode2'
|
|
)
|
|
expect(
|
|
selectOpenCodeHookAgent(undefined, 'sleep 30 && opencode2', (agent) => agent === 'opencode')
|
|
).toBeNull()
|
|
})
|
|
})
|