Skip to content

feat: support pull requests without a local clone - #42

Open
andyhorn wants to merge 3 commits into
malav2110:mainfrom
andyhorn:feature/no-clone-pr-support
Open

andyhorn wants to merge 3 commits into
malav2110:mainfrom
andyhorn:feature/no-clone-pr-support

Conversation

@andyhorn

@andyhorn andyhorn commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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 --json fields leave out the head commit SHA, and the fetch block runs git fetch origin.

Solution

When in_repo is false and the target is a pull request:

  • in_repo is true only when origin matches the owner/repo parsed from the target, so a checkout of a different repository takes the no-clone path.
  • gh pr view -R owner/repo supplies the metadata and gh pr diff -R owner/repo the diff.
  • Changed files come from the paginated pulls/<n>/files endpoint, which skips deleted files and avoids the 100-file cap of gh 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.
  • headRefOid anchors every file:line reference and link.
  • Branch, range and commit targets outside a checkout stop and ask the user to run from a checkout.

Changes

  • skills/explain-diff-html/SKILL.md: "Local clone vs. no clone" section, the no-clone subsection, origin-matching detection, and the git/gh rows 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.
  • The file-list and blob-fetch loop, gh pr diff and gh pr view, run from outside a checkout against cli/cli PR 9000, stored every changed file.
  • The origin parsing, checked against SSH, HTTPS and ssh:// remote forms, yields the same lowercase owner/repo.

Not run:

  • A full skill run on a real pull request from outside a checkout, and validate-output.js on the resulting page. An eval for this path is not included: the eval harness isolates the environment, so a case that needs an authenticated gh cannot pass.

Fixes #38

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
@andyhorn
andyhorn force-pushed the feature/no-clone-pr-support branch from 81b8aa3 to a979890 Compare November 3, 2026 15:31
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
@malav2110

Copy link
Copy Markdown
Owner

Hey @andyhorn. Thank you for raising the PR. I will review and get back to you.

@malav2110 malav2110 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread skills/explain-diff-html/SKILL.md Resolved
Comment thread skills/explain-diff-html/SKILL.md Resolved
Comment thread skills/explain-diff-html/SKILL.md Resolved
Comment thread skills/explain-diff-html/SKILL.md Resolved
Comment thread skills/explain-diff-html/SKILL.md Resolved
Comment thread skills/explain-diff-html/SKILL.md Resolved
Comment thread skills/explain-diff-html/SKILL.md Resolved
@malav2110

Copy link
Copy Markdown
Owner

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?

@andyhorn

Copy link
Copy Markdown
Contributor Author

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
@andyhorn

Copy link
Copy Markdown
Contributor Author

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 git show <ref>:<path>, at lines 121 and 459, and line 365 drops "instead of the working tree". I also took the non-blocking items, with a reply on each comment.

@malav2110 malav2110 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Comment on lines +162 to +163
#### Local clone vs. no clone

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
#### Local clone vs. no clone

Comment on lines +750 to +752
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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
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.

Step 1 has no path for a pull request without a local clone

2 participants