commit_safe_edit
Prevents tunnel vision bugs in JavaScript/TypeScript by verifying dependencies via AST parsing before committing file edits. Ensures AI understands code impact before making changes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_function | Yes | ||
| file_path | Yes | ||
| full_file_content | Yes | ||
| force_override | No |
Implementation Reference
- mcp_edit_math.py:490-504 (handler)The core handler function for the 'commit_safe_edit' MCP tool. Decorated with @mcp.tool() for registration. It checks the approval state of the target_function and writes the provided full_file_content to the specified file_path if approved or with force_override.@mcp.tool() def commit_safe_edit(target_function: str, file_path: str, full_file_content: str, force_override: bool = False) -> str: current_state = APPROVAL_STATE.get(target_function, "NONE") if current_state != "APPROVED" and not force_override: return f"⛔ SECURITY BLOCK: Integrity Score is NOT 1.0. Current state: {current_state}. Access Denied." try: file_path = os.path.normpath(file_path) with open(file_path, 'w', encoding='utf-8') as f: f.write(full_file_content) APPROVAL_STATE[target_function] = "NONE" # Сброс после записи return f"✅ SAFE COMMIT: File '{file_path}' updated." except Exception as e: return f"❌ ERROR: {str(e)}"