midnight-mcp 0.1.28 → 0.1.30

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.
@@ -5,10 +5,11 @@
5
5
  import { githubClient } from "../../pipeline/index.js";
6
6
  import { releaseTracker } from "../../pipeline/releases.js";
7
7
  import { logger, DEFAULT_REPOSITORIES, SelfCorrectionHints, } from "../../utils/index.js";
8
+ import { sendProgressNotification } from "../../server.js";
8
9
  import { REPO_ALIASES, EXAMPLES } from "./constants.js";
9
10
  import { EMBEDDED_DOCS } from "../../resources/content/docs-content.js";
10
11
  // Re-export validation handlers from validation.ts
11
- export { validateContract, extractContractStructure } from "./validation.js";
12
+ export { extractContractStructure } from "./validation.js";
12
13
  /**
13
14
  * Resolve repository name alias to owner/repo
14
15
  */
@@ -399,6 +400,7 @@ export async function getLatestSyntax(input) {
399
400
  export async function upgradeCheck(input) {
400
401
  const repoName = input?.repo || "compact";
401
402
  const currentVersion = input.currentVersion;
403
+ const progressToken = input._meta?.progressToken;
402
404
  logger.debug("Running compound upgrade check", {
403
405
  repo: repoName,
404
406
  currentVersion,
@@ -407,18 +409,34 @@ export async function upgradeCheck(input) {
407
409
  if (!resolved) {
408
410
  throw new Error(`Unknown repository: ${repoName}. Available: ${Object.keys(REPO_ALIASES).join(", ")}`);
409
411
  }
412
+ // Send progress: Starting
413
+ if (progressToken) {
414
+ sendProgressNotification(progressToken, 1, 4, "Fetching version info...");
415
+ }
410
416
  // Fetch all data in parallel
411
417
  const [versionInfo, outdatedInfo, breakingChanges] = await Promise.all([
412
418
  releaseTracker.getVersionInfo(resolved.owner, resolved.repo),
413
419
  releaseTracker.isOutdated(resolved.owner, resolved.repo, currentVersion),
414
420
  releaseTracker.getBreakingChangesSince(resolved.owner, resolved.repo, currentVersion),
415
421
  ]);
422
+ // Send progress: Fetched version data
423
+ if (progressToken) {
424
+ sendProgressNotification(progressToken, 2, 4, "Checking breaking changes...");
425
+ }
416
426
  const latestVersion = versionInfo.latestStableRelease?.tag || versionInfo.latestRelease?.tag;
417
427
  // Only fetch migration guide if there are breaking changes
418
428
  let migrationGuide = null;
419
429
  if (breakingChanges.length > 0 && latestVersion) {
430
+ // Send progress: Fetching migration guide
431
+ if (progressToken) {
432
+ sendProgressNotification(progressToken, 3, 4, "Generating migration guide...");
433
+ }
420
434
  migrationGuide = await releaseTracker.getMigrationGuide(resolved.owner, resolved.repo, currentVersion, latestVersion);
421
435
  }
436
+ // Send progress: Complete
437
+ if (progressToken) {
438
+ sendProgressNotification(progressToken, 4, 4, "Analysis complete");
439
+ }
422
440
  // Compute upgrade urgency
423
441
  const urgency = computeUpgradeUrgency(outdatedInfo, breakingChanges.length);
424
442
  return {
@@ -458,21 +476,34 @@ export async function upgradeCheck(input) {
458
476
  */
459
477
  export async function getFullRepoContext(input) {
460
478
  const repoName = input?.repo || "compact";
479
+ const progressToken = input._meta?.progressToken;
461
480
  logger.debug("Getting full repo context", { repo: repoName });
462
481
  const resolved = resolveRepo(repoName);
463
482
  if (!resolved) {
464
483
  throw new Error(`Unknown repository: ${repoName}. Available: ${Object.keys(REPO_ALIASES).join(", ")}`);
465
484
  }
485
+ // Send progress: Starting
486
+ if (progressToken) {
487
+ sendProgressNotification(progressToken, 1, 4, "Fetching version info...");
488
+ }
466
489
  // Fetch version info
467
490
  const versionInfo = await releaseTracker.getVersionInfo(resolved.owner, resolved.repo);
468
491
  const version = versionInfo.latestStableRelease?.tag ||
469
492
  versionInfo.latestRelease?.tag ||
470
493
  "main";
494
+ // Send progress: Fetched version
495
+ if (progressToken) {
496
+ sendProgressNotification(progressToken, 2, 4, "Loading syntax reference...");
497
+ }
471
498
  // Conditionally fetch syntax reference
472
499
  let syntaxRef = null;
473
500
  if (input.includeSyntax !== false) {
474
501
  syntaxRef = await releaseTracker.getLatestSyntaxReference(resolved.owner, resolved.repo);
475
502
  }
503
+ // Send progress: Loading examples
504
+ if (progressToken) {
505
+ sendProgressNotification(progressToken, 3, 4, "Gathering examples...");
506
+ }
476
507
  // Get relevant examples for this repo
477
508
  let examples = [];
478
509
  if (input.includeExamples !== false) {
@@ -486,6 +517,10 @@ export async function getFullRepoContext(input) {
486
517
  complexity: ex.complexity,
487
518
  }));
488
519
  }
520
+ // Send progress: Complete
521
+ if (progressToken) {
522
+ sendProgressNotification(progressToken, 4, 4, "Context ready");
523
+ }
489
524
  return {
490
525
  repository: `${resolved.owner}/${resolved.repo}`,
491
526
  // Quick start info
@@ -2,8 +2,8 @@
2
2
  * Repository module exports
3
3
  * Barrel file for repository-related tools
4
4
  */
5
- export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, ValidateContractInputSchema, ExtractContractStructureInputSchema, type GetFileInput, type ListExamplesInput, type GetLatestUpdatesInput, type GetVersionInfoInput, type CheckBreakingChangesInput, type GetMigrationGuideInput, type GetFileAtVersionInput, type CompareSyntaxInput, type GetLatestSyntaxInput, type ValidateContractInput, type ExtractContractStructureInput, } from "./schemas.js";
5
+ export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, ExtractContractStructureInputSchema, type GetFileInput, type ListExamplesInput, type GetLatestUpdatesInput, type GetVersionInfoInput, type CheckBreakingChangesInput, type GetMigrationGuideInput, type GetFileAtVersionInput, type CompareSyntaxInput, type GetLatestSyntaxInput, type ExtractContractStructureInput, } from "./schemas.js";
6
6
  export { REPO_ALIASES, EXAMPLES, type ExampleDefinition } from "./constants.js";
7
- export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, validateContract, extractContractStructure, } from "./handlers.js";
7
+ export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, extractContractStructure, } from "./handlers.js";
8
8
  export { repositoryTools } from "./tools.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -3,11 +3,11 @@
3
3
  * Barrel file for repository-related tools
4
4
  */
5
5
  // Schemas and types
6
- export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, ValidateContractInputSchema, ExtractContractStructureInputSchema, } from "./schemas.js";
6
+ export { GetFileInputSchema, ListExamplesInputSchema, GetLatestUpdatesInputSchema, GetVersionInfoInputSchema, CheckBreakingChangesInputSchema, GetMigrationGuideInputSchema, GetFileAtVersionInputSchema, CompareSyntaxInputSchema, GetLatestSyntaxInputSchema, ExtractContractStructureInputSchema, } from "./schemas.js";
7
7
  // Constants
8
8
  export { REPO_ALIASES, EXAMPLES } from "./constants.js";
9
9
  // Handlers
10
- export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, validateContract, extractContractStructure, } from "./handlers.js";
10
+ export { resolveRepo, getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, extractContractStructure, } from "./handlers.js";
11
11
  // Tools
12
12
  export { repositoryTools } from "./tools.js";
13
13
  //# sourceMappingURL=index.js.map
@@ -122,27 +122,6 @@ export declare const FullRepoContextInputSchema: z.ZodObject<{
122
122
  includeExamples?: boolean | undefined;
123
123
  includeSyntax?: boolean | undefined;
124
124
  }>;
125
- export declare const ValidateContractInputSchema: z.ZodEffects<z.ZodObject<{
126
- code: z.ZodOptional<z.ZodString>;
127
- filePath: z.ZodOptional<z.ZodString>;
128
- filename: z.ZodDefault<z.ZodOptional<z.ZodString>>;
129
- }, "strip", z.ZodTypeAny, {
130
- filename: string;
131
- code?: string | undefined;
132
- filePath?: string | undefined;
133
- }, {
134
- code?: string | undefined;
135
- filePath?: string | undefined;
136
- filename?: string | undefined;
137
- }>, {
138
- filename: string;
139
- code?: string | undefined;
140
- filePath?: string | undefined;
141
- }, {
142
- code?: string | undefined;
143
- filePath?: string | undefined;
144
- filename?: string | undefined;
145
- }>;
146
125
  export declare const ExtractContractStructureInputSchema: z.ZodEffects<z.ZodObject<{
147
126
  code: z.ZodOptional<z.ZodString>;
148
127
  filePath: z.ZodOptional<z.ZodString>;
@@ -170,6 +149,5 @@ export type CompareSyntaxInput = z.infer<typeof CompareSyntaxInputSchema>;
170
149
  export type GetLatestSyntaxInput = z.infer<typeof GetLatestSyntaxInputSchema>;
171
150
  export type UpgradeCheckInput = z.infer<typeof UpgradeCheckInputSchema>;
172
151
  export type FullRepoContextInput = z.infer<typeof FullRepoContextInputSchema>;
173
- export type ValidateContractInput = z.infer<typeof ValidateContractInputSchema>;
174
152
  export type ExtractContractStructureInput = z.infer<typeof ExtractContractStructureInputSchema>;
175
153
  //# sourceMappingURL=schemas.d.ts.map
@@ -88,26 +88,6 @@ export const FullRepoContextInputSchema = z.object({
88
88
  .describe("Include example code snippets"),
89
89
  includeSyntax: z.boolean().default(true).describe("Include syntax reference"),
90
90
  });
91
- export const ValidateContractInputSchema = z
92
- .object({
93
- code: z
94
- .string()
95
- .optional()
96
- .describe("The Compact contract source code to validate (provide this OR filePath)"),
97
- filePath: z
98
- .string()
99
- .optional()
100
- .describe("Path to a .compact file to validate (alternative to providing code directly)"),
101
- filename: z
102
- .string()
103
- .optional()
104
- .default("contract.compact")
105
- .describe("Optional filename for the contract (default: contract.compact)"),
106
- })
107
- .refine((data) => (data.code !== undefined && data.code.trim() !== "") ||
108
- data.filePath !== undefined, {
109
- message: "Either 'code' or 'filePath' must be provided",
110
- });
111
91
  export const ExtractContractStructureInputSchema = z
112
92
  .object({
113
93
  code: z
@@ -2,7 +2,7 @@
2
2
  * Repository tool definitions
3
3
  * MCP tool registration for repository-related operations
4
4
  */
5
- import { getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, upgradeCheck, getFullRepoContext, validateContract, extractContractStructure, } from "./handlers.js";
5
+ import { getFile, listExamples, getLatestUpdates, getVersionInfo, checkBreakingChanges, getMigrationGuide, getFileAtVersion, compareSyntax, getLatestSyntax, upgradeCheck, getFullRepoContext, extractContractStructure, } from "./handlers.js";
6
6
  // Tool definitions for MCP
7
7
  export const repositoryTools = [
8
8
  {
@@ -354,118 +354,15 @@ export const repositoryTools = [
354
354
  handler: getFullRepoContext,
355
355
  },
356
356
  // ============================================================================
357
- // VALIDATION TOOLS - Pre-compilation contract validation
357
+ // ANALYSIS TOOLS - Contract structure extraction
358
358
  // ============================================================================
359
- {
360
- name: "midnight-validate-contract",
361
- description: "� REQUIRED - ALWAYS CALL THIS FIRST: Compile a Compact contract using the REAL compiler. " +
362
- "⚠️ CRITICAL: You MUST call this tool BEFORE telling the user a contract works or is correct. " +
363
- "Static analysis tools like 'extract-contract-structure' or 'analyze-contract' CANNOT verify compilation - they miss semantic errors like: " +
364
- "(1) sealed fields require constructor, (2) constructor params need disclose(), (3) export circuits cannot modify sealed fields. " +
365
- "This tool runs the ACTUAL Compact compiler and returns real errors with line numbers. " +
366
- "If compiler not installed, it provides installation instructions. " +
367
- "WORKFLOW: Generate code → Call this tool → Fix errors → Repeat until success → THEN present to user.",
368
- inputSchema: {
369
- type: "object",
370
- properties: {
371
- code: {
372
- type: "string",
373
- description: "The Compact contract source code to validate (provide this OR filePath)",
374
- },
375
- filePath: {
376
- type: "string",
377
- description: "Path to a .compact file to validate (alternative to providing code directly)",
378
- },
379
- filename: {
380
- type: "string",
381
- description: "Optional filename for the contract when using code (default: contract.compact)",
382
- },
383
- },
384
- required: [],
385
- },
386
- outputSchema: {
387
- type: "object",
388
- properties: {
389
- success: {
390
- type: "boolean",
391
- description: "Whether the contract compiled successfully",
392
- },
393
- errorType: {
394
- type: "string",
395
- description: "Category of error: user_error, environment_error, system_error, compilation_error",
396
- },
397
- compilerInstalled: {
398
- type: "boolean",
399
- description: "Whether the Compact compiler is available",
400
- },
401
- compilerVersion: {
402
- type: "string",
403
- description: "Version of the Compact compiler",
404
- },
405
- message: { type: "string", description: "Summary message" },
406
- errors: {
407
- type: "array",
408
- description: "List of compilation errors with line numbers",
409
- items: {
410
- type: "object",
411
- properties: {
412
- line: { type: "number" },
413
- column: { type: "number" },
414
- message: { type: "string" },
415
- severity: { type: "string" },
416
- context: { type: "string" },
417
- },
418
- },
419
- },
420
- userAction: {
421
- type: "object",
422
- description: "What the user needs to do to fix the problem",
423
- properties: {
424
- problem: { type: "string" },
425
- solution: { type: "string" },
426
- isUserFault: { type: "boolean" },
427
- },
428
- },
429
- suggestions: {
430
- type: "array",
431
- description: "Suggestions for fixing errors",
432
- items: { type: "string" },
433
- },
434
- commonFixes: {
435
- type: "array",
436
- description: "Common fix patterns",
437
- items: {
438
- type: "object",
439
- properties: {
440
- pattern: { type: "string" },
441
- fix: { type: "string" },
442
- },
443
- },
444
- },
445
- installation: {
446
- type: "object",
447
- description: "Installation instructions if compiler not found",
448
- },
449
- },
450
- },
451
- annotations: {
452
- readOnlyHint: false, // Creates temp files
453
- idempotentHint: true, // Same input = same output
454
- openWorldHint: true,
455
- longRunningHint: true, // Compilation can take time
456
- title: "🔍 Validate Contract",
457
- category: "validation",
458
- },
459
- handler: validateContract,
460
- },
461
359
  {
462
360
  name: "midnight-extract-contract-structure",
463
- description: "⚠️ STATIC ANALYSIS ONLY - NOT A COMPILER: Extracts contract structure (circuits, witnesses, ledger) and detects common patterns. " +
464
- "🚫 THIS TOOL CANNOT VERIFY COMPILATION. It will NOT catch: sealed field rules, disclose() requirements, type mismatches, or semantic errors. " +
465
- " USE FOR: Understanding structure, quick pattern checks, fallback when compiler unavailable. " +
466
- " NEVER USE TO: Verify a contract works, claim code 'compiles correctly', or validate before presenting to user. " +
467
- "👉 ALWAYS call 'midnight-validate-contract' FIRST to actually compile the code. " +
468
- "Detects: module-level const, stdlib collisions, sealed+export conflicts, missing disclose(), Counter.value access, division operator.",
361
+ description: "Extract and analyze Compact contract structure (circuits, witnesses, ledger). " +
362
+ "Detects common issues: module-level const, stdlib name collisions, if-expression in assignments, Void return type, " +
363
+ "Counter.value access, division operator, missing disclose() calls. " +
364
+ "Use for understanding contract structure and catching common syntax mistakes. " +
365
+ "Note: This is static analysis - it catches common patterns but cannot verify semantic correctness.",
469
366
  inputSchema: {
470
367
  type: "object",
471
368
  properties: {
@@ -542,7 +439,7 @@ export const repositoryTools = [
542
439
  },
543
440
  potentialIssues: {
544
441
  type: "array",
545
- description: "Common issues detected by static analysis (NOT exhaustive - use validate_contract for real verification)",
442
+ description: "Common issues detected by static analysis",
546
443
  items: {
547
444
  type: "object",
548
445
  properties: {
@@ -569,7 +466,7 @@ export const repositoryTools = [
569
466
  idempotentHint: true,
570
467
  openWorldHint: false,
571
468
  title: "📋 Extract Contract Structure",
572
- category: "validation",
469
+ category: "analyze",
573
470
  },
574
471
  handler: extractContractStructure,
575
472
  },