{"draft":null,"from":175,"to":318,"files":[{"path":"server/src/memory-fs.ts","added":27,"removed":4,"diff":"--- a/server/src/memory-fs.ts\n+++ b/server/src/memory-fs.ts\n@@ -9,11 +9,18 @@\n \n type Entry =\n \t| { kind: \"dir\"; children: Set<string>; mtimeMs: number }\n-\t| { kind: \"file\"; data: Uint8Array; exec: boolean; mtimeMs: number }\n+\t| { kind: \"file\"; data: Uint8Array; byteLength?: number; exec: boolean; mtimeMs: number }\n \t| { kind: \"link\"; target: string; mtimeMs: number };\n \n const enc = new TextEncoder();\n \n+/** Optional scratch storage for file contents; directory metadata remains in memory. */\n+export interface FileContents {\n+\twrite(path: string, bytes: Uint8Array): void;\n+\tread(path: string): Uint8Array;\n+\tremove(path: string): void;\n+}\n+\n /** Plain fields, not getters: isomorphic-git writes to them when it normalizes stats. */\n class MemoryStats {\n \tsize: number;\n@@ -25,7 +32,11 @@\n \tconstructor(entry: Entry) {\n \t\tthis.kind = entry.kind;\n \t\tthis.size =\n-\t\t\tentry.kind === \"file\" ? entry.data.byteLength : entry.kind === \"link\" ? enc.encode(entry.target).byteLength : 0;\n+\t\t\tentry.kind === \"file\"\n+\t\t\t\t? (entry.byteLength ?? entry.data.byteLength)\n+\t\t\t\t: entry.kind === \"link\"\n+\t\t\t\t\t? enc.encode(entry.target).byteLength\n+\t\t\t\t\t: 0;\n \t\tthis.mtimeMs = entry.mtimeMs;\n \t\tthis.ctimeMs = entry.mtimeMs;\n \t\tthis.mode = entry.kind === \"dir\" ? 0o040000 : entry.kind === \"link\" ? 0o120000 : entry.exec ? 0o100755 : 0o100644;\n@@ -45,6 +56,10 @@\n }\n \n export class MemoryFS {\n+\tprivate readonly contents?: FileContents;\n+\tconstructor(contents?: FileContents) {\n+\t\tthis.contents = contents;\n+\t}\n \tencoder = new TextEncoder();\n \tdecoder = new TextDecoder();\n \tentries = new Map<string, Entry>([[\"/\", { kind: \"dir\", children: new Set(), mtimeMs: Date.now() }]]);\n@@ -157,10 +172,12 @@\n \t\tconst bytes =\n \t\t\ttypeof data === \"string\" ? this.encoder.encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data);\n \t\tconst mode = typeof options === \"object\" && options !== null ? options.mode : undefined;\n+\t\tthis.contents?.write(target, bytes);\n \n \t\tthis.entries.set(target, {\n \t\t\tkind: \"file\",\n-\t\t\tdata: bytes,\n+\t\t\tdata: this.contents ? new Uint8Array(0) : bytes,\n+\t\t\t...(this.contents ? { byteLength: bytes.byteLength } : {}),\n \t\t\texec: mode !== undefined && (mode & 0o111) !== 0,\n \t\t\tmtimeMs: Date.now(),\n \t\t});\n@@ -174,7 +191,12 @@\n \t\t\tthrow fsError(\"EISDIR\", path);\n \t\t}\n \n-\t\tconst data = entry.kind === \"link\" ? this.encoder.encode(entry.target) : entry.data;\n+\t\tconst data =\n+\t\t\tentry.kind === \"link\"\n+\t\t\t\t? this.encoder.encode(entry.target)\n+\t\t\t\t: this.contents\n+\t\t\t\t\t? this.contents.read(this.normalize(path))\n+\t\t\t\t\t: entry.data;\n \t\tconst encoding = typeof options === \"string\" ? options : options?.encoding;\n \t\treturn encoding ? this.decoder.decode(data) : data;\n \t}\n@@ -190,6 +212,7 @@\n \t\t\tthrow fsError(\"EISDIR\", path);\n \t\t}\n \n+\t\tif (entry.kind === \"file\") this.contents?.remove(target);\n \t\tthis.entries.delete(target);\n \t\tthis.requireDir(this.parent(target)).children.delete(this.basename(target));\n \t}"}],"unmatched":[]}