$npx -y skills add 24601/surreal-skills --skill surrealfsSurrealFS virtual filesystem for AI agents. Rust core + Python agent (Pydantic AI). Persistent file operations backed by SurrealDB. Part of the surreal-skills collection.
| 1 | # SurrealFS -- Virtual Filesystem for AI Agents |
| 2 | |
| 3 | SurrealFS provides a persistent, queryable virtual filesystem backed by SurrealDB. |
| 4 | Designed for AI agents that need durable file operations, hierarchical storage, |
| 5 | and content search across sessions. |
| 6 | |
| 7 | ## Components |
| 8 | |
| 9 | | Component | Crate/Package | Language | Purpose | |
| 10 | |-----------|---------------|----------|---------| |
| 11 | | Core Library | `surrealfs` | Rust | Filesystem operations, CLI REPL, SurrealDB storage layer | |
| 12 | | AI Agent | `surrealfs-ai` | Python (Pydantic AI) | Agent interface with tool integration, HTTP hosting | |
| 13 | |
| 14 | ## Rust Core -- Commands |
| 15 | |
| 16 | The `surrealfs` crate provides a REPL with POSIX-like commands: |
| 17 | |
| 18 | | Command | Description | |
| 19 | |---------|-------------| |
| 20 | | `ls` | List directory contents | |
| 21 | | `cat` | Display file contents | |
| 22 | | `tail` | Show last lines of a file | |
| 23 | | `nl` | Number lines of a file | |
| 24 | | `grep` | Search file contents | |
| 25 | | `touch` | Create empty file | |
| 26 | | `mkdir` | Create directory | |
| 27 | | `write_file` | Write content to file | |
| 28 | | `edit` | Edit file contents | |
| 29 | | `cp` | Copy file | |
| 30 | | `cd` | Change directory | |
| 31 | | `pwd` | Print working directory | |
| 32 | |
| 33 | Supports piping from external commands: `curl https://example.com > /pages/example.html` |
| 34 | |
| 35 | Storage backends: |
| 36 | - Embedded RocksDB (local) |
| 37 | - Remote SurrealDB via WebSocket |
| 38 | |
| 39 | ## Python AI Agent |
| 40 | |
| 41 | Built on Pydantic AI with tools that mirror the filesystem commands. |
| 42 | |
| 43 | ```python |
| 44 | from surrealfs_ai import build_chat_agent |
| 45 | |
| 46 | # Create the agent (default LLM: Claude Haiku) |
| 47 | agent = build_chat_agent() |
| 48 | |
| 49 | # Expose over HTTP |
| 50 | import uvicorn |
| 51 | app = agent.to_web() |
| 52 | uvicorn.run(app, host="127.0.0.1", port=7932) |
| 53 | ``` |
| 54 | |
| 55 | Features: |
| 56 | - Default LLM: Claude Haiku |
| 57 | - Telemetry via Pydantic Logfire (OpenTelemetry) -- see Security section for opt-out |
| 58 | - All filesystem operations available as agent tools |
| 59 | - HTTP hosting (default port 7932, bound to 127.0.0.1) |
| 60 | - Path normalization: virtual FS root `/` is isolated; paths cannot escape to host filesystem |
| 61 | |
| 62 | ## Quick Start |
| 63 | |
| 64 | ```bash |
| 65 | # Install the Rust core |
| 66 | cargo install surrealfs |
| 67 | |
| 68 | # Start the REPL with embedded storage |
| 69 | surrealfs |
| 70 | |
| 71 | # Or connect to a remote SurrealDB instance |
| 72 | surrealfs --endpoint ws://localhost:8000 --user root --pass root --ns agent --db workspace |
| 73 | |
| 74 | # Install the Python agent |
| 75 | pip install surrealfs-ai |
| 76 | |
| 77 | # Run the agent HTTP server |
| 78 | python -m surrealfs_ai --host 127.0.0.1 --port 7932 |
| 79 | ``` |
| 80 | |
| 81 | ## Use Cases |
| 82 | |
| 83 | - Persistent workspace for AI agent sessions |
| 84 | - Hierarchical document storage with metadata queries |
| 85 | - Multi-agent shared file access with SurrealDB permissions |
| 86 | - Content strategy and knowledge management |
| 87 | - Project scaffolding and template management |
| 88 | |
| 89 | ## Security Considerations |
| 90 | |
| 91 | **Credentials**: Remote SurrealDB connections require `--user`/`--pass`. Use |
| 92 | dedicated, least-privilege credentials scoped to a specific namespace/database. |
| 93 | Never use `root` credentials in shared or production environments. |
| 94 | |
| 95 | **Telemetry**: The Python agent uses Pydantic Logfire (OpenTelemetry). To |
| 96 | disable telemetry, set: `export LOGFIRE_SEND_TO_LOGFIRE=false` or configure |
| 97 | Logfire with `send_to_logfire=False` in code. Audit telemetry endpoints before |
| 98 | enabling in environments with sensitive data. |
| 99 | |
| 100 | **HTTP binding**: The agent binds to `127.0.0.1` by default. Do not expose to |
| 101 | `0.0.0.0` or public networks without authentication and TLS. If running in a |
| 102 | container, use network isolation. |
| 103 | |
| 104 | **Pipe commands**: The Rust core supports `curl URL > /path` syntax for content |
| 105 | ingress. This executes the pipe source command on the host. Use only with |
| 106 | trusted URLs in controlled environments. Do not allow untrusted input to |
| 107 | construct pipe commands. |
| 108 | |
| 109 | **Sandboxing**: The virtual FS root (`/`) is a SurrealDB-backed abstraction, |
| 110 | not the host filesystem. Path traversal (e.g., `../../etc/passwd`) is |
| 111 | normalized and rejected. However, pipe commands execute on the host -- run |
| 112 | in a container or sandbox if accepting untrusted agent input. |
| 113 | |
| 114 | ## Full Documentation |
| 115 | |
| 116 | See the main skill's rule file for complete guidance: |
| 117 | - **[rules/s |