Skip to content

Commit d53201d

Browse files
authored
fix: always pass prompt via stdin to satisfy cagent exec's required prompt arg (#46)
Signed-off-by: Derek Misler <derek.misler@docker.com>
1 parent a893bce commit d53201d

File tree

2 files changed

+6
-43
lines changed

2 files changed

+6
-43
lines changed

action.yml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,12 @@ runs:
494494
echo "Using agent: $AGENT"
495495
ARGS+=("$AGENT")
496496
497-
# Add prompt if provided (pass via stdin to avoid "Argument list too long" errors)
497+
# Always pass prompt via stdin to satisfy cagent exec's required prompt arg
498+
ARGS+=("-")
498499
if [ -n "$PROMPT_INPUT" ]; then
499-
ARGS+=("-")
500500
echo "Running cagent with ${#ARGS[@]} arguments (prompt via stdin)"
501501
else
502-
echo "Running cagent with ${#ARGS[@]} arguments (no prompt)"
502+
echo "Running cagent with ${#ARGS[@]} arguments (empty prompt via stdin)"
503503
fi
504504
505505
# Track execution time
@@ -508,23 +508,14 @@ runs:
508508
# SECURE: Direct execution with quoted arguments (no eval!)
509509
set +e # Don't exit on command failure
510510
if [ "$TIMEOUT" != "0" ]; then
511-
if [ -n "$PROMPT_INPUT" ]; then
512-
printf '%s\n' "$PROMPT_INPUT" | timeout "$TIMEOUT" "$GITHUB_WORKSPACE/cagent" "${ARGS[@]}" 2>&1 | tee "$OUTPUT_FILE"
513-
else
514-
timeout "$TIMEOUT" "$GITHUB_WORKSPACE/cagent" "${ARGS[@]}" 2>&1 | tee "$OUTPUT_FILE"
515-
fi
511+
printf '%s\n' "$PROMPT_INPUT" | timeout "$TIMEOUT" "$GITHUB_WORKSPACE/cagent" "${ARGS[@]}" 2>&1 | tee "$OUTPUT_FILE"
516512
EXIT_CODE=$?
517513
if [ $EXIT_CODE -eq 124 ]; then
518514
echo "::error::Agent execution timed out after $TIMEOUT seconds"
519515
fi
520516
else
521-
if [ -n "$PROMPT_INPUT" ]; then
522-
printf '%s\n' "$PROMPT_INPUT" | "$GITHUB_WORKSPACE/cagent" "${ARGS[@]}" 2>&1 | tee "$OUTPUT_FILE"
523-
EXIT_CODE=${PIPESTATUS[0]}
524-
else
525-
"$GITHUB_WORKSPACE/cagent" "${ARGS[@]}" 2>&1 | tee "$OUTPUT_FILE"
526-
EXIT_CODE=$?
527-
fi
517+
printf '%s\n' "$PROMPT_INPUT" | "$GITHUB_WORKSPACE/cagent" "${ARGS[@]}" 2>&1 | tee "$OUTPUT_FILE"
518+
EXIT_CODE=${PIPESTATUS[0]}
528519
fi
529520
set -e
530521

review-pr/README.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,6 @@ AI-powered pull request review using a multi-agent system. Analyzes code changes
88

99
Add `.github/workflows/pr-review.yml` to your repo with this **minimal but safe setup**:
1010

11-
```yaml
12-
name: PR Review
13-
on:
14-
issue_comment: # Enables /review command in PR comments
15-
types: [created]
16-
pull_request_review_comment: # Captures feedback on review comments for learning
17-
types: [created]
18-
pull_request_target: # Triggers auto-review on PR open; uses base branch context so secrets work with forks
19-
types: [ready_for_review, opened]
20-
21-
permissions:
22-
contents: read
23-
24-
jobs:
25-
review:
26-
uses: docker/cagent-action/.github/workflows/review-pr.yml@latest
27-
# Scoped to the job so other jobs in this workflow aren't over-permissioned
28-
permissions:
29-
contents: read # Read repository files and PR diffs
30-
pull-requests: write # Post review comments and approve/request changes
31-
issues: write # Create security incident issues if secrets are detected in output
32-
secrets:
33-
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
34-
CAGENT_ORG_MEMBERSHIP_TOKEN: ${{ secrets.CAGENT_ORG_MEMBERSHIP_TOKEN }} # PAT with read:org scope; gates auto-reviews to org members only
35-
CAGENT_REVIEWER_APP_ID: ${{ secrets.CAGENT_REVIEWER_APP_ID }} # GitHub App ID; reviews appear as your app instead of github-actions[bot]
36-
CAGENT_REVIEWER_APP_PRIVATE_KEY: ${{ secrets.CAGENT_REVIEWER_APP_PRIVATE_KEY }} # GitHub App private key; paired with App ID above
37-
```
38-
3911
> **Why explicit secrets instead of `secrets: inherit`?** This follows the principle of least privilege — the called workflow only receives the secrets it actually needs, not every secret in your repository. This is the recommended approach for public repos and security-conscious teams.
4012
4113
### Customizing for your organization

0 commit comments

Comments
 (0)