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