@juspay/yama 1.5.1 → 2.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/.mcp-config.example.json +26 -0
- package/CHANGELOG.md +40 -0
- package/README.md +311 -685
- package/dist/cli/v2.cli.d.ts +13 -0
- package/dist/cli/v2.cli.js +290 -0
- package/dist/index.d.ts +12 -13
- package/dist/index.js +18 -19
- package/dist/v2/config/ConfigLoader.d.ts +50 -0
- package/dist/v2/config/ConfigLoader.js +205 -0
- package/dist/v2/config/DefaultConfig.d.ts +9 -0
- package/dist/v2/config/DefaultConfig.js +191 -0
- package/dist/v2/core/MCPServerManager.d.ts +22 -0
- package/dist/v2/core/MCPServerManager.js +92 -0
- package/dist/v2/core/SessionManager.d.ts +72 -0
- package/dist/v2/core/SessionManager.js +200 -0
- package/dist/v2/core/YamaV2Orchestrator.d.ts +112 -0
- package/dist/v2/core/YamaV2Orchestrator.js +549 -0
- package/dist/v2/prompts/EnhancementSystemPrompt.d.ts +8 -0
- package/dist/v2/prompts/EnhancementSystemPrompt.js +216 -0
- package/dist/v2/prompts/PromptBuilder.d.ts +38 -0
- package/dist/v2/prompts/PromptBuilder.js +228 -0
- package/dist/v2/prompts/ReviewSystemPrompt.d.ts +8 -0
- package/dist/v2/prompts/ReviewSystemPrompt.js +270 -0
- package/dist/v2/types/config.types.d.ts +120 -0
- package/dist/v2/types/config.types.js +5 -0
- package/dist/v2/types/mcp.types.d.ts +191 -0
- package/dist/v2/types/mcp.types.js +6 -0
- package/dist/v2/types/v2.types.d.ts +182 -0
- package/dist/v2/types/v2.types.js +42 -0
- package/dist/v2/utils/ObservabilityConfig.d.ts +22 -0
- package/dist/v2/utils/ObservabilityConfig.js +48 -0
- package/package.json +11 -9
- package/yama.config.example.yaml +214 -193
- package/dist/cli/index.d.ts +0 -12
- package/dist/cli/index.js +0 -538
- package/dist/core/ContextGatherer.d.ts +0 -110
- package/dist/core/ContextGatherer.js +0 -470
- package/dist/core/Guardian.d.ts +0 -81
- package/dist/core/Guardian.js +0 -474
- package/dist/core/providers/BitbucketProvider.d.ts +0 -105
- package/dist/core/providers/BitbucketProvider.js +0 -489
- package/dist/features/CodeReviewer.d.ts +0 -173
- package/dist/features/CodeReviewer.js +0 -1707
- package/dist/features/DescriptionEnhancer.d.ts +0 -64
- package/dist/features/DescriptionEnhancer.js +0 -445
- package/dist/features/MultiInstanceProcessor.d.ts +0 -74
- package/dist/features/MultiInstanceProcessor.js +0 -360
- package/dist/types/index.d.ts +0 -624
- package/dist/types/index.js +0 -104
- package/dist/utils/Cache.d.ts +0 -103
- package/dist/utils/Cache.js +0 -444
- package/dist/utils/ConfigManager.d.ts +0 -88
- package/dist/utils/ConfigManager.js +0 -603
- package/dist/utils/ContentSimilarityService.d.ts +0 -74
- package/dist/utils/ContentSimilarityService.js +0 -215
- package/dist/utils/ExactDuplicateRemover.d.ts +0 -77
- package/dist/utils/ExactDuplicateRemover.js +0 -361
- package/dist/utils/Logger.d.ts +0 -31
- package/dist/utils/Logger.js +0 -214
- package/dist/utils/MemoryBankManager.d.ts +0 -73
- package/dist/utils/MemoryBankManager.js +0 -310
- package/dist/utils/ParallelProcessing.d.ts +0 -140
- package/dist/utils/ParallelProcessing.js +0 -333
- package/dist/utils/ProviderLimits.d.ts +0 -58
- package/dist/utils/ProviderLimits.js +0 -143
- package/dist/utils/RetryManager.d.ts +0 -78
- package/dist/utils/RetryManager.js +0 -205
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yama V2 TypeScript Type Definitions
|
|
3
|
+
* AI-Native MCP Architecture Types
|
|
4
|
+
*/
|
|
5
|
+
export interface ReviewRequest {
|
|
6
|
+
workspace: string;
|
|
7
|
+
repository: string;
|
|
8
|
+
pullRequestId?: number;
|
|
9
|
+
branch?: string;
|
|
10
|
+
dryRun?: boolean;
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
configPath?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ReviewResult {
|
|
15
|
+
prId: number;
|
|
16
|
+
decision: "APPROVED" | "CHANGES_REQUESTED" | "BLOCKED";
|
|
17
|
+
statistics: ReviewStatistics;
|
|
18
|
+
summary: string;
|
|
19
|
+
duration: number;
|
|
20
|
+
tokenUsage: TokenUsage;
|
|
21
|
+
costEstimate: number;
|
|
22
|
+
sessionId: string;
|
|
23
|
+
descriptionEnhanced?: boolean;
|
|
24
|
+
totalComments?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ReviewStatistics {
|
|
27
|
+
filesReviewed: number;
|
|
28
|
+
issuesFound: IssuesBySeverity;
|
|
29
|
+
requirementCoverage: number;
|
|
30
|
+
codeQualityScore: number;
|
|
31
|
+
toolCallsMade: number;
|
|
32
|
+
cacheHits: number;
|
|
33
|
+
totalComments: number;
|
|
34
|
+
}
|
|
35
|
+
export interface IssuesBySeverity {
|
|
36
|
+
critical: number;
|
|
37
|
+
major: number;
|
|
38
|
+
minor: number;
|
|
39
|
+
suggestions: number;
|
|
40
|
+
}
|
|
41
|
+
export interface TokenUsage {
|
|
42
|
+
input: number;
|
|
43
|
+
output: number;
|
|
44
|
+
total: number;
|
|
45
|
+
}
|
|
46
|
+
export interface ReviewUpdate {
|
|
47
|
+
type: "tool_call" | "ai_thinking" | "comment_posted" | "decision" | "progress";
|
|
48
|
+
timestamp: string;
|
|
49
|
+
sessionId: string;
|
|
50
|
+
data: any;
|
|
51
|
+
}
|
|
52
|
+
export interface ToolCallUpdate {
|
|
53
|
+
toolName: string;
|
|
54
|
+
args: any;
|
|
55
|
+
result?: any;
|
|
56
|
+
error?: string;
|
|
57
|
+
duration?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface ProgressUpdate {
|
|
60
|
+
phase: "context_gathering" | "file_analysis" | "decision_making" | "description_enhancement";
|
|
61
|
+
progress: number;
|
|
62
|
+
message: string;
|
|
63
|
+
currentFile?: string;
|
|
64
|
+
filesProcessed?: number;
|
|
65
|
+
totalFiles?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface ReviewSession {
|
|
68
|
+
sessionId: string;
|
|
69
|
+
request: ReviewRequest;
|
|
70
|
+
startTime: Date;
|
|
71
|
+
endTime?: Date;
|
|
72
|
+
status: "running" | "completed" | "failed";
|
|
73
|
+
toolCalls: ToolCallRecord[];
|
|
74
|
+
result?: ReviewResult;
|
|
75
|
+
error?: Error;
|
|
76
|
+
metadata: SessionMetadata;
|
|
77
|
+
}
|
|
78
|
+
export interface ToolCallRecord {
|
|
79
|
+
timestamp: Date;
|
|
80
|
+
toolName: string;
|
|
81
|
+
args: any;
|
|
82
|
+
result: any;
|
|
83
|
+
error?: string;
|
|
84
|
+
duration: number;
|
|
85
|
+
tokenUsage?: TokenUsage;
|
|
86
|
+
}
|
|
87
|
+
export interface SessionMetadata {
|
|
88
|
+
yamaVersion: string;
|
|
89
|
+
aiProvider: string;
|
|
90
|
+
aiModel: string;
|
|
91
|
+
totalTokens: number;
|
|
92
|
+
totalCost: number;
|
|
93
|
+
cacheHitRatio: number;
|
|
94
|
+
}
|
|
95
|
+
export interface MCPToolResponse {
|
|
96
|
+
success: boolean;
|
|
97
|
+
data?: any;
|
|
98
|
+
error?: string;
|
|
99
|
+
metadata?: {
|
|
100
|
+
cached?: boolean;
|
|
101
|
+
duration?: number;
|
|
102
|
+
source?: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export interface BitbucketPRDetails {
|
|
106
|
+
id: number;
|
|
107
|
+
title: string;
|
|
108
|
+
description: string;
|
|
109
|
+
author: string;
|
|
110
|
+
state: "OPEN" | "MERGED" | "DECLINED";
|
|
111
|
+
sourceRef: string;
|
|
112
|
+
targetRef: string;
|
|
113
|
+
createdDate: string;
|
|
114
|
+
updatedDate: string;
|
|
115
|
+
reviewers: any[];
|
|
116
|
+
comments: any[];
|
|
117
|
+
fileChanges: string[];
|
|
118
|
+
}
|
|
119
|
+
export interface JiraTicketDetails {
|
|
120
|
+
key: string;
|
|
121
|
+
summary: string;
|
|
122
|
+
description: string;
|
|
123
|
+
status: string;
|
|
124
|
+
acceptanceCriteria?: string;
|
|
125
|
+
requirements?: string[];
|
|
126
|
+
issueType: string;
|
|
127
|
+
priority: string;
|
|
128
|
+
}
|
|
129
|
+
export interface PromptLayer {
|
|
130
|
+
name: string;
|
|
131
|
+
priority: number;
|
|
132
|
+
content: string;
|
|
133
|
+
source: "base" | "config" | "project";
|
|
134
|
+
}
|
|
135
|
+
export interface FocusArea {
|
|
136
|
+
name: string;
|
|
137
|
+
priority: "CRITICAL" | "MAJOR" | "MINOR";
|
|
138
|
+
description: string;
|
|
139
|
+
}
|
|
140
|
+
export interface BlockingCriteria {
|
|
141
|
+
condition: string;
|
|
142
|
+
action: "BLOCK" | "REQUEST_CHANGES" | "WARN";
|
|
143
|
+
reason: string;
|
|
144
|
+
}
|
|
145
|
+
export interface ToolContext {
|
|
146
|
+
sessionId: string;
|
|
147
|
+
workspace: string;
|
|
148
|
+
repository: string;
|
|
149
|
+
pullRequestId?: number;
|
|
150
|
+
branch?: string;
|
|
151
|
+
dryRun: boolean;
|
|
152
|
+
metadata: {
|
|
153
|
+
yamaVersion: string;
|
|
154
|
+
startTime: string;
|
|
155
|
+
jiraTicket?: string;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export interface AIAnalysisContext {
|
|
159
|
+
prDetails: BitbucketPRDetails;
|
|
160
|
+
jiraTicket?: JiraTicketDetails;
|
|
161
|
+
projectStandards?: string;
|
|
162
|
+
memoryBankContext?: string;
|
|
163
|
+
clinerules?: string;
|
|
164
|
+
}
|
|
165
|
+
export declare class YamaV2Error extends Error {
|
|
166
|
+
code: string;
|
|
167
|
+
context?: any | undefined;
|
|
168
|
+
constructor(code: string, message: string, context?: any | undefined);
|
|
169
|
+
}
|
|
170
|
+
export declare class MCPServerError extends YamaV2Error {
|
|
171
|
+
constructor(message: string, context?: any);
|
|
172
|
+
}
|
|
173
|
+
export declare class ConfigurationError extends YamaV2Error {
|
|
174
|
+
constructor(message: string, context?: any);
|
|
175
|
+
}
|
|
176
|
+
export declare class ReviewTimeoutError extends YamaV2Error {
|
|
177
|
+
constructor(message: string, context?: any);
|
|
178
|
+
}
|
|
179
|
+
export declare class TokenBudgetExceededError extends YamaV2Error {
|
|
180
|
+
constructor(message: string, context?: any);
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=v2.types.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Yama V2 TypeScript Type Definitions
|
|
3
|
+
* AI-Native MCP Architecture Types
|
|
4
|
+
*/
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Error Types
|
|
7
|
+
// ============================================================================
|
|
8
|
+
export class YamaV2Error extends Error {
|
|
9
|
+
code;
|
|
10
|
+
context;
|
|
11
|
+
constructor(code, message, context) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.context = context;
|
|
15
|
+
this.name = "YamaV2Error";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class MCPServerError extends YamaV2Error {
|
|
19
|
+
constructor(message, context) {
|
|
20
|
+
super("MCP_SERVER_ERROR", message, context);
|
|
21
|
+
this.name = "MCPServerError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class ConfigurationError extends YamaV2Error {
|
|
25
|
+
constructor(message, context) {
|
|
26
|
+
super("CONFIGURATION_ERROR", message, context);
|
|
27
|
+
this.name = "ConfigurationError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class ReviewTimeoutError extends YamaV2Error {
|
|
31
|
+
constructor(message, context) {
|
|
32
|
+
super("REVIEW_TIMEOUT", message, context);
|
|
33
|
+
this.name = "ReviewTimeoutError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class TokenBudgetExceededError extends YamaV2Error {
|
|
37
|
+
constructor(message, context) {
|
|
38
|
+
super("TOKEN_BUDGET_EXCEEDED", message, context);
|
|
39
|
+
this.name = "TokenBudgetExceededError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=v2.types.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability Configuration Builder
|
|
3
|
+
* Builds NeuroLink observability config from environment variables
|
|
4
|
+
*/
|
|
5
|
+
export interface ObservabilityConfig {
|
|
6
|
+
langfuse?: {
|
|
7
|
+
publicKey: string;
|
|
8
|
+
secretKey: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build observability config from environment variables
|
|
15
|
+
* Returns null if observability is not configured
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildObservabilityConfigFromEnv(): ObservabilityConfig | null;
|
|
18
|
+
/**
|
|
19
|
+
* Validate observability configuration
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateObservabilityConfig(config: ObservabilityConfig | null): boolean;
|
|
22
|
+
//# sourceMappingURL=ObservabilityConfig.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability Configuration Builder
|
|
3
|
+
* Builds NeuroLink observability config from environment variables
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Build observability config from environment variables
|
|
7
|
+
* Returns null if observability is not configured
|
|
8
|
+
*/
|
|
9
|
+
export function buildObservabilityConfigFromEnv() {
|
|
10
|
+
const langfusePublicKey = process.env.LANGFUSE_PUBLIC_KEY;
|
|
11
|
+
const langfuseSecretKey = process.env.LANGFUSE_SECRET_KEY;
|
|
12
|
+
const langfuseBaseUrl = process.env.LANGFUSE_BASE_URL;
|
|
13
|
+
const langfuseEnabled = process.env.LANGFUSE_ENABLED !== "false"; // Default to true if keys present
|
|
14
|
+
// Check if Langfuse is configured
|
|
15
|
+
if (langfusePublicKey && langfuseSecretKey) {
|
|
16
|
+
return {
|
|
17
|
+
langfuse: {
|
|
18
|
+
publicKey: langfusePublicKey,
|
|
19
|
+
secretKey: langfuseSecretKey,
|
|
20
|
+
baseUrl: langfuseBaseUrl || "https://cloud.langfuse.com",
|
|
21
|
+
enabled: langfuseEnabled,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// No observability configured
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validate observability configuration
|
|
30
|
+
*/
|
|
31
|
+
export function validateObservabilityConfig(config) {
|
|
32
|
+
if (!config) {
|
|
33
|
+
return true; // No config is valid (observability is optional)
|
|
34
|
+
}
|
|
35
|
+
if (config.langfuse) {
|
|
36
|
+
const { publicKey, secretKey, baseUrl } = config.langfuse;
|
|
37
|
+
if (!publicKey || !secretKey) {
|
|
38
|
+
console.error("❌ Langfuse observability config invalid: missing publicKey or secretKey");
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (baseUrl && !baseUrl.startsWith("http")) {
|
|
42
|
+
console.error("❌ Langfuse observability config invalid: baseUrl must start with http/https");
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=ObservabilityConfig.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/yama",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Enterprise-grade Pull Request automation toolkit with AI-powered code review and description enhancement",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pr",
|
|
@@ -28,10 +28,7 @@
|
|
|
28
28
|
"main": "dist/index.js",
|
|
29
29
|
"types": "dist/index.d.ts",
|
|
30
30
|
"bin": {
|
|
31
|
-
"yama": "dist/cli/
|
|
32
|
-
"pr-guardian": "dist/cli/index.js",
|
|
33
|
-
"pr-police": "dist/cli/index.js",
|
|
34
|
-
"pr-scribe": "dist/cli/index.js"
|
|
31
|
+
"yama": "dist/cli/v2.cli.js"
|
|
35
32
|
},
|
|
36
33
|
"directories": {
|
|
37
34
|
"test": "tests"
|
|
@@ -46,11 +43,14 @@
|
|
|
46
43
|
"README.md",
|
|
47
44
|
"CHANGELOG.md",
|
|
48
45
|
"LICENSE",
|
|
49
|
-
"yama.config.example.yaml"
|
|
46
|
+
"yama.config.example.yaml",
|
|
47
|
+
".mcp-config.example.json",
|
|
48
|
+
"docs/v2"
|
|
50
49
|
],
|
|
51
50
|
"scripts": {
|
|
52
51
|
"build": "tsc && tsc-alias",
|
|
53
|
-
"dev": "
|
|
52
|
+
"dev": "tsx watch src/cli/v2.cli.ts",
|
|
53
|
+
"dev:run": "tsx src/cli/v2.cli.ts",
|
|
54
54
|
"test": "jest",
|
|
55
55
|
"lint": "eslint .",
|
|
56
56
|
"lint:fix": "eslint . --fix",
|
|
@@ -83,8 +83,9 @@
|
|
|
83
83
|
"check:all": "npm run lint && npm run format --check && npm run validate && npm run validate:commit"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@juspay/neurolink": "^
|
|
87
|
-
"@nexus2520/bitbucket-mcp-server": "^
|
|
86
|
+
"@juspay/neurolink": "^8.1.0",
|
|
87
|
+
"@nexus2520/bitbucket-mcp-server": "^1.1.2",
|
|
88
|
+
"@nexus2520/jira-mcp-server": "^1.0.1",
|
|
88
89
|
"chalk": "^4.1.2",
|
|
89
90
|
"commander": "^11.0.0",
|
|
90
91
|
"debug": "^4.3.4",
|
|
@@ -125,6 +126,7 @@
|
|
|
125
126
|
"ts-node": "^10.0.0",
|
|
126
127
|
"ts-node-dev": "^2.0.0",
|
|
127
128
|
"tsc-alias": "^1.8.0",
|
|
129
|
+
"tsx": "^4.20.6",
|
|
128
130
|
"typedoc": "^0.25.0",
|
|
129
131
|
"typescript": "^5.0.0"
|
|
130
132
|
},
|