Files
orca/src/shared/agent-startup-plan-inputs-extra-agent-args.spec.ts
T

89 lines
2.8 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { resolveAgentStartupPlanInputs } from './agent-startup-plan-inputs'
import { mergeExtraAgentArgs } from './automation-extra-agent-args'
import { buildAgentStartupPlan } from './tui-agent-startup'
import { resolveTuiAgentLaunchArgs } from './tui-agent-launch-defaults'
const SETTINGS = {
agentDefaultArgs: { claude: '--dangerously-skip-permissions --model sonnet' },
terminalWindowsShell: 'powershell.exe'
}
describe('resolveAgentStartupPlanInputs with extra agent args', () => {
it.each([
['linux', false],
['win32', false],
['win32', true]
] as const)('merges over the host defaults on %s (remote %s)', (platform, isRemote) => {
const inputs = resolveAgentStartupPlanInputs({
agent: 'claude',
settings: SETTINGS,
platform,
isRemote,
shell: undefined,
extraAgentArgs: '--model opus --add-dir "my docs"'
})
const plan = buildAgentStartupPlan({ ...inputs, prompt: 'go' })
expect(plan?.launchCommand).toContain("'--add-dir' 'my docs'")
expect(plan?.launchCommand).toContain('opus')
expect(plan?.launchCommand).not.toContain('sonnet')
expect(plan?.launchCommand).toContain('--dangerously-skip-permissions')
})
it('matches explicitly composed launch defaults and extras', () => {
const headless = resolveAgentStartupPlanInputs({
agent: 'claude',
settings: SETTINGS,
platform: 'darwin',
isRemote: false,
shell: undefined,
extraAgentArgs: '--effort high'
})
const desktopArgs = mergeExtraAgentArgs({
agent: 'claude',
defaultArgs: resolveTuiAgentLaunchArgs('claude', SETTINGS),
extraAgentArgs: '--effort high',
shell: 'posix'
})
if (!desktopArgs.ok) {
throw new Error(desktopArgs.error)
}
const desktop = buildAgentStartupPlan({
agent: 'claude',
prompt: 'go',
cmdOverrides: {},
platform: 'darwin',
agentArgs: desktopArgs.agentArgs
})
expect(buildAgentStartupPlan({ ...headless, prompt: 'go' })?.launchCommand).toBe(
desktop?.launchCommand
)
})
it('throws on extras the executing host refuses', () => {
expect(() =>
resolveAgentStartupPlanInputs({
agent: 'claude',
settings: SETTINGS,
platform: 'linux',
isRemote: false,
shell: undefined,
extraAgentArgs: '--permission-mode bypassPermissions'
})
).toThrow('"--permission-mode"')
})
it('leaves launches without extras untouched', () => {
const inputs = resolveAgentStartupPlanInputs({
agent: 'claude',
settings: SETTINGS,
platform: 'linux',
isRemote: false,
shell: undefined,
agentArgs: null,
extraAgentArgs: ' '
})
expect(inputs.agentArgs).toBeNull()
})
})