docstodev 1.1.1 → 2.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docstodev",
3
- "version": "1.1.1",
3
+ "version": "2.0.1",
4
4
  "description": "Solution d’automatisation de documentation technique intelligente avec IA",
5
5
  "type": "module",
6
6
  "main": "dist/cli/index.js",
@@ -20,7 +20,7 @@
20
20
  "mermaid",
21
21
  "pdf"
22
22
  ],
23
- "author": "Chadrack Massamba",
23
+ "author": "Chadrack Massamba | Espoir dev",
24
24
  "license": "ISC",
25
25
  "devDependencies": {
26
26
  "@types/node": "^22.0.0",
@@ -1,28 +1,66 @@
1
1
  // Emplacement absolu : M:\workspace\extensions\docstodev\src\ai\analyzer.ts
2
2
 
3
- import "dotenv/config"; // Pour lire GROQ_API_KEY dans ton .env
3
+ import "dotenv/config";
4
4
 
5
- export async function askAI(technicalContext: string) {
5
+ export interface AIAnalysisOptions {
6
+ language?: "fr" | "en";
7
+ includeDesignSystem?: boolean;
8
+ includeRisks?: boolean;
9
+ includeRecommendations?: boolean;
10
+ detailLevel?: "brief" | "detailed" | "comprehensive";
11
+ focusAreas?: ("architecture" | "security" | "performance" | "maintainability")[];
12
+ }
13
+
14
+ export interface AIAnalysisResult {
15
+ summary: string;
16
+ projectGoal?: string;
17
+ designSystem?: {
18
+ primaryColors: string[];
19
+ typography?: string;
20
+ componentPatterns?: string[];
21
+ };
22
+ risks?: Array<{ level: "low" | "medium" | "high"; description: string }>;
23
+ recommendations?: string[];
24
+ rawAnalysis: string;
25
+ }
26
+
27
+ export async function askAI(
28
+ technicalContext: string,
29
+ options: AIAnalysisOptions = {}
30
+ ): Promise<string> {
31
+ const result = await askAIDetailed(technicalContext, options);
32
+ return result.rawAnalysis;
33
+ }
34
+
35
+ export async function askAIDetailed(
36
+ technicalContext: string,
37
+ options: AIAnalysisOptions = {}
38
+ ): Promise<AIAnalysisResult> {
39
+ const {
40
+ language = "fr",
41
+ includeDesignSystem = true,
42
+ includeRisks = true,
43
+ includeRecommendations = true,
44
+ detailLevel = "detailed",
45
+ focusAreas = ["architecture", "maintainability"]
46
+ } = options;
6
47
 
7
- // clé par défaut gratuite
8
48
  const GROQ_API_KEY = process.env.GROQ_API_KEY || "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";
9
49
 
10
50
  if (!GROQ_API_KEY) {
11
- return "⚠️ Erreur : Clé API Groq manquante dans le fichier .env";
51
+ return {
52
+ summary: "⚠️ Erreur : Clé API Groq manquante",
53
+ rawAnalysis: "⚠️ Erreur : Clé API Groq manquante dans le fichier .env"
54
+ };
12
55
  }
13
56
 
14
- const systemPrompt = `
15
- Vous êtes MakazouIA, l'assistant IA de DocsToDev, créé par Chadrack Massamba (EsporDev).
16
- Votre mission : Transformer des données techniques brutes en descriptions métier claires.
17
-
18
- Instructions :
19
- - Vous allez recevoir une liste de fichiers, leurs rôles et leurs exports.
20
- - Pour chaque fichier, rédigez UNE SEULE phrase concise expliquant sa responsabilité métier.
21
- - Soyez pro, mais gardez votre touche amicale et votre pointe d'humour du Congo-Brazzaville.
22
- - mentionnez les imports, technique ( "il y a une fonction X"), expliquez le BUT du fichier.
23
- - selon le nombre d'occurance précisez les couleurs qui reviennen souvent eu suggérez un design systèm , pallette de couleur.
24
- - donnez une très bref description du but de l'ensemble du projet.
25
- `;
57
+ const systemPrompt = buildSystemPrompt(language, {
58
+ includeDesignSystem,
59
+ includeRisks,
60
+ includeRecommendations,
61
+ detailLevel,
62
+ focusAreas
63
+ });
26
64
 
27
65
  try {
28
66
  const resp = await fetch("https://api.groq.com/openai/v1/chat/completions", {
@@ -35,16 +73,217 @@ Instructions :
35
73
  model: "llama-3.3-70b-versatile",
36
74
  messages: [
37
75
  { role: "system", content: systemPrompt },
38
- { role: "user", content: `Voici les données techniques du projet : \n${technicalContext}` }
76
+ {
77
+ role: "user",
78
+ content: language === "fr"
79
+ ? `Voici les données techniques du projet :\n\n${technicalContext}`
80
+ : `Here is the technical project data:\n\n${technicalContext}`
81
+ }
39
82
  ],
40
83
  temperature: 0.7,
84
+ max_tokens: detailLevel === "comprehensive" ? 4096 : detailLevel === "detailed" ? 2048 : 1024
41
85
  }),
42
86
  });
43
87
 
44
88
  const data = await resp.json();
45
- return data.choices?.[0]?.message?.content || "Désolé, je n'ai pas pu analyser ce fichier.";
89
+ const rawAnalysis = data.choices?.[0]?.message?.content ||
90
+ (language === "fr" ? "Désolé, je n'ai pas pu analyser ce fichier." : "Sorry, I couldn't analyze this file.");
91
+
92
+ return parseAIResponse(rawAnalysis, options);
46
93
  } catch (error) {
47
94
  console.error("Erreur IA:", error);
48
- return "Erreur lors de la connexion à l'intelligence artificielle.";
95
+ return {
96
+ summary: language === "fr"
97
+ ? "Erreur lors de la connexion à l'intelligence artificielle."
98
+ : "Error connecting to artificial intelligence.",
99
+ rawAnalysis: language === "fr"
100
+ ? "Erreur lors de la connexion à l'intelligence artificielle."
101
+ : "Error connecting to artificial intelligence."
102
+ };
103
+ }
104
+ }
105
+
106
+ function buildSystemPrompt(
107
+ language: "fr" | "en",
108
+ options: {
109
+ includeDesignSystem: boolean;
110
+ includeRisks: boolean;
111
+ includeRecommendations: boolean;
112
+ detailLevel: string;
113
+ focusAreas: string[];
114
+ }
115
+ ): string {
116
+ const { includeDesignSystem, includeRisks, includeRecommendations, detailLevel, focusAreas } = options;
117
+
118
+ if (language === "fr") {
119
+ return `
120
+ Vous êtes **MakazouIA**, l'assistant IA de **DocsToDev**, créé par **Chadrack Massamba (EsporDev)**.
121
+ Votre mission : Transformer des données techniques brutes en documentation métier claire et structurée.
122
+
123
+ ## 📋 Instructions Générales
124
+ - Analysez les fichiers fournis et identifiez leur rôle métier précis.
125
+ - Rédigez des descriptions concises mais complètes (${detailLevel === "brief" ? "1 phrase" : detailLevel === "detailed" ? "2-3 phrases" : "paragraphe complet"}).
126
+ - Gardez un ton professionnel avec une touche amicale et une pointe d'humour du Congo-Brazzaville.
127
+ - Mentionnez les imports importants et expliquez le BUT métier de chaque fichier, pas seulement la technique.
128
+
129
+ ## 🎯 Structure de Réponse Requise
130
+
131
+ ### 1. **But du Projet** (Section prioritaire)
132
+ Rédigez UN paragraphe clair expliquant :
133
+ - L'objectif principal du projet
134
+ - Les problèmes qu'il résout
135
+ - Le public cible ou cas d'usage
136
+
137
+ ${includeDesignSystem ? `
138
+ ### 2. **Design System Détecté**
139
+ Analysez le code pour identifier :
140
+ - **Palette de couleurs** : Couleurs primaires/secondaires utilisées (avec codes hex si possibles)
141
+ - **Typographie** : Polices détectées
142
+ - **Patterns de composants** : Patterns UI récurrents (cards, modals, forms, etc.)
143
+ ` : ""}
144
+
145
+ ${includeRisks ? `
146
+ ### 3. **⚠️ Risques Identifiés**
147
+ Listez les risques potentiels classés par niveau :
148
+ - 🔴 **Critique** : Problèmes majeurs (sécurité, architecture)
149
+ - 🟡 **Moyen** : Points d'attention (dette technique, performance)
150
+ - 🟢 **Faible** : Améliorations mineures
151
+
152
+ Focus sur : ${focusAreas.join(", ")}
153
+ ` : ""}
154
+
155
+ ${includeRecommendations ? `
156
+ ### 4. **💡 Recommandations**
157
+ Proposez 3-5 actions concrètes pour améliorer le projet :
158
+ - Refactoring suggéré
159
+ - Optimisations possibles
160
+ - Bonnes pratiques à adopter
161
+ ` : ""}
162
+
163
+ ### 5. **Analyse Détaillée des Fichiers**
164
+ Pour chaque fichier majeur, expliquez :
165
+ - Son rôle métier principal
166
+ - Ses dépendances clés
167
+ - Son importance dans l'architecture globale
168
+
169
+ ## ⚡ Ton et Style
170
+ - Soyez technique mais accessible
171
+ - Utilisez des émojis judicieusement (📂 🔧 ⚠️ 💡)
172
+ - Pas de jargon inutile, privilégiez la clarté
173
+ `;
174
+ } else {
175
+ return `
176
+ You are **MakazouIA**, the AI assistant of **DocsToDev**, created by **Chadrack Massamba (EsporDev)**.
177
+ Your mission: Transform raw technical data into clear business documentation.
178
+
179
+ ## 📋 General Instructions
180
+ - Analyze provided files and identify their precise business role.
181
+ - Write concise yet complete descriptions (${detailLevel === "brief" ? "1 sentence" : detailLevel === "detailed" ? "2-3 sentences" : "full paragraph"}).
182
+ - Keep a professional tone with a friendly touch and a hint of Congo-Brazzaville humor.
183
+ - Mention important imports and explain the business PURPOSE of each file, not just the technical aspect.
184
+
185
+ ## 🎯 Required Response Structure
186
+
187
+ ### 1. **Project Goal** (Priority section)
188
+ Write ONE clear paragraph explaining:
189
+ - The main project objective
190
+ - Problems it solves
191
+ - Target audience or use cases
192
+
193
+ ${includeDesignSystem ? `
194
+ ### 2. **Detected Design System**
195
+ Analyze code to identify:
196
+ - **Color palette**: Primary/secondary colors used (with hex codes if possible)
197
+ - **Typography**: Detected fonts
198
+ - **Component patterns**: Recurring UI patterns (cards, modals, forms, etc.)
199
+ ` : ""}
200
+
201
+ ${includeRisks ? `
202
+ ### 3. **⚠️ Identified Risks**
203
+ List potential risks classified by level:
204
+ - 🔴 **Critical**: Major issues (security, architecture)
205
+ - 🟡 **Medium**: Points of attention (technical debt, performance)
206
+ - 🟢 **Low**: Minor improvements
207
+
208
+ Focus on: ${focusAreas.join(", ")}
209
+ ` : ""}
210
+
211
+ ${includeRecommendations ? `
212
+ ### 4. **💡 Recommendations**
213
+ Propose 3-5 concrete actions to improve the project:
214
+ - Suggested refactoring
215
+ - Possible optimizations
216
+ - Best practices to adopt
217
+ ` : ""}
218
+
219
+ ### 5. **Detailed File Analysis**
220
+ For each major file, explain:
221
+ - Its main business role
222
+ - Key dependencies
223
+ - Its importance in the overall architecture
224
+
225
+ ## ⚡ Tone and Style
226
+ - Be technical but accessible
227
+ - Use emojis judiciously (📂 🔧 ⚠️ 💡)
228
+ - No unnecessary jargon, prioritize clarity
229
+ `;
49
230
  }
231
+ }
232
+
233
+ function parseAIResponse(rawAnalysis: string, options: AIAnalysisOptions): AIAnalysisResult {
234
+ const result: AIAnalysisResult = {
235
+ summary: "",
236
+ rawAnalysis
237
+ };
238
+
239
+ // Extraire le but du projet
240
+ const goalMatch = rawAnalysis.match(/(?:But du Projet|Project Goal)[:\s]*\n+([\s\S]*?)(?=\n#{2,}|\n\n[A-Z#]|$)/i);
241
+ if (goalMatch) {
242
+ result.projectGoal = goalMatch[1]?.trim() || "";
243
+ }
244
+
245
+ // Extraire le design system
246
+ if (options.includeDesignSystem) {
247
+ const designMatch = rawAnalysis.match(/(?:Design System|Palette)[:\s]*\n+([\s\S]*?)(?=\n#{2,}|\n\n[A-Z#]|$)/i);
248
+ if (designMatch) {
249
+ const colors = designMatch[1]?.match(/#[0-9A-Fa-f]{6}/g) || [];
250
+ result.designSystem = {
251
+ primaryColors: colors,
252
+ componentPatterns: []
253
+ };
254
+ }
255
+ }
256
+
257
+ // Extraire les risques
258
+ if (options.includeRisks) {
259
+ const risksMatch = rawAnalysis.match(/(?:Risques|Risks)[:\s]*\n+([\s\S]*?)(?=\n#{2,}|\n\n[A-Z#]|$)/i);
260
+ if (risksMatch) {
261
+ result.risks = [];
262
+ const criticalMatches = risksMatch[1]?.match(/🔴[^\n]+/g) || [];
263
+ const mediumMatches = risksMatch[1]?.match(/🟡[^\n]+/g) || [];
264
+ const lowMatches = risksMatch[1]?.match(/🟢[^\n]+/g) || [];
265
+
266
+ criticalMatches.forEach(r => result.risks!.push({ level: "high", description: r.replace(/🔴\s*/, "") }));
267
+ mediumMatches.forEach(r => result.risks!.push({ level: "medium", description: r.replace(/🟡\s*/, "") }));
268
+ lowMatches.forEach(r => result.risks!.push({ level: "low", description: r.replace(/🟢\s*/, "") }));
269
+ }
270
+ }
271
+
272
+ // Extraire les recommandations
273
+ if (options.includeRecommendations) {
274
+ const recoMatch = rawAnalysis.match(/(?:Recommandations|Recommendations)[:\s]*\n+([\s\S]*?)(?=\n#{2,}|\n\n[A-Z#]|$)/i);
275
+ if (recoMatch && recoMatch[1]) {
276
+ result.recommendations = recoMatch[1]
277
+ .split(/\n[-*•]/)
278
+ .map(r => r.trim())
279
+ .filter(r => r.length > 10);
280
+ } else {
281
+ result.recommendations = [];
282
+ }
283
+ }
284
+
285
+ // Résumé (premiers 200 caractères)
286
+ result.summary = rawAnalysis.substring(0, 200).trim() + "...";
287
+
288
+ return result;
50
289
  }
package/src/cli/index.ts CHANGED
@@ -111,17 +111,18 @@ async function showBanner(lang: "fr" | "en"): Promise<void> {
111
111
  const banner = `
112
112
  ╔═══════════════════════════════════════════════════════╗
113
113
  ║ ║
114
- ║ ██████╗ ██████╗ ██████╗███████╗████████╗
115
- ║ ██╔══██╗██╔═══██╗██╔════╝██╔════╝╚══██╔══╝
116
- ║ ██║ ██║██║ ██║██║ ███████╗ ██║
117
- ║ ██║ ██║██║ ██║██║ ╚════██║ ██║
118
- ║ ██████╔╝╚██████╔╝╚██████╗███████║ ██║
119
- ║ ╚═════╝ ╚═════╝ ╚═════╝╚══════╝ ╚═╝ DEV
114
+ ║ ██████╗ ██████╗ ██████╗███████╗████████╗
115
+ ║ ██╔══██╗██╔═══██╗██╔════╝██╔════╝╚══██╔══╝
116
+ ║ ██║ ██║██║ ██║██║ ███████╗ ██║
117
+ ║ ██║ ██║██║ ██║██║ ╚════██║ ██║
118
+ ║ ██████╔╝╚██████╔╝╚██████╗███████║ ██║
119
+ ║ ╚═════╝ ╚═════╝ ╚═════╝╚══════╝ ╚═╝ DEV
120
120
  ║ ║
121
121
  ║ 📚 Analyse Technique & Documentation ║
122
- Intelligente
122
+ Intelligent
123
123
  ║ ║
124
124
  ╚═══════════════════════════════════════════════════════╝
125
+ By EspoirDev Massamba Kiminou chadrack delmard
125
126
  `;
126
127
 
127
128
  console.clear();