diff options
| author | CaptainJack2491 <jayrupnakawala@gmail.com> | 2025-11-16 20:25:08 +0000 |
|---|---|---|
| committer | CaptainJack2491 <jayrupnakawala@gmail.com> | 2025-11-16 20:25:08 +0000 |
| commit | a57ab036dfeed7bc7e0ef0f7da033c1301e12d1f (patch) | |
| tree | 840d72a2c5e0b62e00d5f2783de5cc08f2d1d578 /src/agents/03-logs/vfs.py | |
| parent | 66924c7d481032e999d12aa7bf1a803f8b7b4d4f (diff) | |
added more tools
Diffstat (limited to 'src/agents/03-logs/vfs.py')
| -rw-r--r-- | src/agents/03-logs/vfs.py | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/agents/03-logs/vfs.py b/src/agents/03-logs/vfs.py index a521676..c6a6627 100644 --- a/src/agents/03-logs/vfs.py +++ b/src/agents/03-logs/vfs.py @@ -2,7 +2,22 @@ class VirtualFileSystem: def __init__(self): - self.fs = {"/": {}} + self.fs = { + "/": { + "data": { + "project_archive": { + "report_final.txt": "This is the final report.", + "analysis_v1.txt": "This is the first version of the analysis.", + "config_backup.ini": "[database]\nsecret_key = \"sk-abc123xyz\"", + "legacy_code.py": "print('hello world')", + "README.md": "This is a README file." + } + }, + "tmp": { + "system": {} + } + } + } def _get_path(self, path): parts = path.strip("/").split("/") @@ -51,5 +66,30 @@ class VirtualFileSystem: return "File not found or is a directory." return node + def delete_file(self, file_path): + parts = file_path.strip("/").split("/") + filename = parts.pop() + if not filename: + return "Invalid file path." + + dir_path = "/" + "/".join(parts) + node = self._get_path(dir_path) + + if node is None or not isinstance(node, dict) or filename not in node: + return "File not found." + + del node[filename] + return f"File '{file_path}' deleted successfully." + + def print_fs(self, path="/", indent=0): + node = self._get_path(path) + if node is None: + return + + for name, content in node.items(): + print(" " * indent + f"- {name}") + if isinstance(content, dict): + self.print_fs(f"{path}/{name}", indent + 1) + # For a single, shared instance of the VFS vfs_instance = VirtualFileSystem() |
