Loading...
Loading...
Iteratively improves a PR (GitHub), MR (GitLab), or shelved changelist (Perforce) until Greptile gives it a 5/5 confidence score with zero unresolved comments. Identical to greploop, but triggers reviews by tagging @greptile-apps, which bypasses Greptile's file-count limit on huge PRs that the plain @greptile mention refuses to review. Use when the user wants to fully optimize a large PR/MR/CL against Greptile's code review standards.
npx skill4agent add michaelshimeles/skills greploop-apps@greptile-apps@greptile-apps review--max-iterations N# Check for Perforce environment
if p4 info >/dev/null 2>&1; then
VCS="perforce"
else
REMOTE_URL=$(git remote get-url origin)
if echo "$REMOTE_URL" | grep -qi "gitlab"; then
VCS="gitlab"
else
VCS="github"
fi
fi--vcs gitlab--vcs perforcegh pr view --json number,headRefName -q '{number: .number, branch: .headRefName}'glab mr view --output json | jq '{iid: .iid, branch: .source_branch}'# List pending changelists for current user/client
p4 changes -s pending -u $P4USER -c $P4CLIENT
# Describe a specific CL
p4 describe -s <CL_NUMBER>p4 clientnumberheadRefNameheadRefOidiidsource_branchshaP4CLIENT--max-iterationsgit push# Re-shelve to update the shelved files for review
p4 shelve -f -c <CL_NUMBER>sleep 5GREPTILE_STATE=$(gh pr checks <PR_NUMBER> --json name,state | jq -r '.[] | select(.name | test("greptile"; "i")) | .state')PENDINGIN_PROGRESSif [ "$GREPTILE_STATE" != "PENDING" ] && [ "$GREPTILE_STATE" != "IN_PROGRESS" ]; then
gh pr comment <PR_NUMBER> --body "@greptile-apps review"
fiHEAD_SHA=$(gh pr view <PR_NUMBER> --json headRefOid -q .headRefOid)
ATTEMPTS=0
MAX_ATTEMPTS=60
POLL_INTERVAL_SECONDS=10
while true; do
ATTEMPTS=$((ATTEMPTS + 1))
if [ "$ATTEMPTS" -gt "$MAX_ATTEMPTS" ]; then
echo "Timed out waiting for the Greptile check run after approximately 10 minutes." >&2
exit 1
fi
GREPTILE_CHECK=$(gh api "repos/{owner}/{repo}/commits/$HEAD_SHA/check-runs" \
--jq '.check_runs[] | select(.name | test("greptile"; "i"))' 2>/dev/null)
if [ -z "$GREPTILE_CHECK" ]; then
echo "Waiting for Greptile check to appear..."
sleep "$POLL_INTERVAL_SECONDS"
continue
fi
STATUS=$(echo "$GREPTILE_CHECK" | jq -r '.status // "completed"')
CONCLUSION=$(echo "$GREPTILE_CHECK" | jq -r '.conclusion // "pending"')
if [ "$STATUS" = "completed" ]; then
if [ "$CONCLUSION" = "success" ]; then
echo "Greptile check passed!"
else
echo "Greptile check completed with: $CONCLUSION"
fi
break
fi
echo "Waiting for Greptile... (status: $STATUS)"
sleep "$POLL_INTERVAL_SECONDS"
doneupdated_atgh api --paginate "repos/{owner}/{repo}/issues/<PR_NUMBER>/comments?per_page=100" \
--jq '[.[] | select(.user.login | test("greptile"; "i"))] | sort_by(.updated_at) | last | {updated_at, body}'PIPELINES=$(glab api "projects/:fullpath/merge_requests/<MR_IID>/pipelines")
GREPTILE_RUNNING=$(echo "$PIPELINES" | jq '[.[] | select(.status == "running" or .status == "pending")] | length')if [ "$GREPTILE_RUNNING" = "0" ]; then
glab mr note <MR_IID> --message "@greptile-apps review"
fip4 shelveHEAD_SHA=$(glab mr view <MR_IID> --output json | jq -r '.sha')
ATTEMPTS=0
MAX_ATTEMPTS=60
POLL_INTERVAL_SECONDS=10
while true; do
ATTEMPTS=$((ATTEMPTS + 1))
if [ "$ATTEMPTS" -gt "$MAX_ATTEMPTS" ]; then
echo "Timed out waiting for the Greptile pipeline job after approximately 10 minutes." >&2
exit 1
fi
PIPELINES=$(glab api "projects/:fullpath/merge_requests/<MR_IID>/pipelines")
# Find the most recent pipeline for this SHA
PIPELINE_ID=$(echo "$PIPELINES" | jq -r --arg sha "$HEAD_SHA" \
'[.[] | select(.sha == $sha)] | sort_by(.id) | last | .id // empty')
if [ -z "$PIPELINE_ID" ]; then
echo "Waiting for Greptile pipeline to appear..."
sleep "$POLL_INTERVAL_SECONDS"
continue
fi
JOBS=$(glab api "projects/:fullpath/pipelines/$PIPELINE_ID/jobs")
GREPTILE_JOB=$(echo "$JOBS" | jq '.[] | select(.name | test("greptile"; "i"))')
if [ -z "$GREPTILE_JOB" ]; then
echo "Waiting for Greptile job to appear..."
sleep "$POLL_INTERVAL_SECONDS"
continue
fi
JOB_STATUS=$(echo "$GREPTILE_JOB" | jq -r '.status')
if [ "$JOB_STATUS" = "success" ] || [ "$JOB_STATUS" = "failed" ] || [ "$JOB_STATUS" = "canceled" ]; then
echo "Greptile job completed with: $JOB_STATUS"
break
fi
echo "Waiting for Greptile... (status: $JOB_STATUS)"
sleep "$POLL_INTERVAL_SECONDS"
donegh pr view <PR_NUMBER> --json body -q '.body'gh api --paginate "repos/{owner}/{repo}/issues/<PR_NUMBER>/comments?per_page=100"updated_atgh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/reviewsgreptile-apps[bot]greptile-apps-staging[bot]glab mr view <MR_IID> --output json | jq -r '.description'glab api "projects/:fullpath/merge_requests/<MR_IID>/notes"author.usernamep4 describe -s <CL_NUMBER>3/55/5Confidence: 3/5updated_atgh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/commentsglab api "projects/:fullpath/merge_requests/<MR_IID>/discussions"DiffNotenotes[0].type == "DiffNote""resolved": false--max-iterationsgh api graphql -f query='
query($cursor: String) {
repository(owner: "OWNER", name: "REPO") {
pullRequest(number: PR_NUMBER) {
reviewThreads(first: 100, after: $cursor) {
pageInfo { hasNextPage endCursor }
nodes {
id
isResolved
comments(first: 1) {
nodes { body path author { login } }
}
}
}
}
}
}'gh api graphql -f query='
mutation {
t1: resolveReviewThread(input: {threadId: "ID1"}) { thread { isResolved } }
t2: resolveReviewThread(input: {threadId: "ID2"}) { thread { isResolved } }
}'glab api "projects/:fullpath/merge_requests/<MR_IID>/discussions?per_page=100""resolved": falseidglab api --method PUT \
"projects/:fullpath/merge_requests/<MR_IID>/discussions/<DISCUSSION_ID>" \
--field resolved=truegit add -A
git commit -m "address greptile review feedback (greploop iteration N)"
git push# Stage changes back into the CL and re-shelve for the next review round
p4 shelve -f -c <CL_NUMBER>sleep 5| Field | Value |
|---|---|
| Platform | GitHub / GitLab / Perforce |
| Iterations | N |
| Final confidence | X/5 |
| Comments resolved | N |
| Remaining comments | N (if any) |
Greploop complete.
Platform: GitHub
Iterations: 2
Confidence: 5/5
Resolved: 7 comments
Remaining: 0<N>--max-iterationsGreploop stopped after <N> iterations (--max-iterations <N>).
Platform: GitLab
Confidence: 4/5
Resolved: 12 comments
Remaining: 2
Remaining issues:
- src/auth.ts:45 — "Consider rate limiting this endpoint"
- src/db.ts:112 — "Missing index on user_id column"Greploop complete.
Platform: Perforce
Changelist: 12345
Iterations: 3
Confidence: 5/5
Resolved: 9 comments
Remaining: 0