Remove list_files tool
This commit is contained in:
30
nanocode.py
30
nanocode.py
@@ -24,7 +24,7 @@ MAGENTA = "\033[35m"
|
||||
|
||||
|
||||
def read_file(path: str, offset: int = 0, limit: int = None) -> str:
|
||||
"""Read file contents with line numbers.
|
||||
"""[EXTERNAL FILESYSTEM] Read file contents from disk with line numbers.
|
||||
|
||||
Args:
|
||||
path: Path to the file to read
|
||||
@@ -45,7 +45,7 @@ def read_file(path: str, offset: int = 0, limit: int = None) -> str:
|
||||
|
||||
|
||||
def write_file(path: str, content: str) -> str:
|
||||
"""Write content to a file.
|
||||
"""[EXTERNAL FILESYSTEM] Write content to a file on disk (creates or overwrites).
|
||||
|
||||
Args:
|
||||
path: Path to the file to write
|
||||
@@ -72,7 +72,7 @@ def write_file(path: str, content: str) -> str:
|
||||
|
||||
|
||||
def edit_file(path: str, old: str, new: str, replace_all: bool = False) -> str:
|
||||
"""Replace text in a file.
|
||||
"""[EXTERNAL FILESYSTEM] Replace text in a file on disk.
|
||||
|
||||
Args:
|
||||
path: Path to the file to edit
|
||||
@@ -98,9 +98,9 @@ def edit_file(path: str, old: str, new: str, replace_all: bool = False) -> str:
|
||||
|
||||
|
||||
def glob_files(pattern: str, path: str = ".") -> str:
|
||||
"""Find files by filename matching a glob pattern, sorted by modification time.
|
||||
"""[EXTERNAL FILESYSTEM] Find files on disk matching a glob pattern.
|
||||
|
||||
Respects .gitignore files automatically via ripgrep.
|
||||
Respects .gitignore files automatically via ripgrep. Sorted by modification time.
|
||||
|
||||
Args:
|
||||
pattern: Glob pattern to match (e.g., '**/*.py')
|
||||
@@ -128,7 +128,7 @@ def glob_files(pattern: str, path: str = ".") -> str:
|
||||
|
||||
|
||||
def grep_files(pattern: str, path: str = ".", glob: str = None, max_results: int = 50) -> str:
|
||||
"""Search files for a regex pattern using ripgrep.
|
||||
"""[EXTERNAL FILESYSTEM] Search files on disk for a regex pattern using ripgrep.
|
||||
|
||||
Args:
|
||||
pattern: Regular expression pattern to search for
|
||||
@@ -160,7 +160,7 @@ def grep_files(pattern: str, path: str = ".", glob: str = None, max_results: int
|
||||
|
||||
|
||||
def run_bash(cmd: str) -> str:
|
||||
"""Run a shell command and return output.
|
||||
"""[EXTERNAL SYSTEM] Run a shell command on the host machine.
|
||||
|
||||
Args:
|
||||
cmd: Shell command to execute
|
||||
@@ -204,7 +204,21 @@ class RLMReasoningCallback(BaseCallback):
|
||||
|
||||
|
||||
class CodingAssistant(dspy.Signature):
|
||||
"""You are a concise coding assistant with access to sub agents."""
|
||||
"""You are a concise coding assistant.
|
||||
|
||||
CRITICAL - Two execution environments exist:
|
||||
|
||||
1. INTERNAL REPL (sandbox): Standard Python code you write executes in an isolated sandbox. Variables persist between iterations. Use for data processing, string manipulation, logic, loops, etc.
|
||||
|
||||
2. EXTERNAL TOOLS (real system): Functions like read_file(), write_file(), run_bash(), glob_files(), grep_files() execute OUTSIDE the sandbox on the real filesystem and host machine. These have real, persistent side effects.
|
||||
|
||||
When you need to:
|
||||
- Process data, do math, manipulate strings, iterate → write Python code directly in the REPL
|
||||
- Read/write actual files on disk → call read_file(), write_file(), edit_file()
|
||||
- Run shell commands on the host → call run_bash()
|
||||
- Search the codebase → call glob_files(), grep_files()
|
||||
|
||||
Do NOT confuse REPL variables with external files. Reading a file into a variable does not mean the variable updates if the file changes - you must call read_file() again."""
|
||||
|
||||
task: str = dspy.InputField(desc="The user's coding task or question")
|
||||
answer: str = dspy.OutputField(
|
||||
|
||||
Reference in New Issue
Block a user