fix(skills): normalize gzip archives across hosts

This commit is contained in:
Jinwoo-H
2026-08-11 11:35:04 -04:00
parent bb71b28674
commit 6123082fa3
2 changed files with 19 additions and 1 deletions
@@ -125,7 +125,7 @@ describe('skill package creation and extraction', () => {
archiveSha256: created.archiveSha256,
packageDigest: created.manifest.packageDigest
}).toEqual({
archiveSha256: '6537c6c1820e08f175206df49bc918893770efc464916724869f78374709f90f',
archiveSha256: '4a62b276b1e8100f0b437f2f0aa182d844768160ba30c5f76afd027acfe50ac8',
packageDigest: '3bb1fc63cfea2f2b7f2cf80e539735eebd5bfb6aa65f47cf0db7e9fd35297f57'
})
})
+18
View File
@@ -80,6 +80,23 @@ async function writeWithBackpressure(stream: Writable, bytes: Buffer): Promise<v
}
}
function portableGzipHeader(): Transform {
let emittedBytes = 0
return new Transform({
transform(chunk: Buffer, _encoding, callback) {
if (emittedBytes <= 9 && emittedBytes + chunk.length > 9) {
const portable = Buffer.from(chunk)
portable[9 - emittedBytes] = 0xff
emittedBytes += chunk.length
callback(null, portable)
return
}
emittedBytes += chunk.length
callback(null, chunk)
}
})
}
export async function writeSkillTarGzip(
archivePath: string,
entries: readonly SkillTarWriteEntry[]
@@ -100,6 +117,7 @@ export async function writeSkillTarGzip(
})
const sink = pipeline(
gzip,
portableGzipHeader(),
hashTransform,
createWriteStream(archivePath, { flags: 'wx', mode: 0o600 })
)