feat(installer): add opencode v1.4.0 minimum version check
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+63
-1
@@ -7,6 +7,60 @@ import { getPlatformPackageCandidates, getBinaryPath } from "./bin/platform.js";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const MIN_OPENCODE_VERSION = "1.4.0";
|
||||
|
||||
/**
|
||||
* Parse version string into numeric parts
|
||||
* @param {string} version
|
||||
* @returns {number[]}
|
||||
*/
|
||||
function parseVersion(version) {
|
||||
return version
|
||||
.replace(/^v/, "")
|
||||
.split("-")[0]
|
||||
.split(".")
|
||||
.map((part) => Number.parseInt(part, 10) || 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two version strings
|
||||
* @param {string} current
|
||||
* @param {string} minimum
|
||||
* @returns {boolean} true if current >= minimum
|
||||
*/
|
||||
function compareVersions(current, minimum) {
|
||||
const currentParts = parseVersion(current);
|
||||
const minimumParts = parseVersion(minimum);
|
||||
const length = Math.max(currentParts.length, minimumParts.length);
|
||||
|
||||
for (let index = 0; index < length; index++) {
|
||||
const currentPart = currentParts[index] ?? 0;
|
||||
const minimumPart = minimumParts[index] ?? 0;
|
||||
if (currentPart > minimumPart) return true;
|
||||
if (currentPart < minimumPart) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if opencode version meets minimum requirement
|
||||
* @returns {{ok: boolean, version: string | null}}
|
||||
*/
|
||||
function checkOpenCodeVersion() {
|
||||
try {
|
||||
const result = require("child_process").execSync("opencode --version", {
|
||||
encoding: "utf-8",
|
||||
stdio: ["pipe", "pipe", "ignore"],
|
||||
});
|
||||
const version = result.trim();
|
||||
const ok = compareVersions(version, MIN_OPENCODE_VERSION);
|
||||
return { ok, version };
|
||||
} catch {
|
||||
return { ok: true, version: null };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect libc family on Linux
|
||||
*/
|
||||
@@ -36,7 +90,15 @@ function main() {
|
||||
const { platform, arch } = process;
|
||||
const libcFamily = getLibcFamily();
|
||||
const packageBaseName = getPackageBaseName();
|
||||
|
||||
|
||||
// Check opencode version requirement
|
||||
const versionCheck = checkOpenCodeVersion();
|
||||
if (versionCheck.version && !versionCheck.ok) {
|
||||
console.warn(`⚠ oh-my-opencode requires OpenCode >= ${MIN_OPENCODE_VERSION}`);
|
||||
console.warn(` Detected: ${versionCheck.version}`);
|
||||
console.warn(` Please update OpenCode to avoid compatibility issues.`);
|
||||
}
|
||||
|
||||
try {
|
||||
const packageCandidates = getPlatformPackageCandidates({
|
||||
platform,
|
||||
|
||||
@@ -37,7 +37,7 @@ export const EXIT_CODES = {
|
||||
FAILURE: 1,
|
||||
} as const
|
||||
|
||||
export const MIN_OPENCODE_VERSION = "1.0.150"
|
||||
export const MIN_OPENCODE_VERSION = "1.4.0"
|
||||
|
||||
export const PACKAGE_NAME = PLUGIN_NAME
|
||||
|
||||
|
||||
Reference in New Issue
Block a user