Skip to content

chore: strip deployment-specific refs from pr-review plugin#3

Closed
m0nk111 wants to merge 1 commit into
mainfrom
chore/strip-cryptotrader-refs
Closed

chore: strip deployment-specific refs from pr-review plugin#3
m0nk111 wants to merge 1 commit into
mainfrom
chore/strip-cryptotrader-refs

Conversation

@m0nk111

@m0nk111 m0nk111 commented Jun 17, 2026

Copy link
Copy Markdown
Owner

What

Strip all deployment-specific references from the pr-review plugin so that m0nk111/extensions can serve as a generic extensions registry without leaking a single test deployment's identity into prompts and logs.

What changed since the previous version of this PR

The previous commit on this branch (b5496a8) introduced two new environment variables — PR_REVIEW_TARGET_REPO and PR_REVIEW_BOT_LOGIN — that turned out to be unnecessary:

  • PR_REVIEW_TARGET_REPO duplicates a value that the /pr-reviewer:setup skill already substitutes into REPO at build time. The tarball is intentionally deployment-specific: the setup skill's Step 6 ("Apply exactly five constant substitutions near the top of the file") rewrites the REPO line to the operator's chosen owner/repo before packaging and uploading the tarball. So REPO is back to being a hardcoded string at the top of v2.7/main.py and v2.8/main.py, with a comment explaining that the setup skill rewrites this line.
  • PR_REVIEW_BOT_LOGIN duplicates information that is already available from GITHUB_PERSONAL_ACCESS_TOKEN (the same token that posts the review). The dedup guard now resolves the bot user at runtime via a cached GET /user call (see _get_bot_login). That works for both GITHUB_TOKEN and GITHUB_PERSONAL_ACCESS_TOKEN, with no extra config.

The README env-vars section that I added in the previous commit is gone for the same reason.

What changed in the previous version of this PR (and is still in this one)

  • skills/github-pr-review/SKILL.md: drop the reference URL to m0nklabs/cryptotrader/pull/379 and the "Worked example (matches the format on PR #379)" header.
  • skills/index.js: regenerated from the fixed SKILL.md via node scripts/build-skills-catalog.mjs.
  • plugins/pr-review/agent-canvas-automation/README.md: drop the hardcoded deployment name from the intro.
  • plugins/pr-review/agent-canvas-automation/v2/README.md: drop the 7 direct m0nklabs/cryptotrader URLs from the demo table, the hardcoded automation ID in the deploy steps, and the m0nk111-post reference in the MCP-detection row.
  • plugins/pr-review/agent-canvas-automation/v2.7/main.py and v2.8/main.py: replace all hardcoded "m0nk111-post" literals with a call to the new _get_bot_login(github_token) helper. REPO is hardcoded back to the deployment default with a comment explaining the /pr-reviewer:setup substitution contract.

Behavioural impact

No new env vars. The duplicate-review guard now makes one GET /user request on first call (cached thereafter for the rest of the cron tick), so each review cycle is one extra GitHub API call. That's within the 5000/hr PAT budget.

Verification

  • python3 -c "import ast; ast.parse(open('.../v2.7/main.py').read())" -> OK
  • python3 -c "import ast; ast.parse(open('.../v2.8/main.py').read())" -> OK
  • grep -rnE "m0nklabs|cryptotrader|pull/379|PR 379|PR #379|m0nk111-post" on the whole repo -> only the two intentional REPO = "m0nklabs/cryptotrader" lines in v2.7/v2.8 main.py
  • node scripts/build-skills-catalog.mjs regenerated skills/index.js cleanly

Out of scope (separate PRs)

  • The v2.8 JSON control-character parser bug (newline-in-string breaks brace counter) -> will be addressed in a v2.9/main.py PR after this lands.

This commit supersedes the previous commit on this branch (b5496a8).
The previous one introduced two new environment variables
(PR_REVIEW_TARGET_REPO, PR_REVIEW_BOT_LOGIN) that were both unnecessary:

- PR_REVIEW_TARGET_REPO duplicates a value that the /pr-reviewer:setup
  skill's Step 6 already substitutes into REPO at build time. The
  tarball is intentionally deployment-specific; baking REPO in is by
  design. So REPO is back to being a hardcoded string at the top of
  v2.7/main.py and v2.8/main.py, with a comment explaining that the
  setup skill rewrites this line before packaging.

- PR_REVIEW_BOT_LOGIN duplicates information that is already available
  from GITHUB_PERSONAL_ACCESS_TOKEN (the same token that posts the
  review). The dedup guard now resolves the bot user at runtime via a
  cached GET /user call (see _get_bot_login). That works for both
  GITHUB_TOKEN and GITHUB_PERSONAL_ACCESS_TOKEN, with no extra config.

Other than that the commit covers the same ground as b5496a8:

- skills/github-pr-review/SKILL.md: drop the reference URL to
  m0nklabs/cryptotrader/pull/379 and the 'Worked example (matches the
  format on PR #379)' header.
- skills/index.js: regenerated from the fixed SKILL.md.
- plugins/pr-review/agent-canvas-automation/README.md: drop the
  deployment name from the intro.
- plugins/pr-review/agent-canvas-automation/v2/README.md: drop the 7
  direct cryptotrader URLs from the demo table, the hardcoded automation
  ID in the deploy steps, and the m0nk111-post ref in the
  MCP-detection row.

Co-authored-by: openhands <openhands@all-hands.dev>
@m0nk111-post m0nk111-post force-pushed the chore/strip-cryptotrader-refs branch from b5496a8 to fdb735a Compare June 17, 2026 13:48
@m0nk111-post m0nk111-post deleted the chore/strip-cryptotrader-refs branch June 17, 2026 14:02
m0nk111-post pushed a commit that referenced this pull request Jun 17, 2026
…te guard + deployment-neutral config

Consolidates the work that was previously proposed as PRs #1, #2 and #3
into a single reviewable change.

## What this does

1. Steers the github-pr-review skill and the agent prompt at the GitHub
   Pull Request Reviews API (POST /repos/{owner}/{repo}/pulls/{n}/reviews
   with a comments[] array) instead of the issue-comments API. Inline
   threads, suggestion blocks, and one-click-apply now actually work.

2. Adds the agent-canvas-automation cron runner that watches one repo
   for a trigger label, forks a fresh OpenHands conversation per
   (PR, label_event_id), waits for the conversation to finish, parses
   a ###REVIEW_JSON### contract out of the final response, and posts
   the result as a single Pull Request Review. v2.7 and v2.8 are
   shipped together; the difference between them is the duplicate-review
   guard (see below).

3. Makes the duplicate-review guard robust: before posting a parsed
   payload, the script queries GitHub for an existing review by the
   bot user at the same commit_id. If one is found, the script closes
   the state without re-posting — that fixes the race where the agent
   posts via the GitHub MCP and the script also posts from the parsed
   JSON, producing two reviews with identical content.

4. Removes every hardcoded reference to the original test deployment
   from this repo. The cron runner is generic now: REPO is an empty
   string with a TODO pointing at /pr-reviewer:setup, the bot-user
   check is resolved at runtime via GET /user with the same token that
   posts the review, and the SKILL.md / README references are
   deployment-neutral.

## Files

M  plugins/pr-review/scripts/prompt.py
M  skills/github-pr-review/SKILL.md
M  skills/index.js
A  plugins/pr-review/agent-canvas-automation/README.md
A  plugins/pr-review/agent-canvas-automation/v2/README.md
A  plugins/pr-review/agent-canvas-automation/v2.7/main.py
A  plugins/pr-review/agent-canvas-automation/v2.8/main.py

## Behavioural impact

- New env vars: none.
- One extra GET /user per cron tick (cached thereafter). That's well
  within the 5000/hr PAT budget.
- Until REPO is filled in by /pr-reviewer:setup, _verify_token_and_repo
  will fail with a 404 against an empty path — fail-fast by design.

## Verification

- python3 -c 'import ast; ast.parse(...)' on v2.7 + v2.8 main.py -> OK
- grep -rnE 'm0nklabs|cryptotrader|m0nk111-post|pull/379|PR 379|PR #379'
  on the whole tree -> zero hits (the previous test-deployment literal
  that used to live in REPO = ... is gone; REPO is now empty).
- node scripts/build-skills-catalog.mjs regenerated skills/index.js
  cleanly.

Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants