Is this related to a problem?
When code generation fails, error messages can be vague. Users see generic errors without clear guidance on what went wrong or how to fix it. For example, an LLM timeout and a cargo check failure return similar error formats.
Describe the feature
Add structured error codes and actionable messages to the generate_stylus_code tool:
ERR_LLM_TIMEOUT — "LLM request timed out. Try a simpler prompt or try again."
ERR_LLM_EMPTY — "LLM returned empty response. Retrying with a different model..."
ERR_CARGO_CHECK — "Generated code failed compilation. Error: [specific error]. Attempting auto-fix..."
ERR_DOCKER_UNAVAILABLE — "Docker is not running. Compile verification skipped."
ERR_TEMPLATE_NOT_FOUND — "No matching template for this prompt. Using freeform generation."
Which module does this relate to?
Example usage
Before: "Error generating code"
After: "[ERR_CARGO_CHECK] Compilation failed: missing import 'alloy_sol_types::sol'. Auto-fix attempt 1/3..."
Additional context
- Files:
src/mcp/tools/generate_stylus_code.py, src/utils/compiler_verifier.py
- The
compiler_verifier.py already has an ERROR_GUIDANCE dict mapping Rust error codes to fix hints — this can be exposed to users
Is this related to a problem?
When code generation fails, error messages can be vague. Users see generic errors without clear guidance on what went wrong or how to fix it. For example, an LLM timeout and a cargo check failure return similar error formats.
Describe the feature
Add structured error codes and actionable messages to the
generate_stylus_codetool:ERR_LLM_TIMEOUT— "LLM request timed out. Try a simpler prompt or try again."ERR_LLM_EMPTY— "LLM returned empty response. Retrying with a different model..."ERR_CARGO_CHECK— "Generated code failed compilation. Error: [specific error]. Attempting auto-fix..."ERR_DOCKER_UNAVAILABLE— "Docker is not running. Compile verification skipped."ERR_TEMPLATE_NOT_FOUND— "No matching template for this prompt. Using freeform generation."Which module does this relate to?
Example usage
Before:
"Error generating code"After:
"[ERR_CARGO_CHECK] Compilation failed: missing import 'alloy_sol_types::sol'. Auto-fix attempt 1/3..."Additional context
src/mcp/tools/generate_stylus_code.py,src/utils/compiler_verifier.pycompiler_verifier.pyalready has anERROR_GUIDANCEdict mapping Rust error codes to fix hints — this can be exposed to users