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.

feat(skills): add github pr watch wrapper

cyh79e1eb4babf1
diff --git a/skills/background-watch-hook/SKILL.md b/skills/background-watch-hook/SKILL.md
index 75931f506..fe20397d8 100644
--- a/skills/background-watch-hook/SKILL.md
+++ b/skills/background-watch-hook/SKILL.md
@@ -45,6 +45,8 @@ Use this pattern for any one-off "wait in the background, then come back here" t
- `scripts/watch_then_hook.sh`
General wrapper. Runs a waiter command, captures `stdout`, then calls `vibe hook send`.
+- `scripts/watch_github_pr_then_hook.sh`
+ Thin convenience wrapper for the common GitHub PR case. It forwards GitHub-specific flags to the bundled waiter and generic delivery flags to the main wrapper.
- `scripts/wait_for_github_pr_activity.py`
Included example waiter. Polls a GitHub PR until new review activity appears, then prints a concise summary.
@@ -99,18 +101,16 @@ scripts/watch_then_hook.sh \
## Preferred Execution Pattern
-Run the wrapper itself in the background with `nohup bash -lc '...'`:
+For GitHub PR review activity, prefer the thin convenience wrapper:
```bash
nohup bash -lc '
- scripts/watch_then_hook.sh \
+ scripts/watch_github_pr_then_hook.sh \
--session-key "slack::channel::C123::thread::171717.123" \
+ --repo cyhhao/vibe-remote \
+ --pr 151 \
--prefix "GitHub PR #151 has new review activity. Fetch the latest review state, summarize unresolved items, and continue handling them if needed." \
- -- \
- scripts/wait_for_github_pr_activity.py \
- --repo cyhhao/vibe-remote \
- --pr 151 \
- --interval 45
+ --interval 45
' >/tmp/watch-pr-151.log 2>&1 &
```
@@ -118,6 +118,8 @@ That command returns immediately, leaves the watcher running, and sends the hook
When running inside the Vibe Remote repo or worktree, the wrapper will auto-fallback to `uv run python -m vibe` if the `vibe` executable on `PATH` is not the real CLI.
+For non-GitHub cases, keep using `scripts/watch_then_hook.sh` directly.
+
## Generic Workflow
### 1. Pick the waiter
@@ -127,7 +129,7 @@ For other use cases, either:
- write a new small waiter in the task workspace, or
- reuse another existing blocking command that prints a final summary to `stdout`
-Use `scripts/wait_for_github_pr_activity.py` only when the thing being watched is GitHub PR review activity.
+Use `scripts/watch_github_pr_then_hook.sh` for the normal GitHub PR path. Reach for `scripts/wait_for_github_pr_activity.py` directly only when you need the bare waiter behavior without the convenience wrapper.
If the watcher should immediately surface activity that already exists at startup, add `--catch-up`. Without it, the included GitHub waiter snapshots current activity as the baseline and waits only for newer events.
@@ -147,7 +149,7 @@ The prefix should tell the next turn what to do with the watcher result. Good pr
### 4. Start the detached wrapper
-Run `nohup bash -lc 'scripts/watch_then_hook.sh ...' >/tmp/<name>.log 2>&1 &`.
+Run `nohup bash -lc 'scripts/watch_github_pr_then_hook.sh ...' >/tmp/<name>.log 2>&1 &` for GitHub PRs, or `watch_then_hook.sh` directly for other cases.
### 5. Tell the user what was started
@@ -187,19 +189,17 @@ The wrapper is the reusable part. Waiters should stay disposable and task-specif
## Included Example: GitHub PR Activity
-`scripts/wait_for_github_pr_activity.py` snapshots the current PR state on startup when no explicit cursor is provided, then blocks until something newer appears. Use it as:
+`scripts/watch_github_pr_then_hook.sh` is the normal entry point for GitHub PR activity. It wraps `watch_then_hook.sh` plus `wait_for_github_pr_activity.py` into one command:
```bash
nohup bash -lc '
- scripts/watch_then_hook.sh \
+ scripts/watch_github_pr_then_hook.sh \
--session-key "slack::channel::C123::thread::171717.123" \
+ --repo cyhhao/vibe-remote \
+ --pr 151 \
--prefix "PR review changed. Check the latest GitHub review results and continue the review loop." \
- -- \
- scripts/wait_for_github_pr_activity.py \
- --repo cyhhao/vibe-remote \
- --pr 151 \
- --interval 60 \
- --timeout 14400
+ --interval 60 \
+ --timeout 14400
' >/tmp/watch-pr-151.log 2>&1 &
```
@@ -207,14 +207,12 @@ To catch up on comments or reviews that already exist before the watcher starts,
```bash
nohup bash -lc '
- scripts/watch_then_hook.sh \
+ scripts/watch_github_pr_then_hook.sh \
--session-key "slack::channel::C123::thread::171717.123" \
+ --repo cyhhao/vibe-remote \
+ --pr 151 \
--prefix "PR review already has activity. Pull the current review state and continue the thread." \
- -- \
- scripts/wait_for_github_pr_activity.py \
- --repo cyhhao/vibe-remote \
- --pr 151 \
- --catch-up
+ --catch-up
' >/tmp/watch-pr-151-catch-up.log 2>&1 &
```
@@ -222,15 +220,13 @@ If authentication is unavailable and a quick one-off best-effort watch is still
```bash
nohup bash -lc '
- scripts/watch_then_hook.sh \
+ scripts/watch_github_pr_then_hook.sh \
--session-key "slack::channel::C123::thread::171717.123" \
+ --repo cyhhao/vibe-remote \
+ --pr 151 \
--prefix "Best-effort unauthenticated GitHub watch fired. Inspect the latest PR state." \
- -- \
- scripts/wait_for_github_pr_activity.py \
- --repo cyhhao/vibe-remote \
- --pr 151 \
- --allow-unauthenticated \
- --interval 180
+ --allow-unauthenticated \
+ --interval 180
' >/tmp/watch-pr-151-unauth.log 2>&1 &
```
diff --git a/skills/background-watch-hook/scripts/watch_github_pr_then_hook.sh b/skills/background-watch-hook/scripts/watch_github_pr_then_hook.sh
new file mode 100755
index 000000000..cdc0c6d13
--- /dev/null
+++ b/skills/background-watch-hook/scripts/watch_github_pr_then_hook.sh
@@ -0,0 +1,200 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+WRAPPER="$SCRIPT_DIR/watch_then_hook.sh"
+WAITER="$SCRIPT_DIR/wait_for_github_pr_activity.py"
+
+usage() {
+ cat <<'EOF'
+Usage:
+ watch_github_pr_then_hook.sh --session-key <session_key> --repo <owner/name> --pr <number> [options]
+
+Options:
+ --session-key <value> Required. Target session key for vibe hook send.
+ --repo <value> Required. GitHub repo in owner/name form.
+ --pr <number> Required. Pull request number.
+ --prefix <value> Optional. Hook prefix. If omitted, a sensible default is used.
+ --interval <seconds> Optional. Polling interval passed to the waiter.
+ --timeout <seconds> Optional. Overall waiter timeout.
+ --event-limit <count> Optional. Maximum rendered events.
+ --catch-up Optional. Treat existing PR activity as pending immediately.
+ --allow-unauthenticated Optional. Allow throttled best-effort polling without GitHub auth.
+ --since-review-id <id> Optional. Review cursor.
+ --since-review-comment-id <id> Optional. Review-comment cursor.
+ --since-issue-comment-id <id> Optional. PR conversation comment cursor.
+ --post-to <thread|channel> Optional. Passed through to the wrapper.
+ --deliver-key <value> Optional. Passed through to the wrapper.
+ --hook-bin <value> Optional. Passed through to the wrapper.
+ --hook-cmd <value> Optional. Passed through to the wrapper.
+ --timeout-exit-code <n> Optional. Passed through to the wrapper.
+ -h, --help Show this help.
+EOF
+}
+
+session_key=""
+repo=""
+pr=""
+prefix=""
+interval=""
+timeout=""
+event_limit=""
+catch_up=0
+allow_unauthenticated=0
+since_review_id=""
+since_review_comment_id=""
+since_issue_comment_id=""
+post_to=""
+deliver_key=""
+hook_bin=""
+hook_cmd=""
+timeout_exit_code=""
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --session-key)
+ session_key="${2:-}"
+ shift 2
+ ;;
+ --repo)
+ repo="${2:-}"
+ shift 2
+ ;;
+ --pr)
+ pr="${2:-}"
+ shift 2
+ ;;
+ --prefix)
+ prefix="${2:-}"
+ shift 2
+ ;;
+ --interval)
+ interval="${2:-}"
+ shift 2
+ ;;
+ --timeout)
+ timeout="${2:-}"
+ shift 2
+ ;;
+ --event-limit)
+ event_limit="${2:-}"
+ shift 2
+ ;;
+ --catch-up)
+ catch_up=1
+ shift
+ ;;
+ --allow-unauthenticated)
+ allow_unauthenticated=1
+ shift
+ ;;
+ --since-review-id)
+ since_review_id="${2:-}"
+ shift 2
+ ;;
+ --since-review-comment-id)
+ since_review_comment_id="${2:-}"
+ shift 2
+ ;;
+ --since-issue-comment-id)
+ since_issue_comment_id="${2:-}"
+ shift 2
+ ;;
+ --post-to)
+ post_to="${2:-}"
+ shift 2
+ ;;
+ --deliver-key)
+ deliver_key="${2:-}"
+ shift 2
+ ;;
+ --hook-bin)
+ hook_bin="${2:-}"
+ shift 2
+ ;;
+ --hook-cmd)
+ hook_cmd="${2:-}"
+ shift 2
+ ;;
+ --timeout-exit-code)
+ timeout_exit_code="${2:-}"
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ echo "Unknown option: $1" >&2
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+
+if [[ -z "$session_key" || -z "$repo" || -z "$pr" ]]; then
+ echo "--session-key, --repo, and --pr are required" >&2
+ usage >&2
+ exit 2
+fi
+
+if [[ ! -x "$WRAPPER" ]]; then
+ echo "Wrapper not found or not executable: $WRAPPER" >&2
+ exit 127
+fi
+
+if [[ ! -x "$WAITER" ]]; then
+ echo "Waiter not found or not executable: $WAITER" >&2
+ exit 127
+fi
+
+if [[ -z "$prefix" ]]; then
+ prefix="GitHub PR #$pr has new review activity. Fetch the latest review state, summarize actionable items, and continue handling them if needed."
+fi
+
+wrapper_args=("$WRAPPER" --session-key "$session_key" --prefix "$prefix")
+
+if [[ -n "$post_to" ]]; then
+ wrapper_args+=(--post-to "$post_to")
+fi
+if [[ -n "$deliver_key" ]]; then
+ wrapper_args+=(--deliver-key "$deliver_key")
+fi
+if [[ -n "$hook_bin" ]]; then
+ wrapper_args+=(--hook-bin "$hook_bin")
+fi
+if [[ -n "$hook_cmd" ]]; then
+ wrapper_args+=(--hook-cmd "$hook_cmd")
+fi
+if [[ -n "$timeout_exit_code" ]]; then
+ wrapper_args+=(--timeout-exit-code "$timeout_exit_code")
+fi
+
+waiter_args=("$WAITER" --repo "$repo" --pr "$pr")
+
+if [[ -n "$interval" ]]; then
+ waiter_args+=(--interval "$interval")
+fi
+if [[ -n "$timeout" ]]; then
+ waiter_args+=(--timeout "$timeout")
+fi
+if [[ -n "$event_limit" ]]; then
+ waiter_args+=(--event-limit "$event_limit")
+fi
+if [[ "$catch_up" -eq 1 ]]; then
+ waiter_args+=(--catch-up)
+fi
+if [[ "$allow_unauthenticated" -eq 1 ]]; then
+ waiter_args+=(--allow-unauthenticated)
+fi
+if [[ -n "$since_review_id" ]]; then
+ waiter_args+=(--since-review-id "$since_review_id")
+fi
+if [[ -n "$since_review_comment_id" ]]; then
+ waiter_args+=(--since-review-comment-id "$since_review_comment_id")
+fi
+if [[ -n "$since_issue_comment_id" ]]; then
+ waiter_args+=(--since-issue-comment-id "$since_issue_comment_id")
+fi
+
+"${wrapper_args[@]}" -- "${waiter_args[@]}"