mcp-adr-analysis-server 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/LICENSE +21 -0
- package/README.md +608 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +1722 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/prompts/adr-suggestion-prompts.d.ts +24 -0
- package/dist/src/prompts/adr-suggestion-prompts.d.ts.map +1 -0
- package/dist/src/prompts/adr-suggestion-prompts.js +383 -0
- package/dist/src/prompts/adr-suggestion-prompts.js.map +1 -0
- package/dist/src/prompts/analysis-prompts.d.ts +24 -0
- package/dist/src/prompts/analysis-prompts.d.ts.map +1 -0
- package/dist/src/prompts/analysis-prompts.js +489 -0
- package/dist/src/prompts/analysis-prompts.js.map +1 -0
- package/dist/src/prompts/deployment-analysis-prompts.d.ts +54 -0
- package/dist/src/prompts/deployment-analysis-prompts.d.ts.map +1 -0
- package/dist/src/prompts/deployment-analysis-prompts.js +712 -0
- package/dist/src/prompts/deployment-analysis-prompts.js.map +1 -0
- package/dist/src/prompts/environment-analysis-prompts.d.ts +34 -0
- package/dist/src/prompts/environment-analysis-prompts.d.ts.map +1 -0
- package/dist/src/prompts/environment-analysis-prompts.js +724 -0
- package/dist/src/prompts/environment-analysis-prompts.js.map +1 -0
- package/dist/src/prompts/index.d.ts +43 -0
- package/dist/src/prompts/index.d.ts.map +1 -0
- package/dist/src/prompts/index.js +384 -0
- package/dist/src/prompts/index.js.map +1 -0
- package/dist/src/prompts/research-integration-prompts.d.ts +43 -0
- package/dist/src/prompts/research-integration-prompts.d.ts.map +1 -0
- package/dist/src/prompts/research-integration-prompts.js +398 -0
- package/dist/src/prompts/research-integration-prompts.js.map +1 -0
- package/dist/src/prompts/research-question-prompts.d.ts +75 -0
- package/dist/src/prompts/research-question-prompts.d.ts.map +1 -0
- package/dist/src/prompts/research-question-prompts.js +695 -0
- package/dist/src/prompts/research-question-prompts.js.map +1 -0
- package/dist/src/prompts/rule-generation-prompts.d.ts +63 -0
- package/dist/src/prompts/rule-generation-prompts.d.ts.map +1 -0
- package/dist/src/prompts/rule-generation-prompts.js +630 -0
- package/dist/src/prompts/rule-generation-prompts.js.map +1 -0
- package/dist/src/prompts/security-prompts.d.ts +23 -0
- package/dist/src/prompts/security-prompts.d.ts.map +1 -0
- package/dist/src/prompts/security-prompts.js +287 -0
- package/dist/src/prompts/security-prompts.js.map +1 -0
- package/dist/src/resources/index.d.ts +24 -0
- package/dist/src/resources/index.d.ts.map +1 -0
- package/dist/src/resources/index.js +458 -0
- package/dist/src/resources/index.js.map +1 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts +40 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -0
- package/dist/src/tools/adr-suggestion-tool.js +338 -0
- package/dist/src/tools/adr-suggestion-tool.js.map +1 -0
- package/dist/src/tools/content-masking-tool.d.ts +52 -0
- package/dist/src/tools/content-masking-tool.d.ts.map +1 -0
- package/dist/src/tools/content-masking-tool.js +206 -0
- package/dist/src/tools/content-masking-tool.js.map +1 -0
- package/dist/src/tools/deployment-analysis-tool.d.ts +39 -0
- package/dist/src/tools/deployment-analysis-tool.d.ts.map +1 -0
- package/dist/src/tools/deployment-analysis-tool.js +310 -0
- package/dist/src/tools/deployment-analysis-tool.js.map +1 -0
- package/dist/src/tools/environment-analysis-tool.d.ts +16 -0
- package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -0
- package/dist/src/tools/environment-analysis-tool.js +298 -0
- package/dist/src/tools/environment-analysis-tool.js.map +1 -0
- package/dist/src/tools/research-integration-tool.d.ts +44 -0
- package/dist/src/tools/research-integration-tool.d.ts.map +1 -0
- package/dist/src/tools/research-integration-tool.js +429 -0
- package/dist/src/tools/research-integration-tool.js.map +1 -0
- package/dist/src/tools/research-question-tool.d.ts +55 -0
- package/dist/src/tools/research-question-tool.d.ts.map +1 -0
- package/dist/src/tools/research-question-tool.js +333 -0
- package/dist/src/tools/research-question-tool.js.map +1 -0
- package/dist/src/tools/rule-generation-tool.d.ts +49 -0
- package/dist/src/tools/rule-generation-tool.d.ts.map +1 -0
- package/dist/src/tools/rule-generation-tool.js +432 -0
- package/dist/src/tools/rule-generation-tool.js.map +1 -0
- package/dist/src/types/index.d.ts +531 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +129 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/adr-suggestions.d.ts +104 -0
- package/dist/src/utils/adr-suggestions.d.ts.map +1 -0
- package/dist/src/utils/adr-suggestions.js +228 -0
- package/dist/src/utils/adr-suggestions.js.map +1 -0
- package/dist/src/utils/cache.d.ts +51 -0
- package/dist/src/utils/cache.d.ts.map +1 -0
- package/dist/src/utils/cache.js +243 -0
- package/dist/src/utils/cache.js.map +1 -0
- package/dist/src/utils/config.d.ts +65 -0
- package/dist/src/utils/config.d.ts.map +1 -0
- package/dist/src/utils/config.js +118 -0
- package/dist/src/utils/config.js.map +1 -0
- package/dist/src/utils/content-masking.d.ts +79 -0
- package/dist/src/utils/content-masking.d.ts.map +1 -0
- package/dist/src/utils/content-masking.js +203 -0
- package/dist/src/utils/content-masking.js.map +1 -0
- package/dist/src/utils/deployment-analysis.d.ts +67 -0
- package/dist/src/utils/deployment-analysis.d.ts.map +1 -0
- package/dist/src/utils/deployment-analysis.js +263 -0
- package/dist/src/utils/deployment-analysis.js.map +1 -0
- package/dist/src/utils/environment-analysis.d.ts +76 -0
- package/dist/src/utils/environment-analysis.d.ts.map +1 -0
- package/dist/src/utils/environment-analysis.js +329 -0
- package/dist/src/utils/environment-analysis.js.map +1 -0
- package/dist/src/utils/file-system.d.ts +63 -0
- package/dist/src/utils/file-system.d.ts.map +1 -0
- package/dist/src/utils/file-system.js +189 -0
- package/dist/src/utils/file-system.js.map +1 -0
- package/dist/src/utils/output-masking.d.ts +45 -0
- package/dist/src/utils/output-masking.d.ts.map +1 -0
- package/dist/src/utils/output-masking.js +200 -0
- package/dist/src/utils/output-masking.js.map +1 -0
- package/dist/src/utils/research-documentation.d.ts +58 -0
- package/dist/src/utils/research-documentation.d.ts.map +1 -0
- package/dist/src/utils/research-documentation.js +438 -0
- package/dist/src/utils/research-documentation.js.map +1 -0
- package/dist/src/utils/research-integration.d.ts +89 -0
- package/dist/src/utils/research-integration.d.ts.map +1 -0
- package/dist/src/utils/research-integration.js +432 -0
- package/dist/src/utils/research-integration.js.map +1 -0
- package/dist/src/utils/research-questions.d.ts +97 -0
- package/dist/src/utils/research-questions.d.ts.map +1 -0
- package/dist/src/utils/research-questions.js +319 -0
- package/dist/src/utils/research-questions.js.map +1 -0
- package/dist/src/utils/rule-format.d.ts +76 -0
- package/dist/src/utils/rule-format.d.ts.map +1 -0
- package/dist/src/utils/rule-format.js +257 -0
- package/dist/src/utils/rule-format.js.map +1 -0
- package/dist/src/utils/rule-generation.d.ts +86 -0
- package/dist/src/utils/rule-generation.d.ts.map +1 -0
- package/dist/src/utils/rule-generation.js +330 -0
- package/dist/src/utils/rule-generation.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for MCP ADR Analysis Server
|
|
3
|
+
* Handles environment variables and default settings
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration schema for validation
|
|
8
|
+
*/
|
|
9
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
10
|
+
projectPath: z.ZodString;
|
|
11
|
+
adrDirectory: z.ZodDefault<z.ZodString>;
|
|
12
|
+
logLevel: z.ZodDefault<z.ZodEnum<["DEBUG", "INFO", "WARN", "ERROR"]>>;
|
|
13
|
+
cacheEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
cacheDirectory: z.ZodDefault<z.ZodString>;
|
|
15
|
+
maxCacheSize: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
analysisTimeout: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
projectPath: string;
|
|
19
|
+
adrDirectory: string;
|
|
20
|
+
logLevel: "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
21
|
+
cacheEnabled: boolean;
|
|
22
|
+
cacheDirectory: string;
|
|
23
|
+
maxCacheSize: number;
|
|
24
|
+
analysisTimeout: number;
|
|
25
|
+
}, {
|
|
26
|
+
projectPath: string;
|
|
27
|
+
adrDirectory?: string | undefined;
|
|
28
|
+
logLevel?: "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
|
|
29
|
+
cacheEnabled?: boolean | undefined;
|
|
30
|
+
cacheDirectory?: string | undefined;
|
|
31
|
+
maxCacheSize?: number | undefined;
|
|
32
|
+
analysisTimeout?: number | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
export type ServerConfig = z.infer<typeof ConfigSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* Load and validate configuration from environment variables
|
|
37
|
+
*/
|
|
38
|
+
export declare function loadConfig(): ServerConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Get the absolute path for ADR directory
|
|
41
|
+
*/
|
|
42
|
+
export declare function getAdrDirectoryPath(config: ServerConfig): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get the absolute path for cache directory
|
|
45
|
+
*/
|
|
46
|
+
export declare function getCacheDirectoryPath(config: ServerConfig): string;
|
|
47
|
+
/**
|
|
48
|
+
* Validate that the project path exists and is accessible
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateProjectPath(projectPath: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Create logger with configured log level
|
|
53
|
+
*/
|
|
54
|
+
export declare function createLogger(config: ServerConfig): {
|
|
55
|
+
debug: (message: string, ...args: any[]) => void;
|
|
56
|
+
info: (message: string, ...args: any[]) => void;
|
|
57
|
+
warn: (message: string, ...args: any[]) => void;
|
|
58
|
+
error: (message: string, ...args: any[]) => void;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Print configuration summary for debugging
|
|
62
|
+
*/
|
|
63
|
+
export declare function printConfigSummary(config: ServerConfig): void;
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;EAQhB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;GAEG;AACH,wBAAgB,UAAU,IAAI,YAAY,CA4BzC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAElE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc5E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY;qBAK5B,MAAM,WAAW,GAAG,EAAE;oBAGvB,MAAM,WAAW,GAAG,EAAE;oBAGtB,MAAM,WAAW,GAAG,EAAE;qBAGrB,MAAM,WAAW,GAAG,EAAE;EAI1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAW7D"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management for MCP ADR Analysis Server
|
|
3
|
+
* Handles environment variables and default settings
|
|
4
|
+
*/
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration schema for validation
|
|
9
|
+
*/
|
|
10
|
+
const ConfigSchema = z.object({
|
|
11
|
+
projectPath: z.string().min(1, 'PROJECT_PATH is required'),
|
|
12
|
+
adrDirectory: z.string().default('docs/adrs'),
|
|
13
|
+
logLevel: z.enum(['DEBUG', 'INFO', 'WARN', 'ERROR']).default('INFO'),
|
|
14
|
+
cacheEnabled: z.boolean().default(true),
|
|
15
|
+
cacheDirectory: z.string().default('.mcp-adr-cache'),
|
|
16
|
+
maxCacheSize: z.number().default(100 * 1024 * 1024), // 100MB
|
|
17
|
+
analysisTimeout: z.number().default(30000), // 30 seconds
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Load and validate configuration from environment variables
|
|
21
|
+
*/
|
|
22
|
+
export function loadConfig() {
|
|
23
|
+
// Get PROJECT_PATH from environment or use current working directory
|
|
24
|
+
const projectPath = process.env['PROJECT_PATH'] || process.cwd();
|
|
25
|
+
// Resolve to absolute path
|
|
26
|
+
const absoluteProjectPath = path.resolve(projectPath);
|
|
27
|
+
const rawConfig = {
|
|
28
|
+
projectPath: absoluteProjectPath,
|
|
29
|
+
adrDirectory: process.env['ADR_DIRECTORY'] || 'docs/adrs',
|
|
30
|
+
logLevel: (process.env['LOG_LEVEL'] || 'INFO').toUpperCase(),
|
|
31
|
+
cacheEnabled: process.env['CACHE_ENABLED'] !== 'false',
|
|
32
|
+
cacheDirectory: process.env['CACHE_DIRECTORY'] || '.mcp-adr-cache',
|
|
33
|
+
maxCacheSize: parseInt(process.env['MAX_CACHE_SIZE'] || '104857600'), // 100MB
|
|
34
|
+
analysisTimeout: parseInt(process.env['ANALYSIS_TIMEOUT'] || '30000'), // 30 seconds
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
return ConfigSchema.parse(rawConfig);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error instanceof z.ZodError) {
|
|
41
|
+
const issues = error.issues
|
|
42
|
+
.map(issue => `${issue.path.join('.')}: ${issue.message}`)
|
|
43
|
+
.join(', ');
|
|
44
|
+
throw new Error(`Configuration validation failed: ${issues}`);
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the absolute path for ADR directory
|
|
51
|
+
*/
|
|
52
|
+
export function getAdrDirectoryPath(config) {
|
|
53
|
+
return path.resolve(config.projectPath, config.adrDirectory);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the absolute path for cache directory
|
|
57
|
+
*/
|
|
58
|
+
export function getCacheDirectoryPath(config) {
|
|
59
|
+
return path.resolve(config.projectPath, config.cacheDirectory);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Validate that the project path exists and is accessible
|
|
63
|
+
*/
|
|
64
|
+
export async function validateProjectPath(projectPath) {
|
|
65
|
+
const fs = await import('fs/promises');
|
|
66
|
+
try {
|
|
67
|
+
const stats = await fs.stat(projectPath);
|
|
68
|
+
if (!stats.isDirectory()) {
|
|
69
|
+
throw new Error(`PROJECT_PATH is not a directory: ${projectPath}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.code === 'ENOENT') {
|
|
74
|
+
throw new Error(`PROJECT_PATH does not exist: ${projectPath}`);
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`Cannot access PROJECT_PATH: ${projectPath} - ${error.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create logger with configured log level
|
|
81
|
+
*/
|
|
82
|
+
export function createLogger(config) {
|
|
83
|
+
const levels = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3 };
|
|
84
|
+
const currentLevel = levels[config.logLevel] || 1;
|
|
85
|
+
return {
|
|
86
|
+
debug: (message, ...args) => {
|
|
87
|
+
if (currentLevel <= 0)
|
|
88
|
+
console.debug(`[DEBUG] ${message}`, ...args);
|
|
89
|
+
},
|
|
90
|
+
info: (message, ...args) => {
|
|
91
|
+
if (currentLevel <= 1)
|
|
92
|
+
console.info(`[INFO] ${message}`, ...args);
|
|
93
|
+
},
|
|
94
|
+
warn: (message, ...args) => {
|
|
95
|
+
if (currentLevel <= 2)
|
|
96
|
+
console.warn(`[WARN] ${message}`, ...args);
|
|
97
|
+
},
|
|
98
|
+
error: (message, ...args) => {
|
|
99
|
+
if (currentLevel <= 3)
|
|
100
|
+
console.error(`[ERROR] ${message}`, ...args);
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Print configuration summary for debugging
|
|
106
|
+
*/
|
|
107
|
+
export function printConfigSummary(config) {
|
|
108
|
+
const logger = createLogger(config);
|
|
109
|
+
logger.info('MCP ADR Analysis Server Configuration:');
|
|
110
|
+
logger.info(` Project Path: ${config.projectPath}`);
|
|
111
|
+
logger.info(` ADR Directory: ${config.adrDirectory}`);
|
|
112
|
+
logger.info(` Log Level: ${config.logLevel}`);
|
|
113
|
+
logger.info(` Cache Enabled: ${config.cacheEnabled}`);
|
|
114
|
+
logger.info(` Cache Directory: ${config.cacheDirectory}`);
|
|
115
|
+
logger.info(` Max Cache Size: ${Math.round(config.maxCacheSize / 1024 / 1024)}MB`);
|
|
116
|
+
logger.info(` Analysis Timeout: ${config.analysisTimeout}ms`);
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/utils/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC;I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AAC;gBAAE,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACtE,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAoB;IACrD,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAEpC,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACtD,MAAM,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,IAAI,CAAC,oBAAoB,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,IAAI,CAAC,oBAAoB,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACpF,MAAM,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,eAAe,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content masking utilities using prompt-driven AI analysis
|
|
3
|
+
* Implements intelligent sensitive content detection and masking
|
|
4
|
+
*/
|
|
5
|
+
export interface SensitiveItem {
|
|
6
|
+
type: string;
|
|
7
|
+
category: string;
|
|
8
|
+
content: string;
|
|
9
|
+
startPosition: number;
|
|
10
|
+
endPosition: number;
|
|
11
|
+
confidence: number;
|
|
12
|
+
reasoning: string;
|
|
13
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
14
|
+
suggestedMask: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SensitiveContentAnalysis {
|
|
17
|
+
hasSensitiveContent: boolean;
|
|
18
|
+
detectedItems: SensitiveItem[];
|
|
19
|
+
recommendations: string[];
|
|
20
|
+
overallRisk: 'low' | 'medium' | 'high' | 'critical';
|
|
21
|
+
summary: string;
|
|
22
|
+
}
|
|
23
|
+
export interface MaskingResult {
|
|
24
|
+
maskedContent: string;
|
|
25
|
+
maskingApplied: Array<{
|
|
26
|
+
originalContent: string;
|
|
27
|
+
maskedWith: string;
|
|
28
|
+
position: string;
|
|
29
|
+
reason: string;
|
|
30
|
+
}>;
|
|
31
|
+
preservedStructure: boolean;
|
|
32
|
+
readabilityScore: number;
|
|
33
|
+
securityScore: number;
|
|
34
|
+
recommendations: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface CustomPattern {
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
regex: string;
|
|
40
|
+
category: string;
|
|
41
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
42
|
+
examples: string[];
|
|
43
|
+
falsePositives: string[];
|
|
44
|
+
maskingStrategy: 'full' | 'partial' | 'placeholder' | 'environment';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Analyze content for sensitive information using AI prompts
|
|
48
|
+
*/
|
|
49
|
+
export declare function analyzeSensitiveContent(content: string, contentType?: 'code' | 'documentation' | 'configuration' | 'logs' | 'general', userDefinedPatterns?: string[]): Promise<{
|
|
50
|
+
analysisPrompt: string;
|
|
51
|
+
instructions: string;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Generate content masking prompt for AI processing
|
|
55
|
+
*/
|
|
56
|
+
export declare function generateMaskingInstructions(content: string, detectedSensitiveItems: SensitiveItem[], maskingStrategy?: 'full' | 'partial' | 'placeholder' | 'environment'): Promise<{
|
|
57
|
+
maskingPrompt: string;
|
|
58
|
+
instructions: string;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Generate custom pattern configuration prompt
|
|
62
|
+
*/
|
|
63
|
+
export declare function generateCustomPatternConfiguration(projectContext: string, existingPatterns?: string[]): Promise<{
|
|
64
|
+
configurationPrompt: string;
|
|
65
|
+
instructions: string;
|
|
66
|
+
}>;
|
|
67
|
+
/**
|
|
68
|
+
* Apply basic masking patterns (fallback when AI is not available)
|
|
69
|
+
*/
|
|
70
|
+
export declare function applyBasicMasking(content: string, maskingStrategy?: 'full' | 'partial' | 'placeholder'): string;
|
|
71
|
+
/**
|
|
72
|
+
* Validate that content has been properly masked
|
|
73
|
+
*/
|
|
74
|
+
export declare function validateMasking(originalContent: string, maskedContent: string): {
|
|
75
|
+
isValid: boolean;
|
|
76
|
+
issues: string[];
|
|
77
|
+
securityScore: number;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=content-masking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-masking.d.ts","sourceRoot":"","sources":["../../../src/utils/content-masking.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC;CACjB;AA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gD1D;AAED;;GAEG;AACH,wBAAsB,kCAAkC,CACtD,cAAc,EAAE,MAAM,EACtB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAC1B,OAAO,CAAC;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CA8ChE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,eAAe,GAAE,MAAM,GAAG,SAAS,GAAG,aAAsB,GAC3D,MAAM,CA6CR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,GACpB;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB,CA+BA"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content masking utilities using prompt-driven AI analysis
|
|
3
|
+
* Implements intelligent sensitive content detection and masking
|
|
4
|
+
*/
|
|
5
|
+
import { McpAdrError } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Analyze content for sensitive information using AI prompts
|
|
8
|
+
*/
|
|
9
|
+
export async function analyzeSensitiveContent(content, contentType = 'general', userDefinedPatterns) {
|
|
10
|
+
try {
|
|
11
|
+
const { generateSensitiveContentDetectionPrompt } = await import('../prompts/security-prompts.js');
|
|
12
|
+
const analysisPrompt = generateSensitiveContentDetectionPrompt(content, contentType, userDefinedPatterns);
|
|
13
|
+
const instructions = `
|
|
14
|
+
# Sensitive Content Analysis Instructions
|
|
15
|
+
|
|
16
|
+
This analysis will help identify sensitive information that should be masked or redacted.
|
|
17
|
+
|
|
18
|
+
## Next Steps:
|
|
19
|
+
1. **Review the generated prompt** for sensitive content detection
|
|
20
|
+
2. **Submit the prompt to an AI agent** for analysis
|
|
21
|
+
3. **Parse the JSON response** to get detected sensitive items
|
|
22
|
+
4. **Apply appropriate masking** based on the results
|
|
23
|
+
|
|
24
|
+
## Expected AI Response Format:
|
|
25
|
+
The AI will return a JSON object with:
|
|
26
|
+
- \`hasSensitiveContent\`: boolean indicating if sensitive content was found
|
|
27
|
+
- \`detectedItems\`: array of sensitive items with positions and severity
|
|
28
|
+
- \`recommendations\`: security recommendations
|
|
29
|
+
- \`overallRisk\`: risk assessment (low/medium/high/critical)
|
|
30
|
+
|
|
31
|
+
## Usage Example:
|
|
32
|
+
\`\`\`typescript
|
|
33
|
+
const result = await analyzeSensitiveContent(fileContent, 'code');
|
|
34
|
+
// Submit result.analysisPrompt to AI agent
|
|
35
|
+
// Parse AI response as SensitiveContentAnalysis
|
|
36
|
+
\`\`\`
|
|
37
|
+
`;
|
|
38
|
+
return {
|
|
39
|
+
analysisPrompt,
|
|
40
|
+
instructions,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
throw new McpAdrError(`Failed to generate sensitive content analysis: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Generate content masking prompt for AI processing
|
|
49
|
+
*/
|
|
50
|
+
export async function generateMaskingInstructions(content, detectedSensitiveItems, maskingStrategy = 'full') {
|
|
51
|
+
try {
|
|
52
|
+
const { generateContentMaskingPrompt } = await import('../prompts/security-prompts.js');
|
|
53
|
+
const maskingPrompt = generateContentMaskingPrompt(content, detectedSensitiveItems, maskingStrategy);
|
|
54
|
+
const instructions = `
|
|
55
|
+
# Content Masking Instructions
|
|
56
|
+
|
|
57
|
+
This will apply intelligent masking to content based on detected sensitive information.
|
|
58
|
+
|
|
59
|
+
## Masking Strategy: ${maskingStrategy}
|
|
60
|
+
|
|
61
|
+
## Next Steps:
|
|
62
|
+
1. **Review the generated masking prompt**
|
|
63
|
+
2. **Submit to AI agent** for intelligent masking
|
|
64
|
+
3. **Parse the JSON response** to get masked content
|
|
65
|
+
4. **Validate the results** for security and usability
|
|
66
|
+
|
|
67
|
+
## Expected AI Response Format:
|
|
68
|
+
The AI will return a JSON object with:
|
|
69
|
+
- \`maskedContent\`: the content with sensitive information masked
|
|
70
|
+
- \`maskingApplied\`: details of what was masked and how
|
|
71
|
+
- \`readabilityScore\`: how readable the masked content remains
|
|
72
|
+
- \`securityScore\`: how secure the masking is
|
|
73
|
+
|
|
74
|
+
## Usage Example:
|
|
75
|
+
\`\`\`typescript
|
|
76
|
+
const result = await generateMaskingInstructions(content, sensitiveItems, 'partial');
|
|
77
|
+
// Submit result.maskingPrompt to AI agent
|
|
78
|
+
// Parse AI response as MaskingResult
|
|
79
|
+
\`\`\`
|
|
80
|
+
`;
|
|
81
|
+
return {
|
|
82
|
+
maskingPrompt,
|
|
83
|
+
instructions,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new McpAdrError(`Failed to generate masking instructions: ${error instanceof Error ? error.message : String(error)}`, 'MASKING_ERROR');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Generate custom pattern configuration prompt
|
|
92
|
+
*/
|
|
93
|
+
export async function generateCustomPatternConfiguration(projectContext, existingPatterns) {
|
|
94
|
+
try {
|
|
95
|
+
const { generateCustomPatternConfigurationPrompt } = await import('../prompts/security-prompts.js');
|
|
96
|
+
const configurationPrompt = generateCustomPatternConfigurationPrompt(projectContext, existingPatterns);
|
|
97
|
+
const instructions = `
|
|
98
|
+
# Custom Pattern Configuration Instructions
|
|
99
|
+
|
|
100
|
+
This will help configure project-specific sensitive information patterns.
|
|
101
|
+
|
|
102
|
+
## Next Steps:
|
|
103
|
+
1. **Review the generated configuration prompt**
|
|
104
|
+
2. **Submit to AI agent** for pattern recommendations
|
|
105
|
+
3. **Parse the JSON response** to get custom patterns
|
|
106
|
+
4. **Integrate patterns** into the detection system
|
|
107
|
+
|
|
108
|
+
## Expected AI Response Format:
|
|
109
|
+
The AI will return a JSON object with:
|
|
110
|
+
- \`customPatterns\`: array of project-specific patterns
|
|
111
|
+
- \`recommendations\`: additional security recommendations
|
|
112
|
+
- \`integrationNotes\`: notes on pattern integration
|
|
113
|
+
|
|
114
|
+
## Usage Example:
|
|
115
|
+
\`\`\`typescript
|
|
116
|
+
const result = await generateCustomPatternConfiguration(projectInfo);
|
|
117
|
+
// Submit result.configurationPrompt to AI agent
|
|
118
|
+
// Parse AI response to get CustomPattern[]
|
|
119
|
+
\`\`\`
|
|
120
|
+
`;
|
|
121
|
+
return {
|
|
122
|
+
configurationPrompt,
|
|
123
|
+
instructions,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new McpAdrError(`Failed to generate pattern configuration: ${error instanceof Error ? error.message : String(error)}`, 'CONFIGURATION_ERROR');
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Apply basic masking patterns (fallback when AI is not available)
|
|
132
|
+
*/
|
|
133
|
+
export function applyBasicMasking(content, maskingStrategy = 'full') {
|
|
134
|
+
// Basic patterns for common sensitive information
|
|
135
|
+
const patterns = [
|
|
136
|
+
// API Keys
|
|
137
|
+
{
|
|
138
|
+
pattern: /sk-[a-zA-Z0-9]{32,}/g,
|
|
139
|
+
replacement: maskingStrategy === 'partial' ? 'sk-...****' : '[API_KEY_REDACTED]',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
pattern: /ghp_[a-zA-Z0-9]{36}/g,
|
|
143
|
+
replacement: maskingStrategy === 'partial' ? 'ghp_...****' : '[GITHUB_TOKEN_REDACTED]',
|
|
144
|
+
},
|
|
145
|
+
// AWS Keys
|
|
146
|
+
{
|
|
147
|
+
pattern: /AKIA[0-9A-Z]{16}/g,
|
|
148
|
+
replacement: maskingStrategy === 'partial' ? 'AKIA...****' : '[AWS_ACCESS_KEY_REDACTED]',
|
|
149
|
+
},
|
|
150
|
+
// Email addresses
|
|
151
|
+
{
|
|
152
|
+
pattern: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,
|
|
153
|
+
replacement: maskingStrategy === 'partial' ? '***@***.***' : '[EMAIL_REDACTED]',
|
|
154
|
+
},
|
|
155
|
+
// IP Addresses (private ranges)
|
|
156
|
+
{
|
|
157
|
+
pattern: /\b(?:10\.|172\.(?:1[6-9]|2[0-9]|3[01])\.|192\.168\.)\d{1,3}\.\d{1,3}\b/g,
|
|
158
|
+
replacement: '[IP_ADDRESS_REDACTED]',
|
|
159
|
+
},
|
|
160
|
+
// Common password patterns
|
|
161
|
+
{
|
|
162
|
+
pattern: /password\s*[:=]\s*["']?[^"'\s]+["']?/gi,
|
|
163
|
+
replacement: 'password=[PASSWORD_REDACTED]',
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
let maskedContent = content;
|
|
167
|
+
for (const { pattern, replacement } of patterns) {
|
|
168
|
+
maskedContent = maskedContent.replace(pattern, replacement);
|
|
169
|
+
}
|
|
170
|
+
return maskedContent;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Validate that content has been properly masked
|
|
174
|
+
*/
|
|
175
|
+
export function validateMasking(originalContent, maskedContent) {
|
|
176
|
+
const issues = [];
|
|
177
|
+
let securityScore = 1.0;
|
|
178
|
+
// Check for common patterns that should have been masked
|
|
179
|
+
const sensitivePatterns = [
|
|
180
|
+
/sk-[a-zA-Z0-9]{32,}/g,
|
|
181
|
+
/ghp_[a-zA-Z0-9]{36}/g,
|
|
182
|
+
/AKIA[0-9A-Z]{16}/g,
|
|
183
|
+
/password\s*[:=]\s*["']?[^"'\s\\[\\]]+["']?/gi,
|
|
184
|
+
];
|
|
185
|
+
for (const pattern of sensitivePatterns) {
|
|
186
|
+
const matches = maskedContent.match(pattern);
|
|
187
|
+
if (matches) {
|
|
188
|
+
issues.push(`Potential unmasked sensitive content found: ${matches[0].substring(0, 10)}...`);
|
|
189
|
+
securityScore -= 0.2;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Check that masking was actually applied
|
|
193
|
+
if (originalContent === maskedContent) {
|
|
194
|
+
issues.push('No masking appears to have been applied');
|
|
195
|
+
securityScore = 0;
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
isValid: issues.length === 0,
|
|
199
|
+
issues,
|
|
200
|
+
securityScore: Math.max(0, securityScore),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=content-masking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-masking.js","sourceRoot":"","sources":["../../../src/utils/content-masking.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA+ChD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAe,EACf,cAA+E,SAAS,EACxF,mBAA8B;IAE9B,IAAI,CAAC;QACH,MAAM,EAAE,uCAAuC,EAAE,GAAG,MAAM,MAAM,CAC9D,gCAAgC,CACjC,CAAC;QAEF,MAAM,cAAc,GAAG,uCAAuC,CAC5D,OAAO,EACP,WAAW,EACX,mBAAmB,CACpB,CAAC;QAEF,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBxB,CAAC;QAEE,OAAO;YACL,cAAc;YACd,YAAY;SACb,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,WAAW,CACnB,kDAAkD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAC1G,gBAAgB,CACjB,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,OAAe,EACf,sBAAuC,EACvC,kBAAsE,MAAM;IAE5E,IAAI,CAAC;QACH,MAAM,EAAE,4BAA4B,EAAE,GA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AC,CAAC;QAC7C,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,+CAA+C,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;YAC7F,aAAa,IAAI,GAAG,CAAC;QACvB,CAAC;IACH,CAAC;IAED,0CAA0C;IAC1C,IAAI,eAAe,KAAK,aAAa,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;QACvD,aAAa,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC5B,MAAM;QACN,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployment analysis utilities using prompt-driven AI analysis
|
|
3
|
+
* Implements intelligent deployment progress tracking and completion verification
|
|
4
|
+
*/
|
|
5
|
+
export interface DeploymentTask {
|
|
6
|
+
taskId: string;
|
|
7
|
+
taskName: string;
|
|
8
|
+
description: string;
|
|
9
|
+
category: 'infrastructure' | 'application' | 'cicd' | 'operational';
|
|
10
|
+
priority: 'critical' | 'high' | 'medium' | 'low';
|
|
11
|
+
status: 'not_started' | 'in_progress' | 'completed' | 'blocked' | 'failed';
|
|
12
|
+
progress: number;
|
|
13
|
+
verificationCriteria: string[];
|
|
14
|
+
expectedOutcome: string;
|
|
15
|
+
sourceAdr?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface OutcomeRule {
|
|
18
|
+
ruleId: string;
|
|
19
|
+
description: string;
|
|
20
|
+
criteria: string[];
|
|
21
|
+
verificationMethod: string;
|
|
22
|
+
}
|
|
23
|
+
export interface DeploymentProgress {
|
|
24
|
+
overallProgress: number;
|
|
25
|
+
categoryProgress: Record<string, number>;
|
|
26
|
+
criticalPath: {
|
|
27
|
+
tasks: string[];
|
|
28
|
+
progress: number;
|
|
29
|
+
bottlenecks: string[];
|
|
30
|
+
};
|
|
31
|
+
estimatedCompletion: string;
|
|
32
|
+
riskLevel: 'low' | 'medium' | 'high' | 'critical';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Identify deployment tasks from ADRs and todo content
|
|
36
|
+
*/
|
|
37
|
+
export declare function identifyDeploymentTasks(adrDirectory?: string, todoPath?: string): Promise<{
|
|
38
|
+
identificationPrompt: string;
|
|
39
|
+
instructions: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Analyze CI/CD logs and pipeline status
|
|
43
|
+
*/
|
|
44
|
+
export declare function analyzeCiCdStatus(cicdLogs: string, pipelineConfig?: string, deploymentTasks?: DeploymentTask[]): Promise<{
|
|
45
|
+
analysisPrompt: string;
|
|
46
|
+
instructions: string;
|
|
47
|
+
}>;
|
|
48
|
+
/**
|
|
49
|
+
* Calculate deployment progress
|
|
50
|
+
*/
|
|
51
|
+
export declare function calculateDeploymentProgress(deploymentTasks: DeploymentTask[], cicdStatus?: any, environmentStatus?: any): Promise<{
|
|
52
|
+
progressPrompt: string;
|
|
53
|
+
instructions: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Verify deployment completion with outcome rules
|
|
57
|
+
*/
|
|
58
|
+
export declare function verifyDeploymentCompletion(deploymentTasks: DeploymentTask[], outcomeRules: OutcomeRule[], actualOutcomes?: Array<{
|
|
59
|
+
taskId: string;
|
|
60
|
+
outcome: string;
|
|
61
|
+
evidence: string[];
|
|
62
|
+
timestamp: string;
|
|
63
|
+
}>): Promise<{
|
|
64
|
+
verificationPrompt: string;
|
|
65
|
+
instructions: string;
|
|
66
|
+
}>;
|
|
67
|
+
//# sourceMappingURL=deployment-analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment-analysis.d.ts","sourceRoot":"","sources":["../../../src/utils/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