From 640053d72729152d7194e6bca87ec409a80601b7 Mon Sep 17 00:00:00 2001 From: bigphoot Date: Tue, 27 Jan 2026 09:40:03 -0800 Subject: [PATCH] fix: use bun-runner to find Bun on fresh install (#818) On fresh installations, smart-install.js installs Bun to ~/.bun/bin/bun but Bun isn't in PATH until terminal restart. Subsequent hooks fail because they try to run `bun ...` directly. This fix introduces bun-runner.js - a Node.js script that finds Bun in common install locations (not just PATH) and runs commands with it. All hooks now use `node bun-runner.js ...` instead of `bun ...`. The bun-runner checks: - PATH (via which/where) - ~/.bun/bin/bun (default install location) - /usr/local/bin/bun - /opt/homebrew/bin/bun (macOS Homebrew) - /home/linuxbrew/.linuxbrew/bin/bun (Linuxbrew) - Windows: %LOCALAPPDATA%\bun or fallback paths Fixes #818 Co-Authored-By: Claude Opus 4.5 --- plugin/hooks/hooks.json | 37 ++++++++++++--- plugin/scripts/bun-runner.js | 88 ++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 plugin/scripts/bun-runner.js diff --git a/plugin/hooks/hooks.json b/plugin/hooks/hooks.json index 2620f456..b0502d4a 100644 --- a/plugin/hooks/hooks.json +++ b/plugin/hooks/hooks.json @@ -19,12 +19,22 @@ "hooks": [ { "type": "command", - "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/smart-install.js\" && bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" stop && bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code context", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/smart-install.js\"", "timeout": 300 }, { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code user-message", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start", + "timeout": 60 + }, + { + "type": "command", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code context", + "timeout": 60 + }, + { + "type": "command", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code user-message", "timeout": 60 } ] @@ -35,7 +45,12 @@ "hooks": [ { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code session-init", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start", + "timeout": 60 + }, + { + "type": "command", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code session-init", "timeout": 60 } ] @@ -47,8 +62,13 @@ "hooks": [ { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code observation", - "timeout": 30 + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start", + "timeout": 60 + }, + { + "type": "command", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code observation", + "timeout": 120 } ] } @@ -58,7 +78,12 @@ "hooks": [ { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code summarize", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" start", + "timeout": 60 + }, + { + "type": "command", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/bun-runner.js\" \"${CLAUDE_PLUGIN_ROOT}/scripts/worker-service.cjs\" hook claude-code summarize", "timeout": 120 } ] diff --git a/plugin/scripts/bun-runner.js b/plugin/scripts/bun-runner.js new file mode 100644 index 00000000..aaf8b21d --- /dev/null +++ b/plugin/scripts/bun-runner.js @@ -0,0 +1,88 @@ +#!/usr/bin/env node +/** + * Bun Runner - Finds and executes Bun even when not in PATH + * + * This script solves the fresh install problem where: + * 1. smart-install.js installs Bun to ~/.bun/bin/bun + * 2. But Bun isn't in PATH until terminal restart + * 3. Subsequent hooks fail because they can't find `bun` + * + * Usage: node bun-runner.js