evil-omo 3.11.3 → 3.11.5

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.
@@ -1,13 +1,19 @@
1
1
  #!/usr/bin/env node
2
- // bin/oh-my-opencode.js
2
+ // bin/evil-omo.js
3
3
  // Wrapper script that detects platform and spawns the correct binary
4
4
 
5
5
  import { spawnSync } from "node:child_process";
6
- import { readFileSync } from "node:fs";
6
+ import { resolve } from "node:path";
7
+ import { existsSync, readFileSync } from "node:fs";
7
8
  import { createRequire } from "node:module";
9
+ import { fileURLToPath } from "node:url";
8
10
  import { getPlatformPackageCandidates, getBinaryPath } from "./platform.js";
9
11
 
10
12
  const require = createRequire(import.meta.url);
13
+ const PLUGIN_NAME = "evil-omo";
14
+ const FORCE_BASELINE_ENV = "EVIL_OMO_FORCE_BASELINE";
15
+ const LEGACY_FORCE_BASELINE_ENV = "OH_MY_OPENCODE_FORCE_BASELINE";
16
+ const BUNDLED_CLI_ENTRYPOINT = fileURLToPath(new URL("../dist/cli/index.js", import.meta.url));
11
17
 
12
18
  /**
13
19
  * Detect libc family on Linux
@@ -32,7 +38,7 @@ function supportsAvx2() {
32
38
  return null;
33
39
  }
34
40
 
35
- if (process.env.OH_MY_OPENCODE_FORCE_BASELINE === "1") {
41
+ if (process.env[FORCE_BASELINE_ENV] === "1" || process.env[LEGACY_FORCE_BASELINE_ENV] === "1") {
36
42
  return false;
37
43
  }
38
44
 
@@ -71,7 +77,59 @@ function getSignalExitCode(signal) {
71
77
  return 128 + (signalCodeByName[signal] ?? 1);
72
78
  }
73
79
 
80
+ export function shouldUseBundledCli(versions = process.versions) {
81
+ return Boolean(versions?.bun);
82
+ }
83
+
84
+ export function getBundledCliEntrypoint() {
85
+ return BUNDLED_CLI_ENTRYPOINT;
86
+ }
87
+
88
+ export function resolveBundledCliRuntime(
89
+ versions = process.versions,
90
+ execPath = process.execPath,
91
+ spawnImpl = spawnSync,
92
+ ) {
93
+ if (shouldUseBundledCli(versions)) {
94
+ return execPath;
95
+ }
96
+
97
+ const probe = spawnImpl("bun", ["--version"], {
98
+ encoding: "utf8",
99
+ stdio: "pipe",
100
+ });
101
+
102
+ if (probe.error || probe.status !== 0) {
103
+ return null;
104
+ }
105
+
106
+ return "bun";
107
+ }
108
+
109
+ export function runBundledCli(args, spawnImpl = spawnSync, runtime = process.execPath) {
110
+ return spawnImpl(runtime, [getBundledCliEntrypoint(), ...args], {
111
+ stdio: "inherit",
112
+ });
113
+ }
114
+
115
+ function isDirectExecution() {
116
+ return Boolean(process.argv[1]) && resolve(process.argv[1]) === fileURLToPath(import.meta.url);
117
+ }
118
+
74
119
  function main() {
120
+ const bundledCliRuntime = resolveBundledCliRuntime();
121
+ if (bundledCliRuntime && existsSync(getBundledCliEntrypoint())) {
122
+ const result = runBundledCli(process.argv.slice(2), spawnSync, bundledCliRuntime);
123
+
124
+ if (!result.error) {
125
+ if (result.signal) {
126
+ process.exit(getSignalExitCode(result.signal));
127
+ }
128
+
129
+ process.exit(result.status ?? 1);
130
+ }
131
+ }
132
+
75
133
  const { platform, arch } = process;
76
134
  const libcFamily = getLibcFamily();
77
135
  const avx2Supported = supportsAvx2();
@@ -85,7 +143,7 @@ function main() {
85
143
  preferBaseline: avx2Supported === false,
86
144
  });
87
145
  } catch (error) {
88
- console.error(`\noh-my-opencode: ${error.message}\n`);
146
+ console.error(`\n${PLUGIN_NAME}: ${error.message}\n`);
89
147
  process.exit(1);
90
148
  }
91
149
 
@@ -100,7 +158,7 @@ function main() {
100
158
  .filter((entry) => entry !== null);
101
159
 
102
160
  if (resolvedBinaries.length === 0) {
103
- console.error(`\noh-my-opencode: Platform binary not installed.`);
161
+ console.error(`\n${PLUGIN_NAME}: Platform binary not installed.`);
104
162
  console.error(`\nYour platform: ${platform}-${arch}${libcFamily === "musl" ? "-musl" : ""}`);
105
163
  console.error(`Expected packages (in order): ${packageCandidates.join(", ")}`);
106
164
  console.error(`\nTo fix, run:`);
@@ -120,7 +178,7 @@ function main() {
120
178
  continue;
121
179
  }
122
180
 
123
- console.error(`\noh-my-opencode: Failed to execute binary.`);
181
+ console.error(`\n${PLUGIN_NAME}: Failed to execute binary.`);
124
182
  console.error(`Error: ${result.error.message}\n`);
125
183
  process.exit(2);
126
184
  }
@@ -139,4 +197,6 @@ function main() {
139
197
  process.exit(1);
140
198
  }
141
199
 
142
- main();
200
+ if (isDirectExecution()) {
201
+ main();
202
+ }
@@ -0,0 +1,82 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import {
3
+ getBundledCliEntrypoint,
4
+ resolveBundledCliRuntime,
5
+ runBundledCli,
6
+ shouldUseBundledCli,
7
+ } from "./evil-omo.js"
8
+
9
+ describe("shouldUseBundledCli", () => {
10
+ test("returns true when running under Bun", () => {
11
+ expect(shouldUseBundledCli({ bun: "1.3.10" })).toBe(true)
12
+ })
13
+
14
+ test("returns false when Bun runtime is unavailable", () => {
15
+ expect(shouldUseBundledCli({})).toBe(false)
16
+ })
17
+ })
18
+
19
+ describe("getBundledCliEntrypoint", () => {
20
+ test("returns the packaged CLI entrypoint path", () => {
21
+ expect(getBundledCliEntrypoint().replaceAll("\\", "/")).toEndWith("/dist/cli/index.js")
22
+ })
23
+ })
24
+
25
+ describe("resolveBundledCliRuntime", () => {
26
+ test("uses the current execPath when already running under Bun", () => {
27
+ const runtime = resolveBundledCliRuntime({ bun: "1.3.10" }, "C:/bun.exe", () => {
28
+ throw new Error("should not probe bun when already running under Bun")
29
+ })
30
+
31
+ expect(runtime).toBe("C:/bun.exe")
32
+ })
33
+
34
+ test("uses bun on PATH when running under Node and bun is available", () => {
35
+ const runtime = resolveBundledCliRuntime({}, "C:/node.exe", (command, args, options) => {
36
+ expect(command).toBe("bun")
37
+ expect(args).toEqual(["--version"])
38
+ expect(options).toEqual({ encoding: "utf8", stdio: "pipe" })
39
+
40
+ return {
41
+ status: 0,
42
+ signal: null,
43
+ error: undefined,
44
+ }
45
+ })
46
+
47
+ expect(runtime).toBe("bun")
48
+ })
49
+
50
+ test("returns null when bun is unavailable outside Bun runtime", () => {
51
+ const runtime = resolveBundledCliRuntime({}, "C:/node.exe", () => ({
52
+ status: 1,
53
+ signal: null,
54
+ error: new Error("bun not found"),
55
+ }))
56
+
57
+ expect(runtime).toBeNull()
58
+ })
59
+ })
60
+
61
+ describe("runBundledCli", () => {
62
+ test("spawns the current runtime with the packaged CLI entrypoint", () => {
63
+ const calls: Array<{ command: string; args: string[]; options: { stdio: string } }> = []
64
+ const fakeSpawn = (command: string, args: string[], options: { stdio: string }) => {
65
+ calls.push({ command, args, options })
66
+ return {
67
+ status: 0,
68
+ signal: null,
69
+ error: undefined,
70
+ }
71
+ }
72
+
73
+ runBundledCli(["install"], fakeSpawn, "bun.exe")
74
+
75
+ expect(calls).toHaveLength(1)
76
+ expect(calls[0]).toEqual({
77
+ command: "bun.exe",
78
+ args: [getBundledCliEntrypoint(), "install"],
79
+ options: { stdio: "inherit" },
80
+ })
81
+ })
82
+ })
package/bin/platform.js CHANGED
@@ -1,10 +1,13 @@
1
1
  // bin/platform.js
2
2
  // Shared platform detection module - used by wrapper and postinstall
3
3
 
4
+ const PLATFORM_PACKAGE_PREFIX = "evil-omo";
5
+ const CLI_BINARY_NAME = "evil-omo";
6
+
4
7
  /**
5
8
  * Get the platform-specific package name
6
9
  * @param {{ platform: string, arch: string, libcFamily?: string | null }} options
7
- * @returns {string} Package name like "oh-my-opencode-darwin-arm64"
10
+ * @returns {string} Package name like "evil-omo-darwin-arm64"
8
11
  * @throws {Error} If libc cannot be detected on Linux
9
12
  */
10
13
  export function getPlatformPackage({ platform, arch, libcFamily }) {
@@ -23,7 +26,7 @@ export function getPlatformPackage({ platform, arch, libcFamily }) {
23
26
 
24
27
  // Map platform names: win32 -> windows (for package name)
25
28
  const os = platform === "win32" ? "windows" : platform;
26
- return `oh-my-opencode-${os}-${arch}${suffix}`;
29
+ return `${PLATFORM_PACKAGE_PREFIX}-${os}-${arch}${suffix}`;
27
30
  }
28
31
 
29
32
  /** @param {{ platform: string, arch: string, libcFamily?: string | null, preferBaseline?: boolean }} options */
@@ -45,11 +48,11 @@ function getBaselinePlatformPackage({ platform, arch, libcFamily }) {
45
48
  }
46
49
 
47
50
  if (platform === "darwin") {
48
- return "oh-my-opencode-darwin-x64-baseline";
51
+ return `${PLATFORM_PACKAGE_PREFIX}-darwin-x64-baseline`;
49
52
  }
50
53
 
51
54
  if (platform === "win32") {
52
- return "oh-my-opencode-windows-x64-baseline";
55
+ return `${PLATFORM_PACKAGE_PREFIX}-windows-x64-baseline`;
53
56
  }
54
57
 
55
58
  if (platform === "linux") {
@@ -61,10 +64,10 @@ function getBaselinePlatformPackage({ platform, arch, libcFamily }) {
61
64
  }
62
65
 
63
66
  if (libcFamily === "musl") {
64
- return "oh-my-opencode-linux-x64-musl-baseline";
67
+ return `${PLATFORM_PACKAGE_PREFIX}-linux-x64-musl-baseline`;
65
68
  }
66
69
 
67
- return "oh-my-opencode-linux-x64-baseline";
70
+ return `${PLATFORM_PACKAGE_PREFIX}-linux-x64-baseline`;
68
71
  }
69
72
 
70
73
  return null;
@@ -74,9 +77,9 @@ function getBaselinePlatformPackage({ platform, arch, libcFamily }) {
74
77
  * Get the path to the binary within a platform package
75
78
  * @param {string} pkg Package name
76
79
  * @param {string} platform Process platform
77
- * @returns {string} Relative path like "oh-my-opencode-darwin-arm64/bin/oh-my-opencode"
80
+ * @returns {string} Relative path like "evil-omo-darwin-arm64/bin/evil-omo"
78
81
  */
79
82
  export function getBinaryPath(pkg, platform) {
80
83
  const ext = platform === "win32" ? ".exe" : "";
81
- return `${pkg}/bin/oh-my-opencode${ext}`;
84
+ return `${pkg}/bin/${CLI_BINARY_NAME}${ext}`;
82
85
  }
@@ -12,7 +12,7 @@ describe("getPlatformPackage", () => {
12
12
  const result = getPlatformPackage(input);
13
13
 
14
14
  // #then returns correct package name
15
- expect(result).toBe("oh-my-opencode-darwin-arm64");
15
+ expect(result).toBe("evil-omo-darwin-arm64");
16
16
  });
17
17
 
18
18
  test("returns darwin-x64 for macOS Intel", () => {
@@ -23,7 +23,7 @@ describe("getPlatformPackage", () => {
23
23
  const result = getPlatformPackage(input);
24
24
 
25
25
  // #then returns correct package name
26
- expect(result).toBe("oh-my-opencode-darwin-x64");
26
+ expect(result).toBe("evil-omo-darwin-x64");
27
27
  });
28
28
  // #endregion
29
29
 
@@ -36,7 +36,7 @@ describe("getPlatformPackage", () => {
36
36
  const result = getPlatformPackage(input);
37
37
 
38
38
  // #then returns correct package name
39
- expect(result).toBe("oh-my-opencode-linux-x64");
39
+ expect(result).toBe("evil-omo-linux-x64");
40
40
  });
41
41
 
42
42
  test("returns linux-arm64 for Linux ARM64 with glibc", () => {
@@ -47,7 +47,7 @@ describe("getPlatformPackage", () => {
47
47
  const result = getPlatformPackage(input);
48
48
 
49
49
  // #then returns correct package name
50
- expect(result).toBe("oh-my-opencode-linux-arm64");
50
+ expect(result).toBe("evil-omo-linux-arm64");
51
51
  });
52
52
  // #endregion
53
53
 
@@ -60,7 +60,7 @@ describe("getPlatformPackage", () => {
60
60
  const result = getPlatformPackage(input);
61
61
 
62
62
  // #then returns correct package name with musl suffix
63
- expect(result).toBe("oh-my-opencode-linux-x64-musl");
63
+ expect(result).toBe("evil-omo-linux-x64-musl");
64
64
  });
65
65
 
66
66
  test("returns linux-arm64-musl for Alpine ARM64", () => {
@@ -71,7 +71,7 @@ describe("getPlatformPackage", () => {
71
71
  const result = getPlatformPackage(input);
72
72
 
73
73
  // #then returns correct package name with musl suffix
74
- expect(result).toBe("oh-my-opencode-linux-arm64-musl");
74
+ expect(result).toBe("evil-omo-linux-arm64-musl");
75
75
  });
76
76
  // #endregion
77
77
 
@@ -84,7 +84,7 @@ describe("getPlatformPackage", () => {
84
84
  const result = getPlatformPackage(input);
85
85
 
86
86
  // #then returns correct package name with 'windows' not 'win32'
87
- expect(result).toBe("oh-my-opencode-windows-x64");
87
+ expect(result).toBe("evil-omo-windows-x64");
88
88
  });
89
89
  // #endregion
90
90
 
@@ -112,38 +112,38 @@ describe("getPlatformPackage", () => {
112
112
  describe("getBinaryPath", () => {
113
113
  test("returns path without .exe for Unix platforms", () => {
114
114
  // #given Unix platform package
115
- const pkg = "oh-my-opencode-darwin-arm64";
115
+ const pkg = "evil-omo-darwin-arm64";
116
116
  const platform = "darwin";
117
117
 
118
118
  // #when getting binary path
119
119
  const result = getBinaryPath(pkg, platform);
120
120
 
121
121
  // #then returns path without extension
122
- expect(result).toBe("oh-my-opencode-darwin-arm64/bin/oh-my-opencode");
122
+ expect(result).toBe("evil-omo-darwin-arm64/bin/evil-omo");
123
123
  });
124
124
 
125
125
  test("returns path with .exe for Windows", () => {
126
126
  // #given Windows platform package
127
- const pkg = "oh-my-opencode-windows-x64";
127
+ const pkg = "evil-omo-windows-x64";
128
128
  const platform = "win32";
129
129
 
130
130
  // #when getting binary path
131
131
  const result = getBinaryPath(pkg, platform);
132
132
 
133
133
  // #then returns path with .exe extension
134
- expect(result).toBe("oh-my-opencode-windows-x64/bin/oh-my-opencode.exe");
134
+ expect(result).toBe("evil-omo-windows-x64/bin/evil-omo.exe");
135
135
  });
136
136
 
137
137
  test("returns path without .exe for Linux", () => {
138
138
  // #given Linux platform package
139
- const pkg = "oh-my-opencode-linux-x64";
139
+ const pkg = "evil-omo-linux-x64";
140
140
  const platform = "linux";
141
141
 
142
142
  // #when getting binary path
143
143
  const result = getBinaryPath(pkg, platform);
144
144
 
145
145
  // #then returns path without extension
146
- expect(result).toBe("oh-my-opencode-linux-x64/bin/oh-my-opencode");
146
+ expect(result).toBe("evil-omo-linux-x64/bin/evil-omo");
147
147
  });
148
148
  });
149
149
 
@@ -157,8 +157,8 @@ describe("getPlatformPackageCandidates", () => {
157
157
 
158
158
  // #then returns modern first then baseline fallback
159
159
  expect(result).toEqual([
160
- "oh-my-opencode-linux-x64",
161
- "oh-my-opencode-linux-x64-baseline",
160
+ "evil-omo-linux-x64",
161
+ "evil-omo-linux-x64-baseline",
162
162
  ]);
163
163
  });
164
164
 
@@ -171,8 +171,8 @@ describe("getPlatformPackageCandidates", () => {
171
171
 
172
172
  // #then returns musl modern first then musl baseline fallback
173
173
  expect(result).toEqual([
174
- "oh-my-opencode-linux-x64-musl",
175
- "oh-my-opencode-linux-x64-musl-baseline",
174
+ "evil-omo-linux-x64-musl",
175
+ "evil-omo-linux-x64-musl-baseline",
176
176
  ]);
177
177
  });
178
178
 
@@ -185,8 +185,8 @@ describe("getPlatformPackageCandidates", () => {
185
185
 
186
186
  // #then baseline package is preferred first
187
187
  expect(result).toEqual([
188
- "oh-my-opencode-windows-x64-baseline",
189
- "oh-my-opencode-windows-x64",
188
+ "evil-omo-windows-x64-baseline",
189
+ "evil-omo-windows-x64",
190
190
  ]);
191
191
  });
192
192
 
@@ -198,6 +198,6 @@ describe("getPlatformPackageCandidates", () => {
198
198
  const result = getPlatformPackageCandidates(input);
199
199
 
200
200
  // #then baseline fallback is not included
201
- expect(result).toEqual(["oh-my-opencode-linux-arm64"]);
201
+ expect(result).toEqual(["evil-omo-linux-arm64"]);
202
202
  });
203
203
  });
@@ -11,3 +11,4 @@ export declare function getConfigDir(): string;
11
11
  export declare function getConfigJson(): string;
12
12
  export declare function getConfigJsonc(): string;
13
13
  export declare function getOmoConfigPath(): string;
14
+ export declare function getExistingOmoConfigPath(): string | null;
@@ -25,5 +25,5 @@ export declare const EXIT_CODES: {
25
25
  readonly FAILURE: 1;
26
26
  };
27
27
  export declare const MIN_OPENCODE_VERSION = "1.0.150";
28
- export declare const PACKAGE_NAME = "oh-my-opencode";
28
+ export declare const PACKAGE_NAME = "evil-omo";
29
29
  export declare const OPENCODE_BINARIES: readonly ["opencode", "opencode-desktop"];