chore: cleanup

This commit is contained in:
Ralph Khreish
2025-06-20 16:50:37 +03:00
parent 1c8b1b405a
commit 6816882c5b

View File

@@ -526,17 +526,23 @@ function isApiKeySet(providerName, session = null, projectRoot = null) {
bedrock: 'AWS_ACCESS_KEY_ID' // Bedrock uses AWS credentials bedrock: 'AWS_ACCESS_KEY_ID' // Bedrock uses AWS credentials
// Add other providers as needed // Add other providers as needed
}; };
let envVarName = keyMap[providerName?.toLowerCase()];
if (!envVarName) { const providerKey = providerName?.toLowerCase();
envVarName = `${providerName?.toUpperCase()}_API_KEY`; if (!providerKey || !keyMap[providerKey]) {
log('warn', `Unknown provider name: ${providerName} in isApiKeySet check.`);
return false;
} }
const envVarName = keyMap[providerKey];
const apiKeyValue = resolveEnvVariable(envVarName, session, projectRoot); const apiKeyValue = resolveEnvVariable(envVarName, session, projectRoot);
// Check if the key exists, is not empty, and is not a placeholder
return ( return (
apiKeyValue && apiKeyValue &&
apiKeyValue.trim() !== '' && apiKeyValue.trim() !== '' &&
!/YOUR_.*_API_KEY_HERE/.test(apiKeyValue) && !/YOUR_.*_API_KEY_HERE/.test(apiKeyValue) && // General placeholder check
!apiKeyValue.includes('KEY_HERE') !apiKeyValue.includes('KEY_HERE')
); ); // Another common placeholder pattern
} }
/** /**
@@ -547,8 +553,7 @@ 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) {
// 1. Restore rootDir check and warning const rootDir = projectRoot || findProjectRoot(); // Use existing root finding
const rootDir = projectRoot || findProjectRoot();
if (!rootDir) { if (!rootDir) {
console.warn( console.warn(
chalk.yellow('Warning: Could not find project root to check mcp.json.') chalk.yellow('Warning: Could not find project root to check mcp.json.')
@@ -557,7 +562,6 @@ function getMcpApiKeyStatus(providerName, projectRoot = null) {
} }
const mcpConfigPath = path.join(rootDir, '.cursor', 'mcp.json'); const mcpConfigPath = path.join(rootDir, '.cursor', 'mcp.json');
// 2. File existence check, keep the commented warn
if (!fs.existsSync(mcpConfigPath)) { if (!fs.existsSync(mcpConfigPath)) {
// console.warn(chalk.yellow('Warning: .cursor/mcp.json not found.')); // console.warn(chalk.yellow('Warning: .cursor/mcp.json not found.'));
return false; // File doesn't exist return false; // File doesn't exist
@@ -566,7 +570,10 @@ function getMcpApiKeyStatus(providerName, projectRoot = null) {
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);
const mcpEnv = mcpConfig?.mcpServers?.['task-master-ai']?.env;
const mcpEnv =
mcpConfig?.mcpServers?.['task-master-ai']?.env ||
mcpConfig?.mcpServers?.['taskmaster-ai']?.env;
if (!mcpEnv) { if (!mcpEnv) {
return false; return false;
} }