diff --git a/saist/llm/adapters/ollama.py b/saist/llm/adapters/ollama.py index a90cf0f..487c964 100644 --- a/saist/llm/adapters/ollama.py +++ b/saist/llm/adapters/ollama.py @@ -12,7 +12,7 @@ class OllamaAdapter(BaseLlmAdapter): def __init__(self, base_url: str, model: str = None, api_key: Optional[str] = None): if model is None: - model = "llama3.2" + model = "llama3:latest" self.model = model self.client = ollama.AsyncClient(host=base_url) diff --git a/saist/scm/adapters/filesystem.py b/saist/scm/adapters/filesystem.py index dacdb9d..49cf386 100644 --- a/saist/scm/adapters/filesystem.py +++ b/saist/scm/adapters/filesystem.py @@ -28,14 +28,14 @@ async def get_file_contents(self, filename: str): return contents except Exception as e: - logging.warn(f"ERR: {e}") + logging.warning(f"ERR: {e}") def __init__(self, compare_path: PathLike[AnyStr] | str, base_path: Optional[PathLike[AnyStr] | str] = None): self.base_path = base_path self.compare_path = compare_path def create_review(self, comment, review_comments, request_changes): - write_findings(comment,review_comments,request_changes) + write_findings(comment, review_comments, request_changes) def get_changed_files(self) -> list[File]: return list(self._iter_changed_files()) @@ -44,22 +44,26 @@ def _iter_changed_files(self) -> list[File]: logger.debug(f"Iterate changed files: base:{self.base_path}, compare:{self.compare_path}") if self.base_path is None: - diffs = [path.replace("\\","/") for path in glob.glob("**/*", root_dir=self.compare_path, recursive=True,)] - logger.debug("Changed file paths", extra={"paths": list(diffs)}) + files = [path.replace("\\","/") for path in glob.glob("**/*", root_dir=self.compare_path, recursive=True)] + logger.debug("Returning all file paths as changed files", extra={"paths": list(files)}) - for filename in [path for path in diffs if os.path.isfile(f"{self.compare_path}/{path}")]: - a_path = f"{self.compare_path}/{filename}" + for filename in files: + full_path = os.path.join(self.compare_path, filename) + + if not os.path.isfile(full_path): + continue try: - with open(a_path) as a: - patch = "".join(difflib.unified_diff([], a.readlines(), fromfile="", tofile=f"")) + with open(full_path, 'r', encoding='utf-8') as f: + file_contents = f.readlines() + + patch = "".join(difflib.unified_diff([], file_contents, fromfile="", tofile=filename)) - yield File(filename=filename, patch=patch) + yield File(filename=filename, patch=patch) except UnicodeDecodeError: - # Binary file - ignore - logger.debug(f"File is not valid UTF-8, skipping: {a_path}") + logger.debug(f"Skipping non-text file: {full_path}") - return None + return diffs = dircmp(self.base_path, self.compare_path) @@ -69,14 +73,13 @@ def _iter_changed_files(self) -> list[File]: try: with open(a_path, "r") as a, open(b_path, "r") as b: - patch = "".join(difflib.unified_diff(a.readlines(), b.readlines(), fromfile="", tofile="")) + patch = "".join(difflib.unified_diff(a.readlines(), b.readlines(), fromfile=a_path, tofile=b_path)) yield File(filename=filename, patch=patch) except UnicodeDecodeError: - # Binary file - ignore logger.warning(f"File is not valid UTF-8, skipping: {a_path}, {b_path}") @staticmethod def likely(): # TODO: implement proper logic - return True + return True \ No newline at end of file diff --git a/saist/util/filtering.py b/saist/util/filtering.py index bd73e04..3b10302 100644 --- a/saist/util/filtering.py +++ b/saist/util/filtering.py @@ -52,7 +52,7 @@ def should_process(filepath): include_patterns = load_patterns("saist.include") if not include_patterns: # Fallback to extension-based glob patterns like **/*.py - include_patterns = [f"**/*{ext}" for ext in DEFAULT_EXTENSIONS] + include_patterns = [f"**/*{ext}" for ext in DEFAULT_EXTENSIONS] + [f"*{ext}" for ext in DEFAULT_EXTENSIONS] ignore_patterns = load_patterns("saist.ignore") logger.info(f"include_patterns: {include_patterns}\nignore_patterns:{ignore_patterns}")