Restrict company imports to GitHub and zip packages

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Dotta 2026-03-16 09:52:16 -05:00
parent 0b829ea20b
commit 4a5aba5bac
6 changed files with 163 additions and 94 deletions

View file

@ -1,7 +1,7 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
import { createZipArchive } from "./zip";
import { createZipArchive, readZipArchive } from "./zip";
function readUint16(bytes: Uint8Array, offset: number) {
return bytes[offset]! | (bytes[offset + 1]! << 8);
@ -50,4 +50,24 @@ describe("createZipArchive", () => {
expect(readUint16(archive, endOffset + 8)).toBe(2);
expect(readUint16(archive, endOffset + 10)).toBe(2);
});
it("reads a Paperclip zip archive back into rootPath and file contents", () => {
const archive = createZipArchive(
{
"COMPANY.md": "# Company\n",
"agents/ceo/AGENTS.md": "# CEO\n",
".paperclip.yaml": "schema: paperclip/v1\n",
},
"paperclip-demo",
);
expect(readZipArchive(archive)).toEqual({
rootPath: "paperclip-demo",
files: {
"COMPANY.md": "# Company\n",
"agents/ceo/AGENTS.md": "# CEO\n",
".paperclip.yaml": "schema: paperclip/v1\n",
},
});
});
});