Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Pulse: children never see keys loaded from .env (Bun.spawn uses the start-up environment), so the Work page is empty without gh keychain auth

Open DolphusCY opened this issue 1 month ago • 1 comments

What: pulse.ts loads .env into process.env at runtime. In Bun 1.3.9, Bun.spawn / Bun.spawnSync without an explicit env pass the environment the process started with, so no child Pulse spawns sees those keys.

Proof (3 lines):

process.env.X = "y";
const p = Bun.spawn(["sh", "-c", "echo ${X:-missing}"], { stdout: "pipe" });
console.log(await new Response(p.stdout).text()); // "missing"; with { env: process.env } it prints "y"

Effect: the Work module's gh issue list never gets GH_TOKEN, so the Work page is empty whenever gh has no keychain login (any isolated or service-account install). Log: [work] gh issue list failed (exit 4): To get started with GitHub CLI, please run: gh auth login on every refresh. Passing env: { ...process.env } at the spawn in PULSE/modules/work.ts fixed it here (0 → 11 items). Separately, Work's first refresh runs at import time, before pulse.ts loads .env, so it fails even with the fix; the next refresh succeeds.

Suggested fix: pass the env explicitly at the Pulse spawns that need .env keys (there are 24 spawn calls under PULSE). Not bun --env-file at launch: that would give every child every secret and undo the billing guard that deletes API keys after load. Related: #2422 (a token not reaching cf/wrangler).


LifeOS 8.761.0, isolated install (CLAUDE_CONFIG_DIR + separate HOME), macOS, Bun 1.3.9. Found during an audit of a test install; evidence and a generated architecture map available on request.

DolphusCY avatar Oct 30 '26 18:10 DolphusCY

[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

Thanks @DolphusCY. Your diagnosis held: on Bun 1.4.4 a child spawned without an explicit env sees the start-up environment, so a variable set at runtime is missing in it. Pulse's gh issue list call now passes env: { ...process.env }, with a test that runs a stub gh from the start-up PATH and fails without the fix. Your second point does not apply here, because Pulse loads .env before it imports that module. This lands in the next release.

danielmiessler avatar Nov 06 '26 13:11 danielmiessler