Speed up install with --prefer-offline --no-audit --no-fund, fix postinstall path resolution
Install down from 60s to ~10s. Core packages only (11), heavy optional packages available via feynman packages install. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
import { normalizeThinkingLevel } from "../src/pi/settings.js";
|
||||
import { CORE_PACKAGE_SOURCES, getOptionalPackagePresetSources, shouldPruneLegacyDefaultPackages } from "../src/pi/package-presets.js";
|
||||
import { normalizeFeynmanSettings, normalizeThinkingLevel } from "../src/pi/settings.js";
|
||||
|
||||
test("normalizeThinkingLevel accepts the latest Pi thinking levels", () => {
|
||||
assert.equal(normalizeThinkingLevel("off"), "off");
|
||||
@@ -16,3 +20,56 @@ test("normalizeThinkingLevel rejects unknown values", () => {
|
||||
assert.equal(normalizeThinkingLevel("turbo"), undefined);
|
||||
assert.equal(normalizeThinkingLevel(undefined), undefined);
|
||||
});
|
||||
|
||||
test("normalizeFeynmanSettings seeds the fast core package set", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "feynman-settings-"));
|
||||
const settingsPath = join(root, "settings.json");
|
||||
const bundledSettingsPath = join(root, "bundled-settings.json");
|
||||
const authPath = join(root, "auth.json");
|
||||
|
||||
writeFileSync(bundledSettingsPath, "{}\n", "utf8");
|
||||
writeFileSync(authPath, "{}\n", "utf8");
|
||||
|
||||
normalizeFeynmanSettings(settingsPath, bundledSettingsPath, "medium", authPath);
|
||||
|
||||
const settings = JSON.parse(readFileSync(settingsPath, "utf8")) as { packages?: string[] };
|
||||
assert.deepEqual(settings.packages, [...CORE_PACKAGE_SOURCES]);
|
||||
});
|
||||
|
||||
test("normalizeFeynmanSettings prunes the legacy slow default package set", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "feynman-settings-"));
|
||||
const settingsPath = join(root, "settings.json");
|
||||
const bundledSettingsPath = join(root, "bundled-settings.json");
|
||||
const authPath = join(root, "auth.json");
|
||||
|
||||
writeFileSync(
|
||||
settingsPath,
|
||||
JSON.stringify(
|
||||
{
|
||||
packages: [
|
||||
...CORE_PACKAGE_SOURCES,
|
||||
"npm:pi-generative-ui",
|
||||
"npm:@kaiserlich-dev/pi-session-search",
|
||||
"npm:@samfp/pi-memory",
|
||||
],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
"utf8",
|
||||
);
|
||||
writeFileSync(bundledSettingsPath, "{}\n", "utf8");
|
||||
writeFileSync(authPath, "{}\n", "utf8");
|
||||
|
||||
normalizeFeynmanSettings(settingsPath, bundledSettingsPath, "medium", authPath);
|
||||
|
||||
const settings = JSON.parse(readFileSync(settingsPath, "utf8")) as { packages?: string[] };
|
||||
assert.deepEqual(settings.packages, [...CORE_PACKAGE_SOURCES]);
|
||||
});
|
||||
|
||||
test("optional package presets map friendly aliases", () => {
|
||||
assert.deepEqual(getOptionalPackagePresetSources("memory"), ["npm:@samfp/pi-memory"]);
|
||||
assert.deepEqual(getOptionalPackagePresetSources("ui"), ["npm:pi-generative-ui"]);
|
||||
assert.deepEqual(getOptionalPackagePresetSources("search"), ["npm:@kaiserlich-dev/pi-session-search"]);
|
||||
assert.equal(shouldPruneLegacyDefaultPackages(["npm:custom"]), false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user