huggy-pr-agent 1.10.0 โ 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +15 -0
- package/CHANGELOG.md +41 -0
- package/INSTALL.md +3 -1
- package/README.md +34 -7
- package/action.yml +124 -115
- package/assets/huggy-good.svg +107 -0
- package/assets/huggy-reviewing.svg +690 -227
- package/assets/huggy-serious.svg +113 -0
- package/assets/pi-marketplace-card.png +0 -0
- package/docs/research-sota-pr-review.md +69 -0
- package/docs/self-hosting-gcp.md +166 -0
- package/examples/dependabot.yml +1 -1
- package/examples/gcp/cloud-run/Dockerfile +33 -0
- package/examples/gcp/cloud-run/entrypoint.sh +32 -0
- package/examples/gcp/cloud-run/webhook.py +185 -0
- package/examples/gcp/gce-setup.sh +111 -0
- package/examples/google-vertex.yml +1 -1
- package/examples/node-pnpm.yml +1 -1
- package/examples/swift-macos.yml +1 -1
- package/package.json +3 -1
- package/prompts/judge.md +10 -1
- package/scripts/fetch_pr_context.py +323 -20
- package/scripts/post_progress.py +76 -14
- package/scripts/post_review.py +138 -32
- package/scripts/prepare_command.py +269 -0
- package/scripts/run_fix.py +566 -0
- package/scripts/run_review.py +97 -63
package/AGENTS.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Huggy PR Agent โ Repository Instructions (`AGENTS.md`)
|
|
2
|
+
|
|
3
|
+
`huggy-pr-agent` is a zero-dependency Python 3 stdlib + GitHub Composite Action + Pi Package (`extensions/huggy.ts`) + Agent Skills bundle (`skills/`).
|
|
4
|
+
|
|
5
|
+
## Core Invariants
|
|
6
|
+
|
|
7
|
+
1. **Zero Python third-party runtime dependencies:** All orchestrator scripts under `scripts/` (`fetch_pr_context.py`, `run_review.py`, `post_review.py`, `post_progress.py`, `prepare_command.py`) must use Python 3 standard library only so GitHub Actions runners need zero `pip install` steps.
|
|
8
|
+
2. **Strict Secret & Token Isolation (`SECURITY.md`):**
|
|
9
|
+
- `GH_TOKEN` must **never** be passed into `env:` of any step that runs `pi` or `verify_cmd`, and must **never** be persisted into `.git/config` or `.git/FETCH_HEAD` (`persist-credentials: false` + ephemeral `git -c http.https://github.com/.extraheader=...` + `rm -f .git/FETCH_HEAD`).
|
|
10
|
+
- **GitHub GraphQL `resolveReviewThread` quirk (`orgs/community#20469`):** GitHub's GraphQL `resolveReviewThread` mutation rejects `GITHUB_TOKEN` with `FORBIDDEN: Resource not accessible by integration` unless **both** `contents: write` and `pull-requests: write` are granted on the `review` job. Do not flag `contents: write` on `review` jobs when `persist-credentials: false` and `.git/config` / `FETCH_HEAD` scrubbing are in place.
|
|
11
|
+
- `AGENTS.md`, `CLAUDE.md`, `REVIEW.md`, `.instructions.md`, and `.gitattributes` are always read from the `base` branch (`git show base:...`), never from untrusted PR head files.
|
|
12
|
+
3. **Tests & Validation:**
|
|
13
|
+
- Every behavior change in `scripts/` must be covered in `tests/test_post_review.py` (`python3 tests/test_post_review.py -v`).
|
|
14
|
+
- Every pixel-art SVG in `assets/` must parse as valid XML with `shape-rendering="crispEdges"`.
|
|
15
|
+
- Never merge a PR while `review` is pending or while any review thread remains unresolved (`required_conversation_resolution: true`).
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `huggy-pr-agent` are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.13.0] - 2026-11-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Coalesced Parallel `@huggy` / `@pi` Multi-Comment Fix Swarm & Test-Gate Self-Repair (`scripts/prepare_command.py`, `scripts/run_fix.py`, `scripts/post_progress.py`, `action.yml`)**: coalesces all unanswered `@huggy` / `@pi` / `/fix` comments across open PR review threads and comments into a single batch (so multi-comment PR reviews never lose items to GitHub Actions' 1-pending concurrency cap, and duplicate queued runs exit in 0 tokens via `already_handled=true`), merges same-file edits while running disjoint-file fixes concurrently across the Lead + Wingman worker pool (`ThreadPoolExecutor`), runs `setup_cmd` and `verify_cmd` once (with 1 automatic Lead repair pass if `verify_cmd` fails), commits and pushes atomically, and updates + auto-resolves every addressed thread in parallel.
|
|
9
|
+
- **Active Verification Judge (`scripts/run_review.py`, `prompts/judge.md`)**: equips `--phase judge` with read-only repository tools (`read,grep,find,ls`) and an explicit base-branch policy trust boundary so the Judge verifies claims extending beyond the 20-line excerpt against real files and callers before keeping findings.
|
|
10
|
+
- **Zero-DB Living Team Memory (`scripts/fetch_pr_context.py`, `scripts/run_review.py`)**: combines optional `.github/huggy-learnings.md` from `base-tip` with automatic GraphQL mining of recent closed/merged PR review threads where maintainers reacted `๐` or pushed back (*"intentional"*, *"by design"*, *"wontfix"*), feeding `<team_learnings>` to both Finders and Judge.
|
|
11
|
+
- **Mini Codegraph Downstream Caller Map (`scripts/fetch_pr_context.py`)**: extracts modified public/exported declarations from the PR diff and attaches external `file:line` call sites outside the PR diff (`Downstream Callers of Modified Symbols`) into `<pr_context>`.
|
|
12
|
+
|
|
13
|
+
## [1.12.3] - 2026-11-16
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **Desk Plant in Review Status Animation (`assets/huggy-reviewing.svg`, `scripts/post_progress.py`, `README.md`)**: widens the desk scene to `232x112` (`58x28` at `4px` pixel grid) to place a 16-bit terracotta pot and V-split green sprout (`#86EFAC` / `#4ADE80` / `#22C55E`) with a subtle breeze sway beside Huggy's laptop.
|
|
17
|
+
|
|
18
|
+
## [1.12.2] - 2026-11-16
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- **Exact `head.sha` Line Resolution When Target Branch Moves Ahead (`action.yml`, `scripts/post_review.py`)**: checks out `pull_request.head.sha` and diffs against `git merge-base base-tip HEAD` instead of `refs/pull/<pr>/merge` (`HEAD^1..HEAD`), eliminating `HTTP 422 "Line could not be resolved"` line-number drift when new commits land on the target branch after a PR opens (while continuing to read trusted rubrics, `.github/pi-review-prompt.md`, and `.gitattributes` from `base-tip`). `submit_inline_comments()` also pins `"commit_id": head_sha` and retries individual comments if a multi-comment batch `POST` returns `422`.
|
|
22
|
+
|
|
23
|
+
## [1.12.1] - 2026-11-14
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
- **Polished Coffee-Sip Choreography & Zero-Ghosting SMIL (`assets/huggy-reviewing.svg`)**: re-choreographs `huggy-reviewing.svg` into a smooth 36-beat (`6.12s`) pixel-art loop โ brisk typing, a clear pause on the home row, glancing left and reaching across to grip the mug handle on the desk, lifting to mouth height below the sunglasses, tilting the mug + head `1px` back to sip with rising steam, setting the mug back down on the desk, and returning the hand to resume typing โ driven by discrete `visibility` (`begin="0s"`) with explicit base `visibility` matching each layer's first beat so browsers never alpha-blend overlapping layers.
|
|
27
|
+
|
|
28
|
+
## [1.12.0] - 2026-11-14
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- **Google Cloud Self-Hosting Guides & Turnkey Templates (`docs/self-hosting-gcp.md`, `examples/gcp/`)**: documents and ships ready-to-run templates for both **Option A (Dedicated GCE VM Multi-Slot Runner, `examples/gcp/gce-setup.sh`)** and **Option B (Serverless Scale-to-Zero Ephemeral Runners on Cloud Run Jobs, `examples/gcp/cloud-run/`)** โ keeping GitHub-hosted `runs-on: ubuntu-latest` as the zero-config default while letting high-volume private orgs eliminate GitHub Actions minute usage on GCP Startup Credits with a 1-line `runs-on:` switch.
|
|
32
|
+
|
|
33
|
+
## [1.11.1] - 2026-11-13
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
- **Verified GraphQL `resolveReviewThread` & Ephemeral Fetch Auth (`scripts/post_review.py`, `scripts/fetch_pr_context.py`, `action.yml`)**: inspects GraphQL `errors` and `thread.isResolved` before counting threads as resolved, uses `persist-credentials: false` + ephemeral `-c http.<server>/.extraheader` + `FETCH_HEAD` cleanup so `GH_TOKEN` never persists on disk during `Run Pi`, and reads `.gitattributes` from `base` via `GIT_ATTR_SOURCE=base`.
|
|
37
|
+
- **Provisional `review.md` on `--phase find` (`scripts/run_review.py`)**: writes a provisional `review.md` before handing off to `--phase judge` so `post_review.py` never fails if the Judge step is skipped or interrupted, and preserves `Security: Needs attention` on `nits` verdicts.
|
|
38
|
+
- **Ambiguous Fingerprint & Security Badge Handling (`scripts/post_review.py`)**: avoids cross-line overwrites or premature thread resolution when two findings in the same file share a fingerprint, and displays a distinct `nits ยท security` alert badge when security attention is flagged without High-severity findings.
|
|
39
|
+
|
|
40
|
+
## [1.11.0] - 2026-11-13
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
- **Multi-Act Review Animation with Coffee-Sip Loop (`assets/huggy-reviewing.svg`)**: `huggy-reviewing.svg` now runs a 24-beat (`6.72s`) discrete pixel-art loop โ brisk typing on the laptop with a porcelain mug resting on the desk, followed by an occasional stoic coffee sip before returning to the keyboard.
|
|
44
|
+
- **Expressive Verdict Header Icons & Colored Verdict Badges (`assets/huggy-good.svg`, `assets/huggy-serious.svg`, `scripts/post_review.py`)**: the finished `Review by Huggy` header now adapts to the outcome at a glance โ cheerful smile + emerald badge on `looks good` / `nits`, stoic neutral + amber badge on `Medium` `needs changes`, and furrowed V-brows with crimson lens glint + red alert badge whenever `High` or security findings are present.
|
|
45
|
+
|
|
5
46
|
## [1.10.0] - 2026-11-13
|
|
6
47
|
|
|
7
48
|
### Added
|
package/INSTALL.md
CHANGED
|
@@ -78,7 +78,7 @@ jobs:
|
|
|
78
78
|
runs-on: ubuntu-latest
|
|
79
79
|
timeout-minutes: 60
|
|
80
80
|
permissions:
|
|
81
|
-
contents:
|
|
81
|
+
contents: write # required by GitHub GraphQL resolveReviewThread
|
|
82
82
|
pull-requests: write
|
|
83
83
|
concurrency:
|
|
84
84
|
group: huggy-review-${{ github.event.pull_request.number }}
|
|
@@ -140,3 +140,5 @@ jobs:
|
|
|
140
140
|
- Automatic inline review on every PR push
|
|
141
141
|
- `@huggy <instruction>` (or `@pi <instruction>` / `/fix <instruction>`) on any diff line or PR comment to push a verified fix and auto-resolve the review thread
|
|
142
142
|
- `/describe`, `/improve`, `/ask <question>`, `/review`
|
|
143
|
+
|
|
144
|
+
> **Optional โ Zero GitHub Actions Minutes on GCP (Private Orgs Only):** Keep `runs-on: ubuntu-latest` by default. If the user explicitly asks to run on Google Cloud / self-hosted runners to save private-org Actions minutes, follow [`docs/self-hosting-gcp.md`](https://github.com/tripplen23/huggy-pr-agent/blob/main/docs/self-hosting-gcp.md) (Option A: GCE VM via `examples/gcp/gce-setup.sh`, or Option B: Serverless Ephemeral Cloud Run Jobs via `examples/gcp/cloud-run/`).
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
[](https://github.com/tripplen23/huggy-pr-agent/releases)
|
|
16
16
|
[](LICENSE)
|
|
17
17
|
|
|
18
|
-
[Quick Start](#quick-start) ยท [Providers & Vertex AI](#model-providers--google-vertex-ai) ยท [Commands](#commands--capabilities) ยท [How It Works](#how-it-works) ยท [Configuration](#configuration--inputs) ยท [Agent Install Spec](https://github.com/tripplen23/huggy-pr-agent/blob/main/INSTALL.md)
|
|
18
|
+
[Quick Start](#quick-start) ยท [Providers & Vertex AI](#model-providers--google-vertex-ai) ยท [Self-Host on GCP](https://github.com/tripplen23/huggy-pr-agent/blob/main/docs/self-hosting-gcp.md) ยท [Commands](#commands--capabilities) ยท [How It Works](#how-it-works) ยท [Configuration](#configuration--inputs) ยท [Agent Install Spec](https://github.com/tripplen23/huggy-pr-agent/blob/main/INSTALL.md)
|
|
19
19
|
|
|
20
20
|
</div>
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
While a review pipeline is running, Huggy shows a compact pixel-art status indicator, then replaces it with a clean summary and inline diff comments once finished:
|
|
27
27
|
|
|
28
28
|
<div align="center">
|
|
29
|
-
<img src="https://raw.githubusercontent.com/tripplen23/huggy-pr-agent/main/assets/huggy-reviewing.svg" alt="Huggy reviewing animation" width="
|
|
29
|
+
<img src="https://raw.githubusercontent.com/tripplen23/huggy-pr-agent/main/assets/huggy-reviewing.svg" alt="Huggy reviewing animation" width="232" />
|
|
30
30
|
</div>
|
|
31
31
|
|
|
32
32
|
<br />
|
|
@@ -95,7 +95,7 @@ jobs:
|
|
|
95
95
|
runs-on: ubuntu-latest
|
|
96
96
|
timeout-minutes: 60
|
|
97
97
|
permissions:
|
|
98
|
-
contents:
|
|
98
|
+
contents: write # required by GitHub GraphQL resolveReviewThread
|
|
99
99
|
pull-requests: write
|
|
100
100
|
concurrency:
|
|
101
101
|
group: huggy-review-${{ github.event.pull_request.number }}
|
|
@@ -146,7 +146,7 @@ jobs:
|
|
|
146
146
|
- **Interactive comment commands (`issue_comment`, `pull_request_review_comment`)** activate as soon as `.github/workflows/huggy.yml` lands on your default branch.
|
|
147
147
|
- **Staying in sync with upstream updates:**
|
|
148
148
|
- **Zero-click automatic updates:** Referencing `tripplen23/huggy-pr-agent@v1` automatically picks up every engine, Judge, and prompt improvement as soon as a new `v1.x` release ships.
|
|
149
|
-
- **1-click PR approval updates:** Prefer explicit version review before upgrading? Pin `uses: tripplen23/huggy-pr-agent@v1.
|
|
149
|
+
- **1-click PR approval updates:** Prefer explicit version review before upgrading? Pin `uses: tripplen23/huggy-pr-agent@v1.12.0` and drop [`examples/dependabot.yml`](https://github.com/tripplen23/huggy-pr-agent/blob/main/examples/dependabot.yml) into `.github/dependabot.yml` (or use Renovate) โ GitHub opens a 1-click Merge PR with full release notes whenever a new version is published.
|
|
150
150
|
- **Local Pi package updates:** Run `pi update --extensions` (and `/huggy sync` inside any repo to refresh workflow templates).
|
|
151
151
|
|
|
152
152
|
---
|
|
@@ -179,7 +179,13 @@ By default, `huggy-pr-agent` uses `opencode-go/deepseek-v4.1-flash` with `openco
|
|
|
179
179
|
api_key: ${{ secrets.OPENCODE_GO_KEY }}
|
|
180
180
|
max_parallel_bundles: "2"
|
|
181
181
|
```
|
|
182
|
-
See [`examples/google-vertex.yml`](examples/google-vertex.yml) for a full workflow file.
|
|
182
|
+
See [`examples/google-vertex.yml`](https://github.com/tripplen23/huggy-pr-agent/blob/main/examples/google-vertex.yml) for a full workflow file.
|
|
183
|
+
|
|
184
|
+
### Zero GitHub Actions Minutes on GCP (Optional Self-Hosted Runners)
|
|
185
|
+
|
|
186
|
+
GitHub-hosted `runs-on: ubuntu-latest` is the default and requires zero infrastructure. If your private organization hits GitHub's 2,000 included Actions minutes/month, see **[`docs/self-hosting-gcp.md`](https://github.com/tripplen23/huggy-pr-agent/blob/main/docs/self-hosting-gcp.md)** for two turnkey Google Cloud options (both 100% Google for Startups Cloud Credit eligible, requiring only a 1-line `runs-on: [self-hosted, gcp-huggy]` change):
|
|
187
|
+
- **Option A โ Dedicated GCE VM Multi-Slot Runner** ([`examples/gcp/gce-setup.sh`](https://github.com/tripplen23/huggy-pr-agent/blob/main/examples/gcp/gce-setup.sh)): 0s cold-start and warm SSD caches across 3 concurrent runner slots.
|
|
188
|
+
- **Option B โ Serverless Ephemeral Runners on Cloud Run Jobs** ([`examples/gcp/cloud-run/`](https://github.com/tripplen23/huggy-pr-agent/tree/main/examples/gcp/cloud-run)): isolated `--ephemeral` container per job that scales down to 0 when idle.
|
|
183
189
|
|
|
184
190
|
---
|
|
185
191
|
|
|
@@ -218,7 +224,28 @@ Generic AI reviewers fail in two predictable ways: **single-call diff wrappers**
|
|
|
218
224
|
<div align="center">
|
|
219
225
|
<img src="https://raw.githubusercontent.com/tripplen23/huggy-pr-agent/main/assets/huggy-judging.svg" alt="Huggy precision Judge pass" width="196" />
|
|
220
226
|
<br />
|
|
221
|
-
<sub><em>Live precision Judge indicator โ verifies candidate findings
|
|
227
|
+
<sub><em>Live precision Judge indicator โ verifies candidate findings before transforming into one of three verdict expressions:</em></sub>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<br />
|
|
231
|
+
|
|
232
|
+
<div align="center">
|
|
233
|
+
<table>
|
|
234
|
+
<tr>
|
|
235
|
+
<td align="center" width="210">
|
|
236
|
+
<img src="https://raw.githubusercontent.com/tripplen23/huggy-pr-agent/main/assets/huggy-good.svg" alt="Huggy looks good" width="44" /><br />
|
|
237
|
+
<sub><strong><code>looks good</code> / <code>nits</code></strong></sub>
|
|
238
|
+
</td>
|
|
239
|
+
<td align="center" width="210">
|
|
240
|
+
<img src="https://raw.githubusercontent.com/tripplen23/huggy-pr-agent/main/assets/huggy-icon.svg" alt="Huggy needs changes" width="44" /><br />
|
|
241
|
+
<sub><strong><code>needs changes</code> (Medium)</strong></sub>
|
|
242
|
+
</td>
|
|
243
|
+
<td align="center" width="210">
|
|
244
|
+
<img src="https://raw.githubusercontent.com/tripplen23/huggy-pr-agent/main/assets/huggy-serious.svg" alt="Huggy high-severity alert" width="44" /><br />
|
|
245
|
+
<sub><strong><code>High</code> / Security alert</strong></sub>
|
|
246
|
+
</td>
|
|
247
|
+
</tr>
|
|
248
|
+
</table>
|
|
222
249
|
</div>
|
|
223
250
|
|
|
224
251
|
---
|
|
@@ -269,7 +296,7 @@ Comment any of these in the **PR conversation**, inside an **inline diff review
|
|
|
269
296
|
| `gcp_location` | `global` | Google Cloud region or `global` when using `google-vertex/*` models. |
|
|
270
297
|
| `gcp_credentials_json` | `""` | Google Cloud Service Account JSON key for `google-vertex/*` models (omit when using Workload Identity Federation). |
|
|
271
298
|
| `model` | `opencode-go/deepseek-v4.1-flash` | Primary / Lead model ID passed to `pi --model` (reviews the highest-risk bundle and runs the Judge pass). |
|
|
272
|
-
| `wingman_model` | `""` | Optional Wingman model ID for parallel non-lead bundles (e.g. `google-vertex/gemini-4-argon`). Defaults to `model` when empty. |
|
|
299
|
+
| `wingman_model` | `""` | Optional Wingman model ID for parallel non-lead bundles (e.g. `google-vertex/gemini-4-argon`). Must be reachable with the same credentials configured for `model` (`api_key`/`api_key_env` or Vertex `gcp_*`). Defaults to `model` when empty. |
|
|
273
300
|
| `fallback_model` | `opencode-go/glm-5.3-flash` | Emergency fallback model tried only after `model` or `wingman_model` fails (error, non-zero exit, missing verdict, or timeout) โ supports cross-provider failover. |
|
|
274
301
|
| `thinking` | `high` | Thinking depth (`off`, `minimal`, `low`, `medium`, `high`). |
|
|
275
302
|
| `review_tools` | `read,grep,find,ls` | Built-in Pi tools enabled during read-only PR reviews. |
|
package/action.yml
CHANGED
|
@@ -35,7 +35,7 @@ inputs:
|
|
|
35
35
|
required: false
|
|
36
36
|
default: "opencode-go/deepseek-v4.1-flash"
|
|
37
37
|
wingman_model:
|
|
38
|
-
description: "Optional Wingman Pi model identifier (`provider/model`) for parallel non-lead bundles (e.g. `google-vertex/gemini-4-argon`). Defaults to `model` when empty."
|
|
38
|
+
description: "Optional Wingman Pi model identifier (`provider/model`) for parallel non-lead bundles (e.g. `google-vertex/gemini-4-argon`). Must be reachable with the same credentials configured for `model` (`api_key`/`api_key_env` or Vertex `gcp_*`). Defaults to `model` when empty."
|
|
39
39
|
required: false
|
|
40
40
|
default: ""
|
|
41
41
|
fallback_model:
|
|
@@ -161,11 +161,13 @@ runs:
|
|
|
161
161
|
fi
|
|
162
162
|
echo "go=true" >> "$GITHUB_OUTPUT"
|
|
163
163
|
|
|
164
|
-
- name: Checkout PR
|
|
164
|
+
- name: Checkout PR head ref (review)
|
|
165
165
|
if: steps.gate_review.outputs.go == 'true'
|
|
166
166
|
uses: actions/checkout@v4
|
|
167
167
|
with:
|
|
168
|
-
|
|
168
|
+
ref: ${{ github.event.pull_request.head.sha }}
|
|
169
|
+
fetch-depth: 100
|
|
170
|
+
persist-credentials: false
|
|
169
171
|
token: ${{ inputs.github_token }}
|
|
170
172
|
|
|
171
173
|
- name: Resolve base branch, rubric and review context
|
|
@@ -173,6 +175,7 @@ runs:
|
|
|
173
175
|
shell: bash
|
|
174
176
|
env:
|
|
175
177
|
GH_TOKEN: ${{ inputs.github_token }}
|
|
178
|
+
SERVER: ${{ github.server_url }}
|
|
176
179
|
REPO: ${{ github.repository }}
|
|
177
180
|
TARGET: ${{ github.event.pull_request.base.ref }}
|
|
178
181
|
PR: ${{ github.event.pull_request.number }}
|
|
@@ -185,31 +188,36 @@ runs:
|
|
|
185
188
|
mkdir -p "$RUNNER_TEMP/pi-action"
|
|
186
189
|
cp -R "$ACTION_PATH/scripts" "$ACTION_PATH/prompts" "$RUNNER_TEMP/pi-action/"
|
|
187
190
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
git_basic=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\r\n')
|
|
192
|
+
git -c "http.$SERVER/.extraheader=AUTHORIZATION: basic $git_basic" \
|
|
193
|
+
fetch --no-tags --depth=100 "$SERVER/$REPO.git" \
|
|
194
|
+
"+refs/heads/$TARGET:refs/heads/base-tip"
|
|
195
|
+
mb=$(git merge-base base-tip HEAD 2>/dev/null || true)
|
|
196
|
+
if [ -z "$mb" ]; then
|
|
197
|
+
shallow_flag=""
|
|
198
|
+
[ -f "$(git rev-parse --git-dir)/shallow" ] && shallow_flag="--unshallow"
|
|
199
|
+
git -c "http.$SERVER/.extraheader=AUTHORIZATION: basic $git_basic" \
|
|
200
|
+
fetch --no-tags $shallow_flag "$SERVER/$REPO.git" \
|
|
201
|
+
"+refs/pull/$PR/head:refs/remotes/pr-head" "+refs/heads/$TARGET:refs/heads/base-tip"
|
|
202
|
+
mb=$(git merge-base base-tip HEAD 2>/dev/null || true)
|
|
195
203
|
if [ -z "$mb" ]; then
|
|
196
|
-
echo "no merge base
|
|
204
|
+
echo "no merge base between $TARGET and HEAD; refusing to review an inverted diff" >&2
|
|
197
205
|
exit 1
|
|
198
206
|
fi
|
|
199
|
-
git branch -f base "$mb"
|
|
200
207
|
fi
|
|
201
|
-
|
|
208
|
+
git branch -f base "$mb"
|
|
209
|
+
echo "base = $(git rev-parse --short base) (tip = $(git rev-parse --short base-tip), head = $(git rev-parse --short HEAD))"
|
|
202
210
|
|
|
203
|
-
if git cat-file -e "base:$RUBRIC_FILE" 2>/dev/null; then
|
|
204
|
-
git show "base:$RUBRIC_FILE" > "$RUNNER_TEMP/rubric.md"
|
|
205
|
-
elif git cat-file -e "base:CLAUDE.md" 2>/dev/null; then
|
|
206
|
-
git show "base:CLAUDE.md" > "$RUNNER_TEMP/rubric.md"
|
|
211
|
+
if git cat-file -e "base-tip:$RUBRIC_FILE" 2>/dev/null; then
|
|
212
|
+
git show "base-tip:$RUBRIC_FILE" > "$RUNNER_TEMP/rubric.md"
|
|
213
|
+
elif git cat-file -e "base-tip:CLAUDE.md" 2>/dev/null; then
|
|
214
|
+
git show "base-tip:CLAUDE.md" > "$RUNNER_TEMP/rubric.md"
|
|
207
215
|
else
|
|
208
216
|
: > "$RUNNER_TEMP/rubric.md"
|
|
209
217
|
fi
|
|
210
218
|
|
|
211
|
-
if git cat-file -e "base:.github/pi-review-prompt.md" 2>/dev/null; then
|
|
212
|
-
git show "base:.github/pi-review-prompt.md" > "$RUNNER_TEMP/brief-template.md"
|
|
219
|
+
if git cat-file -e "base-tip:.github/pi-review-prompt.md" 2>/dev/null; then
|
|
220
|
+
git show "base-tip:.github/pi-review-prompt.md" > "$RUNNER_TEMP/brief-template.md"
|
|
213
221
|
else
|
|
214
222
|
cp "$RUNNER_TEMP/pi-action/prompts/review.md" "$RUNNER_TEMP/brief-template.md"
|
|
215
223
|
fi
|
|
@@ -217,9 +225,12 @@ runs:
|
|
|
217
225
|
printf '\n\nAdditional repository instructions:\n%s\n' "$EXTRA_INSTRUCTIONS" >> "$RUNNER_TEMP/brief-template.md"
|
|
218
226
|
fi
|
|
219
227
|
|
|
220
|
-
git -c core.quotePath=false diff base HEAD > "$RUNNER_TEMP/diff.patch"
|
|
228
|
+
GIT_ATTR_SOURCE=base-tip git -c core.quotePath=false diff base HEAD > "$RUNNER_TEMP/diff.patch"
|
|
221
229
|
python3 "$RUNNER_TEMP/pi-action/scripts/fetch_pr_context.py" "$RUNNER_TEMP/pr-context.md" "$RUNNER_TEMP/diff.patch"
|
|
222
230
|
python3 "$RUNNER_TEMP/pi-action/scripts/post_progress.py"
|
|
231
|
+
# Scrub checkout token from .git/config and FETCH_HEAD before the Pi step runs
|
|
232
|
+
git config --local --unset-all "http.$SERVER/.extraheader" 2>/dev/null || true
|
|
233
|
+
rm -f .git/FETCH_HEAD
|
|
223
234
|
|
|
224
235
|
- name: Run Pi (bundle finders)
|
|
225
236
|
if: steps.gate_review.outputs.go == 'true'
|
|
@@ -258,7 +269,9 @@ runs:
|
|
|
258
269
|
python3 "$RUNNER_TEMP/pi-action/scripts/post_progress.py" judge
|
|
259
270
|
|
|
260
271
|
- name: Run Pi (precision judge)
|
|
272
|
+
id: judge
|
|
261
273
|
if: steps.gate_review.outputs.go == 'true'
|
|
274
|
+
continue-on-error: true
|
|
262
275
|
shell: bash
|
|
263
276
|
env:
|
|
264
277
|
PI_API_KEY: ${{ inputs.api_key }}
|
|
@@ -287,9 +300,23 @@ runs:
|
|
|
287
300
|
PR: ${{ github.event.pull_request.number }}
|
|
288
301
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
289
302
|
PI_REVIEW_PROFILE: ${{ inputs.review_profile }}
|
|
303
|
+
JUDGE_OUTCOME: ${{ steps.judge.outcome }}
|
|
290
304
|
run: |
|
|
291
305
|
set -euo pipefail
|
|
292
|
-
|
|
306
|
+
if [ "${JUDGE_OUTCOME:-}" = "failure" ] && [ -f review.md ]; then
|
|
307
|
+
python3 -c '
|
|
308
|
+
p = open("review.md", encoding="utf-8").read()
|
|
309
|
+
note = "\n> โ ๏ธ **Judge pass interrupted:** publishing unverified finder candidates from `--phase find`.\n"
|
|
310
|
+
lines = p.splitlines()
|
|
311
|
+
insert_at = 0
|
|
312
|
+
for i, ln in enumerate(lines):
|
|
313
|
+
if ln.startswith("**Effort:**") or ln.startswith("**Verdict:**"):
|
|
314
|
+
insert_at = i + 1
|
|
315
|
+
lines.insert(insert_at, note)
|
|
316
|
+
open("review.md", "w", encoding="utf-8").write("\n".join(lines) + "\n")
|
|
317
|
+
'
|
|
318
|
+
fi
|
|
319
|
+
GIT_ATTR_SOURCE=base-tip git -c core.quotePath=false diff base HEAD > "$RUNNER_TEMP/diff.patch"
|
|
293
320
|
python3 "$RUNNER_TEMP/pi-action/scripts/post_review.py"
|
|
294
321
|
|
|
295
322
|
- name: Replace a stale verdict when review fails
|
|
@@ -324,6 +351,7 @@ runs:
|
|
|
324
351
|
shell: bash
|
|
325
352
|
env:
|
|
326
353
|
GH_TOKEN: ${{ inputs.github_token }}
|
|
354
|
+
SERVER: ${{ github.server_url }}
|
|
327
355
|
REPO: ${{ github.repository }}
|
|
328
356
|
PR: ${{ github.event.issue.number || github.event.pull_request.number }}
|
|
329
357
|
COMMENT_BODY: ${{ github.event.comment.body }}
|
|
@@ -369,7 +397,8 @@ runs:
|
|
|
369
397
|
echo "go=false" >> "$GITHUB_OUTPUT"
|
|
370
398
|
exit 0
|
|
371
399
|
fi
|
|
372
|
-
|
|
400
|
+
git_basic=$(printf 'x-access-token:%s' "$GH_TOKEN" | base64 | tr -d '\r\n')
|
|
401
|
+
if [ "$cmd" = "fix" ] && ! git -c "http.$SERVER/.extraheader=AUTHORIZATION: basic $git_basic" ls-remote --exit-code "$SERVER/$REPO.git" "refs/heads/$branch" > /dev/null 2>&1; then
|
|
373
402
|
if [ -n "$THREAD" ]; then reply_url="$api/pulls/$PR/comments/$COMMENT_ID/replies"; else reply_url="$api/issues/$PR/comments"; fi
|
|
374
403
|
curl -fsSL -X POST -H "$auth" -H "Content-Type: application/json" \
|
|
375
404
|
"$reply_url" -d "$(jq -n --arg b "$blocked_img"$'\n\n'"Branch \`$branch\` has been deleted on GitHub, so new commits cannot be pushed to this PR yet. Click **Restore branch** on the PR (or push \`$branch\` again), then re-run \`@huggy\`." '{body: $b}')" > /dev/null
|
|
@@ -378,26 +407,35 @@ runs:
|
|
|
378
407
|
fi
|
|
379
408
|
|
|
380
409
|
git init -q .
|
|
381
|
-
git
|
|
410
|
+
git -c "http.$SERVER/.extraheader=AUTHORIZATION: basic $git_basic" \
|
|
411
|
+
fetch -q --no-tags "$SERVER/$REPO.git" \
|
|
382
412
|
"+refs/pull/$PR/head:refs/heads/pr-head" "+refs/heads/$base:refs/heads/base-tip"
|
|
383
413
|
git checkout -q pr-head
|
|
384
414
|
mb=$(git merge-base base-tip pr-head 2>/dev/null || git rev-parse base-tip)
|
|
385
415
|
git branch -f base "$mb"
|
|
386
416
|
|
|
387
|
-
git -c core.quotePath=false diff base HEAD > "$RUNNER_TEMP/diff.patch"
|
|
417
|
+
GIT_ATTR_SOURCE=base-tip git -c core.quotePath=false diff base HEAD > "$RUNNER_TEMP/diff.patch"
|
|
388
418
|
python3 "$RUNNER_TEMP/pi-action/scripts/fetch_pr_context.py" "$RUNNER_TEMP/pr-context.md" "$RUNNER_TEMP/diff.patch"
|
|
389
|
-
python3 "$RUNNER_TEMP/pi-action/scripts/prepare_command.py" build-request "$RUNNER_TEMP/fix-request.md"
|
|
419
|
+
THREAD="${THREAD:-}" python3 "$RUNNER_TEMP/pi-action/scripts/prepare_command.py" build-request "$RUNNER_TEMP/fix-request.md"
|
|
420
|
+
if [ -f "$RUNNER_TEMP/fix-tasks.json" ] && [ "$(jq 'length' "$RUNNER_TEMP/fix-tasks.json" 2>/dev/null || echo 1)" = "0" ]; then
|
|
421
|
+
git config --local --unset-all "http.$SERVER/.extraheader" 2>/dev/null || true
|
|
422
|
+
rm -f .git/FETCH_HEAD
|
|
423
|
+
exit 0
|
|
424
|
+
fi
|
|
390
425
|
if [ "$cmd" = "review" ]; then
|
|
391
426
|
python3 "$RUNNER_TEMP/pi-action/scripts/post_progress.py"
|
|
392
427
|
else
|
|
393
428
|
CMD="$cmd" python3 "$RUNNER_TEMP/pi-action/scripts/post_progress.py" command-start
|
|
394
429
|
fi
|
|
430
|
+
# Scrub any checkout credentials from .git/config and FETCH_HEAD before running Pi
|
|
431
|
+
git config --local --unset-all "http.$SERVER/.extraheader" 2>/dev/null || true
|
|
432
|
+
rm -f .git/FETCH_HEAD
|
|
395
433
|
|
|
396
434
|
# Runs in its own step with neither GH_TOKEN nor PI_API_KEY in env, so
|
|
397
435
|
# dependency lifecycle scripts (`postinstall`) from the PR branch cannot read
|
|
398
436
|
# or exfiltrate any secret.
|
|
399
437
|
- name: Set up project dependencies for fix
|
|
400
|
-
if: steps.prepare.outputs.go == 'true' && steps.prepare.outputs.cmd == 'fix' && inputs.setup_cmd != ''
|
|
438
|
+
if: steps.prepare.outputs.go == 'true' && steps.prepare.outputs.already_handled != 'true' && steps.prepare.outputs.cmd == 'fix' && inputs.setup_cmd != ''
|
|
401
439
|
shell: bash
|
|
402
440
|
env:
|
|
403
441
|
SETUP_CMD: ${{ inputs.setup_cmd }}
|
|
@@ -407,7 +445,7 @@ runs:
|
|
|
407
445
|
|
|
408
446
|
- name: Run Pi (command)
|
|
409
447
|
id: fix
|
|
410
|
-
if: steps.prepare.outputs.go == 'true'
|
|
448
|
+
if: steps.prepare.outputs.go == 'true' && steps.prepare.outputs.already_handled != 'true'
|
|
411
449
|
shell: bash
|
|
412
450
|
env:
|
|
413
451
|
PI_API_KEY: ${{ inputs.api_key }}
|
|
@@ -436,17 +474,17 @@ runs:
|
|
|
436
474
|
# shellcheck disable=SC1091
|
|
437
475
|
source "$RUNNER_TEMP/pi-action/scripts/ensure_tools.sh"
|
|
438
476
|
|
|
439
|
-
if git cat-file -e "base:$RUBRIC_FILE" 2>/dev/null; then
|
|
440
|
-
git show "base:$RUBRIC_FILE" > "$RUNNER_TEMP/rubric.md"
|
|
441
|
-
elif git cat-file -e "base:CLAUDE.md" 2>/dev/null; then
|
|
442
|
-
git show "base:CLAUDE.md" > "$RUNNER_TEMP/rubric.md"
|
|
477
|
+
if git cat-file -e "base-tip:$RUBRIC_FILE" 2>/dev/null; then
|
|
478
|
+
git show "base-tip:$RUBRIC_FILE" > "$RUNNER_TEMP/rubric.md"
|
|
479
|
+
elif git cat-file -e "base-tip:CLAUDE.md" 2>/dev/null; then
|
|
480
|
+
git show "base-tip:CLAUDE.md" > "$RUNNER_TEMP/rubric.md"
|
|
443
481
|
else
|
|
444
482
|
: > "$RUNNER_TEMP/rubric.md"
|
|
445
483
|
fi
|
|
446
484
|
|
|
447
485
|
if [ "$CMD" = "review" ]; then
|
|
448
|
-
if git cat-file -e "base:.github/pi-review-prompt.md" 2>/dev/null; then
|
|
449
|
-
git show "base:.github/pi-review-prompt.md" > "$RUNNER_TEMP/brief-template.md"
|
|
486
|
+
if git cat-file -e "base-tip:.github/pi-review-prompt.md" 2>/dev/null; then
|
|
487
|
+
git show "base-tip:.github/pi-review-prompt.md" > "$RUNNER_TEMP/brief-template.md"
|
|
450
488
|
else
|
|
451
489
|
cp "$RUNNER_TEMP/pi-action/prompts/review.md" "$RUNNER_TEMP/brief-template.md"
|
|
452
490
|
fi
|
|
@@ -459,6 +497,11 @@ runs:
|
|
|
459
497
|
exit 0
|
|
460
498
|
fi
|
|
461
499
|
|
|
500
|
+
if [ "$CMD" = "fix" ]; then
|
|
501
|
+
python3 "$RUNNER_TEMP/pi-action/scripts/run_fix.py" run
|
|
502
|
+
exit 0
|
|
503
|
+
fi
|
|
504
|
+
|
|
462
505
|
if [ -f "$RUNNER_TEMP/fix-request.md" ]; then
|
|
463
506
|
cp "$RUNNER_TEMP/fix-request.md" .pi-fix-request.md
|
|
464
507
|
else
|
|
@@ -533,7 +576,7 @@ runs:
|
|
|
533
576
|
fi
|
|
534
577
|
|
|
535
578
|
- name: Update progress banner to verification test gate
|
|
536
|
-
if: steps.fix.outputs.changed == 'true' && inputs.verify_cmd != ''
|
|
579
|
+
if: steps.fix.outputs.changed == 'true' && inputs.verify_cmd != ''
|
|
537
580
|
shell: bash
|
|
538
581
|
env:
|
|
539
582
|
GH_TOKEN: ${{ inputs.github_token }}
|
|
@@ -546,8 +589,43 @@ runs:
|
|
|
546
589
|
python3 "$RUNNER_TEMP/pi-action/scripts/post_progress.py" command-testing
|
|
547
590
|
|
|
548
591
|
- name: Verify fix
|
|
592
|
+
id: verify1
|
|
549
593
|
if: steps.fix.outputs.changed == 'true' && inputs.verify_cmd != ''
|
|
550
594
|
shell: bash
|
|
595
|
+
env:
|
|
596
|
+
VERIFY_CMD: ${{ inputs.verify_cmd }}
|
|
597
|
+
run: |
|
|
598
|
+
set +e
|
|
599
|
+
eval "$VERIFY_CMD" > >(tee "$RUNNER_TEMP/verify-out.log") 2>&1
|
|
600
|
+
rc=$?
|
|
601
|
+
set -e
|
|
602
|
+
if [ "$rc" -eq 0 ]; then
|
|
603
|
+
echo "ok=true" >> "$GITHUB_OUTPUT"
|
|
604
|
+
else
|
|
605
|
+
echo "ok=false" >> "$GITHUB_OUTPUT"
|
|
606
|
+
fi
|
|
607
|
+
|
|
608
|
+
- name: Repair verification failure (if needed)
|
|
609
|
+
if: steps.fix.outputs.changed == 'true' && inputs.verify_cmd != '' && steps.verify1.outputs.ok == 'false'
|
|
610
|
+
shell: bash
|
|
611
|
+
env:
|
|
612
|
+
PI_API_KEY: ${{ inputs.api_key }}
|
|
613
|
+
PI_API_KEY_ENV: ${{ inputs.api_key_env }}
|
|
614
|
+
PI_GCP_PROJECT: ${{ inputs.gcp_project }}
|
|
615
|
+
PI_GCP_LOCATION: ${{ inputs.gcp_location }}
|
|
616
|
+
PI_GCP_CREDENTIALS_JSON: ${{ inputs.gcp_credentials_json }}
|
|
617
|
+
PI_MODEL: ${{ inputs.model }}
|
|
618
|
+
PI_FALLBACK_MODEL: ${{ inputs.fallback_model }}
|
|
619
|
+
PI_VERSION: ${{ inputs.pi_version }}
|
|
620
|
+
run: |
|
|
621
|
+
set -euo pipefail
|
|
622
|
+
# shellcheck disable=SC1091
|
|
623
|
+
source "$RUNNER_TEMP/pi-action/scripts/ensure_tools.sh"
|
|
624
|
+
python3 "$RUNNER_TEMP/pi-action/scripts/run_fix.py" repair "$RUNNER_TEMP/verify-out.log"
|
|
625
|
+
|
|
626
|
+
- name: Re-verify repaired fix
|
|
627
|
+
if: steps.fix.outputs.changed == 'true' && inputs.verify_cmd != '' && steps.verify1.outputs.ok == 'false'
|
|
628
|
+
shell: bash
|
|
551
629
|
env:
|
|
552
630
|
VERIFY_CMD: ${{ inputs.verify_cmd }}
|
|
553
631
|
run: |
|
|
@@ -555,7 +633,7 @@ runs:
|
|
|
555
633
|
eval "$VERIFY_CMD"
|
|
556
634
|
|
|
557
635
|
- name: Publish command result
|
|
558
|
-
if: success() && steps.prepare.outputs.go == 'true'
|
|
636
|
+
if: success() && steps.prepare.outputs.go == 'true' && steps.prepare.outputs.already_handled != 'true'
|
|
559
637
|
shell: bash
|
|
560
638
|
env:
|
|
561
639
|
GH_TOKEN: ${{ inputs.github_token }}
|
|
@@ -564,16 +642,20 @@ runs:
|
|
|
564
642
|
COMMENT_ID: ${{ github.event.comment.id }}
|
|
565
643
|
THREAD: ${{ github.event_name == 'pull_request_review_comment' && 'yes' || '' }}
|
|
566
644
|
CMD: ${{ steps.prepare.outputs.cmd }}
|
|
645
|
+
FIX_CHANGED: ${{ steps.fix.outputs.changed }}
|
|
567
646
|
PROGRESS_COMMENT_ID: ${{ steps.prepare.outputs.progress_comment_id }}
|
|
568
647
|
PROGRESS_COMMENT_KIND: ${{ steps.prepare.outputs.progress_comment_kind }}
|
|
569
648
|
PI_REVIEW_PROFILE: ${{ inputs.review_profile }}
|
|
570
649
|
GUARDED_PATHS: ${{ inputs.guarded_paths }}
|
|
571
650
|
run: |
|
|
572
651
|
set -euo pipefail
|
|
652
|
+
if [ "$CMD" = "fix" ]; then
|
|
653
|
+
python3 "$RUNNER_TEMP/pi-action/scripts/run_fix.py" publish
|
|
654
|
+
exit 0
|
|
655
|
+
fi
|
|
573
656
|
api="https://api.github.com/repos/$REPO"
|
|
574
657
|
auth="Authorization: Bearer $GH_TOKEN"
|
|
575
658
|
reply=$(cat "$RUNNER_TEMP/reply.md")
|
|
576
|
-
blocked_img='<img src="https://raw.githubusercontent.com/tripplen23/huggy-pr-agent/v1/assets/huggy-blocked.svg" width="160" alt="Huggy stopped on a guarded boundary" />'
|
|
577
659
|
|
|
578
660
|
if [ -n "$THREAD" ]; then
|
|
579
661
|
post="$api/pulls/$PR/comments/$COMMENT_ID/replies"
|
|
@@ -603,7 +685,7 @@ runs:
|
|
|
603
685
|
if [ "$CMD" = "review" ] || [ "$CMD" = "improve" ]; then
|
|
604
686
|
cleanup_progress_comment
|
|
605
687
|
export HEAD_SHA="$(git rev-parse HEAD)"
|
|
606
|
-
git -c core.quotePath=false diff base HEAD > "$RUNNER_TEMP/diff.patch"
|
|
688
|
+
GIT_ATTR_SOURCE=base-tip git -c core.quotePath=false diff base HEAD > "$RUNNER_TEMP/diff.patch"
|
|
607
689
|
python3 "$RUNNER_TEMP/pi-action/scripts/post_review.py"
|
|
608
690
|
exit 0
|
|
609
691
|
fi
|
|
@@ -632,85 +714,8 @@ runs:
|
|
|
632
714
|
exit 0
|
|
633
715
|
fi
|
|
634
716
|
|
|
635
|
-
rm -rf .git/hooks
|
|
636
|
-
git config --local --unset-all core.fsmonitor 2>/dev/null || true
|
|
637
|
-
git config --local --unset-all core.hooksPath 2>/dev/null || true
|
|
638
|
-
|
|
639
|
-
if [ "${{ steps.fix.outputs.changed }}" != "true" ]; then
|
|
640
|
-
answer "$(printf 'No change made.\n\n%s' "$reply")"
|
|
641
|
-
exit 0
|
|
642
|
-
fi
|
|
643
|
-
|
|
644
|
-
read -r branch default < <(curl -fsSL -H "$auth" "$api/pulls/$PR" \
|
|
645
|
-
| jq -r '"\(.head.ref) \(.head.repo.default_branch)"')
|
|
646
|
-
: "${branch:?could not read the PR branch}"
|
|
647
|
-
case "$branch" in
|
|
648
|
-
master|main|HEAD|refs/*|*/master|*/main) branch="" ;;
|
|
649
|
-
esac
|
|
650
|
-
if [ -z "$branch" ] || [ "$branch" = "$default" ]; then
|
|
651
|
-
answer "$(printf '%s\n\nRefusing to push: that is the default branch. Nothing was pushed.' "$blocked_img")"
|
|
652
|
-
exit 1
|
|
653
|
-
fi
|
|
654
|
-
|
|
655
|
-
git add -A
|
|
656
|
-
if [ -n "$GUARDED_PATHS" ]; then
|
|
657
|
-
# shellcheck disable=SC2086
|
|
658
|
-
touched=$(git diff --cached --name-only -- $GUARDED_PATHS)
|
|
659
|
-
if [ -n "$touched" ]; then
|
|
660
|
-
# shellcheck disable=SC2086
|
|
661
|
-
git reset -q -- $GUARDED_PATHS
|
|
662
|
-
answer "$(printf '%s\n\nThat fix wanted to change guarded build, dependency or migration files, which I do not touch (`%s`). Nothing was pushed; do it by hand.' "$blocked_img" "$(printf '%s' "$touched" | tr '\n' ' ')")"
|
|
663
|
-
exit 1
|
|
664
|
-
fi
|
|
665
|
-
fi
|
|
666
|
-
|
|
667
|
-
git -c core.hooksPath=/dev/null -c core.fsmonitor=false \
|
|
668
|
-
-c user.name=Huggy -c user.email=huggy@noreply.github.com \
|
|
669
|
-
commit -q -m "huggy: $(head -n 1 "$RUNNER_TEMP/request.txt" | cut -c1-72)"
|
|
670
|
-
git push -q --no-verify "https://x-access-token:$GH_TOKEN@github.com/$REPO.git" \
|
|
671
|
-
"HEAD:refs/heads/$branch"
|
|
672
|
-
|
|
673
|
-
sha=$(git rev-parse --short HEAD)
|
|
674
|
-
answer "$(printf 'Pushed `%s` to `%s`.\n\n%s' "$sha" "$branch" "$reply")"
|
|
675
|
-
|
|
676
|
-
if [ -n "$THREAD" ]; then
|
|
677
|
-
python3 - <<'PY'
|
|
678
|
-
import json, os, sys, urllib.request
|
|
679
|
-
try:
|
|
680
|
-
owner, name = os.environ["REPO"].split("/", 1)
|
|
681
|
-
pr = int(os.environ["PR"])
|
|
682
|
-
cid = int(os.environ["COMMENT_ID"])
|
|
683
|
-
token = os.environ["GH_TOKEN"]
|
|
684
|
-
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json", "User-Agent": "pi-pr-agent"}
|
|
685
|
-
q = """
|
|
686
|
-
query($owner: String!, $name: String!, $pr: Int!) {
|
|
687
|
-
repository(owner: $owner, name: $name) {
|
|
688
|
-
pullRequest(number: $pr) {
|
|
689
|
-
reviewThreads(last: 100) {
|
|
690
|
-
nodes { id isResolved comments(last: 100) { nodes { databaseId } } }
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
"""
|
|
696
|
-
req = urllib.request.Request("https://api.github.com/graphql", data=json.dumps({"query": q, "variables": {"owner": owner, "name": name, "pr": pr}}).encode("utf-8"), headers=headers, method="POST")
|
|
697
|
-
with urllib.request.urlopen(req, timeout=20) as resp:
|
|
698
|
-
nodes = (((json.loads(resp.read().decode("utf-8")).get("data") or {}).get("repository") or {}).get("pullRequest") or {}).get("reviewThreads", {}).get("nodes") or []
|
|
699
|
-
for t in nodes:
|
|
700
|
-
if not t or t.get("isResolved"):
|
|
701
|
-
continue
|
|
702
|
-
ids = {c.get("databaseId") for c in ((t.get("comments") or {}).get("nodes") or []) if c}
|
|
703
|
-
if cid in ids and t.get("id"):
|
|
704
|
-
m = "mutation($id: ID!) { resolveReviewThread(input: {threadId: $id}) { thread { isResolved } } }"
|
|
705
|
-
urllib.request.urlopen(urllib.request.Request("https://api.github.com/graphql", data=json.dumps({"query": m, "variables": {"id": t["id"]}}).encode("utf-8"), headers=headers, method="POST"), timeout=20).read()
|
|
706
|
-
break
|
|
707
|
-
except Exception as exc:
|
|
708
|
-
sys.stderr.write(f"warning: could not auto-resolve thread for comment {os.environ.get('COMMENT_ID')} ({exc})\n")
|
|
709
|
-
PY
|
|
710
|
-
fi
|
|
711
|
-
|
|
712
717
|
- name: Report when command fails
|
|
713
|
-
if: (failure() || cancelled()) && steps.prepare.outputs.go == 'true'
|
|
718
|
+
if: (failure() || cancelled()) && steps.prepare.outputs.go == 'true' && steps.prepare.outputs.already_handled != 'true'
|
|
714
719
|
shell: bash
|
|
715
720
|
env:
|
|
716
721
|
GH_TOKEN: ${{ inputs.github_token }}
|
|
@@ -724,6 +729,10 @@ runs:
|
|
|
724
729
|
RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
725
730
|
run: |
|
|
726
731
|
set -euo pipefail
|
|
732
|
+
if [ "$CMD" = "fix" ]; then
|
|
733
|
+
python3 "$RUNNER_TEMP/pi-action/scripts/run_fix.py" fail
|
|
734
|
+
exit 0
|
|
735
|
+
fi
|
|
727
736
|
api="https://api.github.com/repos/$REPO"
|
|
728
737
|
auth="Authorization: Bearer $GH_TOKEN"
|
|
729
738
|
if [ "$CMD" = "review" ]; then
|