@mwillbanks/ast-mcp 0.6.4 → 0.6.5

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/package.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "diff-match-patch-ts": "^2.0.0",
37
37
  "onnxruntime-common": "1.30.0",
38
38
  "parse5": "8.0.1",
39
- "posthog-node": "5.56.2",
39
+ "posthog-node": "5.56.4",
40
40
  "tree-sitter-systemverilog": "0.4.1",
41
41
  "tree-sitter-wasm": "2.0.4",
42
42
  "typescript-strada": "npm:@typescript/typescript6@6.0.2",
@@ -133,5 +133,5 @@
133
133
  },
134
134
  "sideEffects": false,
135
135
  "type": "module",
136
- "version": "0.6.4"
136
+ "version": "0.6.5"
137
137
  }
@@ -40,22 +40,62 @@ const CanonicalAbsolutePathSchema = z
40
40
  message: "Expected a canonical absolute path",
41
41
  });
42
42
 
43
+ function validBase64(value: string): boolean {
44
+ if (value.length % 4 !== 0) return false;
45
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
46
+ for (let index = 0; index < value.length - padding; index++) {
47
+ const code = value.charCodeAt(index);
48
+ if (
49
+ !(
50
+ (code >= 65 && code <= 90) ||
51
+ (code >= 97 && code <= 122) ||
52
+ (code >= 48 && code <= 57) ||
53
+ code === 43 ||
54
+ code === 47
55
+ )
56
+ )
57
+ return false;
58
+ }
59
+ return true;
60
+ }
61
+
62
+ const SnapshotBlobSchema = z
63
+ .object({
64
+ id: z.string().regex(/^[1-9][0-9]*-[a-f0-9-]{36}$/),
65
+ sha256: Sha256Schema,
66
+ size: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
67
+ })
68
+ .strict();
69
+
43
70
  const MutationJournalFileSchema = z
44
71
  .object({
45
72
  candidateSha256: Sha256Schema.nullable(),
46
73
  committedDeleted: z.boolean(),
47
74
  committedSha256: Sha256Schema.nullable(),
48
75
  filePath: CanonicalAbsolutePathSchema,
76
+ sourceBlob: SnapshotBlobSchema.nullable().optional(),
49
77
  sourceContentBase64: z
50
78
  .string()
51
- .regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)
79
+ .refine(validBase64, "Invalid Base64")
52
80
  .nullable(),
53
81
  sourceGid: z.number().int().nonnegative().nullable(),
54
82
  sourceMode: z.number().int().nonnegative().nullable(),
55
83
  sourceSha256: Sha256Schema.nullable(),
56
84
  sourceUid: z.number().int().nonnegative().nullable(),
57
85
  })
58
- .strict();
86
+ .strict()
87
+ .superRefine((file, context) => {
88
+ if (
89
+ file.sourceBlob &&
90
+ (file.sourceContentBase64 !== null ||
91
+ file.sourceBlob.sha256 !== file.sourceSha256)
92
+ )
93
+ context.addIssue({
94
+ code: "custom",
95
+ message: "Snapshot identity must match its source digest",
96
+ path: ["sourceBlob"],
97
+ });
98
+ });
59
99
 
60
100
  const MutationJournalRecordSchema = z
61
101
  .object({