@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.
@@ -1,23 +1,150 @@
1
- "use strict";
2
1
  /**
3
2
  * Enhanced Configuration Manager for Yama
4
3
  * Handles configuration loading, validation, and merging from multiple sources
5
4
  */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.configManager = exports.ConfigManager = void 0;
11
- exports.createConfigManager = createConfigManager;
12
- const fs_1 = __importDefault(require("fs"));
13
- const path_1 = __importDefault(require("path"));
14
- const yaml_1 = __importDefault(require("yaml"));
15
- const types_1 = require("../types");
16
- const Logger_1 = require("./Logger");
17
- class ConfigManager {
5
+ import fs from "fs";
6
+ import path from "path";
7
+ import yaml from "yaml";
8
+ import { homedir } from "os";
9
+ import { ConfigurationError } from "../types/index.js";
10
+ import { logger } from "./Logger.js";
11
+ export class ConfigManager {
12
+ config = null;
13
+ configPaths = [];
14
+ /**
15
+ * Default configuration
16
+ */
17
+ static DEFAULT_CONFIG = {
18
+ providers: {
19
+ ai: {
20
+ provider: "auto",
21
+ enableFallback: true,
22
+ enableAnalytics: false,
23
+ enableEvaluation: false,
24
+ timeout: "10m",
25
+ retryAttempts: 3,
26
+ temperature: 0.3,
27
+ maxTokens: 1000000,
28
+ },
29
+ git: {
30
+ platform: "bitbucket",
31
+ credentials: {
32
+ username: process.env.BITBUCKET_USERNAME || "",
33
+ token: process.env.BITBUCKET_TOKEN || "",
34
+ baseUrl: process.env.BITBUCKET_BASE_URL ||
35
+ "https://your-bitbucket-server.com",
36
+ },
37
+ },
38
+ },
39
+ features: {
40
+ codeReview: {
41
+ enabled: true,
42
+ severityLevels: ["CRITICAL", "MAJOR", "MINOR", "SUGGESTION"],
43
+ categories: [
44
+ "security",
45
+ "performance",
46
+ "maintainability",
47
+ "functionality",
48
+ "error_handling",
49
+ "testing",
50
+ ],
51
+ excludePatterns: ["*.lock", "*.svg", "*.min.js", "*.map"],
52
+ contextLines: 3,
53
+ systemPrompt: "You are an Expert Security Code Reviewer for enterprise applications. Your role is to:\n\n๐Ÿ”’ SECURITY FIRST: Prioritize security vulnerabilities and data protection\nโšก PERFORMANCE AWARE: Identify performance bottlenecks and optimization opportunities\n๐Ÿ—๏ธ QUALITY FOCUSED: Ensure maintainable, readable, and robust code\n๐Ÿ›ก๏ธ ERROR RESILIENT: Verify comprehensive error handling and edge cases\n\nYou provide actionable, educational feedback with specific examples and solutions.\nFocus on critical issues that could impact production systems.",
54
+ focusAreas: [
55
+ "๐Ÿ”’ Security Analysis (CRITICAL PRIORITY)",
56
+ "โšก Performance Review",
57
+ "๐Ÿ—๏ธ Code Quality",
58
+ "๐Ÿงช Testing & Error Handling",
59
+ ],
60
+ },
61
+ descriptionEnhancement: {
62
+ enabled: true,
63
+ preserveContent: true,
64
+ requiredSections: [
65
+ {
66
+ key: "changelog",
67
+ name: "Changelog (Modules Modified)",
68
+ required: true,
69
+ },
70
+ {
71
+ key: "testcases",
72
+ name: "Test Cases (What to be tested)",
73
+ required: true,
74
+ },
75
+ {
76
+ key: "config_changes",
77
+ name: "CAC Config Or Service Config Changes",
78
+ required: true,
79
+ },
80
+ ],
81
+ autoFormat: true,
82
+ systemPrompt: "You are an Expert Technical Writer specializing in pull request documentation. Your role is to:\n\n๐Ÿ“ CLARITY FIRST: Create clear, comprehensive PR descriptions that help reviewers understand the changes\n๐ŸŽฅ STORY TELLING: Explain the 'why' behind changes, not just the 'what'\n๐Ÿ“ˆ STRUCTURED: Follow consistent formatting with required sections\n๐Ÿ”— CONTEXTUAL: Link changes to business value and technical rationale\n\nCRITICAL INSTRUCTION: Return ONLY the enhanced PR description content as clean markdown. Do NOT include any meta-commentary, explanations about what you're doing, or introductory text like \"I will enhance...\" or \"Here is the enhanced description:\". \n\nOutput the enhanced description directly without any wrapper text or explanations.",
83
+ outputTemplate: "# PR Title Enhancement (if needed)\n\n## Summary\n[Clear overview of what this PR accomplishes]\n\n## Changes Made\n[Specific technical changes - be precise]\n\n## Testing\n[How the changes were tested]\n\n## Impact\n[Business/technical impact and considerations]\n\n## Additional Notes\n[Any deployment notes, follow-ups, or special considerations]",
84
+ enhancementInstructions: 'Return ONLY the enhanced PR description as clean markdown. Do NOT include any explanatory text, meta-commentary, or phrases like "Here is the enhanced description:" or "I will enhance...".\n\nStart directly with the enhanced description content using this structure:',
85
+ },
86
+ securityScan: {
87
+ enabled: true,
88
+ level: "strict",
89
+ scanTypes: ["secrets", "vulnerabilities", "dependencies"],
90
+ },
91
+ analytics: {
92
+ enabled: true,
93
+ trackMetrics: true,
94
+ exportFormat: "json",
95
+ },
96
+ },
97
+ cache: {
98
+ enabled: true,
99
+ ttl: "1h",
100
+ maxSize: "100MB",
101
+ storage: "memory",
102
+ },
103
+ performance: {
104
+ batch: {
105
+ enabled: true,
106
+ maxConcurrent: 5,
107
+ delayBetween: "1s",
108
+ },
109
+ optimization: {
110
+ reuseConnections: true,
111
+ compressRequests: true,
112
+ enableHttp2: true,
113
+ },
114
+ },
115
+ rules: {
116
+ security: [
117
+ {
118
+ name: "No hardcoded secrets",
119
+ pattern: "(password|secret|key|token)\\s*[=:]\\s*['\"][^'\"]{8,}['\"]",
120
+ severity: "CRITICAL",
121
+ message: "Hardcoded secrets detected",
122
+ suggestion: "Use environment variables or secure configuration management",
123
+ },
124
+ ],
125
+ performance: [
126
+ {
127
+ name: "Avoid N+1 queries",
128
+ pattern: "for.*\\.(find|get|query|select)",
129
+ severity: "MAJOR",
130
+ message: "Potential N+1 query pattern detected",
131
+ suggestion: "Consider using batch queries or joins",
132
+ },
133
+ ],
134
+ },
135
+ reporting: {
136
+ formats: ["markdown", "json"],
137
+ includeAnalytics: true,
138
+ includeMetrics: true,
139
+ },
140
+ monitoring: {
141
+ enabled: true,
142
+ metrics: ["performance", "cache", "api_calls"],
143
+ exportFormat: "json",
144
+ interval: "5m",
145
+ },
146
+ };
18
147
  constructor() {
19
- this.config = null;
20
- this.configPaths = [];
21
148
  this.setupConfigPaths();
22
149
  }
23
150
  /**
@@ -25,20 +152,20 @@ class ConfigManager {
25
152
  */
26
153
  setupConfigPaths() {
27
154
  const cwd = process.cwd();
28
- const homeDir = require("os").homedir();
155
+ const homeDir = homedir();
29
156
  this.configPaths = [
30
- path_1.default.join(cwd, "yama.config.yaml"),
31
- path_1.default.join(cwd, "yama.config.yml"),
32
- path_1.default.join(cwd, "yama.config.json"),
33
- path_1.default.join(cwd, ".yama.yaml"),
34
- path_1.default.join(cwd, ".yama.yml"),
35
- path_1.default.join(cwd, ".yama.json"),
36
- path_1.default.join(homeDir, ".yama", "config.yaml"),
37
- path_1.default.join(homeDir, ".yama", "config.yml"),
38
- path_1.default.join(homeDir, ".yama", "config.json"),
39
- path_1.default.join(homeDir, ".config", "yama", "config.yaml"),
40
- path_1.default.join(homeDir, ".config", "yama", "config.yml"),
41
- path_1.default.join(homeDir, ".config", "yama", "config.json"),
157
+ path.join(cwd, "yama.config.yaml"),
158
+ path.join(cwd, "yama.config.yml"),
159
+ path.join(cwd, "yama.config.json"),
160
+ path.join(cwd, ".yama.yaml"),
161
+ path.join(cwd, ".yama.yml"),
162
+ path.join(cwd, ".yama.json"),
163
+ path.join(homeDir, ".yama", "config.yaml"),
164
+ path.join(homeDir, ".yama", "config.yml"),
165
+ path.join(homeDir, ".yama", "config.json"),
166
+ path.join(homeDir, ".config", "yama", "config.yaml"),
167
+ path.join(homeDir, ".config", "yama", "config.yml"),
168
+ path.join(homeDir, ".config", "yama", "config.json"),
42
169
  ];
43
170
  }
44
171
  /**
@@ -48,30 +175,30 @@ class ConfigManager {
48
175
  if (this.config) {
49
176
  return this.config;
50
177
  }
51
- Logger_1.logger.debug("Loading Yama configuration...");
178
+ logger.debug("Loading Yama configuration...");
52
179
  // Start with default config
53
180
  let config = this.deepClone(ConfigManager.DEFAULT_CONFIG);
54
181
  // If specific config path provided, use only that
55
182
  if (configPath) {
56
- if (!fs_1.default.existsSync(configPath)) {
57
- throw new types_1.ConfigurationError(`Configuration file not found: ${configPath}`);
183
+ if (!fs.existsSync(configPath)) {
184
+ throw new ConfigurationError(`Configuration file not found: ${configPath}`);
58
185
  }
59
186
  const fileConfig = await this.loadConfigFile(configPath);
60
187
  config = this.mergeConfigs(config, fileConfig);
61
- Logger_1.logger.debug(`Loaded configuration from: ${configPath}`);
188
+ logger.debug(`Loaded configuration from: ${configPath}`);
62
189
  }
63
190
  else {
64
191
  // Search for config files in predefined paths
65
192
  for (const configFilePath of this.configPaths) {
66
- if (fs_1.default.existsSync(configFilePath)) {
193
+ if (fs.existsSync(configFilePath)) {
67
194
  try {
68
195
  const fileConfig = await this.loadConfigFile(configFilePath);
69
196
  config = this.mergeConfigs(config, fileConfig);
70
- Logger_1.logger.debug(`Loaded configuration from: ${configFilePath}`);
197
+ logger.debug(`Loaded configuration from: ${configFilePath}`);
71
198
  break;
72
199
  }
73
200
  catch (error) {
74
- Logger_1.logger.warn(`Failed to load config from ${configFilePath}:`, error);
201
+ logger.warn(`Failed to load config from ${configFilePath}:`, error);
75
202
  }
76
203
  }
77
204
  }
@@ -81,7 +208,7 @@ class ConfigManager {
81
208
  // Validate configuration
82
209
  this.validateConfig(config);
83
210
  this.config = config;
84
- Logger_1.logger.debug("Configuration loaded successfully");
211
+ logger.debug("Configuration loaded successfully");
85
212
  return config;
86
213
  }
87
214
  /**
@@ -89,20 +216,20 @@ class ConfigManager {
89
216
  */
90
217
  async loadConfigFile(filePath) {
91
218
  try {
92
- const content = fs_1.default.readFileSync(filePath, "utf8");
93
- const ext = path_1.default.extname(filePath).toLowerCase();
219
+ const content = fs.readFileSync(filePath, "utf8");
220
+ const ext = path.extname(filePath).toLowerCase();
94
221
  switch (ext) {
95
222
  case ".yaml":
96
223
  case ".yml":
97
- return yaml_1.default.parse(content);
224
+ return yaml.parse(content);
98
225
  case ".json":
99
226
  return JSON.parse(content);
100
227
  default:
101
- throw new types_1.ConfigurationError(`Unsupported config file format: ${ext}`);
228
+ throw new ConfigurationError(`Unsupported config file format: ${ext}`);
102
229
  }
103
230
  }
104
231
  catch (error) {
105
- throw new types_1.ConfigurationError(`Failed to parse config file ${filePath}: ${error.message}`);
232
+ throw new ConfigurationError(`Failed to parse config file ${filePath}: ${error.message}`);
106
233
  }
107
234
  }
108
235
  /**
@@ -163,10 +290,10 @@ class ConfigManager {
163
290
  }
164
291
  // Debug mode
165
292
  if (env.GUARDIAN_DEBUG === "true") {
166
- Logger_1.logger.setLevel("debug");
167
- Logger_1.logger.setVerbose(true);
293
+ logger.setLevel("debug");
294
+ logger.setVerbose(true);
168
295
  }
169
- Logger_1.logger.debug("Applied environment variable overrides");
296
+ logger.debug("Applied environment variable overrides");
170
297
  return config;
171
298
  }
172
299
  /**
@@ -203,9 +330,9 @@ class ConfigManager {
203
330
  }
204
331
  }
205
332
  if (errors.length > 0) {
206
- throw new types_1.ConfigurationError(`Configuration validation failed:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
333
+ throw new ConfigurationError(`Configuration validation failed:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
207
334
  }
208
- Logger_1.logger.debug("Configuration validation passed");
335
+ logger.debug("Configuration validation passed");
209
336
  }
210
337
  /**
211
338
  * Merge two configuration objects deeply
@@ -241,7 +368,7 @@ class ConfigManager {
241
368
  */
242
369
  getConfig() {
243
370
  if (!this.config) {
244
- throw new types_1.ConfigurationError("Configuration not loaded. Call loadConfig() first.");
371
+ throw new ConfigurationError("Configuration not loaded. Call loadConfig() first.");
245
372
  }
246
373
  return this.config;
247
374
  }
@@ -249,15 +376,15 @@ class ConfigManager {
249
376
  * Create default configuration file
250
377
  */
251
378
  async createDefaultConfig(outputPath) {
252
- const defaultPath = outputPath || path_1.default.join(process.cwd(), "yama.config.yaml");
253
- const configContent = yaml_1.default.stringify(ConfigManager.DEFAULT_CONFIG, {
379
+ const defaultPath = outputPath || path.join(process.cwd(), "yama.config.yaml");
380
+ const configContent = yaml.stringify(ConfigManager.DEFAULT_CONFIG, {
254
381
  indent: 2,
255
382
  lineWidth: 100,
256
383
  });
257
384
  // Add comments to make the config file more user-friendly
258
385
  const commentedConfig = this.addConfigComments(configContent);
259
- fs_1.default.writeFileSync(defaultPath, commentedConfig, "utf8");
260
- Logger_1.logger.info(`Default configuration created at: ${defaultPath}`);
386
+ fs.writeFileSync(defaultPath, commentedConfig, "utf8");
387
+ logger.info(`Default configuration created at: ${defaultPath}`);
261
388
  return defaultPath;
262
389
  }
263
390
  /**
@@ -303,7 +430,7 @@ class ConfigManager {
303
430
  }
304
431
  }
305
432
  catch (error) {
306
- Logger_1.logger.error(`Validation failed for section ${section}:`, error);
433
+ logger.error(`Validation failed for section ${String(section)}:`, error);
307
434
  return false;
308
435
  }
309
436
  }
@@ -401,7 +528,7 @@ class ConfigManager {
401
528
  */
402
529
  findConfigFile() {
403
530
  for (const configPath of this.configPaths) {
404
- if (fs_1.default.existsSync(configPath)) {
531
+ if (fs.existsSync(configPath)) {
405
532
  return configPath;
406
533
  }
407
534
  }
@@ -412,32 +539,32 @@ class ConfigManager {
412
539
  */
413
540
  watchConfig(callback) {
414
541
  if (!this.configPaths.length) {
415
- Logger_1.logger.warn("No configuration file found to watch");
542
+ logger.warn("No configuration file found to watch");
416
543
  return () => { };
417
544
  }
418
545
  const configPath = this.findConfigFile();
419
546
  if (!configPath) {
420
- Logger_1.logger.warn("No configuration file found to watch");
547
+ logger.warn("No configuration file found to watch");
421
548
  return () => { };
422
549
  }
423
- Logger_1.logger.debug(`Watching configuration file: ${configPath}`);
424
- fs_1.default.watchFile(configPath, { interval: 1000 }, async () => {
550
+ logger.debug(`Watching configuration file: ${configPath}`);
551
+ fs.watchFile(configPath, { interval: 1000 }, async () => {
425
552
  try {
426
- Logger_1.logger.info("Configuration file changed, reloading...");
553
+ logger.info("Configuration file changed, reloading...");
427
554
  const newConfig = await this.loadConfig();
428
555
  if (callback) {
429
556
  callback(newConfig);
430
557
  }
431
- Logger_1.logger.success("Configuration reloaded successfully");
558
+ logger.success("Configuration reloaded successfully");
432
559
  }
433
560
  catch (error) {
434
- Logger_1.logger.error(`Failed to reload configuration: ${error.message}`);
561
+ logger.error(`Failed to reload configuration: ${error.message}`);
435
562
  }
436
563
  });
437
564
  // Return cleanup function
438
565
  return () => {
439
- fs_1.default.unwatchFile(configPath);
440
- Logger_1.logger.debug("Stopped watching configuration file");
566
+ fs.unwatchFile(configPath);
567
+ logger.debug("Stopped watching configuration file");
441
568
  };
442
569
  }
443
570
  /**
@@ -447,144 +574,10 @@ class ConfigManager {
447
574
  return this.watchConfig(callback);
448
575
  }
449
576
  }
450
- exports.ConfigManager = ConfigManager;
451
- /**
452
- * Default configuration
453
- */
454
- ConfigManager.DEFAULT_CONFIG = {
455
- providers: {
456
- ai: {
457
- provider: "auto",
458
- enableFallback: true,
459
- enableAnalytics: false,
460
- enableEvaluation: false,
461
- timeout: "10m",
462
- retryAttempts: 3,
463
- temperature: 0.3,
464
- maxTokens: 1000000,
465
- },
466
- git: {
467
- platform: "bitbucket",
468
- credentials: {
469
- username: process.env.BITBUCKET_USERNAME || "",
470
- token: process.env.BITBUCKET_TOKEN || "",
471
- baseUrl: process.env.BITBUCKET_BASE_URL ||
472
- "https://your-bitbucket-server.com",
473
- },
474
- },
475
- },
476
- features: {
477
- codeReview: {
478
- enabled: true,
479
- severityLevels: ["CRITICAL", "MAJOR", "MINOR", "SUGGESTION"],
480
- categories: [
481
- "security",
482
- "performance",
483
- "maintainability",
484
- "functionality",
485
- "error_handling",
486
- "testing",
487
- ],
488
- excludePatterns: ["*.lock", "*.svg", "*.min.js", "*.map"],
489
- contextLines: 3,
490
- systemPrompt: "You are an Expert Security Code Reviewer for enterprise applications. Your role is to:\n\n๐Ÿ”’ SECURITY FIRST: Prioritize security vulnerabilities and data protection\nโšก PERFORMANCE AWARE: Identify performance bottlenecks and optimization opportunities\n๐Ÿ—๏ธ QUALITY FOCUSED: Ensure maintainable, readable, and robust code\n๐Ÿ›ก๏ธ ERROR RESILIENT: Verify comprehensive error handling and edge cases\n\nYou provide actionable, educational feedback with specific examples and solutions.\nFocus on critical issues that could impact production systems.",
491
- focusAreas: [
492
- "๐Ÿ”’ Security Analysis (CRITICAL PRIORITY)",
493
- "โšก Performance Review",
494
- "๐Ÿ—๏ธ Code Quality",
495
- "๐Ÿงช Testing & Error Handling",
496
- ],
497
- },
498
- descriptionEnhancement: {
499
- enabled: true,
500
- preserveContent: true,
501
- requiredSections: [
502
- {
503
- key: "changelog",
504
- name: "Changelog (Modules Modified)",
505
- required: true,
506
- },
507
- {
508
- key: "testcases",
509
- name: "Test Cases (What to be tested)",
510
- required: true,
511
- },
512
- {
513
- key: "config_changes",
514
- name: "CAC Config Or Service Config Changes",
515
- required: true,
516
- },
517
- ],
518
- autoFormat: true,
519
- systemPrompt: "You are an Expert Technical Writer specializing in pull request documentation. Your role is to:\n\n๐Ÿ“ CLARITY FIRST: Create clear, comprehensive PR descriptions that help reviewers understand the changes\n๐ŸŽฅ STORY TELLING: Explain the 'why' behind changes, not just the 'what'\n๐Ÿ“ˆ STRUCTURED: Follow consistent formatting with required sections\n๐Ÿ”— CONTEXTUAL: Link changes to business value and technical rationale\n\nCRITICAL INSTRUCTION: Return ONLY the enhanced PR description content as clean markdown. Do NOT include any meta-commentary, explanations about what you're doing, or introductory text like \"I will enhance...\" or \"Here is the enhanced description:\". \n\nOutput the enhanced description directly without any wrapper text or explanations.",
520
- outputTemplate: "# PR Title Enhancement (if needed)\n\n## Summary\n[Clear overview of what this PR accomplishes]\n\n## Changes Made\n[Specific technical changes - be precise]\n\n## Testing\n[How the changes were tested]\n\n## Impact\n[Business/technical impact and considerations]\n\n## Additional Notes\n[Any deployment notes, follow-ups, or special considerations]",
521
- enhancementInstructions: 'Return ONLY the enhanced PR description as clean markdown. Do NOT include any explanatory text, meta-commentary, or phrases like "Here is the enhanced description:" or "I will enhance...".\n\nStart directly with the enhanced description content using this structure:',
522
- },
523
- securityScan: {
524
- enabled: true,
525
- level: "strict",
526
- scanTypes: ["secrets", "vulnerabilities", "dependencies"],
527
- },
528
- analytics: {
529
- enabled: true,
530
- trackMetrics: true,
531
- exportFormat: "json",
532
- },
533
- },
534
- cache: {
535
- enabled: true,
536
- ttl: "1h",
537
- maxSize: "100MB",
538
- storage: "memory",
539
- },
540
- performance: {
541
- batch: {
542
- enabled: true,
543
- maxConcurrent: 5,
544
- delayBetween: "1s",
545
- },
546
- optimization: {
547
- reuseConnections: true,
548
- compressRequests: true,
549
- enableHttp2: true,
550
- },
551
- },
552
- rules: {
553
- security: [
554
- {
555
- name: "No hardcoded secrets",
556
- pattern: "(password|secret|key|token)\\s*[=:]\\s*['\"][^'\"]{8,}['\"]",
557
- severity: "CRITICAL",
558
- message: "Hardcoded secrets detected",
559
- suggestion: "Use environment variables or secure configuration management",
560
- },
561
- ],
562
- performance: [
563
- {
564
- name: "Avoid N+1 queries",
565
- pattern: "for.*\\.(find|get|query|select)",
566
- severity: "MAJOR",
567
- message: "Potential N+1 query pattern detected",
568
- suggestion: "Consider using batch queries or joins",
569
- },
570
- ],
571
- },
572
- reporting: {
573
- formats: ["markdown", "json"],
574
- includeAnalytics: true,
575
- includeMetrics: true,
576
- },
577
- monitoring: {
578
- enabled: true,
579
- metrics: ["performance", "cache", "api_calls"],
580
- exportFormat: "json",
581
- interval: "5m",
582
- },
583
- };
584
577
  // Export singleton instance
585
- exports.configManager = new ConfigManager();
578
+ export const configManager = new ConfigManager();
586
579
  // Export factory function
587
- function createConfigManager() {
580
+ export function createConfigManager() {
588
581
  return new ConfigManager();
589
582
  }
590
583
  //# sourceMappingURL=ConfigManager.js.map
@@ -2,7 +2,7 @@
2
2
  * Enhanced Logger utility - Optimized from both pr-police.js and pr-describe.js
3
3
  * Provides consistent logging across all Guardian operations
4
4
  */
5
- import { Logger as ILogger, LogLevel, LoggerOptions } from "../types";
5
+ import { Logger as ILogger, LogLevel, LoggerOptions } from "../types/index.js";
6
6
  export declare class Logger implements ILogger {
7
7
  private options;
8
8
  constructor(options?: Partial<LoggerOptions>);
@@ -1,15 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * Enhanced Logger utility - Optimized from both pr-police.js and pr-describe.js
4
3
  * Provides consistent logging across all Guardian operations
5
4
  */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.logger = exports.Logger = void 0;
11
- exports.createLogger = createLogger;
12
- const chalk_1 = __importDefault(require("chalk"));
5
+ import chalk from "chalk";
13
6
  const YAMA_BADGE = `
14
7
  โš”๏ธ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• โš”๏ธ
15
8
  โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—
@@ -21,7 +14,8 @@ const YAMA_BADGE = `
21
14
  โš”๏ธ โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• โš”๏ธ
22
15
  AI-Powered PR Automation โ€ข Enterprise Security โ€ข Code Quality Yama
23
16
  `;
24
- class Logger {
17
+ export class Logger {
18
+ options;
25
19
  constructor(options = {}) {
26
20
  this.options = {
27
21
  level: "info",
@@ -67,13 +61,13 @@ class Logger {
67
61
  }
68
62
  switch (level) {
69
63
  case "debug":
70
- return chalk_1.default.gray(text);
64
+ return chalk.gray(text);
71
65
  case "info":
72
- return chalk_1.default.blue(text);
66
+ return chalk.blue(text);
73
67
  case "warn":
74
- return chalk_1.default.yellow(text);
68
+ return chalk.yellow(text);
75
69
  case "error":
76
- return chalk_1.default.red(text);
70
+ return chalk.red(text);
77
71
  default:
78
72
  return text;
79
73
  }
@@ -107,22 +101,22 @@ class Logger {
107
101
  console.error(this.colorize("error", formatted));
108
102
  }
109
103
  badge() {
110
- console.log(chalk_1.default.cyan(YAMA_BADGE));
104
+ console.log(chalk.cyan(YAMA_BADGE));
111
105
  }
112
106
  phase(message) {
113
107
  const formatted = `\n๐Ÿ”„ ${message}`;
114
- console.log(this.options.colors ? chalk_1.default.magenta(formatted) : formatted);
108
+ console.log(this.options.colors ? chalk.magenta(formatted) : formatted);
115
109
  }
116
110
  success(message) {
117
111
  const formatted = `โœ… ${message}`;
118
- console.log(this.options.colors ? chalk_1.default.green(formatted) : formatted);
112
+ console.log(this.options.colors ? chalk.green(formatted) : formatted);
119
113
  }
120
114
  operation(operation, status) {
121
115
  const emoji = status === "started" ? "๐Ÿš€" : status === "completed" ? "โœ…" : "โŒ";
122
116
  const color = status === "started" ? "blue" : status === "completed" ? "green" : "red";
123
117
  const message = `${emoji} ${operation.toUpperCase()}: ${status}`;
124
118
  if (this.options.colors) {
125
- console.log(chalk_1.default[color](message));
119
+ console.log(chalk[color](message));
126
120
  }
127
121
  else {
128
122
  console.log(message);
@@ -144,7 +138,7 @@ class Logger {
144
138
  const location = file ? ` in ${file}` : "";
145
139
  const formatted = `${emoji} ${severity}: ${message}${location}`;
146
140
  if (this.options.colors) {
147
- console.log(chalk_1.default[color](formatted));
141
+ console.log(chalk[color](formatted));
148
142
  }
149
143
  else {
150
144
  console.log(formatted);
@@ -166,7 +160,7 @@ class Logger {
166
160
  const filled = Math.round((percentage / 100) * width);
167
161
  const empty = width - filled;
168
162
  if (this.options.colors) {
169
- return chalk_1.default.green("โ–ˆ".repeat(filled)) + chalk_1.default.gray("โ–‘".repeat(empty));
163
+ return chalk.green("โ–ˆ".repeat(filled)) + chalk.gray("โ–‘".repeat(empty));
170
164
  }
171
165
  else {
172
166
  return "โ–ˆ".repeat(filled) + "โ–‘".repeat(empty);
@@ -201,7 +195,6 @@ class Logger {
201
195
  return { ...this.options };
202
196
  }
203
197
  }
204
- exports.Logger = Logger;
205
198
  // Export singleton instance for convenience with environment-aware defaults
206
199
  const loggerOptions = {};
207
200
  // Check environment variables for debug mode
@@ -209,9 +202,9 @@ if (process.env.YAMA_DEBUG === "true") {
209
202
  loggerOptions.level = "debug";
210
203
  loggerOptions.verbose = true;
211
204
  }
212
- exports.logger = new Logger(loggerOptions);
205
+ export const logger = new Logger(loggerOptions);
213
206
  // Export factory function
214
- function createLogger(options) {
207
+ export function createLogger(options) {
215
208
  return new Logger(options);
216
209
  }
217
210
  //# sourceMappingURL=Logger.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/yama",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Enterprise-grade Pull Request automation toolkit with AI-powered code review and description enhancement",
5
5
  "keywords": [
6
6
  "pr",