Skip to main content

Safer, sandboxed token-aware filesystem tools for LLM agents.

Project description

ai_shell

Safe, token-aware filesystem tools for LLM agents.

ai_shell is a library of familiar shell-like tools — cat, ls, grep, find, head/tail, cut, sed, git, unified-diff patching, and a few more — reimplemented in pure Python, jailed to a root folder, and tuned to return useful, token-bounded output (with optional markdown variants). They are provider-agnostic: wire them into any agent via the generated JSON Schemas and a neutral dispatch table. Bring your own agent loop.

History: this started in 2023 as an OpenAI-Assistant shell, before Claude Code / aider / open-interpreter existed. That bot runtime has been removed; what remains is the part that was actually worth keeping — the safe tools.

Install

pip install ai-shell

Optional linters/formatters/test-runners used by the goal-checker helpers:

pip install "ai-shell[checkers]"

Use as a library

Each tool is a small class scoped to a root folder. Tools refuse to read or write outside that folder.

import ai_shell

config = ai_shell.Config()

cat = ai_shell.CatTool(".", config)
print(cat.cat_markdown(["pyproject.toml"]))

ls = ai_shell.LsTool(".", config)
print(ls.ls_markdown(path="."))

Use with any tool-calling model

ai_shell exposes JSON Schemas for the tools and a neutral dispatcher. Register the schemas with your model, then route each tool call through ToolKit.dispatch(name, arguments):

import ai_shell
from ai_shell.tools_registry import ALL_TOOLS, initialize_all_tools

# Pick the tools you want to expose.
tool_names = ["ls", "cat_markdown", "grep", "apply_git_patch"]
initialize_all_tools(keeps=tool_names)

toolkit = ai_shell.ToolKit(
    root_folder=".", token_model="gpt-4o", global_max_lines=500,
    permitted_tools=tool_names, config=ai_shell.Config(),
)

# `ALL_TOOLS` holds the JSON Schemas to hand to your model.
# When the model asks for a tool, dispatch it:
result_json = toolkit.dispatch("ls", {"path": "."})

dispatch enforces the per-session tool allowlist, tracks usage stats, applies optional media-type conversion, and converts errors to RFC7807 JSON so a model can read and recover from them.

CLI (sanity harness)

A generated CLI mirrors the tools — handy for checking a tool behaves before giving it to a model:

ais cat_markdown --file-paths pyproject.toml
ais grep --regex "def " --glob-pattern "ai_shell/*.py"

Tools

  • Read: ls, find, cat, grep, head/tail, cut, pycat (python-aware), count_tokens, and read-only git (status/diff/log/show/branch).
  • Edit: apply_git_patch (unified diff — the primary edit path), plus replace, insert, rewrite_file / write_new_file for non-diff edits.
  • Tasking: a small TODO store (ai_shell.todo) for splitting work into verifiable items — see ai_shell/todo/README.md.

Every file is read and written as UTF-8.

Project links

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

ai_shell-2.0.0.tar.gz (446.9 kB view details)

Uploaded Source

Built Distribution

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

ai_shell-2.0.0-py3-none-any.whl (97.6 kB view details)

Uploaded Python 3

File details

Details for the file ai_shell-2.0.0.tar.gz.

File metadata

  • Download URL: ai_shell-2.0.0.tar.gz
  • Upload date:
  • Size: 446.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ai_shell-2.0.0.tar.gz
Algorithm Hash digest
SHA256 f682d85162e7650eb8ee174d7831cc1fdbffd3ee53061dab252bf9e765145386
MD5 00087c5eb78fcc8942e2a844c6348e38
BLAKE2b-256 3e51dba8e13cee42468583e6b4798051f6702df1f97beb4bd55b1036112e7d15

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_shell-2.0.0.tar.gz:

Publisher: release.yml on matthewdeanmartin/ai_shell

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_shell-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: ai_shell-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 97.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ai_shell-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d76e1646e2dc192e7720e0fedd1613e5d35d45d536cb549747adc6b6b5be27ec
MD5 e57d5cb111a701a6ef888d4797bd6d16
BLAKE2b-256 b3644421b7c83d57d2c51a69282ec4e3fe9fa9c099f4ef67a35d88c377e872b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_shell-2.0.0-py3-none-any.whl:

Publisher: release.yml on matthewdeanmartin/ai_shell

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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