@rickgetz/codex 0.137.0-rick.2 → 0.139.0-rick.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 +2 -2
package/bin/codex.js CHANGED
@@ -88,45 +88,25 @@ if (!platformPackageSuffix) {
88
88
  }
89
89
  const platformPackage = packageAliasName(rootPackageName, platformPackageSuffix);
90
90
 
91
- const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
92
- const localVendorRoot = path.join(__dirname, "..", "vendor");
93
- const packageBinaryPath = (vendorRoot) =>
94
- path.join(vendorRoot, targetTriple, "bin", codexBinaryName);
95
- const legacyBinaryPath = (vendorRoot) =>
96
- path.join(vendorRoot, targetTriple, "codex", codexBinaryName);
97
-
98
- function resolveNativePackage(vendorRoot) {
99
- const packageRoot = path.join(vendorRoot, targetTriple);
100
- const binaryPath = packageBinaryPath(vendorRoot);
101
- if (existsSync(binaryPath)) {
102
- return {
103
- binaryPath,
104
- pathDir: path.join(packageRoot, "codex-path"),
105
- };
106
- }
107
-
108
- const legacyPath = legacyBinaryPath(vendorRoot);
109
- if (existsSync(legacyPath)) {
110
- return {
111
- binaryPath: legacyPath,
112
- pathDir: path.join(packageRoot, "path"),
113
- };
91
+ function findCodexExecutable() {
92
+ let vendorRoot;
93
+ try {
94
+ const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
95
+ vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
96
+ } catch {
97
+ vendorRoot = path.join(__dirname, "..", "vendor");
114
98
  }
115
99
 
116
- return null;
117
- }
118
-
119
- let nativePackage;
120
- try {
121
- const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
122
- nativePackage = resolveNativePackage(
123
- path.join(path.dirname(packageJsonPath), "vendor"),
100
+ const codexExecutable = path.join(
101
+ vendorRoot,
102
+ targetTriple,
103
+ "bin",
104
+ process.platform === "win32" ? "codex.exe" : "codex",
124
105
  );
125
- } catch {
126
- nativePackage = resolveNativePackage(localVendorRoot);
127
- }
106
+ if (existsSync(codexExecutable)) {
107
+ return codexExecutable;
108
+ }
128
109
 
129
- if (!nativePackage) {
130
110
  const packageManager = detectPackageManager();
131
111
  const updateCommand =
132
112
  packageManager === "bun"
@@ -137,7 +117,7 @@ if (!nativePackage) {
137
117
  );
138
118
  }
139
119
 
140
- const { binaryPath, pathDir } = nativePackage;
120
+ const binaryPath = findCodexExecutable();
141
121
 
142
122
  // Use an asynchronous spawn instead of spawnSync so that Node is able to
143
123
  // respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
@@ -145,16 +125,6 @@ const { binaryPath, pathDir } = nativePackage;
145
125
  // and guarantees that when either the child terminates or the parent
146
126
  // receives a fatal signal, both processes exit in a predictable manner.
147
127
 
148
- function getUpdatedPath(newDirs) {
149
- const pathSep = process.platform === "win32" ? ";" : ":";
150
- const existingPath = process.env.PATH || "";
151
- const updatedPath = [
152
- ...newDirs,
153
- ...existingPath.split(pathSep).filter(Boolean),
154
- ].join(pathSep);
155
- return updatedPath;
156
- }
157
-
158
128
  /**
159
129
  * Use heuristics to detect the package manager that was used to install Codex
160
130
  * in order to give the user a hint about how to update it.
@@ -180,19 +150,15 @@ function detectPackageManager() {
180
150
  return userAgent ? "npm" : null;
181
151
  }
182
152
 
183
- const additionalDirs = [];
184
- if (existsSync(pathDir)) {
185
- additionalDirs.push(pathDir);
186
- }
187
- const updatedPath = getUpdatedPath(additionalDirs);
188
-
189
- const env = { ...process.env, PATH: updatedPath };
190
153
  const packageManagerEnvVar =
191
154
  detectPackageManager() === "bun"
192
155
  ? "CODEX_MANAGED_BY_BUN"
193
156
  : "CODEX_MANAGED_BY_NPM";
194
- env[packageManagerEnvVar] = "1";
195
- env.CODEX_MANAGED_PACKAGE_ROOT = realpathSync(path.join(__dirname, ".."));
157
+ const env = {
158
+ ...process.env,
159
+ [packageManagerEnvVar]: "1",
160
+ CODEX_MANAGED_PACKAGE_ROOT: realpathSync(path.join(__dirname, "..")),
161
+ };
196
162
 
197
163
  const child = spawn(binaryPath, process.argv.slice(2), {
198
164
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rickgetz/codex",
3
- "version": "0.137.0-rick.2",
3
+ "version": "0.139.0-rick.1",
4
4
  "description": "Codex CLI is a coding agent from OpenAI that runs locally on your computer.",
5
5
  "license": "Apache-2.0",
6
6
  "bin": {
@@ -20,6 +20,6 @@
20
20
  },
21
21
  "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
22
22
  "optionalDependencies": {
23
- "@rickgetz/codex-darwin-arm64": "npm:@rickgetz/codex@0.137.0-rick.2-darwin-arm64"
23
+ "@rickgetz/codex-darwin-arm64": "npm:@rickgetz/codex@0.139.0-rick.1-darwin-arm64"
24
24
  }
25
25
  }