An open API service indexing awesome lists of open source software.

https://github.com/stephanj/adkcodeassistant


https://github.com/stephanj/adkcodeassistant

Last synced: 29 days ago
JSON representation

Awesome Lists containing this project

README

        

# Coding Assistant - An Agent-Based Development Helper

A powerful AI coding assistant built with Google's Agent Development Kit (ADK) that helps with code analysis, planning, implementation, and review.

## Overview

The Coding Assistant is an intelligent agent designed to enhance the software development workflow. It uses specialized sub-agents to tackle different aspects of development:

- **Analyzer Agent**: Understands and explains code structures and project architecture
- **Planner Agent**: Helps design and plan new features or components
- **Coder Agent**: Generates high-quality code implementations
- **Reviewer Agent**: Reviews code for bugs, best practices, and improvements

## Features

- 🔍 **Deep Code Analysis**: Understand complex codebases and their structures
- 📐 **Architecture Planning**: Get assistance with system design and component architecture
- 💻 **Smart Code Generation**: Generate working implementations with proper error handling
- 🔎 **Thorough Code Reviews**: Identify bugs, security issues, and improvement opportunities
- 📁 **File System Integration**: Seamlessly interacts with your project files
- 🚀 **Cloud Deployment**: Ready-to-deploy setup for Google Cloud Run
- ☕ **Java Integration**: Example Java implementation of the Bash execution service
- 🔄 **GitHub Integration**: Access GitHub repositories for code retrieval and search

https://github.com/user-attachments/assets/753255f3-7fe7-41d6-8781-bdd70028b887

The video was sped up.

Screenshot 2025-04-11 at 16 06 58

### Generated by the ADK Coding Assistant Agents

Screenshot 2025-04-11 at 16 08 57

## Setup Instructions

### Prerequisites

- Python 3.9 or higher
- Poetry package manager
- Google API key for accessing Gemini models

### Installation

1. Clone this repository:
```bash
git clone https://github.com/stephanj/agenticCodingWithADK.git
cd agenticCodingWithADK
```

2. Install dependencies using Poetry:
```bash
poetry install
```

3. Create a `.env` file in the project root (copy from `.env.example`):
```bash
cp .env.example .env
```

4. Edit the `.env` file and add your Google API key and GitHub token (if needed):
```
GOOGLE_API_KEY=your_google_api_key_here
GITHUB_TOKEN=your_github_personal_access_token
GITHUB_REPOSITORY=your_github_username/repository_name
```

## Running the Coding Assistant

There are several ways to run the Coding Assistant:

### Using the ADK CLI

```bash
# Run using the ADK CLI
adk run coding_assistant

# Or use the web interface
adk web
```

### Using the Python Module

```bash
# Run with a specific query
poetry run python -m coding_assistant.main "Analyze this project structure"

# Or run with the default query
poetry run python -m coding_assistant.main
```

### Cloud Run Deployment

The project includes files for deploying to Google Cloud Run:

```bash
# Build and deploy using Google Cloud Build
gcloud builds submit --config=cloudbuild.yaml

# Or run locally with Docker
docker build -t coding-assistant:latest .
docker run -p 8080:8080 \
-e GOOGLE_API_KEY=your_key_here \
-e GITHUB_TOKEN=your_github_token \
-e GITHUB_REPOSITORY=your_github_username/repo \
coding-assistant:latest
```

The Cloud Run deployment provides a simple API interface where you can send queries to the coding assistant via HTTP POST requests to the root endpoint.

Example request:
```bash
curl -X POST https://your-cloud-run-url/ \
-H "Content-Type: application/json" \
-d '{"query": "Analyze this project structure"}'
```

### Programmatic Usage

```python
from coding_assistant.agent import root_agent
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.adk.artifacts.in_memory_artifact_service import InMemoryArtifactService
from google.genai import types

# Set up services
session_service = InMemorySessionService()
artifact_service = InMemoryArtifactService()

# Create a session with initial state
initial_state = {
"project_path": "/path/to/your/project",
"project_language": "python",
"project_framework": "flask",
}

session = session_service.create_session(
state=initial_state, app_name="coding_assistant", user_id="user1"
)

# Create a query
query = "Analyze the project structure"
content = types.Content(role="user", parts=[types.Part(text=query)])

# Create a runner
runner = Runner(
app_name="coding_assistant",
agent=root_agent,
artifact_service=artifact_service,
session_service=session_service,
)

# Run the agent
for event in runner.run(
session_id=session.id, user_id="user1", new_message=content
):
if event.content:
for part in event.content.parts:
if hasattr(part, "text") and part.text:
print(f"[{event.author}]: {part.text}")
```

## Example Queries

- "Analyze the structure and architecture of this project"
- "Help me plan a user authentication system with JWT"
- "Generate a Python function to parse and validate CSV files"
- "Review this code for performance issues and security vulnerabilities"
- "Explain how this algorithm works and suggest improvements"
- "Find all files in the GitHub repository that use JWT authentication"
- "Get the implementation of login handler from the stephanj/DevoxxGenieApp repository"
- "Search for error handling patterns in my GitHub project"

## Project Structure

```
├── coding_assistant/ # Main Python package for AI assistant
│ ├── sub_agents/ # Specialized agent implementations
│ │ ├── analyzer/ # Code analysis agent
│ │ ├── planner/ # Feature planning agent
│ │ ├── coder/ # Code generation agent
│ │ └── reviewer/ # Code review agent
│ ├── prompts/ # Agent prompts and instructions
│ ├── tools/ # Tool implementations
│ │ ├── filesystem.py # Filesystem interaction tools
│ │ ├── code_analysis.py # Code analysis tools
│ │ ├── planning.py # Planning tools
│ │ ├── coding.py # Code generation tools
│ │ ├── github_tools.py # GitHub repository interaction
│ │ ├── grep.py # Advanced code search functionality
│ │ └── review.py # Code review tools
│ ├── shared_libraries/ # Shared functionality
│ │ ├── constants.py # Constants and keys
│ │ └── types.py # Type definitions using Pydantic
│ ├── agent.py # Main agent definition
│ ├── main.py # Command-line entry point
│ └── coding_assistant_context.json # Agent configuration
├── src/ # Java implementation
│ └── main/java/com/devoxx/mcp/filesystem/tools/
│ └── BashService.java # Java implementation of Bash execution service
├── Dockerfile # Container definition for Cloud Run
├── cloud_run.py # Flask server for Cloud Run deployments
├── cloudbuild.yaml # Google Cloud Build configuration
├── pyproject.toml # Poetry project configuration
└── requirements.txt # Dependencies for container deployments
```

## Troubleshooting

### Common Issues

- **API Key Issues**: Ensure your Google API key is set correctly and has access to Gemini models
- **Import Errors**: Make sure you're using Poetry to manage dependencies
- **Module Not Found**: Verify that you have the `PYTHONPATH` environment variable set correctly
- **GitHub Access Issues**: Ensure your GitHub Personal Access Token has the required permissions (repo scope) and is correctly set in the .env file
- **Repository Not Found**: Verify that the repository name is correct in the format 'username/repo'

### Getting Help

If you encounter issues, please check the [Google ADK documentation](https://github.com/google/adk) or open an issue in this repository.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.