fix: more regression bugs

This commit is contained in:
Ralph Khreish
2025-07-11 07:25:29 +03:00
parent 3e61d26235
commit 8e9d00e03d
6 changed files with 62 additions and 23 deletions

View File

@@ -1500,10 +1500,16 @@ function registerCommands(programInstance) {
.option('--tag <tag>', 'Specify tag context for task operations')
.action(async (options) => {
// Initialize TaskMaster
const taskMaster = initTaskMaster({
tasksPath: options.file || true,
complexityReportPath: options.report || false
});
const initOptions = {
tasksPath: options.file || true
};
// Only pass complexityReportPath if user provided a custom path
if (options.report && options.report !== COMPLEXITY_REPORT_FILE) {
initOptions.complexityReportPath = options.report;
}
const taskMaster = initTaskMaster(initOptions);
const statusFilter = options.status;
const withSubtasks = options.withSubtasks || false;
@@ -1690,7 +1696,7 @@ function registerCommands(programInstance) {
const outputPath =
options.output === COMPLEXITY_REPORT_FILE && targetTag !== 'master'
? baseOutputPath.replace('.json', `_${targetTag}.json`)
: baseOutputPath;
: options.output || baseOutputPath;
console.log(
chalk.blue(
@@ -1770,6 +1776,11 @@ function registerCommands(programInstance) {
)
.option('--tag <tag>', 'Specify tag context for task operations')
.action(async (prompt, options) => {
// Initialize TaskMaster
const taskMaster = initTaskMaster({
tasksPath: options.file || true
});
// Parameter validation
if (!prompt || typeof prompt !== 'string' || prompt.trim().length === 0) {
console.error(
@@ -2211,6 +2222,8 @@ ${result.result}
tasksPath: options.file || true
});
const projectRoot = taskMaster.getProjectRoot();
// Show current tag context
displayCurrentTagIndicator(
options.tag || getCurrentTag(taskMaster.getProjectRoot()) || 'master'
@@ -3462,6 +3475,9 @@ Examples:
const taskMaster = initTaskMaster({
tasksPath: options.file || false
});
const projectRoot = taskMaster.getProjectRoot();
// Validate flags: cannot use multiple provider flags simultaneously
const providerFlags = [
options.openrouter,

View File

@@ -4,7 +4,7 @@ import chalk from 'chalk';
import { z } from 'zod';
import { fileURLToPath } from 'url';
import { log, findProjectRoot, resolveEnvVariable, isEmpty } from './utils.js';
import { LEGACY_CONFIG_FILE } from '../../src/constants/paths.js';
import { LEGACY_CONFIG_FILE, TASKMASTER_DIR } from '../../src/constants/paths.js';
import { findConfigPath } from '../../src/utils/path-utils.js';
import {
VALIDATED_PROVIDERS,
@@ -99,17 +99,29 @@ function _loadAndValidateConfig(explicitRoot = null) {
if (rootToUse) {
configSource = `found root (${rootToUse})`;
} else {
// No root found, return defaults immediately
return defaults;
// No root found, use current working directory as fallback
// This prevents infinite loops during initialization
rootToUse = process.cwd();
configSource = `current directory (${rootToUse}) - no project markers found`;
}
}
// ---> End find project root logic <---
// --- Find configuration file using centralized path utility ---
const configPath = findConfigPath(null, { projectRoot: rootToUse });
// --- Find configuration file ---
let configPath = null;
let config = { ...defaults }; // Start with a deep copy of defaults
let configExists = false;
// During initialization (no project markers), skip config file search entirely
const hasProjectMarkers = fs.existsSync(path.join(rootToUse, TASKMASTER_DIR)) ||
fs.existsSync(path.join(rootToUse, LEGACY_CONFIG_FILE));
if (hasProjectMarkers) {
// Only try to find config if we have project markers
// This prevents the repeated warnings during init
configPath = findConfigPath(null, { projectRoot: rootToUse });
}
if (configPath) {
configExists = true;
const isLegacy = configPath.endsWith(LEGACY_CONFIG_FILE);
@@ -199,12 +211,19 @@ function _loadAndValidateConfig(explicitRoot = null) {
)
);
} else {
// Don't warn about missing config during initialization
// Only warn if this looks like an existing project (has .taskmaster dir or legacy config marker)
const hasTaskmasterDir = fs.existsSync(path.join(rootToUse, TASKMASTER_DIR));
const hasLegacyMarker = fs.existsSync(path.join(rootToUse, LEGACY_CONFIG_FILE));
if (hasTaskmasterDir || hasLegacyMarker) {
console.warn(
chalk.yellow(
`Warning: Configuration file not found at derived root (${rootToUse}). Using defaults.`
)
);
}
}
// Keep config as defaults
config = { ...defaults };
configSource = `defaults (no config file found at ${rootToUse})`;

View File

@@ -469,7 +469,7 @@ async function expandTask(
complexityReasoningContext: complexityReasoningContext,
gatheredContext: gatheredContext,
useResearch: useResearch,
expansionPrompt: taskAnalysis?.expansionPrompt || null
expansionPrompt: taskAnalysis?.expansionPrompt || undefined
};
let variantKey = 'default';

View File

@@ -205,12 +205,10 @@ async function performResearch(
}
};
// Select variant based on detail level
const variantKey = detailLevel; // 'low', 'medium', or 'high'
// Load prompts - the research template handles detail level internally
const { systemPrompt, userPrompt } = await promptManager.loadPrompt(
'research',
promptParams,
variantKey
promptParams
);
// Count tokens for system and user prompts

View File

@@ -214,7 +214,7 @@ async function updateSubtaskById(
title: parentTask.subtasks[subtaskIndex - 1].title,
status: parentTask.subtasks[subtaskIndex - 1].status
}
: null;
: undefined;
const nextSubtask =
subtaskIndex < parentTask.subtasks.length - 1
? {
@@ -222,7 +222,7 @@ async function updateSubtaskById(
title: parentTask.subtasks[subtaskIndex + 1].title,
status: parentTask.subtasks[subtaskIndex + 1].status
}
: null;
: undefined;
// Build prompts using PromptManager
const promptManager = getPromptManager();

View File

@@ -218,7 +218,13 @@ export function initTaskMaster(overrides = {}) {
);
}
// Remaining paths - only resolve if key exists in overrides
// Always set default paths first
// These can be overridden below if needed
paths.configPath = path.join(paths.projectRoot, TASKMASTER_CONFIG_FILE);
paths.statePath = path.join(paths.taskMasterDir || path.join(paths.projectRoot, TASKMASTER_DIR), 'state.json');
paths.tasksPath = path.join(paths.projectRoot, TASKMASTER_TASKS_FILE);
// Handle overrides - only validate/resolve if explicitly provided
if ('configPath' in overrides) {
paths.configPath = resolvePath(
'config file',