@juspay/yama 1.0.0

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/README.md ADDED
@@ -0,0 +1,828 @@
1
+ # ⚔️ Yama
2
+
3
+ > **Enterprise-grade Pull Request automation toolkit with AI-powered code review and description enhancement**
4
+
5
+ [![Version](https://img.shields.io/npm/v/@juspay/yama.svg)](https://www.npmjs.com/package/@juspay/yama)
6
+ [![License](https://img.shields.io/npm/l/@juspay/yama.svg)](https://github.com/juspay/yama/blob/main/LICENSE)
7
+ [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/)
8
+
9
+ ## 🎯 **What is Yama?**
10
+
11
+ Yama is the **code quality judge** that combines and optimizes the functionality from pr-police.js and pr-describe.js into a unified, enterprise-grade toolkit. It provides **AI-powered code review** and **intelligent description enhancement** with **90% fewer API calls** through unified context gathering.
12
+
13
+ **Named after the Hindu deity of justice and death, Yama judges code quality and ensures only the worthy changes pass through.**
14
+
15
+ ---
16
+
17
+ ## ✨ **Core Features**
18
+
19
+ ### 🔍 **AI-Powered Code Review**
20
+
21
+ - **🔒 Security Analysis**: SQL injection, XSS, hardcoded secrets detection
22
+ - **⚡ Performance Review**: N+1 queries, memory leaks, algorithm efficiency
23
+ - **🏗️ Code Quality**: SOLID principles, maintainability, best practices
24
+ - **💬 Smart Comments**: Contextual inline comments with actionable suggestions
25
+ - **📊 Severity Levels**: CRITICAL, MAJOR, MINOR, SUGGESTION with intelligent categorization
26
+
27
+ ### 📝 **Intelligent Description Enhancement**
28
+
29
+ - **📎 Content Preservation**: Never removes screenshots, links, or existing explanations
30
+ - **📋 Required Sections**: Configurable sections (Changelog, Test Cases, Config Changes, etc.)
31
+ - **🤖 AI Enhancement**: Automatically improves incomplete descriptions while preserving content
32
+ - **🧠 Project Context**: Uses memory-bank and .clinerules for contextual enhancement
33
+
34
+ ### 🚀 **Unified Context System** (Core Innovation)
35
+
36
+ - **⚡ One-Time Gathering**: Collect all PR context once, reuse across all operations
37
+ - **🧠 Smart Diff Strategy**: Automatically chooses whole diff vs file-by-file based on PR size
38
+ - **💾 Intelligent Caching**: 90% reduction in API calls through multi-layer caching
39
+ - **📦 Batch Processing**: Process large PRs efficiently with intelligent file batching
40
+
41
+ ### 🏗️ **Enterprise Ready**
42
+
43
+ - **🌐 Multi-Platform**: Bitbucket Server (Phase 1), GitHub/GitLab (Future phases)
44
+ - **📘 Full TypeScript**: Complete type safety and excellent developer experience
45
+ - **⚙️ Highly Configurable**: YAML/JSON configuration with validation and hot-reload
46
+ - **🛠️ CLI + API**: Use as command-line tool or programmatic library
47
+
48
+ ---
49
+
50
+ ## 🚀 **Performance Benefits**
51
+
52
+ | Metric | Individual Scripts | Yama | Improvement |
53
+ | ------------------------- | --------------------- | -------------------- | ----------------------- |
54
+ | **API Calls** | ~50-100 per operation | ~10-20 total | **90% reduction** |
55
+ | **Execution Time** | 3-5 minutes each | 2-3 minutes total | **3x faster** |
56
+ | **Memory Usage** | High duplication | Shared context | **50% reduction** |
57
+ | **Cache Efficiency** | None | 80-90% hit ratio | **New capability** |
58
+ | **Large PRs (40+ files)** | Often fails/timeouts | Intelligent batching | **Reliable processing** |
59
+
60
+ ---
61
+
62
+ ## 📦 **Installation**
63
+
64
+ ```bash
65
+ # Install globally for CLI usage
66
+ npm install -g @juspay/yama
67
+
68
+ # Or install locally for programmatic usage
69
+ npm install @juspay/yama
70
+ ```
71
+
72
+ ---
73
+
74
+ ## ⚡ **Quick Start**
75
+
76
+ ### **1. Initialize Configuration**
77
+
78
+ ```bash
79
+ # Interactive setup
80
+ yama init --interactive
81
+
82
+ # Quick setup with defaults
83
+ yama init
84
+ ```
85
+
86
+ ### **2. Basic Usage**
87
+
88
+ #### **Unified Processing (Recommended)**
89
+
90
+ ```bash
91
+ # Process PR with both review and description enhancement
92
+ yama process --workspace YOUR_WORKSPACE --repository my-repo --branch feature/auth
93
+
94
+ # Process specific operations
95
+ yama process --workspace YOUR_WORKSPACE --repository my-repo --branch feature/auth --operations review,enhance
96
+ ```
97
+
98
+ #### **Individual Operations**
99
+
100
+ ```bash
101
+ # Code review only
102
+ yama review --workspace YOUR_WORKSPACE --repository my-repo --branch feature/auth
103
+
104
+ # Description enhancement only
105
+ yama enhance --workspace YOUR_WORKSPACE --repository my-repo --branch feature/auth
106
+ ```
107
+
108
+ #### **Backward Compatibility**
109
+
110
+ ```bash
111
+ # Still works exactly like pr-police.js
112
+ yama police --workspace YOUR_WORKSPACE --repository my-repo --branch feature/auth
113
+
114
+ # Still works exactly like pr-describe.js / pr-scribe.js
115
+ yama scribe --workspace YOUR_WORKSPACE --repository my-repo --branch feature/auth
116
+ ```
117
+
118
+ ---
119
+
120
+ ## 🔧 **Advanced Configuration**
121
+
122
+ ### **File Exclusion Patterns**
123
+
124
+ ```bash
125
+ # Exclude specific file types and directories
126
+ yama process \
127
+ --workspace YOUR_WORKSPACE \
128
+ --repository my-repo \
129
+ --branch feature/auth \
130
+ --exclude "*.lock,*.svg,*.min.js,dist/**,node_modules/**,coverage/**"
131
+
132
+ # Different exclusions for different operations
133
+ yama review --exclude "*.lock,*.svg,**/*.test.js"
134
+ yama enhance --exclude "*.md" # Don't process existing markdown files
135
+ ```
136
+
137
+ ### **Context and Performance Tuning**
138
+
139
+ ```bash
140
+ # More context lines for better AI analysis
141
+ yama review --context-lines 5 --exclude "*.lock"
142
+
143
+ # Dry run to preview changes
144
+ yama process --dry-run --verbose
145
+
146
+ # Force cache refresh
147
+ yama process --force-refresh
148
+ ```
149
+
150
+ ---
151
+
152
+ ## ⚙️ **Configuration File**
153
+
154
+ Create `yama.config.yaml` in your project root:
155
+
156
+ ```yaml
157
+ # AI Provider Configuration
158
+ ai:
159
+ provider: "auto" # auto, google-ai, openai, anthropic
160
+ enableFallback: true
161
+ enableAnalytics: true
162
+ timeout: "5m"
163
+ temperature: 0.7
164
+
165
+ # Git Platform Configuration
166
+ git:
167
+ platform: "bitbucket"
168
+ credentials:
169
+ username: "${BITBUCKET_USERNAME}"
170
+ token: "${BITBUCKET_TOKEN}"
171
+ baseUrl: "https://your-bitbucket-server.com"
172
+ defaultWorkspace: "${DEFAULT_WORKSPACE}"
173
+
174
+ # Feature Configuration
175
+ features:
176
+ codeReview:
177
+ enabled: true
178
+ severityLevels: ["CRITICAL", "MAJOR", "MINOR", "SUGGESTION"]
179
+ excludePatterns:
180
+ - "*.lock"
181
+ - "*.svg"
182
+ - "*.min.js"
183
+ - "node_modules/**"
184
+ - "dist/**"
185
+ - "build/**"
186
+ - "coverage/**"
187
+ contextLines: 3
188
+
189
+ # Custom AI Prompts for Code Review (Advanced)
190
+ systemPrompt: |
191
+ You are an Expert Security Code Reviewer focusing on enterprise standards.
192
+ Prioritize security vulnerabilities, performance issues, and code quality.
193
+ Provide actionable feedback with specific examples and solutions.
194
+
195
+ focusAreas:
196
+ - "🔒 Security Analysis (CRITICAL PRIORITY)"
197
+ - "⚡ Performance Review"
198
+ - "🏗️ Code Quality & Best Practices"
199
+ - "🧪 Testing & Error Handling"
200
+ - "📖 Documentation & Maintainability"
201
+
202
+ descriptionEnhancement:
203
+ enabled: true
204
+ preserveContent: true # NEVER remove existing content
205
+ requiredSections:
206
+ # Default sections
207
+ - key: "changelog"
208
+ name: "📋 Changelog (Modules Modified)"
209
+ required: true
210
+
211
+ - key: "testcases"
212
+ name: "🧪 Test Cases (What to be tested)"
213
+ required: true
214
+
215
+ - key: "config_changes"
216
+ name: "⚙️ Config Changes (CAC/Service Config)"
217
+ required: true
218
+
219
+ # Optional custom sections
220
+ - key: "breaking_changes"
221
+ name: "⚠️ Breaking Changes"
222
+ required: false
223
+
224
+ - key: "migration_notes"
225
+ name: "🔄 Migration Notes"
226
+ required: false
227
+
228
+ - key: "performance_impact"
229
+ name: "⚡ Performance Impact"
230
+ required: false
231
+
232
+ - key: "security_considerations"
233
+ name: "🔒 Security Considerations"
234
+ required: false
235
+
236
+ # Custom AI Prompts and Templates (Advanced)
237
+ systemPrompt: |
238
+ You are an Expert Technical Writer specializing in pull request documentation.
239
+ Focus on clarity, completeness, and helping reviewers understand the changes.
240
+ CRITICAL: Return ONLY the enhanced description without meta-commentary.
241
+
242
+ enhancementInstructions: |
243
+ Return ONLY the enhanced PR description as clean markdown.
244
+ Start directly with the enhanced description content.
245
+
246
+ outputTemplate: |
247
+ # {{PR_TITLE}}
248
+
249
+ ## Summary
250
+ [Clear overview of what this PR accomplishes]
251
+
252
+ ## Changes Made
253
+ [Specific technical changes with file references]
254
+
255
+ ## Testing Strategy
256
+ [How changes were tested and validated]
257
+
258
+ ## Impact & Considerations
259
+ [Business impact, performance implications, breaking changes]
260
+
261
+ # Performance Configuration
262
+ cache:
263
+ enabled: true
264
+ ttl: "1h"
265
+ maxSize: "100mb"
266
+ storage: "memory"
267
+
268
+ # Monitoring and Analytics
269
+ monitoring:
270
+ enabled: true
271
+ metrics: ["performance", "cache", "api_calls"]
272
+ ```
273
+
274
+ ---
275
+
276
+ ## 🤖 **Programmatic Usage**
277
+
278
+ ### **Basic Setup**
279
+
280
+ ```typescript
281
+ import { Guardian, createGuardian } from "@juspay/yama";
282
+
283
+ // Create Guardian instance
284
+ const guardian = createGuardian({
285
+ providers: {
286
+ ai: {
287
+ provider: "google-ai",
288
+ enableAnalytics: true,
289
+ },
290
+ git: {
291
+ platform: "bitbucket",
292
+ credentials: {
293
+ username: process.env.BITBUCKET_USERNAME!,
294
+ token: process.env.BITBUCKET_TOKEN!,
295
+ baseUrl: "https://your-bitbucket-server.com",
296
+ },
297
+ },
298
+ },
299
+ });
300
+
301
+ // Initialize
302
+ await guardian.initialize();
303
+ ```
304
+
305
+ ### **Unified Processing**
306
+
307
+ ```typescript
308
+ // Process PR with multiple operations using shared context
309
+ const result = await guardian.processPR({
310
+ workspace: "YOUR_WORKSPACE",
311
+ repository: "my-repo",
312
+ branch: "feature/auth",
313
+ operations: ["review", "enhance-description"],
314
+ });
315
+
316
+ console.log(`Processed ${result.operations.length} operations`);
317
+ console.log(`API calls saved: ${result.performance.apiCallsSaved}`);
318
+ console.log(`Cache hit ratio: ${result.performance.cacheHitRatio}%`);
319
+ ```
320
+
321
+ ### **Streaming Processing with Real-time Updates**
322
+
323
+ ```typescript
324
+ // Real-time progress updates
325
+ for await (const update of guardian.processPRStream({
326
+ workspace: "YOUR_WORKSPACE",
327
+ repository: "my-repo",
328
+ branch: "feature/auth",
329
+ operations: ["review", "enhance-description"],
330
+ })) {
331
+ console.log(`${update.operation}: ${update.status} - ${update.message}`);
332
+
333
+ if (update.progress) {
334
+ console.log(`Progress: ${update.progress}%`);
335
+ }
336
+ }
337
+ ```
338
+
339
+ ### **Individual Operations**
340
+
341
+ ```typescript
342
+ // Code review only
343
+ const reviewResult = await guardian.reviewCode({
344
+ workspace: "YOUR_WORKSPACE",
345
+ repository: "my-repo",
346
+ branch: "feature/auth",
347
+ excludePatterns: ["*.lock", "*.svg"],
348
+ });
349
+
350
+ // Description enhancement only
351
+ const enhancementResult = await guardian.enhanceDescription({
352
+ workspace: "YOUR_WORKSPACE",
353
+ repository: "my-repo",
354
+ branch: "feature/auth",
355
+ customSections: [
356
+ { key: "summary", name: "📝 Summary", required: true },
357
+ { key: "rollback", name: "🔄 Rollback Plan", required: true },
358
+ ],
359
+ });
360
+ ```
361
+
362
+ ### **Configuration Hot-Reload**
363
+
364
+ ```typescript
365
+ import { configManager } from "@juspay/yama";
366
+
367
+ // Enable hot-reload for configuration changes
368
+ const stopWatching = configManager.enableHotReload((newConfig) => {
369
+ console.log("Configuration updated:", newConfig);
370
+ // Optionally reinitialize Guardian with new config
371
+ });
372
+
373
+ // Stop watching when done
374
+ process.on("SIGINT", () => {
375
+ stopWatching();
376
+ process.exit(0);
377
+ });
378
+ ```
379
+
380
+ ---
381
+
382
+ ## 🧠 **Smart Diff Strategy**
383
+
384
+ Yama automatically chooses the optimal diff processing strategy:
385
+
386
+ ### **Strategy Selection**
387
+
388
+ ```typescript
389
+ // File count ≤ 5: Whole diff strategy
390
+ if (fileCount <= 5) {
391
+ strategy = "whole"; // Fast, provides full context
392
+ reason = "Small PR, whole diff provides better context";
393
+ }
394
+
395
+ // File count 6-20: Still whole diff (manageable)
396
+ else if (fileCount <= 20) {
397
+ strategy = "whole";
398
+ reason = "Moderate PR size, whole diff manageable";
399
+ }
400
+
401
+ // File count 21-50: File-by-file with batching
402
+ else if (fileCount <= 50) {
403
+ strategy = "file-by-file"; // Batch process 5 files at a time
404
+ reason = "Large PR, file-by-file more efficient";
405
+ }
406
+
407
+ // File count > 50: Essential batching for performance
408
+ else {
409
+ strategy = "file-by-file";
410
+ reason = "Very large PR, batching required for performance";
411
+ }
412
+ ```
413
+
414
+ ### **Batch Processing for Large PRs**
415
+
416
+ ```typescript
417
+ // Process files in optimized batches
418
+ const batchSize = 5;
419
+ for (let i = 0; i < filteredFiles.length; i += batchSize) {
420
+ const batch = filteredFiles.slice(i, i + batchSize);
421
+
422
+ // Process batch in parallel with intelligent caching
423
+ const batchResults = await Promise.all(
424
+ batch.map((file) => processFileWithCache(file)),
425
+ );
426
+ }
427
+ ```
428
+
429
+ ---
430
+
431
+ ## 🎯 **File Exclusion Patterns**
432
+
433
+ ### **Built-in Smart Exclusions**
434
+
435
+ ```yaml
436
+ # Default exclusions (always applied unless overridden)
437
+ excludePatterns:
438
+ - "*.lock" # Package lock files
439
+ - "*.svg" # SVG images
440
+ - "*.min.js" # Minified JavaScript
441
+ - "*.min.css" # Minified CSS
442
+ - "node_modules/**" # Dependencies
443
+ - "dist/**" # Build outputs
444
+ - "build/**" # Build outputs
445
+ - "coverage/**" # Test coverage
446
+ ```
447
+
448
+ ### **Pattern Syntax**
449
+
450
+ ```bash
451
+ # Examples of supported patterns:
452
+ --exclude "*.lock" # All lock files
453
+ --exclude "**/*.test.js" # Test files in any directory
454
+ --exclude "src/generated/**" # Entire generated directory
455
+ --exclude "*.{lock,svg,min.js}" # Multiple extensions
456
+ --exclude "!important.lock" # Exclude everything except important.lock
457
+ ```
458
+
459
+ ### **Context-Aware Exclusions**
460
+
461
+ ```typescript
462
+ // Different exclusions for different operations
463
+ const reviewExclusions = ["*.lock", "*.svg", "**/*.test.js"];
464
+ const enhancementExclusions = ["*.lock"]; // Allow SVGs in descriptions
465
+
466
+ await guardian.processPR({
467
+ operations: [
468
+ {
469
+ type: "review",
470
+ excludePatterns: reviewExclusions,
471
+ },
472
+ {
473
+ type: "enhance-description",
474
+ excludePatterns: enhancementExclusions,
475
+ },
476
+ ],
477
+ });
478
+ ```
479
+
480
+ ---
481
+
482
+ ## 📋 **Configurable Description Sections**
483
+
484
+ ### **Default Required Sections**
485
+
486
+ ```typescript
487
+ const defaultSections = [
488
+ { key: "changelog", name: "📋 Changelog (Modules Modified)", required: true },
489
+ {
490
+ key: "testcases",
491
+ name: "🧪 Test Cases (What to be tested)",
492
+ required: true,
493
+ },
494
+ { key: "config_changes", name: "⚙️ Config Changes", required: true },
495
+ ];
496
+ ```
497
+
498
+ ### **Custom Section Examples**
499
+
500
+ ```yaml
501
+ # Enterprise setup
502
+ requiredSections:
503
+ - key: "summary"
504
+ name: "📝 Executive Summary"
505
+ required: true
506
+
507
+ - key: "business_impact"
508
+ name: "💼 Business Impact"
509
+ required: true
510
+
511
+ - key: "technical_changes"
512
+ name: "🔧 Technical Changes"
513
+ required: true
514
+
515
+ - key: "testing_strategy"
516
+ name: "🧪 Testing Strategy"
517
+ required: true
518
+
519
+ - key: "rollback_plan"
520
+ name: "🔄 Rollback Plan"
521
+ required: true
522
+
523
+ - key: "monitoring"
524
+ name: "📊 Monitoring & Alerts"
525
+ required: false
526
+
527
+ - key: "documentation"
528
+ name: "📖 Documentation Updates"
529
+ required: false
530
+ ```
531
+
532
+ ### **Section Auto-Detection**
533
+
534
+ ```typescript
535
+ // Smart pattern matching for existing sections
536
+ const sectionPatterns = {
537
+ changelog: [
538
+ /##.*?[Cc]hangelog/i,
539
+ /##.*?[Mm]odules?\s+[Mm]odified/i,
540
+ /📋.*?[Cc]hangelog/i,
541
+ ],
542
+ testcases: [/##.*?[Tt]est\s+[Cc]ases?/i, /##.*?[Tt]esting/i, /🧪.*?[Tt]est/i],
543
+ security: [/##.*?[Ss]ecurity/i, /🔒.*?[Ss]ecurity/i, /##.*?[Vv]ulnerabilit/i],
544
+ };
545
+ ```
546
+
547
+ ---
548
+
549
+ ## 🛠️ **Utility Commands**
550
+
551
+ ### **Health and Status**
552
+
553
+ ```bash
554
+ # Check system health
555
+ yama status --detailed
556
+
557
+ # Output:
558
+ # ⚔️ Yama Status
559
+ # ✅ Overall Health: Healthy
560
+ #
561
+ # 📊 Component Status:
562
+ # ✅ ai: OK
563
+ # ✅ git: OK
564
+ # ✅ cache: OK
565
+ # ✅ config: OK
566
+ #
567
+ # 📈 Statistics:
568
+ # {
569
+ # "totalOperations": 45,
570
+ # "successRate": 0.98,
571
+ # "avgProcessingTime": 120,
572
+ # "apiCallsSaved": 1250
573
+ # }
574
+ #
575
+ # 💾 Cache: 67 keys, 423 hits, 89% hit ratio
576
+ ```
577
+
578
+ ### **Cache Management**
579
+
580
+ ```bash
581
+ # View cache statistics
582
+ yama cache stats
583
+
584
+ # Output:
585
+ # 💾 Cache Statistics
586
+ # Keys: 67
587
+ # Hits: 423
588
+ # Misses: 52
589
+ # Hit Ratio: 89%
590
+ #
591
+ # 📊 Detailed Stats:
592
+ # {
593
+ # "pr": { "hits": 45, "misses": 5 },
594
+ # "file-diff": { "hits": 234, "misses": 28 },
595
+ # "context": { "hits": 144, "misses": 19 }
596
+ # }
597
+
598
+ # Clear caches
599
+ yama cache clear
600
+ ```
601
+
602
+ ### **Configuration Management**
603
+
604
+ ```bash
605
+ # Validate configuration
606
+ yama config validate
607
+
608
+ # Show current configuration (sensitive data masked)
609
+ yama config show
610
+
611
+ # Output:
612
+ # ⚙️ Current Configuration
613
+ # {
614
+ # "ai": {
615
+ # "provider": "google-ai",
616
+ # "enableAnalytics": true
617
+ # },
618
+ # "git": {
619
+ # "platform": "bitbucket",
620
+ # "credentials": {
621
+ # "token": "***MASKED***"
622
+ # }
623
+ # }
624
+ # }
625
+ ```
626
+
627
+ ---
628
+
629
+ ## 🔄 **Migration from Individual Scripts**
630
+
631
+ Yama provides **100% backward compatibility** with your existing workflows:
632
+
633
+ ### **From pr-police.js**
634
+
635
+ ```bash
636
+ # Old way
637
+ node pr-police.js --workspace YOUR_WORKSPACE --repository repo --branch branch
638
+
639
+ # New way (identical functionality + optimizations)
640
+ yama review --workspace YOUR_WORKSPACE --repository repo --branch branch
641
+
642
+ # OR use the direct alias
643
+ yama police --workspace YOUR_WORKSPACE --repository repo --branch branch
644
+ ```
645
+
646
+ ### **From pr-describe.js / pr-scribe.js**
647
+
648
+ ```bash
649
+ # Old way
650
+ node pr-describe.js --workspace YOUR_WORKSPACE --repository repo --branch branch
651
+
652
+ # New way (identical functionality + optimizations)
653
+ yama enhance --workspace YOUR_WORKSPACE --repository repo --branch branch
654
+
655
+ # OR use the direct alias
656
+ yama scribe --workspace YOUR_WORKSPACE --repository repo --branch branch
657
+ ```
658
+
659
+ ### **New Unified Approach (Best Performance)**
660
+
661
+ ```bash
662
+ # Best of both worlds + 90% performance improvement
663
+ yama process --workspace YOUR_WORKSPACE --repository repo --branch branch --operations all
664
+ ```
665
+
666
+ ---
667
+
668
+ ## 🏗️ **Architecture Overview**
669
+
670
+ ```
671
+ ⚔️ YAMA ARCHITECTURE ⚔️
672
+ ┌─────────────────────────────────────────────────────────────┐
673
+ │ 🔍 UNIFIED CONTEXT GATHERING (Once for all operations) │
674
+ │ ├── 🔍 Find Open PR (by branch or PR ID) │
675
+ │ ├── 📄 Get PR Details (title, description, comments) │
676
+ │ ├── 🧠 Get Memory Bank Context (project rules) │
677
+ │ ├── 📊 Smart Diff Strategy (whole vs file-by-file) │
678
+ │ └── 📎 Apply File Exclusions & Filters │
679
+ ├─────────────────────────────────────────────────────────────┤
680
+ │ ⚡ OPTIMIZED OPERATIONS (Use shared context) │
681
+ │ ├── 🛡️ Code Review (security, performance, quality) │
682
+ │ ├── 📝 Description Enhancement (preserve + enhance) │
683
+ │ ├── 🔒 Security Scan (future) │
684
+ │ └── 📊 Analytics & Reporting (future) │
685
+ ├─────────────────────────────────────────────────────────────┤
686
+ │ 🚀 PERFORMANCE LAYER │
687
+ │ ├── 💾 Multi-Layer Caching (90% fewer API calls) │
688
+ │ ├── 🔗 Connection Reuse (single MCP connection) │
689
+ │ ├── 📦 Intelligent Batching (5 files per batch) │
690
+ │ └── 🔄 Smart Retry Logic (exponential backoff) │
691
+ └─────────────────────────────────────────────────────────────┘
692
+ ```
693
+
694
+ ---
695
+
696
+ ## 🌟 **Why Yama?**
697
+
698
+ ### **vs Individual Scripts**
699
+
700
+ 1. **🚀 90% Performance Gain**: Unified context eliminates duplicate API calls
701
+ 2. **🧠 Shared Intelligence**: AI analysis benefits from complete PR context
702
+ 3. **💾 Intelligent Caching**: Multi-layer caching with 80-90% hit rates
703
+ 4. **📦 Batch Processing**: Handles large PRs (50+ files) that would fail before
704
+ 5. **🔧 Enterprise Features**: Health monitoring, configuration management, analytics
705
+ 6. **📘 Type Safety**: Complete TypeScript implementation with IntelliSense
706
+ 7. **🔄 Backward Compatible**: Existing workflows work unchanged
707
+
708
+ ### **vs Other Tools**
709
+
710
+ 1. **🎯 Purpose-Built**: Specifically designed for enterprise PR workflows
711
+ 2. **🔒 Security-First**: Built-in security analysis and hardcoded secret detection
712
+ 3. **🤖 AI-Native**: Deep integration with multiple AI providers with fallbacks
713
+ 4. **⚙️ Highly Configurable**: Every aspect can be customized via configuration
714
+ 5. **📊 Analytics Ready**: Built-in performance monitoring and metrics collection
715
+
716
+ ---
717
+
718
+ ## 🛡️ **Security & Privacy**
719
+
720
+ - **🔐 No Data Storage**: All processing is ephemeral, no permanent data storage
721
+ - **🔒 Token Security**: All credentials are handled securely and never logged
722
+ - **🌐 Local Processing**: Diffs and code analysis happen locally before AI submission
723
+ - **🚫 No Tracking**: No usage analytics sent to external services (unless explicitly enabled)
724
+ - **🛡️ Content Filtering**: Automatic detection and filtering of sensitive data before AI processing
725
+
726
+ ---
727
+
728
+ ## 📈 **Performance Monitoring**
729
+
730
+ ### **Built-in Metrics**
731
+
732
+ ```typescript
733
+ const stats = guardian.getStats();
734
+
735
+ console.log({
736
+ performance: {
737
+ totalOperations: stats.totalOperations,
738
+ avgProcessingTime: stats.avgProcessingTime,
739
+ successRate: stats.successRate,
740
+ apiCallsSaved: stats.apiCallsSaved,
741
+ },
742
+ cache: {
743
+ hitRatio: stats.cache.hitRatio,
744
+ totalHits: stats.cache.hits,
745
+ keyCount: stats.cache.keys,
746
+ },
747
+ resources: {
748
+ memoryUsage: stats.memory,
749
+ activeConnections: stats.connections,
750
+ },
751
+ });
752
+ ```
753
+
754
+ ### **Performance Tracking**
755
+
756
+ ```bash
757
+ # View performance metrics
758
+ yama status --detailed
759
+
760
+ # Example output shows:
761
+ # - 90% reduction in API calls vs individual scripts
762
+ # - 3x faster execution through shared context
763
+ # - 89% cache hit ratio
764
+ # - Average processing time: 2.3 minutes for medium PRs
765
+ ```
766
+
767
+ ---
768
+
769
+ ## 🚀 **Coming Soon (Future Phases)**
770
+
771
+ - **🔒 Advanced Security Scanning**: Dependency vulnerability analysis, SAST integration
772
+ - **🌐 Multi-Platform Support**: GitHub, GitLab, Azure DevOps integration
773
+ - **📊 Advanced Analytics**: Team productivity metrics, code quality trends
774
+ - **🤖 Custom AI Rules**: Train models on your codebase patterns
775
+ - **⚡ Parallel Processing**: Multi-PR batch processing for CI/CD integration
776
+ - **🔗 IDE Integration**: VSCode, IntelliJ plugins for real-time analysis
777
+
778
+ ---
779
+
780
+ ## 🤝 **Contributing**
781
+
782
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
783
+
784
+ 1. **Fork** the repository
785
+ 2. **Create** a feature branch (`git checkout -b feature/amazing-feature`)
786
+ 3. **Commit** your changes (`git commit -m 'Add amazing feature'`)
787
+ 4. **Push** to the branch (`git push origin feature/amazing-feature`)
788
+ 5. **Open** a Pull Request
789
+
790
+ ---
791
+
792
+ ## 📄 **License**
793
+
794
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
795
+
796
+ ---
797
+
798
+ ## 🆘 **Support**
799
+
800
+ - **📖 Documentation**: [GitHub Wiki](https://github.com/juspay/yama/wiki)
801
+ - **🐛 Issues**: [GitHub Issues](https://github.com/juspay/yama/issues)
802
+ - **💬 Discussions**: [GitHub Discussions](https://github.com/juspay/yama/discussions)
803
+ - **📧 Email**: opensource@juspay.in
804
+
805
+ ---
806
+
807
+ ## 🎯 **Environment Variables**
808
+
809
+ ```bash
810
+ # Required
811
+ BITBUCKET_USERNAME=your-username
812
+ BITBUCKET_TOKEN=your-personal-access-token
813
+ GOOGLE_AI_API_KEY=your-google-ai-api-key
814
+
815
+ # Optional
816
+ BITBUCKET_BASE_URL=https://your-bitbucket-server.com
817
+ AI_PROVIDER=google-ai
818
+ AI_MODEL=gemini-2.5-pro
819
+ DEFAULT_WORKSPACE=YOUR_WORKSPACE
820
+ ENABLE_CACHE=true
821
+ YAMA_DEBUG=false
822
+ ```
823
+
824
+ ---
825
+
826
+ **⚔️ Built with ❤️ by the Juspay team • Powered by AI & Enterprise Security • Code Quality Justice**
827
+
828
+ > _"In the realm of code, Yama stands as the eternal judge, ensuring only the worthy changes pass through to enlightenment."_