feat(mcp): Refactor initialize_project tool for direct execution
Refactors the initialize_project MCP tool to call a dedicated direct function (initializeProjectDirect) instead of executing the CLI command. This improves reliability and aligns it with other MCP tools. Key changes include: Modified initialize-project.js to call initializeProjectDirect, required projectRoot parameter, implemented handleApiResult for MCP response formatting, enhanced direct function to prioritize args.projectRoot over session-derived paths, added validation to prevent initialization in invalid directories, forces yes:true for non-interactive use, ensures process.chdir() targets validated directory, and added isSilentMode() checks to suppress console output during MCP operations. This resolves issues where the tool previously failed due to incorrect fallback directory resolution when session context was incomplete.
This commit is contained in:
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -4,30 +4,36 @@ about: Create a report to help us improve
|
||||
title: 'bug: '
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Description
|
||||
|
||||
Detailed description of the problem, including steps to reproduce the issue.
|
||||
|
||||
### Steps to Reproduce
|
||||
|
||||
1. Step-by-step instructions to reproduce the issue
|
||||
2. Include command examples or UI interactions
|
||||
|
||||
### Expected Behavior
|
||||
|
||||
Describe clearly what the expected outcome or behavior should be.
|
||||
|
||||
### Actual Behavior
|
||||
|
||||
Describe clearly what the actual outcome or behavior is.
|
||||
|
||||
### Screenshots or Logs
|
||||
|
||||
Provide screenshots, logs, or error messages if applicable.
|
||||
|
||||
### Environment
|
||||
|
||||
- Task Master version:
|
||||
- Node.js version:
|
||||
- Operating system:
|
||||
- IDE (if applicable):
|
||||
|
||||
### Additional Context
|
||||
|
||||
Any additional information or context that might help diagnose the issue.
|
||||
|
||||
@@ -4,30 +4,35 @@ about: Suggest an idea for this project
|
||||
title: 'feat: '
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
> "Direct quote or clear summary of user request or need or user story."
|
||||
|
||||
### Motivation
|
||||
|
||||
Detailed explanation of why this feature is important. Describe the problem it solves or the benefit it provides.
|
||||
|
||||
### Proposed Solution
|
||||
|
||||
Clearly describe the proposed feature, including:
|
||||
|
||||
- High-level overview of the feature
|
||||
- Relevant technologies or integrations
|
||||
- How it fits into the existing workflow or architecture
|
||||
|
||||
### High-Level Workflow
|
||||
|
||||
1. Step-by-step description of how the feature will be implemented
|
||||
2. Include necessary intermediate milestones
|
||||
|
||||
### Key Elements
|
||||
|
||||
- Bullet-point list of technical or UX/UI enhancements
|
||||
- Mention specific integrations or APIs
|
||||
- Highlight changes needed in existing data models or commands
|
||||
|
||||
### Example Workflow
|
||||
|
||||
Provide a clear, concrete example demonstrating the feature:
|
||||
|
||||
```shell
|
||||
@@ -36,9 +41,11 @@ $ task-master [action]
|
||||
```
|
||||
|
||||
### Implementation Considerations
|
||||
|
||||
- Dependencies on external components or APIs
|
||||
- Backward compatibility requirements
|
||||
- Potential performance impacts or resource usage
|
||||
|
||||
### Out of Scope (Future Considerations)
|
||||
|
||||
Clearly list any features or improvements not included but relevant for future iterations.
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/feedback.md
vendored
7
.github/ISSUE_TEMPLATE/feedback.md
vendored
@@ -4,23 +4,28 @@ about: Give us specific feedback on the product/approach/tech
|
||||
title: 'feedback: '
|
||||
labels: feedback
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Feedback Summary
|
||||
|
||||
Provide a clear summary or direct quote from user feedback.
|
||||
|
||||
### User Context
|
||||
|
||||
Explain the user's context or scenario in which this feedback was provided.
|
||||
|
||||
### User Impact
|
||||
|
||||
Describe how this feedback affects the user experience or workflow.
|
||||
|
||||
### Suggestions
|
||||
|
||||
Provide any initial thoughts, potential solutions, or improvements based on the feedback.
|
||||
|
||||
### Relevant Screenshots or Examples
|
||||
|
||||
Attach screenshots, logs, or examples that illustrate the feedback.
|
||||
|
||||
### Additional Notes
|
||||
|
||||
Any additional context or related information.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
#!/usr/bin/env node --trace-deprecation
|
||||
|
||||
/**
|
||||
* Task Master
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
import path from 'path';
|
||||
import { initializeProject, log as initLog } from '../../../../scripts/init.js'; // Import core function and its logger if needed separately
|
||||
import {
|
||||
enableSilentMode,
|
||||
disableSilentMode
|
||||
// isSilentMode // Not used directly here
|
||||
} from '../../../../scripts/modules/utils.js';
|
||||
import { getProjectRootFromSession } from '../../tools/utils.js'; // Adjust path if necessary
|
||||
import os from 'os'; // Import os module for home directory check
|
||||
|
||||
/**
|
||||
* Direct function wrapper for initializing a project.
|
||||
* Derives target directory from session, sets CWD, and calls core init logic.
|
||||
* @param {object} args - Arguments containing project details and options (projectName, projectDescription, yes, etc.)
|
||||
* @param {object} log - The FastMCP logger instance.
|
||||
* @param {object} context - The context object, must contain { session }.
|
||||
* @returns {Promise<{success: boolean, data?: any, error?: {code: string, message: string}}>} - Standard result object.
|
||||
*/
|
||||
export async function initializeProjectDirect(args, log, context = {}) {
|
||||
const { session } = context;
|
||||
const homeDir = os.homedir();
|
||||
let targetDirectory = null;
|
||||
|
||||
log.info(
|
||||
`CONTEXT received in direct function: ${context ? JSON.stringify(Object.keys(context)) : 'MISSING or Falsy'}`
|
||||
);
|
||||
log.info(
|
||||
`SESSION extracted in direct function: ${session ? 'Exists' : 'MISSING or Falsy'}`
|
||||
);
|
||||
log.info(`Args received in direct function: ${JSON.stringify(args)}`);
|
||||
|
||||
// --- Determine Target Directory ---
|
||||
// 1. Prioritize projectRoot passed directly in args
|
||||
// Ensure it's not null, '/', or the home directory
|
||||
if (
|
||||
args.projectRoot &&
|
||||
args.projectRoot !== '/' &&
|
||||
args.projectRoot !== homeDir
|
||||
) {
|
||||
log.info(`Using projectRoot directly from args: ${args.projectRoot}`);
|
||||
targetDirectory = args.projectRoot;
|
||||
} else {
|
||||
// 2. If args.projectRoot is missing or invalid, THEN try session (as a fallback)
|
||||
log.warn(
|
||||
`args.projectRoot ('${args.projectRoot}') is missing or invalid. Attempting to derive from session.`
|
||||
);
|
||||
const sessionDerivedPath = getProjectRootFromSession(session, log);
|
||||
// Validate the session-derived path as well
|
||||
if (
|
||||
sessionDerivedPath &&
|
||||
sessionDerivedPath !== '/' &&
|
||||
sessionDerivedPath !== homeDir
|
||||
) {
|
||||
log.info(
|
||||
`Using project root derived from session: ${sessionDerivedPath}`
|
||||
);
|
||||
targetDirectory = sessionDerivedPath;
|
||||
} else {
|
||||
log.error(
|
||||
`Could not determine a valid project root. args.projectRoot='${args.projectRoot}', sessionDerivedPath='${sessionDerivedPath}'`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Validate the final targetDirectory
|
||||
if (!targetDirectory) {
|
||||
// This error now covers cases where neither args.projectRoot nor session provided a valid path
|
||||
return {
|
||||
success: false,
|
||||
error: {
|
||||
code: 'INVALID_TARGET_DIRECTORY',
|
||||
message: `Cannot initialize project: Could not determine a valid target directory. Please ensure a workspace/folder is open or specify projectRoot.`,
|
||||
details: `Attempted args.projectRoot: ${args.projectRoot}`
|
||||
},
|
||||
fromCache: false
|
||||
};
|
||||
}
|
||||
|
||||
// --- Proceed with validated targetDirectory ---
|
||||
log.info(`Validated target directory for initialization: ${targetDirectory}`);
|
||||
|
||||
const originalCwd = process.cwd();
|
||||
let resultData;
|
||||
let success = false;
|
||||
let errorResult = null;
|
||||
|
||||
log.info(
|
||||
`Temporarily changing CWD to ${targetDirectory} for initialization.`
|
||||
);
|
||||
process.chdir(targetDirectory); // Change CWD to the *validated* targetDirectory
|
||||
|
||||
enableSilentMode(); // Enable silent mode BEFORE calling the core function
|
||||
try {
|
||||
// Always force yes: true when called via MCP to avoid interactive prompts
|
||||
const options = {
|
||||
name: args.projectName,
|
||||
description: args.projectDescription,
|
||||
version: args.projectVersion,
|
||||
author: args.authorName,
|
||||
skipInstall: args.skipInstall,
|
||||
aliases: args.addAliases,
|
||||
yes: true // Force yes mode
|
||||
};
|
||||
|
||||
log.info(`Initializing project with options: ${JSON.stringify(options)}`);
|
||||
const result = await initializeProject(options); // Call core logic
|
||||
|
||||
// Format success result for handleApiResult
|
||||
resultData = {
|
||||
message: 'Project initialized successfully.',
|
||||
next_step:
|
||||
'Now that the project is initialized, create a PRD file at scripts/prd.txt and use the parse-prd tool to generate initial tasks.',
|
||||
...result // Include details returned by initializeProject
|
||||
};
|
||||
success = true;
|
||||
log.info(
|
||||
`Project initialization completed successfully in ${targetDirectory}.`
|
||||
);
|
||||
} catch (error) {
|
||||
log.error(`Core initializeProject failed: ${error.message}`);
|
||||
errorResult = {
|
||||
code: 'INITIALIZATION_FAILED',
|
||||
message: `Core project initialization failed: ${error.message}`,
|
||||
details: error.stack
|
||||
};
|
||||
success = false;
|
||||
} finally {
|
||||
disableSilentMode(); // ALWAYS disable silent mode in finally
|
||||
log.info(`Restoring original CWD: ${originalCwd}`);
|
||||
process.chdir(originalCwd); // Change back to original CWD
|
||||
}
|
||||
|
||||
// Return in format expected by handleApiResult
|
||||
if (success) {
|
||||
return { success: true, data: resultData, fromCache: false };
|
||||
} else {
|
||||
return { success: false, error: errorResult, fromCache: false };
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import { fixDependenciesDirect } from './direct-functions/fix-dependencies.js';
|
||||
import { complexityReportDirect } from './direct-functions/complexity-report.js';
|
||||
import { addDependencyDirect } from './direct-functions/add-dependency.js';
|
||||
import { removeTaskDirect } from './direct-functions/remove-task.js';
|
||||
import { initializeProjectDirect } from './direct-functions/initialize-project-direct.js';
|
||||
|
||||
// Re-export utility functions
|
||||
export { findTasksJsonPath } from './utils/path-utils.js';
|
||||
@@ -92,5 +93,6 @@ export {
|
||||
fixDependenciesDirect,
|
||||
complexityReportDirect,
|
||||
addDependencyDirect,
|
||||
removeTaskDirect
|
||||
removeTaskDirect,
|
||||
initializeProjectDirect
|
||||
};
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { z } from 'zod';
|
||||
import { execSync } from 'child_process';
|
||||
import {
|
||||
createContentResponse,
|
||||
createErrorResponse,
|
||||
getProjectRootFromSession
|
||||
handleApiResult
|
||||
} from './utils.js';
|
||||
import { initializeProjectDirect } from '../core/task-master-core.js';
|
||||
|
||||
export function registerInitializeProjectTool(server) {
|
||||
server.addTool({
|
||||
name: 'initialize_project',
|
||||
description:
|
||||
"Initializes a new Task Master project structure in the specified project directory by running 'task-master init'. If the project information required for the initialization is not available or provided by the user, prompt if the user wishes to provide them (name, description, author) or skip them. If the user wishes to skip, set the 'yes' flag to true and do not set any other parameters. DO NOT run the initialize_project tool without parameters.",
|
||||
"Initializes a new Task Master project structure by calling the core initialization logic. Derives target directory from client session. If project details (name, description, author) are not provided, prompts the user or skips if 'yes' flag is true. DO NOT run without parameters.",
|
||||
parameters: z.object({
|
||||
projectName: z
|
||||
.string()
|
||||
@@ -59,93 +59,35 @@ export function registerInitializeProjectTool(server) {
|
||||
),
|
||||
projectRoot: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
'Optional fallback project root if session data is unavailable. Setting a value is not needed unless you are running the tool from a different directory than the project root.'
|
||||
'The root directory for the project. ALWAYS SET THIS TO THE PROJECT ROOT DIRECTORY. IF NOT SET, THE TOOL WILL NOT WORK.'
|
||||
)
|
||||
}),
|
||||
execute: async (args, { log, session }) => {
|
||||
execute: async (args, context) => {
|
||||
const { log } = context;
|
||||
const session = context.session;
|
||||
|
||||
log.info(
|
||||
'>>> Full Context Received by Tool:',
|
||||
JSON.stringify(context, null, 2)
|
||||
);
|
||||
log.info(`Context received in tool function: ${context}`);
|
||||
log.info(
|
||||
`Session received in tool function: ${session ? session : 'undefined'}`
|
||||
);
|
||||
|
||||
try {
|
||||
log.info(
|
||||
`Executing initialize_project with args: ${JSON.stringify(args)}`
|
||||
`Executing initialize_project tool with args: ${JSON.stringify(args)}`
|
||||
);
|
||||
|
||||
let targetDirectory = getProjectRootFromSession(session, log);
|
||||
if (!targetDirectory) {
|
||||
if (args.projectRoot) {
|
||||
targetDirectory = args.projectRoot;
|
||||
log.warn(
|
||||
`Using projectRoot argument as fallback: ${targetDirectory}`
|
||||
);
|
||||
} else {
|
||||
log.error(
|
||||
'Could not determine target directory for initialization from session or arguments.'
|
||||
);
|
||||
return createErrorResponse(
|
||||
'Failed to determine target directory for initialization.'
|
||||
);
|
||||
}
|
||||
}
|
||||
log.info(`Target directory for initialization: ${targetDirectory}`);
|
||||
const result = await initializeProjectDirect(args, log, { session });
|
||||
|
||||
let commandBase = 'npx task-master init';
|
||||
const cliArgs = [];
|
||||
if (args.projectName)
|
||||
cliArgs.push(`--name "${args.projectName.replace(/"/g, '\\"')}"`);
|
||||
if (args.projectDescription)
|
||||
cliArgs.push(
|
||||
`--description "${args.projectDescription.replace(/"/g, '\\"')}"`
|
||||
);
|
||||
if (args.projectVersion)
|
||||
cliArgs.push(
|
||||
`--version "${args.projectVersion.replace(/"/g, '\\"')}"`
|
||||
);
|
||||
if (args.authorName)
|
||||
cliArgs.push(`--author "${args.authorName.replace(/"/g, '\\"')}"`);
|
||||
if (args.skipInstall) cliArgs.push('--skip-install');
|
||||
if (args.addAliases) cliArgs.push('--aliases');
|
||||
|
||||
log.debug(
|
||||
`Value of args.yes before check: ${args.yes} (Type: ${typeof args.yes})`
|
||||
);
|
||||
if (args.yes === true) {
|
||||
cliArgs.push('--yes');
|
||||
log.info('Added --yes flag to cliArgs.');
|
||||
} else {
|
||||
log.info(`Did NOT add --yes flag. args.yes value: ${args.yes}`);
|
||||
}
|
||||
|
||||
const command =
|
||||
cliArgs.length > 0
|
||||
? `${commandBase} ${cliArgs.join(' ')}`
|
||||
: commandBase;
|
||||
|
||||
log.info(`FINAL Constructed command for execSync: ${command}`);
|
||||
|
||||
const output = execSync(command, {
|
||||
encoding: 'utf8',
|
||||
stdio: 'pipe',
|
||||
timeout: 300000,
|
||||
cwd: targetDirectory
|
||||
});
|
||||
|
||||
log.info(`Initialization output:\n${output}`);
|
||||
|
||||
return createContentResponse({
|
||||
message: `Taskmaster successfully initialized in ${targetDirectory}.`,
|
||||
next_step:
|
||||
'Now that the project is initialized, the next step is to create the tasks by parsing a PRD. This will create the tasks folder and the initial task files. The parse-prd tool will required a prd.txt file as input in scripts/prd.txt. You can create a prd.txt file by asking the user about their idea, and then using the scripts/example_prd.txt file as a template to genrate a prd.txt file in scripts/. Before creating the PRD for the user, make sure you understand the idea fully and ask questions to eliminate ambiguity. You can then use the parse-prd tool to create the tasks. So: step 1 after initialization is to create a prd.txt file in scripts/prd.txt. Step 2 is to use the parse-prd tool to create the tasks. Do not bother looking for tasks after initialization, just use the parse-prd tool to create the tasks after creating a prd.txt from which to parse the tasks. ',
|
||||
output: output
|
||||
});
|
||||
return handleApiResult(result, log, 'Initialization failed');
|
||||
} catch (error) {
|
||||
const errorMessage = `Project initialization failed: ${
|
||||
error.message || 'Unknown error'
|
||||
}`;
|
||||
const errorDetails =
|
||||
error.stderr?.toString() || error.stdout?.toString() || error.message;
|
||||
log.error(`${errorMessage}\nDetails: ${errorDetails}`);
|
||||
|
||||
return createErrorResponse(errorMessage, { details: errorDetails });
|
||||
const errorMessage = `Project initialization tool failed: ${error.message || 'Unknown error'}`;
|
||||
log.error(errorMessage, error);
|
||||
return createErrorResponse(errorMessage, { details: error.stack });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
16113
package-lock.json
generated
16113
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
304
scripts/init.js
304
scripts/init.js
@@ -13,8 +13,6 @@
|
||||
* For the full license text, see the LICENSE file in the root directory.
|
||||
*/
|
||||
|
||||
console.log('Starting task-master-ai...');
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
@@ -25,11 +23,23 @@ import chalk from 'chalk';
|
||||
import figlet from 'figlet';
|
||||
import boxen from 'boxen';
|
||||
import gradient from 'gradient-string';
|
||||
import {
|
||||
isSilentMode,
|
||||
enableSilentMode,
|
||||
disableSilentMode
|
||||
} from './modules/utils.js';
|
||||
|
||||
// Debug information
|
||||
console.log('Node version:', process.version);
|
||||
console.log('Current directory:', process.cwd());
|
||||
console.log('Script path:', import.meta.url);
|
||||
// Only log if not in silent mode
|
||||
if (!isSilentMode()) {
|
||||
console.log('Starting task-master-ai...');
|
||||
}
|
||||
|
||||
// Debug information - only log if not in silent mode
|
||||
if (!isSilentMode()) {
|
||||
console.log('Node version:', process.version);
|
||||
console.log('Current directory:', process.cwd());
|
||||
console.log('Script path:', import.meta.url);
|
||||
}
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
@@ -54,6 +64,8 @@ const warmGradient = gradient(['#fb8b24', '#e36414', '#9a031e']);
|
||||
|
||||
// Display a fancy banner
|
||||
function displayBanner() {
|
||||
if (isSilentMode()) return;
|
||||
|
||||
console.clear();
|
||||
const bannerText = figlet.textSync('Task Master AI', {
|
||||
font: 'Standard',
|
||||
@@ -91,16 +103,19 @@ function log(level, ...args) {
|
||||
if (LOG_LEVELS[level] >= LOG_LEVEL) {
|
||||
const icon = icons[level] || '';
|
||||
|
||||
if (level === 'error') {
|
||||
console.error(icon, chalk.red(...args));
|
||||
} else if (level === 'warn') {
|
||||
console.warn(icon, chalk.yellow(...args));
|
||||
} else if (level === 'success') {
|
||||
console.log(icon, chalk.green(...args));
|
||||
} else if (level === 'info') {
|
||||
console.log(icon, chalk.blue(...args));
|
||||
} else {
|
||||
console.log(icon, ...args);
|
||||
// Only output to console if not in silent mode
|
||||
if (!isSilentMode()) {
|
||||
if (level === 'error') {
|
||||
console.error(icon, chalk.red(...args));
|
||||
} else if (level === 'warn') {
|
||||
console.warn(icon, chalk.yellow(...args));
|
||||
} else if (level === 'success') {
|
||||
console.log(icon, chalk.green(...args));
|
||||
} else if (level === 'info') {
|
||||
console.log(icon, chalk.blue(...args));
|
||||
} else {
|
||||
console.log(icon, ...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,25 +396,37 @@ function copyTemplateFile(templateName, targetPath, replacements = {}) {
|
||||
}
|
||||
|
||||
// Main function to initialize a new project (Now relies solely on passed options)
|
||||
async function initializeProject(options = {}) { // Receives options as argument
|
||||
displayBanner();
|
||||
async function initializeProject(options = {}) {
|
||||
// Receives options as argument
|
||||
// Only display banner if not in silent mode
|
||||
if (!isSilentMode()) {
|
||||
displayBanner();
|
||||
}
|
||||
|
||||
console.log('===== DEBUG: INITIALIZE PROJECT OPTIONS RECEIVED =====');
|
||||
console.log('Full options object:', JSON.stringify(options));
|
||||
console.log('options.yes:', options.yes);
|
||||
console.log('options.name:', options.name);
|
||||
console.log('==================================================');
|
||||
// Debug logging only if not in silent mode
|
||||
if (!isSilentMode()) {
|
||||
console.log('===== DEBUG: INITIALIZE PROJECT OPTIONS RECEIVED =====');
|
||||
console.log('Full options object:', JSON.stringify(options));
|
||||
console.log('options.yes:', options.yes);
|
||||
console.log('options.name:', options.name);
|
||||
console.log('==================================================');
|
||||
}
|
||||
|
||||
// Determine if we should skip prompts based on the passed options
|
||||
const skipPrompts = options.yes || (options.name && options.description);
|
||||
console.log('Skip prompts determined:', skipPrompts);
|
||||
if (!isSilentMode()) {
|
||||
console.log('Skip prompts determined:', skipPrompts);
|
||||
}
|
||||
|
||||
if (skipPrompts) {
|
||||
console.log('SKIPPING PROMPTS - Using defaults or provided values');
|
||||
if (!isSilentMode()) {
|
||||
console.log('SKIPPING PROMPTS - Using defaults or provided values');
|
||||
}
|
||||
|
||||
// Use provided options or defaults
|
||||
const projectName = options.name || 'task-master-project';
|
||||
const projectDescription = options.description || 'A project managed with Task Master AI';
|
||||
const projectDescription =
|
||||
options.description || 'A project managed with Task Master AI';
|
||||
const projectVersion = options.version || '0.1.0'; // Default from commands.js or here
|
||||
const authorName = options.author || 'Vibe coder'; // Default if not provided
|
||||
const dryRun = options.dryRun || false;
|
||||
@@ -408,7 +435,10 @@ async function initializeProject(options = {}) { // Receives options as argument
|
||||
|
||||
if (dryRun) {
|
||||
log('info', 'DRY RUN MODE: No files will be modified');
|
||||
log('info', `Would initialize project: ${projectName} (${projectVersion})`);
|
||||
log(
|
||||
'info',
|
||||
`Would initialize project: ${projectName} (${projectVersion})`
|
||||
);
|
||||
log('info', `Description: ${projectDescription}`);
|
||||
log('info', `Author: ${authorName || 'Not specified'}`);
|
||||
log('info', 'Would create/update necessary project files');
|
||||
@@ -446,13 +476,30 @@ async function initializeProject(options = {}) { // Receives options as argument
|
||||
|
||||
try {
|
||||
// Prompt user for input...
|
||||
const projectName = await promptQuestion(rl, chalk.cyan('Enter project name: '));
|
||||
const projectDescription = await promptQuestion(rl, chalk.cyan('Enter project description: '));
|
||||
const projectVersionInput = await promptQuestion(rl, chalk.cyan('Enter project version (default: 1.0.0): ')); // Use a default for prompt
|
||||
const authorName = await promptQuestion(rl, chalk.cyan('Enter your name: '));
|
||||
const addAliasesInput = await promptQuestion(rl, chalk.cyan('Add shell aliases for task-master? (Y/n): '));
|
||||
const projectName = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter project name: ')
|
||||
);
|
||||
const projectDescription = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter project description: ')
|
||||
);
|
||||
const projectVersionInput = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter project version (default: 1.0.0): ')
|
||||
); // Use a default for prompt
|
||||
const authorName = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Enter your name: ')
|
||||
);
|
||||
const addAliasesInput = await promptQuestion(
|
||||
rl,
|
||||
chalk.cyan('Add shell aliases for task-master? (Y/n): ')
|
||||
);
|
||||
const addAliasesPrompted = addAliasesInput.trim().toLowerCase() !== 'n';
|
||||
const projectVersion = projectVersionInput.trim() ? projectVersionInput : '1.0.0';
|
||||
const projectVersion = projectVersionInput.trim()
|
||||
? projectVersionInput
|
||||
: '1.0.0';
|
||||
|
||||
// Confirm settings...
|
||||
console.log('\nProject settings:');
|
||||
@@ -464,11 +511,16 @@ async function initializeProject(options = {}) { // Receives options as argument
|
||||
chalk.white(authorName || 'Not specified')
|
||||
);
|
||||
console.log(
|
||||
chalk.blue('Add shell aliases (so you can use "tm" instead of "task-master"):'),
|
||||
chalk.blue(
|
||||
'Add shell aliases (so you can use "tm" instead of "task-master"):'
|
||||
),
|
||||
chalk.white(addAliasesPrompted ? 'Yes' : 'No')
|
||||
);
|
||||
|
||||
const confirmInput = await promptQuestion(rl, chalk.yellow('\nDo you want to continue with these settings? (Y/n): '));
|
||||
const confirmInput = await promptQuestion(
|
||||
rl,
|
||||
chalk.yellow('\nDo you want to continue with these settings? (Y/n): ')
|
||||
);
|
||||
const shouldContinue = confirmInput.trim().toLowerCase() !== 'n';
|
||||
rl.close();
|
||||
|
||||
@@ -484,7 +536,10 @@ async function initializeProject(options = {}) { // Receives options as argument
|
||||
|
||||
if (dryRun) {
|
||||
log('info', 'DRY RUN MODE: No files will be modified');
|
||||
log('info', `Would initialize project: ${projectName} (${projectVersion})`);
|
||||
log(
|
||||
'info',
|
||||
`Would initialize project: ${projectName} (${projectVersion})`
|
||||
);
|
||||
log('info', `Description: ${projectDescription}`);
|
||||
log('info', `Author: ${authorName || 'Not specified'}`);
|
||||
log('info', 'Would create/update necessary project files');
|
||||
@@ -512,7 +567,6 @@ async function initializeProject(options = {}) { // Receives options as argument
|
||||
skipInstall, // Use value from initial options
|
||||
addAliasesPrompted // Use value from prompt
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
rl.close();
|
||||
log('error', `Error during prompting: ${error.message}`); // Use log function
|
||||
@@ -727,14 +781,16 @@ function createProjectStructure(
|
||||
}
|
||||
|
||||
// Run npm install automatically
|
||||
console.log(
|
||||
boxen(chalk.cyan('Installing dependencies...'), {
|
||||
padding: 0.5,
|
||||
margin: 0.5,
|
||||
borderStyle: 'round',
|
||||
borderColor: 'blue'
|
||||
})
|
||||
);
|
||||
if (!isSilentMode()) {
|
||||
console.log(
|
||||
boxen(chalk.cyan('Installing dependencies...'), {
|
||||
padding: 0.5,
|
||||
margin: 0.5,
|
||||
borderStyle: 'round',
|
||||
borderColor: 'blue'
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!skipInstall) {
|
||||
@@ -749,21 +805,23 @@ function createProjectStructure(
|
||||
}
|
||||
|
||||
// Display success message
|
||||
console.log(
|
||||
boxen(
|
||||
warmGradient.multiline(
|
||||
figlet.textSync('Success!', { font: 'Standard' })
|
||||
) +
|
||||
'\n' +
|
||||
chalk.green('Project initialized successfully!'),
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
borderStyle: 'double',
|
||||
borderColor: 'green'
|
||||
}
|
||||
)
|
||||
);
|
||||
if (!isSilentMode()) {
|
||||
console.log(
|
||||
boxen(
|
||||
warmGradient.multiline(
|
||||
figlet.textSync('Success!', { font: 'Standard' })
|
||||
) +
|
||||
'\n' +
|
||||
chalk.green('Project initialized successfully!'),
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
borderStyle: 'double',
|
||||
borderColor: 'green'
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Add shell aliases if requested
|
||||
if (addAliases) {
|
||||
@@ -771,68 +829,70 @@ function createProjectStructure(
|
||||
}
|
||||
|
||||
// Display next steps in a nice box
|
||||
console.log(
|
||||
boxen(
|
||||
chalk.cyan.bold('Things you can now do:') +
|
||||
'\n\n' +
|
||||
chalk.white('1. ') +
|
||||
chalk.yellow(
|
||||
'Rename .env.example to .env and add your ANTHROPIC_API_KEY and PERPLEXITY_API_KEY'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('2. ') +
|
||||
chalk.yellow(
|
||||
'Discuss your idea with AI, and once ready ask for a PRD using the example_prd.txt file, and save what you get to scripts/PRD.txt'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('3. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor Agent to parse your PRD.txt and generate tasks'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white(' └─ ') +
|
||||
chalk.dim('You can also run ') +
|
||||
chalk.cyan('task-master parse-prd <your-prd-file.txt>') +
|
||||
'\n' +
|
||||
chalk.white('4. ') +
|
||||
chalk.yellow('Ask Cursor to analyze the complexity of your tasks') +
|
||||
'\n' +
|
||||
chalk.white('5. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor which task is next to determine where to start'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('6. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to expand any complex tasks that are too large or complex.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('7. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to set the status of a task, or multiple tasks. Use the task id from the task lists.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('8. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to update all tasks from a specific task id based on new learnings or pivots in your project.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('9. ') +
|
||||
chalk.green.bold('Ship it!') +
|
||||
'\n\n' +
|
||||
chalk.dim(
|
||||
'* Review the README.md file to learn how to use other commands via Cursor Agent.'
|
||||
),
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
borderStyle: 'round',
|
||||
borderColor: 'yellow',
|
||||
title: 'Getting Started',
|
||||
titleAlignment: 'center'
|
||||
}
|
||||
)
|
||||
);
|
||||
if (!isSilentMode()) {
|
||||
console.log(
|
||||
boxen(
|
||||
chalk.cyan.bold('Things you can now do:') +
|
||||
'\n\n' +
|
||||
chalk.white('1. ') +
|
||||
chalk.yellow(
|
||||
'Rename .env.example to .env and add your ANTHROPIC_API_KEY and PERPLEXITY_API_KEY'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('2. ') +
|
||||
chalk.yellow(
|
||||
'Discuss your idea with AI, and once ready ask for a PRD using the example_prd.txt file, and save what you get to scripts/PRD.txt'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('3. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor Agent to parse your PRD.txt and generate tasks'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white(' └─ ') +
|
||||
chalk.dim('You can also run ') +
|
||||
chalk.cyan('task-master parse-prd <your-prd-file.txt>') +
|
||||
'\n' +
|
||||
chalk.white('4. ') +
|
||||
chalk.yellow('Ask Cursor to analyze the complexity of your tasks') +
|
||||
'\n' +
|
||||
chalk.white('5. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor which task is next to determine where to start'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('6. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to expand any complex tasks that are too large or complex.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('7. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to set the status of a task, or multiple tasks. Use the task id from the task lists.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('8. ') +
|
||||
chalk.yellow(
|
||||
'Ask Cursor to update all tasks from a specific task id based on new learnings or pivots in your project.'
|
||||
) +
|
||||
'\n' +
|
||||
chalk.white('9. ') +
|
||||
chalk.green.bold('Ship it!') +
|
||||
'\n\n' +
|
||||
chalk.dim(
|
||||
'* Review the README.md file to learn how to use other commands via Cursor Agent.'
|
||||
),
|
||||
{
|
||||
padding: 1,
|
||||
margin: 1,
|
||||
borderStyle: 'round',
|
||||
borderColor: 'yellow',
|
||||
title: 'Getting Started',
|
||||
titleAlignment: 'center'
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to setup MCP configuration for Cursor integration
|
||||
|
||||
39
tasks/task_060.txt
Normal file
39
tasks/task_060.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
# Task ID: 60
|
||||
# Title: Implement isValidTaskId Utility Function
|
||||
# Status: pending
|
||||
# Dependencies: None
|
||||
# Priority: medium
|
||||
# Description: Create a utility function that validates whether a given string conforms to the project's task ID format specification.
|
||||
# Details:
|
||||
Develop a function named `isValidTaskId` that takes a string parameter and returns a boolean indicating whether the string matches our task ID format. The task ID format follows these rules:
|
||||
|
||||
1. Must start with 'TASK-' prefix (case-sensitive)
|
||||
2. Followed by a numeric value (at least 1 digit)
|
||||
3. The numeric portion should not have leading zeros (unless it's just zero)
|
||||
4. The total length should be between 6 and 12 characters inclusive
|
||||
|
||||
Example valid IDs: 'TASK-1', 'TASK-42', 'TASK-1000'
|
||||
Example invalid IDs: 'task-1' (wrong case), 'TASK-' (missing number), 'TASK-01' (leading zero), 'TASK-A1' (non-numeric), 'TSK-1' (wrong prefix)
|
||||
|
||||
The function should be placed in the utilities directory and properly exported. Include JSDoc comments for clear documentation of parameters and return values.
|
||||
|
||||
# Test Strategy:
|
||||
Testing should include the following cases:
|
||||
|
||||
1. Valid task IDs:
|
||||
- 'TASK-1'
|
||||
- 'TASK-123'
|
||||
- 'TASK-9999'
|
||||
|
||||
2. Invalid task IDs:
|
||||
- Null or undefined input
|
||||
- Empty string
|
||||
- 'task-1' (lowercase prefix)
|
||||
- 'TASK-' (missing number)
|
||||
- 'TASK-01' (leading zero)
|
||||
- 'TASK-ABC' (non-numeric suffix)
|
||||
- 'TSK-1' (incorrect prefix)
|
||||
- 'TASK-12345678901' (too long)
|
||||
- 'TASK1' (missing hyphen)
|
||||
|
||||
Implement unit tests using the project's testing framework. Each test case should have a clear assertion message explaining why the test failed if it does. Also include edge cases such as strings with whitespace ('TASK- 1') or special characters ('TASK-1#').
|
||||
@@ -2726,6 +2726,16 @@
|
||||
"priority": "medium",
|
||||
"details": "Currently, the application is attempting to manually modify users' package.json files, which is not the recommended approach for npm packages. Instead:\n\n1. Review all code that directly manipulates package.json files in users' projects\n2. Remove these manual modifications\n3. Properly define all dependencies in the package.json of task-master-ai itself\n4. Ensure all peer dependencies are correctly specified\n5. For any scripts that need to be available to users, use proper npm bin linking or npx commands\n6. Update the installation process to leverage npm's built-in dependency management\n7. If configuration is needed in users' projects, implement a proper initialization command that creates config files rather than modifying package.json\n8. Document the new approach in the README and any other relevant documentation\n\nThis change will make the package more reliable, follow npm best practices, and prevent potential conflicts or errors when modifying users' project files.",
|
||||
"testStrategy": "1. Create a fresh test project directory\n2. Install the updated task-master-ai package using npm install task-master-ai\n3. Verify that no code attempts to modify the test project's package.json\n4. Confirm all dependencies are properly installed in node_modules\n5. Test all commands to ensure they work without the previous manual package.json modifications\n6. Try installing in projects with various existing configurations to ensure no conflicts occur\n7. Test the uninstall process to verify it cleanly removes the package without leaving unwanted modifications\n8. Verify the package works in different npm environments (npm 6, 7, 8) and with different Node.js versions\n9. Create an integration test that simulates a real user workflow from installation through usage"
|
||||
},
|
||||
{
|
||||
"id": 60,
|
||||
"title": "Implement isValidTaskId Utility Function",
|
||||
"description": "Create a utility function that validates whether a given string conforms to the project's task ID format specification.",
|
||||
"details": "Develop a function named `isValidTaskId` that takes a string parameter and returns a boolean indicating whether the string matches our task ID format. The task ID format follows these rules:\n\n1. Must start with 'TASK-' prefix (case-sensitive)\n2. Followed by a numeric value (at least 1 digit)\n3. The numeric portion should not have leading zeros (unless it's just zero)\n4. The total length should be between 6 and 12 characters inclusive\n\nExample valid IDs: 'TASK-1', 'TASK-42', 'TASK-1000'\nExample invalid IDs: 'task-1' (wrong case), 'TASK-' (missing number), 'TASK-01' (leading zero), 'TASK-A1' (non-numeric), 'TSK-1' (wrong prefix)\n\nThe function should be placed in the utilities directory and properly exported. Include JSDoc comments for clear documentation of parameters and return values.",
|
||||
"testStrategy": "Testing should include the following cases:\n\n1. Valid task IDs:\n - 'TASK-1'\n - 'TASK-123'\n - 'TASK-9999'\n\n2. Invalid task IDs:\n - Null or undefined input\n - Empty string\n - 'task-1' (lowercase prefix)\n - 'TASK-' (missing number)\n - 'TASK-01' (leading zero)\n - 'TASK-ABC' (non-numeric suffix)\n - 'TSK-1' (incorrect prefix)\n - 'TASK-12345678901' (too long)\n - 'TASK1' (missing hyphen)\n\nImplement unit tests using the project's testing framework. Each test case should have a clear assertion message explaining why the test failed if it does. Also include edge cases such as strings with whitespace ('TASK- 1') or special characters ('TASK-1#').",
|
||||
"status": "pending",
|
||||
"dependencies": [],
|
||||
"priority": "medium"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"dependencies": [],
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
"tasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"dependencies": [],
|
||||
"subtasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user