atlas-pipeline-mcp 1.0.17 → 1.0.19

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.
Files changed (50) hide show
  1. package/README.md +54 -1
  2. package/dist/benchmark.d.ts +12 -0
  3. package/dist/benchmark.d.ts.map +1 -0
  4. package/dist/benchmark.js +183 -0
  5. package/dist/benchmark.js.map +1 -0
  6. package/dist/mcp.d.ts +14 -0
  7. package/dist/mcp.d.ts.map +1 -1
  8. package/dist/mcp.js +297 -8
  9. package/dist/mcp.js.map +1 -1
  10. package/dist/pipeline.d.ts +13 -3
  11. package/dist/pipeline.d.ts.map +1 -1
  12. package/dist/pipeline.js +36 -5
  13. package/dist/pipeline.js.map +1 -1
  14. package/dist/providers/llm-provider.d.ts +11 -5
  15. package/dist/providers/llm-provider.d.ts.map +1 -1
  16. package/dist/providers/llm-provider.js +32 -6
  17. package/dist/providers/llm-provider.js.map +1 -1
  18. package/dist/tools/debug.d.ts +101 -0
  19. package/dist/tools/debug.d.ts.map +1 -0
  20. package/dist/tools/debug.js +712 -0
  21. package/dist/tools/debug.js.map +1 -0
  22. package/dist/tools/docs.d.ts +94 -0
  23. package/dist/tools/docs.d.ts.map +1 -0
  24. package/dist/tools/docs.js +508 -0
  25. package/dist/tools/docs.js.map +1 -0
  26. package/dist/tools/explain.d.ts +82 -0
  27. package/dist/tools/explain.d.ts.map +1 -0
  28. package/dist/tools/explain.js +543 -0
  29. package/dist/tools/explain.js.map +1 -0
  30. package/dist/tools/security.d.ts +45 -0
  31. package/dist/tools/security.d.ts.map +1 -0
  32. package/dist/tools/security.js +417 -0
  33. package/dist/tools/security.js.map +1 -0
  34. package/dist/tools/testgen.d.ts +52 -0
  35. package/dist/tools/testgen.d.ts.map +1 -0
  36. package/dist/tools/testgen.js +413 -0
  37. package/dist/tools/testgen.js.map +1 -0
  38. package/dist/tools/think.d.ts +223 -0
  39. package/dist/tools/think.d.ts.map +1 -0
  40. package/dist/tools/think.js +529 -0
  41. package/dist/tools/think.js.map +1 -0
  42. package/dist/types.d.ts +10 -2
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/types.js +17 -4
  45. package/dist/types.js.map +1 -1
  46. package/dist/utils.d.ts +86 -1
  47. package/dist/utils.d.ts.map +1 -1
  48. package/dist/utils.js +158 -1
  49. package/dist/utils.js.map +1 -1
  50. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/tools/docs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA+FrC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAAY,EACZ,UAAgC,EAAE;IAElC,MAAM,EACJ,KAAK,GAAG,MAAM,EACd,MAAM,GAAG,UAAU,EACnB,eAAe,GAAG,IAAI,EACtB,YAAY,GAAG,IAAI,EACnB,OAAO,GAAG,KAAK,EACf,QAAQ,GACT,GAAG,OAAO,CAAC;IAEZ,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,mCAAmC,CAAC,CAAC;IAE9F,4BAA4B;IAC5B,MAAM,gBAAgB,GAAG,QAAQ,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,aAAa,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAElF,yBAAyB;IACzB,MAAM,YAAY,GAAG,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAElE,yBAAyB;IACzB,IAAI,cAAsB,CAAC;IAC3B,IAAI,aA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,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7C,MAAM,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;IAE7C,MAAM,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;IAC5C,MAAM,UAAU,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;IAC3D,MAAM,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAE1E,OAAO;QACL,cAAc;QACd,mBAAmB;QACnB,YAAY;QACZ,iBAAiB;QACjB,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Atlas Server - Code Explanation Tool
3
+ *
4
+ * Intelligent code explanation capabilities:
5
+ * - Line-by-line explanation
6
+ * - Algorithm analysis
7
+ * - Complexity analysis (Big O)
8
+ * - Design pattern identification
9
+ * - Dependency explanation
10
+ * - Beginner-friendly mode
11
+ */
12
+ export type ExplanationLevel = 'beginner' | 'intermediate' | 'expert';
13
+ export type ExplanationType = 'overview' | 'detailed' | 'line-by-line' | 'algorithm';
14
+ export interface ExplanationOptions {
15
+ level?: ExplanationLevel;
16
+ type?: ExplanationType;
17
+ language?: string;
18
+ focusArea?: string;
19
+ includeComplexity?: boolean;
20
+ includePatterns?: boolean;
21
+ }
22
+ export interface CodeExplanation {
23
+ summary: string;
24
+ purpose: string;
25
+ howItWorks: string;
26
+ sections: ExplanationSection[];
27
+ complexity?: ComplexityAnalysis;
28
+ patterns?: DesignPattern[];
29
+ dependencies?: DependencyInfo[];
30
+ suggestions?: string[];
31
+ glossary?: GlossaryTerm[];
32
+ }
33
+ export interface ExplanationSection {
34
+ title: string;
35
+ lineRange: {
36
+ start: number;
37
+ end: number;
38
+ };
39
+ code: string;
40
+ explanation: string;
41
+ keyPoints: string[];
42
+ }
43
+ export interface ComplexityAnalysis {
44
+ time: string;
45
+ space: string;
46
+ explanation: string;
47
+ bestCase?: string;
48
+ worstCase?: string;
49
+ averageCase?: string;
50
+ }
51
+ export interface DesignPattern {
52
+ name: string;
53
+ type: 'creational' | 'structural' | 'behavioral' | 'architectural';
54
+ description: string;
55
+ locationHint: string;
56
+ }
57
+ export interface DependencyInfo {
58
+ name: string;
59
+ type: 'import' | 'external' | 'internal';
60
+ purpose: string;
61
+ required: boolean;
62
+ }
63
+ export interface GlossaryTerm {
64
+ term: string;
65
+ definition: string;
66
+ example?: string;
67
+ }
68
+ export interface ExplanationResult {
69
+ explanation: CodeExplanation;
70
+ metadata: {
71
+ level: ExplanationLevel;
72
+ type: ExplanationType;
73
+ language: string;
74
+ lineCount: number;
75
+ };
76
+ generatedAt: string;
77
+ }
78
+ /**
79
+ * Generate an explanation for the given code
80
+ */
81
+ export declare function explainCode(code: string, options?: ExplanationOptions): Promise<ExplanationResult>;
82
+ //# sourceMappingURL=explain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../src/tools/explain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,WAAW,CAAC;AAErF,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UA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AC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,EAAE;QACR,KAAK,EAAE,gBAAgB,CAAC;QACxB,IAAI,EAAE,eAAe,CAAC;QACtB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;CACrB;AAMD;;GAEG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAkD5B"}
@@ -0,0 +1,543 @@
1
+ /**
2
+ * Atlas Server - Code Explanation Tool
3
+ *
4
+ * Intelligent code explanation capabilities:
5
+ * - Line-by-line explanation
6
+ * - Algorithm analysis
7
+ * - Complexity analysis (Big O)
8
+ * - Design pattern identification
9
+ * - Dependency explanation
10
+ * - Beginner-friendly mode
11
+ */
12
+ import { getActiveProvider, isNoLLMMode } from '../providers/index.js';
13
+ import { logger } from '../utils.js';
14
+ // ============================================================================
15
+ // Code Explanation
16
+ // ============================================================================
17
+ /**
18
+ * Generate an explanation for the given code
19
+ */
20
+ export async function explainCode(code, options = {}) {
21
+ const { level = 'intermediate', type = 'overview', language, focusArea, includeComplexity = true, includePatterns = true, } = options;
22
+ logger.debug({ level, type, codeLength: code.length }, 'Starting code explanation');
23
+ // Detect language
24
+ const detectedLanguage = language ?? detectLanguage(code);
25
+ // Analyze code structure
26
+ const structure = analyzeCodeStructure(code, detectedLanguage);
27
+ // Generate explanation
28
+ let explanation;
29
+ if (!isNoLLMMode()) {
30
+ try {
31
+ explanation = await explainWithAI(code, {
32
+ level,
33
+ type,
34
+ language: detectedLanguage,
35
+ focusArea,
36
+ includeComplexity,
37
+ includePatterns,
38
+ structure,
39
+ });
40
+ }
41
+ catch (error) {
42
+ logger.warn({ error }, 'AI explanation failed, using heuristic explanation');
43
+ explanation = generateHeuristicExplanation(code, detectedLanguage, level, type, structure);
44
+ }
45
+ }
46
+ else {
47
+ explanation = generateHeuristicExplanation(code, detectedLanguage, level, type, structure);
48
+ }
49
+ return {
50
+ explanation,
51
+ metadata: {
52
+ level,
53
+ type,
54
+ language: detectedLanguage,
55
+ lineCount: code.split('\n').length,
56
+ },
57
+ generatedAt: new Date().toISOString(),
58
+ };
59
+ }
60
+ function analyzeCodeStructure(code, language) {
61
+ const structure = {
62
+ functions: [],
63
+ classes: [],
64
+ imports: [],
65
+ controlFlow: [],
66
+ loops: [],
67
+ conditionals: 0,
68
+ complexity: 1, // Base complexity
69
+ };
70
+ const lines = code.split('\n');
71
+ if (['typescript', 'javascript'].includes(language.toLowerCase())) {
72
+ // Analyze functions
73
+ const funcRegex = /(?:export\s+)?(?:async\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*([^{]+))?/g;
74
+ let match;
75
+ while ((match = funcRegex.exec(code)) !== null) {
76
+ const lineStart = code.substring(0, match.index).split('\n').length;
77
+ structure.functions.push({
78
+ name: match[1],
79
+ params: match[2] ? match[2].split(',').map(p => p.trim()) : [],
80
+ returnType: match[3]?.trim(),
81
+ isAsync: match[0].includes('async'),
82
+ lineStart,
83
+ lineEnd: lineStart + 10, // Approximate
84
+ });
85
+ }
86
+ // Analyze arrow functions
87
+ const arrowRegex = /(?:export\s+)?(?:const|let)\s+(\w+)\s*=\s*(?:async\s+)?\([^)]*\)\s*(?::\s*[^=]+)?\s*=>/g;
88
+ while ((match = arrowRegex.exec(code)) !== null) {
89
+ const lineStart = code.substring(0, match.index).split('\n').length;
90
+ structure.functions.push({
91
+ name: match[1],
92
+ params: [],
93
+ isAsync: match[0].includes('async'),
94
+ lineStart,
95
+ lineEnd: lineStart + 10,
96
+ });
97
+ }
98
+ // Analyze imports
99
+ const importRegex = /import\s+(?:(\w+)|{([^}]+)}|(\*\s+as\s+\w+))\s+from\s+['"]([^'"]+)['"]/g;
100
+ while ((match = importRegex.exec(code)) !== null) {
101
+ structure.imports.push({
102
+ module: match[4],
103
+ items: match[2] ? match[2].split(',').map(i => i.trim()) : [match[1] ?? match[3] ?? 'default'],
104
+ isDefault: !!match[1],
105
+ });
106
+ }
107
+ // Analyze classes
108
+ const classRegex = /class\s+(\w+)/g;
109
+ while ((match = classRegex.exec(code)) !== null) {
110
+ const lineStart = code.substring(0, match.index).split('\n').length;
111
+ structure.classes.push({
112
+ name: match[1],
113
+ methods: [],
114
+ properties: [],
115
+ lineStart,
116
+ });
117
+ }
118
+ // Analyze loops
119
+ const forLoopRegex = /\bfor\s*\(/g;
120
+ let depth = 0;
121
+ while ((match = forLoopRegex.exec(code)) !== null) {
122
+ const lineNumber = code.substring(0, match.index).split('\n').length;
123
+ // Check if nested by looking at bracket depth
124
+ const beforeCode = code.substring(0, match.index);
125
+ const openBrackets = (beforeCode.match(/{/g) || []).length;
126
+ const closeBrackets = (beforeCode.match(/}/g) || []).length;
127
+ const nested = openBrackets - closeBrackets > 1;
128
+ structure.loops.push({
129
+ type: 'for',
130
+ lineNumber,
131
+ nested,
132
+ });
133
+ if (nested)
134
+ structure.complexity += 2;
135
+ else
136
+ structure.complexity += 1;
137
+ }
138
+ const whileRegex = /\bwhile\s*\(/g;
139
+ while ((match = whileRegex.exec(code)) !== null) {
140
+ const lineNumber = code.substring(0, match.index).split('\n').length;
141
+ structure.loops.push({
142
+ type: 'while',
143
+ lineNumber,
144
+ nested: false,
145
+ });
146
+ structure.complexity += 1;
147
+ }
148
+ // Count conditionals
149
+ structure.conditionals = (code.match(/\bif\s*\(|\belse\s+if\s*\(|\?\s*[^:]+\s*:/g) || []).length;
150
+ structure.complexity += structure.conditionals;
151
+ // Analyze control flow
152
+ if (code.includes('try'))
153
+ structure.controlFlow.push('exception handling');
154
+ if (code.includes('async'))
155
+ structure.controlFlow.push('async/await');
156
+ if (code.includes('.then'))
157
+ structure.controlFlow.push('promises');
158
+ if (code.includes('callback'))
159
+ structure.controlFlow.push('callbacks');
160
+ if (code.includes('yield'))
161
+ structure.controlFlow.push('generators');
162
+ if (code.includes('Observable') || code.includes('subscribe'))
163
+ structure.controlFlow.push('reactive');
164
+ }
165
+ return structure;
166
+ }
167
+ // ============================================================================
168
+ // AI Explanation
169
+ // ============================================================================
170
+ async function explainWithAI(code, options) {
171
+ const provider = await getActiveProvider();
172
+ const levelInstructions = {
173
+ beginner: 'Explain like I\'m new to programming. Define all technical terms. Use simple analogies.',
174
+ intermediate: 'Assume basic programming knowledge. Focus on the logic and architecture.',
175
+ expert: 'Be concise and technical. Focus on advanced patterns, edge cases, and optimizations.',
176
+ };
177
+ const prompt = `Explain this ${options.language} code.
178
+
179
+ ## Code
180
+ \`\`\`${options.language}
181
+ ${code}
182
+ \`\`\`
183
+
184
+ ## Explanation Level
185
+ ${levelInstructions[options.level]}
186
+
187
+ ## Explanation Type
188
+ ${options.type === 'line-by-line' ? 'Explain each significant line or block of code.' : ''}
189
+ ${options.type === 'algorithm' ? 'Focus on the algorithm, data structures, and computational logic.' : ''}
190
+ ${options.type === 'detailed' ? 'Provide comprehensive explanation of all aspects.' : ''}
191
+ ${options.type === 'overview' ? 'Provide a high-level overview of what the code does.' : ''}
192
+
193
+ ${options.focusArea ? `## Focus on: ${options.focusArea}` : ''}
194
+
195
+ ## Code Structure Found
196
+ - Functions: ${options.structure.functions.map(f => f.name).join(', ') || 'none'}
197
+ - Classes: ${options.structure.classes.map(c => c.name).join(', ') || 'none'}
198
+ - Loops: ${options.structure.loops.length}
199
+ - Conditionals: ${options.structure.conditionals}
200
+ - Estimated complexity: ${options.structure.complexity}
201
+
202
+ ## Output Format
203
+ {
204
+ "summary": "One-line summary",
205
+ "purpose": "What problem does this code solve?",
206
+ "howItWorks": "Step-by-step explanation of the logic",
207
+ "sections": [
208
+ {
209
+ "title": "Section name",
210
+ "lineRange": {"start": 1, "end": 10},
211
+ "code": "relevant code snippet",
212
+ "explanation": "what this section does",
213
+ "keyPoints": ["key point 1", "key point 2"]
214
+ }
215
+ ],
216
+ ${options.includeComplexity ? `"complexity": {
217
+ "time": "O(n)",
218
+ "space": "O(1)",
219
+ "explanation": "Why this complexity"
220
+ },` : ''}
221
+ ${options.includePatterns ? `"patterns": [
222
+ {"name": "pattern name", "type": "creational|structural|behavioral|architectural", "description": "how it's used", "locationHint": "where in the code"}
223
+ ],` : ''}
224
+ "dependencies": [
225
+ {"name": "module", "type": "import|external|internal", "purpose": "why it's needed", "required": true}
226
+ ],
227
+ "suggestions": ["improvement suggestion"],
228
+ "glossary": [
229
+ {"term": "technical term", "definition": "simple definition", "example": "usage example"}
230
+ ]
231
+ }`;
232
+ const response = await provider.completeJson(prompt, {
233
+ systemPrompt: `You are a patient, expert programming tutor. Explain code clearly at the ${options.level} level. Return valid JSON only.`,
234
+ temperature: 0.4,
235
+ maxTokens: 4096,
236
+ });
237
+ if (response.data) {
238
+ return response.data;
239
+ }
240
+ throw new Error('Failed to generate explanation with AI');
241
+ }
242
+ // ============================================================================
243
+ // Heuristic Explanation
244
+ // ============================================================================
245
+ function generateHeuristicExplanation(code, language, level, type, structure) {
246
+ const lines = code.split('\n');
247
+ // Generate summary
248
+ const summary = generateSummary(structure);
249
+ // Generate purpose
250
+ const purpose = generatePurpose(structure);
251
+ // Generate how it works
252
+ const howItWorks = generateHowItWorks(structure, language);
253
+ // Generate sections
254
+ const sections = generateSections(code, structure, level);
255
+ // Generate complexity analysis
256
+ const complexity = generateComplexityAnalysis(structure);
257
+ // Generate patterns
258
+ const patterns = detectPatterns(code, language);
259
+ // Generate dependency info
260
+ const dependencies = structure.imports.map(imp => ({
261
+ name: imp.module,
262
+ type: imp.module.startsWith('.') ? 'internal' : 'external',
263
+ purpose: `Imports ${imp.items.join(', ')}`,
264
+ required: true,
265
+ }));
266
+ // Generate suggestions
267
+ const suggestions = generateSuggestions(structure, code);
268
+ // Generate glossary for beginners
269
+ const glossary = level === 'beginner' ? generateGlossary(code, language) : undefined;
270
+ return {
271
+ summary,
272
+ purpose,
273
+ howItWorks,
274
+ sections,
275
+ complexity,
276
+ patterns,
277
+ dependencies,
278
+ suggestions,
279
+ glossary,
280
+ };
281
+ }
282
+ function generateSummary(structure) {
283
+ const parts = [];
284
+ if (structure.functions.length > 0) {
285
+ parts.push(`${structure.functions.length} function(s)`);
286
+ }
287
+ if (structure.classes.length > 0) {
288
+ parts.push(`${structure.classes.length} class(es)`);
289
+ }
290
+ if (structure.loops.length > 0) {
291
+ parts.push(`iterative logic`);
292
+ }
293
+ if (structure.controlFlow.includes('async/await')) {
294
+ parts.push(`async operations`);
295
+ }
296
+ return `This code contains ${parts.join(', ') || 'basic logic'}.`;
297
+ }
298
+ function generatePurpose(structure) {
299
+ const mainFunc = structure.functions[0];
300
+ if (mainFunc) {
301
+ return `The main purpose is to implement ${humanizeName(mainFunc.name)} functionality.`;
302
+ }
303
+ if (structure.classes.length > 0) {
304
+ return `Defines the ${structure.classes[0].name} class for encapsulating related functionality.`;
305
+ }
306
+ return 'This code implements specific business logic or utility functions.';
307
+ }
308
+ function generateHowItWorks(structure, language) {
309
+ const steps = [];
310
+ if (structure.imports.length > 0) {
311
+ steps.push(`1. Imports dependencies: ${structure.imports.map(i => i.module).join(', ')}`);
312
+ }
313
+ if (structure.classes.length > 0) {
314
+ steps.push(`2. Defines class(es): ${structure.classes.map(c => c.name).join(', ')}`);
315
+ }
316
+ if (structure.functions.length > 0) {
317
+ for (const [i, func] of structure.functions.entries()) {
318
+ steps.push(`${steps.length + 1}. Function \`${func.name}\`: ${humanizeName(func.name)}`);
319
+ }
320
+ }
321
+ if (structure.loops.length > 0) {
322
+ steps.push(`${steps.length + 1}. Uses ${structure.loops.length} loop(s) for iteration`);
323
+ }
324
+ if (structure.controlFlow.length > 0) {
325
+ steps.push(`${steps.length + 1}. Control flow includes: ${structure.controlFlow.join(', ')}`);
326
+ }
327
+ return steps.join('\n') || 'The code executes sequentially from top to bottom.';
328
+ }
329
+ function generateSections(code, structure, level) {
330
+ const sections = [];
331
+ const lines = code.split('\n');
332
+ // Imports section
333
+ if (structure.imports.length > 0) {
334
+ const importLines = lines.filter(l => l.includes('import '));
335
+ sections.push({
336
+ title: 'Dependencies',
337
+ lineRange: { start: 1, end: Math.min(structure.imports.length + 1, lines.length) },
338
+ code: importLines.join('\n'),
339
+ explanation: 'This section imports external modules and dependencies needed by the code.',
340
+ keyPoints: structure.imports.map(i => `${i.module}: provides ${i.items.join(', ')}`),
341
+ });
342
+ }
343
+ // Function sections
344
+ for (const func of structure.functions) {
345
+ const funcCode = lines.slice(func.lineStart - 1, func.lineEnd).join('\n');
346
+ sections.push({
347
+ title: `Function: ${func.name}`,
348
+ lineRange: { start: func.lineStart, end: func.lineEnd },
349
+ code: funcCode,
350
+ explanation: `${humanizeName(func.name)}. ${func.isAsync ? 'This is an async function that returns a Promise.' : ''}`,
351
+ keyPoints: [
352
+ `Parameters: ${func.params.length > 0 ? func.params.join(', ') : 'none'}`,
353
+ `Returns: ${func.returnType ?? 'unspecified'}`,
354
+ func.isAsync ? 'Asynchronous execution' : 'Synchronous execution',
355
+ ],
356
+ });
357
+ }
358
+ // Class sections
359
+ for (const cls of structure.classes) {
360
+ sections.push({
361
+ title: `Class: ${cls.name}`,
362
+ lineRange: { start: cls.lineStart, end: cls.lineStart + 20 },
363
+ code: `class ${cls.name} { ... }`,
364
+ explanation: `Defines the ${cls.name} class which encapsulates related data and behavior.`,
365
+ keyPoints: [
366
+ 'Classes group related functionality together',
367
+ 'Methods define what actions the class can perform',
368
+ 'Properties store the class state',
369
+ ],
370
+ });
371
+ }
372
+ return sections;
373
+ }
374
+ function generateComplexityAnalysis(structure) {
375
+ // Estimate time complexity based on loops
376
+ let timeComplexity = 'O(1)';
377
+ let spaceComplexity = 'O(1)';
378
+ let explanation = 'Constant time - no significant loops or recursion detected.';
379
+ const nestedLoops = structure.loops.filter(l => l.nested).length;
380
+ const regularLoops = structure.loops.filter(l => !l.nested).length;
381
+ if (nestedLoops > 0) {
382
+ timeComplexity = `O(n^${nestedLoops + 1})`;
383
+ explanation = `Polynomial time due to ${nestedLoops + 1} nested loops.`;
384
+ }
385
+ else if (regularLoops > 0) {
386
+ timeComplexity = 'O(n)';
387
+ explanation = 'Linear time - iterates through input once.';
388
+ }
389
+ if (regularLoops > 0) {
390
+ spaceComplexity = 'O(n)';
391
+ }
392
+ return {
393
+ time: timeComplexity,
394
+ space: spaceComplexity,
395
+ explanation,
396
+ bestCase: timeComplexity,
397
+ worstCase: timeComplexity,
398
+ averageCase: timeComplexity,
399
+ };
400
+ }
401
+ function detectPatterns(code, language) {
402
+ const patterns = [];
403
+ // Singleton pattern
404
+ if (code.includes('getInstance') || code.includes('static instance')) {
405
+ patterns.push({
406
+ name: 'Singleton',
407
+ type: 'creational',
408
+ description: 'Ensures only one instance of a class exists.',
409
+ locationHint: 'Look for getInstance() method or static instance property.',
410
+ });
411
+ }
412
+ // Factory pattern
413
+ if (code.includes('create') && code.includes('return new')) {
414
+ patterns.push({
415
+ name: 'Factory',
416
+ type: 'creational',
417
+ description: 'Creates objects without specifying exact class.',
418
+ locationHint: 'Functions that return new instances of different types.',
419
+ });
420
+ }
421
+ // Observer pattern
422
+ if (code.includes('subscribe') || code.includes('addEventListener') || code.includes('emit')) {
423
+ patterns.push({
424
+ name: 'Observer',
425
+ type: 'behavioral',
426
+ description: 'Objects subscribe to events and get notified of changes.',
427
+ locationHint: 'Look for subscribe/emit or addEventListener methods.',
428
+ });
429
+ }
430
+ // Strategy pattern
431
+ if (code.includes('strategy') || (code.includes('interface') && code.match(/execute|run|process/))) {
432
+ patterns.push({
433
+ name: 'Strategy',
434
+ type: 'behavioral',
435
+ description: 'Allows selecting algorithm at runtime.',
436
+ locationHint: 'Multiple implementations of the same interface.',
437
+ });
438
+ }
439
+ // Decorator pattern
440
+ if (code.includes('@') || code.includes('wrapper') || code.includes('decorator')) {
441
+ patterns.push({
442
+ name: 'Decorator',
443
+ type: 'structural',
444
+ description: 'Adds behavior to objects dynamically.',
445
+ locationHint: 'Look for @ syntax or wrapper functions.',
446
+ });
447
+ }
448
+ // Module pattern (common in JS)
449
+ if (code.includes('export') && code.includes('import')) {
450
+ patterns.push({
451
+ name: 'Module',
452
+ type: 'architectural',
453
+ description: 'Encapsulates code and exposes public API.',
454
+ locationHint: 'File-level exports and imports.',
455
+ });
456
+ }
457
+ return patterns;
458
+ }
459
+ function generateSuggestions(structure, code) {
460
+ const suggestions = [];
461
+ if (structure.complexity > 10) {
462
+ suggestions.push('Consider breaking down complex functions into smaller, focused functions.');
463
+ }
464
+ if (structure.loops.some(l => l.nested)) {
465
+ suggestions.push('Nested loops may impact performance. Consider using maps or memoization.');
466
+ }
467
+ if (!code.includes('try') && structure.controlFlow.includes('async/await')) {
468
+ suggestions.push('Add error handling (try/catch) for async operations.');
469
+ }
470
+ if (structure.functions.some(f => f.params.length > 4)) {
471
+ suggestions.push('Functions with many parameters could use an options object instead.');
472
+ }
473
+ if (!code.includes('const') && code.includes('let')) {
474
+ suggestions.push('Prefer const over let when variables are not reassigned.');
475
+ }
476
+ return suggestions;
477
+ }
478
+ function generateGlossary(code, language) {
479
+ const glossary = [];
480
+ if (code.includes('async')) {
481
+ glossary.push({
482
+ term: 'async',
483
+ definition: 'A keyword that marks a function as asynchronous, meaning it returns a Promise.',
484
+ example: 'async function fetchData() { }',
485
+ });
486
+ }
487
+ if (code.includes('await')) {
488
+ glossary.push({
489
+ term: 'await',
490
+ definition: 'Pauses execution until a Promise resolves, then returns its value.',
491
+ example: 'const data = await fetchData();',
492
+ });
493
+ }
494
+ if (code.includes('=>')) {
495
+ glossary.push({
496
+ term: 'Arrow function (=>)',
497
+ definition: 'A shorter syntax for writing functions.',
498
+ example: 'const add = (a, b) => a + b;',
499
+ });
500
+ }
501
+ if (code.includes('map(')) {
502
+ glossary.push({
503
+ term: 'map()',
504
+ definition: 'Creates a new array by applying a function to each element.',
505
+ example: '[1, 2, 3].map(x => x * 2) // [2, 4, 6]',
506
+ });
507
+ }
508
+ if (code.includes('filter(')) {
509
+ glossary.push({
510
+ term: 'filter()',
511
+ definition: 'Creates a new array with elements that pass a test.',
512
+ example: '[1, 2, 3, 4].filter(x => x > 2) // [3, 4]',
513
+ });
514
+ }
515
+ if (code.includes('reduce(')) {
516
+ glossary.push({
517
+ term: 'reduce()',
518
+ definition: 'Reduces an array to a single value by applying a function.',
519
+ example: '[1, 2, 3].reduce((sum, x) => sum + x, 0) // 6',
520
+ });
521
+ }
522
+ return glossary;
523
+ }
524
+ function humanizeName(name) {
525
+ return name
526
+ .replace(/([A-Z])/g, ' $1')
527
+ .replace(/_/g, ' ')
528
+ .toLowerCase()
529
+ .trim();
530
+ }
531
+ function detectLanguage(code) {
532
+ if (code.includes('interface ') || code.includes(': string') || code.includes(': number')) {
533
+ return 'typescript';
534
+ }
535
+ if (code.includes('def ') && code.includes(':')) {
536
+ return 'python';
537
+ }
538
+ if (code.includes('func ') && code.includes('package ')) {
539
+ return 'go';
540
+ }
541
+ return 'javascript';
542
+ }
543
+ //# sourceMappingURL=explain.js.map