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
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/worker/project/tree.ts?format=json
25 linesFirst import 100%Last change First import in version 0, 1 version changed it
1// A tree hash (#39, the merge queue; #42, Actions): one sha256 for a set of
2// files, so a queue candidate and the version that lands from it, or a run in
3// someone's own account, can be matched without comparing every file. It
4// covers each file's path, mode (executable, or link target) and content (the
5// text's sha256, or the blob's sha256 for a binary file), in path order.
6import { createHash } from "node:crypto";
7
8export interface TreeFiles {
9 readonly files: Readonly<Record<string, string>>;
10 readonly modes?: Readonly<Record<string, { readonly exec?: boolean; readonly link?: string | null }>>;
11 readonly blobs?: Readonly<Record<string, string>>;
14const sha = (s: string): string => createHash("sha256").update(s, "utf8").digest("hex");
16export function treeHash(tree: TreeFiles): string {
17 const paths = [...new Set([...Object.keys(tree.files), ...Object.keys(tree.blobs ?? {})])].sort();
18 const lines = paths.map((p) => {
19 const m = tree.modes?.[p];
20 const mode = m?.link != null ? `link:${m.link}` : m?.exec ? "exec" : "file";
21 const content = tree.blobs?.[p] ?? sha(tree.files[p] ?? "");
22 return `${mode} ${content} ${p}`;
23 });
24 return sha(lines.join("\n"));