@codexed/codex 0.151.0-codexed.1 → 0.153.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.
- package/bin/codex.js +52 -6
- package/package.json +4 -4
package/bin/codex.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Unified entry point for the Codex CLI.
|
|
3
3
|
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { existsSync, realpathSync } from "fs";
|
|
5
|
+
import { existsSync, readFileSync, realpathSync } from "fs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import path from "path";
|
|
8
8
|
import { fileURLToPath } from "url";
|
|
@@ -101,7 +101,9 @@ function findCodexExecutable() {
|
|
|
101
101
|
? "bun install -g @codexed/codex@latest"
|
|
102
102
|
: packageManager === "pnpm"
|
|
103
103
|
? "pnpm add -g @openai/codex@latest"
|
|
104
|
-
:
|
|
104
|
+
: packageManager === "vite-plus"
|
|
105
|
+
? "vp install -g @openai/codex@latest"
|
|
106
|
+
: "npm install -g @codexed/codex@latest";
|
|
105
107
|
throw new Error(
|
|
106
108
|
`Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
|
|
107
109
|
);
|
|
@@ -130,14 +132,52 @@ function isPnpmOwnedCodexInstall(nodeModulesDir) {
|
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
|
|
135
|
+
function isVitePlusOwnedCodexInstall(packagesDir) {
|
|
136
|
+
if (path.basename(packagesDir) !== "packages") {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
const metadata = JSON.parse(
|
|
142
|
+
readFileSync(path.join(packagesDir, "@openai", "codex.json"), "utf8"),
|
|
143
|
+
);
|
|
144
|
+
if (metadata.name !== "@openai/codex") {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Vite+ records the active global installation in packages/@openai/codex.json.
|
|
149
|
+
// Older installs have no ID or append a #-prefixed ID to the package name;
|
|
150
|
+
// newer installs put the ID in a subdirectory of the package prefix.
|
|
151
|
+
const installId = metadata.installId || "";
|
|
152
|
+
const installDir = installId.startsWith("#")
|
|
153
|
+
? path.join(packagesDir, `@openai/codex${installId}`)
|
|
154
|
+
: path.join(packagesDir, "@openai/codex", installId);
|
|
155
|
+
for (const nodeModulesDir of [
|
|
156
|
+
path.join(installDir, "lib", "node_modules"),
|
|
157
|
+
path.join(installDir, "node_modules"),
|
|
158
|
+
]) {
|
|
159
|
+
const packageRoot = path.join(nodeModulesDir, "@openai", "codex");
|
|
160
|
+
if (
|
|
161
|
+
existsSync(packageRoot) &&
|
|
162
|
+
realpathSync(packageRoot) === codexPackageRoot
|
|
163
|
+
) {
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} catch {
|
|
168
|
+
// Missing or unreadable ownership metadata must not prevent Codex starting.
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
133
173
|
/**
|
|
134
174
|
* Use heuristics to detect the package manager that was used to install Codex
|
|
135
175
|
* in order to give the user a hint about how to update it.
|
|
136
176
|
*/
|
|
137
177
|
function detectPackageManager() {
|
|
138
|
-
//
|
|
139
|
-
//
|
|
140
|
-
//
|
|
178
|
+
// Package-manager ownership metadata can be several parents above the package.
|
|
179
|
+
// Search ancestors of both the canonical package root and lexical entrypoint
|
|
180
|
+
// because the package manager may link either path.
|
|
141
181
|
const entrypointDir = path.dirname(path.resolve(process.argv[1]));
|
|
142
182
|
for (const startDir of new Set([codexPackageRoot, entrypointDir])) {
|
|
143
183
|
const filesystemRoot = path.parse(startDir).root;
|
|
@@ -146,6 +186,9 @@ function detectPackageManager() {
|
|
|
146
186
|
currentDir !== filesystemRoot;
|
|
147
187
|
currentDir = path.dirname(currentDir)
|
|
148
188
|
) {
|
|
189
|
+
if (isVitePlusOwnedCodexInstall(currentDir)) {
|
|
190
|
+
return "vite-plus";
|
|
191
|
+
}
|
|
149
192
|
if (isPnpmOwnedCodexInstall(path.join(currentDir, "node_modules"))) {
|
|
150
193
|
return "pnpm";
|
|
151
194
|
}
|
|
@@ -182,7 +225,9 @@ const packageManagerEnvVar =
|
|
|
182
225
|
? "CODEX_MANAGED_BY_BUN"
|
|
183
226
|
: packageManager === "pnpm"
|
|
184
227
|
? "CODEX_MANAGED_BY_PNPM"
|
|
185
|
-
: "
|
|
228
|
+
: packageManager === "vite-plus"
|
|
229
|
+
? "CODEX_MANAGED_BY_VITE_PLUS"
|
|
230
|
+
: "CODEX_MANAGED_BY_NPM";
|
|
186
231
|
const env = {
|
|
187
232
|
...process.env,
|
|
188
233
|
CODEX_MANAGED_PACKAGE_ROOT: codexPackageRoot,
|
|
@@ -190,6 +235,7 @@ const env = {
|
|
|
190
235
|
delete env.CODEX_MANAGED_BY_NPM;
|
|
191
236
|
delete env.CODEX_MANAGED_BY_BUN;
|
|
192
237
|
delete env.CODEX_MANAGED_BY_PNPM;
|
|
238
|
+
delete env.CODEX_MANAGED_BY_VITE_PLUS;
|
|
193
239
|
env[packageManagerEnvVar] = "1";
|
|
194
240
|
|
|
195
241
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codexed/codex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.153.0-codexed.1",
|
|
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.
|
|
28
|
-
"@codexed/codex-linux-arm64": "0.
|
|
29
|
-
"@codexed/codex-win32-x64": "0.
|
|
27
|
+
"@codexed/codex-linux-x64": "0.153.0-codexed.1",
|
|
28
|
+
"@codexed/codex-linux-arm64": "0.153.0-codexed.1",
|
|
29
|
+
"@codexed/codex-win32-x64": "0.153.0-codexed.1"
|
|
30
30
|
}
|
|
31
31
|
}
|