driftdetect-mcp 0.6.1 → 0.7.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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/dist/bin/server.js +0 -0
  3. package/dist/enterprise-server.d.ts +1 -0
  4. package/dist/enterprise-server.d.ts.map +1 -1
  5. package/dist/enterprise-server.js +8 -1
  6. package/dist/enterprise-server.js.map +1 -1
  7. package/dist/tools/analysis/constants.d.ts +99 -0
  8. package/dist/tools/analysis/constants.d.ts.map +1 -0
  9. package/dist/tools/analysis/constants.js +421 -0
  10. package/dist/tools/analysis/constants.js.map +1 -0
  11. package/dist/tools/analysis/index.d.ts +1 -0
  12. package/dist/tools/analysis/index.d.ts.map +1 -1
  13. package/dist/tools/analysis/index.js +70 -0
  14. package/dist/tools/analysis/index.js.map +1 -1
  15. package/dist/tools/exploration/env.d.ts +53 -0
  16. package/dist/tools/exploration/env.d.ts.map +1 -0
  17. package/dist/tools/exploration/env.js +283 -0
  18. package/dist/tools/exploration/env.js.map +1 -0
  19. package/dist/tools/exploration/index.d.ts +2 -0
  20. package/dist/tools/exploration/index.d.ts.map +1 -1
  21. package/dist/tools/exploration/index.js +32 -0
  22. package/dist/tools/exploration/index.js.map +1 -1
  23. package/dist/tools/index.d.ts +6 -1
  24. package/dist/tools/index.d.ts.map +1 -1
  25. package/dist/tools/index.js +6 -1
  26. package/dist/tools/index.js.map +1 -1
  27. package/dist/tools/registry.d.ts +7 -5
  28. package/dist/tools/registry.d.ts.map +1 -1
  29. package/dist/tools/registry.js +10 -4
  30. package/dist/tools/registry.js.map +1 -1
  31. package/dist/tools/surgical/callers.d.ts +85 -0
  32. package/dist/tools/surgical/callers.d.ts.map +1 -0
  33. package/dist/tools/surgical/callers.js +239 -0
  34. package/dist/tools/surgical/callers.js.map +1 -0
  35. package/dist/tools/surgical/dependencies.d.ts +96 -0
  36. package/dist/tools/surgical/dependencies.d.ts.map +1 -0
  37. package/dist/tools/surgical/dependencies.js +433 -0
  38. package/dist/tools/surgical/dependencies.js.map +1 -0
  39. package/dist/tools/surgical/errors.d.ts +88 -0
  40. package/dist/tools/surgical/errors.d.ts.map +1 -0
  41. package/dist/tools/surgical/errors.js +275 -0
  42. package/dist/tools/surgical/errors.js.map +1 -0
  43. package/dist/tools/surgical/hooks.d.ts +69 -0
  44. package/dist/tools/surgical/hooks.d.ts.map +1 -0
  45. package/dist/tools/surgical/hooks.js +247 -0
  46. package/dist/tools/surgical/hooks.js.map +1 -0
  47. package/dist/tools/surgical/imports.d.ts +61 -0
  48. package/dist/tools/surgical/imports.d.ts.map +1 -0
  49. package/dist/tools/surgical/imports.js +211 -0
  50. package/dist/tools/surgical/imports.js.map +1 -0
  51. package/dist/tools/surgical/index.d.ts +42 -0
  52. package/dist/tools/surgical/index.d.ts.map +1 -0
  53. package/dist/tools/surgical/index.js +66 -0
  54. package/dist/tools/surgical/index.js.map +1 -0
  55. package/dist/tools/surgical/middleware.d.ts +69 -0
  56. package/dist/tools/surgical/middleware.d.ts.map +1 -0
  57. package/dist/tools/surgical/middleware.js +237 -0
  58. package/dist/tools/surgical/middleware.js.map +1 -0
  59. package/dist/tools/surgical/prevalidate.d.ts +76 -0
  60. package/dist/tools/surgical/prevalidate.d.ts.map +1 -0
  61. package/dist/tools/surgical/prevalidate.js +303 -0
  62. package/dist/tools/surgical/prevalidate.js.map +1 -0
  63. package/dist/tools/surgical/recent.d.ts +66 -0
  64. package/dist/tools/surgical/recent.d.ts.map +1 -0
  65. package/dist/tools/surgical/recent.js +238 -0
  66. package/dist/tools/surgical/recent.js.map +1 -0
  67. package/dist/tools/surgical/signature.d.ts +73 -0
  68. package/dist/tools/surgical/signature.d.ts.map +1 -0
  69. package/dist/tools/surgical/signature.js +190 -0
  70. package/dist/tools/surgical/signature.js.map +1 -0
  71. package/dist/tools/surgical/similar.d.ts +77 -0
  72. package/dist/tools/surgical/similar.d.ts.map +1 -0
  73. package/dist/tools/surgical/similar.js +285 -0
  74. package/dist/tools/surgical/similar.js.map +1 -0
  75. package/dist/tools/surgical/test-template.d.ts +70 -0
  76. package/dist/tools/surgical/test-template.d.ts.map +1 -0
  77. package/dist/tools/surgical/test-template.js +298 -0
  78. package/dist/tools/surgical/test-template.js.map +1 -0
  79. package/dist/tools/surgical/type.d.ts +69 -0
  80. package/dist/tools/surgical/type.d.ts.map +1 -0
  81. package/dist/tools/surgical/type.js +289 -0
  82. package/dist/tools/surgical/type.js.map +1 -0
  83. package/package.json +11 -11
@@ -1,13 +1,18 @@
1
1
  /**
2
2
  * Enterprise MCP Tools
3
3
  *
4
- * Tools organized into three layers:
4
+ * Tools organized into layers:
5
5
  * - Discovery: Lightweight status and capability tools
6
6
  * - Exploration: Paginated listing tools
7
7
  * - Detail: Focused single-item tools
8
+ * - Surgical: Ultra-focused, minimal-token tools for AI code generation
9
+ * - Analysis: Deep analysis tools (coupling, error handling, etc.)
10
+ * - Generation: Code generation and validation tools
11
+ * - Orchestration: Intent-aware context synthesis
8
12
  */
9
13
  export * from './discovery/index.js';
10
14
  export * from './exploration/index.js';
11
15
  export * from './detail/index.js';
16
+ export * from './surgical/index.js';
12
17
  export * from './registry.js';
13
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC"}
@@ -13,10 +13,11 @@ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
13
13
  * Order matters for AI discovery:
14
14
  * 1. Orchestration (recommended starting point)
15
15
  * 2. Discovery (quick health checks)
16
- * 3. Exploration (browsing/listing)
17
- * 4. Detail (deep inspection)
18
- * 5. Analysis (deeper analysis)
19
- * 6. Generation (AI-powered code intelligence)
16
+ * 3. Surgical (ultra-focused lookups for code generation)
17
+ * 4. Exploration (browsing/listing)
18
+ * 5. Detail (deep inspection)
19
+ * 6. Analysis (deeper analysis)
20
+ * 7. Generation (AI-powered code intelligence)
20
21
  */
21
22
  export declare const ALL_TOOLS: Tool[];
22
23
  /**
@@ -25,6 +26,7 @@ export declare const ALL_TOOLS: Tool[];
25
26
  export declare const TOOL_CATEGORIES: {
26
27
  orchestration: string[];
27
28
  discovery: string[];
29
+ surgical: string[];
28
30
  exploration: string[];
29
31
  detail: string[];
30
32
  analysis: string[];
@@ -41,5 +43,5 @@ export declare function hasTool(name: string): boolean;
41
43
  /**
42
44
  * Get tools by category
43
45
  */
44
- export declare function getToolsByCategory(category: 'orchestration' | 'discovery' | 'exploration' | 'detail' | 'analysis' | 'generation'): Tool[];
46
+ export declare function getToolsByCategory(category: 'orchestration' | 'discovery' | 'surgical' | 'exploration' | 'detail' | 'analysis' | 'generation'): Tool[];
45
47
  //# sourceMappingURL=registry.d.ts.map
@@ -1 +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;AAQ/D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,EAAE,IAAI,EAO3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;CAO3B,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,UAAU,GAAG,YAAY,GAAG,IAAI,EAAE,CAezI"}
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;AAS/D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,EAAE,IAAI,EAQ3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;CAQ3B,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,UAAU,GAAG,aAAa,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,IAAI,EAAE,CAiBtJ"}
@@ -9,6 +9,7 @@
9
9
  import { DISCOVERY_TOOLS } from './discovery/index.js';
10
10
  import { EXPLORATION_TOOLS } from './exploration/index.js';
11
11
  import { DETAIL_TOOLS } from './detail/index.js';
12
+ import { SURGICAL_TOOLS } from './surgical/index.js';
12
13
  import { ORCHESTRATION_TOOLS } from './orchestration/index.js';
13
14
  import { ANALYSIS_TOOLS } from './analysis/index.js';
14
15
  import { GENERATION_TOOLS } from './generation/index.js';
@@ -18,14 +19,16 @@ import { GENERATION_TOOLS } from './generation/index.js';
18
19
  * Order matters for AI discovery:
19
20
  * 1. Orchestration (recommended starting point)
20
21
  * 2. Discovery (quick health checks)
21
- * 3. Exploration (browsing/listing)
22
- * 4. Detail (deep inspection)
23
- * 5. Analysis (deeper analysis)
24
- * 6. Generation (AI-powered code intelligence)
22
+ * 3. Surgical (ultra-focused lookups for code generation)
23
+ * 4. Exploration (browsing/listing)
24
+ * 5. Detail (deep inspection)
25
+ * 6. Analysis (deeper analysis)
26
+ * 7. Generation (AI-powered code intelligence)
25
27
  */
26
28
  export const ALL_TOOLS = [
27
29
  ...ORCHESTRATION_TOOLS, // Start here
28
30
  ...DISCOVERY_TOOLS,
31
+ ...SURGICAL_TOOLS, // Quick lookups for AI
29
32
  ...EXPLORATION_TOOLS,
30
33
  ...DETAIL_TOOLS,
31
34
  ...ANALYSIS_TOOLS,
@@ -37,6 +40,7 @@ export const ALL_TOOLS = [
37
40
  export const TOOL_CATEGORIES = {
38
41
  orchestration: ORCHESTRATION_TOOLS.map(t => t.name),
39
42
  discovery: DISCOVERY_TOOLS.map(t => t.name),
43
+ surgical: SURGICAL_TOOLS.map(t => t.name),
40
44
  exploration: EXPLORATION_TOOLS.map(t => t.name),
41
45
  detail: DETAIL_TOOLS.map(t => t.name),
42
46
  analysis: ANALYSIS_TOOLS.map(t => t.name),
@@ -63,6 +67,8 @@ export function getToolsByCategory(category) {
63
67
  return ORCHESTRATION_TOOLS;
64
68
  case 'discovery':
65
69
  return DISCOVERY_TOOLS;
70
+ case 'surgical':
71
+ return SURGICAL_TOOLS;
66
72
  case 'exploration':
67
73
  return EXPLORATION_TOOLS;
68
74
  case 'detail':
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,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AAgB,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * drift_callers - Lightweight Caller Lookup
3
+ *
4
+ * Layer: Surgical
5
+ * Token Budget: 300 target, 800 max
6
+ * Cache TTL: 5 minutes
7
+ * Invalidation Keys: callgraph
8
+ *
9
+ * Returns who calls a function without full impact analysis.
10
+ * Solves: AI needs to know impact of changing a function quickly.
11
+ */
12
+ import type { CallGraphStore } from 'driftdetect-core';
13
+ export interface CallersArgs {
14
+ /** Function name to look up */
15
+ function: string;
16
+ /** Optional: specific file containing the function */
17
+ file?: string;
18
+ /** Include indirect callers? (default: false) */
19
+ transitive?: boolean;
20
+ /** Max depth for transitive (default: 2) */
21
+ maxDepth?: number;
22
+ }
23
+ export interface CallerInfo {
24
+ function: string;
25
+ file: string;
26
+ line: number;
27
+ callSite: number;
28
+ }
29
+ export interface TransitiveCaller {
30
+ function: string;
31
+ file: string;
32
+ depth: number;
33
+ path: string[];
34
+ }
35
+ export interface CallersData {
36
+ target: {
37
+ function: string;
38
+ file: string;
39
+ line: number;
40
+ };
41
+ directCallers: CallerInfo[];
42
+ transitiveCallers?: TransitiveCaller[] | undefined;
43
+ stats: {
44
+ directCount: number;
45
+ transitiveCount?: number | undefined;
46
+ isPublicApi: boolean;
47
+ isWidelyUsed: boolean;
48
+ };
49
+ }
50
+ export declare function handleCallers(store: CallGraphStore, args: CallersArgs): Promise<{
51
+ content: Array<{
52
+ type: string;
53
+ text: string;
54
+ }>;
55
+ }>;
56
+ /**
57
+ * Tool definition for MCP registration
58
+ */
59
+ export declare const callersToolDefinition: {
60
+ name: string;
61
+ description: string;
62
+ inputSchema: {
63
+ type: "object";
64
+ properties: {
65
+ function: {
66
+ type: string;
67
+ description: string;
68
+ };
69
+ file: {
70
+ type: string;
71
+ description: string;
72
+ };
73
+ transitive: {
74
+ type: string;
75
+ description: string;
76
+ };
77
+ maxDepth: {
78
+ type: string;
79
+ description: string;
80
+ };
81
+ };
82
+ required: string[];
83
+ };
84
+ };
85
+ //# sourceMappingURL=callers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callers.d.ts","sourceRoot":"","sources":["../../../src/tools/surgical/callers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAgB,MAAM,kBAAkB,CAAC;AAOrE,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,aAAa,EAAE,UAAU,EAAE,CAAC;IAC5B,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,GAAG,SAAS,CAAC;IACnD,KAAK,EAAE;QACL,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACrC,WAAW,EAAE,OAAO,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH;AAMD,wBAAsB,aAAa,CACjC,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAsI7D;AAuGD;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBjC,CAAC"}
@@ -0,0 +1,239 @@
1
+ /**
2
+ * drift_callers - Lightweight Caller Lookup
3
+ *
4
+ * Layer: Surgical
5
+ * Token Budget: 300 target, 800 max
6
+ * Cache TTL: 5 minutes
7
+ * Invalidation Keys: callgraph
8
+ *
9
+ * Returns who calls a function without full impact analysis.
10
+ * Solves: AI needs to know impact of changing a function quickly.
11
+ */
12
+ import { createResponseBuilder, Errors, metrics } from '../../infrastructure/index.js';
13
+ // ============================================================================
14
+ // Handler
15
+ // ============================================================================
16
+ export async function handleCallers(store, args) {
17
+ const startTime = Date.now();
18
+ const builder = createResponseBuilder();
19
+ // Validate input
20
+ if (!args.function || args.function.trim() === '') {
21
+ throw Errors.missingParameter('function');
22
+ }
23
+ const funcName = args.function.trim();
24
+ const includeTransitive = args.transitive === true;
25
+ const maxDepth = args.maxDepth ?? 2;
26
+ // Load call graph
27
+ await store.initialize();
28
+ const graph = store.getGraph();
29
+ if (!graph) {
30
+ throw Errors.custom('CALLGRAPH_NOT_BUILT', 'Call graph has not been built. Run "drift callgraph build" first.', ['drift_status']);
31
+ }
32
+ // Find the target function
33
+ let targetFunc = null;
34
+ for (const [, func] of graph.functions) {
35
+ const nameMatch = func.name === funcName ||
36
+ func.qualifiedName === funcName ||
37
+ func.qualifiedName.endsWith(`.${funcName}`);
38
+ const fileMatch = !args.file ||
39
+ func.file === args.file ||
40
+ func.file.endsWith(args.file);
41
+ if (nameMatch && fileMatch) {
42
+ targetFunc = func;
43
+ break;
44
+ }
45
+ }
46
+ if (!targetFunc) {
47
+ throw Errors.notFound('function', funcName);
48
+ }
49
+ // Get direct callers
50
+ const directCallers = targetFunc.calledBy.map(call => {
51
+ const callerFunc = graph.functions.get(call.callerId);
52
+ return {
53
+ function: callerFunc?.name ?? call.callerId,
54
+ file: call.file,
55
+ line: callerFunc?.startLine ?? call.line,
56
+ callSite: call.line,
57
+ };
58
+ });
59
+ // Sort by file then line
60
+ directCallers.sort((a, b) => {
61
+ const fileCompare = a.file.localeCompare(b.file);
62
+ if (fileCompare !== 0)
63
+ return fileCompare;
64
+ return a.callSite - b.callSite;
65
+ });
66
+ // Limit direct callers
67
+ const limitedDirectCallers = directCallers.slice(0, 10);
68
+ // Get transitive callers if requested
69
+ let transitiveCallers;
70
+ if (includeTransitive) {
71
+ transitiveCallers = findTransitiveCallers(graph, targetFunc.id, maxDepth);
72
+ }
73
+ // Check if this is a public API (called from entry points)
74
+ const isPublicApi = graph.entryPoints.some(ep => {
75
+ const entryFunc = graph.functions.get(ep);
76
+ if (!entryFunc)
77
+ return false;
78
+ return canReach(graph, ep, targetFunc.id, 5);
79
+ });
80
+ const data = {
81
+ target: {
82
+ function: targetFunc.name,
83
+ file: targetFunc.file,
84
+ line: targetFunc.startLine,
85
+ },
86
+ directCallers: limitedDirectCallers,
87
+ transitiveCallers,
88
+ stats: {
89
+ directCount: directCallers.length,
90
+ ...(transitiveCallers ? { transitiveCount: transitiveCallers.length } : {}),
91
+ isPublicApi,
92
+ isWidelyUsed: directCallers.length > 5,
93
+ },
94
+ };
95
+ // Build summary
96
+ let summary = `"${targetFunc.name}" has ${directCallers.length} direct caller${directCallers.length !== 1 ? 's' : ''}`;
97
+ if (transitiveCallers) {
98
+ summary += `, ${transitiveCallers.length} transitive`;
99
+ }
100
+ if (isPublicApi) {
101
+ summary += ' (public API)';
102
+ }
103
+ // Build hints
104
+ const hints = {
105
+ nextActions: [
106
+ directCallers.length > 0
107
+ ? `Review callers before modifying "${targetFunc.name}"`
108
+ : `"${targetFunc.name}" appears unused - safe to modify`,
109
+ 'Use drift_impact_analysis for full blast radius',
110
+ ],
111
+ relatedTools: ['drift_impact_analysis', 'drift_signature', 'drift_reachability'],
112
+ };
113
+ if (data.stats.isWidelyUsed) {
114
+ hints.warnings = ['Widely used function - changes may have broad impact'];
115
+ }
116
+ if (directCallers.length > 10) {
117
+ hints.warnings = hints.warnings ?? [];
118
+ hints.warnings.push(`${directCallers.length - 10} additional callers not shown`);
119
+ }
120
+ // Record metrics
121
+ metrics.recordRequest('drift_callers', Date.now() - startTime, true, false);
122
+ return builder
123
+ .withSummary(summary)
124
+ .withData(data)
125
+ .withHints(hints)
126
+ .buildContent();
127
+ }
128
+ // ============================================================================
129
+ // Helpers
130
+ // ============================================================================
131
+ /**
132
+ * Find transitive callers using BFS
133
+ */
134
+ function findTransitiveCallers(graph, targetId, maxDepth) {
135
+ const result = [];
136
+ const visited = new Set([targetId]);
137
+ const queue = [];
138
+ // Start with direct callers
139
+ const targetFunc = graph.functions.get(targetId);
140
+ if (!targetFunc)
141
+ return result;
142
+ for (const call of targetFunc.calledBy) {
143
+ if (!visited.has(call.callerId)) {
144
+ visited.add(call.callerId);
145
+ queue.push({
146
+ id: call.callerId,
147
+ depth: 1,
148
+ path: [targetFunc.name],
149
+ });
150
+ }
151
+ }
152
+ // BFS up the call tree
153
+ while (queue.length > 0) {
154
+ const current = queue.shift();
155
+ const func = graph.functions.get(current.id);
156
+ if (!func)
157
+ continue;
158
+ // Add to result if depth > 1 (direct callers handled separately)
159
+ if (current.depth > 1) {
160
+ result.push({
161
+ function: func.name,
162
+ file: func.file,
163
+ depth: current.depth,
164
+ path: [...current.path, func.name],
165
+ });
166
+ }
167
+ // Continue BFS if not at max depth
168
+ if (current.depth < maxDepth) {
169
+ for (const call of func.calledBy) {
170
+ if (!visited.has(call.callerId)) {
171
+ visited.add(call.callerId);
172
+ queue.push({
173
+ id: call.callerId,
174
+ depth: current.depth + 1,
175
+ path: [...current.path, func.name],
176
+ });
177
+ }
178
+ }
179
+ }
180
+ }
181
+ // Limit results
182
+ return result.slice(0, 20);
183
+ }
184
+ /**
185
+ * Check if one function can reach another (simple DFS)
186
+ */
187
+ function canReach(graph, fromId, toId, maxDepth) {
188
+ const visited = new Set();
189
+ const stack = [{ id: fromId, depth: 0 }];
190
+ while (stack.length > 0) {
191
+ const current = stack.pop();
192
+ if (current.id === toId)
193
+ return true;
194
+ if (current.depth >= maxDepth)
195
+ continue;
196
+ if (visited.has(current.id))
197
+ continue;
198
+ visited.add(current.id);
199
+ const func = graph.functions.get(current.id);
200
+ if (!func)
201
+ continue;
202
+ for (const call of func.calls) {
203
+ if (call.calleeId && !visited.has(call.calleeId)) {
204
+ stack.push({ id: call.calleeId, depth: current.depth + 1 });
205
+ }
206
+ }
207
+ }
208
+ return false;
209
+ }
210
+ /**
211
+ * Tool definition for MCP registration
212
+ */
213
+ export const callersToolDefinition = {
214
+ name: 'drift_callers',
215
+ description: 'Lightweight "who calls this function" lookup. Returns direct callers and optionally transitive callers. Much faster than full impact analysis.',
216
+ inputSchema: {
217
+ type: 'object',
218
+ properties: {
219
+ function: {
220
+ type: 'string',
221
+ description: 'Function name to look up',
222
+ },
223
+ file: {
224
+ type: 'string',
225
+ description: 'Optional: specific file containing the function',
226
+ },
227
+ transitive: {
228
+ type: 'boolean',
229
+ description: 'Include indirect callers (default: false)',
230
+ },
231
+ maxDepth: {
232
+ type: 'number',
233
+ description: 'Max depth for transitive callers (default: 2)',
234
+ },
235
+ },
236
+ required: ['function'],
237
+ },
238
+ };
239
+ //# sourceMappingURL=callers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callers.js","sourceRoot":"","sources":["../../../src/tools/surgical/callers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AA+CvF,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAqB,EACrB,IAAiB;IAEjB,MAAM,SAAS,GAAG,IAAI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AAC,EAAE,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,gJAAgJ;IAC7J,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0BAA0B;aACxC;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iDAAiD;aAC/D;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,2CAA2C;aACzD;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,+CAA+C;aAC7D;SACF;QACD,QAAQ,EAAE,CAAC,UAAU,CAAC;KACvB;CACF,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * drift_dependencies - Package Dependencies Lookup
3
+ *
4
+ * Layer: Surgical
5
+ * Token Budget: 300 target, 800 max
6
+ *
7
+ * Returns package dependencies and their versions across all supported languages.
8
+ * Solves: AI needs to know installed packages before suggesting imports.
9
+ *
10
+ * Supported:
11
+ * - JavaScript/TypeScript: package.json
12
+ * - Python: requirements.txt, pyproject.toml
13
+ * - Java: pom.xml, build.gradle
14
+ * - PHP: composer.json
15
+ * - C#: *.csproj
16
+ * - Go: go.mod
17
+ */
18
+ export type DependencyLanguage = 'javascript' | 'python' | 'java' | 'php' | 'csharp' | 'go';
19
+ export interface DependenciesArgs {
20
+ /** Search for specific package */
21
+ search?: string;
22
+ /** Filter: prod, dev, peer, all */
23
+ type?: 'prod' | 'dev' | 'peer' | 'all';
24
+ /** Category filter: framework, testing, utility, database, ui, all */
25
+ category?: 'framework' | 'testing' | 'utility' | 'database' | 'ui' | 'all';
26
+ /** Language filter */
27
+ language?: DependencyLanguage | 'all';
28
+ /** Max results */
29
+ limit?: number;
30
+ }
31
+ export interface DependencyInfo {
32
+ name: string;
33
+ version: string;
34
+ type: 'prod' | 'dev' | 'peer';
35
+ category: string;
36
+ language: DependencyLanguage;
37
+ source: string;
38
+ }
39
+ export interface DependenciesData {
40
+ dependencies: DependencyInfo[];
41
+ byCategory: Record<string, number>;
42
+ byLanguage: Record<string, number>;
43
+ byType: {
44
+ prod: number;
45
+ dev: number;
46
+ peer: number;
47
+ };
48
+ stats: {
49
+ total: number;
50
+ languages: DependencyLanguage[];
51
+ frameworks: string[];
52
+ testingLibs: string[];
53
+ };
54
+ }
55
+ export declare function handleDependencies(args: DependenciesArgs, rootDir: string): Promise<{
56
+ content: Array<{
57
+ type: string;
58
+ text: string;
59
+ }>;
60
+ }>;
61
+ /**
62
+ * Tool definition for MCP registration
63
+ */
64
+ export declare const dependenciesToolDefinition: {
65
+ name: string;
66
+ description: string;
67
+ inputSchema: {
68
+ type: "object";
69
+ properties: {
70
+ search: {
71
+ type: string;
72
+ description: string;
73
+ };
74
+ type: {
75
+ type: string;
76
+ enum: string[];
77
+ description: string;
78
+ };
79
+ category: {
80
+ type: string;
81
+ enum: string[];
82
+ description: string;
83
+ };
84
+ language: {
85
+ type: string;
86
+ enum: string[];
87
+ description: string;
88
+ };
89
+ limit: {
90
+ type: string;
91
+ description: string;
92
+ };
93
+ };
94
+ };
95
+ };
96
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../src/tools/surgical/dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,IAAI,CAAC;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