agent-self-debugger-looplisted
Install: claude install-skill RMAzrim/opencode-artes
# Agent Self-Debugger Loop
## 1. System Architecture & Prerequisites
### Runtime requirements
- **Python 3.9+** (uses `ast`, `ast.NodeTransformer`, `ast.unparse` available since 3.9).
- **pytest** installed and importable in the same interpreter that runs the CLI.
- **git** available on `PATH` for the rollback mechanism (`git stash`).
- No other third-party packages. The modules used: `ast`, `argparse`, `re`, `sys`, `subprocess`, `tempfile`, `pathlib`, `os`, `json`, `contextlib`, `io`, `types`.
### Architecture
The tool is one self-contained CLI module. Its pipeline stages, in order:
1. **Traceback ingestion** — read pytest output from a file or stream, parse `File "x.py", line N` frames and extract the topmost (deepest) frame inside the project.
2. **AST parsing** — load the failing file, build an AST, and locate the exact statement node whose line falls within the failing line range.
3. **Probe injection** — wrap the failing statement with a `try/except` that logs `sys._getframe()` locals/states plus a `print` tracing probe before the statement runs.
4. **Guard patching** — a `NodeTransformer` rewrites attribute accesses and subscripts that previously raised `AttributeError`/`TypeError`/`NameError` into null-safe guarded forms when the failure signature is detectable.
5. **Iterative execution** — re-run pytest (up to `--max-attempts`, default 4). On success the patch is kept; on exhaustion, `git stash` restores the file.
6. **Reporting** — emit a machine-readable JSON s