Files
orca/src/shared/opencode-cli-version.ts
T
Neilandnwparker 8b5de39217 Submit initial OpenCode 2.0.12 prompts through the native startup plugin (#25428)
* fix(opencode): submit initial prompts for reviewed 2.0.12

Route the reported release through the existing native startup intent.
Retain conservative behavior for other unreviewed versions.

* Wait for OpenCode startup fixture file reads in the hydration test

---------

Co-authored-by: nwparker <nwparker@users.noreply.github.com>
2026-10-05 03:08:22 -07:00

34 lines
1.0 KiB
TypeScript

import { isValidAppVersion } from './app-version'
export const OPENCODE_NATIVE_PROMPT_VERSIONS = ['2.0.12', '2.0.16'] as const
export type OpenCodeCliCapabilities = {
version: string | null
pluginApi: 'v1' | 'v2' | 'unknown'
promptMode: 'submit' | 'prefill' | 'unknown'
}
export function parseOpenCodeCliVersion(output: string | null | undefined): string | null {
const version = output
?.trim()
.match(/^(?:opencode\s+)?v?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)$/i)?.[1]
return version && isValidAppVersion(version) ? version : null
}
export function getOpenCodeCliCapabilities(
output: string | null | undefined
): OpenCodeCliCapabilities {
const version = parseOpenCodeCliVersion(output)
const major = version?.split('.')[0]
return {
version,
pluginApi: major === '1' ? 'v1' : major === '2' ? 'v2' : 'unknown',
promptMode:
major === '1'
? 'submit'
: OPENCODE_NATIVE_PROMPT_VERSIONS.some((supported) => supported === version)
? 'prefill'
: 'unknown'
}
}