"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix: tilde expansion in file tools — safe_path doesn't expand ~, causing paths like ~/.vibe-trading/ to resolve to root/~/.vibe-trading/ (nonsense). Now all three tools (read/write/edit) expand tildes before path validation.
skloxo5561a548d710
diff --git a/agent/src/tools/edit_file_tool.py b/agent/src/tools/edit_file_tool.pyindex eefc5de21..fa12020d9 100644--- a/agent/src/tools/edit_file_tool.py+++ b/agent/src/tools/edit_file_tool.py@@ -63,8 +63,18 @@ class EditFileTool(BaseTool):try:run_root = _safe_run_dir(str(run_dir))resolved = _safe_path(file_path, run_root)- except ValueError as exc:- # Fallback: check if path resolves inside a configured extra file root+ except ValueError:+ pass+ else:+ # _safe_path may not expand tildes; verify path is valid+ if not resolved.exists():+ candidate = Path(file_path).expanduser().resolve()+ if candidate.is_absolute():+ for extra_root in _allowed_file_roots():+ if candidate.is_relative_to(extra_root):+ resolved = candidate+ break+ if not resolved or (not resolved.exists()):candidate = Path(file_path).expanduser().resolve()allowed = Falsefor extra_root in _allowed_file_roots():@@ -76,7 +86,7 @@ class EditFileTool(BaseTool):return json.dumps({"status": "error",- "error": str(exc),+ "error": f"Path {file_path!r} is outside allowed workspace",},ensure_ascii=False,)diff --git a/agent/src/tools/read_file_tool.py b/agent/src/tools/read_file_tool.pyindex 92ffcc5fc..d0c7a332a 100644--- a/agent/src/tools/read_file_tool.py+++ b/agent/src/tools/read_file_tool.py@@ -71,6 +71,7 @@ class ReadFileTool(BaseTool):paths_to_try.append(file_path[len("skills/") :])resolved = None+ expanded_candidate = Path(file_path).expanduser().resolve()for root in allowed_roots:for p in paths_to_try:try:@@ -79,7 +80,11 @@ class ReadFileTool(BaseTool):resolved = candidatebreakexcept ValueError:- continue+ pass+ # _safe_path doesn't expand tildes; try expanded path directly+ if expanded_candidate.is_absolute() and expanded_candidate.is_relative_to(root) and expanded_candidate.exists():+ resolved = expanded_candidate+ breakif resolved:breakdiff --git a/agent/src/tools/write_file_tool.py b/agent/src/tools/write_file_tool.pyindex 293c4d9f5..271052924 100644--- a/agent/src/tools/write_file_tool.py+++ b/agent/src/tools/write_file_tool.py@@ -61,8 +61,18 @@ class WriteFileTool(BaseTool):try:run_root = _safe_run_dir(str(run_dir))resolved = _safe_path(file_path, run_root)- except ValueError as exc:- # Fallback: check if path resolves inside a configured extra file root+ except ValueError:+ pass+ else:+ # _safe_path may not expand tildes; verify path is valid+ if not resolved.exists():+ candidate = Path(file_path).expanduser().resolve()+ if candidate.is_absolute():+ for extra_root in _allowed_file_roots():+ if candidate.is_relative_to(extra_root):+ resolved = candidate+ break+ if not resolved or (not resolved.exists() and not resolved.parent.exists()):candidate = Path(file_path).expanduser().resolve()allowed = Falsefor extra_root in _allowed_file_roots():@@ -74,7 +84,7 @@ class WriteFileTool(BaseTool):return json.dumps({"status": "error",- "error": str(exc),+ "error": f"Path {file_path!r} is outside allowed workspace",},ensure_ascii=False,)