diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore index b7faf40..e8fece7 100644 --- a/.gitignore +++ b/.gitignore @@ -173,7 +173,7 @@ cython_debug/ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +.idea/ # Abstra # Abstra is an AI-powered process automation framework. diff --git a/README.md b/README.md index 5d323b9..e37f88e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,128 @@ -# devops-agent -Agent team for DevOps that solves Kubernetes, Docker, Terraform, and monitoring challenges through intelligent automation. +# DevOps Agent + +An AI-powered CLI tool to assist with DevOps tasks, log analysis, and infrastructure code generation. + +## Features + +- 📊 **Log Analysis**: Analyze log files and get actionable insights +- 💬 **Query Interface**: Ask questions about DevOps best practices, Terraform, Kubernetes, etc. +- 🛠️ **Template Generation**: Generate infrastructure code templates +- 🤖 **AI-Powered**: Leverages Claude AI for intelligent responses + +## Installation + +```bash +# Clone the repository +git clone https://github.com/yourusername/devops-agent.git +cd devops-agent + +# Install in development mode +pip install -e . + +# Or install from PyPI (when published) +pip install devops-agent +``` + +## Configuration + +Create a `.env` file in the project root: + +```env +ANTHROPIC_API_KEY=your_api_key_here +``` + +## Usage + +### Analyze Log Files + +```bash +devops-agent run --log-file /path/to/app.log +``` + +### Ask Questions + +```bash +devops-agent run --query "I need terraform script to spin up Azure blob storage" +devops-agent run --query "How to increase my pod memory and CPU in k8s" +``` + +### Generate Templates + +```bash +devops-agent template terraform +devops-agent template kubernetes +devops-agent template docker +``` + +### Configuration + +```bash +devops-agent config +``` + +## Examples + +```bash +# Analyze application logs +devops-agent run --log-file ./logs/app.log --format json + +# Get Terraform help +devops-agent run --query "terraform script for AWS S3 bucket with versioning" + +# Kubernetes troubleshooting +devops-agent run --query "pod is in CrashLoopBackOff status, how to debug?" + +# Save output to file +devops-agent run --query "docker-compose for nginx and postgres" --output docker-compose.yml +``` + +## Development + +```bash +# Install development dependencies +pip install -e ".[dev]" + +# Run tests +pytest + +# Format code +black devops_agent/ +isort devops_agent/ + +# Lint +flake8 devops_agent/ +``` + +## Project Structure + +``` +devops-agent/ +├── devops_agent/ # Main package +│ ├── cli.py # CLI interface +│ ├── core/ # Core functionality +│ ├── templates/ # Template generators +│ ├── utils/ # Utilities +│ └── prompts/ # LLM prompts +└── docs/ # Documentation +``` + +## Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. + +## License + +Apache2.0 License - see LICENSE file for details + +## Roadmap + +- [ ] Implement log analysis with pattern detection +- [ ] Add support for multiple LLM providers +- [ ] Create template library for common infrastructure patterns +- [ ] Add interactive mode +- [ ] Support for custom plugins +- [ ] Integration with CI/CD pipelines + +## Support + +For issues and questions, please open an issue on GitHub. \ No newline at end of file diff --git a/devops_agent/__init__.py b/devops_agent/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/devops_agent/cli.py b/devops_agent/cli.py new file mode 100644 index 0000000..f1c7270 --- /dev/null +++ b/devops_agent/cli.py @@ -0,0 +1,61 @@ +import click +from rich.console import Console +from rich.panel import Panel +from pathlib import Path + +console = Console() + +@click.group() +@click.version_option(version="0.1.0") +def cli(): + """DevOps Agent - Your AI-powered DevOps assistant""" + pass + +@cli.command() +@click.option('--log-file', type=click.Path(exists=True), help='Path to log file to analyze') +@click.option('--query', type=str, help='Query to ask the DevOps agent') +@click.option('--output', type=click.Path(), help='Output file path (optional)') +@click.option('--format', type=click.Choice(['text', 'json', 'markdown']), default='text', help='Output format') +def run(log_file, query, output, format): + """Run the DevOps agent with specified options""" + + if not log_file and not query: + console.print("[red]Error: You must provide either --log-file or --query[/red]") + raise click.Abort() + + if log_file and query: + console.print("[red]Error: Cannot use both --log-file and --query simultaneously[/red]") + raise click.Abort() + + console.print(Panel.fit( + "[bold cyan]DevOps Agent[/bold cyan]\n[dim]Initializing...[/dim]", + border_style="cyan" + )) + + if log_file: + console.print(f"[yellow]Analyzing log file:[/yellow] {log_file}") + console.print("[green]✓[/green] Log analysis will be implemented here") + + if query: + console.print(f"[yellow]Processing query:[/yellow] {query}") + console.print("[green]✓[/green] Query processing will be implemented here") + + if output: + console.print(f"[blue]Output will be saved to:[/blue] {output}") + +@cli.command() +def config(): + """Configure the DevOps agent""" + console.print("[yellow]Configuration interface will be implemented here[/yellow]") + +@cli.command() +@click.argument('template_type', type=click.Choice(['terraform', 'kubernetes', 'docker'])) +def template(template_type): + """Generate templates for various DevOps tools""" + console.print(f"[yellow]Generating {template_type} template...[/yellow]") + +def main(): + cli() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/devops_agent/core/__init__.py b/devops_agent/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/devops_agent/prompts/__init__.py b/devops_agent/prompts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/devops_agent/templates/__init__.py b/devops_agent/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/devops_agent/utils/__init__.py b/devops_agent/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/playground.py b/playground.py new file mode 100644 index 0000000..d9a8857 --- /dev/null +++ b/playground.py @@ -0,0 +1 @@ +print('playground!') \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..94bb253 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "devops-agent" +version = "0.1.0" +description = "AI-powered DevOps CLI assistant" +readme = "README.md" +requires-python = ">=3.8" +license = {text = "MIT"} +authors = [ + {name = "M K Pavan Kumar", email = "manthapavankumar11@gamil.com"} +] +keywords = ["devops", "cli", "ai", "automation", "terraform", "kubernetes", "docker"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "License :: OSI Approved :: Apache2.0 License", + "Programming Language :: Python :: 3", +] + +dependencies = [ + "click>=8.3.0", + "rich>=14.1.0", + "anthropic>=0.69.0", + "pyyaml>=6.0.3", + "python-dotenv>=1.1.1", + "requests>=2.32.5", + "colorama>=0.4.6", + "agno>=2.1.0", + "poml>=0.0.8" +] + +[project.scripts] +devops-agent = "devops_agent.cli:main" + +[project.optional-dependencies] +dev = [ + "black>=25.9.0", + "isort>=6.1.0", + "flake8>=7.3.0", +] + +[tool.setuptools] +packages = ["devops_agent", "devops_agent.core", "devops_agent.templates", "devops_agent.utils", "devops_agent.prompts"] + +[tool.black] +line-length = 100 +target-version = ['py38', 'py39', 'py310', 'py311'] + +[tool.isort] +profile = "black" +line_length = 100 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e0a3e28 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,25 @@ +# Agentic framework +poml==0.0.8 +agno==2.1.0 + +# CLI Framework +click>=8.1.0 +rich>=13.0.0 + +# LLM Integration +anthropic>=0.18.0 + +# File Processing +pyyaml>=6.0 +python-dotenv>=1.0.0 + +# Utilities +requests>=2.31.0 +colorama>=0.4.6 + +# Development +pytest>=7.4.0 +pytest-cov>=4.1.0 +black>=23.0.0 +isort>=5.12.0 +flake8>=6.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..2338b62 --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +from setuptools import setup, find_packages + +with open("README.md", "r", encoding="utf-8") as fh: + long_description = fh.read() + +with open("requirements.txt", "r", encoding="utf-8") as fh: + requirements = [line.strip() for line in fh if line.strip() and not line.startswith("#")] + +setup( + name="devops-agent", + version="0.1.0", + author="Your Name", + author_email="your.email@example.com", + description="AI-powered DevOps CLI assistant", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/yourusername/devops-agent", + packages=find_packages(), + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + ], + python_requires=">=3.8", + install_requires=requirements, + entry_points={ + "console_scripts": [ + "devops-agent=devops_agent.cli:main", + ], + }, +) \ No newline at end of file