From da66d038a05cd9da5008e9f98c2a4946f1f1f13c Mon Sep 17 00:00:00 2001 From: Genie Automagik Date: Fri, 22 May 2026 17:04:35 +0000 Subject: [PATCH 1/5] fix: read pgserve runtime port in update diagnostics --- src/genie-commands/__tests__/update.test.ts | 11 +++++++++++ src/genie-commands/update.ts | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/genie-commands/__tests__/update.test.ts b/src/genie-commands/__tests__/update.test.ts index 243d79c7f..f6f093560 100644 --- a/src/genie-commands/__tests__/update.test.ts +++ b/src/genie-commands/__tests__/update.test.ts @@ -893,6 +893,17 @@ describe('Diagnostics schema (G5)', () => { expect(extractPgservePortFromStatus('not-json')).toBe(null); }); + test('diagnostics derives pgserve port from live pgserve runtime status json', () => { + const liveStatus = JSON.stringify({ + installed: true, + status: 'online', + port: null, + runtime: { port: 8432, live: true }, + }); + + expect(extractPgservePortFromStatus(liveStatus)).toBe('8432'); + }); + test('NO_COLOR honored via colorEnabled() helper', () => { const source = readFileSync(join(__dirname, '..', 'update.ts'), 'utf-8'); expect(source).toContain('process.env.NO_COLOR'); diff --git a/src/genie-commands/update.ts b/src/genie-commands/update.ts index 8e0c5fa5b..b610498ab 100644 --- a/src/genie-commands/update.ts +++ b/src/genie-commands/update.ts @@ -1247,8 +1247,12 @@ export function isGenieProcessSnapshotLine(line: string): boolean { export function extractPgservePortFromStatus(output: string): string | null { try { - const parsed = JSON.parse(output) as { port?: unknown; instance?: { port?: unknown } }; - const rawPort = parsed.port ?? parsed.instance?.port; + const parsed = JSON.parse(output) as { + port?: unknown; + instance?: { port?: unknown }; + runtime?: { port?: unknown }; + }; + const rawPort = parsed.port ?? parsed.instance?.port ?? parsed.runtime?.port; if (typeof rawPort === 'number' && Number.isFinite(rawPort)) return String(rawPort); if (typeof rawPort === 'string' && rawPort.trim()) return rawPort.trim(); } catch { From 9e8fb6cd34212c3572b14916f8f6211a13913040 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 22 May 2026 17:06:26 +0000 Subject: [PATCH 2/5] chore(version): bump to 4.260522.15 [auto-version] --- .claude-plugin/marketplace.json | 2 +- package.json | 2 +- plugins/genie/.claude-plugin/plugin.json | 2 +- plugins/genie/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index a8a19db21..d976e0a53 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,7 +10,7 @@ "plugins": [ { "name": "genie", - "version": "4.260522.14", + "version": "4.260522.15", "source": "./plugins/genie", "description": "Human-AI partnership for Claude Code. Share a terminal, orchestrate workers, evolve together. Brainstorm ideas, wish them into plans, make with parallel agents, ship as one team. A coding genie that grows with your project." } diff --git a/package.json b/package.json index d0745af3b..be3351fd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@automagik/genie", - "version": "4.260522.14", + "version": "4.260522.15", "description": "Collaborative terminal toolkit for human + AI workflows. NOTE: npm distribution discontinued 2026-05-09 — install via `curl -fsSL https://raw.githubusercontent.com/automagik-dev/genie/main/install.sh | bash` (cosign + SLSA verified). See https://automagik.dev/genie/release-process", "type": "module", "bin": { diff --git a/plugins/genie/.claude-plugin/plugin.json b/plugins/genie/.claude-plugin/plugin.json index 53b34873d..062612a01 100644 --- a/plugins/genie/.claude-plugin/plugin.json +++ b/plugins/genie/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "genie", - "version": "4.260522.14", + "version": "4.260522.15", "description": "Human-AI partnership for Claude Code. Share a terminal, orchestrate workers, evolve together. Brainstorm ideas, turn them into wishes, execute with /work, validate with /review, and ship as one team.", "author": { "name": "Namastex Labs" diff --git a/plugins/genie/package.json b/plugins/genie/package.json index b10df418a..60ce50347 100644 --- a/plugins/genie/package.json +++ b/plugins/genie/package.json @@ -1,6 +1,6 @@ { "name": "genie-plugin", - "version": "4.260522.14", + "version": "4.260522.15", "private": true, "description": "Runtime dependencies for genie bundled CLIs", "type": "module", From 8d77994c31f715759e18428954f9bc8da36fb5bd Mon Sep 17 00:00:00 2001 From: Genie Automagik Date: Fri, 22 May 2026 17:04:35 +0000 Subject: [PATCH 3/5] fix: report pgserve socket transport in diagnostics --- src/genie-commands/__tests__/update.test.ts | 25 +++++++++++++++++++++ src/genie-commands/update.ts | 18 +++++++++++++++ src/term-commands/serve.ts | 10 +++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/genie-commands/__tests__/update.test.ts b/src/genie-commands/__tests__/update.test.ts index f6f093560..adc6e5de6 100644 --- a/src/genie-commands/__tests__/update.test.ts +++ b/src/genie-commands/__tests__/update.test.ts @@ -24,6 +24,7 @@ import { downloadAndVerifyTarball, ensureCanonicalInstall, extractPgservePortFromStatus, + extractPgserveSocketDirFromStatus, fetchLatestManifest, formatVerifyBanner, isGenieProcessSnapshotLine, @@ -893,6 +894,18 @@ describe('Diagnostics schema (G5)', () => { expect(extractPgservePortFromStatus('not-json')).toBe(null); }); + test('diagnostics derives pgserve socket dir from live pgserve runtime status json', () => { + const liveStatus = JSON.stringify({ + installed: true, + status: 'online', + port: 8432, + socketDir: '/run/user/1000/pgserve', + runtime: { socketDir: '/run/user/1000/pgserve', port: 8432, live: true }, + }); + + expect(extractPgserveSocketDirFromStatus(liveStatus)).toBe('/run/user/1000/pgserve'); + }); + test('diagnostics derives pgserve port from live pgserve runtime status json', () => { const liveStatus = JSON.stringify({ installed: true, @@ -904,6 +917,18 @@ describe('Diagnostics schema (G5)', () => { expect(extractPgservePortFromStatus(liveStatus)).toBe('8432'); }); + test('serve status reports pgserve transport from resolver instead of stale active port', () => { + const source = readFileSync(join(__dirname, '..', '..', 'term-commands', 'serve.ts'), 'utf-8'); + const fnStart = source.indexOf('async function printPgserveHealth'); + expect(fnStart).toBeGreaterThan(-1); + const fnBody = source.slice(fnStart, source.indexOf('/**', fnStart + 1)); + + expect(fnBody).toContain('resolvePgserveTransport'); + expect(fnBody).toContain("transport?.kind === 'unix'"); + expect(fnBody).not.toContain('isSocketMode()'); + expect(fnBody).not.toContain('getActivePort()'); + }); + test('NO_COLOR honored via colorEnabled() helper', () => { const source = readFileSync(join(__dirname, '..', 'update.ts'), 'utf-8'); expect(source).toContain('process.env.NO_COLOR'); diff --git a/src/genie-commands/update.ts b/src/genie-commands/update.ts index b610498ab..a83836577 100644 --- a/src/genie-commands/update.ts +++ b/src/genie-commands/update.ts @@ -1245,6 +1245,20 @@ export function isGenieProcessSnapshotLine(line: string): boolean { ); } +export function extractPgserveSocketDirFromStatus(output: string): string | null { + try { + const parsed = JSON.parse(output) as { + socketDir?: unknown; + runtime?: { socketDir?: unknown }; + }; + const rawSocketDir = parsed.runtime?.socketDir ?? parsed.socketDir; + if (typeof rawSocketDir === 'string' && rawSocketDir.trim()) return rawSocketDir.trim(); + } catch { + // best-effort diagnostics only; callers fall back to null. + } + return null; +} + export function extractPgservePortFromStatus(output: string): string | null { try { const parsed = JSON.parse(output) as { @@ -1291,7 +1305,9 @@ async function collectUpdateDiagnostics( const signals = summarizeJsonlSignals(schedulerLog); const pgservePortFromFile = safeRead(join(GENIE_HOME, 'pgserve.port'), 200); const pgserveStatusJson = (await runCommandSilent('pgserve', ['status', '--json'], undefined, 2000)).output.trim(); + const pgserveSocketDir = extractPgserveSocketDirFromStatus(pgserveStatusJson); const pgservePort = pgservePortFromFile ?? extractPgservePortFromStatus(pgserveStatusJson); + const pgserveTransport = pgserveSocketDir ? 'unix-socket' : pgservePort ? 'tcp' : null; const diagnostics = { schemaVersion: UPDATE_DIAGNOSTIC_SCHEMA_VERSION, @@ -1331,6 +1347,8 @@ async function collectUpdateDiagnostics( genieBinPrevious: GENIE_BIN_PREVIOUS, logsDir, servePid: safeRead(join(GENIE_HOME, 'serve.pid'), 200), + pgserveTransport, + pgserveSocketDir, pgservePort, schedulerLog, tuiCrashLog, diff --git a/src/term-commands/serve.ts b/src/term-commands/serve.ts index 3bb0336ec..71f1efd9c 100644 --- a/src/term-commands/serve.ts +++ b/src/term-commands/serve.ts @@ -1475,9 +1475,15 @@ async function stopServe(): Promise { /** Check pgserve health and print status */ async function printPgserveHealth(): Promise { try { - const { isAvailable, getActivePort, isSocketMode, resolvePgserveSocketDir } = await import('../lib/db.js'); + const { isAvailable, resolvePgserveTransport } = await import('../lib/db.js'); const dbOk = await isAvailable(); - const where = isSocketMode() ? `socket ${resolvePgserveSocketDir()}` : `port ${getActivePort()}`; + const transport = dbOk ? await resolvePgserveTransport() : null; + const where = + transport?.kind === 'unix' + ? `socket ${transport.socketDir}` + : transport + ? `tcp ${transport.host}:${transport.port}` + : null; console.log(` pgserve: ${dbOk ? `healthy (${where})` : 'unreachable'}`); } catch { console.log(' pgserve: unavailable'); From 3c3aed5ccee6f0190e35b1a916144ef2f926db35 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 22 May 2026 17:28:31 +0000 Subject: [PATCH 4/5] chore(version): bump to 4.260522.16 [auto-version] --- .claude-plugin/marketplace.json | 2 +- package.json | 2 +- plugins/genie/.claude-plugin/plugin.json | 2 +- plugins/genie/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index d976e0a53..b983091ca 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,7 +10,7 @@ "plugins": [ { "name": "genie", - "version": "4.260522.15", + "version": "4.260522.16", "source": "./plugins/genie", "description": "Human-AI partnership for Claude Code. Share a terminal, orchestrate workers, evolve together. Brainstorm ideas, wish them into plans, make with parallel agents, ship as one team. A coding genie that grows with your project." } diff --git a/package.json b/package.json index be3351fd9..e3d159ad7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@automagik/genie", - "version": "4.260522.15", + "version": "4.260522.16", "description": "Collaborative terminal toolkit for human + AI workflows. NOTE: npm distribution discontinued 2026-05-09 — install via `curl -fsSL https://raw.githubusercontent.com/automagik-dev/genie/main/install.sh | bash` (cosign + SLSA verified). See https://automagik.dev/genie/release-process", "type": "module", "bin": { diff --git a/plugins/genie/.claude-plugin/plugin.json b/plugins/genie/.claude-plugin/plugin.json index 062612a01..2a8d18edc 100644 --- a/plugins/genie/.claude-plugin/plugin.json +++ b/plugins/genie/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "genie", - "version": "4.260522.15", + "version": "4.260522.16", "description": "Human-AI partnership for Claude Code. Share a terminal, orchestrate workers, evolve together. Brainstorm ideas, turn them into wishes, execute with /work, validate with /review, and ship as one team.", "author": { "name": "Namastex Labs" diff --git a/plugins/genie/package.json b/plugins/genie/package.json index 60ce50347..ff4fab6c0 100644 --- a/plugins/genie/package.json +++ b/plugins/genie/package.json @@ -1,6 +1,6 @@ { "name": "genie-plugin", - "version": "4.260522.15", + "version": "4.260522.16", "private": true, "description": "Runtime dependencies for genie bundled CLIs", "type": "module", From fb866331f93087455e8220fa8390deacc913d4f3 Mon Sep 17 00:00:00 2001 From: Genie Automagik Date: Fri, 22 May 2026 17:49:39 +0000 Subject: [PATCH 5/5] fix: recognize standalone brain installs --- src/term-commands/brain.ts | 26 ++++++++++++++++++++++++++ src/term-commands/serve.ts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/src/term-commands/brain.ts b/src/term-commands/brain.ts index 0c420084f..3efaa769c 100644 --- a/src/term-commands/brain.ts +++ b/src/term-commands/brain.ts @@ -351,6 +351,10 @@ async function showVersion(): Promise { } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); if (isModuleNotFound(msg)) { + if (canRunStandaloneBrain()) { + executeStandaloneBrain(['--version']); + return; + } console.log(' Brain is not installed. Run: genie brain install'); return; } @@ -492,6 +496,24 @@ function isModuleNotFound(msg: string): boolean { return msg.includes('Cannot find') || msg.includes('not found') || msg.includes('MODULE_NOT_FOUND'); } +function shellQuote(value: string): string { + return `'${value.replace(/'/g, "'\\''")}'`; +} + +function canRunStandaloneBrain(): boolean { + try { + execSync('command -v brain', { stdio: 'ignore', shell: '/bin/bash' }); + return true; + } catch { + return false; + } +} + +function executeStandaloneBrain(args: string[]): void { + const quotedArgs = args.map(shellQuote).join(' '); + execSync(`brain ${quotedArgs}`, { stdio: 'inherit', env: process.env, shell: '/bin/bash' }); +} + function printNotInstalledMessage(): void { console.log(''); console.log(' Brain is an enterprise knowledge graph engine.'); @@ -524,6 +546,10 @@ async function executeBrainCommand(args: string[]): Promise { } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); if (isModuleNotFound(msg)) { + if (canRunStandaloneBrain()) { + executeStandaloneBrain(args); + return; + } printNotInstalledMessage(); process.exit(1); } else { diff --git a/src/term-commands/serve.ts b/src/term-commands/serve.ts index 71f1efd9c..5cb818e3c 100644 --- a/src/term-commands/serve.ts +++ b/src/term-commands/serve.ts @@ -1558,6 +1558,43 @@ async function probeBrainHealth(brainPort: number): Promise { } } +interface ActiveBrainConfigFile { + brainSlug?: string; + database?: string; + pid?: number; + port?: number; +} + +function readActiveBrainConfigFile(): ActiveBrainConfigFile | null { + try { + const configPath = join(homedir(), '.brain', 'config.json'); + if (!existsSync(configPath)) return null; + const config = JSON.parse(readFileSync(configPath, 'utf-8')) as ActiveBrainConfigFile; + if (!config.pid || !isProcessAlive(config.pid) || !config.port) return null; + return config; + } catch { + return null; + } +} + +async function printStandaloneBrainStatus(): Promise { + const config = readActiveBrainConfigFile(); + if (!config?.port) return false; + try { + const resp = await fetch(`http://127.0.0.1:${config.port}/healthz`); + const label = config.brainSlug ?? config.database ?? `port ${config.port}`; + console.log( + resp.ok + ? ` brain: running (${label}, port ${config.port})` + : ` brain: unhealthy (${label}, status ${resp.status})`, + ); + return true; + } catch { + console.log(` brain: stopped (port ${config.port} unreachable)`); + return true; + } +} + async function printBrainStatus(): Promise { try { // @ts-expect-error — brain is enterprise-only, not in genie's deps @@ -1575,6 +1612,7 @@ async function printBrainStatus(): Promise { console.log(' brain: stopped'); } } catch { + if (await printStandaloneBrainStatus()) return; console.log(' brain: not installed'); } }