driftdetect-mcp 0.4.0 → 0.4.3
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/dist/bin/server.d.ts +12 -2
- package/dist/bin/server.d.ts.map +1 -1
- package/dist/bin/server.js +25 -5
- package/dist/bin/server.js.map +1 -1
- package/dist/enterprise-server.d.ts +78 -0
- package/dist/enterprise-server.d.ts.map +1 -0
- package/dist/enterprise-server.js +201 -0
- package/dist/enterprise-server.js.map +1 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/cache.d.ts +86 -0
- package/dist/infrastructure/cache.d.ts.map +1 -0
- package/dist/infrastructure/cache.js +271 -0
- package/dist/infrastructure/cache.js.map +1 -0
- package/dist/infrastructure/cursor-manager.d.ts +86 -0
- package/dist/infrastructure/cursor-manager.d.ts.map +1 -0
- package/dist/infrastructure/cursor-manager.js +175 -0
- package/dist/infrastructure/cursor-manager.js.map +1 -0
- package/dist/infrastructure/error-handler.d.ts +82 -0
- package/dist/infrastructure/error-handler.d.ts.map +1 -0
- package/dist/infrastructure/error-handler.js +226 -0
- package/dist/infrastructure/error-handler.js.map +1 -0
- package/dist/infrastructure/index.d.ts +19 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +26 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/metrics.d.ts +104 -0
- package/dist/infrastructure/metrics.d.ts.map +1 -0
- package/dist/infrastructure/metrics.js +291 -0
- package/dist/infrastructure/metrics.js.map +1 -0
- package/dist/infrastructure/rate-limiter.d.ts +59 -0
- package/dist/infrastructure/rate-limiter.d.ts.map +1 -0
- package/dist/infrastructure/rate-limiter.js +132 -0
- package/dist/infrastructure/rate-limiter.js.map +1 -0
- package/dist/infrastructure/response-builder.d.ts +104 -0
- package/dist/infrastructure/response-builder.d.ts.map +1 -0
- package/dist/infrastructure/response-builder.js +207 -0
- package/dist/infrastructure/response-builder.js.map +1 -0
- package/dist/infrastructure/token-estimator.d.ts +48 -0
- package/dist/infrastructure/token-estimator.d.ts.map +1 -0
- package/dist/infrastructure/token-estimator.js +131 -0
- package/dist/infrastructure/token-estimator.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1074 -17
- package/dist/server.js.map +1 -1
- package/dist/tools/detail/code-examples.d.ts +33 -0
- package/dist/tools/detail/code-examples.d.ts.map +1 -0
- package/dist/tools/detail/code-examples.js +126 -0
- package/dist/tools/detail/code-examples.js.map +1 -0
- package/dist/tools/detail/dna-check.d.ts +32 -0
- package/dist/tools/detail/dna-check.d.ts.map +1 -0
- package/dist/tools/detail/dna-check.js +231 -0
- package/dist/tools/detail/dna-check.js.map +1 -0
- package/dist/tools/detail/dna-profile.d.ts +37 -0
- package/dist/tools/detail/dna-profile.d.ts.map +1 -0
- package/dist/tools/detail/dna-profile.js +101 -0
- package/dist/tools/detail/dna-profile.js.map +1 -0
- package/dist/tools/detail/file-patterns.d.ts +39 -0
- package/dist/tools/detail/file-patterns.d.ts.map +1 -0
- package/dist/tools/detail/file-patterns.js +103 -0
- package/dist/tools/detail/file-patterns.js.map +1 -0
- package/dist/tools/detail/files-list.d.ts +30 -0
- package/dist/tools/detail/files-list.d.ts.map +1 -0
- package/dist/tools/detail/files-list.js +99 -0
- package/dist/tools/detail/files-list.js.map +1 -0
- package/dist/tools/detail/impact-analysis.d.ts +53 -0
- package/dist/tools/detail/impact-analysis.d.ts.map +1 -0
- package/dist/tools/detail/impact-analysis.js +130 -0
- package/dist/tools/detail/impact-analysis.js.map +1 -0
- package/dist/tools/detail/index.d.ts +23 -0
- package/dist/tools/detail/index.d.ts.map +1 -0
- package/dist/tools/detail/index.js +200 -0
- package/dist/tools/detail/index.js.map +1 -0
- package/dist/tools/detail/pattern-get.d.ts +45 -0
- package/dist/tools/detail/pattern-get.d.ts.map +1 -0
- package/dist/tools/detail/pattern-get.js +87 -0
- package/dist/tools/detail/pattern-get.js.map +1 -0
- package/dist/tools/detail/reachability.d.ts +60 -0
- package/dist/tools/detail/reachability.d.ts.map +1 -0
- package/dist/tools/detail/reachability.js +168 -0
- package/dist/tools/detail/reachability.js.map +1 -0
- package/dist/tools/discovery/capabilities.d.ts +28 -0
- package/dist/tools/discovery/capabilities.d.ts.map +1 -0
- package/dist/tools/discovery/capabilities.js +112 -0
- package/dist/tools/discovery/capabilities.js.map +1 -0
- package/dist/tools/discovery/index.d.ts +13 -0
- package/dist/tools/discovery/index.d.ts.map +1 -0
- package/dist/tools/discovery/index.js +30 -0
- package/dist/tools/discovery/index.js.map +1 -0
- package/dist/tools/discovery/projects.d.ts +26 -0
- package/dist/tools/discovery/projects.d.ts.map +1 -0
- package/dist/tools/discovery/projects.js +210 -0
- package/dist/tools/discovery/projects.js.map +1 -0
- package/dist/tools/discovery/status.d.ts +42 -0
- package/dist/tools/discovery/status.d.ts.map +1 -0
- package/dist/tools/discovery/status.js +157 -0
- package/dist/tools/discovery/status.js.map +1 -0
- package/dist/tools/exploration/contracts-list.d.ts +35 -0
- package/dist/tools/exploration/contracts-list.d.ts.map +1 -0
- package/dist/tools/exploration/contracts-list.js +106 -0
- package/dist/tools/exploration/contracts-list.js.map +1 -0
- package/dist/tools/exploration/files-list.d.ts +29 -0
- package/dist/tools/exploration/files-list.d.ts.map +1 -0
- package/dist/tools/exploration/files-list.js +94 -0
- package/dist/tools/exploration/files-list.js.map +1 -0
- package/dist/tools/exploration/index.d.ts +17 -0
- package/dist/tools/exploration/index.d.ts.map +1 -0
- package/dist/tools/exploration/index.js +126 -0
- package/dist/tools/exploration/index.js.map +1 -0
- package/dist/tools/exploration/patterns-list.d.ts +40 -0
- package/dist/tools/exploration/patterns-list.d.ts.map +1 -0
- package/dist/tools/exploration/patterns-list.js +172 -0
- package/dist/tools/exploration/patterns-list.js.map +1 -0
- package/dist/tools/exploration/security-summary.d.ts +49 -0
- package/dist/tools/exploration/security-summary.d.ts.map +1 -0
- package/dist/tools/exploration/security-summary.js +111 -0
- package/dist/tools/exploration/security-summary.js.map +1 -0
- package/dist/tools/exploration/trends.d.ts +49 -0
- package/dist/tools/exploration/trends.d.ts.map +1 -0
- package/dist/tools/exploration/trends.js +147 -0
- package/dist/tools/exploration/trends.js.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +13 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/orchestration/context.d.ts +72 -0
- package/dist/tools/orchestration/context.d.ts.map +1 -0
- package/dist/tools/orchestration/context.js +499 -0
- package/dist/tools/orchestration/context.js.map +1 -0
- package/dist/tools/orchestration/index.d.ts +11 -0
- package/dist/tools/orchestration/index.d.ts.map +1 -0
- package/dist/tools/orchestration/index.js +56 -0
- package/dist/tools/orchestration/index.js.map +1 -0
- package/dist/tools/registry.d.ts +41 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +64 -0
- package/dist/tools/registry.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drift_files_list - List Files with Patterns
|
|
3
|
+
*
|
|
4
|
+
* Detail tool that lists files matching a glob pattern with their pattern counts.
|
|
5
|
+
* Supports pagination for large codebases.
|
|
6
|
+
*/
|
|
7
|
+
import { createResponseBuilder, createCursor, parseCursor } from '../../infrastructure/index.js';
|
|
8
|
+
const DEFAULT_LIMIT = 20;
|
|
9
|
+
export async function handleFilesList(store, args) {
|
|
10
|
+
const builder = createResponseBuilder();
|
|
11
|
+
await store.load();
|
|
12
|
+
const manifest = await store.get();
|
|
13
|
+
const limit = args.limit ?? DEFAULT_LIMIT;
|
|
14
|
+
const offset = args.cursor ? parseCursor(args.cursor).offset : 0;
|
|
15
|
+
const pathPattern = args.path ?? '**/*';
|
|
16
|
+
// Get all files from manifest
|
|
17
|
+
const allFiles = Object.entries(manifest.files);
|
|
18
|
+
// Filter by path pattern (simple glob matching)
|
|
19
|
+
let filteredFiles = allFiles.filter(([filePath]) => matchGlob(filePath, pathPattern));
|
|
20
|
+
// Build file entries with pattern info
|
|
21
|
+
let fileEntries = filteredFiles.map(([filePath, fileData]) => {
|
|
22
|
+
const patternIds = fileData.patterns;
|
|
23
|
+
const categories = new Set();
|
|
24
|
+
for (const patternId of patternIds) {
|
|
25
|
+
const pattern = manifest.patterns[patternId];
|
|
26
|
+
if (pattern) {
|
|
27
|
+
categories.add(pattern.category);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
file: filePath,
|
|
32
|
+
patternCount: patternIds.length,
|
|
33
|
+
categories: Array.from(categories).sort(),
|
|
34
|
+
lastScanned: fileData.lastScanned,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
// Filter by category if specified
|
|
38
|
+
if (args.category) {
|
|
39
|
+
fileEntries = fileEntries.filter(f => f.categories.includes(args.category));
|
|
40
|
+
}
|
|
41
|
+
// Sort by pattern count (most patterns first)
|
|
42
|
+
fileEntries.sort((a, b) => b.patternCount - a.patternCount);
|
|
43
|
+
const totalFiles = fileEntries.length;
|
|
44
|
+
const totalPatterns = fileEntries.reduce((sum, f) => sum + f.patternCount, 0);
|
|
45
|
+
// Apply pagination
|
|
46
|
+
const paginatedFiles = fileEntries.slice(offset, offset + limit);
|
|
47
|
+
const hasMore = offset + limit < totalFiles;
|
|
48
|
+
const data = {
|
|
49
|
+
files: paginatedFiles,
|
|
50
|
+
totalFiles,
|
|
51
|
+
totalPatterns,
|
|
52
|
+
};
|
|
53
|
+
// Build summary
|
|
54
|
+
let summary = `${totalFiles} files with ${totalPatterns} pattern instances.`;
|
|
55
|
+
if (args.path && args.path !== '**/*') {
|
|
56
|
+
summary = `Matching "${args.path}": ${summary}`;
|
|
57
|
+
}
|
|
58
|
+
if (args.category) {
|
|
59
|
+
summary += ` Filtered to ${args.category} category.`;
|
|
60
|
+
}
|
|
61
|
+
// Add pagination
|
|
62
|
+
if (hasMore) {
|
|
63
|
+
builder.withPagination({
|
|
64
|
+
cursor: createCursor(offset + limit, limit),
|
|
65
|
+
hasMore: true,
|
|
66
|
+
totalCount: totalFiles,
|
|
67
|
+
pageSize: limit,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return builder
|
|
71
|
+
.withSummary(summary)
|
|
72
|
+
.withData(data)
|
|
73
|
+
.withHints({
|
|
74
|
+
nextActions: paginatedFiles.length > 0
|
|
75
|
+
? [
|
|
76
|
+
'Use drift_file_patterns with a specific file to see its patterns',
|
|
77
|
+
hasMore ? `Use cursor="${createCursor(offset + limit, limit)}" to see more files` : '',
|
|
78
|
+
].filter(Boolean)
|
|
79
|
+
: ['Run drift scan to discover patterns'],
|
|
80
|
+
relatedTools: ['drift_file_patterns', 'drift_patterns_list'],
|
|
81
|
+
})
|
|
82
|
+
.buildContent();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Simple glob matching (supports * and **)
|
|
86
|
+
*/
|
|
87
|
+
function matchGlob(filePath, pattern) {
|
|
88
|
+
if (pattern === '**/*' || pattern === '*')
|
|
89
|
+
return true;
|
|
90
|
+
const regexPattern = pattern
|
|
91
|
+
.replace(/\*\*/g, '{{GLOBSTAR}}')
|
|
92
|
+
.replace(/\*/g, '[^/]*')
|
|
93
|
+
.replace(/{{GLOBSTAR}}/g, '.*')
|
|
94
|
+
.replace(/\?/g, '.')
|
|
95
|
+
.replace(/\./g, '\\.');
|
|
96
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
97
|
+
return regex.test(filePath);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=files-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-list.js","sourceRoot":"","sources":["../../../src/tools/detail/files-list.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM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AAG,IAAI,MAAM,CAAC,IAAI,YAAY,GAAG,CAAC,CAAC;IAC9C,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drift_impact_analysis - Code Change Impact Analysis
|
|
3
|
+
*
|
|
4
|
+
* Detail tool that analyzes the impact of changing a file or function.
|
|
5
|
+
* Shows affected callers, entry points, and sensitive data paths.
|
|
6
|
+
*/
|
|
7
|
+
export interface AffectedCaller {
|
|
8
|
+
name: string;
|
|
9
|
+
file: string;
|
|
10
|
+
line: number;
|
|
11
|
+
depth: number;
|
|
12
|
+
isEntryPoint: boolean;
|
|
13
|
+
accessesSensitiveData: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface SensitivePath {
|
|
16
|
+
table: string;
|
|
17
|
+
fields: string[];
|
|
18
|
+
operation: string;
|
|
19
|
+
sensitivity: string;
|
|
20
|
+
entryPoint: string;
|
|
21
|
+
pathLength: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ImpactData {
|
|
24
|
+
target: {
|
|
25
|
+
type: 'file' | 'function';
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
risk: {
|
|
29
|
+
level: string;
|
|
30
|
+
score: number;
|
|
31
|
+
};
|
|
32
|
+
summary: {
|
|
33
|
+
directCallers: number;
|
|
34
|
+
transitiveCallers: number;
|
|
35
|
+
affectedEntryPoints: number;
|
|
36
|
+
sensitiveDataPaths: number;
|
|
37
|
+
maxDepth: number;
|
|
38
|
+
};
|
|
39
|
+
entryPoints: AffectedCaller[];
|
|
40
|
+
sensitiveDataPaths: SensitivePath[];
|
|
41
|
+
directCallers: AffectedCaller[];
|
|
42
|
+
}
|
|
43
|
+
export declare function handleImpactAnalysis(projectRoot: string, args: {
|
|
44
|
+
target: string;
|
|
45
|
+
maxDepth?: number;
|
|
46
|
+
limit?: number;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
content: Array<{
|
|
49
|
+
type: string;
|
|
50
|
+
text: string;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
53
|
+
//# sourceMappingURL=impact-analysis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impact-analysis.d.ts","sourceRoot":"","sources":["../../../src/tools/detail/impact-analysis.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,OAAO,CAAC;IACtB,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,kBAAkB,EAAE,aAAa,EAAE,CAAC;IACpC,aAAa,EAAE,cAAc,EAAE,CAAC;CACjC;AAKD,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAyI7D"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drift_impact_analysis - Code Change Impact Analysis
|
|
3
|
+
*
|
|
4
|
+
* Detail tool that analyzes the impact of changing a file or function.
|
|
5
|
+
* Shows affected callers, entry points, and sensitive data paths.
|
|
6
|
+
*/
|
|
7
|
+
import { createCallGraphAnalyzer, createImpactAnalyzer, } from 'driftdetect-core';
|
|
8
|
+
import { createResponseBuilder, Errors } from '../../infrastructure/index.js';
|
|
9
|
+
const DEFAULT_MAX_DEPTH = 10;
|
|
10
|
+
const DEFAULT_LIMIT = 10;
|
|
11
|
+
export async function handleImpactAnalysis(projectRoot, args) {
|
|
12
|
+
const builder = createResponseBuilder();
|
|
13
|
+
if (!args.target) {
|
|
14
|
+
throw Errors.missingParameter('target');
|
|
15
|
+
}
|
|
16
|
+
const maxDepth = args.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
17
|
+
const limit = args.limit ?? DEFAULT_LIMIT;
|
|
18
|
+
// Initialize call graph analyzer
|
|
19
|
+
const analyzer = createCallGraphAnalyzer({ rootDir: projectRoot });
|
|
20
|
+
await analyzer.initialize();
|
|
21
|
+
const graph = analyzer.getGraph();
|
|
22
|
+
if (!graph) {
|
|
23
|
+
throw Errors.custom('NO_CALL_GRAPH', 'No call graph found. Run drift_callgraph action="build" first.', ['drift_callgraph action="build"']);
|
|
24
|
+
}
|
|
25
|
+
// Create impact analyzer
|
|
26
|
+
const impactAnalyzer = createImpactAnalyzer(graph);
|
|
27
|
+
// Determine if target is a file or function
|
|
28
|
+
const isFile = args.target.includes('/') ||
|
|
29
|
+
args.target.endsWith('.py') ||
|
|
30
|
+
args.target.endsWith('.ts') ||
|
|
31
|
+
args.target.endsWith('.tsx') ||
|
|
32
|
+
args.target.endsWith('.js') ||
|
|
33
|
+
args.target.endsWith('.jsx');
|
|
34
|
+
let result;
|
|
35
|
+
if (isFile) {
|
|
36
|
+
result = impactAnalyzer.analyzeFile(args.target, { maxDepth });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
result = impactAnalyzer.analyzeFunctionByName(args.target, { maxDepth });
|
|
40
|
+
}
|
|
41
|
+
// Map entry points
|
|
42
|
+
const entryPoints = result.entryPoints
|
|
43
|
+
.slice(0, limit)
|
|
44
|
+
.map(ep => ({
|
|
45
|
+
name: ep.qualifiedName,
|
|
46
|
+
file: ep.file,
|
|
47
|
+
line: ep.line,
|
|
48
|
+
depth: ep.depth,
|
|
49
|
+
isEntryPoint: true,
|
|
50
|
+
accessesSensitiveData: ep.accessesSensitiveData,
|
|
51
|
+
}));
|
|
52
|
+
// Map sensitive data paths
|
|
53
|
+
const sensitiveDataPaths = result.sensitiveDataPaths
|
|
54
|
+
.slice(0, limit)
|
|
55
|
+
.map(dp => ({
|
|
56
|
+
table: dp.table,
|
|
57
|
+
fields: dp.fields,
|
|
58
|
+
operation: dp.operation,
|
|
59
|
+
sensitivity: dp.sensitivity,
|
|
60
|
+
entryPoint: dp.entryPoint,
|
|
61
|
+
pathLength: dp.fullPath.length,
|
|
62
|
+
}));
|
|
63
|
+
// Map direct callers
|
|
64
|
+
const directCallers = result.affected
|
|
65
|
+
.filter(a => a.depth === 1)
|
|
66
|
+
.slice(0, limit)
|
|
67
|
+
.map(c => ({
|
|
68
|
+
name: c.qualifiedName,
|
|
69
|
+
file: c.file,
|
|
70
|
+
line: c.line,
|
|
71
|
+
depth: c.depth,
|
|
72
|
+
isEntryPoint: c.isEntryPoint,
|
|
73
|
+
accessesSensitiveData: c.accessesSensitiveData,
|
|
74
|
+
}));
|
|
75
|
+
const data = {
|
|
76
|
+
target: {
|
|
77
|
+
type: isFile ? 'file' : 'function',
|
|
78
|
+
name: args.target,
|
|
79
|
+
},
|
|
80
|
+
risk: {
|
|
81
|
+
level: result.risk,
|
|
82
|
+
score: result.riskScore,
|
|
83
|
+
},
|
|
84
|
+
summary: {
|
|
85
|
+
directCallers: result.summary.directCallers,
|
|
86
|
+
transitiveCallers: result.summary.transitiveCallers,
|
|
87
|
+
affectedEntryPoints: result.summary.affectedEntryPoints,
|
|
88
|
+
sensitiveDataPaths: result.summary.affectedDataPaths,
|
|
89
|
+
maxDepth: result.summary.maxDepth,
|
|
90
|
+
},
|
|
91
|
+
entryPoints,
|
|
92
|
+
sensitiveDataPaths,
|
|
93
|
+
directCallers,
|
|
94
|
+
};
|
|
95
|
+
// Build summary
|
|
96
|
+
const riskEmoji = result.risk === 'critical' ? '🔴' :
|
|
97
|
+
result.risk === 'high' ? '🟠' :
|
|
98
|
+
result.risk === 'medium' ? '🟡' : '🟢';
|
|
99
|
+
let summary = `${riskEmoji} ${result.risk.toUpperCase()} risk (${result.riskScore}/100). `;
|
|
100
|
+
summary += `${result.summary.directCallers} direct callers, `;
|
|
101
|
+
summary += `${result.summary.affectedEntryPoints} entry points affected`;
|
|
102
|
+
if (result.summary.affectedDataPaths > 0) {
|
|
103
|
+
summary += `, ${result.summary.affectedDataPaths} sensitive data paths`;
|
|
104
|
+
}
|
|
105
|
+
summary += '.';
|
|
106
|
+
const hints = {
|
|
107
|
+
nextActions: [
|
|
108
|
+
result.summary.affectedEntryPoints > 0
|
|
109
|
+
? 'Review affected entry points before merging'
|
|
110
|
+
: 'Low impact - safe to proceed',
|
|
111
|
+
'Use drift_reachability to trace data access paths',
|
|
112
|
+
],
|
|
113
|
+
relatedTools: ['drift_reachability', 'drift_callgraph'],
|
|
114
|
+
};
|
|
115
|
+
if (result.risk === 'critical' || result.risk === 'high') {
|
|
116
|
+
hints.warnings = [];
|
|
117
|
+
if (result.sensitiveDataPaths.length > 0) {
|
|
118
|
+
hints.warnings.push('Sensitive data paths affected - review security implications');
|
|
119
|
+
}
|
|
120
|
+
if (result.summary.affectedEntryPoints > 5) {
|
|
121
|
+
hints.warnings.push('Many entry points affected - consider incremental rollout');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return builder
|
|
125
|
+
.withSummary(summary)
|
|
126
|
+
.withData(data)
|
|
127
|
+
.withHints(hints)
|
|
128
|
+
.buildContent();
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=impact-analysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"impact-analysis.js","sourceRoot":"","sources":["../../../src/tools/detail/impact-analysis.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAyC9E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,WAAmB,EACnB,IAIC;IAED,MAAM,OAAO,GAAG,qBAAqB,EAAc,CAAC;IAEpD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,iBAAiB,CAAC;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,aAAa,CAAC;IAE1C,iCAAiC;IACjC,MAAM,QAAQ,GAAG,uBAAuB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IACnE,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAC;IAE5B,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ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AK,UAAU,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzD,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC;QACpB,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,GAAG,CAAC,EAAE,CAAC;YAC3C,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;IAED,OAAO,OAAO;SACX,WAAW,CAAC,OAAO,CAAC;SACpB,QAAQ,CAAC,IAAI,CAAC;SACd,SAAS,CAAC,KAAK,CAAC;SAChB,YAAY,EAAE,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detail Tools
|
|
3
|
+
*
|
|
4
|
+
* Layer 3: Focused single-item tools for deep inspection.
|
|
5
|
+
* These return complete information for a specific pattern, file, or analysis.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
export declare const DETAIL_TOOLS: Tool[];
|
|
9
|
+
export { handlePatternGet } from './pattern-get.js';
|
|
10
|
+
export { handleCodeExamples } from './code-examples.js';
|
|
11
|
+
export { handleFilesList } from './files-list.js';
|
|
12
|
+
export { handleFilePatterns } from './file-patterns.js';
|
|
13
|
+
export { handleImpactAnalysis } from './impact-analysis.js';
|
|
14
|
+
export { handleReachability } from './reachability.js';
|
|
15
|
+
export { handleDNAProfile } from './dna-profile.js';
|
|
16
|
+
export type { PatternGetData, PatternLocation, PatternOutlier } from './pattern-get.js';
|
|
17
|
+
export type { CodeExamplesData, CodeExample } from './code-examples.js';
|
|
18
|
+
export type { FilesListData, FileEntry } from './files-list.js';
|
|
19
|
+
export type { FilePatternData, FilePattern, FilePatternLocation } from './file-patterns.js';
|
|
20
|
+
export type { ImpactData, AffectedCaller, SensitivePath } from './impact-analysis.js';
|
|
21
|
+
export type { ReachabilityData, ForwardReachabilityData, InverseReachabilityData, ReachableData, SensitiveField, AccessPath } from './reachability.js';
|
|
22
|
+
export type { DNAProfileData, GeneProfile } from './dna-profile.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/detail/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAc/D,eAAO,MAAM,YAAY,EAAE,IAAI,EAiL9B,CAAC;AAGF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxF,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5F,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACtF,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACvJ,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detail Tools
|
|
3
|
+
*
|
|
4
|
+
* Layer 3: Focused single-item tools for deep inspection.
|
|
5
|
+
* These return complete information for a specific pattern, file, or analysis.
|
|
6
|
+
*/
|
|
7
|
+
const PATTERN_CATEGORIES = [
|
|
8
|
+
'api', 'auth', 'security', 'errors', 'logging',
|
|
9
|
+
'data-access', 'config', 'testing', 'performance',
|
|
10
|
+
'components', 'styling', 'structural', 'types',
|
|
11
|
+
'accessibility', 'documentation',
|
|
12
|
+
];
|
|
13
|
+
const GENE_IDS = [
|
|
14
|
+
'variant-handling', 'responsive-approach', 'state-styling',
|
|
15
|
+
'theming', 'spacing-philosophy', 'animation-approach',
|
|
16
|
+
];
|
|
17
|
+
export const DETAIL_TOOLS = [
|
|
18
|
+
// Pattern Tools
|
|
19
|
+
{
|
|
20
|
+
name: 'drift_pattern_get',
|
|
21
|
+
description: 'Get complete details for a specific pattern. Includes all locations, outliers, confidence breakdown, and examples. Use pattern ID from drift_patterns_list.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
id: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'Pattern ID (from drift_patterns_list)',
|
|
28
|
+
},
|
|
29
|
+
includeLocations: {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
description: 'Include all location details (default: true)',
|
|
32
|
+
},
|
|
33
|
+
includeOutliers: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description: 'Include outlier details (default: true)',
|
|
36
|
+
},
|
|
37
|
+
maxLocations: {
|
|
38
|
+
type: 'number',
|
|
39
|
+
description: 'Max locations to return (default: 20)',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
required: ['id'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'drift_code_examples',
|
|
47
|
+
description: 'Get real code examples for patterns. Shows how patterns are implemented in this codebase. Essential before generating new code.',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
categories: {
|
|
52
|
+
type: 'array',
|
|
53
|
+
items: { type: 'string' },
|
|
54
|
+
description: `Categories to get examples for: ${PATTERN_CATEGORIES.join(', ')}`,
|
|
55
|
+
},
|
|
56
|
+
pattern: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Specific pattern name or ID',
|
|
59
|
+
},
|
|
60
|
+
maxExamples: {
|
|
61
|
+
type: 'number',
|
|
62
|
+
description: 'Max examples per pattern (default: 3)',
|
|
63
|
+
},
|
|
64
|
+
contextLines: {
|
|
65
|
+
type: 'number',
|
|
66
|
+
description: 'Lines of context around each match (default: 10)',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
required: [],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
// File Tools
|
|
73
|
+
{
|
|
74
|
+
name: 'drift_files_list',
|
|
75
|
+
description: 'List files with patterns matching a glob pattern. Shows pattern counts and categories per file. Supports pagination.',
|
|
76
|
+
inputSchema: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
path: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'Glob pattern to match files (default: **/*)',
|
|
82
|
+
},
|
|
83
|
+
category: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
description: 'Filter to files with patterns in this category',
|
|
86
|
+
},
|
|
87
|
+
limit: {
|
|
88
|
+
type: 'number',
|
|
89
|
+
description: 'Max files to return (default: 20)',
|
|
90
|
+
},
|
|
91
|
+
cursor: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
description: 'Pagination cursor from previous response',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
required: [],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'drift_file_patterns',
|
|
101
|
+
description: 'Get all patterns found in a specific file. Shows pattern details, locations within the file, and outliers.',
|
|
102
|
+
inputSchema: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {
|
|
105
|
+
file: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
description: 'File path (relative to project root)',
|
|
108
|
+
},
|
|
109
|
+
category: {
|
|
110
|
+
type: 'string',
|
|
111
|
+
description: 'Filter to patterns in this category',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
required: ['file'],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
// Call Graph Analysis Tools
|
|
118
|
+
{
|
|
119
|
+
name: 'drift_impact_analysis',
|
|
120
|
+
description: 'Analyze the impact of changing a file or function. Shows affected callers, entry points, and sensitive data paths. Use before making changes to understand blast radius.',
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
target: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
description: 'File path or function name to analyze',
|
|
127
|
+
},
|
|
128
|
+
maxDepth: {
|
|
129
|
+
type: 'number',
|
|
130
|
+
description: 'Maximum call depth to traverse (default: 10)',
|
|
131
|
+
},
|
|
132
|
+
limit: {
|
|
133
|
+
type: 'number',
|
|
134
|
+
description: 'Max items per section (default: 10)',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
required: ['target'],
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'drift_reachability',
|
|
142
|
+
description: 'Analyze data reachability. Forward: "What data can this code access?" Inverse: "Who can access this data?" Essential for security analysis.',
|
|
143
|
+
inputSchema: {
|
|
144
|
+
type: 'object',
|
|
145
|
+
properties: {
|
|
146
|
+
direction: {
|
|
147
|
+
type: 'string',
|
|
148
|
+
enum: ['forward', 'inverse'],
|
|
149
|
+
description: 'forward: what data can location access. inverse: who can access target data (default: forward)',
|
|
150
|
+
},
|
|
151
|
+
location: {
|
|
152
|
+
type: 'string',
|
|
153
|
+
description: 'For forward: file:line or function_name',
|
|
154
|
+
},
|
|
155
|
+
target: {
|
|
156
|
+
type: 'string',
|
|
157
|
+
description: 'For inverse: table or table.field',
|
|
158
|
+
},
|
|
159
|
+
maxDepth: {
|
|
160
|
+
type: 'number',
|
|
161
|
+
description: 'Maximum traversal depth (default: 10)',
|
|
162
|
+
},
|
|
163
|
+
limit: {
|
|
164
|
+
type: 'number',
|
|
165
|
+
description: 'Max items to return (default: 15)',
|
|
166
|
+
},
|
|
167
|
+
sensitiveOnly: {
|
|
168
|
+
type: 'boolean',
|
|
169
|
+
description: 'Only show sensitive data access (default: false)',
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
required: [],
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
// DNA Tools
|
|
176
|
+
{
|
|
177
|
+
name: 'drift_dna_profile',
|
|
178
|
+
description: 'Get the complete styling DNA profile. Shows how components are styled (variants, responsive, states, theming, spacing, animation) with confidence scores.',
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: 'object',
|
|
181
|
+
properties: {
|
|
182
|
+
gene: {
|
|
183
|
+
type: 'string',
|
|
184
|
+
enum: GENE_IDS,
|
|
185
|
+
description: 'Specific gene to query (optional)',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
required: [],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
// Handler exports
|
|
193
|
+
export { handlePatternGet } from './pattern-get.js';
|
|
194
|
+
export { handleCodeExamples } from './code-examples.js';
|
|
195
|
+
export { handleFilesList } from './files-list.js';
|
|
196
|
+
export { handleFilePatterns } from './file-patterns.js';
|
|
197
|
+
export { handleImpactAnalysis } from './impact-analysis.js';
|
|
198
|
+
export { handleReachability } from './reachability.js';
|
|
199
|
+
export { handleDNAProfile } from './dna-profile.js';
|
|
200
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/detail/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,kBAAkB,GAAG;IACzB,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS;IAC9C,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa;IACjD,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO;IAC9C,eAAe,EAAE,eAAe;CACjC,CAAC;AAEF,MAAM,QAAQ,GAAG;IACf,kBAAkB,EAAE,qBAAqB,EAAE,eAAe;IAC1D,SAAS,EAAE,oBAAoB,EAAE,oBAAoB;CACtD,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAW;IAClC,gBAAgB;IAChB;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,6JAA6J;QAC1K,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,EAAE,EAAE;oBACF,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uCAAuC;iBACrD;gBACD,gBAAgB,EAAE;oBAChB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,8CAA8C;iBAC5D;gBACD,eAAe,EAAE;oBACf,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,yCAAyC;iBACvD;gBACD,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uCAAuC;iBACrD;aACF;YACD,QAAQ,EAAE,CAAC,IAAI,CAAC;SACjB;KACF;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,iIAAiI;QAC9I,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAA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BACd,WAAW,EAAE,mCAAmC;iBACjD;aACF;YACD,QAAQ,EAAE,EAAE;SACb;KACF;CACF,CAAC;AAEF,kBAAkB;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drift_pattern_get - Full Pattern Details
|
|
3
|
+
*
|
|
4
|
+
* Detail tool that returns complete information for a specific pattern.
|
|
5
|
+
* Use pattern ID from drift_patterns_list.
|
|
6
|
+
*/
|
|
7
|
+
import type { PatternStore } from 'driftdetect-core';
|
|
8
|
+
export interface PatternLocation {
|
|
9
|
+
file: string;
|
|
10
|
+
line: number;
|
|
11
|
+
column?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PatternOutlier {
|
|
14
|
+
file: string;
|
|
15
|
+
line: number;
|
|
16
|
+
reason: string;
|
|
17
|
+
}
|
|
18
|
+
export interface PatternGetData {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
category: string;
|
|
23
|
+
subcategory: string;
|
|
24
|
+
status: string;
|
|
25
|
+
confidence: {
|
|
26
|
+
score: number;
|
|
27
|
+
level: string;
|
|
28
|
+
};
|
|
29
|
+
locations: PatternLocation[];
|
|
30
|
+
outliers: PatternOutlier[];
|
|
31
|
+
locationCount: number;
|
|
32
|
+
outlierCount: number;
|
|
33
|
+
}
|
|
34
|
+
export declare function handlePatternGet(store: PatternStore, args: {
|
|
35
|
+
id: string;
|
|
36
|
+
includeLocations?: boolean;
|
|
37
|
+
includeOutliers?: boolean;
|
|
38
|
+
maxLocations?: number;
|
|
39
|
+
}): Promise<{
|
|
40
|
+
content: Array<{
|
|
41
|
+
type: string;
|
|
42
|
+
text: string;
|
|
43
|
+
}>;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=pattern-get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-get.d.ts","sourceRoot":"","sources":["../../../src/tools/detail/pattern-get.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB;AAID,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE;IACJ,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,CAAC,E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