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,484 +0,0 @@
1
- /**
2
- * Repository tool definitions
3
- * MCP tool registration for repository-related operations
4
- */
5
- import { getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, upgradeCheck, getFullRepoContext, extractContractStructure, } from "./handlers.js";
6
- // Tool definitions for MCP
7
- export const repositoryTools = [
8
- {
9
- name: "midnight-get-file",
10
- description: "Retrieve a specific file from Midnight repositories. Use repository aliases like 'compact', 'midnight-js', 'counter', or 'bboard' for convenience.",
11
- inputSchema: {
12
- type: "object",
13
- properties: {
14
- repo: {
15
- type: "string",
16
- description: "Repository name (e.g., 'compact', 'midnight-js', 'example-counter')",
17
- },
18
- path: {
19
- type: "string",
20
- description: "File path within repository",
21
- },
22
- ref: {
23
- type: "string",
24
- description: "Branch, tag, or commit SHA (default: main)",
25
- },
26
- },
27
- required: ["repo", "path"],
28
- },
29
- annotations: {
30
- readOnlyHint: true,
31
- openWorldHint: true,
32
- title: "Get Repository File",
33
- category: "repository",
34
- },
35
- handler: getFile,
36
- },
37
- {
38
- name: "midnight-list-examples",
39
- description: "List available Midnight example contracts and DApps with descriptions, complexity ratings, and key features.",
40
- inputSchema: {
41
- type: "object",
42
- properties: {
43
- category: {
44
- type: "string",
45
- enum: ["counter", "bboard", "token", "voting", "all"],
46
- description: "Filter by example type (default: all)",
47
- },
48
- },
49
- required: [],
50
- },
51
- annotations: {
52
- readOnlyHint: true,
53
- idempotentHint: true,
54
- title: "List Example Contracts",
55
- category: "repository",
56
- },
57
- handler: listExamples,
58
- },
59
- {
60
- name: "midnight-get-latest-updates",
61
- description: "Retrieve recent changes and commits across Midnight repositories. Useful for staying up-to-date with the latest developments.",
62
- inputSchema: {
63
- type: "object",
64
- properties: {
65
- since: {
66
- type: "string",
67
- description: "ISO date to fetch updates from (default: last 7 days)",
68
- },
69
- repos: {
70
- type: "array",
71
- items: { type: "string" },
72
- description: "Specific repos to check (default: all configured repos)",
73
- },
74
- },
75
- required: [],
76
- },
77
- annotations: {
78
- readOnlyHint: true,
79
- openWorldHint: true,
80
- title: "Get Latest Updates",
81
- category: "repository",
82
- },
83
- handler: getLatestUpdates,
84
- },
85
- {
86
- name: "midnight-get-version-info",
87
- description: "Get the latest version, release notes, and recent breaking changes for a Midnight repository. Use this to ensure you're working with the latest implementation.",
88
- inputSchema: {
89
- type: "object",
90
- properties: {
91
- repo: {
92
- type: "string",
93
- description: "Repository name (e.g., 'compact', 'midnight-js', 'sdk')",
94
- },
95
- },
96
- required: ["repo"],
97
- },
98
- annotations: {
99
- readOnlyHint: true,
100
- openWorldHint: true,
101
- title: "Get Version Info",
102
- category: "versioning",
103
- },
104
- handler: getVersionInfo,
105
- },
106
- {
107
- name: "midnight-check-breaking-changes",
108
- description: "Check if there are breaking changes between your current version and the latest release. Essential before upgrading dependencies.",
109
- inputSchema: {
110
- type: "object",
111
- properties: {
112
- repo: {
113
- type: "string",
114
- description: "Repository name (e.g., 'compact', 'midnight-js')",
115
- },
116
- currentVersion: {
117
- type: "string",
118
- description: "Version you're currently using (e.g., 'v1.0.0', '0.5.2')",
119
- },
120
- },
121
- required: ["repo", "currentVersion"],
122
- },
123
- annotations: {
124
- readOnlyHint: true,
125
- openWorldHint: true,
126
- title: "Check Breaking Changes",
127
- category: "versioning",
128
- },
129
- handler: checkBreakingChanges,
130
- },
131
- {
132
- name: "midnight-get-migration-guide",
133
- description: "Get a detailed migration guide for upgrading between versions, including all breaking changes, deprecations, and recommended steps.",
134
- inputSchema: {
135
- type: "object",
136
- properties: {
137
- repo: {
138
- type: "string",
139
- description: "Repository name (e.g., 'compact', 'midnight-js')",
140
- },
141
- fromVersion: {
142
- type: "string",
143
- description: "Version you're migrating from",
144
- },
145
- toVersion: {
146
- type: "string",
147
- description: "Target version (default: latest stable)",
148
- },
149
- },
150
- required: ["repo", "fromVersion"],
151
- },
152
- annotations: {
153
- readOnlyHint: true,
154
- openWorldHint: true,
155
- title: "Get Migration Guide",
156
- category: "versioning",
157
- },
158
- handler: getMigrationGuide,
159
- },
160
- {
161
- name: "midnight-get-file-at-version",
162
- description: "Get the exact content of a file at a specific version. CRITICAL: Use this to ensure code recommendations match the user's version. Always prefer this over get-file when version accuracy matters.",
163
- inputSchema: {
164
- type: "object",
165
- properties: {
166
- repo: {
167
- type: "string",
168
- description: "Repository name (e.g., 'compact', 'midnight-js')",
169
- },
170
- path: {
171
- type: "string",
172
- description: "File path within repository",
173
- },
174
- version: {
175
- type: "string",
176
- description: "Version tag (e.g., 'v1.0.0') or branch (e.g., 'main')",
177
- },
178
- },
179
- required: ["repo", "path", "version"],
180
- },
181
- annotations: {
182
- readOnlyHint: true,
183
- idempotentHint: true,
184
- openWorldHint: true,
185
- title: "Get File at Version",
186
- category: "versioning",
187
- },
188
- handler: getFileAtVersion,
189
- },
190
- {
191
- name: "midnight-compare-syntax",
192
- description: "Compare a file between two versions to see what changed. Use this before recommending code patterns to ensure they work with the user's version.",
193
- inputSchema: {
194
- type: "object",
195
- properties: {
196
- repo: {
197
- type: "string",
198
- description: "Repository name (e.g., 'compact')",
199
- },
200
- path: {
201
- type: "string",
202
- description: "File path to compare",
203
- },
204
- oldVersion: {
205
- type: "string",
206
- description: "Old version tag (e.g., 'v0.9.0')",
207
- },
208
- newVersion: {
209
- type: "string",
210
- description: "New version tag (default: latest stable)",
211
- },
212
- },
213
- required: ["repo", "path", "oldVersion"],
214
- },
215
- annotations: {
216
- readOnlyHint: true,
217
- idempotentHint: true,
218
- openWorldHint: true,
219
- title: "Compare Syntax Between Versions",
220
- category: "versioning",
221
- },
222
- handler: compareSyntax,
223
- },
224
- {
225
- name: "midnight-get-latest-syntax",
226
- description: `🚨 CALL THIS BEFORE GENERATING ANY COMPACT CODE!
227
- Get the authoritative Compact syntax reference. Prevents hallucination by providing:
228
- - Correct syntax patterns (Compact is NOT TypeScript!)
229
- - commonMistakes array with wrong→correct mappings
230
- - Type casting rules (Uint→Bytes needs two casts)
231
- - disclose() requirements for circuit params
232
- - Map.lookup()/Set.member() ARE available in circuits
233
-
234
- ALWAYS check this reference before writing Compact contracts.`,
235
- inputSchema: {
236
- type: "object",
237
- properties: {
238
- repo: {
239
- type: "string",
240
- description: "Repository name (default: 'compact')",
241
- },
242
- },
243
- required: [],
244
- },
245
- annotations: {
246
- readOnlyHint: true,
247
- openWorldHint: true,
248
- title: "🚨 Get Syntax Reference (Call First!)",
249
- category: "versioning",
250
- },
251
- handler: getLatestSyntax,
252
- },
253
- // ============================================================================
254
- // COMPOUND TOOLS - Multi-step operations in a single call
255
- // These reduce token usage by 50-70% compared to calling individual tools
256
- // ============================================================================
257
- {
258
- name: "midnight-upgrade-check",
259
- description: "🚀 COMPOUND TOOL: Complete upgrade analysis in ONE call. Combines version check + breaking changes + migration guide. Use this instead of calling midnight-get-version-info, midnight-check-breaking-changes, and midnight-get-migration-guide separately. Saves ~60% tokens.",
260
- inputSchema: {
261
- type: "object",
262
- properties: {
263
- repo: {
264
- type: "string",
265
- description: "Repository name (default: 'compact')",
266
- },
267
- currentVersion: {
268
- type: "string",
269
- description: "Your current version (e.g., 'v0.14.0', '0.13.5')",
270
- },
271
- },
272
- required: ["currentVersion"],
273
- },
274
- outputSchema: {
275
- type: "object",
276
- properties: {
277
- repository: { type: "string", description: "Full repository path" },
278
- currentVersion: {
279
- type: "string",
280
- description: "Version being checked",
281
- },
282
- version: {
283
- type: "object",
284
- description: "Version summary",
285
- properties: {
286
- latest: { type: "string" },
287
- latestStable: { type: "string" },
288
- isOutdated: { type: "boolean" },
289
- versionsBehind: { type: "number" },
290
- },
291
- },
292
- breakingChanges: {
293
- type: "object",
294
- description: "Breaking changes summary",
295
- properties: {
296
- count: { type: "number" },
297
- hasBreakingChanges: { type: "boolean" },
298
- items: { type: "array" },
299
- },
300
- },
301
- migration: { type: "object", description: "Migration guide if needed" },
302
- urgency: {
303
- type: "string",
304
- description: "none|low|medium|high|critical",
305
- },
306
- recommendation: {
307
- type: "string",
308
- description: "Actionable recommendation",
309
- },
310
- },
311
- },
312
- annotations: {
313
- readOnlyHint: true,
314
- openWorldHint: true,
315
- longRunningHint: true,
316
- title: "⚡ Upgrade Check (Compound)",
317
- category: "compound",
318
- },
319
- handler: upgradeCheck,
320
- },
321
- {
322
- name: "midnight-get-repo-context",
323
- description: "🚀 COMPOUND TOOL: Get everything needed to start working with a repository in ONE call. Combines version info + syntax reference + relevant examples. Use this at the start of a coding session instead of multiple individual calls. Saves ~50% tokens.",
324
- inputSchema: {
325
- type: "object",
326
- properties: {
327
- repo: {
328
- type: "string",
329
- description: "Repository name (e.g., 'compact', 'midnight-js')",
330
- },
331
- includeExamples: {
332
- type: "boolean",
333
- description: "Include example code snippets (default: true)",
334
- },
335
- includeSyntax: {
336
- type: "boolean",
337
- description: "Include syntax reference (default: true)",
338
- },
339
- },
340
- required: ["repo"],
341
- },
342
- outputSchema: {
343
- type: "object",
344
- properties: {
345
- repository: { type: "string", description: "Full repository path" },
346
- quickStart: {
347
- type: "object",
348
- description: "Version and install command",
349
- },
350
- version: { type: "object", description: "Version details" },
351
- syntax: { type: "object", description: "Syntax reference summary" },
352
- examples: { type: "array", description: "Relevant examples" },
353
- },
354
- },
355
- annotations: {
356
- readOnlyHint: true,
357
- openWorldHint: true,
358
- longRunningHint: true,
359
- title: "⚡ Get Repo Context (Compound)",
360
- category: "compound",
361
- },
362
- handler: getFullRepoContext,
363
- },
364
- // ============================================================================
365
- // ANALYSIS TOOLS - Contract structure extraction
366
- // ============================================================================
367
- {
368
- name: "midnight-extract-contract-structure",
369
- description: "Extract and analyze Compact contract structure (circuits, witnesses, ledger). " +
370
- "CRITICAL CHECKS: deprecated 'ledger { }' block syntax, 'Void' return type (should be []), " +
371
- "old pragma format, unexported enums, deprecated Cell<T> wrapper. " +
372
- "Also detects: module-level const, stdlib name collisions, division operator, " +
373
- "Counter.value access, missing disclose() calls, potential overflow. " +
374
- "Use BEFORE generating contracts to catch syntax errors. " +
375
- "Note: Static analysis only - catches common patterns but not semantic errors.",
376
- inputSchema: {
377
- type: "object",
378
- properties: {
379
- code: {
380
- type: "string",
381
- description: "The Compact contract source code to analyze (provide this OR filePath)",
382
- },
383
- filePath: {
384
- type: "string",
385
- description: "Path to a .compact file to analyze (alternative to providing code directly)",
386
- },
387
- },
388
- required: [],
389
- },
390
- outputSchema: {
391
- type: "object",
392
- properties: {
393
- success: { type: "boolean" },
394
- filename: { type: "string" },
395
- languageVersion: { type: "string" },
396
- imports: { type: "array", items: { type: "string" } },
397
- structure: {
398
- type: "object",
399
- properties: {
400
- circuits: {
401
- type: "array",
402
- items: {
403
- type: "object",
404
- properties: {
405
- name: { type: "string" },
406
- params: { type: "array", items: { type: "string" } },
407
- returnType: { type: "string" },
408
- isExport: { type: "boolean" },
409
- line: { type: "number" },
410
- },
411
- },
412
- },
413
- witnesses: {
414
- type: "array",
415
- items: {
416
- type: "object",
417
- properties: {
418
- name: { type: "string" },
419
- type: { type: "string" },
420
- isExport: { type: "boolean" },
421
- line: { type: "number" },
422
- },
423
- },
424
- },
425
- ledgerItems: {
426
- type: "array",
427
- items: {
428
- type: "object",
429
- properties: {
430
- name: { type: "string" },
431
- type: { type: "string" },
432
- isExport: { type: "boolean" },
433
- line: { type: "number" },
434
- },
435
- },
436
- },
437
- types: { type: "array" },
438
- structs: { type: "array" },
439
- enums: { type: "array" },
440
- },
441
- },
442
- exports: {
443
- type: "object",
444
- description: "Names of all exported items",
445
- },
446
- stats: {
447
- type: "object",
448
- description: "Counts of each type of definition",
449
- },
450
- potentialIssues: {
451
- type: "array",
452
- description: "Common issues detected by static analysis",
453
- items: {
454
- type: "object",
455
- properties: {
456
- type: {
457
- type: "string",
458
- description: "Issue type: module_level_const, stdlib_name_collision, sealed_export_conflict, missing_constructor, stdlib_type_mismatch",
459
- },
460
- line: { type: "number" },
461
- message: { type: "string" },
462
- suggestion: { type: "string" },
463
- severity: {
464
- type: "string",
465
- enum: ["error", "warning"],
466
- },
467
- },
468
- },
469
- },
470
- summary: { type: "string" },
471
- message: { type: "string" },
472
- },
473
- },
474
- annotations: {
475
- readOnlyHint: true,
476
- idempotentHint: true,
477
- openWorldHint: false,
478
- title: "📋 Extract Contract Structure",
479
- category: "analyze",
480
- },
481
- handler: extractContractStructure,
482
- },
483
- ];
484
- //# sourceMappingURL=tools.js.map
@@ -1,106 +0,0 @@
1
- /**
2
- * Contract validation handlers
3
- * Static analysis for Compact contracts
4
- */
5
- import type { ExtractContractStructureInput } from "./schemas.js";
6
- /**
7
- * Extract the structure of a Compact contract (circuits, witnesses, ledger, etc.)
8
- * This helps agents understand what a contract does without parsing it themselves
9
- */
10
- export declare function extractContractStructure(input: ExtractContractStructureInput): Promise<{
11
- success: boolean;
12
- error: string;
13
- message: string | undefined;
14
- details?: undefined;
15
- filename?: undefined;
16
- languageVersion?: undefined;
17
- imports?: undefined;
18
- structure?: undefined;
19
- exports?: undefined;
20
- stats?: undefined;
21
- potentialIssues?: undefined;
22
- summary?: undefined;
23
- } | {
24
- success: boolean;
25
- error: string;
26
- message: string;
27
- details: string | undefined;
28
- filename?: undefined;
29
- languageVersion?: undefined;
30
- imports?: undefined;
31
- structure?: undefined;
32
- exports?: undefined;
33
- stats?: undefined;
34
- potentialIssues?: undefined;
35
- summary?: undefined;
36
- } | {
37
- success: boolean;
38
- filename: string;
39
- languageVersion: string | null;
40
- imports: string[];
41
- structure: {
42
- circuits: {
43
- name: string;
44
- params: string[];
45
- returnType: string;
46
- isExport: boolean;
47
- line: number;
48
- }[];
49
- witnesses: {
50
- name: string;
51
- type: string;
52
- isExport: boolean;
53
- line: number;
54
- }[];
55
- ledgerItems: {
56
- name: string;
57
- type: string;
58
- isExport: boolean;
59
- line: number;
60
- }[];
61
- types: {
62
- name: string;
63
- definition: string;
64
- line: number;
65
- }[];
66
- structs: {
67
- name: string;
68
- fields: string[];
69
- line: number;
70
- }[];
71
- enums: {
72
- name: string;
73
- variants: string[];
74
- line: number;
75
- }[];
76
- };
77
- exports: {
78
- circuits: string[];
79
- witnesses: string[];
80
- ledger: string[];
81
- };
82
- stats: {
83
- lineCount: number;
84
- circuitCount: number;
85
- witnessCount: number;
86
- ledgerCount: number;
87
- typeCount: number;
88
- structCount: number;
89
- enumCount: number;
90
- exportedCircuits: number;
91
- exportedWitnesses: number;
92
- exportedLedger: number;
93
- };
94
- potentialIssues: {
95
- type: string;
96
- line?: number;
97
- message: string;
98
- suggestion: string;
99
- severity: "error" | "warning";
100
- }[] | undefined;
101
- summary: string;
102
- message: string;
103
- error?: undefined;
104
- details?: undefined;
105
- }>;
106
- //# sourceMappingURL=validation.d.ts.map