claude-issue-solver 1.28.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -137,14 +137,15 @@ echo -ne "\\033]0;Issue #${issueNumber}: ${issue.title.replace(/"/g, '\\"').slic
137
137
  echo "🤖 Claude Code - Issue #${issueNumber}: ${issue.title}"
138
138
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
139
139
  echo ""
140
- ${autoMode ? 'echo "🔄 AUTO MODE: Will solve → review → fix until approved (max 3 iterations)"' : 'echo "When Claude commits, a PR will be created automatically."'}
140
+ ${autoMode ? `echo "🔄 AUTO MODE: Fully autonomous solve → review → fix loop"
141
+ echo " Max 3 iterations. No user input required."
142
+ ${!botToken ? 'echo "⚠️ No bot token configured. Run: cis config bot-token"' : ''}` : 'echo "When Claude commits, a PR will be created automatically."'}
141
143
  echo "The terminal stays open for follow-up changes."
142
144
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
143
145
  echo ""
144
146
 
145
- ${botToken ? `# Bot token for reviews
147
+ ${botToken ? `# Bot token for reviews (only used during review, not PR creation)
146
148
  export BOT_TOKEN="${botToken}"
147
- export GH_TOKEN="${botToken}"
148
149
  ` : ''}
149
150
 
150
151
  # Function to create PR
@@ -213,42 +214,36 @@ get_pr_number() {
213
214
 
214
215
  # Function to get PR review status
215
216
  get_review_status() {
216
- ${botToken ? 'GH_TOKEN="${BOT_TOKEN}"' : ''} gh pr view "$1" --json reviewDecision --jq '.reviewDecision' 2>/dev/null
217
+ gh pr view "$1" --json reviewDecision --jq '.reviewDecision' 2>/dev/null
217
218
  }
218
219
 
219
- # Watch for new commits in background and create PR
220
- LAST_COMMIT=""
221
- while true; do
222
- CURRENT_COMMIT=$(git rev-parse HEAD 2>/dev/null)
223
- if [ "$CURRENT_COMMIT" != "$LAST_COMMIT" ] && [ -n "$LAST_COMMIT" ]; then
224
- create_pr > /dev/null
225
- fi
226
- LAST_COMMIT="$CURRENT_COMMIT"
227
- sleep 2
228
- done &
229
- WATCHER_PID=$!
220
+ ${autoMode ? `# AUTO MODE: Non-interactive solve review → fix loop
221
+ echo ""
222
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
223
+ echo "📝 STEP 1: Solving issue..."
224
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
225
+ echo ""
230
226
 
231
- # Run Claude interactively (read prompt from file to avoid shell escaping issues)
232
- claude --dangerously-skip-permissions "$(cat '${promptFile}')"
227
+ # Run Claude non-interactively to solve
228
+ claude -p --dangerously-skip-permissions "$(cat '${promptFile}')"
233
229
 
234
230
  # Clean up prompt file
235
231
  rm -f '${promptFile}'
236
232
 
237
- # Kill the watcher
238
- kill $WATCHER_PID 2>/dev/null
239
-
240
- # Final PR check after Claude exits
241
- create_pr > /dev/null
233
+ # Create PR
234
+ echo ""
235
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
236
+ echo "📤 Creating PR..."
237
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
238
+ create_pr
242
239
 
243
- ${autoMode ? `
244
- # AUTO MODE: Review loop
240
+ # Review loop
245
241
  MAX_ITERATIONS=3
246
242
  ITERATION=0
247
243
 
248
244
  while [ $ITERATION -lt $MAX_ITERATIONS ]; do
249
245
  ITERATION=$((ITERATION + 1))
250
246
 
251
- # Wait for PR to be created
252
247
  sleep 2
253
248
  PR_NUM=$(get_pr_number)
254
249
 
@@ -260,59 +255,57 @@ while [ $ITERATION -lt $MAX_ITERATIONS ]; do
260
255
 
261
256
  echo ""
262
257
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
263
- echo "🔍 AUTO-REVIEW: Iteration $ITERATION of $MAX_ITERATIONS"
258
+ echo "🔍 STEP 2: Review iteration $ITERATION of $MAX_ITERATIONS"
264
259
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
265
260
  echo ""
266
261
 
267
262
  # Get PR diff for review
268
263
  PR_DIFF=$(gh pr diff $PR_NUM 2>/dev/null | head -500)
269
264
 
270
- # Create review prompt
271
- REVIEW_PROMPT="You are reviewing PR #$PR_NUM for issue #${issueNumber}: ${issue.title.replace(/"/g, '\\"')}
272
-
273
- ## Issue Description
274
- ${issue.body.replace(/"/g, '\\"').replace(/\$/g, '\\$').replace(/\`/g, '\\`')}
275
-
276
- ## Your Task
277
- Review the code changes in this PR. Look for:
278
- 1. Bugs and logic errors
279
- 2. Security vulnerabilities
280
- 3. Missing error handling
281
- 4. Code quality issues
282
- 5. Performance problems
283
-
284
- ## How to Leave Feedback
285
- ${botToken ? `Use GH_TOKEN=\\$BOT_TOKEN prefix for all gh commands.
286
-
287
- If the code looks good:
288
- \\\`\\\`\\\`bash
289
- GH_TOKEN=\\$BOT_TOKEN gh pr review $PR_NUM --approve --body \\"LGTM! Code looks good.\\"
290
- \\\`\\\`\\\`
291
-
292
- If changes are needed:
293
- \\\`\\\`\\\`bash
294
- GH_TOKEN=\\$BOT_TOKEN gh pr review $PR_NUM --request-changes --body \\"<your feedback>\\"
295
- \\\`\\\`\\\`
296
- ` : `If the code looks good:
297
- \\\`\\\`\\\`bash
298
- gh pr review $PR_NUM --approve --body \\"LGTM! Code looks good.\\"
299
- \\\`\\\`\\\`
300
-
301
- If changes are needed:
302
- \\\`\\\`\\\`bash
303
- gh pr review $PR_NUM --request-changes --body \\"<your feedback>\\"
304
- \\\`\\\`\\\`
305
- `}
265
+ # Write review prompt to file (avoid escaping issues)
266
+ REVIEW_FILE=".claude-review-prompt.txt"
267
+ cat > "$REVIEW_FILE" << 'REVIEW_EOF'
268
+ You are reviewing a PR. Your task is to review the code and leave feedback using the gh CLI.
306
269
 
307
- ## PR Diff (first 500 lines)
308
- \\\`\\\`\\\`diff
309
- $PR_DIFF
310
- \\\`\\\`\\\`
270
+ IMPORTANT: You must run ONE of these commands before finishing:
271
+ ${botToken ? `
272
+ To APPROVE (if code looks good):
273
+ GH_TOKEN=$BOT_TOKEN gh pr review PR_NUM --approve --body "LGTM! Code looks good."
311
274
 
312
- Review the code and either approve or request changes."
275
+ To REQUEST CHANGES (if issues found):
276
+ GH_TOKEN=$BOT_TOKEN gh pr review PR_NUM --request-changes --body "Your detailed feedback here"
277
+ ` : `
278
+ To APPROVE (if code looks good):
279
+ gh pr review PR_NUM --approve --body "LGTM! Code looks good."
313
280
 
314
- # Run Claude for review
315
- claude --dangerously-skip-permissions "$REVIEW_PROMPT"
281
+ To REQUEST CHANGES (if issues found):
282
+ gh pr review PR_NUM --request-changes --body "Your detailed feedback here"
283
+ `}
284
+ Review criteria:
285
+ 1. Does the code solve the issue correctly?
286
+ 2. Are there bugs or logic errors?
287
+ 3. Security vulnerabilities?
288
+ 4. Missing error handling?
289
+ 5. Code quality issues?
290
+
291
+ REVIEW_EOF
292
+
293
+ # Append issue and diff info
294
+ echo "" >> "$REVIEW_FILE"
295
+ echo "## Issue #${issueNumber}: ${issue.title.replace(/"/g, '\\"')}" >> "$REVIEW_FILE"
296
+ echo "${issue.body.replace(/"/g, '\\"').replace(/\$/g, '\\$').replace(/\`/g, '\\`')}" >> "$REVIEW_FILE"
297
+ echo "" >> "$REVIEW_FILE"
298
+ echo "## PR Diff:" >> "$REVIEW_FILE"
299
+ echo "\\\`\\\`\\\`diff" >> "$REVIEW_FILE"
300
+ echo "$PR_DIFF" >> "$REVIEW_FILE"
301
+ echo "\\\`\\\`\\\`" >> "$REVIEW_FILE"
302
+
303
+ # Replace PR_NUM placeholder
304
+ sed -i '' "s/PR_NUM/$PR_NUM/g" "$REVIEW_FILE" 2>/dev/null || sed -i "s/PR_NUM/$PR_NUM/g" "$REVIEW_FILE"
305
+
306
+ # Run Claude for review (non-interactive)
307
+ claude -p --dangerously-skip-permissions "$(cat "$REVIEW_FILE")"
308
+ rm -f "$REVIEW_FILE"
316
309
 
317
310
  # Check review status
318
311
  sleep 2
@@ -332,22 +325,27 @@ Review the code and either approve or request changes."
332
325
  if [ $ITERATION -lt $MAX_ITERATIONS ]; then
333
326
  echo ""
334
327
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
335
- echo "🔧 Changes requested. Claude will fix them..."
328
+ echo "🔧 STEP 3: Fixing requested changes..."
336
329
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
337
330
  echo ""
338
331
 
339
332
  # Get the review comments
340
- REVIEW_COMMENTS=$(${botToken ? 'GH_TOKEN="${BOT_TOKEN}"' : ''} gh pr view $PR_NUM --json reviews --jq '.reviews[-1].body' 2>/dev/null)
333
+ REVIEW_COMMENTS=$(gh pr view $PR_NUM --json reviews --jq '.reviews[-1].body' 2>/dev/null)
341
334
 
342
- FIX_PROMPT="The code review requested changes. Please fix them:
335
+ # Write fix prompt to file
336
+ FIX_FILE=".claude-fix-prompt.txt"
337
+ cat > "$FIX_FILE" << FIX_EOF
338
+ The code review requested changes. Please fix them and commit.
343
339
 
344
340
  ## Review Feedback
345
341
  $REVIEW_COMMENTS
346
342
 
347
- Please address the feedback above, make the necessary changes, and commit them."
343
+ Please address the feedback above, make the necessary changes, and commit them.
344
+ FIX_EOF
348
345
 
349
- # Run Claude to fix
350
- claude --dangerously-skip-permissions "$FIX_PROMPT"
346
+ # Run Claude to fix (non-interactive)
347
+ claude -p --dangerously-skip-permissions "$(cat "$FIX_FILE")"
348
+ rm -f "$FIX_FILE"
351
349
 
352
350
  # Push changes
353
351
  git push origin "${branchName}" 2>/dev/null
@@ -366,7 +364,30 @@ Please address the feedback above, make the necessary changes, and commit them."
366
364
  break
367
365
  fi
368
366
  done
369
- ` : ''}
367
+ ` : `# INTERACTIVE MODE: Watch for commits and create PR automatically
368
+ LAST_COMMIT=""
369
+ while true; do
370
+ CURRENT_COMMIT=$(git rev-parse HEAD 2>/dev/null)
371
+ if [ "$CURRENT_COMMIT" != "$LAST_COMMIT" ] && [ -n "$LAST_COMMIT" ]; then
372
+ create_pr > /dev/null
373
+ fi
374
+ LAST_COMMIT="$CURRENT_COMMIT"
375
+ sleep 2
376
+ done &
377
+ WATCHER_PID=$!
378
+
379
+ # Run Claude interactively
380
+ claude --dangerously-skip-permissions "$(cat '${promptFile}')"
381
+
382
+ # Clean up prompt file
383
+ rm -f '${promptFile}'
384
+
385
+ # Kill the watcher
386
+ kill $WATCHER_PID 2>/dev/null
387
+
388
+ # Final PR check after Claude exits
389
+ create_pr > /dev/null
390
+ `}
370
391
 
371
392
  echo ""
372
393
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-issue-solver",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "description": "Automatically solve GitHub issues using Claude Code",
5
5
  "main": "dist/index.js",
6
6
  "bin": {