mdan-cli 2.5.1 → 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.
- package/AGENTS.md +76 -1
- package/README.md +274 -4
- package/agents/auto-orchestrator.md +343 -0
- package/agents/devops.md +511 -94
- package/cli/mdan.py +111 -6
- package/cli/mdan_crewai.py +539 -0
- package/core/crewai_orchestrator.md +419 -0
- package/core/debate-protocol.md +454 -0
- package/core/universal-envelope.md +113 -0
- package/integrations/__init__.py +33 -0
- package/integrations/crewai/__init__.py +27 -0
- package/integrations/crewai/agents/__init__.py +21 -0
- package/integrations/crewai/agents/architect_agent.py +264 -0
- package/integrations/crewai/agents/dev_agent.py +271 -0
- package/integrations/crewai/agents/devops_agent.py +421 -0
- package/integrations/crewai/agents/doc_agent.py +388 -0
- package/integrations/crewai/agents/product_agent.py +203 -0
- package/integrations/crewai/agents/security_agent.py +386 -0
- package/integrations/crewai/agents/test_agent.py +358 -0
- package/integrations/crewai/agents/ux_agent.py +257 -0
- package/integrations/crewai/flows/__init__.py +13 -0
- package/integrations/crewai/flows/auto_flow.py +451 -0
- package/integrations/crewai/flows/build_flow.py +297 -0
- package/integrations/crewai/flows/debate_flow.py +422 -0
- package/integrations/crewai/flows/discovery_flow.py +267 -0
- package/integrations/crewai/orchestrator.py +558 -0
- package/integrations/crewai/skills/__init__.py +8 -0
- package/integrations/crewai/skills/skill_router.py +534 -0
- package/integrations/crewai/tools/__init__.py +11 -0
- package/integrations/crewai/tools/file_tool.py +355 -0
- package/integrations/crewai/tools/serper_tool.py +169 -0
- package/integrations/crewai/tools/sql_tool.py +435 -0
- package/memory/CONTEXT-SAVE-FORMAT.md +328 -0
- package/memory/MEMORY-AUTO.json +66 -0
- package/memory/RESUME-PROTOCOL.md +379 -0
- package/package.json +1 -1
- package/phases/auto-01-load.md +165 -0
- package/phases/auto-02-discover.md +207 -0
- package/phases/auto-03-plan.md +509 -0
- package/phases/auto-04-architect.md +567 -0
- package/phases/auto-05-implement.md +713 -0
- package/phases/auto-06-test.md +559 -0
- package/phases/auto-07-deploy.md +510 -0
- package/phases/auto-08-doc.md +970 -0
- package/skills/azure-devops/skill.md +1757 -0
- package/templates/dotnet-blazor/README.md +415 -0
- package/templates/external-services/ExampleService.cs +361 -0
- package/templates/external-services/IService.cs +113 -0
- package/templates/external-services/README.md +325 -0
- package/templates/external-services/ServiceBase.cs +492 -0
- package/templates/external-services/ServiceProvider.cs +243 -0
- package/templates/prompts/devops-agent.yaml +327 -0
- package/templates/prompts.json +15 -1
- package/templates/sql-server/README.md +37 -0
- package/templates/sql-server/functions.sql +158 -0
- package/templates/sql-server/schema.sql +188 -0
- package/templates/sql-server/stored-procedures.sql +284 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Templates d'Intégration de Services Externes
|
|
2
|
+
|
|
3
|
+
Ce répertoire contient des templates génériques pour intégrer des services externes dans les projets MDAN-AUTO.
|
|
4
|
+
|
|
5
|
+
## Vue d'Ensemble
|
|
6
|
+
|
|
7
|
+
Les templates fournis permettent d'intégrer n'importe quel service externe (API REST, services web, etc.) avec des patterns avancés intégrés:
|
|
8
|
+
- **Retry automatique** - Réessai automatique en cas d'échec
|
|
9
|
+
- **Circuit Breaker** - Protection contre les défaillances en cascade
|
|
10
|
+
- **Rate Limiting** - Limitation du taux de requêtes
|
|
11
|
+
- **Caching** - Mise en cache des réponses
|
|
12
|
+
- **Logging structuré** - Journalisation détaillée
|
|
13
|
+
- **Gestion des erreurs** - Gestion centralisée des exceptions
|
|
14
|
+
|
|
15
|
+
## Fichiers
|
|
16
|
+
|
|
17
|
+
- `IService.cs` - Interface générique pour tous les services externes
|
|
18
|
+
- `ServiceBase.cs` - Implémentation de base avec patterns avancés
|
|
19
|
+
- `ServiceProvider.cs` - Template pour implémenter un fournisseur spécifique
|
|
20
|
+
- `ExampleService.cs` - Exemple complet d'implémentation
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Copier le template dans votre projet
|
|
26
|
+
cp -r templates/external-services src/Services/
|
|
27
|
+
|
|
28
|
+
# Ajouter les références nécessaires
|
|
29
|
+
cd src/Services/external-services
|
|
30
|
+
dotnet add package Microsoft.Extensions.Http
|
|
31
|
+
dotnet add package Microsoft.Extensions.Caching.Memory
|
|
32
|
+
dotnet add package Polly
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
### Configuration de Base (Un Service)
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"ExternalServices": {
|
|
42
|
+
"Default": {
|
|
43
|
+
"BaseUrl": "https://api.example.com/v1",
|
|
44
|
+
"ApiKey": "your-api-key",
|
|
45
|
+
"Timeout": 30,
|
|
46
|
+
"RetryCount": 3,
|
|
47
|
+
"RetryDelay": 1000,
|
|
48
|
+
"EnableCircuitBreaker": true,
|
|
49
|
+
"CircuitBreakerThreshold": 5,
|
|
50
|
+
"EnableRateLimiting": true,
|
|
51
|
+
"RateLimitPerMinute": 60,
|
|
52
|
+
"EnableCaching": true,
|
|
53
|
+
"CacheDurationMinutes": 5
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Configuration Multiples Services
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"ExternalServices": {
|
|
64
|
+
"ServiceA": {
|
|
65
|
+
"BaseUrl": "https://api.servicea.com/v1",
|
|
66
|
+
"ApiKey": "service-a-key",
|
|
67
|
+
"Timeout": 15,
|
|
68
|
+
"RetryCount": 2,
|
|
69
|
+
"EnableCircuitBreaker": true,
|
|
70
|
+
"EnableRateLimiting": true,
|
|
71
|
+
"RateLimitPerMinute": 100
|
|
72
|
+
},
|
|
73
|
+
"ServiceB": {
|
|
74
|
+
"BaseUrl": "https://api.serviceb.com/v2",
|
|
75
|
+
"ApiKey": "service-b-key",
|
|
76
|
+
"Timeout": 45,
|
|
77
|
+
"RetryCount": 5,
|
|
78
|
+
"EnableCircuitBreaker": false,
|
|
79
|
+
"EnableRateLimiting": false,
|
|
80
|
+
"EnableCaching": false
|
|
81
|
+
},
|
|
82
|
+
"ServiceC": {
|
|
83
|
+
"BaseUrl": "https://api.servicec.com/v1",
|
|
84
|
+
"ApiKey": "service-c-key",
|
|
85
|
+
"Timeout": 30,
|
|
86
|
+
"RetryCount": 3,
|
|
87
|
+
"EnableCircuitBreaker": true,
|
|
88
|
+
"CircuitBreakerThreshold": 10,
|
|
89
|
+
"EnableRateLimiting": true,
|
|
90
|
+
"RateLimitPerMinute": 30,
|
|
91
|
+
"EnableCaching": true,
|
|
92
|
+
"CacheDurationMinutes": 10
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Utilisation
|
|
99
|
+
|
|
100
|
+
### 1. Implémenter un Service Spécifique
|
|
101
|
+
|
|
102
|
+
Créez une classe qui hérite de `ServiceBase`:
|
|
103
|
+
|
|
104
|
+
```csharp
|
|
105
|
+
using ExternalServices.Services;
|
|
106
|
+
|
|
107
|
+
public class MonService : ServiceBase
|
|
108
|
+
{
|
|
109
|
+
public MonService(IConfiguration configuration, ILogger<MonService> logger)
|
|
110
|
+
: base(configuration, "MonService", logger)
|
|
111
|
+
{
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public async Task<DonneesResponse> ObtenirDonneesAsync(int id)
|
|
115
|
+
{
|
|
116
|
+
return await GetDataAsync<DonneesResponse>($"donnees/{id}");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public async Task<Reponse> EnvoyerDonneesAsync(DonneesRequest request)
|
|
120
|
+
{
|
|
121
|
+
return await PostDataAsync<Reponse>("donnees", request);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 2. Enregistrer le Service
|
|
127
|
+
|
|
128
|
+
Dans `Program.cs` ou `Startup.cs`:
|
|
129
|
+
|
|
130
|
+
```csharp
|
|
131
|
+
// Enregistrer le service par défaut
|
|
132
|
+
builder.Services.AddScoped<IService, ExternalService>();
|
|
133
|
+
|
|
134
|
+
// Ou enregistrer un service spécifique
|
|
135
|
+
builder.Services.AddScoped<MonService>();
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3. Utiliser le Service
|
|
139
|
+
|
|
140
|
+
```csharp
|
|
141
|
+
public class MonController : ControllerBase
|
|
142
|
+
{
|
|
143
|
+
private readonly IService _service;
|
|
144
|
+
|
|
145
|
+
public MonController(IService service)
|
|
146
|
+
{
|
|
147
|
+
_service = service;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
[HttpGet]
|
|
151
|
+
public async Task<IActionResult> Get()
|
|
152
|
+
{
|
|
153
|
+
await _service.AuthenticateAsync();
|
|
154
|
+
var data = await _service.GetDataAsync<ResponseType>("endpoint");
|
|
155
|
+
return Ok(data);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Patterns Implémentés
|
|
161
|
+
|
|
162
|
+
### Retry Automatique
|
|
163
|
+
|
|
164
|
+
Le service réessaie automatiquement les requêtes échouées:
|
|
165
|
+
|
|
166
|
+
```csharp
|
|
167
|
+
// Configuration
|
|
168
|
+
"RetryCount": 3,
|
|
169
|
+
"RetryDelay": 1000
|
|
170
|
+
|
|
171
|
+
// Comportement
|
|
172
|
+
// 1ère tentative -> Échec
|
|
173
|
+
// Attente 1000ms
|
|
174
|
+
// 2ème tentative -> Échec
|
|
175
|
+
// Attente 1000ms
|
|
176
|
+
// 3ème tentative -> Succès
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Circuit Breaker
|
|
180
|
+
|
|
181
|
+
Protection contre les défaillances en cascade:
|
|
182
|
+
|
|
183
|
+
```csharp
|
|
184
|
+
// Configuration
|
|
185
|
+
"EnableCircuitBreaker": true,
|
|
186
|
+
"CircuitBreakerThreshold": 5
|
|
187
|
+
|
|
188
|
+
// Comportement
|
|
189
|
+
// 5 échecs consécutifs -> Circuit ouvert
|
|
190
|
+
// Requêtes suivantes -> Échec immédiat (sans appel API)
|
|
191
|
+
// Après délai -> Tentative de rétablissement
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Rate Limiting
|
|
195
|
+
|
|
196
|
+
Limitation du taux de requêtes:
|
|
197
|
+
|
|
198
|
+
```csharp
|
|
199
|
+
// Configuration
|
|
200
|
+
"EnableRateLimiting": true,
|
|
201
|
+
"RateLimitPerMinute": 60
|
|
202
|
+
|
|
203
|
+
// Comportement
|
|
204
|
+
// Maximum 60 requêtes par minute
|
|
205
|
+
// Requêtes au-delà -> Mise en attente ou rejet
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Caching
|
|
209
|
+
|
|
210
|
+
Mise en cache des réponses:
|
|
211
|
+
|
|
212
|
+
```csharp
|
|
213
|
+
// Configuration
|
|
214
|
+
"EnableCaching": true,
|
|
215
|
+
"CacheDurationMinutes": 5
|
|
216
|
+
|
|
217
|
+
// Comportement
|
|
218
|
+
// 1ère requête -> Appel API + mise en cache
|
|
219
|
+
// Requêtes suivantes (5 min) -> Réponse depuis cache
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Modèles de Réponse
|
|
223
|
+
|
|
224
|
+
Tous les appels retournent un `ServiceResponse<T>`:
|
|
225
|
+
|
|
226
|
+
```csharp
|
|
227
|
+
public class ServiceResponse<T>
|
|
228
|
+
{
|
|
229
|
+
public bool Success { get; set; }
|
|
230
|
+
public T? Data { get; set; }
|
|
231
|
+
public string? ErrorCode { get; set; }
|
|
232
|
+
public string? ErrorMessage { get; set; }
|
|
233
|
+
public DateTime Timestamp { get; set; }
|
|
234
|
+
public int? StatusCode { get; set; }
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Gestion des Erreurs
|
|
239
|
+
|
|
240
|
+
Les erreurs sont gérées automatiquement:
|
|
241
|
+
|
|
242
|
+
- **Timeouts** - Retry automatique
|
|
243
|
+
- **5xx errors** - Retry automatique
|
|
244
|
+
- **4xx errors** - Pas de retry (erreur client)
|
|
245
|
+
- **Network errors** - Retry automatique
|
|
246
|
+
- **Circuit ouvert** - Échec immédiat
|
|
247
|
+
|
|
248
|
+
## Tests
|
|
249
|
+
|
|
250
|
+
### Tests Unitaires
|
|
251
|
+
|
|
252
|
+
```csharp
|
|
253
|
+
[Fact]
|
|
254
|
+
public async Task GetDataAsync_ShouldReturnData()
|
|
255
|
+
{
|
|
256
|
+
// Arrange
|
|
257
|
+
var service = new MonService(configuration, logger);
|
|
258
|
+
|
|
259
|
+
// Act
|
|
260
|
+
var result = await service.GetDataAsync<ResponseType>("endpoint");
|
|
261
|
+
|
|
262
|
+
// Assert
|
|
263
|
+
Assert.True(result.Success);
|
|
264
|
+
Assert.NotNull(result.Data);
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Tests d'Intégration
|
|
269
|
+
|
|
270
|
+
```csharp
|
|
271
|
+
[Fact]
|
|
272
|
+
public async Task HealthCheckAsync_ShouldReturnTrue()
|
|
273
|
+
{
|
|
274
|
+
// Arrange
|
|
275
|
+
var service = new MonService(configuration, logger);
|
|
276
|
+
|
|
277
|
+
// Act
|
|
278
|
+
var result = await service.HealthCheckAsync();
|
|
279
|
+
|
|
280
|
+
// Assert
|
|
281
|
+
Assert.True(result);
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Bonnes Pratiques
|
|
286
|
+
|
|
287
|
+
1. **Toujours vérifier Success** avant d'utiliser les données
|
|
288
|
+
2. **Gérer les erreurs** avec try-catch pour les opérations critiques
|
|
289
|
+
3. **Utiliser le caching** pour les données qui changent rarement
|
|
290
|
+
4. **Configurer le retry** selon la criticité de l'opération
|
|
291
|
+
5. **Activer le circuit breaker** pour les services critiques
|
|
292
|
+
6. **Surveiller les logs** pour identifier les problèmes
|
|
293
|
+
7. **Tester en environnement sandbox** avant la production
|
|
294
|
+
|
|
295
|
+
## Sécurité
|
|
296
|
+
|
|
297
|
+
- **Jamais commiter** les clés API ou secrets
|
|
298
|
+
- **Toujours utiliser HTTPS** en production
|
|
299
|
+
- **Valider les entrées** avant envoi
|
|
300
|
+
- **Implémenter la rotation** des clés API
|
|
301
|
+
- **Utiliser des variables d'environnement** pour la configuration
|
|
302
|
+
|
|
303
|
+
## Dépannage
|
|
304
|
+
|
|
305
|
+
### Erreur: "Service non configuré"
|
|
306
|
+
|
|
307
|
+
Vérifiez que la configuration contient la section `ExternalServices` avec le nom de votre service.
|
|
308
|
+
|
|
309
|
+
### Erreur: "Circuit ouvert"
|
|
310
|
+
|
|
311
|
+
Le circuit breaker est ouvert suite à trop d'échecs. Attendez le délai de rétablissement ou vérifiez l'état du service externe.
|
|
312
|
+
|
|
313
|
+
### Erreur: "Rate limit exceeded"
|
|
314
|
+
|
|
315
|
+
Vous avez dépassé la limite de requêtes. Augmentez `RateLimitPerMinute` ou réduisez la fréquence des appels.
|
|
316
|
+
|
|
317
|
+
### Erreur: "Timeout"
|
|
318
|
+
|
|
319
|
+
Le service ne répond pas dans le délai imparti. Augmentez `Timeout` ou vérifiez la connectivité.
|
|
320
|
+
|
|
321
|
+
## Support
|
|
322
|
+
|
|
323
|
+
Pour plus d'informations ou de l'aide:
|
|
324
|
+
- Documentation MDAN: https://github.com/khalilbenaz/MDAN
|
|
325
|
+
- Issues: https://github.com/khalilbenaz/MDAN/issues
|