Skip to content

Commit a3da367

Browse files
committed
Add more tests.
1 parent b83a9bc commit a3da367

2 files changed

Lines changed: 347 additions & 2 deletions

File tree

python_agent_harness/tools/filesystem.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ def run(self, args: dict, ctx: ToolContext) -> str:
168168
return f"Error: cannot read {path}: {e}"
169169
if end is not None and reached_eof and total is not None:
170170
end = min(end, total) # clamp to the real file end
171-
if start > (total or 0):
171+
if total is None:
172+
total = 0 # empty file
173+
if start > total:
172174
return f"Error: start_line {start} > end_line {end if end is not None else total}"
173175
end_eff = end if end is not None else total
174176
if total is not None and reached_eof:
@@ -277,6 +279,8 @@ def _git_glob_results(
277279
base_depth = 1 + rel_base.count(os.sep)
278280
filtered = []
279281
for l in lines:
282+
if rel_base != "." and not (l == rel_base or l.startswith(rel_base + "/")):
283+
continue # outside the search base subtree
280284
if l.count("/") >= base_depth + depth:
281285
continue
282286
filtered.append(l)
@@ -517,6 +521,8 @@ def _parse_unified_diff(diff: str) -> list[_Hunk]:
517521
hunks: list[_Hunk] = []
518522
current: _Hunk | None = None
519523
for raw in diff.splitlines(keepends=True):
524+
if raw.lstrip().startswith("```"):
525+
continue # code fences (```diff / ```patch / ```)
520526
if raw.startswith("--- ") or raw.startswith("+++ ") or raw.startswith("diff --git"):
521527
continue
522528
m = _HUNK_HEADER_RE.match(raw)

0 commit comments

Comments
 (0)