@juspay/yama 1.6.0 โ†’ 2.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.
Files changed (79) hide show
  1. package/.mcp-config.example.json +26 -0
  2. package/CHANGELOG.md +46 -0
  3. package/README.md +311 -685
  4. package/dist/cli/v2.cli.d.ts +13 -0
  5. package/dist/cli/v2.cli.js +359 -0
  6. package/dist/index.d.ts +12 -13
  7. package/dist/index.js +18 -19
  8. package/dist/v2/config/ConfigLoader.d.ts +50 -0
  9. package/dist/v2/config/ConfigLoader.js +205 -0
  10. package/dist/v2/config/DefaultConfig.d.ts +9 -0
  11. package/dist/v2/config/DefaultConfig.js +187 -0
  12. package/dist/v2/core/LearningOrchestrator.d.ts +65 -0
  13. package/dist/v2/core/LearningOrchestrator.js +499 -0
  14. package/dist/v2/core/MCPServerManager.d.ts +22 -0
  15. package/dist/v2/core/MCPServerManager.js +100 -0
  16. package/dist/v2/core/SessionManager.d.ts +72 -0
  17. package/dist/v2/core/SessionManager.js +200 -0
  18. package/dist/v2/core/YamaV2Orchestrator.d.ts +112 -0
  19. package/dist/v2/core/YamaV2Orchestrator.js +549 -0
  20. package/dist/v2/learning/FeedbackExtractor.d.ts +46 -0
  21. package/dist/v2/learning/FeedbackExtractor.js +237 -0
  22. package/dist/v2/learning/KnowledgeBaseManager.d.ts +91 -0
  23. package/dist/v2/learning/KnowledgeBaseManager.js +475 -0
  24. package/dist/v2/learning/types.d.ts +121 -0
  25. package/dist/v2/learning/types.js +15 -0
  26. package/dist/v2/prompts/EnhancementSystemPrompt.d.ts +8 -0
  27. package/dist/v2/prompts/EnhancementSystemPrompt.js +216 -0
  28. package/dist/v2/prompts/LangfusePromptManager.d.ts +48 -0
  29. package/dist/v2/prompts/LangfusePromptManager.js +144 -0
  30. package/dist/v2/prompts/LearningSystemPrompt.d.ts +11 -0
  31. package/dist/v2/prompts/LearningSystemPrompt.js +180 -0
  32. package/dist/v2/prompts/PromptBuilder.d.ts +45 -0
  33. package/dist/v2/prompts/PromptBuilder.js +257 -0
  34. package/dist/v2/prompts/ReviewSystemPrompt.d.ts +8 -0
  35. package/dist/v2/prompts/ReviewSystemPrompt.js +270 -0
  36. package/dist/v2/types/config.types.d.ts +141 -0
  37. package/dist/v2/types/config.types.js +5 -0
  38. package/dist/v2/types/mcp.types.d.ts +191 -0
  39. package/dist/v2/types/mcp.types.js +6 -0
  40. package/dist/v2/types/v2.types.d.ts +182 -0
  41. package/dist/v2/types/v2.types.js +42 -0
  42. package/dist/v2/utils/ObservabilityConfig.d.ts +22 -0
  43. package/dist/v2/utils/ObservabilityConfig.js +48 -0
  44. package/package.json +16 -10
  45. package/yama.config.example.yaml +259 -204
  46. package/dist/cli/index.d.ts +0 -12
  47. package/dist/cli/index.js +0 -538
  48. package/dist/core/ContextGatherer.d.ts +0 -110
  49. package/dist/core/ContextGatherer.js +0 -470
  50. package/dist/core/Guardian.d.ts +0 -81
  51. package/dist/core/Guardian.js +0 -480
  52. package/dist/core/providers/BitbucketProvider.d.ts +0 -105
  53. package/dist/core/providers/BitbucketProvider.js +0 -489
  54. package/dist/features/CodeReviewer.d.ts +0 -173
  55. package/dist/features/CodeReviewer.js +0 -1707
  56. package/dist/features/DescriptionEnhancer.d.ts +0 -70
  57. package/dist/features/DescriptionEnhancer.js +0 -511
  58. package/dist/features/MultiInstanceProcessor.d.ts +0 -74
  59. package/dist/features/MultiInstanceProcessor.js +0 -360
  60. package/dist/types/index.d.ts +0 -624
  61. package/dist/types/index.js +0 -104
  62. package/dist/utils/Cache.d.ts +0 -103
  63. package/dist/utils/Cache.js +0 -444
  64. package/dist/utils/ConfigManager.d.ts +0 -88
  65. package/dist/utils/ConfigManager.js +0 -602
  66. package/dist/utils/ContentSimilarityService.d.ts +0 -74
  67. package/dist/utils/ContentSimilarityService.js +0 -215
  68. package/dist/utils/ExactDuplicateRemover.d.ts +0 -77
  69. package/dist/utils/ExactDuplicateRemover.js +0 -361
  70. package/dist/utils/Logger.d.ts +0 -31
  71. package/dist/utils/Logger.js +0 -214
  72. package/dist/utils/MemoryBankManager.d.ts +0 -73
  73. package/dist/utils/MemoryBankManager.js +0 -310
  74. package/dist/utils/ParallelProcessing.d.ts +0 -140
  75. package/dist/utils/ParallelProcessing.js +0 -333
  76. package/dist/utils/ProviderLimits.d.ts +0 -58
  77. package/dist/utils/ProviderLimits.js +0 -143
  78. package/dist/utils/RetryManager.d.ts +0 -78
  79. package/dist/utils/RetryManager.js +0 -205
@@ -1,215 +1,270 @@
1
1
  # Yama Configuration Example
2
- # This file contains all available configuration options with explanations
2
+ # Copy this file to yama.config.yaml and customize for your project
3
3
 
4
- # Display Configuration
4
+ version: 2
5
+ configType: "yama-v2"
6
+
7
+ # ============================================================================
8
+ # Display & Streaming Configuration
9
+ # ============================================================================
5
10
  display:
6
- showBanner: true # Show ASCII art banner on startup (default: true)
7
-
8
- # AI Provider Configuration
9
- providers:
10
- ai:
11
- provider: "auto" # Options: auto, google-ai, openai, anthropic, azure, bedrock
12
- model: "best" # Model name or "best" for auto-selection
13
- temperature: 0.3 # Lower = more focused (0.0-1.0)
14
- maxTokens: 60000 # Maximum tokens for response (provider-aware limits will be applied automatically)
15
- timeout: "15m" # Timeout for AI operations
16
- enableAnalytics: true
17
- enableEvaluation: false
18
-
19
- # Git Platform Configuration
20
- git:
21
- platform: "bitbucket" # Options: bitbucket, github, gitlab, azure-devops
22
- credentials:
23
- username: "${BITBUCKET_USERNAME}" # Environment variable
24
- token: "${BITBUCKET_TOKEN}" # Environment variable
25
- baseUrl: "${BITBUCKET_BASE_URL}" # Your Bitbucket server URL
26
-
27
- # Feature Configuration
28
- features:
29
- # Code Review Configuration
30
- codeReview:
31
- enabled: true
32
- postSummaryComment: true # Post summary comment at the end of review (default: true)
33
- severityLevels: ["CRITICAL", "MAJOR", "MINOR", "SUGGESTION"]
34
- categories:
35
- [
36
- "security",
37
- "performance",
38
- "maintainability",
39
- "functionality",
40
- "error_handling",
41
- ]
42
- excludePatterns:
43
- - "*.lock"
44
- - "*.svg"
45
- - "*.png"
46
- - "*.jpg"
47
- - "*.gif"
48
- - "*.min.js"
49
- - "*.min.css"
50
- - "dist/**"
51
- - "build/**"
52
- - "vendor/**"
53
- contextLines: 3 # Lines of context around changes
54
- focusAreas:
55
- - "Security vulnerabilities"
56
- - "Performance bottlenecks"
57
- - "Error handling"
58
- - "Code quality"
59
-
60
- # NEW: Batch Processing Configuration
61
- batchProcessing:
62
- enabled: true # Enable batch processing for large PRs
63
- maxFilesPerBatch: 3 # Maximum files to process in each batch
64
- prioritizeSecurityFiles: true # Process security-sensitive files first
65
- parallelBatches: false # Keep for backward compatibility
66
- batchDelayMs: 1000 # Delay between batches in milliseconds
67
- singleRequestThreshold: 5 # Use single request for PRs with โ‰ค5 files
68
-
69
- # NEW: Parallel Processing Configuration
70
- parallel:
71
- enabled: true # Enable parallel processing by default
72
- maxConcurrentBatches: 3 # Maximum concurrent batches
73
- rateLimitStrategy: "fixed" # Options: fixed, adaptive
74
- tokenBudgetDistribution: "equal" # Options: equal, weighted
75
- failureHandling: "continue" # Options: continue, stop-all
76
-
77
- # Multi-Instance Processing Configuration
78
- multiInstance:
79
- enabled: true # Enable multi-instance review
80
- instanceCount: 2 # Number of instances to run in parallel
81
- instances:
82
- - name: "primary"
83
- provider: "vertex"
84
- model: "gemini-2.5-pro"
85
- temperature: 0.3
86
- weight: 1.0
87
- - name: "secondary"
88
- provider: "vertex"
89
- model: "gemini-2.5-pro"
90
- temperature: 0.1
91
- weight: 1.0
92
- deduplication:
93
- enabled: true
94
- similarityThreshold: 40 # Similarity percentage threshold (0-100)
95
- maxCommentsToPost: 30
96
- prioritizeBy: "severity"
97
-
98
- # NEW: Semantic Comment Deduplication Configuration
99
- semanticDeduplication:
100
- enabled: true # Enable AI-powered semantic similarity analysis
101
- similarityThreshold: 70 # Similarity percentage threshold (0-100)
102
- batchSize: 15 # Number of violations to process per batch
103
- timeout: "5m" # Timeout for similarity analysis
104
- fallbackOnError: true # Return all violations if AI analysis fails
105
- logMatches: true # Log detailed similarity match information
106
-
107
- # Description Enhancement Configuration
108
- descriptionEnhancement:
109
- enabled: true
110
- preserveContent: true # Always preserve existing content
111
- autoFormat: true
112
-
113
- requiredSections:
114
- - key: "changelog"
115
- name: "Changelog (Modules Modified)"
116
- required: true
117
- - key: "testcases"
118
- name: "Test Cases (What to be tested)"
119
- required: true
120
- - key: "config_changes"
121
- name: "CAC Config Or Service Config Changes"
122
- required: true
123
-
124
- # Customize AI behavior:
125
- systemPrompt: |
126
- You are a Senior Staff Engineer writing comprehensive technical documentation.
127
- Focus on architectural decisions, trade-offs, and long-term maintainability.
128
-
129
- # Customize formatting:
130
- enhancementInstructions: |
131
- Keep descriptions under 300 words. Use bullet points, not paragraphs.
132
- No emojis. Professional tone only. Include numbers and metrics.
133
-
134
- # NEW: Diff Strategy Configuration
135
- diffStrategy:
11
+ showBanner: true # Show Yama banner on startup
12
+ streamingMode: false # Enable real-time streaming of AI decisions
13
+ verboseToolCalls: false # Log every MCP tool call
14
+ showAIThinking: false # Display AI reasoning process
15
+
16
+ # ============================================================================
17
+ # AI Configuration
18
+ # ============================================================================
19
+ ai:
20
+ provider: "auto" # auto | google-ai | anthropic | openai | bedrock
21
+ model: "gemini-2.5-pro" # or claude-3-7-sonnet-20250219-v1:0, gpt-4, etc.
22
+ temperature: 0.2 # Lower = more deterministic (0.0-1.0)
23
+ maxTokens: 128000 # Maximum tokens per AI call
24
+ enableAnalytics: true # Track token usage and costs
25
+ enableEvaluation: false # Enable quality evaluation (slower)
26
+ timeout: "15m" # Maximum time for review
27
+ retryAttempts: 3 # Number of retries on failure
28
+
29
+ # Conversation memory for maintaining review state
30
+ conversationMemory:
136
31
  enabled: true
137
- thresholds:
138
- wholeDiffMaxFiles: 2 # Use whole diff for โ‰ค2 files
139
- fileByFileMinFiles: 3 # Use file-by-file for โ‰ฅ3 files
140
- # Optional: Force a specific strategy regardless of file count
141
- # forceStrategy: "file-by-file" # Options: whole, file-by-file, auto
142
-
143
- # Security Scan Configuration (Future)
144
- securityScan:
145
- enabled: false
146
- level: "strict" # Options: strict, moderate, basic
147
- scanTypes: ["dependencies", "secrets", "vulnerabilities"]
148
-
149
- # Analytics Configuration (Future)
150
- analytics:
151
- enabled: false
152
- trackMetrics: true
153
- exportFormat: "json" # Options: json, csv, yaml
154
-
155
- # Cache Configuration
156
- cache:
32
+ store: "memory" # memory | redis
33
+ maxSessions: 50
34
+ maxTurnsPerSession: 300 # Long reviews need many turns
35
+ enableSummarization: false # Don't summarize mid-review
36
+
37
+ # ============================================================================
38
+ # MCP Servers Configuration
39
+ # ============================================================================
40
+ # Bitbucket MCP is always enabled (hardcoded)
41
+ # Jira MCP can be enabled/disabled here
42
+ # Use blockedTools to prevent AI from using specific MCP tools
43
+ mcpServers:
44
+ bitbucket:
45
+ # Optional: Block specific Bitbucket tools from AI access
46
+ # This prevents the AI from performing certain actions
47
+ blockedTools: []
48
+ # Example blocked tools (uncomment to use):
49
+ # - merge_pull_request # Prevent AI from merging PRs
50
+ # - delete_branch # Prevent AI from deleting branches
51
+ # - approve_pull_request # Prevent AI from auto-approving PRs
52
+
53
+ jira:
54
+ enabled: true # Set to false to disable Jira integration
55
+ # Optional: Block specific Jira tools from AI access
56
+ blockedTools: []
57
+ # Example blocked tools (uncomment to use):
58
+ # - jira_create_issue # Prevent AI from creating Jira issues
59
+ # - jira_delete_issue # Prevent AI from deleting issues
60
+ # - jira_update_issue # Prevent AI from modifying issues
61
+
62
+ # ============================================================================
63
+ # Review Configuration
64
+ # ============================================================================
65
+ review:
157
66
  enabled: true
158
- ttl: "30m" # Time to live for cache entries
159
- maxSize: "100MB"
160
- storage: "memory" # Options: memory, redis, file
161
67
 
162
- # Performance Configuration
163
- performance:
164
- batch:
165
- enabled: true
166
- maxConcurrent: 5 # Max concurrent API calls
167
- delayBetween: "1s" # Delay between batches
168
- optimization:
169
- reuseConnections: true
170
- compressRequests: false
171
- enableHttp2: true
172
-
173
- # Custom Rules Configuration
174
- rules:
175
- security:
176
- - name: "No hardcoded secrets"
177
- pattern: "(password|secret|key)\\s*=\\s*[\"'][^\"']+[\"']"
178
- severity: "CRITICAL"
179
- message: "Hardcoded secrets detected"
180
- suggestion: "Use environment variables or secure configuration"
181
-
182
- - name: "SQL injection prevention"
183
- pattern: "query\\([^?]+\\+.*\\)"
184
- severity: "CRITICAL"
185
- message: "Potential SQL injection vulnerability"
186
- suggestion: "Use parameterized queries"
187
-
188
- performance:
189
- - name: "Avoid N+1 queries"
190
- pattern: "forEach.*await.*query"
191
- severity: "MAJOR"
192
- message: "Potential N+1 query pattern detected"
193
- suggestion: "Consider batch loading or joins"
194
-
195
- # Reporting Configuration
196
- reporting:
197
- formats: ["markdown", "json"]
198
- includeAnalytics: true
199
- includeMetrics: true
200
-
201
- # Monitoring Configuration (Future)
202
- monitoring:
203
- enabled: false
204
- metrics: ["api_calls", "cache_hits", "processing_time"]
205
- exportFormat: "prometheus"
206
- interval: "1m"
68
+ # High-level workflow instructions (combined with base system prompt)
69
+ workflowInstructions: |
70
+ Follow the autonomous review workflow:
71
+ 1. Read PR details and find Jira ticket
72
+ 2. Read project standards from memory-bank
73
+ 3. Analyze files one-by-one
74
+ 4. Search code for context as needed
75
+ 5. Comment on issues immediately
76
+ 6. Make final decision based on blocking criteria
77
+
78
+ # Analysis focus areas (in priority order)
79
+ focusAreas:
80
+ - name: "Security Analysis"
81
+ priority: "CRITICAL"
82
+ description: |
83
+ - SQL/NoSQL injection vulnerabilities
84
+ - Cross-Site Scripting (XSS)
85
+ - Authentication/Authorization flaws
86
+ - Hardcoded secrets, API keys, passwords
87
+ - Input validation and sanitization
88
+ - Data exposure and privacy violations
89
+
90
+ - name: "Performance Review"
91
+ priority: "MAJOR"
92
+ description: |
93
+ - N+1 database query patterns
94
+ - Memory leaks and resource management
95
+ - Algorithm complexity issues
96
+ - Missing caching opportunities
97
+ - Blocking I/O in async contexts
98
+
99
+ - name: "Code Quality"
100
+ priority: "MAJOR"
101
+ description: |
102
+ - SOLID principle violations
103
+ - Poor error handling
104
+ - Code duplication (DRY violations)
105
+ - Poor naming conventions
106
+ - Missing edge case handling
107
+
108
+ # Blocking criteria (OPTIONAL - AI uses these to decide whether to block PR)
109
+ # If not provided or empty, AI will review and comment but NOT auto-block/approve PRs
110
+ # Uncomment and customize the examples below to enable auto-blocking:
111
+ blockingCriteria: []
112
+ # blockingCriteria:
113
+ # - condition: "ANY CRITICAL severity issue"
114
+ # action: "BLOCK"
115
+ # reason: "Security or data loss risk"
116
+ #
117
+ # - condition: "3 or more MAJOR severity issues"
118
+ # action: "BLOCK"
119
+ # reason: "Too many significant bugs/performance issues"
120
+ #
121
+ # - condition: "Jira requirement coverage < 70%"
122
+ # action: "BLOCK"
123
+ # reason: "Incomplete implementation of requirements"
124
+
125
+ # Files to exclude from analysis
126
+ excludePatterns:
127
+ - "*.lock"
128
+ - "*.svg"
129
+ - "*.min.js"
130
+ - "*.map"
131
+ - "package-lock.json"
132
+ - "pnpm-lock.yaml"
133
+ - "yarn.lock"
134
+
135
+ # Context settings
136
+ contextLines: 3 # Lines of context around each diff change
137
+ maxFilesPerReview: 100 # Maximum files to review
138
+ fileAnalysisTimeout: "2m" # Timeout per file
139
+
140
+ # Tool usage preferences
141
+ toolPreferences:
142
+ lazyLoading: true # Read files on-demand (RECOMMENDED)
143
+ cacheToolResults: true # Cache MCP tool responses
144
+ parallelToolCalls: false # Sequential for better context
145
+ maxToolCallsPerFile: 20 # Prevent infinite loops
146
+ enableCodeSearch: true # Allow search_code() usage
147
+ enableDirectoryListing: true # Allow list_directory_content()
148
+
149
+ # ============================================================================
150
+ # PR Description Enhancement
151
+ # ============================================================================
152
+ descriptionEnhancement:
153
+ enabled: true
154
+
155
+ instructions: |
156
+ Enhance the PR description using Jira requirements and diff analysis.
157
+ Generate comprehensive, well-structured description with all required sections.
158
+
159
+ requiredSections:
160
+ - key: "summary"
161
+ name: "๐Ÿ“‹ Summary"
162
+ required: true
163
+ description: "Clear overview of what this PR accomplishes"
164
+
165
+ - key: "changes"
166
+ name: "๐Ÿ”ง Changes Made"
167
+ required: true
168
+ description: "Specific technical changes with file references"
207
169
 
208
- # Memory Bank Configuration
170
+ - key: "jira"
171
+ name: "๐ŸŽซ Jira Reference"
172
+ required: false
173
+ description: "Link to Jira ticket and requirement coverage"
174
+
175
+ - key: "testing"
176
+ name: "๐Ÿงช Testing Strategy"
177
+ required: true
178
+ description: "How changes were tested and validation approach"
179
+
180
+ - key: "impact"
181
+ name: "โšก Impact & Considerations"
182
+ required: false
183
+ description: "Business impact, performance implications, breaking changes"
184
+
185
+ preserveContent: true # Don't remove existing images/links/tables
186
+ autoFormat: true # Clean up markdown formatting
187
+
188
+ # ============================================================================
189
+ # Memory Bank & Project Context
190
+ # ============================================================================
209
191
  memoryBank:
210
192
  enabled: true
211
- path: "memory-bank" # Primary path to look for memory bank files
212
- fallbackPaths: # Optional fallback paths if primary doesn't exist
193
+ path: "memory-bank"
194
+ fallbackPaths:
213
195
  - "docs/memory-bank"
214
196
  - ".memory-bank"
215
- - "project-docs/context"
197
+
198
+ # Standard files to read for project context
199
+ standardFiles:
200
+ - "project-overview.md"
201
+ - "architecture.md"
202
+ - "coding-standards.md"
203
+ - "security-guidelines.md"
204
+
205
+ # ============================================================================
206
+ # Knowledge Base - Reinforcement Learning from PR Feedback
207
+ # ============================================================================
208
+ # Yama learns from developer feedback on AI comments across merged PRs.
209
+ # Use 'yama learn -w <workspace> -r <repo> -p <pr-id>' to extract learnings.
210
+ knowledgeBase:
211
+ enabled: true
212
+
213
+ # Path to knowledge base file (relative to repo root)
214
+ path: ".yama/knowledge-base.md"
215
+
216
+ # Patterns to identify AI-generated comments (author name matching)
217
+ aiAuthorPatterns:
218
+ - "Yama"
219
+ - "yama-bot"
220
+ - "yama-review"
221
+
222
+ # Automatically summarize knowledge base when entry count exceeds this
223
+ maxEntriesBeforeSummarization: 50
224
+
225
+ # How many consolidated entries to keep after summarization
226
+ summaryRetentionCount: 20
227
+
228
+ # Automatically commit knowledge base changes (with --commit flag)
229
+ autoCommit: false
230
+
231
+ # ============================================================================
232
+ # Project-Specific Standards (Override in your repository)
233
+ # ============================================================================
234
+ projectStandards:
235
+ # Path to project-specific prompt files (relative to repo root)
236
+ customPromptsPath: "config/prompts/"
237
+
238
+ # Additional focus areas beyond defaults
239
+ additionalFocusAreas: []
240
+
241
+ # Custom blocking rules
242
+ customBlockingRules: []
243
+
244
+ # Severity level overrides
245
+ severityOverrides: {}
246
+
247
+ # ============================================================================
248
+ # Monitoring & Analytics
249
+ # ============================================================================
250
+ monitoring:
251
+ enabled: true
252
+ logToolCalls: true # Log every MCP tool execution
253
+ logAIDecisions: true # Log AI decision points
254
+ logTokenUsage: true # Log token usage for cost tracking
255
+ exportFormat: "json" # json | csv
256
+ exportPath: ".yama/analytics/"
257
+
258
+ # ============================================================================
259
+ # Performance & Cost Controls
260
+ # ============================================================================
261
+ performance:
262
+ maxReviewDuration: "15m" # Kill switch for long reviews
263
+
264
+ tokenBudget:
265
+ maxTokensPerReview: 500000 # Hard limit on tokens
266
+ warningThreshold: 400000 # Warn when approaching limit
267
+
268
+ costControls:
269
+ maxCostPerReview: 2.0 # USD limit per review
270
+ warningThreshold: 1.5 # Warn at $1.50
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Yama CLI - Enhanced command line interface
4
- * Provides backward compatibility with pr-police.js and pr-describe.js
5
- * Plus new unified commands for the enhanced functionality
6
- */
7
- /**
8
- * Main execution
9
- */
10
- declare function main(): void;
11
- export { main };
12
- //# sourceMappingURL=index.d.ts.map