-
Notifications
You must be signed in to change notification settings - Fork 13k
feat(skills): improve async-pr-review workflow and logging #21790
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
Merged
+499
−0
Merged
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
902311f
feat(skills): add async-pr-review skill
mattKorwel c1b640a
refactor(skills): optimize async-pr-review for agentic workflow
mattKorwel c3272a5
refactor(skills): dynamic paths and worktree scoping for async-pr-review
mattKorwel a49a502
feat(skills): improve async-pr-review workflow and logging
mattKorwel 4fbf969
Merge remote-tracking branch 'origin/main' into feat/update-async-pr-…
mattKorwel dcb7dd7
feat(skills): add macOS notifications to async-pr-review
mattKorwel 3f7523b
Merge branch 'main' into feat/update-async-pr-review
mattKorwel ee5d325
feat(skills): improve async-pr-review test running and diff analysis
mattKorwel ccf29e5
fix(skills): remove full test suite fallback in async review
mattKorwel 9f46923
fix(skills): handle pending CI checks in async pr review test step
mattKorwel fb0a1e1
Update .gemini/skills/async-pr-review/SKILL.md
mattKorwel 0c8b8bd
feat(skills): migrate async-pr-review to use policy.toml
mattKorwel 739de66
fix(skills): secure and complete async-pr-review policy.toml
mattKorwel 6e79770
fix(skills): restrict gh pr commands to read-only in policy.toml
mattKorwel 0052657
feat(skills): enrich async-pr-review policy with core unix and read-o…
mattKorwel 078ad35
Merge branch 'main' into feat/update-async-pr-review
mattKorwel 17f3266
Apply suggestion from @mattKorwel
mattKorwel 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
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,45 @@ | ||
| --- | ||
| name: async-pr-review | ||
| description: Trigger this skill when the user wants to start an asynchronous PR review, run background checks on a PR, or check the status of a previously started async PR review. | ||
| --- | ||
|
|
||
| # Async PR Review | ||
|
|
||
| This skill provides a set of tools to asynchronously review a Pull Request. It will create a background job to run the project's preflight checks, execute Gemini-powered test plans, and perform a comprehensive code review using custom prompts. | ||
|
|
||
| This skill is designed to showcase an advanced "Agentic Asynchronous Pattern": | ||
| 1. **Native Background Shells vs Headless Inference**: While Gemini CLI can natively spawn and detach background shell commands (using the `run_shell_command` tool with `is_background: true`), a standard bash background job cannot perform LLM inference. To conduct AI-driven code reviews and test generation in the background, the shell script *must* invoke the `gemini` executable headlessly using `-p`. This offloads the AI tasks to independent worker agents. | ||
| 2. **Dynamic Git Scoping**: The review scripts avoid hardcoded paths. They use `git rev-parse --show-toplevel` to automatically resolve the root of the user's current project. | ||
| 3. **Ephemeral Worktrees**: Instead of checking out branches in the user's main workspace, the skill provisions temporary git worktrees in `.gemini/tmp/async-reviews/pr-<number>`. This prevents git lock conflicts and namespace pollution. | ||
| 4. **Agentic Evaluation (`check-async-review.sh`)**: The check script outputs clean JSON/text statuses for the main agent to parse. The interactive agent itself synthesizes the final assessment dynamically from the generated log files. | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. **Determine Action**: Establish whether the user wants to start a new async review or check the status of an existing one. | ||
| * If the user says "start an async review for PR #123" or similar, proceed to **Start Review**. | ||
| * If the user says "check the status of my async review for PR #123" or similar, proceed to **Check Status**. | ||
|
|
||
| ### Start Review | ||
|
|
||
| If the user wants to start a new async PR review: | ||
|
|
||
| 1. Ask the user for the PR number if they haven't provided it. | ||
| 2. Execute the `async-review.sh` script, passing the PR number as the first argument. Be sure to run it with the `is_background` flag set to true to ensure it immediately detaches. | ||
| ```bash | ||
| .gemini/skills/async-pr-review/scripts/async-review.sh <PR_NUMBER> | ||
| ``` | ||
| 3. Inform the user that the tasks have started successfully and they can check the status later. | ||
|
|
||
| ### Check Status | ||
|
|
||
| If the user wants to check the status or view the final assessment of a previously started async review: | ||
|
|
||
| 1. Ask the user for the PR number if they haven't provided it. | ||
| 2. Execute the `check-async-review.sh` script, passing the PR number as the first argument: | ||
| ```bash | ||
| .gemini/skills/async-pr-review/scripts/check-async-review.sh <PR_NUMBER> | ||
| ``` | ||
| 3. **Evaluate Output**: Read the output from the script. | ||
| * If the output contains `STATUS: IN_PROGRESS`, tell the user which tasks are still running. | ||
| * If the output contains `STATUS: COMPLETE`, use your file reading tools (`read_file`) to retrieve the contents of `final-assessment.md`, `review.md`, `pr-diff.diff`, `npm-test.log`, and `test-execution.log` files from the `LOG_DIR` specified in the output. | ||
| * **Final Assessment**: Read those files, synthesize their results, and give the user a concise recommendation on whether the PR builds successfully, passes tests, and if you recommend they approve it based on the review. | ||
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,150 @@ | ||
| # --- CORE TOOLS --- | ||
| [[rule]] | ||
| toolName = "read_file" | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| [[rule]] | ||
| toolName = "write_file" | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| [[rule]] | ||
| toolName = "grep_search" | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| [[rule]] | ||
| toolName = "glob" | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| [[rule]] | ||
| toolName = "list_directory" | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| [[rule]] | ||
| toolName = "codebase_investigator" | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| # --- SHELL COMMANDS --- | ||
|
|
||
| # Git (Safe/Read-only) | ||
| [[rule]] | ||
| toolName = "run_shell_command" | ||
| commandPrefix = [ | ||
| "git blame", | ||
| "git show", | ||
| "git grep", | ||
| "git show-ref", | ||
| "git ls-tree", | ||
| "git ls-remote", | ||
| "git reflog", | ||
| "git remote -v", | ||
| "git diff", | ||
| "git rev-list", | ||
| "git rev-parse", | ||
| "git merge-base", | ||
| "git cherry", | ||
| "git fetch", | ||
| "git status", | ||
| "git st", | ||
| "git branch", | ||
| "git br", | ||
| "git log", | ||
| "git --version" | ||
| ] | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| # GitHub CLI (Read-only) | ||
| [[rule]] | ||
| toolName = "run_shell_command" | ||
| commandPrefix = [ | ||
| "gh workflow list", | ||
| "gh auth status", | ||
| "gh checkout view", | ||
| "gh run view", | ||
| "gh run job view", | ||
| "gh run list", | ||
| "gh run --help", | ||
| "gh issue view", | ||
| "gh issue list", | ||
| "gh label list", | ||
| "gh pr diff", | ||
| "gh pr check", | ||
| "gh pr checks", | ||
| "gh pr view", | ||
| "gh pr list", | ||
| "gh pr status", | ||
| "gh repo view", | ||
| "gh job view", | ||
| "gh api", | ||
| "gh log" | ||
| ] | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| # Node.js/NPM (Generic Tests, Checks, and Build) | ||
| [[rule]] | ||
| toolName = "run_shell_command" | ||
| commandPrefix = [ | ||
| "npm run start", | ||
| "npm install", | ||
| "npm run", | ||
| "npm test", | ||
| "npm ci", | ||
| "npm list", | ||
| "npm --version", | ||
| "node", | ||
mattKorwel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "npx" | ||
mattKorwel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ] | ||
| decision = "allow" | ||
| priority = 100 | ||
|
|
||
| # Core Utilities (Safe) | ||
| [[rule]] | ||
| toolName = "run_shell_command" | ||
| commandPrefix = [ | ||
| "sleep", | ||
| "env", | ||
| "break", | ||
| "xargs", | ||
| "base64", | ||
| "uniq", | ||
| "sort", | ||
| "echo", | ||
| "which", | ||
| "ls", | ||
| "find", | ||
| "tail", | ||
| "head", | ||
| "cat", | ||
| "cd", | ||
| "grep", | ||
| "ps", | ||
| "pwd", | ||
| "wc", | ||
| "file", | ||
| "stat", | ||
| "diff", | ||
| "lsof", | ||
| "date", | ||
| "whoami", | ||
| "uname", | ||
| "du", | ||
| "cut", | ||
| "true", | ||
| "false", | ||
| "readlink", | ||
| "awk", | ||
| "jq", | ||
| "rg", | ||
| "less", | ||
| "more", | ||
| "tree" | ||
| ] | ||
| decision = "allow" | ||
| priority = 100 | ||
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.