(debugUrl: string)
| 35 | } |
| 36 | |
| 37 | function getDebugInstructions(debugUrl: string): string { |
| 38 | return ` |
| 39 | ## Debug Mode Instructions |
| 40 | |
| 41 | You are now in DEBUG MODE. Your task is to instrument the codebase with fetch calls to capture runtime data for debugging. |
| 42 | |
| 43 | ### Workflow: |
| 44 | 1. **Analyze the issue** - Understand what the user is trying to debug |
| 45 | 2. **Identify key locations** - Find functions, handlers, or code paths relevant to the issue |
| 46 | 3. **Insert fetch calls** - Place debug fetch calls at strategic points to capture: |
| 47 | - Function inputs/outputs |
| 48 | - State changes |
| 49 | - Error conditions |
| 50 | - Control flow branches |
| 51 | 4. **Hand back to user** - Let them reproduce the issue |
| 52 | 5. **Read logs** - Use debug_read to analyze the captured data |
| 53 | |
| 54 | ### Fetch Call Pattern: |
| 55 | \`\`\`javascript |
| 56 | ${generateFetchSnippet( |
| 57 | debugUrl, |
| 58 | "descriptive-label", |
| 59 | "{ variable1, variable2 }" |
| 60 | )} |
| 61 | \`\`\` |
| 62 | |
| 63 | ### Best Practices: |
| 64 | - Use descriptive labels like "user-login-start", "api-response", "error-caught" |
| 65 | - Capture relevant variables in the data object |
| 66 | - Place calls at function entry/exit points |
| 67 | - Add calls before and after async operations |
| 68 | - Capture error objects in catch blocks |
| 69 | - Don't forget to capture the state you're debugging |
| 70 | |
| 71 | ### Examples: |
| 72 | \`\`\`javascript |
| 73 | // At function entry |
| 74 | ${generateFetchSnippet(debugUrl, "processOrder-entry", "{ orderId, items }")} |
| 75 | |
| 76 | // Before async call |
| 77 | ${generateFetchSnippet(debugUrl, "api-call-start", "{ endpoint, payload }")} |
| 78 | |
| 79 | // After async call |
| 80 | ${generateFetchSnippet(debugUrl, "api-call-complete", "{ response, status }")} |
| 81 | |
| 82 | // In catch block |
| 83 | ${generateFetchSnippet( |
| 84 | debugUrl, |
| 85 | "error-caught", |
| 86 | "{ error: err.message, stack: err.stack }" |
| 87 | )} |
| 88 | |
| 89 | // State changes |
| 90 | ${generateFetchSnippet(debugUrl, "state-updated", "{ prevState, nextState }")} |
| 91 | \`\`\` |
| 92 | |
| 93 | ### Debug URL: ${debugUrl} |
| 94 | `; |
no test coverage detected