@juspay/yama 1.0.0 ā 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cli/index.js +75 -78
- package/dist/core/ContextGatherer.d.ts +2 -2
- package/dist/core/ContextGatherer.js +59 -62
- package/dist/core/Guardian.d.ts +1 -1
- package/dist/core/Guardian.js +61 -61
- package/dist/core/providers/BitbucketProvider.d.ts +1 -1
- package/dist/core/providers/BitbucketProvider.js +68 -66
- package/dist/features/CodeReviewer.d.ts +3 -3
- package/dist/features/CodeReviewer.js +66 -68
- package/dist/features/DescriptionEnhancer.d.ts +3 -3
- package/dist/features/DescriptionEnhancer.js +37 -40
- package/dist/index.d.ts +11 -11
- package/dist/index.js +10 -48
- package/dist/types/index.js +6 -11
- package/dist/utils/Cache.d.ts +1 -1
- package/dist/utils/Cache.js +48 -55
- package/dist/utils/ConfigManager.d.ts +1 -1
- package/dist/utils/ConfigManager.js +191 -198
- package/dist/utils/Logger.d.ts +1 -1
- package/dist/utils/Logger.js +15 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.1.1](https://github.com/juspay/yama/compare/v1.1.0...v1.1.1) (2025-07-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump version to 1.2.1 ([8964645](https://github.com/juspay/yama/commit/89646450a7dec6ffcc3ad7fb745e1414fc751d4f))
|
|
7
|
+
|
|
8
|
+
# [1.1.0](https://github.com/juspay/yama/compare/v1.0.0...v1.1.0) (2025-07-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* migrate from CommonJS to ESM modules ([b45559f](https://github.com/juspay/yama/commit/b45559f86d37ab3516079becfa56a9f73ff8f062))
|
|
14
|
+
|
|
1
15
|
# 1.0.0 (2025-07-25)
|
|
2
16
|
|
|
3
17
|
|
package/dist/cli/index.js
CHANGED
|
@@ -1,31 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
/**
|
|
4
3
|
* Yama CLI - Enhanced command line interface
|
|
5
4
|
* Provides backward compatibility with pr-police.js and pr-describe.js
|
|
6
5
|
* Plus new unified commands for the enhanced functionality
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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");
|
|
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";
|
|
22
17
|
// Load environment variables
|
|
23
|
-
|
|
24
|
-
const program = new
|
|
18
|
+
dotenv.config();
|
|
19
|
+
const program = new Command();
|
|
25
20
|
// Package info
|
|
26
21
|
const packageInfo = {
|
|
27
22
|
name: "@juspay/yama",
|
|
28
|
-
version: "1.1
|
|
23
|
+
version: "1.2.1",
|
|
29
24
|
description: "Enterprise-grade Pull Request automation toolkit",
|
|
30
25
|
};
|
|
31
26
|
/**
|
|
@@ -84,18 +79,18 @@ function setupProcessCommand() {
|
|
|
84
79
|
dryRun: options.dryRun,
|
|
85
80
|
verbose: options.verbose,
|
|
86
81
|
};
|
|
87
|
-
const guardian = new
|
|
82
|
+
const guardian = new Guardian();
|
|
88
83
|
await guardian.initialize(options.config);
|
|
89
84
|
if (options.verbose) {
|
|
90
85
|
// Use streaming for verbose mode
|
|
91
|
-
console.log(
|
|
86
|
+
console.log(chalk.blue("\nš” Starting streaming processing...\n"));
|
|
92
87
|
for await (const update of guardian.processPRStream(operationOptions)) {
|
|
93
88
|
logStreamUpdate(update);
|
|
94
89
|
}
|
|
95
90
|
}
|
|
96
91
|
else {
|
|
97
92
|
// Use regular processing
|
|
98
|
-
const spinner = (
|
|
93
|
+
const spinner = ora("Processing PR...").start();
|
|
99
94
|
try {
|
|
100
95
|
const result = await guardian.processPR(operationOptions);
|
|
101
96
|
spinner.succeed("Processing completed");
|
|
@@ -108,7 +103,7 @@ function setupProcessCommand() {
|
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
105
|
catch (error) {
|
|
111
|
-
console.error(
|
|
106
|
+
console.error(chalk.red(`ā Error: ${error.message}`));
|
|
112
107
|
process.exit(1);
|
|
113
108
|
}
|
|
114
109
|
});
|
|
@@ -142,9 +137,9 @@ function setupReviewCommand() {
|
|
|
142
137
|
.map((p) => p.trim()),
|
|
143
138
|
contextLines: parseInt(options.contextLines),
|
|
144
139
|
};
|
|
145
|
-
const guardian = new
|
|
140
|
+
const guardian = new Guardian();
|
|
146
141
|
await guardian.initialize(options.config);
|
|
147
|
-
const spinner = (
|
|
142
|
+
const spinner = ora("Conducting code review...").start();
|
|
148
143
|
try {
|
|
149
144
|
const result = await guardian.reviewCode(reviewOptions);
|
|
150
145
|
spinner.succeed("Code review completed");
|
|
@@ -156,7 +151,7 @@ function setupReviewCommand() {
|
|
|
156
151
|
}
|
|
157
152
|
}
|
|
158
153
|
catch (error) {
|
|
159
|
-
console.error(
|
|
154
|
+
console.error(chalk.red(`ā Error: ${error.message}`));
|
|
160
155
|
process.exit(1);
|
|
161
156
|
}
|
|
162
157
|
});
|
|
@@ -187,9 +182,9 @@ function setupEnhanceCommand() {
|
|
|
187
182
|
preserveContent: options.preserve !== false,
|
|
188
183
|
ensureRequiredSections: true,
|
|
189
184
|
};
|
|
190
|
-
const guardian = new
|
|
185
|
+
const guardian = new Guardian();
|
|
191
186
|
await guardian.initialize(options.config);
|
|
192
|
-
const spinner = (
|
|
187
|
+
const spinner = ora("Enhancing PR description...").start();
|
|
193
188
|
try {
|
|
194
189
|
const result = await guardian.enhanceDescription(enhancementOptions);
|
|
195
190
|
spinner.succeed("Description enhancement completed");
|
|
@@ -201,7 +196,7 @@ function setupEnhanceCommand() {
|
|
|
201
196
|
}
|
|
202
197
|
}
|
|
203
198
|
catch (error) {
|
|
204
|
-
console.error(
|
|
199
|
+
console.error(chalk.red(`ā Error: ${error.message}`));
|
|
205
200
|
process.exit(1);
|
|
206
201
|
}
|
|
207
202
|
});
|
|
@@ -221,14 +216,14 @@ function setupInitCommand() {
|
|
|
221
216
|
await interactiveInit();
|
|
222
217
|
}
|
|
223
218
|
else {
|
|
224
|
-
const configPath = await
|
|
225
|
-
console.log(
|
|
226
|
-
console.log(
|
|
227
|
-
console.log(
|
|
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"));
|
|
228
223
|
}
|
|
229
224
|
}
|
|
230
225
|
catch (error) {
|
|
231
|
-
console.error(
|
|
226
|
+
console.error(chalk.red(`ā Error: ${error.message}`));
|
|
232
227
|
process.exit(1);
|
|
233
228
|
}
|
|
234
229
|
});
|
|
@@ -244,11 +239,11 @@ function setupStatusCommand() {
|
|
|
244
239
|
.action(async (options) => {
|
|
245
240
|
try {
|
|
246
241
|
await handleGlobalOptions(options);
|
|
247
|
-
const guardian = new
|
|
242
|
+
const guardian = new Guardian();
|
|
248
243
|
await guardian.initialize(options.config);
|
|
249
244
|
const health = await guardian.healthCheck();
|
|
250
245
|
const stats = guardian.getStats();
|
|
251
|
-
console.log(
|
|
246
|
+
console.log(chalk.cyan("\nš”ļø Yama Status\n"));
|
|
252
247
|
// Health status
|
|
253
248
|
const healthEmoji = health.healthy ? "ā
" : "ā";
|
|
254
249
|
console.log(`${healthEmoji} Overall Health: ${health.healthy ? "Healthy" : "Issues Detected"}`);
|
|
@@ -264,11 +259,11 @@ function setupStatusCommand() {
|
|
|
264
259
|
console.log(JSON.stringify(stats, null, 2));
|
|
265
260
|
}
|
|
266
261
|
// Cache status
|
|
267
|
-
const cacheStats =
|
|
268
|
-
console.log(`\nš¾ Cache: ${cacheStats.keys} keys, ${cacheStats.hits} hits, ${Math.round(
|
|
262
|
+
const cacheStats = cache.stats();
|
|
263
|
+
console.log(`\nš¾ Cache: ${cacheStats.keys} keys, ${cacheStats.hits} hits, ${Math.round(cache.getHitRatio() * 100)}% hit ratio`);
|
|
269
264
|
}
|
|
270
265
|
catch (error) {
|
|
271
|
-
console.error(
|
|
266
|
+
console.error(chalk.red(`ā Error: ${error.message}`));
|
|
272
267
|
process.exit(1);
|
|
273
268
|
}
|
|
274
269
|
});
|
|
@@ -284,20 +279,20 @@ function setupCacheCommand() {
|
|
|
284
279
|
.command("clear")
|
|
285
280
|
.description("Clear all caches")
|
|
286
281
|
.action(() => {
|
|
287
|
-
|
|
288
|
-
console.log(
|
|
282
|
+
cache.clear();
|
|
283
|
+
console.log(chalk.green("ā
All caches cleared"));
|
|
289
284
|
});
|
|
290
285
|
cacheCommand
|
|
291
286
|
.command("stats")
|
|
292
287
|
.description("Show cache statistics")
|
|
293
288
|
.action(() => {
|
|
294
|
-
const stats =
|
|
295
|
-
const detailed =
|
|
296
|
-
console.log(
|
|
289
|
+
const stats = cache.stats();
|
|
290
|
+
const detailed = cache.debug();
|
|
291
|
+
console.log(chalk.cyan("\nš¾ Cache Statistics\n"));
|
|
297
292
|
console.log(`Keys: ${stats.keys}`);
|
|
298
293
|
console.log(`Hits: ${stats.hits}`);
|
|
299
294
|
console.log(`Misses: ${stats.misses}`);
|
|
300
|
-
console.log(`Hit Ratio: ${Math.round(
|
|
295
|
+
console.log(`Hit Ratio: ${Math.round(cache.getHitRatio() * 100)}%`);
|
|
301
296
|
console.log("\nš Detailed Stats:");
|
|
302
297
|
console.log(JSON.stringify(detailed, null, 2));
|
|
303
298
|
});
|
|
@@ -315,11 +310,11 @@ function setupConfigCommand() {
|
|
|
315
310
|
.option("-c, --config <path>", "Configuration file path")
|
|
316
311
|
.action(async (options) => {
|
|
317
312
|
try {
|
|
318
|
-
await
|
|
319
|
-
console.log(
|
|
313
|
+
await configManager.loadConfig(options.config);
|
|
314
|
+
console.log(chalk.green("ā
Configuration is valid"));
|
|
320
315
|
}
|
|
321
316
|
catch (error) {
|
|
322
|
-
console.error(
|
|
317
|
+
console.error(chalk.red(`ā Configuration error: ${error.message}`));
|
|
323
318
|
process.exit(1);
|
|
324
319
|
}
|
|
325
320
|
});
|
|
@@ -329,8 +324,8 @@ function setupConfigCommand() {
|
|
|
329
324
|
.option("-c, --config <path>", "Configuration file path")
|
|
330
325
|
.action(async (options) => {
|
|
331
326
|
try {
|
|
332
|
-
const config = await
|
|
333
|
-
console.log(
|
|
327
|
+
const config = await configManager.loadConfig(options.config);
|
|
328
|
+
console.log(chalk.cyan("\nāļø Current Configuration\n"));
|
|
334
329
|
// Mask sensitive information
|
|
335
330
|
const sanitizedConfig = { ...config };
|
|
336
331
|
if (sanitizedConfig.providers?.git?.credentials?.token) {
|
|
@@ -339,7 +334,7 @@ function setupConfigCommand() {
|
|
|
339
334
|
console.log(JSON.stringify(sanitizedConfig, null, 2));
|
|
340
335
|
}
|
|
341
336
|
catch (error) {
|
|
342
|
-
console.error(
|
|
337
|
+
console.error(chalk.red(`ā Error: ${error.message}`));
|
|
343
338
|
process.exit(1);
|
|
344
339
|
}
|
|
345
340
|
});
|
|
@@ -368,12 +363,12 @@ function setupBackwardCompatibility() {
|
|
|
368
363
|
async function handleGlobalOptions(options) {
|
|
369
364
|
// Set up logging
|
|
370
365
|
if (options.verbose) {
|
|
371
|
-
|
|
372
|
-
|
|
366
|
+
logger.setVerbose(true);
|
|
367
|
+
logger.setLevel("debug");
|
|
373
368
|
}
|
|
374
369
|
// Handle cache disabling
|
|
375
370
|
if (options.cache === false) {
|
|
376
|
-
|
|
371
|
+
cache.clear();
|
|
377
372
|
}
|
|
378
373
|
}
|
|
379
374
|
function parseOperations(operationsStr) {
|
|
@@ -397,21 +392,21 @@ function logStreamUpdate(update) {
|
|
|
397
392
|
const progressStr = update.progress ? ` (${update.progress}%)` : "";
|
|
398
393
|
switch (update.status) {
|
|
399
394
|
case "started":
|
|
400
|
-
console.log(
|
|
395
|
+
console.log(chalk.blue(`š [${timestamp}] ${update.operation}: ${update.message}`));
|
|
401
396
|
break;
|
|
402
397
|
case "progress":
|
|
403
|
-
console.log(
|
|
398
|
+
console.log(chalk.yellow(`š [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
|
|
404
399
|
break;
|
|
405
400
|
case "completed":
|
|
406
|
-
console.log(
|
|
401
|
+
console.log(chalk.green(`ā
[${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
|
|
407
402
|
break;
|
|
408
403
|
case "error":
|
|
409
|
-
console.log(
|
|
404
|
+
console.log(chalk.red(`ā [${timestamp}] ${update.operation}: ${update.message}`));
|
|
410
405
|
break;
|
|
411
406
|
}
|
|
412
407
|
}
|
|
413
408
|
function printProcessResult(result) {
|
|
414
|
-
console.log(
|
|
409
|
+
console.log(chalk.cyan("\nš”ļø Yama Process Result\n"));
|
|
415
410
|
console.log(`PR: #${result.pullRequest.id} - ${result.pullRequest.title}`);
|
|
416
411
|
console.log(`Author: ${result.pullRequest.author}`);
|
|
417
412
|
console.log(`Operations: ${result.operations.length}`);
|
|
@@ -426,13 +421,13 @@ function printProcessResult(result) {
|
|
|
426
421
|
const emoji = op.status === "success" ? "ā
" : op.status === "error" ? "ā" : "āļø";
|
|
427
422
|
console.log(` ${emoji} ${op.operation}: ${op.status} (${Math.round(op.duration / 1000)}s)`);
|
|
428
423
|
if (op.error) {
|
|
429
|
-
console.log(
|
|
424
|
+
console.log(chalk.red(` Error: ${op.error}`));
|
|
430
425
|
}
|
|
431
426
|
});
|
|
432
427
|
}
|
|
433
428
|
function printReviewResult(result) {
|
|
434
429
|
const stats = result.statistics;
|
|
435
|
-
console.log(
|
|
430
|
+
console.log(chalk.cyan("\nš”ļø Code Review Results\n"));
|
|
436
431
|
console.log(`š Total Issues: ${stats.totalIssues}`);
|
|
437
432
|
console.log(`šØ Critical: ${stats.criticalCount}`);
|
|
438
433
|
console.log(`ā ļø Major: ${stats.majorCount}`);
|
|
@@ -440,20 +435,20 @@ function printReviewResult(result) {
|
|
|
440
435
|
console.log(`š” Suggestions: ${stats.suggestionCount}`);
|
|
441
436
|
console.log(`š Files Reviewed: ${stats.filesReviewed}`);
|
|
442
437
|
if (stats.criticalCount > 0) {
|
|
443
|
-
console.log(
|
|
438
|
+
console.log(chalk.red("\nā CRITICAL issues found - must fix before merge!"));
|
|
444
439
|
}
|
|
445
440
|
else if (stats.majorCount > 0) {
|
|
446
|
-
console.log(
|
|
441
|
+
console.log(chalk.yellow("\nā ļø Major issues found - should fix before merge"));
|
|
447
442
|
}
|
|
448
443
|
else if (stats.minorCount > 0) {
|
|
449
|
-
console.log(
|
|
444
|
+
console.log(chalk.blue("\nš Minor improvements suggested"));
|
|
450
445
|
}
|
|
451
446
|
else {
|
|
452
|
-
console.log(
|
|
447
|
+
console.log(chalk.green("\nā
Code quality approved!"));
|
|
453
448
|
}
|
|
454
449
|
}
|
|
455
450
|
function printEnhancementResult(result) {
|
|
456
|
-
console.log(
|
|
451
|
+
console.log(chalk.cyan("\nš Description Enhancement Results\n"));
|
|
457
452
|
console.log(`š Original Length: ${result.statistics.originalLength} characters`);
|
|
458
453
|
console.log(`š Enhanced Length: ${result.statistics.enhancedLength} characters`);
|
|
459
454
|
console.log(`š Sections Completed: ${result.statistics.completedSections}/${result.statistics.totalSections}`);
|
|
@@ -465,15 +460,15 @@ function printEnhancementResult(result) {
|
|
|
465
460
|
}
|
|
466
461
|
console.log(`š Content Preserved: ${result.preservedItems.media} media, ${result.preservedItems.files} files, ${result.preservedItems.links} links`);
|
|
467
462
|
if (result.statistics.completedSections === result.statistics.totalSections) {
|
|
468
|
-
console.log(
|
|
463
|
+
console.log(chalk.green("\nā
All required sections completed!"));
|
|
469
464
|
}
|
|
470
465
|
else {
|
|
471
|
-
console.log(
|
|
466
|
+
console.log(chalk.yellow("\nā ļø Some required sections may still need attention"));
|
|
472
467
|
}
|
|
473
468
|
}
|
|
474
469
|
async function interactiveInit() {
|
|
475
|
-
console.log(
|
|
476
|
-
await
|
|
470
|
+
console.log(chalk.cyan("\nš”ļø Yama Interactive Setup\n"));
|
|
471
|
+
await inquirer.prompt([
|
|
477
472
|
{
|
|
478
473
|
type: "input",
|
|
479
474
|
name: "workspace",
|
|
@@ -506,12 +501,12 @@ async function interactiveInit() {
|
|
|
506
501
|
default: true,
|
|
507
502
|
},
|
|
508
503
|
]);
|
|
509
|
-
const configPath = await
|
|
510
|
-
console.log(
|
|
511
|
-
console.log(
|
|
512
|
-
console.log(
|
|
513
|
-
console.log(
|
|
514
|
-
console.log(
|
|
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"));
|
|
515
510
|
}
|
|
516
511
|
/**
|
|
517
512
|
* Main execution
|
|
@@ -527,15 +522,17 @@ function main() {
|
|
|
527
522
|
}
|
|
528
523
|
// Handle uncaught errors
|
|
529
524
|
process.on("uncaughtException", (error) => {
|
|
530
|
-
console.error(
|
|
525
|
+
console.error(chalk.red(`\nš„ Uncaught Exception: ${error.message}`));
|
|
531
526
|
process.exit(1);
|
|
532
527
|
});
|
|
533
528
|
process.on("unhandledRejection", (reason) => {
|
|
534
|
-
console.error(
|
|
529
|
+
console.error(chalk.red(`\nš„ Unhandled Rejection: ${reason}`));
|
|
535
530
|
process.exit(1);
|
|
536
531
|
});
|
|
537
532
|
// Run if this is the main module
|
|
538
|
-
|
|
533
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
534
|
+
if (process.argv[1] === __filename) {
|
|
539
535
|
main();
|
|
540
536
|
}
|
|
537
|
+
export { main };
|
|
541
538
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,8 +2,8 @@
|
|
|
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";
|
|
6
|
-
import { BitbucketProvider } from "./providers/BitbucketProvider";
|
|
5
|
+
import { PRIdentifier, PRInfo, PRDiff, AIProviderConfig, DiffStrategyConfig } from "../types/index.js";
|
|
6
|
+
import { BitbucketProvider } from "./providers/BitbucketProvider.js";
|
|
7
7
|
export interface ProjectContext {
|
|
8
8
|
memoryBank: {
|
|
9
9
|
summary: string;
|