mason-context 0.17.2 → 0.17.4
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/CHANGELOG.md +20 -0
- package/dist/mason-audit.js +309 -179
- package/dist/mason-audit.js.map +1 -1
- package/dist/mason-auto.js +475 -289
- package/dist/mason-auto.js.map +1 -1
- package/dist/mason-drift.js +45 -18
- package/dist/mason-drift.js.map +1 -1
- package/dist/mason-hook.js +41 -13
- package/dist/mason-hook.js.map +1 -1
- package/dist/mason-mcp.js +632 -456
- package/dist/mason-mcp.js.map +1 -1
- package/dist/mason-review.js +53 -25
- package/dist/mason-review.js.map +1 -1
- package/dist/mason.js +510 -324
- package/dist/mason.js.map +1 -1
- package/package.json +1 -1
package/dist/mason-review.js
CHANGED
|
@@ -7,26 +7,57 @@ import { stripVTControlCharacters } from "util";
|
|
|
7
7
|
// src/review/review.ts
|
|
8
8
|
import fs5 from "fs/promises";
|
|
9
9
|
import path11 from "path";
|
|
10
|
-
import { execFile as
|
|
11
|
-
import { promisify as
|
|
10
|
+
import { execFile as execFile3 } from "child_process";
|
|
11
|
+
import { promisify as promisify3 } from "util";
|
|
12
|
+
|
|
13
|
+
// src/utils/git-read.ts
|
|
14
|
+
import { execFile } from "child_process";
|
|
15
|
+
import { promisify } from "util";
|
|
16
|
+
|
|
17
|
+
// src/utils/profile.ts
|
|
18
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
19
|
+
var profiles = new AsyncLocalStorage();
|
|
20
|
+
async function profilePhase(label, run) {
|
|
21
|
+
const phases = profiles.getStore();
|
|
22
|
+
if (!phases) return run();
|
|
23
|
+
const start = performance.now();
|
|
24
|
+
try {
|
|
25
|
+
return await run();
|
|
26
|
+
} finally {
|
|
27
|
+
const timing = phases[label] ??= { calls: 0, totalMs: 0 };
|
|
28
|
+
timing.calls++;
|
|
29
|
+
timing.totalMs += performance.now() - start;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/utils/git-read.ts
|
|
34
|
+
var execute = promisify(execFile);
|
|
35
|
+
var commands = /* @__PURE__ */ new Set(["rev-parse", "symbolic-ref", "for-each-ref", "ls-files", "check-ignore", "status", "log", "diff", "ls-tree", "show", "merge-base"]);
|
|
36
|
+
function execGit(args, options) {
|
|
37
|
+
const command = args.find((arg) => !arg.startsWith("-")) ?? "other";
|
|
38
|
+
return profilePhase("git." + (commands.has(command) ? command : "other"), async () => {
|
|
39
|
+
const { input, ...processOptions } = options;
|
|
40
|
+
const operation = execute("git", args, processOptions);
|
|
41
|
+
if (input !== void 0) {
|
|
42
|
+
operation.child.stdin.on("error", () => {
|
|
43
|
+
});
|
|
44
|
+
operation.child.stdin.end(input);
|
|
45
|
+
}
|
|
46
|
+
return operation;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
12
49
|
|
|
13
50
|
// src/drift/drift.ts
|
|
14
51
|
import fs3 from "fs/promises";
|
|
15
52
|
import path6 from "path";
|
|
16
|
-
import { execFile as execFile3 } from "child_process";
|
|
17
|
-
import { promisify as promisify3 } from "util";
|
|
18
53
|
|
|
19
54
|
// src/snapshot/snapshot.ts
|
|
20
55
|
import path5 from "path";
|
|
21
|
-
import { execFile as execFile2 } from "child_process";
|
|
22
|
-
import { promisify as promisify2 } from "util";
|
|
23
56
|
|
|
24
57
|
// src/utils/files.ts
|
|
25
58
|
import fs from "fs/promises";
|
|
26
59
|
import { constants } from "fs";
|
|
27
60
|
import path2 from "path";
|
|
28
|
-
import { execFile } from "child_process";
|
|
29
|
-
import { promisify } from "util";
|
|
30
61
|
import fg from "fast-glob";
|
|
31
62
|
|
|
32
63
|
// src/utils/paths.ts
|
|
@@ -52,7 +83,6 @@ function matchingPaths(anchors, files) {
|
|
|
52
83
|
}
|
|
53
84
|
|
|
54
85
|
// src/utils/files.ts
|
|
55
|
-
var exec = promisify(execFile);
|
|
56
86
|
var SOURCE_EXTENSIONS = ["ts", "tsx", "js", "jsx", "mts", "cts", "mjs", "cjs", "vue", "svelte", "kt", "kts", "java", "py", "go", "rs", "swift", "rb", "cs", "cpp", "c", "h", "hpp", "dart", "php"];
|
|
57
87
|
var SOURCE_GLOB = `**/*.{${SOURCE_EXTENSIONS.join(",")}}`;
|
|
58
88
|
var SOURCE_IGNORE = [
|
|
@@ -131,12 +161,12 @@ async function createFileAccess(rootDir) {
|
|
|
131
161
|
const ignore = [...SOURCE_IGNORE, ...config.ignore ?? []];
|
|
132
162
|
let gitFiles = null;
|
|
133
163
|
try {
|
|
134
|
-
const { stdout } = await
|
|
164
|
+
const { stdout } = await execGit(["ls-files", "-z", "--cached", "--others", "--exclude-standard"], { cwd: root, maxBuffer: 50 * 1024 * 1024 });
|
|
135
165
|
gitFiles = new Set(stdout.split("\0").filter(Boolean));
|
|
136
166
|
} catch {
|
|
137
167
|
let inGit = false;
|
|
138
168
|
try {
|
|
139
|
-
await
|
|
169
|
+
await execGit(["rev-parse", "--git-dir"], { cwd: root });
|
|
140
170
|
inGit = true;
|
|
141
171
|
} catch {
|
|
142
172
|
}
|
|
@@ -297,7 +327,6 @@ function commonSegments(pathA, pathB) {
|
|
|
297
327
|
}
|
|
298
328
|
|
|
299
329
|
// src/snapshot/snapshot.ts
|
|
300
|
-
var exec2 = promisify2(execFile2);
|
|
301
330
|
var repoPath = z.string().refine((value) => normalizeRepoPath(value) !== null, "Expected a relative repository path");
|
|
302
331
|
var verificationFields = {
|
|
303
332
|
refreshedHash: z.string().optional(),
|
|
@@ -324,7 +353,7 @@ var snapshotSchema = z.object({
|
|
|
324
353
|
}).passthrough();
|
|
325
354
|
async function getCurrentGitHash(rootDir) {
|
|
326
355
|
try {
|
|
327
|
-
const { stdout } = await
|
|
356
|
+
const { stdout } = await execGit(["rev-parse", "HEAD"], {
|
|
328
357
|
cwd: rootDir
|
|
329
358
|
});
|
|
330
359
|
return stdout.trim();
|
|
@@ -334,7 +363,6 @@ async function getCurrentGitHash(rootDir) {
|
|
|
334
363
|
}
|
|
335
364
|
|
|
336
365
|
// src/drift/drift.ts
|
|
337
|
-
var exec3 = promisify3(execFile3);
|
|
338
366
|
function parseChanges(output) {
|
|
339
367
|
const fields = output.split("\0");
|
|
340
368
|
const changes = [];
|
|
@@ -355,7 +383,7 @@ function touchedPaths(changes) {
|
|
|
355
383
|
async function getChangesWithStatus(resolvedRoot, fromHash, toHash = "HEAD") {
|
|
356
384
|
if (!fromHash || fromHash === "unknown" || fromHash.startsWith("-") || !toHash || toHash === "unknown" || toHash.startsWith("-")) return null;
|
|
357
385
|
try {
|
|
358
|
-
const { stdout } = await
|
|
386
|
+
const { stdout } = await execGit(["diff", "--name-status", "-z", "-M", fromHash, toHash, "--"], { cwd: resolvedRoot, maxBuffer: 10 * 1024 * 1024 });
|
|
359
387
|
return parseChanges(stdout);
|
|
360
388
|
} catch {
|
|
361
389
|
return null;
|
|
@@ -364,8 +392,8 @@ async function getChangesWithStatus(resolvedRoot, fromHash, toHash = "HEAD") {
|
|
|
364
392
|
async function getWorkingTree(resolvedRoot) {
|
|
365
393
|
try {
|
|
366
394
|
const [diff, untracked] = await Promise.all([
|
|
367
|
-
|
|
368
|
-
|
|
395
|
+
execGit(["diff", "--name-status", "-z", "-M", "HEAD", "--"], { cwd: resolvedRoot, maxBuffer: 10 * 1024 * 1024 }),
|
|
396
|
+
execGit(["ls-files", "-z", "--others", "--exclude-standard"], { cwd: resolvedRoot, maxBuffer: 10 * 1024 * 1024 })
|
|
369
397
|
]);
|
|
370
398
|
const untrackedFiles = untracked.stdout.split("\0").filter((f) => f && !f.startsWith(".mason/"));
|
|
371
399
|
return { available: true, changedFiles: [.../* @__PURE__ */ new Set([...touchedPaths(parseChanges(diff.stdout)), ...untrackedFiles])].sort(), untrackedFiles };
|
|
@@ -617,9 +645,9 @@ async function computeDecisionDrift(rootDir, decisions) {
|
|
|
617
645
|
}
|
|
618
646
|
|
|
619
647
|
// src/review/cochange.ts
|
|
620
|
-
import { execFile as
|
|
621
|
-
import { promisify as
|
|
622
|
-
var
|
|
648
|
+
import { execFile as execFile2 } from "child_process";
|
|
649
|
+
import { promisify as promisify2 } from "util";
|
|
650
|
+
var exec = promisify2(execFile2);
|
|
623
651
|
var HISTORY_COMMITS = 1500;
|
|
624
652
|
var MIN_FILE_COMMITS = 5;
|
|
625
653
|
var MIN_SHARED_COMMITS = 4;
|
|
@@ -627,9 +655,9 @@ var MIN_COCHANGE_RATE = 0.6;
|
|
|
627
655
|
var MAX_COMMIT_FILES = 30;
|
|
628
656
|
async function buildMatrix(resolvedRoot) {
|
|
629
657
|
try {
|
|
630
|
-
const { stdout: shallow } = await
|
|
658
|
+
const { stdout: shallow } = await exec("git", ["rev-parse", "--is-shallow-repository"], { cwd: resolvedRoot });
|
|
631
659
|
if (shallow.trim() === "true") return null;
|
|
632
|
-
const { stdout } = await
|
|
660
|
+
const { stdout } = await exec(
|
|
633
661
|
"git",
|
|
634
662
|
["log", `-n${HISTORY_COMMITS}`, "--format=%x01", "--name-only", "-M"],
|
|
635
663
|
{ cwd: resolvedRoot, maxBuffer: 100 * 1024 * 1024 }
|
|
@@ -1129,11 +1157,11 @@ async function collectReviewEvidence(root, manifests, changedFiles, decisions, d
|
|
|
1129
1157
|
}
|
|
1130
1158
|
|
|
1131
1159
|
// src/review/review.ts
|
|
1132
|
-
var
|
|
1160
|
+
var exec2 = promisify3(execFile3);
|
|
1133
1161
|
var MAX_ANALYZED_FILES = 50;
|
|
1134
1162
|
async function resolveMergeBase(resolvedRoot, base, head) {
|
|
1135
1163
|
try {
|
|
1136
|
-
const { stdout } = await
|
|
1164
|
+
const { stdout } = await exec2("git", ["merge-base", base, head], {
|
|
1137
1165
|
cwd: resolvedRoot
|
|
1138
1166
|
});
|
|
1139
1167
|
return stdout.trim() || null;
|
|
@@ -1144,7 +1172,7 @@ async function resolveMergeBase(resolvedRoot, base, head) {
|
|
|
1144
1172
|
async function defaultBase(resolvedRoot) {
|
|
1145
1173
|
for (const ref of ["origin/HEAD", "origin/main", "origin/master", "main"]) {
|
|
1146
1174
|
try {
|
|
1147
|
-
await
|
|
1175
|
+
await exec2("git", ["rev-parse", "--verify", "--quiet", ref], {
|
|
1148
1176
|
cwd: resolvedRoot
|
|
1149
1177
|
});
|
|
1150
1178
|
return ref;
|