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