opsmith-cli 0.1.2a0__tar.gz → 0.2.2b0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- opsmith_cli-0.2.2b0/PKG-INFO +282 -0
- opsmith_cli-0.2.2b0/README.md +243 -0
- opsmith_cli-0.2.2b0/opsmith/agent.py +105 -0
- opsmith_cli-0.2.2b0/opsmith/cloud_providers/__init__.py +3 -0
- opsmith_cli-0.2.2b0/opsmith/cloud_providers/aws.py +158 -0
- opsmith_cli-0.2.2b0/opsmith/cloud_providers/base.py +182 -0
- opsmith_cli-0.2.2b0/opsmith/cloud_providers/gcp.py +197 -0
- opsmith_cli-0.2.2b0/opsmith/deployment_strategies/__init__.py +3 -0
- opsmith_cli-0.2.2b0/opsmith/deployment_strategies/base.py +474 -0
- opsmith_cli-0.2.2b0/opsmith/deployment_strategies/monolithic.py +1037 -0
- opsmith_cli-0.2.2b0/opsmith/exceptions.py +10 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/git_repo.py +31 -0
- opsmith_cli-0.2.2b0/opsmith/infra_provisioners/__init__.py +0 -0
- opsmith_cli-0.2.2b0/opsmith/infra_provisioners/ansible_provisioner.py +50 -0
- opsmith_cli-0.2.2b0/opsmith/infra_provisioners/base_provisioner.py +98 -0
- opsmith_cli-0.2.2b0/opsmith/infra_provisioners/terraform_provisioner.py +80 -0
- opsmith_cli-0.2.2b0/opsmith/main.py +579 -0
- opsmith_cli-0.2.2b0/opsmith/models.py +223 -0
- opsmith_cli-0.2.2b0/opsmith/prompts.py +223 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/repo_map.py +2 -3
- opsmith_cli-0.2.2b0/opsmith/service_detector.py +342 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/settings.py +4 -1
- opsmith_cli-0.2.2b0/opsmith/templates/cloud_storage_cleanup/aws/main.yml +24 -0
- opsmith_cli-0.2.2b0/opsmith/templates/cloud_storage_cleanup/gcp/main.yml +24 -0
- opsmith_cli-0.2.2b0/opsmith/templates/container_registry/aws/main.tf +12 -0
- opsmith_cli-0.2.2b0/opsmith/templates/container_registry/aws/outputs.tf +4 -0
- opsmith_cli-0.2.2b0/opsmith/templates/container_registry/aws/variables.tf +14 -0
- opsmith_cli-0.2.2b0/opsmith/templates/container_registry/gcp/main.tf +11 -0
- opsmith_cli-0.2.2b0/opsmith/templates/container_registry/gcp/outputs.tf +4 -0
- opsmith_cli-0.2.2b0/opsmith/templates/container_registry/gcp/variables.tf +19 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_build_push/aws/main.yml +51 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_build_push/gcp/main.yml +45 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_deploy/aws/main.yml +91 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_deploy/gcp/main.yml +81 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_run/common/main.yml +19 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/base.yml +14 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/elasticsearch.yml +16 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/kafka.yml +20 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/mongodb.yml +13 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/mysql.yml +14 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/postgresql.yml +13 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/rabbitmq.yml +13 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/redis.yml +9 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/services/backend_api.yml +15 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/services/backend_worker.yml +3 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/services/full_stack.yml +14 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/traefik.yml +49 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_compose_snippets/weaviate.yml +15 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_setup/aws/main.yml +36 -0
- opsmith_cli-0.2.2b0/opsmith/templates/docker_setup/gcp/main.yml +38 -0
- opsmith_cli-0.2.2b0/opsmith/templates/fetch_remote_files/common/main.yml +22 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_bucket_cert/aws/main.tf +33 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_bucket_cert/aws/outputs.tf +21 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_bucket_cert/aws/variables.tf +15 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_bucket_cert/gcp/main.tf +27 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_bucket_cert/gcp/outputs.tf +10 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_bucket_cert/gcp/variables.tf +19 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_cdn/aws/main.tf +96 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_cdn/aws/outputs.tf +21 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_cdn/aws/variables.tf +25 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_cdn/gcp/main.tf +47 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_cdn/gcp/outputs.tf +21 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_cdn/gcp/variables.tf +29 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_deploy/aws/main.yml +28 -0
- opsmith_cli-0.2.2b0/opsmith/templates/frontend_deploy/gcp/main.yml +74 -0
- opsmith_cli-0.2.2b0/opsmith/templates/virtual_machine/aws/main.tf +136 -0
- opsmith_cli-0.2.2b0/opsmith/templates/virtual_machine/aws/outputs.tf +14 -0
- opsmith_cli-0.2.2b0/opsmith/templates/virtual_machine/aws/variables.tf +19 -0
- opsmith_cli-0.2.2b0/opsmith/templates/virtual_machine/gcp/main.tf +74 -0
- opsmith_cli-0.2.2b0/opsmith/templates/virtual_machine/gcp/outputs.tf +14 -0
- opsmith_cli-0.2.2b0/opsmith/templates/virtual_machine/gcp/variables.tf +24 -0
- opsmith_cli-0.2.2b0/opsmith/types.py +312 -0
- opsmith_cli-0.2.2b0/opsmith/utils.py +114 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/pyproject.toml +9 -2
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/uv.lock +654 -38
- opsmith_cli-0.1.2a0/PKG-INFO +0 -31
- opsmith_cli-0.1.2a0/README.md +0 -1
- opsmith_cli-0.1.2a0/opsmith/agent.py +0 -243
- opsmith_cli-0.1.2a0/opsmith/cloud_providers/__init__.py +0 -10
- opsmith_cli-0.1.2a0/opsmith/cloud_providers/aws.py +0 -46
- opsmith_cli-0.1.2a0/opsmith/cloud_providers/base.py +0 -57
- opsmith_cli-0.1.2a0/opsmith/cloud_providers/gcp.py +0 -67
- opsmith_cli-0.1.2a0/opsmith/deployer.py +0 -236
- opsmith_cli-0.1.2a0/opsmith/main.py +0 -269
- opsmith_cli-0.1.2a0/opsmith/prompts.py +0 -76
- opsmith_cli-0.1.2a0/opsmith/spinner.py +0 -221
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/.flake8 +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/.github/workflows/python-publish.yml +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/.gitignore +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/.pre-commit-config.yaml +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/CONVENTIONS.md +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/LICENSE.txt +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/__init__.py +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/constants.py +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/README.md +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/arduino-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/c-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/c_sharp-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/chatito-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/commonlisp-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/cpp-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/csharp-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/d-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/dart-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/elisp-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/elixir-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/elm-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/gleam-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/go-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/hcl-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/java-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/javascript-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/kotlin-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/lua-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/ocaml-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/ocaml_interface-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/php-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/pony-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/properties-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/python-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/ql-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/r-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/racket-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/ruby-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/rust-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/scala-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/solidity-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/swift-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/typescript-tags.scm +0 -0
- {opsmith_cli-0.1.2a0 → opsmith_cli-0.2.2b0}/opsmith/queries/tree-sitter-languages/udev-tags.scm +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: opsmith-cli
|
|
3
|
+
Version: 0.2.2b0
|
|
4
|
+
Summary: Opsmith is an AI devops engineer in your terminal
|
|
5
|
+
License-Expression: GPL-3.0-only
|
|
6
|
+
License-File: LICENSE.txt
|
|
7
|
+
Classifier: Development Status :: 4 - Beta
|
|
8
|
+
Classifier: Environment :: Console
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: ansible>=10.7.0
|
|
19
|
+
Requires-Dist: black>=25.1.0
|
|
20
|
+
Requires-Dist: boto3-stubs==1.38.36
|
|
21
|
+
Requires-Dist: gitpython>=3.1.44
|
|
22
|
+
Requires-Dist: google-api-python-client>=2.175.0
|
|
23
|
+
Requires-Dist: google-cloud-compute>=1.31.0
|
|
24
|
+
Requires-Dist: google-cloud-resource-manager>=1.14.2
|
|
25
|
+
Requires-Dist: google-cloud-storage>=3.2.0
|
|
26
|
+
Requires-Dist: grep-ast>=0.9.0
|
|
27
|
+
Requires-Dist: inquirer>=3.4.0
|
|
28
|
+
Requires-Dist: jinja2>=3.1.6
|
|
29
|
+
Requires-Dist: networkx>=3.4.2
|
|
30
|
+
Requires-Dist: pick>=2.4.0
|
|
31
|
+
Requires-Dist: pydantic-ai[logfire]==0.4.2
|
|
32
|
+
Requires-Dist: pydantic>=2.11.5
|
|
33
|
+
Requires-Dist: python-dotenv>=1.1.0
|
|
34
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
35
|
+
Requires-Dist: tqdm>=4.67.1
|
|
36
|
+
Requires-Dist: tree-sitter-language-pack>=0.7.3
|
|
37
|
+
Requires-Dist: typer>=0.16.0
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# Opsmith: An AI devops engineer in your terminal
|
|
41
|
+
|
|
42
|
+
Opsmith is a command-line tool that acts as an AI-powered DevOps assistant. It's designed to streamline the process of deploying your applications to the cloud, from analyzing your codebase to provisioning infrastructure and deploying your services.
|
|
43
|
+
|
|
44
|
+
Opsmith helps you with the following tasks:
|
|
45
|
+
|
|
46
|
+
- **Codebase Analysis**: It scans your repository to automatically detect services, programming languages, frameworks, and infrastructure dependencies (like databases or caches).
|
|
47
|
+
- **Configuration Generation**: Based on its analysis, Opsmith generates necessary deployment artifacts.
|
|
48
|
+
- **Infrastructure Provisioning**: It uses tools like Terraform and Ansible to provision and configure required cloud resources on supported providers (e.g., AWS, GCP).
|
|
49
|
+
- **Deployment**: It handles the deployment of your application using various strategies, such as a monolithic deployment on a single virtual machine for hobby projects.
|
|
50
|
+
|
|
51
|
+
The primary goal of Opsmith is to make cloud deployments accessible to all developers, regardless of their DevOps expertise. It achieves this by automating complex tasks through an interactive setup process, allowing you to focus on writing code. Opsmith is also designed to prevent cloud provider lock-in, which helps control long-term costs. The generated configurations are standard and maintainable, making it easy to hand over the deployment to an in-house DevOps team.
|
|
52
|
+
|
|
53
|
+
## Table of Contents
|
|
54
|
+
|
|
55
|
+
- [Getting Started](#getting-started)
|
|
56
|
+
- [Installation](#installation)
|
|
57
|
+
- [Deployment Workflow](#deployment-workflow)
|
|
58
|
+
- [User Guide](#user-guide)
|
|
59
|
+
- [LLMs](#llms)
|
|
60
|
+
- [Supported Models](#supported-models)
|
|
61
|
+
- [Cloud Providers](#cloud-providers)
|
|
62
|
+
- [AWS](#aws-amazon-web-services)
|
|
63
|
+
- [GCP](#gcp-google-cloud-platform)
|
|
64
|
+
- [Deployment Strategies](#deployment-strategies)
|
|
65
|
+
- [Monolithic](#monolithic)
|
|
66
|
+
- [Deployments Directory](#deployments-directory)
|
|
67
|
+
- [Extending Opsmith](#extending-opsmith)
|
|
68
|
+
- [Adding a Cloud Provider](#adding-a-cloud-provider)
|
|
69
|
+
- [Adding a Deployment Strategy](#adding-a-deployment-strategy)
|
|
70
|
+
- [Contributing](#contributing)
|
|
71
|
+
|
|
72
|
+
## Getting Started
|
|
73
|
+
|
|
74
|
+
### Installation
|
|
75
|
+
|
|
76
|
+
1. **Prerequisites**: Opsmith requires `Docker` and `Terraform` to be installed and available in your system's `PATH`.
|
|
77
|
+
|
|
78
|
+
- **macOS (with [Homebrew](https://brew.sh/))**:
|
|
79
|
+
```shell
|
|
80
|
+
brew install --cask docker
|
|
81
|
+
brew install terraform
|
|
82
|
+
```
|
|
83
|
+
After installation, make sure you start Docker Desktop.
|
|
84
|
+
|
|
85
|
+
- **Windows (with [Chocolatey](https://chocolatey.org/))**:
|
|
86
|
+
```shell
|
|
87
|
+
choco install docker-desktop terraform
|
|
88
|
+
```
|
|
89
|
+
After installation, make sure you start Docker Desktop.
|
|
90
|
+
|
|
91
|
+
- **Linux (Debian/Ubuntu)**:
|
|
92
|
+
Please follow the official installation guides for [Docker](https://docs.docker.com/engine/install/ubuntu/) and [Terraform](https://developer.hashicorp.com/terraform/install).
|
|
93
|
+
|
|
94
|
+
2. **Install Opsmith**:
|
|
95
|
+
Once the prerequisites are installed, you can install Opsmith using `pip`:
|
|
96
|
+
```shell
|
|
97
|
+
pip install opsmith-cli
|
|
98
|
+
```
|
|
99
|
+
On macOS, you might need to use `pip3` if `pip` doesn't work.
|
|
100
|
+
|
|
101
|
+
### Deployment Workflow
|
|
102
|
+
|
|
103
|
+
Deploying your application with Opsmith follows a straightforward workflow:
|
|
104
|
+
|
|
105
|
+
1. **Setup Your Project**
|
|
106
|
+
|
|
107
|
+
Navigate to your project's root directory, which should be a Git repository, and run the `setup` command. This command initializes your deployment configuration by analyzing your codebase to detect services and infrastructure requirements.
|
|
108
|
+
|
|
109
|
+
```shell
|
|
110
|
+
opsmith --model <your-llm-provider:model-name> --api-key <your-api-key> setup
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
You will be prompted to:
|
|
114
|
+
- Provide an application name.
|
|
115
|
+
- Select a cloud provider (e.g., AWS, GCP — see [Cloud Providers](#cloud-providers) for setup).
|
|
116
|
+
- Review and confirm the services and infrastructure dependencies detected by the AI.
|
|
117
|
+
- Opsmith will then generate a `Dockerfile` for each of your services.
|
|
118
|
+
|
|
119
|
+
2. **Deploy Your Application**
|
|
120
|
+
|
|
121
|
+
After setting up the configuration, deploy your application using the `deploy` command:
|
|
122
|
+
|
|
123
|
+
```shell
|
|
124
|
+
opsmith --model <your-llm-provider:model-name> --api-key <your-api-key> deploy
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This will guide you through:
|
|
128
|
+
- Creating a new deployment environment (e.g., `dev`, `staging`, `production`).
|
|
129
|
+
- Selecting a cloud region.
|
|
130
|
+
- Choosing a deployment strategy (e.g., `Monolithic`).
|
|
131
|
+
- Configuring domain names for your services if needed.
|
|
132
|
+
|
|
133
|
+
Opsmith will then provision all the necessary cloud infrastructure and deploy your application.
|
|
134
|
+
|
|
135
|
+
3. **Manage Your Deployments**
|
|
136
|
+
|
|
137
|
+
To manage an existing environment, run the `deploy` command again. You can select an environment and perform the following actions:
|
|
138
|
+
- `release`: Deploy a new version of your application.
|
|
139
|
+
- `run`: Execute a command on a specific service within your environment (e.g., run database migrations).
|
|
140
|
+
- `delete`: Tear down all the infrastructure and delete the environment.
|
|
141
|
+
|
|
142
|
+
## User Guide
|
|
143
|
+
|
|
144
|
+
### LLMs
|
|
145
|
+
|
|
146
|
+
Opsmith leverages Large Language Models (LLMs) to analyze your codebase, generate configurations, and make decisions about your infrastructure. To use Opsmith, you must provide an LLM model and a corresponding API key from the model's provider.
|
|
147
|
+
|
|
148
|
+
#### Supported Models
|
|
149
|
+
|
|
150
|
+
Opsmith supports a variety of models from different providers. Here is a list of the currently supported models:
|
|
151
|
+
|
|
152
|
+
- **OpenAI**:
|
|
153
|
+
- `openai:gpt-4.1`
|
|
154
|
+
- `openai:gpt-o3`
|
|
155
|
+
- **Anthropic**:
|
|
156
|
+
- `anthropic:claude-3-7-sonnet-20250219`
|
|
157
|
+
- `anthropic:claude-sonnet-4-20250514`
|
|
158
|
+
- **Google**:
|
|
159
|
+
- `google-gla:gemini-2.5-pro`
|
|
160
|
+
|
|
161
|
+
#### Usage
|
|
162
|
+
|
|
163
|
+
To specify which model to use, pass the `--model` option with the full model name, and provide your API key with the `--api-key` option.
|
|
164
|
+
|
|
165
|
+
**Example with OpenAI:**
|
|
166
|
+
```shell
|
|
167
|
+
opsmith --model openai:gpt-4.1 --api-key YOUR_OPENAI_API_KEY COMMAND
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Example with Anthropic:**
|
|
171
|
+
```shell
|
|
172
|
+
opsmith --model anthropic:claude-3-7-sonnet-20250219 --api-key YOUR_ANTHROPIC_API_KEY COMMAND
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Example with Google:**
|
|
176
|
+
```shell
|
|
177
|
+
opsmith --model google-gla:gemini-2.5-pro --api-key YOUR_GEMINI_API_KEY COMMAND
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Cloud Providers
|
|
181
|
+
|
|
182
|
+
Opsmith uses your cloud provider's command-line tools to authenticate and manage resources. Before using Opsmith, you need to configure the credentials for your chosen cloud provider.
|
|
183
|
+
|
|
184
|
+
#### AWS (Amazon Web Services)
|
|
185
|
+
|
|
186
|
+
Opsmith uses the official AWS CLI to interact with your account.
|
|
187
|
+
|
|
188
|
+
1. **Install the AWS CLI**: Follow the [official installation guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) for your operating system.
|
|
189
|
+
|
|
190
|
+
2. **Configure Credentials**: Once installed, configure the CLI with your AWS credentials by running:
|
|
191
|
+
```shell
|
|
192
|
+
aws configure
|
|
193
|
+
```
|
|
194
|
+
You will be prompted to enter your `AWS Access Key ID`, `AWS Secret Access Key`, default region, and default output format. This will store your credentials in the `~/.aws/credentials` file, which Opsmith will use automatically.
|
|
195
|
+
|
|
196
|
+
#### GCP (Google Cloud Platform)
|
|
197
|
+
|
|
198
|
+
Opsmith uses the Google Cloud CLI to authenticate.
|
|
199
|
+
|
|
200
|
+
1. **Install the gcloud CLI**: Follow the [official installation guide](https://cloud.google.com/sdk/docs/install) for your operating system.
|
|
201
|
+
|
|
202
|
+
2. **Authenticate with Application Default Credentials (ADC)**: Run the following command to log in and create your ADC file:
|
|
203
|
+
```shell
|
|
204
|
+
gcloud auth application-default login
|
|
205
|
+
```
|
|
206
|
+
This command will open a browser window for you to log in to your Google account and authorize access. Once completed, your credentials will be stored locally, and Opsmith will use them to authenticate.
|
|
207
|
+
|
|
208
|
+
### Deployment Strategies
|
|
209
|
+
|
|
210
|
+
Deployment strategies in Opsmith define the architecture and approach for deploying your application. When you create a new environment, you will be prompted to select a strategy that best fits your project's needs. Each strategy automates the provisioning of specific infrastructure and handles the deployment process accordingly.
|
|
211
|
+
|
|
212
|
+
#### Monolithic
|
|
213
|
+
|
|
214
|
+
The **Monolithic** strategy is designed for simplicity and is ideal for hobby projects, experiments, or small-scale applications. It deploys your entire application to a single virtual machine (VM).
|
|
215
|
+
|
|
216
|
+
Key features of the Monolithic strategy include:
|
|
217
|
+
|
|
218
|
+
- **Single Virtual Machine**: Provisions one VM to host all backend services and infrastructure dependencies.
|
|
219
|
+
- **Containerization**: Backend and full-stack services are containerized using Docker and managed with `docker-compose`. This isolates services and simplifies dependency management.
|
|
220
|
+
- **Frontend Deployment**: Frontend services are built and deployed to a cloud storage bucket (like AWS S3 or GCS) and served through a Content Delivery Network (CDN) for optimal performance.
|
|
221
|
+
|
|
222
|
+
This strategy is a great starting point for getting your application running in the cloud quickly with minimal complexity.
|
|
223
|
+
|
|
224
|
+
### Deployments Directory
|
|
225
|
+
|
|
226
|
+
When you run `opsmith`, it creates a `.opsmith` directory in the root of your project. This directory stores all the configurations, generated artifacts, and state files required to manage your deployments. This directory is intended to be committed to your git repository so that your deployment configurations are versioned. Sensitive files like Terraform state are automatically ignored.
|
|
227
|
+
|
|
228
|
+
Here is an overview of what you can find inside the `.opsmith` directory:
|
|
229
|
+
|
|
230
|
+
- `deployments.yml`: The main configuration file for your application. It contains the list of services, infrastructure dependencies, cloud provider details, and environment configurations.
|
|
231
|
+
- `docker/`: Contains the generated `Dockerfile`s for each of your services, organized into subdirectories by service name.
|
|
232
|
+
- `environments/`: This directory holds the state and configuration for each of your deployment environments (e.g., `dev`, `staging`).
|
|
233
|
+
- `<environment-name>/`: A directory for each environment, containing Terraform state for provisioned infrastructure and other environment-specific files.
|
|
234
|
+
- `global/`: Contains configurations that are shared across environments within a specific region, such as container registries.
|
|
235
|
+
|
|
236
|
+
### Extending Opsmith
|
|
237
|
+
|
|
238
|
+
Opsmith has been designed with extensibility in mind, allowing you to add your own cloud providers and deployment strategies. This is achieved through Python's entry points mechanism, which enables other packages to plug into Opsmith seamlessly.
|
|
239
|
+
|
|
240
|
+
#### Adding a Cloud Provider
|
|
241
|
+
|
|
242
|
+
To add a new cloud provider, you need to:
|
|
243
|
+
|
|
244
|
+
1. Create a Python class that inherits from `opsmith.cloud_providers.base.BaseCloudProvider` and implements all its abstract methods (`name`, `description`, `get_detail_model`, `get_account_details`, `get_instance_types`, `get_regions`).
|
|
245
|
+
2. Package your new provider class.
|
|
246
|
+
3. In your package's `pyproject.toml`, add an entry point under the `[project.entry-points."opsmith.cloud_providers"]` group.
|
|
247
|
+
|
|
248
|
+
Example `pyproject.toml` entry:
|
|
249
|
+
|
|
250
|
+
```toml
|
|
251
|
+
[project.entry-points."opsmith.cloud_providers"]
|
|
252
|
+
my-provider = "my_opsmith_plugin.providers:MyCloudProvider"
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Once your package is installed in the same environment as `opsmith-cli`, Opsmith will automatically discover and register your new provider.
|
|
256
|
+
|
|
257
|
+
#### Adding a Deployment Strategy
|
|
258
|
+
|
|
259
|
+
Similarly, you can add a new deployment strategy by:
|
|
260
|
+
|
|
261
|
+
1. Creating a Python class that inherits from `opsmith.deployment_strategies.base.BaseDeploymentStrategy` and implements its abstract methods (`name`, `description`, `deploy`, `release`, `destroy`, `run`).
|
|
262
|
+
2. Packaging your new strategy class.
|
|
263
|
+
3. In your package's `pyproject.toml`, add an entry point under the `[project.entry-points."opsmith.deployment_strategies"]` group.
|
|
264
|
+
|
|
265
|
+
Example `pyproject.toml` entry:
|
|
266
|
+
|
|
267
|
+
```toml
|
|
268
|
+
[project.entry-points."opsmith.deployment_strategies"]
|
|
269
|
+
my-strategy = "my_opsmith_plugin.strategies:MyStrategy"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
After installation, your custom deployment strategy will be available for selection when creating a new environment.
|
|
273
|
+
|
|
274
|
+
## Contributing
|
|
275
|
+
|
|
276
|
+
We welcome contributions to Opsmith! If you're interested in helping improve the tool, here are a few ways to get started:
|
|
277
|
+
|
|
278
|
+
- **Reporting Bugs**: If you encounter a bug, please open an issue on our GitHub repository. Include as much detail as possible, such as your operating system, the command you ran, and the full error message.
|
|
279
|
+
- **Suggesting Enhancements**: Have an idea for a new feature or an improvement to an existing one? We'd love to hear it. Open an issue to start a discussion.
|
|
280
|
+
- **Submitting Pull Requests**: If you'd like to contribute code, please fork the repository and submit a pull request. For major changes, it's best to discuss your idea in an issue first.
|
|
281
|
+
|
|
282
|
+
When contributing, please follow our [engineering conventions](./CONVENTIONS.md) and ensure your code is formatted with `black`.
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Opsmith: An AI devops engineer in your terminal
|
|
2
|
+
|
|
3
|
+
Opsmith is a command-line tool that acts as an AI-powered DevOps assistant. It's designed to streamline the process of deploying your applications to the cloud, from analyzing your codebase to provisioning infrastructure and deploying your services.
|
|
4
|
+
|
|
5
|
+
Opsmith helps you with the following tasks:
|
|
6
|
+
|
|
7
|
+
- **Codebase Analysis**: It scans your repository to automatically detect services, programming languages, frameworks, and infrastructure dependencies (like databases or caches).
|
|
8
|
+
- **Configuration Generation**: Based on its analysis, Opsmith generates necessary deployment artifacts.
|
|
9
|
+
- **Infrastructure Provisioning**: It uses tools like Terraform and Ansible to provision and configure required cloud resources on supported providers (e.g., AWS, GCP).
|
|
10
|
+
- **Deployment**: It handles the deployment of your application using various strategies, such as a monolithic deployment on a single virtual machine for hobby projects.
|
|
11
|
+
|
|
12
|
+
The primary goal of Opsmith is to make cloud deployments accessible to all developers, regardless of their DevOps expertise. It achieves this by automating complex tasks through an interactive setup process, allowing you to focus on writing code. Opsmith is also designed to prevent cloud provider lock-in, which helps control long-term costs. The generated configurations are standard and maintainable, making it easy to hand over the deployment to an in-house DevOps team.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Getting Started](#getting-started)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Deployment Workflow](#deployment-workflow)
|
|
19
|
+
- [User Guide](#user-guide)
|
|
20
|
+
- [LLMs](#llms)
|
|
21
|
+
- [Supported Models](#supported-models)
|
|
22
|
+
- [Cloud Providers](#cloud-providers)
|
|
23
|
+
- [AWS](#aws-amazon-web-services)
|
|
24
|
+
- [GCP](#gcp-google-cloud-platform)
|
|
25
|
+
- [Deployment Strategies](#deployment-strategies)
|
|
26
|
+
- [Monolithic](#monolithic)
|
|
27
|
+
- [Deployments Directory](#deployments-directory)
|
|
28
|
+
- [Extending Opsmith](#extending-opsmith)
|
|
29
|
+
- [Adding a Cloud Provider](#adding-a-cloud-provider)
|
|
30
|
+
- [Adding a Deployment Strategy](#adding-a-deployment-strategy)
|
|
31
|
+
- [Contributing](#contributing)
|
|
32
|
+
|
|
33
|
+
## Getting Started
|
|
34
|
+
|
|
35
|
+
### Installation
|
|
36
|
+
|
|
37
|
+
1. **Prerequisites**: Opsmith requires `Docker` and `Terraform` to be installed and available in your system's `PATH`.
|
|
38
|
+
|
|
39
|
+
- **macOS (with [Homebrew](https://brew.sh/))**:
|
|
40
|
+
```shell
|
|
41
|
+
brew install --cask docker
|
|
42
|
+
brew install terraform
|
|
43
|
+
```
|
|
44
|
+
After installation, make sure you start Docker Desktop.
|
|
45
|
+
|
|
46
|
+
- **Windows (with [Chocolatey](https://chocolatey.org/))**:
|
|
47
|
+
```shell
|
|
48
|
+
choco install docker-desktop terraform
|
|
49
|
+
```
|
|
50
|
+
After installation, make sure you start Docker Desktop.
|
|
51
|
+
|
|
52
|
+
- **Linux (Debian/Ubuntu)**:
|
|
53
|
+
Please follow the official installation guides for [Docker](https://docs.docker.com/engine/install/ubuntu/) and [Terraform](https://developer.hashicorp.com/terraform/install).
|
|
54
|
+
|
|
55
|
+
2. **Install Opsmith**:
|
|
56
|
+
Once the prerequisites are installed, you can install Opsmith using `pip`:
|
|
57
|
+
```shell
|
|
58
|
+
pip install opsmith-cli
|
|
59
|
+
```
|
|
60
|
+
On macOS, you might need to use `pip3` if `pip` doesn't work.
|
|
61
|
+
|
|
62
|
+
### Deployment Workflow
|
|
63
|
+
|
|
64
|
+
Deploying your application with Opsmith follows a straightforward workflow:
|
|
65
|
+
|
|
66
|
+
1. **Setup Your Project**
|
|
67
|
+
|
|
68
|
+
Navigate to your project's root directory, which should be a Git repository, and run the `setup` command. This command initializes your deployment configuration by analyzing your codebase to detect services and infrastructure requirements.
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
opsmith --model <your-llm-provider:model-name> --api-key <your-api-key> setup
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You will be prompted to:
|
|
75
|
+
- Provide an application name.
|
|
76
|
+
- Select a cloud provider (e.g., AWS, GCP — see [Cloud Providers](#cloud-providers) for setup).
|
|
77
|
+
- Review and confirm the services and infrastructure dependencies detected by the AI.
|
|
78
|
+
- Opsmith will then generate a `Dockerfile` for each of your services.
|
|
79
|
+
|
|
80
|
+
2. **Deploy Your Application**
|
|
81
|
+
|
|
82
|
+
After setting up the configuration, deploy your application using the `deploy` command:
|
|
83
|
+
|
|
84
|
+
```shell
|
|
85
|
+
opsmith --model <your-llm-provider:model-name> --api-key <your-api-key> deploy
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
This will guide you through:
|
|
89
|
+
- Creating a new deployment environment (e.g., `dev`, `staging`, `production`).
|
|
90
|
+
- Selecting a cloud region.
|
|
91
|
+
- Choosing a deployment strategy (e.g., `Monolithic`).
|
|
92
|
+
- Configuring domain names for your services if needed.
|
|
93
|
+
|
|
94
|
+
Opsmith will then provision all the necessary cloud infrastructure and deploy your application.
|
|
95
|
+
|
|
96
|
+
3. **Manage Your Deployments**
|
|
97
|
+
|
|
98
|
+
To manage an existing environment, run the `deploy` command again. You can select an environment and perform the following actions:
|
|
99
|
+
- `release`: Deploy a new version of your application.
|
|
100
|
+
- `run`: Execute a command on a specific service within your environment (e.g., run database migrations).
|
|
101
|
+
- `delete`: Tear down all the infrastructure and delete the environment.
|
|
102
|
+
|
|
103
|
+
## User Guide
|
|
104
|
+
|
|
105
|
+
### LLMs
|
|
106
|
+
|
|
107
|
+
Opsmith leverages Large Language Models (LLMs) to analyze your codebase, generate configurations, and make decisions about your infrastructure. To use Opsmith, you must provide an LLM model and a corresponding API key from the model's provider.
|
|
108
|
+
|
|
109
|
+
#### Supported Models
|
|
110
|
+
|
|
111
|
+
Opsmith supports a variety of models from different providers. Here is a list of the currently supported models:
|
|
112
|
+
|
|
113
|
+
- **OpenAI**:
|
|
114
|
+
- `openai:gpt-4.1`
|
|
115
|
+
- `openai:gpt-o3`
|
|
116
|
+
- **Anthropic**:
|
|
117
|
+
- `anthropic:claude-3-7-sonnet-20250219`
|
|
118
|
+
- `anthropic:claude-sonnet-4-20250514`
|
|
119
|
+
- **Google**:
|
|
120
|
+
- `google-gla:gemini-2.5-pro`
|
|
121
|
+
|
|
122
|
+
#### Usage
|
|
123
|
+
|
|
124
|
+
To specify which model to use, pass the `--model` option with the full model name, and provide your API key with the `--api-key` option.
|
|
125
|
+
|
|
126
|
+
**Example with OpenAI:**
|
|
127
|
+
```shell
|
|
128
|
+
opsmith --model openai:gpt-4.1 --api-key YOUR_OPENAI_API_KEY COMMAND
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Example with Anthropic:**
|
|
132
|
+
```shell
|
|
133
|
+
opsmith --model anthropic:claude-3-7-sonnet-20250219 --api-key YOUR_ANTHROPIC_API_KEY COMMAND
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Example with Google:**
|
|
137
|
+
```shell
|
|
138
|
+
opsmith --model google-gla:gemini-2.5-pro --api-key YOUR_GEMINI_API_KEY COMMAND
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Cloud Providers
|
|
142
|
+
|
|
143
|
+
Opsmith uses your cloud provider's command-line tools to authenticate and manage resources. Before using Opsmith, you need to configure the credentials for your chosen cloud provider.
|
|
144
|
+
|
|
145
|
+
#### AWS (Amazon Web Services)
|
|
146
|
+
|
|
147
|
+
Opsmith uses the official AWS CLI to interact with your account.
|
|
148
|
+
|
|
149
|
+
1. **Install the AWS CLI**: Follow the [official installation guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) for your operating system.
|
|
150
|
+
|
|
151
|
+
2. **Configure Credentials**: Once installed, configure the CLI with your AWS credentials by running:
|
|
152
|
+
```shell
|
|
153
|
+
aws configure
|
|
154
|
+
```
|
|
155
|
+
You will be prompted to enter your `AWS Access Key ID`, `AWS Secret Access Key`, default region, and default output format. This will store your credentials in the `~/.aws/credentials` file, which Opsmith will use automatically.
|
|
156
|
+
|
|
157
|
+
#### GCP (Google Cloud Platform)
|
|
158
|
+
|
|
159
|
+
Opsmith uses the Google Cloud CLI to authenticate.
|
|
160
|
+
|
|
161
|
+
1. **Install the gcloud CLI**: Follow the [official installation guide](https://cloud.google.com/sdk/docs/install) for your operating system.
|
|
162
|
+
|
|
163
|
+
2. **Authenticate with Application Default Credentials (ADC)**: Run the following command to log in and create your ADC file:
|
|
164
|
+
```shell
|
|
165
|
+
gcloud auth application-default login
|
|
166
|
+
```
|
|
167
|
+
This command will open a browser window for you to log in to your Google account and authorize access. Once completed, your credentials will be stored locally, and Opsmith will use them to authenticate.
|
|
168
|
+
|
|
169
|
+
### Deployment Strategies
|
|
170
|
+
|
|
171
|
+
Deployment strategies in Opsmith define the architecture and approach for deploying your application. When you create a new environment, you will be prompted to select a strategy that best fits your project's needs. Each strategy automates the provisioning of specific infrastructure and handles the deployment process accordingly.
|
|
172
|
+
|
|
173
|
+
#### Monolithic
|
|
174
|
+
|
|
175
|
+
The **Monolithic** strategy is designed for simplicity and is ideal for hobby projects, experiments, or small-scale applications. It deploys your entire application to a single virtual machine (VM).
|
|
176
|
+
|
|
177
|
+
Key features of the Monolithic strategy include:
|
|
178
|
+
|
|
179
|
+
- **Single Virtual Machine**: Provisions one VM to host all backend services and infrastructure dependencies.
|
|
180
|
+
- **Containerization**: Backend and full-stack services are containerized using Docker and managed with `docker-compose`. This isolates services and simplifies dependency management.
|
|
181
|
+
- **Frontend Deployment**: Frontend services are built and deployed to a cloud storage bucket (like AWS S3 or GCS) and served through a Content Delivery Network (CDN) for optimal performance.
|
|
182
|
+
|
|
183
|
+
This strategy is a great starting point for getting your application running in the cloud quickly with minimal complexity.
|
|
184
|
+
|
|
185
|
+
### Deployments Directory
|
|
186
|
+
|
|
187
|
+
When you run `opsmith`, it creates a `.opsmith` directory in the root of your project. This directory stores all the configurations, generated artifacts, and state files required to manage your deployments. This directory is intended to be committed to your git repository so that your deployment configurations are versioned. Sensitive files like Terraform state are automatically ignored.
|
|
188
|
+
|
|
189
|
+
Here is an overview of what you can find inside the `.opsmith` directory:
|
|
190
|
+
|
|
191
|
+
- `deployments.yml`: The main configuration file for your application. It contains the list of services, infrastructure dependencies, cloud provider details, and environment configurations.
|
|
192
|
+
- `docker/`: Contains the generated `Dockerfile`s for each of your services, organized into subdirectories by service name.
|
|
193
|
+
- `environments/`: This directory holds the state and configuration for each of your deployment environments (e.g., `dev`, `staging`).
|
|
194
|
+
- `<environment-name>/`: A directory for each environment, containing Terraform state for provisioned infrastructure and other environment-specific files.
|
|
195
|
+
- `global/`: Contains configurations that are shared across environments within a specific region, such as container registries.
|
|
196
|
+
|
|
197
|
+
### Extending Opsmith
|
|
198
|
+
|
|
199
|
+
Opsmith has been designed with extensibility in mind, allowing you to add your own cloud providers and deployment strategies. This is achieved through Python's entry points mechanism, which enables other packages to plug into Opsmith seamlessly.
|
|
200
|
+
|
|
201
|
+
#### Adding a Cloud Provider
|
|
202
|
+
|
|
203
|
+
To add a new cloud provider, you need to:
|
|
204
|
+
|
|
205
|
+
1. Create a Python class that inherits from `opsmith.cloud_providers.base.BaseCloudProvider` and implements all its abstract methods (`name`, `description`, `get_detail_model`, `get_account_details`, `get_instance_types`, `get_regions`).
|
|
206
|
+
2. Package your new provider class.
|
|
207
|
+
3. In your package's `pyproject.toml`, add an entry point under the `[project.entry-points."opsmith.cloud_providers"]` group.
|
|
208
|
+
|
|
209
|
+
Example `pyproject.toml` entry:
|
|
210
|
+
|
|
211
|
+
```toml
|
|
212
|
+
[project.entry-points."opsmith.cloud_providers"]
|
|
213
|
+
my-provider = "my_opsmith_plugin.providers:MyCloudProvider"
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Once your package is installed in the same environment as `opsmith-cli`, Opsmith will automatically discover and register your new provider.
|
|
217
|
+
|
|
218
|
+
#### Adding a Deployment Strategy
|
|
219
|
+
|
|
220
|
+
Similarly, you can add a new deployment strategy by:
|
|
221
|
+
|
|
222
|
+
1. Creating a Python class that inherits from `opsmith.deployment_strategies.base.BaseDeploymentStrategy` and implements its abstract methods (`name`, `description`, `deploy`, `release`, `destroy`, `run`).
|
|
223
|
+
2. Packaging your new strategy class.
|
|
224
|
+
3. In your package's `pyproject.toml`, add an entry point under the `[project.entry-points."opsmith.deployment_strategies"]` group.
|
|
225
|
+
|
|
226
|
+
Example `pyproject.toml` entry:
|
|
227
|
+
|
|
228
|
+
```toml
|
|
229
|
+
[project.entry-points."opsmith.deployment_strategies"]
|
|
230
|
+
my-strategy = "my_opsmith_plugin.strategies:MyStrategy"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
After installation, your custom deployment strategy will be available for selection when creating a new environment.
|
|
234
|
+
|
|
235
|
+
## Contributing
|
|
236
|
+
|
|
237
|
+
We welcome contributions to Opsmith! If you're interested in helping improve the tool, here are a few ways to get started:
|
|
238
|
+
|
|
239
|
+
- **Reporting Bugs**: If you encounter a bug, please open an issue on our GitHub repository. Include as much detail as possible, such as your operating system, the command you ran, and the full error message.
|
|
240
|
+
- **Suggesting Enhancements**: Have an idea for a new feature or an improvement to an existing one? We'd love to hear it. Open an issue to start a discussion.
|
|
241
|
+
- **Submitting Pull Requests**: If you'd like to contribute code, please fork the repository and submit a pull request. For major changes, it's best to discuss your idea in an issue first.
|
|
242
|
+
|
|
243
|
+
When contributing, please follow our [engineering conventions](./CONVENTIONS.md) and ensure your code is formatted with `black`.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import List, Type
|
|
5
|
+
|
|
6
|
+
from pydantic_ai import Agent, ModelRetry, RunContext
|
|
7
|
+
|
|
8
|
+
from opsmith.models import BaseAiModel
|
|
9
|
+
from opsmith.prompts import SYSTEM_PROMPT
|
|
10
|
+
from opsmith.utils import generate_secret_string
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class AgentDeps:
|
|
15
|
+
src_dir: Path
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def is_duplicate_tool_call(ctx: RunContext[AgentDeps], tool_name: str) -> bool:
|
|
19
|
+
""""""
|
|
20
|
+
tool_calls = set()
|
|
21
|
+
message_parts = [item for message in ctx.messages for item in message.parts]
|
|
22
|
+
for part in message_parts:
|
|
23
|
+
if part.part_kind == "tool-call" and part.tool_name == tool_name:
|
|
24
|
+
if isinstance(part.args, dict):
|
|
25
|
+
tool_args = json.dumps(part.args, sort_keys=True)
|
|
26
|
+
else:
|
|
27
|
+
tool_args = part.args
|
|
28
|
+
if tool_args in tool_calls:
|
|
29
|
+
return True
|
|
30
|
+
else:
|
|
31
|
+
# logger.debug(f"Tool {tool_def.name} called with arguments: {tool_args}")
|
|
32
|
+
tool_calls.add(tool_args)
|
|
33
|
+
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def build_agent(model_config: Type[BaseAiModel], instrument: bool = False) -> Agent:
|
|
38
|
+
agent = Agent(
|
|
39
|
+
model=model_config.model_name_abs(),
|
|
40
|
+
model_settings=model_config.get_model_settings(),
|
|
41
|
+
instructions=SYSTEM_PROMPT,
|
|
42
|
+
instrument=instrument,
|
|
43
|
+
deps_type=AgentDeps,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
@agent.tool(retries=5)
|
|
47
|
+
def read_file_content(ctx: RunContext[AgentDeps], filenames: List[str]) -> List[str]:
|
|
48
|
+
"""
|
|
49
|
+
Reads and returns the content of specified files from the repository.
|
|
50
|
+
Use this to understand file structures, dependencies, or specific configurations.
|
|
51
|
+
Provide the relative file paths from the repository root.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
ctx: The run context object containing the dependencies of the agent.
|
|
55
|
+
filenames: A list of relative paths to the files from the repository root.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
A list of strings, where each string is the content of the corresponding file.
|
|
59
|
+
The order of contents in the list matches the order of filenames in the input.
|
|
60
|
+
"""
|
|
61
|
+
if is_duplicate_tool_call(ctx, "read_file_content"):
|
|
62
|
+
raise ModelRetry(
|
|
63
|
+
"The tool 'read_file_content' has already been called with the exact same list of "
|
|
64
|
+
"files in this conversation."
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
contents = []
|
|
68
|
+
for filename in filenames:
|
|
69
|
+
if Path(filename).is_absolute():
|
|
70
|
+
raise ModelRetry(
|
|
71
|
+
f"Absolute file paths are not allowed for '{filename}'. Please provide a"
|
|
72
|
+
" relative path."
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
absolute_file_path = ctx.deps.src_dir.joinpath(filename).resolve()
|
|
76
|
+
|
|
77
|
+
if not str(absolute_file_path).startswith(str(ctx.deps.src_dir)):
|
|
78
|
+
raise ModelRetry(
|
|
79
|
+
f"Access denied. File '{filename}' is outside the repository root."
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
if not absolute_file_path.is_file():
|
|
83
|
+
raise ModelRetry(f"File '{filename}' not found or is not a regular file.")
|
|
84
|
+
|
|
85
|
+
with open(absolute_file_path, "r", encoding="utf-8", errors="ignore") as f:
|
|
86
|
+
content = f.read()
|
|
87
|
+
contents.append(content)
|
|
88
|
+
return contents
|
|
89
|
+
|
|
90
|
+
@agent.tool()
|
|
91
|
+
def generate_secret(ctx: RunContext[AgentDeps], length: int = 32) -> str:
|
|
92
|
+
"""
|
|
93
|
+
Generates a secure random string of a specified length.
|
|
94
|
+
Useful for creating passwords, API keys, or other secrets.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
ctx: The run context object.
|
|
98
|
+
length: The desired length of the secret string. Defaults to 32.
|
|
99
|
+
|
|
100
|
+
Returns:
|
|
101
|
+
A secure random string.
|
|
102
|
+
"""
|
|
103
|
+
return generate_secret_string(length)
|
|
104
|
+
|
|
105
|
+
return agent
|