@bluehansl/claudex 0.142.5 → 0.144.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/README.md +1 -1
- package/bin/claudex.js +49 -4
- package/package.json +2 -2
package/README.md
CHANGED
package/bin/claudex.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-musl": "@bluehansl/claudex-linux-x64",
|
|
@@ -121,6 +122,8 @@ if (!nativePackage) {
|
|
|
121
122
|
const updateCommand =
|
|
122
123
|
packageManager === "bun"
|
|
123
124
|
? "bun install -g @bluehansl/claudex@latest"
|
|
125
|
+
: packageManager === "pnpm"
|
|
126
|
+
? "pnpm add -g @bluehansl/claudex@latest"
|
|
124
127
|
: "npm install -g @bluehansl/claudex@latest";
|
|
125
128
|
throw new Error(
|
|
126
129
|
`Missing optional dependency ${platformPackage}. Reinstall Claudex: ${updateCommand}`,
|
|
@@ -145,11 +148,47 @@ function getUpdatedPath(newDirs) {
|
|
|
145
148
|
return updatedPath;
|
|
146
149
|
}
|
|
147
150
|
|
|
151
|
+
function isPnpmOwnedCodexInstall(nodeModulesDir) {
|
|
152
|
+
if (!existsSync(path.join(nodeModulesDir, ".modules.yaml"))) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
return (
|
|
158
|
+
realpathSync(path.join(nodeModulesDir, "@bluehansl", "claudex")) ===
|
|
159
|
+
codexPackageRoot
|
|
160
|
+
);
|
|
161
|
+
} catch {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
148
166
|
/**
|
|
149
167
|
* Use heuristics to detect the package manager that was used to install Claudex
|
|
150
168
|
* in order to give the user a hint about how to update it.
|
|
151
169
|
*/
|
|
152
170
|
function detectPackageManager() {
|
|
171
|
+
// pnpm's owning node_modules directory can be several parents above the
|
|
172
|
+
// package in isolated global layouts. Search ancestors of both the canonical
|
|
173
|
+
// package root and lexical entrypoint because pnpm may link either path.
|
|
174
|
+
const entrypointDir = path.dirname(path.resolve(process.argv[1]));
|
|
175
|
+
for (const startDir of new Set([codexPackageRoot, entrypointDir])) {
|
|
176
|
+
const filesystemRoot = path.parse(startDir).root;
|
|
177
|
+
for (
|
|
178
|
+
let currentDir = startDir;
|
|
179
|
+
currentDir !== filesystemRoot;
|
|
180
|
+
currentDir = path.dirname(currentDir)
|
|
181
|
+
) {
|
|
182
|
+
if (isPnpmOwnedCodexInstall(path.join(currentDir, "node_modules"))) {
|
|
183
|
+
return "pnpm";
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (isPnpmOwnedCodexInstall(path.join(filesystemRoot, "node_modules"))) {
|
|
188
|
+
return "pnpm";
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
153
192
|
const userAgent = process.env.npm_config_user_agent || "";
|
|
154
193
|
if (/\bbun\//.test(userAgent)) {
|
|
155
194
|
return "bun";
|
|
@@ -170,10 +209,13 @@ function detectPackageManager() {
|
|
|
170
209
|
return userAgent ? "npm" : null;
|
|
171
210
|
}
|
|
172
211
|
|
|
212
|
+
const packageManager = detectPackageManager();
|
|
173
213
|
const packageManagerEnvVar =
|
|
174
|
-
|
|
214
|
+
packageManager === "bun"
|
|
175
215
|
? "CODEX_MANAGED_BY_BUN"
|
|
176
|
-
: "
|
|
216
|
+
: packageManager === "pnpm"
|
|
217
|
+
? "CODEX_MANAGED_BY_PNPM"
|
|
218
|
+
: "CODEX_MANAGED_BY_NPM";
|
|
177
219
|
const additionalDirs = [];
|
|
178
220
|
if (existsSync(pathDir)) {
|
|
179
221
|
additionalDirs.push(pathDir);
|
|
@@ -182,9 +224,12 @@ const updatedPath = getUpdatedPath(additionalDirs);
|
|
|
182
224
|
const env = {
|
|
183
225
|
...process.env,
|
|
184
226
|
PATH: updatedPath,
|
|
185
|
-
|
|
186
|
-
CODEX_MANAGED_PACKAGE_ROOT: realpathSync(path.join(__dirname, "..")),
|
|
227
|
+
CODEX_MANAGED_PACKAGE_ROOT: codexPackageRoot,
|
|
187
228
|
};
|
|
229
|
+
delete env.CODEX_MANAGED_BY_NPM;
|
|
230
|
+
delete env.CODEX_MANAGED_BY_BUN;
|
|
231
|
+
delete env.CODEX_MANAGED_BY_PNPM;
|
|
232
|
+
env[packageManagerEnvVar] = "1";
|
|
188
233
|
|
|
189
234
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
190
235
|
stdio: "inherit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bluehansl/claudex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.144.1",
|
|
4
4
|
"description": "Claudex CLI is a customized Codex CLI 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
|
-
"@bluehansl/claudex-darwin-arm64": "npm:@bluehansl/claudex@0.
|
|
23
|
+
"@bluehansl/claudex-darwin-arm64": "npm:@bluehansl/claudex@0.144.1-darwin-arm64"
|
|
24
24
|
}
|
|
25
25
|
}
|