@juspay/yama 1.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.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Yama CLI - Enhanced command line interface
4
+ * Provides backward compatibility with pr-police.js and pr-describe.js
5
+ * Plus new unified commands for the enhanced functionality
6
+ */
7
+ /**
8
+ * Main execution
9
+ */
10
+ declare function main(): void;
11
+ export { main };
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,541 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * Yama CLI - Enhanced command line interface
5
+ * Provides backward compatibility with pr-police.js and pr-describe.js
6
+ * Plus new unified commands for the enhanced functionality
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.main = main;
13
+ const commander_1 = require("commander");
14
+ const chalk_1 = __importDefault(require("chalk"));
15
+ const ora_1 = __importDefault(require("ora"));
16
+ const inquirer_1 = __importDefault(require("inquirer"));
17
+ const dotenv_1 = __importDefault(require("dotenv"));
18
+ const Guardian_1 = require("../core/Guardian");
19
+ const Logger_1 = require("../utils/Logger");
20
+ const ConfigManager_1 = require("../utils/ConfigManager");
21
+ const Cache_1 = require("../utils/Cache");
22
+ // Load environment variables
23
+ dotenv_1.default.config();
24
+ const program = new commander_1.Command();
25
+ // Package info
26
+ const packageInfo = {
27
+ name: "@juspay/yama",
28
+ version: "1.1.0",
29
+ description: "Enterprise-grade Pull Request automation toolkit",
30
+ };
31
+ /**
32
+ * Main CLI setup
33
+ */
34
+ function setupCLI() {
35
+ program
36
+ .name("yama")
37
+ .description(packageInfo.description)
38
+ .version(packageInfo.version);
39
+ // Global options
40
+ program
41
+ .option("-v, --verbose", "Enable verbose logging")
42
+ .option("-c, --config <path>", "Path to configuration file")
43
+ .option("--dry-run", "Preview mode - no changes made")
44
+ .option("--no-cache", "Disable caching");
45
+ // Configure help options (removed custom formatter to fix recursion)
46
+ program.configureHelp({
47
+ sortSubcommands: true,
48
+ });
49
+ // Setup commands
50
+ setupProcessCommand();
51
+ setupReviewCommand();
52
+ setupEnhanceCommand();
53
+ setupInitCommand();
54
+ setupStatusCommand();
55
+ setupCacheCommand();
56
+ setupConfigCommand();
57
+ // Backward compatibility aliases
58
+ setupBackwardCompatibility();
59
+ }
60
+ /**
61
+ * Main unified processing command
62
+ */
63
+ function setupProcessCommand() {
64
+ program
65
+ .command("process")
66
+ .description("Process PR with multiple operations using unified context (NEW)")
67
+ .requiredOption("-w, --workspace <workspace>", "Bitbucket workspace")
68
+ .requiredOption("-r, --repository <repository>", "Repository name")
69
+ .option("-b, --branch <branch>", "Branch name")
70
+ .option("-p, --pr <id>", "Pull request ID")
71
+ .option("-o, --operations <operations>", "Operations to perform (review,enhance-description,all)", "all")
72
+ .option("--exclude <patterns>", "Comma-separated exclude patterns", "*.lock,*.svg")
73
+ .option("--context-lines <number>", "Context lines for diff", "3")
74
+ .action(async (options) => {
75
+ try {
76
+ await handleGlobalOptions(options);
77
+ const operations = parseOperations(options.operations);
78
+ const operationOptions = {
79
+ workspace: options.workspace,
80
+ repository: options.repository,
81
+ branch: options.branch,
82
+ pullRequestId: options.pr,
83
+ operations,
84
+ dryRun: options.dryRun,
85
+ verbose: options.verbose,
86
+ };
87
+ const guardian = new Guardian_1.Guardian();
88
+ await guardian.initialize(options.config);
89
+ if (options.verbose) {
90
+ // Use streaming for verbose mode
91
+ console.log(chalk_1.default.blue("\n📡 Starting streaming processing...\n"));
92
+ for await (const update of guardian.processPRStream(operationOptions)) {
93
+ logStreamUpdate(update);
94
+ }
95
+ }
96
+ else {
97
+ // Use regular processing
98
+ const spinner = (0, ora_1.default)("Processing PR...").start();
99
+ try {
100
+ const result = await guardian.processPR(operationOptions);
101
+ spinner.succeed("Processing completed");
102
+ printProcessResult(result);
103
+ }
104
+ catch (error) {
105
+ spinner.fail("Processing failed");
106
+ throw error;
107
+ }
108
+ }
109
+ }
110
+ catch (error) {
111
+ console.error(chalk_1.default.red(`❌ Error: ${error.message}`));
112
+ process.exit(1);
113
+ }
114
+ });
115
+ }
116
+ /**
117
+ * Code review command (backward compatible with pr-police.js)
118
+ */
119
+ function setupReviewCommand() {
120
+ program
121
+ .command("review")
122
+ .alias("police") // Backward compatibility
123
+ .description("AI-powered code review (equivalent to pr-police.js)")
124
+ .requiredOption("-w, --workspace <workspace>", "Bitbucket workspace")
125
+ .requiredOption("-r, --repository <repository>", "Repository name")
126
+ .option("-b, --branch <branch>", "Branch name")
127
+ .option("-p, --pr <id>", "Pull request ID")
128
+ .option("--exclude <patterns>", "Comma-separated exclude patterns", "*.lock,*.svg")
129
+ .option("--context-lines <number>", "Context lines for diff", "3")
130
+ .action(async (options) => {
131
+ try {
132
+ await handleGlobalOptions(options);
133
+ const reviewOptions = {
134
+ workspace: options.workspace,
135
+ repository: options.repository,
136
+ branch: options.branch,
137
+ pullRequestId: options.pr,
138
+ dryRun: options.dryRun,
139
+ verbose: options.verbose,
140
+ excludePatterns: options.exclude
141
+ ?.split(",")
142
+ .map((p) => p.trim()),
143
+ contextLines: parseInt(options.contextLines),
144
+ };
145
+ const guardian = new Guardian_1.Guardian();
146
+ await guardian.initialize(options.config);
147
+ const spinner = (0, ora_1.default)("Conducting code review...").start();
148
+ try {
149
+ const result = await guardian.reviewCode(reviewOptions);
150
+ spinner.succeed("Code review completed");
151
+ printReviewResult(result);
152
+ }
153
+ catch (error) {
154
+ spinner.fail("Code review failed");
155
+ throw error;
156
+ }
157
+ }
158
+ catch (error) {
159
+ console.error(chalk_1.default.red(`❌ Error: ${error.message}`));
160
+ process.exit(1);
161
+ }
162
+ });
163
+ }
164
+ /**
165
+ * Description enhancement command (backward compatible with pr-describe.js)
166
+ */
167
+ function setupEnhanceCommand() {
168
+ program
169
+ .command("enhance")
170
+ .alias("scribe") // Backward compatibility
171
+ .description("AI-powered description enhancement (equivalent to pr-describe.js)")
172
+ .requiredOption("-w, --workspace <workspace>", "Bitbucket workspace")
173
+ .requiredOption("-r, --repository <repository>", "Repository name")
174
+ .option("-b, --branch <branch>", "Branch name")
175
+ .option("-p, --pr <id>", "Pull request ID")
176
+ .option("--no-preserve", "Disable content preservation")
177
+ .action(async (options) => {
178
+ try {
179
+ await handleGlobalOptions(options);
180
+ const enhancementOptions = {
181
+ workspace: options.workspace,
182
+ repository: options.repository,
183
+ branch: options.branch,
184
+ pullRequestId: options.pr,
185
+ dryRun: options.dryRun,
186
+ verbose: options.verbose,
187
+ preserveContent: options.preserve !== false,
188
+ ensureRequiredSections: true,
189
+ };
190
+ const guardian = new Guardian_1.Guardian();
191
+ await guardian.initialize(options.config);
192
+ const spinner = (0, ora_1.default)("Enhancing PR description...").start();
193
+ try {
194
+ const result = await guardian.enhanceDescription(enhancementOptions);
195
+ spinner.succeed("Description enhancement completed");
196
+ printEnhancementResult(result);
197
+ }
198
+ catch (error) {
199
+ spinner.fail("Description enhancement failed");
200
+ throw error;
201
+ }
202
+ }
203
+ catch (error) {
204
+ console.error(chalk_1.default.red(`❌ Error: ${error.message}`));
205
+ process.exit(1);
206
+ }
207
+ });
208
+ }
209
+ /**
210
+ * Initialize configuration command
211
+ */
212
+ function setupInitCommand() {
213
+ program
214
+ .command("init")
215
+ .description("Initialize Yama configuration")
216
+ .option("-o, --output <path>", "Output configuration file path")
217
+ .option("-i, --interactive", "Interactive configuration setup")
218
+ .action(async (options) => {
219
+ try {
220
+ if (options.interactive) {
221
+ await interactiveInit();
222
+ }
223
+ else {
224
+ const configPath = await ConfigManager_1.configManager.createDefaultConfig(options.output);
225
+ console.log(chalk_1.default.green(`✅ Configuration file created: ${configPath}`));
226
+ console.log(chalk_1.default.yellow("💡 Edit the configuration file to customize settings"));
227
+ console.log(chalk_1.default.blue("📖 Visit https://github.com/juspay/yama for documentation"));
228
+ }
229
+ }
230
+ catch (error) {
231
+ console.error(chalk_1.default.red(`❌ Error: ${error.message}`));
232
+ process.exit(1);
233
+ }
234
+ });
235
+ }
236
+ /**
237
+ * Status and health check command
238
+ */
239
+ function setupStatusCommand() {
240
+ program
241
+ .command("status")
242
+ .description("Check Yama status and health")
243
+ .option("-d, --detailed", "Show detailed status information")
244
+ .action(async (options) => {
245
+ try {
246
+ await handleGlobalOptions(options);
247
+ const guardian = new Guardian_1.Guardian();
248
+ await guardian.initialize(options.config);
249
+ const health = await guardian.healthCheck();
250
+ const stats = guardian.getStats();
251
+ console.log(chalk_1.default.cyan("\n🛡️ Yama Status\n"));
252
+ // Health status
253
+ const healthEmoji = health.healthy ? "✅" : "❌";
254
+ console.log(`${healthEmoji} Overall Health: ${health.healthy ? "Healthy" : "Issues Detected"}`);
255
+ // Component status
256
+ console.log("\n📊 Component Status:");
257
+ Object.entries(health.components).forEach(([component, status]) => {
258
+ const emoji = status.healthy ? "✅" : "❌";
259
+ console.log(` ${emoji} ${component}: ${status.healthy ? "OK" : "Error"}`);
260
+ });
261
+ // Statistics
262
+ if (options.detailed) {
263
+ console.log("\n📈 Statistics:");
264
+ console.log(JSON.stringify(stats, null, 2));
265
+ }
266
+ // Cache status
267
+ const cacheStats = Cache_1.cache.stats();
268
+ console.log(`\n💾 Cache: ${cacheStats.keys} keys, ${cacheStats.hits} hits, ${Math.round(Cache_1.cache.getHitRatio() * 100)}% hit ratio`);
269
+ }
270
+ catch (error) {
271
+ console.error(chalk_1.default.red(`❌ Error: ${error.message}`));
272
+ process.exit(1);
273
+ }
274
+ });
275
+ }
276
+ /**
277
+ * Cache management command
278
+ */
279
+ function setupCacheCommand() {
280
+ const cacheCommand = program
281
+ .command("cache")
282
+ .description("Cache management operations");
283
+ cacheCommand
284
+ .command("clear")
285
+ .description("Clear all caches")
286
+ .action(() => {
287
+ Cache_1.cache.clear();
288
+ console.log(chalk_1.default.green("✅ All caches cleared"));
289
+ });
290
+ cacheCommand
291
+ .command("stats")
292
+ .description("Show cache statistics")
293
+ .action(() => {
294
+ const stats = Cache_1.cache.stats();
295
+ const detailed = Cache_1.cache.debug();
296
+ console.log(chalk_1.default.cyan("\n💾 Cache Statistics\n"));
297
+ console.log(`Keys: ${stats.keys}`);
298
+ console.log(`Hits: ${stats.hits}`);
299
+ console.log(`Misses: ${stats.misses}`);
300
+ console.log(`Hit Ratio: ${Math.round(Cache_1.cache.getHitRatio() * 100)}%`);
301
+ console.log("\n📊 Detailed Stats:");
302
+ console.log(JSON.stringify(detailed, null, 2));
303
+ });
304
+ }
305
+ /**
306
+ * Configuration management command
307
+ */
308
+ function setupConfigCommand() {
309
+ const configCommand = program
310
+ .command("config")
311
+ .description("Configuration management");
312
+ configCommand
313
+ .command("validate")
314
+ .description("Validate configuration file")
315
+ .option("-c, --config <path>", "Configuration file path")
316
+ .action(async (options) => {
317
+ try {
318
+ await ConfigManager_1.configManager.loadConfig(options.config);
319
+ console.log(chalk_1.default.green("✅ Configuration is valid"));
320
+ }
321
+ catch (error) {
322
+ console.error(chalk_1.default.red(`❌ Configuration error: ${error.message}`));
323
+ process.exit(1);
324
+ }
325
+ });
326
+ configCommand
327
+ .command("show")
328
+ .description("Show current configuration")
329
+ .option("-c, --config <path>", "Configuration file path")
330
+ .action(async (options) => {
331
+ try {
332
+ const config = await ConfigManager_1.configManager.loadConfig(options.config);
333
+ console.log(chalk_1.default.cyan("\n⚙️ Current Configuration\n"));
334
+ // Mask sensitive information
335
+ const sanitizedConfig = { ...config };
336
+ if (sanitizedConfig.providers?.git?.credentials?.token) {
337
+ sanitizedConfig.providers.git.credentials.token = "***MASKED***";
338
+ }
339
+ console.log(JSON.stringify(sanitizedConfig, null, 2));
340
+ }
341
+ catch (error) {
342
+ console.error(chalk_1.default.red(`❌ Error: ${error.message}`));
343
+ process.exit(1);
344
+ }
345
+ });
346
+ }
347
+ /**
348
+ * Backward compatibility with original scripts
349
+ */
350
+ function setupBackwardCompatibility() {
351
+ // pr-police.js compatibility
352
+ if (process.argv[1]?.includes("pr-police")) {
353
+ // Redirect to review command
354
+ const args = process.argv.slice(2);
355
+ process.argv = ["node", "yama", "review", ...args];
356
+ }
357
+ // pr-describe.js / pr-scribe.js compatibility
358
+ if (process.argv[1]?.includes("pr-scribe") ||
359
+ process.argv[1]?.includes("pr-describe")) {
360
+ // Redirect to enhance command
361
+ const args = process.argv.slice(2);
362
+ process.argv = ["node", "yama", "enhance", ...args];
363
+ }
364
+ }
365
+ /**
366
+ * Utility functions
367
+ */
368
+ async function handleGlobalOptions(options) {
369
+ // Set up logging
370
+ if (options.verbose) {
371
+ Logger_1.logger.setVerbose(true);
372
+ Logger_1.logger.setLevel("debug");
373
+ }
374
+ // Handle cache disabling
375
+ if (options.cache === false) {
376
+ Cache_1.cache.clear();
377
+ }
378
+ }
379
+ function parseOperations(operationsStr) {
380
+ const operationMap = {
381
+ review: "review",
382
+ enhance: "enhance-description",
383
+ "enhance-description": "enhance-description",
384
+ security: "security-scan",
385
+ "security-scan": "security-scan",
386
+ analytics: "analytics",
387
+ all: "all",
388
+ };
389
+ return operationsStr
390
+ .split(",")
391
+ .map((op) => op.trim())
392
+ .map((op) => operationMap[op] || op)
393
+ .filter((op) => op);
394
+ }
395
+ function logStreamUpdate(update) {
396
+ const timestamp = new Date(update.timestamp).toLocaleTimeString();
397
+ const progressStr = update.progress ? ` (${update.progress}%)` : "";
398
+ switch (update.status) {
399
+ case "started":
400
+ console.log(chalk_1.default.blue(`🚀 [${timestamp}] ${update.operation}: ${update.message}`));
401
+ break;
402
+ case "progress":
403
+ console.log(chalk_1.default.yellow(`🔄 [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
404
+ break;
405
+ case "completed":
406
+ console.log(chalk_1.default.green(`✅ [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
407
+ break;
408
+ case "error":
409
+ console.log(chalk_1.default.red(`❌ [${timestamp}] ${update.operation}: ${update.message}`));
410
+ break;
411
+ }
412
+ }
413
+ function printProcessResult(result) {
414
+ console.log(chalk_1.default.cyan("\n🛡️ Yama Process Result\n"));
415
+ console.log(`PR: #${result.pullRequest.id} - ${result.pullRequest.title}`);
416
+ console.log(`Author: ${result.pullRequest.author}`);
417
+ console.log(`Operations: ${result.operations.length}`);
418
+ console.log("\n📊 Summary:");
419
+ console.log(`✅ Success: ${result.summary.successCount}`);
420
+ console.log(`❌ Errors: ${result.summary.errorCount}`);
421
+ console.log(`⏭️ Skipped: ${result.summary.skippedCount}`);
422
+ console.log(`⏱️ Total Duration: ${Math.round(result.summary.totalDuration / 1000)}s`);
423
+ // Show individual operation results
424
+ console.log("\n📋 Operations:");
425
+ result.operations.forEach((op) => {
426
+ const emoji = op.status === "success" ? "✅" : op.status === "error" ? "❌" : "⏭️";
427
+ console.log(` ${emoji} ${op.operation}: ${op.status} (${Math.round(op.duration / 1000)}s)`);
428
+ if (op.error) {
429
+ console.log(chalk_1.default.red(` Error: ${op.error}`));
430
+ }
431
+ });
432
+ }
433
+ function printReviewResult(result) {
434
+ const stats = result.statistics;
435
+ console.log(chalk_1.default.cyan("\n🛡️ Code Review Results\n"));
436
+ console.log(`📊 Total Issues: ${stats.totalIssues}`);
437
+ console.log(`🚨 Critical: ${stats.criticalCount}`);
438
+ console.log(`⚠️ Major: ${stats.majorCount}`);
439
+ console.log(`📝 Minor: ${stats.minorCount}`);
440
+ console.log(`💡 Suggestions: ${stats.suggestionCount}`);
441
+ console.log(`📁 Files Reviewed: ${stats.filesReviewed}`);
442
+ if (stats.criticalCount > 0) {
443
+ console.log(chalk_1.default.red("\n⛔ CRITICAL issues found - must fix before merge!"));
444
+ }
445
+ else if (stats.majorCount > 0) {
446
+ console.log(chalk_1.default.yellow("\n⚠️ Major issues found - should fix before merge"));
447
+ }
448
+ else if (stats.minorCount > 0) {
449
+ console.log(chalk_1.default.blue("\n📝 Minor improvements suggested"));
450
+ }
451
+ else {
452
+ console.log(chalk_1.default.green("\n✅ Code quality approved!"));
453
+ }
454
+ }
455
+ function printEnhancementResult(result) {
456
+ console.log(chalk_1.default.cyan("\n📝 Description Enhancement Results\n"));
457
+ console.log(`📏 Original Length: ${result.statistics.originalLength} characters`);
458
+ console.log(`📏 Enhanced Length: ${result.statistics.enhancedLength} characters`);
459
+ console.log(`📋 Sections Completed: ${result.statistics.completedSections}/${result.statistics.totalSections}`);
460
+ if (result.sectionsAdded.length > 0) {
461
+ console.log(`➕ Sections Added: ${result.sectionsAdded.join(", ")}`);
462
+ }
463
+ if (result.sectionsEnhanced.length > 0) {
464
+ console.log(`✨ Sections Enhanced: ${result.sectionsEnhanced.join(", ")}`);
465
+ }
466
+ console.log(`📎 Content Preserved: ${result.preservedItems.media} media, ${result.preservedItems.files} files, ${result.preservedItems.links} links`);
467
+ if (result.statistics.completedSections === result.statistics.totalSections) {
468
+ console.log(chalk_1.default.green("\n✅ All required sections completed!"));
469
+ }
470
+ else {
471
+ console.log(chalk_1.default.yellow("\n⚠️ Some required sections may still need attention"));
472
+ }
473
+ }
474
+ async function interactiveInit() {
475
+ console.log(chalk_1.default.cyan("\n🛡️ Yama Interactive Setup\n"));
476
+ await inquirer_1.default.prompt([
477
+ {
478
+ type: "input",
479
+ name: "workspace",
480
+ message: "Default Bitbucket workspace:",
481
+ default: "YOUR_WORKSPACE",
482
+ },
483
+ {
484
+ type: "input",
485
+ name: "baseUrl",
486
+ message: "Bitbucket server URL:",
487
+ default: "https://your-bitbucket-server.com",
488
+ },
489
+ {
490
+ type: "list",
491
+ name: "aiProvider",
492
+ message: "AI provider:",
493
+ choices: ["auto", "google-ai", "openai", "anthropic"],
494
+ default: "auto",
495
+ },
496
+ {
497
+ type: "confirm",
498
+ name: "enableAnalytics",
499
+ message: "Enable AI analytics:",
500
+ default: true,
501
+ },
502
+ {
503
+ type: "confirm",
504
+ name: "enableCache",
505
+ message: "Enable caching:",
506
+ default: true,
507
+ },
508
+ ]);
509
+ const configPath = await ConfigManager_1.configManager.createDefaultConfig();
510
+ console.log(chalk_1.default.green(`\n✅ Configuration created: ${configPath}`));
511
+ console.log(chalk_1.default.yellow("💡 Don't forget to set your environment variables:"));
512
+ console.log(chalk_1.default.blue(" BITBUCKET_USERNAME=your-username"));
513
+ console.log(chalk_1.default.blue(" BITBUCKET_TOKEN=your-token"));
514
+ console.log(chalk_1.default.blue(" GOOGLE_AI_API_KEY=your-api-key"));
515
+ }
516
+ /**
517
+ * Main execution
518
+ */
519
+ function main() {
520
+ setupCLI();
521
+ // Parse command line arguments
522
+ program.parse();
523
+ // Show help if no command provided
524
+ if (!process.argv.slice(2).length) {
525
+ program.outputHelp();
526
+ }
527
+ }
528
+ // Handle uncaught errors
529
+ process.on("uncaughtException", (error) => {
530
+ console.error(chalk_1.default.red(`\n💥 Uncaught Exception: ${error.message}`));
531
+ process.exit(1);
532
+ });
533
+ process.on("unhandledRejection", (reason) => {
534
+ console.error(chalk_1.default.red(`\n💥 Unhandled Rejection: ${reason}`));
535
+ process.exit(1);
536
+ });
537
+ // Run if this is the main module
538
+ if (require.main === module) {
539
+ main();
540
+ }
541
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Unified Context Gatherer - The foundation for all Yama operations
3
+ * Gathers all necessary context once and reuses it across all operations
4
+ */
5
+ import { PRIdentifier, PRInfo, PRDiff, AIProviderConfig, DiffStrategyConfig } from "../types";
6
+ import { BitbucketProvider } from "./providers/BitbucketProvider";
7
+ export interface ProjectContext {
8
+ memoryBank: {
9
+ summary: string;
10
+ projectContext: string;
11
+ patterns: string;
12
+ standards: string;
13
+ };
14
+ clinerules: string;
15
+ filesProcessed: number;
16
+ }
17
+ export interface DiffStrategy {
18
+ strategy: "whole" | "file-by-file";
19
+ reason: string;
20
+ fileCount: number;
21
+ estimatedSize: string;
22
+ }
23
+ export interface UnifiedContext {
24
+ pr: PRInfo;
25
+ identifier: PRIdentifier;
26
+ projectContext: ProjectContext;
27
+ diffStrategy: DiffStrategy;
28
+ prDiff?: PRDiff;
29
+ fileDiffs?: Map<string, string>;
30
+ contextId: string;
31
+ gatheredAt: string;
32
+ cacheHits: string[];
33
+ gatheringDuration: number;
34
+ }
35
+ export declare class ContextGatherer {
36
+ private neurolink;
37
+ private bitbucketProvider;
38
+ private aiConfig;
39
+ private startTime;
40
+ constructor(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig);
41
+ /**
42
+ * Main context gathering method - used by all operations
43
+ */
44
+ gatherContext(identifier: PRIdentifier, options?: {
45
+ excludePatterns?: string[];
46
+ contextLines?: number;
47
+ forceRefresh?: boolean;
48
+ includeDiff?: boolean;
49
+ diffStrategyConfig?: DiffStrategyConfig;
50
+ }): Promise<UnifiedContext>;
51
+ /**
52
+ * Step 1: Find PR and get detailed information
53
+ */
54
+ private findAndGetPR;
55
+ /**
56
+ * Step 2: Gather project context (memory bank + clinerules)
57
+ */
58
+ private gatherProjectContext;
59
+ /**
60
+ * Parse project context with AI
61
+ */
62
+ private parseProjectContextWithAI;
63
+ /**
64
+ * Step 3: Determine optimal diff strategy
65
+ */
66
+ private determineDiffStrategy;
67
+ /**
68
+ * Estimate diff size based on file count
69
+ */
70
+ private estimateDiffSize;
71
+ /**
72
+ * Get whole PR diff
73
+ */
74
+ private getPRDiff;
75
+ /**
76
+ * Get file-by-file diffs for large changesets
77
+ */
78
+ private getFileByFileDiffs;
79
+ /**
80
+ * Cache the complete context for reuse
81
+ */
82
+ private cacheContext;
83
+ /**
84
+ * Get cached context if available
85
+ */
86
+ getCachedContext(identifier: PRIdentifier): Promise<UnifiedContext | null>;
87
+ /**
88
+ * Invalidate context cache for a specific PR
89
+ */
90
+ invalidateContext(identifier: PRIdentifier): void;
91
+ /**
92
+ * Generate unique context ID
93
+ */
94
+ private generateContextId;
95
+ /**
96
+ * Parse AI response utility
97
+ */
98
+ private parseAIResponse;
99
+ /**
100
+ * Get gathering statistics
101
+ */
102
+ getStats(): any;
103
+ }
104
+ export declare function createContextGatherer(bitbucketProvider: BitbucketProvider, aiConfig: AIProviderConfig): ContextGatherer;
105
+ //# sourceMappingURL=ContextGatherer.d.ts.map