Skip to main content

A CLI-driven virtual filesystem for AI agents

Project description

agent-clifs

A virtual filesystem for AI agents. Unix commands they already know. Zero dependencies.


Load documents, codebases, or any text into an in-memory filesystem and let your AI agent explore it with ls, grep, find, tree, and more.

Install

pip install agent-clifs

Quick Start

from agent_clifs import AgentCLI

cli = AgentCLI()

# Load your content
cli.execute("mkdir -p /docs/api")
cli.execute("write /docs/api/users.md '# Users API\nGET /users\nPOST /users'")
cli.execute("write /docs/api/auth.md '# Auth API\nPOST /auth/login'")

# An agent explores just like a developer would
cli.execute("tree /docs")              # See the structure
cli.execute("grep -rn 'POST' /docs")   # Search for patterns
cli.execute("cat /docs/api/users.md")  # Read a file

Bulk Loading

The most common pattern — load from a dictionary:

from agent_clifs import AgentCLI, VirtualFileSystem

vfs = VirtualFileSystem()
vfs.load_from_dict({
    "/src/app.py": "from flask import Flask\napp = Flask(__name__)",
    "/src/models.py": "class User:\n    ...",
    "/docs/setup.md": "# Setup\nRun `pip install -r requirements.txt`",
})

cli = AgentCLI(vfs)
cli.execute("find /src -name '*.py'")

Use with Any Agent Framework

Just pass cli.execute as a tool function:

from langchain.tools import Tool

tool = Tool(
    name="filesystem",
    description="Execute filesystem commands: ls, cat, grep, find, tree, head, tail, wc",
    func=cli.execute,
)

AgentCLI Configuration

AgentCLI(
    vfs=None,
    structured=False,
    readonly=False,
    allowed_commands=None,
    disabled_commands=None,
)
Parameter Type Default Description
vfs VirtualFileSystem | None None Existing VFS to use; creates a new empty one if omitted
structured bool | set[str] False LLM-optimized output (see below)
readonly bool False Disable all write commands (write, append, rm, cp, mv, mkdir, touch)
allowed_commands set[str] | None None Whitelist of permitted commands; mutually exclusive with disabled_commands
disabled_commands set[str] | None None Blacklist of forbidden commands; mutually exclusive with allowed_commands

structured mode

Controls token-efficient output formatting for LLM consumption:

  • False — raw Unix-style output (default)
  • True — apply LLM formatting to all supported commands: ls, tree, grep, find, wc
  • set[str] — apply formatting only to the specified commands, e.g. structured={"grep", "tree"}
cli = AgentCLI(structured=True)
# grep (standard)                    # grep (structured)
/docs/api/auth.md:3:POST /api/auth   [/docs/api/auth.md]
/docs/api/users.md:3:POST /api/users   L3: POST /api/auth
                                     [/docs/api/users.md]
                                       L3: POST /api/users

Command access control

# Only allow read commands
cli = AgentCLI(allowed_commands={"ls", "cat", "grep", "find", "tree", "head", "tail", "wc", "pwd"})

# Or just disable specific ones
cli = AgentCLI(disabled_commands={"rm", "mv"})

# Shorthand for disabling all writes
cli = AgentCLI(readonly=True)

Commands

Pipes (|) and output redirection (>, >>) are supported between commands.

Command Description Key Flags
ls List directory -l -h -R -S -a -d -1 -r -F
tree Directory tree -L -d -a
cat Display files -n -b -s
head / tail First/last lines -n -c
grep Search contents -r -i -n -l -c -v -w -x -F -o -A/-B/-C --include --exclude --max-depth
find Find files/dirs -name -iname -type -path -size -empty -maxdepth -mindepth -delete
sed Stream editor -n -e; supports p, d, q, = commands
wc Count lines/words/bytes -l -w -c -m
mkdir Create directory -p -v
touch Create empty file -c
write Write content to file write <path> <content>
append Append content to file append <path> <content>
cp Copy -r -a -n -v
mv Move/rename -f -n -v
rm Remove -r -f -v
pwd / cd Navigate cd - cd ~

Use cli.help() for full help text, or cli.help("grep") for a specific command.

Python API

Direct access to the underlying VFS:

from agent_clifs import VirtualFileSystem

vfs = VirtualFileSystem()
vfs.load_from_dict({"/file.txt": "hello"})  # bulk load
content = vfs.read_file("/file.txt")         # read
vfs.write_file("/new.txt", "world")          # write
vfs.mkdir("/data", parents=True)             # create directory
snapshot = vfs.to_dict()                     # export as {path: content}

License

Unlicense — public domain.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_clifs-1.2.0.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_clifs-1.2.0-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

Details for the file agent_clifs-1.2.0.tar.gz.

File metadata

  • Download URL: agent_clifs-1.2.0.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for agent_clifs-1.2.0.tar.gz
Algorithm Hash digest
SHA256 35fd2cb42d672ee8425e9946f0400ccac7593fa4eef63451c70718c2e8b3951a
MD5 eb26b227dbaf39911b0e86b8f4e11bb7
BLAKE2b-256 9cc0855dda0a5bb45bfcb7e7c51fbae0b3e367b971b7fee8fd4a3ab4650784a1

See more details on using hashes here.

File details

Details for the file agent_clifs-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: agent_clifs-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for agent_clifs-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6965233be4ed7c2c3cb85c833d838f40ea75ff9f7c256ba4a27121c4fcfd589
MD5 67959b81c8c8298656535125f0e689f6
BLAKE2b-256 8533584b55d73a291d4f822898c04adbb9df7ae388591ca0b6224879ecb6b226

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page