@juspay/yama 1.1.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/dist/cli/index.js CHANGED
@@ -1,50 +1,45 @@
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
- name: '@juspay/yama',
28
- version: '1.1.0',
29
- description: 'Enterprise-grade Pull Request automation toolkit'
22
+ name: "@juspay/yama",
23
+ version: "1.2.1",
24
+ description: "Enterprise-grade Pull Request automation toolkit",
30
25
  };
31
26
  /**
32
27
  * Main CLI setup
33
28
  */
34
29
  function setupCLI() {
35
30
  program
36
- .name('yama')
31
+ .name("yama")
37
32
  .description(packageInfo.description)
38
33
  .version(packageInfo.version);
39
34
  // Global options
40
35
  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');
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");
45
40
  // Configure help options (removed custom formatter to fix recursion)
46
41
  program.configureHelp({
47
- sortSubcommands: true
42
+ sortSubcommands: true,
48
43
  });
49
44
  // Setup commands
50
45
  setupProcessCommand();
@@ -62,15 +57,15 @@ function setupCLI() {
62
57
  */
63
58
  function setupProcessCommand() {
64
59
  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')
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")
74
69
  .action(async (options) => {
75
70
  try {
76
71
  await handleGlobalOptions(options);
@@ -82,33 +77,33 @@ function setupProcessCommand() {
82
77
  pullRequestId: options.pr,
83
78
  operations,
84
79
  dryRun: options.dryRun,
85
- verbose: options.verbose
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
- spinner.succeed('Processing completed');
96
+ spinner.succeed("Processing completed");
102
97
  printProcessResult(result);
103
98
  }
104
99
  catch (error) {
105
- spinner.fail('Processing failed');
100
+ spinner.fail("Processing failed");
106
101
  throw error;
107
102
  }
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
  });
@@ -118,15 +113,15 @@ function setupProcessCommand() {
118
113
  */
119
114
  function setupReviewCommand() {
120
115
  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')
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")
130
125
  .action(async (options) => {
131
126
  try {
132
127
  await handleGlobalOptions(options);
@@ -137,24 +132,26 @@ function setupReviewCommand() {
137
132
  pullRequestId: options.pr,
138
133
  dryRun: options.dryRun,
139
134
  verbose: options.verbose,
140
- excludePatterns: options.exclude?.split(',').map((p) => p.trim()),
141
- contextLines: parseInt(options.contextLines)
135
+ excludePatterns: options.exclude
136
+ ?.split(",")
137
+ .map((p) => p.trim()),
138
+ contextLines: parseInt(options.contextLines),
142
139
  };
143
- const guardian = new Guardian_1.Guardian();
140
+ const guardian = new Guardian();
144
141
  await guardian.initialize(options.config);
145
- const spinner = (0, ora_1.default)('Conducting code review...').start();
142
+ const spinner = ora("Conducting code review...").start();
146
143
  try {
147
144
  const result = await guardian.reviewCode(reviewOptions);
148
- spinner.succeed('Code review completed');
145
+ spinner.succeed("Code review completed");
149
146
  printReviewResult(result);
150
147
  }
151
148
  catch (error) {
152
- spinner.fail('Code review failed');
149
+ spinner.fail("Code review failed");
153
150
  throw error;
154
151
  }
155
152
  }
156
153
  catch (error) {
157
- console.error(chalk_1.default.red(`āŒ Error: ${error.message}`));
154
+ console.error(chalk.red(`āŒ Error: ${error.message}`));
158
155
  process.exit(1);
159
156
  }
160
157
  });
@@ -164,14 +161,14 @@ function setupReviewCommand() {
164
161
  */
165
162
  function setupEnhanceCommand() {
166
163
  program
167
- .command('enhance')
168
- .alias('scribe') // Backward compatibility
169
- .description('AI-powered description enhancement (equivalent to pr-describe.js)')
170
- .requiredOption('-w, --workspace <workspace>', 'Bitbucket workspace')
171
- .requiredOption('-r, --repository <repository>', 'Repository name')
172
- .option('-b, --branch <branch>', 'Branch name')
173
- .option('-p, --pr <id>', 'Pull request ID')
174
- .option('--no-preserve', 'Disable content preservation')
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")
175
172
  .action(async (options) => {
176
173
  try {
177
174
  await handleGlobalOptions(options);
@@ -183,23 +180,23 @@ function setupEnhanceCommand() {
183
180
  dryRun: options.dryRun,
184
181
  verbose: options.verbose,
185
182
  preserveContent: options.preserve !== false,
186
- ensureRequiredSections: true
183
+ ensureRequiredSections: true,
187
184
  };
188
- const guardian = new Guardian_1.Guardian();
185
+ const guardian = new Guardian();
189
186
  await guardian.initialize(options.config);
190
- const spinner = (0, ora_1.default)('Enhancing PR description...').start();
187
+ const spinner = ora("Enhancing PR description...").start();
191
188
  try {
192
189
  const result = await guardian.enhanceDescription(enhancementOptions);
193
- spinner.succeed('Description enhancement completed');
190
+ spinner.succeed("Description enhancement completed");
194
191
  printEnhancementResult(result);
195
192
  }
196
193
  catch (error) {
197
- spinner.fail('Description enhancement failed');
194
+ spinner.fail("Description enhancement failed");
198
195
  throw error;
199
196
  }
200
197
  }
201
198
  catch (error) {
202
- console.error(chalk_1.default.red(`āŒ Error: ${error.message}`));
199
+ console.error(chalk.red(`āŒ Error: ${error.message}`));
203
200
  process.exit(1);
204
201
  }
205
202
  });
@@ -209,24 +206,24 @@ function setupEnhanceCommand() {
209
206
  */
210
207
  function setupInitCommand() {
211
208
  program
212
- .command('init')
213
- .description('Initialize Yama configuration')
214
- .option('-o, --output <path>', 'Output configuration file path')
215
- .option('-i, --interactive', 'Interactive configuration setup')
209
+ .command("init")
210
+ .description("Initialize Yama configuration")
211
+ .option("-o, --output <path>", "Output configuration file path")
212
+ .option("-i, --interactive", "Interactive configuration setup")
216
213
  .action(async (options) => {
217
214
  try {
218
215
  if (options.interactive) {
219
216
  await interactiveInit();
220
217
  }
221
218
  else {
222
- const configPath = await ConfigManager_1.configManager.createDefaultConfig(options.output);
223
- console.log(chalk_1.default.green(`āœ… Configuration file created: ${configPath}`));
224
- console.log(chalk_1.default.yellow('šŸ’” Edit the configuration file to customize settings'));
225
- 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"));
226
223
  }
227
224
  }
228
225
  catch (error) {
229
- console.error(chalk_1.default.red(`āŒ Error: ${error.message}`));
226
+ console.error(chalk.red(`āŒ Error: ${error.message}`));
230
227
  process.exit(1);
231
228
  }
232
229
  });
@@ -236,37 +233,37 @@ function setupInitCommand() {
236
233
  */
237
234
  function setupStatusCommand() {
238
235
  program
239
- .command('status')
240
- .description('Check Yama status and health')
241
- .option('-d, --detailed', 'Show detailed status information')
236
+ .command("status")
237
+ .description("Check Yama status and health")
238
+ .option("-d, --detailed", "Show detailed status information")
242
239
  .action(async (options) => {
243
240
  try {
244
241
  await handleGlobalOptions(options);
245
- const guardian = new Guardian_1.Guardian();
242
+ const guardian = new Guardian();
246
243
  await guardian.initialize(options.config);
247
244
  const health = await guardian.healthCheck();
248
245
  const stats = guardian.getStats();
249
- console.log(chalk_1.default.cyan('\nšŸ›”ļø Yama Status\n'));
246
+ console.log(chalk.cyan("\nšŸ›”ļø Yama Status\n"));
250
247
  // Health status
251
- const healthEmoji = health.healthy ? 'āœ…' : 'āŒ';
252
- console.log(`${healthEmoji} Overall Health: ${health.healthy ? 'Healthy' : 'Issues Detected'}`);
248
+ const healthEmoji = health.healthy ? "āœ…" : "āŒ";
249
+ console.log(`${healthEmoji} Overall Health: ${health.healthy ? "Healthy" : "Issues Detected"}`);
253
250
  // Component status
254
- console.log('\nšŸ“Š Component Status:');
251
+ console.log("\nšŸ“Š Component Status:");
255
252
  Object.entries(health.components).forEach(([component, status]) => {
256
- const emoji = status.healthy ? 'āœ…' : 'āŒ';
257
- console.log(` ${emoji} ${component}: ${status.healthy ? 'OK' : 'Error'}`);
253
+ const emoji = status.healthy ? "āœ…" : "āŒ";
254
+ console.log(` ${emoji} ${component}: ${status.healthy ? "OK" : "Error"}`);
258
255
  });
259
256
  // Statistics
260
257
  if (options.detailed) {
261
- console.log('\nšŸ“ˆ Statistics:');
258
+ console.log("\nšŸ“ˆ Statistics:");
262
259
  console.log(JSON.stringify(stats, null, 2));
263
260
  }
264
261
  // Cache status
265
- const cacheStats = Cache_1.cache.stats();
266
- 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`);
267
264
  }
268
265
  catch (error) {
269
- console.error(chalk_1.default.red(`āŒ Error: ${error.message}`));
266
+ console.error(chalk.red(`āŒ Error: ${error.message}`));
270
267
  process.exit(1);
271
268
  }
272
269
  });
@@ -276,27 +273,27 @@ function setupStatusCommand() {
276
273
  */
277
274
  function setupCacheCommand() {
278
275
  const cacheCommand = program
279
- .command('cache')
280
- .description('Cache management operations');
276
+ .command("cache")
277
+ .description("Cache management operations");
281
278
  cacheCommand
282
- .command('clear')
283
- .description('Clear all caches')
279
+ .command("clear")
280
+ .description("Clear all caches")
284
281
  .action(() => {
285
- Cache_1.cache.clear();
286
- console.log(chalk_1.default.green('āœ… All caches cleared'));
282
+ cache.clear();
283
+ console.log(chalk.green("āœ… All caches cleared"));
287
284
  });
288
285
  cacheCommand
289
- .command('stats')
290
- .description('Show cache statistics')
286
+ .command("stats")
287
+ .description("Show cache statistics")
291
288
  .action(() => {
292
- const stats = Cache_1.cache.stats();
293
- const detailed = Cache_1.cache.debug();
294
- 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"));
295
292
  console.log(`Keys: ${stats.keys}`);
296
293
  console.log(`Hits: ${stats.hits}`);
297
294
  console.log(`Misses: ${stats.misses}`);
298
- console.log(`Hit Ratio: ${Math.round(Cache_1.cache.getHitRatio() * 100)}%`);
299
- console.log('\nšŸ“Š Detailed Stats:');
295
+ console.log(`Hit Ratio: ${Math.round(cache.getHitRatio() * 100)}%`);
296
+ console.log("\nšŸ“Š Detailed Stats:");
300
297
  console.log(JSON.stringify(detailed, null, 2));
301
298
  });
302
299
  }
@@ -305,39 +302,39 @@ function setupCacheCommand() {
305
302
  */
306
303
  function setupConfigCommand() {
307
304
  const configCommand = program
308
- .command('config')
309
- .description('Configuration management');
305
+ .command("config")
306
+ .description("Configuration management");
310
307
  configCommand
311
- .command('validate')
312
- .description('Validate configuration file')
313
- .option('-c, --config <path>', 'Configuration file path')
308
+ .command("validate")
309
+ .description("Validate configuration file")
310
+ .option("-c, --config <path>", "Configuration file path")
314
311
  .action(async (options) => {
315
312
  try {
316
- await ConfigManager_1.configManager.loadConfig(options.config);
317
- console.log(chalk_1.default.green('āœ… Configuration is valid'));
313
+ await configManager.loadConfig(options.config);
314
+ console.log(chalk.green("āœ… Configuration is valid"));
318
315
  }
319
316
  catch (error) {
320
- console.error(chalk_1.default.red(`āŒ Configuration error: ${error.message}`));
317
+ console.error(chalk.red(`āŒ Configuration error: ${error.message}`));
321
318
  process.exit(1);
322
319
  }
323
320
  });
324
321
  configCommand
325
- .command('show')
326
- .description('Show current configuration')
327
- .option('-c, --config <path>', 'Configuration file path')
322
+ .command("show")
323
+ .description("Show current configuration")
324
+ .option("-c, --config <path>", "Configuration file path")
328
325
  .action(async (options) => {
329
326
  try {
330
- const config = await ConfigManager_1.configManager.loadConfig(options.config);
331
- 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"));
332
329
  // Mask sensitive information
333
330
  const sanitizedConfig = { ...config };
334
331
  if (sanitizedConfig.providers?.git?.credentials?.token) {
335
- sanitizedConfig.providers.git.credentials.token = '***MASKED***';
332
+ sanitizedConfig.providers.git.credentials.token = "***MASKED***";
336
333
  }
337
334
  console.log(JSON.stringify(sanitizedConfig, null, 2));
338
335
  }
339
336
  catch (error) {
340
- console.error(chalk_1.default.red(`āŒ Error: ${error.message}`));
337
+ console.error(chalk.red(`āŒ Error: ${error.message}`));
341
338
  process.exit(1);
342
339
  }
343
340
  });
@@ -347,16 +344,17 @@ function setupConfigCommand() {
347
344
  */
348
345
  function setupBackwardCompatibility() {
349
346
  // pr-police.js compatibility
350
- if (process.argv[1]?.includes('pr-police')) {
347
+ if (process.argv[1]?.includes("pr-police")) {
351
348
  // Redirect to review command
352
349
  const args = process.argv.slice(2);
353
- process.argv = ['node', 'yama', 'review', ...args];
350
+ process.argv = ["node", "yama", "review", ...args];
354
351
  }
355
352
  // pr-describe.js / pr-scribe.js compatibility
356
- if (process.argv[1]?.includes('pr-scribe') || process.argv[1]?.includes('pr-describe')) {
353
+ if (process.argv[1]?.includes("pr-scribe") ||
354
+ process.argv[1]?.includes("pr-describe")) {
357
355
  // Redirect to enhance command
358
356
  const args = process.argv.slice(2);
359
- process.argv = ['node', 'yama', 'enhance', ...args];
357
+ process.argv = ["node", "yama", "enhance", ...args];
360
358
  }
361
359
  }
362
360
  /**
@@ -365,70 +363,71 @@ function setupBackwardCompatibility() {
365
363
  async function handleGlobalOptions(options) {
366
364
  // Set up logging
367
365
  if (options.verbose) {
368
- Logger_1.logger.setVerbose(true);
369
- Logger_1.logger.setLevel('debug');
366
+ logger.setVerbose(true);
367
+ logger.setLevel("debug");
370
368
  }
371
369
  // Handle cache disabling
372
370
  if (options.cache === false) {
373
- Cache_1.cache.clear();
371
+ cache.clear();
374
372
  }
375
373
  }
376
374
  function parseOperations(operationsStr) {
377
375
  const operationMap = {
378
- 'review': 'review',
379
- 'enhance': 'enhance-description',
380
- 'enhance-description': 'enhance-description',
381
- 'security': 'security-scan',
382
- 'security-scan': 'security-scan',
383
- 'analytics': 'analytics',
384
- 'all': 'all'
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",
385
383
  };
386
- return operationsStr.split(',')
387
- .map(op => op.trim())
388
- .map(op => operationMap[op] || op)
389
- .filter(op => op);
384
+ return operationsStr
385
+ .split(",")
386
+ .map((op) => op.trim())
387
+ .map((op) => operationMap[op] || op)
388
+ .filter((op) => op);
390
389
  }
391
390
  function logStreamUpdate(update) {
392
391
  const timestamp = new Date(update.timestamp).toLocaleTimeString();
393
- const progressStr = update.progress ? ` (${update.progress}%)` : '';
392
+ const progressStr = update.progress ? ` (${update.progress}%)` : "";
394
393
  switch (update.status) {
395
- case 'started':
396
- console.log(chalk_1.default.blue(`šŸš€ [${timestamp}] ${update.operation}: ${update.message}`));
394
+ case "started":
395
+ console.log(chalk.blue(`šŸš€ [${timestamp}] ${update.operation}: ${update.message}`));
397
396
  break;
398
- case 'progress':
399
- console.log(chalk_1.default.yellow(`šŸ”„ [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
397
+ case "progress":
398
+ console.log(chalk.yellow(`šŸ”„ [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
400
399
  break;
401
- case 'completed':
402
- console.log(chalk_1.default.green(`āœ… [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
400
+ case "completed":
401
+ console.log(chalk.green(`āœ… [${timestamp}] ${update.operation}: ${update.message}${progressStr}`));
403
402
  break;
404
- case 'error':
405
- console.log(chalk_1.default.red(`āŒ [${timestamp}] ${update.operation}: ${update.message}`));
403
+ case "error":
404
+ console.log(chalk.red(`āŒ [${timestamp}] ${update.operation}: ${update.message}`));
406
405
  break;
407
406
  }
408
407
  }
409
408
  function printProcessResult(result) {
410
- console.log(chalk_1.default.cyan('\nšŸ›”ļø Yama Process Result\n'));
409
+ console.log(chalk.cyan("\nšŸ›”ļø Yama Process Result\n"));
411
410
  console.log(`PR: #${result.pullRequest.id} - ${result.pullRequest.title}`);
412
411
  console.log(`Author: ${result.pullRequest.author}`);
413
412
  console.log(`Operations: ${result.operations.length}`);
414
- console.log('\nšŸ“Š Summary:');
413
+ console.log("\nšŸ“Š Summary:");
415
414
  console.log(`āœ… Success: ${result.summary.successCount}`);
416
415
  console.log(`āŒ Errors: ${result.summary.errorCount}`);
417
416
  console.log(`ā­ļø Skipped: ${result.summary.skippedCount}`);
418
417
  console.log(`ā±ļø Total Duration: ${Math.round(result.summary.totalDuration / 1000)}s`);
419
418
  // Show individual operation results
420
- console.log('\nšŸ“‹ Operations:');
419
+ console.log("\nšŸ“‹ Operations:");
421
420
  result.operations.forEach((op) => {
422
- const emoji = op.status === 'success' ? 'āœ…' : op.status === 'error' ? 'āŒ' : 'ā­ļø';
421
+ const emoji = op.status === "success" ? "āœ…" : op.status === "error" ? "āŒ" : "ā­ļø";
423
422
  console.log(` ${emoji} ${op.operation}: ${op.status} (${Math.round(op.duration / 1000)}s)`);
424
423
  if (op.error) {
425
- console.log(chalk_1.default.red(` Error: ${op.error}`));
424
+ console.log(chalk.red(` Error: ${op.error}`));
426
425
  }
427
426
  });
428
427
  }
429
428
  function printReviewResult(result) {
430
429
  const stats = result.statistics;
431
- console.log(chalk_1.default.cyan('\nšŸ›”ļø Code Review Results\n'));
430
+ console.log(chalk.cyan("\nšŸ›”ļø Code Review Results\n"));
432
431
  console.log(`šŸ“Š Total Issues: ${stats.totalIssues}`);
433
432
  console.log(`🚨 Critical: ${stats.criticalCount}`);
434
433
  console.log(`āš ļø Major: ${stats.majorCount}`);
@@ -436,78 +435,78 @@ function printReviewResult(result) {
436
435
  console.log(`šŸ’” Suggestions: ${stats.suggestionCount}`);
437
436
  console.log(`šŸ“ Files Reviewed: ${stats.filesReviewed}`);
438
437
  if (stats.criticalCount > 0) {
439
- 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!"));
440
439
  }
441
440
  else if (stats.majorCount > 0) {
442
- 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"));
443
442
  }
444
443
  else if (stats.minorCount > 0) {
445
- console.log(chalk_1.default.blue('\nšŸ“ Minor improvements suggested'));
444
+ console.log(chalk.blue("\nšŸ“ Minor improvements suggested"));
446
445
  }
447
446
  else {
448
- console.log(chalk_1.default.green('\nāœ… Code quality approved!'));
447
+ console.log(chalk.green("\nāœ… Code quality approved!"));
449
448
  }
450
449
  }
451
450
  function printEnhancementResult(result) {
452
- console.log(chalk_1.default.cyan('\nšŸ“ Description Enhancement Results\n'));
451
+ console.log(chalk.cyan("\nšŸ“ Description Enhancement Results\n"));
453
452
  console.log(`šŸ“ Original Length: ${result.statistics.originalLength} characters`);
454
453
  console.log(`šŸ“ Enhanced Length: ${result.statistics.enhancedLength} characters`);
455
454
  console.log(`šŸ“‹ Sections Completed: ${result.statistics.completedSections}/${result.statistics.totalSections}`);
456
455
  if (result.sectionsAdded.length > 0) {
457
- console.log(`āž• Sections Added: ${result.sectionsAdded.join(', ')}`);
456
+ console.log(`āž• Sections Added: ${result.sectionsAdded.join(", ")}`);
458
457
  }
459
458
  if (result.sectionsEnhanced.length > 0) {
460
- console.log(`✨ Sections Enhanced: ${result.sectionsEnhanced.join(', ')}`);
459
+ console.log(`✨ Sections Enhanced: ${result.sectionsEnhanced.join(", ")}`);
461
460
  }
462
461
  console.log(`šŸ“Ž Content Preserved: ${result.preservedItems.media} media, ${result.preservedItems.files} files, ${result.preservedItems.links} links`);
463
462
  if (result.statistics.completedSections === result.statistics.totalSections) {
464
- console.log(chalk_1.default.green('\nāœ… All required sections completed!'));
463
+ console.log(chalk.green("\nāœ… All required sections completed!"));
465
464
  }
466
465
  else {
467
- 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"));
468
467
  }
469
468
  }
470
469
  async function interactiveInit() {
471
- console.log(chalk_1.default.cyan('\nšŸ›”ļø Yama Interactive Setup\n'));
472
- await inquirer_1.default.prompt([
470
+ console.log(chalk.cyan("\nšŸ›”ļø Yama Interactive Setup\n"));
471
+ await inquirer.prompt([
473
472
  {
474
- type: 'input',
475
- name: 'workspace',
476
- message: 'Default Bitbucket workspace:',
477
- default: 'YOUR_WORKSPACE'
473
+ type: "input",
474
+ name: "workspace",
475
+ message: "Default Bitbucket workspace:",
476
+ default: "YOUR_WORKSPACE",
478
477
  },
479
478
  {
480
- type: 'input',
481
- name: 'baseUrl',
482
- message: 'Bitbucket server URL:',
483
- default: 'https://your-bitbucket-server.com'
479
+ type: "input",
480
+ name: "baseUrl",
481
+ message: "Bitbucket server URL:",
482
+ default: "https://your-bitbucket-server.com",
484
483
  },
485
484
  {
486
- type: 'list',
487
- name: 'aiProvider',
488
- message: 'AI provider:',
489
- choices: ['auto', 'google-ai', 'openai', 'anthropic'],
490
- default: 'auto'
485
+ type: "list",
486
+ name: "aiProvider",
487
+ message: "AI provider:",
488
+ choices: ["auto", "google-ai", "openai", "anthropic"],
489
+ default: "auto",
491
490
  },
492
491
  {
493
- type: 'confirm',
494
- name: 'enableAnalytics',
495
- message: 'Enable AI analytics:',
496
- default: true
492
+ type: "confirm",
493
+ name: "enableAnalytics",
494
+ message: "Enable AI analytics:",
495
+ default: true,
497
496
  },
498
497
  {
499
- type: 'confirm',
500
- name: 'enableCache',
501
- message: 'Enable caching:',
502
- default: true
503
- }
498
+ type: "confirm",
499
+ name: "enableCache",
500
+ message: "Enable caching:",
501
+ default: true,
502
+ },
504
503
  ]);
505
- const configPath = await ConfigManager_1.configManager.createDefaultConfig();
506
- console.log(chalk_1.default.green(`\nāœ… Configuration created: ${configPath}`));
507
- console.log(chalk_1.default.yellow('šŸ’” Don\'t forget to set your environment variables:'));
508
- console.log(chalk_1.default.blue(' BITBUCKET_USERNAME=your-username'));
509
- console.log(chalk_1.default.blue(' BITBUCKET_TOKEN=your-token'));
510
- 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"));
511
510
  }
512
511
  /**
513
512
  * Main execution
@@ -522,16 +521,18 @@ function main() {
522
521
  }
523
522
  }
524
523
  // Handle uncaught errors
525
- process.on('uncaughtException', (error) => {
526
- console.error(chalk_1.default.red(`\nšŸ’„ Uncaught Exception: ${error.message}`));
524
+ process.on("uncaughtException", (error) => {
525
+ console.error(chalk.red(`\nšŸ’„ Uncaught Exception: ${error.message}`));
527
526
  process.exit(1);
528
527
  });
529
- process.on('unhandledRejection', (reason) => {
530
- console.error(chalk_1.default.red(`\nšŸ’„ Unhandled Rejection: ${reason}`));
528
+ process.on("unhandledRejection", (reason) => {
529
+ console.error(chalk.red(`\nšŸ’„ Unhandled Rejection: ${reason}`));
531
530
  process.exit(1);
532
531
  });
533
532
  // Run if this is the main module
534
- if (require.main === module) {
533
+ const __filename = fileURLToPath(import.meta.url);
534
+ if (process.argv[1] === __filename) {
535
535
  main();
536
536
  }
537
+ export { main };
537
538
  //# sourceMappingURL=index.js.map