@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 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
- 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");
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
- dotenv_1.default.config();
24
- const program = new commander_1.Command();
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.0",
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 Guardian_1.Guardian();
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(chalk_1.default.blue("\nšŸ“” Starting streaming processing...\n"));
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 = (0, ora_1.default)("Processing PR...").start();
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(chalk_1.default.red(`āŒ Error: ${error.message}`));
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 Guardian_1.Guardian();
140
+ const guardian = new Guardian();
146
141
  await guardian.initialize(options.config);
147
- const spinner = (0, ora_1.default)("Conducting code review...").start();
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(chalk_1.default.red(`āŒ Error: ${error.message}`));
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 Guardian_1.Guardian();
185
+ const guardian = new Guardian();
191
186
  await guardian.initialize(options.config);
192
- const spinner = (0, ora_1.default)("Enhancing PR description...").start();
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(chalk_1.default.red(`āŒ Error: ${error.message}`));
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 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"));
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(chalk_1.default.red(`āŒ Error: ${error.message}`));
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 Guardian_1.Guardian();
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(chalk_1.default.cyan("\nšŸ›”ļø Yama Status\n"));
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 = Cache_1.cache.stats();
268
- console.log(`\nšŸ’¾ Cache: ${cacheStats.keys} keys, ${cacheStats.hits} hits, ${Math.round(Cache_1.cache.getHitRatio() * 100)}% hit ratio`);
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(chalk_1.default.red(`āŒ Error: ${error.message}`));
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
- Cache_1.cache.clear();
288
- console.log(chalk_1.default.green("āœ… All caches cleared"));
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 = Cache_1.cache.stats();
295
- const detailed = Cache_1.cache.debug();
296
- console.log(chalk_1.default.cyan("\nšŸ’¾ Cache Statistics\n"));
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(Cache_1.cache.getHitRatio() * 100)}%`);
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 ConfigManager_1.configManager.loadConfig(options.config);
319
- console.log(chalk_1.default.green("āœ… Configuration is valid"));
313
+ await configManager.loadConfig(options.config);
314
+ console.log(chalk.green("āœ… Configuration is valid"));
320
315
  }
321
316
  catch (error) {
322
- console.error(chalk_1.default.red(`āŒ Configuration error: ${error.message}`));
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 ConfigManager_1.configManager.loadConfig(options.config);
333
- console.log(chalk_1.default.cyan("\nāš™ļø Current Configuration\n"));
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(chalk_1.default.red(`āŒ Error: ${error.message}`));
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
- Logger_1.logger.setVerbose(true);
372
- Logger_1.logger.setLevel("debug");
366
+ logger.setVerbose(true);
367
+ logger.setLevel("debug");
373
368
  }
374
369
  // Handle cache disabling
375
370
  if (options.cache === false) {
376
- Cache_1.cache.clear();
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(chalk_1.default.blue(`šŸš€ [${timestamp}] ${update.operation}: ${update.message}`));
395
+ console.log(chalk.blue(`šŸš€ [${timestamp}] ${update.operation}: ${update.message}`));
401
396
  break;
402
397
  case "progress":
403
- console.log(chalk_1.default.yellow(`šŸ”„ [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
398
+ console.log(chalk.yellow(`šŸ”„ [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
404
399
  break;
405
400
  case "completed":
406
- console.log(chalk_1.default.green(`āœ… [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
401
+ console.log(chalk.green(`āœ… [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
407
402
  break;
408
403
  case "error":
409
- console.log(chalk_1.default.red(`āŒ [${timestamp}] ${update.operation}: ${update.message}`));
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(chalk_1.default.cyan("\nšŸ›”ļø Yama Process Result\n"));
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(chalk_1.default.red(` Error: ${op.error}`));
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(chalk_1.default.cyan("\nšŸ›”ļø Code Review Results\n"));
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(chalk_1.default.red("\nā›” CRITICAL issues found - must fix before merge!"));
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(chalk_1.default.yellow("\nāš ļø Major issues found - should fix before merge"));
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(chalk_1.default.blue("\nšŸ“ Minor improvements suggested"));
444
+ console.log(chalk.blue("\nšŸ“ Minor improvements suggested"));
450
445
  }
451
446
  else {
452
- console.log(chalk_1.default.green("\nāœ… Code quality approved!"));
447
+ console.log(chalk.green("\nāœ… Code quality approved!"));
453
448
  }
454
449
  }
455
450
  function printEnhancementResult(result) {
456
- console.log(chalk_1.default.cyan("\nšŸ“ Description Enhancement Results\n"));
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(chalk_1.default.green("\nāœ… All required sections completed!"));
463
+ console.log(chalk.green("\nāœ… All required sections completed!"));
469
464
  }
470
465
  else {
471
- console.log(chalk_1.default.yellow("\nāš ļø Some required sections may still need attention"));
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(chalk_1.default.cyan("\nšŸ›”ļø Yama Interactive Setup\n"));
476
- await inquirer_1.default.prompt([
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 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"));
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(chalk_1.default.red(`\nšŸ’„ Uncaught Exception: ${error.message}`));
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(chalk_1.default.red(`\nšŸ’„ Unhandled Rejection: ${reason}`));
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
- if (require.main === module) {
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;