-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: isolate PR review agent profiles #226
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
Merged
Changes from all commits
Commits
Show all changes
3 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
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
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
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
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
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
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,74 @@ | ||
| #!/usr/bin/env bash | ||
| # Codex PR-review profile, sourced by scripts/pr-review.sh. | ||
| # Keep provider and workspace ownership explicit: Codex uses a pre-provisioned | ||
| # OpenShell workspace by default. CI may opt into an ephemeral local gateway | ||
| # bootstrap, which keeps the credentials in the gateway and out of the sandbox. | ||
| # shellcheck disable=SC2034,SC2154 # configuration and lifecycle state are shared with the wrapper. | ||
|
|
||
| agent_configure() { | ||
| [[ "$codex_inference_provider" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]{0,62}$ && "$codex_model" =~ ^[A-Za-z0-9_.@/-]+$ ]] || { | ||
| echo "invalid Codex inference provider or model" >&2 | ||
| return 1 | ||
| } | ||
| [[ "$codex_workspace" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]{0,62}$ ]] || { | ||
| echo "Codex requires a valid pre-provisioned workspace" >&2 | ||
| return 1 | ||
| } | ||
|
|
||
| if [[ "${CODEX_BOOTSTRAP:-false}" == true ]]; then | ||
| workspace="codex-$(openssl rand -hex 6)" | ||
| configured_target=false | ||
| else | ||
| workspace="$codex_workspace" | ||
| configured_target=true | ||
| fi | ||
| sandbox_name="codex-$(openssl rand -hex 6)" | ||
| github_provider=github-review | ||
| } | ||
|
|
||
| agent_require_credentials() { | ||
| if [[ "$configured_target" != true ]]; then | ||
| : "${GITHUB_TOKEN:?set the workflow GitHub token for provider bootstrap}" | ||
| : "${OPENSHELL_CODEX_API_KEY:?set the OpenAI API key for the local Codex provider}" | ||
| fi | ||
| } | ||
|
|
||
| agent_setup() { | ||
| [[ "$configured_target" == true ]] && return 0 | ||
|
|
||
| timeout 60s openshell workspace create --gateway "$gateway" --name "$workspace" | ||
| created_workspace=true | ||
|
|
||
| profiles="$(timeout 60s openshell provider list-profiles --gateway "$gateway" --workspace "$workspace" -o json)" | ||
| jq -e 'type == "array" and all(.[]; (.id | type) == "string")' <<< "$profiles" >/dev/null | ||
| if ! jq -e 'any(.[]; .id == "github-review")' <<< "$profiles" >/dev/null; then | ||
| timeout 60s openshell provider profile import --gateway "$gateway" --workspace "$workspace" \ | ||
| --file tasks/github-pr-reviewer/openshell/providers/github-review.yaml | ||
| created_github_profile=true | ||
| fi | ||
| timeout 60s openshell provider create --gateway "$gateway" --workspace "$workspace" \ | ||
| --name github-review --type github-review --credential GITHUB_TOKEN | ||
| created_github_provider=true | ||
| timeout 60s openshell provider create --gateway "$gateway" --workspace "$workspace" \ | ||
| --name "$codex_inference_provider" --type openai --credential OPENSHELL_CODEX_API_KEY | ||
| created_codex_provider=true | ||
| timeout 60s openshell inference set --gateway "$gateway" --workspace "$workspace" \ | ||
| --provider "$codex_inference_provider" --model "$codex_model" --no-verify | ||
| } | ||
|
|
||
| agent_workflow_file() { | ||
| printf '%s\n' tasks/github-pr-reviewer/workflow/codex-harness.yaml | ||
| } | ||
|
|
||
| agent_validator() { | ||
| printf '%s\n' scripts/review/validate-codex-output.sh | ||
| } | ||
|
|
||
| agent_extract_output() { | ||
| if [[ -s "$REVIEW_DIR/codex-final.txt" ]]; then | ||
| cp "$REVIEW_DIR/codex-final.txt" "$REVIEW_DIR/review.txt" | ||
| else | ||
| jq -Rr 'fromjson? | select(.type == "item.completed" and .item.type == "agent_message") | .item.text' \ | ||
| "$REVIEW_DIR/agent.ndjson" > "$REVIEW_DIR/review.txt" | ||
| fi | ||
| } | ||
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,54 @@ | ||
| #!/usr/bin/env bash | ||
| # OpenCode PR-review profile, sourced by scripts/pr-review.sh. | ||
| # This legacy profile owns the temporary Vertex workspace and provider setup. | ||
| # shellcheck disable=SC2034,SC2154 # configuration and lifecycle state are shared with the wrapper. | ||
|
|
||
| agent_configure() { | ||
| workspace="${OPENSHELL_WORKSPACE:-rev-$RANDOM-$$}" | ||
| sandbox_name="review-$(openssl rand -hex 6)" | ||
| configured_target=false | ||
| github_provider="github-review" | ||
| if [[ -n "${OPENSHELL_WORKSPACE:-}" ]]; then | ||
| configured_target=true | ||
| else | ||
| github_provider="github-review-$RANDOM-$$" | ||
| fi | ||
| } | ||
|
|
||
| agent_require_credentials() { | ||
| if [[ "$configured_target" != true ]]; then | ||
| : "${GITHUB_TOKEN:?set the workflow GitHub token for provider bootstrap}" | ||
| : "${GOOGLE_VERTEX_AI_TOKEN:?set a short-lived Vertex token}" \ | ||
| "${VERTEX_AI_PROJECT_ID:?set Vertex project}" | ||
| fi | ||
| } | ||
|
|
||
| agent_setup() { | ||
| [[ "$configured_target" == true ]] && return 0 | ||
|
|
||
| timeout 60s openshell workspace create --gateway "$gateway" --name "$workspace" | ||
| created_workspace=true | ||
| timeout 60s openshell provider create --gateway "$gateway" --workspace "$workspace" \ | ||
| --name vertex-review --type google-vertex-ai --from-existing \ | ||
| --config "VERTEX_AI_PROJECT_ID=$VERTEX_AI_PROJECT_ID" \ | ||
| --config "VERTEX_AI_REGION=${VERTEX_AI_REGION:-global}" | ||
| created_vertex_provider=true | ||
| timeout 60s openshell provider create --gateway "$gateway" --workspace "$workspace" \ | ||
| --name "$github_provider" --type github --credential GITHUB_TOKEN | ||
| created_github_provider=true | ||
| timeout 60s openshell inference set --gateway "$gateway" --workspace "$workspace" \ | ||
| --provider vertex-review --model gemini-2.5-pro --no-verify | ||
| } | ||
|
|
||
| agent_workflow_file() { | ||
| printf '%s\n' tasks/github-pr-reviewer/workflow/opencode-harness.yaml | ||
| } | ||
|
|
||
| agent_validator() { | ||
| printf '%s\n' scripts/review/validate-agent-output.sh | ||
| } | ||
|
|
||
| agent_extract_output() { | ||
| jq -Rr 'fromjson? | select(.type == "text") | .part.text' \ | ||
| "$REVIEW_DIR/agent.ndjson" > "$REVIEW_DIR/review.txt" | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: stackrox/harness-openshell
Length of output: 14821
🏁 Script executed:
Repository: stackrox/harness-openshell
Length of output: 29399
🤖 get_repo_knowledge executed:
get_repo_knowledge stackrox/harness-openshell /tmp/coderabbit-repo-knowledge/stackrox-harness-openshell-26b5f74d/conventionsLength of output: 4902
🏁 Script executed:
Repository: stackrox/harness-openshell
Length of output: 30333
🏁 Script executed:
Repository: stackrox/harness-openshell
Length of output: 7918
Reject invalid
CODEX_BOOTSTRAPvalues.Local direct-target runs invoke
scripts/pr-review.shwith environment configuration. Any value other than exact lowercasetruesetsconfigured_target=true, skips bootstrap setup, and passescodex_workspaceto the task runner. A typo orTRUEcan redirect a Codex run to the configured pre-provisioned workspace. Accept onlytrueandfalse, and return an error for other values.🤖 Prompt for AI Agents