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-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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f682d85162e7650eb8ee174d7831cc1fdbffd3ee53061dab252bf9e765145386
|
|
| MD5 |
00087c5eb78fcc8942e2a844c6348e38
|
|
| BLAKE2b-256 |
3e51dba8e13cee42468583e6b4798051f6702df1f97beb4bd55b1036112e7d15
|
Provenance
The following attestation bundles were made for ai_shell-2.0.0.tar.gz:
Publisher:
release.yml on matthewdeanmartin/ai_shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_shell-2.0.0.tar.gz -
Subject digest:
f682d85162e7650eb8ee174d7831cc1fdbffd3ee53061dab252bf9e765145386 - Sigstore transparency entry: 1749570675
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/ai_shell@c34497776383de2a8c66170a736b7a66c36115c3 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c34497776383de2a8c66170a736b7a66c36115c3 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d76e1646e2dc192e7720e0fedd1613e5d35d45d536cb549747adc6b6b5be27ec
|
|
| MD5 |
e57d5cb111a701a6ef888d4797bd6d16
|
|
| BLAKE2b-256 |
b3644421b7c83d57d2c51a69282ec4e3fe9fa9c099f4ef67a35d88c377e872b1
|
Provenance
The following attestation bundles were made for ai_shell-2.0.0-py3-none-any.whl:
Publisher:
release.yml on matthewdeanmartin/ai_shell
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_shell-2.0.0-py3-none-any.whl -
Subject digest:
d76e1646e2dc192e7720e0fedd1613e5d35d45d536cb549747adc6b6b5be27ec - Sigstore transparency entry: 1749570831
- Sigstore integration time:
-
Permalink:
matthewdeanmartin/ai_shell@c34497776383de2a8c66170a736b7a66c36115c3 -
Branch / Tag:
refs/tags/v2.0.0 - Owner: https://github.com/matthewdeanmartin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c34497776383de2a8c66170a736b7a66c36115c3 -
Trigger Event:
release
-
Statement type: