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,285 +0,0 @@
1
- /**
2
- * Contract generation tool using sampling capability
3
- *
4
- * Enables AI-assisted generation and review of Compact smart contracts
5
- */
6
- import { z } from "zod";
7
- import { generateContract, reviewContract, generateDocumentation, isSamplingAvailable, } from "../services/index.js";
8
- // Input schemas
9
- const generateContractSchema = z.object({
10
- requirements: z
11
- .string()
12
- .describe("Natural language description of the contract requirements"),
13
- contractType: z
14
- .enum(["counter", "token", "voting", "custom"])
15
- .optional()
16
- .describe("Type of contract to generate"),
17
- baseExample: z
18
- .string()
19
- .optional()
20
- .describe("Example contract code to use as a base"),
21
- });
22
- const reviewContractSchema = z.object({
23
- code: z.string().describe("Compact contract code to review"),
24
- });
25
- const documentContractSchema = z.object({
26
- code: z.string().describe("Compact contract code to document"),
27
- format: z
28
- .enum(["markdown", "jsdoc"])
29
- .optional()
30
- .describe("Documentation format (default: markdown)"),
31
- });
32
- // Output schemas for structured responses
33
- const generateContractOutputSchema = {
34
- type: "object",
35
- properties: {
36
- code: {
37
- type: "string",
38
- description: "Generated Compact contract code",
39
- },
40
- explanation: {
41
- type: "string",
42
- description: "Brief explanation of what the contract does",
43
- },
44
- warnings: {
45
- type: "array",
46
- items: { type: "string" },
47
- description: "Any warnings or notes about the generated code",
48
- },
49
- samplingAvailable: {
50
- type: "boolean",
51
- description: "Whether sampling capability was available",
52
- },
53
- },
54
- required: ["code", "explanation", "warnings", "samplingAvailable"],
55
- };
56
- const reviewContractOutputSchema = {
57
- type: "object",
58
- properties: {
59
- summary: {
60
- type: "string",
61
- description: "Summary of the contract review",
62
- },
63
- issues: {
64
- type: "array",
65
- items: {
66
- type: "object",
67
- properties: {
68
- severity: {
69
- type: "string",
70
- enum: ["error", "warning", "info"],
71
- },
72
- line: { type: "number" },
73
- message: { type: "string" },
74
- suggestion: { type: "string" },
75
- },
76
- },
77
- description: "List of issues found",
78
- },
79
- improvedCode: {
80
- type: "string",
81
- description: "Improved version of the contract if applicable",
82
- },
83
- samplingAvailable: {
84
- type: "boolean",
85
- description: "Whether sampling capability was available",
86
- },
87
- },
88
- required: ["summary", "issues", "samplingAvailable"],
89
- };
90
- const documentContractOutputSchema = {
91
- type: "object",
92
- properties: {
93
- documentation: {
94
- type: "string",
95
- description: "Generated documentation",
96
- },
97
- format: {
98
- type: "string",
99
- description: "Format of the documentation",
100
- },
101
- samplingAvailable: {
102
- type: "boolean",
103
- description: "Whether sampling capability was available",
104
- },
105
- },
106
- required: ["documentation", "format", "samplingAvailable"],
107
- };
108
- // Handler functions
109
- async function handleGenerateContract(args) {
110
- const result = await generateContract(args.requirements, {
111
- contractType: args.contractType,
112
- baseExample: args.baseExample,
113
- });
114
- return {
115
- ...result,
116
- samplingAvailable: isSamplingAvailable(),
117
- };
118
- }
119
- async function handleReviewContract(args) {
120
- const result = await reviewContract(args.code);
121
- return {
122
- ...result,
123
- samplingAvailable: isSamplingAvailable(),
124
- };
125
- }
126
- async function handleDocumentContract(args) {
127
- const documentation = await generateDocumentation(args.code, args.format || "markdown");
128
- return {
129
- documentation,
130
- format: args.format || "markdown",
131
- samplingAvailable: isSamplingAvailable(),
132
- };
133
- }
134
- // Tool definitions
135
- export const generationTools = [
136
- {
137
- name: "midnight-generate-contract",
138
- description: `🔮 AI-POWERED CONTRACT GENERATION
139
-
140
- Generates Compact smart contracts from natural language requirements.
141
- Uses the client's LLM through MCP sampling to create contracts.
142
-
143
- REQUIREMENTS FORMAT:
144
- - Describe what the contract should do
145
- - Specify state variables needed
146
- - Define access control requirements
147
- - List the operations/circuits needed
148
-
149
- CONTRACT TYPES:
150
- • counter - Simple counter with increment/decrement
151
- • token - Token with transfers and balances
152
- • voting - Voting/governance mechanisms
153
- • custom - Free-form custom contract
154
-
155
- EXAMPLE USAGE:
156
- "Create a token contract with private balances, mint/burn capabilities for admin, and transfer functionality between users"
157
-
158
- ⚠️ REQUIRES: Client with sampling capability (e.g., Claude Desktop)`,
159
- inputSchema: {
160
- type: "object",
161
- properties: {
162
- requirements: {
163
- type: "string",
164
- description: "Natural language description of the contract requirements",
165
- },
166
- contractType: {
167
- type: "string",
168
- enum: ["counter", "token", "voting", "custom"],
169
- description: "Type of contract to generate",
170
- },
171
- baseExample: {
172
- type: "string",
173
- description: "Example contract code to use as a base",
174
- },
175
- },
176
- required: ["requirements"],
177
- },
178
- outputSchema: generateContractOutputSchema,
179
- annotations: {
180
- title: "Generate Compact Contract",
181
- readOnlyHint: false,
182
- idempotentHint: false,
183
- openWorldHint: true,
184
- longRunningHint: true,
185
- category: "generation",
186
- },
187
- handler: handleGenerateContract,
188
- },
189
- {
190
- name: "midnight-review-contract",
191
- description: `🔍 AI-POWERED CONTRACT REVIEW
192
-
193
- Performs security review and analysis of Compact smart contracts.
194
- Uses the client's LLM to identify issues and suggest improvements.
195
-
196
- CHECKS PERFORMED:
197
- • Security vulnerabilities
198
- • Privacy concerns (shielded state handling)
199
- • Logic errors
200
- • Best practice violations
201
- • Performance issues
202
-
203
- OUTPUT INCLUDES:
204
- • Summary of contract quality
205
- • List of issues with severity levels
206
- • Suggested fixes for each issue
207
- • Improved code version if applicable
208
-
209
- ⚠️ REQUIRES: Client with sampling capability (e.g., Claude Desktop)`,
210
- inputSchema: {
211
- type: "object",
212
- properties: {
213
- code: {
214
- type: "string",
215
- description: "Compact contract code to review",
216
- },
217
- },
218
- required: ["code"],
219
- },
220
- outputSchema: reviewContractOutputSchema,
221
- annotations: {
222
- title: "Review Compact Contract",
223
- readOnlyHint: true,
224
- idempotentHint: true,
225
- openWorldHint: true,
226
- longRunningHint: true,
227
- category: "generation",
228
- },
229
- handler: handleReviewContract,
230
- },
231
- {
232
- name: "midnight-document-contract",
233
- description: `📝 AI-POWERED DOCUMENTATION GENERATION
234
-
235
- Generates comprehensive documentation for Compact smart contracts.
236
- Uses the client's LLM to create detailed, human-readable docs.
237
-
238
- FORMATS:
239
- • markdown - Full Markdown documentation with examples
240
- • jsdoc - JSDoc-style inline comments
241
-
242
- MARKDOWN INCLUDES:
243
- • Contract overview and purpose
244
- • State variables with privacy annotations
245
- • Circuit function documentation
246
- • Witness function documentation
247
- • Usage examples
248
- • Security considerations
249
-
250
- ⚠️ REQUIRES: Client with sampling capability (e.g., Claude Desktop)`,
251
- inputSchema: {
252
- type: "object",
253
- properties: {
254
- code: {
255
- type: "string",
256
- description: "Compact contract code to document",
257
- },
258
- format: {
259
- type: "string",
260
- enum: ["markdown", "jsdoc"],
261
- description: "Documentation format (default: markdown)",
262
- },
263
- },
264
- required: ["code"],
265
- },
266
- outputSchema: documentContractOutputSchema,
267
- annotations: {
268
- title: "Generate Contract Documentation",
269
- readOnlyHint: true,
270
- idempotentHint: true,
271
- openWorldHint: true,
272
- longRunningHint: true,
273
- category: "generation",
274
- },
275
- handler: handleDocumentContract,
276
- },
277
- ];
278
- // Export handler map
279
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
280
- export const generationHandlers = {
281
- "midnight-generate-contract": handleGenerateContract,
282
- "midnight-review-contract": handleReviewContract,
283
- "midnight-document-contract": handleDocumentContract,
284
- };
285
- //# sourceMappingURL=generation.js.map
@@ -1,120 +0,0 @@
1
- /**
2
- * Health check and diagnostic tools for MCP server
3
- */
4
- import { z } from "zod";
5
- import type { ExtendedToolDefinition } from "../types/index.js";
6
- export declare const HealthCheckInputSchema: z.ZodObject<{
7
- detailed: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
8
- }, "strip", z.ZodTypeAny, {
9
- detailed: boolean;
10
- }, {
11
- detailed?: boolean | undefined;
12
- }>;
13
- export declare const GetStatusInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
14
- export declare const CheckVersionInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
15
- export type HealthCheckInput = z.infer<typeof HealthCheckInputSchema>;
16
- export type GetStatusInput = z.infer<typeof GetStatusInputSchema>;
17
- export type CheckVersionInput = z.infer<typeof CheckVersionInputSchema>;
18
- /**
19
- * Perform health check on the MCP server
20
- */
21
- export declare function healthCheck(input: HealthCheckInput): Promise<{
22
- rateLimit: string;
23
- cacheStats: {
24
- search: import("../utils/cache.js").CacheStats;
25
- file: import("../utils/cache.js").CacheStats;
26
- metadata: import("../utils/cache.js").CacheStats;
27
- };
28
- status: "healthy" | "degraded" | "unhealthy";
29
- timestamp: string;
30
- version: string;
31
- uptime: number;
32
- checks: {
33
- name: string;
34
- status: "pass" | "warn" | "fail";
35
- message?: string;
36
- latency?: number;
37
- }[];
38
- } | {
39
- rateLimit: string;
40
- status: "healthy" | "degraded" | "unhealthy";
41
- version: string;
42
- timestamp: string;
43
- uptime: number;
44
- checks: {
45
- name: string;
46
- status: "pass";
47
- }[];
48
- }>;
49
- /**
50
- * Get current server status and statistics
51
- */
52
- export declare function getStatus(_input: GetStatusInput): Promise<{
53
- server: string;
54
- status: string;
55
- timestamp: string;
56
- rateLimit: {
57
- remaining: number;
58
- limit: number;
59
- percentUsed: number;
60
- status: string;
61
- message: string;
62
- };
63
- cache: {
64
- search: import("../utils/cache.js").CacheStats;
65
- file: import("../utils/cache.js").CacheStats;
66
- metadata: import("../utils/cache.js").CacheStats;
67
- };
68
- }>;
69
- /**
70
- * Check if current version is up to date with npm
71
- */
72
- export declare function checkVersion(_input: CheckVersionInput): Promise<{
73
- currentVersion: string;
74
- latestVersion: string;
75
- isUpToDate: boolean;
76
- error: string;
77
- message?: undefined;
78
- updateInstructions?: undefined;
79
- newFeatures?: undefined;
80
- } | {
81
- currentVersion: string;
82
- latestVersion: string;
83
- isUpToDate: boolean;
84
- message: string;
85
- updateInstructions: {
86
- step1: string;
87
- step2: string;
88
- step3: string;
89
- alternative: string;
90
- } | null;
91
- newFeatures: string[] | null;
92
- error?: undefined;
93
- }>;
94
- export declare const AutoUpdateConfigInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
95
- export type AutoUpdateConfigInput = z.infer<typeof AutoUpdateConfigInputSchema>;
96
- /**
97
- * Get config file paths and update instructions for AI agent to auto-update
98
- */
99
- export declare function getAutoUpdateConfig(_input: AutoUpdateConfigInput): Promise<{
100
- instruction: string;
101
- platform: NodeJS.Platform;
102
- configPaths: Record<string, {
103
- path: string;
104
- exists: boolean;
105
- }>;
106
- searchAndReplace: {
107
- find: string;
108
- replaceWith: string;
109
- description: string;
110
- };
111
- alternativePatterns: {
112
- find: string;
113
- replaceWith: string;
114
- context: string;
115
- }[];
116
- agentInstructions: string[];
117
- postUpdateMessage: string;
118
- }>;
119
- export declare const healthTools: ExtendedToolDefinition[];
120
- //# sourceMappingURL=health.d.ts.map