@buildautomaton/cli 0.1.42 → 0.1.43
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/cli.js +100 -49
- package/dist/cli.js.map +4 -4
- package/dist/index.js +459 -408
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25174,7 +25174,7 @@ var {
|
|
|
25174
25174
|
} = import_index.default;
|
|
25175
25175
|
|
|
25176
25176
|
// src/cli-version.ts
|
|
25177
|
-
var CLI_VERSION = "0.1.
|
|
25177
|
+
var CLI_VERSION = "0.1.43".length > 0 ? "0.1.43" : "0.0.0-dev";
|
|
25178
25178
|
|
|
25179
25179
|
// src/cli/defaults.ts
|
|
25180
25180
|
var DEFAULT_API_URL = process.env.BUILDAUTOMATON_API_URL ?? "https://api.buildautomaton.com";
|
|
@@ -27903,6 +27903,99 @@ function dedupeSessionFileChangesByPath(items, richness = (item) => defaultRichn
|
|
|
27903
27903
|
return Array.from(byPath.entries()).sort(([a], [b]) => a.localeCompare(b)).map(([, v]) => v);
|
|
27904
27904
|
}
|
|
27905
27905
|
|
|
27906
|
+
// ../types/src/diff/line-diff.ts
|
|
27907
|
+
function normalizeDiffLineText(line) {
|
|
27908
|
+
return line.replace(/\r$/, "").replace(/\s*\\s*$/, "");
|
|
27909
|
+
}
|
|
27910
|
+
function normalizePatchContent(patch) {
|
|
27911
|
+
return patch.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
27912
|
+
}
|
|
27913
|
+
function splitTextIntoDiffLines(text) {
|
|
27914
|
+
if (text.length === 0) return [];
|
|
27915
|
+
const lines = text.split("\n").map((line) => normalizeDiffLineText(line));
|
|
27916
|
+
if (text.endsWith("\n") && lines.at(-1) === "") {
|
|
27917
|
+
lines.pop();
|
|
27918
|
+
}
|
|
27919
|
+
return lines;
|
|
27920
|
+
}
|
|
27921
|
+
function createEofNewlineDiffLine(change) {
|
|
27922
|
+
return {
|
|
27923
|
+
type: change === "added" ? "add" : "remove",
|
|
27924
|
+
line: "",
|
|
27925
|
+
oldLineNo: null,
|
|
27926
|
+
newLineNo: null,
|
|
27927
|
+
eofNewlineChange: change
|
|
27928
|
+
};
|
|
27929
|
+
}
|
|
27930
|
+
function hasSameLogicalLines(left, right) {
|
|
27931
|
+
return left.length === right.length && left.every((line, index) => line === right[index]);
|
|
27932
|
+
}
|
|
27933
|
+
function detectEofNewlineChange(oldText, newText, oldLines, newLines) {
|
|
27934
|
+
if (!hasSameLogicalLines(oldLines, newLines) || oldLines.length === 0) return null;
|
|
27935
|
+
if (!oldText.endsWith("\n") && newText.endsWith("\n")) return "added";
|
|
27936
|
+
if (oldText.endsWith("\n") && !newText.endsWith("\n")) return "removed";
|
|
27937
|
+
return null;
|
|
27938
|
+
}
|
|
27939
|
+
function computeLineDiff(oldText, newText) {
|
|
27940
|
+
const oldLines = splitTextIntoDiffLines(oldText);
|
|
27941
|
+
const newLines = splitTextIntoDiffLines(newText);
|
|
27942
|
+
const m = oldLines.length;
|
|
27943
|
+
const n = newLines.length;
|
|
27944
|
+
const dp = Array(m + 1);
|
|
27945
|
+
for (let i2 = 0; i2 <= m; i2++) dp[i2] = Array(n + 1).fill(0);
|
|
27946
|
+
for (let i2 = 1; i2 <= m; i2++) {
|
|
27947
|
+
for (let j2 = 1; j2 <= n; j2++) {
|
|
27948
|
+
if (oldLines[i2 - 1] === newLines[j2 - 1]) {
|
|
27949
|
+
dp[i2][j2] = dp[i2 - 1][j2 - 1] + 1;
|
|
27950
|
+
} else {
|
|
27951
|
+
dp[i2][j2] = Math.max(dp[i2 - 1][j2], dp[i2][j2 - 1]);
|
|
27952
|
+
}
|
|
27953
|
+
}
|
|
27954
|
+
}
|
|
27955
|
+
const result = [];
|
|
27956
|
+
let i = m;
|
|
27957
|
+
let j = n;
|
|
27958
|
+
while (i > 0 || j > 0) {
|
|
27959
|
+
if (i > 0 && j > 0 && oldLines[i - 1] === newLines[j - 1]) {
|
|
27960
|
+
result.unshift({ type: "context", line: oldLines[i - 1] });
|
|
27961
|
+
i--;
|
|
27962
|
+
j--;
|
|
27963
|
+
} else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
|
|
27964
|
+
result.unshift({ type: "add", line: newLines[j - 1] });
|
|
27965
|
+
j--;
|
|
27966
|
+
} else {
|
|
27967
|
+
result.unshift({ type: "remove", line: oldLines[i - 1] });
|
|
27968
|
+
i--;
|
|
27969
|
+
}
|
|
27970
|
+
}
|
|
27971
|
+
const eofNewlineChange = detectEofNewlineChange(oldText, newText, oldLines, newLines);
|
|
27972
|
+
if (eofNewlineChange) result.push(createEofNewlineDiffLine(eofNewlineChange));
|
|
27973
|
+
return result;
|
|
27974
|
+
}
|
|
27975
|
+
function editSnippetToUnifiedDiff(filePath, oldText, newText) {
|
|
27976
|
+
const lines = computeLineDiff(oldText, newText);
|
|
27977
|
+
const out = [`--- ${filePath}`, `+++ ${filePath}`];
|
|
27978
|
+
for (const d of lines) {
|
|
27979
|
+
if (d.eofNewlineChange) {
|
|
27980
|
+
const previous = out.at(-1);
|
|
27981
|
+
if (previous?.startsWith(" ")) {
|
|
27982
|
+
const line = previous.slice(1);
|
|
27983
|
+
out.pop();
|
|
27984
|
+
if (d.eofNewlineChange === "added") {
|
|
27985
|
+
out.push(`-${line}`, "\", `+${line}`);
|
|
27986
|
+
} else {
|
|
27987
|
+
out.push(`-${line}`, `+${line}`, "\");
|
|
27988
|
+
}
|
|
27989
|
+
continue;
|
|
27990
|
+
}
|
|
27991
|
+
}
|
|
27992
|
+
if (d.type === "add") out.push(`+${d.line}`);
|
|
27993
|
+
else if (d.type === "remove") out.push(`-${d.line}`);
|
|
27994
|
+
else out.push(` ${d.line}`);
|
|
27995
|
+
}
|
|
27996
|
+
return out.join("\n");
|
|
27997
|
+
}
|
|
27998
|
+
|
|
27906
27999
|
// ../types/src/artifacts.ts
|
|
27907
28000
|
init_zod();
|
|
27908
28001
|
var ArtifactMetaSchema = external_exports.object({
|
|
@@ -28419,52 +28512,6 @@ function enrichAcpPermissionRpcResultFromRequestParams(result, params) {
|
|
|
28419
28512
|
import { mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
28420
28513
|
import { dirname as dirname3 } from "node:path";
|
|
28421
28514
|
|
|
28422
|
-
// src/files/diff/unified-diff.ts
|
|
28423
|
-
function computeLineDiff(oldText, newText) {
|
|
28424
|
-
const oldLines = oldText.split("\n");
|
|
28425
|
-
const newLines = newText.split("\n");
|
|
28426
|
-
const m = oldLines.length;
|
|
28427
|
-
const n = newLines.length;
|
|
28428
|
-
const dp = Array(m + 1);
|
|
28429
|
-
for (let i2 = 0; i2 <= m; i2++) dp[i2] = Array(n + 1).fill(0);
|
|
28430
|
-
for (let i2 = 1; i2 <= m; i2++) {
|
|
28431
|
-
for (let j2 = 1; j2 <= n; j2++) {
|
|
28432
|
-
if (oldLines[i2 - 1] === newLines[j2 - 1]) {
|
|
28433
|
-
dp[i2][j2] = dp[i2 - 1][j2 - 1] + 1;
|
|
28434
|
-
} else {
|
|
28435
|
-
dp[i2][j2] = Math.max(dp[i2 - 1][j2], dp[i2][j2 - 1]);
|
|
28436
|
-
}
|
|
28437
|
-
}
|
|
28438
|
-
}
|
|
28439
|
-
const result = [];
|
|
28440
|
-
let i = m;
|
|
28441
|
-
let j = n;
|
|
28442
|
-
while (i > 0 || j > 0) {
|
|
28443
|
-
if (i > 0 && j > 0 && oldLines[i - 1] === newLines[j - 1]) {
|
|
28444
|
-
result.unshift({ type: "context", line: oldLines[i - 1] });
|
|
28445
|
-
i--;
|
|
28446
|
-
j--;
|
|
28447
|
-
} else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
|
|
28448
|
-
result.unshift({ type: "add", line: newLines[j - 1] });
|
|
28449
|
-
j--;
|
|
28450
|
-
} else {
|
|
28451
|
-
result.unshift({ type: "remove", line: oldLines[i - 1] });
|
|
28452
|
-
i--;
|
|
28453
|
-
}
|
|
28454
|
-
}
|
|
28455
|
-
return result;
|
|
28456
|
-
}
|
|
28457
|
-
function editSnippetToUnifiedDiff(filePath, oldText, newText) {
|
|
28458
|
-
const lines = computeLineDiff(oldText, newText);
|
|
28459
|
-
const out = [`--- ${filePath}`, `+++ ${filePath}`];
|
|
28460
|
-
for (const d of lines) {
|
|
28461
|
-
if (d.type === "add") out.push(`+${d.line}`);
|
|
28462
|
-
else if (d.type === "remove") out.push(`-${d.line}`);
|
|
28463
|
-
else out.push(` ${d.line}`);
|
|
28464
|
-
}
|
|
28465
|
-
return out.join("\n");
|
|
28466
|
-
}
|
|
28467
|
-
|
|
28468
28515
|
// src/agents/acp/safe-fs-path.ts
|
|
28469
28516
|
import * as path13 from "node:path";
|
|
28470
28517
|
function resolveSafePathUnderCwd(cwd, filePath) {
|
|
@@ -36750,12 +36797,16 @@ async function hydrateUnifiedPatchWithFileContext(patch, filePath, repoGitCwd, p
|
|
|
36750
36797
|
}
|
|
36751
36798
|
|
|
36752
36799
|
// src/git/changes/unified-diff-for-file.ts
|
|
36800
|
+
function patchTextFromGitDiffOutput(raw) {
|
|
36801
|
+
if (raw.trim() === "") return void 0;
|
|
36802
|
+
return normalizePatchContent(raw);
|
|
36803
|
+
}
|
|
36753
36804
|
async function unifiedDiffForFile(repoCwd, pathInRepo, change) {
|
|
36754
36805
|
const g = cliSimpleGit(repoCwd);
|
|
36755
36806
|
const args = change === "added" ? ["diff", "--no-color", "HEAD", "--", pathInRepo] : change === "removed" ? ["diff", "--no-color", "HEAD", "--", pathInRepo] : ["diff", "--no-color", "HEAD", "--", pathInRepo];
|
|
36756
36807
|
const raw = await g.raw([...args]).catch(() => "");
|
|
36757
|
-
const
|
|
36758
|
-
return
|
|
36808
|
+
const patch = patchTextFromGitDiffOutput(String(raw));
|
|
36809
|
+
return patch ? truncatePatch(patch) : void 0;
|
|
36759
36810
|
}
|
|
36760
36811
|
|
|
36761
36812
|
// src/git/changes/list-changed-files-for-repo.ts
|