@@ -9,6 +9,39 @@ BRANCH_PREFIX=$4
99ANTHROPIC_API_KEY=$5
1010GITHUB_TOKEN=$6
1111
12+ # Validate required inputs
13+ if [ -z " $ISSUE_NUMBER " ]; then
14+ echo " Error: Missing issue number"
15+ exit 1
16+ fi
17+
18+ if [ -z " $REPO_OWNER " ]; then
19+ echo " Error: Missing repository owner"
20+ exit 1
21+ fi
22+
23+ if [ -z " $REPO_NAME " ]; then
24+ echo " Error: Missing repository name"
25+ exit 1
26+ fi
27+
28+ if [ -z " $ANTHROPIC_API_KEY " ]; then
29+ echo " Error: Missing Anthropic API key"
30+ exit 1
31+ fi
32+
33+ if [ -z " $GITHUB_TOKEN " ]; then
34+ echo " Error: Missing GitHub token"
35+ exit 1
36+ fi
37+
38+ # Log parameter values for debugging (excluding sensitive info)
39+ echo " Running issue-fix-mode with parameters:"
40+ echo " Issue Number: $ISSUE_NUMBER "
41+ echo " Repo Owner: $REPO_OWNER "
42+ echo " Repo Name: $REPO_NAME "
43+ echo " Branch Prefix: ${BRANCH_PREFIX:- fix} "
44+
1245# Set up authentication
1346echo " $GITHUB_TOKEN " | gh auth login --with-token
1447export ANTHROPIC_API_KEY=" $ANTHROPIC_API_KEY "
@@ -23,14 +56,18 @@ FIX_BRANCH="${BRANCH_PREFIX:-fix}-issue-${ISSUE_NUMBER}-${DATE}"
2356
2457# Get issue details
2558echo " Fetching issue #$ISSUE_NUMBER details"
26- ISSUE_DETAILS=$( gh issue view $ISSUE_NUMBER --json title,body,labels)
59+ # Make sure we're using the correct repo format for the gh cli
60+ FULL_REPO=" $REPO_OWNER /$REPO_NAME "
61+ echo " Using repository: $FULL_REPO "
62+ ISSUE_DETAILS=$( gh issue view $ISSUE_NUMBER --repo " $FULL_REPO " --json title,body,labels)
2763
2864ISSUE_TITLE=$( echo " $ISSUE_DETAILS " | jq -r ' .title' )
2965ISSUE_BODY=$( echo " $ISSUE_DETAILS " | jq -r ' .body' )
3066ISSUE_LABELS=$( echo " $ISSUE_DETAILS " | jq -r ' .labels[].name' | tr ' \n' ' ,' | sed ' s/,$//' )
3167
3268# Get repo information
33- REPO_INFO=$( gh repo view --json name,description,defaultBranchRef,languages)
69+ echo " Fetching repository information"
70+ REPO_INFO=$( gh repo view " $FULL_REPO " --json name,description,defaultBranchRef,languages)
3471REPO_DESC=$( echo " $REPO_INFO " | jq -r ' .description' )
3572DEFAULT_BRANCH=$( echo " $REPO_INFO " | jq -r ' .defaultBranchRef.name' )
3673REPO_LANGUAGES=$( echo " $REPO_INFO " | jq -r ' .languages[].name' | tr ' \n' ' , ' | sed ' s/,$//' )
74111
75112# Run Claude CLI to analyze the issue
76113echo " Sending request to Claude for issue analysis..."
77- echo " $ANALYZE_PROMPT " | claude -p - > " $RESPONSE_FILE "
114+ if ! echo " $ANALYZE_PROMPT " | claude -p - > " $RESPONSE_FILE " ; then
115+ echo " Error: Claude API request failed. Check your API key and connectivity."
116+ exit 1
117+ fi
78118
79119# Parse Claude's response to extract files to examine
80120FILES_TO_EXAMINE=$( grep -Eo " Files Involved:.*" -A 20 " $RESPONSE_FILE " | grep -v " Proposed Changes:" | grep -v " Testing Plan:" | grep " /" | sed -E ' s/^[ -]*([^ ].*)/\1/' | sed -E ' s/ *$//' | grep -v " ^$" )
225265)
226266
227267# Create the PR
228- PR_URL=$( gh pr create --title " Fix: $ISSUE_TITLE " --body " $PR_BODY " --base " $DEFAULT_BRANCH " --head " $FIX_BRANCH " )
268+ echo " Creating pull request"
269+ PR_URL=$( gh pr create --repo " $FULL_REPO " --title " Fix: $ISSUE_TITLE " --body " $PR_BODY " --base " $DEFAULT_BRANCH " --head " $FIX_BRANCH " )
229270
230271# Add a comment to the issue
231272ISSUE_COMMENT=$( cat << EOF
@@ -244,7 +285,8 @@ Please review the PR and test the changes to verify they resolve the issue.
244285EOF
245286)
246287
247- gh issue comment $ISSUE_NUMBER --body " $ISSUE_COMMENT "
288+ echo " Adding comment to issue # $ISSUE_NUMBER"
289+ gh issue comment "$ISSUE_NUMBER" --repo "$FULL_REPO" --body "$ISSUE_COMMENT"
248290
249291# Clean up temp files
250292rm -f "$RESPONSE_FILE" "$FIX_DETAILS_FILE"
0 commit comments