An OpenCode plugin that acts as a safety net for Python file edits. It automatically detects if an edit introduces syntax or indentation errors, and if so, safely reverts the file to its previous state and reports the error inline.
- Automatic Detection: Hooks into the
edittool to validate Python syntax immediately after changes. - Auto-Revert: If
python3 -m py_compilefails, the file is instantly reverted to prevent broken code from persisting. - TUI/LSP Integration: Injects error status directly into the OpenCode diagnostics view, so you see "REVERTED" status alongside standard linting errors.
- Safe: Does not corrupt the Agent TUI with raw stderr output.
This plugin is intended for use with the OpenCode agent.
npm install @cometjc/opencode-py-indent-guardRegister the plugin in your OpenCode configuration.
import { PythonIndentGuard } from "@cometjc/opencode-py-indent-guard";
// In your plugin registration
register(PythonIndentGuard);