midnight-mcp 0.1.41 → 0.2.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.
Files changed (103) hide show
  1. package/README.md +32 -1
  2. package/dist/bin.d.ts +1 -0
  3. package/dist/bin.js +60 -0
  4. package/dist/chunk-HOWO4K5A.js +2197 -0
  5. package/dist/chunk-S7G4OHA4.js +8306 -0
  6. package/dist/db-YDGUWI5K.js +7 -0
  7. package/dist/index.d.ts +205 -3
  8. package/dist/index.js +28 -16
  9. package/package.json +16 -6
  10. package/dist/config/compact-version.d.ts +0 -183
  11. package/dist/config/compact-version.js +0 -423
  12. package/dist/db/index.d.ts +0 -3
  13. package/dist/db/index.js +0 -2
  14. package/dist/db/vectorStore.d.ts +0 -69
  15. package/dist/db/vectorStore.js +0 -196
  16. package/dist/pipeline/embeddings.d.ts +0 -25
  17. package/dist/pipeline/embeddings.js +0 -103
  18. package/dist/pipeline/github.d.ts +0 -84
  19. package/dist/pipeline/github.js +0 -399
  20. package/dist/pipeline/index.d.ts +0 -11
  21. package/dist/pipeline/index.js +0 -6
  22. package/dist/pipeline/indexer.d.ts +0 -41
  23. package/dist/pipeline/indexer.js +0 -254
  24. package/dist/pipeline/parser.d.ts +0 -46
  25. package/dist/pipeline/parser.js +0 -436
  26. package/dist/pipeline/releases.d.ts +0 -112
  27. package/dist/pipeline/releases.js +0 -298
  28. package/dist/pipeline/repository.d.ts +0 -372
  29. package/dist/pipeline/repository.js +0 -520
  30. package/dist/prompts/index.d.ts +0 -3
  31. package/dist/prompts/index.js +0 -2
  32. package/dist/prompts/templates.d.ts +0 -26
  33. package/dist/prompts/templates.js +0 -443
  34. package/dist/resources/code.d.ts +0 -15
  35. package/dist/resources/code.js +0 -122
  36. package/dist/resources/content/code-content.d.ts +0 -6
  37. package/dist/resources/content/code-content.js +0 -802
  38. package/dist/resources/content/docs-content.d.ts +0 -14
  39. package/dist/resources/content/docs-content.js +0 -1202
  40. package/dist/resources/content/index.d.ts +0 -6
  41. package/dist/resources/content/index.js +0 -6
  42. package/dist/resources/docs.d.ts +0 -15
  43. package/dist/resources/docs.js +0 -98
  44. package/dist/resources/index.d.ts +0 -6
  45. package/dist/resources/index.js +0 -13
  46. package/dist/resources/schemas.d.ts +0 -16
  47. package/dist/resources/schemas.js +0 -407
  48. package/dist/scripts/index-repos.d.ts +0 -12
  49. package/dist/scripts/index-repos.js +0 -53
  50. package/dist/server.d.ts +0 -43
  51. package/dist/server.js +0 -696
  52. package/dist/services/index.d.ts +0 -6
  53. package/dist/services/index.js +0 -6
  54. package/dist/services/sampling.d.ts +0 -62
  55. package/dist/services/sampling.js +0 -277
  56. package/dist/tools/analyze.d.ts +0 -106
  57. package/dist/tools/analyze.js +0 -431
  58. package/dist/tools/generation.d.ts +0 -9
  59. package/dist/tools/generation.js +0 -285
  60. package/dist/tools/health.d.ts +0 -120
  61. package/dist/tools/health.js +0 -365
  62. package/dist/tools/index.d.ts +0 -14
  63. package/dist/tools/index.js +0 -22
  64. package/dist/tools/meta.d.ts +0 -61
  65. package/dist/tools/meta.js +0 -282
  66. package/dist/tools/repository/constants.d.ts +0 -19
  67. package/dist/tools/repository/constants.js +0 -324
  68. package/dist/tools/repository/handlers.d.ts +0 -373
  69. package/dist/tools/repository/handlers.js +0 -724
  70. package/dist/tools/repository/index.d.ts +0 -9
  71. package/dist/tools/repository/index.js +0 -13
  72. package/dist/tools/repository/schemas.d.ts +0 -153
  73. package/dist/tools/repository/schemas.js +0 -106
  74. package/dist/tools/repository/tools.d.ts +0 -7
  75. package/dist/tools/repository/tools.js +0 -484
  76. package/dist/tools/repository/validation.d.ts +0 -106
  77. package/dist/tools/repository/validation.js +0 -820
  78. package/dist/tools/repository.d.ts +0 -6
  79. package/dist/tools/repository.js +0 -7
  80. package/dist/tools/search.d.ts +0 -76
  81. package/dist/tools/search.js +0 -423
  82. package/dist/types/index.d.ts +0 -2
  83. package/dist/types/index.js +0 -2
  84. package/dist/types/mcp.d.ts +0 -187
  85. package/dist/types/mcp.js +0 -6
  86. package/dist/utils/cache.d.ts +0 -77
  87. package/dist/utils/cache.js +0 -172
  88. package/dist/utils/config.d.ts +0 -70
  89. package/dist/utils/config.js +0 -294
  90. package/dist/utils/errors.d.ts +0 -111
  91. package/dist/utils/errors.js +0 -165
  92. package/dist/utils/health.d.ts +0 -29
  93. package/dist/utils/health.js +0 -132
  94. package/dist/utils/hosted-api.d.ts +0 -67
  95. package/dist/utils/hosted-api.js +0 -119
  96. package/dist/utils/index.d.ts +0 -16
  97. package/dist/utils/index.js +0 -15
  98. package/dist/utils/logger.d.ts +0 -48
  99. package/dist/utils/logger.js +0 -124
  100. package/dist/utils/rate-limit.d.ts +0 -61
  101. package/dist/utils/rate-limit.js +0 -148
  102. package/dist/utils/validation.d.ts +0 -52
  103. package/dist/utils/validation.js +0 -255
@@ -1,187 +0,0 @@
1
- /**
2
- * Extended MCP types for advanced features
3
- * Includes tool annotations, output schemas, and resource templates
4
- */
5
- /**
6
- * Tool annotations provide hints about tool behavior
7
- * These help clients make better decisions about tool usage
8
- */
9
- export interface ToolAnnotations {
10
- /**
11
- * If true, the tool does not modify any state
12
- * Clients can safely retry or parallelize read-only tools
13
- */
14
- readOnlyHint?: boolean;
15
- /**
16
- * If true, calling the tool multiple times with the same input
17
- * produces the same result (safe to retry)
18
- */
19
- idempotentHint?: boolean;
20
- /**
21
- * If true, the tool may return results from external sources
22
- * that could change over time
23
- */
24
- openWorldHint?: boolean;
25
- /**
26
- * If true, the tool may take a long time to complete
27
- * Clients should show progress indicators
28
- */
29
- longRunningHint?: boolean;
30
- /**
31
- * Human-readable title for display in UIs
32
- */
33
- title?: string;
34
- /**
35
- * If true, this tool performs destructive or irreversible actions
36
- * Clients should require human confirmation before execution
37
- */
38
- destructiveHint?: boolean;
39
- /**
40
- * If true, this tool requires explicit human confirmation
41
- * before execution (e.g., financial transactions, deletions)
42
- */
43
- requiresConfirmation?: boolean;
44
- /**
45
- * Tool category for progressive disclosure
46
- * Allows clients to group/filter tools by domain
47
- */
48
- category?: ToolCategory;
49
- }
50
- /**
51
- * Tool categories for progressive disclosure
52
- * Clients can initially show categories, then expand to individual tools
53
- */
54
- export type ToolCategory = "search" | "analyze" | "repository" | "versioning" | "generation" | "health" | "compound";
55
- /**
56
- * JSON Schema for structured tool outputs
57
- * Enables better LLM parsing and IDE integration
58
- */
59
- export interface OutputSchema {
60
- type: "object" | "array" | "string" | "number" | "boolean";
61
- properties?: Record<string, PropertySchema>;
62
- items?: PropertySchema;
63
- required?: string[];
64
- description?: string;
65
- }
66
- export interface PropertySchema {
67
- type: "string" | "number" | "boolean" | "array" | "object";
68
- description?: string;
69
- items?: PropertySchema;
70
- properties?: Record<string, PropertySchema>;
71
- enum?: string[];
72
- }
73
- export interface ExtendedToolDefinition {
74
- name: string;
75
- description: string;
76
- inputSchema: {
77
- type: "object";
78
- properties: Record<string, unknown>;
79
- required?: string[];
80
- };
81
- outputSchema?: OutputSchema;
82
- annotations?: ToolAnnotations;
83
- handler: (input: any) => Promise<any>;
84
- }
85
- export interface ResourceTemplate {
86
- /**
87
- * URI template following RFC 6570
88
- * e.g., "midnight://code/{owner}/{repo}/{path}"
89
- */
90
- uriTemplate: string;
91
- /**
92
- * Human-readable name
93
- */
94
- name: string;
95
- /**
96
- * Human-readable title for display
97
- */
98
- title?: string;
99
- /**
100
- * Description of what resources this template provides
101
- */
102
- description: string;
103
- /**
104
- * MIME type of resources matching this template
105
- */
106
- mimeType: string;
107
- }
108
- export interface ResourceAnnotations {
109
- /**
110
- * Intended audience for the resource
111
- * "user" = for human consumption
112
- * "assistant" = for LLM context
113
- */
114
- audience?: ("user" | "assistant")[];
115
- /**
116
- * Priority from 0.0 (optional) to 1.0 (required)
117
- */
118
- priority?: number;
119
- /**
120
- * ISO 8601 timestamp of last modification
121
- */
122
- lastModified?: string;
123
- }
124
- export interface SamplingRequest {
125
- messages: SamplingMessage[];
126
- systemPrompt?: string;
127
- modelPreferences?: ModelPreferences;
128
- maxTokens?: number;
129
- temperature?: number;
130
- stopSequences?: string[];
131
- }
132
- export interface SamplingMessage {
133
- role: "user" | "assistant";
134
- content: TextContent | ImageContent;
135
- }
136
- export interface TextContent {
137
- type: "text";
138
- text: string;
139
- }
140
- export interface ImageContent {
141
- type: "image";
142
- data: string;
143
- mimeType: string;
144
- }
145
- export interface ModelPreferences {
146
- hints?: {
147
- name: string;
148
- }[];
149
- costPriority?: number;
150
- speedPriority?: number;
151
- intelligencePriority?: number;
152
- }
153
- export interface SamplingResponse {
154
- role: "assistant";
155
- content: TextContent;
156
- model: string;
157
- stopReason: "endTurn" | "maxTokens" | "stopSequence";
158
- }
159
- export interface SearchResult {
160
- content: string;
161
- relevanceScore: number;
162
- source: {
163
- repository: string;
164
- filePath: string;
165
- lines: string;
166
- };
167
- codeType: string;
168
- }
169
- export interface SearchResponse {
170
- results: SearchResult[];
171
- totalResults: number;
172
- query: string;
173
- warnings?: string[];
174
- }
175
- export interface AnalysisResponse {
176
- name: string;
177
- type: string;
178
- summary: string;
179
- components: {
180
- name: string;
181
- type: string;
182
- description: string;
183
- }[];
184
- securityNotes: string[];
185
- recommendations: string[];
186
- }
187
- //# sourceMappingURL=mcp.d.ts.map
package/dist/types/mcp.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Extended MCP types for advanced features
3
- * Includes tool annotations, output schemas, and resource templates
4
- */
5
- export {};
6
- //# sourceMappingURL=mcp.js.map
@@ -1,77 +0,0 @@
1
- /**
2
- * Generic caching utilities for MCP server
3
- * Provides TTL-based caching with memory management
4
- */
5
- export interface CacheOptions {
6
- ttl: number;
7
- maxSize?: number;
8
- name?: string;
9
- }
10
- export interface CacheEntry<T> {
11
- value: T;
12
- expiresAt: number;
13
- createdAt: number;
14
- }
15
- export interface CacheStats {
16
- hits: number;
17
- misses: number;
18
- size: number;
19
- hitRate: number;
20
- }
21
- /**
22
- * Generic cache implementation with TTL and size limits
23
- */
24
- export declare class Cache<T> {
25
- private cache;
26
- private options;
27
- private stats;
28
- constructor(options: CacheOptions);
29
- /**
30
- * Get a value from the cache
31
- */
32
- get(key: string): T | undefined;
33
- /**
34
- * Set a value in the cache
35
- */
36
- set(key: string, value: T, ttl?: number): void;
37
- /**
38
- * Check if a key exists and is not expired
39
- */
40
- has(key: string): boolean;
41
- /**
42
- * Delete a key from the cache
43
- */
44
- delete(key: string): boolean;
45
- /**
46
- * Clear all entries from the cache
47
- */
48
- clear(): void;
49
- /**
50
- * Remove expired entries
51
- */
52
- prune(): number;
53
- /**
54
- * Evict the oldest entry to make room
55
- */
56
- private evictOldest;
57
- /**
58
- * Get cache statistics
59
- */
60
- getStats(): CacheStats;
61
- /**
62
- * Get or set with a factory function
63
- */
64
- getOrSet(key: string, factory: () => Promise<T>, ttl?: number): Promise<T>;
65
- }
66
- /**
67
- * Create a cache key from multiple parts
68
- */
69
- export declare function createCacheKey(...parts: (string | number | boolean | undefined)[]): string;
70
- export declare const searchCache: Cache<unknown>;
71
- export declare const fileCache: Cache<string>;
72
- export declare const metadataCache: Cache<unknown>;
73
- /**
74
- * Prune all caches periodically
75
- */
76
- export declare function pruneAllCaches(): void;
77
- //# sourceMappingURL=cache.d.ts.map
@@ -1,172 +0,0 @@
1
- /**
2
- * Generic caching utilities for MCP server
3
- * Provides TTL-based caching with memory management
4
- */
5
- import { logger } from "./logger.js";
6
- /**
7
- * Generic cache implementation with TTL and size limits
8
- */
9
- export class Cache {
10
- cache = new Map();
11
- options;
12
- stats = { hits: 0, misses: 0 };
13
- constructor(options) {
14
- this.options = {
15
- ttl: options.ttl,
16
- maxSize: options.maxSize || 1000,
17
- name: options.name || "cache",
18
- };
19
- }
20
- /**
21
- * Get a value from the cache
22
- */
23
- get(key) {
24
- const entry = this.cache.get(key);
25
- if (!entry) {
26
- this.stats.misses++;
27
- return undefined;
28
- }
29
- // Check if expired
30
- if (Date.now() > entry.expiresAt) {
31
- this.cache.delete(key);
32
- this.stats.misses++;
33
- return undefined;
34
- }
35
- this.stats.hits++;
36
- return entry.value;
37
- }
38
- /**
39
- * Set a value in the cache
40
- */
41
- set(key, value, ttl) {
42
- // Enforce size limit
43
- if (this.cache.size >= this.options.maxSize) {
44
- this.evictOldest();
45
- }
46
- const now = Date.now();
47
- this.cache.set(key, {
48
- value,
49
- expiresAt: now + (ttl || this.options.ttl),
50
- createdAt: now,
51
- });
52
- }
53
- /**
54
- * Check if a key exists and is not expired
55
- */
56
- has(key) {
57
- const entry = this.cache.get(key);
58
- if (!entry)
59
- return false;
60
- if (Date.now() > entry.expiresAt) {
61
- this.cache.delete(key);
62
- return false;
63
- }
64
- return true;
65
- }
66
- /**
67
- * Delete a key from the cache
68
- */
69
- delete(key) {
70
- return this.cache.delete(key);
71
- }
72
- /**
73
- * Clear all entries from the cache
74
- */
75
- clear() {
76
- this.cache.clear();
77
- logger.debug(`Cache cleared: ${this.options.name}`);
78
- }
79
- /**
80
- * Remove expired entries
81
- */
82
- prune() {
83
- const now = Date.now();
84
- let pruned = 0;
85
- for (const [key, entry] of this.cache.entries()) {
86
- if (now > entry.expiresAt) {
87
- this.cache.delete(key);
88
- pruned++;
89
- }
90
- }
91
- if (pruned > 0) {
92
- logger.debug(`Cache pruned: ${this.options.name}`, { pruned });
93
- }
94
- return pruned;
95
- }
96
- /**
97
- * Evict the oldest entry to make room
98
- */
99
- evictOldest() {
100
- let oldestKey = null;
101
- let oldestTime = Infinity;
102
- for (const [key, entry] of this.cache.entries()) {
103
- if (entry.createdAt < oldestTime) {
104
- oldestTime = entry.createdAt;
105
- oldestKey = key;
106
- }
107
- }
108
- if (oldestKey) {
109
- this.cache.delete(oldestKey);
110
- }
111
- }
112
- /**
113
- * Get cache statistics
114
- */
115
- getStats() {
116
- const total = this.stats.hits + this.stats.misses;
117
- return {
118
- hits: this.stats.hits,
119
- misses: this.stats.misses,
120
- size: this.cache.size,
121
- hitRate: total > 0 ? this.stats.hits / total : 0,
122
- };
123
- }
124
- /**
125
- * Get or set with a factory function
126
- */
127
- async getOrSet(key, factory, ttl) {
128
- const cached = this.get(key);
129
- if (cached !== undefined) {
130
- return cached;
131
- }
132
- const value = await factory();
133
- this.set(key, value, ttl);
134
- return value;
135
- }
136
- }
137
- /**
138
- * Create a cache key from multiple parts
139
- */
140
- export function createCacheKey(...parts) {
141
- return parts
142
- .filter((p) => p !== undefined)
143
- .map((p) => String(p))
144
- .join(":");
145
- }
146
- // Pre-configured caches for common use cases
147
- export const searchCache = new Cache({
148
- ttl: 5 * 60 * 1000, // 5 minutes
149
- maxSize: 500,
150
- name: "search",
151
- });
152
- export const fileCache = new Cache({
153
- ttl: 10 * 60 * 1000, // 10 minutes
154
- maxSize: 200,
155
- name: "file",
156
- });
157
- export const metadataCache = new Cache({
158
- ttl: 15 * 60 * 1000, // 15 minutes
159
- maxSize: 100,
160
- name: "metadata",
161
- });
162
- /**
163
- * Prune all caches periodically
164
- */
165
- export function pruneAllCaches() {
166
- searchCache.prune();
167
- fileCache.prune();
168
- metadataCache.prune();
169
- }
170
- // Auto-prune every 5 minutes
171
- setInterval(pruneAllCaches, 5 * 60 * 1000);
172
- //# sourceMappingURL=cache.js.map
@@ -1,70 +0,0 @@
1
- import { z } from "zod";
2
- declare const ConfigSchema: z.ZodObject<{
3
- mode: z.ZodDefault<z.ZodEnum<["hosted", "local"]>>;
4
- hostedApiUrl: z.ZodDefault<z.ZodString>;
5
- githubToken: z.ZodOptional<z.ZodString>;
6
- chromaUrl: z.ZodDefault<z.ZodString>;
7
- openaiApiKey: z.ZodOptional<z.ZodString>;
8
- embeddingModel: z.ZodDefault<z.ZodString>;
9
- logLevel: z.ZodDefault<z.ZodEnum<["debug", "info", "warn", "error"]>>;
10
- syncInterval: z.ZodDefault<z.ZodNumber>;
11
- port: z.ZodDefault<z.ZodNumber>;
12
- dataDir: z.ZodDefault<z.ZodString>;
13
- cacheDir: z.ZodDefault<z.ZodString>;
14
- }, "strip", z.ZodTypeAny, {
15
- mode: "hosted" | "local";
16
- hostedApiUrl: string;
17
- chromaUrl: string;
18
- embeddingModel: string;
19
- logLevel: "debug" | "info" | "warn" | "error";
20
- syncInterval: number;
21
- port: number;
22
- dataDir: string;
23
- cacheDir: string;
24
- githubToken?: string | undefined;
25
- openaiApiKey?: string | undefined;
26
- }, {
27
- mode?: "hosted" | "local" | undefined;
28
- hostedApiUrl?: string | undefined;
29
- githubToken?: string | undefined;
30
- chromaUrl?: string | undefined;
31
- openaiApiKey?: string | undefined;
32
- embeddingModel?: string | undefined;
33
- logLevel?: "debug" | "info" | "warn" | "error" | undefined;
34
- syncInterval?: number | undefined;
35
- port?: number | undefined;
36
- dataDir?: string | undefined;
37
- cacheDir?: string | undefined;
38
- }>;
39
- export type Config = z.infer<typeof ConfigSchema>;
40
- export declare const config: {
41
- mode: "hosted" | "local";
42
- hostedApiUrl: string;
43
- chromaUrl: string;
44
- embeddingModel: string;
45
- logLevel: "debug" | "info" | "warn" | "error";
46
- syncInterval: number;
47
- port: number;
48
- dataDir: string;
49
- cacheDir: string;
50
- githubToken?: string | undefined;
51
- openaiApiKey?: string | undefined;
52
- };
53
- /**
54
- * Check if running in hosted mode (default)
55
- */
56
- export declare function isHostedMode(): boolean;
57
- /**
58
- * Check if running in local mode
59
- */
60
- export declare function isLocalMode(): boolean;
61
- export interface RepositoryConfig {
62
- owner: string;
63
- repo: string;
64
- branch: string;
65
- patterns: string[];
66
- exclude: string[];
67
- }
68
- export declare const DEFAULT_REPOSITORIES: RepositoryConfig[];
69
- export {};
70
- //# sourceMappingURL=config.d.ts.map