Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(skills): preserve explicit hook bin in detached mode

cyhfd5c023cf100
diff --git a/skills/background-watch-hook/scripts/watch_then_hook.sh b/skills/background-watch-hook/scripts/watch_then_hook.sh
index 5a4ca35e7..949459725 100755
--- a/skills/background-watch-hook/scripts/watch_then_hook.sh
+++ b/skills/background-watch-hook/scripts/watch_then_hook.sh
@@ -213,7 +213,6 @@ _run_hook_command() {
}
if [[ "$foreground" -ne 1 ]]; then
- hook_runner="$(_resolve_hook_command)"
if [[ -z "$log_file" ]]; then
log_file="/tmp/background-watch-hook-$(date +%Y%m%d%H%M%S)-$$.log"
fi
@@ -222,11 +221,21 @@ if [[ "$foreground" -ne 1 ]]; then
"$script_path"
--foreground
--session-key "$session_key"
- --hook-cmd "$hook_runner"
--timeout "$timeout_seconds"
--timeout-exit-code "$timeout_exit_code"
)
+ if [[ -n "$hook_cmd_override" ]]; then
+ _resolve_hook_command >/dev/null
+ child_args+=(--hook-cmd "$hook_cmd_override")
+ elif [[ -n "$hook_bin" ]]; then
+ _resolve_hook_command >/dev/null
+ child_args+=(--hook-bin "$hook_bin")
+ else
+ hook_runner="$(_resolve_hook_command)"
+ child_args+=(--hook-cmd "$hook_runner")
+ fi
+
if [[ -n "$prefix" ]]; then
child_args+=(--prefix "$prefix")
fi
diff --git a/tests/test_background_watch_hook_scripts.py b/tests/test_background_watch_hook_scripts.py
index c168c1bdc..23ba393de 100644
--- a/tests/test_background_watch_hook_scripts.py
+++ b/tests/test_background_watch_hook_scripts.py
@@ -228,3 +228,80 @@ exit 124
assert "--timeout-exit-code" in first_args
assert "125" in first_args
assert "retrying" not in result.stderr
+
+
+def test_detached_watch_preserves_explicit_hook_bin(tmp_path: Path) -> None:
+ source_script = (
+ Path(__file__).resolve().parents[1]
+ / "skills"
+ / "background-watch-hook"
+ / "scripts"
+ / "watch_then_hook.sh"
+ )
+ script_dir = tmp_path / "scripts"
+ script_dir.mkdir()
+
+ watch_script = script_dir / "watch_then_hook.sh"
+ shutil.copy2(source_script, watch_script)
+ watch_script.chmod(watch_script.stat().st_mode | stat.S_IXUSR)
+
+ hook_calls = tmp_path / "hook-calls.jsonl"
+ fake_hook = tmp_path / "fake-hook"
+ fake_hook.write_text(
+ f"""#!/usr/bin/env bash
+set -euo pipefail
+
+if [[ "${{1:-}}" == "hook" && "${{2:-}}" == "send" && "${{3:-}}" == "--help" ]]; then
+ echo "custom help without codex phrase"
+ exit 0
+fi
+
+python3 - <<'PY' "{str(hook_calls)}" "$@"
+import json
+import sys
+from pathlib import Path
+
+path = Path(sys.argv[1])
+args = sys.argv[2:]
+with path.open("a", encoding="utf-8") as handle:
+ handle.write(json.dumps({{"args": args}}) + "\\n")
+PY
+""",
+ encoding="utf-8",
+ )
+ fake_hook.chmod(fake_hook.stat().st_mode | stat.S_IXUSR)
+
+ log_file = tmp_path / "watch.log"
+ result = subprocess.run(
+ [
+ "bash",
+ str(watch_script),
+ "--session-key",
+ "slack::channel::C123",
+ "--hook-bin",
+ str(fake_hook),
+ "--log-file",
+ str(log_file),
+ "--",
+ "bash",
+ "-lc",
+ "echo waiter output",
+ ],
+ cwd=tmp_path,
+ capture_output=True,
+ text=True,
+ check=False,
+ timeout=10,
+ env={**os.environ, "PATH": os.environ.get("PATH", "")},
+ )
+
+ assert result.returncode == 0, result.stderr
+ deadline = time.time() + 5
+ while time.time() < deadline:
+ if hook_calls.exists():
+ break
+ time.sleep(0.05)
+
+ assert hook_calls.exists(), log_file.read_text(encoding="utf-8")
+ payload = json.loads(hook_calls.read_text(encoding="utf-8").splitlines()[-1])
+ assert payload["args"][:2] == ["hook", "send"]