Fix: Ensure consistent handling of kebab-case flags in CLI
- Enhanced the function in ℹ️ Initialized Perplexity client with OpenAI compatibility layer _____ _ __ __ _ |_ _|_ _ ___| | __ | \/ | __ _ ___| |_ ___ _ __ | |/ _` / __| |/ / | |\/| |/ _` / __| __/ _ \ '__| | | (_| \__ \ < | | | | (_| \__ \ || __/ | |_|\__,_|___/_|\_\ |_| |_|\__,_|___/\__\___|_| by https://x.com/eyaltoledano ╭────────────────────────────────────────────╮ │ │ │ Version: 0.9.24 Project: Task Master │ │ │ ╰────────────────────────────────────────────╯ ╭─────────────────────╮ │ │ │ Task Master CLI │ │ │ ╰─────────────────────╯ ╭───────────────────╮ │ Task Generation │ ╰───────────────────╯ parse-prd --input=<file.txt> [--tasks=10] Generate tasks from a PRD document generate Create individual task files from tasks… ╭───────────────────╮ │ Task Management │ ╰───────────────────╯ list [--status=<status>] [--with-subtas… List all tasks with their status set-status --id=<id> --status=<status> Update task status (done, pending, etc.) update --from=<id> --prompt="<context>" Update tasks based on new requirements add-task --prompt="<text>" [--dependencies=… Add a new task using AI add-dependency --id=<id> --depends-on=<id> Add a dependency to a task remove-dependency --id=<id> --depends-on=<id> Remove a dependency from a task ╭──────────────────────────╮ │ Task Analysis & Detail │ ╰──────────────────────────╯ analyze-complexity [--research] [--threshold=5] Analyze tasks and generate expansion re… complexity-report [--file=<path>] Display the complexity analysis report expand --id=<id> [--num=5] [--research] [… Break down tasks into detailed subtasks expand --all [--force] [--research] Expand all pending tasks with subtasks clear-subtasks --id=<id> Remove subtasks from specified tasks ╭─────────────────────────────╮ │ Task Navigation & Viewing │ ╰─────────────────────────────╯ next Show the next task to work on based on … show <id> Display detailed information about a sp… ╭─────────────────────────╮ │ Dependency Management │ ╰─────────────────────────╯ validate-dependenci… Identify invalid dependencies without f… fix-dependencies Fix invalid dependencies automatically ╭─────────────────────────╮ │ Environment Variables │ ╰─────────────────────────╯ ANTHROPIC_API_KEY Your Anthropic API key Required MODEL Claude model to use Default: claude-3-7-sonn… MAX_TOKENS Maximum tokens for responses Default: 4000 TEMPERATURE Temperature for model responses Default: 0.7 PERPLEXITY_API_KEY Perplexity API key for research Optional PERPLEXITY_MODEL Perplexity model to use Default: sonar-pro DEBUG Enable debug logging Default: false LOG_LEVEL Console output level (debug,info,warn,error) Default: info DEFAULT_SUBTASKS Default number of subtasks to generate Default: 3 DEFAULT_PRIORITY Default task priority Default: medium PROJECT_NAME Project name displayed in UI Default: Task Master _____ _ __ __ _ |_ _|_ _ ___| | __ | \/ | __ _ ___| |_ ___ _ __ | |/ _` / __| |/ / | |\/| |/ _` / __| __/ _ \ '__| | | (_| \__ \ < | | | | (_| \__ \ || __/ | |_|\__,_|___/_|\_\ |_| |_|\__,_|___/\__\___|_| by https://x.com/eyaltoledano ╭────────────────────────────────────────────╮ │ │ │ Version: 0.9.24 Project: Task Master │ │ │ ╰────────────────────────────────────────────╯ ╭─────────────────────╮ │ │ │ Task Master CLI │ │ │ ╰─────────────────────╯ ╭───────────────────╮ │ Task Generation │ ╰───────────────────╯ parse-prd --input=<file.txt> [--tasks=10] Generate tasks from a PRD document generate Create individual task files from tasks… ╭───────────────────╮ │ Task Management │ ╰───────────────────╯ list [--status=<status>] [--with-subtas… List all tasks with their status set-status --id=<id> --status=<status> Update task status (done, pending, etc.) update --from=<id> --prompt="<context>" Update tasks based on new requirements add-task --prompt="<text>" [--dependencies=… Add a new task using AI add-dependency --id=<id> --depends-on=<id> Add a dependency to a task remove-dependency --id=<id> --depends-on=<id> Remove a dependency from a task ╭──────────────────────────╮ │ Task Analysis & Detail │ ╰──────────────────────────╯ analyze-complexity [--research] [--threshold=5] Analyze tasks and generate expansion re… complexity-report [--file=<path>] Display the complexity analysis report expand --id=<id> [--num=5] [--research] [… Break down tasks into detailed subtasks expand --all [--force] [--research] Expand all pending tasks with subtasks clear-subtasks --id=<id> Remove subtasks from specified tasks ╭─────────────────────────────╮ │ Task Navigation & Viewing │ ╰─────────────────────────────╯ next Show the next task to work on based on … show <id> Display detailed information about a sp… ╭─────────────────────────╮ │ Dependency Management │ ╰─────────────────────────╯ validate-dependenci… Identify invalid dependencies without f… fix-dependencies Fix invalid dependencies automatically ╭─────────────────────────╮ │ Environment Variables │ ╰─────────────────────────╯ ANTHROPIC_API_KEY Your Anthropic API key Required MODEL Claude model to use Default: claude-3-7-sonn… MAX_TOKENS Maximum tokens for responses Default: 4000 TEMPERATURE Temperature for model responses Default: 0.7 PERPLEXITY_API_KEY Perplexity API key for research Optional PERPLEXITY_MODEL Perplexity model to use Default: sonar-pro DEBUG Enable debug logging Default: false LOG_LEVEL Console output level (debug,info,warn,error) Default: info DEFAULT_SUBTASKS Default number of subtasks to generate Default: 3 DEFAULT_PRIORITY Default task priority Default: medium PROJECT_NAME Project name displayed in UI Default: Task Master to correctly handle kebab-case flags by: - Converting camelCase options back to kebab-case for command line arguments. - Checking the original CLI arguments to determine the format used by the user. - Preserving the original flag format when passing it to the underlying script. - Special handling for and flags to ensure they are correctly interpreted. - Updated boolean flag handling to correctly manage negated options and preserve user-specified formats. - Marked task 022 as done and updated the status of its sub-tasks in . - Added tasks 26, 27 and 28 for context improvements related to task generation This commit ensures that all kebab-case flags are handled consistently across the CLI, improving user experience and command reliability.
This commit is contained in:
@@ -52,24 +52,82 @@ function createDevScriptAction(commandName) {
|
||||
args.push(...cmd.args);
|
||||
}
|
||||
|
||||
// Get the original CLI arguments to detect which options were explicitly specified
|
||||
const originalArgs = process.argv;
|
||||
|
||||
// Special handling for parent parameter which seems to have issues
|
||||
const parentArg = originalArgs.find(arg => arg.startsWith('--parent='));
|
||||
if (parentArg) {
|
||||
args.push('-p', parentArg.split('=')[1]);
|
||||
} else if (options.parent) {
|
||||
args.push('-p', options.parent);
|
||||
}
|
||||
|
||||
// Add all options
|
||||
Object.entries(options).forEach(([key, value]) => {
|
||||
// Skip the Command's built-in properties
|
||||
// Skip the Command's built-in properties and parent (special handling)
|
||||
if (['parent', 'commands', 'options', 'rawArgs'].includes(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Special case: handle the 'generate' option which is automatically set to true
|
||||
// We should only include it if --no-generate was explicitly specified
|
||||
if (key === 'generate') {
|
||||
// Check if --no-generate was explicitly specified
|
||||
if (originalArgs.includes('--no-generate')) {
|
||||
args.push('--no-generate');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Look for how this parameter was passed in the original arguments
|
||||
// Find if it was passed as --key=value
|
||||
const equalsFormat = originalArgs.find(arg => arg.startsWith(`--${key}=`));
|
||||
|
||||
// Check for kebab-case flags
|
||||
// Convert camelCase back to kebab-case for command line arguments
|
||||
const kebabKey = key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
||||
|
||||
// Check if it was passed with kebab-case
|
||||
const foundInOriginal = originalArgs.find(arg =>
|
||||
arg === `--${key}` ||
|
||||
arg === `--${kebabKey}` ||
|
||||
arg.startsWith(`--${key}=`) ||
|
||||
arg.startsWith(`--${kebabKey}=`)
|
||||
);
|
||||
|
||||
// Determine the actual flag name to use (original or kebab-case)
|
||||
const flagName = foundInOriginal ?
|
||||
(foundInOriginal.startsWith('--') ? foundInOriginal.split('=')[0].slice(2) : key) :
|
||||
key;
|
||||
|
||||
if (equalsFormat) {
|
||||
// Preserve the original format with equals sign
|
||||
args.push(equalsFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle boolean flags
|
||||
if (typeof value === 'boolean') {
|
||||
if (value === true) {
|
||||
args.push(`--${key}`);
|
||||
} else if (key.startsWith('no-')) {
|
||||
// Handle --no-X options
|
||||
const baseOption = key.substring(3);
|
||||
args.push(`--${baseOption}`);
|
||||
// For non-negated options, add the flag
|
||||
if (!flagName.startsWith('no-')) {
|
||||
args.push(`--${flagName}`);
|
||||
}
|
||||
} else {
|
||||
// For false values, use --no-X format
|
||||
if (flagName.startsWith('no-')) {
|
||||
// If option is already in --no-X format, it means the user used --no-X explicitly
|
||||
// We need to pass it as is
|
||||
args.push(`--${flagName}`);
|
||||
} else {
|
||||
// If it's a regular option set to false, convert to --no-X
|
||||
args.push(`--no-${flagName}`);
|
||||
}
|
||||
}
|
||||
} else if (value !== undefined) {
|
||||
args.push(`--${key}`, value.toString());
|
||||
// For non-boolean values, pass as --key value (space-separated)
|
||||
args.push(`--${flagName}`, value.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user