@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.
@@ -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>);
@@ -16,7 +16,7 @@ export declare class Logger implements ILogger {
16
16
  badge(): void;
17
17
  phase(message: string): void;
18
18
  success(message: string): void;
19
- operation(operation: string, status: 'started' | 'completed' | 'failed'): void;
19
+ operation(operation: string, status: "started" | "completed" | "failed"): void;
20
20
  violation(severity: string, message: string, file?: string): void;
21
21
  progress(current: number, total: number, operation: string): void;
22
22
  private createProgressBar;
@@ -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,14 +14,15 @@ 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
- level: 'info',
21
+ level: "info",
28
22
  verbose: false,
29
- format: 'simple',
23
+ format: "simple",
30
24
  colors: true,
31
- ...options
25
+ ...options,
32
26
  };
33
27
  }
34
28
  shouldLog(level) {
@@ -36,84 +30,93 @@ class Logger {
36
30
  debug: 0,
37
31
  info: 1,
38
32
  warn: 2,
39
- error: 3
33
+ error: 3,
40
34
  };
41
35
  return levels[level] >= levels[this.options.level];
42
36
  }
43
37
  formatMessage(level, message, ...args) {
44
38
  const timestamp = new Date().toISOString();
45
- const formattedArgs = args.length > 0 ? ` ${args.map(a => typeof a === 'object' ? JSON.stringify(a, null, 2) : String(a)).join(' ')}` : '';
39
+ const formattedArgs = args.length > 0
40
+ ? ` ${args
41
+ .map((a) => typeof a === "object" ? JSON.stringify(a, null, 2) : String(a))
42
+ .join(" ")}`
43
+ : "";
46
44
  switch (this.options.format) {
47
- case 'json':
45
+ case "json":
48
46
  return JSON.stringify({
49
47
  timestamp,
50
48
  level: level.toUpperCase(),
51
49
  message: message + formattedArgs,
52
- args: args.length > 0 ? args : undefined
50
+ args: args.length > 0 ? args : undefined,
53
51
  });
54
- case 'detailed':
52
+ case "detailed":
55
53
  return `[${timestamp}] [${level.toUpperCase().padEnd(5)}] ${message}${formattedArgs}`;
56
54
  default: // simple
57
55
  return `${message}${formattedArgs}`;
58
56
  }
59
57
  }
60
58
  colorize(level, text) {
61
- if (!this.options.colors)
59
+ if (!this.options.colors) {
62
60
  return text;
61
+ }
63
62
  switch (level) {
64
- case 'debug':
65
- return chalk_1.default.gray(text);
66
- case 'info':
67
- return chalk_1.default.blue(text);
68
- case 'warn':
69
- return chalk_1.default.yellow(text);
70
- case 'error':
71
- return chalk_1.default.red(text);
63
+ case "debug":
64
+ return chalk.gray(text);
65
+ case "info":
66
+ return chalk.blue(text);
67
+ case "warn":
68
+ return chalk.yellow(text);
69
+ case "error":
70
+ return chalk.red(text);
72
71
  default:
73
72
  return text;
74
73
  }
75
74
  }
76
75
  debug(message, ...args) {
77
- if (!this.shouldLog('debug') || !this.options.verbose)
76
+ if (!this.shouldLog("debug") || !this.options.verbose) {
78
77
  return;
79
- const formatted = this.formatMessage('debug', `🔍 ${message}`, ...args);
80
- console.log(this.colorize('debug', formatted));
78
+ }
79
+ const formatted = this.formatMessage("debug", `🔍 ${message}`, ...args);
80
+ console.log(this.colorize("debug", formatted));
81
81
  }
82
82
  info(message, ...args) {
83
- if (!this.shouldLog('info'))
83
+ if (!this.shouldLog("info")) {
84
84
  return;
85
- const formatted = this.formatMessage('info', `ℹ️ ${message}`, ...args);
86
- console.log(this.colorize('info', formatted));
85
+ }
86
+ const formatted = this.formatMessage("info", `ℹ️ ${message}`, ...args);
87
+ console.log(this.colorize("info", formatted));
87
88
  }
88
89
  warn(message, ...args) {
89
- if (!this.shouldLog('warn'))
90
+ if (!this.shouldLog("warn")) {
90
91
  return;
91
- const formatted = this.formatMessage('warn', `⚠️ ${message}`, ...args);
92
- console.warn(this.colorize('warn', formatted));
92
+ }
93
+ const formatted = this.formatMessage("warn", `⚠️ ${message}`, ...args);
94
+ console.warn(this.colorize("warn", formatted));
93
95
  }
94
96
  error(message, ...args) {
95
- if (!this.shouldLog('error'))
97
+ if (!this.shouldLog("error")) {
96
98
  return;
97
- const formatted = this.formatMessage('error', `❌ ${message}`, ...args);
98
- console.error(this.colorize('error', formatted));
99
+ }
100
+ const formatted = this.formatMessage("error", `❌ ${message}`, ...args);
101
+ console.error(this.colorize("error", formatted));
99
102
  }
100
103
  badge() {
101
- console.log(chalk_1.default.cyan(YAMA_BADGE));
104
+ console.log(chalk.cyan(YAMA_BADGE));
102
105
  }
103
106
  phase(message) {
104
107
  const formatted = `\n🔄 ${message}`;
105
- console.log(this.options.colors ? chalk_1.default.magenta(formatted) : formatted);
108
+ console.log(this.options.colors ? chalk.magenta(formatted) : formatted);
106
109
  }
107
110
  success(message) {
108
111
  const formatted = `✅ ${message}`;
109
- console.log(this.options.colors ? chalk_1.default.green(formatted) : formatted);
112
+ console.log(this.options.colors ? chalk.green(formatted) : formatted);
110
113
  }
111
114
  operation(operation, status) {
112
- const emoji = status === 'started' ? '🚀' : status === 'completed' ? '' : '';
113
- const color = status === 'started' ? 'blue' : status === 'completed' ? 'green' : 'red';
115
+ const emoji = status === "started" ? "🚀" : status === "completed" ? "" : "";
116
+ const color = status === "started" ? "blue" : status === "completed" ? "green" : "red";
114
117
  const message = `${emoji} ${operation.toUpperCase()}: ${status}`;
115
118
  if (this.options.colors) {
116
- console.log(chalk_1.default[color](message));
119
+ console.log(chalk[color](message));
117
120
  }
118
121
  else {
119
122
  console.log(message);
@@ -121,21 +124,21 @@ class Logger {
121
124
  }
122
125
  violation(severity, message, file) {
123
126
  const emoji = {
124
- 'CRITICAL': '🚨',
125
- 'MAJOR': '⚠️',
126
- 'MINOR': '📝',
127
- 'SUGGESTION': '💡'
128
- }[severity] || '📋';
127
+ CRITICAL: "🚨",
128
+ MAJOR: "⚠️",
129
+ MINOR: "📝",
130
+ SUGGESTION: "💡",
131
+ }[severity] || "📋";
129
132
  const color = {
130
- 'CRITICAL': 'red',
131
- 'MAJOR': 'yellow',
132
- 'MINOR': 'blue',
133
- 'SUGGESTION': 'cyan'
134
- }[severity] || 'white';
135
- const location = file ? ` in ${file}` : '';
133
+ CRITICAL: "red",
134
+ MAJOR: "yellow",
135
+ MINOR: "blue",
136
+ SUGGESTION: "cyan",
137
+ }[severity] || "white";
138
+ const location = file ? ` in ${file}` : "";
136
139
  const formatted = `${emoji} ${severity}: ${message}${location}`;
137
140
  if (this.options.colors) {
138
- console.log(chalk_1.default[color](formatted));
141
+ console.log(chalk[color](formatted));
139
142
  }
140
143
  else {
141
144
  console.log(formatted);
@@ -149,7 +152,7 @@ class Logger {
149
152
  process.stdout.write(`\r${message}`);
150
153
  // Add newline when complete
151
154
  if (current === total) {
152
- process.stdout.write('\n');
155
+ process.stdout.write("\n");
153
156
  }
154
157
  }
155
158
  createProgressBar(percentage) {
@@ -157,23 +160,23 @@ class Logger {
157
160
  const filled = Math.round((percentage / 100) * width);
158
161
  const empty = width - filled;
159
162
  if (this.options.colors) {
160
- return chalk_1.default.green(''.repeat(filled)) + chalk_1.default.gray(''.repeat(empty));
163
+ return chalk.green("".repeat(filled)) + chalk.gray("".repeat(empty));
161
164
  }
162
165
  else {
163
- return ''.repeat(filled) + ''.repeat(empty);
166
+ return "".repeat(filled) + "".repeat(empty);
164
167
  }
165
168
  }
166
169
  // Method to create child logger with context
167
170
  child(context) {
168
171
  const childLogger = new Logger(this.options);
169
172
  // Override methods to include context
170
- const originalMethods = ['debug', 'info', 'warn', 'error'];
171
- originalMethods.forEach(method => {
173
+ const originalMethods = ["debug", "info", "warn", "error"];
174
+ originalMethods.forEach((method) => {
172
175
  const original = childLogger[method].bind(childLogger);
173
176
  childLogger[method] = (message, ...args) => {
174
177
  const contextStr = Object.entries(context)
175
178
  .map(([k, v]) => `${k}=${v}`)
176
- .join(' ');
179
+ .join(" ");
177
180
  original(`[${contextStr}] ${message}`, ...args);
178
181
  };
179
182
  });
@@ -192,17 +195,16 @@ class Logger {
192
195
  return { ...this.options };
193
196
  }
194
197
  }
195
- exports.Logger = Logger;
196
198
  // Export singleton instance for convenience with environment-aware defaults
197
199
  const loggerOptions = {};
198
200
  // Check environment variables for debug mode
199
- if (process.env.YAMA_DEBUG === 'true') {
200
- loggerOptions.level = 'debug';
201
+ if (process.env.YAMA_DEBUG === "true") {
202
+ loggerOptions.level = "debug";
201
203
  loggerOptions.verbose = true;
202
204
  }
203
- exports.logger = new Logger(loggerOptions);
205
+ export const logger = new Logger(loggerOptions);
204
206
  // Export factory function
205
- function createLogger(options) {
207
+ export function createLogger(options) {
206
208
  return new Logger(options);
207
209
  }
208
210
  //# sourceMappingURL=Logger.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/yama",
3
- "version": "1.1.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",
@@ -52,7 +52,8 @@
52
52
  "build": "tsc && tsc-alias",
53
53
  "dev": "ts-node-dev --respawn --transpile-only src/cli/index.ts",
54
54
  "test": "jest",
55
- "lint": "eslint src/**/*.ts",
55
+ "lint": "eslint .",
56
+ "lint:fix": "eslint . --fix",
56
57
  "type-check": "tsc --noEmit",
57
58
  "format": "prettier --write .",
58
59
  "format:check": "prettier --check .",
@@ -63,7 +64,6 @@
63
64
  "changeset": "changeset",
64
65
  "changeset:version": "changeset version && git add --all",
65
66
  "release": "npm run build && npm run test && changeset publish",
66
- "release:check": "npm run build && publint && size-limit",
67
67
  "release:dry": "npm publish --dry-run",
68
68
  "release:github": "npm publish --registry https://npm.pkg.github.com",
69
69
  "version:check": "npm version --no-git-tag-version",
@@ -89,9 +89,10 @@
89
89
  "@types/jest": "^29.0.0",
90
90
  "@types/lodash": "^4.14.0",
91
91
  "@types/node": "^20.0.0",
92
- "@typescript-eslint/eslint-plugin": "^6.0.0",
93
- "@typescript-eslint/parser": "^6.0.0",
94
- "eslint": "^8.0.0",
92
+ "@eslint/js": "^9.0.0",
93
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
94
+ "@typescript-eslint/parser": "^8.0.0",
95
+ "eslint": "^9.0.0",
95
96
  "jest": "^29.0.0",
96
97
  "rimraf": "^5.0.0",
97
98
  "ts-jest": "^29.0.0",
@@ -4,21 +4,21 @@
4
4
  # AI Provider Configuration
5
5
  providers:
6
6
  ai:
7
- provider: "auto" # Options: auto, google-ai, openai, anthropic, azure, bedrock
8
- model: "best" # Model name or "best" for auto-selection
9
- temperature: 0.3 # Lower = more focused (0.0-1.0)
10
- maxTokens: 2000000 # Maximum tokens for response
11
- timeout: "15m" # Timeout for AI operations
7
+ provider: "auto" # Options: auto, google-ai, openai, anthropic, azure, bedrock
8
+ model: "best" # Model name or "best" for auto-selection
9
+ temperature: 0.3 # Lower = more focused (0.0-1.0)
10
+ maxTokens: 2000000 # Maximum tokens for response
11
+ timeout: "15m" # Timeout for AI operations
12
12
  enableAnalytics: true
13
13
  enableEvaluation: false
14
14
 
15
15
  # Git Platform Configuration
16
16
  git:
17
- platform: "bitbucket" # Options: bitbucket, github, gitlab, azure-devops
17
+ platform: "bitbucket" # Options: bitbucket, github, gitlab, azure-devops
18
18
  credentials:
19
- username: "${BITBUCKET_USERNAME}" # Environment variable
20
- token: "${BITBUCKET_TOKEN}" # Environment variable
21
- baseUrl: "${BITBUCKET_BASE_URL}" # Your Bitbucket server URL
19
+ username: "${BITBUCKET_USERNAME}" # Environment variable
20
+ token: "${BITBUCKET_TOKEN}" # Environment variable
21
+ baseUrl: "${BITBUCKET_BASE_URL}" # Your Bitbucket server URL
22
22
 
23
23
  # Feature Configuration
24
24
  features:
@@ -26,7 +26,14 @@ features:
26
26
  codeReview:
27
27
  enabled: true
28
28
  severityLevels: ["CRITICAL", "MAJOR", "MINOR", "SUGGESTION"]
29
- categories: ["security", "performance", "maintainability", "functionality", "error_handling"]
29
+ categories:
30
+ [
31
+ "security",
32
+ "performance",
33
+ "maintainability",
34
+ "functionality",
35
+ "error_handling",
36
+ ]
30
37
  excludePatterns:
31
38
  - "*.lock"
32
39
  - "*.svg"
@@ -38,7 +45,7 @@ features:
38
45
  - "dist/**"
39
46
  - "build/**"
40
47
  - "vendor/**"
41
- contextLines: 3 # Lines of context around changes
48
+ contextLines: 3 # Lines of context around changes
42
49
  focusAreas:
43
50
  - "Security vulnerabilities"
44
51
  - "Performance bottlenecks"
@@ -48,7 +55,7 @@ features:
48
55
  # Description Enhancement Configuration
49
56
  descriptionEnhancement:
50
57
  enabled: true
51
- preserveContent: true # Always preserve existing content
58
+ preserveContent: true # Always preserve existing content
52
59
  autoFormat: true
53
60
  requiredSections:
54
61
  - key: "changelog"
@@ -65,36 +72,36 @@ features:
65
72
  diffStrategy:
66
73
  enabled: true
67
74
  thresholds:
68
- wholeDiffMaxFiles: 2 # Use whole diff for ≤2 files
69
- fileByFileMinFiles: 3 # Use file-by-file for ≥3 files
75
+ wholeDiffMaxFiles: 2 # Use whole diff for ≤2 files
76
+ fileByFileMinFiles: 3 # Use file-by-file for ≥3 files
70
77
  # Optional: Force a specific strategy regardless of file count
71
78
  # forceStrategy: "file-by-file" # Options: whole, file-by-file, auto
72
79
 
73
80
  # Security Scan Configuration (Future)
74
81
  securityScan:
75
82
  enabled: false
76
- level: "strict" # Options: strict, moderate, basic
83
+ level: "strict" # Options: strict, moderate, basic
77
84
  scanTypes: ["dependencies", "secrets", "vulnerabilities"]
78
85
 
79
86
  # Analytics Configuration (Future)
80
87
  analytics:
81
88
  enabled: false
82
89
  trackMetrics: true
83
- exportFormat: "json" # Options: json, csv, yaml
90
+ exportFormat: "json" # Options: json, csv, yaml
84
91
 
85
92
  # Cache Configuration
86
93
  cache:
87
94
  enabled: true
88
- ttl: "30m" # Time to live for cache entries
95
+ ttl: "30m" # Time to live for cache entries
89
96
  maxSize: "100MB"
90
- storage: "memory" # Options: memory, redis, file
97
+ storage: "memory" # Options: memory, redis, file
91
98
 
92
99
  # Performance Configuration
93
100
  performance:
94
101
  batch:
95
102
  enabled: true
96
- maxConcurrent: 5 # Max concurrent API calls
97
- delayBetween: "1s" # Delay between batches
103
+ maxConcurrent: 5 # Max concurrent API calls
104
+ delayBetween: "1s" # Delay between batches
98
105
  optimization:
99
106
  reuseConnections: true
100
107
  compressRequests: false
@@ -108,7 +115,7 @@ rules:
108
115
  severity: "CRITICAL"
109
116
  message: "Hardcoded secrets detected"
110
117
  suggestion: "Use environment variables or secure configuration"
111
-
118
+
112
119
  - name: "SQL injection prevention"
113
120
  pattern: "query\\([^?]+\\+.*\\)"
114
121
  severity: "CRITICAL"