Repository navigation
feat(pi): add the gh_pr_status tool — GitHub PR + charly/pr-validator status checking - #31
Conversation
… status checking The org-wide charly/pr-validator validates every PR on GitHub Actions, but its verdicts land on GitHub with NO path into a pi session — an agent that opens or fixes PRs cannot know whether its PR passed without manually polling gh. This added a pi extension tool (gh_pr_status) that: - check: one-shot status of a PR — state, head SHA, mergeable state, the latest pr-validator run ON THE CURRENT HEAD (not a stale one), its conclusion, the failing step (Gate (BLOCK) vs wait-for-ci), and the latest PASS/BLOCK verdict comment. - watch: polls until the validator concludes on the current head (or the PR merges/closes, or a timeout) and returns the full matrix — the real 'wake me with the result' primitive when run in a background subagent. The tool distinguishes a pr-validator BLOCK (Gate step failed) from a CI-wait timeout (wait-for-ci failed) from a gofmt failure, because each demands a different agent response. Wraps gh read-only.
Review — BLOCKHead SHA: Change class: feature (pi agent tooling) — new Security screen: PASS — the tool wraps Blocks
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
…does not exist The extension used Type.StringEnum (typebox), which is not a function in the typebox version pi bundles. pi's own example extensions use StringEnum from @earendil-works/pi-ai; this matches the canonical pattern.
Review — BLOCKHead SHA: Change class: feature (pi agent tooling) — new Security screen: PASS — the tool wraps Blocks
The two findings from the prior review were re-derived against the CURRENT body/diff and both still hold (the Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
Review — BLOCKHead SHA: Change class: feature (pi agent tooling) — new Security screen: PASS — the tool wraps Blocks
Notes (non-blocking, tool-limited)
Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
…e) — not an absolute machine path
Review — BLOCKHead SHA: Change class: feature (pi agent tooling) — new Security screen: PASS — the tool wraps Blocks
Resolved (prior findings re-derived against current state)
Placement: CORRECT — the tool lives in Verdict: BLOCK ollama/deepseek-v4-flash — pi-review-action. |
1. latestVerdict used 'gh api --jq .[].body' which emits raw unquoted
markdown — not valid JSON — so JSON.parse always threw and the verdict
was permanently 'unknown'. Now fetches the JSON array and scans bodies
in JS.
2. getPR requested the 'mergeableState' field, which the installed gh CLI
rejects ('Unknown JSON field'). Now uses 'mergeStateStatus'.
Both verified live via a fresh 'pi --print' session calling the tool.
Review — PASSHead SHA: Security screen: PASS — the tool wraps Checklist: All applicable rules PASS or NA. Prior findings re-derived against the CURRENT diff/body — all resolved:
Placement: CORRECT — the tool lives in Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
Review — PASSHead SHA: Security screen: PASS — the tool wraps Checklist: All applicable rules PASS or NA. Prior findings re-derived against the CURRENT diff/body — all resolved:
Placement: CORRECT — the tool lives in Verdict: PASS ollama/deepseek-v4-flash — pi-review-action. |
…status checking (#74) Recovered from git history: ab2448f (#31) added .pi/extensions/github-pr-status.ts (gh_pr_status check/watch — GitHub PR + org-wide charly/pr-validator status), c291b96 (#61) accidentally slim-deleted it together with the APPEND_SYSTEM.md instruction to use it. Restoring verbatim, re-registering the extension in settings.json, and re-adding the system-prompt instruction: check EVERY PR with gh_pr_status after opening/fixing; watch in a background subagent while waiting.
Summary
Adds a project pi extension tool
gh_pr_statusto the umbrella's.pi/config, closing the gap where the org-widecharly/pr-validatorverdicts land on GitHub Actions with no path into a pi session.The tool (
.pi/extensions/github-pr-status.ts, registered in.pi/settings.json):charly/pr-validatorrun ON THE CURRENT HEAD (not a stale one), its conclusion, the failing step (Gate (BLOCK)vswait-for-civs gofmt), and the latest PASS/BLOCK verdict comment.It distinguishes a pr-validator BLOCK from a CI-wait timeout from a gofmt failure, because each demands a different agent response. It wraps
ghread-only only.How tested
The exact gh command sequences the tool runs were exercised live against opencharly/charly#414:
The settings.json parses;
scripts/check-harness-parity.shpasses (the.piconfig is NOT in the parity SHARED list, so this does not affect the mechanical harness twins).Tool execution evidence — live pi-session runs (real output)
Ran the tool in a fresh pi session (which loads the project config, extensions included) after fixing two bugs the live testing caught:
Both calls succeeded; the tool returned state, head, mergeable, verdict, and the validator run conclusion.
Two bugs the live testing caught and fixed
latestVerdictusedgh api --jq ".[].body", which emits raw unquoted markdown — not valid JSON — soJSON.parsealways threw and the verdict was permanentlyunknown. Fixed to fetch the JSON array and scan bodies in JS.getPRrequested themergeableStatefield, which gh rejects ("Unknown JSON field"); the valid field ismergeStateStatus. Fixed.Both fixes are in the pushed extension; the fresh-session run above exercises the corrected code paths.
Rulebook compliance
.pi/settings.jsonis not in the parity SHARED list; the parity check passesChange classification
Assisted-by: pi openrouter/deepseek/deepseek-v4-flash-0731 (analysed on a live system)