fix(packages): load bundled Pi runtime for local installs

This commit is contained in:
brother7 committed 2026-09-02 23:03:12 +08:00
1 parent 28e1690038
commit 5a2f0eb678
9 files changed
+356 -19

No files matched your search

+36
View File
@@ -16,6 +16,7 @@ import {
verifyBundledCodingPluginResources,
defaultProductExecutable,
readPackagedMarketplaceTrustSource,
verifyPackagedDevicePackageRuntime,
verifyPackagedMarketplaceClientArtifact,
validatePiArtifactMetadata,
verifyMarketplaceClientArtifact,
@@ -326,6 +327,41 @@ describe('final Pi product artifact verification', () => {
await expect(readPackagedMarketplaceTrustSource(appAsar)).rejects.toThrow('trust source');
});
it('rejects the incomplete app Pi graph and requires the bundled runtime package manager', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-device-package-runtime-asar-'));
roots.push(root);
const source = path.join(root, 'source');
await mkdir(path.join(source, 'dist-electron'), { recursive: true });
await writeFile(path.join(source, 'package.json'), JSON.stringify({ main: 'dist-electron/main.js' }));
await writeFile(
path.join(source, 'dist-electron', 'main.js'),
'export async function prepare() { return await import("@earendil-works/pi-coding-agent"); }',
);
const appAsar = path.join(root, 'app.asar');
await createAsarFixture(source, appAsar);
const runtimePlatform = {
devicePackageManager: { defaultPackageManager: 'function', settingsManager: 'function' },
};
await expect(verifyPackagedDevicePackageRuntime(appAsar, runtimePlatform))
.rejects.toThrow('incomplete app graph');
await writeFile(
path.join(source, 'dist-electron', 'main.js'),
'export const devicePackageManagerAuthority = "bundled-pi-runtime";',
);
const cleanAsar = path.join(root, 'clean.asar');
await createAsarFixture(source, cleanAsar);
await expect(verifyPackagedDevicePackageRuntime(cleanAsar, runtimePlatform)).resolves.toEqual({
authority: 'bundled-pi-runtime',
appAsarRootImport: false,
exports: runtimePlatform.devicePackageManager,
result: 'pass',
});
await expect(verifyPackagedDevicePackageRuntime(cleanAsar, { devicePackageManager: null }))
.rejects.toThrow('cannot load the Device Package manager');
});
it('binds Marketplace route, Renderer, and effective markers to the package main graph', async () => {
const root = await mkdtemp(path.join(tmpdir(), 'makelore-marketplace-contract-asar-'));
roots.push(root);