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): require auth for github polling

cyh64ad45c49b5a
diff --git a/skills/background-watch-hook/SKILL.md b/skills/background-watch-hook/SKILL.md
index 253b58fd3..75931f506 100644
--- a/skills/background-watch-hook/SKILL.md
+++ b/skills/background-watch-hook/SKILL.md
@@ -131,6 +131,8 @@ Use `scripts/wait_for_github_pr_activity.py` only when the thing being watched i
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.
+The included GitHub waiter expects GitHub authentication by default. It will use `GITHUB_TOKEN`, `GH_TOKEN`, or `gh auth token`. Only use `--allow-unauthenticated` for slower best-effort polling when authentication is not available.
+
### 2. Decide the session target
Use the current thread when the user wants the result to continue in context.
@@ -216,6 +218,22 @@ nohup bash -lc '
' >/tmp/watch-pr-151-catch-up.log 2>&1 &
```
+If authentication is unavailable and a quick one-off best-effort watch is still acceptable, you may opt in explicitly:
+
+```bash
+nohup bash -lc '
+ scripts/watch_then_hook.sh \
+ --session-key "slack::channel::C123::thread::171717.123" \
+ --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
+' >/tmp/watch-pr-151-unauth.log 2>&1 &
+```
+
## Failure Handling
- If the waiter requires credentials, verify them before starting the background process.
diff --git a/skills/background-watch-hook/scripts/wait_for_github_pr_activity.py b/skills/background-watch-hook/scripts/wait_for_github_pr_activity.py
index 6a07a02a7..60806bad6 100755
--- a/skills/background-watch-hook/scripts/wait_for_github_pr_activity.py
+++ b/skills/background-watch-hook/scripts/wait_for_github_pr_activity.py
@@ -39,6 +39,12 @@ def _get_token() -> str | None:
return token or None
+def _min_interval_for_unauthenticated() -> float:
+ # Each poll performs three API requests. Keep unauthenticated usage at or below
+ # GitHub's 60 requests/hour ceiling with a small safety margin.
+ return 180.0
+
+
def _github_get(url: str, token: str | None) -> Any:
request = urllib.request.Request(url)
request.add_header("Accept", "application/vnd.github+json")
@@ -189,9 +195,39 @@ def main() -> int:
action="store_true",
help="Treat current existing activity as pending when no explicit cursor is provided",
)
+ parser.add_argument(
+ "--allow-unauthenticated",
+ action="store_true",
+ help="Allow polling without GitHub auth; the interval will be clamped to a safer minimum",
+ )
args = parser.parse_args()
token = _get_token()
+ if token is None and not args.allow_unauthenticated:
+ print(
+ (
+ "GitHub authentication is required for reliable polling. "
+ "Set GITHUB_TOKEN/GH_TOKEN, run 'gh auth login', or pass "
+ "--allow-unauthenticated for a throttled best-effort run."
+ ),
+ file=sys.stderr,
+ )
+ return 2
+
+ effective_interval = max(args.interval, 1.0)
+ if token is None:
+ unauthenticated_min = _min_interval_for_unauthenticated()
+ if effective_interval < unauthenticated_min:
+ print(
+ (
+ "No GitHub token detected; clamping polling interval from %.1fs to %.1fs "
+ "to avoid unauthenticated rate-limit lockout."
+ )
+ % (effective_interval, unauthenticated_min),
+ file=sys.stderr,
+ )
+ effective_interval = unauthenticated_min
+
start = time.monotonic()
try:
@@ -245,11 +281,20 @@ def main() -> int:
print("Timed out while waiting for GitHub PR activity", file=sys.stderr)
return 124
- time.sleep(max(args.interval, 1.0))
+ time.sleep(effective_interval)
try:
state = _fetch_state(args.repo, args.pr, token)
except urllib.error.HTTPError as err:
+ if token is None and err.code in {403, 429}:
+ print(
+ (
+ "GitHub unauthenticated polling hit a rate limit. "
+ "Authenticate with 'gh auth login' or GITHUB_TOKEN/GH_TOKEN."
+ ),
+ file=sys.stderr,
+ )
+ return 1
print(f"GitHub API error during polling: {err.code} {err.reason}", file=sys.stderr)
continue
except Exception as err: # noqa: BLE001