@juspay/yama 1.5.1 → 2.0.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.
Files changed (67) hide show
  1. package/.mcp-config.example.json +26 -0
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +311 -685
  4. package/dist/cli/v2.cli.d.ts +13 -0
  5. package/dist/cli/v2.cli.js +290 -0
  6. package/dist/index.d.ts +12 -13
  7. package/dist/index.js +18 -19
  8. package/dist/v2/config/ConfigLoader.d.ts +50 -0
  9. package/dist/v2/config/ConfigLoader.js +205 -0
  10. package/dist/v2/config/DefaultConfig.d.ts +9 -0
  11. package/dist/v2/config/DefaultConfig.js +191 -0
  12. package/dist/v2/core/MCPServerManager.d.ts +22 -0
  13. package/dist/v2/core/MCPServerManager.js +92 -0
  14. package/dist/v2/core/SessionManager.d.ts +72 -0
  15. package/dist/v2/core/SessionManager.js +200 -0
  16. package/dist/v2/core/YamaV2Orchestrator.d.ts +112 -0
  17. package/dist/v2/core/YamaV2Orchestrator.js +549 -0
  18. package/dist/v2/prompts/EnhancementSystemPrompt.d.ts +8 -0
  19. package/dist/v2/prompts/EnhancementSystemPrompt.js +216 -0
  20. package/dist/v2/prompts/PromptBuilder.d.ts +38 -0
  21. package/dist/v2/prompts/PromptBuilder.js +228 -0
  22. package/dist/v2/prompts/ReviewSystemPrompt.d.ts +8 -0
  23. package/dist/v2/prompts/ReviewSystemPrompt.js +270 -0
  24. package/dist/v2/types/config.types.d.ts +120 -0
  25. package/dist/v2/types/config.types.js +5 -0
  26. package/dist/v2/types/mcp.types.d.ts +191 -0
  27. package/dist/v2/types/mcp.types.js +6 -0
  28. package/dist/v2/types/v2.types.d.ts +182 -0
  29. package/dist/v2/types/v2.types.js +42 -0
  30. package/dist/v2/utils/ObservabilityConfig.d.ts +22 -0
  31. package/dist/v2/utils/ObservabilityConfig.js +48 -0
  32. package/package.json +11 -9
  33. package/yama.config.example.yaml +214 -193
  34. package/dist/cli/index.d.ts +0 -12
  35. package/dist/cli/index.js +0 -538
  36. package/dist/core/ContextGatherer.d.ts +0 -110
  37. package/dist/core/ContextGatherer.js +0 -470
  38. package/dist/core/Guardian.d.ts +0 -81
  39. package/dist/core/Guardian.js +0 -474
  40. package/dist/core/providers/BitbucketProvider.d.ts +0 -105
  41. package/dist/core/providers/BitbucketProvider.js +0 -489
  42. package/dist/features/CodeReviewer.d.ts +0 -173
  43. package/dist/features/CodeReviewer.js +0 -1707
  44. package/dist/features/DescriptionEnhancer.d.ts +0 -64
  45. package/dist/features/DescriptionEnhancer.js +0 -445
  46. package/dist/features/MultiInstanceProcessor.d.ts +0 -74
  47. package/dist/features/MultiInstanceProcessor.js +0 -360
  48. package/dist/types/index.d.ts +0 -624
  49. package/dist/types/index.js +0 -104
  50. package/dist/utils/Cache.d.ts +0 -103
  51. package/dist/utils/Cache.js +0 -444
  52. package/dist/utils/ConfigManager.d.ts +0 -88
  53. package/dist/utils/ConfigManager.js +0 -603
  54. package/dist/utils/ContentSimilarityService.d.ts +0 -74
  55. package/dist/utils/ContentSimilarityService.js +0 -215
  56. package/dist/utils/ExactDuplicateRemover.d.ts +0 -77
  57. package/dist/utils/ExactDuplicateRemover.js +0 -361
  58. package/dist/utils/Logger.d.ts +0 -31
  59. package/dist/utils/Logger.js +0 -214
  60. package/dist/utils/MemoryBankManager.d.ts +0 -73
  61. package/dist/utils/MemoryBankManager.js +0 -310
  62. package/dist/utils/ParallelProcessing.d.ts +0 -140
  63. package/dist/utils/ParallelProcessing.js +0 -333
  64. package/dist/utils/ProviderLimits.d.ts +0 -58
  65. package/dist/utils/ProviderLimits.js +0 -143
  66. package/dist/utils/RetryManager.d.ts +0 -78
  67. package/dist/utils/RetryManager.js +0 -205
@@ -1,64 +0,0 @@
1
- /**
2
- * Enhanced Description Enhancer - Optimized to work with Unified Context
3
- * Preserves all original functionality from pr-describe.js but optimized
4
- */
5
- import { EnhancementOptions, EnhancementResult, AIProviderConfig } from "../types/index.js";
6
- import { UnifiedContext } from "../core/ContextGatherer.js";
7
- import { BitbucketProvider } from "../core/providers/BitbucketProvider.js";
8
- export declare class DescriptionEnhancer {
9
- private neurolink;
10
- private bitbucketProvider;
11
- private aiConfig;
12
- private defaultRequiredSections;
13
- constructor(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig);
14
- /**
15
- * Enhance description using pre-gathered unified context (OPTIMIZED)
16
- */
17
- enhanceWithContext(context: UnifiedContext, options: EnhancementOptions): Promise<EnhancementResult>;
18
- /**
19
- * Analyze existing PR description content
20
- */
21
- private analyzeExistingContent;
22
- /**
23
- * Extract preservable content (media, files, links)
24
- */
25
- private extractPreservableContent;
26
- /**
27
- * Validate presence of required sections
28
- */
29
- private validateRequiredSections;
30
- /**
31
- * Extract content for a specific section
32
- */
33
- private extractSectionContent;
34
- /**
35
- * Identify content gaps (TODOs, unanswered questions, etc.)
36
- */
37
- private identifyContentGaps;
38
- /**
39
- * Generate enhanced description using AI and unified context
40
- */
41
- private generateEnhancedDescription;
42
- /**
43
- * Build comprehensive enhancement prompt using unified context
44
- */
45
- private buildEnhancementPrompt;
46
- /**
47
- * Update PR description in Bitbucket
48
- */
49
- private updatePRDescription;
50
- /**
51
- * Show description preview for dry run
52
- */
53
- private showDescriptionPreview;
54
- /**
55
- * Generate enhancement result summary
56
- */
57
- private generateEnhancementResult;
58
- /**
59
- * Get enhancement statistics
60
- */
61
- getStats(): any;
62
- }
63
- export declare function createDescriptionEnhancer(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig): DescriptionEnhancer;
64
- //# sourceMappingURL=DescriptionEnhancer.d.ts.map
@@ -1,445 +0,0 @@
1
- /**
2
- * Enhanced Description Enhancer - Optimized to work with Unified Context
3
- * Preserves all original functionality from pr-describe.js but optimized
4
- */
5
- import { ProviderError, } from "../types/index.js";
6
- import { logger } from "../utils/Logger.js";
7
- export class DescriptionEnhancer {
8
- neurolink;
9
- bitbucketProvider;
10
- aiConfig;
11
- defaultRequiredSections = [
12
- { key: "changelog", name: "Changelog (Modules Modified)", required: true },
13
- {
14
- key: "testcases",
15
- name: "Test Cases (What to be tested)",
16
- required: true,
17
- },
18
- {
19
- key: "config_changes",
20
- name: "CAC Config Or Service Config Changes",
21
- required: true,
22
- },
23
- ];
24
- constructor(bitbucketProvider, aiConfig) {
25
- this.bitbucketProvider = bitbucketProvider;
26
- this.aiConfig = aiConfig;
27
- }
28
- /**
29
- * Enhance description using pre-gathered unified context (OPTIMIZED)
30
- */
31
- async enhanceWithContext(context, options) {
32
- const startTime = Date.now();
33
- try {
34
- logger.phase("📝 Enhancing PR description...");
35
- logger.info(`Processing PR #${context.pr.id}: "${context.pr.title}"`);
36
- // Step 1: Analyze existing content and identify what needs enhancement
37
- const analysisResult = this.analyzeExistingContent(context.pr.description, options.customSections || this.defaultRequiredSections);
38
- logger.info(`Content analysis: ${analysisResult.preservedContent.media.length} media items, ` +
39
- `${analysisResult.missingCount} missing sections`);
40
- // Step 2: Generate enhanced description using AI
41
- const enhancedDescription = await this.generateEnhancedDescription(context, analysisResult, options);
42
- // Step 3: Update PR description if not dry run
43
- if (!options.dryRun) {
44
- await this.updatePRDescription(context, enhancedDescription);
45
- }
46
- else {
47
- this.showDescriptionPreview(enhancedDescription, analysisResult);
48
- }
49
- const duration = Math.round((Date.now() - startTime) / 1000);
50
- const result = this.generateEnhancementResult(context.pr.description, enhancedDescription, analysisResult, duration);
51
- logger.success(`Description enhancement completed in ${duration}s: ` +
52
- `${result.sectionsAdded.length} sections added, ${result.sectionsEnhanced.length} enhanced`);
53
- return result;
54
- }
55
- catch (error) {
56
- logger.error(`Description enhancement failed: ${error.message}`);
57
- throw new ProviderError(`Description enhancement failed: ${error.message}`);
58
- }
59
- }
60
- /**
61
- * Analyze existing PR description content
62
- */
63
- analyzeExistingContent(description, requiredSections) {
64
- logger.debug("Analyzing existing PR description content...");
65
- // Extract preservable content (media, files, links)
66
- const preservedContent = this.extractPreservableContent(description);
67
- // Validate required sections
68
- const sectionsAnalysis = this.validateRequiredSections(description, requiredSections);
69
- const missingCount = sectionsAnalysis.filter((s) => !s.present).length;
70
- // Identify content gaps
71
- const gaps = this.identifyContentGaps(description);
72
- return {
73
- requiredSections: sectionsAnalysis,
74
- missingCount,
75
- preservedContent,
76
- gaps,
77
- };
78
- }
79
- /**
80
- * Extract preservable content (media, files, links)
81
- */
82
- extractPreservableContent(description) {
83
- const preservableContent = {
84
- media: [],
85
- files: [],
86
- links: [],
87
- originalText: description || "",
88
- };
89
- if (!description) {
90
- return preservableContent;
91
- }
92
- // Extract images and media (screenshots, etc.)
93
- const mediaRegex = /!\[.*?\]\(.*?\)|<img[^>]*>|<video[^>]*>|<audio[^>]*>/g;
94
- preservableContent.media = description.match(mediaRegex) || [];
95
- // Extract file attachments
96
- const fileRegex = /\[.*?\]\([^)]*\.(pdf|doc|docx|xls|xlsx|ppt|pptx|zip|rar|tar|gz)[^)]*\)/gi;
97
- preservableContent.files = description.match(fileRegex) || [];
98
- // Extract links (excluding images and files)
99
- const linkRegex = /\[[^\]]*\]\([^)]+\)/g;
100
- const allLinks = description.match(linkRegex) || [];
101
- preservableContent.links = allLinks.filter((link) => !mediaRegex.test(link) && !fileRegex.test(link));
102
- logger.debug(`Preservable content: ${preservableContent.media.length} media, ` +
103
- `${preservableContent.files.length} files, ${preservableContent.links.length} links`);
104
- return preservableContent;
105
- }
106
- /**
107
- * Validate presence of required sections
108
- */
109
- validateRequiredSections(description, requiredSections) {
110
- if (!description) {
111
- return requiredSections.map((section) => ({
112
- ...section,
113
- present: false,
114
- content: "",
115
- }));
116
- }
117
- const sectionPatterns = {
118
- changelog: [
119
- /##.*?[Cc]hangelog/i,
120
- /##.*?[Mm]odules?\s+[Mm]odified/i,
121
- /##.*?[Cc]hanges?\s+[Mm]ade/i,
122
- /📋.*?[Cc]hangelog/i,
123
- ],
124
- testcases: [
125
- /##.*?[Tt]est\s+[Cc]ases?/i,
126
- /##.*?[Tt]esting/i,
127
- /🧪.*?[Tt]est/i,
128
- /##.*?[Tt]est\s+[Pp]lan/i,
129
- ],
130
- config_changes: [
131
- /##.*?[Cc]onfig/i,
132
- /##.*?CAC/i,
133
- /##.*?[Ss]ervice\s+[Cc]onfig/i,
134
- /⚙️.*?[Cc]onfig/i,
135
- ],
136
- };
137
- return requiredSections.map((section) => {
138
- const patterns = sectionPatterns[section.key];
139
- const isPresent = patterns
140
- ? patterns.some((pattern) => pattern.test(description))
141
- : false;
142
- return {
143
- ...section,
144
- present: isPresent,
145
- content: isPresent
146
- ? this.extractSectionContent(description, patterns || [])
147
- : "",
148
- };
149
- });
150
- }
151
- /**
152
- * Extract content for a specific section
153
- */
154
- extractSectionContent(description, patterns) {
155
- for (const pattern of patterns) {
156
- const match = description.match(pattern);
157
- if (match) {
158
- const startIndex = match.index + match[0].length;
159
- const nextHeaderIndex = description
160
- .substring(startIndex)
161
- .search(/\n##/);
162
- const endIndex = nextHeaderIndex === -1
163
- ? description.length
164
- : startIndex + nextHeaderIndex;
165
- return description.substring(startIndex, endIndex).trim();
166
- }
167
- }
168
- return "";
169
- }
170
- /**
171
- * Identify content gaps (TODOs, unanswered questions, etc.)
172
- */
173
- identifyContentGaps(description) {
174
- const gaps = [];
175
- if (!description) {
176
- gaps.push("No description provided");
177
- return gaps;
178
- }
179
- // Check for unanswered questions and placeholders
180
- const gapMarkers = [
181
- { pattern: /\?\s*$/gm, name: "unanswered questions" },
182
- { pattern: /TODO/gi, name: "TODO items" },
183
- { pattern: /FIXME/gi, name: "FIXME items" },
184
- { pattern: /\[TBD\]/gi, name: "TBD placeholders" },
185
- { pattern: /\[TO BE DETERMINED\]/gi, name: "TBD placeholders" },
186
- { pattern: /\[PENDING\]/gi, name: "pending items" },
187
- ];
188
- gapMarkers.forEach((marker) => {
189
- const matches = description.match(marker.pattern);
190
- if (matches) {
191
- gaps.push(`${matches.length} ${marker.name}`);
192
- }
193
- });
194
- return gaps;
195
- }
196
- /**
197
- * Generate enhanced description using AI and unified context
198
- */
199
- async generateEnhancedDescription(context, analysisResult, options) {
200
- logger.debug("Generating AI-enhanced description...");
201
- // Initialize NeuroLink with eval-based dynamic import
202
- if (!this.neurolink) {
203
- const { NeuroLink } = await import("@juspay/neurolink");
204
- this.neurolink = new NeuroLink();
205
- }
206
- const enhancementPrompt = this.buildEnhancementPrompt(context, analysisResult, options);
207
- try {
208
- const result = await this.neurolink.generate({
209
- input: { text: enhancementPrompt },
210
- provider: this.aiConfig.provider,
211
- model: this.aiConfig.model,
212
- temperature: this.aiConfig.temperature || 0.7,
213
- maxTokens: this.aiConfig.maxTokens || 1000000,
214
- timeout: "8m", // Longer timeout for description generation
215
- enableAnalytics: this.aiConfig.enableAnalytics,
216
- enableEvaluation: this.aiConfig.enableEvaluation,
217
- });
218
- let enhancedDescription = result.content ||
219
- result.text ||
220
- result.response ||
221
- "";
222
- // Clean up any markdown code blocks if AI wrapped the response
223
- enhancedDescription = enhancedDescription
224
- .replace(/^```markdown\s*/, "")
225
- .replace(/\s*```$/, "")
226
- .trim();
227
- if (!enhancedDescription) {
228
- throw new Error("AI generated empty description");
229
- }
230
- // Validate that required sections are present after enhancement
231
- const finalValidation = this.validateRequiredSections(enhancedDescription, options.customSections || this.defaultRequiredSections);
232
- const stillMissing = finalValidation.filter((s) => !s.present);
233
- if (stillMissing.length > 0) {
234
- logger.warn(`Warning: ${stillMissing.length} required sections still missing after AI enhancement`);
235
- }
236
- return enhancedDescription;
237
- }
238
- catch (error) {
239
- if (error.message?.includes("timeout")) {
240
- logger.error("⏰ Description enhancement timed out after 8 minutes");
241
- throw new Error("Enhancement timeout - try with smaller diff or adjust timeout");
242
- }
243
- logger.error(`AI description generation failed: ${error.message}`);
244
- throw error;
245
- }
246
- }
247
- /**
248
- * Build comprehensive enhancement prompt using unified context
249
- */
250
- buildEnhancementPrompt(context, analysisResult, _options) {
251
- // Prepare diff information based on strategy
252
- let diffInfo = "";
253
- if (context.diffStrategy.strategy === "whole" && context.prDiff) {
254
- diffInfo = `**Diff Strategy**: Whole PR diff (${context.diffStrategy.fileCount} files)
255
- **Changes**: ${JSON.stringify(context.prDiff.fileChanges?.slice(0, 20) || [], null, 2)}`;
256
- }
257
- else if (context.diffStrategy.strategy === "file-by-file" &&
258
- context.fileDiffs) {
259
- const fileList = Array.from(context.fileDiffs.keys()).slice(0, 20);
260
- diffInfo = `**Diff Strategy**: File-by-file analysis (${context.diffStrategy.fileCount} files)
261
- **Modified Files**: ${JSON.stringify(fileList, null, 2)}`;
262
- }
263
- return `You are an expert technical writer specializing in comprehensive PR descriptions.
264
-
265
- ## PR INFORMATION:
266
- **Title**: ${context.pr.title}
267
- **Author**: ${context.pr.author}
268
- **Current Description**:
269
- ${analysisResult.preservedContent.originalText || "[No existing description]"}
270
-
271
- ## CODE CHANGES ANALYSIS:
272
- ${diffInfo}
273
-
274
- ## PROJECT CONTEXT:
275
- ${context.projectContext.memoryBank.summary}
276
-
277
- ## PROJECT RULES:
278
- ${context.projectContext.clinerules || "No specific rules defined"}
279
-
280
- ## CONTENT PRESERVATION REQUIREMENTS:
281
- **CRITICAL**: This is content ENHANCEMENT, not replacement!
282
-
283
- ### Preserved Content Analysis:
284
- - **Media Items**: ${analysisResult.preservedContent.media.length} (${analysisResult.preservedContent.media.join(", ")})
285
- - **File Attachments**: ${analysisResult.preservedContent.files.length} (${analysisResult.preservedContent.files.join(", ")})
286
- - **Links**: ${analysisResult.preservedContent.links.length}
287
- - **Content Gaps**: ${analysisResult.gaps.join(", ") || "None identified"}
288
-
289
- ### PRESERVATION RULES:
290
- - **NEVER REMOVE**: Screenshots, images, file attachments, existing explanations, or links
291
- - **PRESERVE EXACTLY**: All media links, file references, and existing valuable content
292
- - **ONLY ADD**: Missing required sections or enhance clearly incomplete ones
293
- - **MAINTAIN**: Original structure, tone, and author's explanations
294
-
295
- ## REQUIRED SECTIONS STATUS:
296
- ${analysisResult.requiredSections
297
- .map((section) => `
298
- **${section.name}**:
299
- - Present: ${section.present ? "✅ Yes" : "❌ Missing"}
300
- - Content: ${section.content ? `"${section.content.substring(0, 100)}..."` : "None"}
301
- - Action Needed: ${section.present ? ((section.content?.length || 0) < 50 ? "Enhancement" : "None") : "Add Section"}`)
302
- .join("")}
303
-
304
- ## REQUIRED SECTIONS TO IMPLEMENT:
305
-
306
- ### 1. 📋 CHANGELOG (Modules Modified)
307
- **Purpose**: Clear documentation of what changed
308
- **Content Requirements**:
309
- - List specific files/modules modified, added, or removed
310
- - Categorize changes (Features, Bug Fixes, Improvements, Breaking Changes)
311
- - Mention key components affected
312
- - Highlight any architectural changes
313
-
314
- ### 2. 🧪 TEST CASES (What to be tested)
315
- **Purpose**: Comprehensive testing guidance
316
- **Content Requirements**:
317
- - Unit tests to run or add
318
- - Integration test scenarios
319
- - Manual testing steps for reviewers
320
- - Edge cases to verify
321
- - Regression testing considerations
322
- - Performance testing if applicable
323
-
324
- ### 3. ⚙️ CAC CONFIG OR SERVICE CONFIG CHANGES
325
- **Purpose**: Infrastructure and configuration impact
326
- **Content Requirements**:
327
- - Configuration files modified
328
- - Environment variables added/changed/removed
329
- - Service configuration updates
330
- - Database schema changes
331
- - Deployment considerations
332
- - If no config changes: explicitly state "No configuration changes required"
333
-
334
- ## ENHANCEMENT STRATEGY:
335
-
336
- ### For Missing Sections:
337
- 1. **START** with the complete existing description
338
- 2. **ANALYZE** the code changes to understand the scope
339
- 3. **ADD** each missing required section with comprehensive content
340
- 4. **EXTRACT** relevant information from the diff to populate sections
341
-
342
- ### For Incomplete Sections:
343
- 1. **PRESERVE** all existing content in the section
344
- 2. **ENHANCE** with additional details based on code analysis
345
- 3. **MAINTAIN** the original structure and format
346
-
347
- ### Content Generation Guidelines:
348
- - **Be Specific**: Use actual file names, function names, and module names from the changes
349
- - **Be Actionable**: Provide clear, executable test instructions
350
- - **Be Complete**: Cover all aspects of the change comprehensively
351
- - **Be Professional**: Maintain technical accuracy and clear communication
352
-
353
- ## OUTPUT REQUIREMENTS:
354
- Return the COMPLETE enhanced description as properly formatted markdown text (NOT JSON).
355
-
356
- **CRITICAL INSTRUCTIONS**:
357
- 1. **START WITH**: The entire existing description as your foundation
358
- 2. **PRESERVE**: Every single piece of existing content (media, links, explanations)
359
- 3. **ADD ONLY**: Missing required sections at appropriate locations
360
- 4. **ENHANCE ONLY**: Clearly incomplete sections with additional details
361
- 5. **EXTRACT**: Specific details from the code changes for accuracy
362
- 6. **MAINTAIN**: Professional tone and clear markdown formatting
363
-
364
- Generate the enhanced description now, ensuring ALL preservation requirements are met:`;
365
- }
366
- /**
367
- * Update PR description in Bitbucket
368
- */
369
- async updatePRDescription(context, enhancedDescription) {
370
- logger.debug(`Updating PR description for #${context.pr.id}...`);
371
- try {
372
- await this.bitbucketProvider.updatePRDescription(context.identifier, enhancedDescription);
373
- logger.success("✅ PR description updated successfully");
374
- }
375
- catch (error) {
376
- logger.error(`Failed to update PR description: ${error.message}`);
377
- throw new ProviderError(`Description update failed: ${error.message}`);
378
- }
379
- }
380
- /**
381
- * Show description preview for dry run
382
- */
383
- showDescriptionPreview(enhancedDescription, analysisResult) {
384
- console.log("\n" + "═".repeat(80));
385
- console.log("📝 ENHANCED PR DESCRIPTION PREVIEW");
386
- console.log("═".repeat(80));
387
- console.log(enhancedDescription);
388
- console.log("═".repeat(80));
389
- console.log("\n📊 ENHANCEMENT SUMMARY:");
390
- console.log(`✅ Required sections completed: ${analysisResult.requiredSections.filter((s) => s.present).length}/${analysisResult.requiredSections.length}`);
391
- console.log(`📎 Preserved content: ${analysisResult.preservedContent.media.length} media items, ${analysisResult.preservedContent.files.length} files`);
392
- console.log(`📏 Enhanced description length: ${enhancedDescription.length} characters`);
393
- if (analysisResult.gaps.length > 0) {
394
- console.log(`🔍 Content gaps addressed: ${analysisResult.gaps.join(", ")}`);
395
- }
396
- }
397
- /**
398
- * Generate enhancement result summary
399
- */
400
- generateEnhancementResult(originalDescription, enhancedDescription, analysisResult, _duration) {
401
- // Determine what sections were added or enhanced
402
- const originalSections = this.validateRequiredSections(originalDescription, analysisResult.requiredSections);
403
- const enhancedSections = this.validateRequiredSections(enhancedDescription, analysisResult.requiredSections);
404
- const sectionsAdded = enhancedSections
405
- .filter((enhanced, i) => enhanced.present && !originalSections[i].present)
406
- .map((s) => s.name);
407
- const sectionsEnhanced = enhancedSections
408
- .filter((enhanced, i) => enhanced.present &&
409
- originalSections[i].present &&
410
- (enhanced.content?.length || 0) >
411
- (originalSections[i].content?.length || 0) + 50)
412
- .map((s) => s.name);
413
- const completedSections = enhancedSections.filter((s) => s.present).length;
414
- return {
415
- originalDescription: originalDescription || "",
416
- enhancedDescription,
417
- sectionsAdded,
418
- sectionsEnhanced,
419
- preservedItems: {
420
- media: analysisResult.preservedContent.media.length,
421
- files: analysisResult.preservedContent.files.length,
422
- links: analysisResult.preservedContent.links.length,
423
- },
424
- statistics: {
425
- originalLength: originalDescription?.length || 0,
426
- enhancedLength: enhancedDescription.length,
427
- completedSections,
428
- totalSections: analysisResult.requiredSections.length,
429
- },
430
- };
431
- }
432
- /**
433
- * Get enhancement statistics
434
- */
435
- getStats() {
436
- return {
437
- defaultSections: this.defaultRequiredSections.length,
438
- aiProvider: this.aiConfig.provider,
439
- };
440
- }
441
- }
442
- export function createDescriptionEnhancer(bitbucketProvider, aiConfig) {
443
- return new DescriptionEnhancer(bitbucketProvider, aiConfig);
444
- }
445
- //# sourceMappingURL=DescriptionEnhancer.js.map
@@ -1,74 +0,0 @@
1
- /**
2
- * Multi-Instance Processor for Parallel Code Review
3
- * Orchestrates multiple Neurolink SDK instances for diverse code analysis
4
- */
5
- import { MultiInstanceConfig, MultiInstanceResult, CodeReviewConfig, ReviewOptions } from "../types/index.js";
6
- import { UnifiedContext } from "../core/ContextGatherer.js";
7
- import { BitbucketProvider } from "../core/providers/BitbucketProvider.js";
8
- /**
9
- * Multi-Instance Processor
10
- * Manages parallel execution of multiple CodeReviewer instances
11
- */
12
- export declare class MultiInstanceProcessor {
13
- private bitbucketProvider;
14
- private baseReviewConfig;
15
- private duplicateRemover;
16
- constructor(bitbucketProvider: BitbucketProvider, baseReviewConfig: CodeReviewConfig);
17
- /**
18
- * Process code review using multiple instances
19
- */
20
- processWithMultipleInstances(context: UnifiedContext, options: ReviewOptions, multiInstanceConfig: MultiInstanceConfig): Promise<MultiInstanceResult>;
21
- /**
22
- * Execute all instances in parallel with concurrency control
23
- */
24
- private executeInstancesInParallel;
25
- /**
26
- * Execute a single instance with concurrency control
27
- */
28
- private executeInstanceWithConcurrency;
29
- /**
30
- * Validate provider string against allowed provider types
31
- */
32
- private validateProvider;
33
- /**
34
- * Execute a single instance
35
- */
36
- private executeInstance;
37
- /**
38
- * Validate multi-instance configuration
39
- */
40
- private validateMultiInstanceConfig;
41
- /**
42
- * Estimate tokens per instance based on context
43
- */
44
- private estimateTokensPerInstance;
45
- /**
46
- * Calculate total token budget for all instances
47
- */
48
- private calculateTotalTokenBudget;
49
- /**
50
- * Extract token usage from review result (if available)
51
- */
52
- private extractTokenUsage;
53
- /**
54
- * Create non-deduplicated result (when deduplication is disabled)
55
- */
56
- private createNonDeduplicatedResult;
57
- /**
58
- * Apply final filtering based on configuration
59
- */
60
- private applyFinalFiltering;
61
- /**
62
- * Prioritize violations based on strategy
63
- */
64
- private prioritizeViolations;
65
- /**
66
- * Create summary of multi-instance processing
67
- */
68
- private createSummary;
69
- }
70
- /**
71
- * Factory function to create MultiInstanceProcessor
72
- */
73
- export declare function createMultiInstanceProcessor(bitbucketProvider: BitbucketProvider, baseReviewConfig: CodeReviewConfig): MultiInstanceProcessor;
74
- //# sourceMappingURL=MultiInstanceProcessor.d.ts.map