@juspay/yama 1.1.1 → 1.3.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 +16 -7
- package/README.md +1 -1
- package/dist/core/ContextGatherer.d.ts +8 -3
- package/dist/core/ContextGatherer.js +40 -21
- package/dist/core/Guardian.js +5 -1
- package/dist/core/providers/BitbucketProvider.js +1 -1
- package/dist/features/CodeReviewer.d.ts +49 -1
- package/dist/features/CodeReviewer.js +452 -26
- package/dist/types/index.d.ts +44 -0
- package/dist/utils/Cache.d.ts +5 -0
- package/dist/utils/Cache.js +17 -1
- package/dist/utils/ConfigManager.d.ts +4 -0
- package/dist/utils/ConfigManager.js +21 -1
- package/dist/utils/MemoryBankManager.d.ts +73 -0
- package/dist/utils/MemoryBankManager.js +310 -0
- package/dist/utils/ProviderLimits.d.ts +58 -0
- package/dist/utils/ProviderLimits.js +143 -0
- package/package.json +30 -5
- package/yama.config.example.yaml +19 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
# [1.3.0](https://github.com/juspay/yama/compare/v1.2.0...v1.3.0) (2025-09-01)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
2
4
|
|
|
5
|
+
- **github:** implement comprehensive automation with proper Yama branding ([a03cb7f](https://github.com/juspay/yama/commit/a03cb7f499ea7793d626686beebde907551035d0))
|
|
6
|
+
|
|
7
|
+
# [1.2.0](https://github.com/juspay/yama/compare/v1.1.1...v1.2.0) (2025-08-08)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- **Memory:** support memory bank path and maxToken from config file ([1bc69d5](https://github.com/juspay/yama/commit/1bc69d5bda3ac5868d7537b881007beaf6916476))
|
|
12
|
+
|
|
13
|
+
## [1.1.1](https://github.com/juspay/yama/compare/v1.1.0...v1.1.1) (2025-07-28)
|
|
3
14
|
|
|
4
15
|
### Bug Fixes
|
|
5
16
|
|
|
6
|
-
|
|
17
|
+
- bump version to 1.2.1 ([8964645](https://github.com/juspay/yama/commit/89646450a7dec6ffcc3ad7fb745e1414fc751d4f))
|
|
7
18
|
|
|
8
19
|
# [1.1.0](https://github.com/juspay/yama/compare/v1.0.0...v1.1.0) (2025-07-28)
|
|
9
20
|
|
|
10
|
-
|
|
11
21
|
### Features
|
|
12
22
|
|
|
13
|
-
|
|
23
|
+
- migrate from CommonJS to ESM modules ([b45559f](https://github.com/juspay/yama/commit/b45559f86d37ab3516079becfa56a9f73ff8f062))
|
|
14
24
|
|
|
15
25
|
# 1.0.0 (2025-07-25)
|
|
16
26
|
|
|
17
|
-
|
|
18
27
|
### Features
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
- add enterprise-grade CI/CD pipeline and release automation ([e385d69](https://github.com/juspay/yama/commit/e385d69d135bee72f51ac4462adcfc9a4a4be17b))
|
|
30
|
+
- v1.1.0 - Enhanced AI configuration and performance improvements ([e763e93](https://github.com/juspay/yama/commit/e763e9341c2869433097b7a6bcc9080028934e1b))
|
|
22
31
|
|
|
23
32
|
# Changelog
|
|
24
33
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Unified Context Gatherer - The foundation for all Yama operations
|
|
3
3
|
* Gathers all necessary context once and reuses it across all operations
|
|
4
4
|
*/
|
|
5
|
-
import { PRIdentifier, PRInfo, PRDiff, AIProviderConfig, DiffStrategyConfig } from "../types/index.js";
|
|
5
|
+
import { PRIdentifier, PRInfo, PRDiff, AIProviderConfig, DiffStrategyConfig, MemoryBankConfig } from "../types/index.js";
|
|
6
6
|
import { BitbucketProvider } from "./providers/BitbucketProvider.js";
|
|
7
7
|
export interface ProjectContext {
|
|
8
8
|
memoryBank: {
|
|
@@ -36,8 +36,9 @@ export declare class ContextGatherer {
|
|
|
36
36
|
private neurolink;
|
|
37
37
|
private bitbucketProvider;
|
|
38
38
|
private aiConfig;
|
|
39
|
+
private memoryBankManager;
|
|
39
40
|
private startTime;
|
|
40
|
-
constructor(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig);
|
|
41
|
+
constructor(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig, memoryBankConfig: MemoryBankConfig);
|
|
41
42
|
/**
|
|
42
43
|
* Main context gathering method - used by all operations
|
|
43
44
|
*/
|
|
@@ -56,6 +57,10 @@ export declare class ContextGatherer {
|
|
|
56
57
|
* Step 2: Gather project context (memory bank + clinerules)
|
|
57
58
|
*/
|
|
58
59
|
private gatherProjectContext;
|
|
60
|
+
/**
|
|
61
|
+
* Get safe token limit based on AI provider using shared utility
|
|
62
|
+
*/
|
|
63
|
+
private getSafeTokenLimit;
|
|
59
64
|
/**
|
|
60
65
|
* Parse project context with AI
|
|
61
66
|
*/
|
|
@@ -101,5 +106,5 @@ export declare class ContextGatherer {
|
|
|
101
106
|
*/
|
|
102
107
|
getStats(): any;
|
|
103
108
|
}
|
|
104
|
-
export declare function createContextGatherer(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig): ContextGatherer;
|
|
109
|
+
export declare function createContextGatherer(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig, memoryBankConfig: MemoryBankConfig): ContextGatherer;
|
|
105
110
|
//# sourceMappingURL=ContextGatherer.d.ts.map
|
|
@@ -6,14 +6,18 @@
|
|
|
6
6
|
import { ProviderError, } from "../types/index.js";
|
|
7
7
|
import { logger } from "../utils/Logger.js";
|
|
8
8
|
import { cache, Cache } from "../utils/Cache.js";
|
|
9
|
+
import { createMemoryBankManager } from "../utils/MemoryBankManager.js";
|
|
10
|
+
import { getProviderTokenLimit } from "../utils/ProviderLimits.js";
|
|
9
11
|
export class ContextGatherer {
|
|
10
12
|
neurolink;
|
|
11
13
|
bitbucketProvider;
|
|
12
14
|
aiConfig;
|
|
15
|
+
memoryBankManager;
|
|
13
16
|
startTime = 0;
|
|
14
|
-
constructor(bitbucketProvider, aiConfig) {
|
|
17
|
+
constructor(bitbucketProvider, aiConfig, memoryBankConfig) {
|
|
15
18
|
this.bitbucketProvider = bitbucketProvider;
|
|
16
19
|
this.aiConfig = aiConfig;
|
|
20
|
+
this.memoryBankManager = createMemoryBankManager(memoryBankConfig, bitbucketProvider);
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Main context gathering method - used by all operations
|
|
@@ -122,10 +126,10 @@ export class ContextGatherer {
|
|
|
122
126
|
}
|
|
123
127
|
return cache.getOrSet(cacheKey, async () => {
|
|
124
128
|
try {
|
|
125
|
-
//
|
|
126
|
-
const
|
|
127
|
-
if (
|
|
128
|
-
logger.debug("No memory
|
|
129
|
+
// Use MemoryBankManager to get memory bank files
|
|
130
|
+
const memoryBankResult = await this.memoryBankManager.getMemoryBankFiles(identifier, forceRefresh);
|
|
131
|
+
if (memoryBankResult.files.length === 0) {
|
|
132
|
+
logger.debug("No memory bank files found");
|
|
129
133
|
return {
|
|
130
134
|
memoryBank: {
|
|
131
135
|
summary: "No project context available",
|
|
@@ -137,19 +141,12 @@ export class ContextGatherer {
|
|
|
137
141
|
filesProcessed: 0,
|
|
138
142
|
};
|
|
139
143
|
}
|
|
140
|
-
//
|
|
144
|
+
// Convert MemoryBankFile[] to Record<string, string> for AI processing
|
|
141
145
|
const fileContents = {};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
await this.bitbucketProvider.getFileContent(identifier.workspace, identifier.repository, `memory-bank/${file.name}`, identifier.branch || "main");
|
|
147
|
-
logger.debug(`✓ Got content for: ${file.name}`);
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
logger.debug(`Could not read file ${file.name}: ${error.message}`);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
146
|
+
memoryBankResult.files.forEach((file) => {
|
|
147
|
+
fileContents[file.name] = file.content;
|
|
148
|
+
});
|
|
149
|
+
logger.debug(`✓ Loaded ${memoryBankResult.files.length} memory bank files from ${memoryBankResult.resolvedPath}${memoryBankResult.fallbackUsed ? " (fallback)" : ""}`);
|
|
153
150
|
// Get .clinerules file
|
|
154
151
|
let clinerules = "";
|
|
155
152
|
try {
|
|
@@ -171,7 +168,7 @@ Standards: ${contextData.standards}`,
|
|
|
171
168
|
standards: contextData.standards,
|
|
172
169
|
},
|
|
173
170
|
clinerules,
|
|
174
|
-
filesProcessed:
|
|
171
|
+
filesProcessed: memoryBankResult.filesProcessed,
|
|
175
172
|
};
|
|
176
173
|
}
|
|
177
174
|
catch (error) {
|
|
@@ -189,6 +186,23 @@ Standards: ${contextData.standards}`,
|
|
|
189
186
|
}
|
|
190
187
|
}, 7200);
|
|
191
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Get safe token limit based on AI provider using shared utility
|
|
191
|
+
*/
|
|
192
|
+
getSafeTokenLimit() {
|
|
193
|
+
const provider = this.aiConfig.provider || "auto";
|
|
194
|
+
const configuredTokens = this.aiConfig.maxTokens;
|
|
195
|
+
// Use conservative limits for ContextGatherer (safer for large context processing)
|
|
196
|
+
const providerLimit = getProviderTokenLimit(provider, true);
|
|
197
|
+
// Use the smaller of configured tokens or provider limit
|
|
198
|
+
if (configuredTokens && configuredTokens > 0) {
|
|
199
|
+
const safeLimit = Math.min(configuredTokens, providerLimit);
|
|
200
|
+
logger.debug(`Token limit: configured=${configuredTokens}, provider=${providerLimit}, using=${safeLimit}`);
|
|
201
|
+
return safeLimit;
|
|
202
|
+
}
|
|
203
|
+
logger.debug(`Token limit: using provider default=${providerLimit} for ${provider}`);
|
|
204
|
+
return providerLimit;
|
|
205
|
+
}
|
|
192
206
|
/**
|
|
193
207
|
* Parse project context with AI
|
|
194
208
|
*/
|
|
@@ -219,13 +233,18 @@ Extract and summarize the content and return ONLY this JSON format:
|
|
|
219
233
|
hasClinerules: !!clinerules,
|
|
220
234
|
analysisType: "memory-bank-synthesis",
|
|
221
235
|
};
|
|
236
|
+
// Get safe token limit based on provider
|
|
237
|
+
const safeMaxTokens = this.getSafeTokenLimit();
|
|
238
|
+
logger.debug(`Using AI provider: ${this.aiConfig.provider || "auto"}`);
|
|
239
|
+
logger.debug(`Configured maxTokens: ${this.aiConfig.maxTokens}`);
|
|
240
|
+
logger.debug(`Safe maxTokens limit: ${safeMaxTokens}`);
|
|
222
241
|
const result = await this.neurolink.generate({
|
|
223
242
|
input: { text: prompt },
|
|
224
243
|
systemPrompt: "You are an Expert Project Analyst. Synthesize project context from documentation and configuration files to help AI understand the codebase architecture, patterns, and business domain.",
|
|
225
244
|
provider: this.aiConfig.provider,
|
|
226
245
|
model: this.aiConfig.model,
|
|
227
246
|
temperature: 0.3,
|
|
228
|
-
maxTokens:
|
|
247
|
+
maxTokens: safeMaxTokens, // Use provider-aware safe token limit
|
|
229
248
|
timeout: "10m", // Allow longer processing for quality
|
|
230
249
|
context: aiContext,
|
|
231
250
|
enableAnalytics: this.aiConfig.enableAnalytics || true,
|
|
@@ -445,7 +464,7 @@ Extract and summarize the content and return ONLY this JSON format:
|
|
|
445
464
|
}
|
|
446
465
|
}
|
|
447
466
|
// Export factory function
|
|
448
|
-
export function createContextGatherer(bitbucketProvider, aiConfig) {
|
|
449
|
-
return new ContextGatherer(bitbucketProvider, aiConfig);
|
|
467
|
+
export function createContextGatherer(bitbucketProvider, aiConfig, memoryBankConfig) {
|
|
468
|
+
return new ContextGatherer(bitbucketProvider, aiConfig, memoryBankConfig);
|
|
450
469
|
}
|
|
451
470
|
//# sourceMappingURL=ContextGatherer.js.map
|
package/dist/core/Guardian.js
CHANGED
|
@@ -43,7 +43,11 @@ export class Guardian {
|
|
|
43
43
|
const { NeuroLink } = await import("@juspay/neurolink");
|
|
44
44
|
this.neurolink = new NeuroLink();
|
|
45
45
|
// Initialize core components
|
|
46
|
-
this.contextGatherer = new ContextGatherer(this.bitbucketProvider, this.config.providers.ai
|
|
46
|
+
this.contextGatherer = new ContextGatherer(this.bitbucketProvider, this.config.providers.ai, this.config.memoryBank || {
|
|
47
|
+
enabled: true,
|
|
48
|
+
path: "memory-bank",
|
|
49
|
+
fallbackPaths: ["docs/memory-bank", ".memory-bank"],
|
|
50
|
+
});
|
|
47
51
|
this.codeReviewer = new CodeReviewer(this.bitbucketProvider, this.config.providers.ai, this.config.features.codeReview);
|
|
48
52
|
this.descriptionEnhancer = new DescriptionEnhancer(this.bitbucketProvider, this.config.providers.ai);
|
|
49
53
|
this.initialized = true;
|
|
@@ -27,7 +27,7 @@ export class BitbucketProvider {
|
|
|
27
27
|
}
|
|
28
28
|
try {
|
|
29
29
|
logger.debug("Initializing Bitbucket MCP handlers...");
|
|
30
|
-
const dynamicImport =
|
|
30
|
+
const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
31
31
|
const [{ BitbucketApiClient }, { BranchHandlers }, { PullRequestHandlers }, { ReviewHandlers }, { FileHandlers },] = await Promise.all([
|
|
32
32
|
dynamicImport("@nexus2520/bitbucket-mcp-server/build/utils/api-client.js"),
|
|
33
33
|
dynamicImport("@nexus2520/bitbucket-mcp-server/build/handlers/branch-handlers.js"),
|
|
@@ -12,7 +12,7 @@ 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)
|
|
15
|
+
* Review code using pre-gathered unified context (OPTIMIZED with Batch Processing)
|
|
16
16
|
*/
|
|
17
17
|
reviewCodeWithContext(context: UnifiedContext, options: ReviewOptions): Promise<ReviewResult>;
|
|
18
18
|
/**
|
|
@@ -51,6 +51,10 @@ export declare class CodeReviewer {
|
|
|
51
51
|
* Legacy method - kept for compatibility but simplified
|
|
52
52
|
*/
|
|
53
53
|
private buildAnalysisPrompt;
|
|
54
|
+
/**
|
|
55
|
+
* Get safe token limit based on AI provider using shared utility
|
|
56
|
+
*/
|
|
57
|
+
private getSafeTokenLimit;
|
|
54
58
|
/**
|
|
55
59
|
* Analyze code with AI using the enhanced prompt
|
|
56
60
|
*/
|
|
@@ -88,6 +92,46 @@ export declare class CodeReviewer {
|
|
|
88
92
|
private groupViolationsByCategory;
|
|
89
93
|
private calculateStats;
|
|
90
94
|
private generateReviewResult;
|
|
95
|
+
/**
|
|
96
|
+
* Get batch processing configuration with defaults
|
|
97
|
+
*/
|
|
98
|
+
private getBatchProcessingConfig;
|
|
99
|
+
/**
|
|
100
|
+
* Determine if batch processing should be used
|
|
101
|
+
*/
|
|
102
|
+
private shouldUseBatchProcessing;
|
|
103
|
+
/**
|
|
104
|
+
* Main batch processing method
|
|
105
|
+
*/
|
|
106
|
+
private reviewWithBatchProcessing;
|
|
107
|
+
/**
|
|
108
|
+
* Prioritize files based on security importance and file type
|
|
109
|
+
*/
|
|
110
|
+
private prioritizeFiles;
|
|
111
|
+
/**
|
|
112
|
+
* Calculate file priority based on path and content
|
|
113
|
+
*/
|
|
114
|
+
private calculateFilePriority;
|
|
115
|
+
/**
|
|
116
|
+
* Estimate token count for a file
|
|
117
|
+
*/
|
|
118
|
+
private estimateFileTokens;
|
|
119
|
+
/**
|
|
120
|
+
* Create batches from prioritized files
|
|
121
|
+
*/
|
|
122
|
+
private createBatches;
|
|
123
|
+
/**
|
|
124
|
+
* Process a single batch of files
|
|
125
|
+
*/
|
|
126
|
+
private processBatch;
|
|
127
|
+
/**
|
|
128
|
+
* Create context for a specific batch
|
|
129
|
+
*/
|
|
130
|
+
private createBatchContext;
|
|
131
|
+
/**
|
|
132
|
+
* Build analysis prompt for a specific batch
|
|
133
|
+
*/
|
|
134
|
+
private buildBatchAnalysisPrompt;
|
|
91
135
|
/**
|
|
92
136
|
* Utility methods
|
|
93
137
|
*/
|
|
@@ -96,6 +140,10 @@ export declare class CodeReviewer {
|
|
|
96
140
|
* Extract line information for comment from context
|
|
97
141
|
*/
|
|
98
142
|
private extractLineInfoForComment;
|
|
143
|
+
/**
|
|
144
|
+
* Detect programming language from file extension
|
|
145
|
+
*/
|
|
146
|
+
private detectLanguageFromFile;
|
|
99
147
|
/**
|
|
100
148
|
* Generate all possible path variations for a file
|
|
101
149
|
*/
|