mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
test: remove low-value startup hook and keyboard facade tests (#43494)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@ vi.mock('os', async () => {
|
||||
})
|
||||
|
||||
import { DevinHookService } from './hook-service'
|
||||
import { applyDevinManagedHooks, getDevinConfigPath, getDevinManagedCommand } from './hook-settings'
|
||||
import { getDevinConfigPath } from './hook-settings'
|
||||
|
||||
describe('DevinHookService', () => {
|
||||
let homeDir: string
|
||||
@@ -70,38 +70,4 @@ describe('DevinHookService', () => {
|
||||
expect(removed).toContain('mine.sh')
|
||||
expect(parseJsonc(removed).hooks.UserPromptSubmit).toBeUndefined()
|
||||
})
|
||||
|
||||
it('registers a forward-slash cmd path on Windows and replaces the legacy backslash entry', () => {
|
||||
const previous = process.platform
|
||||
Object.defineProperty(process, 'platform', { value: 'win32' })
|
||||
try {
|
||||
const scriptPath = 'C:\\Users\\ada\\.orca\\agent-hooks\\devin-hook.cmd'
|
||||
const command = getDevinManagedCommand(scriptPath)
|
||||
// Forward slashes survive Git Bash path handling.
|
||||
expect(command).toBe('C:/Users/ada/.orca/agent-hooks/devin-hook.cmd')
|
||||
// UNC paths retain the encoded launcher because they have no drive letter.
|
||||
expect(
|
||||
getDevinManagedCommand('\\\\server\\share\\ada\\.orca\\agent-hooks\\devin-hook.cmd')
|
||||
).toMatch(/ -EncodedCommand \S+$/)
|
||||
|
||||
const next = applyDevinManagedHooks(
|
||||
{
|
||||
hooks: {
|
||||
Stop: [
|
||||
{ hooks: [{ type: 'command', command: scriptPath }] },
|
||||
{ hooks: [{ type: 'command', command: 'C:\\tools\\user-hook.cmd' }] }
|
||||
]
|
||||
}
|
||||
},
|
||||
command,
|
||||
'devin-hook.cmd'
|
||||
)
|
||||
expect(next.hooks?.Stop?.flatMap((definition) => definition.hooks ?? [])).toEqual([
|
||||
{ type: 'command', command: 'C:\\tools\\user-hook.cmd' },
|
||||
expect.objectContaining({ command })
|
||||
])
|
||||
} finally {
|
||||
Object.defineProperty(process, 'platform', { value: previous })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -51,20 +51,4 @@ describe('Hermes remote installer through a local filesystem adapter (no SSH)',
|
||||
expect(readdirSync(join(directory, '.hermes'))).toEqual(['config.yaml'])
|
||||
}
|
||||
)
|
||||
|
||||
it('keeps the config and cleans staged files when remote rename fails', async () => {
|
||||
writeFileSync(configPath, 'model: fixture\n')
|
||||
const filesystem = createManagedHookLocalFilesystem()
|
||||
const rename = filesystem.ext_openssh_rename.bind(filesystem)
|
||||
filesystem.ext_openssh_rename = (source, destination, callback) => {
|
||||
if (destination === configPath) {
|
||||
callback(new Error('fixture rename refusal'))
|
||||
} else {
|
||||
rename(source, destination, callback)
|
||||
}
|
||||
}
|
||||
expect((await service.installRemote(filesystem, directory)).state).toBe('error')
|
||||
expect(readFileSync(configPath, 'utf8')).toBe('model: fixture\n')
|
||||
expect(readdirSync(join(directory, '.hermes')).sort()).toEqual(['config.yaml', 'plugins'])
|
||||
})
|
||||
})
|
||||
|
||||
-22
@@ -61,28 +61,6 @@ it('ignores old reads across host switches, restarts, and re-pairing', async ()
|
||||
)
|
||||
})
|
||||
|
||||
it('reopens a freshly mounted menu with the last host answer, then revalidates', async () => {
|
||||
const first = renderHook(() =>
|
||||
useNewTabAgentMenuRows('wt', true, { kind: 'runtime', environmentId: 'alpha' })
|
||||
)
|
||||
await act(async () => {})
|
||||
first.unmount()
|
||||
const pending = Promise.withResolvers<{ settings: typeof server }>()
|
||||
rpc.call.mockReturnValueOnce(pending.promise)
|
||||
const second = renderHook(() =>
|
||||
useNewTabAgentMenuRows('wt', true, { kind: 'runtime', environmentId: 'alpha' })
|
||||
)
|
||||
expect(second.result.current.state === 'settled' && second.result.current.rows[0]?.agent).toBe(
|
||||
'codex'
|
||||
)
|
||||
await act(async () =>
|
||||
pending.resolve({ settings: projectAgentLaunchSettings({ defaultTuiAgent: 'claude' }) })
|
||||
)
|
||||
expect(second.result.current.state === 'settled' && second.result.current.rows[0]?.agent).toBe(
|
||||
'claude'
|
||||
)
|
||||
})
|
||||
|
||||
it('stops waiting on a stalled host, then applies its late answer', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
// @vitest-environment happy-dom
|
||||
import { act, cleanup, renderHook } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
||||
import { useAppStore } from '@/store'
|
||||
import { useGlobalKeybindings } from './use-global-keybindings'
|
||||
import { useAppChromeLayout } from '../../app-shell/chrome/use-app-chrome-layout'
|
||||
import { useFloatingWorkspacePanel } from '../../components/floating-terminal/workspace/use-floating-workspace-panel'
|
||||
import { replayAppKeyDown } from '@/lib/keyboard/app-keyboard-router'
|
||||
|
||||
vi.mock('@/app-shell/chrome/app-window-chrome', () => ({ shortcutPlatform: 'darwin' }))
|
||||
|
||||
const initial = useAppStore.getState()
|
||||
const openSettingsPage = vi.fn()
|
||||
const openSettingsTarget = vi.fn()
|
||||
|
||||
beforeEach(() => {
|
||||
useAppStore.setState({
|
||||
keybindings: { 'view.plugins': ['Alt+E'] },
|
||||
openSettingsPage,
|
||||
openSettingsTarget
|
||||
})
|
||||
renderHook(() =>
|
||||
useGlobalKeybindings({
|
||||
layout: useAppChromeLayout(),
|
||||
floatingWorkspace: useFloatingWorkspacePanel()
|
||||
})
|
||||
)
|
||||
})
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
document.body.replaceChildren()
|
||||
useAppStore.setState(initial, true)
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
function press(target: HTMLElement, init: KeyboardEventInit = {}) {
|
||||
const event = new KeyboardEvent('keydown', {
|
||||
key: 'e',
|
||||
code: 'KeyE',
|
||||
altKey: true,
|
||||
bubbles: true,
|
||||
cancelable: true,
|
||||
...init
|
||||
})
|
||||
act(() => target.dispatchEvent(event))
|
||||
return event
|
||||
}
|
||||
|
||||
it('opens Plugins from app focus but preserves textarea editing for the same configured chord', () => {
|
||||
const textarea = document.createElement('textarea')
|
||||
document.body.append(textarea)
|
||||
for (const target of [document.body, textarea]) {
|
||||
for (const init of [{ key: 'Dead' }, { key: 'Process' }, { isComposing: true }]) {
|
||||
expect(press(target, init).defaultPrevented).toBe(false)
|
||||
expect(openSettingsPage).not.toHaveBeenCalled()
|
||||
}
|
||||
}
|
||||
expect(press(textarea).defaultPrevented).toBe(false)
|
||||
expect(openSettingsPage).not.toHaveBeenCalled()
|
||||
expect(press(document.body).defaultPrevented).toBe(true)
|
||||
expect(openSettingsPage).toHaveBeenCalledOnce()
|
||||
expect(openSettingsTarget).toHaveBeenCalledWith({
|
||||
pane: 'plugins',
|
||||
repoId: null,
|
||||
intent: undefined
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves recorder, already-claimed input and repeat protections', () => {
|
||||
const recorder = document.createElement('button')
|
||||
recorder.dataset.shortcutRecorderActive = ''
|
||||
document.body.append(recorder)
|
||||
expect(press(recorder).defaultPrevented).toBe(false)
|
||||
expect(press(document.body, { repeat: true }).defaultPrevented).toBe(false)
|
||||
const claimed = new KeyboardEvent('keydown', {
|
||||
key: 'e',
|
||||
code: 'KeyE',
|
||||
altKey: true,
|
||||
cancelable: true
|
||||
})
|
||||
claimed.preventDefault()
|
||||
act(() => replayAppKeyDown(claimed))
|
||||
expect(openSettingsPage).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('dispatches guest replay chords and double taps through the real Plugins handler', () => {
|
||||
const chord = new KeyboardEvent('keydown', {
|
||||
key: 'e',
|
||||
code: 'KeyE',
|
||||
altKey: true,
|
||||
cancelable: true
|
||||
})
|
||||
act(() => replayAppKeyDown(chord))
|
||||
expect(chord.defaultPrevented).toBe(true)
|
||||
expect(openSettingsPage).toHaveBeenCalledOnce()
|
||||
act(() => useAppStore.setState({ keybindings: { 'view.plugins': ['DoubleTap+Shift'] } }))
|
||||
const gesture = Object.assign(new KeyboardEvent('keydown', { cancelable: true }), {
|
||||
doubleTapModifier: 'Shift'
|
||||
})
|
||||
act(() => replayAppKeyDown(gesture))
|
||||
expect(gesture.defaultPrevented).toBe(true)
|
||||
expect(openSettingsPage).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
@@ -1,65 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
resolvedTuiAgentArgsBypassPermissions,
|
||||
tuiAgentArgsBypassPermissions
|
||||
} from './tui-agent-launch-defaults'
|
||||
|
||||
describe('tuiAgentArgsBypassPermissions', () => {
|
||||
// Legacy Yolo intent lives in Arguments, not separate storage; recognize its token sequence anywhere before --.
|
||||
it.each([
|
||||
['claude', '--dangerously-skip-permissions', true],
|
||||
// A token boundary, so a longer flag that merely starts the same way is not a bypass.
|
||||
['claude', '--dangerously-skip-permissions-not-really', false],
|
||||
[
|
||||
'claude',
|
||||
'--append-system-prompt "mention --dangerously-skip-permissions only as text"',
|
||||
false
|
||||
],
|
||||
['claude', '-- --dangerously-skip-permissions', false],
|
||||
// Two-token bypass flags match as a token sequence, not one token.
|
||||
['grok', '--permission-mode bypassPermissions', true],
|
||||
['grok', '--permission-mode default', false],
|
||||
['grok', '--permission-mode', false],
|
||||
['grok', '--permission-mode "bypassPermissions now"', false],
|
||||
['grok', '-- --permission-mode bypassPermissions', false],
|
||||
['devin', '--permission-mode bypass --respect-workspace-trust false', true],
|
||||
['devin', '--permission-mode bypass', false]
|
||||
] as const)('reads %s args %s as %s', (agent, args, expected) => {
|
||||
expect(tuiAgentArgsBypassPermissions(agent, args, 'posix')).toBe(expected)
|
||||
})
|
||||
|
||||
it('uses the configured local Windows shell family', () => {
|
||||
expect(
|
||||
resolvedTuiAgentArgsBypassPermissions(
|
||||
'claude',
|
||||
{
|
||||
agentDefaultArgs: { claude: '`--dangerously-skip-permissions' },
|
||||
terminalWindowsShell: 'powershell.exe'
|
||||
},
|
||||
'win32'
|
||||
)
|
||||
).toBe(true)
|
||||
expect(
|
||||
resolvedTuiAgentArgsBypassPermissions(
|
||||
'codex',
|
||||
{
|
||||
agentDefaultArgs: { codex: '^--dangerously-bypass-approvals-and-sandbox' },
|
||||
terminalWindowsShell: 'cmd.exe'
|
||||
},
|
||||
'win32'
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolvedTuiAgentArgsBypassPermissions', () => {
|
||||
it('fails closed when the configured arguments cannot be tokenized', () => {
|
||||
expect(
|
||||
resolvedTuiAgentArgsBypassPermissions(
|
||||
'codex',
|
||||
{ agentDefaultArgs: { codex: '"--dangerously-bypass-approvals-and-sandbox' } },
|
||||
'linux'
|
||||
)
|
||||
).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -7,48 +7,7 @@ const CODEX_SESSION = {
|
||||
id: '0199aa11-2b3c-4d5e-8f90-a1b2c3d4e5f6'
|
||||
}
|
||||
|
||||
function planFor(platform: NodeJS.Platform, agentArgs?: string): string {
|
||||
const plan = buildAgentResumeStartupPlan({
|
||||
agent: 'codex',
|
||||
providerSession: CODEX_SESSION,
|
||||
cmdOverrides: {},
|
||||
platform,
|
||||
...(agentArgs ? { agentArgs } : {})
|
||||
})
|
||||
if (!plan) {
|
||||
throw new Error('expected a codex resume plan')
|
||||
}
|
||||
return plan.launchCommand
|
||||
}
|
||||
|
||||
describe('dropAgentResumeArgvFromCommand', () => {
|
||||
it('drops the resume argv the shared builder appended on every platform', () => {
|
||||
for (const platform of ['darwin', 'linux', 'win32'] as const) {
|
||||
const command = planFor(platform)
|
||||
expect(command).toContain(CODEX_SESSION.id)
|
||||
expect(
|
||||
dropAgentResumeArgvFromCommand({
|
||||
command,
|
||||
agent: 'codex',
|
||||
providerSession: CODEX_SESSION
|
||||
})
|
||||
).toEqual({
|
||||
status: 'dropped',
|
||||
command: platform === 'win32' ? 'codex' : "codex '-c' 'disable_paste_burst=true'"
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps the user CLI args that precede the resume argv', () => {
|
||||
expect(
|
||||
dropAgentResumeArgvFromCommand({
|
||||
command: planFor('darwin', '--search'),
|
||||
agent: 'codex',
|
||||
providerSession: CODEX_SESSION
|
||||
})
|
||||
).toEqual({ status: 'dropped', command: "codex '-c' 'disable_paste_burst=true' '--search'" })
|
||||
})
|
||||
|
||||
it('drops the joined Copilot resume token and keeps the user args', () => {
|
||||
const providerSession = {
|
||||
key: 'session_id' as const,
|
||||
|
||||
@@ -1,57 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildClaudeResumeLaunchCommand } from './agent-resume-launch-command'
|
||||
import { buildAgentResumeStartupPlan } from './tui-agent-resume-startup'
|
||||
import { tokenizeStartupCommand, type AgentStartupShell } from './tui-agent-startup-shell'
|
||||
|
||||
const SESSION_ID = 'claude-session-1'
|
||||
const RESUME = ['--resume', SESSION_ID] as const
|
||||
const providerSession = { key: 'session_id', id: SESSION_ID } as const
|
||||
|
||||
const SHELLS: { platform: NodeJS.Platform; shell: AgentStartupShell }[] = [
|
||||
{ platform: 'linux', shell: 'posix' },
|
||||
{ platform: 'darwin', shell: 'posix' },
|
||||
{ platform: 'win32', shell: 'powershell' },
|
||||
{ platform: 'win32', shell: 'cmd' }
|
||||
]
|
||||
|
||||
/** Use an independent selector oracle so shrinking the stripped set cannot also blind the assertion. */
|
||||
function isResumeSelectorToken(token: string): boolean {
|
||||
return (
|
||||
['--resume', '--continue', '-r', '-c'].includes(token) ||
|
||||
['--resume=', '--continue=', '-r=', '-c='].some((prefix) => token.startsWith(prefix))
|
||||
)
|
||||
}
|
||||
|
||||
/** Tokenizes a launch command and asserts exactly one identity-bearing resume. */
|
||||
function expectSingleAuthoritativeResume(command: string, shell: AgentStartupShell): void {
|
||||
const tokenized = tokenizeStartupCommand(command, shell)
|
||||
expect(tokenized.ok).toBe(true)
|
||||
if (!tokenized.ok) {
|
||||
return
|
||||
}
|
||||
const selectors = tokenized.tokens.filter(isResumeSelectorToken)
|
||||
expect(selectors).toEqual(['--resume'])
|
||||
const index = tokenized.tokens.indexOf('--resume')
|
||||
expect(tokenized.tokens[index + 1]).toBe(SESSION_ID)
|
||||
}
|
||||
|
||||
describe('buildClaudeResumeLaunchCommand', () => {
|
||||
it.each([
|
||||
'claude --resume stale-session',
|
||||
'claude --resume=stale-session',
|
||||
'claude -r stale-session',
|
||||
'claude -r=stale-session',
|
||||
'claude --resume= --model sonnet',
|
||||
'claude --continue',
|
||||
'claude -c',
|
||||
'claude --continue=1',
|
||||
'claude -c=1',
|
||||
'claude --resume stale -r older --continue -c'
|
||||
])('replaces stale selectors in %s', (base) => {
|
||||
const command = buildClaudeResumeLaunchCommand(base, RESUME, 'posix')
|
||||
expectSingleAuthoritativeResume(command, 'posix')
|
||||
})
|
||||
|
||||
it('never mistakes a dash-leading option value for a selector', () => {
|
||||
expect(buildClaudeResumeLaunchCommand('claude --model -recent', RESUME, 'posix')).toBe(
|
||||
`claude --model -recent '--resume' '${SESSION_ID}'`
|
||||
@@ -152,32 +105,3 @@ describe('buildClaudeResumeLaunchCommand', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildAgentResumeStartupPlan claude effort', () => {
|
||||
it.each(SHELLS)(
|
||||
"resumes at the session's effort after a stale launch flag ($platform/$shell)",
|
||||
({ platform, shell }) => {
|
||||
const session = { ...providerSession, effort: 'max' }
|
||||
const restored = buildAgentResumeStartupPlan({
|
||||
agent: 'claude',
|
||||
providerSession: session,
|
||||
cmdOverrides: {},
|
||||
agentArgs: '--effort low',
|
||||
platform,
|
||||
shell
|
||||
})
|
||||
const command = restored?.launchCommand ?? ''
|
||||
const tokens = tokenizeStartupCommand(command, shell)
|
||||
// Claude keeps the last --effort it parses.
|
||||
expect(tokens.ok && tokens.tokens.slice(-6)).toEqual([
|
||||
'--effort',
|
||||
'low',
|
||||
'--effort',
|
||||
'max',
|
||||
...RESUME
|
||||
])
|
||||
// The saved launch recipe stays the user's own.
|
||||
expect(restored?.launchConfig.agentArgs).toBe('--effort low')
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -5,41 +5,6 @@ import {
|
||||
} from './agent-startup-plan-inputs'
|
||||
import { buildAgentStartupPlan } from './tui-agent-startup'
|
||||
|
||||
describe('resolveAgentStartupPlanInputs', () => {
|
||||
it('classifies the Windows shell only for a local win32 launch', () => {
|
||||
const settings: AgentStartupSettings = { terminalWindowsShell: 'git-bash' }
|
||||
|
||||
expect(
|
||||
resolveAgentStartupPlanInputs({
|
||||
agent: 'claude',
|
||||
settings,
|
||||
platform: 'win32',
|
||||
isRemote: false,
|
||||
shell: undefined
|
||||
}).shell
|
||||
).toBe('posix')
|
||||
// Remote targets need their own shell signal before quoting can be overridden.
|
||||
expect(
|
||||
resolveAgentStartupPlanInputs({
|
||||
agent: 'claude',
|
||||
settings,
|
||||
platform: 'win32',
|
||||
isRemote: true,
|
||||
shell: undefined
|
||||
}).shell
|
||||
).toBeUndefined()
|
||||
expect(
|
||||
resolveAgentStartupPlanInputs({
|
||||
agent: 'claude',
|
||||
settings,
|
||||
platform: 'darwin',
|
||||
isRemote: false,
|
||||
shell: undefined
|
||||
}).shell
|
||||
).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
describe('a picked session option outranks configured launch arguments', () => {
|
||||
// Compose the surfaces: prove one model flag reaches argv and the chat can name the selected model, beyond asserting the policy flag.
|
||||
function commandFor(settings: AgentStartupSettings) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createHash } from 'node:crypto'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildAgentStartupPlan, buildAgentDraftLaunchPlan } from './tui-agent-startup'
|
||||
import { buildAgentStartupPlan } from './tui-agent-startup'
|
||||
import {
|
||||
OPENCODE_STARTUP_PROMPT_SHA256_ENV,
|
||||
OPENCODE_STARTUP_PROMPT_BODY_ENV,
|
||||
@@ -79,18 +79,4 @@ describe('native OpenCode startup submission intent', () => {
|
||||
expect(plan?.env).toBeUndefined()
|
||||
}
|
||||
)
|
||||
|
||||
it('never gives an editable draft or empty launch an automatic submission intent', () => {
|
||||
const args = { agent: 'opencode' as const, cmdOverrides: {}, platform: 'linux' as const }
|
||||
expect(
|
||||
buildAgentDraftLaunchPlan({ ...args, draft: 'draft' })?.env?.[
|
||||
OPENCODE_STARTUP_PROMPT_SHA256_ENV
|
||||
]
|
||||
).toBeUndefined()
|
||||
expect(
|
||||
buildAgentStartupPlan({ ...args, prompt: '', allowEmptyPromptLaunch: true })?.env?.[
|
||||
OPENCODE_STARTUP_PROMPT_SHA256_ENV
|
||||
]
|
||||
).toBeUndefined()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -30,16 +30,4 @@ describe('agent fork startup', () => {
|
||||
"codex '-c' 'disable_paste_burst=true' '-c' 'tui.resume_cwd=current' 'fork' 's1'"
|
||||
)
|
||||
})
|
||||
|
||||
it('refuses a fork for an agent that cannot fork rather than resuming it', () => {
|
||||
expect(
|
||||
buildAgentResumeStartupPlan({
|
||||
agent: 'gemini',
|
||||
providerSession: SESSION,
|
||||
cmdOverrides: {},
|
||||
platform: 'darwin',
|
||||
fork: true
|
||||
})
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,37 +1,11 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildAgentResumeStartupPlan } from './tui-agent-resume-startup'
|
||||
import { buildAgentStartupPlan } from './tui-agent-startup'
|
||||
import {
|
||||
unwrapPosixShellScript,
|
||||
unwrapPowerShellScript
|
||||
} from './tui-agent-startup-script.test-fixture'
|
||||
import { unwrapPosixShellScript } from './tui-agent-startup-script.test-fixture'
|
||||
|
||||
// Hermes owns startup query/TUI/subcommand flag placement; keep its token-rewrite cases together.
|
||||
|
||||
describe('hermes startup plans', () => {
|
||||
it.each([
|
||||
{
|
||||
shell: 'powershell' as const,
|
||||
override: '"C:\\Program Files\\Hermes\\hermes.exe" --tui',
|
||||
expected: "& 'C:\\Program Files\\Hermes\\hermes.exe' 'chat'"
|
||||
},
|
||||
{
|
||||
shell: 'cmd' as const,
|
||||
override: 'C:\\Tools\\hermes.exe --tui',
|
||||
expected: "& 'C:\\Tools\\hermes.exe' 'chat'"
|
||||
}
|
||||
])('preserves Windows paths in Hermes command overrides on $shell', (testCase) => {
|
||||
const plan = buildAgentStartupPlan({
|
||||
agent: 'hermes',
|
||||
prompt: 'run it',
|
||||
cmdOverrides: { hermes: testCase.override },
|
||||
platform: 'win32',
|
||||
shell: testCase.shell
|
||||
})
|
||||
|
||||
expect(unwrapPowerShellScript(plan?.launchCommand)).toContain(testCase.expected)
|
||||
})
|
||||
|
||||
it('removes a configured duplicate chat subcommand', () => {
|
||||
const plan = buildAgentStartupPlan({
|
||||
agent: 'hermes',
|
||||
@@ -124,17 +98,6 @@ describe('hermes startup plans', () => {
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('measures POSIX Hermes query limits in UTF-8 bytes', () => {
|
||||
const plan = buildAgentStartupPlan({
|
||||
agent: 'hermes',
|
||||
prompt: '界'.repeat(50_000),
|
||||
cmdOverrides: {},
|
||||
platform: 'linux'
|
||||
})
|
||||
|
||||
expect(plan).toBeNull()
|
||||
})
|
||||
|
||||
it('keeps the override and agent args of a prompted Hermes launch when it resumes', () => {
|
||||
const launch = buildAgentStartupPlan({
|
||||
agent: 'hermes',
|
||||
|
||||
@@ -1,52 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { clearEnvCommand, tokenizeStartupCommand } from './tui-agent-startup-shell'
|
||||
import { buildAgentDraftLaunchPlan } from './tui-agent-startup'
|
||||
|
||||
function expectSpansCoverTokens(source: string, shell: 'powershell' | 'cmd'): string[] {
|
||||
const result = tokenizeStartupCommand(source, shell)
|
||||
expect(result.ok).toBe(true)
|
||||
if (!result.ok) {
|
||||
return []
|
||||
}
|
||||
expect(result.spans).toHaveLength(result.tokens.length)
|
||||
let previousEnd = 0
|
||||
for (const [index, { start, end }] of result.spans.entries()) {
|
||||
expect(start).toBeGreaterThanOrEqual(previousEnd)
|
||||
expect(end).toBeGreaterThan(start)
|
||||
// Every raw span must re-tokenize to exactly its own token.
|
||||
const slice = tokenizeStartupCommand(source.slice(start, end), shell)
|
||||
expect(slice.ok && slice.tokens).toEqual([result.tokens[index]])
|
||||
previousEnd = end
|
||||
}
|
||||
return result.spans.map(({ start, end }) => source.slice(start, end))
|
||||
}
|
||||
|
||||
describe('tokenizeStartupCommand spans (windows shells)', () => {
|
||||
it('starts a span at a token-leading escape character', () => {
|
||||
expect(expectSpansCoverTokens('claude ^&literal next', 'cmd')).toEqual([
|
||||
'claude',
|
||||
'^&literal',
|
||||
'next'
|
||||
])
|
||||
expect(expectSpansCoverTokens('claude `x tail', 'powershell')).toEqual(['claude', '`x', 'tail'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('one Unix startup dialect', () => {
|
||||
it.each([
|
||||
'FOO; rm -rf /tmp/x',
|
||||
'FOO BAR',
|
||||
'',
|
||||
'1LEADING_DIGIT',
|
||||
'has-dash',
|
||||
'$FOO',
|
||||
'PATH\nHOME'
|
||||
])('refuses %j as an environment variable name', (bad) => {
|
||||
// Interpolated names must be identifiers; shell syntax would inject commands and fish erase could delete session variables.
|
||||
expect(() => clearEnvCommand(bad, 'posix')).toThrow(/not an environment variable name/)
|
||||
expect(() => clearEnvCommand(['OK', bad], 'posix')).toThrow(/not an environment variable name/)
|
||||
})
|
||||
|
||||
it('leaves a multi-line argv draft to the paste fallback in cmd.exe', () => {
|
||||
const draft = 'Linked Linear issue: ENG-1\nhttps://linear.app/acme/issue/ENG-1'
|
||||
const args = { agent: 'claude' as const, draft, cmdOverrides: {}, platform: 'win32' as const }
|
||||
|
||||
@@ -3,6 +3,5 @@ import './agent-resume-launch-command.spec'
|
||||
import './agent-startup-plan-inputs.spec'
|
||||
import './opencode-startup-prompt.spec'
|
||||
import './tui-agent-fork-startup.spec'
|
||||
import '../choices/tui-agent-launch-defaults.spec'
|
||||
import './tui-agent-startup-hermes.spec'
|
||||
import './tui-agent-startup-shell.spec'
|
||||
|
||||
Reference in New Issue
Block a user