From ab259b1970ba06ef09552634c36faff15f58f463 Mon Sep 17 00:00:00 2001 From: jerry <260902108@qq.com> Date: Sat, 24 Jan 2026 08:58:44 +0800 Subject: [PATCH] fix: resolve CodexLens installation failure with NPM global install - Implement two-pass search strategy for codex-lens path detection - First pass: prefer non-node_modules paths (development environment) - Second pass: allow node_modules paths (NPM global install) - Fixes CodexLens installation for all NPM global install users - No breaking changes, maintains backward compatibility Resolves issue where NPM global install users could not install CodexLens because the code rejected paths containing /node_modules/, which is the only valid location for codex-lens in NPM installations. Tested on macOS with Node.js v22.18.0 via NPM global install. --- ccw/src/tools/codex-lens.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ccw/src/tools/codex-lens.ts b/ccw/src/tools/codex-lens.ts index 74cd27da..71d0fb60 100644 --- a/ccw/src/tools/codex-lens.ts +++ b/ccw/src/tools/codex-lens.ts @@ -83,8 +83,8 @@ function findLocalPackagePath(packageName: string): string | null { possiblePaths.push(join(cwdParent, packageName)); } + // First pass: prefer non-node_modules paths (development environment) for (const localPath of possiblePaths) { - // Skip paths inside node_modules if (isInsideNodeModules(localPath)) { continue; } @@ -94,8 +94,12 @@ function findLocalPackagePath(packageName: string): string | null { } } - if (!isDevEnvironment()) { - console.log(`[CodexLens] Running from node_modules - will try PyPI for ${packageName}`); + // Second pass: allow node_modules paths (NPM global install) + for (const localPath of possiblePaths) { + if (existsSync(join(localPath, 'pyproject.toml'))) { + console.log(`[CodexLens] Found ${packageName} in node_modules at: ${localPath}`); + return localPath; + } } return null;