mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 08:22:20 +02:00
Replay the inactive Pi-only admission patch on the frozen Pi 1.0.0 source, preserving profile 11, its exact digest and all native closure inputs. Cursor and Copilot remain gated. This local preparation requires complete qualification and rebuilt normal-mode acceptance before activation. Co-Authored-By: Paperclip <noreply@paperclip.ing>
45 lines
2.7 KiB
JavaScript
45 lines
2.7 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { parseProviderPackArguments, materializeCandidateProviderPack, providerPackSelections } from "./candidate-provider-pack.mjs";
|
|
|
|
test("candidate options stay explicit and Pi is the only default qualified native asset", () => {
|
|
assert.deepEqual(parseProviderPackArguments(["--", "/pack"]), { output: "/pack", candidates: [] });
|
|
assert.deepEqual(parseProviderPackArguments(["/pack", "--candidate-providers=pi,cursor"]), { output: "/pack", candidates: ["pi", "cursor"] });
|
|
assert.deepEqual(providerPackSelections([]), [{ provider: "pi", qualification: "qualified" }]);
|
|
assert.deepEqual(providerPackSelections(["pi", "cursor", "copilot"]), [
|
|
{ provider: "pi", qualification: "qualified" },
|
|
{ provider: "cursor", qualification: "pending" },
|
|
{ provider: "copilot", qualification: "pending" },
|
|
]);
|
|
assert.throws(() => providerPackSelections(["other"]), /Unknown/);
|
|
assert.throws(() => providerPackSelections(["pi", "pi"]), /duplicate/);
|
|
});
|
|
test("candidate builder cannot admit unknown providers, options or duplicate assets", async () => {
|
|
for (const args of [["--candidate-providers=cursor,cursor"], ["--candidate-providers=other"], ["--executable=/tmp/x"], ["/one", "/two"]]) {
|
|
assert.throws(() => parseProviderPackArguments(args));
|
|
}
|
|
await assert.rejects(materializeCandidateProviderPack({ provider: "arbitrary", outputRoot: "/tmp/unused" }), /Unknown candidate/);
|
|
});
|
|
|
|
test("Copilot pack selection reaches only the pinned native archive builder", async t => {
|
|
const requests = [];
|
|
t.mock.method(globalThis, "fetch", async (url, options) => {
|
|
requests.push({ url, redirect: options.redirect, credentials: options.credentials });
|
|
return new Response("corrupt archive");
|
|
});
|
|
await assert.rejects(materializeCandidateProviderPack({ provider: "copilot", outputRoot: "/unused-copilot-build" }), /integrity mismatch/);
|
|
assert.equal(requests.length, 1);
|
|
assert.match(requests[0].url, /^https:\/\/registry\.npmjs\.org\/@github\/copilot-(darwin-(arm64|x64)|linux-x64)\/-\/copilot-.*-1\.0\.88\.tgz$/);
|
|
assert.deepEqual({ redirect: requests[0].redirect, credentials: requests[0].credentials }, { redirect: "error", credentials: "omit" });
|
|
});
|
|
|
|
test("Pi pack selection reaches its pinned builder and rejects unsafe output before downloading", async t => {
|
|
let requests = 0;
|
|
t.mock.method(globalThis, "fetch", async () => {
|
|
requests += 1;
|
|
throw new Error("Unexpected download for invalid Pi output");
|
|
});
|
|
await assert.rejects(materializeCandidateProviderPack({ provider: "pi", outputRoot: "relative-pi-output" }), /Pi distribution output must be absolute/);
|
|
assert.equal(requests, 0);
|
|
});
|