Files
orca/config/scripts/smoke-packaged-cli.mjs
T
Kelvin Amoaba 7f885c19a6 fix(skills): rename computer use to orca-computer-use (#37659)
* fix(skills): rename computer use to orca-computer-use

* test(skills): resolve rename fixture after main cleanup
2026-11-03 21:05:37 +00:00

105 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { cp, mkdtemp, rm } from 'node:fs/promises'
import { execFile } from 'node:child_process'
import { tmpdir } from 'node:os'
import { basename, join, resolve } from 'node:path'
import { promisify } from 'node:util'
import assert from 'node:assert/strict'
const execFileAsync = promisify(execFile)
function readAppDirArg(argv) {
const explicit = argv.find((arg) => arg.startsWith('--app-dir='))
if (explicit) {
return explicit.slice('--app-dir='.length)
}
if (process.platform === 'darwin') {
return 'dist/mac-arm64/Orca.app'
}
if (process.platform === 'win32') {
return 'dist/win-unpacked'
}
return 'dist/linux-unpacked'
}
function getPackagedCliPath(appDir) {
if (process.platform === 'darwin' || appDir.endsWith('.app')) {
return join(appDir, 'Contents', 'Resources', 'bin', 'orca')
}
if (process.platform === 'win32') {
return join(appDir, 'resources', 'bin', 'orca.exe')
}
return join(appDir, 'resources', 'bin', 'orca-ide')
}
const appDir = resolve(readAppDirArg(process.argv.slice(2)))
const tempRoot = await mkdtemp(join(tmpdir(), 'orca-packaged-cli-smoke-'))
const copiedAppDir = join(tempRoot, basename(appDir))
let smokeFailure = null
try {
await cp(appDir, copiedAppDir, { recursive: true, verbatimSymlinks: true })
const cliPath = getPackagedCliPath(copiedAppDir)
const env = { ...process.env, NODE_PATH: '' }
delete env.ORCA_CLI_CWD
const run = (args) =>
execFileAsync(cliPath, args, {
env,
killSignal: 'SIGKILL',
maxBuffer: 16 * 1024 * 1024,
timeout: 30_000
})
await run(['--help'])
const list = JSON.parse((await run(['skills', 'list', '--json'])).stdout)
assert(list.topics.some((topic) => topic.name === 'orca-cli'))
assert.match((await run(['skills', 'get', 'orca-cli'])).stdout, /name: orca-cli/)
assert.match(
(await run(['skills', 'get', 'orca-computer-use'])).stdout,
/name: orca-computer-use/
)
assert.match((await run(['skills', 'get', 'computer-use'])).stdout, /name: orca-computer-use/)
const install = JSON.parse(
(
await run([
'skills',
'install',
'--skill',
'orca-cli',
'--agent',
'codex',
'--dry-run',
'--json'
])
).stdout
)
const update = JSON.parse(
(await run(['skills', 'update', '--skill', 'orca-cli', '--dry-run', '--json'])).stdout
)
assert.equal(install.executed, false)
assert.equal(update.executed, false)
console.log(`[packaged-cli-smoke] help and skills commands passed via ${cliPath}`)
} catch (error) {
smokeFailure = error
}
// Retry Windows cleanup locks from just-exited Orca.exe/crashpad descendants; persistent lock still throws unless it would mask smoke’s original failure.
const cleanupFailure = await rm(tempRoot, {
recursive: true,
force: true,
maxRetries: 20,
retryDelay: 250
}).then(
() => null,
(error) => error
)
if (smokeFailure) {
if (cleanupFailure) {
console.warn(`[packaged-cli-smoke] temp cleanup failed: ${cleanupFailure.message}`)
}
throw smokeFailure
}
if (cleanupFailure) {
throw cleanupFailure
}