mirror of
https://github.com/stablyai/orca.git
synced 2026-10-03 00:02:19 +00:00
* wip(omp): prove fresh settings overlay without redirecting storage * fix(omp): guard fresh launches with execution-host settings * fix(omp): preserve unmodelled shell launch commands * test(omp): consolidate shell fixture path import * preserve fresh OMP launch status * test: cover preserved OMP launch status * fix: recognize wrapped fresh OMP launches * chore(ci): refresh validation against fixed main baseline * fix(omp): recognize generated fresh launch guards across shells * fix(omp): preserve draft status and clear prefill across Unix shells * fix(omp): run cmd draft cleanup after either guard branch * fix(omp): launch drafts safely with nounset enabled * fix(omp): select draft shell without parser diagnostics * test(omp): await relay environment augmentation
73 lines
2.7 KiB
TypeScript
73 lines
2.7 KiB
TypeScript
import { existsSync } from 'node:fs'
|
|
import { mkdtemp, writeFile, readFile, rm } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { delimiter, join } from 'node:path'
|
|
import { expect, it } from 'vitest'
|
|
import { runProcess } from './child-process/run-process'
|
|
import { buildAgentDraftLaunchPlan } from './tui-agent-startup'
|
|
|
|
const shells = ['sh', 'bash', 'zsh', 'dash', 'ksh', 'fish'].filter(
|
|
(shell) =>
|
|
process.platform !== 'win32' &&
|
|
(process.env.PATH ?? '')
|
|
.split(delimiter)
|
|
.some((directory) => existsSync(join(directory, shell)))
|
|
)
|
|
|
|
it.each(
|
|
shells.flatMap((shell) =>
|
|
shell === 'fish'
|
|
? [{ shell, nounset: false }]
|
|
: [false, true].map((nounset) => ({ shell, nounset }))
|
|
)
|
|
)(
|
|
'clears the draft and preserves status in $shell (nounset=$nounset)',
|
|
async ({ shell, nounset }) => {
|
|
const root = await mkdtemp(join(tmpdir(), 'orca-omp-draft-'))
|
|
try {
|
|
const config = join(root, 'fresh settings.yml')
|
|
const calls = join(root, 'calls')
|
|
await writeFile(config, 'autoResume: false\n')
|
|
const plan = buildAgentDraftLaunchPlan({
|
|
agent: 'omp',
|
|
draft: 'task with spaces',
|
|
cmdOverrides: {},
|
|
platform: 'linux'
|
|
})
|
|
if (!plan) {
|
|
throw new Error('Expected draft plan')
|
|
}
|
|
const define =
|
|
shell === 'fish'
|
|
? 'function omp; printf "%s\\n" "$ORCA_OMP_PREFILL" >> "$CAPTURE"; printf agent-stderr >&2; return 17; end; '
|
|
: 'omp() { printf "%s\\n" "$ORCA_OMP_PREFILL" >> "$CAPTURE"; printf agent-stderr >&2; return 17; }; '
|
|
const observe =
|
|
shell === 'fish'
|
|
? '; set -l result $status; set -q ORCA_OMP_PREFILL; and exit 91; exit $result'
|
|
: '; result=$?; test -z "${ORCA_OMP_PREFILL+x}" || exit 91; exit "$result"'
|
|
for (const present of [true, false]) {
|
|
if (!present) {
|
|
await rm(config)
|
|
}
|
|
const result = await runProcess({
|
|
program: shell,
|
|
args: ['-c', (nounset ? 'set -u; ' : '') + define + plan.launchCommand + observe],
|
|
cwd: root,
|
|
env: { ...process.env, ...plan.env, ORCA_OMP_FRESH_CONFIG: config, CAPTURE: calls }
|
|
})
|
|
expect(result.code, result.stderr).toBe(present ? 17 : 1)
|
|
expect(result.stderr).toContain(
|
|
present ? 'agent-stderr' : 'fresh OMP settings are unavailable'
|
|
)
|
|
if (present) {
|
|
expect(result.stderr).toBe('agent-stderr')
|
|
}
|
|
expect(result.stderr).not.toContain('command substitutions not allowed')
|
|
expect(await readFile(calls, 'utf8')).toBe('task with spaces\n')
|
|
}
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true })
|
|
}
|
|
}
|
|
)
|