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:
Advait Paliwal
2026-03-23 22:17:51 -07:00
parent 8a409bcfc8
commit e73743d407
13 changed files with 332 additions and 16 deletions

87
src/pi/package-presets.ts Normal file
View File

@@ -0,0 +1,87 @@
import type { PackageSource } from "@mariozechner/pi-coding-agent";
export const CORE_PACKAGE_SOURCES = [
"npm:pi-subagents",
"npm:pi-btw",
"npm:pi-docparser",
"npm:pi-web-access",
"npm:pi-markdown-preview",
"npm:@walterra/pi-charts",
"npm:pi-mermaid",
"npm:@aliou/pi-processes",
"npm:pi-zotero",
"npm:pi-schedule-prompt",
"npm:@tmustier/pi-ralph-wiggum",
] as const;
export const OPTIONAL_PACKAGE_PRESETS = {
"generative-ui": {
description: "Interactive Glimpse UI widgets.",
sources: ["npm:pi-generative-ui"],
},
memory: {
description: "Cross-session memory and preference recall.",
sources: ["npm:@samfp/pi-memory"],
},
"session-search": {
description: "Indexed session recall with SQLite-backed search.",
sources: ["npm:@kaiserlich-dev/pi-session-search"],
},
"all-extras": {
description: "Install all optional packages.",
sources: ["npm:pi-generative-ui", "npm:@samfp/pi-memory", "npm:@kaiserlich-dev/pi-session-search"],
},
} as const;
const LEGACY_DEFAULT_PACKAGE_SOURCES = [
...CORE_PACKAGE_SOURCES,
"npm:pi-generative-ui",
"npm:@kaiserlich-dev/pi-session-search",
"npm:@samfp/pi-memory",
] as const;
export type OptionalPackagePresetName = keyof typeof OPTIONAL_PACKAGE_PRESETS;
function arraysMatchAsSets(left: readonly string[], right: readonly string[]): boolean {
if (left.length !== right.length) {
return false;
}
const rightSet = new Set(right);
return left.every((entry) => rightSet.has(entry));
}
export function shouldPruneLegacyDefaultPackages(packages: PackageSource[] | undefined): boolean {
if (!Array.isArray(packages)) {
return false;
}
if (packages.some((entry) => typeof entry !== "string")) {
return false;
}
return arraysMatchAsSets(packages as string[], LEGACY_DEFAULT_PACKAGE_SOURCES);
}
export function getOptionalPackagePresetSources(name: string): string[] | undefined {
const normalized = name.trim().toLowerCase();
if (normalized === "ui") {
return [...OPTIONAL_PACKAGE_PRESETS["generative-ui"].sources];
}
if (normalized === "search") {
return [...OPTIONAL_PACKAGE_PRESETS["session-search"].sources];
}
const preset = OPTIONAL_PACKAGE_PRESETS[normalized as OptionalPackagePresetName];
return preset ? [...preset.sources] : undefined;
}
export function listOptionalPackagePresets(): Array<{
name: OptionalPackagePresetName;
description: string;
sources: string[];
}> {
return Object.entries(OPTIONAL_PACKAGE_PRESETS).map(([name, preset]) => ({
name: name as OptionalPackagePresetName,
description: preset.description,
sources: [...preset.sources],
}));
}