@juspay/yama 1.3.0 โ†’ 1.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [1.4.0](https://github.com/juspay/yama/compare/v1.3.0...v1.4.0) (2025-09-18)
2
+
3
+ ### Features
4
+
5
+ - **Multi-Instance:** Added support for Multi-Instance Processing and Deduplication ([2724758](https://github.com/juspay/yama/commit/27247587f44740b26218f23694ebdcde4c323266))
6
+
1
7
  # [1.3.0](https://github.com/juspay/yama/compare/v1.2.0...v1.3.0) (2025-09-01)
2
8
 
3
9
  ### Features
package/README.md CHANGED
@@ -199,6 +199,34 @@ features:
199
199
  - "๐Ÿงช Testing & Error Handling"
200
200
  - "๐Ÿ“– Documentation & Maintainability"
201
201
 
202
+ # Multi-Instance Processing Configuration
203
+ multiInstance:
204
+ enabled: true
205
+ instanceCount: 2
206
+ instances:
207
+ - name: "primary"
208
+ provider: "vertex"
209
+ model: "gemini-2.5-pro"
210
+ temperature: 0.3
211
+ - name: "secondary"
212
+ provider: "vertex"
213
+ model: "gemini-2.5-pro"
214
+ temperature: 0.1
215
+ deduplication:
216
+ enabled: true
217
+ similarityThreshold: 40 # 0-100 percentage scale
218
+ maxCommentsToPost: 30
219
+ prioritizeBy: "severity"
220
+
221
+ # Semantic Deduplication Configuration
222
+ semanticDeduplication:
223
+ enabled: true
224
+ similarityThreshold: 70 # 0-100 percentage scale
225
+ batchSize: 15
226
+ timeout: "5m"
227
+ fallbackOnError: true
228
+ logMatches: true
229
+
202
230
  descriptionEnhancement:
203
231
  enabled: true
204
232
  preserveContent: true # NEVER remove existing content
@@ -477,7 +505,7 @@ await guardian.processPR({
477
505
  });
478
506
  ```
479
507
 
480
- ----
508
+ ---
481
509
 
482
510
  ## ๐Ÿ“‹ **Configurable Description Sections**
483
511
 
@@ -281,7 +281,6 @@ export class Guardian {
281
281
  logger.info("Code review is disabled in configuration");
282
282
  return { skipped: true, reason: "disabled in config" };
283
283
  }
284
- logger.phase("๐Ÿ” Executing code review...");
285
284
  const reviewOptions = {
286
285
  workspace: context.identifier.workspace,
287
286
  repository: context.identifier.repository,
@@ -291,8 +290,12 @@ export class Guardian {
291
290
  excludePatterns: this.config.features.codeReview.excludePatterns,
292
291
  contextLines: this.config.features.codeReview.contextLines,
293
292
  };
294
- // Use the already gathered context instead of gathering again
295
- return await this.codeReviewer.reviewCodeWithContext(context, reviewOptions);
293
+ logger.phase("๐Ÿ” Executing code review...");
294
+ // Check if multi-instance processing is configured
295
+ const multiInstanceConfig = this.config.features?.codeReview
296
+ ?.multiInstance;
297
+ // Use code review with multi-instance support
298
+ return await this.codeReviewer.reviewCodeWithContext(context, reviewOptions, multiInstanceConfig);
296
299
  }
297
300
  /**
298
301
  * Execute description enhancement using shared context
@@ -56,7 +56,7 @@ export declare class BitbucketProvider {
56
56
  message: string;
57
57
  }>;
58
58
  /**
59
- * Add comment to PR with smart positioning
59
+ * Add comment to PR with smart positioning and validation
60
60
  */
61
61
  addComment(identifier: PRIdentifier, commentText: string, options?: {
62
62
  filePath?: string;
@@ -286,7 +286,7 @@ export class BitbucketProvider {
286
286
  }
287
287
  }
288
288
  /**
289
- * Add comment to PR with smart positioning
289
+ * Add comment to PR with smart positioning and validation
290
290
  */
291
291
  async addComment(identifier, commentText, options = {}) {
292
292
  await this.initialize();
@@ -351,6 +351,36 @@ export class BitbucketProvider {
351
351
  }
352
352
  catch (error) {
353
353
  logger.error(`Failed to add comment: ${error.message}`);
354
+ // If inline comment fails, try posting as general comment
355
+ if (options.filePath && options.codeSnippet) {
356
+ logger.debug(`Attempting fallback to general comment...`);
357
+ try {
358
+ const fallbackArgs = {
359
+ workspace,
360
+ repository,
361
+ pull_request_id: pullRequestId,
362
+ comment_text: `**File: ${options.filePath}**\n\n${commentText}`,
363
+ };
364
+ const fallbackResult = await this.pullRequestHandlers.handleAddComment(fallbackArgs);
365
+ let fallbackData;
366
+ if (fallbackResult.content &&
367
+ fallbackResult.content[0] &&
368
+ fallbackResult.content[0].text) {
369
+ fallbackData = JSON.parse(fallbackResult.content[0].text);
370
+ }
371
+ else {
372
+ fallbackData = fallbackResult;
373
+ }
374
+ logger.debug(`Fallback comment posted successfully`);
375
+ return {
376
+ success: true,
377
+ commentId: fallbackData.id || fallbackData.comment_id,
378
+ };
379
+ }
380
+ catch (fallbackError) {
381
+ logger.error(`Fallback comment also failed: ${fallbackError.message}`);
382
+ }
383
+ }
354
384
  throw new ProviderError(`Comment failed: ${error.message}`);
355
385
  }
356
386
  }
@@ -12,17 +12,13 @@ export declare class CodeReviewer {
12
12
  private reviewConfig;
13
13
  constructor(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig, reviewConfig: CodeReviewConfig);
14
14
  /**
15
- * Review code using pre-gathered unified context (OPTIMIZED with Batch Processing)
15
+ * Review code using pre-gathered unified context (OPTIMIZED with Multi-Instance and Batch Processing)
16
16
  */
17
- reviewCodeWithContext(context: UnifiedContext, options: ReviewOptions): Promise<ReviewResult>;
17
+ reviewCodeWithContext(context: UnifiedContext, options: ReviewOptions, multiInstanceConfig?: any): Promise<ReviewResult>;
18
18
  /**
19
- * Validate violations to ensure code snippets exist in diff
19
+ * Review code using multiple instances for enhanced analysis
20
20
  */
21
- private validateViolations;
22
- /**
23
- * Try to fix code snippet by finding it in the actual diff
24
- */
25
- private tryFixCodeSnippet;
21
+ reviewWithMultipleInstances(context: UnifiedContext, options: ReviewOptions, multiInstanceConfig: any): Promise<any>;
26
22
  /**
27
23
  * Get system prompt for security-focused code review
28
24
  */
@@ -101,9 +97,21 @@ export declare class CodeReviewer {
101
97
  */
102
98
  private shouldUseBatchProcessing;
103
99
  /**
104
- * Main batch processing method
100
+ * Main batch processing method with parallel processing support
105
101
  */
106
102
  private reviewWithBatchProcessing;
103
+ /**
104
+ * Process batches in parallel with concurrency control
105
+ */
106
+ private processInParallel;
107
+ /**
108
+ * Process batches serially (original implementation)
109
+ */
110
+ private processSerially;
111
+ /**
112
+ * Process a single batch with concurrency control
113
+ */
114
+ private processBatchWithConcurrency;
107
115
  /**
108
116
  * Prioritize files based on security importance and file type
109
117
  */