enable file editing tools
This commit is contained in:
parent
28d9032ca5
commit
4aeb52e41d
|
|
@ -487,7 +487,6 @@ Important Notes:
|
|||
- Do not add features not explicitly required.
|
||||
- Only create or modify files directly related to this task.
|
||||
- Use file_str_replace and put_complete_file_contents for simple file modifications.
|
||||
- Delegate to run_programming_task for more complex programming tasks. This is a capable human programmer that can work on multiple files at once.
|
||||
|
||||
Testing:
|
||||
|
||||
|
|
@ -527,8 +526,6 @@ FOLLOW TEST DRIVEN DEVELOPMENT (TDD) PRACTICES WHERE POSSIBE. E.G. COMPILE CODE
|
|||
|
||||
IF YOU CAN SEE THE CODE WRITTEN/CHANGED BY THE PROGRAMMER, TRUST IT. YOU DO NOT NEED TO RE-READ EVERY FILE WITH EVERY SMALL EDIT.
|
||||
|
||||
YOU MUST CALL emit_related_files BEFORE CALLING run_programming_task WITH ALL RELEVANT FILES, UNLESS THEY ARE ALREADY RECORDED AS RELATED FILES.
|
||||
|
||||
NEVER ANNOUNCE WHAT YOU ARE DOING, JUST DO IT!
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ from ra_aid.tools import (
|
|||
emit_key_snippet,
|
||||
emit_related_files,
|
||||
emit_research_notes,
|
||||
file_str_replace,
|
||||
put_complete_file_contents,
|
||||
fuzzy_find_project_files,
|
||||
list_directory_tree,
|
||||
read_file_tool,
|
||||
|
|
@ -78,10 +80,10 @@ def get_all_tools() -> list[BaseTool]:
|
|||
|
||||
# Define constant tool groups
|
||||
READ_ONLY_TOOLS = get_read_only_tools()
|
||||
# MODIFICATION_TOOLS = [run_programming_task, put_complete_file_contents]
|
||||
MODIFICATION_TOOLS = [
|
||||
run_programming_task
|
||||
] # having put_complete_file_contents causes trouble :(
|
||||
MODIFICATION_TOOLS = [file_str_replace, put_complete_file_contents]
|
||||
# MODIFICATION_TOOLS = [
|
||||
# run_programming_task
|
||||
# ] # having put_complete_file_contents causes trouble :(
|
||||
COMMON_TOOLS = get_read_only_tools()
|
||||
EXPERT_TOOLS = [emit_expert_context, ask_expert]
|
||||
RESEARCH_TOOLS = [
|
||||
|
|
|
|||
|
|
@ -311,7 +311,6 @@ def request_task_implementation(task_spec: str) -> Dict[str, Any]:
|
|||
}
|
||||
if work_log is not None:
|
||||
response_data["work_log"] = work_log
|
||||
print("TASK HERE", response_data)
|
||||
return response_data
|
||||
|
||||
|
||||
|
|
@ -378,5 +377,4 @@ def request_implementation(task_spec: str) -> Dict[str, Any]:
|
|||
if work_log is not None:
|
||||
response_data["work_log"] = work_log
|
||||
|
||||
print("HERE", response_data)
|
||||
return response_data
|
||||
|
|
|
|||
|
|
@ -47,11 +47,6 @@ def file_str_replace(filepath: str, old_str: str, new_str: str) -> Dict[str, any
|
|||
filepath: Path to the file to modify
|
||||
old_str: Exact string to replace
|
||||
new_str: String to replace with
|
||||
|
||||
Returns:
|
||||
Dict containing:
|
||||
- success: Whether the operation succeeded
|
||||
- message: Success confirmation or error details
|
||||
"""
|
||||
try:
|
||||
path = Path(filepath)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ def put_complete_file_contents(
|
|||
filepath: str,
|
||||
complete_file_contents: str = "",
|
||||
encoding: str = "utf-8",
|
||||
verbose: bool = True,
|
||||
) -> Dict[str, any]:
|
||||
"""Write the complete contents of a file, creating it if it doesn't exist.
|
||||
This tool is specifically for writing the entire contents of a file at once,
|
||||
|
|
@ -28,17 +27,6 @@ def put_complete_file_contents(
|
|||
complete_file_contents: Complete string content to write to the file. Defaults to
|
||||
an empty string, which will create an empty file.
|
||||
encoding: File encoding to use (default: utf-8)
|
||||
verbose: Whether to display a Rich panel with write statistics (default: True)
|
||||
|
||||
Returns:
|
||||
Dict containing:
|
||||
- success: Boolean indicating if write was successful
|
||||
- bytes_written: Number of bytes written
|
||||
- elapsed_time: Time taken in seconds
|
||||
- error: Error message if any (None if successful)
|
||||
|
||||
Raises:
|
||||
RuntimeError: If file cannot be written
|
||||
"""
|
||||
start_time = time.time()
|
||||
result = {
|
||||
|
|
@ -77,14 +65,13 @@ def put_complete_file_contents(
|
|||
f"File write complete: {bytes_written} bytes in {elapsed:.2f}s"
|
||||
)
|
||||
|
||||
if verbose:
|
||||
console.print(
|
||||
Panel(
|
||||
f"{'Initialized empty file' if not complete_file_contents else f'Wrote {bytes_written} bytes'} at {filepath} in {elapsed:.2f}s",
|
||||
title="💾 File Write",
|
||||
border_style="bright_green",
|
||||
)
|
||||
console.print(
|
||||
Panel(
|
||||
f"{'Initialized empty file' if not complete_file_contents else f'Wrote {bytes_written} bytes'} at {filepath} in {elapsed:.2f}s",
|
||||
title="💾 File Write",
|
||||
border_style="bright_green",
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
elapsed = time.time() - start_time
|
||||
|
|
@ -97,13 +84,12 @@ def put_complete_file_contents(
|
|||
else:
|
||||
result["message"] = error_msg
|
||||
|
||||
if verbose:
|
||||
console.print(
|
||||
Panel(
|
||||
f"Failed to write {filepath}\nError: {error_msg}",
|
||||
title="❌ File Write Error",
|
||||
border_style="red",
|
||||
)
|
||||
console.print(
|
||||
Panel(
|
||||
f"Failed to write {filepath}\nError: {error_msg}",
|
||||
title="❌ File Write Error",
|
||||
border_style="red",
|
||||
)
|
||||
)
|
||||
|
||||
return result
|
||||
|
|
|
|||
Loading…
Reference in New Issue