driftdetect-mcp 0.4.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/bin/server.d.ts +12 -2
- package/dist/bin/server.d.ts.map +1 -1
- package/dist/bin/server.js +25 -5
- package/dist/bin/server.js.map +1 -1
- package/dist/enterprise-server.d.ts +78 -0
- package/dist/enterprise-server.d.ts.map +1 -0
- package/dist/enterprise-server.js +201 -0
- package/dist/enterprise-server.js.map +1 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/cache.d.ts +86 -0
- package/dist/infrastructure/cache.d.ts.map +1 -0
- package/dist/infrastructure/cache.js +271 -0
- package/dist/infrastructure/cache.js.map +1 -0
- package/dist/infrastructure/cursor-manager.d.ts +86 -0
- package/dist/infrastructure/cursor-manager.d.ts.map +1 -0
- package/dist/infrastructure/cursor-manager.js +175 -0
- package/dist/infrastructure/cursor-manager.js.map +1 -0
- package/dist/infrastructure/error-handler.d.ts +82 -0
- package/dist/infrastructure/error-handler.d.ts.map +1 -0
- package/dist/infrastructure/error-handler.js +226 -0
- package/dist/infrastructure/error-handler.js.map +1 -0
- package/dist/infrastructure/index.d.ts +19 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +26 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/metrics.d.ts +104 -0
- package/dist/infrastructure/metrics.d.ts.map +1 -0
- package/dist/infrastructure/metrics.js +291 -0
- package/dist/infrastructure/metrics.js.map +1 -0
- package/dist/infrastructure/rate-limiter.d.ts +59 -0
- package/dist/infrastructure/rate-limiter.d.ts.map +1 -0
- package/dist/infrastructure/rate-limiter.js +132 -0
- package/dist/infrastructure/rate-limiter.js.map +1 -0
- package/dist/infrastructure/response-builder.d.ts +104 -0
- package/dist/infrastructure/response-builder.d.ts.map +1 -0
- package/dist/infrastructure/response-builder.js +207 -0
- package/dist/infrastructure/response-builder.js.map +1 -0
- package/dist/infrastructure/token-estimator.d.ts +48 -0
- package/dist/infrastructure/token-estimator.d.ts.map +1 -0
- package/dist/infrastructure/token-estimator.js +131 -0
- package/dist/infrastructure/token-estimator.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1074 -17
- package/dist/server.js.map +1 -1
- package/dist/tools/detail/code-examples.d.ts +33 -0
- package/dist/tools/detail/code-examples.d.ts.map +1 -0
- package/dist/tools/detail/code-examples.js +126 -0
- package/dist/tools/detail/code-examples.js.map +1 -0
- package/dist/tools/detail/dna-check.d.ts +32 -0
- package/dist/tools/detail/dna-check.d.ts.map +1 -0
- package/dist/tools/detail/dna-check.js +231 -0
- package/dist/tools/detail/dna-check.js.map +1 -0
- package/dist/tools/detail/dna-profile.d.ts +37 -0
- package/dist/tools/detail/dna-profile.d.ts.map +1 -0
- package/dist/tools/detail/dna-profile.js +101 -0
- package/dist/tools/detail/dna-profile.js.map +1 -0
- package/dist/tools/detail/file-patterns.d.ts +39 -0
- package/dist/tools/detail/file-patterns.d.ts.map +1 -0
- package/dist/tools/detail/file-patterns.js +103 -0
- package/dist/tools/detail/file-patterns.js.map +1 -0
- package/dist/tools/detail/files-list.d.ts +30 -0
- package/dist/tools/detail/files-list.d.ts.map +1 -0
- package/dist/tools/detail/files-list.js +99 -0
- package/dist/tools/detail/files-list.js.map +1 -0
- package/dist/tools/detail/impact-analysis.d.ts +53 -0
- package/dist/tools/detail/impact-analysis.d.ts.map +1 -0
- package/dist/tools/detail/impact-analysis.js +130 -0
- package/dist/tools/detail/impact-analysis.js.map +1 -0
- package/dist/tools/detail/index.d.ts +23 -0
- package/dist/tools/detail/index.d.ts.map +1 -0
- package/dist/tools/detail/index.js +200 -0
- package/dist/tools/detail/index.js.map +1 -0
- package/dist/tools/detail/pattern-get.d.ts +45 -0
- package/dist/tools/detail/pattern-get.d.ts.map +1 -0
- package/dist/tools/detail/pattern-get.js +87 -0
- package/dist/tools/detail/pattern-get.js.map +1 -0
- package/dist/tools/detail/reachability.d.ts +60 -0
- package/dist/tools/detail/reachability.d.ts.map +1 -0
- package/dist/tools/detail/reachability.js +168 -0
- package/dist/tools/detail/reachability.js.map +1 -0
- package/dist/tools/discovery/capabilities.d.ts +28 -0
- package/dist/tools/discovery/capabilities.d.ts.map +1 -0
- package/dist/tools/discovery/capabilities.js +112 -0
- package/dist/tools/discovery/capabilities.js.map +1 -0
- package/dist/tools/discovery/index.d.ts +13 -0
- package/dist/tools/discovery/index.d.ts.map +1 -0
- package/dist/tools/discovery/index.js +30 -0
- package/dist/tools/discovery/index.js.map +1 -0
- package/dist/tools/discovery/projects.d.ts +26 -0
- package/dist/tools/discovery/projects.d.ts.map +1 -0
- package/dist/tools/discovery/projects.js +210 -0
- package/dist/tools/discovery/projects.js.map +1 -0
- package/dist/tools/discovery/status.d.ts +42 -0
- package/dist/tools/discovery/status.d.ts.map +1 -0
- package/dist/tools/discovery/status.js +157 -0
- package/dist/tools/discovery/status.js.map +1 -0
- package/dist/tools/exploration/contracts-list.d.ts +35 -0
- package/dist/tools/exploration/contracts-list.d.ts.map +1 -0
- package/dist/tools/exploration/contracts-list.js +106 -0
- package/dist/tools/exploration/contracts-list.js.map +1 -0
- package/dist/tools/exploration/files-list.d.ts +29 -0
- package/dist/tools/exploration/files-list.d.ts.map +1 -0
- package/dist/tools/exploration/files-list.js +94 -0
- package/dist/tools/exploration/files-list.js.map +1 -0
- package/dist/tools/exploration/index.d.ts +17 -0
- package/dist/tools/exploration/index.d.ts.map +1 -0
- package/dist/tools/exploration/index.js +126 -0
- package/dist/tools/exploration/index.js.map +1 -0
- package/dist/tools/exploration/patterns-list.d.ts +40 -0
- package/dist/tools/exploration/patterns-list.d.ts.map +1 -0
- package/dist/tools/exploration/patterns-list.js +172 -0
- package/dist/tools/exploration/patterns-list.js.map +1 -0
- package/dist/tools/exploration/security-summary.d.ts +49 -0
- package/dist/tools/exploration/security-summary.d.ts.map +1 -0
- package/dist/tools/exploration/security-summary.js +111 -0
- package/dist/tools/exploration/security-summary.js.map +1 -0
- package/dist/tools/exploration/trends.d.ts +49 -0
- package/dist/tools/exploration/trends.d.ts.map +1 -0
- package/dist/tools/exploration/trends.js +147 -0
- package/dist/tools/exploration/trends.js.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +13 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/orchestration/context.d.ts +72 -0
- package/dist/tools/orchestration/context.d.ts.map +1 -0
- package/dist/tools/orchestration/context.js +499 -0
- package/dist/tools/orchestration/context.js.map +1 -0
- package/dist/tools/orchestration/index.d.ts +11 -0
- package/dist/tools/orchestration/index.d.ts.map +1 -0
- package/dist/tools/orchestration/index.js +56 -0
- package/dist/tools/orchestration/index.js.map +1 -0
- package/dist/tools/registry.d.ts +41 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +64 -0
- package/dist/tools/registry.js.map +1 -0
- package/package.json +11 -11
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.d.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* Drift MCP Server Entry Point
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
|
-
* drift-mcp
|
|
7
|
-
* drift-mcp /path/to/project
|
|
6
|
+
* drift-mcp # Run server in current directory
|
|
7
|
+
* drift-mcp /path/to/project # Run for specific project
|
|
8
|
+
* drift-mcp --no-cache # Disable response caching
|
|
9
|
+
* drift-mcp --no-rate-limit # Disable rate limiting
|
|
8
10
|
*
|
|
9
11
|
* MCP Config (add to mcp.json):
|
|
10
12
|
* {
|
|
@@ -15,6 +17,14 @@
|
|
|
15
17
|
* }
|
|
16
18
|
* }
|
|
17
19
|
* }
|
|
20
|
+
*
|
|
21
|
+
* Features:
|
|
22
|
+
* - DataLake as central source of truth (pre-computed views, sharded storage)
|
|
23
|
+
* - Layered tool architecture (orchestration → discovery → exploration → detail)
|
|
24
|
+
* - Intent-aware context synthesis via drift_context
|
|
25
|
+
* - Token budget awareness and cursor-based pagination
|
|
26
|
+
* - Structured error handling with recovery hints
|
|
27
|
+
* - Response caching, rate limiting, and metrics
|
|
18
28
|
*/
|
|
19
29
|
export {};
|
|
20
30
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/bin/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/bin/server.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/bin/server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
|
package/dist/bin/server.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* Drift MCP Server Entry Point
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
|
-
* drift-mcp
|
|
7
|
-
* drift-mcp /path/to/project
|
|
6
|
+
* drift-mcp # Run server in current directory
|
|
7
|
+
* drift-mcp /path/to/project # Run for specific project
|
|
8
|
+
* drift-mcp --no-cache # Disable response caching
|
|
9
|
+
* drift-mcp --no-rate-limit # Disable rate limiting
|
|
8
10
|
*
|
|
9
11
|
* MCP Config (add to mcp.json):
|
|
10
12
|
* {
|
|
@@ -15,12 +17,30 @@
|
|
|
15
17
|
* }
|
|
16
18
|
* }
|
|
17
19
|
* }
|
|
20
|
+
*
|
|
21
|
+
* Features:
|
|
22
|
+
* - DataLake as central source of truth (pre-computed views, sharded storage)
|
|
23
|
+
* - Layered tool architecture (orchestration → discovery → exploration → detail)
|
|
24
|
+
* - Intent-aware context synthesis via drift_context
|
|
25
|
+
* - Token budget awareness and cursor-based pagination
|
|
26
|
+
* - Structured error handling with recovery hints
|
|
27
|
+
* - Response caching, rate limiting, and metrics
|
|
18
28
|
*/
|
|
19
29
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
20
|
-
import {
|
|
30
|
+
import { createEnterpriseMCPServer } from '../enterprise-server.js';
|
|
21
31
|
async function main() {
|
|
22
|
-
const
|
|
23
|
-
|
|
32
|
+
const args = process.argv.slice(2);
|
|
33
|
+
// Parse flags
|
|
34
|
+
const noCache = args.includes('--no-cache');
|
|
35
|
+
const noRateLimit = args.includes('--no-rate-limit');
|
|
36
|
+
// Get project root (first non-flag argument, or cwd)
|
|
37
|
+
const projectRoot = args.find(arg => !arg.startsWith('--')) ?? process.cwd();
|
|
38
|
+
const server = createEnterpriseMCPServer({
|
|
39
|
+
projectRoot,
|
|
40
|
+
enableCache: !noCache,
|
|
41
|
+
enableRateLimiting: !noRateLimit,
|
|
42
|
+
enableMetrics: true,
|
|
43
|
+
});
|
|
24
44
|
const transport = new StdioServerTransport();
|
|
25
45
|
await server.connect(transport);
|
|
26
46
|
// Handle graceful shutdown
|
package/dist/bin/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/bin/server.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/bin/server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,KAAK,UAAU,IAAI;IACjB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC,cAAc;IACd,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAErD,qDAAqD;IACrD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAE7E,MAAM,MAAM,GAAG,yBAAyB,CAAC;QACvC,WAAW;QACX,WAAW,EAAE,CAAC,OAAO;QACrB,kBAAkB,EAAE,CAAC,WAAW;QAChC,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,2BAA2B;IAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enterprise Drift MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Layered tool architecture following Block's pattern:
|
|
5
|
+
* - Discovery: Lightweight status and capability tools
|
|
6
|
+
* - Exploration: Paginated listing tools
|
|
7
|
+
* - Detail: Focused single-item tools
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Token budget awareness
|
|
11
|
+
* - Cursor-based pagination
|
|
12
|
+
* - Structured error handling with recovery hints
|
|
13
|
+
* - Response caching
|
|
14
|
+
* - Rate limiting
|
|
15
|
+
* - Metrics collection
|
|
16
|
+
*/
|
|
17
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
18
|
+
export interface EnterpriseMCPConfig {
|
|
19
|
+
projectRoot: string;
|
|
20
|
+
enableCache?: boolean;
|
|
21
|
+
enableRateLimiting?: boolean;
|
|
22
|
+
enableMetrics?: boolean;
|
|
23
|
+
maxRequestsPerMinute?: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function createEnterpriseMCPServer(config: EnterpriseMCPConfig): Server;
|
|
26
|
+
/**
|
|
27
|
+
* Get tool categories for documentation
|
|
28
|
+
*/
|
|
29
|
+
export declare function getToolCategories(): {
|
|
30
|
+
orchestration: string[];
|
|
31
|
+
discovery: string[];
|
|
32
|
+
exploration: string[];
|
|
33
|
+
detail: string[];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Get all tools
|
|
37
|
+
*/
|
|
38
|
+
export declare function getAllTools(): {
|
|
39
|
+
inputSchema: {
|
|
40
|
+
[x: string]: unknown;
|
|
41
|
+
type: "object";
|
|
42
|
+
properties?: {
|
|
43
|
+
[x: string]: object;
|
|
44
|
+
} | undefined;
|
|
45
|
+
required?: string[] | undefined;
|
|
46
|
+
};
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string | undefined;
|
|
49
|
+
outputSchema?: {
|
|
50
|
+
[x: string]: unknown;
|
|
51
|
+
type: "object";
|
|
52
|
+
properties?: {
|
|
53
|
+
[x: string]: object;
|
|
54
|
+
} | undefined;
|
|
55
|
+
required?: string[] | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
annotations?: {
|
|
58
|
+
title?: string | undefined;
|
|
59
|
+
readOnlyHint?: boolean | undefined;
|
|
60
|
+
destructiveHint?: boolean | undefined;
|
|
61
|
+
idempotentHint?: boolean | undefined;
|
|
62
|
+
openWorldHint?: boolean | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
execution?: {
|
|
65
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
_meta?: {
|
|
68
|
+
[x: string]: unknown;
|
|
69
|
+
} | undefined;
|
|
70
|
+
icons?: {
|
|
71
|
+
src: string;
|
|
72
|
+
mimeType?: string | undefined;
|
|
73
|
+
sizes?: string[] | undefined;
|
|
74
|
+
theme?: "light" | "dark" | undefined;
|
|
75
|
+
}[] | undefined;
|
|
76
|
+
title?: string | undefined;
|
|
77
|
+
}[];
|
|
78
|
+
//# sourceMappingURL=enterprise-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enterprise-server.d.ts","sourceRoot":"","sources":["../src/enterprise-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAkDnE,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;CAC/B;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAwF7E;AAgHD;;GAEG;AACH,wBAAgB,iBAAiB;;;;;EAEhC;AAED;;GAEG;AACH,wBAAgB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAE1B"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enterprise Drift MCP Server
|
|
3
|
+
*
|
|
4
|
+
* Layered tool architecture following Block's pattern:
|
|
5
|
+
* - Discovery: Lightweight status and capability tools
|
|
6
|
+
* - Exploration: Paginated listing tools
|
|
7
|
+
* - Detail: Focused single-item tools
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Token budget awareness
|
|
11
|
+
* - Cursor-based pagination
|
|
12
|
+
* - Structured error handling with recovery hints
|
|
13
|
+
* - Response caching
|
|
14
|
+
* - Rate limiting
|
|
15
|
+
* - Metrics collection
|
|
16
|
+
*/
|
|
17
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
18
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
19
|
+
import { PatternStore, ManifestStore, HistoryStore, DNAStore, BoundaryStore, ContractStore, CallGraphStore, createDataLake, } from 'driftdetect-core';
|
|
20
|
+
// Infrastructure
|
|
21
|
+
import { handleError, rateLimiter, metrics, createCache, } from './infrastructure/index.js';
|
|
22
|
+
// Tool definitions
|
|
23
|
+
import { ALL_TOOLS, TOOL_CATEGORIES } from './tools/registry.js';
|
|
24
|
+
// Discovery handlers
|
|
25
|
+
import { handleStatus } from './tools/discovery/status.js';
|
|
26
|
+
import { handleCapabilities } from './tools/discovery/capabilities.js';
|
|
27
|
+
// Exploration handlers
|
|
28
|
+
import { handlePatternsList } from './tools/exploration/patterns-list.js';
|
|
29
|
+
import { handleSecuritySummary } from './tools/exploration/security-summary.js';
|
|
30
|
+
import { handleContractsList } from './tools/exploration/contracts-list.js';
|
|
31
|
+
import { handleTrends } from './tools/exploration/trends.js';
|
|
32
|
+
// Detail handlers
|
|
33
|
+
import { handlePatternGet } from './tools/detail/pattern-get.js';
|
|
34
|
+
import { handleCodeExamples } from './tools/detail/code-examples.js';
|
|
35
|
+
import { handleFilesList } from './tools/detail/files-list.js';
|
|
36
|
+
import { handleFilePatterns } from './tools/detail/file-patterns.js';
|
|
37
|
+
import { handleImpactAnalysis } from './tools/detail/impact-analysis.js';
|
|
38
|
+
import { handleReachability } from './tools/detail/reachability.js';
|
|
39
|
+
import { handleDNAProfile } from './tools/detail/dna-profile.js';
|
|
40
|
+
// Orchestration handlers
|
|
41
|
+
import { handleContext } from './tools/orchestration/index.js';
|
|
42
|
+
export function createEnterpriseMCPServer(config) {
|
|
43
|
+
const server = new Server({ name: 'drift-enterprise', version: '2.0.0' }, { capabilities: { tools: {} } });
|
|
44
|
+
// Initialize stores
|
|
45
|
+
const stores = {
|
|
46
|
+
pattern: new PatternStore({ rootDir: config.projectRoot }),
|
|
47
|
+
manifest: new ManifestStore(config.projectRoot),
|
|
48
|
+
history: new HistoryStore({ rootDir: config.projectRoot }),
|
|
49
|
+
dna: new DNAStore({ rootDir: config.projectRoot }),
|
|
50
|
+
boundary: new BoundaryStore({ rootDir: config.projectRoot }),
|
|
51
|
+
contract: new ContractStore({ rootDir: config.projectRoot }),
|
|
52
|
+
callGraph: new CallGraphStore({ rootDir: config.projectRoot }),
|
|
53
|
+
};
|
|
54
|
+
// Initialize data lake for optimized queries
|
|
55
|
+
const dataLake = createDataLake({ rootDir: config.projectRoot });
|
|
56
|
+
// Initialize cache if enabled
|
|
57
|
+
const cache = config.enableCache !== false
|
|
58
|
+
? createCache(config.projectRoot)
|
|
59
|
+
: null;
|
|
60
|
+
// List available tools
|
|
61
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
62
|
+
metrics.increment('tools.list');
|
|
63
|
+
return { tools: ALL_TOOLS };
|
|
64
|
+
});
|
|
65
|
+
// Handle tool calls
|
|
66
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
67
|
+
const { name, arguments: args = {} } = request.params;
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
try {
|
|
70
|
+
// Rate limiting
|
|
71
|
+
if (config.enableRateLimiting !== false) {
|
|
72
|
+
try {
|
|
73
|
+
rateLimiter.checkLimit(name, 'default');
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
metrics.increment('tools.rate_limited', { tool: name });
|
|
77
|
+
return {
|
|
78
|
+
content: [{
|
|
79
|
+
type: 'text',
|
|
80
|
+
text: JSON.stringify({
|
|
81
|
+
error: 'Rate limit exceeded',
|
|
82
|
+
hint: 'Wait a moment before making more requests',
|
|
83
|
+
retryAfter: 60,
|
|
84
|
+
}),
|
|
85
|
+
}],
|
|
86
|
+
isError: true,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Check cache
|
|
91
|
+
const cacheKey = cache?.generateKey(name, args);
|
|
92
|
+
if (cache && cacheKey) {
|
|
93
|
+
const cached = await cache.get(cacheKey);
|
|
94
|
+
if (cached) {
|
|
95
|
+
metrics.increment('tools.cache_hit', { tool: name });
|
|
96
|
+
return cached.data;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// Route to handler
|
|
100
|
+
const result = await routeToolCall(name, args, stores, config.projectRoot, dataLake);
|
|
101
|
+
// Cache result
|
|
102
|
+
if (cache && cacheKey && result && !('isError' in result && result.isError)) {
|
|
103
|
+
await cache.set(cacheKey, result);
|
|
104
|
+
}
|
|
105
|
+
// Record metrics
|
|
106
|
+
metrics.increment('tools.call', { tool: name });
|
|
107
|
+
metrics.observe('tools.duration_ms', Date.now() - startTime, { tool: name });
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
metrics.increment('tools.error', { tool: name });
|
|
112
|
+
return handleError(error);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return server;
|
|
116
|
+
}
|
|
117
|
+
async function routeToolCall(name, args, stores, projectRoot, dataLake) {
|
|
118
|
+
// ============================================================================
|
|
119
|
+
// Orchestration Tools (Meta Layer - Start Here)
|
|
120
|
+
// ============================================================================
|
|
121
|
+
switch (name) {
|
|
122
|
+
case 'drift_context':
|
|
123
|
+
return handleContext({
|
|
124
|
+
pattern: stores.pattern,
|
|
125
|
+
manifest: stores.manifest,
|
|
126
|
+
boundary: stores.boundary,
|
|
127
|
+
callGraph: stores.callGraph,
|
|
128
|
+
dna: stores.dna,
|
|
129
|
+
}, projectRoot, args);
|
|
130
|
+
}
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Discovery Tools (Layer 1)
|
|
133
|
+
// ============================================================================
|
|
134
|
+
switch (name) {
|
|
135
|
+
case 'drift_status':
|
|
136
|
+
return handleStatus(stores.pattern, args, dataLake);
|
|
137
|
+
case 'drift_capabilities':
|
|
138
|
+
return handleCapabilities(args);
|
|
139
|
+
}
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// Exploration Tools (Layer 2)
|
|
142
|
+
// ============================================================================
|
|
143
|
+
switch (name) {
|
|
144
|
+
case 'drift_patterns_list':
|
|
145
|
+
return handlePatternsList(stores.pattern, args, dataLake);
|
|
146
|
+
case 'drift_security_summary':
|
|
147
|
+
return handleSecuritySummary(stores.boundary, args);
|
|
148
|
+
case 'drift_contracts_list':
|
|
149
|
+
return handleContractsList(stores.contract, args);
|
|
150
|
+
case 'drift_trends':
|
|
151
|
+
return handleTrends(stores.history, args);
|
|
152
|
+
}
|
|
153
|
+
// ============================================================================
|
|
154
|
+
// Detail Tools (Layer 3)
|
|
155
|
+
// ============================================================================
|
|
156
|
+
switch (name) {
|
|
157
|
+
// Pattern detail tools
|
|
158
|
+
case 'drift_pattern_get':
|
|
159
|
+
return handlePatternGet(stores.pattern, args);
|
|
160
|
+
case 'drift_code_examples':
|
|
161
|
+
return handleCodeExamples(stores.pattern, projectRoot, args);
|
|
162
|
+
// File detail tools
|
|
163
|
+
case 'drift_files_list':
|
|
164
|
+
return handleFilesList(stores.manifest, args);
|
|
165
|
+
case 'drift_file_patterns':
|
|
166
|
+
return handleFilePatterns(stores.manifest, args);
|
|
167
|
+
// Call graph analysis tools
|
|
168
|
+
case 'drift_impact_analysis':
|
|
169
|
+
return handleImpactAnalysis(projectRoot, args);
|
|
170
|
+
case 'drift_reachability':
|
|
171
|
+
return handleReachability(projectRoot, args);
|
|
172
|
+
// DNA tools
|
|
173
|
+
case 'drift_dna_profile':
|
|
174
|
+
return handleDNAProfile(stores.dna, args);
|
|
175
|
+
}
|
|
176
|
+
// Unknown tool
|
|
177
|
+
return {
|
|
178
|
+
content: [{
|
|
179
|
+
type: 'text',
|
|
180
|
+
text: JSON.stringify({
|
|
181
|
+
error: `Unknown tool: ${name}`,
|
|
182
|
+
hint: 'Use drift_capabilities to see available tools',
|
|
183
|
+
availableTools: TOOL_CATEGORIES,
|
|
184
|
+
}),
|
|
185
|
+
}],
|
|
186
|
+
isError: true,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Get tool categories for documentation
|
|
191
|
+
*/
|
|
192
|
+
export function getToolCategories() {
|
|
193
|
+
return TOOL_CATEGORIES;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get all tools
|
|
197
|
+
*/
|
|
198
|
+
export function getAllTools() {
|
|
199
|
+
return ALL_TOOLS;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=enterprise-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enterprise-server.js","sourceRoot":"","sources":["../src/enterprise-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;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,GAEf,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,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,uBAAuB;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,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,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;A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K,mBAAmB;YACtB,OAAO,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,IAA8C,CAAC,CAAC;QAE1F,KAAK,qBAAqB;YACxB,OAAO,kBAAkB,CACvB,MAAM,CAAC,OAAO,EACd,WAAW,EACX,IAAgD,CACjD,CAAC;QAEJ,oBAAoB;QACpB,KAAK,kBAAkB;YACrB,OAAO,eAAe,CAAC,MAAM,CAAC,QAAQ,EAAE,IAA6C,CAAC,CAAC;QAEzF,KAAK,qBAAqB;YACxB,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAgD,CAAC,CAAC;QAE/F,4BAA4B;QAC5B,KAAK,uBAAuB;YAC1B,OAAO,oBAAoB,CAAC,WAAW,EAAE,IAAkD,CAAC,CAAC;QAE/F,KAAK,oBAAoB;YACvB,OAAO,kBAAkB,CAAC,WAAW,EAAE,IAAgD,CAAC,CAAC;QAE3F,YAAY;QACZ,KAAK,mBAAmB;YACtB,OAAO,gBAAgB,CAAC,MAAM,CAAC,GAAG,EAAE,IAA8C,CAAC,CAAC;IACxF,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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,11 +3,24 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exposes drift functionality as MCP tools for AI agents.
|
|
5
5
|
* This enables structured, type-safe access to codebase patterns.
|
|
6
|
+
*
|
|
7
|
+
* The server uses the DataLake as the central source of truth for all data:
|
|
8
|
+
* - Pre-computed views for instant status/pattern queries
|
|
9
|
+
* - Sharded storage for efficient category-based lookups
|
|
10
|
+
* - Automatic fallback to source stores when lake data unavailable
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Layered tool architecture (orchestration → discovery → exploration → detail)
|
|
14
|
+
* - Intent-aware context synthesis via drift_context
|
|
15
|
+
* - Token budget awareness and cursor-based pagination
|
|
16
|
+
* - Structured error handling with recovery hints
|
|
17
|
+
* - Response caching, rate limiting, and metrics
|
|
6
18
|
*/
|
|
7
|
-
export { createDriftMCPServer } from './server.js';
|
|
8
|
-
export type { DriftMCPConfig } from './server.js';
|
|
19
|
+
export { createEnterpriseMCPServer as createDriftMCPServer, createEnterpriseMCPServer, getAllTools, getToolCategories, } from './enterprise-server.js';
|
|
20
|
+
export type { EnterpriseMCPConfig, EnterpriseMCPConfig as DriftMCPConfig } from './enterprise-server.js';
|
|
9
21
|
export { PackManager, DEFAULT_PACKS } from './packs.js';
|
|
10
22
|
export type { PackDefinition, PackMeta, PackResult, PackUsage, SuggestedPack, } from './packs.js';
|
|
11
23
|
export { FeedbackManager } from './feedback.js';
|
|
12
24
|
export type { ExampleFeedback, FeedbackStats, LocationScore, } from './feedback.js';
|
|
25
|
+
export { createResponseBuilder, TokenEstimator, CursorManager, DriftError, Errors, createCache, rateLimiter, metrics, } from './infrastructure/index.js';
|
|
13
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EACL,yBAAyB,IAAI,oBAAoB,EACjD,yBAAyB,EACzB,WAAW,EACX,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGzG,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,SAAS,EACT,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EACV,eAAe,EACf,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,UAAU,EACV,MAAM,EACN,WAAW,EACX,WAAW,EACX,OAAO,GACR,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,24 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Exposes drift functionality as MCP tools for AI agents.
|
|
5
5
|
* This enables structured, type-safe access to codebase patterns.
|
|
6
|
+
*
|
|
7
|
+
* The server uses the DataLake as the central source of truth for all data:
|
|
8
|
+
* - Pre-computed views for instant status/pattern queries
|
|
9
|
+
* - Sharded storage for efficient category-based lookups
|
|
10
|
+
* - Automatic fallback to source stores when lake data unavailable
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Layered tool architecture (orchestration → discovery → exploration → detail)
|
|
14
|
+
* - Intent-aware context synthesis via drift_context
|
|
15
|
+
* - Token budget awareness and cursor-based pagination
|
|
16
|
+
* - Structured error handling with recovery hints
|
|
17
|
+
* - Response caching, rate limiting, and metrics
|
|
6
18
|
*/
|
|
7
|
-
|
|
19
|
+
// Primary Server Export
|
|
20
|
+
export { createEnterpriseMCPServer as createDriftMCPServer, createEnterpriseMCPServer, getAllTools, getToolCategories, } from './enterprise-server.js';
|
|
21
|
+
// Utilities
|
|
8
22
|
export { PackManager, DEFAULT_PACKS } from './packs.js';
|
|
9
23
|
export { FeedbackManager } from './feedback.js';
|
|
24
|
+
// Infrastructure (for custom server implementations)
|
|
25
|
+
export { createResponseBuilder, TokenEstimator, CursorManager, DriftError, Errors, createCache, rateLimiter, metrics, } from './infrastructure/index.js';
|
|
10
26
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAwB;AACxB,OAAO,EACL,yBAAyB,IAAI,oBAAoB,EACjD,yBAAyB,EACzB,WAAW,EACX,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAGhC,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AASxD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOhD,qDAAqD;AACrD,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,UAAU,EACV,MAAM,EACN,WAAW,EACX,WAAW,EACX,OAAO,GACR,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response Cache
|
|
3
|
+
*
|
|
4
|
+
* Multi-level caching for MCP responses:
|
|
5
|
+
* - L1: In-memory LRU cache (fast, limited size)
|
|
6
|
+
* - L2: File-based cache (slower, larger, persistent)
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Automatic invalidation on pattern changes
|
|
10
|
+
* - TTL-based expiration
|
|
11
|
+
* - Cache key generation from tool + args
|
|
12
|
+
*/
|
|
13
|
+
export interface CachedResponse<T = unknown> {
|
|
14
|
+
data: T;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
expiresAt: number;
|
|
17
|
+
source?: 'l1' | 'l2';
|
|
18
|
+
invalidationKeys?: string[] | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface CacheConfig {
|
|
21
|
+
l1MaxSize: number;
|
|
22
|
+
l1TtlMs: number;
|
|
23
|
+
l2Enabled: boolean;
|
|
24
|
+
l2TtlMs: number;
|
|
25
|
+
l2CacheDir?: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare class ResponseCache {
|
|
28
|
+
private l1;
|
|
29
|
+
private config;
|
|
30
|
+
private invalidationIndex;
|
|
31
|
+
constructor(config?: Partial<CacheConfig>);
|
|
32
|
+
/**
|
|
33
|
+
* Get cached response
|
|
34
|
+
*/
|
|
35
|
+
get<T>(key: string): Promise<CachedResponse<T> | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Set cached response
|
|
38
|
+
*/
|
|
39
|
+
set<T>(key: string, data: T, options?: {
|
|
40
|
+
ttlMs?: number;
|
|
41
|
+
invalidationKeys?: string[];
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Delete cached response
|
|
45
|
+
*/
|
|
46
|
+
delete(key: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Invalidate all caches matching an invalidation key
|
|
49
|
+
*/
|
|
50
|
+
invalidate(invalidationKey: string): Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* Invalidate caches for specific categories
|
|
53
|
+
*/
|
|
54
|
+
invalidateCategories(categories: string[]): Promise<number>;
|
|
55
|
+
/**
|
|
56
|
+
* Invalidate all pattern-related caches
|
|
57
|
+
*/
|
|
58
|
+
invalidatePatterns(): Promise<number>;
|
|
59
|
+
/**
|
|
60
|
+
* Clear all caches
|
|
61
|
+
*/
|
|
62
|
+
clear(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Generate cache key from tool name and arguments
|
|
65
|
+
*/
|
|
66
|
+
generateKey(tool: string, args: Record<string, unknown>): string;
|
|
67
|
+
/**
|
|
68
|
+
* Get cache statistics
|
|
69
|
+
*/
|
|
70
|
+
getStats(): {
|
|
71
|
+
l1Size: number;
|
|
72
|
+
l1MaxSize: number;
|
|
73
|
+
invalidationKeys: number;
|
|
74
|
+
};
|
|
75
|
+
private isExpired;
|
|
76
|
+
private getFromL2;
|
|
77
|
+
private setToL2;
|
|
78
|
+
private deleteFromL2;
|
|
79
|
+
private clearL2;
|
|
80
|
+
private getL2Path;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a cache instance with project-specific L2 directory
|
|
84
|
+
*/
|
|
85
|
+
export declare function createCache(projectRoot: string, config?: Partial<CacheConfig>): ResponseCache;
|
|
86
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/infrastructure/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AA+DD,qBAAa,aAAa;IACxB,OAAO,CAAC,EAAE,CAAmC;IAC7C,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,iBAAiB,CAAuC;gBAEpD,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM;IAK7C;;OAEG;IACG,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO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