Remove redundant package installer — let Pi handle it at runtime
Pi's own package manager already installs packages from settings.json on first REPL launch. Feynman was duplicating this in both postinstall and first-run, causing slow installs and looping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@companion-ai/feynman",
|
"name": "@companion-ai/feynman",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@companion-ai/feynman",
|
"name": "@companion-ai/feynman",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@companion-ai/alpha-hub": "^0.1.2",
|
"@companion-ai/alpha-hub": "^0.1.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@companion-ai/feynman",
|
"name": "@companion-ai/feynman",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "Research-first CLI agent built on Pi and alphaXiv",
|
"description": "Research-first CLI agent built on Pi and alphaXiv",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -27,53 +27,7 @@ const settingsPath = resolve(appRoot, ".feynman", "settings.json");
|
|||||||
const workspaceDir = resolve(appRoot, ".feynman", "npm");
|
const workspaceDir = resolve(appRoot, ".feynman", "npm");
|
||||||
const workspacePackageJsonPath = resolve(workspaceDir, "package.json");
|
const workspacePackageJsonPath = resolve(workspaceDir, "package.json");
|
||||||
|
|
||||||
function ensurePackageWorkspace() {
|
// Pi handles package installation from .feynman/settings.json at runtime — no manual install needed
|
||||||
if (!existsSync(settingsPath)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const settings = JSON.parse(readFileSync(settingsPath, "utf8"));
|
|
||||||
const packageSpecs = Array.isArray(settings.packages)
|
|
||||||
? settings.packages
|
|
||||||
.filter((value) => typeof value === "string" && value.startsWith("npm:"))
|
|
||||||
.map((value) => value.slice(4))
|
|
||||||
: [];
|
|
||||||
|
|
||||||
if (packageSpecs.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mkdirSync(workspaceDir, { recursive: true });
|
|
||||||
|
|
||||||
writeFileSync(
|
|
||||||
workspacePackageJsonPath,
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
name: "pi-extensions",
|
|
||||||
private: true,
|
|
||||||
dependencies: Object.fromEntries(packageSpecs.map((spec) => [spec, "latest"])),
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2,
|
|
||||||
) + "\n",
|
|
||||||
"utf8",
|
|
||||||
);
|
|
||||||
|
|
||||||
const npmExec = process.env.npm_execpath;
|
|
||||||
const install = npmExec
|
|
||||||
? spawnSync(process.execPath, [npmExec, "install", "--prefix", workspaceDir, ...packageSpecs], {
|
|
||||||
stdio: "inherit",
|
|
||||||
})
|
|
||||||
: spawnSync("npm", ["install", "--prefix", workspaceDir, ...packageSpecs], {
|
|
||||||
stdio: "inherit",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (install.status !== 0) {
|
|
||||||
console.warn("[feynman] warning: failed to preinstall default Pi packages into .feynman/npm");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ensurePackageWorkspace();
|
|
||||||
|
|
||||||
if (existsSync(packageJsonPath)) {
|
if (existsSync(packageJsonPath)) {
|
||||||
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
||||||
|
|||||||
Reference in New Issue
Block a user