Remove list_files tool
This commit is contained in:
27
nanocode.py
27
nanocode.py
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import glob as globlib
|
||||
from modaic import PrecompiledProgram, PrecompiledConfig
|
||||
import dspy
|
||||
import subprocess
|
||||
@@ -98,29 +97,8 @@ def edit_file(path: str, old: str, new: str, replace_all: bool = False) -> str:
|
||||
return "ok"
|
||||
|
||||
|
||||
def list_files(path: str = ".") -> str:
|
||||
"""List all files in a directory, respecting .gitignore.
|
||||
|
||||
Args:
|
||||
path: Directory to list files from
|
||||
|
||||
Returns:
|
||||
Newline-separated list of files
|
||||
"""
|
||||
print(f"{MAGENTA}⏺ List: {path}{RESET}")
|
||||
|
||||
cmd = ["rg", "--files", path]
|
||||
try:
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
|
||||
return result.stdout.strip() or "no files found"
|
||||
except FileNotFoundError:
|
||||
return "error: ripgrep (rg) not installed - install with 'brew install ripgrep'"
|
||||
except subprocess.TimeoutExpired:
|
||||
return "error: search timed out after 30s"
|
||||
|
||||
|
||||
def glob_files(pattern: str, path: str = ".") -> str:
|
||||
"""Find files matching a glob pattern, sorted by modification time.
|
||||
"""Find files by filename matching a glob pattern, sorted by modification time.
|
||||
|
||||
Respects .gitignore files automatically via ripgrep.
|
||||
|
||||
@@ -256,7 +234,6 @@ class RLMCodingProgram(PrecompiledProgram):
|
||||
"read_file": read_file,
|
||||
"write_file": write_file,
|
||||
"edit_file": edit_file,
|
||||
"list_files": list_files,
|
||||
"glob_files": glob_files,
|
||||
"grep_files": grep_files,
|
||||
"run_bash": run_bash,
|
||||
@@ -412,7 +389,7 @@ if __name__ == "__main__":
|
||||
for branch in branches:
|
||||
agent.push_to_hub(
|
||||
MODAIC_REPO_PATH,
|
||||
commit_message="Add list_files tool",
|
||||
commit_message="Remove list_files tool",
|
||||
branch=branch,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user