driftdetect-mcp 0.4.4 → 0.5.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/dist/bin/server.js +0 -0
- package/dist/enterprise-server.d.ts +7 -0
- package/dist/enterprise-server.d.ts.map +1 -1
- package/dist/enterprise-server.js +77 -7
- package/dist/enterprise-server.js.map +1 -1
- package/dist/infrastructure/index.d.ts +2 -0
- package/dist/infrastructure/index.d.ts.map +1 -1
- package/dist/infrastructure/index.js +3 -0
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/infrastructure/project-resolver.d.ts +43 -0
- package/dist/infrastructure/project-resolver.d.ts.map +1 -0
- package/dist/infrastructure/project-resolver.js +108 -0
- package/dist/infrastructure/project-resolver.js.map +1 -0
- package/dist/tools/analysis/coupling.d.ts +56 -0
- package/dist/tools/analysis/coupling.d.ts.map +1 -0
- package/dist/tools/analysis/coupling.js +248 -0
- package/dist/tools/analysis/coupling.js.map +1 -0
- package/dist/tools/analysis/error-handling.d.ts +45 -0
- package/dist/tools/analysis/error-handling.d.ts.map +1 -0
- package/dist/tools/analysis/error-handling.js +220 -0
- package/dist/tools/analysis/error-handling.js.map +1 -0
- package/dist/tools/analysis/index.d.ts +11 -0
- package/dist/tools/analysis/index.d.ts.map +1 -0
- package/dist/tools/analysis/index.js +111 -0
- package/dist/tools/analysis/index.js.map +1 -0
- package/dist/tools/analysis/test-topology.d.ts +43 -0
- package/dist/tools/analysis/test-topology.d.ts.map +1 -0
- package/dist/tools/analysis/test-topology.js +294 -0
- package/dist/tools/analysis/test-topology.js.map +1 -0
- package/dist/tools/detail/code-examples.d.ts +20 -3
- package/dist/tools/detail/code-examples.d.ts.map +1 -1
- package/dist/tools/detail/code-examples.js +104 -0
- package/dist/tools/detail/code-examples.js.map +1 -1
- package/dist/tools/detail/index.d.ts +6 -4
- package/dist/tools/detail/index.d.ts.map +1 -1
- package/dist/tools/detail/index.js +44 -6
- package/dist/tools/detail/index.js.map +1 -1
- package/dist/tools/detail/pattern-get.d.ts +20 -3
- package/dist/tools/detail/pattern-get.d.ts.map +1 -1
- package/dist/tools/detail/pattern-get.js +87 -0
- package/dist/tools/detail/pattern-get.js.map +1 -1
- package/dist/tools/detail/wrappers.d.ts +97 -0
- package/dist/tools/detail/wrappers.d.ts.map +1 -0
- package/dist/tools/detail/wrappers.js +124 -0
- package/dist/tools/detail/wrappers.js.map +1 -0
- package/dist/tools/discovery/index.d.ts +3 -1
- package/dist/tools/discovery/index.d.ts.map +1 -1
- package/dist/tools/discovery/index.js +36 -3
- package/dist/tools/discovery/index.js.map +1 -1
- package/dist/tools/discovery/projects.d.ts +7 -1
- package/dist/tools/discovery/projects.d.ts.map +1 -1
- package/dist/tools/discovery/projects.js +55 -1
- package/dist/tools/discovery/projects.js.map +1 -1
- package/dist/tools/discovery/status.d.ts +16 -3
- package/dist/tools/discovery/status.d.ts.map +1 -1
- package/dist/tools/discovery/status.js +83 -1
- package/dist/tools/discovery/status.js.map +1 -1
- package/dist/tools/exploration/index.d.ts +2 -2
- package/dist/tools/exploration/index.d.ts.map +1 -1
- package/dist/tools/exploration/index.js +1 -5
- package/dist/tools/exploration/index.js.map +1 -1
- package/dist/tools/exploration/patterns-list.d.ts +21 -4
- package/dist/tools/exploration/patterns-list.d.ts.map +1 -1
- package/dist/tools/exploration/patterns-list.js +70 -0
- package/dist/tools/exploration/patterns-list.js.map +1 -1
- package/dist/tools/generation/__tests__/generation-tools.test.d.ts +6 -0
- package/dist/tools/generation/__tests__/generation-tools.test.d.ts.map +1 -0
- package/dist/tools/generation/__tests__/generation-tools.test.js +119 -0
- package/dist/tools/generation/__tests__/generation-tools.test.js.map +1 -0
- package/dist/tools/generation/explain.d.ts +75 -0
- package/dist/tools/generation/explain.d.ts.map +1 -0
- package/dist/tools/generation/explain.js +238 -0
- package/dist/tools/generation/explain.js.map +1 -0
- package/dist/tools/generation/index.d.ts +12 -0
- package/dist/tools/generation/index.d.ts.map +1 -0
- package/dist/tools/generation/index.js +90 -0
- package/dist/tools/generation/index.js.map +1 -0
- package/dist/tools/generation/suggest-changes.d.ts +64 -0
- package/dist/tools/generation/suggest-changes.d.ts.map +1 -0
- package/dist/tools/generation/suggest-changes.js +342 -0
- package/dist/tools/generation/suggest-changes.js.map +1 -0
- package/dist/tools/generation/validate-change.d.ts +76 -0
- package/dist/tools/generation/validate-change.d.ts.map +1 -0
- package/dist/tools/generation/validate-change.js +415 -0
- package/dist/tools/generation/validate-change.js.map +1 -0
- package/dist/tools/orchestration/context.d.ts +41 -0
- package/dist/tools/orchestration/context.d.ts.map +1 -1
- package/dist/tools/orchestration/context.js +215 -14
- package/dist/tools/orchestration/context.js.map +1 -1
- package/dist/tools/orchestration/index.d.ts.map +1 -1
- package/dist/tools/orchestration/index.js +13 -1
- package/dist/tools/orchestration/index.js.map +1 -1
- package/dist/tools/registry.d.ts +5 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +12 -0
- package/dist/tools/registry.js.map +1 -1
- package/package.json +11 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Geoffrey Fernald
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/bin/server.js
CHANGED
|
File without changes
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
* - Response caching
|
|
14
14
|
* - Rate limiting
|
|
15
15
|
* - Metrics collection
|
|
16
|
+
*
|
|
17
|
+
* MIGRATION: Now uses IPatternService for pattern operations.
|
|
18
|
+
* The service provides a unified interface with caching and business logic.
|
|
16
19
|
*/
|
|
17
20
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
18
21
|
export interface EnterpriseMCPConfig {
|
|
@@ -21,6 +24,8 @@ export interface EnterpriseMCPConfig {
|
|
|
21
24
|
enableRateLimiting?: boolean;
|
|
22
25
|
enableMetrics?: boolean;
|
|
23
26
|
maxRequestsPerMinute?: number;
|
|
27
|
+
/** Use the new IPatternService instead of direct PatternStore access */
|
|
28
|
+
usePatternService?: boolean;
|
|
24
29
|
}
|
|
25
30
|
export declare function createEnterpriseMCPServer(config: EnterpriseMCPConfig): Server;
|
|
26
31
|
/**
|
|
@@ -31,6 +36,8 @@ export declare function getToolCategories(): {
|
|
|
31
36
|
discovery: string[];
|
|
32
37
|
exploration: string[];
|
|
33
38
|
detail: string[];
|
|
39
|
+
analysis: string[];
|
|
40
|
+
generation: string[];
|
|
34
41
|
};
|
|
35
42
|
/**
|
|
36
43
|
* Get all tools
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enterprise-server.d.ts","sourceRoot":"","sources":["../src/enterprise-server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"enterprise-server.d.ts","sourceRoot":"","sources":["../src/enterprise-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAkEnE,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAwG7E;AAoMD;;GAEG;AACH,wBAAgB,iBAAiB;;;;;;;EAEhC;AAED;;GAEG;AACH,wBAAgB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAE1B"}
|
|
@@ -13,32 +13,46 @@
|
|
|
13
13
|
* - Response caching
|
|
14
14
|
* - Rate limiting
|
|
15
15
|
* - Metrics collection
|
|
16
|
+
*
|
|
17
|
+
* MIGRATION: Now uses IPatternService for pattern operations.
|
|
18
|
+
* The service provides a unified interface with caching and business logic.
|
|
16
19
|
*/
|
|
17
20
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
18
21
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
19
|
-
import { PatternStore, ManifestStore, HistoryStore, DNAStore, BoundaryStore, ContractStore, CallGraphStore, createDataLake, } from 'driftdetect-core';
|
|
22
|
+
import { PatternStore, ManifestStore, HistoryStore, DNAStore, BoundaryStore, ContractStore, CallGraphStore, createDataLake, createPatternServiceFromStore, } from 'driftdetect-core';
|
|
20
23
|
// Infrastructure
|
|
21
24
|
import { handleError, rateLimiter, metrics, createCache, } from './infrastructure/index.js';
|
|
22
25
|
// Tool definitions
|
|
23
26
|
import { ALL_TOOLS, TOOL_CATEGORIES } from './tools/registry.js';
|
|
24
27
|
// Discovery handlers
|
|
25
|
-
import { handleStatus } from './tools/discovery/status.js';
|
|
28
|
+
import { handleStatus, handleStatusWithService } from './tools/discovery/status.js';
|
|
26
29
|
import { handleCapabilities } from './tools/discovery/capabilities.js';
|
|
27
30
|
// Exploration handlers
|
|
28
|
-
import { handlePatternsList } from './tools/exploration/patterns-list.js';
|
|
31
|
+
import { handlePatternsList, handlePatternsListWithService } from './tools/exploration/patterns-list.js';
|
|
29
32
|
import { handleSecuritySummary } from './tools/exploration/security-summary.js';
|
|
30
33
|
import { handleContractsList } from './tools/exploration/contracts-list.js';
|
|
31
34
|
import { handleTrends } from './tools/exploration/trends.js';
|
|
32
35
|
// Detail handlers
|
|
33
|
-
import { handlePatternGet } from './tools/detail/pattern-get.js';
|
|
34
|
-
import { handleCodeExamples } from './tools/detail/code-examples.js';
|
|
36
|
+
import { handlePatternGet, handlePatternGetWithService } from './tools/detail/pattern-get.js';
|
|
37
|
+
import { handleCodeExamples, handleCodeExamplesWithService } from './tools/detail/code-examples.js';
|
|
35
38
|
import { handleFilesList } from './tools/detail/files-list.js';
|
|
36
39
|
import { handleFilePatterns } from './tools/detail/file-patterns.js';
|
|
37
40
|
import { handleImpactAnalysis } from './tools/detail/impact-analysis.js';
|
|
38
41
|
import { handleReachability } from './tools/detail/reachability.js';
|
|
39
42
|
import { handleDNAProfile } from './tools/detail/dna-profile.js';
|
|
43
|
+
import { handleWrappers } from './tools/detail/wrappers.js';
|
|
44
|
+
// Discovery handlers (additional)
|
|
45
|
+
import { handleProjects } from './tools/discovery/projects.js';
|
|
40
46
|
// Orchestration handlers
|
|
41
47
|
import { handleContext } from './tools/orchestration/index.js';
|
|
48
|
+
// Generation handlers (new AI-powered tools)
|
|
49
|
+
import { handleSuggestChanges } from './tools/generation/suggest-changes.js';
|
|
50
|
+
import { handleValidateChange } from './tools/generation/validate-change.js';
|
|
51
|
+
import { handleExplain } from './tools/generation/explain.js';
|
|
52
|
+
// Analysis handlers (L5-L7 layers)
|
|
53
|
+
import { handleTestTopology } from './tools/analysis/test-topology.js';
|
|
54
|
+
import { handleCoupling } from './tools/analysis/coupling.js';
|
|
55
|
+
import { handleErrorHandling } from './tools/analysis/error-handling.js';
|
|
42
56
|
export function createEnterpriseMCPServer(config) {
|
|
43
57
|
const server = new Server({ name: 'drift-enterprise', version: '2.0.0' }, { capabilities: { tools: {} } });
|
|
44
58
|
// Initialize stores
|
|
@@ -51,6 +65,14 @@ export function createEnterpriseMCPServer(config) {
|
|
|
51
65
|
contract: new ContractStore({ rootDir: config.projectRoot }),
|
|
52
66
|
callGraph: new CallGraphStore({ rootDir: config.projectRoot }),
|
|
53
67
|
};
|
|
68
|
+
// Initialize pattern service (wraps PatternStore with unified interface)
|
|
69
|
+
// Default to using the new service for better abstraction
|
|
70
|
+
const usePatternService = config.usePatternService !== false;
|
|
71
|
+
const patternService = usePatternService
|
|
72
|
+
? createPatternServiceFromStore(stores.pattern, config.projectRoot, {
|
|
73
|
+
enableCache: config.enableCache !== false,
|
|
74
|
+
})
|
|
75
|
+
: null;
|
|
54
76
|
// Initialize data lake for optimized queries
|
|
55
77
|
const dataLake = createDataLake({ rootDir: config.projectRoot });
|
|
56
78
|
// Initialize cache if enabled
|
|
@@ -97,7 +119,7 @@ export function createEnterpriseMCPServer(config) {
|
|
|
97
119
|
}
|
|
98
120
|
}
|
|
99
121
|
// Route to handler
|
|
100
|
-
const result = await routeToolCall(name, args, stores, config.projectRoot, dataLake);
|
|
122
|
+
const result = await routeToolCall(name, args, stores, config.projectRoot, dataLake, patternService);
|
|
101
123
|
// Cache result
|
|
102
124
|
if (cache && cacheKey && result && !('isError' in result && result.isError)) {
|
|
103
125
|
await cache.set(cacheKey, result);
|
|
@@ -114,7 +136,7 @@ export function createEnterpriseMCPServer(config) {
|
|
|
114
136
|
});
|
|
115
137
|
return server;
|
|
116
138
|
}
|
|
117
|
-
async function routeToolCall(name, args, stores, projectRoot, dataLake) {
|
|
139
|
+
async function routeToolCall(name, args, stores, projectRoot, dataLake, patternService) {
|
|
118
140
|
// ============================================================================
|
|
119
141
|
// Orchestration Tools (Meta Layer - Start Here)
|
|
120
142
|
// ============================================================================
|
|
@@ -133,15 +155,25 @@ async function routeToolCall(name, args, stores, projectRoot, dataLake) {
|
|
|
133
155
|
// ============================================================================
|
|
134
156
|
switch (name) {
|
|
135
157
|
case 'drift_status':
|
|
158
|
+
// Use new service if available, otherwise fall back to legacy store
|
|
159
|
+
if (patternService) {
|
|
160
|
+
return handleStatusWithService(patternService, args, dataLake);
|
|
161
|
+
}
|
|
136
162
|
return handleStatus(stores.pattern, args, dataLake);
|
|
137
163
|
case 'drift_capabilities':
|
|
138
164
|
return handleCapabilities(args);
|
|
165
|
+
case 'drift_projects':
|
|
166
|
+
return handleProjects(args);
|
|
139
167
|
}
|
|
140
168
|
// ============================================================================
|
|
141
169
|
// Exploration Tools (Layer 2)
|
|
142
170
|
// ============================================================================
|
|
143
171
|
switch (name) {
|
|
144
172
|
case 'drift_patterns_list':
|
|
173
|
+
// Use new service if available, otherwise fall back to legacy store
|
|
174
|
+
if (patternService) {
|
|
175
|
+
return handlePatternsListWithService(patternService, args, dataLake);
|
|
176
|
+
}
|
|
145
177
|
return handlePatternsList(stores.pattern, args, dataLake);
|
|
146
178
|
case 'drift_security_summary':
|
|
147
179
|
return handleSecuritySummary(stores.boundary, args);
|
|
@@ -156,8 +188,16 @@ async function routeToolCall(name, args, stores, projectRoot, dataLake) {
|
|
|
156
188
|
switch (name) {
|
|
157
189
|
// Pattern detail tools
|
|
158
190
|
case 'drift_pattern_get':
|
|
191
|
+
// Use new service if available, otherwise fall back to legacy store
|
|
192
|
+
if (patternService) {
|
|
193
|
+
return handlePatternGetWithService(patternService, args);
|
|
194
|
+
}
|
|
159
195
|
return handlePatternGet(stores.pattern, args);
|
|
160
196
|
case 'drift_code_examples':
|
|
197
|
+
// Use new service if available, otherwise fall back to legacy store
|
|
198
|
+
if (patternService) {
|
|
199
|
+
return handleCodeExamplesWithService(patternService, projectRoot, args);
|
|
200
|
+
}
|
|
161
201
|
return handleCodeExamples(stores.pattern, projectRoot, args);
|
|
162
202
|
// File detail tools
|
|
163
203
|
case 'drift_files_list':
|
|
@@ -172,6 +212,36 @@ async function routeToolCall(name, args, stores, projectRoot, dataLake) {
|
|
|
172
212
|
// DNA tools
|
|
173
213
|
case 'drift_dna_profile':
|
|
174
214
|
return handleDNAProfile(stores.dna, args);
|
|
215
|
+
// Wrapper detection tools
|
|
216
|
+
case 'drift_wrappers':
|
|
217
|
+
return handleWrappers(args, projectRoot);
|
|
218
|
+
}
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// Analysis Tools (L5-L7 Layers)
|
|
221
|
+
// ============================================================================
|
|
222
|
+
switch (name) {
|
|
223
|
+
case 'drift_test_topology':
|
|
224
|
+
return handleTestTopology(projectRoot, args);
|
|
225
|
+
case 'drift_coupling':
|
|
226
|
+
return handleCoupling(projectRoot, args);
|
|
227
|
+
case 'drift_error_handling':
|
|
228
|
+
return handleErrorHandling(projectRoot, args);
|
|
229
|
+
}
|
|
230
|
+
// ============================================================================
|
|
231
|
+
// Generation Tools (AI-Powered Code Intelligence)
|
|
232
|
+
// ============================================================================
|
|
233
|
+
switch (name) {
|
|
234
|
+
case 'drift_suggest_changes':
|
|
235
|
+
return handleSuggestChanges({ pattern: stores.pattern, boundary: stores.boundary }, projectRoot, args);
|
|
236
|
+
case 'drift_validate_change':
|
|
237
|
+
return handleValidateChange(stores.pattern, projectRoot, args);
|
|
238
|
+
case 'drift_explain':
|
|
239
|
+
return handleExplain({
|
|
240
|
+
pattern: stores.pattern,
|
|
241
|
+
manifest: stores.manifest,
|
|
242
|
+
boundary: stores.boundary,
|
|
243
|
+
callGraph: stores.callGraph,
|
|
244
|
+
}, projectRoot, args);
|
|
175
245
|
}
|
|
176
246
|
// Unknown tool
|
|
177
247
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enterprise-server.js","sourceRoot":"","sources":["../src/enterprise-server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"enterprise-server.js","sourceRoot":"","sources":["../src/enterprise-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,6BAA6B,GAG9B,MAAM,kBAAkB,CAAC;AAE1B,iBAAiB;AACjB,OAAO,EACL,WAAW,EACX,WAAW,EACX,OAAO,EACP,WAAW,GACZ,MAAM,2BAA2B,CAAC;AAEnC,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEjE,qBAAqB;AACrB,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,kBAAkB;AAClB,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,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AE,CAAC;QACb,KAAK,uBAAuB;YAC1B,OAAO,oBAAoB,CACzB,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,EACtD,WAAW,EACX,IAA6D,CAC9D,CAAC;QAEJ,KAAK,uBAAuB;YAC1B,OAAO,oBAAoB,CACzB,MAAM,CAAC,OAAO,EACd,WAAW,EACX,IAA6D,CAC9D,CAAC;QAEJ,KAAK,eAAe;YAClB,OAAO,aAAa,CAClB;gBACE,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,EACD,WAAW,EACX,IAAsD,CACvD,CAAC;IACN,CAAC;IAED,eAAe;IACf,OAAO;QACL,OAAO,EAAE,CAAC;gBACR,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,KAAK,EAAE,iBAAiB,IAAI,EAAE;oBAC9B,IAAI,EAAE,+CAA+C;oBACrD,cAAc,EAAE,eAAe;iBAChC,CAAC;aACH,CAAC;QACF,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - Caching with invalidation
|
|
9
9
|
* - Rate limiting
|
|
10
10
|
* - Metrics collection
|
|
11
|
+
* - Multi-project resolution
|
|
11
12
|
*/
|
|
12
13
|
export { ResponseBuilder, createResponseBuilder, type MCPResponse, type MCPResponseMeta, type PaginationInfo, type ResponseHints, type ResponseBuilderConfig, } from './response-builder.js';
|
|
13
14
|
export { TokenEstimator, tokenEstimator, type TokenEstimate, } from './token-estimator.js';
|
|
@@ -16,4 +17,5 @@ export { DriftError, DriftErrorCode, Errors, handleError, type DriftErrorDetails
|
|
|
16
17
|
export { ResponseCache, createCache, type CachedResponse, type CacheConfig, } from './cache.js';
|
|
17
18
|
export { RateLimiter, rateLimiter, type RateLimitConfig, } from './rate-limiter.js';
|
|
18
19
|
export { MetricsCollector, metrics, type Metric, type MetricLabels, type HistogramBuckets, } from './metrics.js';
|
|
20
|
+
export { resolveProject, formatProjectContext, ProjectNotFoundError, ProjectInvalidError, type ProjectResolution, } from './project-resolver.js';
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infrastructure/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infrastructure/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,cAAc,EACd,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,UAAU,EACV,cAAc,EACd,MAAM,EACN,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,aAAa,EACb,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,WAAW,EACX,WAAW,EACX,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,iBAAiB,GACvB,MAAM,uBAAuB,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - Caching with invalidation
|
|
9
9
|
* - Rate limiting
|
|
10
10
|
* - Metrics collection
|
|
11
|
+
* - Multi-project resolution
|
|
11
12
|
*/
|
|
12
13
|
// Response Building
|
|
13
14
|
export { ResponseBuilder, createResponseBuilder, } from './response-builder.js';
|
|
@@ -23,4 +24,6 @@ export { ResponseCache, createCache, } from './cache.js';
|
|
|
23
24
|
export { RateLimiter, rateLimiter, } from './rate-limiter.js';
|
|
24
25
|
// Metrics
|
|
25
26
|
export { MetricsCollector, metrics, } from './metrics.js';
|
|
27
|
+
// Project Resolution
|
|
28
|
+
export { resolveProject, formatProjectContext, ProjectNotFoundError, ProjectInvalidError, } from './project-resolver.js';
|
|
26
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infrastructure/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infrastructure/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,qBAAqB,GAMtB,MAAM,uBAAuB,CAAC;AAE/B,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,cAAc,GAEf,MAAM,sBAAsB,CAAC;AAE9B,oBAAoB;AACpB,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,GAGZ,MAAM,qBAAqB,CAAC;AAE7B,iBAAiB;AACjB,OAAO,EACL,UAAU,EACV,cAAc,EACd,MAAM,EACN,WAAW,GAGZ,MAAM,oBAAoB,CAAC;AAE5B,UAAU;AACV,OAAO,EACL,aAAa,EACb,WAAW,GAGZ,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAChB,OAAO,EACL,WAAW,EACX,WAAW,GAEZ,MAAM,mBAAmB,CAAC;AAE3B,UAAU;AACV,OAAO,EACL,gBAAgB,EAChB,OAAO,GAIR,MAAM,cAAc,CAAC;AAEtB,qBAAqB;AACrB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Resolver - Resolves project names to paths for MCP tools
|
|
3
|
+
*
|
|
4
|
+
* Enables AI agents to work across multiple registered projects
|
|
5
|
+
* by resolving project names/IDs to their actual paths.
|
|
6
|
+
*/
|
|
7
|
+
import { type RegisteredProject } from 'driftdetect-core';
|
|
8
|
+
export interface ProjectResolution {
|
|
9
|
+
/** Resolved project root path */
|
|
10
|
+
projectRoot: string;
|
|
11
|
+
/** Project metadata if resolved from registry */
|
|
12
|
+
project?: RegisteredProject;
|
|
13
|
+
/** Whether this was resolved from registry or used default */
|
|
14
|
+
fromRegistry: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a project name/ID to its path
|
|
18
|
+
*
|
|
19
|
+
* @param projectNameOrId - Project name, ID, or undefined for default
|
|
20
|
+
* @param defaultRoot - Default project root to use if no project specified
|
|
21
|
+
* @returns Resolved project path and metadata
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveProject(projectNameOrId: string | undefined, defaultRoot: string): Promise<ProjectResolution>;
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when a project is not found in the registry
|
|
26
|
+
*/
|
|
27
|
+
export declare class ProjectNotFoundError extends Error {
|
|
28
|
+
readonly searchTerm: string;
|
|
29
|
+
readonly partialMatches: RegisteredProject[];
|
|
30
|
+
constructor(searchTerm: string, partialMatches?: RegisteredProject[]);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown when a project path no longer exists
|
|
34
|
+
*/
|
|
35
|
+
export declare class ProjectInvalidError extends Error {
|
|
36
|
+
readonly project: RegisteredProject;
|
|
37
|
+
constructor(project: RegisteredProject);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Format project resolution result for MCP response
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatProjectContext(resolution: ProjectResolution): Record<string, unknown>;
|
|
43
|
+
//# sourceMappingURL=project-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-resolver.d.ts","sourceRoot":"","sources":["../../src/infrastructure/project-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,8DAA8D;IAC9D,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,eAAe,EAAE,MAAM,GAAG,SAAS,EACnC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAyD5B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;aAE3B,UAAU,EAAE,MAAM;aAClB,cAAc,EAAE,iBAAiB,EAAE;gBADnC,UAAU,EAAE,MAAM,EAClB,cAAc,GAAE,iBAAiB,EAAO;CAQ3D;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,OAAO,EAAE,iBAAiB;gBAA1B,OAAO,EAAE,iBAAiB;CAIvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAY3F"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Resolver - Resolves project names to paths for MCP tools
|
|
3
|
+
*
|
|
4
|
+
* Enables AI agents to work across multiple registered projects
|
|
5
|
+
* by resolving project names/IDs to their actual paths.
|
|
6
|
+
*/
|
|
7
|
+
import { getProjectRegistry } from 'driftdetect-core';
|
|
8
|
+
/**
|
|
9
|
+
* Resolve a project name/ID to its path
|
|
10
|
+
*
|
|
11
|
+
* @param projectNameOrId - Project name, ID, or undefined for default
|
|
12
|
+
* @param defaultRoot - Default project root to use if no project specified
|
|
13
|
+
* @returns Resolved project path and metadata
|
|
14
|
+
*/
|
|
15
|
+
export async function resolveProject(projectNameOrId, defaultRoot) {
|
|
16
|
+
// No project specified - use default
|
|
17
|
+
if (!projectNameOrId) {
|
|
18
|
+
return {
|
|
19
|
+
projectRoot: defaultRoot,
|
|
20
|
+
fromRegistry: false,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const registry = await getProjectRegistry();
|
|
25
|
+
// Try to find by name first, then by ID, then by path
|
|
26
|
+
const project = registry.findByName(projectNameOrId) ??
|
|
27
|
+
registry.get(projectNameOrId) ??
|
|
28
|
+
registry.findByPath(projectNameOrId);
|
|
29
|
+
if (!project) {
|
|
30
|
+
// Try partial match
|
|
31
|
+
const matches = registry.search(projectNameOrId);
|
|
32
|
+
if (matches.length === 1 && matches[0]) {
|
|
33
|
+
await registry.updateLastAccessed(matches[0].id);
|
|
34
|
+
return {
|
|
35
|
+
projectRoot: matches[0].path,
|
|
36
|
+
project: matches[0],
|
|
37
|
+
fromRegistry: true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// No match found - throw with helpful error
|
|
41
|
+
throw new ProjectNotFoundError(projectNameOrId, matches);
|
|
42
|
+
}
|
|
43
|
+
// Validate project path still exists
|
|
44
|
+
if (project.isValid === false) {
|
|
45
|
+
throw new ProjectInvalidError(project);
|
|
46
|
+
}
|
|
47
|
+
// Update last accessed
|
|
48
|
+
await registry.updateLastAccessed(project.id);
|
|
49
|
+
return {
|
|
50
|
+
projectRoot: project.path,
|
|
51
|
+
project,
|
|
52
|
+
fromRegistry: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error instanceof ProjectNotFoundError || error instanceof ProjectInvalidError) {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
// Registry not available - fall back to default
|
|
60
|
+
return {
|
|
61
|
+
projectRoot: defaultRoot,
|
|
62
|
+
fromRegistry: false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error thrown when a project is not found in the registry
|
|
68
|
+
*/
|
|
69
|
+
export class ProjectNotFoundError extends Error {
|
|
70
|
+
searchTerm;
|
|
71
|
+
partialMatches;
|
|
72
|
+
constructor(searchTerm, partialMatches = []) {
|
|
73
|
+
const message = partialMatches.length > 0
|
|
74
|
+
? `Project "${searchTerm}" not found. Did you mean: ${partialMatches.map(p => p.name).join(', ')}?`
|
|
75
|
+
: `Project "${searchTerm}" not found. Use drift_projects action="list" to see available projects.`;
|
|
76
|
+
super(message);
|
|
77
|
+
this.searchTerm = searchTerm;
|
|
78
|
+
this.partialMatches = partialMatches;
|
|
79
|
+
this.name = 'ProjectNotFoundError';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Error thrown when a project path no longer exists
|
|
84
|
+
*/
|
|
85
|
+
export class ProjectInvalidError extends Error {
|
|
86
|
+
project;
|
|
87
|
+
constructor(project) {
|
|
88
|
+
super(`Project "${project.name}" path no longer exists: ${project.path}`);
|
|
89
|
+
this.project = project;
|
|
90
|
+
this.name = 'ProjectInvalidError';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Format project resolution result for MCP response
|
|
95
|
+
*/
|
|
96
|
+
export function formatProjectContext(resolution) {
|
|
97
|
+
if (!resolution.fromRegistry || !resolution.project) {
|
|
98
|
+
return { projectRoot: resolution.projectRoot };
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
projectRoot: resolution.projectRoot,
|
|
102
|
+
projectName: resolution.project.name,
|
|
103
|
+
projectId: resolution.project.id,
|
|
104
|
+
language: resolution.project.language,
|
|
105
|
+
framework: resolution.project.framework,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=project-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-resolver.js","sourceRoot":"","sources":["../../src/infrastructure/project-resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AAW9E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,eAAmC,EACnC,WAAmB;IAEnB,qCAAqC;IACrC,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO;YACL,WAAW,EAAE,WAAW;YACxB,YAAY,EAAE,KAAK;SACpB,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,kBAAkB,EAAE,CAAC;QAE5C,sDAAsD;QACtD,MAAM,OAAO,GACX,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC;YACpC,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC;YAC7B,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,oBAAoB;YACpB,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YACjD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,MAAM,QAAQ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AC;QACrG,KAAK,CAAC,OAAO,CAAC,CAAC;QANC,eAAU,GAAV,UAAU,CAAQ;QAClB,mBAAc,GAAd,cAAc,CAA0B;QAMxD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAChB;IAA5B,YAA4B,OAA0B;QACpD,KAAK,CAAC,YAAY,OAAO,CAAC,IAAI,4BAA4B,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QADhD,YAAO,GAAP,OAAO,CAAmB;QAEpD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAA6B;IAChE,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACpD,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;IACjD,CAAC;IAED,OAAO;QACL,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI;QACpC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE;QAChC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,QAAQ;QACrC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,SAAS;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drift_coupling - Module Coupling Analysis
|
|
3
|
+
*
|
|
4
|
+
* Analysis tool for module dependencies, cycles, and coupling metrics.
|
|
5
|
+
* Based on Robert C. Martin's coupling metrics (Ca, Ce, Instability, Abstractness, Distance).
|
|
6
|
+
*/
|
|
7
|
+
import { type AggregateCouplingMetrics, type DependencyCycle, type ModuleCouplingAnalysis, type RefactorImpact, type UnusedExportAnalysis, type CouplingMetrics } from 'driftdetect-core';
|
|
8
|
+
export type CouplingAction = 'status' | 'cycles' | 'hotspots' | 'analyze' | 'refactor-impact' | 'unused-exports';
|
|
9
|
+
export interface CouplingArgs {
|
|
10
|
+
action: CouplingAction;
|
|
11
|
+
module?: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
minCoupling?: number;
|
|
14
|
+
maxCycleLength?: number;
|
|
15
|
+
minSeverity?: 'info' | 'warning' | 'critical';
|
|
16
|
+
}
|
|
17
|
+
export interface CouplingStatusData {
|
|
18
|
+
metrics: AggregateCouplingMetrics;
|
|
19
|
+
generatedAt?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CouplingCyclesData {
|
|
22
|
+
cycles: DependencyCycle[];
|
|
23
|
+
total: number;
|
|
24
|
+
bySeverity: {
|
|
25
|
+
critical: number;
|
|
26
|
+
warning: number;
|
|
27
|
+
info: number;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface CouplingHotspotsData {
|
|
31
|
+
hotspots: Array<{
|
|
32
|
+
path: string;
|
|
33
|
+
coupling: number;
|
|
34
|
+
metrics: CouplingMetrics;
|
|
35
|
+
}>;
|
|
36
|
+
total: number;
|
|
37
|
+
}
|
|
38
|
+
export interface CouplingAnalyzeData {
|
|
39
|
+
module: string;
|
|
40
|
+
analysis: ModuleCouplingAnalysis;
|
|
41
|
+
}
|
|
42
|
+
export interface CouplingRefactorData {
|
|
43
|
+
module: string;
|
|
44
|
+
impact: RefactorImpact;
|
|
45
|
+
}
|
|
46
|
+
export interface CouplingUnusedData {
|
|
47
|
+
unused: UnusedExportAnalysis[];
|
|
48
|
+
total: number;
|
|
49
|
+
}
|
|
50
|
+
export declare function handleCoupling(projectRoot: string, args: CouplingArgs): Promise<{
|
|
51
|
+
content: Array<{
|
|
52
|
+
type: string;
|
|
53
|
+
text: string;
|
|
54
|
+
}>;
|
|
55
|
+
}>;
|
|
56
|
+
//# sourceMappingURL=coupling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coupling.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