# code-tools
A powerful framework for providing tools to AI agents with Docker/local deployment support.
CodeInstance is a class that wraps deployment environments (Docker/local) and provides various code tools to AI agents including file operations, bash sessions, search capabilities, and more.
## Installation
You can install the package using pip:
```bash
pip install code-tools-agent
```
Or for development:
```bash
pip install -e .
```
## Quick Start
```python
from codetools import CodeInstance
# Create instance with Docker environment
config = {
'docker': {
'image': 'python:3.12',
},
'tool_config': {}
}
# Create and start the instance
instance = CodeInstance('docker', config, auto_start=True)
# Get specific tools for your agent
tools = instance.get_tools(include=['read_file', 'write_file', 'run_command'])
# Use with your AI agent framework (e.g., Swarms)
from swarms import Agent
agent = Agent(
agent_name="CodingAgent",
system_prompt="You are a helpful coding assistant with file and command tools.",
tools=tools
)
# Clean up when done
instance.stop_sync()
```
## Available Tools
The CodeInstance provides access to these tools:
- **File Operations**: `read_file`, `write_file`, `edit_file`
- **Directory Operations**: `list_directory`
- **Command Execution**: `run_command`, `run_bash_session`, `create_bash_session`
- **Code Analysis**: `format_code`, `analyze_project_structure`, `get_file_dependencies`
- **Search Operations**: `glob_files`, `grep_files`, `find_references`
## Usage Examples
### Basic Usage (Async)
```python
import asyncio
from codetools import CodeInstance
async def example_usage():
config = {
'docker': {'image': 'python:3.12'},
'tool_config': {}
}
# Using async context manager (recommended)
async with CodeInstance('docker', config) as instance:
print(f"Started CodeInstance with {instance.get_deployment_type()} deployment")
# Get available tools
tools = instance.get_available_tools()
print(f"Available tools: {len(tools)}")
# Get wrapped tools for your agent
wrapped_tools = instance.get_tools(include=['read_file', 'write_file', 'list_directory'])
print(f"Wrapped tools: {len(wrapped_tools)}")
asyncio.run(example_usage())
```
### Agent Integration Example
```python
from dotenv import load_dotenv
from swarms import Agent
from swarms.structs import Conversation
from codetools import CodeInstance
load_dotenv()
def create_coding_agent_with_tools():
"""Create a coding agent with read, write, and run_command tools using Docker"""
config = {
'docker': {
'image': 'python:3.12',
},
'tool_config': {}
}
# Create CodeInstance with auto_start=True to immediately get tools
instance = CodeInstance('docker', config, auto_start=True)
# Get the three main tools: read, write, run_command
tools = instance.get_tools(include=['read_file', 'write_file', 'run_command'])
# Create the coding agent with tools
coding_agent = Agent(
agent_name="CodingAgent",
system_prompt="""You are a helpful coding agent with access to file operations and command execution in a Docker container.
You can:
1. Read files to understand code structure
2. Write/modify files to implement features
3. Run commands to test and execute code
You are running in a Python 3.12 Docker container environment.
Always be careful with file operations and command execution.""",
model_name="gemini/gemini-2.0-flash",
max_loops=3,
max_tokens=4096,
temperature=0.3,
output_type="str",
tools=tools
)
return coding_agent, instance
# Create and use the agent
agent, instance = create_coding_agent_with_tools()
# Run a task
response = agent.run("Create a simple Python script called 'hello_world.py' that prints 'Hello, World!' and then run it")
print(response)
# Clean up
instance.stop_sync()
```
## Features
- **Docker & Local Deployment**: Run tools in isolated Docker containers or local environment
- **Tool Statistics**: Track tool usage and performance metrics
- **Async Support**: Full async/await support with context managers
- **Safety Features**: Read-before-write protection for file operations
- **Agent Integration**: Works seamlessly with AI agent frameworks like Swarms
- **Comprehensive Tools**: 14+ built-in tools for file operations, command execution, and code analysis
## Requirements
- Python 3.10+
- Docker (for Docker deployment)
- Dependencies: swarms, swerex
## Development
### Code Quality ๐งน
- `make style` to format the code
- `make check_code_quality` to check code quality (PEP8 basically)
- `black .`
- `ruff . --fix`
### Tests ๐งช
[`pytests`](https://docs.pytest.org/en/7.1.x/) is used to run our tests.
### Publishing ๐
```bash
poetry build
poetry publish
```
## License
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/balajidinesh/code-tools",
"name": "code-tools-agent",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "artificial intelligence, ai agents, code tools, docker, swarms",
"author": "balajidinesh",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/34/22/f1b92786eb1d2657e5cd9767bdcb0f520a8f822c50e94a214c41c4084ea6/code_tools_agent-0.1.3.tar.gz",
"platform": null,
"description": "# code-tools\n\nA powerful framework for providing tools to AI agents with Docker/local deployment support.\n\nCodeInstance is a class that wraps deployment environments (Docker/local) and provides various code tools to AI agents including file operations, bash sessions, search capabilities, and more.\n\n\n## Installation\n\nYou can install the package using pip:\n\n```bash\npip install code-tools-agent\n```\n\nOr for development:\n\n```bash\npip install -e .\n```\n\n## Quick Start\n\n```python\nfrom codetools import CodeInstance\n\n# Create instance with Docker environment\nconfig = {\n 'docker': {\n 'image': 'python:3.12',\n },\n 'tool_config': {}\n}\n\n# Create and start the instance\ninstance = CodeInstance('docker', config, auto_start=True)\n\n# Get specific tools for your agent\ntools = instance.get_tools(include=['read_file', 'write_file', 'run_command'])\n\n# Use with your AI agent framework (e.g., Swarms)\nfrom swarms import Agent\n\nagent = Agent(\n agent_name=\"CodingAgent\",\n system_prompt=\"You are a helpful coding assistant with file and command tools.\",\n tools=tools\n)\n\n# Clean up when done\ninstance.stop_sync()\n```\n\n## Available Tools\n\nThe CodeInstance provides access to these tools:\n\n- **File Operations**: `read_file`, `write_file`, `edit_file`\n- **Directory Operations**: `list_directory`\n- **Command Execution**: `run_command`, `run_bash_session`, `create_bash_session`\n- **Code Analysis**: `format_code`, `analyze_project_structure`, `get_file_dependencies`\n- **Search Operations**: `glob_files`, `grep_files`, `find_references`\n\n## Usage Examples\n\n### Basic Usage (Async)\n\n```python\nimport asyncio\nfrom codetools import CodeInstance\n\nasync def example_usage():\n config = {\n 'docker': {'image': 'python:3.12'},\n 'tool_config': {}\n }\n \n # Using async context manager (recommended)\n async with CodeInstance('docker', config) as instance:\n print(f\"Started CodeInstance with {instance.get_deployment_type()} deployment\")\n \n # Get available tools\n tools = instance.get_available_tools()\n print(f\"Available tools: {len(tools)}\")\n \n # Get wrapped tools for your agent\n wrapped_tools = instance.get_tools(include=['read_file', 'write_file', 'list_directory'])\n print(f\"Wrapped tools: {len(wrapped_tools)}\")\n\nasyncio.run(example_usage())\n```\n\n### Agent Integration Example\n\n```python\nfrom dotenv import load_dotenv\nfrom swarms import Agent\nfrom swarms.structs import Conversation\nfrom codetools import CodeInstance\n\nload_dotenv()\n\ndef create_coding_agent_with_tools():\n \"\"\"Create a coding agent with read, write, and run_command tools using Docker\"\"\"\n \n config = {\n 'docker': {\n 'image': 'python:3.12',\n },\n 'tool_config': {}\n }\n \n # Create CodeInstance with auto_start=True to immediately get tools\n instance = CodeInstance('docker', config, auto_start=True)\n \n # Get the three main tools: read, write, run_command\n tools = instance.get_tools(include=['read_file', 'write_file', 'run_command'])\n \n # Create the coding agent with tools\n coding_agent = Agent(\n agent_name=\"CodingAgent\",\n system_prompt=\"\"\"You are a helpful coding agent with access to file operations and command execution in a Docker container.\n You can:\n 1. Read files to understand code structure\n 2. Write/modify files to implement features\n 3. Run commands to test and execute code\n \n You are running in a Python 3.12 Docker container environment.\n Always be careful with file operations and command execution.\"\"\",\n model_name=\"gemini/gemini-2.0-flash\",\n max_loops=3,\n max_tokens=4096,\n temperature=0.3,\n output_type=\"str\",\n tools=tools\n )\n \n return coding_agent, instance\n\n# Create and use the agent\nagent, instance = create_coding_agent_with_tools()\n\n# Run a task\nresponse = agent.run(\"Create a simple Python script called 'hello_world.py' that prints 'Hello, World!' and then run it\")\nprint(response)\n\n# Clean up\ninstance.stop_sync()\n```\n\n## Features\n\n- **Docker & Local Deployment**: Run tools in isolated Docker containers or local environment\n- **Tool Statistics**: Track tool usage and performance metrics\n- **Async Support**: Full async/await support with context managers\n- **Safety Features**: Read-before-write protection for file operations\n- **Agent Integration**: Works seamlessly with AI agent frameworks like Swarms\n- **Comprehensive Tools**: 14+ built-in tools for file operations, command execution, and code analysis\n\n## Requirements\n\n- Python 3.10+\n- Docker (for Docker deployment)\n- Dependencies: swarms, swerex\n\n## Development\n\n### Code Quality \ud83e\uddf9\n\n- `make style` to format the code\n- `make check_code_quality` to check code quality (PEP8 basically)\n- `black .`\n- `ruff . --fix`\n\n### Tests \ud83e\uddea\n\n[`pytests`](https://docs.pytest.org/en/7.1.x/) is used to run our tests.\n\n### Publishing \ud83d\ude80\n\n```bash\npoetry build\npoetry publish\n```\n\n## License\n\nMIT\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A powerful framework for providing tools to AI agents with Docker/local deployment support",
"version": "0.1.3",
"project_urls": {
"Documentation": "https://github.com/balajidinesh/code-tools",
"Homepage": "https://github.com/balajidinesh/code-tools",
"Repository": "https://github.com/balajidinesh/code-tools"
},
"split_keywords": [
"artificial intelligence",
" ai agents",
" code tools",
" docker",
" swarms"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4c4660555b3ab9e0a2f39be540143270d6bc0e496467ccd5c02444e679151da3",
"md5": "fa34919c57538ce9f7c07997025d634f",
"sha256": "990ba4dc0fc39c99bfaf2bf2417d606b5792af8cbc1a93fdc3129ea6249c6a9d"
},
"downloads": -1,
"filename": "code_tools_agent-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fa34919c57538ce9f7c07997025d634f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 41983,
"upload_time": "2025-08-01T08:12:08",
"upload_time_iso_8601": "2025-08-01T08:12:08.143462Z",
"url": "https://files.pythonhosted.org/packages/4c/46/60555b3ab9e0a2f39be540143270d6bc0e496467ccd5c02444e679151da3/code_tools_agent-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3422f1b92786eb1d2657e5cd9767bdcb0f520a8f822c50e94a214c41c4084ea6",
"md5": "62c918be32e5c0769d179c952dddfab7",
"sha256": "cd76aabded726b92302e19d1045539b7283de9e1592bc193d7b69cbe57117594"
},
"downloads": -1,
"filename": "code_tools_agent-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "62c918be32e5c0769d179c952dddfab7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 38726,
"upload_time": "2025-08-01T08:12:10",
"upload_time_iso_8601": "2025-08-01T08:12:10.041660Z",
"url": "https://files.pythonhosted.org/packages/34/22/f1b92786eb1d2657e5cd9767bdcb0f520a8f822c50e94a214c41c4084ea6/code_tools_agent-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-01 08:12:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "balajidinesh",
"github_project": "code-tools",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "swarms",
"specs": []
}
],
"lcname": "code-tools-agent"
}