@juspay/yama 1.0.0 โ 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cli/index.js +75 -78
- package/dist/core/ContextGatherer.d.ts +2 -2
- package/dist/core/ContextGatherer.js +59 -62
- package/dist/core/Guardian.d.ts +1 -1
- package/dist/core/Guardian.js +61 -61
- package/dist/core/providers/BitbucketProvider.d.ts +1 -1
- package/dist/core/providers/BitbucketProvider.js +68 -66
- package/dist/features/CodeReviewer.d.ts +3 -3
- package/dist/features/CodeReviewer.js +66 -68
- package/dist/features/DescriptionEnhancer.d.ts +3 -3
- package/dist/features/DescriptionEnhancer.js +37 -40
- package/dist/index.d.ts +11 -11
- package/dist/index.js +10 -48
- package/dist/types/index.js +6 -11
- package/dist/utils/Cache.d.ts +1 -1
- package/dist/utils/Cache.js +48 -55
- package/dist/utils/ConfigManager.d.ts +1 -1
- package/dist/utils/ConfigManager.js +191 -198
- package/dist/utils/Logger.d.ts +1 -1
- package/dist/utils/Logger.js +15 -22
- package/package.json +1 -1
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 =
|
|
155
|
+
const homeDir = homedir();
|
|
29
156
|
this.configPaths = [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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 (!
|
|
57
|
-
throw new
|
|
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
|
-
|
|
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 (
|
|
193
|
+
if (fs.existsSync(configFilePath)) {
|
|
67
194
|
try {
|
|
68
195
|
const fileConfig = await this.loadConfigFile(configFilePath);
|
|
69
196
|
config = this.mergeConfigs(config, fileConfig);
|
|
70
|
-
|
|
197
|
+
logger.debug(`Loaded configuration from: ${configFilePath}`);
|
|
71
198
|
break;
|
|
72
199
|
}
|
|
73
200
|
catch (error) {
|
|
74
|
-
|
|
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
|
-
|
|
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 =
|
|
93
|
-
const ext =
|
|
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
|
|
224
|
+
return yaml.parse(content);
|
|
98
225
|
case ".json":
|
|
99
226
|
return JSON.parse(content);
|
|
100
227
|
default:
|
|
101
|
-
throw new
|
|
228
|
+
throw new ConfigurationError(`Unsupported config file format: ${ext}`);
|
|
102
229
|
}
|
|
103
230
|
}
|
|
104
231
|
catch (error) {
|
|
105
|
-
throw new
|
|
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
|
-
|
|
167
|
-
|
|
293
|
+
logger.setLevel("debug");
|
|
294
|
+
logger.setVerbose(true);
|
|
168
295
|
}
|
|
169
|
-
|
|
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
|
|
333
|
+
throw new ConfigurationError(`Configuration validation failed:\n${errors.map((e) => ` - ${e}`).join("\n")}`);
|
|
207
334
|
}
|
|
208
|
-
|
|
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
|
|
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 ||
|
|
253
|
-
const configContent =
|
|
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
|
-
|
|
260
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
547
|
+
logger.warn("No configuration file found to watch");
|
|
421
548
|
return () => { };
|
|
422
549
|
}
|
|
423
|
-
|
|
424
|
-
|
|
550
|
+
logger.debug(`Watching configuration file: ${configPath}`);
|
|
551
|
+
fs.watchFile(configPath, { interval: 1000 }, async () => {
|
|
425
552
|
try {
|
|
426
|
-
|
|
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
|
-
|
|
558
|
+
logger.success("Configuration reloaded successfully");
|
|
432
559
|
}
|
|
433
560
|
catch (error) {
|
|
434
|
-
|
|
561
|
+
logger.error(`Failed to reload configuration: ${error.message}`);
|
|
435
562
|
}
|
|
436
563
|
});
|
|
437
564
|
// Return cleanup function
|
|
438
565
|
return () => {
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
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
|
package/dist/utils/Logger.d.ts
CHANGED
|
@@ -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>);
|
package/dist/utils/Logger.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
64
|
+
return chalk.gray(text);
|
|
71
65
|
case "info":
|
|
72
|
-
return
|
|
66
|
+
return chalk.blue(text);
|
|
73
67
|
case "warn":
|
|
74
|
-
return
|
|
68
|
+
return chalk.yellow(text);
|
|
75
69
|
case "error":
|
|
76
|
-
return
|
|
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(
|
|
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 ?
|
|
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 ?
|
|
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(
|
|
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(
|
|
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
|
|
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
|
-
|
|
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
|