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:
@@ -1,5 +1,5 @@
|
||||
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 { resolve as resolvePath } from "node:path";
|
||||
|
||||
@@ -133,33 +133,30 @@ type SystemResources = {
|
||||
docker: boolean;
|
||||
};
|
||||
|
||||
function detectSystemResources(): SystemResources {
|
||||
const cores = cpus().length;
|
||||
const cpu = cpus()[0]?.model?.trim() ?? "unknown";
|
||||
const totalBytes = totalmem();
|
||||
const freeBytes = freemem();
|
||||
const ramTotal = `${Math.round(totalBytes / (1024 ** 3))}GB`;
|
||||
const ramFree = `${Math.round(freeBytes / (1024 ** 3))}GB`;
|
||||
let cachedResources: SystemResources | null = null;
|
||||
|
||||
function detectSystemResources(): SystemResources {
|
||||
if (cachedResources) return cachedResources;
|
||||
|
||||
const cores = cpus().length;
|
||||
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 {
|
||||
if (process.platform === "darwin") {
|
||||
const out = execSync("system_profiler SPDisplaysDataType 2>/dev/null | grep 'Chipset Model\\|Chip Model'", { encoding: "utf8", timeout: 3000 }).trim();
|
||||
const match = out.match(/:\s*(.+)/);
|
||||
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();
|
||||
const out = execSync("sysctl -n machdep.cpu.brand_string 2>/dev/null", { encoding: "utf8", timeout: 1000 }).trim();
|
||||
if (out) cachedResources.cpu = out;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
let docker = false;
|
||||
try {
|
||||
execSync("docker info 2>/dev/null", { timeout: 3000 });
|
||||
docker = true;
|
||||
execSync("command -v docker >/dev/null 2>&1", { timeout: 500 });
|
||||
cachedResources.docker = true;
|
||||
} catch {}
|
||||
|
||||
return { cpu, cores, ramTotal, ramFree, gpu, docker };
|
||||
return cachedResources;
|
||||
}
|
||||
|
||||
type WorkflowInfo = { name: string; description: string };
|
||||
@@ -268,10 +265,9 @@ export function installFeynmanHeader(
|
||||
pushLabeled("directory", dirLabel, "text");
|
||||
pushLabeled("session", sessionId, "dim");
|
||||
leftLines.push("");
|
||||
pushLabeled("cpu", `${resources.cores} cores`, "dim");
|
||||
pushLabeled("ram", `${resources.ramFree} free / ${resources.ramTotal}`, "dim");
|
||||
if (resources.gpu) pushLabeled("gpu", resources.gpu, "dim");
|
||||
pushLabeled("docker", resources.docker ? "available" : "not found", "dim");
|
||||
const sysParts = [`${resources.cores} cores`, resources.ramTotal];
|
||||
if (resources.docker) sysParts.push("docker");
|
||||
pushLabeled("system", sysParts.join(" · "), "dim");
|
||||
leftLines.push("");
|
||||
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", "directory".padEnd(10))} ${theme.fg("text", truncateVisible(dirLabel, 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(`${toolCount} tools · ${agentCount} agents · ${commandCount} commands`, contentW))));
|
||||
push(emptyRow());
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@companion-ai/feynman",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@companion-ai/feynman",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@companion-ai/alpha-hub": "^0.1.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@companion-ai/feynman",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"description": "Research-first CLI agent built on Pi and alphaXiv",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -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)) {
|
||||
let source = readFileSync(piMemoryPath, "utf8");
|
||||
const memoryOriginal = 'const MEMORY_DIR = join(homedir(), ".pi", "memory");';
|
||||
|
||||
Reference in New Issue
Block a user