diff --git a/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts b/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts index 3232c702dfd..c52d6656013 100644 --- a/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts +++ b/src/main/agent-hooks/managed-hook-stdin-lifecycle.test.ts @@ -4,7 +4,7 @@ // missing-Orca-env path, so their writer may break there. import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { spawn } from 'node:child_process' -import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs' +import { mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' import type { SFTPWrapper } from 'ssh2' @@ -30,25 +30,6 @@ afterEach(() => { rmSync(isolatedUserDataDir, { recursive: true, force: true }) }) -function findGitBash(): string { - if (process.env.KIMI_SHELL_PATH) { - return process.env.KIMI_SHELL_PATH - } - const candidates = [ - process.env.ProgramFiles && join(process.env.ProgramFiles, 'Git', 'bin', 'bash.exe'), - process.env['ProgramFiles(x86)'] && - join(process.env['ProgramFiles(x86)'], 'Git', 'bin', 'bash.exe'), - process.env.LOCALAPPDATA && join(process.env.LOCALAPPDATA, 'Programs', 'Git', 'bin', 'bash.exe') - ] - const bash = candidates.find((candidate): candidate is string => - Boolean(candidate && existsSync(candidate)) - ) - if (!bash) { - throw new Error('Git Bash is required for the Windows Kimi hook lifecycle test') - } - return bash -} - const { homedirMock } = vi.hoisted(() => ({ homedirMock: vi.fn<() => string>() })) @@ -84,6 +65,7 @@ import { wrapPosixHookCommand, wrapWindowsHookCommand } from './installer-utils' import { POSIX_HOOK_STDIN_READER } from './hook-stdin-contract' import { wrapRuntimeHomeHookCommand } from './runtime-home-hook-command' import { createAgentHookMemorySftp } from './agent-hook-memory-sftp.test-fixture' +import { findGitBash } from './windows-git-bash-path.test-fixture' const REMOTE_HOME = '/home/dev' const LARGE_PAYLOAD = Buffer.alloc(1_000_000, 'x') diff --git a/src/main/agent-hooks/windows-git-bash-path.test-fixture.ts b/src/main/agent-hooks/windows-git-bash-path.test-fixture.ts new file mode 100644 index 00000000000..9bef35da989 --- /dev/null +++ b/src/main/agent-hooks/windows-git-bash-path.test-fixture.ts @@ -0,0 +1,23 @@ +import { existsSync } from 'node:fs' +import { join } from 'node:path' + +// Why: Windows hook tests must run the registered command through MSYS too — it +// rewrites switches and paths, so a launcher can pass under cmd.exe and fail here. +export function findGitBash(): string { + if (process.env.KIMI_SHELL_PATH) { + return process.env.KIMI_SHELL_PATH + } + const candidates = [ + process.env.ProgramFiles && join(process.env.ProgramFiles, 'Git', 'bin', 'bash.exe'), + process.env['ProgramFiles(x86)'] && + join(process.env['ProgramFiles(x86)'], 'Git', 'bin', 'bash.exe'), + process.env.LOCALAPPDATA && join(process.env.LOCALAPPDATA, 'Programs', 'Git', 'bin', 'bash.exe') + ] + const bash = candidates.find((candidate): candidate is string => + Boolean(candidate && existsSync(candidate)) + ) + if (!bash) { + throw new Error('Git Bash is required for the Windows managed hook tests') + } + return bash +} diff --git a/src/main/agent-hooks/windows-hook-payload-delivery.test.ts b/src/main/agent-hooks/windows-hook-payload-delivery.test.ts new file mode 100644 index 00000000000..aabf2545172 --- /dev/null +++ b/src/main/agent-hooks/windows-hook-payload-delivery.test.ts @@ -0,0 +1,205 @@ +// Why: 1.4.184 registered `conhost.exe --headless /d /c