@self-review/core 1.43.3 → 1.44.0
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/dist/chunk-A7A5ZFT3.js +233 -0
- package/dist/chunk-A7A5ZFT3.js.map +1 -0
- package/dist/chunk-OQRS7NDT.js +200 -0
- package/dist/chunk-OQRS7NDT.js.map +1 -0
- package/dist/diff-parser-2JM4CZR3.js +7 -0
- package/dist/diff-parser-2JM4CZR3.js.map +1 -0
- package/dist/git-E7WZPKRC.js +23 -0
- package/dist/git-E7WZPKRC.js.map +1 -0
- package/dist/index.cjs +1522 -378
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +454 -6
- package/dist/index.d.ts +454 -6
- package/dist/index.js +1091 -428
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,162 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (currentHunk && currentHunk.header && currentFile) {
|
|
16
|
-
currentFile.hunks.push(currentHunk);
|
|
17
|
-
currentHunk = null;
|
|
18
|
-
}
|
|
19
|
-
if (currentFile && currentFile.oldPath !== void 0 && currentFile.newPath !== void 0) {
|
|
20
|
-
if (currentFile.isBinary || currentFile.hunks && currentFile.hunks.length > 0 || currentFile.changeType === "added") {
|
|
21
|
-
files.push(currentFile);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const gitPaths = parseGitDiffHeader(line);
|
|
25
|
-
currentFile = {
|
|
26
|
-
oldPath: gitPaths.oldPath,
|
|
27
|
-
newPath: gitPaths.newPath,
|
|
28
|
-
changeType: "modified",
|
|
29
|
-
isBinary: false,
|
|
30
|
-
hunks: []
|
|
31
|
-
};
|
|
32
|
-
currentHunk = null;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (!currentFile) continue;
|
|
36
|
-
if (line.startsWith("new file mode")) {
|
|
37
|
-
currentFile.changeType = "added";
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
if (line.startsWith("deleted file mode")) {
|
|
41
|
-
currentFile.changeType = "deleted";
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (line.startsWith("rename from ")) {
|
|
45
|
-
currentFile.changeType = "renamed";
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (line.startsWith("--- ")) {
|
|
49
|
-
const path3 = line.substring(4);
|
|
50
|
-
currentFile.oldPath = path3 === "/dev/null" ? "" : stripPrefix(path3);
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (line.startsWith("+++ ")) {
|
|
54
|
-
const path3 = line.substring(4);
|
|
55
|
-
currentFile.newPath = path3 === "/dev/null" ? "" : stripPrefix(path3);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (line.startsWith("Binary files ")) {
|
|
59
|
-
currentFile.isBinary = true;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (line.startsWith("@@")) {
|
|
63
|
-
if (currentHunk && currentHunk.header) {
|
|
64
|
-
currentFile.hunks.push(currentHunk);
|
|
65
|
-
}
|
|
66
|
-
const match = line.match(
|
|
67
|
-
/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/
|
|
68
|
-
);
|
|
69
|
-
if (match) {
|
|
70
|
-
const oldStart = parseInt(match[1], 10);
|
|
71
|
-
const oldLines = match[2] ? parseInt(match[2], 10) : 1;
|
|
72
|
-
const newStart = parseInt(match[3], 10);
|
|
73
|
-
const newLines = match[4] ? parseInt(match[4], 10) : 1;
|
|
74
|
-
const _context = match[5];
|
|
75
|
-
currentHunk = {
|
|
76
|
-
header: line,
|
|
77
|
-
oldStart,
|
|
78
|
-
oldLines,
|
|
79
|
-
newStart,
|
|
80
|
-
newLines,
|
|
81
|
-
lines: []
|
|
82
|
-
};
|
|
83
|
-
oldLineNumber = oldStart;
|
|
84
|
-
newLineNumber = newStart;
|
|
85
|
-
}
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (currentHunk && currentHunk.lines) {
|
|
89
|
-
if (line.startsWith("+")) {
|
|
90
|
-
currentHunk.lines.push({
|
|
91
|
-
type: "addition",
|
|
92
|
-
oldLineNumber: null,
|
|
93
|
-
newLineNumber,
|
|
94
|
-
content: line.substring(1)
|
|
95
|
-
});
|
|
96
|
-
newLineNumber++;
|
|
97
|
-
} else if (line.startsWith("-")) {
|
|
98
|
-
currentHunk.lines.push({
|
|
99
|
-
type: "deletion",
|
|
100
|
-
oldLineNumber,
|
|
101
|
-
newLineNumber: null,
|
|
102
|
-
content: line.substring(1)
|
|
103
|
-
});
|
|
104
|
-
oldLineNumber++;
|
|
105
|
-
} else if (line.startsWith(" ")) {
|
|
106
|
-
currentHunk.lines.push({
|
|
107
|
-
type: "context",
|
|
108
|
-
oldLineNumber,
|
|
109
|
-
newLineNumber,
|
|
110
|
-
content: line.substring(1)
|
|
111
|
-
});
|
|
112
|
-
oldLineNumber++;
|
|
113
|
-
newLineNumber++;
|
|
114
|
-
} else if (line.startsWith("\\")) {
|
|
115
|
-
continue;
|
|
116
|
-
} else {
|
|
117
|
-
if (currentHunk.lines.length > 0) {
|
|
118
|
-
currentHunk.lines.push({
|
|
119
|
-
type: "context",
|
|
120
|
-
oldLineNumber,
|
|
121
|
-
newLineNumber,
|
|
122
|
-
content: line
|
|
123
|
-
});
|
|
124
|
-
oldLineNumber++;
|
|
125
|
-
newLineNumber++;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (currentHunk && currentHunk.header && currentFile) {
|
|
131
|
-
currentFile.hunks.push(currentHunk);
|
|
132
|
-
}
|
|
133
|
-
if (currentFile && currentFile.oldPath !== void 0 && currentFile.newPath !== void 0) {
|
|
134
|
-
if (currentFile.isBinary || currentFile.hunks && currentFile.hunks.length > 0 || currentFile.changeType === "added") {
|
|
135
|
-
files.push(currentFile);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return files;
|
|
139
|
-
}
|
|
140
|
-
function stripPrefix(path3) {
|
|
141
|
-
if (path3.length > 2 && path3[1] === "/") {
|
|
142
|
-
return path3.substring(2);
|
|
143
|
-
}
|
|
144
|
-
return path3;
|
|
145
|
-
}
|
|
146
|
-
function parseGitDiffHeader(line) {
|
|
147
|
-
const withoutPrefix = line.substring("diff --git ".length);
|
|
148
|
-
let bIdx = -1;
|
|
149
|
-
for (const prefix of [" b/", " w/", " i/", " c/", " o/"]) {
|
|
150
|
-
bIdx = withoutPrefix.indexOf(prefix);
|
|
151
|
-
if (bIdx !== -1) break;
|
|
152
|
-
}
|
|
153
|
-
if (bIdx === -1) {
|
|
154
|
-
return { oldPath: "", newPath: "" };
|
|
155
|
-
}
|
|
156
|
-
const oldPath = stripPrefix(withoutPrefix.substring(0, bIdx));
|
|
157
|
-
const newPath = stripPrefix(withoutPrefix.substring(bIdx + 1));
|
|
158
|
-
return { oldPath, newPath };
|
|
159
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
parseDiff
|
|
3
|
+
} from "./chunk-OQRS7NDT.js";
|
|
4
|
+
import {
|
|
5
|
+
generateSyntheticDiffs,
|
|
6
|
+
generateUntrackedDiffs,
|
|
7
|
+
getRepoRoot,
|
|
8
|
+
getRepoRootAsync,
|
|
9
|
+
getUntrackedFilesAsync,
|
|
10
|
+
runGitDiff,
|
|
11
|
+
runGitDiffAsync,
|
|
12
|
+
stripTrailingNewline,
|
|
13
|
+
validateGitAvailable
|
|
14
|
+
} from "./chunk-A7A5ZFT3.js";
|
|
160
15
|
|
|
161
16
|
// src/xml-serializer.ts
|
|
162
17
|
import * as path from "path";
|
|
@@ -857,9 +712,13 @@ async function serializeReview(state, outputFilePath) {
|
|
|
857
712
|
throw error;
|
|
858
713
|
}
|
|
859
714
|
if (error instanceof Error) {
|
|
860
|
-
console.error(
|
|
715
|
+
console.error(
|
|
716
|
+
`[main] XML validation infrastructure failed: ${error.message} - emitting XML without validation`
|
|
717
|
+
);
|
|
861
718
|
} else {
|
|
862
|
-
console.error(
|
|
719
|
+
console.error(
|
|
720
|
+
"[main] XML validation infrastructure failed - emitting XML without validation"
|
|
721
|
+
);
|
|
863
722
|
}
|
|
864
723
|
return xml;
|
|
865
724
|
}
|
|
@@ -1373,9 +1232,7 @@ async function parseGuideXml(xmlContent) {
|
|
|
1373
1232
|
try {
|
|
1374
1233
|
const validationResult = await validateXML2({
|
|
1375
1234
|
xml: [{ fileName: "guide.xml", contents: xmlContent }],
|
|
1376
|
-
schema: [
|
|
1377
|
-
{ fileName: "self-review-guide-v1.xsd", contents: GUIDE_XSD_SCHEMA }
|
|
1378
|
-
]
|
|
1235
|
+
schema: [{ fileName: "self-review-guide-v1.xsd", contents: GUIDE_XSD_SCHEMA }]
|
|
1379
1236
|
});
|
|
1380
1237
|
if (!validationResult.valid) {
|
|
1381
1238
|
const details = (validationResult.errors || []).map((err) => typeof err === "string" ? err : err.message).join("; ");
|
|
@@ -1450,190 +1307,17 @@ function reconcileGuide(guide, diffFilePaths) {
|
|
|
1450
1307
|
});
|
|
1451
1308
|
}
|
|
1452
1309
|
}
|
|
1453
|
-
const leftover = diffFilePaths.filter((
|
|
1310
|
+
const leftover = diffFilePaths.filter((path4) => !claimed.has(path4));
|
|
1454
1311
|
if (leftover.length > 0) {
|
|
1455
1312
|
resolved.push({
|
|
1456
1313
|
name: IMPLICIT_GUIDE_GROUP_NAME,
|
|
1457
1314
|
implicit: true,
|
|
1458
|
-
files: leftover.map((
|
|
1315
|
+
files: leftover.map((path4) => ({ path: path4 }))
|
|
1459
1316
|
});
|
|
1460
1317
|
}
|
|
1461
1318
|
return resolved;
|
|
1462
1319
|
}
|
|
1463
1320
|
|
|
1464
|
-
// src/git.ts
|
|
1465
|
-
import { execSync, exec, execFile } from "child_process";
|
|
1466
|
-
import { promisify } from "util";
|
|
1467
|
-
|
|
1468
|
-
// src/synthetic-diff.ts
|
|
1469
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
1470
|
-
function generateSyntheticDiffs(paths, rootDir) {
|
|
1471
|
-
const diffs = [];
|
|
1472
|
-
for (const filePath of paths) {
|
|
1473
|
-
const fullPath = `${rootDir}/${filePath}`;
|
|
1474
|
-
let content;
|
|
1475
|
-
try {
|
|
1476
|
-
content = readFileSync2(fullPath);
|
|
1477
|
-
} catch {
|
|
1478
|
-
continue;
|
|
1479
|
-
}
|
|
1480
|
-
const sample = content.subarray(0, 8192);
|
|
1481
|
-
const isBinary = sample.includes(0);
|
|
1482
|
-
if (isBinary) {
|
|
1483
|
-
diffs.push(
|
|
1484
|
-
`diff --git a/${filePath} b/${filePath}
|
|
1485
|
-
new file mode 100644
|
|
1486
|
-
Binary files /dev/null and b/${filePath} differ`
|
|
1487
|
-
);
|
|
1488
|
-
continue;
|
|
1489
|
-
}
|
|
1490
|
-
const text = content.toString("utf-8");
|
|
1491
|
-
const lines = text.split("\n");
|
|
1492
|
-
if (lines.length > 0 && lines[lines.length - 1] === "") {
|
|
1493
|
-
lines.pop();
|
|
1494
|
-
}
|
|
1495
|
-
const lineCount = lines.length;
|
|
1496
|
-
const addedLines = lines.map((line) => `+${line}`).join("\n");
|
|
1497
|
-
let diff = `diff --git a/${filePath} b/${filePath}
|
|
1498
|
-
new file mode 100644
|
|
1499
|
-
--- /dev/null
|
|
1500
|
-
+++ b/${filePath}
|
|
1501
|
-
@@ -0,0 +1,${lineCount} @@
|
|
1502
|
-
` + addedLines;
|
|
1503
|
-
if (text.length > 0 && !text.endsWith("\n")) {
|
|
1504
|
-
diff += "\n\";
|
|
1505
|
-
}
|
|
1506
|
-
diffs.push(diff);
|
|
1507
|
-
}
|
|
1508
|
-
return diffs.join("\n");
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
// src/git.ts
|
|
1512
|
-
var execAsync = promisify(exec);
|
|
1513
|
-
function runGitDiff(args) {
|
|
1514
|
-
try {
|
|
1515
|
-
try {
|
|
1516
|
-
execSync("git --version", { stdio: "ignore" });
|
|
1517
|
-
} catch {
|
|
1518
|
-
console.error("Error: git is not installed or not in PATH");
|
|
1519
|
-
process.exit(1);
|
|
1520
|
-
}
|
|
1521
|
-
try {
|
|
1522
|
-
execSync("git rev-parse --git-dir", { stdio: "ignore" });
|
|
1523
|
-
} catch {
|
|
1524
|
-
console.error(
|
|
1525
|
-
"Error: not a git repository (or any parent up to mount point)"
|
|
1526
|
-
);
|
|
1527
|
-
process.exit(1);
|
|
1528
|
-
}
|
|
1529
|
-
const result = execSync(`git diff ${args.join(" ")}`, {
|
|
1530
|
-
encoding: "utf-8",
|
|
1531
|
-
maxBuffer: 50 * 1024 * 1024
|
|
1532
|
-
// 50MB buffer for large diffs
|
|
1533
|
-
});
|
|
1534
|
-
return result;
|
|
1535
|
-
} catch (error) {
|
|
1536
|
-
if (error instanceof Error) {
|
|
1537
|
-
console.error(`Error running git diff: ${error.message}`);
|
|
1538
|
-
} else {
|
|
1539
|
-
console.error("Error running git diff: unknown error");
|
|
1540
|
-
}
|
|
1541
|
-
process.exit(1);
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
function getRepoRoot() {
|
|
1545
|
-
try {
|
|
1546
|
-
const result = execSync("git rev-parse --show-toplevel", {
|
|
1547
|
-
encoding: "utf-8"
|
|
1548
|
-
});
|
|
1549
|
-
return result.trim();
|
|
1550
|
-
} catch (error) {
|
|
1551
|
-
if (error instanceof Error) {
|
|
1552
|
-
console.error(`Error getting repository root: ${error.message}`);
|
|
1553
|
-
} else {
|
|
1554
|
-
console.error("Error getting repository root: unknown error");
|
|
1555
|
-
}
|
|
1556
|
-
process.exit(1);
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
function validateGitAvailable() {
|
|
1560
|
-
try {
|
|
1561
|
-
execSync("git --version", { stdio: "ignore" });
|
|
1562
|
-
} catch {
|
|
1563
|
-
console.error("Error: git is not installed or not in PATH");
|
|
1564
|
-
process.exit(1);
|
|
1565
|
-
}
|
|
1566
|
-
try {
|
|
1567
|
-
execSync("git rev-parse --git-dir", { stdio: "ignore" });
|
|
1568
|
-
} catch {
|
|
1569
|
-
console.error(
|
|
1570
|
-
"Error: not a git repository (or any parent up to mount point)"
|
|
1571
|
-
);
|
|
1572
|
-
process.exit(1);
|
|
1573
|
-
}
|
|
1574
|
-
}
|
|
1575
|
-
async function getRepoRootAsync(cwd) {
|
|
1576
|
-
try {
|
|
1577
|
-
const { stdout } = await execAsync("git rev-parse --show-toplevel", {
|
|
1578
|
-
timeout: 1e4,
|
|
1579
|
-
// 10 second timeout
|
|
1580
|
-
cwd
|
|
1581
|
-
});
|
|
1582
|
-
return stdout.trim();
|
|
1583
|
-
} catch (error) {
|
|
1584
|
-
if (error instanceof Error) {
|
|
1585
|
-
console.error(`Error getting repository root: ${error.message}`);
|
|
1586
|
-
} else {
|
|
1587
|
-
console.error("Error getting repository root: unknown error");
|
|
1588
|
-
}
|
|
1589
|
-
throw error;
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
async function runGitDiffAsync(args, cwd) {
|
|
1593
|
-
try {
|
|
1594
|
-
const { stdout } = await execAsync(`git diff ${args.join(" ")}`, {
|
|
1595
|
-
maxBuffer: 50 * 1024 * 1024,
|
|
1596
|
-
// 50MB buffer
|
|
1597
|
-
timeout: 3e4,
|
|
1598
|
-
// 30 second timeout
|
|
1599
|
-
cwd
|
|
1600
|
-
});
|
|
1601
|
-
return stdout;
|
|
1602
|
-
} catch (error) {
|
|
1603
|
-
if (error instanceof Error) {
|
|
1604
|
-
console.error(`Error running git diff: ${error.message}`);
|
|
1605
|
-
} else {
|
|
1606
|
-
console.error("Error running git diff: unknown error");
|
|
1607
|
-
}
|
|
1608
|
-
throw error;
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
async function getUntrackedFilesAsync(cwd) {
|
|
1612
|
-
try {
|
|
1613
|
-
const { stdout } = await execAsync(
|
|
1614
|
-
"git ls-files --others --exclude-standard",
|
|
1615
|
-
{
|
|
1616
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
1617
|
-
timeout: 1e4,
|
|
1618
|
-
cwd
|
|
1619
|
-
}
|
|
1620
|
-
);
|
|
1621
|
-
return stdout.trim().split("\n").filter((line) => line.length > 0);
|
|
1622
|
-
} catch (error) {
|
|
1623
|
-
if (error instanceof Error) {
|
|
1624
|
-
console.error(
|
|
1625
|
-
`Warning: Failed to list untracked files: ${error.message}`
|
|
1626
|
-
);
|
|
1627
|
-
} else {
|
|
1628
|
-
console.error("Warning: Failed to list untracked files: unknown error");
|
|
1629
|
-
}
|
|
1630
|
-
return [];
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
function generateUntrackedDiffs(paths, repoRoot) {
|
|
1634
|
-
return generateSyntheticDiffs(paths, repoRoot);
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
1321
|
// src/forge-provider.ts
|
|
1638
1322
|
var ForgeCliUnavailableError = class extends Error {
|
|
1639
1323
|
constructor(forge, cli, message) {
|
|
@@ -1695,20 +1379,14 @@ async function scanDirectory(directoryPath, ignorePatterns = []) {
|
|
|
1695
1379
|
try {
|
|
1696
1380
|
const dirStat = await stat(directoryPath);
|
|
1697
1381
|
if (!dirStat.isDirectory()) {
|
|
1698
|
-
console.error(
|
|
1699
|
-
`Error: "${directoryPath}" is not a directory`
|
|
1700
|
-
);
|
|
1382
|
+
console.error(`Error: "${directoryPath}" is not a directory`);
|
|
1701
1383
|
return [];
|
|
1702
1384
|
}
|
|
1703
1385
|
} catch (error) {
|
|
1704
1386
|
if (error instanceof Error) {
|
|
1705
|
-
console.error(
|
|
1706
|
-
`Error accessing directory "${directoryPath}": ${error.message}`
|
|
1707
|
-
);
|
|
1387
|
+
console.error(`Error accessing directory "${directoryPath}": ${error.message}`);
|
|
1708
1388
|
} else {
|
|
1709
|
-
console.error(
|
|
1710
|
-
`Error accessing directory "${directoryPath}": unknown error`
|
|
1711
|
-
);
|
|
1389
|
+
console.error(`Error accessing directory "${directoryPath}": unknown error`);
|
|
1712
1390
|
}
|
|
1713
1391
|
return [];
|
|
1714
1392
|
}
|
|
@@ -1729,13 +1407,9 @@ async function scanDirectory(directoryPath, ignorePatterns = []) {
|
|
|
1729
1407
|
}
|
|
1730
1408
|
} catch (error) {
|
|
1731
1409
|
if (error instanceof Error) {
|
|
1732
|
-
console.error(
|
|
1733
|
-
`Error reading directory "${directoryPath}": ${error.message}`
|
|
1734
|
-
);
|
|
1410
|
+
console.error(`Error reading directory "${directoryPath}": ${error.message}`);
|
|
1735
1411
|
} else {
|
|
1736
|
-
console.error(
|
|
1737
|
-
`Error reading directory "${directoryPath}": unknown error`
|
|
1738
|
-
);
|
|
1412
|
+
console.error(`Error reading directory "${directoryPath}": unknown error`);
|
|
1739
1413
|
}
|
|
1740
1414
|
return [];
|
|
1741
1415
|
}
|
|
@@ -1770,7 +1444,7 @@ async function scanFile(filePath) {
|
|
|
1770
1444
|
}
|
|
1771
1445
|
|
|
1772
1446
|
// src/config.ts
|
|
1773
|
-
import { readFileSync as
|
|
1447
|
+
import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
|
|
1774
1448
|
import { join as join3 } from "path";
|
|
1775
1449
|
import { homedir } from "os";
|
|
1776
1450
|
import { parse as parseYaml } from "yaml";
|
|
@@ -1847,20 +1521,13 @@ var defaults = {
|
|
|
1847
1521
|
};
|
|
1848
1522
|
function loadConfig() {
|
|
1849
1523
|
let config = { ...defaults };
|
|
1850
|
-
const userConfigPath = join3(
|
|
1851
|
-
homedir(),
|
|
1852
|
-
".config",
|
|
1853
|
-
"self-review",
|
|
1854
|
-
"config.yaml"
|
|
1855
|
-
);
|
|
1524
|
+
const userConfigPath = join3(homedir(), ".config", "self-review", "config.yaml");
|
|
1856
1525
|
if (existsSync2(userConfigPath)) {
|
|
1857
1526
|
try {
|
|
1858
1527
|
const userConfig = loadYamlConfig(userConfigPath);
|
|
1859
1528
|
config = mergeConfig(config, userConfig);
|
|
1860
1529
|
} catch (error) {
|
|
1861
|
-
console.error(
|
|
1862
|
-
`Warning: Failed to load user config from ${userConfigPath}: ${error}`
|
|
1863
|
-
);
|
|
1530
|
+
console.error(`Warning: Failed to load user config from ${userConfigPath}: ${error}`);
|
|
1864
1531
|
}
|
|
1865
1532
|
}
|
|
1866
1533
|
const projectConfigPath = join3(process.cwd(), ".self-review.yaml");
|
|
@@ -1869,15 +1536,13 @@ function loadConfig() {
|
|
|
1869
1536
|
const projectConfig = loadYamlConfig(projectConfigPath);
|
|
1870
1537
|
config = mergeConfig(config, projectConfig);
|
|
1871
1538
|
} catch (error) {
|
|
1872
|
-
console.error(
|
|
1873
|
-
`Warning: Failed to load project config from ${projectConfigPath}: ${error}`
|
|
1874
|
-
);
|
|
1539
|
+
console.error(`Warning: Failed to load project config from ${projectConfigPath}: ${error}`);
|
|
1875
1540
|
}
|
|
1876
1541
|
}
|
|
1877
1542
|
return config;
|
|
1878
1543
|
}
|
|
1879
|
-
function loadYamlConfig(
|
|
1880
|
-
const content =
|
|
1544
|
+
function loadYamlConfig(path4) {
|
|
1545
|
+
const content = readFileSync2(path4, "utf-8");
|
|
1881
1546
|
const raw = parseYaml(content);
|
|
1882
1547
|
if (raw === null || raw === void 0) {
|
|
1883
1548
|
return {};
|
|
@@ -1890,18 +1555,14 @@ function loadYamlConfig(path3) {
|
|
|
1890
1555
|
if (["light", "dark", "system"].includes(raw.theme)) {
|
|
1891
1556
|
config.theme = raw.theme;
|
|
1892
1557
|
} else {
|
|
1893
|
-
console.error(
|
|
1894
|
-
`Warning: Invalid theme value "${raw.theme}", using default`
|
|
1895
|
-
);
|
|
1558
|
+
console.error(`Warning: Invalid theme value "${raw.theme}", using default`);
|
|
1896
1559
|
}
|
|
1897
1560
|
}
|
|
1898
1561
|
if ("diff-view" in raw) {
|
|
1899
1562
|
if (["split", "unified"].includes(raw["diff-view"])) {
|
|
1900
1563
|
config.diffView = raw["diff-view"];
|
|
1901
1564
|
} else {
|
|
1902
|
-
console.error(
|
|
1903
|
-
`Warning: Invalid diff-view value "${raw["diff-view"]}", using default`
|
|
1904
|
-
);
|
|
1565
|
+
console.error(`Warning: Invalid diff-view value "${raw["diff-view"]}", using default`);
|
|
1905
1566
|
}
|
|
1906
1567
|
}
|
|
1907
1568
|
if ("font-size" in raw && typeof raw["font-size"] === "number") {
|
|
@@ -1911,14 +1572,19 @@ function loadYamlConfig(path3) {
|
|
|
1911
1572
|
config.outputFormat = raw["output-format"];
|
|
1912
1573
|
}
|
|
1913
1574
|
if ("ignore" in raw && Array.isArray(raw.ignore)) {
|
|
1914
|
-
config.ignore = raw.ignore.filter(
|
|
1915
|
-
(item) => typeof item === "string"
|
|
1916
|
-
);
|
|
1575
|
+
config.ignore = raw.ignore.filter((item) => typeof item === "string");
|
|
1917
1576
|
}
|
|
1918
1577
|
if ("categories" in raw && Array.isArray(raw.categories)) {
|
|
1919
|
-
|
|
1920
|
-
(cat) => cat !== null && typeof cat === "object" && typeof cat.name === "string" && typeof cat.description === "string" && typeof cat.color === "string"
|
|
1578
|
+
const usableCategories = raw.categories.filter(
|
|
1579
|
+
(cat) => cat !== null && typeof cat === "object" && typeof cat.name === "string" && cat.name !== "" && typeof cat.description === "string" && typeof cat.color === "string"
|
|
1921
1580
|
);
|
|
1581
|
+
if (usableCategories.length > 0) {
|
|
1582
|
+
config.categories = usableCategories;
|
|
1583
|
+
} else {
|
|
1584
|
+
console.error(
|
|
1585
|
+
"Warning: Category configuration has no usable categories, using default categories"
|
|
1586
|
+
);
|
|
1587
|
+
}
|
|
1922
1588
|
}
|
|
1923
1589
|
if ("default-diff-args" in raw && typeof raw["default-diff-args"] === "string") {
|
|
1924
1590
|
config.defaultDiffArgs = raw["default-diff-args"];
|
|
@@ -1955,9 +1621,9 @@ function mergeConfig(base, override) {
|
|
|
1955
1621
|
}
|
|
1956
1622
|
|
|
1957
1623
|
// src/payload-sizing.ts
|
|
1958
|
-
import {
|
|
1959
|
-
import { promisify
|
|
1960
|
-
var
|
|
1624
|
+
import { execFile } from "child_process";
|
|
1625
|
+
import { promisify } from "util";
|
|
1626
|
+
var execFileAsync = promisify(execFile);
|
|
1961
1627
|
function computePayloadStats(fileCount, totalLines, config) {
|
|
1962
1628
|
const maxFiles = config.maxFiles;
|
|
1963
1629
|
const maxTotalLines = config.maxTotalLines;
|
|
@@ -1982,7 +1648,7 @@ function countTotalLines(files) {
|
|
|
1982
1648
|
}
|
|
1983
1649
|
async function getGitDiffStats(args, repoRoot) {
|
|
1984
1650
|
try {
|
|
1985
|
-
const { stdout } = await
|
|
1651
|
+
const { stdout } = await execFileAsync("git", ["diff", "--numstat", ...args], {
|
|
1986
1652
|
maxBuffer: 10 * 1024 * 1024,
|
|
1987
1653
|
timeout: 15e3,
|
|
1988
1654
|
cwd: repoRoot
|
|
@@ -2022,6 +1688,108 @@ function checkWritability(filePath) {
|
|
|
2022
1688
|
}
|
|
2023
1689
|
}
|
|
2024
1690
|
|
|
1691
|
+
// src/apply-suggestion.ts
|
|
1692
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
1693
|
+
import { isAbsolute, relative as relative2, resolve, sep } from "path";
|
|
1694
|
+
function refuse(filePath, reason, detail) {
|
|
1695
|
+
return { status: "refused", filePath, reason, detail };
|
|
1696
|
+
}
|
|
1697
|
+
function errorCode(error) {
|
|
1698
|
+
return error?.code;
|
|
1699
|
+
}
|
|
1700
|
+
function splitLines(content) {
|
|
1701
|
+
if (content === "") return [];
|
|
1702
|
+
const lines = content.split("\n");
|
|
1703
|
+
if (lines[lines.length - 1] === "") lines.pop();
|
|
1704
|
+
return lines;
|
|
1705
|
+
}
|
|
1706
|
+
function isCrlfRegion(anchored) {
|
|
1707
|
+
return anchored.length > 0 && anchored.every((line) => line.endsWith("\r"));
|
|
1708
|
+
}
|
|
1709
|
+
function applySuggestion(request) {
|
|
1710
|
+
const { destinationRoot, filePath, lineRange, suggestion } = request;
|
|
1711
|
+
if (!lineRange) {
|
|
1712
|
+
return refuse(
|
|
1713
|
+
filePath,
|
|
1714
|
+
"no-anchor",
|
|
1715
|
+
"This suggestion is file-level, so there are no lines to replace."
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
if (lineRange.side === "old") {
|
|
1719
|
+
return refuse(
|
|
1720
|
+
filePath,
|
|
1721
|
+
"old-side-anchor",
|
|
1722
|
+
"This suggestion is anchored to deleted lines, which are not in the working file."
|
|
1723
|
+
);
|
|
1724
|
+
}
|
|
1725
|
+
if (!isAbsolute(destinationRoot)) {
|
|
1726
|
+
return refuse(
|
|
1727
|
+
filePath,
|
|
1728
|
+
"destination-not-absolute",
|
|
1729
|
+
"The destination directory must be an absolute path."
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
const root = resolve(destinationRoot);
|
|
1733
|
+
const absolutePath = resolve(root, filePath);
|
|
1734
|
+
const rel = relative2(root, absolutePath);
|
|
1735
|
+
if (isAbsolute(filePath) || rel === "" || rel === ".." || rel.startsWith(`..${sep}`)) {
|
|
1736
|
+
return refuse(
|
|
1737
|
+
filePath,
|
|
1738
|
+
"path-escapes-destination",
|
|
1739
|
+
"The file path resolves outside the destination directory."
|
|
1740
|
+
);
|
|
1741
|
+
}
|
|
1742
|
+
let buffer;
|
|
1743
|
+
try {
|
|
1744
|
+
buffer = readFileSync3(absolutePath);
|
|
1745
|
+
} catch (error) {
|
|
1746
|
+
const code = errorCode(error);
|
|
1747
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
1748
|
+
return refuse(filePath, "file-missing", "The file is not in the destination directory.");
|
|
1749
|
+
}
|
|
1750
|
+
return refuse(
|
|
1751
|
+
filePath,
|
|
1752
|
+
"file-unreadable",
|
|
1753
|
+
`The file could not be read (${code ?? "unknown"}).`
|
|
1754
|
+
);
|
|
1755
|
+
}
|
|
1756
|
+
const content = buffer.toString("utf8");
|
|
1757
|
+
if (!Buffer.from(content, "utf8").equals(buffer)) {
|
|
1758
|
+
return refuse(filePath, "file-not-utf8", "The file is not valid UTF-8 text.");
|
|
1759
|
+
}
|
|
1760
|
+
const lines = splitLines(content);
|
|
1761
|
+
const { start, end } = lineRange;
|
|
1762
|
+
if (start < 1 || end < start || end > lines.length) {
|
|
1763
|
+
return refuse(
|
|
1764
|
+
filePath,
|
|
1765
|
+
"anchor-out-of-range",
|
|
1766
|
+
`Lines ${start}-${end} are outside this file, which has ${lines.length} line(s).`
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1769
|
+
const anchored = lines.slice(start - 1, end);
|
|
1770
|
+
if (anchored.join("\n") !== suggestion.originalCode) {
|
|
1771
|
+
return refuse(
|
|
1772
|
+
filePath,
|
|
1773
|
+
"context-mismatch",
|
|
1774
|
+
`Lines ${start}-${end} no longer match the code this suggestion was written against.`
|
|
1775
|
+
);
|
|
1776
|
+
}
|
|
1777
|
+
const proposed = suggestion.proposedCode.split("\n");
|
|
1778
|
+
const replacement = isCrlfRegion(anchored) ? proposed.map((line) => line.endsWith("\r") ? line : `${line}\r`) : proposed;
|
|
1779
|
+
const updated = [...lines.slice(0, start - 1), ...replacement, ...lines.slice(end)];
|
|
1780
|
+
const output = updated.join("\n") + (content.endsWith("\n") ? "\n" : "");
|
|
1781
|
+
try {
|
|
1782
|
+
writeFileSync2(absolutePath, output, "utf8");
|
|
1783
|
+
} catch (error) {
|
|
1784
|
+
return refuse(
|
|
1785
|
+
filePath,
|
|
1786
|
+
"write-failed",
|
|
1787
|
+
`The file could not be written (${errorCode(error) ?? "unknown"}).`
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1790
|
+
return { status: "applied", filePath, absolutePath, replacedLines: anchored.length };
|
|
1791
|
+
}
|
|
1792
|
+
|
|
2025
1793
|
// src/file-type-utils.ts
|
|
2026
1794
|
var RASTER_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png", ".gif", ".webp", ".ico", ".bmp"]);
|
|
2027
1795
|
var MARKDOWN_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown"]);
|
|
@@ -2126,11 +1894,7 @@ async function runGh(runCommand, args) {
|
|
|
2126
1894
|
result = await runCommand(GH_CLI, args);
|
|
2127
1895
|
} catch (error) {
|
|
2128
1896
|
const detail = error instanceof Error ? error.message : String(error);
|
|
2129
|
-
throw new ForgeCliUnavailableError(
|
|
2130
|
-
"github",
|
|
2131
|
-
GH_CLI,
|
|
2132
|
-
`Failed to run the gh CLI: ${detail}`
|
|
2133
|
-
);
|
|
1897
|
+
throw new ForgeCliUnavailableError("github", GH_CLI, `Failed to run the gh CLI: ${detail}`);
|
|
2134
1898
|
}
|
|
2135
1899
|
if (result.exitCode !== 0) {
|
|
2136
1900
|
const detail = result.stderr.trim() || `exit code ${result.exitCode}`;
|
|
@@ -2209,11 +1973,7 @@ function createGitHubProvider(runCommand) {
|
|
|
2209
1973
|
]);
|
|
2210
1974
|
const parsed = parseGhJson(stdout, "pr view");
|
|
2211
1975
|
if (typeof parsed?.baseRefName !== "string" || parsed.baseRefName === "") {
|
|
2212
|
-
throw new ForgeCliUnavailableError(
|
|
2213
|
-
"github",
|
|
2214
|
-
GH_CLI,
|
|
2215
|
-
"gh pr view returned no baseRefName"
|
|
2216
|
-
);
|
|
1976
|
+
throw new ForgeCliUnavailableError("github", GH_CLI, "gh pr view returned no baseRefName");
|
|
2217
1977
|
}
|
|
2218
1978
|
return parsed.baseRefName;
|
|
2219
1979
|
},
|
|
@@ -2266,6 +2026,69 @@ function mapAnchorToLineRange(anchor) {
|
|
|
2266
2026
|
function internalId(turn) {
|
|
2267
2027
|
return `remote-${turn.remoteId}`;
|
|
2268
2028
|
}
|
|
2029
|
+
var FENCE_OPEN = /^( {0,3})(`{3,}|~{3,})(.*)$/;
|
|
2030
|
+
function stripCr(line) {
|
|
2031
|
+
return line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
2032
|
+
}
|
|
2033
|
+
function stripIndent(line, width) {
|
|
2034
|
+
let i = 0;
|
|
2035
|
+
while (i < width && line[i] === " ") i++;
|
|
2036
|
+
return line.slice(i);
|
|
2037
|
+
}
|
|
2038
|
+
function isClosingFence(line, marker) {
|
|
2039
|
+
const match = FENCE_OPEN.exec(line);
|
|
2040
|
+
return match !== null && match[2][0] === marker[0] && match[2].length >= marker.length && match[3].trim() === "";
|
|
2041
|
+
}
|
|
2042
|
+
function findSuggestionBlocks(body) {
|
|
2043
|
+
const lines = body.split("\n").map(stripCr);
|
|
2044
|
+
const blocks = [];
|
|
2045
|
+
let i = 0;
|
|
2046
|
+
while (i < lines.length) {
|
|
2047
|
+
const open = FENCE_OPEN.exec(lines[i]);
|
|
2048
|
+
if (!open) {
|
|
2049
|
+
i++;
|
|
2050
|
+
continue;
|
|
2051
|
+
}
|
|
2052
|
+
const [, indent, marker, info] = open;
|
|
2053
|
+
if (marker[0] === "`" && info.includes("`")) {
|
|
2054
|
+
i++;
|
|
2055
|
+
continue;
|
|
2056
|
+
}
|
|
2057
|
+
const content = [];
|
|
2058
|
+
let j = i + 1;
|
|
2059
|
+
for (; j < lines.length && !isClosingFence(lines[j], marker); j++) {
|
|
2060
|
+
content.push(stripIndent(lines[j], indent.length));
|
|
2061
|
+
}
|
|
2062
|
+
if (info.trim().toLowerCase() === "suggestion") {
|
|
2063
|
+
blocks.push(content.join("\n"));
|
|
2064
|
+
}
|
|
2065
|
+
i = j + 1;
|
|
2066
|
+
}
|
|
2067
|
+
return blocks;
|
|
2068
|
+
}
|
|
2069
|
+
function readAnchoredLines(diffFiles, filePath, range) {
|
|
2070
|
+
const sidePath = (file2) => range.side === "old" ? file2.oldPath : file2.newPath;
|
|
2071
|
+
const file = diffFiles.find((f) => sidePath(f) === filePath) ?? diffFiles.find((f) => f.oldPath === filePath || f.newPath === filePath);
|
|
2072
|
+
if (!file) return null;
|
|
2073
|
+
const found = [];
|
|
2074
|
+
for (const hunk of file.hunks) {
|
|
2075
|
+
for (const line of hunk.lines) {
|
|
2076
|
+
const number = range.side === "old" ? line.oldLineNumber : line.newLineNumber;
|
|
2077
|
+
if (number !== null && number >= range.start && number <= range.end) {
|
|
2078
|
+
found.push(line.content);
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
return found.length === range.end - range.start + 1 ? found.join("\n") : null;
|
|
2083
|
+
}
|
|
2084
|
+
function extractSuggestion(body, filePath, range, diffFiles) {
|
|
2085
|
+
if (!range) return null;
|
|
2086
|
+
const blocks = findSuggestionBlocks(body);
|
|
2087
|
+
if (blocks.length !== 1) return null;
|
|
2088
|
+
const originalCode = readAnchoredLines(diffFiles, filePath, range);
|
|
2089
|
+
if (originalCode === null) return null;
|
|
2090
|
+
return { originalCode, proposedCode: blocks[0] };
|
|
2091
|
+
}
|
|
2269
2092
|
function mapReply(turn) {
|
|
2270
2093
|
return {
|
|
2271
2094
|
id: internalId(turn),
|
|
@@ -2274,15 +2097,17 @@ function mapReply(turn) {
|
|
|
2274
2097
|
remoteId: turn.remoteId
|
|
2275
2098
|
};
|
|
2276
2099
|
}
|
|
2277
|
-
function mapThreadsToReviewComments(threads) {
|
|
2100
|
+
function mapThreadsToReviewComments(threads, diffFiles = []) {
|
|
2278
2101
|
return threads.map((thread) => {
|
|
2102
|
+
const filePath = thread.anchor?.filePath ?? REVIEW_LEVEL_FILE_PATH;
|
|
2103
|
+
const lineRange = thread.anchor ? mapAnchorToLineRange(thread.anchor) : null;
|
|
2279
2104
|
const comment = {
|
|
2280
2105
|
id: internalId(thread.root),
|
|
2281
|
-
filePath
|
|
2282
|
-
lineRange
|
|
2106
|
+
filePath,
|
|
2107
|
+
lineRange,
|
|
2283
2108
|
body: thread.root.body,
|
|
2284
2109
|
category: "",
|
|
2285
|
-
suggestion:
|
|
2110
|
+
suggestion: extractSuggestion(thread.root.body, filePath, lineRange, diffFiles),
|
|
2286
2111
|
author: thread.root.author,
|
|
2287
2112
|
remoteId: thread.root.remoteId
|
|
2288
2113
|
};
|
|
@@ -2442,24 +2267,19 @@ import * as path2 from "path";
|
|
|
2442
2267
|
var LOCAL_BASE_REF = "refs/self-review/base";
|
|
2443
2268
|
var LOCAL_HEAD_REF = "refs/self-review/head";
|
|
2444
2269
|
var AUTH_HINT = "Hint: if this repository is private or requires authentication, run `gh auth setup-git` (GitHub) or `glab auth git-credential` (GitLab) to wire your CLI credentials into git.";
|
|
2445
|
-
var defaultGitRunner = (command, args) => new Promise((
|
|
2446
|
-
execFile2(
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
const spawnCode = error?.code;
|
|
2452
|
-
if (error && typeof spawnCode === "string") {
|
|
2453
|
-
reject(error);
|
|
2454
|
-
return;
|
|
2455
|
-
}
|
|
2456
|
-
resolve({
|
|
2457
|
-
stdout: stdout ?? "",
|
|
2458
|
-
stderr: stderr ?? "",
|
|
2459
|
-
exitCode: error ? typeof spawnCode === "number" ? spawnCode : 1 : 0
|
|
2460
|
-
});
|
|
2270
|
+
var defaultGitRunner = (command, args) => new Promise((resolve6, reject) => {
|
|
2271
|
+
execFile2(command, args, { maxBuffer: 50 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
2272
|
+
const spawnCode = error?.code;
|
|
2273
|
+
if (error && typeof spawnCode === "string") {
|
|
2274
|
+
reject(error);
|
|
2275
|
+
return;
|
|
2461
2276
|
}
|
|
2462
|
-
|
|
2277
|
+
resolve6({
|
|
2278
|
+
stdout: stdout ?? "",
|
|
2279
|
+
stderr: stderr ?? "",
|
|
2280
|
+
exitCode: error ? typeof spawnCode === "number" ? spawnCode : 1 : 0
|
|
2281
|
+
});
|
|
2282
|
+
});
|
|
2463
2283
|
});
|
|
2464
2284
|
function headRefFor(url) {
|
|
2465
2285
|
return url.forge === "github" ? `refs/pull/${url.number}/head` : `refs/merge-requests/${url.number}/head`;
|
|
@@ -2528,7 +2348,7 @@ async function detectExistingClone(url, cwd, runner = defaultGitRunner) {
|
|
|
2528
2348
|
if (toplevel.exitCode !== 0) {
|
|
2529
2349
|
return null;
|
|
2530
2350
|
}
|
|
2531
|
-
const repoPath = toplevel.stdout
|
|
2351
|
+
const repoPath = stripTrailingNewline(toplevel.stdout);
|
|
2532
2352
|
const remotes = await runner("git", ["-C", repoPath, "remote", "-v"]);
|
|
2533
2353
|
if (remotes.exitCode !== 0) {
|
|
2534
2354
|
return null;
|
|
@@ -2537,9 +2357,7 @@ async function detectExistingClone(url, cwd, runner = defaultGitRunner) {
|
|
|
2537
2357
|
return remoteName === null ? null : { repoPath, remoteName };
|
|
2538
2358
|
}
|
|
2539
2359
|
async function materializeIntoExistingClone(runner, url, baseBranch, repoPath, remoteName) {
|
|
2540
|
-
console.error(
|
|
2541
|
-
`self-review: reusing existing clone at ${repoPath} (remote "${remoteName}")`
|
|
2542
|
-
);
|
|
2360
|
+
console.error(`self-review: reusing existing clone at ${repoPath} (remote "${remoteName}")`);
|
|
2543
2361
|
const fetch = await runner("git", [
|
|
2544
2362
|
"-C",
|
|
2545
2363
|
repoPath,
|
|
@@ -2569,16 +2387,9 @@ async function materializeIntoTempClone(runner, url, baseBranch) {
|
|
|
2569
2387
|
fs2.rmSync(tempDir, { recursive: true, force: true });
|
|
2570
2388
|
};
|
|
2571
2389
|
try {
|
|
2572
|
-
console.error(
|
|
2573
|
-
`self-review: created temporary blobless clone at ${tempDir}`
|
|
2574
|
-
);
|
|
2390
|
+
console.error(`self-review: created temporary blobless clone at ${tempDir}`);
|
|
2575
2391
|
const cloneUrl = cloneUrlFor(url);
|
|
2576
|
-
const clone = await runner("git", [
|
|
2577
|
-
"clone",
|
|
2578
|
-
"--filter=blob:none",
|
|
2579
|
-
cloneUrl,
|
|
2580
|
-
tempDir
|
|
2581
|
-
]);
|
|
2392
|
+
const clone = await runner("git", ["clone", "--filter=blob:none", cloneUrl, tempDir]);
|
|
2582
2393
|
if (clone.exitCode !== 0) {
|
|
2583
2394
|
throw gitFailure(`clone of ${cloneUrl}`, clone, true);
|
|
2584
2395
|
}
|
|
@@ -2634,26 +2445,863 @@ async function resolveRemoteDefaultBranch(url, runner = defaultGitRunner, existi
|
|
|
2634
2445
|
}
|
|
2635
2446
|
return match[1];
|
|
2636
2447
|
}
|
|
2448
|
+
|
|
2449
|
+
// src/review-handlers.ts
|
|
2450
|
+
import * as fs3 from "fs";
|
|
2451
|
+
import path3 from "path";
|
|
2452
|
+
|
|
2453
|
+
// src/git-diff-args.ts
|
|
2454
|
+
import { existsSync as existsSync3 } from "fs";
|
|
2455
|
+
import { resolve as resolve2 } from "path";
|
|
2456
|
+
var OPTIONS_WITH_SEPARATE_VALUES = /* @__PURE__ */ new Set([
|
|
2457
|
+
"--output",
|
|
2458
|
+
"--src-prefix",
|
|
2459
|
+
"--dst-prefix",
|
|
2460
|
+
"--line-prefix",
|
|
2461
|
+
"--output-indicator-new",
|
|
2462
|
+
"--output-indicator-old",
|
|
2463
|
+
"--output-indicator-context",
|
|
2464
|
+
"--inter-hunk-context",
|
|
2465
|
+
"--stat-width",
|
|
2466
|
+
"--stat-name-width",
|
|
2467
|
+
"--stat-graph-width",
|
|
2468
|
+
"--stat-count",
|
|
2469
|
+
"--diff-algorithm",
|
|
2470
|
+
"--word-diff-regex",
|
|
2471
|
+
"--ignore-matching-lines",
|
|
2472
|
+
"--anchored",
|
|
2473
|
+
"--diff-filter",
|
|
2474
|
+
"--find-object",
|
|
2475
|
+
"--rotate-to",
|
|
2476
|
+
"--skip-to",
|
|
2477
|
+
"--ws-error-highlight",
|
|
2478
|
+
"--color-moved-ws"
|
|
2479
|
+
]);
|
|
2480
|
+
function consumesNextArgument(arg) {
|
|
2481
|
+
if (arg.startsWith("--")) return OPTIONS_WITH_SEPARATE_VALUES.has(arg);
|
|
2482
|
+
if (!arg.startsWith("-")) return false;
|
|
2483
|
+
for (let i = 1; i < arg.length; i++) {
|
|
2484
|
+
if ("SGOIl".includes(arg[i])) return i === arg.length - 1;
|
|
2485
|
+
if ("UBMC".includes(arg[i])) return false;
|
|
2486
|
+
}
|
|
2487
|
+
return false;
|
|
2488
|
+
}
|
|
2489
|
+
function classifyGitDiffArgs(args) {
|
|
2490
|
+
const positionalIndices = [];
|
|
2491
|
+
let hasSeparator = false;
|
|
2492
|
+
for (let i = 0; i < args.length; i++) {
|
|
2493
|
+
const arg = args[i];
|
|
2494
|
+
if (!hasSeparator) {
|
|
2495
|
+
if (arg === "--") {
|
|
2496
|
+
hasSeparator = true;
|
|
2497
|
+
continue;
|
|
2498
|
+
}
|
|
2499
|
+
if (consumesNextArgument(arg)) {
|
|
2500
|
+
i++;
|
|
2501
|
+
continue;
|
|
2502
|
+
}
|
|
2503
|
+
if (arg.startsWith("-")) continue;
|
|
2504
|
+
}
|
|
2505
|
+
positionalIndices.push(i);
|
|
2506
|
+
}
|
|
2507
|
+
return { positionalIndices, hasSeparator };
|
|
2508
|
+
}
|
|
2509
|
+
function normalizeGitDiffArgs(args, cwd = process.cwd()) {
|
|
2510
|
+
const { positionalIndices, hasSeparator } = classifyGitDiffArgs(args);
|
|
2511
|
+
if (hasSeparator) return args;
|
|
2512
|
+
for (const i of positionalIndices) {
|
|
2513
|
+
const arg = args[i];
|
|
2514
|
+
if (existsSync3(resolve2(cwd, arg))) {
|
|
2515
|
+
return [...args.slice(0, i), "--", ...args.slice(i)];
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
return args;
|
|
2519
|
+
}
|
|
2520
|
+
function tokenizeGitDiffArgs(value) {
|
|
2521
|
+
const args = [];
|
|
2522
|
+
let current = "";
|
|
2523
|
+
let started = false;
|
|
2524
|
+
let quote = null;
|
|
2525
|
+
for (let i = 0; i < value.length; i++) {
|
|
2526
|
+
const char = value[i];
|
|
2527
|
+
if (quote === "'") {
|
|
2528
|
+
if (char === "'") quote = null;
|
|
2529
|
+
else current += char;
|
|
2530
|
+
continue;
|
|
2531
|
+
}
|
|
2532
|
+
if (quote === '"') {
|
|
2533
|
+
if (char === "\\" && (value[i + 1] === '"' || value[i + 1] === "\\")) {
|
|
2534
|
+
current += value[++i];
|
|
2535
|
+
} else if (char === '"') {
|
|
2536
|
+
quote = null;
|
|
2537
|
+
} else {
|
|
2538
|
+
current += char;
|
|
2539
|
+
}
|
|
2540
|
+
continue;
|
|
2541
|
+
}
|
|
2542
|
+
if (char === "'" || char === '"') {
|
|
2543
|
+
quote = char;
|
|
2544
|
+
started = true;
|
|
2545
|
+
continue;
|
|
2546
|
+
}
|
|
2547
|
+
if (char === "\\" && i + 1 < value.length) {
|
|
2548
|
+
current += value[++i];
|
|
2549
|
+
started = true;
|
|
2550
|
+
continue;
|
|
2551
|
+
}
|
|
2552
|
+
if (/\s/.test(char)) {
|
|
2553
|
+
if (started) {
|
|
2554
|
+
args.push(current);
|
|
2555
|
+
current = "";
|
|
2556
|
+
started = false;
|
|
2557
|
+
}
|
|
2558
|
+
continue;
|
|
2559
|
+
}
|
|
2560
|
+
current += char;
|
|
2561
|
+
started = true;
|
|
2562
|
+
}
|
|
2563
|
+
if (started) args.push(current);
|
|
2564
|
+
return args;
|
|
2565
|
+
}
|
|
2566
|
+
function needsQuoting(arg) {
|
|
2567
|
+
return arg.length === 0 || /[\s'"\\]/.test(arg);
|
|
2568
|
+
}
|
|
2569
|
+
function formatGitDiffArgs(args) {
|
|
2570
|
+
return args.map((arg) => needsQuoting(arg) ? `'${arg.replace(/'/g, "'\\''")}'` : arg).join(" ");
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
// src/review-handlers.ts
|
|
2574
|
+
function createReviewSession() {
|
|
2575
|
+
return {
|
|
2576
|
+
reviewState: null,
|
|
2577
|
+
diffData: null,
|
|
2578
|
+
guideData: null,
|
|
2579
|
+
config: null,
|
|
2580
|
+
outputPathInfo: null,
|
|
2581
|
+
resumeComments: [],
|
|
2582
|
+
resumeViewedFiles: [],
|
|
2583
|
+
resumeRemoteDrift: null,
|
|
2584
|
+
applyDestinationRoot: null
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
function preparePayload(payload) {
|
|
2588
|
+
if (payload.isLargePayload) {
|
|
2589
|
+
return {
|
|
2590
|
+
...payload,
|
|
2591
|
+
files: payload.files.map((f) => ({ ...f, hunks: [], contentLoaded: false }))
|
|
2592
|
+
};
|
|
2593
|
+
}
|
|
2594
|
+
return {
|
|
2595
|
+
...payload,
|
|
2596
|
+
files: payload.files.map((f) => ({ ...f, contentLoaded: true }))
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function getDiffLoad(session) {
|
|
2600
|
+
if (!session.diffData) {
|
|
2601
|
+
return null;
|
|
2602
|
+
}
|
|
2603
|
+
return {
|
|
2604
|
+
diff: preparePayload(session.diffData),
|
|
2605
|
+
guide: session.guideData
|
|
2606
|
+
};
|
|
2607
|
+
}
|
|
2608
|
+
function resolveSourceBaseDir(session) {
|
|
2609
|
+
const source = session.diffData?.source;
|
|
2610
|
+
if (!source) return null;
|
|
2611
|
+
if (source.type === "git") return source.repository;
|
|
2612
|
+
if (source.type === "directory") return source.sourcePath;
|
|
2613
|
+
if (source.type === "file") return path3.dirname(source.sourcePath);
|
|
2614
|
+
return null;
|
|
2615
|
+
}
|
|
2616
|
+
async function loadImage(session, filePath) {
|
|
2617
|
+
const MIME_MAP = {
|
|
2618
|
+
".jpg": "image/jpeg",
|
|
2619
|
+
".jpeg": "image/jpeg",
|
|
2620
|
+
".png": "image/png",
|
|
2621
|
+
".gif": "image/gif",
|
|
2622
|
+
".webp": "image/webp",
|
|
2623
|
+
".ico": "image/x-icon",
|
|
2624
|
+
".bmp": "image/bmp",
|
|
2625
|
+
".svg": "image/svg+xml"
|
|
2626
|
+
};
|
|
2627
|
+
const MAX_SIZE = 10 * 1024 * 1024;
|
|
2628
|
+
const baseDir = resolveSourceBaseDir(session) ?? process.cwd();
|
|
2629
|
+
const resolved = path3.isAbsolute(filePath) ? filePath : path3.resolve(baseDir, filePath);
|
|
2630
|
+
const ext = path3.extname(filePath).toLowerCase();
|
|
2631
|
+
const mimeType = MIME_MAP[ext] ?? "application/octet-stream";
|
|
2632
|
+
const remote = session.diffData?.remote;
|
|
2633
|
+
if (remote && session.diffData?.source.type === "git") {
|
|
2634
|
+
try {
|
|
2635
|
+
const { readGitBlobAsync } = await import("./git-E7WZPKRC.js");
|
|
2636
|
+
const data = await readGitBlobAsync(
|
|
2637
|
+
session.diffData.source.repository,
|
|
2638
|
+
`${remote.remoteHeadSha}:${filePath}`
|
|
2639
|
+
);
|
|
2640
|
+
if (data.length > MAX_SIZE) {
|
|
2641
|
+
return { error: "File too large to preview (>10 MB)" };
|
|
2642
|
+
}
|
|
2643
|
+
return { dataUri: `data:${mimeType};base64,${data.toString("base64")}` };
|
|
2644
|
+
} catch {
|
|
2645
|
+
return {
|
|
2646
|
+
error: "Image preview unavailable \u2014 blob not found at the reviewed commit."
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
try {
|
|
2651
|
+
const stat2 = await fs3.promises.stat(resolved);
|
|
2652
|
+
if (stat2.size > MAX_SIZE) {
|
|
2653
|
+
return { error: "File too large to preview (>10 MB)" };
|
|
2654
|
+
}
|
|
2655
|
+
const data = await fs3.promises.readFile(resolved);
|
|
2656
|
+
return { dataUri: `data:${mimeType};base64,${data.toString("base64")}` };
|
|
2657
|
+
} catch {
|
|
2658
|
+
return { error: "Image preview unavailable \u2014 file not found on disk." };
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
function getFileHunks(session, filePath) {
|
|
2662
|
+
if (!session.diffData) return null;
|
|
2663
|
+
const file = session.diffData.files.find((f) => (f.newPath || f.oldPath) === filePath);
|
|
2664
|
+
if (!file) return null;
|
|
2665
|
+
return file.hunks;
|
|
2666
|
+
}
|
|
2667
|
+
function getConfigLoad(session) {
|
|
2668
|
+
if (!session.config) {
|
|
2669
|
+
return null;
|
|
2670
|
+
}
|
|
2671
|
+
return { config: session.config, outputPathInfo: session.outputPathInfo };
|
|
2672
|
+
}
|
|
2673
|
+
function submitReviewState(session, state) {
|
|
2674
|
+
console.error(
|
|
2675
|
+
"[review] Review state submitted:",
|
|
2676
|
+
JSON.stringify({
|
|
2677
|
+
timestamp: state.timestamp,
|
|
2678
|
+
source: state.source,
|
|
2679
|
+
fileCount: state.files.length
|
|
2680
|
+
})
|
|
2681
|
+
);
|
|
2682
|
+
session.reviewState = state;
|
|
2683
|
+
}
|
|
2684
|
+
function takeReviewState(session) {
|
|
2685
|
+
const state = session.reviewState;
|
|
2686
|
+
session.reviewState = null;
|
|
2687
|
+
return state;
|
|
2688
|
+
}
|
|
2689
|
+
function isTemporaryCloneSession(session) {
|
|
2690
|
+
return session.diffData?.remote?.temporaryClone === true;
|
|
2691
|
+
}
|
|
2692
|
+
function resolveApplyDestination(session) {
|
|
2693
|
+
if (isTemporaryCloneSession(session)) {
|
|
2694
|
+
return session.applyDestinationRoot;
|
|
2695
|
+
}
|
|
2696
|
+
return resolveSourceBaseDir(session);
|
|
2697
|
+
}
|
|
2698
|
+
function applySuggestionForSession(session, request) {
|
|
2699
|
+
const destinationRoot = resolveApplyDestination(session);
|
|
2700
|
+
if (!destinationRoot) {
|
|
2701
|
+
const temporary = isTemporaryCloneSession(session);
|
|
2702
|
+
return {
|
|
2703
|
+
status: "refused",
|
|
2704
|
+
filePath: request.filePath,
|
|
2705
|
+
reason: temporary ? "destination-required" : "no-destination",
|
|
2706
|
+
detail: temporary ? "This pull request was cloned into a temporary directory that is deleted when the review ends. Choose a destination directory to apply into." : "This review has no working directory to write into."
|
|
2707
|
+
};
|
|
2708
|
+
}
|
|
2709
|
+
const result = applySuggestion({
|
|
2710
|
+
destinationRoot,
|
|
2711
|
+
filePath: request.filePath,
|
|
2712
|
+
lineRange: request.lineRange,
|
|
2713
|
+
suggestion: request.suggestion
|
|
2714
|
+
});
|
|
2715
|
+
console.error(
|
|
2716
|
+
`[suggestion:apply] ${request.filePath}: ${result.status === "applied" ? "applied" : `refused (${result.reason})`}`
|
|
2717
|
+
);
|
|
2718
|
+
if (result.status === "applied") {
|
|
2719
|
+
return {
|
|
2720
|
+
status: "applied",
|
|
2721
|
+
filePath: result.filePath,
|
|
2722
|
+
replacedLines: result.replacedLines
|
|
2723
|
+
};
|
|
2724
|
+
}
|
|
2725
|
+
return {
|
|
2726
|
+
status: "refused",
|
|
2727
|
+
filePath: result.filePath,
|
|
2728
|
+
reason: result.reason,
|
|
2729
|
+
detail: result.detail
|
|
2730
|
+
};
|
|
2731
|
+
}
|
|
2732
|
+
async function readAttachment(filePath) {
|
|
2733
|
+
try {
|
|
2734
|
+
const buffer = await fs3.promises.readFile(filePath);
|
|
2735
|
+
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
2736
|
+
} catch {
|
|
2737
|
+
console.error(`[attachment:read] Failed to read file: ${filePath}`);
|
|
2738
|
+
return null;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
function getResumeLoad(session) {
|
|
2742
|
+
if (session.resumeComments.length > 0 || session.resumeViewedFiles.length > 0 || session.resumeRemoteDrift !== null) {
|
|
2743
|
+
const payload = {
|
|
2744
|
+
comments: session.resumeComments,
|
|
2745
|
+
viewedFiles: session.resumeViewedFiles
|
|
2746
|
+
};
|
|
2747
|
+
if (session.resumeRemoteDrift !== null) {
|
|
2748
|
+
payload.remoteDrift = session.resumeRemoteDrift;
|
|
2749
|
+
}
|
|
2750
|
+
return payload;
|
|
2751
|
+
}
|
|
2752
|
+
return null;
|
|
2753
|
+
}
|
|
2754
|
+
async function expandContext(session, request) {
|
|
2755
|
+
const diffData = session.diffData;
|
|
2756
|
+
if (!diffData || diffData.source.type !== "git") {
|
|
2757
|
+
return null;
|
|
2758
|
+
}
|
|
2759
|
+
try {
|
|
2760
|
+
const { runGitDiffAsync: runGitDiffAsync2 } = await import("./git-E7WZPKRC.js");
|
|
2761
|
+
const { parseDiff: parseDiff2 } = await import("./diff-parser-2JM4CZR3.js");
|
|
2762
|
+
const source = diffData.source;
|
|
2763
|
+
const originalArgs = tokenizeGitDiffArgs(source.gitDiffArgs);
|
|
2764
|
+
const filteredArgs = [];
|
|
2765
|
+
for (let i = 0; i < originalArgs.length; i++) {
|
|
2766
|
+
const arg = originalArgs[i];
|
|
2767
|
+
if (arg.match(/^-U\d+$/) || arg.match(/^--unified=\d+$/)) {
|
|
2768
|
+
continue;
|
|
2769
|
+
}
|
|
2770
|
+
if (arg === "-U" || arg === "--unified") {
|
|
2771
|
+
i++;
|
|
2772
|
+
continue;
|
|
2773
|
+
}
|
|
2774
|
+
if (arg === "--") {
|
|
2775
|
+
break;
|
|
2776
|
+
}
|
|
2777
|
+
filteredArgs.push(arg);
|
|
2778
|
+
}
|
|
2779
|
+
const expandArgs = [...filteredArgs, `-U${request.contextLines}`, "--", request.filePath];
|
|
2780
|
+
const rawDiff = await runGitDiffAsync2(expandArgs, source.repository);
|
|
2781
|
+
const parsedFiles = parseDiff2(rawDiff);
|
|
2782
|
+
if (parsedFiles.length === 0) {
|
|
2783
|
+
return null;
|
|
2784
|
+
}
|
|
2785
|
+
const expandedFile = parsedFiles[0];
|
|
2786
|
+
let totalLines = 0;
|
|
2787
|
+
try {
|
|
2788
|
+
const content = await fs3.promises.readFile(
|
|
2789
|
+
path3.resolve(source.repository, request.filePath),
|
|
2790
|
+
"utf-8"
|
|
2791
|
+
);
|
|
2792
|
+
totalLines = content.split("\n").length;
|
|
2793
|
+
if (content.endsWith("\n")) totalLines--;
|
|
2794
|
+
} catch {
|
|
2795
|
+
}
|
|
2796
|
+
session.diffData = {
|
|
2797
|
+
...diffData,
|
|
2798
|
+
files: diffData.files.map((f) => {
|
|
2799
|
+
const fPath = f.newPath || f.oldPath;
|
|
2800
|
+
if (fPath === request.filePath) {
|
|
2801
|
+
return { ...f, hunks: expandedFile.hunks };
|
|
2802
|
+
}
|
|
2803
|
+
return f;
|
|
2804
|
+
})
|
|
2805
|
+
};
|
|
2806
|
+
return { hunks: expandedFile.hunks, totalLines };
|
|
2807
|
+
} catch (error) {
|
|
2808
|
+
console.error(`[review] Failed to expand context for ${request.filePath}:`, error);
|
|
2809
|
+
return null;
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
async function prepareDirectoryReview(session, directoryPath) {
|
|
2813
|
+
console.error("[review] Starting directory review for:", directoryPath);
|
|
2814
|
+
let isFile = false;
|
|
2815
|
+
try {
|
|
2816
|
+
isFile = fs3.statSync(directoryPath).isFile();
|
|
2817
|
+
} catch {
|
|
2818
|
+
}
|
|
2819
|
+
let payload;
|
|
2820
|
+
if (isFile) {
|
|
2821
|
+
const files = await scanFile(directoryPath);
|
|
2822
|
+
payload = {
|
|
2823
|
+
files,
|
|
2824
|
+
source: { type: "file", sourcePath: directoryPath }
|
|
2825
|
+
};
|
|
2826
|
+
} else {
|
|
2827
|
+
const ignorePatterns = session.config?.ignore ?? [];
|
|
2828
|
+
const files = await scanDirectory(directoryPath, ignorePatterns);
|
|
2829
|
+
payload = {
|
|
2830
|
+
files,
|
|
2831
|
+
source: { type: "directory", sourcePath: directoryPath }
|
|
2832
|
+
};
|
|
2833
|
+
}
|
|
2834
|
+
if (!session.config) {
|
|
2835
|
+
return { payload, stats: null, exceedsThresholds: false };
|
|
2836
|
+
}
|
|
2837
|
+
const stats = computePayloadStats(
|
|
2838
|
+
payload.files.length,
|
|
2839
|
+
countTotalLines(payload.files),
|
|
2840
|
+
session.config
|
|
2841
|
+
);
|
|
2842
|
+
return { payload, stats, exceedsThresholds: stats.exceedsAny };
|
|
2843
|
+
}
|
|
2844
|
+
function commitReviewStart(session, payload) {
|
|
2845
|
+
session.diffData = payload;
|
|
2846
|
+
return preparePayload(payload);
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
// src/startup-mode.ts
|
|
2850
|
+
import { existsSync as existsSync4, statSync as statSync2 } from "fs";
|
|
2851
|
+
import { execFileSync, execSync } from "child_process";
|
|
2852
|
+
import { resolve as resolve3 } from "path";
|
|
2853
|
+
function isInGitRepo() {
|
|
2854
|
+
try {
|
|
2855
|
+
execSync("git rev-parse --git-dir", { stdio: "ignore" });
|
|
2856
|
+
return true;
|
|
2857
|
+
} catch {
|
|
2858
|
+
return false;
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
function isGitTracked(filePath) {
|
|
2862
|
+
try {
|
|
2863
|
+
execFileSync("git", ["ls-files", "--error-unmatch", "--", filePath], {
|
|
2864
|
+
stdio: "ignore"
|
|
2865
|
+
});
|
|
2866
|
+
return true;
|
|
2867
|
+
} catch {
|
|
2868
|
+
return false;
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
function determineMode(gitDiffArgs) {
|
|
2872
|
+
const { positionalIndices } = classifyGitDiffArgs(gitDiffArgs);
|
|
2873
|
+
const firstPositional = gitDiffArgs[positionalIndices[0]];
|
|
2874
|
+
if (firstPositional) {
|
|
2875
|
+
const candidate = resolve3(process.cwd(), firstPositional);
|
|
2876
|
+
try {
|
|
2877
|
+
if (existsSync4(candidate) && statSync2(candidate).isFile()) {
|
|
2878
|
+
if (isInGitRepo()) {
|
|
2879
|
+
return isGitTracked(firstPositional) ? "git" : "file";
|
|
2880
|
+
}
|
|
2881
|
+
return "file";
|
|
2882
|
+
}
|
|
2883
|
+
} catch {
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
if (isInGitRepo()) {
|
|
2887
|
+
return "git";
|
|
2888
|
+
}
|
|
2889
|
+
if (firstPositional) {
|
|
2890
|
+
const candidate = resolve3(process.cwd(), firstPositional);
|
|
2891
|
+
try {
|
|
2892
|
+
if (existsSync4(candidate) && statSync2(candidate).isDirectory()) {
|
|
2893
|
+
return "directory";
|
|
2894
|
+
}
|
|
2895
|
+
} catch {
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
return "welcome";
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
// src/guide-loader.ts
|
|
2902
|
+
import { readFile } from "fs/promises";
|
|
2903
|
+
import { extname, resolve as resolve4 } from "path";
|
|
2904
|
+
function deriveGuidePath(outputPath) {
|
|
2905
|
+
const ext = extname(outputPath);
|
|
2906
|
+
const base = ext ? outputPath.slice(0, -ext.length) : outputPath;
|
|
2907
|
+
return `${base}.guide.xml`;
|
|
2908
|
+
}
|
|
2909
|
+
function resolveGuidePath(outputPath, config) {
|
|
2910
|
+
if (config.guideFile) {
|
|
2911
|
+
return resolve4(process.cwd(), config.guideFile);
|
|
2912
|
+
}
|
|
2913
|
+
return deriveGuidePath(outputPath);
|
|
2914
|
+
}
|
|
2915
|
+
async function loadGuide(outputPath, config, diffFilePaths) {
|
|
2916
|
+
let guidePath;
|
|
2917
|
+
try {
|
|
2918
|
+
guidePath = resolveGuidePath(outputPath, config);
|
|
2919
|
+
} catch {
|
|
2920
|
+
return null;
|
|
2921
|
+
}
|
|
2922
|
+
try {
|
|
2923
|
+
let content;
|
|
2924
|
+
try {
|
|
2925
|
+
content = await readFile(guidePath, "utf-8");
|
|
2926
|
+
} catch (error) {
|
|
2927
|
+
const code = error.code;
|
|
2928
|
+
if (code === "ENOENT") {
|
|
2929
|
+
return null;
|
|
2930
|
+
}
|
|
2931
|
+
console.error(
|
|
2932
|
+
`[guide] Ignoring guide at ${guidePath}: unreadable (${code ?? "unknown error"})`
|
|
2933
|
+
);
|
|
2934
|
+
return null;
|
|
2935
|
+
}
|
|
2936
|
+
const result = await parseGuideXml(content);
|
|
2937
|
+
if (result.ok === false) {
|
|
2938
|
+
console.error(`[guide] Ignoring guide at ${guidePath}: invalid (${result.reason})`);
|
|
2939
|
+
return null;
|
|
2940
|
+
}
|
|
2941
|
+
const payload = {
|
|
2942
|
+
groups: reconcileGuide(result.guide, diffFilePaths)
|
|
2943
|
+
};
|
|
2944
|
+
if (result.guide.overview !== void 0) {
|
|
2945
|
+
payload.overview = result.guide.overview;
|
|
2946
|
+
}
|
|
2947
|
+
return payload;
|
|
2948
|
+
} catch (error) {
|
|
2949
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2950
|
+
console.error(`[guide] Ignoring guide at ${guidePath}: invalid (${message})`);
|
|
2951
|
+
return null;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
// src/git-diff-loader.ts
|
|
2956
|
+
async function loadGitDiffWithUntracked(gitDiffArgs, cwd, options = {}) {
|
|
2957
|
+
const { includeUntracked = true } = options;
|
|
2958
|
+
const repository = await getRepoRootAsync(cwd);
|
|
2959
|
+
const rawDiff = await runGitDiffAsync(gitDiffArgs, cwd);
|
|
2960
|
+
const files = parseDiff(rawDiff);
|
|
2961
|
+
if (!includeUntracked) {
|
|
2962
|
+
return { files, repository };
|
|
2963
|
+
}
|
|
2964
|
+
const untrackedPaths = await getUntrackedFilesAsync(repository);
|
|
2965
|
+
let allFiles = files;
|
|
2966
|
+
if (untrackedPaths.length > 0) {
|
|
2967
|
+
const untrackedDiffStr = generateUntrackedDiffs(untrackedPaths, repository);
|
|
2968
|
+
if (untrackedDiffStr.length > 0) {
|
|
2969
|
+
const untrackedFiles = parseDiff(untrackedDiffStr);
|
|
2970
|
+
for (const file of untrackedFiles) {
|
|
2971
|
+
file.isUntracked = true;
|
|
2972
|
+
}
|
|
2973
|
+
allFiles = [...files, ...untrackedFiles];
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
return { files: allFiles, repository };
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
// src/staged-untracked.ts
|
|
2980
|
+
function applyStagedUntrackedDefault(config, gitDiffArgs) {
|
|
2981
|
+
const stagedMode = gitDiffArgs.includes("--staged") || gitDiffArgs.includes("--cached");
|
|
2982
|
+
if (!stagedMode) return config;
|
|
2983
|
+
const userExplicitOptIn = config.showUntrackedExplicit && config.showUntracked;
|
|
2984
|
+
if (userExplicitOptIn) return config;
|
|
2985
|
+
return { ...config, showUntracked: false };
|
|
2986
|
+
}
|
|
2987
|
+
|
|
2988
|
+
// src/remote-mode.ts
|
|
2989
|
+
function defaultCreateProvider(forge, runner) {
|
|
2990
|
+
return forge === "github" ? createGitHubProvider(runner) : createGitLabProvider(runner);
|
|
2991
|
+
}
|
|
2992
|
+
var defaultDeps = {
|
|
2993
|
+
createProvider: defaultCreateProvider,
|
|
2994
|
+
detectExistingClone,
|
|
2995
|
+
materialize,
|
|
2996
|
+
resolveRemoteDefaultBranch,
|
|
2997
|
+
runner: defaultGitRunner,
|
|
2998
|
+
loadDiff: (gitDiffArgs, cwd) => (
|
|
2999
|
+
// A base...head diff of a remote PR/MR must never pick up local
|
|
3000
|
+
// untracked files (an existing clone may have unrelated ones).
|
|
3001
|
+
loadGitDiffWithUntracked(gitDiffArgs, cwd, { includeUntracked: false })
|
|
3002
|
+
)
|
|
3003
|
+
};
|
|
3004
|
+
async function startRemoteSession(url, cwd, deps = {}) {
|
|
3005
|
+
const d = { ...defaultDeps, ...deps };
|
|
3006
|
+
const forgeUrl = parseForgeUrl(url);
|
|
3007
|
+
if (!forgeUrl) {
|
|
3008
|
+
throw new Error(`Not a recognized pull-request or merge-request URL: ${url}`);
|
|
3009
|
+
}
|
|
3010
|
+
const provider = d.createProvider(forgeUrl.forge, d.runner);
|
|
3011
|
+
let cliAvailable = true;
|
|
3012
|
+
let baseBranch;
|
|
3013
|
+
let existingClone;
|
|
3014
|
+
try {
|
|
3015
|
+
baseBranch = await provider.fetchBaseBranch(forgeUrl);
|
|
3016
|
+
} catch (error) {
|
|
3017
|
+
if (!(error instanceof ForgeCliUnavailableError)) {
|
|
3018
|
+
throw error;
|
|
3019
|
+
}
|
|
3020
|
+
cliAvailable = false;
|
|
3021
|
+
console.error(
|
|
3022
|
+
`[remote] Forge CLI unavailable (${error.cli}): ${error.message} \u2014 falling back to the remote default branch via git.`
|
|
3023
|
+
);
|
|
3024
|
+
existingClone = await d.detectExistingClone(forgeUrl, cwd, d.runner);
|
|
3025
|
+
baseBranch = await d.resolveRemoteDefaultBranch(forgeUrl, d.runner, existingClone);
|
|
3026
|
+
}
|
|
3027
|
+
const materialized = await d.materialize(forgeUrl, baseBranch, cwd, d.runner, existingClone);
|
|
3028
|
+
let fetchedThreads = [];
|
|
3029
|
+
let threadSyncAvailable = false;
|
|
3030
|
+
if (cliAvailable) {
|
|
3031
|
+
try {
|
|
3032
|
+
fetchedThreads = await provider.fetchThreads(forgeUrl);
|
|
3033
|
+
threadSyncAvailable = true;
|
|
3034
|
+
} catch (error) {
|
|
3035
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3036
|
+
console.error(
|
|
3037
|
+
`[remote] thread sync unavailable \u2014 continuing without forge threads: ${message}`
|
|
3038
|
+
);
|
|
3039
|
+
}
|
|
3040
|
+
} else {
|
|
3041
|
+
console.error(
|
|
3042
|
+
"[remote] thread sync unavailable \u2014 forge CLI missing, continuing without forge threads."
|
|
3043
|
+
);
|
|
3044
|
+
}
|
|
3045
|
+
return {
|
|
3046
|
+
forgeUrl,
|
|
3047
|
+
repoPath: materialized.repoPath,
|
|
3048
|
+
gitDiffArgs: [`${materialized.baseSha}...${materialized.headSha}`],
|
|
3049
|
+
mode: materialized.mode,
|
|
3050
|
+
cleanup: materialized.cleanup,
|
|
3051
|
+
remote: {
|
|
3052
|
+
remoteUrl: url,
|
|
3053
|
+
remoteBaseSha: materialized.baseSha,
|
|
3054
|
+
remoteHeadSha: materialized.headSha,
|
|
3055
|
+
remoteForge: forgeUrl.forge,
|
|
3056
|
+
threadSyncAvailable,
|
|
3057
|
+
// A temporary clone is deleted on exit, so nothing may be written
|
|
3058
|
+
// into it; the front end needs the fact, not the path.
|
|
3059
|
+
temporaryClone: materialized.mode === "temp-clone"
|
|
3060
|
+
},
|
|
3061
|
+
fetchedComments: mapThreadsToReviewComments(fetchedThreads),
|
|
3062
|
+
fetchedThreads
|
|
3063
|
+
};
|
|
3064
|
+
}
|
|
3065
|
+
async function bootstrapRemoteDiff(url, cwd, ignorePatterns, deps = {}) {
|
|
3066
|
+
const d = { ...defaultDeps, ...deps };
|
|
3067
|
+
const started = await startRemoteSession(url, cwd, d);
|
|
3068
|
+
let files;
|
|
3069
|
+
let repository;
|
|
3070
|
+
try {
|
|
3071
|
+
({ files, repository } = await d.loadDiff(started.gitDiffArgs, started.repoPath));
|
|
3072
|
+
} catch (error) {
|
|
3073
|
+
started.cleanup();
|
|
3074
|
+
throw error;
|
|
3075
|
+
}
|
|
3076
|
+
const shouldKeep = createIgnoreFilter(ignorePatterns);
|
|
3077
|
+
const filteredFiles = files.filter((f) => shouldKeep(f.newPath || f.oldPath));
|
|
3078
|
+
const session = {
|
|
3079
|
+
...started,
|
|
3080
|
+
fetchedComments: mapThreadsToReviewComments(started.fetchedThreads, filteredFiles)
|
|
3081
|
+
};
|
|
3082
|
+
return {
|
|
3083
|
+
session,
|
|
3084
|
+
payload: {
|
|
3085
|
+
files: filteredFiles,
|
|
3086
|
+
source: {
|
|
3087
|
+
type: "git",
|
|
3088
|
+
// Same renderer the git-mode path uses, so expand-context can
|
|
3089
|
+
// tokenize this string back into the exact argv.
|
|
3090
|
+
gitDiffArgs: formatGitDiffArgs(session.gitDiffArgs),
|
|
3091
|
+
repository
|
|
3092
|
+
},
|
|
3093
|
+
remote: session.remote
|
|
3094
|
+
}
|
|
3095
|
+
};
|
|
3096
|
+
}
|
|
3097
|
+
function mergeRemoteThreads(resumed, fetched) {
|
|
3098
|
+
const resumedRemoteIds = new Set(
|
|
3099
|
+
resumed.map((c) => c.remoteId).filter((id) => id !== void 0)
|
|
3100
|
+
);
|
|
3101
|
+
return [
|
|
3102
|
+
...resumed,
|
|
3103
|
+
...fetched.filter((c) => c.remoteId === void 0 || !resumedRemoteIds.has(c.remoteId))
|
|
3104
|
+
];
|
|
3105
|
+
}
|
|
3106
|
+
function applyRemoteProvenance(state, remote) {
|
|
3107
|
+
return {
|
|
3108
|
+
...state,
|
|
3109
|
+
// The three source shapes are mutually exclusive in the document: the
|
|
3110
|
+
// remote-* attributes ARE the source, so the in-session git source
|
|
3111
|
+
// (the materialized clone) must not leak into the saved review. The
|
|
3112
|
+
// welcome source emits no source attributes, mirroring fetch-comments.
|
|
3113
|
+
source: { type: "welcome" },
|
|
3114
|
+
remoteUrl: remote.remoteUrl,
|
|
3115
|
+
remoteBaseSha: remote.remoteBaseSha,
|
|
3116
|
+
remoteHeadSha: remote.remoteHeadSha,
|
|
3117
|
+
remoteForge: remote.remoteForge
|
|
3118
|
+
};
|
|
3119
|
+
}
|
|
3120
|
+
function computeRemoteDrift(recordedHeadSha, liveHeadSha) {
|
|
3121
|
+
if (recordedHeadSha === void 0) {
|
|
3122
|
+
return null;
|
|
3123
|
+
}
|
|
3124
|
+
return {
|
|
3125
|
+
recordedHeadSha,
|
|
3126
|
+
liveHeadSha,
|
|
3127
|
+
drifted: recordedHeadSha !== liveHeadSha
|
|
3128
|
+
};
|
|
3129
|
+
}
|
|
3130
|
+
|
|
3131
|
+
// src/fetch-comments.ts
|
|
3132
|
+
import { writeFileSync as writeFileSync3 } from "fs";
|
|
3133
|
+
import { resolve as resolve5 } from "path";
|
|
3134
|
+
function defaultDeps2() {
|
|
3135
|
+
return {
|
|
3136
|
+
runner: defaultGitRunner,
|
|
3137
|
+
createProvider: (forge, runner) => forge === "github" ? createGitHubProvider(runner) : createGitLabProvider(runner),
|
|
3138
|
+
detectExistingClone,
|
|
3139
|
+
materialize,
|
|
3140
|
+
resolveRemoteDefaultBranch,
|
|
3141
|
+
loadDiffFiles: async (repoPath, baseSha, headSha) => (
|
|
3142
|
+
// Triple-dot: diff from the merge base, matching how forges present a
|
|
3143
|
+
// PR/MR diff. Runs inside the materialized clone.
|
|
3144
|
+
parseDiff(await runGitDiffAsync([`${baseSha}...${headSha}`], repoPath))
|
|
3145
|
+
),
|
|
3146
|
+
serialize: serializeReview,
|
|
3147
|
+
writeFile: (path4, content) => writeFileSync3(path4, content, "utf-8"),
|
|
3148
|
+
loadConfig,
|
|
3149
|
+
now: () => /* @__PURE__ */ new Date()
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
function buildRemoteReviewState(args) {
|
|
3153
|
+
const commentsByPath = /* @__PURE__ */ new Map();
|
|
3154
|
+
for (const comment of args.comments) {
|
|
3155
|
+
const list = commentsByPath.get(comment.filePath);
|
|
3156
|
+
if (list) {
|
|
3157
|
+
list.push(comment);
|
|
3158
|
+
} else {
|
|
3159
|
+
commentsByPath.set(comment.filePath, [comment]);
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
const files = [];
|
|
3163
|
+
const diffPaths = /* @__PURE__ */ new Set();
|
|
3164
|
+
for (const diffFile of args.diffFiles) {
|
|
3165
|
+
const path4 = diffFile.changeType === "deleted" ? diffFile.oldPath : diffFile.newPath;
|
|
3166
|
+
diffPaths.add(path4);
|
|
3167
|
+
files.push({
|
|
3168
|
+
path: path4,
|
|
3169
|
+
changeType: diffFile.changeType,
|
|
3170
|
+
viewed: false,
|
|
3171
|
+
comments: commentsByPath.get(path4) ?? []
|
|
3172
|
+
});
|
|
3173
|
+
}
|
|
3174
|
+
for (const [path4, comments] of commentsByPath) {
|
|
3175
|
+
if (path4 === REVIEW_LEVEL_FILE_PATH || diffPaths.has(path4)) continue;
|
|
3176
|
+
files.push({ path: path4, changeType: "modified", viewed: false, comments });
|
|
3177
|
+
}
|
|
3178
|
+
const reviewLevel = commentsByPath.get(REVIEW_LEVEL_FILE_PATH);
|
|
3179
|
+
if (reviewLevel && reviewLevel.length > 0) {
|
|
3180
|
+
files.push({
|
|
3181
|
+
path: REVIEW_LEVEL_FILE_PATH,
|
|
3182
|
+
changeType: "modified",
|
|
3183
|
+
viewed: false,
|
|
3184
|
+
comments: reviewLevel
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
return {
|
|
3188
|
+
timestamp: args.timestamp,
|
|
3189
|
+
source: { type: "welcome" },
|
|
3190
|
+
files,
|
|
3191
|
+
remoteUrl: args.remoteUrl,
|
|
3192
|
+
remoteBaseSha: args.baseSha,
|
|
3193
|
+
remoteHeadSha: args.headSha,
|
|
3194
|
+
remoteForge: args.forge
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3197
|
+
async function runFetchComments(url, options = {}) {
|
|
3198
|
+
const deps = { ...defaultDeps2(), ...options.deps };
|
|
3199
|
+
const cwd = options.cwd ?? process.cwd();
|
|
3200
|
+
const forgeUrl = parseForgeUrl(url);
|
|
3201
|
+
if (forgeUrl === null) {
|
|
3202
|
+
throw new Error(
|
|
3203
|
+
`Not a recognized pull/merge request URL: ${url}
|
|
3204
|
+
Expected a GitHub PR URL (\u2026/pull/N) or a GitLab MR URL (\u2026/-/merge_requests/N).`
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3207
|
+
const provider = deps.createProvider(forgeUrl.forge, deps.runner);
|
|
3208
|
+
let baseBranch;
|
|
3209
|
+
let existingClone;
|
|
3210
|
+
try {
|
|
3211
|
+
baseBranch = await provider.fetchBaseBranch(forgeUrl);
|
|
3212
|
+
} catch (error) {
|
|
3213
|
+
if (!(error instanceof ForgeCliUnavailableError)) throw error;
|
|
3214
|
+
console.error(`[fetch-comments] ${error.message}`);
|
|
3215
|
+
console.error(
|
|
3216
|
+
`[fetch-comments] ${error.cli} unavailable for the base-branch lookup \u2014 falling back to the remote default branch via git ls-remote.`
|
|
3217
|
+
);
|
|
3218
|
+
existingClone = await deps.detectExistingClone(forgeUrl, cwd, deps.runner);
|
|
3219
|
+
baseBranch = await deps.resolveRemoteDefaultBranch(forgeUrl, deps.runner, existingClone);
|
|
3220
|
+
}
|
|
3221
|
+
console.error(`[fetch-comments] Base branch: ${baseBranch}`);
|
|
3222
|
+
const materialized = await deps.materialize(
|
|
3223
|
+
forgeUrl,
|
|
3224
|
+
baseBranch,
|
|
3225
|
+
cwd,
|
|
3226
|
+
deps.runner,
|
|
3227
|
+
existingClone
|
|
3228
|
+
);
|
|
3229
|
+
try {
|
|
3230
|
+
let threads;
|
|
3231
|
+
try {
|
|
3232
|
+
threads = await provider.fetchThreads(forgeUrl, {
|
|
3233
|
+
includeResolved: options.includeResolved ?? false
|
|
3234
|
+
});
|
|
3235
|
+
} catch (error) {
|
|
3236
|
+
if (error instanceof ForgeCliUnavailableError) {
|
|
3237
|
+
throw new Error(
|
|
3238
|
+
`Cannot fetch discussion threads: ${error.message}
|
|
3239
|
+
fetch-comments requires the ${error.cli} CLI to be installed and authenticated.`
|
|
3240
|
+
);
|
|
3241
|
+
}
|
|
3242
|
+
throw error;
|
|
3243
|
+
}
|
|
3244
|
+
console.error(`[fetch-comments] Fetched ${threads.length} threads`);
|
|
3245
|
+
const diffFiles = await deps.loadDiffFiles(
|
|
3246
|
+
materialized.repoPath,
|
|
3247
|
+
materialized.baseSha,
|
|
3248
|
+
materialized.headSha
|
|
3249
|
+
);
|
|
3250
|
+
const comments = mapThreadsToReviewComments(threads, diffFiles);
|
|
3251
|
+
const state = buildRemoteReviewState({
|
|
3252
|
+
remoteUrl: url,
|
|
3253
|
+
forge: forgeUrl.forge,
|
|
3254
|
+
baseSha: materialized.baseSha,
|
|
3255
|
+
headSha: materialized.headSha,
|
|
3256
|
+
diffFiles,
|
|
3257
|
+
comments,
|
|
3258
|
+
timestamp: deps.now().toISOString()
|
|
3259
|
+
});
|
|
3260
|
+
const config = deps.loadConfig();
|
|
3261
|
+
const outputPath = resolve5(cwd, config.outputFile);
|
|
3262
|
+
const xml = await deps.serialize(state, outputPath);
|
|
3263
|
+
deps.writeFile(outputPath, xml + "\n");
|
|
3264
|
+
console.error(`[fetch-comments] ${comments.length} threads written to ${outputPath}`);
|
|
3265
|
+
} finally {
|
|
3266
|
+
materialized.cleanup();
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
2637
3269
|
export {
|
|
2638
3270
|
ForgeCliUnavailableError,
|
|
2639
3271
|
GUIDE_XSD_SCHEMA,
|
|
2640
3272
|
IMPLICIT_GUIDE_GROUP_NAME,
|
|
2641
3273
|
REVIEW_LEVEL_FILE_PATH,
|
|
3274
|
+
applyRemoteProvenance,
|
|
3275
|
+
applyStagedUntrackedDefault,
|
|
3276
|
+
applySuggestion,
|
|
3277
|
+
applySuggestionForSession,
|
|
3278
|
+
bootstrapRemoteDiff,
|
|
3279
|
+
buildRemoteReviewState,
|
|
2642
3280
|
checkWritability,
|
|
3281
|
+
commitReviewStart,
|
|
2643
3282
|
computePayloadStats,
|
|
3283
|
+
computeRemoteDrift,
|
|
2644
3284
|
countTotalLines,
|
|
2645
3285
|
createGitHubProvider,
|
|
2646
3286
|
createGitLabProvider,
|
|
2647
3287
|
createIgnoreFilter,
|
|
3288
|
+
createReviewSession,
|
|
2648
3289
|
defaultGitRunner,
|
|
3290
|
+
deriveGuidePath,
|
|
2649
3291
|
detectExistingClone,
|
|
3292
|
+
determineMode,
|
|
3293
|
+
expandContext,
|
|
2650
3294
|
generateSyntheticDiffs,
|
|
2651
3295
|
generateUntrackedDiffs,
|
|
3296
|
+
getConfigLoad,
|
|
3297
|
+
getDiffLoad,
|
|
3298
|
+
getFileHunks,
|
|
2652
3299
|
getGitDiffStats,
|
|
2653
3300
|
getLanguageFromPath,
|
|
2654
3301
|
getRenderedTextMode,
|
|
2655
3302
|
getRepoRoot,
|
|
2656
3303
|
getRepoRootAsync,
|
|
3304
|
+
getResumeLoad,
|
|
2657
3305
|
getUntrackedFilesAsync,
|
|
2658
3306
|
isHtmlFile,
|
|
2659
3307
|
isMarkdownFile,
|
|
@@ -2661,20 +3309,35 @@ export {
|
|
|
2661
3309
|
isPreviewableRenderedText,
|
|
2662
3310
|
isPreviewableSvg,
|
|
2663
3311
|
loadConfig,
|
|
3312
|
+
loadGitDiffWithUntracked,
|
|
3313
|
+
loadGuide,
|
|
3314
|
+
loadImage,
|
|
2664
3315
|
mapThreadsToReviewComments,
|
|
2665
3316
|
materialize,
|
|
3317
|
+
mergeRemoteThreads,
|
|
3318
|
+
normalizeGitDiffArgs,
|
|
2666
3319
|
parseDiff,
|
|
2667
3320
|
parseForgeUrl,
|
|
2668
3321
|
parseGuideXml,
|
|
2669
3322
|
parseReviewXml,
|
|
2670
3323
|
parseReviewXmlString,
|
|
3324
|
+
prepareDirectoryReview,
|
|
3325
|
+
preparePayload,
|
|
3326
|
+
readAttachment,
|
|
2671
3327
|
reconcileGuide,
|
|
3328
|
+
resolveApplyDestination,
|
|
3329
|
+
resolveGuidePath,
|
|
2672
3330
|
resolveRemoteDefaultBranch,
|
|
3331
|
+
resolveSourceBaseDir,
|
|
3332
|
+
runFetchComments,
|
|
2673
3333
|
runGitDiff,
|
|
2674
3334
|
runGitDiffAsync,
|
|
2675
3335
|
scanDirectory,
|
|
2676
3336
|
scanFile,
|
|
2677
3337
|
serializeReview,
|
|
3338
|
+
startRemoteSession,
|
|
3339
|
+
submitReviewState,
|
|
3340
|
+
takeReviewState,
|
|
2678
3341
|
validateGitAvailable
|
|
2679
3342
|
};
|
|
2680
3343
|
//# sourceMappingURL=index.js.map
|