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

Versions 175 to 318

Compare

+47 −1 in 2 places
Lines 7–13 at 318 (were 7–12 at 175)
77// The engine's own key, so both sides match spellings the same way (#49). Not in core.ts: the edit mod installs core.ts alone.
88import {
99 type Api,
10+ ApiError,
1011 type Collision,
1112 type FileChange,
1213 type MergedLine,
Lines 432–485 at 318 (were 431–439 at 175)
431432 * overwritten.
432433 */
433434export async function syncFolder(root: string, api: Api, full = false): Promise<Applied> {
434− return applyAnswer(root, api, await api.sync({ full }));
435+ const applied = await applyAnswer(root, api, await pullAnswer(root, api, full));
436+ pullWritten(root);
437+ return applied;
435438}
436439
440+const PULLING_FILE = "pulling.json";
442+/**
443+ * Whether a pull here asked the server and never wrote its answer (abso-core 26): it timed out, or stopped
444+ * partway. The server moved the agent's base when it answered, and later pulls send only what changed since
445+ * that base, so the files it would have written stay behind until a pull asks for every file.
446+ */
447+export function pullUnfinished(root: string): boolean {
448+ return existsSync(join(stateDir(root), PULLING_FILE));
449+}
451+/**
452+ * Ask the server for a pull, noting first that one is under way, so a pull whose answer never gets written
453+ * leaves the note behind. With that note, or `full`, it asks for every file in the agent's view, which the
454+ * folder's own checks then write only where the folder differs. pullWritten takes the note away.
455+ */
456+export async function pullAnswer(root: string, api: Api, full = false): Promise<SyncAnswer> {
457+ const unfinished = pullUnfinished(root);
458+ writeFileAtomic(join(stateDir(root), PULLING_FILE), `${JSON.stringify({ at: new Date().toISOString() })}\n`);
459+ if (!full && !unfinished) return api.sync();
460+ try {
461+ return await api.sync({ full: true });
462+ } catch (err) {
463+ // A server from before full pulls (501): the plain pull is still better than none.
464+ if (unfinished && !full && err instanceof ApiError && err.status === 501) return api.sync();
465+ throw err;
466+ }
467+}
469+/** The pull's answer is written into the folder: take away pullAnswer's note. */
470+export function pullWritten(root: string): void {
471+ rmSync(join(stateDir(root), PULLING_FILE), { force: true });
472+}
474+/** Status's line, and pull's when it caught up. */
475+export function pullUnfinishedText(root: string): string[] {
476+ return pullUnfinished(root)
477+ ? [
478+ "A pull here didn't finish (its answer never arrived or wasn't written), so files may be behind this folder's base. abso pull fetches every file and writes the ones that differ.",
479+ ]
480+ : [];
481+}
437483/** What writing a sync or switch answer into the folder did. */
438484export interface Applied {
439485 readonly version: number;
MCP
compare on this site's /mcp
CLI
abso diff 175 318 client/src/commands.ts --json
JSON
/christopher/abso-core/compare/175..318?file=client%2Fsrc%2Fcommands.ts&format=json