@juspay/yama 1.1.0 → 1.2.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 +34 -1
- package/README.md +152 -120
- package/dist/cli/index.js +201 -200
- package/dist/core/ContextGatherer.d.ts +10 -5
- package/dist/core/ContextGatherer.js +176 -161
- package/dist/core/Guardian.d.ts +1 -1
- package/dist/core/Guardian.js +126 -122
- package/dist/core/providers/BitbucketProvider.d.ts +3 -3
- package/dist/core/providers/BitbucketProvider.js +129 -121
- package/dist/features/CodeReviewer.d.ts +7 -3
- package/dist/features/CodeReviewer.js +314 -222
- package/dist/features/DescriptionEnhancer.d.ts +3 -3
- package/dist/features/DescriptionEnhancer.js +115 -94
- package/dist/index.d.ts +11 -11
- package/dist/index.js +10 -48
- package/dist/types/index.d.ts +27 -21
- package/dist/types/index.js +13 -18
- package/dist/utils/Cache.d.ts +6 -1
- package/dist/utils/Cache.js +78 -68
- package/dist/utils/ConfigManager.d.ts +5 -1
- package/dist/utils/ConfigManager.js +301 -253
- package/dist/utils/Logger.d.ts +2 -2
- package/dist/utils/Logger.js +69 -67
- 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 +7 -6
- package/yama.config.example.yaml +37 -21
package/dist/core/Guardian.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Yama - Unified orchestrator class
|
|
3
3
|
* The main class that coordinates all operations using shared context
|
|
4
4
|
*/
|
|
5
|
-
import { GuardianConfig, OperationOptions, ProcessResult, StreamUpdate, StreamOptions, ReviewOptions, EnhancementOptions } from
|
|
5
|
+
import { GuardianConfig, OperationOptions, ProcessResult, StreamUpdate, StreamOptions, ReviewOptions, EnhancementOptions } from "../types/index.js";
|
|
6
6
|
export declare class Guardian {
|
|
7
7
|
private config;
|
|
8
8
|
private bitbucketProvider;
|
package/dist/core/Guardian.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Yama - Unified orchestrator class
|
|
4
3
|
* The main class that coordinates all operations using shared context
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { GuardianError, } from "../types/index.js";
|
|
6
|
+
import { BitbucketProvider } from "./providers/BitbucketProvider.js";
|
|
7
|
+
import { ContextGatherer } from "./ContextGatherer.js";
|
|
8
|
+
import { CodeReviewer } from "../features/CodeReviewer.js";
|
|
9
|
+
import { DescriptionEnhancer } from "../features/DescriptionEnhancer.js";
|
|
10
|
+
import { logger } from "../utils/Logger.js";
|
|
11
|
+
import { configManager } from "../utils/ConfigManager.js";
|
|
12
|
+
import { cache } from "../utils/Cache.js";
|
|
13
|
+
export class Guardian {
|
|
14
|
+
config;
|
|
15
|
+
bitbucketProvider;
|
|
16
|
+
contextGatherer;
|
|
17
|
+
codeReviewer;
|
|
18
|
+
descriptionEnhancer;
|
|
19
|
+
neurolink;
|
|
20
|
+
initialized = false;
|
|
18
21
|
constructor(config) {
|
|
19
|
-
this.initialized = false;
|
|
20
22
|
this.config = {};
|
|
21
23
|
if (config) {
|
|
22
24
|
this.config = { ...this.config, ...config };
|
|
@@ -30,27 +32,30 @@ class Guardian {
|
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
34
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
logger.badge();
|
|
36
|
+
logger.phase("🚀 Initializing Yama...");
|
|
35
37
|
// Load configuration
|
|
36
|
-
this.config = await
|
|
38
|
+
this.config = await configManager.loadConfig(configPath);
|
|
37
39
|
// Initialize providers
|
|
38
|
-
this.bitbucketProvider = new
|
|
40
|
+
this.bitbucketProvider = new BitbucketProvider(this.config.providers.git.credentials);
|
|
39
41
|
await this.bitbucketProvider.initialize();
|
|
40
|
-
// Initialize NeuroLink with
|
|
41
|
-
const
|
|
42
|
-
const { NeuroLink } = await dynamicImport('@juspay/neurolink');
|
|
42
|
+
// Initialize NeuroLink with native ESM dynamic import
|
|
43
|
+
const { NeuroLink } = await import("@juspay/neurolink");
|
|
43
44
|
this.neurolink = new NeuroLink();
|
|
44
45
|
// Initialize core components
|
|
45
|
-
this.contextGatherer = new
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
});
|
|
51
|
+
this.codeReviewer = new CodeReviewer(this.bitbucketProvider, this.config.providers.ai, this.config.features.codeReview);
|
|
52
|
+
this.descriptionEnhancer = new DescriptionEnhancer(this.bitbucketProvider, this.config.providers.ai);
|
|
48
53
|
this.initialized = true;
|
|
49
|
-
|
|
54
|
+
logger.success("✅ Yama initialized successfully");
|
|
50
55
|
}
|
|
51
56
|
catch (error) {
|
|
52
|
-
|
|
53
|
-
throw new
|
|
57
|
+
logger.error(`Failed to initialize Yama: ${error.message}`);
|
|
58
|
+
throw new GuardianError("INITIALIZATION_ERROR", `Initialization failed: ${error.message}`);
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
/**
|
|
@@ -61,30 +66,30 @@ class Guardian {
|
|
|
61
66
|
const startTime = Date.now();
|
|
62
67
|
const operations = [];
|
|
63
68
|
try {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
logger.operation("PR Processing", "started");
|
|
70
|
+
logger.info(`Target: ${options.workspace}/${options.repository}`);
|
|
71
|
+
logger.info(`Operations: ${options.operations.join(", ")}`);
|
|
72
|
+
logger.info(`Mode: ${options.dryRun ? "DRY RUN" : "LIVE"}`);
|
|
68
73
|
// Step 1: Gather unified context ONCE for all operations
|
|
69
|
-
|
|
74
|
+
logger.phase("📋 Gathering unified context...");
|
|
70
75
|
const context = await this.gatherUnifiedContext(options);
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
logger.success(`Context ready: PR #${context.pr.id} - "${context.pr.title}"`);
|
|
77
|
+
logger.info(`Files: ${context.diffStrategy.fileCount}, Strategy: ${context.diffStrategy.strategy}`);
|
|
73
78
|
// Step 2: Execute requested operations using shared context
|
|
74
79
|
for (const operation of options.operations) {
|
|
75
|
-
if (operation ===
|
|
80
|
+
if (operation === "all") {
|
|
76
81
|
// Execute all available operations
|
|
77
|
-
operations.push(await this.executeOperation(
|
|
78
|
-
operations.push(await this.executeOperation(
|
|
82
|
+
operations.push(await this.executeOperation("review", context, options));
|
|
83
|
+
operations.push(await this.executeOperation("enhance-description", context, options));
|
|
79
84
|
}
|
|
80
85
|
else {
|
|
81
86
|
operations.push(await this.executeOperation(operation, context, options));
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
const duration = Date.now() - startTime;
|
|
85
|
-
const successCount = operations.filter(op => op.status ===
|
|
86
|
-
const errorCount = operations.filter(op => op.status ===
|
|
87
|
-
const skippedCount = operations.filter(op => op.status ===
|
|
90
|
+
const successCount = operations.filter((op) => op.status === "success").length;
|
|
91
|
+
const errorCount = operations.filter((op) => op.status === "error").length;
|
|
92
|
+
const skippedCount = operations.filter((op) => op.status === "skipped").length;
|
|
88
93
|
const result = {
|
|
89
94
|
pullRequest: context.pr,
|
|
90
95
|
operations,
|
|
@@ -93,17 +98,17 @@ class Guardian {
|
|
|
93
98
|
successCount,
|
|
94
99
|
errorCount,
|
|
95
100
|
skippedCount,
|
|
96
|
-
totalDuration: duration
|
|
97
|
-
}
|
|
101
|
+
totalDuration: duration,
|
|
102
|
+
},
|
|
98
103
|
};
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
logger.operation("PR Processing", "completed");
|
|
105
|
+
logger.success(`✅ Processing completed in ${Math.round(duration / 1000)}s: ` +
|
|
101
106
|
`${successCount} success, ${errorCount} errors, ${skippedCount} skipped`);
|
|
102
107
|
return result;
|
|
103
108
|
}
|
|
104
109
|
catch (error) {
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
logger.operation("PR Processing", "failed");
|
|
111
|
+
logger.error(`Processing failed: ${error.message}`);
|
|
107
112
|
throw error;
|
|
108
113
|
}
|
|
109
114
|
}
|
|
@@ -116,27 +121,27 @@ class Guardian {
|
|
|
116
121
|
try {
|
|
117
122
|
// Initial update
|
|
118
123
|
yield {
|
|
119
|
-
operation:
|
|
120
|
-
status:
|
|
121
|
-
message:
|
|
122
|
-
timestamp: new Date().toISOString()
|
|
124
|
+
operation: "all",
|
|
125
|
+
status: "started",
|
|
126
|
+
message: "Yama processing initiated",
|
|
127
|
+
timestamp: new Date().toISOString(),
|
|
123
128
|
};
|
|
124
129
|
// Context gathering phase
|
|
125
130
|
yield {
|
|
126
|
-
operation:
|
|
127
|
-
status:
|
|
131
|
+
operation: "all",
|
|
132
|
+
status: "progress",
|
|
128
133
|
progress: 10,
|
|
129
|
-
message:
|
|
130
|
-
timestamp: new Date().toISOString()
|
|
134
|
+
message: "Gathering unified context...",
|
|
135
|
+
timestamp: new Date().toISOString(),
|
|
131
136
|
};
|
|
132
137
|
const context = await this.gatherUnifiedContext(options);
|
|
133
138
|
yield {
|
|
134
|
-
operation:
|
|
135
|
-
status:
|
|
139
|
+
operation: "all",
|
|
140
|
+
status: "progress",
|
|
136
141
|
progress: 30,
|
|
137
142
|
message: `Context ready: PR #${context.pr.id}`,
|
|
138
143
|
data: { prId: context.pr.id, title: context.pr.title },
|
|
139
|
-
timestamp: new Date().toISOString()
|
|
144
|
+
timestamp: new Date().toISOString(),
|
|
140
145
|
};
|
|
141
146
|
// Execute operations with progress updates
|
|
142
147
|
const totalOps = options.operations.length;
|
|
@@ -144,29 +149,29 @@ class Guardian {
|
|
|
144
149
|
for (const operation of options.operations) {
|
|
145
150
|
yield {
|
|
146
151
|
operation,
|
|
147
|
-
status:
|
|
152
|
+
status: "started",
|
|
148
153
|
message: `Starting ${operation}...`,
|
|
149
|
-
timestamp: new Date().toISOString()
|
|
154
|
+
timestamp: new Date().toISOString(),
|
|
150
155
|
};
|
|
151
156
|
try {
|
|
152
157
|
const result = await this.executeOperation(operation, context, options);
|
|
153
|
-
if (result.status ===
|
|
158
|
+
if (result.status === "error") {
|
|
154
159
|
yield {
|
|
155
160
|
operation,
|
|
156
|
-
status:
|
|
161
|
+
status: "error",
|
|
157
162
|
message: `${operation} failed: ${result.error}`,
|
|
158
|
-
timestamp: new Date().toISOString()
|
|
163
|
+
timestamp: new Date().toISOString(),
|
|
159
164
|
};
|
|
160
165
|
}
|
|
161
166
|
else {
|
|
162
167
|
completedOps++;
|
|
163
168
|
yield {
|
|
164
169
|
operation,
|
|
165
|
-
status:
|
|
170
|
+
status: "completed",
|
|
166
171
|
progress: 30 + Math.round((completedOps / totalOps) * 60),
|
|
167
172
|
message: `${operation} completed`,
|
|
168
173
|
data: result,
|
|
169
|
-
timestamp: new Date().toISOString()
|
|
174
|
+
timestamp: new Date().toISOString(),
|
|
170
175
|
};
|
|
171
176
|
}
|
|
172
177
|
}
|
|
@@ -174,28 +179,28 @@ class Guardian {
|
|
|
174
179
|
// This catch is for unexpected errors that bypass executeOperation's own error handling
|
|
175
180
|
yield {
|
|
176
181
|
operation,
|
|
177
|
-
status:
|
|
182
|
+
status: "error",
|
|
178
183
|
message: `${operation} failed: ${error.message}`,
|
|
179
|
-
timestamp: new Date().toISOString()
|
|
184
|
+
timestamp: new Date().toISOString(),
|
|
180
185
|
};
|
|
181
186
|
}
|
|
182
187
|
}
|
|
183
188
|
// Final completion
|
|
184
189
|
const duration = Date.now() - startTime;
|
|
185
190
|
yield {
|
|
186
|
-
operation:
|
|
187
|
-
status:
|
|
191
|
+
operation: "all",
|
|
192
|
+
status: "completed",
|
|
188
193
|
progress: 100,
|
|
189
194
|
message: `Processing completed in ${Math.round(duration / 1000)}s`,
|
|
190
|
-
timestamp: new Date().toISOString()
|
|
195
|
+
timestamp: new Date().toISOString(),
|
|
191
196
|
};
|
|
192
197
|
}
|
|
193
198
|
catch (error) {
|
|
194
199
|
yield {
|
|
195
|
-
operation:
|
|
196
|
-
status:
|
|
200
|
+
operation: "all",
|
|
201
|
+
status: "error",
|
|
197
202
|
message: `Processing failed: ${error.message}`,
|
|
198
|
-
timestamp: new Date().toISOString()
|
|
203
|
+
timestamp: new Date().toISOString(),
|
|
199
204
|
};
|
|
200
205
|
}
|
|
201
206
|
}
|
|
@@ -207,22 +212,22 @@ class Guardian {
|
|
|
207
212
|
workspace: options.workspace,
|
|
208
213
|
repository: options.repository,
|
|
209
214
|
branch: options.branch,
|
|
210
|
-
pullRequestId: options.pullRequestId
|
|
215
|
+
pullRequestId: options.pullRequestId,
|
|
211
216
|
};
|
|
212
217
|
// Check if we have cached context first
|
|
213
218
|
const cachedContext = await this.contextGatherer.getCachedContext(identifier);
|
|
214
219
|
if (cachedContext && options.config?.cache?.enabled !== false) {
|
|
215
|
-
|
|
220
|
+
logger.debug("✓ Using cached context");
|
|
216
221
|
return cachedContext;
|
|
217
222
|
}
|
|
218
223
|
// Determine what operations need diff data
|
|
219
|
-
const needsDiff = options.operations.some(op => op ===
|
|
224
|
+
const needsDiff = options.operations.some((op) => op === "review" || op === "security-scan" || op === "all");
|
|
220
225
|
const contextOptions = {
|
|
221
226
|
excludePatterns: this.config.features.codeReview.excludePatterns,
|
|
222
227
|
contextLines: this.config.features.codeReview.contextLines,
|
|
223
228
|
forceRefresh: false,
|
|
224
229
|
includeDiff: needsDiff,
|
|
225
|
-
diffStrategyConfig: this.config.features.diffStrategy
|
|
230
|
+
diffStrategyConfig: this.config.features.diffStrategy,
|
|
226
231
|
};
|
|
227
232
|
return await this.contextGatherer.gatherContext(identifier, contextOptions);
|
|
228
233
|
}
|
|
@@ -234,37 +239,37 @@ class Guardian {
|
|
|
234
239
|
try {
|
|
235
240
|
let data;
|
|
236
241
|
switch (operation) {
|
|
237
|
-
case
|
|
242
|
+
case "review":
|
|
238
243
|
data = await this.executeCodeReview(context, options);
|
|
239
244
|
break;
|
|
240
|
-
case
|
|
245
|
+
case "enhance-description":
|
|
241
246
|
data = await this.executeDescriptionEnhancement(context, options);
|
|
242
247
|
break;
|
|
243
|
-
case
|
|
248
|
+
case "security-scan":
|
|
244
249
|
// TODO: Implement in future phases
|
|
245
|
-
throw new Error(
|
|
246
|
-
case
|
|
250
|
+
throw new Error("Security scan not implemented in Phase 1");
|
|
251
|
+
case "analytics":
|
|
247
252
|
// TODO: Implement in future phases
|
|
248
|
-
throw new Error(
|
|
253
|
+
throw new Error("Analytics not implemented in Phase 1");
|
|
249
254
|
default:
|
|
250
255
|
throw new Error(`Unknown operation: ${operation}`);
|
|
251
256
|
}
|
|
252
257
|
return {
|
|
253
258
|
operation,
|
|
254
|
-
status:
|
|
259
|
+
status: "success",
|
|
255
260
|
data,
|
|
256
261
|
duration: Date.now() - startTime,
|
|
257
|
-
timestamp: new Date().toISOString()
|
|
262
|
+
timestamp: new Date().toISOString(),
|
|
258
263
|
};
|
|
259
264
|
}
|
|
260
265
|
catch (error) {
|
|
261
|
-
|
|
266
|
+
logger.error(`Operation ${operation} failed: ${error.message}`);
|
|
262
267
|
return {
|
|
263
268
|
operation,
|
|
264
|
-
status:
|
|
269
|
+
status: "error",
|
|
265
270
|
error: error.message,
|
|
266
271
|
duration: Date.now() - startTime,
|
|
267
|
-
timestamp: new Date().toISOString()
|
|
272
|
+
timestamp: new Date().toISOString(),
|
|
268
273
|
};
|
|
269
274
|
}
|
|
270
275
|
}
|
|
@@ -273,18 +278,18 @@ class Guardian {
|
|
|
273
278
|
*/
|
|
274
279
|
async executeCodeReview(context, options) {
|
|
275
280
|
if (!this.config.features.codeReview.enabled) {
|
|
276
|
-
|
|
277
|
-
return { skipped: true, reason:
|
|
281
|
+
logger.info("Code review is disabled in configuration");
|
|
282
|
+
return { skipped: true, reason: "disabled in config" };
|
|
278
283
|
}
|
|
279
|
-
|
|
284
|
+
logger.phase("🔍 Executing code review...");
|
|
280
285
|
const reviewOptions = {
|
|
281
286
|
workspace: context.identifier.workspace,
|
|
282
287
|
repository: context.identifier.repository,
|
|
283
288
|
pullRequestId: context.identifier.pullRequestId,
|
|
284
289
|
dryRun: options.dryRun,
|
|
285
|
-
verbose:
|
|
290
|
+
verbose: logger.getConfig().verbose,
|
|
286
291
|
excludePatterns: this.config.features.codeReview.excludePatterns,
|
|
287
|
-
contextLines: this.config.features.codeReview.contextLines
|
|
292
|
+
contextLines: this.config.features.codeReview.contextLines,
|
|
288
293
|
};
|
|
289
294
|
// Use the already gathered context instead of gathering again
|
|
290
295
|
return await this.codeReviewer.reviewCodeWithContext(context, reviewOptions);
|
|
@@ -294,19 +299,19 @@ class Guardian {
|
|
|
294
299
|
*/
|
|
295
300
|
async executeDescriptionEnhancement(context, options) {
|
|
296
301
|
if (!this.config.features.descriptionEnhancement.enabled) {
|
|
297
|
-
|
|
298
|
-
return { skipped: true, reason:
|
|
302
|
+
logger.info("Description enhancement is disabled in configuration");
|
|
303
|
+
return { skipped: true, reason: "disabled in config" };
|
|
299
304
|
}
|
|
300
|
-
|
|
305
|
+
logger.phase("📝 Executing description enhancement...");
|
|
301
306
|
const enhancementOptions = {
|
|
302
307
|
workspace: context.identifier.workspace,
|
|
303
308
|
repository: context.identifier.repository,
|
|
304
309
|
pullRequestId: context.identifier.pullRequestId,
|
|
305
310
|
dryRun: options.dryRun,
|
|
306
|
-
verbose:
|
|
311
|
+
verbose: logger.getConfig().verbose,
|
|
307
312
|
preserveContent: this.config.features.descriptionEnhancement.preserveContent,
|
|
308
313
|
ensureRequiredSections: true,
|
|
309
|
-
customSections: this.config.features.descriptionEnhancement.requiredSections
|
|
314
|
+
customSections: this.config.features.descriptionEnhancement.requiredSections,
|
|
310
315
|
};
|
|
311
316
|
// Use the already gathered context instead of gathering again
|
|
312
317
|
return await this.descriptionEnhancer.enhanceWithContext(context, enhancementOptions);
|
|
@@ -323,22 +328,22 @@ class Guardian {
|
|
|
323
328
|
workspace: options.workspace,
|
|
324
329
|
repository: options.repository,
|
|
325
330
|
branch: options.branch,
|
|
326
|
-
pullRequestId: options.pullRequestId
|
|
331
|
+
pullRequestId: options.pullRequestId,
|
|
327
332
|
};
|
|
328
|
-
|
|
333
|
+
logger.operation("Code Review", "started");
|
|
329
334
|
try {
|
|
330
335
|
// Gather context specifically for code review
|
|
331
336
|
const context = await this.contextGatherer.gatherContext(identifier, {
|
|
332
337
|
excludePatterns: options.excludePatterns,
|
|
333
338
|
contextLines: options.contextLines,
|
|
334
|
-
includeDiff: true
|
|
339
|
+
includeDiff: true,
|
|
335
340
|
});
|
|
336
341
|
const result = await this.codeReviewer.reviewCodeWithContext(context, options);
|
|
337
|
-
|
|
342
|
+
logger.operation("Code Review", "completed");
|
|
338
343
|
return result;
|
|
339
344
|
}
|
|
340
345
|
catch (error) {
|
|
341
|
-
|
|
346
|
+
logger.operation("Code Review", "failed");
|
|
342
347
|
throw error;
|
|
343
348
|
}
|
|
344
349
|
}
|
|
@@ -351,20 +356,20 @@ class Guardian {
|
|
|
351
356
|
workspace: options.workspace,
|
|
352
357
|
repository: options.repository,
|
|
353
358
|
branch: options.branch,
|
|
354
|
-
pullRequestId: options.pullRequestId
|
|
359
|
+
pullRequestId: options.pullRequestId,
|
|
355
360
|
};
|
|
356
|
-
|
|
361
|
+
logger.operation("Description Enhancement", "started");
|
|
357
362
|
try {
|
|
358
363
|
// Gather context specifically for description enhancement
|
|
359
364
|
const context = await this.contextGatherer.gatherContext(identifier, {
|
|
360
|
-
includeDiff: true // Description enhancement may need to see changes
|
|
365
|
+
includeDiff: true, // Description enhancement may need to see changes
|
|
361
366
|
});
|
|
362
367
|
const result = await this.descriptionEnhancer.enhanceWithContext(context, options);
|
|
363
|
-
|
|
368
|
+
logger.operation("Description Enhancement", "completed");
|
|
364
369
|
return result;
|
|
365
370
|
}
|
|
366
371
|
catch (error) {
|
|
367
|
-
|
|
372
|
+
logger.operation("Description Enhancement", "failed");
|
|
368
373
|
throw error;
|
|
369
374
|
}
|
|
370
375
|
}
|
|
@@ -379,17 +384,17 @@ class Guardian {
|
|
|
379
384
|
// Check cache
|
|
380
385
|
components.cache = {
|
|
381
386
|
healthy: true,
|
|
382
|
-
stats:
|
|
387
|
+
stats: cache.stats(),
|
|
383
388
|
};
|
|
384
389
|
// Check NeuroLink (if initialized)
|
|
385
390
|
components.neurolink = {
|
|
386
391
|
healthy: true,
|
|
387
|
-
initialized: !!this.neurolink
|
|
392
|
+
initialized: !!this.neurolink,
|
|
388
393
|
};
|
|
389
394
|
const allHealthy = Object.values(components).every((comp) => comp.healthy);
|
|
390
395
|
return {
|
|
391
396
|
healthy: allHealthy,
|
|
392
|
-
components
|
|
397
|
+
components,
|
|
393
398
|
};
|
|
394
399
|
}
|
|
395
400
|
catch (error) {
|
|
@@ -397,8 +402,8 @@ class Guardian {
|
|
|
397
402
|
healthy: false,
|
|
398
403
|
components: {
|
|
399
404
|
...components,
|
|
400
|
-
error: error.message
|
|
401
|
-
}
|
|
405
|
+
error: error.message,
|
|
406
|
+
},
|
|
402
407
|
};
|
|
403
408
|
}
|
|
404
409
|
}
|
|
@@ -410,22 +415,22 @@ class Guardian {
|
|
|
410
415
|
initialized: this.initialized,
|
|
411
416
|
config: {
|
|
412
417
|
features: Object.keys(this.config.features || {}),
|
|
413
|
-
cacheEnabled: this.config.cache?.enabled
|
|
418
|
+
cacheEnabled: this.config.cache?.enabled,
|
|
414
419
|
},
|
|
415
420
|
providers: {
|
|
416
421
|
bitbucket: this.bitbucketProvider?.getStats(),
|
|
417
|
-
context: this.contextGatherer?.getStats()
|
|
422
|
+
context: this.contextGatherer?.getStats(),
|
|
418
423
|
},
|
|
419
|
-
cache:
|
|
424
|
+
cache: cache.stats(),
|
|
420
425
|
};
|
|
421
426
|
}
|
|
422
427
|
/**
|
|
423
428
|
* Clear all caches
|
|
424
429
|
*/
|
|
425
430
|
clearCache() {
|
|
426
|
-
|
|
431
|
+
cache.clear();
|
|
427
432
|
this.bitbucketProvider?.clearCache();
|
|
428
|
-
|
|
433
|
+
logger.info("All caches cleared");
|
|
429
434
|
}
|
|
430
435
|
/**
|
|
431
436
|
* Ensure Guardian is initialized
|
|
@@ -439,19 +444,18 @@ class Guardian {
|
|
|
439
444
|
* Shutdown Guardian gracefully
|
|
440
445
|
*/
|
|
441
446
|
async shutdown() {
|
|
442
|
-
|
|
447
|
+
logger.info("Shutting down Yama...");
|
|
443
448
|
// Clear caches
|
|
444
449
|
this.clearCache();
|
|
445
450
|
// Reset state
|
|
446
451
|
this.initialized = false;
|
|
447
|
-
|
|
452
|
+
logger.success("Yama shutdown complete");
|
|
448
453
|
}
|
|
449
454
|
}
|
|
450
|
-
exports.Guardian = Guardian;
|
|
451
455
|
// Export factory function
|
|
452
|
-
function createGuardian(config) {
|
|
456
|
+
export function createGuardian(config) {
|
|
453
457
|
return new Guardian(config);
|
|
454
458
|
}
|
|
455
459
|
// Export default instance
|
|
456
|
-
|
|
460
|
+
export const guardian = new Guardian();
|
|
457
461
|
//# sourceMappingURL=Guardian.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Enhanced Bitbucket Provider - Optimized from both pr-police.js and pr-describe.js
|
|
3
3
|
* Provides unified, cached, and optimized Bitbucket operations
|
|
4
4
|
*/
|
|
5
|
-
import { PRIdentifier, PRInfo, PRDiff, GitCredentials } from
|
|
5
|
+
import { PRIdentifier, PRInfo, PRDiff, GitCredentials } from "../../types/index.js";
|
|
6
6
|
export interface BitbucketMCPResponse {
|
|
7
7
|
content?: Array<{
|
|
8
8
|
text?: string;
|
|
@@ -61,13 +61,13 @@ export declare class BitbucketProvider {
|
|
|
61
61
|
addComment(identifier: PRIdentifier, commentText: string, options?: {
|
|
62
62
|
filePath?: string;
|
|
63
63
|
lineNumber?: number;
|
|
64
|
-
lineType?:
|
|
64
|
+
lineType?: "ADDED" | "REMOVED" | "CONTEXT";
|
|
65
65
|
codeSnippet?: string;
|
|
66
66
|
searchContext?: {
|
|
67
67
|
before: string[];
|
|
68
68
|
after: string[];
|
|
69
69
|
};
|
|
70
|
-
matchStrategy?:
|
|
70
|
+
matchStrategy?: "exact" | "best" | "strict";
|
|
71
71
|
suggestion?: string;
|
|
72
72
|
}): Promise<{
|
|
73
73
|
success: boolean;
|