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