@juspay/yama 1.3.0 โ 1.4.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/CHANGELOG.md +12 -0
- package/README.md +29 -1
- package/dist/core/Guardian.d.ts +1 -0
- package/dist/core/Guardian.js +21 -8
- package/dist/core/providers/BitbucketProvider.d.ts +1 -1
- package/dist/core/providers/BitbucketProvider.js +31 -1
- package/dist/features/CodeReviewer.d.ts +17 -9
- package/dist/features/CodeReviewer.js +274 -215
- package/dist/features/MultiInstanceProcessor.d.ts +74 -0
- package/dist/features/MultiInstanceProcessor.js +359 -0
- package/dist/types/index.d.ts +124 -1
- package/dist/utils/ContentSimilarityService.d.ts +74 -0
- package/dist/utils/ContentSimilarityService.js +215 -0
- package/dist/utils/ExactDuplicateRemover.d.ts +77 -0
- package/dist/utils/ExactDuplicateRemover.js +361 -0
- package/dist/utils/Logger.d.ts +3 -2
- package/dist/utils/Logger.js +8 -4
- package/dist/utils/ParallelProcessing.d.ts +112 -0
- package/dist/utils/ParallelProcessing.js +228 -0
- package/package.json +17 -17
- package/yama.config.example.yaml +46 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [1.4.1](https://github.com/juspay/yama/compare/v1.4.0...v1.4.1) (2025-09-18)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **config:** resolve config layering issue in Guardian initialization ([6a27428](https://github.com/juspay/yama/commit/6a2742863b73dee458f83eadc464f41290fe52d9))
|
|
6
|
+
|
|
7
|
+
# [1.4.0](https://github.com/juspay/yama/compare/v1.3.0...v1.4.0) (2025-09-18)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- **Multi-Instance:** Added support for Multi-Instance Processing and Deduplication ([2724758](https://github.com/juspay/yama/commit/27247587f44740b26218f23694ebdcde4c323266))
|
|
12
|
+
|
|
1
13
|
# [1.3.0](https://github.com/juspay/yama/compare/v1.2.0...v1.3.0) (2025-09-01)
|
|
2
14
|
|
|
3
15
|
### 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
|
|
package/dist/core/Guardian.d.ts
CHANGED
package/dist/core/Guardian.js
CHANGED
|
@@ -7,7 +7,7 @@ import { BitbucketProvider } from "./providers/BitbucketProvider.js";
|
|
|
7
7
|
import { ContextGatherer } from "./ContextGatherer.js";
|
|
8
8
|
import { CodeReviewer } from "../features/CodeReviewer.js";
|
|
9
9
|
import { DescriptionEnhancer } from "../features/DescriptionEnhancer.js";
|
|
10
|
-
import { logger } from "../utils/Logger.js";
|
|
10
|
+
import { logger, createLogger } from "../utils/Logger.js";
|
|
11
11
|
import { configManager } from "../utils/ConfigManager.js";
|
|
12
12
|
import { cache } from "../utils/Cache.js";
|
|
13
13
|
export class Guardian {
|
|
@@ -18,6 +18,7 @@ export class Guardian {
|
|
|
18
18
|
descriptionEnhancer;
|
|
19
19
|
neurolink;
|
|
20
20
|
initialized = false;
|
|
21
|
+
logger = logger; // Default logger, will be updated after config load
|
|
21
22
|
constructor(config) {
|
|
22
23
|
this.config = {};
|
|
23
24
|
if (config) {
|
|
@@ -32,10 +33,19 @@ export class Guardian {
|
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
this.config =
|
|
36
|
+
// Load configuration first
|
|
37
|
+
const loaded = await configManager.loadConfig(configPath);
|
|
38
|
+
// Loaded file first, then in-memory overrides last
|
|
39
|
+
this.config = { ...loaded, ...this.config };
|
|
40
|
+
// Create logger with banner configuration if needed
|
|
41
|
+
const showBanner = this.config.display?.showBanner ?? true;
|
|
42
|
+
if (showBanner !== true) {
|
|
43
|
+
// Only create a new logger if we need to change the banner setting
|
|
44
|
+
this.logger = createLogger(logger.getConfig(), showBanner);
|
|
45
|
+
}
|
|
46
|
+
// Otherwise, keep using the default logger
|
|
47
|
+
this.logger.badge();
|
|
48
|
+
this.logger.phase("๐ Initializing Yama...");
|
|
39
49
|
// Initialize providers
|
|
40
50
|
this.bitbucketProvider = new BitbucketProvider(this.config.providers.git.credentials);
|
|
41
51
|
await this.bitbucketProvider.initialize();
|
|
@@ -281,7 +291,6 @@ export class Guardian {
|
|
|
281
291
|
logger.info("Code review is disabled in configuration");
|
|
282
292
|
return { skipped: true, reason: "disabled in config" };
|
|
283
293
|
}
|
|
284
|
-
logger.phase("๐ Executing code review...");
|
|
285
294
|
const reviewOptions = {
|
|
286
295
|
workspace: context.identifier.workspace,
|
|
287
296
|
repository: context.identifier.repository,
|
|
@@ -291,8 +300,12 @@ export class Guardian {
|
|
|
291
300
|
excludePatterns: this.config.features.codeReview.excludePatterns,
|
|
292
301
|
contextLines: this.config.features.codeReview.contextLines,
|
|
293
302
|
};
|
|
294
|
-
|
|
295
|
-
|
|
303
|
+
logger.phase("๐ Executing code review...");
|
|
304
|
+
// Check if multi-instance processing is configured
|
|
305
|
+
const multiInstanceConfig = this.config.features?.codeReview
|
|
306
|
+
?.multiInstance;
|
|
307
|
+
// Use code review with multi-instance support
|
|
308
|
+
return await this.codeReviewer.reviewCodeWithContext(context, reviewOptions, multiInstanceConfig);
|
|
296
309
|
}
|
|
297
310
|
/**
|
|
298
311
|
* 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
|
-
*
|
|
19
|
+
* Review code using multiple instances for enhanced analysis
|
|
20
20
|
*/
|
|
21
|
-
|
|
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
|
*/
|