The agent that turns websites into APIs!
fix: sync leak on error
kalil032180eb4e8c0715
diff --git a/src/reverse_api/base_engineer.py b/src/reverse_api/base_engineer.pyindex 08dba71..84f1838 100644--- a/src/reverse_api/base_engineer.py+++ b/src/reverse_api/base_engineer.py@@ -4,7 +4,7 @@ from abc import ABC, abstractmethodfrom pathlib import Pathfrom typing import Optional, Dict, Any-from .utils import get_scripts_dir, get_timestamp, generate_folder_name+from .utils import get_scripts_dir, generate_folder_namefrom .tui import ClaudeUIfrom .messages import MessageStorefrom .sync import FileSyncWatcher@@ -24,6 +24,7 @@ class BaseEngineer(ABC):verbose: bool = True,enable_sync: bool = False,sdk: str = "claude",+ is_fresh: bool = False,):self.run_id = run_idself.har_path = har_path@@ -36,6 +37,7 @@ class BaseEngineer(ABC):self.message_store = MessageStore(run_id, output_dir)self.enable_sync = enable_syncself.sdk = sdk+ self.is_fresh = is_freshself.sync_watcher: Optional[FileSyncWatcher] = Noneself.local_scripts_dir: Optional[Path] = None@@ -78,8 +80,12 @@ class BaseEngineer(ABC):def stop_sync(self):"""Stop real-time file sync."""if self.sync_watcher:- self.sync_watcher.stop()- self.sync_watcher = None+ try:+ self.sync_watcher.stop()+ except Exception as e:+ self.ui.sync_error(f"Failed to stop sync watcher: {e}")+ finally:+ self.sync_watcher = Nonedef get_sync_status(self) -> Optional[dict]:"""Get current sync status."""@@ -200,7 +206,27 @@ Your final output should confirm that the files have been created and provide af"\n\nAdditional instructions:\n{self.additional_instructions}")- return base_prompt+ tag_context = f"""+## Tag-Based Workflows++This session uses tag-based context loading:++- **@id <run_id>**: Re-engineer mode active+ - Target run: {self.run_id}+ - HAR location: {self.har_path.parent}+ - Existing scripts: {self.scripts_dir}+ - Message history: {self.message_store.messages_path.parent} (available for reference if needed)+ - Fresh mode: {str(self.is_fresh).lower()}++By default, treat this as an iterative refinement. The user's prompt describes+changes or improvements to make to the existing script. If fresh mode is enabled,+ignore previous implementation and start from scratch.++Note: Full message history is available at the messages path above if you need+to understand previous context, but it is not automatically loaded into this+conversation.+"""+ return base_prompt + tag_context@abstractmethodasync def analyze_and_generate(self) -> Optional[Dict[str, Any]]: