Coverage for integrations / coding_agent / aider_core / io_adapter.py: 56.5%

23 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-12 04:49 +0000

1""" 

2Minimal IO adapter replacing Aider's InputOutput class. 

3 

4Aider's repomap.py and repo.py call self.io.read_text(), self.io.tool_output(), 

5self.io.tool_warning(), self.io.tool_error(). This adapter provides those methods 

6using standard Python I/O, no terminal dependencies. 

7""" 

8import logging 

9import os 

10from pathlib import Path 

11 

12logger = logging.getLogger('hevolve.coding_agent.aider_core') 

13 

14 

15class SimpleIO: 

16 """Minimal IO adapter for vendored Aider modules. 

17 

18 Replaces Aider's rich InputOutput class with plain logging and file reads. 

19 """ 

20 

21 def __init__(self, encoding='utf-8'): 

22 self.encoding = encoding 

23 

24 def read_text(self, fname): 

25 """Read a file's text content.""" 

26 try: 

27 return Path(fname).read_text(encoding=self.encoding, errors='replace') 

28 except (OSError, UnicodeDecodeError) as e: 

29 logger.warning(f"Could not read {fname}: {e}") 

30 return None 

31 

32 def tool_output(self, msg='', log_only=False): 

33 """Log a tool output message.""" 

34 logger.info(msg) 

35 

36 def tool_warning(self, msg=''): 

37 """Log a warning.""" 

38 logger.warning(msg) 

39 

40 def tool_error(self, msg=''): 

41 """Log an error.""" 

42 logger.error(msg) 

43 

44 def get_input(self, *args, **kwargs): 

45 """Not used in headless mode.""" 

46 return '' 

47 

48 def confirm_ask(self, *args, **kwargs): 

49 """Auto-confirm in headless mode.""" 

50 return True