From 7b997838c45463f707672692e7f953047d2dcb8a Mon Sep 17 00:00:00 2001 From: garrytan Date: Tue, 6 Oct 2026 20:34:58 +0000 Subject: [PATCH] fix(ship): Greptile triage runs only when a PR exists; every other case says why PR: unknown (gh missing, not logged in, a non-GitHub remote, or a failed lookup) used to dispatch the triage child anyway. The Step 10 check now tests gh, its login, the remote and the PR in that order, and every case but 'PR: exists' skips the dispatch and records 'Greptile: not run (); runs on the PR once it exists'. Co-authored-by: dgrant --- ship/sections/greptile.md | 13 ++++++++++--- ship/sections/greptile.md.tmpl | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ship/sections/greptile.md b/ship/sections/greptile.md index e74feb2a9..51f4f76c2 100644 --- a/ship/sections/greptile.md +++ b/ship/sections/greptile.md @@ -2,13 +2,20 @@ ## Step 10: Address Greptile review comments (if PR exists) -Check for a PR first; with none there is nothing for Greptile to have reviewed: +Check for a PR first. Greptile reviews a PR, so with no PR, no `gh`, no `gh` login or +a non-GitHub remote there is nothing to triage yet: ```bash -_PR_ERR=$(gh pr view --json number -q .number 2>&1 >/dev/null) && echo "PR: exists" || case "$_PR_ERR" in *"no pull requests found"*) echo "PR: none" ;; *) echo "PR: unknown ($_PR_ERR)" ;; esac +if ! command -v gh >/dev/null 2>&1; then echo "PR: skip (gh not installed)" +elif ! gh auth status >/dev/null 2>&1; then echo "PR: skip (gh not logged in)" +elif ! _GH_ERR=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>&1 >/dev/null); then echo "PR: skip (not a GitHub remote: $(printf '%s' "$_GH_ERR" | head -1))" +elif _PR_ERR=$(gh pr view --json number -q .number 2>&1 >/dev/null); then echo "PR: exists" +else case "$_PR_ERR" in *"no pull requests found"*) echo "PR: skip (no PR yet)" ;; *) echo "PR: skip (PR lookup failed: $(printf '%s' "$_PR_ERR" | head -1))" ;; esac +fi ``` -`PR: none` → skip the dispatch, record "Greptile: runs on the PR once it exists; the next /ship or /review triages it", and continue to Step 11. Otherwise dispatch: +Only `PR: exists` dispatches. `PR: skip ()` → do not dispatch; record +"Greptile: not run (); runs on the PR once it exists" and continue to Step 11. Dispatch a subagent through Agent with `subagent_type: "general-purpose"` and `run_in_background: false`, using Step 7's shared foreground-dispatch rule. diff --git a/ship/sections/greptile.md.tmpl b/ship/sections/greptile.md.tmpl index f1cbcb760..42bb6e913 100644 --- a/ship/sections/greptile.md.tmpl +++ b/ship/sections/greptile.md.tmpl @@ -1,12 +1,19 @@ ## Step 10: Address Greptile review comments (if PR exists) -Check for a PR first; with none there is nothing for Greptile to have reviewed: +Check for a PR first. Greptile reviews a PR, so with no PR, no `gh`, no `gh` login or +a non-GitHub remote there is nothing to triage yet: ```bash -_PR_ERR=$(gh pr view --json number -q .number 2>&1 >/dev/null) && echo "PR: exists" || case "$_PR_ERR" in *"no pull requests found"*) echo "PR: none" ;; *) echo "PR: unknown ($_PR_ERR)" ;; esac +if ! command -v gh >/dev/null 2>&1; then echo "PR: skip (gh not installed)" +elif ! gh auth status >/dev/null 2>&1; then echo "PR: skip (gh not logged in)" +elif ! _GH_ERR=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>&1 >/dev/null); then echo "PR: skip (not a GitHub remote: $(printf '%s' "$_GH_ERR" | head -1))" +elif _PR_ERR=$(gh pr view --json number -q .number 2>&1 >/dev/null); then echo "PR: exists" +else case "$_PR_ERR" in *"no pull requests found"*) echo "PR: skip (no PR yet)" ;; *) echo "PR: skip (PR lookup failed: $(printf '%s' "$_PR_ERR" | head -1))" ;; esac +fi ``` -`PR: none` → skip the dispatch, record "Greptile: runs on the PR once it exists; the next /ship or /review triages it", and continue to Step 11. Otherwise dispatch: +Only `PR: exists` dispatches. `PR: skip ()` → do not dispatch; record +"Greptile: not run (); runs on the PR once it exists" and continue to Step 11. Dispatch a subagent through Agent with `subagent_type: "general-purpose"` and `run_in_background: false`, using Step 7's shared foreground-dispatch rule.