feat: add optional feature flag for code context (#1165)
* feat: add featureFlag for codebase analysis * chore: add changeset * chore: run format
This commit is contained in:
@@ -72,7 +72,8 @@ const DEFAULTS = {
|
||||
projectName: 'Task Master',
|
||||
ollamaBaseURL: 'http://localhost:11434/api',
|
||||
bedrockBaseURL: 'https://bedrock.us-east-1.amazonaws.com',
|
||||
responseLanguage: 'English'
|
||||
responseLanguage: 'English',
|
||||
enableCodebaseAnalysis: true
|
||||
},
|
||||
claudeCode: {}
|
||||
};
|
||||
@@ -428,15 +429,56 @@ function getResearchProvider(explicitRoot = null) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a codebase analysis provider is being used (Claude Code or Gemini CLI)
|
||||
* Check if codebase analysis feature flag is enabled across all sources
|
||||
* Priority: .env > MCP env > config.json
|
||||
* @param {object|null} session - MCP session object (optional)
|
||||
* @param {string|null} projectRoot - Project root path (optional)
|
||||
* @returns {boolean} True if codebase analysis is enabled
|
||||
*/
|
||||
function isCodebaseAnalysisEnabled(session = null, projectRoot = null) {
|
||||
// Priority 1: Environment variable
|
||||
const envFlag = resolveEnvVariable(
|
||||
'TASKMASTER_ENABLE_CODEBASE_ANALYSIS',
|
||||
session,
|
||||
projectRoot
|
||||
);
|
||||
if (envFlag !== null && envFlag !== undefined && envFlag !== '') {
|
||||
return envFlag.toLowerCase() === 'true' || envFlag === '1';
|
||||
}
|
||||
|
||||
// Priority 2: MCP session environment
|
||||
if (session?.env?.TASKMASTER_ENABLE_CODEBASE_ANALYSIS) {
|
||||
const mcpFlag = session.env.TASKMASTER_ENABLE_CODEBASE_ANALYSIS;
|
||||
return mcpFlag.toLowerCase() === 'true' || mcpFlag === '1';
|
||||
}
|
||||
|
||||
// Priority 3: Configuration file
|
||||
const globalConfig = getGlobalConfig(projectRoot);
|
||||
return globalConfig.enableCodebaseAnalysis !== false; // Default to true
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if codebase analysis is available and enabled
|
||||
* @param {boolean} useResearch - Whether to check research provider or main provider
|
||||
* @param {string|null} projectRoot - Project root path (optional)
|
||||
* @returns {boolean} True if a codebase analysis provider is the current provider
|
||||
* @param {object|null} session - MCP session object (optional)
|
||||
* @returns {boolean} True if codebase analysis is available and enabled
|
||||
*/
|
||||
function hasCodebaseAnalysis(useResearch = false, projectRoot = null) {
|
||||
function hasCodebaseAnalysis(
|
||||
useResearch = false,
|
||||
projectRoot = null,
|
||||
session = null
|
||||
) {
|
||||
// First check if the feature is enabled
|
||||
if (!isCodebaseAnalysisEnabled(session, projectRoot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Then check if a codebase analysis provider is configured
|
||||
const currentProvider = useResearch
|
||||
? getResearchProvider(projectRoot)
|
||||
: getMainProvider(projectRoot);
|
||||
|
||||
return (
|
||||
currentProvider === CUSTOM_PROVIDERS.CLAUDE_CODE ||
|
||||
currentProvider === CUSTOM_PROVIDERS.GEMINI_CLI
|
||||
@@ -558,6 +600,11 @@ function getResponseLanguage(explicitRoot = null) {
|
||||
return getGlobalConfig(explicitRoot).responseLanguage;
|
||||
}
|
||||
|
||||
function getCodebaseAnalysisEnabled(explicitRoot = null) {
|
||||
// Directly return value from config
|
||||
return getGlobalConfig(explicitRoot).enableCodebaseAnalysis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets model parameters (maxTokens, temperature) for a specific role,
|
||||
* considering model-specific overrides from supported-models.json.
|
||||
@@ -1016,6 +1063,8 @@ export {
|
||||
getAzureBaseURL,
|
||||
getBedrockBaseURL,
|
||||
getResponseLanguage,
|
||||
getCodebaseAnalysisEnabled,
|
||||
isCodebaseAnalysisEnabled,
|
||||
getParametersForRole,
|
||||
getUserId,
|
||||
// API Key Checkers (still relevant)
|
||||
|
||||
@@ -426,7 +426,11 @@ async function addTask(
|
||||
useResearch,
|
||||
priority: effectivePriority,
|
||||
dependencies: numericDependencies,
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(useResearch, projectRoot),
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(
|
||||
useResearch,
|
||||
projectRoot,
|
||||
session
|
||||
),
|
||||
projectRoot: projectRoot
|
||||
}
|
||||
);
|
||||
|
||||
@@ -419,7 +419,11 @@ async function analyzeTaskComplexity(options, context = {}) {
|
||||
tasks: tasksData.tasks,
|
||||
gatheredContext: gatheredContext || '',
|
||||
useResearch: useResearch,
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(useResearch, projectRoot),
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(
|
||||
useResearch,
|
||||
projectRoot,
|
||||
session
|
||||
),
|
||||
projectRoot: projectRoot || ''
|
||||
};
|
||||
|
||||
|
||||
@@ -458,7 +458,8 @@ async function expandTask(
|
||||
// Check if a codebase analysis provider is being used
|
||||
const hasCodebaseAnalysisCapability = hasCodebaseAnalysis(
|
||||
useResearch,
|
||||
projectRoot
|
||||
projectRoot,
|
||||
session
|
||||
);
|
||||
|
||||
// Combine all context sources into a single additionalContext parameter
|
||||
|
||||
@@ -77,7 +77,7 @@ export class PrdParseConfig {
|
||||
* Check if codebase analysis is available (Claude Code or Gemini CLI)
|
||||
*/
|
||||
hasCodebaseAnalysis() {
|
||||
return hasCodebaseAnalysis(this.research, this.projectRoot);
|
||||
return hasCodebaseAnalysis(this.research, this.projectRoot, this.session);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,11 @@ async function updateSubtaskById(
|
||||
updatePrompt: prompt,
|
||||
useResearch: useResearch,
|
||||
gatheredContext: gatheredContext || '',
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(useResearch, projectRoot),
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(
|
||||
useResearch,
|
||||
projectRoot,
|
||||
session
|
||||
),
|
||||
projectRoot: projectRoot
|
||||
};
|
||||
|
||||
|
||||
@@ -458,7 +458,11 @@ async function updateTaskById(
|
||||
useResearch: useResearch,
|
||||
currentDetails: taskToUpdate.details || '(No existing details)',
|
||||
gatheredContext: gatheredContext || '',
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(useResearch, projectRoot),
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(
|
||||
useResearch,
|
||||
projectRoot,
|
||||
session
|
||||
),
|
||||
projectRoot: projectRoot
|
||||
};
|
||||
|
||||
|
||||
@@ -436,7 +436,11 @@ async function updateTasks(
|
||||
updatePrompt: prompt,
|
||||
useResearch,
|
||||
projectContext: gatheredContext,
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(useResearch, projectRoot),
|
||||
hasCodebaseAnalysis: hasCodebaseAnalysis(
|
||||
useResearch,
|
||||
projectRoot,
|
||||
session
|
||||
),
|
||||
projectRoot: projectRoot
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user