driftdetect-mcp 0.3.0 → 0.4.2
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/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 +1136 -18
- 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 +3 -3
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* drift_context - Intent-Aware Context Orchestration
|
|
3
|
+
*
|
|
4
|
+
* The "final boss" tool. Instead of making the AI figure out which tools to call
|
|
5
|
+
* and how to synthesize the results, this tool understands the AI's intent and
|
|
6
|
+
* returns a curated context package with everything needed for the task.
|
|
7
|
+
*
|
|
8
|
+
* This is the recommended starting point for any code generation task.
|
|
9
|
+
*/
|
|
10
|
+
import { PatternStore, ManifestStore, BoundaryStore, CallGraphStore, DNAStore, } from 'driftdetect-core';
|
|
11
|
+
import { createResponseBuilder } from '../../infrastructure/index.js';
|
|
12
|
+
import * as fs from 'fs/promises';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
const INTENT_STRATEGIES = {
|
|
15
|
+
add_feature: {
|
|
16
|
+
categories: ['api', 'components', 'structural', 'errors', 'logging', 'types'],
|
|
17
|
+
prioritizePatterns: (patterns, focus) => {
|
|
18
|
+
const focusLower = focus.toLowerCase();
|
|
19
|
+
return patterns
|
|
20
|
+
.filter(p => p.name.toLowerCase().includes(focusLower) ||
|
|
21
|
+
p.description.toLowerCase().includes(focusLower) ||
|
|
22
|
+
p.locations.some(l => l.file.toLowerCase().includes(focusLower)))
|
|
23
|
+
.sort((a, b) => b.confidence.score - a.confidence.score);
|
|
24
|
+
},
|
|
25
|
+
generateGuidance: (patterns) => ({
|
|
26
|
+
keyInsights: [
|
|
27
|
+
patterns.some(p => p.category === 'api')
|
|
28
|
+
? 'This codebase has established API patterns - follow them for consistency'
|
|
29
|
+
: 'No strong API patterns detected - you have flexibility in approach',
|
|
30
|
+
patterns.some(p => p.category === 'errors')
|
|
31
|
+
? 'Error handling patterns exist - use the established error types'
|
|
32
|
+
: 'Consider adding error handling following common practices',
|
|
33
|
+
],
|
|
34
|
+
commonMistakes: [
|
|
35
|
+
'Don\'t create new patterns when existing ones apply',
|
|
36
|
+
'Remember to add appropriate logging',
|
|
37
|
+
'Include error handling from the start',
|
|
38
|
+
],
|
|
39
|
+
decisionPoints: [
|
|
40
|
+
'Decide if this feature needs its own module or fits in existing structure',
|
|
41
|
+
'Consider if new types/interfaces are needed',
|
|
42
|
+
],
|
|
43
|
+
}),
|
|
44
|
+
getWarningTypes: () => ['breaking_change', 'complexity'],
|
|
45
|
+
},
|
|
46
|
+
fix_bug: {
|
|
47
|
+
categories: ['errors', 'logging', 'data-access', 'api', 'testing'],
|
|
48
|
+
prioritizePatterns: (patterns, focus) => {
|
|
49
|
+
const focusLower = focus.toLowerCase();
|
|
50
|
+
// For bugs, prioritize error handling and the specific area
|
|
51
|
+
return patterns
|
|
52
|
+
.filter(p => p.category === 'errors' ||
|
|
53
|
+
p.name.toLowerCase().includes(focusLower) ||
|
|
54
|
+
p.locations.some(l => l.file.toLowerCase().includes(focusLower)))
|
|
55
|
+
.sort((a, b) => {
|
|
56
|
+
if (a.category === 'errors' && b.category !== 'errors')
|
|
57
|
+
return -1;
|
|
58
|
+
if (b.category === 'errors' && a.category !== 'errors')
|
|
59
|
+
return 1;
|
|
60
|
+
return b.confidence.score - a.confidence.score;
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
generateGuidance: (patterns) => ({
|
|
64
|
+
keyInsights: [
|
|
65
|
+
'Understand the error handling flow before making changes',
|
|
66
|
+
'Check if similar bugs exist elsewhere (pattern outliers)',
|
|
67
|
+
patterns.some(p => p.category === 'logging')
|
|
68
|
+
? 'Add logging to help debug if the fix doesn\'t work'
|
|
69
|
+
: 'Consider adding logging for future debugging',
|
|
70
|
+
],
|
|
71
|
+
commonMistakes: [
|
|
72
|
+
'Don\'t just fix the symptom - understand the root cause',
|
|
73
|
+
'Avoid changing unrelated code in the same commit',
|
|
74
|
+
'Don\'t remove error handling to "fix" the bug',
|
|
75
|
+
],
|
|
76
|
+
decisionPoints: [
|
|
77
|
+
`Is this a one-off bug or a pattern that might exist elsewhere?`,
|
|
78
|
+
'Should this fix include a regression test?',
|
|
79
|
+
],
|
|
80
|
+
}),
|
|
81
|
+
getWarningTypes: () => ['breaking_change', 'data_access'],
|
|
82
|
+
},
|
|
83
|
+
refactor: {
|
|
84
|
+
categories: ['structural', 'components', 'types', 'api', 'styling'],
|
|
85
|
+
prioritizePatterns: (patterns, focus) => {
|
|
86
|
+
const focusLower = focus.toLowerCase();
|
|
87
|
+
return patterns
|
|
88
|
+
.filter(p => p.locations.some(l => l.file.toLowerCase().includes(focusLower)) ||
|
|
89
|
+
p.name.toLowerCase().includes(focusLower))
|
|
90
|
+
.sort((a, b) => b.locations.length - a.locations.length); // Most used patterns first
|
|
91
|
+
},
|
|
92
|
+
generateGuidance: (patterns) => ({
|
|
93
|
+
keyInsights: [
|
|
94
|
+
'Identify the dominant patterns before changing anything',
|
|
95
|
+
'Refactoring should move toward patterns, not away from them',
|
|
96
|
+
patterns.filter(p => p.outliers.length > 0).length > 0
|
|
97
|
+
? 'There are outliers that might be good refactoring targets'
|
|
98
|
+
: 'Patterns are consistent - be careful not to introduce outliers',
|
|
99
|
+
],
|
|
100
|
+
commonMistakes: [
|
|
101
|
+
'Don\'t refactor and add features in the same change',
|
|
102
|
+
'Avoid changing public APIs without updating all callers',
|
|
103
|
+
'Don\'t "improve" working code without clear benefit',
|
|
104
|
+
],
|
|
105
|
+
decisionPoints: [
|
|
106
|
+
'Is this refactor worth the risk of introducing bugs?',
|
|
107
|
+
'Should you refactor incrementally or all at once?',
|
|
108
|
+
'Are there tests covering the code you\'re changing?',
|
|
109
|
+
],
|
|
110
|
+
}),
|
|
111
|
+
getWarningTypes: () => ['breaking_change', 'complexity'],
|
|
112
|
+
},
|
|
113
|
+
security_audit: {
|
|
114
|
+
categories: ['security', 'auth', 'data-access', 'api'],
|
|
115
|
+
prioritizePatterns: (patterns, _focus) => {
|
|
116
|
+
// Security audit prioritizes security-related patterns
|
|
117
|
+
return patterns
|
|
118
|
+
.filter(p => ['security', 'auth', 'data-access'].includes(p.category) ||
|
|
119
|
+
p.name.toLowerCase().includes('auth') ||
|
|
120
|
+
p.name.toLowerCase().includes('permission') ||
|
|
121
|
+
p.name.toLowerCase().includes('access'))
|
|
122
|
+
.sort((a, b) => {
|
|
123
|
+
const securityOrder = ['security', 'auth', 'data-access', 'api'];
|
|
124
|
+
return securityOrder.indexOf(a.category) - securityOrder.indexOf(b.category);
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
generateGuidance: () => ({
|
|
128
|
+
keyInsights: [
|
|
129
|
+
'Focus on data access patterns - who can access what?',
|
|
130
|
+
'Check authentication flows for consistency',
|
|
131
|
+
'Look for authorization checks at entry points',
|
|
132
|
+
],
|
|
133
|
+
commonMistakes: [
|
|
134
|
+
'Don\'t assume authentication implies authorization',
|
|
135
|
+
'Don\'t trust client-side validation alone',
|
|
136
|
+
'Don\'t log sensitive data',
|
|
137
|
+
],
|
|
138
|
+
decisionPoints: [
|
|
139
|
+
'Are there data access paths that bypass authorization?',
|
|
140
|
+
'Is sensitive data properly encrypted at rest and in transit?',
|
|
141
|
+
'Are there any hardcoded credentials or secrets?',
|
|
142
|
+
],
|
|
143
|
+
}),
|
|
144
|
+
getWarningTypes: () => ['security', 'data_access'],
|
|
145
|
+
},
|
|
146
|
+
understand_code: {
|
|
147
|
+
categories: ['structural', 'api', 'components', 'data-access', 'types'],
|
|
148
|
+
prioritizePatterns: (patterns, focus) => {
|
|
149
|
+
const focusLower = focus.toLowerCase();
|
|
150
|
+
return patterns
|
|
151
|
+
.filter(p => p.locations.some(l => l.file.toLowerCase().includes(focusLower)) ||
|
|
152
|
+
p.name.toLowerCase().includes(focusLower) ||
|
|
153
|
+
p.description.toLowerCase().includes(focusLower))
|
|
154
|
+
.sort((a, b) => b.locations.length - a.locations.length);
|
|
155
|
+
},
|
|
156
|
+
generateGuidance: (patterns) => ({
|
|
157
|
+
keyInsights: [
|
|
158
|
+
`This area uses ${patterns.length} distinct patterns`,
|
|
159
|
+
patterns.length > 0
|
|
160
|
+
? `The dominant pattern is "${patterns[0]?.name}" with ${patterns[0]?.locations.length} occurrences`
|
|
161
|
+
: 'No strong patterns detected in this area',
|
|
162
|
+
],
|
|
163
|
+
commonMistakes: [
|
|
164
|
+
'Don\'t assume you understand the code from names alone',
|
|
165
|
+
'Check for edge cases in pattern outliers',
|
|
166
|
+
],
|
|
167
|
+
decisionPoints: [
|
|
168
|
+
'Do you need to understand the full call graph?',
|
|
169
|
+
'Are there related patterns in other categories?',
|
|
170
|
+
],
|
|
171
|
+
}),
|
|
172
|
+
getWarningTypes: () => ['complexity'],
|
|
173
|
+
},
|
|
174
|
+
add_test: {
|
|
175
|
+
categories: ['testing', 'errors', 'api', 'data-access'],
|
|
176
|
+
prioritizePatterns: (patterns, focus) => {
|
|
177
|
+
const focusLower = focus.toLowerCase();
|
|
178
|
+
// Prioritize testing patterns, then the area being tested
|
|
179
|
+
return patterns
|
|
180
|
+
.filter(p => p.category === 'testing' ||
|
|
181
|
+
p.locations.some(l => l.file.toLowerCase().includes(focusLower)))
|
|
182
|
+
.sort((a, b) => {
|
|
183
|
+
if (a.category === 'testing' && b.category !== 'testing')
|
|
184
|
+
return -1;
|
|
185
|
+
if (b.category === 'testing' && a.category !== 'testing')
|
|
186
|
+
return 1;
|
|
187
|
+
return b.confidence.score - a.confidence.score;
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
generateGuidance: (patterns) => ({
|
|
191
|
+
keyInsights: [
|
|
192
|
+
patterns.some(p => p.category === 'testing')
|
|
193
|
+
? 'Follow the existing test patterns for consistency'
|
|
194
|
+
: 'No strong testing patterns - establish good practices',
|
|
195
|
+
'Focus on behavior, not implementation details',
|
|
196
|
+
],
|
|
197
|
+
commonMistakes: [
|
|
198
|
+
'Don\'t test implementation details that might change',
|
|
199
|
+
'Don\'t forget edge cases and error paths',
|
|
200
|
+
'Don\'t mock everything - some integration is good',
|
|
201
|
+
],
|
|
202
|
+
decisionPoints: [
|
|
203
|
+
'Unit test, integration test, or both?',
|
|
204
|
+
'What edge cases need coverage?',
|
|
205
|
+
'Should you test the happy path or error paths first?',
|
|
206
|
+
],
|
|
207
|
+
}),
|
|
208
|
+
getWarningTypes: () => ['complexity'],
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
// =============================================================================
|
|
212
|
+
// Main Handler
|
|
213
|
+
// =============================================================================
|
|
214
|
+
export async function handleContext(stores, projectRoot, args) {
|
|
215
|
+
const builder = createResponseBuilder();
|
|
216
|
+
const { intent, focus, question } = args;
|
|
217
|
+
const strategy = INTENT_STRATEGIES[intent];
|
|
218
|
+
// Initialize stores
|
|
219
|
+
await stores.pattern.initialize();
|
|
220
|
+
await stores.manifest.load();
|
|
221
|
+
// Get all patterns
|
|
222
|
+
const allPatterns = stores.pattern.getAll();
|
|
223
|
+
// Filter to relevant categories and prioritize
|
|
224
|
+
const categoryPatterns = allPatterns.filter(p => strategy.categories.includes(p.category));
|
|
225
|
+
const prioritizedPatterns = strategy.prioritizePatterns(categoryPatterns, focus);
|
|
226
|
+
// Get top patterns with examples
|
|
227
|
+
const relevantPatterns = await getRelevantPatterns(prioritizedPatterns.slice(0, 5), projectRoot, focus);
|
|
228
|
+
// Find suggested files
|
|
229
|
+
const suggestedFiles = await getSuggestedFiles(stores.manifest, stores.boundary, prioritizedPatterns, focus, intent);
|
|
230
|
+
// Generate guidance
|
|
231
|
+
const guidance = strategy.generateGuidance(prioritizedPatterns, focus);
|
|
232
|
+
// Add question-specific insight if provided
|
|
233
|
+
if (question) {
|
|
234
|
+
guidance.keyInsights.unshift(`Regarding "${question}": Check the patterns below for established approaches.`);
|
|
235
|
+
}
|
|
236
|
+
// Generate warnings
|
|
237
|
+
const warnings = await generateWarnings(stores.boundary, projectRoot, suggestedFiles, strategy.getWarningTypes());
|
|
238
|
+
// Calculate confidence
|
|
239
|
+
const confidence = calculateConfidence(stores.pattern, prioritizedPatterns, focus);
|
|
240
|
+
// Generate deeper dive suggestions
|
|
241
|
+
const deeperDive = generateDeeperDive(intent, focus, relevantPatterns, suggestedFiles);
|
|
242
|
+
// Build summary
|
|
243
|
+
const summary = buildSummary(intent, focus, relevantPatterns, suggestedFiles, warnings);
|
|
244
|
+
const contextPackage = {
|
|
245
|
+
summary,
|
|
246
|
+
relevantPatterns,
|
|
247
|
+
suggestedFiles,
|
|
248
|
+
guidance,
|
|
249
|
+
warnings,
|
|
250
|
+
confidence,
|
|
251
|
+
deeperDive,
|
|
252
|
+
};
|
|
253
|
+
return builder
|
|
254
|
+
.withSummary(summary)
|
|
255
|
+
.withData(contextPackage)
|
|
256
|
+
.withHints({
|
|
257
|
+
nextActions: deeperDive.slice(0, 2).map(d => `${d.tool}: ${d.reason}`),
|
|
258
|
+
relatedTools: ['drift_code_examples', 'drift_impact_analysis', 'drift_reachability'],
|
|
259
|
+
})
|
|
260
|
+
.buildContent();
|
|
261
|
+
}
|
|
262
|
+
// =============================================================================
|
|
263
|
+
// Helper Functions
|
|
264
|
+
// =============================================================================
|
|
265
|
+
async function getRelevantPatterns(patterns, projectRoot, focus) {
|
|
266
|
+
const results = [];
|
|
267
|
+
for (const pattern of patterns) {
|
|
268
|
+
// Find best example location (prefer files matching focus)
|
|
269
|
+
const focusLower = focus.toLowerCase();
|
|
270
|
+
const sortedLocations = [...pattern.locations].sort((a, b) => {
|
|
271
|
+
const aMatches = a.file.toLowerCase().includes(focusLower) ? 1 : 0;
|
|
272
|
+
const bMatches = b.file.toLowerCase().includes(focusLower) ? 1 : 0;
|
|
273
|
+
return bMatches - aMatches;
|
|
274
|
+
});
|
|
275
|
+
const bestLocation = sortedLocations[0];
|
|
276
|
+
let example = '';
|
|
277
|
+
if (bestLocation) {
|
|
278
|
+
try {
|
|
279
|
+
const filePath = path.join(projectRoot, bestLocation.file);
|
|
280
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
281
|
+
const lines = content.split('\n');
|
|
282
|
+
const start = Math.max(0, bestLocation.line - 3);
|
|
283
|
+
const end = Math.min(lines.length, bestLocation.line + 7);
|
|
284
|
+
example = lines.slice(start, end).join('\n');
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
example = `// See ${bestLocation.file}:${bestLocation.line}`;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
results.push({
|
|
291
|
+
id: pattern.id,
|
|
292
|
+
name: pattern.name,
|
|
293
|
+
category: pattern.category,
|
|
294
|
+
why: generatePatternWhy(pattern, focus),
|
|
295
|
+
example,
|
|
296
|
+
confidence: Math.round(pattern.confidence.score * 100) / 100,
|
|
297
|
+
locationCount: pattern.locations.length,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
return results;
|
|
301
|
+
}
|
|
302
|
+
function generatePatternWhy(pattern, focus) {
|
|
303
|
+
const focusLower = focus.toLowerCase();
|
|
304
|
+
if (pattern.name.toLowerCase().includes(focusLower)) {
|
|
305
|
+
return `Directly related to "${focus}" - this is the established pattern`;
|
|
306
|
+
}
|
|
307
|
+
if (pattern.locations.some(l => l.file.toLowerCase().includes(focusLower))) {
|
|
308
|
+
return `Used in files matching "${focus}" - follow this for consistency`;
|
|
309
|
+
}
|
|
310
|
+
if (pattern.category === 'errors') {
|
|
311
|
+
return 'Error handling pattern - use this for consistent error management';
|
|
312
|
+
}
|
|
313
|
+
if (pattern.category === 'auth') {
|
|
314
|
+
return 'Authentication pattern - critical for security consistency';
|
|
315
|
+
}
|
|
316
|
+
return `${pattern.category} pattern with ${pattern.locations.length} occurrences - established convention`;
|
|
317
|
+
}
|
|
318
|
+
async function getSuggestedFiles(_manifestStore, _boundaryStore, patterns, focus, intent) {
|
|
319
|
+
const focusLower = focus.toLowerCase();
|
|
320
|
+
const fileScores = new Map();
|
|
321
|
+
// Score files based on pattern matches
|
|
322
|
+
for (const pattern of patterns) {
|
|
323
|
+
for (const location of pattern.locations) {
|
|
324
|
+
const file = location.file;
|
|
325
|
+
const existing = fileScores.get(file) || { score: 0, patterns: [], reasons: [] };
|
|
326
|
+
// Higher score for focus matches
|
|
327
|
+
const focusMatch = file.toLowerCase().includes(focusLower);
|
|
328
|
+
existing.score += focusMatch ? 10 : 1;
|
|
329
|
+
if (!existing.patterns.includes(pattern.name)) {
|
|
330
|
+
existing.patterns.push(pattern.name);
|
|
331
|
+
}
|
|
332
|
+
if (focusMatch && !existing.reasons.includes('Matches focus area')) {
|
|
333
|
+
existing.reasons.push('Matches focus area');
|
|
334
|
+
}
|
|
335
|
+
fileScores.set(file, existing);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// Sort by score and take top files
|
|
339
|
+
const sortedFiles = Array.from(fileScores.entries())
|
|
340
|
+
.sort((a, b) => b[1].score - a[1].score)
|
|
341
|
+
.slice(0, 5);
|
|
342
|
+
// Determine risk based on intent and patterns
|
|
343
|
+
const results = sortedFiles.map(([file, data]) => {
|
|
344
|
+
let risk = 'low';
|
|
345
|
+
// Higher risk for security-related intents
|
|
346
|
+
if (intent === 'security_audit' && data.patterns.some(p => p.toLowerCase().includes('auth') || p.toLowerCase().includes('security'))) {
|
|
347
|
+
risk = 'high';
|
|
348
|
+
}
|
|
349
|
+
// Higher risk for files with many patterns (more complex)
|
|
350
|
+
if (data.patterns.length > 3) {
|
|
351
|
+
risk = risk === 'low' ? 'medium' : 'high';
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
file,
|
|
355
|
+
reason: data.reasons[0] || `Contains ${data.patterns.length} relevant pattern(s)`,
|
|
356
|
+
patterns: data.patterns.slice(0, 3),
|
|
357
|
+
risk,
|
|
358
|
+
};
|
|
359
|
+
});
|
|
360
|
+
return results;
|
|
361
|
+
}
|
|
362
|
+
async function generateWarnings(boundaryStore, _projectRoot, suggestedFiles, warningTypes) {
|
|
363
|
+
const warnings = [];
|
|
364
|
+
// Check for security warnings
|
|
365
|
+
if (warningTypes.includes('security') || warningTypes.includes('data_access')) {
|
|
366
|
+
try {
|
|
367
|
+
await boundaryStore.initialize();
|
|
368
|
+
const accessMap = boundaryStore.getAccessMap();
|
|
369
|
+
if (accessMap) {
|
|
370
|
+
// Check if suggested files access sensitive data
|
|
371
|
+
for (const file of suggestedFiles) {
|
|
372
|
+
const fileAccess = accessMap.accessPoints[file.file];
|
|
373
|
+
if (fileAccess) {
|
|
374
|
+
const sensitiveFields = accessMap.sensitiveFields.filter(sf => sf.file === file.file);
|
|
375
|
+
if (sensitiveFields.length > 0) {
|
|
376
|
+
warnings.push({
|
|
377
|
+
type: 'data_access',
|
|
378
|
+
message: `${file.file} accesses sensitive data: ${sensitiveFields.map(sf => `${sf.table}.${sf.field}`).join(', ')}`,
|
|
379
|
+
severity: 'warning',
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
catch {
|
|
387
|
+
// Boundary store not available
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
// Check for complexity warnings
|
|
391
|
+
if (warningTypes.includes('complexity')) {
|
|
392
|
+
const complexFiles = suggestedFiles.filter(f => f.patterns.length > 3);
|
|
393
|
+
if (complexFiles.length > 0) {
|
|
394
|
+
warnings.push({
|
|
395
|
+
type: 'complexity',
|
|
396
|
+
message: `${complexFiles.length} file(s) have high pattern density - changes may have wide impact`,
|
|
397
|
+
severity: 'info',
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// Check for breaking change potential
|
|
402
|
+
if (warningTypes.includes('breaking_change')) {
|
|
403
|
+
const highRiskFiles = suggestedFiles.filter(f => f.risk === 'high');
|
|
404
|
+
if (highRiskFiles.length > 0) {
|
|
405
|
+
warnings.push({
|
|
406
|
+
type: 'breaking_change',
|
|
407
|
+
message: `${highRiskFiles.length} file(s) are high-risk - consider impact analysis before changes`,
|
|
408
|
+
severity: 'warning',
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return warnings;
|
|
413
|
+
}
|
|
414
|
+
function calculateConfidence(patternStore, relevantPatterns, focus) {
|
|
415
|
+
const stats = patternStore.getStats();
|
|
416
|
+
const focusLower = focus.toLowerCase();
|
|
417
|
+
// Calculate how well we understand this area
|
|
418
|
+
const focusPatterns = relevantPatterns.filter(p => p.name.toLowerCase().includes(focusLower) ||
|
|
419
|
+
p.locations.some(l => l.file.toLowerCase().includes(focusLower)));
|
|
420
|
+
const patternCoverage = focusPatterns.length > 0
|
|
421
|
+
? Math.min(100, focusPatterns.length * 20) // 5 patterns = 100%
|
|
422
|
+
: relevantPatterns.length > 0 ? 50 : 10;
|
|
423
|
+
const limitations = [];
|
|
424
|
+
if (focusPatterns.length === 0) {
|
|
425
|
+
limitations.push(`No patterns directly match "${focus}" - results are inferred from related patterns`);
|
|
426
|
+
}
|
|
427
|
+
if (stats.totalPatterns < 10) {
|
|
428
|
+
limitations.push('Limited pattern data - consider running a full scan');
|
|
429
|
+
}
|
|
430
|
+
return {
|
|
431
|
+
patternCoverage,
|
|
432
|
+
dataFreshness: 'Current session', // Would be better with actual timestamps
|
|
433
|
+
limitations,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function generateDeeperDive(intent, _focus, patterns, files) {
|
|
437
|
+
const suggestions = [];
|
|
438
|
+
// Always suggest code examples if we have patterns
|
|
439
|
+
if (patterns.length > 0) {
|
|
440
|
+
suggestions.push({
|
|
441
|
+
tool: 'drift_code_examples',
|
|
442
|
+
args: { pattern: patterns[0]?.id, maxExamples: 3 },
|
|
443
|
+
reason: `See more examples of "${patterns[0]?.name}" pattern`,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
// Suggest impact analysis for risky changes
|
|
447
|
+
if (files.some(f => f.risk === 'high')) {
|
|
448
|
+
const highRiskFile = files.find(f => f.risk === 'high');
|
|
449
|
+
suggestions.push({
|
|
450
|
+
tool: 'drift_impact_analysis',
|
|
451
|
+
args: { target: highRiskFile?.file },
|
|
452
|
+
reason: `Understand blast radius before changing ${highRiskFile?.file}`,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
// Suggest reachability for security audits
|
|
456
|
+
if (intent === 'security_audit' && files.length > 0) {
|
|
457
|
+
suggestions.push({
|
|
458
|
+
tool: 'drift_reachability',
|
|
459
|
+
args: { direction: 'forward', location: files[0]?.file },
|
|
460
|
+
reason: 'Trace what data this code can access',
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
// Suggest file patterns for understanding
|
|
464
|
+
if (intent === 'understand_code' && files.length > 0) {
|
|
465
|
+
suggestions.push({
|
|
466
|
+
tool: 'drift_file_patterns',
|
|
467
|
+
args: { file: files[0]?.file },
|
|
468
|
+
reason: `Deep dive into patterns in ${files[0]?.file}`,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
return suggestions;
|
|
472
|
+
}
|
|
473
|
+
function buildSummary(intent, focus, patterns, files, warnings) {
|
|
474
|
+
const intentLabels = {
|
|
475
|
+
add_feature: 'Adding feature',
|
|
476
|
+
fix_bug: 'Fixing bug',
|
|
477
|
+
refactor: 'Refactoring',
|
|
478
|
+
security_audit: 'Security audit',
|
|
479
|
+
understand_code: 'Understanding code',
|
|
480
|
+
add_test: 'Adding tests',
|
|
481
|
+
};
|
|
482
|
+
let summary = `${intentLabels[intent]} in "${focus}". `;
|
|
483
|
+
summary += `Found ${patterns.length} relevant pattern(s) and ${files.length} suggested file(s). `;
|
|
484
|
+
if (warnings.length > 0) {
|
|
485
|
+
const criticalCount = warnings.filter(w => w.severity === 'critical').length;
|
|
486
|
+
const warningCount = warnings.filter(w => w.severity === 'warning').length;
|
|
487
|
+
if (criticalCount > 0) {
|
|
488
|
+
summary += `⚠️ ${criticalCount} critical warning(s). `;
|
|
489
|
+
}
|
|
490
|
+
else if (warningCount > 0) {
|
|
491
|
+
summary += `${warningCount} warning(s) to review. `;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (patterns.length > 0 && patterns[0]) {
|
|
495
|
+
summary += `Primary pattern: "${patterns[0].name}" (${Math.round(patterns[0].confidence * 100)}% confidence).`;
|
|
496
|
+
}
|
|
497
|
+
return summary;
|
|
498
|
+
}
|
|
499
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/tools/orchestration/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,QAAQ,GAGT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AA4E7B,MAAM,iBAAiB,GAAuC;IAC5D,WAAW,EAAE;QACX,UAAU,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC;QAC7E,kBAAkB,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YACtC,MAAM,UAAU,GAAG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
* These are the "smart" tools that reduce cognitive load on the AI.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
export declare const ORCHESTRATION_TOOLS: Tool[];
|
|
9
|
+
export { handleContext } from './context.js';
|
|
10
|
+
export type { TaskIntent, ContextPackage, RelevantPattern, SuggestedFile, Guidance, Warning, Confidence, DeeperDive, } from './context.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/orchestration/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,eAAO,MAAM,mBAAmB,EAAE,IAAI,EA8CrC,CAAC;AAGF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,YAAY,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,QAAQ,EACR,OAAO,EACP,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestration Tools
|
|
3
|
+
*
|
|
4
|
+
* Meta-layer tools that understand intent and synthesize context from multiple sources.
|
|
5
|
+
* These are the "smart" tools that reduce cognitive load on the AI.
|
|
6
|
+
*/
|
|
7
|
+
export const ORCHESTRATION_TOOLS = [
|
|
8
|
+
{
|
|
9
|
+
name: 'drift_context',
|
|
10
|
+
description: `Get curated context for a specific task. This is the RECOMMENDED STARTING POINT for any code generation task.
|
|
11
|
+
|
|
12
|
+
Instead of calling multiple tools and synthesizing results yourself, tell drift_context what you're trying to do and it will return everything you need:
|
|
13
|
+
- Relevant patterns with examples
|
|
14
|
+
- Files you'll likely need to modify
|
|
15
|
+
- Guidance on how to approach the task
|
|
16
|
+
- Warnings about potential issues
|
|
17
|
+
- Confidence signals so you know when to verify
|
|
18
|
+
|
|
19
|
+
WHEN TO USE:
|
|
20
|
+
- Starting any code generation task
|
|
21
|
+
- Before making changes to unfamiliar code
|
|
22
|
+
- When you need to understand how something is done in this codebase
|
|
23
|
+
|
|
24
|
+
EXAMPLE:
|
|
25
|
+
intent: "add_feature", focus: "user authentication"
|
|
26
|
+
→ Returns auth patterns, example code, files to modify, security warnings`,
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
intent: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
enum: ['add_feature', 'fix_bug', 'refactor', 'security_audit', 'understand_code', 'add_test'],
|
|
33
|
+
description: `What are you trying to accomplish?
|
|
34
|
+
- add_feature: Adding new functionality
|
|
35
|
+
- fix_bug: Fixing a bug or issue
|
|
36
|
+
- refactor: Improving code structure without changing behavior
|
|
37
|
+
- security_audit: Reviewing code for security issues
|
|
38
|
+
- understand_code: Learning how something works
|
|
39
|
+
- add_test: Adding test coverage`,
|
|
40
|
+
},
|
|
41
|
+
focus: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'The specific area, feature, or file you\'re working with. Examples: "user authentication", "payment processing", "src/api/users.ts"',
|
|
44
|
+
},
|
|
45
|
+
question: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: 'Optional: A specific question you need answered. This helps tailor the guidance.',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
required: ['intent', 'focus'],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
// Handler export
|
|
55
|
+
export { handleContext } from './context.js';
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/orchestration/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,CAAC,MAAM,mBAAmB,GAAW;IACzC;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE;;;;;;;;;;;;;;;;4EAgB2D;QACxE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,CAAC;oBAC7F,WAAW,EAAE;;;;;;iCAMU;iBACxB;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qIAAqI;iBACnJ;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kFAAkF;iBAChG;aACF;YACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;SAC9B;KACF;CACF,CAAC;AAEF,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all MCP tools with:
|
|
5
|
+
* - Tool definitions (schemas)
|
|
6
|
+
* - Handler routing
|
|
7
|
+
* - Middleware support
|
|
8
|
+
*/
|
|
9
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
10
|
+
/**
|
|
11
|
+
* All registered tools
|
|
12
|
+
*
|
|
13
|
+
* Order matters for AI discovery:
|
|
14
|
+
* 1. Orchestration (recommended starting point)
|
|
15
|
+
* 2. Discovery (quick health checks)
|
|
16
|
+
* 3. Exploration (browsing/listing)
|
|
17
|
+
* 4. Detail (deep inspection)
|
|
18
|
+
*/
|
|
19
|
+
export declare const ALL_TOOLS: Tool[];
|
|
20
|
+
/**
|
|
21
|
+
* Tool categories for documentation
|
|
22
|
+
*/
|
|
23
|
+
export declare const TOOL_CATEGORIES: {
|
|
24
|
+
orchestration: string[];
|
|
25
|
+
discovery: string[];
|
|
26
|
+
exploration: string[];
|
|
27
|
+
detail: string[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Get tool by name
|
|
31
|
+
*/
|
|
32
|
+
export declare function getTool(name: string): Tool | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Check if tool exists
|
|
35
|
+
*/
|
|
36
|
+
export declare function hasTool(name: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get tools by category
|
|
39
|
+
*/
|
|
40
|
+
export declare function getToolsByCategory(category: 'orchestration' | 'discovery' | 'exploration' | 'detail'): Tool[];
|
|
41
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAM/D;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,EAAE,IAAI,EAK3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAEtD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,GAAG,IAAI,EAAE,CAW7G"}
|