Useful ToolsShell

Shell

Shell command execution tool.

Installation

main.py
from connectonion import Shell shell = Shell()

Want to customize? Run co copy shell to get an editable copy.

API

run(command)

Execute a shell command, returns output.

main.py
result = shell.run("ls -la") # Returns: "total 12\ndrwxr-xr-x 8 user staff..." result = shell.run("git status") # Returns: "On branch main\nnothing to commit..." result = shell.run("python --version") # Returns: "Python 3.11.0"

run_in_dir(command, directory)

Execute command in a specific directory.

main.py
result = shell.run_in_dir("npm install", "/path/to/project") # Returns: "added 100 packages..." result = shell.run_in_dir("pytest", "/path/to/tests") # Returns: "5 passed in 0.5s"

Use with Agent

main.py
from connectonion import Agent, Shell shell = Shell() agent = Agent("coder", tools=[shell]) agent.input("list all python files in current directory") # Agent runs: shell.run("ls *.py") agent.input("run the tests") # Agent runs: shell.run("pytest") agent.input("install requests package") # Agent runs: shell.run("pip install requests")

Common Use Cases

main.py
# Git operations shell.run("git status") shell.run("git add .") shell.run("git commit -m 'update'") # Package management shell.run("pip install requests") shell.run("npm install express") # Build and test shell.run("pytest") shell.run("npm run build") # System info shell.run("pwd") shell.run("whoami") shell.run("df -h")

Star us on GitHub

If ConnectOnion saves you time, a ⭐ goes a long way — and earns you a coffee chat with our founder.