Diagnose and Self Heal System Runtime and Codebase Flaws
diagnose_and_heal_systemDiagnoses and repairs workspace health issues like Python syntax errors, missing standard imports, broken virtualenv paths, UTF-8 BOM artifacts, and stale bytecode, reporting before-and-after scores.
Instructions
Diagnoses and automatically repairs environment misconfigurations, virtualenv breakages, syntax errors, missing standard library imports, UTF-8 BOM artifacts, and orphaned bytecode across the workspace, distinguishing from 'heal_hallucinated_code' which strictly corrects phantom AST symbols in code snippets by instead performing holistic system-level health diagnostics and autonomous multi-category file healing.
Parameters:
workspace_dir(str, optional, default='.'): Target repository root directory containing source code and environment configurations to diagnose.auto_repair(bool, optional, default=True): When True, applies surgical AST syntax patches, BOM sanitization, and cache cleanup to disk.dry_run(bool, optional, default=False): When True, evaluates diagnostics and previews repair diffs without modifying files on disk.
Behavior:
Mutability: Modifies files only when auto_repair=True and dry_run=False; otherwise strictly read-only.
Idempotency: Multiple sequential executions converge to a 100% clean state without regressions.
Performance & Latency: Scans and repairs 250+ files in <400ms using local standard library AST.
Resources: Consumes <50MB RAM; local file system operations only.
Privacy: 100% offline local processing; zero external network transmission.
Auth & Limits: Zero external credentials or API keys required; zero rate limits.
Error Handling: Continues diagnostic sweep across entire workspace if individual files contain unrecoverable binary corruption.
Usage Guidelines:
When to use: Use when diagnosing overall workspace health, repairing Python syntax breakages (missing colons, Python 2 print), resolving missing standard imports, fixing virtualenv paths, or clearing stale cache bloat.
When NOT to use: Do not use for repairing hallucinated LLM method names in isolated code snippets (use 'heal_hallucinated_code' instead); do not use for static cyclomatic complexity code smell audits (use 'audit_code_quality' instead).
Returns: Formatted Markdown report detailing initial health score, detected defects, surgical patch actions, and final post-healing health score.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "diagnose_and_heal_system"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | Whether to preview repairs without writing to disk (default: False). | |
| auto_repair | No | Whether to apply self-healing patches to disk (default: True). | |
| workspace_dir | No | Target repository root directory (default: current directory). | . |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |