@codexed/codex 0.142.4-codexed.1 → 0.144.1-codexed.2

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/README.md CHANGED
@@ -21,7 +21,7 @@ curl -fsSL https://chatgpt.com/codex/install.sh | sh
21
21
 
22
22
  Run the following on Windows to install Codex CLI:
23
23
 
24
- ```
24
+ ```shell
25
25
  powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
26
26
  ```
27
27
 
package/bin/codex.js CHANGED
@@ -11,6 +11,7 @@ import { fileURLToPath } from "url";
11
11
  const __filename = fileURLToPath(import.meta.url);
12
12
  const __dirname = path.dirname(__filename);
13
13
  const require = createRequire(import.meta.url);
14
+ const codexPackageRoot = realpathSync(path.join(__dirname, ".."));
14
15
 
15
16
  const PLATFORM_PACKAGE_BY_TARGET = {
16
17
  "x86_64-unknown-linux-gnu": "@codexed/codex-linux-x64",
@@ -98,7 +99,9 @@ function findCodexExecutable() {
98
99
  const updateCommand =
99
100
  packageManager === "bun"
100
101
  ? "bun install -g @codexed/codex@latest"
101
- : "npm install -g @codexed/codex@latest";
102
+ : packageManager === "pnpm"
103
+ ? "pnpm add -g @openai/codex@latest"
104
+ : "npm install -g @codexed/codex@latest";
102
105
  throw new Error(
103
106
  `Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
104
107
  );
@@ -112,11 +115,47 @@ const binaryPath = findCodexExecutable();
112
115
  // and guarantees that when either the child terminates or the parent
113
116
  // receives a fatal signal, both processes exit in a predictable manner.
114
117
 
118
+ function isPnpmOwnedCodexInstall(nodeModulesDir) {
119
+ if (!existsSync(path.join(nodeModulesDir, ".modules.yaml"))) {
120
+ return false;
121
+ }
122
+
123
+ try {
124
+ return (
125
+ realpathSync(path.join(nodeModulesDir, "@openai", "codex")) ===
126
+ codexPackageRoot
127
+ );
128
+ } catch {
129
+ return false;
130
+ }
131
+ }
132
+
115
133
  /**
116
134
  * Use heuristics to detect the package manager that was used to install Codex
117
135
  * in order to give the user a hint about how to update it.
118
136
  */
119
137
  function detectPackageManager() {
138
+ // pnpm's owning node_modules directory can be several parents above the
139
+ // package in isolated global layouts. Search ancestors of both the canonical
140
+ // package root and lexical entrypoint because pnpm may link either path.
141
+ const entrypointDir = path.dirname(path.resolve(process.argv[1]));
142
+ for (const startDir of new Set([codexPackageRoot, entrypointDir])) {
143
+ const filesystemRoot = path.parse(startDir).root;
144
+ for (
145
+ let currentDir = startDir;
146
+ currentDir !== filesystemRoot;
147
+ currentDir = path.dirname(currentDir)
148
+ ) {
149
+ if (isPnpmOwnedCodexInstall(path.join(currentDir, "node_modules"))) {
150
+ return "pnpm";
151
+ }
152
+ }
153
+
154
+ if (isPnpmOwnedCodexInstall(path.join(filesystemRoot, "node_modules"))) {
155
+ return "pnpm";
156
+ }
157
+ }
158
+
120
159
  const userAgent = process.env.npm_config_user_agent || "";
121
160
  if (/\bbun\//.test(userAgent)) {
122
161
  return "bun";
@@ -137,15 +176,21 @@ function detectPackageManager() {
137
176
  return userAgent ? "npm" : null;
138
177
  }
139
178
 
179
+ const packageManager = detectPackageManager();
140
180
  const packageManagerEnvVar =
141
- detectPackageManager() === "bun"
181
+ packageManager === "bun"
142
182
  ? "CODEX_MANAGED_BY_BUN"
143
- : "CODEX_MANAGED_BY_NPM";
183
+ : packageManager === "pnpm"
184
+ ? "CODEX_MANAGED_BY_PNPM"
185
+ : "CODEX_MANAGED_BY_NPM";
144
186
  const env = {
145
187
  ...process.env,
146
- [packageManagerEnvVar]: "1",
147
- CODEX_MANAGED_PACKAGE_ROOT: realpathSync(path.join(__dirname, "..")),
188
+ CODEX_MANAGED_PACKAGE_ROOT: codexPackageRoot,
148
189
  };
190
+ delete env.CODEX_MANAGED_BY_NPM;
191
+ delete env.CODEX_MANAGED_BY_BUN;
192
+ delete env.CODEX_MANAGED_BY_PNPM;
193
+ env[packageManagerEnvVar] = "1";
149
194
 
150
195
  const child = spawn(binaryPath, process.argv.slice(2), {
151
196
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexed/codex",
3
- "version": "0.142.4-codexed.1",
3
+ "version": "0.144.1-codexed.2",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "codex": "bin/codex.js"
@@ -24,8 +24,8 @@
24
24
  "postinstall": "node scripts/postinstall.mjs"
25
25
  },
26
26
  "optionalDependencies": {
27
- "@codexed/codex-linux-x64": "0.142.4-codexed.1",
28
- "@codexed/codex-linux-arm64": "0.142.4-codexed.1",
29
- "@codexed/codex-win32-x64": "0.142.4-codexed.1"
27
+ "@codexed/codex-linux-x64": "0.144.1-codexed.2",
28
+ "@codexed/codex-linux-arm64": "0.144.1-codexed.2",
29
+ "@codexed/codex-win32-x64": "0.144.1-codexed.2"
30
30
  }
31
31
  }