@juspay/yama 1.1.0 → 1.1.1
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 +27 -1
- package/README.md +151 -119
- package/dist/cli/index.js +201 -200
- package/dist/core/ContextGatherer.d.ts +3 -3
- package/dist/core/ContextGatherer.js +145 -149
- package/dist/core/Guardian.d.ts +1 -1
- package/dist/core/Guardian.js +122 -122
- package/dist/core/providers/BitbucketProvider.d.ts +3 -3
- package/dist/core/providers/BitbucketProvider.js +129 -121
- package/dist/features/CodeReviewer.d.ts +3 -3
- package/dist/features/CodeReviewer.js +290 -221
- package/dist/features/DescriptionEnhancer.d.ts +3 -3
- package/dist/features/DescriptionEnhancer.js +115 -94
- package/dist/index.d.ts +11 -11
- package/dist/index.js +10 -48
- package/dist/types/index.d.ts +21 -21
- package/dist/types/index.js +13 -18
- package/dist/utils/Cache.d.ts +1 -1
- package/dist/utils/Cache.js +62 -68
- package/dist/utils/ConfigManager.d.ts +1 -1
- package/dist/utils/ConfigManager.js +281 -253
- package/dist/utils/Logger.d.ts +2 -2
- package/dist/utils/Logger.js +69 -67
- package/package.json +7 -6
- package/yama.config.example.yaml +28 -21
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Consolidates all interfaces and types used across the application
|
|
4
4
|
*/
|
|
5
5
|
export interface AIProviderConfig {
|
|
6
|
-
provider?:
|
|
6
|
+
provider?: "auto" | "google-ai" | "openai" | "anthropic" | "azure" | "bedrock";
|
|
7
7
|
model?: string;
|
|
8
8
|
enableFallback?: boolean;
|
|
9
9
|
enableAnalytics?: boolean;
|
|
@@ -47,7 +47,7 @@ export interface EvaluationData {
|
|
|
47
47
|
};
|
|
48
48
|
confidence: number;
|
|
49
49
|
}
|
|
50
|
-
export type GitPlatform =
|
|
50
|
+
export type GitPlatform = "bitbucket" | "github" | "gitlab" | "azure-devops";
|
|
51
51
|
export interface GitCredentials {
|
|
52
52
|
username: string;
|
|
53
53
|
token: string;
|
|
@@ -69,7 +69,7 @@ export interface PRInfo {
|
|
|
69
69
|
title: string;
|
|
70
70
|
description: string;
|
|
71
71
|
author: string;
|
|
72
|
-
state:
|
|
72
|
+
state: "OPEN" | "MERGED" | "DECLINED" | "CLOSED";
|
|
73
73
|
sourceRef: string;
|
|
74
74
|
targetRef: string;
|
|
75
75
|
createdDate: string;
|
|
@@ -85,7 +85,7 @@ export interface PRReviewer {
|
|
|
85
85
|
displayName: string;
|
|
86
86
|
};
|
|
87
87
|
approved: boolean;
|
|
88
|
-
status:
|
|
88
|
+
status: "APPROVED" | "UNAPPROVED" | "NEEDS_WORK";
|
|
89
89
|
}
|
|
90
90
|
export interface PRComment {
|
|
91
91
|
id: number;
|
|
@@ -100,7 +100,7 @@ export interface PRComment {
|
|
|
100
100
|
filePath: string;
|
|
101
101
|
lineFrom: number;
|
|
102
102
|
lineTo: number;
|
|
103
|
-
lineType:
|
|
103
|
+
lineType: "ADDED" | "REMOVED" | "CONTEXT";
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
export interface PRDiff {
|
|
@@ -111,7 +111,7 @@ export interface PRDiff {
|
|
|
111
111
|
}
|
|
112
112
|
export interface FileChange {
|
|
113
113
|
path: string;
|
|
114
|
-
changeType:
|
|
114
|
+
changeType: "ADDED" | "MODIFIED" | "DELETED" | "RENAMED";
|
|
115
115
|
additions: number;
|
|
116
116
|
deletions: number;
|
|
117
117
|
hunks: DiffHunk[];
|
|
@@ -124,14 +124,14 @@ export interface DiffHunk {
|
|
|
124
124
|
lines: DiffLine[];
|
|
125
125
|
}
|
|
126
126
|
export interface DiffLine {
|
|
127
|
-
type:
|
|
127
|
+
type: "added" | "removed" | "context";
|
|
128
128
|
content: string;
|
|
129
129
|
oldLineNumber?: number;
|
|
130
130
|
newLineNumber?: number;
|
|
131
131
|
}
|
|
132
|
-
export type ViolationSeverity =
|
|
133
|
-
export type ViolationType =
|
|
134
|
-
export type ViolationCategory =
|
|
132
|
+
export type ViolationSeverity = "CRITICAL" | "MAJOR" | "MINOR" | "SUGGESTION";
|
|
133
|
+
export type ViolationType = "inline" | "general";
|
|
134
|
+
export type ViolationCategory = "security" | "performance" | "maintainability" | "functionality" | "error_handling" | "testing" | "general";
|
|
135
135
|
export interface Violation {
|
|
136
136
|
type: ViolationType;
|
|
137
137
|
file?: string;
|
|
@@ -140,7 +140,7 @@ export interface Violation {
|
|
|
140
140
|
before: string[];
|
|
141
141
|
after: string[];
|
|
142
142
|
};
|
|
143
|
-
line_type?:
|
|
143
|
+
line_type?: "ADDED" | "REMOVED" | "CONTEXT";
|
|
144
144
|
severity: ViolationSeverity;
|
|
145
145
|
category: ViolationCategory;
|
|
146
146
|
issue: string;
|
|
@@ -265,23 +265,23 @@ export interface DiffStrategyConfig {
|
|
|
265
265
|
wholeDiffMaxFiles: number;
|
|
266
266
|
fileByFileMinFiles: number;
|
|
267
267
|
};
|
|
268
|
-
forceStrategy?:
|
|
268
|
+
forceStrategy?: "whole" | "file-by-file" | "auto";
|
|
269
269
|
}
|
|
270
270
|
export interface SecurityScanConfig {
|
|
271
271
|
enabled: boolean;
|
|
272
|
-
level:
|
|
272
|
+
level: "strict" | "moderate" | "basic";
|
|
273
273
|
scanTypes: string[];
|
|
274
274
|
}
|
|
275
275
|
export interface AnalyticsConfig {
|
|
276
276
|
enabled: boolean;
|
|
277
277
|
trackMetrics: boolean;
|
|
278
|
-
exportFormat:
|
|
278
|
+
exportFormat: "json" | "csv" | "yaml";
|
|
279
279
|
}
|
|
280
280
|
export interface CacheConfig {
|
|
281
281
|
enabled: boolean;
|
|
282
282
|
ttl: string;
|
|
283
283
|
maxSize: string;
|
|
284
|
-
storage:
|
|
284
|
+
storage: "memory" | "redis" | "file";
|
|
285
285
|
}
|
|
286
286
|
export interface PerformanceConfig {
|
|
287
287
|
batch: {
|
|
@@ -314,11 +314,11 @@ export interface ReportingConfig {
|
|
|
314
314
|
export interface MonitoringConfig {
|
|
315
315
|
enabled: boolean;
|
|
316
316
|
metrics: string[];
|
|
317
|
-
exportFormat?:
|
|
317
|
+
exportFormat?: "json" | "prometheus" | "csv";
|
|
318
318
|
endpoint?: string;
|
|
319
319
|
interval?: string;
|
|
320
320
|
}
|
|
321
|
-
export type OperationType =
|
|
321
|
+
export type OperationType = "review" | "enhance-description" | "security-scan" | "analytics" | "all";
|
|
322
322
|
export interface OperationOptions {
|
|
323
323
|
workspace: string;
|
|
324
324
|
repository: string;
|
|
@@ -331,7 +331,7 @@ export interface OperationOptions {
|
|
|
331
331
|
}
|
|
332
332
|
export interface OperationResult {
|
|
333
333
|
operation: OperationType;
|
|
334
|
-
status:
|
|
334
|
+
status: "success" | "error" | "skipped";
|
|
335
335
|
data?: any;
|
|
336
336
|
error?: string;
|
|
337
337
|
duration: number;
|
|
@@ -350,7 +350,7 @@ export interface ProcessResult {
|
|
|
350
350
|
}
|
|
351
351
|
export interface StreamUpdate {
|
|
352
352
|
operation: OperationType;
|
|
353
|
-
status:
|
|
353
|
+
status: "started" | "progress" | "completed" | "error";
|
|
354
354
|
progress?: number;
|
|
355
355
|
message?: string;
|
|
356
356
|
data?: any;
|
|
@@ -361,11 +361,11 @@ export interface StreamOptions {
|
|
|
361
361
|
onError?: (error: Error) => void;
|
|
362
362
|
onComplete?: (result: ProcessResult) => void;
|
|
363
363
|
}
|
|
364
|
-
export type LogLevel =
|
|
364
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
365
365
|
export interface LoggerOptions {
|
|
366
366
|
level: LogLevel;
|
|
367
367
|
verbose: boolean;
|
|
368
|
-
format:
|
|
368
|
+
format: "simple" | "json" | "detailed";
|
|
369
369
|
colors: boolean;
|
|
370
370
|
}
|
|
371
371
|
export interface Logger {
|
package/dist/types/index.js
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Core TypeScript types for Yama
|
|
4
3
|
* Consolidates all interfaces and types used across the application
|
|
5
4
|
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ValidationError = exports.ProviderError = exports.ConfigurationError = exports.GuardianError = void 0;
|
|
8
5
|
// ============================================================================
|
|
9
6
|
// Error Types
|
|
10
7
|
// ============================================================================
|
|
11
|
-
class GuardianError extends Error {
|
|
8
|
+
export class GuardianError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
context;
|
|
12
11
|
constructor(code, message, context) {
|
|
13
12
|
super(message);
|
|
14
13
|
this.code = code;
|
|
15
14
|
this.context = context;
|
|
16
|
-
this.name =
|
|
15
|
+
this.name = "GuardianError";
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
class ConfigurationError extends GuardianError {
|
|
18
|
+
export class ConfigurationError extends GuardianError {
|
|
21
19
|
constructor(message, context) {
|
|
22
|
-
super(
|
|
23
|
-
this.name =
|
|
20
|
+
super("CONFIGURATION_ERROR", message, context);
|
|
21
|
+
this.name = "ConfigurationError";
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
class ProviderError extends GuardianError {
|
|
24
|
+
export class ProviderError extends GuardianError {
|
|
28
25
|
constructor(message, context) {
|
|
29
|
-
super(
|
|
30
|
-
this.name =
|
|
26
|
+
super("PROVIDER_ERROR", message, context);
|
|
27
|
+
this.name = "ProviderError";
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
|
-
|
|
34
|
-
class ValidationError extends GuardianError {
|
|
30
|
+
export class ValidationError extends GuardianError {
|
|
35
31
|
constructor(message, context) {
|
|
36
|
-
super(
|
|
37
|
-
this.name =
|
|
32
|
+
super("VALIDATION_ERROR", message, context);
|
|
33
|
+
this.name = "ValidationError";
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
|
-
exports.ValidationError = ValidationError;
|
|
41
36
|
// ============================================================================
|
|
42
37
|
// Export all types - Main file, no re-exports needed
|
|
43
38
|
// ============================================================================
|
package/dist/utils/Cache.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Enhanced Cache utility for Yama
|
|
3
3
|
* Provides intelligent caching for PR data, file contents, and AI responses
|
|
4
4
|
*/
|
|
5
|
-
import { Cache as ICache, CacheOptions } from
|
|
5
|
+
import { Cache as ICache, CacheOptions } from "../types/index.js";
|
|
6
6
|
export declare class Cache implements ICache {
|
|
7
7
|
private cache;
|
|
8
8
|
private statsData;
|
package/dist/utils/Cache.js
CHANGED
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Enhanced Cache utility for Yama
|
|
4
3
|
* Provides intelligent caching for PR data, file contents, and AI responses
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class Cache {
|
|
5
|
+
import NodeCache from "node-cache";
|
|
6
|
+
import { logger } from "./Logger.js";
|
|
7
|
+
export class Cache {
|
|
8
|
+
cache;
|
|
9
|
+
statsData = {
|
|
10
|
+
hits: 0,
|
|
11
|
+
misses: 0,
|
|
12
|
+
};
|
|
15
13
|
constructor(options = {}) {
|
|
16
|
-
this.statsData = {
|
|
17
|
-
hits: 0,
|
|
18
|
-
misses: 0
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Cache with tags for group invalidation
|
|
22
|
-
*/
|
|
23
|
-
this.tags = new Map();
|
|
24
14
|
const { ttl = 3600, // 1 hour default
|
|
25
15
|
maxSize = 100, // 100 keys max
|
|
26
|
-
checkPeriod = 600 // Check every 10 minutes
|
|
16
|
+
checkPeriod = 600, // Check every 10 minutes
|
|
27
17
|
} = options;
|
|
28
|
-
this.cache = new
|
|
18
|
+
this.cache = new NodeCache({
|
|
29
19
|
stdTTL: ttl,
|
|
30
20
|
maxKeys: maxSize,
|
|
31
21
|
checkperiod: checkPeriod,
|
|
32
22
|
useClones: false,
|
|
33
|
-
deleteOnExpire: true
|
|
23
|
+
deleteOnExpire: true,
|
|
34
24
|
});
|
|
35
|
-
this.cache.on(
|
|
36
|
-
|
|
25
|
+
this.cache.on("set", (key, _value) => {
|
|
26
|
+
logger.debug(`Cache SET: ${key}`);
|
|
37
27
|
});
|
|
38
|
-
this.cache.on(
|
|
39
|
-
|
|
28
|
+
this.cache.on("expired", (key, _value) => {
|
|
29
|
+
logger.debug(`Cache EXPIRED: ${key}`);
|
|
40
30
|
});
|
|
41
|
-
this.cache.on(
|
|
42
|
-
|
|
31
|
+
this.cache.on("del", (key, _value) => {
|
|
32
|
+
logger.debug(`Cache DELETE: ${key}`);
|
|
43
33
|
});
|
|
44
34
|
}
|
|
45
35
|
/**
|
|
@@ -49,12 +39,12 @@ class Cache {
|
|
|
49
39
|
const value = this.cache.get(key);
|
|
50
40
|
if (value !== undefined) {
|
|
51
41
|
this.statsData.hits++;
|
|
52
|
-
|
|
42
|
+
logger.debug(`Cache HIT: ${key}`);
|
|
53
43
|
return value;
|
|
54
44
|
}
|
|
55
45
|
else {
|
|
56
46
|
this.statsData.misses++;
|
|
57
|
-
|
|
47
|
+
logger.debug(`Cache MISS: ${key}`);
|
|
58
48
|
return undefined;
|
|
59
49
|
}
|
|
60
50
|
}
|
|
@@ -65,15 +55,15 @@ class Cache {
|
|
|
65
55
|
try {
|
|
66
56
|
const success = this.cache.set(key, value, ttl || 0);
|
|
67
57
|
if (success) {
|
|
68
|
-
|
|
58
|
+
logger.debug(`Cache SET successful: ${key}`);
|
|
69
59
|
}
|
|
70
60
|
else {
|
|
71
|
-
|
|
61
|
+
logger.warn(`Cache SET failed: ${key}`);
|
|
72
62
|
}
|
|
73
63
|
return success;
|
|
74
64
|
}
|
|
75
65
|
catch (error) {
|
|
76
|
-
|
|
66
|
+
logger.error(`Cache SET error: ${key}`, error);
|
|
77
67
|
return false;
|
|
78
68
|
}
|
|
79
69
|
}
|
|
@@ -82,7 +72,7 @@ class Cache {
|
|
|
82
72
|
*/
|
|
83
73
|
del(key) {
|
|
84
74
|
const deleted = this.cache.del(key);
|
|
85
|
-
|
|
75
|
+
logger.debug(`Cache DELETE: ${key}, deleted: ${deleted}`);
|
|
86
76
|
return deleted;
|
|
87
77
|
}
|
|
88
78
|
/**
|
|
@@ -98,7 +88,7 @@ class Cache {
|
|
|
98
88
|
this.cache.flushAll();
|
|
99
89
|
this.statsData.hits = 0;
|
|
100
90
|
this.statsData.misses = 0;
|
|
101
|
-
|
|
91
|
+
logger.debug("Cache cleared");
|
|
102
92
|
}
|
|
103
93
|
/**
|
|
104
94
|
* Get all cache keys
|
|
@@ -114,7 +104,7 @@ class Cache {
|
|
|
114
104
|
hits: this.statsData.hits,
|
|
115
105
|
misses: this.statsData.misses,
|
|
116
106
|
keys: this.cache.keys().length,
|
|
117
|
-
size: this.cache.getStats().keys
|
|
107
|
+
size: this.cache.getStats().keys,
|
|
118
108
|
};
|
|
119
109
|
}
|
|
120
110
|
/**
|
|
@@ -132,21 +122,25 @@ class Cache {
|
|
|
132
122
|
return cached;
|
|
133
123
|
}
|
|
134
124
|
try {
|
|
135
|
-
|
|
125
|
+
logger.debug(`Cache FETCH: ${key}`);
|
|
136
126
|
const value = await fetchFn();
|
|
137
127
|
this.set(key, value, ttl);
|
|
138
128
|
return value;
|
|
139
129
|
}
|
|
140
130
|
catch (error) {
|
|
141
|
-
|
|
131
|
+
logger.error(`Cache FETCH error: ${key}`, error);
|
|
142
132
|
throw error;
|
|
143
133
|
}
|
|
144
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Cache with tags for group invalidation
|
|
137
|
+
*/
|
|
138
|
+
tags = new Map();
|
|
145
139
|
setWithTags(key, value, tags, ttl) {
|
|
146
140
|
const success = this.set(key, value, ttl);
|
|
147
141
|
if (success) {
|
|
148
142
|
// Associate key with tags
|
|
149
|
-
tags.forEach(tag => {
|
|
143
|
+
tags.forEach((tag) => {
|
|
150
144
|
if (!this.tags.has(tag)) {
|
|
151
145
|
this.tags.set(tag, new Set());
|
|
152
146
|
}
|
|
@@ -160,29 +154,47 @@ class Cache {
|
|
|
160
154
|
*/
|
|
161
155
|
invalidateTag(tag) {
|
|
162
156
|
const keys = this.tags.get(tag);
|
|
163
|
-
if (!keys)
|
|
157
|
+
if (!keys) {
|
|
164
158
|
return 0;
|
|
159
|
+
}
|
|
165
160
|
let deleted = 0;
|
|
166
|
-
keys.forEach(key => {
|
|
161
|
+
keys.forEach((key) => {
|
|
167
162
|
deleted += this.del(key);
|
|
168
163
|
});
|
|
169
164
|
// Clean up tag associations
|
|
170
165
|
this.tags.delete(tag);
|
|
171
|
-
|
|
166
|
+
logger.debug(`Invalidated tag "${tag}": ${deleted} keys`);
|
|
172
167
|
return deleted;
|
|
173
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Cache key generators for common patterns
|
|
171
|
+
*/
|
|
172
|
+
static keys = {
|
|
173
|
+
prInfo: (workspace, repository, prId) => `pr:${workspace}:${repository}:${prId}`,
|
|
174
|
+
prDiff: (workspace, repository, prId) => `diff:${workspace}:${repository}:${prId}`,
|
|
175
|
+
fileContent: (workspace, repository, filePath, branch) => `file:${workspace}:${repository}:${branch}:${filePath}`,
|
|
176
|
+
directoryContent: (workspace, repository, path, branch) => `dir:${workspace}:${repository}:${branch}:${path}`,
|
|
177
|
+
branchInfo: (workspace, repository, branch) => `branch:${workspace}:${repository}:${branch}`,
|
|
178
|
+
aiResponse: (prompt, provider, model) => {
|
|
179
|
+
// Create a hash of the prompt for consistent keys
|
|
180
|
+
const hash = Buffer.from(prompt).toString("base64").slice(0, 16);
|
|
181
|
+
return `ai:${provider}:${model}:${hash}`;
|
|
182
|
+
},
|
|
183
|
+
projectContext: (workspace, repository, branch) => `context:${workspace}:${repository}:${branch}`,
|
|
184
|
+
reviewResult: (workspace, repository, prId, configHash) => `review:${workspace}:${repository}:${prId}:${configHash}`,
|
|
185
|
+
};
|
|
174
186
|
/**
|
|
175
187
|
* Smart cache warming for common patterns
|
|
176
188
|
*/
|
|
177
189
|
async warmPRCache(workspace, repository, prId) {
|
|
178
|
-
|
|
190
|
+
logger.debug(`Warming cache for PR ${workspace}/${repository}#${prId}`);
|
|
179
191
|
// Pre-generate cache keys that are likely to be needed
|
|
180
192
|
const keys = [
|
|
181
193
|
Cache.keys.prInfo(workspace, repository, prId),
|
|
182
|
-
Cache.keys.prDiff(workspace, repository, prId)
|
|
194
|
+
Cache.keys.prDiff(workspace, repository, prId),
|
|
183
195
|
];
|
|
184
196
|
// This would be implemented by the calling code to actually fetch the data
|
|
185
|
-
|
|
197
|
+
logger.debug(`Cache warming prepared for keys: ${keys.join(", ")}`);
|
|
186
198
|
}
|
|
187
199
|
/**
|
|
188
200
|
* Cleanup expired entries and optimize memory
|
|
@@ -191,17 +203,17 @@ class Cache {
|
|
|
191
203
|
// Node-cache handles TTL cleanup automatically, but we can force it
|
|
192
204
|
const beforeKeys = this.cache.keys().length;
|
|
193
205
|
// Force check for expired keys
|
|
194
|
-
this.cache.keys().forEach(key => {
|
|
206
|
+
this.cache.keys().forEach((key) => {
|
|
195
207
|
this.cache.get(key); // This triggers expiry check
|
|
196
208
|
});
|
|
197
209
|
const afterKeys = this.cache.keys().length;
|
|
198
210
|
const cleaned = beforeKeys - afterKeys;
|
|
199
211
|
if (cleaned > 0) {
|
|
200
|
-
|
|
212
|
+
logger.debug(`Cache cleanup: removed ${cleaned} expired entries`);
|
|
201
213
|
}
|
|
202
214
|
// Clean up tag associations for deleted keys
|
|
203
215
|
this.tags.forEach((keys, tag) => {
|
|
204
|
-
const validKeys = new Set([...keys].filter(key => this.cache.has(key)));
|
|
216
|
+
const validKeys = new Set([...keys].filter((key) => this.cache.has(key)));
|
|
205
217
|
if (validKeys.size !== keys.size) {
|
|
206
218
|
this.tags.set(tag, validKeys);
|
|
207
219
|
}
|
|
@@ -223,32 +235,14 @@ class Cache {
|
|
|
223
235
|
hitRatio: this.getHitRatio(),
|
|
224
236
|
detailedStats: this.getDetailedStats(),
|
|
225
237
|
keys: this.keys(),
|
|
226
|
-
tags: Object.fromEntries(this.tags.entries())
|
|
238
|
+
tags: Object.fromEntries(this.tags.entries()),
|
|
227
239
|
};
|
|
228
240
|
}
|
|
229
241
|
}
|
|
230
|
-
exports.Cache = Cache;
|
|
231
|
-
/**
|
|
232
|
-
* Cache key generators for common patterns
|
|
233
|
-
*/
|
|
234
|
-
Cache.keys = {
|
|
235
|
-
prInfo: (workspace, repository, prId) => `pr:${workspace}:${repository}:${prId}`,
|
|
236
|
-
prDiff: (workspace, repository, prId) => `diff:${workspace}:${repository}:${prId}`,
|
|
237
|
-
fileContent: (workspace, repository, filePath, branch) => `file:${workspace}:${repository}:${branch}:${filePath}`,
|
|
238
|
-
directoryContent: (workspace, repository, path, branch) => `dir:${workspace}:${repository}:${branch}:${path}`,
|
|
239
|
-
branchInfo: (workspace, repository, branch) => `branch:${workspace}:${repository}:${branch}`,
|
|
240
|
-
aiResponse: (prompt, provider, model) => {
|
|
241
|
-
// Create a hash of the prompt for consistent keys
|
|
242
|
-
const hash = Buffer.from(prompt).toString('base64').slice(0, 16);
|
|
243
|
-
return `ai:${provider}:${model}:${hash}`;
|
|
244
|
-
},
|
|
245
|
-
projectContext: (workspace, repository, branch) => `context:${workspace}:${repository}:${branch}`,
|
|
246
|
-
reviewResult: (workspace, repository, prId, configHash) => `review:${workspace}:${repository}:${prId}:${configHash}`
|
|
247
|
-
};
|
|
248
242
|
// Export singleton instance
|
|
249
|
-
|
|
243
|
+
export const cache = new Cache();
|
|
250
244
|
// Export factory function
|
|
251
|
-
function createCache(options) {
|
|
245
|
+
export function createCache(options) {
|
|
252
246
|
return new Cache(options);
|
|
253
247
|
}
|
|
254
248
|
//# sourceMappingURL=Cache.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Enhanced Configuration Manager for Yama
|
|
3
3
|
* Handles configuration loading, validation, and merging from multiple sources
|
|
4
4
|
*/
|
|
5
|
-
import { GuardianConfig } from
|
|
5
|
+
import { GuardianConfig } from "../types/index.js";
|
|
6
6
|
export declare class ConfigManager {
|
|
7
7
|
private config;
|
|
8
8
|
private configPaths;
|