feat: automatically create tasks.json when missing (Task #68)

This commit implements automatic tasks.json file creation when it doesn't exist:

- When tasks.json is missing or invalid, create a new one with { tasks: [] }
- Allows adding tasks immediately after initializing a project without parsing a PRD
- Replaces error with informative feedback about file creation
- Enables smoother workflow for new projects or directories

This change improves user experience by removing the requirement to parse a PRD
before adding the first task to a newly initialized project. Closes #494
This commit is contained in:
Eyal Toledano
2025-05-22 01:18:27 -04:00
parent 5e9bc28abe
commit 34df2c8bbd
6 changed files with 34 additions and 70 deletions

View File

@@ -0,0 +1,5 @@
---
'task-master-ai': patch
---
You can now add tasks to a newly initialized project without having to parse a prd. This will automatically create the missing tasks.json file and create the first task. Lets you vibe if you want to vibe."

View File

@@ -146,10 +146,18 @@ async function addTask(
try {
// Read the existing tasks
const data = readJSON(tasksPath);
let data = readJSON(tasksPath);
// If tasks.json doesn't exist or is invalid, create a new one
if (!data || !data.tasks) {
report('Invalid or missing tasks.json.', 'error');
throw new Error('Invalid or missing tasks.json.');
report('tasks.json not found or invalid. Creating a new one.', 'info');
// Create default tasks data structure
data = {
tasks: []
};
// Ensure the directory exists and write the new file
writeJSON(tasksPath, data);
report('Created new tasks.json file with empty tasks array.', 'info');
}
// Find the highest task ID to determine the next ID

View File

@@ -1,6 +1,6 @@
# Task ID: 68
# Title: Ability to create tasks without parsing PRD
# Status: pending
# Status: done
# Dependencies: None
# Priority: medium
# Description: Which just means that when we create a task, if there's no tasks.json, we should create it calling the same function that is done by parse-prd. this lets taskmaster be used without a prd as a starding point.
@@ -11,13 +11,13 @@
# Subtasks:
## 1. Design task creation form without PRD [pending]
## 1. Design task creation form without PRD [done]
### Dependencies: None
### Description: Create a user interface form that allows users to manually input task details without requiring a PRD document
### Details:
Design a form with fields for task title, description, priority, assignee, due date, and other relevant task attributes. Include validation to ensure required fields are completed. The form should be intuitive and provide clear guidance on how to create a task manually.
## 2. Implement task saving functionality [pending]
## 2. Implement task saving functionality [done]
### Dependencies: 68.1
### Description: Develop the backend functionality to save manually created tasks to the database
### Details:

View File

@@ -1,6 +1,6 @@
# Task ID: 88
# Title: Enhance Add-Task Functionality to Consider All Task Dependencies
# Status: pending
# Status: done
# Dependencies: None
# Priority: medium
# Description: Improve the add-task feature to accurately account for all dependencies among tasks, ensuring proper task ordering and execution.
@@ -25,31 +25,31 @@
7. Execute automated tests to verify no regressions in existing functionality.
# Subtasks:
## 1. Review Current Add-Task Implementation and Identify Dependency Mechanisms [pending]
## 1. Review Current Add-Task Implementation and Identify Dependency Mechanisms [done]
### Dependencies: None
### Description: Examine the existing add-task functionality to understand how task dependencies are currently handled.
### Details:
Conduct a code review of the add-task feature. Document any existing mechanisms for handling task dependencies.
## 2. Modify Add-Task to Recursively Analyze Dependencies [pending]
## 2. Modify Add-Task to Recursively Analyze Dependencies [done]
### Dependencies: 88.1
### Description: Update the add-task functionality to recursively analyze and incorporate all task dependencies.
### Details:
Implement a recursive algorithm that identifies and incorporates all dependencies for a given task. Ensure it handles nested dependencies correctly.
## 3. Ensure Correct Order of Dependency Resolution [pending]
## 3. Ensure Correct Order of Dependency Resolution [done]
### Dependencies: 88.2
### Description: Modify the add-task functionality to ensure that dependencies are resolved in the correct order during task execution.
### Details:
Implement logic to sort and execute tasks based on their dependency order. Handle cases where multiple tasks depend on each other.
## 4. Integrate with Existing Validation and Error Handling [pending]
## 4. Integrate with Existing Validation and Error Handling [done]
### Dependencies: 88.3
### Description: Update the add-task functionality to integrate with existing validation and error handling mechanisms (from Task 87).
### Details:
Modify the code to provide clear feedback if dependencies cannot be resolved. Ensure that circular dependencies are detected and handled appropriately.
## 5. Optimize Performance for Large Projects [pending]
## 5. Optimize Performance for Large Projects [done]
### Dependencies: 88.4
### Description: Optimize the add-task functionality to ensure efficient dependency resolution, especially for projects with a large number of tasks.
### Details:

View File

@@ -1,32 +0,0 @@
# Task ID: 92
# Title: Implement Scheduling System for Periodic Task Execution
# Status: pending
# Dependencies: 1, 3, 11, 17, 19
# Priority: medium
# Description: Develop a system that allows tasks to be scheduled with custom time intervals and timezone configuration, enabling periodic execution of tasks at specified times.
# Details:
1. Design the scheduling system architecture to support:
- Custom time intervals (e.g., every X minutes/hours/days)
- Timezone configuration
- Task prioritization in scheduling
2. Implement the core scheduling functionality:
- Create a scheduler service that manages scheduled tasks
- Develop task execution logic based on schedules
- Integrate with existing task management system (Task 3)
3. Add user interface for scheduling tasks:
- Create command-line options for setting up scheduled tasks
- Implement configuration validation and error handling (Task 19)
4. Ensure proper logging of scheduled tasks and their execution (Task 17)
5. Handle timezone conversions accurately
6. Implement batch scheduling operations (Task 11)
7. Add support for recurring tasks with complex schedules (e.g., cron-like syntax)
8. Integrate with the existing task data structure (Task 1)
# Test Strategy:
1. Verify that tasks can be scheduled with various time intervals and timezone configurations
2. Test scheduling edge cases (e.g., overlapping schedules, different timezones)
3. Check proper execution of scheduled tasks at specified times
4. Validate logging of scheduled task executions
5. Ensure error handling works correctly for invalid schedule configurations
6. Test batch scheduling operations
7. Verify timezone conversion accuracy

View File

@@ -4517,7 +4517,7 @@
"description": "Which just means that when we create a task, if there's no tasks.json, we should create it calling the same function that is done by parse-prd. this lets taskmaster be used without a prd as a starding point.",
"details": "",
"testStrategy": "",
"status": "pending",
"status": "done",
"dependencies": [],
"priority": "medium",
"subtasks": [
@@ -4527,7 +4527,7 @@
"description": "Create a user interface form that allows users to manually input task details without requiring a PRD document",
"dependencies": [],
"details": "Design a form with fields for task title, description, priority, assignee, due date, and other relevant task attributes. Include validation to ensure required fields are completed. The form should be intuitive and provide clear guidance on how to create a task manually.",
"status": "pending"
"status": "done"
},
{
"id": 2,
@@ -4537,7 +4537,7 @@
1
],
"details": "Create API endpoints to handle task creation requests from the frontend. Implement data validation, error handling, and confirmation messages. Ensure the saved tasks appear in the task list view and can be edited or deleted like PRD-parsed tasks.",
"status": "pending"
"status": "done"
}
]
},
@@ -5244,7 +5244,7 @@
"description": "Improve the add-task feature to accurately account for all dependencies among tasks, ensuring proper task ordering and execution.",
"details": "1. Review current implementation of add-task functionality.\n2. Identify existing mechanisms for handling task dependencies.\n3. Modify add-task to recursively analyze and incorporate all dependencies.\n4. Ensure that dependencies are resolved in the correct order during task execution.\n5. Update documentation to reflect changes in dependency handling.\n6. Consider edge cases such as circular dependencies and handle them appropriately.\n7. Optimize performance to ensure efficient dependency resolution, especially for projects with a large number of tasks.\n8. Integrate with existing validation and error handling mechanisms (from Task 87) to provide clear feedback if dependencies cannot be resolved.\n9. Test thoroughly with various dependency scenarios to ensure robustness.",
"testStrategy": "1. Create test cases with simple linear dependencies to verify correct ordering.\n2. Develop test cases with complex, nested dependencies to ensure recursive resolution works correctly.\n3. Include tests for edge cases such as circular dependencies, verifying appropriate error messages are displayed.\n4. Measure performance with large sets of tasks and dependencies to ensure efficiency.\n5. Conduct integration testing with other components that rely on task dependencies.\n6. Perform manual code reviews to validate implementation against requirements.\n7. Execute automated tests to verify no regressions in existing functionality.",
"status": "pending",
"status": "done",
"dependencies": [],
"priority": "medium",
"subtasks": [
@@ -5254,7 +5254,7 @@
"description": "Examine the existing add-task functionality to understand how task dependencies are currently handled.",
"dependencies": [],
"details": "Conduct a code review of the add-task feature. Document any existing mechanisms for handling task dependencies.",
"status": "pending",
"status": "done",
"testStrategy": "Verify that all current dependency handling features work as expected."
},
{
@@ -5265,7 +5265,7 @@
1
],
"details": "Implement a recursive algorithm that identifies and incorporates all dependencies for a given task. Ensure it handles nested dependencies correctly.",
"status": "pending",
"status": "done",
"testStrategy": "Test with various dependency scenarios, including nested dependencies."
},
{
@@ -5276,7 +5276,7 @@
2
],
"details": "Implement logic to sort and execute tasks based on their dependency order. Handle cases where multiple tasks depend on each other.",
"status": "pending",
"status": "done",
"testStrategy": "Test with complex dependency chains to verify correct ordering."
},
{
@@ -5287,7 +5287,7 @@
3
],
"details": "Modify the code to provide clear feedback if dependencies cannot be resolved. Ensure that circular dependencies are detected and handled appropriately.",
"status": "pending",
"status": "done",
"testStrategy": "Test with invalid dependency scenarios to verify proper error handling."
},
{
@@ -5298,7 +5298,7 @@
4
],
"details": "Profile and optimize the recursive dependency analysis algorithm. Implement caching or other performance improvements as needed.",
"status": "pending",
"status": "done",
"testStrategy": "Test with large sets of tasks to verify performance improvements."
}
]
@@ -5341,23 +5341,6 @@
],
"priority": "medium",
"subtasks": []
},
{
"id": 92,
"title": "Implement Scheduling System for Periodic Task Execution",
"description": "Develop a system that allows tasks to be scheduled with custom time intervals and timezone configuration, enabling periodic execution of tasks at specified times.",
"details": "1. Design the scheduling system architecture to support:\n - Custom time intervals (e.g., every X minutes/hours/days)\n - Timezone configuration\n - Task prioritization in scheduling\n2. Implement the core scheduling functionality:\n - Create a scheduler service that manages scheduled tasks\n - Develop task execution logic based on schedules\n - Integrate with existing task management system (Task 3)\n3. Add user interface for scheduling tasks:\n - Create command-line options for setting up scheduled tasks\n - Implement configuration validation and error handling (Task 19)\n4. Ensure proper logging of scheduled tasks and their execution (Task 17)\n5. Handle timezone conversions accurately\n6. Implement batch scheduling operations (Task 11)\n7. Add support for recurring tasks with complex schedules (e.g., cron-like syntax)\n8. Integrate with the existing task data structure (Task 1)",
"testStrategy": "1. Verify that tasks can be scheduled with various time intervals and timezone configurations\n2. Test scheduling edge cases (e.g., overlapping schedules, different timezones)\n3. Check proper execution of scheduled tasks at specified times\n4. Validate logging of scheduled task executions\n5. Ensure error handling works correctly for invalid schedule configurations\n6. Test batch scheduling operations\n7. Verify timezone conversion accuracy",
"status": "pending",
"dependencies": [
1,
3,
11,
17,
19
],
"priority": "medium",
"subtasks": []
}
]
}