Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion saist/llm/adapters/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
33 changes: 18 additions & 15 deletions saist/scm/adapters/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)

Expand All @@ -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
2 changes: 1 addition & 1 deletion saist/util/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")