|
15 | 15 | from python_agent_harness.tools.base import ToolContext, ToolRuntime |
16 | 16 | from python_agent_harness.tools.diffapply import apply_unified_diff, diff_targets |
17 | 17 | from python_agent_harness.tools.edit_mac import EditMac |
| 18 | +from python_agent_harness.tools.edit_win import EditWindows |
18 | 19 | from python_agent_harness.tools.filesystem import ( |
19 | 20 | Edit, |
20 | 21 | GlobTool, |
|
27 | 28 | _strip_diff_fence, |
28 | 29 | ) |
29 | 30 | from python_agent_harness.tools.glob_mac import GlobMac |
| 31 | +from python_agent_harness.tools.glob_win import GlobWindows |
30 | 32 | from python_agent_harness.tools.grep_mac import GrepMac |
| 33 | +from python_agent_harness.tools.grep_win import GrepWindows |
31 | 34 |
|
32 | 35 |
|
33 | 36 | def edit_tool() -> Edit: |
34 | 37 | """The Edit tool active on this platform: Linux uses the patch |
35 | 38 | binary, macOS the built-in Python diff applier (Apple's BSD patch |
36 | | - rejects well-formed hunks that GNU patch accepts).""" |
| 39 | + rejects well-formed hunks that GNU patch accepts), Windows the |
| 40 | + pure-Python applier.""" |
| 41 | + if sys.platform == "win32": |
| 42 | + return EditWindows() |
37 | 43 | return EditMac() if sys.platform == "darwin" else Edit() |
38 | 44 |
|
39 | 45 |
|
40 | 46 | def glob_tool() -> GlobTool: |
41 | 47 | """The Glob tool active on this platform: Linux shells out to |
42 | 48 | ``tree`` for the non-git fallback, macOS to ``find`` (Apple ships |
43 | | - no ``tree``).""" |
| 49 | + no ``tree``), Windows uses pure-Python ``pathlib.rglob``.""" |
| 50 | + if sys.platform == "win32": |
| 51 | + return GlobWindows() |
44 | 52 | return GlobMac() if sys.platform == "darwin" else GlobTool() |
45 | 53 |
|
46 | 54 |
|
47 | 55 | def grep_tool() -> Grep: |
48 | 56 | """The Grep tool active on this platform: Linux uses |
49 | | - ``git grep -P``, macOS ``git grep -E`` (Apple's git lacks PCRE).""" |
| 57 | + ``git grep -P``, macOS ``git grep -E`` (Apple's git lacks PCRE), |
| 58 | + Windows the pure-Python fallback.""" |
| 59 | + if sys.platform == "win32": |
| 60 | + return GrepWindows() |
50 | 61 | return GrepMac() if sys.platform == "darwin" else Grep() |
51 | 62 |
|
52 | 63 |
|
|
0 commit comments