MCPcopy Index your code
hub / github.com/MrgSub/opencode-debug / getDebugInstructions

Function getDebugInstructions

src/index.ts:37–95  ·  view source on GitHub ↗
(debugUrl: string)

Source from the content-addressed store, hash-verified

35}
36
37function getDebugInstructions(debugUrl: string): string {
38 return `
39## Debug Mode Instructions
40
41You are now in DEBUG MODE. Your task is to instrument the codebase with fetch calls to capture runtime data for debugging.
42
43### Workflow:
441. **Analyze the issue** - Understand what the user is trying to debug
452. **Identify key locations** - Find functions, handlers, or code paths relevant to the issue
463. **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
514. **Hand back to user** - Let them reproduce the issue
525. **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`;

Callers 1

DebugPluginFunction · 0.85

Calls 1

generateFetchSnippetFunction · 0.85

Tested by

no test coverage detected