import { kvCached } from "./cache"; import type { GitStore } from "../git/store"; const MAX_LISTED_FILES = 20_000; export type FileListing = { paths: string[]; truncated: boolean }; /** Recursive blob paths under a root tree, cached in KV by tree sha since trees are immutable. */ export async function listAllFiles(store: GitStore, treeSha: string): Promise { return kvCached(`files:v1:${store.artifactsName}:${treeSha}`, async () => { const { entries, truncated } = await store.walk(treeSha, MAX_LISTED_FILES); return { paths: entries.filter((entry) => entry.type !== "gitlink").map((entry) => entry.path), truncated }; }); }