test(runtime): guard pi package contracts
This commit is contained in:
1 parent
c26e7420fb
commit
245586a9aa
6 files changed
+293
-26
No files matched your search
@@ -1,28 +1,51 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
type PackageJson = {
|
||||
dependencies?: Record<string, string>;
|
||||
};
|
||||
|
||||
const PI_RUNTIME_PACKAGES = [
|
||||
"@mariozechner/pi-agent-core",
|
||||
"@mariozechner/pi-ai",
|
||||
"@mariozechner/pi-coding-agent",
|
||||
] as const;
|
||||
|
||||
function readRootPackage(): PackageJson {
|
||||
return JSON.parse(readFileSync(join(process.cwd(), "package.json"), "utf8")) as PackageJson;
|
||||
}
|
||||
import {
|
||||
PI_RUNTIME_PACKAGES,
|
||||
PI_RUNTIME_VERSION,
|
||||
lockfileHasImporterPin,
|
||||
lockfileHasPackageResolution,
|
||||
lockfileHasPackageSnapshot,
|
||||
readInstalledPackage,
|
||||
readPnpmLockfile,
|
||||
readRootPackage,
|
||||
} from "../support/pi-runtime-contract";
|
||||
|
||||
describe("pi runtime dependency contract", () => {
|
||||
it("keeps the shipping pi runtime on exact npm package pins", () => {
|
||||
const dependencies = readRootPackage().dependencies ?? {};
|
||||
|
||||
for (const packageName of PI_RUNTIME_PACKAGES) {
|
||||
expect(dependencies[packageName]).toBe("0.67.68");
|
||||
expect(dependencies[packageName]).toBe(PI_RUNTIME_VERSION);
|
||||
expect(dependencies[packageName]).toMatch(/^\d+\.\d+\.\d+$/);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps package.json, pnpm-lock, and installed packages on one pi runtime version", () => {
|
||||
const lockfile = readPnpmLockfile();
|
||||
|
||||
for (const packageName of PI_RUNTIME_PACKAGES) {
|
||||
expect(lockfileHasImporterPin(lockfile, packageName, PI_RUNTIME_VERSION)).toBe(true);
|
||||
expect(lockfileHasPackageResolution(lockfile, packageName, PI_RUNTIME_VERSION)).toBe(true);
|
||||
expect(lockfileHasPackageSnapshot(lockfile, packageName, PI_RUNTIME_VERSION)).toBe(true);
|
||||
expect(readInstalledPackage(packageName).version).toBe(PI_RUNTIME_VERSION);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps the pi API surface used by AgentCompany available", async () => {
|
||||
const [agentCore, piAi, piCodingAgent] = await Promise.all([
|
||||
import("@mariozechner/pi-agent-core"),
|
||||
import("@mariozechner/pi-ai"),
|
||||
import("@mariozechner/pi-coding-agent"),
|
||||
]);
|
||||
|
||||
expect(typeof agentCore.Agent).toBe("function");
|
||||
expect(typeof piAi.createAssistantMessageEventStream).toBe("function");
|
||||
expect(typeof piAi.getEnvApiKey).toBe("function");
|
||||
expect(typeof piAi.getModel).toBe("function");
|
||||
expect(typeof piAi.getModels).toBe("function");
|
||||
expect(typeof piAi.streamSimple).toBe("function");
|
||||
expect(typeof piAi.Type.Record).toBe("function");
|
||||
expect(typeof piCodingAgent.createCodingTools).toBe("function");
|
||||
expect(typeof piCodingAgent.loadSkills).toBe("function");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user