@codexed/codex 0.135.0-codexed.1 → 0.139.0-codexed.1

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.
Files changed (2) hide show
  1. package/bin/codex.js +21 -55
  2. package/package.json +4 -4
package/bin/codex.js CHANGED
@@ -75,45 +75,25 @@ if (!platformPackage) {
75
75
  throw new Error(`Unsupported target triple: ${targetTriple}`);
76
76
  }
77
77
 
78
- const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
79
- const localVendorRoot = path.join(__dirname, "..", "vendor");
80
- const packageBinaryPath = (vendorRoot) =>
81
- path.join(vendorRoot, targetTriple, "bin", codexBinaryName);
82
- const legacyBinaryPath = (vendorRoot) =>
83
- path.join(vendorRoot, targetTriple, "codex", codexBinaryName);
84
-
85
- function resolveNativePackage(vendorRoot) {
86
- const packageRoot = path.join(vendorRoot, targetTriple);
87
- const binaryPath = packageBinaryPath(vendorRoot);
88
- if (existsSync(binaryPath)) {
89
- return {
90
- binaryPath,
91
- pathDir: path.join(packageRoot, "codex-path"),
92
- };
93
- }
94
-
95
- const legacyPath = legacyBinaryPath(vendorRoot);
96
- if (existsSync(legacyPath)) {
97
- return {
98
- binaryPath: legacyPath,
99
- pathDir: path.join(packageRoot, "path"),
100
- };
78
+ function findCodexExecutable() {
79
+ let vendorRoot;
80
+ try {
81
+ const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
82
+ vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
83
+ } catch {
84
+ vendorRoot = path.join(__dirname, "..", "vendor");
101
85
  }
102
86
 
103
- return null;
104
- }
105
-
106
- let nativePackage;
107
- try {
108
- const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
109
- nativePackage = resolveNativePackage(
110
- path.join(path.dirname(packageJsonPath), "vendor"),
87
+ const codexExecutable = path.join(
88
+ vendorRoot,
89
+ targetTriple,
90
+ "bin",
91
+ process.platform === "win32" ? "codex.exe" : "codex",
111
92
  );
112
- } catch {
113
- nativePackage = resolveNativePackage(localVendorRoot);
114
- }
93
+ if (existsSync(codexExecutable)) {
94
+ return codexExecutable;
95
+ }
115
96
 
116
- if (!nativePackage) {
117
97
  const packageManager = detectPackageManager();
118
98
  const updateCommand =
119
99
  packageManager === "bun"
@@ -124,7 +104,7 @@ if (!nativePackage) {
124
104
  );
125
105
  }
126
106
 
127
- const { binaryPath, pathDir } = nativePackage;
107
+ const binaryPath = findCodexExecutable();
128
108
 
129
109
  // Use an asynchronous spawn instead of spawnSync so that Node is able to
130
110
  // respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
@@ -132,16 +112,6 @@ const { binaryPath, pathDir } = nativePackage;
132
112
  // and guarantees that when either the child terminates or the parent
133
113
  // receives a fatal signal, both processes exit in a predictable manner.
134
114
 
135
- function getUpdatedPath(newDirs) {
136
- const pathSep = process.platform === "win32" ? ";" : ":";
137
- const existingPath = process.env.PATH || "";
138
- const updatedPath = [
139
- ...newDirs,
140
- ...existingPath.split(pathSep).filter(Boolean),
141
- ].join(pathSep);
142
- return updatedPath;
143
- }
144
-
145
115
  /**
146
116
  * Use heuristics to detect the package manager that was used to install Codex
147
117
  * in order to give the user a hint about how to update it.
@@ -167,19 +137,15 @@ function detectPackageManager() {
167
137
  return userAgent ? "npm" : null;
168
138
  }
169
139
 
170
- const additionalDirs = [];
171
- if (existsSync(pathDir)) {
172
- additionalDirs.push(pathDir);
173
- }
174
- const updatedPath = getUpdatedPath(additionalDirs);
175
-
176
- const env = { ...process.env, PATH: updatedPath };
177
140
  const packageManagerEnvVar =
178
141
  detectPackageManager() === "bun"
179
142
  ? "CODEX_MANAGED_BY_BUN"
180
143
  : "CODEX_MANAGED_BY_NPM";
181
- env[packageManagerEnvVar] = "1";
182
- env.CODEX_MANAGED_PACKAGE_ROOT = realpathSync(path.join(__dirname, ".."));
144
+ const env = {
145
+ ...process.env,
146
+ [packageManagerEnvVar]: "1",
147
+ CODEX_MANAGED_PACKAGE_ROOT: realpathSync(path.join(__dirname, "..")),
148
+ };
183
149
 
184
150
  const child = spawn(binaryPath, process.argv.slice(2), {
185
151
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexed/codex",
3
- "version": "0.135.0-codexed.1",
3
+ "version": "0.139.0-codexed.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -21,8 +21,8 @@
21
21
  "postinstall": "node scripts/postinstall.mjs"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@codexed/codex-linux-x64": "0.135.0-codexed.1",
25
- "@codexed/codex-linux-arm64": "0.135.0-codexed.1",
26
- "@codexed/codex-win32-x64": "0.135.0-codexed.1"
24
+ "@codexed/codex-linux-x64": "0.139.0-codexed.1",
25
+ "@codexed/codex-linux-arm64": "0.139.0-codexed.1",
26
+ "@codexed/codex-win32-x64": "0.139.0-codexed.1"
27
27
  }
28
28
  }