A powerful command-line interface for an AI-powered coding assistant that can analyze, generate, and manage code projects. Built with Google's Gemini AI for intelligent code understanding and generation.
- Python Code Analysis: Parse and analyze Python files with AST
- Code Quality Review: Detect issues, suggest improvements
- Dependency Analysis: Analyze project dependencies and security
- Smart File Management: List, read, write, and organize files
- Advanced Search: Search for patterns across multiple files
- Directory Management: Create and manage project directories
- Project Type Detection: Automatically detect Python, Node.js, Java projects
- Dependency Management: Analyze and suggest dependency improvements
- Structure Analysis: Understand and optimize project organization
- README Generation: Create comprehensive documentation
- Template Creation: Generate Python modules, classes, and functions
- Test File Generation: Create unit tests with pytest or unittest
- Configuration Files: Generate .gitignore and other config files
- Interactive Chat Mode: Continuous conversation with memory
- Shell Integration: Safe command execution
- Multi-format Support: Work with various file types and languages
- Conversation History: Remembers previous interactions
- Token Optimization: Efficient API usage with smart history management
- Python 3.13+
- Google Gemini API key
- UV package manager (recommended)
# Clone the repository
git clone https://github.com/erenkara1907/ai-code-agent.git
cd ai-code-agent
# Install dependencies
uv install
# Set up environment variables
echo "GEMINI_API_KEY=your_api_key_here" > .env
# Start interactive chat session
uv run main.py
# This starts an interactive session where you can:
💬 You: Analyze this project
💬 You: Create a README file
💬 You: q # to quit
# Simple file listing
python main.py "List all Python files in this project"
# Code analysis
python main.py "Analyze the main.py file and suggest improvements"
# Generate documentation
python main.py "Create a comprehensive README for this project"
# Verbose mode for detailed output
python main.py "Analyze project structure" --verbose
# Clear conversation history
python main.py --clear
The interactive mode provides a ChatGPT-like experience:
- Continuous Conversation: Ask follow-up questions naturally
- Memory Retention: Agent remembers previous context
- Smart Commands: Built-in commands for session management
- Token Efficient: Automatically manages conversation history
help # Show available commands
clear # Clear conversation history
q, quit # Exit the session
# Analyze Python file structure
python main.py "Analyze src/agent.py - show classes, functions, and metrics"
# Detect code issues
python main.py "Review main.py and suggest code improvements"
# Check project dependencies
python main.py "Analyze project dependencies and security recommendations"
# Detect project type and structure
python main.py "What type of project is this? Analyze the technology stack"
# Get improvement suggestions
python main.py "Suggest improvements for this project structure"
# Create missing project files
python main.py "Create .gitignore and basic test structure for this project"
# Generate README
python main.py "Create a README.md file with installation and usage instructions"
# Create Python module
python main.py "Generate a user_manager.py module with UserManager class and CRUD functions"
# Generate test files
python main.py "Create pytest tests for the agent module"
# Create configuration files
python main.py "Generate appropriate .gitignore for Python project"
# Search in files
python main.py "Search for 'import' in all Python files"
# File information
python main.py "Get detailed information about src/agent.py"
# Create directories
python main.py "Create a docs directory and add a basic structure"
# Comprehensive project analysis
python main.py "Analyze this entire project: structure, code quality, missing files, and improvement suggestions"
# Code refactoring assistance
python main.py "Review all Python files and suggest refactoring opportunities"
# Project setup automation
python main.py "Set up this project for production: create missing files, improve structure, add documentation"
ai_code_agent/
├── src/
│ ├── agent.py # Main AI Agent class
│ └── tools/
│ ├── file_operations.py # File management tools
│ ├── shell_executor.py # Safe shell execution
│ ├── code_analyzer.py # Python code analysis
│ ├── project_detector.py # Project type detection
│ └── code_generator.py # Code template generation
├── main.py # CLI entry point
├── pyproject.toml # Dependencies and metadata
└── README.md # Documentation
- CodeAgent: Main orchestrator that manages AI interactions
- FileOperations: Handle file system operations safely
- ShellExecutor: Execute shell commands with security measures
- CodeAnalyzer: Parse and analyze Python code using AST
- ProjectDetector: Detect project types and analyze structure
- CodeGenerator: Generate code templates and documentation
GEMINI_API_KEY=your_google_gemini_api_key
- Python: pyproject.toml, requirements.txt, setup.py
- Node.js: package.json, yarn.lock, package-lock.json
- Java: pom.xml, build.gradle
- Generic: Any project structure
# Run all tests
python -m pytest tests/
# Run with coverage
python -m pytest tests/ --cov=src/
# Run specific test
python -m pytest tests/test_agent.py
# Format code
black src/
# Lint code
flake8 src/
# Type checking
mypy src/
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature
- Write tests for new functionality
- Ensure code quality: Run linting and tests
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Create Pull Request
Feature Category | Capabilities | Status |
---|---|---|
File Operations | List, Read, Write, Search, Info | ✅ Complete |
Code Analysis | Python AST, Issues Detection, Metrics | ✅ Complete |
Project Detection | Type Detection, Dependencies, Structure | ✅ Complete |
Code Generation | README, .gitignore, Modules, Tests | ✅ Complete |
Shell Integration | Safe Command Execution | ✅ Complete |
AI Integration | Google Gemini API, Function Calling | ✅ Complete |
- Currently optimized for Python projects
- Shell execution limited to safe commands
- Requires internet connection for AI features
- API rate limits apply based on Gemini usage
- Sandboxed Execution: Shell commands are restricted to safe operations
- Path Validation: All file operations are contained within working directory
- Input Sanitization: User inputs are validated before processing
- No Credential Storage: API keys should be stored in environment variables
- Support for more programming languages
- Integration with popular IDEs
- Real-time collaboration features
- Advanced code refactoring suggestions
- Custom plugin system
- Web interface option
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Report bugs and feature requests on GitHub Issues
- Discussions: Join community discussions in GitHub Discussions
- Email: erenkaraaa47@gmail.com
- LinkedIn: Eren Kara
- Google Gemini AI for powerful language understanding
- Python AST for code analysis capabilities
- UV Package Manager for fast dependency management
- Open Source Community for inspiration and tools
Made with ❤️ by Eren Kara for the developer community