an_post_return 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,645 @@
1
+ # Task Master
2
+
3
+ ### by [@eyaltoledano](https://x.com/eyaltoledano)
4
+
5
+ A task management system for AI-driven development with Claude, designed to work seamlessly with Cursor AI.
6
+
7
+ ## Requirements
8
+
9
+ - Node.js 14.0.0 or higher
10
+ - Anthropic API key (Claude API)
11
+ - Anthropic SDK version 0.39.0 or higher
12
+ - OpenAI SDK (for Perplexity API integration, optional)
13
+
14
+ ## Configuration
15
+
16
+ The script can be configured through environment variables in a `.env` file at the root of the project:
17
+
18
+ ### Required Configuration
19
+
20
+ - `ANTHROPIC_API_KEY`: Your Anthropic API key for Claude
21
+
22
+ ### Optional Configuration
23
+
24
+ - `MODEL`: Specify which Claude model to use (default: "claude-3-7-sonnet-20250219")
25
+ - `MAX_TOKENS`: Maximum tokens for model responses (default: 4000)
26
+ - `TEMPERATURE`: Temperature for model responses (default: 0.7)
27
+ - `PERPLEXITY_API_KEY`: Your Perplexity API key for research-backed subtask generation
28
+ - `PERPLEXITY_MODEL`: Specify which Perplexity model to use (default: "sonar-medium-online")
29
+ - `DEBUG`: Enable debug logging (default: false)
30
+ - `LOG_LEVEL`: Log level - debug, info, warn, error (default: info)
31
+ - `DEFAULT_SUBTASKS`: Default number of subtasks when expanding (default: 3)
32
+ - `DEFAULT_PRIORITY`: Default priority for generated tasks (default: medium)
33
+ - `PROJECT_NAME`: Override default project name in tasks.json
34
+ - `PROJECT_VERSION`: Override default version in tasks.json
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ # Install globally
40
+ npm install -g task-master-ai
41
+
42
+ # OR install locally within your project
43
+ npm install task-master-ai
44
+ ```
45
+
46
+ ### Initialize a new project
47
+
48
+ ```bash
49
+ # If installed globally
50
+ task-master init
51
+
52
+ # If installed locally
53
+ npx task-master-init
54
+ ```
55
+
56
+ This will prompt you for project details and set up a new project with the necessary files and structure.
57
+
58
+ ### Important Notes
59
+
60
+ 1. **ES Modules Configuration:**
61
+
62
+ - This project uses ES Modules (ESM) instead of CommonJS.
63
+ - This is set via `"type": "module"` in your package.json.
64
+ - Use `import/export` syntax instead of `require()`.
65
+ - Files should use `.js` or `.mjs` extensions.
66
+ - To use a CommonJS module, either:
67
+ - Rename it with `.cjs` extension
68
+ - Use `await import()` for dynamic imports
69
+ - If you need CommonJS throughout your project, remove `"type": "module"` from package.json, but Task Master scripts expect ESM.
70
+
71
+ 2. The Anthropic SDK version should be 0.39.0 or higher.
72
+
73
+ ## Quick Start with Global Commands
74
+
75
+ After installing the package globally, you can use these CLI commands from any directory:
76
+
77
+ ```bash
78
+ # Initialize a new project
79
+ task-master init
80
+
81
+ # Parse a PRD and generate tasks
82
+ task-master parse-prd your-prd.txt
83
+
84
+ # List all tasks
85
+ task-master list
86
+
87
+ # Show the next task to work on
88
+ task-master next
89
+
90
+ # Generate task files
91
+ task-master generate
92
+ ```
93
+
94
+ ## Troubleshooting
95
+
96
+ ### If `task-master init` doesn't respond:
97
+
98
+ Try running it with Node directly:
99
+
100
+ ```bash
101
+ node node_modules/claude-task-master/scripts/init.js
102
+ ```
103
+
104
+ Or clone the repository and run:
105
+
106
+ ```bash
107
+ git clone https://github.com/eyaltoledano/claude-task-master.git
108
+ cd claude-task-master
109
+ node scripts/init.js
110
+ ```
111
+
112
+ ## Task Structure
113
+
114
+ Tasks in tasks.json have the following structure:
115
+
116
+ - `id`: Unique identifier for the task (Example: `1`)
117
+ - `title`: Brief, descriptive title of the task (Example: `"Initialize Repo"`)
118
+ - `description`: Concise description of what the task involves (Example: `"Create a new repository, set up initial structure."`)
119
+ - `status`: Current state of the task (Example: `"pending"`, `"done"`, `"deferred"`)
120
+ - `dependencies`: IDs of tasks that must be completed before this task (Example: `[1, 2]`)
121
+ - Dependencies are displayed with status indicators (✅ for completed, ⏱️ for pending)
122
+ - This helps quickly identify which prerequisite tasks are blocking work
123
+ - `priority`: Importance level of the task (Example: `"high"`, `"medium"`, `"low"`)
124
+ - `details`: In-depth implementation instructions (Example: `"Use GitHub client ID/secret, handle callback, set session token."`)
125
+ - `testStrategy`: Verification approach (Example: `"Deploy and call endpoint to confirm 'Hello World' response."`)
126
+ - `subtasks`: List of smaller, more specific tasks that make up the main task (Example: `[{"id": 1, "title": "Configure OAuth", ...}]`)
127
+
128
+ ## Integrating with Cursor AI
129
+
130
+ Claude Task Master is designed to work seamlessly with [Cursor AI](https://www.cursor.so/), providing a structured workflow for AI-driven development.
131
+
132
+ ### Setup with Cursor
133
+
134
+ 1. After initializing your project, open it in Cursor
135
+ 2. The `.cursor/rules/dev_workflow.mdc` file is automatically loaded by Cursor, providing the AI with knowledge about the task management system
136
+ 3. Place your PRD document in the `scripts/` directory (e.g., `scripts/prd.txt`)
137
+ 4. Open Cursor's AI chat and switch to Agent mode
138
+
139
+ ### Setting up MCP in Cursor
140
+
141
+ To enable enhanced task management capabilities directly within Cursor using the Model Control Protocol (MCP):
142
+
143
+ 1. Go to Cursor settings
144
+ 2. Navigate to the MCP section
145
+ 3. Click on "Add New MCP Server"
146
+ 4. Configure with the following details:
147
+ - Name: "Task Master"
148
+ - Type: "Command"
149
+ - Command: "npx -y task-master-ai"
150
+ 5. Save the settings
151
+
152
+ Once configured, you can interact with Task Master's task management commands directly through Cursor's interface, providing a more integrated experience.
153
+
154
+ ### Initial Task Generation
155
+
156
+ In Cursor's AI chat, instruct the agent to generate tasks from your PRD:
157
+
158
+ ```
159
+ Please use the task-master parse-prd command to generate tasks from my PRD. The PRD is located at scripts/prd.txt.
160
+ ```
161
+
162
+ The agent will execute:
163
+
164
+ ```bash
165
+ task-master parse-prd scripts/prd.txt
166
+ ```
167
+
168
+ This will:
169
+
170
+ - Parse your PRD document
171
+ - Generate a structured `tasks.json` file with tasks, dependencies, priorities, and test strategies
172
+ - The agent will understand this process due to the Cursor rules
173
+
174
+ ### Generate Individual Task Files
175
+
176
+ Next, ask the agent to generate individual task files:
177
+
178
+ ```
179
+ Please generate individual task files from tasks.json
180
+ ```
181
+
182
+ The agent will execute:
183
+
184
+ ```bash
185
+ task-master generate
186
+ ```
187
+
188
+ This creates individual task files in the `tasks/` directory (e.g., `task_001.txt`, `task_002.txt`), making it easier to reference specific tasks.
189
+
190
+ ## AI-Driven Development Workflow
191
+
192
+ The Cursor agent is pre-configured (via the rules file) to follow this workflow:
193
+
194
+ ### 1. Task Discovery and Selection
195
+
196
+ Ask the agent to list available tasks:
197
+
198
+ ```
199
+ What tasks are available to work on next?
200
+ ```
201
+
202
+ The agent will:
203
+
204
+ - Run `task-master list` to see all tasks
205
+ - Run `task-master next` to determine the next task to work on
206
+ - Analyze dependencies to determine which tasks are ready to be worked on
207
+ - Prioritize tasks based on priority level and ID order
208
+ - Suggest the next task(s) to implement
209
+
210
+ ### 2. Task Implementation
211
+
212
+ When implementing a task, the agent will:
213
+
214
+ - Reference the task's details section for implementation specifics
215
+ - Consider dependencies on previous tasks
216
+ - Follow the project's coding standards
217
+ - Create appropriate tests based on the task's testStrategy
218
+
219
+ You can ask:
220
+
221
+ ```
222
+ Let's implement task 3. What does it involve?
223
+ ```
224
+
225
+ ### 3. Task Verification
226
+
227
+ Before marking a task as complete, verify it according to:
228
+
229
+ - The task's specified testStrategy
230
+ - Any automated tests in the codebase
231
+ - Manual verification if required
232
+
233
+ ### 4. Task Completion
234
+
235
+ When a task is completed, tell the agent:
236
+
237
+ ```
238
+ Task 3 is now complete. Please update its status.
239
+ ```
240
+
241
+ The agent will execute:
242
+
243
+ ```bash
244
+ task-master set-status --id=3 --status=done
245
+ ```
246
+
247
+ ### 5. Handling Implementation Drift
248
+
249
+ If during implementation, you discover that:
250
+
251
+ - The current approach differs significantly from what was planned
252
+ - Future tasks need to be modified due to current implementation choices
253
+ - New dependencies or requirements have emerged
254
+
255
+ Tell the agent:
256
+
257
+ ```
258
+ We've changed our approach. We're now using Express instead of Fastify. Please update all future tasks to reflect this change.
259
+ ```
260
+
261
+ The agent will execute:
262
+
263
+ ```bash
264
+ task-master update --from=4 --prompt="Now we are using Express instead of Fastify."
265
+ ```
266
+
267
+ This will rewrite or re-scope subsequent tasks in tasks.json while preserving completed work.
268
+
269
+ ### 6. Breaking Down Complex Tasks
270
+
271
+ For complex tasks that need more granularity:
272
+
273
+ ```
274
+ Task 5 seems complex. Can you break it down into subtasks?
275
+ ```
276
+
277
+ The agent will execute:
278
+
279
+ ```bash
280
+ task-master expand --id=5 --num=3
281
+ ```
282
+
283
+ You can provide additional context:
284
+
285
+ ```
286
+ Please break down task 5 with a focus on security considerations.
287
+ ```
288
+
289
+ The agent will execute:
290
+
291
+ ```bash
292
+ task-master expand --id=5 --prompt="Focus on security aspects"
293
+ ```
294
+
295
+ You can also expand all pending tasks:
296
+
297
+ ```
298
+ Please break down all pending tasks into subtasks.
299
+ ```
300
+
301
+ The agent will execute:
302
+
303
+ ```bash
304
+ task-master expand --all
305
+ ```
306
+
307
+ For research-backed subtask generation using Perplexity AI:
308
+
309
+ ```
310
+ Please break down task 5 using research-backed generation.
311
+ ```
312
+
313
+ The agent will execute:
314
+
315
+ ```bash
316
+ task-master expand --id=5 --research
317
+ ```
318
+
319
+ ## Command Reference
320
+
321
+ Here's a comprehensive reference of all available commands:
322
+
323
+ ### Parse PRD
324
+
325
+ ```bash
326
+ # Parse a PRD file and generate tasks
327
+ task-master parse-prd <prd-file.txt>
328
+
329
+ # Limit the number of tasks generated
330
+ task-master parse-prd <prd-file.txt> --num-tasks=10
331
+ ```
332
+
333
+ ### List Tasks
334
+
335
+ ```bash
336
+ # List all tasks
337
+ task-master list
338
+
339
+ # List tasks with a specific status
340
+ task-master list --status=<status>
341
+
342
+ # List tasks with subtasks
343
+ task-master list --with-subtasks
344
+
345
+ # List tasks with a specific status and include subtasks
346
+ task-master list --status=<status> --with-subtasks
347
+ ```
348
+
349
+ ### Show Next Task
350
+
351
+ ```bash
352
+ # Show the next task to work on based on dependencies and status
353
+ task-master next
354
+ ```
355
+
356
+ ### Show Specific Task
357
+
358
+ ```bash
359
+ # Show details of a specific task
360
+ task-master show <id>
361
+ # or
362
+ task-master show --id=<id>
363
+
364
+ # View a specific subtask (e.g., subtask 2 of task 1)
365
+ task-master show 1.2
366
+ ```
367
+
368
+ ### Update Tasks
369
+
370
+ ```bash
371
+ # Update tasks from a specific ID and provide context
372
+ task-master update --from=<id> --prompt="<prompt>"
373
+ ```
374
+
375
+ ### Generate Task Files
376
+
377
+ ```bash
378
+ # Generate individual task files from tasks.json
379
+ task-master generate
380
+ ```
381
+
382
+ ### Set Task Status
383
+
384
+ ```bash
385
+ # Set status of a single task
386
+ task-master set-status --id=<id> --status=<status>
387
+
388
+ # Set status for multiple tasks
389
+ task-master set-status --id=1,2,3 --status=<status>
390
+
391
+ # Set status for subtasks
392
+ task-master set-status --id=1.1,1.2 --status=<status>
393
+ ```
394
+
395
+ When marking a task as "done", all of its subtasks will automatically be marked as "done" as well.
396
+
397
+ ### Expand Tasks
398
+
399
+ ```bash
400
+ # Expand a specific task with subtasks
401
+ task-master expand --id=<id> --num=<number>
402
+
403
+ # Expand with additional context
404
+ task-master expand --id=<id> --prompt="<context>"
405
+
406
+ # Expand all pending tasks
407
+ task-master expand --all
408
+
409
+ # Force regeneration of subtasks for tasks that already have them
410
+ task-master expand --all --force
411
+
412
+ # Research-backed subtask generation for a specific task
413
+ task-master expand --id=<id> --research
414
+
415
+ # Research-backed generation for all tasks
416
+ task-master expand --all --research
417
+ ```
418
+
419
+ ### Clear Subtasks
420
+
421
+ ```bash
422
+ # Clear subtasks from a specific task
423
+ task-master clear-subtasks --id=<id>
424
+
425
+ # Clear subtasks from multiple tasks
426
+ task-master clear-subtasks --id=1,2,3
427
+
428
+ # Clear subtasks from all tasks
429
+ task-master clear-subtasks --all
430
+ ```
431
+
432
+ ### Analyze Task Complexity
433
+
434
+ ```bash
435
+ # Analyze complexity of all tasks
436
+ task-master analyze-complexity
437
+
438
+ # Save report to a custom location
439
+ task-master analyze-complexity --output=my-report.json
440
+
441
+ # Use a specific LLM model
442
+ task-master analyze-complexity --model=claude-3-opus-20240229
443
+
444
+ # Set a custom complexity threshold (1-10)
445
+ task-master analyze-complexity --threshold=6
446
+
447
+ # Use an alternative tasks file
448
+ task-master analyze-complexity --file=custom-tasks.json
449
+
450
+ # Use Perplexity AI for research-backed complexity analysis
451
+ task-master analyze-complexity --research
452
+ ```
453
+
454
+ ### View Complexity Report
455
+
456
+ ```bash
457
+ # Display the task complexity analysis report
458
+ task-master complexity-report
459
+
460
+ # View a report at a custom location
461
+ task-master complexity-report --file=my-report.json
462
+ ```
463
+
464
+ ### Managing Task Dependencies
465
+
466
+ ```bash
467
+ # Add a dependency to a task
468
+ task-master add-dependency --id=<id> --depends-on=<id>
469
+
470
+ # Remove a dependency from a task
471
+ task-master remove-dependency --id=<id> --depends-on=<id>
472
+
473
+ # Validate dependencies without fixing them
474
+ task-master validate-dependencies
475
+
476
+ # Find and fix invalid dependencies automatically
477
+ task-master fix-dependencies
478
+ ```
479
+
480
+ ### Add a New Task
481
+
482
+ ```bash
483
+ # Add a new task using AI
484
+ task-master add-task --prompt="Description of the new task"
485
+
486
+ # Add a task with dependencies
487
+ task-master add-task --prompt="Description" --dependencies=1,2,3
488
+
489
+ # Add a task with priority
490
+ task-master add-task --prompt="Description" --priority=high
491
+ ```
492
+
493
+ ## Feature Details
494
+
495
+ ### Analyzing Task Complexity
496
+
497
+ The `analyze-complexity` command:
498
+
499
+ - Analyzes each task using AI to assess its complexity on a scale of 1-10
500
+ - Recommends optimal number of subtasks based on configured DEFAULT_SUBTASKS
501
+ - Generates tailored prompts for expanding each task
502
+ - Creates a comprehensive JSON report with ready-to-use commands
503
+ - Saves the report to scripts/task-complexity-report.json by default
504
+
505
+ The generated report contains:
506
+
507
+ - Complexity analysis for each task (scored 1-10)
508
+ - Recommended number of subtasks based on complexity
509
+ - AI-generated expansion prompts customized for each task
510
+ - Ready-to-run expansion commands directly within each task analysis
511
+
512
+ ### Viewing Complexity Report
513
+
514
+ The `complexity-report` command:
515
+
516
+ - Displays a formatted, easy-to-read version of the complexity analysis report
517
+ - Shows tasks organized by complexity score (highest to lowest)
518
+ - Provides complexity distribution statistics (low, medium, high)
519
+ - Highlights tasks recommended for expansion based on threshold score
520
+ - Includes ready-to-use expansion commands for each complex task
521
+ - If no report exists, offers to generate one on the spot
522
+
523
+ ### Smart Task Expansion
524
+
525
+ The `expand` command automatically checks for and uses the complexity report:
526
+
527
+ When a complexity report exists:
528
+
529
+ - Tasks are automatically expanded using the recommended subtask count and prompts
530
+ - When expanding all tasks, they're processed in order of complexity (highest first)
531
+ - Research-backed generation is preserved from the complexity analysis
532
+ - You can still override recommendations with explicit command-line options
533
+
534
+ Example workflow:
535
+
536
+ ```bash
537
+ # Generate the complexity analysis report with research capabilities
538
+ task-master analyze-complexity --research
539
+
540
+ # Review the report in a readable format
541
+ task-master complexity-report
542
+
543
+ # Expand tasks using the optimized recommendations
544
+ task-master expand --id=8
545
+ # or expand all tasks
546
+ task-master expand --all
547
+ ```
548
+
549
+ ### Finding the Next Task
550
+
551
+ The `next` command:
552
+
553
+ - Identifies tasks that are pending/in-progress and have all dependencies satisfied
554
+ - Prioritizes tasks by priority level, dependency count, and task ID
555
+ - Displays comprehensive information about the selected task:
556
+ - Basic task details (ID, title, priority, dependencies)
557
+ - Implementation details
558
+ - Subtasks (if they exist)
559
+ - Provides contextual suggested actions:
560
+ - Command to mark the task as in-progress
561
+ - Command to mark the task as done
562
+ - Commands for working with subtasks
563
+
564
+ ### Viewing Specific Task Details
565
+
566
+ The `show` command:
567
+
568
+ - Displays comprehensive details about a specific task or subtask
569
+ - Shows task status, priority, dependencies, and detailed implementation notes
570
+ - For parent tasks, displays all subtasks and their status
571
+ - For subtasks, shows parent task relationship
572
+ - Provides contextual action suggestions based on the task's state
573
+ - Works with both regular tasks and subtasks (using the format taskId.subtaskId)
574
+
575
+ ## Best Practices for AI-Driven Development
576
+
577
+ 1. **Start with a detailed PRD**: The more detailed your PRD, the better the generated tasks will be.
578
+
579
+ 2. **Review generated tasks**: After parsing the PRD, review the tasks to ensure they make sense and have appropriate dependencies.
580
+
581
+ 3. **Analyze task complexity**: Use the complexity analysis feature to identify which tasks should be broken down further.
582
+
583
+ 4. **Follow the dependency chain**: Always respect task dependencies - the Cursor agent will help with this.
584
+
585
+ 5. **Update as you go**: If your implementation diverges from the plan, use the update command to keep future tasks aligned with your current approach.
586
+
587
+ 6. **Break down complex tasks**: Use the expand command to break down complex tasks into manageable subtasks.
588
+
589
+ 7. **Regenerate task files**: After any updates to tasks.json, regenerate the task files to keep them in sync.
590
+
591
+ 8. **Communicate context to the agent**: When asking the Cursor agent to help with a task, provide context about what you're trying to achieve.
592
+
593
+ 9. **Validate dependencies**: Periodically run the validate-dependencies command to check for invalid or circular dependencies.
594
+
595
+ ## Example Cursor AI Interactions
596
+
597
+ ### Starting a new project
598
+
599
+ ```
600
+ I've just initialized a new project with Claude Task Master. I have a PRD at scripts/prd.txt.
601
+ Can you help me parse it and set up the initial tasks?
602
+ ```
603
+
604
+ ### Working on tasks
605
+
606
+ ```
607
+ What's the next task I should work on? Please consider dependencies and priorities.
608
+ ```
609
+
610
+ ### Implementing a specific task
611
+
612
+ ```
613
+ I'd like to implement task 4. Can you help me understand what needs to be done and how to approach it?
614
+ ```
615
+
616
+ ### Managing subtasks
617
+
618
+ ```
619
+ I need to regenerate the subtasks for task 3 with a different approach. Can you help me clear and regenerate them?
620
+ ```
621
+
622
+ ### Handling changes
623
+
624
+ ```
625
+ We've decided to use MongoDB instead of PostgreSQL. Can you update all future tasks to reflect this change?
626
+ ```
627
+
628
+ ### Completing work
629
+
630
+ ```
631
+ I've finished implementing the authentication system described in task 2. All tests are passing.
632
+ Please mark it as complete and tell me what I should work on next.
633
+ ```
634
+
635
+ ### Analyzing complexity
636
+
637
+ ```
638
+ Can you analyze the complexity of our tasks to help me understand which ones need to be broken down further?
639
+ ```
640
+
641
+ ### Viewing complexity report
642
+
643
+ ```
644
+ Can you show me the complexity report in a more readable format?
645
+ ```