How algorithmicmind/codeshield works
CodeShield is a Python execution runtime for code generated by people or AI agents. Its main workflow accepts code, validates it through an AST security gate, runs it in an isolated temporary environment, detects runtime or suspicious-output failures, and attempts diagnosis and repair before returning results. The CLI and agent-tool wrapper are separate entry points into the same engine. The README documents the main flow; sampled source confirms key orchestration and sandbox behavior, while some internal repair details are not fully excerpted.
Main entry points: loop.py Self-healing engine · cli.py Command-line interface · tools.py Agent execution tool · schemas.py Execution result and diagnosis
Components 14
Entry points
- Command-line interface
src/codeshield/cli.py - Agent execution tool
src/codeshield/tools.py
Execution and recovery
- Self-healing engine
src/codeshield/loop.py - AST security gate
src/codeshield/analyzer.py - Sandbox manager
src/codeshield/environment.py - Subprocess runner
src/codeshield/runner.py - Traceback classifier
src/codeshield/classifier.py - Local repair heuristics
src/codeshield/loop.py - LLM patch generation
src/codeshield/loop.py
Runtime contracts
- Execution request
src/codeshield/schemas.py - Execution result and diagnosis
src/codeshield/schemas.py
Other components
- CLI user
- Agent or caller
- Configured LLM provider
Connections 17
- CLI user → Command-line interface: submits code
README.md - Command-line interface → Self-healing engine: runs code
src/codeshield/cli.py - Agent or caller → Agent execution tool: provides code
README.md - Agent execution tool → Self-healing engine: invokes
src/codeshield/tools.py - Command-line interface → Execution request: forms request
- Self-healing engine → Execution request: accepts
README.md - Self-healing engine → AST security gate: validates code
README.md - Self-healing engine → Sandbox manager: creates and cleans
src/codeshield/loop.py - Self-healing engine → Subprocess runner: executes request
src/codeshield/loop.py - Subprocess runner → Sandbox manager: uses interpreter
src/codeshield/runner.py - Self-healing engine → Traceback classifier: classifies failures
README.md - Self-healing engine → Local repair heuristics: tries local repair
README.md - Self-healing engine → LLM patch generation: requests patch
README.md - LLM patch generation → Configured LLM provider: requests patch
README.md - Self-healing engine → Execution result and diagnosis: returns outcome
README.md - Agent execution tool → Execution result and diagnosis: formats outcome
src/codeshield/tools.py - Command-line interface → Execution result and diagnosis: prints outcome
src/codeshield/cli.py