From 3e1b8b957e090cf0a979d99cc4e03efb0554c013 Mon Sep 17 00:00:00 2001 From: He-Xun <1226807142@qq.com> Date: Sun, 8 Jun 2025 21:24:51 +0800 Subject: [PATCH] Adjust the code according to the suggestions --- scripts/modules/config-manager.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/modules/config-manager.js b/scripts/modules/config-manager.js index 741d28b1..d179f567 100644 --- a/scripts/modules/config-manager.js +++ b/scripts/modules/config-manager.js @@ -547,11 +547,22 @@ function isApiKeySet(providerName, session = null, projectRoot = null) { * @returns {boolean} True if the key exists and is not a placeholder, false otherwise. */ function getMcpApiKeyStatus(providerName, projectRoot = null) { - const mcpConfigPath = path.join( - findProjectRoot() || '.', - '.cursor', - 'mcp.json' - ); + // 1. 恢复rootDir检查和警告 + const rootDir = projectRoot || findProjectRoot(); + if (!rootDir) { + console.warn( + chalk.yellow('Warning: Could not find project root to check mcp.json.') + ); + return false; // Cannot check without root + } + const mcpConfigPath = path.join(rootDir, '.cursor', 'mcp.json'); + + // 2. 文件存在性检查,保留注释warn + if (!fs.existsSync(mcpConfigPath)) { + // console.warn(chalk.yellow('Warning: .cursor/mcp.json not found.')); + return false; // File doesn't exist + } + try { const mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8'); const mcpConfig = JSON.parse(mcpConfigRaw);