Files
orca/src/main/powershell-osc133-bootstrap.test.ts
T
Rod BoevandOrcaWin 271776f233 fix(codex): keep shell-profile-only Windows CODEX_HOME on the managed lane (#10221)
* fix(codex): keep shell-profile-only Windows CODEX_HOME on the managed lane

* test(codex): harden platform probe regression coverage

* test(codex): isolate Windows home ownership coverage

* fix(codex): preserve managed home in constrained PowerShell

* fix(powershell): continue constrained startup commands

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-07-31 11:58:46 -07:00

45 lines
2.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
encodePowerShellCommand,
getPowerShellOsc133Bootstrap
} from './powershell-osc133-bootstrap'
describe('PowerShell OSC 133 bootstrap', () => {
it('wraps prompt/readline without bypassing profiles or execution policy', () => {
const script = getPowerShellOsc133Bootstrap()
expect(script).toContain('[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()')
expect(script).toContain('ORCA_OPENCODE_CONFIG_DIR')
expect(script).toContain('ORCA_MIMOCODE_HOME')
expect(script).not.toContain('ORCA_PI_CODING_AGENT_DIR')
expect(script).not.toContain('ORCA_OMP_CODING_AGENT_DIR')
expect(script).toContain('ORCA_OMP_STATUS_EXTENSION')
expect(script).toContain('function Global:omp')
expect(script).toContain('--extension $env:ORCA_OMP_STATUS_EXTENSION')
expect(script).toContain('ORCA_CODEX_HOME')
expect(script).toContain('function Global:prompt')
expect(script).toContain('function Global:PSConsoleHostReadLine')
expect(script).toContain('Esc = [char]27')
expect(script).toContain('Bel = [char]7')
expect(script).toContain(')]133;D;$fakeExitCode$(')
expect(script).toContain(')]133;A$(')
expect(script).toContain(')]133;B$(')
expect(script).toContain(')]133;C$(')
expect(script).not.toContain('`e]133')
expect(script).not.toContain('$PROFILE')
expect(script).not.toContain('ExecutionPolicy')
expect(script).not.toContain('NoProfile')
const codexHomeRestore = script.indexOf('if ($env:ORCA_CODEX_HOME)')
expect(codexHomeRestore).toBeGreaterThan(-1)
expect(codexHomeRestore).toBeLessThan(script.indexOf('Test-Path variable:global:'))
expect(codexHomeRestore).toBeLessThan(script.indexOf('LanguageMode -eq "FullLanguage"'))
})
it('encodes commands as UTF-16LE base64 for PowerShell -EncodedCommand', () => {
expect(encodePowerShellCommand('Write-Output ok')).toBe(
Buffer.from('Write-Output ok', 'utf16le').toString('base64')
)
})
})