Adjust the code according to the suggestions

This commit is contained in:
He-Xun
2025-06-08 21:24:51 +08:00
committed by Ralph Khreish
parent 91b9f11c03
commit 3e1b8b957e

View File

@@ -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. * @returns {boolean} True if the key exists and is not a placeholder, false otherwise.
*/ */
function getMcpApiKeyStatus(providerName, projectRoot = null) { function getMcpApiKeyStatus(providerName, projectRoot = null) {
const mcpConfigPath = path.join( // 1. 恢复rootDir检查和警告
findProjectRoot() || '.', const rootDir = projectRoot || findProjectRoot();
'.cursor', if (!rootDir) {
'mcp.json' 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 { try {
const mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8'); const mcpConfigRaw = fs.readFileSync(mcpConfigPath, 'utf-8');
const mcpConfig = JSON.parse(mcpConfigRaw); const mcpConfig = JSON.parse(mcpConfigRaw);