Spaces:
Paused
Paused
Commit
·
7693ee9
1
Parent(s):
9d6b77b
feat: add multiple prompts for enhanced bug localization workflow
Browse files
main.py
CHANGED
|
@@ -202,14 +202,9 @@ async def search_space_routing(request: SearchSpaceRoutingRequest, ctx: Context)
|
|
| 202 |
@mcp.prompt(
|
| 203 |
title="Augment Bug Report"
|
| 204 |
)
|
| 205 |
-
async def augment_bug_report(
|
| 206 |
-
return
|
| 207 |
-
You are a bug localization expert with access to this codebase. Your task is to augment the bug description with technical details that help pinpoint the bug location.
|
| 208 |
-
|
| 209 |
-
Original bug description:
|
| 210 |
-
\"\"\"
|
| 211 |
-
{raw_bug_description}
|
| 212 |
-
\"\"\"
|
| 213 |
|
| 214 |
Steps:
|
| 215 |
1. **Analyze the codebase** - Examine project structure, modules, and architectural patterns
|
|
@@ -226,7 +221,99 @@ Steps:
|
|
| 226 |
Return a 2-3x more detailed bug report with precise technical terms for effective bug localization.
|
| 227 |
"""
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
if __name__ == "__main__":
|
| 232 |
mcp.run(transport="streamable-http")
|
|
|
|
| 202 |
@mcp.prompt(
|
| 203 |
title="Augment Bug Report"
|
| 204 |
)
|
| 205 |
+
async def augment_bug_report() -> str:
|
| 206 |
+
return """
|
| 207 |
+
You are a bug localization expert with access to this codebase. Your task is to augment the bug description from this conversation with technical details that help pinpoint the bug location.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
Steps:
|
| 210 |
1. **Analyze the codebase** - Examine project structure, modules, and architectural patterns
|
|
|
|
| 221 |
Return a 2-3x more detailed bug report with precise technical terms for effective bug localization.
|
| 222 |
"""
|
| 223 |
|
| 224 |
+
@mcp.prompt(
|
| 225 |
+
title="Route Bug to Appropriate Tool"
|
| 226 |
+
)
|
| 227 |
+
async def route_bug_to_tool() -> str:
|
| 228 |
+
return """
|
| 229 |
+
You have access to bug localization tools in this MCP server. Determine the best approach for the current bug based on the description provided in this conversation.
|
| 230 |
+
|
| 231 |
+
Recommend:
|
| 232 |
+
1. **Primary Tool** - Which tool to use first and why
|
| 233 |
+
2. **Tool Sequence** - If multiple tools needed, in what order
|
| 234 |
+
3. **Reasoning** - Why this approach is optimal
|
| 235 |
+
4. **Expected Workflow** - Step-by-step tool usage plan
|
| 236 |
+
|
| 237 |
+
Provide specific tool recommendations with rationale.
|
| 238 |
+
"""
|
| 239 |
+
|
| 240 |
+
@mcp.prompt(
|
| 241 |
+
title="Localize Bug Using Selected Tool"
|
| 242 |
+
)
|
| 243 |
+
async def localize_bug_using_tool() -> str:
|
| 244 |
+
return """
|
| 245 |
+
You are using a bug localization tool to identify potential files related to the bug described in this conversation. Execute the following steps:
|
| 246 |
+
|
| 247 |
+
1. **Input the augmented bug description** - Use the detailed description from the previous step
|
| 248 |
+
2. **Run the localization tool** - Execute the tool to find ares related to the bug
|
| 249 |
+
3. **Collect results** - Gather the results identified by the tool
|
| 250 |
+
4. **Return results** - Provide the results and any additional metadata
|
| 251 |
+
The tool will return info that are likely related to the bug.
|
| 252 |
+
"""
|
| 253 |
+
|
| 254 |
+
@mcp.prompt(
|
| 255 |
+
title="Interpret Localization Results"
|
| 256 |
+
)
|
| 257 |
+
async def interpret_localization_results() -> str:
|
| 258 |
+
return """
|
| 259 |
+
You received a response from a bug localization tool in this conversation. Interpret the results for actionable next steps.
|
| 260 |
+
|
| 261 |
+
Analyze and provide:
|
| 262 |
+
1. **Key Files Identified** - Prioritized list of files to investigate
|
| 263 |
+
2. **Investigation Order** - Which files to check first and why
|
| 264 |
+
3. **Code Patterns to Look For** - Specific methods, classes, or patterns
|
| 265 |
+
4. **Next Tool Recommendations** - Should you use single_module on specific modules?
|
| 266 |
+
5. **Confidence Assessment** - How reliable are these results?
|
| 267 |
+
|
| 268 |
+
Provide actionable guidance for the developer's next steps.
|
| 269 |
+
"""
|
| 270 |
+
|
| 271 |
+
@mcp.prompt(
|
| 272 |
+
title="Analyze and Fix Localized Bug"
|
| 273 |
+
)
|
| 274 |
+
async def analyze_and_fix_localized_bug() -> str:
|
| 275 |
+
return """
|
| 276 |
+
You have codebase access. A bug localization tool has identified files as potential starting points in this conversation - not all may contain the actual bug.
|
| 277 |
+
|
| 278 |
+
Steps:
|
| 279 |
+
1. **Examine the identified files** - Use these as starting points to explore related code
|
| 280 |
+
2. **Follow the trail** - Trace connections to find the actual bug location
|
| 281 |
+
3. **Identify root cause** - Pinpoint exact lines/methods causing the issue
|
| 282 |
+
4. **Provide concrete fixes** - Show specific code changes with before/after examples
|
| 283 |
+
5. **Suggest testing** - How to verify the fix works
|
| 284 |
+
|
| 285 |
+
These files are investigation starting points. The actual bug may be in related code you discover.
|
| 286 |
+
"""
|
| 287 |
+
|
| 288 |
+
@mcp.prompt(
|
| 289 |
+
title="Complete Bug Resolution Workflow"
|
| 290 |
+
)
|
| 291 |
+
async def complete_bug_workflow(raw_bug_description: str) -> str:
|
| 292 |
+
return f"""
|
| 293 |
+
You are a bug resolution expert with access to this codebase and bug localization tools. Complete the full workflow from bug description to fix.
|
| 294 |
|
| 295 |
+
Original bug description:
|
| 296 |
+
\"\"\"
|
| 297 |
+
{raw_bug_description}
|
| 298 |
+
\"\"\"
|
| 299 |
+
|
| 300 |
+
Follow this workflow:
|
| 301 |
+
|
| 302 |
+
1. **AUGMENT** - First, examine the codebase and augment the bug description with technical details, specific modules, file types, and architectural context.
|
| 303 |
+
|
| 304 |
+
2. **ROUTE** - Decide which bug localization tool to use:
|
| 305 |
+
- search_space_routing: If you don't know which microservices are involved
|
| 306 |
+
- multi_module_bug_localization: If multiple modules likely affected
|
| 307 |
+
- single_module_bug_localization: If you know the specific module
|
| 308 |
+
|
| 309 |
+
3. **LOCALIZE** - Call the appropriate tool(s) with the augmented description.
|
| 310 |
+
|
| 311 |
+
4. **INTERPRET** - Analyze the localization results to identify key files and investigation priorities.
|
| 312 |
+
|
| 313 |
+
5. **FIX** - Examine the identified files (as starting points), find the actual bug, and provide concrete code fixes.
|
| 314 |
+
|
| 315 |
+
Execute each step and provide the final resolution with specific code changes.
|
| 316 |
+
"""
|
| 317 |
|
| 318 |
if __name__ == "__main__":
|
| 319 |
mcp.run(transport="streamable-http")
|