Repository navigation
Conversation
Detect a checkout only when origin matches the target repository, and otherwise reach the pull request through gh -R and the GitHub API: the diff from gh pr diff, and each changed file by blob sha from the paginated pull request files endpoint. Align the README requirements and add an end-to-end eval for the no-clone path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T58NPz2J74Vkr1ABminq2L
81b8aa3 to
a979890
Compare
The eval harness isolates the environment, so the fixture cannot reach an authenticated gh and the case cannot pass. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T58NPz2J74Vkr1ABminq2L
|
Hey @andyhorn. Thank you for raising the PR. I will review and get back to you. |
malav2110
left a comment
There was a problem hiding this comment.
Thanks, @andyhorn. The no-clone steps work. I ran steps 3 to 5 from outside a checkout against two PRs here, and every stored file matched the head commit.
One blocking issue: the new step 2 text tells the clone path to read the working tree. The working tree only holds the PR's code if the PR is checked out. The rest are non-blocking.
GitHub Enterprise URLs also lose their host on the no-clone path. I'll open a follow-up issue for that rather than add it to this PR.
Once this lands, I'd like to move step 1's commands into a tested Node script, the way #29 did for the validator. The shell fixes below still matter, because this version ships until then.
|
Hey @andyhorn, are you still up for the working-tree fix in step 2? It's the only blocking one. If it's easier, I can push it and the shell fixes to your branch and merge, and take the rest in a follow-up. Which would you prefer? |
My apologies, I'll get to it ASAP! |
Read changed files with `git show <ref>:<path>` on the clone path, since the fetch never checks the PR out. Name the no-clone file location in step 7, list the tree with `?recursive=1`, and report failed blob fetches instead of storing GitHub's error JSON. Move the clone overview to the top of step 1 and the no-clone path to its end, fix the `in_repo` detection block, add `commits` to the metadata fetch, and say the `git` requirement has an exception. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137fL7B1JC5DHsTNFBAkNv7
|
Thanks for waiting, @malav2110. I'll push the fixes to this branch myself, so there's no need for you to push them. They are in ffb7ba0. The blocking one is done: the clone path now reads each changed file with |
malav2110
left a comment
There was a problem hiding this comment.
Thanks for working through these, @andyhorn. The blocking issue is fixed: the overview and step 2 now read each file with git show <ref>:<path>. The other threads are addressed too.
I re-ran the new file loop against a PR that bumps a submodule. Under bash and zsh it printed FAILED: lib/chibios and stored nothing for that path, so the failure branch works on a real 404.
I left a few non-blocking comments below. The nits are one-click. Once you've had a look at these, I'll merge.
| removes the file and prints `FAILED: <path>` rather than leaving that JSON | ||
| stored as the file. A submodule bump always fails here: the files endpoint | ||
| lists the submodule path with a commit sha, and the blob fetch for it returns | ||
| 404. For a `FAILED` path, rely on the diff, which already shows the pointer |
There was a problem hiding this comment.
nitpick (non-blocking): "For a FAILED path" reads as covering every failed fetch, but line 449 says to report any other one. Naming the submodule case makes the two lines agree.
| 404. For a `FAILED` path, rely on the diff, which already shows the pointer | |
| 404. For a submodule path, rely on the diff, which already shows the pointer |
| #### Local clone vs. no clone | ||
|
|
There was a problem hiding this comment.
nitpick (non-blocking): With the overview now opening step 1, this heading covers the clone path too, down to line 385. The clone path has no heading of its own. Dropping this one makes the overview the opening text of step 1, as line 204 already describes.
| #### Local clone vs. no clone |
| With no clone there is no local ref to re-read. The sub-agent works from its own | ||
| prompt, so put this in it: read a changed file from `<work>/files/<path>`, and | ||
| fetch any other file as step 1's no-clone path describes. |
There was a problem hiding this comment.
suggestion (non-blocking): Step 2's sub-agents need this paragraph too. Line 510 tells the agent to hand broad reads to sub-agents. With no clone, those sub-agents have no local files to read, just like step 7's. Moving this paragraph up to that one in step 2, and pointing step 7 back to it, covers both steps.
The same paragraph could also name the clone path's read: git show <ref>:<path>. A sub-agent told only "at the target ref" can still read the working tree, which line 472 now warns about.
Summary
Adds a no-clone path so the skill can explain a pull request from outside a git checkout, using only
gh.Problem
Step 1 assumed a local clone. Outside one,
gh pr view <n>fails, the suggested--jsonfields leave out the head commit SHA, and the fetch block runsgit fetch origin.Solution
When
in_repois false and the target is a pull request:in_repois true only whenoriginmatches theowner/repoparsed from the target, so a checkout of a different repository takes the no-clone path.gh pr view -R owner/reposupplies the metadata andgh pr diff -R owner/repothe diff.pulls/<n>/filesendpoint, which skips deleted files and avoids the 100-file cap ofgh pr view --json files. Each is fetched by blob sha with the raw media type, so no path needs URL-encoding and the Contents API's 1 MB limit does not apply.headRefOidanchors everyfile:linereference and link.Changes
skills/explain-diff-html/SKILL.md: "Local clone vs. no clone" section, the no-clone subsection, origin-matching detection, and thegit/ghrows of the requirements table.README.md: the same requirements rows.The branch is rebased onto current
main.Testing
Run on this branch after the rebase:
npm ci,npm run build(leaves the working tree clean),npm run check,npm test(66 tests) and.github/scripts/validate-samples.sh(9 sample pages) all pass. This change does not touch the validator.gh pr diffandgh pr view, run from outside a checkout against cli/cli PR 9000, stored every changed file.originparsing, checked against SSH, HTTPS andssh://remote forms, yields the same lowercaseowner/repo.Not run:
validate-output.json the resulting page. An eval for this path is not included: the eval harness isolates the environment, so a case that needs an authenticatedghcannot pass.Fixes #38