@juspay/yama 2.0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [2.1.0](https://github.com/juspay/yama/compare/v2.0.0...v2.1.0) (2025-12-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **ci:** migrate to npm trusted publishing with OIDC authentication ([c836a0c](https://github.com/juspay/yama/commit/c836a0c0b3c7077f96fe0ffc8731296e997106c2))
7
+
8
+
9
+ ### Features
10
+
11
+ * **learn:** add knowledge base learning from PR feedback ([a9c3d9d](https://github.com/juspay/yama/commit/a9c3d9d75175048caf5468a94949f8fe61bcb0f9))
12
+
1
13
  # [2.0.0](https://github.com/juspay/yama/compare/v1.6.0...v2.0.0) (2025-11-26)
2
14
 
3
15
  ### Features
@@ -6,6 +6,7 @@
6
6
  import { Command } from "commander";
7
7
  import dotenv from "dotenv";
8
8
  import { createYamaV2 } from "../v2/core/YamaV2Orchestrator.js";
9
+ import { createLearningOrchestrator } from "../v2/core/LearningOrchestrator.js";
9
10
  // Load environment variables
10
11
  dotenv.config();
11
12
  const program = new Command();
@@ -27,6 +28,8 @@ export function setupV2CLI() {
27
28
  setupReviewCommand();
28
29
  // Enhance description command
29
30
  setupEnhanceCommand();
31
+ // Learn from PR feedback command
32
+ setupLearnCommand();
30
33
  // Init command
31
34
  setupInitCommand();
32
35
  // Migrate config command
@@ -162,6 +165,72 @@ function setupEnhanceCommand() {
162
165
  }
163
166
  });
164
167
  }
168
+ /**
169
+ * Learn from PR feedback command
170
+ * Extracts learnings from merged PRs to improve future reviews
171
+ */
172
+ function setupLearnCommand() {
173
+ program
174
+ .command("learn")
175
+ .description("Extract learnings from merged PR to improve future reviews")
176
+ .requiredOption("-w, --workspace <workspace>", "Bitbucket workspace")
177
+ .requiredOption("-r, --repository <repository>", "Repository name")
178
+ .requiredOption("-p, --pr <id>", "Merged pull request ID")
179
+ .option("--commit", "Auto-commit knowledge base changes to git")
180
+ .option("--summarize", "Force summarization of knowledge base")
181
+ .option("--output <path>", "Override knowledge base output path")
182
+ .option("--format <format>", "Output format for dry-run preview (md|json)", "md")
183
+ .action(async (options) => {
184
+ try {
185
+ const globalOpts = program.opts();
186
+ // Parse and validate PR ID
187
+ const pullRequestId = parseInt(options.pr, 10);
188
+ if (isNaN(pullRequestId)) {
189
+ console.error(`❌ Error: Invalid PR ID "${options.pr}" (must be a number)`);
190
+ process.exit(1);
191
+ }
192
+ // Validate format option
193
+ if (options.format && !["md", "json"].includes(options.format)) {
194
+ console.error(`❌ Error: Invalid format "${options.format}" (must be md or json)`);
195
+ process.exit(1);
196
+ }
197
+ const request = {
198
+ workspace: options.workspace,
199
+ repository: options.repository,
200
+ pullRequestId,
201
+ dryRun: globalOpts.dryRun || false,
202
+ commit: options.commit || false,
203
+ summarize: options.summarize || false,
204
+ outputPath: options.output,
205
+ outputFormat: options.format || "md",
206
+ };
207
+ // Create and initialize learning orchestrator
208
+ const orchestrator = createLearningOrchestrator();
209
+ await orchestrator.initialize(globalOpts.config);
210
+ // Extract learnings
211
+ const result = await orchestrator.extractLearnings(request);
212
+ // Handle result
213
+ if (!result.success) {
214
+ console.error(`\n❌ Learning extraction failed: ${result.error}`);
215
+ process.exit(1);
216
+ }
217
+ // Show final summary for live runs
218
+ if (!globalOpts.dryRun && result.learningsAdded > 0) {
219
+ console.log("\n🎉 Knowledge base updated successfully!");
220
+ console.log(` Use 'yama review' to apply these learnings to future reviews.`);
221
+ }
222
+ process.exit(0);
223
+ }
224
+ catch (error) {
225
+ console.error("\n❌ Learning extraction failed:", error.message);
226
+ if (error.stack && program.opts().verbose) {
227
+ console.error("\nStack trace:");
228
+ console.error(error.stack);
229
+ }
230
+ process.exit(1);
231
+ }
232
+ });
233
+ }
165
234
  /**
166
235
  * Initialize configuration command
167
236
  */
@@ -31,8 +31,12 @@ export class DefaultConfig {
31
31
  },
32
32
  },
33
33
  mcpServers: {
34
+ bitbucket: {
35
+ blockedTools: [],
36
+ },
34
37
  jira: {
35
38
  enabled: false, // Opt-in: users must explicitly enable Jira integration
39
+ blockedTools: [],
36
40
  },
37
41
  },
38
42
  review: {
@@ -79,23 +83,7 @@ export class DefaultConfig {
79
83
  `.trim(),
80
84
  },
81
85
  ],
82
- blockingCriteria: [
83
- {
84
- condition: "ANY CRITICAL severity issue",
85
- action: "BLOCK",
86
- reason: "Security or data loss risk",
87
- },
88
- {
89
- condition: "3 or more MAJOR severity issues",
90
- action: "BLOCK",
91
- reason: "Too many significant bugs/performance issues",
92
- },
93
- {
94
- condition: "Jira requirement coverage < 70% (only when Jira is enabled)",
95
- action: "BLOCK",
96
- reason: "Incomplete implementation of requirements",
97
- },
98
- ],
86
+ blockingCriteria: [], // Empty by default - no auto-blocking. Users can add custom criteria in their config.
99
87
  excludePatterns: [
100
88
  "*.lock",
101
89
  "*.svg",
@@ -160,6 +148,14 @@ export class DefaultConfig {
160
148
  "security-guidelines.md",
161
149
  ],
162
150
  },
151
+ knowledgeBase: {
152
+ enabled: true,
153
+ path: ".yama/knowledge-base.md",
154
+ aiAuthorPatterns: ["Yama", "yama-bot", "yama-review"],
155
+ maxEntriesBeforeSummarization: 50,
156
+ summaryRetentionCount: 20,
157
+ autoCommit: false,
158
+ },
163
159
  projectStandards: {
164
160
  customPromptsPath: "config/prompts/",
165
161
  additionalFocusAreas: [],
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Learning Orchestrator
3
+ * Main entry point for the knowledge base learning feature
4
+ * Orchestrates PR comment extraction, AI analysis, and knowledge base updates
5
+ */
6
+ import { LearnRequest, LearnResult } from "../learning/types.js";
7
+ export declare class LearningOrchestrator {
8
+ private neurolink;
9
+ private mcpManager;
10
+ private configLoader;
11
+ private promptManager;
12
+ private config;
13
+ private initialized;
14
+ constructor();
15
+ /**
16
+ * Initialize the learning orchestrator
17
+ */
18
+ initialize(configPath?: string): Promise<void>;
19
+ /**
20
+ * Extract learnings from a merged PR
21
+ * Uses fully agentic AI approach - AI decides which tools to call
22
+ */
23
+ extractLearnings(request: LearnRequest): Promise<LearnResult>;
24
+ /**
25
+ * Build instructions for Step 1: Fetch PR comments
26
+ */
27
+ private buildFetchCommentsInstructions;
28
+ /**
29
+ * Build instructions for Step 2: Extract learnings from fetched data
30
+ */
31
+ private buildExtractionInstructions;
32
+ /**
33
+ * Parse structured response from AI output
34
+ */
35
+ private parseStructuredLearnings;
36
+ /**
37
+ * Initialize NeuroLink with observability
38
+ */
39
+ private initializeNeurolink;
40
+ /**
41
+ * Ensure orchestrator is initialized
42
+ */
43
+ private ensureInitialized;
44
+ /**
45
+ * Handle dry run mode
46
+ */
47
+ private handleDryRun;
48
+ /**
49
+ * Run AI-powered summarization
50
+ */
51
+ private runSummarization;
52
+ /**
53
+ * Create empty result for cases with no learnings
54
+ */
55
+ private createEmptyResult;
56
+ /**
57
+ * Log the final result
58
+ */
59
+ private logResult;
60
+ }
61
+ /**
62
+ * Factory function to create LearningOrchestrator
63
+ */
64
+ export declare function createLearningOrchestrator(): LearningOrchestrator;
65
+ //# sourceMappingURL=LearningOrchestrator.d.ts.map