This document provides guidance for LLMs using Jido.Shell for file and shell operations.
# Create a session with in-memory VFS
{:ok, session} = Jido.Shell.Agent.new("my_workspace")# Synchronous command execution
{:ok, output} = Jido.Shell.Agent.run(session, "ls")
{:ok, output} = Jido.Shell.Agent.run(session, "pwd")
{:ok, output} = Jido.Shell.Agent.run(session, "cat /path/to/file")
# Multiple commands
results = Jido.Shell.Agent.run_all(session, ["mkdir /dir", "cd /dir", "pwd"])# Persistent sandboxed Bash
{:ok, bash_session} =
Jido.Shell.Agent.new("my_workspace",
backend: {Jido.Shell.Backend.Bash, %{}})
# Persistent sandboxed Lua VM
{:ok, lua_session} =
Jido.Shell.Agent.new("my_workspace",
backend: {Jido.Shell.Backend.Lua, %{}})
{:ok, output} =
Jido.Shell.Agent.run(lua_session, ~S|jido.echo("hello", "lua")|)Lua scripts must call registered commands through the jido.* namespace. Host
I/O, require, file loading, and os.execute are sandboxed by Lua.new/0;
filesystem access goes through bridged Jido commands and the VFS.
# Write files
:ok = Jido.Shell.Agent.write_file(session, "/path/to/file.txt", "content")
# Read files
{:ok, content} = Jido.Shell.Agent.read_file(session, "/path/to/file.txt")
# List directory
{:ok, entries} = Jido.Shell.Agent.list_dir(session, "/path")# Get current directory
cwd = Jido.Shell.Agent.cwd(session)
# Get full state
{:ok, state} = Jido.Shell.Agent.state(session)# Always stop sessions when done
:ok = Jido.Shell.Agent.stop(session)| Command | Usage | Description |
|---|---|---|
echo |
echo hello world |
Print text |
pwd |
pwd |
Print working directory |
cd |
cd /path |
Change directory |
ls |
ls [path] |
List directory |
cat |
cat file |
Display file contents |
write |
write file content |
Write to file |
mkdir |
mkdir dir |
Create directory |
rm |
rm file |
Remove file |
cp |
cp src dest |
Copy file |
env |
env VAR=value |
Set environment variable |
bash |
bash -c "script" |
Execute sandboxed Bash script |
help |
help [cmd] |
Show help |
- Use absolute paths when possible to avoid ambiguity
- Check command results - handle
{:error, _}tuples appropriately - Create directories before writing files in them
- Stop sessions when done to free resources
- Use
run_allfor sequential operations that depend on each other
case Jido.Shell.Agent.run(session, "cat /missing.txt") do
{:ok, output} -> handle_output(output)
{:error, %Jido.Shell.Error{code: {:vfs, :not_found}}} -> handle_missing()
{:error, error} -> handle_error(error)
end{:vfs, :not_found}- File or directory not found{:vfs, :not_directory}- Expected directory, got file{:shell, :unknown_command}- Command not recognized{:shell, :busy}- Another command is running{:command, :timeout}- Command timed out