From 6716772e0a31f3653e44341b28984757ed3e7bd7 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Mon, 19 Jan 2026 11:43:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(codexlens):=20=E6=B7=BB=E5=8A=A0=20Yarn=20P?= =?UTF-8?q?nP=20=E6=94=AF=E6=8C=81=E4=BB=A5=E6=94=B9=E8=BF=9B=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题分析: - Yarn PnP 不使用 node_modules 目录 - 原有逻辑仅检测 node_modules 会错误识别为开发环境 - 导致在 Yarn PnP 项目中尝试使用本地路径安装失败 修复内容: - 在 isDevEnvironment() 中添加 Yarn PnP 检测 - 检查 process.versions.pnp 属性判断是否为 Yarn PnP 环境 - Yarn PnP 环境被视为生产环境,使用 PyPI 安装 改进影响: - npm/pnpm: 使用 node_modules 检测(原有逻辑) - Yarn PnP: 使用 pnp 版本检测(新增逻辑) - 开发环境: 两项检测均不满足时识别为开发环境 Based on Gemini code review suggestion (ID: 1768794060352-gemini) --- ccw/src/tools/codex-lens.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ccw/src/tools/codex-lens.ts b/ccw/src/tools/codex-lens.ts index 940b63ac..f461e9dc 100644 --- a/ccw/src/tools/codex-lens.ts +++ b/ccw/src/tools/codex-lens.ts @@ -41,8 +41,13 @@ function isInsideNodeModules(pathToCheck: string): boolean { /** * Check if we're running in a development environment (not from node_modules) + * Also detects Yarn PnP (Plug'n'Play) which doesn't use node_modules. */ function isDevEnvironment(): boolean { + // Yarn PnP detection: if pnp version exists, it's a managed production environment + if ((process.versions as any).pnp) { + return false; + } return !isInsideNodeModules(__dirname); }