driftdetect-mcp 0.7.1 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +121 -21
  2. package/dist/bin/server.js +8 -1
  3. package/dist/bin/server.js.map +1 -1
  4. package/dist/enterprise-server.d.ts +4 -0
  5. package/dist/enterprise-server.d.ts.map +1 -1
  6. package/dist/enterprise-server.js +32 -2
  7. package/dist/enterprise-server.js.map +1 -1
  8. package/dist/infrastructure/index.d.ts +1 -0
  9. package/dist/infrastructure/index.d.ts.map +1 -1
  10. package/dist/infrastructure/index.js +2 -0
  11. package/dist/infrastructure/index.js.map +1 -1
  12. package/dist/infrastructure/startup-warmer.d.ts +65 -0
  13. package/dist/infrastructure/startup-warmer.d.ts.map +1 -0
  14. package/dist/infrastructure/startup-warmer.js +257 -0
  15. package/dist/infrastructure/startup-warmer.js.map +1 -0
  16. package/dist/tools/analysis/coupling.js +181 -63
  17. package/dist/tools/analysis/coupling.js.map +1 -1
  18. package/dist/tools/analysis/cpp.d.ts +51 -0
  19. package/dist/tools/analysis/cpp.d.ts.map +1 -0
  20. package/dist/tools/analysis/cpp.js +224 -0
  21. package/dist/tools/analysis/cpp.js.map +1 -0
  22. package/dist/tools/analysis/error-handling.js +130 -37
  23. package/dist/tools/analysis/error-handling.js.map +1 -1
  24. package/dist/tools/analysis/index.d.ts +3 -0
  25. package/dist/tools/analysis/index.d.ts.map +1 -1
  26. package/dist/tools/analysis/index.js +100 -0
  27. package/dist/tools/analysis/index.js.map +1 -1
  28. package/dist/tools/analysis/quality-gate.d.ts +78 -0
  29. package/dist/tools/analysis/quality-gate.d.ts.map +1 -0
  30. package/dist/tools/analysis/quality-gate.js +164 -0
  31. package/dist/tools/analysis/quality-gate.js.map +1 -0
  32. package/dist/tools/analysis/rust.d.ts +51 -0
  33. package/dist/tools/analysis/rust.d.ts.map +1 -0
  34. package/dist/tools/analysis/rust.js +253 -0
  35. package/dist/tools/analysis/rust.js.map +1 -0
  36. package/dist/tools/analysis/simulate.d.ts +1 -0
  37. package/dist/tools/analysis/simulate.d.ts.map +1 -1
  38. package/dist/tools/analysis/simulate.js +78 -74
  39. package/dist/tools/analysis/simulate.js.map +1 -1
  40. package/dist/tools/analysis/test-topology.js +117 -44
  41. package/dist/tools/analysis/test-topology.js.map +1 -1
  42. package/dist/tools/detail/reachability.d.ts +2 -0
  43. package/dist/tools/detail/reachability.d.ts.map +1 -1
  44. package/dist/tools/detail/reachability.js +42 -32
  45. package/dist/tools/detail/reachability.js.map +1 -1
  46. package/dist/tools/orchestration/index.d.ts +2 -0
  47. package/dist/tools/orchestration/index.d.ts.map +1 -1
  48. package/dist/tools/orchestration/index.js +3 -0
  49. package/dist/tools/orchestration/index.js.map +1 -1
  50. package/dist/tools/orchestration/package-context.d.ts +134 -0
  51. package/dist/tools/orchestration/package-context.d.ts.map +1 -0
  52. package/dist/tools/orchestration/package-context.js +261 -0
  53. package/dist/tools/orchestration/package-context.js.map +1 -0
  54. package/package.json +4 -4
  55. package/dist/server.d.ts +0 -11
  56. package/dist/server.d.ts.map +0 -1
  57. package/dist/server.js +0 -3177
  58. package/dist/server.js.map +0 -1
  59. package/dist/tools/detail/dna-check.d.ts +0 -32
  60. package/dist/tools/detail/dna-check.d.ts.map +0 -1
  61. package/dist/tools/detail/dna-check.js +0 -231
  62. package/dist/tools/detail/dna-check.js.map +0 -1
  63. package/dist/tools/exploration/files-list.d.ts +0 -29
  64. package/dist/tools/exploration/files-list.d.ts.map +0 -1
  65. package/dist/tools/exploration/files-list.js +0 -94
  66. package/dist/tools/exploration/files-list.js.map +0 -1
@@ -1 +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,EA0DrC,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"}
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;AAG/D,eAAO,MAAM,mBAAmB,EAAE,IAAI,EA2DrC,CAAC;AAGF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,YAAY,EACV,UAAU,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,QAAQ,EACR,OAAO,EACP,UAAU,EACV,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC"}
@@ -4,6 +4,7 @@
4
4
  * Meta-layer tools that understand intent and synthesize context from multiple sources.
5
5
  * These are the "smart" tools that reduce cognitive load on the AI.
6
6
  */
7
+ import { packageContextToolDefinition } from './package-context.js';
7
8
  export const ORCHESTRATION_TOOLS = [
8
9
  {
9
10
  name: 'drift_context',
@@ -62,7 +63,9 @@ EXAMPLE:
62
63
  required: ['intent', 'focus'],
63
64
  },
64
65
  },
66
+ packageContextToolDefinition,
65
67
  ];
66
68
  // Handler export
67
69
  export { handleContext } from './context.js';
70
+ export { handlePackageContext } from './package-context.js';
68
71
  //# sourceMappingURL=index.js.map
@@ -1 +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,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I,EAAE,QAAQ;oBACd,WAAW,EAAE,qIAAqI;iBACnJ;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,kFAAkF;iBAChG;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qHAAqH;iBACnI;aACF;YACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;SAC9B;KACF;IACD,4BAAoC;CACrC,CAAC;AAEF,iBAAiB;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * drift_package_context - Package-Scoped AI Context Generation
3
+ *
4
+ * @license Apache-2.0
5
+ *
6
+ * Generates AI-optimized context for specific packages in a monorepo.
7
+ * Minimizes token usage by scoping patterns, constraints, and examples
8
+ * to only what's relevant for the target package.
9
+ *
10
+ * This tool is essential for monorepo workflows where you want to:
11
+ * - Focus AI context on a specific package
12
+ * - Reduce token usage by excluding irrelevant patterns
13
+ * - Get package-specific guidance and constraints
14
+ */
15
+ import { type PackageContext } from 'driftdetect-core';
16
+ export interface PackageContextInput {
17
+ /** Package name or path to generate context for */
18
+ package?: string;
19
+ /** List all packages instead of generating context */
20
+ list?: boolean;
21
+ /** Include code snippets in context */
22
+ includeSnippets?: boolean;
23
+ /** Include internal dependency patterns */
24
+ includeDependencies?: boolean;
25
+ /** Categories to include (empty = all) */
26
+ categories?: string[];
27
+ /** Minimum pattern confidence (0.0-1.0) */
28
+ minConfidence?: number;
29
+ /** Maximum tokens for context */
30
+ maxTokens?: number;
31
+ /** Output format: json, ai */
32
+ format?: 'json' | 'ai';
33
+ /** Optional: Target a specific registered project */
34
+ project?: string;
35
+ }
36
+ export interface PackageListResult {
37
+ isMonorepo: boolean;
38
+ packageManager: string;
39
+ workspaceConfig?: string;
40
+ packages: Array<{
41
+ name: string;
42
+ path: string;
43
+ language: string;
44
+ isRoot: boolean;
45
+ description?: string;
46
+ internalDependencies: string[];
47
+ }>;
48
+ }
49
+ export interface PackageContextOutput {
50
+ /** Summary of the context */
51
+ summary: string;
52
+ /** Package information */
53
+ package?: {
54
+ name: string;
55
+ path: string;
56
+ language: string;
57
+ description?: string;
58
+ };
59
+ /** Statistics */
60
+ stats?: {
61
+ patterns: number;
62
+ constraints: number;
63
+ entryPoints: number;
64
+ dataAccessors: number;
65
+ estimatedTokens: number;
66
+ };
67
+ /** Full context (for json format) */
68
+ context?: PackageContext;
69
+ /** AI-formatted context (for ai format) */
70
+ aiContext?: string;
71
+ /** Package list (for list mode) */
72
+ packages?: PackageListResult;
73
+ /** Warnings */
74
+ warnings: string[];
75
+ /** Project context if using multi-project */
76
+ projectContext?: Record<string, unknown>;
77
+ }
78
+ export declare function handlePackageContext(projectRoot: string, args: PackageContextInput): Promise<{
79
+ content: Array<{
80
+ type: string;
81
+ text: string;
82
+ }>;
83
+ }>;
84
+ export declare const packageContextToolDefinition: {
85
+ name: string;
86
+ description: string;
87
+ inputSchema: {
88
+ type: "object";
89
+ properties: {
90
+ package: {
91
+ type: string;
92
+ description: string;
93
+ };
94
+ list: {
95
+ type: string;
96
+ description: string;
97
+ };
98
+ includeSnippets: {
99
+ type: string;
100
+ description: string;
101
+ };
102
+ includeDependencies: {
103
+ type: string;
104
+ description: string;
105
+ };
106
+ categories: {
107
+ type: string;
108
+ items: {
109
+ type: string;
110
+ };
111
+ description: string;
112
+ };
113
+ minConfidence: {
114
+ type: string;
115
+ description: string;
116
+ };
117
+ maxTokens: {
118
+ type: string;
119
+ description: string;
120
+ };
121
+ format: {
122
+ type: string;
123
+ enum: string[];
124
+ description: string;
125
+ };
126
+ project: {
127
+ type: string;
128
+ description: string;
129
+ };
130
+ };
131
+ required: never[];
132
+ };
133
+ };
134
+ //# sourceMappingURL=package-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-context.d.ts","sourceRoot":"","s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MAAM,CAAC;KACtB,CAAC;IACF,iBAAiB;IACjB,KAAK,CAAC,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,qCAAqC;IACrC,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,eAAe;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C;AAMD,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAwB7D;AAmMD,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DxC,CAAC"}
@@ -0,0 +1,261 @@
1
+ /**
2
+ * drift_package_context - Package-Scoped AI Context Generation
3
+ *
4
+ * @license Apache-2.0
5
+ *
6
+ * Generates AI-optimized context for specific packages in a monorepo.
7
+ * Minimizes token usage by scoping patterns, constraints, and examples
8
+ * to only what's relevant for the target package.
9
+ *
10
+ * This tool is essential for monorepo workflows where you want to:
11
+ * - Focus AI context on a specific package
12
+ * - Reduce token usage by excluding irrelevant patterns
13
+ * - Get package-specific guidance and constraints
14
+ */
15
+ import { createPackageDetector, createPackageContextGenerator, } from 'driftdetect-core';
16
+ import { createResponseBuilder, resolveProject, formatProjectContext } from '../../infrastructure/index.js';
17
+ // =============================================================================
18
+ // Handler
19
+ // =============================================================================
20
+ export async function handlePackageContext(projectRoot, args) {
21
+ const builder = createResponseBuilder();
22
+ // Resolve project - allows targeting different registered projects
23
+ const resolution = await resolveProject(args.project, projectRoot);
24
+ const effectiveRoot = resolution.projectRoot;
25
+ // List mode
26
+ if (args.list) {
27
+ return handleListPackages(effectiveRoot, resolution, builder);
28
+ }
29
+ // Context generation mode - requires package
30
+ if (!args.package) {
31
+ return builder
32
+ .withSummary('Package name or path required. Use list=true to see available packages.')
33
+ .withData({
34
+ summary: 'Package name or path required',
35
+ warnings: ['Use list=true to see available packages, then specify a package name'],
36
+ })
37
+ .buildContent();
38
+ }
39
+ return handleGenerateContext(effectiveRoot, args, resolution, builder);
40
+ }
41
+ /**
42
+ * List all packages in the monorepo
43
+ */
44
+ async function handleListPackages(projectRoot, resolution, builder) {
45
+ const detector = createPackageDetector(projectRoot);
46
+ const structure = await detector.detect();
47
+ const packages = {
48
+ isMonorepo: structure.isMonorepo,
49
+ packageManager: structure.packageManager,
50
+ ...(structure.workspaceConfig && { workspaceConfig: structure.workspaceConfig }),
51
+ packages: structure.packages.map((pkg) => ({
52
+ name: pkg.name,
53
+ path: pkg.path,
54
+ language: pkg.language,
55
+ isRoot: pkg.isRoot,
56
+ ...(pkg.description && { description: pkg.description }),
57
+ internalDependencies: pkg.internalDependencies,
58
+ })),
59
+ };
60
+ const summary = structure.isMonorepo
61
+ ? `Monorepo with ${structure.packages.length} packages (${structure.packageManager})`
62
+ : `Single package project (${structure.packageManager})`;
63
+ const projectContext = formatProjectContext(resolution);
64
+ return builder
65
+ .withSummary(summary)
66
+ .withData({
67
+ summary,
68
+ packages,
69
+ warnings: [],
70
+ projectContext,
71
+ })
72
+ .withHints({
73
+ nextActions: structure.packages.slice(0, 3).map((p) => `drift_package_context package="${p.name}" to get context for ${p.name}`),
74
+ relatedTools: ['drift_context', 'drift_status'],
75
+ })
76
+ .buildContent();
77
+ }
78
+ /**
79
+ * Generate context for a specific package
80
+ */
81
+ async function handleGenerateContext(projectRoot, args, resolution, builder) {
82
+ const generator = createPackageContextGenerator(projectRoot);
83
+ const options = {
84
+ package: args.package,
85
+ ...(args.includeSnippets !== undefined && { includeSnippets: args.includeSnippets }),
86
+ ...(args.includeDependencies !== undefined && { includeDependencies: args.includeDependencies }),
87
+ ...(args.includeDependencies !== undefined && { includeInternalDeps: args.includeDependencies }),
88
+ ...(args.categories && { categories: args.categories }),
89
+ ...(args.minConfidence !== undefined && { minConfidence: args.minConfidence }),
90
+ ...(args.maxTokens !== undefined && { maxTokens: args.maxTokens }),
91
+ };
92
+ // Generate based on format
93
+ if (args.format === 'ai') {
94
+ const aiContext = await generator.generateAIContext(options);
95
+ if (aiContext.combined.startsWith('Error:')) {
96
+ return builder
97
+ .withSummary(`Error generating context: ${aiContext.combined}`)
98
+ .withData({
99
+ summary: aiContext.combined,
100
+ warnings: [],
101
+ })
102
+ .buildContent();
103
+ }
104
+ const summary = `AI context for ${args.package} (~${aiContext.tokens.total} tokens)`;
105
+ const projectContext = formatProjectContext(resolution);
106
+ return builder
107
+ .withSummary(summary)
108
+ .withData({
109
+ summary,
110
+ aiContext: aiContext.combined,
111
+ stats: {
112
+ patterns: 0, // Not available in AI format
113
+ constraints: 0,
114
+ entryPoints: 0,
115
+ dataAccessors: 0,
116
+ estimatedTokens: aiContext.tokens.total,
117
+ },
118
+ warnings: [],
119
+ projectContext,
120
+ })
121
+ .withHints({
122
+ nextActions: [
123
+ 'Use the aiContext field directly in your system prompt',
124
+ 'drift_code_examples for more detailed examples',
125
+ ],
126
+ relatedTools: ['drift_context', 'drift_code_examples'],
127
+ })
128
+ .buildContent();
129
+ }
130
+ // JSON format (default)
131
+ const result = await generator.generate(options);
132
+ if (!result.success || !result.context) {
133
+ return builder
134
+ .withSummary(`Error: ${result.error}`)
135
+ .withData({
136
+ summary: result.error || 'Unknown error',
137
+ warnings: result.warnings,
138
+ })
139
+ .buildContent();
140
+ }
141
+ const ctx = result.context;
142
+ const summary = buildSummary(ctx, result.warnings);
143
+ const projectContext = formatProjectContext(resolution);
144
+ return builder
145
+ .withSummary(summary)
146
+ .withData({
147
+ summary,
148
+ package: ctx.package,
149
+ stats: {
150
+ patterns: ctx.summary.totalPatterns,
151
+ constraints: ctx.summary.totalConstraints,
152
+ entryPoints: ctx.summary.totalEntryPoints,
153
+ dataAccessors: ctx.summary.totalDataAccessors,
154
+ estimatedTokens: ctx.summary.estimatedTokens,
155
+ },
156
+ context: ctx,
157
+ warnings: result.warnings,
158
+ projectContext,
159
+ })
160
+ .withHints({
161
+ nextActions: generateNextActions(ctx),
162
+ relatedTools: ['drift_context', 'drift_code_examples', 'drift_file_patterns'],
163
+ })
164
+ .buildContent();
165
+ }
166
+ /**
167
+ * Build summary string
168
+ */
169
+ function buildSummary(ctx, warnings) {
170
+ let summary = `Context for ${ctx.package.name} (${ctx.package.language}): `;
171
+ summary += `${ctx.summary.totalPatterns} patterns, `;
172
+ summary += `${ctx.summary.totalConstraints} constraints, `;
173
+ summary += `${ctx.summary.totalEntryPoints} entry points. `;
174
+ summary += `~${ctx.summary.estimatedTokens} tokens.`;
175
+ if (warnings.length > 0) {
176
+ summary += ` ⚠️ ${warnings.length} warning(s).`;
177
+ }
178
+ return summary;
179
+ }
180
+ /**
181
+ * Generate next action suggestions
182
+ */
183
+ function generateNextActions(ctx) {
184
+ const actions = [];
185
+ if (ctx.patterns.length > 0) {
186
+ actions.push(`drift_code_examples pattern="${ctx.patterns[0]?.id}" for more examples`);
187
+ }
188
+ if (ctx.keyFiles.length > 0) {
189
+ actions.push(`drift_file_patterns file="${ctx.keyFiles[0]?.file}" for file details`);
190
+ }
191
+ if (ctx.entryPoints.length > 0) {
192
+ actions.push(`drift_impact_analysis target="${ctx.entryPoints[0]?.file}" for impact analysis`);
193
+ }
194
+ return actions;
195
+ }
196
+ // =============================================================================
197
+ // Tool Definition
198
+ // =============================================================================
199
+ export const packageContextToolDefinition = {
200
+ name: 'drift_package_context',
201
+ description: `Generate AI-optimized context for a specific package in a monorepo.
202
+
203
+ This tool minimizes token usage by scoping patterns, constraints, and examples to only what's relevant for the target package.
204
+
205
+ Use cases:
206
+ - Focus AI context on a specific package in a monorepo
207
+ - Reduce token usage by excluding irrelevant patterns
208
+ - Get package-specific guidance and constraints
209
+ - List all packages in a monorepo
210
+
211
+ Examples:
212
+ - List packages: list=true
213
+ - Get context: package="@drift/core"
214
+ - AI format: package="@drift/core", format="ai"
215
+ - With snippets: package="@drift/core", includeSnippets=true`,
216
+ inputSchema: {
217
+ type: 'object',
218
+ properties: {
219
+ package: {
220
+ type: 'string',
221
+ description: 'Package name or path to generate context for',
222
+ },
223
+ list: {
224
+ type: 'boolean',
225
+ description: 'List all packages instead of generating context',
226
+ },
227
+ includeSnippets: {
228
+ type: 'boolean',
229
+ description: 'Include code snippets in context',
230
+ },
231
+ includeDependencies: {
232
+ type: 'boolean',
233
+ description: 'Include internal dependency patterns',
234
+ },
235
+ categories: {
236
+ type: 'array',
237
+ items: { type: 'string' },
238
+ description: 'Categories to include (empty = all)',
239
+ },
240
+ minConfidence: {
241
+ type: 'number',
242
+ description: 'Minimum pattern confidence (0.0-1.0)',
243
+ },
244
+ maxTokens: {
245
+ type: 'number',
246
+ description: 'Maximum tokens for context (default: 8000)',
247
+ },
248
+ format: {
249
+ type: 'string',
250
+ enum: ['json', 'ai'],
251
+ description: 'Output format: json (structured) or ai (markdown for prompts)',
252
+ },
253
+ project: {
254
+ type: 'string',
255
+ description: 'Optional: Target a specific registered project by name',
256
+ },
257
+ },
258
+ required: [],
259
+ },
260
+ };
261
+ //# sourceMappingURL=package-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-context.js","sourceRoot":"","sources":["../../../src/tools/orchestration/package-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,qBAAqB,EACrB,6BAA6B,GAG9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,E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;gBACb,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sCAAsC;aACpD;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4CAA4C;aAC1D;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC;gBACpB,WAAW,EAAE,+DAA+D;aAC7E;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wDAAwD;aACtE;SACF;QACD,QAAQ,EAAE,EAAE;KACb;CACF,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "driftdetect-mcp",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "description": "MCP server that gives AI agents (Claude, Cursor, Copilot) deep understanding of your codebase patterns, conventions, and architecture. Query patterns, security boundaries, call graphs in real-time.",
5
- "license": "MIT",
5
+ "license": "Apache-2.0",
6
6
  "author": "Geoffrey Fernald",
7
7
  "repository": {
8
8
  "type": "git",
@@ -48,8 +48,8 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "@modelcontextprotocol/sdk": "^1.0.0",
51
- "driftdetect-core": "0.7.1",
52
- "driftdetect-detectors": "0.7.1"
51
+ "driftdetect-core": "0.8.1",
52
+ "driftdetect-detectors": "0.8.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^20.10.0",
package/dist/server.d.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Drift MCP Server Implementation
3
- *
4
- * Provides structured access to drift functionality for AI agents.
5
- */
6
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
7
- export interface DriftMCPConfig {
8
- projectRoot: string;
9
- }
10
- export declare function createDriftMCPServer(config: DriftMCPConfig): Server;
11
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAsCnE,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB;AA8eD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAwLnE"}