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-onlygit(status/diff/log/show/branch). - Edit:
apply_git_patch(unified diff — the primary edit path), plusreplace,insert,rewrite_file/write_new_filefor 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
Metadata
Release files for ai-shell 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ai_shell-2.0.0.tar.gz | 446.9 kB | With provenance | Details for ai_shell-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_shell-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for ai_shell-2.0.0-py3-none-any.whl |
Total release size: 544.5 kB
Release files / ai_shell-2.0.0.tar.gz
| Download URL | ai_shell-2.0.0.tar.gz |
|---|---|
| Size | 446.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f682d85162e7650eb8ee174d7831cc1fdbffd3ee53061dab252bf9e765145386
|
|
BLAKE2b-256 checksum How to use checksums |
3e51dba8e13cee42468583e6b4798051f6702df1f97beb4bd55b1036112e7d15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logRelease files / ai_shell-2.0.0-py3-none-any.whl
| Download URL | ai_shell-2.0.0-py3-none-any.whl |
|---|---|
| Size | 97.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d76e1646e2dc192e7720e0fedd1613e5d35d45d536cb549747adc6b6b5be27ec
|
|
BLAKE2b-256 checksum How to use checksums |
b3644421b7c83d57d2c51a69282ec4e3fe9fa9c099f4ef67a35d88c377e872b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logSecurity for ai-shell 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ai_shell-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.