make write_file tool available and fix empty dir creation bug
This commit is contained in:
parent
7b42ab569c
commit
5b0e759f3a
|
|
@ -15,7 +15,7 @@ from ra_aid.tools import (
|
||||||
emit_research_notes, emit_plan, emit_related_files, emit_task,
|
emit_research_notes, emit_plan, emit_related_files, emit_task,
|
||||||
emit_expert_context, get_memory_value, emit_key_facts, delete_key_facts,
|
emit_expert_context, get_memory_value, emit_key_facts, delete_key_facts,
|
||||||
emit_key_snippets, delete_key_snippets,
|
emit_key_snippets, delete_key_snippets,
|
||||||
emit_research_subtask, request_implementation, read_file_tool, fuzzy_find_project_files, ripgrep_search, list_directory_tree,
|
emit_research_subtask, request_implementation, read_file_tool, write_file_tool, fuzzy_find_project_files, ripgrep_search, list_directory_tree,
|
||||||
file_str_replace
|
file_str_replace
|
||||||
)
|
)
|
||||||
from ra_aid.tools.memory import _global_memory, get_related_files
|
from ra_aid.tools.memory import _global_memory, get_related_files
|
||||||
|
|
@ -38,6 +38,7 @@ COMMON_TOOLS = [
|
||||||
emit_key_snippets,
|
emit_key_snippets,
|
||||||
delete_key_snippets,
|
delete_key_snippets,
|
||||||
read_file_tool,
|
read_file_tool,
|
||||||
|
write_file_tool,
|
||||||
fuzzy_find_project_files,
|
fuzzy_find_project_files,
|
||||||
ripgrep_search,
|
ripgrep_search,
|
||||||
file_str_replace
|
file_str_replace
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,10 @@ def write_file_tool(
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Ensure directory exists
|
# Ensure directory exists if filepath contains directories
|
||||||
os.makedirs(os.path.dirname(filepath), exist_ok=True)
|
dirpath = os.path.dirname(filepath)
|
||||||
|
if dirpath:
|
||||||
|
os.makedirs(dirpath, exist_ok=True)
|
||||||
|
|
||||||
logging.debug(f"Starting to write file: {filepath}")
|
logging.debug(f"Starting to write file: {filepath}")
|
||||||
|
|
||||||
|
|
@ -71,7 +73,6 @@ def write_file_tool(
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
elapsed = time.time() - start_time
|
elapsed = time.time() - start_time
|
||||||
error_msg = str(e)
|
error_msg = str(e)
|
||||||
logging.error(f"Error writing file {filepath} after {elapsed:.2f}s: {error_msg}")
|
|
||||||
|
|
||||||
result["elapsed_time"] = elapsed
|
result["elapsed_time"] = elapsed
|
||||||
result["error"] = error_msg
|
result["error"] = error_msg
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue