Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.3 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { buildWindowsCmdRunnerDelayedLaunchCommand } from './windows-cmd-runner-delayed-launch'

function decodePayload(command: string): string {
  const encoded = command.match(/ -EncodedCommand (\S+)$/)?.[1]
  if (!encoded) {
    throw new Error(`no -EncodedCommand payload in: ${command}`)
  }
  return Buffer.from(encoded, 'base64').toString('utf16le')
}

describe('buildWindowsCmdRunnerDelayedLaunchCommand', () => {
  it('keeps the base64 that shields the runner path from the pane shell', () => {
    // This command is typed into a pane shell; base64 must protect cmd metacharacters in its path.
    const command = buildWindowsCmdRunnerDelayedLaunchCommand('C:\\work (x86)\\se&tup.cmd')

    expect(command).toMatch(
      /^powershell\.exe -NoProfile -NonInteractive -EncodedCommand [A-Za-z0-9+/=]+$/
    )
    const script = decodePayload(command)
    expect(script).toContain("$runner = 'C:\\work (x86)\\se&tup.cmd'")
    expect(script).toContain('/d /s /v:on /c ""!ORCA_SETUP_RUNNER!""')
  })

  it('doubles typographic single quotes in the runner path literal', () => {
    const script = decodePayload(
      buildWindowsCmdRunnerDelayedLaunchCommand('C:\\O\u2019Brien\\setup.cmd')
    )
    expect(script).toContain("$runner = 'C:\\O\u2019\u2019Brien\\setup.cmd'")
  })
})