mdan-cli 2.6.0 → 2.7.0

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.
@@ -0,0 +1,421 @@
1
+ """DevOps Agent (Anas) - SHIP Phase
2
+
3
+ Responsible for deployment, CI/CD, infrastructure, and cloud operations.
4
+ """
5
+
6
+ from crewai import Agent, Task
7
+ from typing import List, Optional
8
+ from ..tools.sql_tool import SQLTool
9
+ from ..tools.serper_tool import SerperTool
10
+ from ..tools.file_tool import FileTool
11
+
12
+
13
+ class DevOpsAgent:
14
+ """DevOps Agent for SHIP phase - Deployment, CI/CD, and infrastructure management."""
15
+
16
+ def __init__(
17
+ self,
18
+ sql_tool: Optional[SQLTool] = None,
19
+ serper_tool: Optional[SerperTool] = None,
20
+ file_tool: Optional[FileTool] = None,
21
+ llm=None,
22
+ ):
23
+ """Initialize DevOps Agent.
24
+
25
+ Args:
26
+ sql_tool: SQL connector tool
27
+ serper_tool: Web search tool
28
+ file_tool: File operations tool
29
+ llm: Language model instance
30
+ """
31
+ self.sql_tool = sql_tool
32
+ self.serper_tool = serper_tool
33
+ self.file_tool = file_tool
34
+ self.llm = llm
35
+
36
+ tools = []
37
+ if sql_tool:
38
+ tools.append(sql_tool)
39
+ if serper_tool:
40
+ tools.append(serper_tool)
41
+ if file_tool:
42
+ tools.append(file_tool)
43
+
44
+ self.agent = Agent(
45
+ role="DevOps Engineer & Cloud Specialist",
46
+ goal="Ensure reliable deployment and infrastructure management through CI/CD and cloud operations",
47
+ backstory="""You are Anas, an expert DevOps Engineer with deep knowledge of cloud infrastructure,
48
+ CI/CD pipelines, containerization, and infrastructure as code. You excel at designing robust deployment
49
+ strategies, automating operations, and ensuring high availability. You are automation-focused,
50
+ reliability-conscious, and committed to operational excellence.""",
51
+ verbose=True,
52
+ allow_delegation=False,
53
+ tools=tools,
54
+ llm=llm,
55
+ )
56
+
57
+ def create_ci_cd_pipeline_task(self, project_context: str) -> Task:
58
+ """Create task for setting up CI/CD pipeline.
59
+
60
+ Args:
61
+ project_context: Project structure and requirements
62
+
63
+ Returns:
64
+ Task for CI/CD pipeline setup
65
+ """
66
+ return Task(
67
+ description=f"""Design and implement CI/CD pipeline.
68
+
69
+ Project Context:
70
+ {project_context}
71
+
72
+ Your task:
73
+ 1. Analyze project structure and requirements
74
+ 2. Design CI/CD pipeline stages:
75
+ - Build
76
+ - Test (unit, integration, E2E)
77
+ - Code quality checks (linting, type checking)
78
+ - Security scanning
79
+ - Build artifacts
80
+ - Deploy to staging
81
+ - Integration tests
82
+ - Deploy to production
83
+ 3. Select CI/CD platform (GitHub Actions, GitLab CI, Azure DevOps, etc.)
84
+ 4. Configure pipeline triggers (push, PR, schedule)
85
+ 5. Set up environment-specific configurations
86
+ 6. Configure secrets management
87
+ 7. Set up notifications and approvals
88
+ 8. Document pipeline configuration
89
+
90
+ Output: Complete CI/CD pipeline configuration with documentation.
91
+ """,
92
+ agent=self.agent,
93
+ expected_output="CI/CD pipeline configuration with all stages and documentation",
94
+ )
95
+
96
+ def create_docker_setup_task(self, application_context: str) -> Task:
97
+ """Create task for Docker containerization.
98
+
99
+ Args:
100
+ application_context: Application details and dependencies
101
+
102
+ Returns:
103
+ Task for Docker setup
104
+ """
105
+ return Task(
106
+ description=f
107
+ < arg_value
108
+ > """Set up Docker containerization for the application.
109
+
110
+ Application Context:
111
+ {application_context}
112
+
113
+ Your task:
114
+ 1. Create optimized Dockerfile for the application
115
+ 2. Use multi-stage builds for smaller images
116
+ 3. Configure health checks
117
+ 4. Set up proper environment variables
118
+ 5. Create docker-compose for local development
119
+ 6. Configure volume mounts for development
120
+ 7. Set up networking between services
121
+ 8. Document Docker setup and usage
122
+ 9. Create .dockerignore file
123
+
124
+ Output: Complete Docker setup with Dockerfile, docker-compose, and documentation.
125
+ """,
126
+ agent=self.agent,
127
+ expected_output="Docker setup with Dockerfile, docker-compose, and usage documentation",
128
+ )
129
+
130
+ def create_kubernetes_setup_task(self, k8s_context: str) -> Task:
131
+ """Create task for Kubernetes deployment.
132
+
133
+ Args:
134
+ k8s_context: Application and infrastructure requirements
135
+
136
+ Returns:
137
+ Task for Kubernetes setup
138
+ """
139
+ return Task(
140
+ description=f"""Set up Kubernetes deployment configuration.
141
+
142
+ Kubernetes Context:
143
+ {k8s_context}
144
+
145
+ Your task:
146
+ 1. Design Kubernetes architecture
147
+ 2. Create deployment manifests:
148
+ - Deployment
149
+ - Service
150
+ - ConfigMap
151
+ - Secret
152
+ - Ingress
153
+ - HorizontalPodAutoscaler
154
+ 3. Configure resource limits and requests
155
+ 4. Set up liveness and readiness probes
156
+ 5. Configure persistent volumes if needed
157
+ 6. Set up namespace isolation
158
+ 7. Create Helm chart if applicable
159
+ 8. Document Kubernetes setup and deployment process
160
+
161
+ Output: Complete Kubernetes manifests with deployment documentation.
162
+ """,
163
+ agent=self.agent,
164
+ expected_output="Kubernetes deployment manifests with setup documentation",
165
+ )
166
+
167
+ def create_azure_deployment_task(self, azure_context: str) -> Task:
168
+ """Create task for Azure cloud deployment.
169
+
170
+ Args:
171
+ azure_context: Azure requirements and configuration
172
+
173
+ Returns:
174
+ Task for Azure deployment
175
+ """
176
+ return Task(
177
+ description=f"""Set up Azure cloud deployment infrastructure.
178
+
179
+ Azure Context:
180
+ {azure_context}
181
+
182
+ Your task:
183
+ 1. Design Azure architecture
184
+ 2. Set up Azure resources:
185
+ - Resource Group
186
+ - App Service / Container Apps / AKS
187
+ - Azure SQL / PostgreSQL
188
+ - Azure Storage
189
+ - Azure Key Vault
190
+ - Application Insights
191
+ - Azure CDN (if needed)
192
+ 3. Configure networking (VNet, subnets, NSG)
193
+ 4. Set up identity and access management
194
+ 5. Configure backup and disaster recovery
195
+ 6. Set up monitoring and alerting
196
+ 7. Create Infrastructure as Code (Terraform/Bicep)
197
+ 8. Document Azure setup and deployment process
198
+
199
+ Output: Complete Azure infrastructure setup with IaC and documentation.
200
+ """,
201
+ agent=self.agent,
202
+ expected_output="Azure infrastructure setup with IaC and deployment documentation",
203
+ )
204
+
205
+ def create_monitoring_setup_task(self, monitoring_context: str) -> Task:
206
+ """Create task for monitoring and observability.
207
+
208
+ Args:
209
+ monitoring_context: Application and infrastructure context
210
+
211
+ Returns:
212
+ Task for monitoring setup
213
+ """
214
+ return Task(
215
+ description=f"""Set up comprehensive monitoring and observability.
216
+
217
+ Monitoring Context:
218
+ {monitoring_context}
219
+
220
+ Your task:
221
+ 1. Define monitoring requirements and metrics
222
+ 2. Set up application monitoring:
223
+ - Performance metrics (latency, throughput, error rate)
224
+ - Business metrics
225
+ - Custom metrics
226
+ 3. Set up infrastructure monitoring:
227
+ - CPU, memory, disk, network
228
+ - Container metrics
229
+ - Database metrics
230
+ 4. Configure logging:
231
+ - Application logs
232
+ - Access logs
233
+ - Error logs
234
+ - Structured logging
235
+ 5. Set up distributed tracing
236
+ 6. Configure dashboards and visualizations
237
+ 7. Set up alerts and notifications
238
+ 8. Document monitoring setup and alert thresholds
239
+
240
+ Output: Complete monitoring setup with dashboards and alerting.
241
+ """,
242
+ agent=self.agent,
243
+ expected_output="Monitoring infrastructure with dashboards and alerting configuration",
244
+ )
245
+
246
+ def create_deployment_strategy_task(self, deployment_context: str) -> Task:
247
+ """Create task for deployment strategy.
248
+
249
+ Args:
250
+ deployment_context: Application and business requirements
251
+
252
+ Returns:
253
+ Task for deployment strategy
254
+ """
255
+ return Task(
256
+ description=f"""Design deployment strategy for the application.
257
+
258
+ Deployment Context:
259
+ {deployment_context}
260
+
261
+ Your task:
262
+ 1. Analyze application and business requirements
263
+ 2. Select deployment strategy:
264
+ - Blue-Green deployment
265
+ - Canary deployment
266
+ - Rolling update
267
+ - Feature flags
268
+ 3. Design deployment pipeline stages
269
+ 4. Configure rollback procedures
270
+ 5. Set up health checks and smoke tests
271
+ 6. Configure traffic shifting
272
+ 7. Set up deployment approvals
273
+ 8. Document deployment strategy and procedures
274
+
275
+ Output: Deployment strategy document with implementation details.
276
+ """,
277
+ agent=self.agent,
278
+ expected_output="Deployment strategy document with implementation procedures",
279
+ )
280
+
281
+ def create_infrastructure_as_code_task(self, iac_context: str) -> Task:
282
+ """Create task for Infrastructure as Code.
283
+
284
+ Args:
285
+ iac_context: Infrastructure requirements
286
+
287
+ Returns:
288
+ Task for IaC setup
289
+ """
290
+ return Task(
291
+ description=f"""Set up Infrastructure as Code.
292
+
293
+ IaC Context:
294
+ {iac_context}
295
+
296
+ Your task:
297
+ 1. Select IaC tool (Terraform, Bicep, Pulumi, etc.)
298
+ 2. Design infrastructure modules
299
+ 3. Create reusable infrastructure components
300
+ 4. Configure state management
301
+ 5. Set up environment-specific configurations
302
+ 6. Configure secrets management
303
+ 7. Set up infrastructure testing
304
+ 8. Document IaC structure and usage
305
+ 9. Create infrastructure validation
306
+
307
+ Output: Complete IaC setup with modules and documentation.
308
+ """,
309
+ agent=self.agent,
310
+ expected_output="Infrastructure as Code setup with modules and documentation",
311
+ )
312
+
313
+ def create_backup_recovery_task(self, backup_context: str) -> Task:
314
+ """Create task for backup and disaster recovery.
315
+
316
+ Args:
317
+ backup_context: Data and infrastructure context
318
+
319
+ Returns:
320
+ Task for backup and recovery setup
321
+ """
322
+ return Task(
323
+ description=f"""Set up backup and disaster recovery strategy.
324
+
325
+ Backup Context:
326
+ {backup_context}
327
+
328
+ Your task:
329
+ 1. Identify critical data and infrastructure
330
+ 2. Define backup requirements (RPO, RTO)
331
+ 3. Set up automated backups:
332
+ - Database backups
333
+ - Application data backups
334
+ - Configuration backups
335
+ 4. Configure backup retention policies
336
+ 5. Set up backup monitoring and alerts
337
+ 6. Design disaster recovery procedures
338
+ 7. Test backup and recovery procedures
339
+ 8. Document backup and recovery processes
340
+
341
+ Output: Backup and disaster recovery setup with documentation.
342
+ """,
343
+ agent=self.agent,
344
+ expected_output="Backup and disaster recovery setup with procedures documentation",
345
+ )
346
+
347
+ def create_scaling_strategy_task(self, scaling_context: str) -> Task:
348
+ """Create task for scaling strategy.
349
+
350
+ Args:
351
+ scaling_context: Application and traffic patterns
352
+
353
+ Returns:
354
+ Task for scaling strategy
355
+ """
356
+ return Task(
357
+ description=f"""Design scaling strategy for the application.
358
+
359
+ Scaling Context:
360
+ {scaling_context}
361
+
362
+ Your task:
363
+ 1. Analyze traffic patterns and load requirements
364
+ 2. Design scaling strategy:
365
+ - Horizontal scaling
366
+ - Vertical scaling
367
+ - Auto-scaling policies
368
+ 3. Configure load balancing
369
+ 4. Set up caching strategy
370
+ 5. Configure database scaling
371
+ 6. Set up CDN for static assets
372
+ 7. Configure auto-scaling rules and thresholds
373
+ 8. Document scaling strategy and procedures
374
+
375
+ Output: Scaling strategy document with implementation details.
376
+ """,
377
+ agent=self.agent,
378
+ expected_output="Scaling strategy document with auto-scaling configuration",
379
+ )
380
+
381
+ def create_security_hardening_task(self, security_context: str) -> Task:
382
+ """Create task for infrastructure security hardening.
383
+
384
+ Args:
385
+ security_context: Infrastructure and security requirements
386
+
387
+ Returns:
388
+ Task for security hardening
389
+ """
390
+ return Task(
391
+ description=f"""Implement infrastructure security hardening.
392
+
393
+ Security Context:
394
+ {security_context}
395
+
396
+ Your task:
397
+ 1. Review infrastructure security posture
398
+ 2. Implement network security:
399
+ - VNet isolation
400
+ - Network security groups
401
+ - Private endpoints
402
+ 3. Configure identity and access management
403
+ 4. Set up secrets management
404
+ 5. Configure SSL/TLS certificates
405
+ 6. Implement security monitoring
406
+ 7. Configure firewall rules
407
+ 8. Document security hardening measures
408
+
409
+ Output: Infrastructure security hardening implementation with documentation.
410
+ """,
411
+ agent=self.agent,
412
+ expected_output="Infrastructure security hardening with documentation",
413
+ )
414
+
415
+ def get_agent(self) -> Agent:
416
+ """Get the CrewAI Agent instance.
417
+
418
+ Returns:
419
+ CrewAI Agent instance
420
+ """
421
+ return self.agent