Fix slow header, rebrand OAuth page, fix alpha-hub login callback

- Replace slow system_profiler/docker info with fast cached alternatives
- Single-line system info: cores · ram · docker
- Patch Pi OAuth callback page with Feynman branding
- Fix alpha-hub login: wait for server ready before opening browser, handle port conflicts, auto-close tab

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Advait Paliwal
2026-03-23 19:00:13 -07:00
parent cac7494af7
commit 6c9d629b5d
4 changed files with 35 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
import { readdir } from "node:fs/promises"; import { readdir } from "node:fs/promises";
import { cpus, freemem, homedir, totalmem } from "node:os"; import { cpus, homedir, totalmem } from "node:os";
import { execSync } from "node:child_process"; import { execSync } from "node:child_process";
import { resolve as resolvePath } from "node:path"; import { resolve as resolvePath } from "node:path";
@@ -133,33 +133,30 @@ type SystemResources = {
docker: boolean; docker: boolean;
}; };
function detectSystemResources(): SystemResources { let cachedResources: SystemResources | null = null;
const cores = cpus().length;
const cpu = cpus()[0]?.model?.trim() ?? "unknown"; function detectSystemResources(): SystemResources {
const totalBytes = totalmem(); if (cachedResources) return cachedResources;
const freeBytes = freemem();
const ramTotal = `${Math.round(totalBytes / (1024 ** 3))}GB`; const cores = cpus().length;
const ramFree = `${Math.round(freeBytes / (1024 ** 3))}GB`; const totalBytes = totalmem();
const ramTotal = `${Math.round(totalBytes / (1024 ** 3))}GB`;
cachedResources = { cpu: "", cores, ramTotal, ramFree: "", gpu: null, docker: false };
let gpu: string | null = null;
try { try {
if (process.platform === "darwin") { if (process.platform === "darwin") {
const out = execSync("system_profiler SPDisplaysDataType 2>/dev/null | grep 'Chipset Model\\|Chip Model'", { encoding: "utf8", timeout: 3000 }).trim(); const out = execSync("sysctl -n machdep.cpu.brand_string 2>/dev/null", { encoding: "utf8", timeout: 1000 }).trim();
const match = out.match(/:\s*(.+)/); if (out) cachedResources.cpu = out;
if (match) gpu = match[1]!.trim();
} else {
const out = execSync("nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null", { encoding: "utf8", timeout: 3000 }).trim();
if (out) gpu = out.split("\n")[0]!.trim();
} }
} catch {} } catch {}
let docker = false;
try { try {
execSync("docker info 2>/dev/null", { timeout: 3000 }); execSync("command -v docker >/dev/null 2>&1", { timeout: 500 });
docker = true; cachedResources.docker = true;
} catch {} } catch {}
return { cpu, cores, ramTotal, ramFree, gpu, docker }; return cachedResources;
} }
type WorkflowInfo = { name: string; description: string }; type WorkflowInfo = { name: string; description: string };
@@ -268,10 +265,9 @@ export function installFeynmanHeader(
pushLabeled("directory", dirLabel, "text"); pushLabeled("directory", dirLabel, "text");
pushLabeled("session", sessionId, "dim"); pushLabeled("session", sessionId, "dim");
leftLines.push(""); leftLines.push("");
pushLabeled("cpu", `${resources.cores} cores`, "dim"); const sysParts = [`${resources.cores} cores`, resources.ramTotal];
pushLabeled("ram", `${resources.ramFree} free / ${resources.ramTotal}`, "dim"); if (resources.docker) sysParts.push("docker");
if (resources.gpu) pushLabeled("gpu", resources.gpu, "dim"); pushLabeled("system", sysParts.join(" · "), "dim");
pushLabeled("docker", resources.docker ? "available" : "not found", "dim");
leftLines.push(""); leftLines.push("");
leftLines.push(theme.fg("dim", `${toolCount} tools · ${agentCount} agents`)); leftLines.push(theme.fg("dim", `${toolCount} tools · ${agentCount} agents`));
@@ -343,7 +339,7 @@ export function installFeynmanHeader(
push(row(`${theme.fg("dim", "model".padEnd(10))} ${theme.fg("text", truncateVisible(modelLabel, narrowValW))}`)); push(row(`${theme.fg("dim", "model".padEnd(10))} ${theme.fg("text", truncateVisible(modelLabel, narrowValW))}`));
push(row(`${theme.fg("dim", "directory".padEnd(10))} ${theme.fg("text", truncateVisible(dirLabel, narrowValW))}`)); push(row(`${theme.fg("dim", "directory".padEnd(10))} ${theme.fg("text", truncateVisible(dirLabel, narrowValW))}`));
push(row(`${theme.fg("dim", "session".padEnd(10))} ${theme.fg("dim", truncateVisible(sessionId, narrowValW))}`)); push(row(`${theme.fg("dim", "session".padEnd(10))} ${theme.fg("dim", truncateVisible(sessionId, narrowValW))}`));
const resourceLine = `${resources.cores} cores · ${resources.ramTotal} ram${resources.gpu ? ` · ${resources.gpu}` : ""}${resources.docker ? " · docker" : ""}`; const resourceLine = `${resources.cores} cores · ${resources.ramTotal}${resources.docker ? " · docker" : ""}`;
push(row(theme.fg("dim", truncateVisible(resourceLine, contentW)))); push(row(theme.fg("dim", truncateVisible(resourceLine, contentW))));
push(row(theme.fg("dim", truncateVisible(`${toolCount} tools · ${agentCount} agents · ${commandCount} commands`, contentW)))); push(row(theme.fg("dim", truncateVisible(`${toolCount} tools · ${agentCount} agents · ${commandCount} commands`, contentW))));
push(emptyRow()); push(emptyRow());

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@companion-ai/feynman", "name": "@companion-ai/feynman",
"version": "0.2.2", "version": "0.2.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@companion-ai/feynman", "name": "@companion-ai/feynman",
"version": "0.2.2", "version": "0.2.3",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@companion-ai/alpha-hub": "^0.1.2", "@companion-ai/alpha-hub": "^0.1.2",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@companion-ai/feynman", "name": "@companion-ai/feynman",
"version": "0.2.2", "version": "0.2.3",
"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": {

View File

@@ -250,6 +250,18 @@ if (existsSync(sessionSearchIndexerPath)) {
} }
} }
const oauthPagePath = resolve(appRoot, "node_modules", "@mariozechner", "pi-ai", "dist", "utils", "oauth", "oauth-page.js");
if (existsSync(oauthPagePath)) {
let source = readFileSync(oauthPagePath, "utf8");
const piLogo = 'const LOGO_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800" aria-hidden="true"><path fill="#fff" fill-rule="evenodd" d="M165.29 165.29 H517.36 V400 H400 V517.36 H282.65 V634.72 H165.29 Z M282.65 282.65 V400 H400 V282.65 Z"/><path fill="#fff" d="M517.36 400 H634.72 V634.72 H517.36 Z"/></svg>`;';
if (source.includes(piLogo)) {
const feynmanLogo = 'const LOGO_SVG = `<span style="font-size:32px;font-weight:700;color:#10b981;font-family:system-ui,sans-serif;letter-spacing:-0.02em">feynman</span>`;';
source = source.replace(piLogo, feynmanLogo);
writeFileSync(oauthPagePath, source, "utf8");
}
}
if (existsSync(piMemoryPath)) { if (existsSync(piMemoryPath)) {
let source = readFileSync(piMemoryPath, "utf8"); let source = readFileSync(piMemoryPath, "utf8");
const memoryOriginal = 'const MEMORY_DIR = join(homedir(), ".pi", "memory");'; const memoryOriginal = 'const MEMORY_DIR = join(homedir(), ".pi", "memory");';