@bluehansl/claudex 0.149.1 → 0.153.4

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/claudex.js +55 -6
  2. package/package.json +3 -3
package/bin/claudex.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // Unified entry point for the Claudex 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";
@@ -124,7 +124,9 @@ if (!nativePackage) {
124
124
  ? "bun install -g @bluehansl/claudex@latest"
125
125
  : packageManager === "pnpm"
126
126
  ? "pnpm add -g @bluehansl/claudex@latest"
127
- : "npm install -g @bluehansl/claudex@latest";
127
+ : packageManager === "vite-plus"
128
+ ? "vp install -g @bluehansl/claudex@latest"
129
+ : "npm install -g @bluehansl/claudex@latest";
128
130
  throw new Error(
129
131
  `Missing optional dependency ${platformPackage}. Reinstall Claudex: ${updateCommand}`,
130
132
  );
@@ -163,14 +165,55 @@ function isPnpmOwnedCodexInstall(nodeModulesDir) {
163
165
  }
164
166
  }
165
167
 
168
+ function isVitePlusOwnedClaudexInstall(packagesDir) {
169
+ if (path.basename(packagesDir) !== "packages") {
170
+ return false;
171
+ }
172
+
173
+ try {
174
+ const metadata = JSON.parse(
175
+ readFileSync(
176
+ path.join(packagesDir, "@bluehansl", "claudex.json"),
177
+ "utf8",
178
+ ),
179
+ );
180
+ if (metadata.name !== "@bluehansl/claudex") {
181
+ return false;
182
+ }
183
+
184
+ // Vite+ records the active global installation in packages/@bluehansl/claudex.json.
185
+ // Older installs have no ID or append a #-prefixed ID to the package name;
186
+ // newer installs put the ID in a subdirectory of the package prefix.
187
+ const installId = metadata.installId || "";
188
+ const installDir = installId.startsWith("#")
189
+ ? path.join(packagesDir, `@bluehansl/claudex${installId}`)
190
+ : path.join(packagesDir, "@bluehansl/claudex", installId);
191
+ for (const nodeModulesDir of [
192
+ path.join(installDir, "lib", "node_modules"),
193
+ path.join(installDir, "node_modules"),
194
+ ]) {
195
+ const packageRoot = path.join(nodeModulesDir, "@bluehansl", "claudex");
196
+ if (
197
+ existsSync(packageRoot) &&
198
+ realpathSync(packageRoot) === codexPackageRoot
199
+ ) {
200
+ return true;
201
+ }
202
+ }
203
+ } catch {
204
+ // Missing or unreadable ownership metadata must not prevent Codex starting.
205
+ }
206
+ return false;
207
+ }
208
+
166
209
  /**
167
210
  * Use heuristics to detect the package manager that was used to install Claudex
168
211
  * in order to give the user a hint about how to update it.
169
212
  */
170
213
  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.
214
+ // Package-manager ownership metadata can be several parents above the package.
215
+ // Search ancestors of both the canonical package root and lexical entrypoint
216
+ // because the package manager may link either path.
174
217
  const entrypointDir = path.dirname(path.resolve(process.argv[1]));
175
218
  for (const startDir of new Set([codexPackageRoot, entrypointDir])) {
176
219
  const filesystemRoot = path.parse(startDir).root;
@@ -179,6 +222,9 @@ function detectPackageManager() {
179
222
  currentDir !== filesystemRoot;
180
223
  currentDir = path.dirname(currentDir)
181
224
  ) {
225
+ if (isVitePlusOwnedClaudexInstall(currentDir)) {
226
+ return "vite-plus";
227
+ }
182
228
  if (isPnpmOwnedCodexInstall(path.join(currentDir, "node_modules"))) {
183
229
  return "pnpm";
184
230
  }
@@ -215,7 +261,9 @@ const packageManagerEnvVar =
215
261
  ? "CODEX_MANAGED_BY_BUN"
216
262
  : packageManager === "pnpm"
217
263
  ? "CODEX_MANAGED_BY_PNPM"
218
- : "CODEX_MANAGED_BY_NPM";
264
+ : packageManager === "vite-plus"
265
+ ? "CODEX_MANAGED_BY_VITE_PLUS"
266
+ : "CODEX_MANAGED_BY_NPM";
219
267
  const additionalDirs = [];
220
268
  if (existsSync(pathDir)) {
221
269
  additionalDirs.push(pathDir);
@@ -229,6 +277,7 @@ const env = {
229
277
  delete env.CODEX_MANAGED_BY_NPM;
230
278
  delete env.CODEX_MANAGED_BY_BUN;
231
279
  delete env.CODEX_MANAGED_BY_PNPM;
280
+ delete env.CODEX_MANAGED_BY_VITE_PLUS;
232
281
  env[packageManagerEnvVar] = "1";
233
282
 
234
283
  const child = spawn(binaryPath, process.argv.slice(2), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluehansl/claudex",
3
- "version": "0.149.1",
3
+ "version": "0.153.4",
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": {
@@ -18,8 +18,8 @@
18
18
  "url": "git+https://github.com/bluehansl/claudex.git",
19
19
  "directory": "codex-cli"
20
20
  },
21
- "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
21
+ "packageManager": "pnpm@10.34.5+sha512.a4ee05f2f73658255bd6a89859c065a45c28a57daefae2c893a168ee2b73168c37b91e83e57ea67654ad03f03031746430e8bce38e362e042605fb8abc80192e",
22
22
  "optionalDependencies": {
23
- "@bluehansl/claudex-darwin-arm64": "npm:@bluehansl/claudex@0.149.1-darwin-arm64"
23
+ "@bluehansl/claudex-darwin-arm64": "npm:@bluehansl/claudex@0.153.4-darwin-arm64"
24
24
  }
25
25
  }