-
Notifications
You must be signed in to change notification settings - Fork 4
Taylor/nathan command #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Telucero
wants to merge
4
commits into
main
Choose a base branch
from
taylor/nathan-command
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- | ||
| name: nathan | ||
| description: Triggers the Nathan AI review workflow by posting "+Nathan" on the open GitHub PR for the current branch. Works for both direct contributors and fork contributors. Requires an open PR on the current branch and the GitHub CLI (gh) to be authenticated with write access or higher on the upstream repository. | ||
| chain-role: isolated | ||
| invocation: user | ||
| allowed-tools: Bash(git branch:*) Bash(gh repo view:*) Bash(gh api:*) Bash(gh pr list:*) Bash(gh pr comment:*) | ||
| --- | ||
|
|
||
| # Nathan | ||
|
|
||
| Trigger the Nathan AI review by posting `+Nathan` on the open GitHub PR for the current branch. Works transparently whether you are working on the main repo or a fork. | ||
|
|
||
| ## Instructions | ||
|
|
||
| ### Step 1: Resolve current branch | ||
| Run `git branch --show-current`. | ||
|
|
||
| If output is empty (detached HEAD), stop: "Cannot determine the current branch — the repository is in detached HEAD state. Check out a branch first." | ||
|
|
||
| ### Step 2: Detect fork and resolve target repo | ||
| Run: | ||
| ``` | ||
| gh repo view --json isFork,parent | ||
| ``` | ||
|
|
||
| - If `isFork` is `false`: the target repo is the current repo. Use `<branch-name>` as the head filter. | ||
| - If `isFork` is `true`: the target repo is `parent.nameWithOwner` (the upstream). Get the authenticated user's login to build the head filter: | ||
| ``` | ||
| gh api user --jq '.login' | ||
| ``` | ||
| Use `<login>:<branch-name>` as the head filter and `<parent.nameWithOwner>` as the repo. | ||
|
|
||
| ### Step 3: Find open PR | ||
|
|
||
| **Not a fork:** | ||
| ``` | ||
| gh pr list --head "<branch-name>" --state open --json number,title,url --limit 1 | ||
| ``` | ||
|
|
||
| **Fork:** | ||
| ``` | ||
| gh pr list --repo "<upstream-repo>" --head "<login>:<branch-name>" --state open --json number,title,url --limit 1 | ||
| ``` | ||
|
|
||
| - If result is `[]`, stop: "No open PR found for branch '<branch-name>'. Please open a PR on GitHub before triggering a review." | ||
| - If command fails, report the error and stop. | ||
|
|
||
| Parse `number`, `title`, and `url` from the result. | ||
|
|
||
| ### Step 4: Post +Nathan comment | ||
| Use the PR URL so the comment always targets the correct repo regardless of fork status: | ||
| ```bash | ||
| gh pr comment "<url>" --body '+Nathan' | ||
| ``` | ||
|
|
||
| ### Step 5: Confirm | ||
| ``` | ||
| ✅ Nathan review triggered on PR #<number> (<title>) | ||
| <url> | ||
| The Nathan Gate workflow will begin shortly. | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Direct contributor (not a fork) | ||
| User says: `/Nathan` | ||
| Actions: | ||
| 1. Gets branch → `feature/add-docs` | ||
| 2. Repo is not a fork | ||
| 3. Finds open PR → #23 "Add documentation" | ||
| 4. Posts `+Nathan` | ||
| Result: "✅ Nathan review triggered on PR #23 (Add documentation)\nhttps://github.com/..." | ||
|
|
||
| ### Example 2: Fork contributor | ||
| User says: `/Nathan` | ||
| Actions: | ||
| 1. Gets branch → `fix/typo` | ||
| 2. Repo is a fork of `upstream-org/repo`; user login is `contributor` | ||
| 3. Searches upstream for PR with head `contributor:fix/typo` → #47 "Fix typo in README" | ||
| 4. Posts `+Nathan` using the PR URL | ||
| Result: "✅ Nathan review triggered on PR #47 (Fix typo in README)\nhttps://github.com/upstream-org/repo/pull/47" | ||
|
|
||
| ### Example 3: No open PR (edge case) | ||
| User says: `/Nathan` | ||
| Actions: | ||
| 1. Gets branch → `old-branch` | ||
| 2. No open PR found | ||
| Result: "No open PR found for branch 'old-branch'. Please open a PR on GitHub before triggering a review." | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Error: `gh: command not found` | ||
| Cause: GitHub CLI not installed or not in PATH. | ||
| Solution: Install from https://cli.github.com and run `gh auth login`. | ||
|
|
||
| ### Error: HTTP 401 / auth failure | ||
| Cause: GitHub CLI is not authenticated. | ||
| Solution: Run `gh auth login` and follow the prompts. | ||
|
|
||
| ### Error: No open PR found | ||
| Cause: PR does not exist for this branch, or is closed/merged. | ||
| Solution: Open a PR on GitHub first, or switch to a branch with an active PR. | ||
|
|
||
| ### Error: Nathan review does not start | ||
| Cause: Your account does not have write access or higher on the upstream repository. | ||
| Solution: Verify your permissions — the Nathan Gate workflow requires at least write access to dispatch. | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.