prompt.ts
1 import { FILE_EDIT_TOOL_NAME } from '../FileEditTool/constants.js' 2 3 export const PROMPT = `Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. 4 It also helps the user understand the progress of the task and overall progress of their requests. 5 6 ## When to Use This Tool 7 Use this tool proactively in these scenarios: 8 9 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions 10 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations 11 3. User explicitly requests todo list - When the user directly asks you to use the todo list 12 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated) 13 5. After receiving new instructions - Immediately capture user requirements as todos 14 6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time 15 7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation 16 17 ## When NOT to Use This Tool 18 19 Skip using this tool when: 20 1. There is only a single, straightforward task 21 2. The task is trivial and tracking it provides no organizational benefit 22 3. The task can be completed in less than 3 trivial steps 23 4. The task is purely conversational or informational 24 25 NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly. 26 27 ## Examples of When to Use the Todo List 28 29 <example> 30 User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done! 31 Assistant: *Creates todo list with the following items:* 32 1. Creating dark mode toggle component in Settings page 33 2. Adding dark mode state management (context/store) 34 3. Implementing CSS-in-JS styles for dark theme 35 4. Updating existing components to support theme switching 36 5. Running tests and build process, addressing any failures or errors that occur 37 *Begins working on the first task* 38 39 <reasoning> 40 The assistant used the todo list because: 41 1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes 42 2. The user explicitly requested tests and build be run afterward 43 3. The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task 44 </reasoning> 45 </example> 46 47 <example> 48 User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project 49 Assistant: *Uses grep or search tools to locate all instances of getCwd in the codebase* 50 I've found 15 instances of 'getCwd' across 8 different files. 51 *Creates todo list with specific items for each file that needs updating* 52 53 <reasoning> 54 The assistant used the todo list because: 55 1. First, the assistant searched to understand the scope of the task 56 2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps 57 3. The todo list helps ensure every instance is tracked and updated systematically 58 4. This approach prevents missing any occurrences and maintains code consistency 59 </reasoning> 60 </example> 61 62 63 <example> 64 User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow. 65 Assistant: *Creates a todo list breaking down each feature into specific tasks based on the project architecture* 66 Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system. 67 68 <reasoning> 69 The assistant used the todo list because: 70 1. The user provided multiple complex features to implement in a comma separated list 71 2. The todo list helps organize these large features into manageable tasks 72 3. This approach allows for tracking progress across the entire implementation 73 </reasoning> 74 </example> 75 76 <example> 77 User: Can you help optimize my React application? It's rendering slowly and has performance issues. 78 Assistant: *Reviews component structure, render patterns, state management, and data fetching* 79 After analyzing your codebase, I've identified several performance issues. 80 *Creates todo list with items like: 1) Implementing memoization for expensive calculations in ProductList, 2) Adding virtualization for long lists in Dashboard, 3) Optimizing image loading in Gallery component, 4) Fixing state update loops in ShoppingCart, 5) Reviewing bundle size and implementing code splitting* 81 Let's start by implementing memoization for the expensive calculations in your ProductList component. 82 83 <reasoning> 84 The assistant used the todo list because: 85 1. First, the assistant examined the codebase to identify specific performance issues 86 2. Based on this analysis, it identified multiple optimization opportunities 87 3. Performance optimization is a non-trivial task requiring multiple steps 88 4. The todo list helps methodically track improvements across different components 89 5. This systematic approach ensures all performance bottlenecks are addressed 90 </reasoning> 91 </example> 92 93 ## Examples of When NOT to Use the Todo List 94 95 <example> 96 User: How do I print 'Hello World' in Python? 97 Assistant: In Python, you can print "Hello World" with this simple code: 98 99 python 100 print("Hello World") 101 102 This will output the text "Hello World" to the console when executed. 103 104 <reasoning> 105 The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request. 106 </reasoning> 107 </example> 108 109 <example> 110 User: What does the git status command do? 111 Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits. 112 113 <reasoning> 114 The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks. 115 </reasoning> 116 </example> 117 118 <example> 119 User: Can you add a comment to the calculateTotal function to explain what it does? 120 Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does. 121 * Uses the ${FILE_EDIT_TOOL_NAME} tool to add a comment to the calculateTotal function * 122 123 <reasoning> 124 The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization. 125 </reasoning> 126 </example> 127 128 <example> 129 User: Run npm install for me and tell me what happens. 130 Assistant: I'll run the npm install command for you. 131 132 *Executes: npm install* 133 134 The command completed successfully. Here's the output: 135 [Output of npm install command] 136 137 All dependencies have been installed according to your package.json file. 138 139 <reasoning> 140 The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task. 141 </reasoning> 142 </example> 143 144 ## Task States and Management 145 146 1. **Task States**: Use these states to track progress: 147 - pending: Task not yet started 148 - in_progress: Currently working on (limit to ONE task at a time) 149 - completed: Task finished successfully 150 151 **IMPORTANT**: Task descriptions must have two forms: 152 - content: The imperative form describing what needs to be done (e.g., "Run tests", "Build the project") 153 - activeForm: The present continuous form shown during execution (e.g., "Running tests", "Building the project") 154 155 2. **Task Management**: 156 - Update task status in real-time as you work 157 - Mark tasks complete IMMEDIATELY after finishing (don't batch completions) 158 - Exactly ONE task must be in_progress at any time (not less, not more) 159 - Complete current tasks before starting new ones 160 - Remove tasks that are no longer relevant from the list entirely 161 162 3. **Task Completion Requirements**: 163 - ONLY mark a task as completed when you have FULLY accomplished it 164 - If you encounter errors, blockers, or cannot finish, keep the task as in_progress 165 - When blocked, create a new task describing what needs to be resolved 166 - Never mark a task as completed if: 167 - Tests are failing 168 - Implementation is partial 169 - You encountered unresolved errors 170 - You couldn't find necessary files or dependencies 171 172 4. **Task Breakdown**: 173 - Create specific, actionable items 174 - Break complex tasks into smaller, manageable steps 175 - Use clear, descriptive task names 176 - Always provide both forms: 177 - content: "Fix authentication bug" 178 - activeForm: "Fixing authentication bug" 179 180 When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully. 181 ` 182 183 export const DESCRIPTION = 184 'Update the todo list for the current session. To be used proactively and often to track progress and pending tasks. Make sure that at least one task is in_progress at all times. Always provide both content (imperative) and activeForm (present continuous) for each task.'