oh-my-opencode-unguarded 3.10.20 → 3.10.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/oh-my-opencode.js +13 -137
- package/dist/cli/index.js +2 -5
- package/package.json +2 -5
- package/bin/platform.js +0 -82
- package/bin/platform.test.ts +0 -203
- package/postinstall.mjs +0 -59
package/bin/oh-my-opencode.js
CHANGED
|
@@ -1,66 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// bin/oh-my-opencode.js
|
|
3
|
-
// Wrapper script that
|
|
3
|
+
// Wrapper script that spawns the JavaScript CLI via bun
|
|
4
4
|
|
|
5
5
|
import { spawnSync } from "node:child_process";
|
|
6
|
-
import { existsSync
|
|
7
|
-
import { createRequire } from "node:module";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
8
7
|
import path from "node:path";
|
|
9
8
|
import { fileURLToPath } from "node:url";
|
|
10
|
-
import { getPlatformPackageCandidates, getBinaryPath } from "./platform.js";
|
|
11
|
-
|
|
12
|
-
const require = createRequire(import.meta.url);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Detect libc family on Linux
|
|
16
|
-
* @returns {string | null} 'glibc', 'musl', or null if detection fails
|
|
17
|
-
*/
|
|
18
|
-
function getLibcFamily() {
|
|
19
|
-
if (process.platform !== "linux") {
|
|
20
|
-
return undefined; // Not needed on non-Linux
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const detectLibc = require("detect-libc");
|
|
25
|
-
return detectLibc.familySync();
|
|
26
|
-
} catch {
|
|
27
|
-
// detect-libc not available
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function supportsAvx2() {
|
|
33
|
-
if (process.arch !== "x64") {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (process.env.OH_MY_OPENCODE_FORCE_BASELINE === "1") {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (process.platform === "linux") {
|
|
42
|
-
try {
|
|
43
|
-
const cpuInfo = readFileSync("/proc/cpuinfo", "utf8").toLowerCase();
|
|
44
|
-
return cpuInfo.includes("avx2");
|
|
45
|
-
} catch {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (process.platform === "darwin") {
|
|
51
|
-
const probe = spawnSync("sysctl", ["-n", "machdep.cpu.leaf7_features"], {
|
|
52
|
-
encoding: "utf8",
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
if (probe.error || probe.status !== 0) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return probe.stdout.toUpperCase().includes("AVX2");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
9
|
|
|
65
10
|
function getSignalExitCode(signal) {
|
|
66
11
|
const signalCodeByName = {
|
|
@@ -73,17 +18,21 @@ function getSignalExitCode(signal) {
|
|
|
73
18
|
return 128 + (signalCodeByName[signal] ?? 1);
|
|
74
19
|
}
|
|
75
20
|
|
|
76
|
-
function
|
|
21
|
+
function main() {
|
|
77
22
|
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
78
23
|
const cliPath = path.resolve(currentDir, "../dist/cli/index.js");
|
|
79
24
|
|
|
80
25
|
if (!existsSync(cliPath)) {
|
|
81
|
-
|
|
26
|
+
console.error(`\noh-my-opencode-unguarded: dist/cli/index.js not found.`);
|
|
27
|
+
console.error(`This usually means the package was not built correctly.\n`);
|
|
28
|
+
process.exit(1);
|
|
82
29
|
}
|
|
83
30
|
|
|
84
31
|
const bunProbe = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
85
32
|
if (bunProbe.error || bunProbe.status !== 0) {
|
|
86
|
-
|
|
33
|
+
console.error(`\noh-my-opencode-unguarded: bun is required but not found.`);
|
|
34
|
+
console.error(`Install bun: https://bun.sh\n`);
|
|
35
|
+
process.exit(1);
|
|
87
36
|
}
|
|
88
37
|
|
|
89
38
|
const result = spawnSync("bun", [cliPath, ...process.argv.slice(2)], {
|
|
@@ -91,89 +40,16 @@ function runJavaScriptCli() {
|
|
|
91
40
|
});
|
|
92
41
|
|
|
93
42
|
if (result.error) {
|
|
94
|
-
console.error(`\noh-my-opencode-unguarded: Failed to execute
|
|
43
|
+
console.error(`\noh-my-opencode-unguarded: Failed to execute CLI.`);
|
|
95
44
|
console.error(`Error: ${result.error.message}\n`);
|
|
96
|
-
|
|
45
|
+
process.exit(2);
|
|
97
46
|
}
|
|
98
47
|
|
|
99
48
|
if (result.signal) {
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return result.status ?? 1;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function main() {
|
|
107
|
-
const jsCliExitCode = runJavaScriptCli();
|
|
108
|
-
if (jsCliExitCode !== null) {
|
|
109
|
-
process.exit(jsCliExitCode);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const { platform, arch } = process;
|
|
113
|
-
const libcFamily = getLibcFamily();
|
|
114
|
-
const avx2Supported = supportsAvx2();
|
|
115
|
-
|
|
116
|
-
let packageCandidates;
|
|
117
|
-
try {
|
|
118
|
-
packageCandidates = getPlatformPackageCandidates({
|
|
119
|
-
platform,
|
|
120
|
-
arch,
|
|
121
|
-
libcFamily,
|
|
122
|
-
preferBaseline: avx2Supported === false,
|
|
123
|
-
});
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.error(`\nevil-oh-my-opencode: ${error.message}\n`);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const resolvedBinaries = packageCandidates
|
|
130
|
-
.map((pkg) => {
|
|
131
|
-
try {
|
|
132
|
-
return { pkg, binPath: require.resolve(getBinaryPath(pkg, platform)) };
|
|
133
|
-
} catch {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
.filter((entry) => entry !== null);
|
|
138
|
-
|
|
139
|
-
if (resolvedBinaries.length === 0) {
|
|
140
|
-
console.error(`\nevil-oh-my-opencode: Platform binary not installed.`);
|
|
141
|
-
console.error(`\nYour platform: ${platform}-${arch}${libcFamily === "musl" ? "-musl" : ""}`);
|
|
142
|
-
console.error(`Expected packages (in order): ${packageCandidates.join(", ")}`);
|
|
143
|
-
console.error(`\nTo fix, run:`);
|
|
144
|
-
console.error(` npm install ${packageCandidates[0]}\n`);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
for (let index = 0; index < resolvedBinaries.length; index += 1) {
|
|
149
|
-
const currentBinary = resolvedBinaries[index];
|
|
150
|
-
const hasFallback = index < resolvedBinaries.length - 1;
|
|
151
|
-
const result = spawnSync(currentBinary.binPath, process.argv.slice(2), {
|
|
152
|
-
stdio: "inherit",
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (result.error) {
|
|
156
|
-
if (hasFallback) {
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
console.error(`\nevil-oh-my-opencode: Failed to execute binary.`);
|
|
161
|
-
console.error(`Error: ${result.error.message}\n`);
|
|
162
|
-
process.exit(2);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (result.signal === "SIGILL" && hasFallback) {
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (result.signal) {
|
|
170
|
-
process.exit(getSignalExitCode(result.signal));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
process.exit(result.status ?? 1);
|
|
49
|
+
process.exit(getSignalExitCode(result.signal));
|
|
174
50
|
}
|
|
175
51
|
|
|
176
|
-
process.exit(1);
|
|
52
|
+
process.exit(result.status ?? 1);
|
|
177
53
|
}
|
|
178
54
|
|
|
179
55
|
main();
|
package/dist/cli/index.js
CHANGED
|
@@ -9495,7 +9495,7 @@ var {
|
|
|
9495
9495
|
// package.json
|
|
9496
9496
|
var package_default = {
|
|
9497
9497
|
name: "oh-my-opencode-unguarded",
|
|
9498
|
-
version: "3.10.
|
|
9498
|
+
version: "3.10.21",
|
|
9499
9499
|
description: "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
|
|
9500
9500
|
main: "dist/index.js",
|
|
9501
9501
|
types: "dist/index.d.ts",
|
|
@@ -9505,8 +9505,7 @@ var package_default = {
|
|
|
9505
9505
|
},
|
|
9506
9506
|
files: [
|
|
9507
9507
|
"dist",
|
|
9508
|
-
"bin"
|
|
9509
|
-
"postinstall.mjs"
|
|
9508
|
+
"bin"
|
|
9510
9509
|
],
|
|
9511
9510
|
exports: {
|
|
9512
9511
|
".": {
|
|
@@ -9519,7 +9518,6 @@ var package_default = {
|
|
|
9519
9518
|
build: "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun run build:schema",
|
|
9520
9519
|
"build:schema": "bun run script/build-schema.ts",
|
|
9521
9520
|
clean: "rm -rf dist",
|
|
9522
|
-
postinstall: "node postinstall.mjs",
|
|
9523
9521
|
prepublishOnly: "bun run clean && bun run build",
|
|
9524
9522
|
typecheck: "tsc --noEmit",
|
|
9525
9523
|
test: "bun test"
|
|
@@ -9552,7 +9550,6 @@ var package_default = {
|
|
|
9552
9550
|
"@opencode-ai/plugin": "^1.1.19",
|
|
9553
9551
|
"@opencode-ai/sdk": "^1.1.19",
|
|
9554
9552
|
commander: "^14.0.2",
|
|
9555
|
-
"detect-libc": "^2.0.0",
|
|
9556
9553
|
diff: "^8.0.3",
|
|
9557
9554
|
"js-yaml": "^4.1.1",
|
|
9558
9555
|
"jsonc-parser": "^3.3.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oh-my-opencode-unguarded",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.21",
|
|
4
4
|
"description": "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
|
-
"bin"
|
|
14
|
-
"postinstall.mjs"
|
|
13
|
+
"bin"
|
|
15
14
|
],
|
|
16
15
|
"exports": {
|
|
17
16
|
".": {
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
"build": "bun build src/index.ts --outdir dist --target bun --format esm --external @ast-grep/napi && tsc --emitDeclarationOnly && bun build src/cli/index.ts --outdir dist/cli --target bun --format esm --external @ast-grep/napi && bun run build:schema",
|
|
25
24
|
"build:schema": "bun run script/build-schema.ts",
|
|
26
25
|
"clean": "rm -rf dist",
|
|
27
|
-
"postinstall": "node postinstall.mjs",
|
|
28
26
|
"prepublishOnly": "bun run clean && bun run build",
|
|
29
27
|
"typecheck": "tsc --noEmit",
|
|
30
28
|
"test": "bun test"
|
|
@@ -57,7 +55,6 @@
|
|
|
57
55
|
"@opencode-ai/plugin": "^1.1.19",
|
|
58
56
|
"@opencode-ai/sdk": "^1.1.19",
|
|
59
57
|
"commander": "^14.0.2",
|
|
60
|
-
"detect-libc": "^2.0.0",
|
|
61
58
|
"diff": "^8.0.3",
|
|
62
59
|
"js-yaml": "^4.1.1",
|
|
63
60
|
"jsonc-parser": "^3.3.1",
|
package/bin/platform.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// bin/platform.js
|
|
2
|
-
// Shared platform detection module - used by wrapper and postinstall
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Get the platform-specific package name
|
|
6
|
-
* @param {{ platform: string, arch: string, libcFamily?: string | null }} options
|
|
7
|
-
* @returns {string} Package name like "evil-oh-my-opencode-darwin-arm64"
|
|
8
|
-
* @throws {Error} If libc cannot be detected on Linux
|
|
9
|
-
*/
|
|
10
|
-
export function getPlatformPackage({ platform, arch, libcFamily }) {
|
|
11
|
-
let suffix = "";
|
|
12
|
-
if (platform === "linux") {
|
|
13
|
-
if (libcFamily === null || libcFamily === undefined) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
"Could not detect libc on Linux. " +
|
|
16
|
-
"Please ensure detect-libc is installed or report this issue."
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
if (libcFamily === "musl") {
|
|
20
|
-
suffix = "-musl";
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Map platform names: win32 -> windows (for package name)
|
|
25
|
-
const os = platform === "win32" ? "windows" : platform;
|
|
26
|
-
return `evil-oh-my-opencode-${os}-${arch}${suffix}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** @param {{ platform: string, arch: string, libcFamily?: string | null, preferBaseline?: boolean }} options */
|
|
30
|
-
export function getPlatformPackageCandidates({ platform, arch, libcFamily, preferBaseline = false }) {
|
|
31
|
-
const primaryPackage = getPlatformPackage({ platform, arch, libcFamily });
|
|
32
|
-
const baselinePackage = getBaselinePlatformPackage({ platform, arch, libcFamily });
|
|
33
|
-
|
|
34
|
-
if (!baselinePackage) {
|
|
35
|
-
return [primaryPackage];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return preferBaseline ? [baselinePackage, primaryPackage] : [primaryPackage, baselinePackage];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** @param {{ platform: string, arch: string, libcFamily?: string | null }} options */
|
|
42
|
-
function getBaselinePlatformPackage({ platform, arch, libcFamily }) {
|
|
43
|
-
if (arch !== "x64") {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (platform === "darwin") {
|
|
48
|
-
return "evil-oh-my-opencode-darwin-x64-baseline";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (platform === "win32") {
|
|
52
|
-
return "evil-oh-my-opencode-windows-x64-baseline";
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (platform === "linux") {
|
|
56
|
-
if (libcFamily === null || libcFamily === undefined) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
"Could not detect libc on Linux. " +
|
|
59
|
-
"Please ensure detect-libc is installed or report this issue."
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (libcFamily === "musl") {
|
|
64
|
-
return "evil-oh-my-opencode-linux-x64-musl-baseline";
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return "evil-oh-my-opencode-linux-x64-baseline";
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get the path to the binary within a platform package
|
|
75
|
-
* @param {string} pkg Package name
|
|
76
|
-
* @param {string} platform Process platform
|
|
77
|
-
* @returns {string} Relative path like "evil-oh-my-opencode-darwin-arm64/bin/evil-oh-my-opencode"
|
|
78
|
-
*/
|
|
79
|
-
export function getBinaryPath(pkg, platform) {
|
|
80
|
-
const ext = platform === "win32" ? ".exe" : "";
|
|
81
|
-
return `${pkg}/bin/evil-oh-my-opencode${ext}`;
|
|
82
|
-
}
|
package/bin/platform.test.ts
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
// bin/platform.test.ts
|
|
2
|
-
import { describe, expect, test } from "bun:test";
|
|
3
|
-
import { getBinaryPath, getPlatformPackage, getPlatformPackageCandidates } from "./platform.js";
|
|
4
|
-
|
|
5
|
-
describe("getPlatformPackage", () => {
|
|
6
|
-
// #region Darwin platforms
|
|
7
|
-
test("returns darwin-arm64 for macOS ARM64", () => {
|
|
8
|
-
// #given macOS ARM64 platform
|
|
9
|
-
const input = { platform: "darwin", arch: "arm64" };
|
|
10
|
-
|
|
11
|
-
// #when getting platform package
|
|
12
|
-
const result = getPlatformPackage(input);
|
|
13
|
-
|
|
14
|
-
// #then returns correct package name
|
|
15
|
-
expect(result).toBe("evil-oh-my-opencode-darwin-arm64");
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("returns darwin-x64 for macOS Intel", () => {
|
|
19
|
-
// #given macOS x64 platform
|
|
20
|
-
const input = { platform: "darwin", arch: "x64" };
|
|
21
|
-
|
|
22
|
-
// #when getting platform package
|
|
23
|
-
const result = getPlatformPackage(input);
|
|
24
|
-
|
|
25
|
-
// #then returns correct package name
|
|
26
|
-
expect(result).toBe("evil-oh-my-opencode-darwin-x64");
|
|
27
|
-
});
|
|
28
|
-
// #endregion
|
|
29
|
-
|
|
30
|
-
// #region Linux glibc platforms
|
|
31
|
-
test("returns linux-x64 for Linux x64 with glibc", () => {
|
|
32
|
-
// #given Linux x64 with glibc
|
|
33
|
-
const input = { platform: "linux", arch: "x64", libcFamily: "glibc" };
|
|
34
|
-
|
|
35
|
-
// #when getting platform package
|
|
36
|
-
const result = getPlatformPackage(input);
|
|
37
|
-
|
|
38
|
-
// #then returns correct package name
|
|
39
|
-
expect(result).toBe("evil-oh-my-opencode-linux-x64");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test("returns linux-arm64 for Linux ARM64 with glibc", () => {
|
|
43
|
-
// #given Linux ARM64 with glibc
|
|
44
|
-
const input = { platform: "linux", arch: "arm64", libcFamily: "glibc" };
|
|
45
|
-
|
|
46
|
-
// #when getting platform package
|
|
47
|
-
const result = getPlatformPackage(input);
|
|
48
|
-
|
|
49
|
-
// #then returns correct package name
|
|
50
|
-
expect(result).toBe("evil-oh-my-opencode-linux-arm64");
|
|
51
|
-
});
|
|
52
|
-
// #endregion
|
|
53
|
-
|
|
54
|
-
// #region Linux musl platforms
|
|
55
|
-
test("returns linux-x64-musl for Alpine x64", () => {
|
|
56
|
-
// #given Linux x64 with musl (Alpine)
|
|
57
|
-
const input = { platform: "linux", arch: "x64", libcFamily: "musl" };
|
|
58
|
-
|
|
59
|
-
// #when getting platform package
|
|
60
|
-
const result = getPlatformPackage(input);
|
|
61
|
-
|
|
62
|
-
// #then returns correct package name with musl suffix
|
|
63
|
-
expect(result).toBe("evil-oh-my-opencode-linux-x64-musl");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("returns linux-arm64-musl for Alpine ARM64", () => {
|
|
67
|
-
// #given Linux ARM64 with musl (Alpine)
|
|
68
|
-
const input = { platform: "linux", arch: "arm64", libcFamily: "musl" };
|
|
69
|
-
|
|
70
|
-
// #when getting platform package
|
|
71
|
-
const result = getPlatformPackage(input);
|
|
72
|
-
|
|
73
|
-
// #then returns correct package name with musl suffix
|
|
74
|
-
expect(result).toBe("evil-oh-my-opencode-linux-arm64-musl");
|
|
75
|
-
});
|
|
76
|
-
// #endregion
|
|
77
|
-
|
|
78
|
-
// #region Windows platform
|
|
79
|
-
test("returns windows-x64 for Windows", () => {
|
|
80
|
-
// #given Windows x64 platform (win32 is Node's platform name)
|
|
81
|
-
const input = { platform: "win32", arch: "x64" };
|
|
82
|
-
|
|
83
|
-
// #when getting platform package
|
|
84
|
-
const result = getPlatformPackage(input);
|
|
85
|
-
|
|
86
|
-
// #then returns correct package name with 'windows' not 'win32'
|
|
87
|
-
expect(result).toBe("evil-oh-my-opencode-windows-x64");
|
|
88
|
-
});
|
|
89
|
-
// #endregion
|
|
90
|
-
|
|
91
|
-
// #region Error cases
|
|
92
|
-
test("throws error for Linux with null libcFamily", () => {
|
|
93
|
-
// #given Linux platform with null libc detection
|
|
94
|
-
const input = { platform: "linux", arch: "x64", libcFamily: null };
|
|
95
|
-
|
|
96
|
-
// #when getting platform package
|
|
97
|
-
// #then throws descriptive error
|
|
98
|
-
expect(() => getPlatformPackage(input)).toThrow("Could not detect libc");
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test("throws error for Linux with undefined libcFamily", () => {
|
|
102
|
-
// #given Linux platform with undefined libc
|
|
103
|
-
const input = { platform: "linux", arch: "x64", libcFamily: undefined };
|
|
104
|
-
|
|
105
|
-
// #when getting platform package
|
|
106
|
-
// #then throws descriptive error
|
|
107
|
-
expect(() => getPlatformPackage(input)).toThrow("Could not detect libc");
|
|
108
|
-
});
|
|
109
|
-
// #endregion
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe("getBinaryPath", () => {
|
|
113
|
-
test("returns path without .exe for Unix platforms", () => {
|
|
114
|
-
// #given Unix platform package
|
|
115
|
-
const pkg = "evil-oh-my-opencode-darwin-arm64";
|
|
116
|
-
const platform = "darwin";
|
|
117
|
-
|
|
118
|
-
// #when getting binary path
|
|
119
|
-
const result = getBinaryPath(pkg, platform);
|
|
120
|
-
|
|
121
|
-
// #then returns path without extension
|
|
122
|
-
expect(result).toBe("evil-oh-my-opencode-darwin-arm64/bin/evil-oh-my-opencode");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("returns path with .exe for Windows", () => {
|
|
126
|
-
// #given Windows platform package
|
|
127
|
-
const pkg = "evil-oh-my-opencode-windows-x64";
|
|
128
|
-
const platform = "win32";
|
|
129
|
-
|
|
130
|
-
// #when getting binary path
|
|
131
|
-
const result = getBinaryPath(pkg, platform);
|
|
132
|
-
|
|
133
|
-
// #then returns path with .exe extension
|
|
134
|
-
expect(result).toBe("evil-oh-my-opencode-windows-x64/bin/evil-oh-my-opencode.exe");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test("returns path without .exe for Linux", () => {
|
|
138
|
-
// #given Linux platform package
|
|
139
|
-
const pkg = "evil-oh-my-opencode-linux-x64";
|
|
140
|
-
const platform = "linux";
|
|
141
|
-
|
|
142
|
-
// #when getting binary path
|
|
143
|
-
const result = getBinaryPath(pkg, platform);
|
|
144
|
-
|
|
145
|
-
// #then returns path without extension
|
|
146
|
-
expect(result).toBe("evil-oh-my-opencode-linux-x64/bin/evil-oh-my-opencode");
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe("getPlatformPackageCandidates", () => {
|
|
151
|
-
test("returns x64 and baseline candidates for Linux glibc", () => {
|
|
152
|
-
// #given Linux x64 with glibc
|
|
153
|
-
const input = { platform: "linux", arch: "x64", libcFamily: "glibc" };
|
|
154
|
-
|
|
155
|
-
// #when getting package candidates
|
|
156
|
-
const result = getPlatformPackageCandidates(input);
|
|
157
|
-
|
|
158
|
-
// #then returns modern first then baseline fallback
|
|
159
|
-
expect(result).toEqual([
|
|
160
|
-
"evil-oh-my-opencode-linux-x64",
|
|
161
|
-
"evil-oh-my-opencode-linux-x64-baseline",
|
|
162
|
-
]);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
test("returns x64 musl and baseline candidates for Linux musl", () => {
|
|
166
|
-
// #given Linux x64 with musl
|
|
167
|
-
const input = { platform: "linux", arch: "x64", libcFamily: "musl" };
|
|
168
|
-
|
|
169
|
-
// #when getting package candidates
|
|
170
|
-
const result = getPlatformPackageCandidates(input);
|
|
171
|
-
|
|
172
|
-
// #then returns musl modern first then musl baseline fallback
|
|
173
|
-
expect(result).toEqual([
|
|
174
|
-
"evil-oh-my-opencode-linux-x64-musl",
|
|
175
|
-
"evil-oh-my-opencode-linux-x64-musl-baseline",
|
|
176
|
-
]);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test("returns baseline first when preferBaseline is true", () => {
|
|
180
|
-
// #given Windows x64 and baseline preference
|
|
181
|
-
const input = { platform: "win32", arch: "x64", preferBaseline: true };
|
|
182
|
-
|
|
183
|
-
// #when getting package candidates
|
|
184
|
-
const result = getPlatformPackageCandidates(input);
|
|
185
|
-
|
|
186
|
-
// #then baseline package is preferred first
|
|
187
|
-
expect(result).toEqual([
|
|
188
|
-
"evil-oh-my-opencode-windows-x64-baseline",
|
|
189
|
-
"evil-oh-my-opencode-windows-x64",
|
|
190
|
-
]);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
test("returns only one candidate for ARM64", () => {
|
|
194
|
-
// #given non-x64 platform
|
|
195
|
-
const input = { platform: "linux", arch: "arm64", libcFamily: "glibc" };
|
|
196
|
-
|
|
197
|
-
// #when getting package candidates
|
|
198
|
-
const result = getPlatformPackageCandidates(input);
|
|
199
|
-
|
|
200
|
-
// #then baseline fallback is not included
|
|
201
|
-
expect(result).toEqual(["evil-oh-my-opencode-linux-arm64"]);
|
|
202
|
-
});
|
|
203
|
-
});
|
package/postinstall.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// postinstall.mjs
|
|
2
|
-
// Runs after npm install to verify platform binary is available
|
|
3
|
-
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
|
-
import { getPlatformPackageCandidates, getBinaryPath } from "./bin/platform.js";
|
|
6
|
-
|
|
7
|
-
const require = createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Detect libc family on Linux
|
|
11
|
-
*/
|
|
12
|
-
function getLibcFamily() {
|
|
13
|
-
if (process.platform !== "linux") {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const detectLibc = require("detect-libc");
|
|
19
|
-
return detectLibc.familySync();
|
|
20
|
-
} catch {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function main() {
|
|
26
|
-
const { platform, arch } = process;
|
|
27
|
-
const libcFamily = getLibcFamily();
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const packageCandidates = getPlatformPackageCandidates({
|
|
31
|
-
platform,
|
|
32
|
-
arch,
|
|
33
|
-
libcFamily,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const resolvedPackage = packageCandidates.find((pkg) => {
|
|
37
|
-
try {
|
|
38
|
-
require.resolve(getBinaryPath(pkg, platform));
|
|
39
|
-
return true;
|
|
40
|
-
} catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
if (!resolvedPackage) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`No platform binary package installed. Tried: ${packageCandidates.join(", ")}`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log(`✓ evil-oh-my-opencode binary installed for ${platform}-${arch} (${resolvedPackage})`);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.warn(`⚠ evil-oh-my-opencode: ${error.message}`);
|
|
54
|
-
console.warn(` The CLI may not work on this platform.`);
|
|
55
|
-
// Don't fail installation - let user try anyway
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
main();
|