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.1.tar.gz (42.4 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.1-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agent_clifs-1.2.1.tar.gz
  • Upload date:
  • Size: 42.4 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.1.tar.gz
Algorithm Hash digest
SHA256 c04d111202b60612be1c010ab4ab2e721d2f4097bc25aac6d9d4e328dc7e16f3
MD5 d0feb6b6a82f099702d0cac43de9b084
BLAKE2b-256 a2596037a37cdb4df87ededf31e8a005c74ea17cd5ab35b2419d99a527deaca3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agent_clifs-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 32.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fec328009f8874dec0356dfbc89ed501fd4b4c8925d3b5a12b4883b0327d4a51
MD5 8071dc52804d2c69e29e41f9fc5b2992
BLAKE2b-256 9ae90225b10f2d7add0f0cc8ada5f2ec56c705f74e5d5418fcc65b909267e25c

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