Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 12 --json
JSON
/christopher/abso-core/versions/12?format=json

record and publish note two things git users know the hard way, without blocking. (1) A file that holds what looks like a git conflict (a '<<<<<<< ' line, a '=======' line, then a '>>>>>>> ' line, other than abso's own blocks) gets: 'Note: <file> has lines that look like a git conflict (from line N)...'. (2) A sent path of 160+ characters inside the folder, or 240+ with the folder's location, gets a note that Windows stops at 260. Both are one line per file, only when the file is sent, and the JSON carries gitMarkers and longPaths. gitMarkerLine is in settle.ts, longPathsOf in commands.ts. Tests: three new ones; the whole suite passes (702) and biome ci is clean.

of shared·review··Not checked

Version 11 · Files at version 12

3 files, 126 lines added, 4 removed.

--- a/client/src/commands.ts
+++ b/client/src/commands.ts
@@ -75,6 +75,8 @@
7575 staleModText,
7676} from "./status-commands.ts";
7777
78+import { gitMarkerLine } from "./settle.ts";
7880// --- record ---
7981
8082interface Recorded {
@@ -91,6 +93,10 @@
9193 readonly news: News;
9294 readonly leftOut: readonly LeftOut[];
9395 readonly turnedBinary: readonly TurnedBinary[];
96+ /** Text files sent that hold what looks like a git conflict (a merge git left unfinished, or markers typed by hand). */
97+ readonly gitMarkers?: readonly { path: string; line: number }[];
98+ /** Sent files whose path is long enough to fail on Windows, here or in another agent's folder. */
99+ readonly longPaths?: readonly { path: string; length: number }[];
94100}
95101
96102/** The warning for text files that turned binary: what, where, and what to do. Empty when there are none. */
@@ -239,14 +245,63 @@
239245 ...(answer.spelling ?? []).map(spellingText),
240246 ...(answer.uncomposed ?? []).map(uncomposedText),
241247 ]);
242− return { sent, paths, deleted, added, changed: answer.changed, news: answer.news, leftOut, turnedBinary };
248+ const longPaths = longPathsOf(
249+ root,
250+ [...files].filter(([, text]) => text !== null).map(([path]) => path),
251+ );
252+ const gitMarkers = [...files]
253+ .flatMap(([path, text]) => {
254+ const line = text === null ? undefined : gitMarkerLine(text);
255+ return line === undefined ? [] : [{ path, line }];
256+ })
257+ .sort((a, b) => (a.path < b.path ? -1 : 1));
258+ return {
259+ sent,
260+ paths,
261+ deleted,
262+ added,
263+ changed: answer.changed,
264+ news: answer.news,
265+ leftOut,
266+ turnedBinary,
267+ gitMarkers,
268+ longPaths,
269+ };
243270}
244271
272+/** A note per file that holds what looks like a git conflict: abso records it as it is, as text, and does not call it a collision. */
273+export function gitMarkerText(list: readonly { path: string; line: number }[] | undefined): string[] {
274+ return (list ?? []).map(
275+ (m) =>
276+ `Note: ${m.path} has lines that look like a git conflict (from line ${m.line}). abso records them as ordinary text and will publish them as they are. If a merge was left unfinished, fix the file first.`,
277+ );
278+}
280+/** Windows stops at 260 characters for a whole path, and another agent's folder may sit deeper than this one. */
281+const LONG_FULL_PATH = 240;
282+const LONG_RELATIVE_PATH = 160;
284+/** The sent files whose path will likely fail to write on Windows: the whole path is near its limit here, or the part inside the folder is already long. */
285+export function longPathsOf(root: string, paths: Iterable<string>): { path: string; length: number }[] {
286+ return [...paths]
287+ .map((path) => ({ path, length: absolute(root, path).length }))
288+ .filter((p) => p.length >= LONG_FULL_PATH || p.path.length >= LONG_RELATIVE_PATH)
289+ .sort((a, b) => (a.path < b.path ? -1 : 1));
290+}
292+/** A note per long path: abso keeps it, but a Windows agent may not be able to write the file. */
293+export function longPathText(list: readonly { path: string; length: number }[] | undefined): string[] {
294+ return (list ?? []).map(
295+ (p) =>
296+ `Note: ${p.path} is ${p.path.length} characters inside the folder (${p.length} with this folder's location). Windows stops at 260 for a whole path, so an agent on Windows may be unable to write it. A shorter path avoids that.`,
297+ );
298+}
245300/** "Recorded 3 files first: a, b, c." (names cut short past 8), or a word that the folder is paused. Empty when nothing was sent. */
246301export function recordedFirst(r: Recorded): string[] {
247302 if (r.paused) return ["Recording is paused (abso resume): your folder's changes were not sent first."];
248303 if (r.sent === 0) return [];
249− return [`Recorded first: ${recordedList(r)}.`];
304+ return [`Recorded first: ${recordedList(r)}.`, ...gitMarkerText(r.gitMarkers), ...longPathText(r.longPaths)];
250305}
251306
252307/** "2 changed (a, b), 3 deleted (x, y, z)": deletions said as such (#37, Builder 2 read its rm'd files as edits). */
@@ -307,13 +362,21 @@
307362 : `Recorded ${recordedList(r)}${changed === undefined ? "" : `; ${changed} changed on the server`}.`;
308363 return withLeftOut(
309364 {
310− text: [...turnedBinaryText(r.turnedBinary), text, ...leftOutText(r.leftOut)].join("\n"),
365+ text: [
366+ ...turnedBinaryText(r.turnedBinary),
367+ text,
368+ ...gitMarkerText(r.gitMarkers),
369+ ...longPathText(r.longPaths),
370+ ...leftOutText(r.leftOut),
371+ ].join("\n"),
311372 json: {
312373 sent: r.sent,
313374 changed: r.changed ?? null,
314375 news: newsLines(r.news),
315376 leftOut: r.leftOut,
316377 turnedBinary: r.turnedBinary,
378+ gitMarkers: r.gitMarkers ?? [],
379+ longPaths: r.longPaths ?? [],
317380 },
318381 },
319382 r.leftOut,
--- a/client/src/settle.ts
+++ b/client/src/settle.ts
@@ -100,3 +100,22 @@
100100 return 0;
101101 }
102102}
104+/**
105+ * The first line (1-based) of what looks like a git conflict left in a text: a "<<<<<<< " line, then a "=======" line,
106+ * then a ">>>>>>> " line. abso's own blocks are not these (their opening line is exact, and `abso settle` finds them);
107+ * a merge done by git, or markers typed or pasted by hand, are plain text to abso, which would publish them as they are.
108+ */
109+export function gitMarkerLine(text: string): number | undefined {
110+ const lines = text.split(/\r?\n/);
111+ for (let i = 0; i < lines.length; i++) {
112+ if (!lines[i]!.startsWith("<<<<<<< ") || lines[i] === OPEN) continue;
113+ let mid = false;
114+ for (let j = i + 1; j < lines.length; j++) {
115+ if (lines[j]!.startsWith("<<<<<<< ")) break;
116+ if (lines[j] === MID) mid = true;
117+ else if (mid && lines[j]!.startsWith(">>>>>>> ")) return i + 1;
118+ }
119+ }
120+ return undefined;
121+}
--- a/client/test/client.test.ts
+++ b/client/test/client.test.ts
@@ -51,7 +51,7 @@
5151import { pulledText } from "../src/queue.ts";
5252import { noteText, titleLine } from "../src/review.ts";
5353import { screenAnswer, throughLink, unsafeLink, unsafePath } from "../src/safety.ts";
54−import { findBlocks, keepFrom, settleText } from "../src/settle.ts";
54+import { findBlocks, gitMarkerLine, keepFrom, settleText } from "../src/settle.ts";
5555import { tar } from "../src/tar.ts";
5656import { type Fake, startFake, untar } from "./fake-server.ts";
5757
@@ -4340,3 +4340,43 @@
43404340 for (const [path, data] of files) assert.deepEqual(back.get(path), data);
43414341 });
43424342});
4344+describe("git conflict markers typed or left by hand", () => {
4345+ it("finds what looks like a git conflict, and not abso's own blocks or a lone marker", () => {
4346+ const git = "a\n<<<<<<< HEAD\nmine\n=======\ntheirs\n>>>>>>> feature\nb\n";
4347+ assert.equal(gitMarkerLine(git), 2);
4348+ assert.equal(gitMarkerLine(git.replaceAll("\n", "\r\n")), 2, "CRLF files too");
4349+ assert.equal(gitMarkerLine("a\n=======\nb\n"), undefined, "a lone ======= is a heading underline");
4350+ assert.equal(gitMarkerLine("<<<<<<< HEAD\nmine\n"), undefined, "no middle and no close");
4351+ const mine =
4352+ '<<<<<<< yours (unpublished)\nx\n||||||| before (version 3)\ny\n=======\nz\n>>>>>>> theirs: bob, version 4 "m"\n';
4353+ assert.equal(gitMarkerLine(mine), undefined, "abso's own blocks are settled with abso settle");
4354+ });
4356+ it("record and publish say so, once, and still send the file", async () => {
4357+ const { folders } = await project({ "a.txt": "a\n" }, "alice");
4358+ const dir = folders.alice!;
4359+ writeFileSync(join(dir, "a.txt"), "a\n<<<<<<< HEAD\nmine\n=======\ntheirs\n>>>>>>> feature\n");
4360+ const said = await main(["record"], { cwd: dir, env: ENV, write: () => {} });
4361+ assert.equal(said.exit, 0, said.stdout);
4362+ assert.match(said.stdout, /Note: a\.txt has lines that look like a git conflict \(from line 2\)/);
4363+ const again = await main(["record"], { cwd: dir, env: ENV, write: () => {} });
4364+ assert.doesNotMatch(again.stdout, /git conflict/, "nothing new was sent, so nothing to say");
4365+ });
4366+});
4368+describe("paths too long for Windows", () => {
4369+ it("notes a long path once, as it is sent, and sends the file", async () => {
4370+ const { folders } = await project({ "a.txt": "a\n" }, "alice");
4371+ const dir = folders.alice!;
4372+ const long = `${"d".repeat(80)}/${"e".repeat(80)}/f.txt`;
4373+ mkdirSync(join(dir, dirname(long)), { recursive: true });
4374+ writeFileSync(join(dir, long), "deep\n");
4375+ const said = await main(["record"], { cwd: dir, env: ENV, write: () => {} });
4376+ assert.equal(said.exit, 0, said.stdout);
4377+ assert.match(said.stdout, /Note: d{80}\/e{80}\/f\.txt is 167 characters inside the folder/);
4378+ assert.match(said.stdout, /Windows stops at 260/);
4379+ const again = await main(["record"], { cwd: dir, env: ENV, write: () => {} });
4380+ assert.doesNotMatch(again.stdout, /Windows stops at 260/, "nothing new was sent");
4381+ });
4382+});