From 75b657af2256a407e31a0a57cf0a864cff74172a Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 9 Mar 2026 18:38:13 +0000 Subject: [PATCH] Add debug output to workflow --- .gitea/workflows/claude.yml | 53 +++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/.gitea/workflows/claude.yml b/.gitea/workflows/claude.yml index dc89eee..5a4c13c 100644 --- a/.gitea/workflows/claude.yml +++ b/.gitea/workflows/claude.yml @@ -23,7 +23,14 @@ jobs: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} GIT_TOKEN: ${{ secrets.GIT_TOKEN }} run: | - set -e + set -x + + # Debug info + echo "Running as: $(whoami)" + echo "Home: $HOME" + echo "Claude version: $(claude --version 2>&1)" + echo "Working dir: $(pwd)" + ls -la # Configure git git config user.name "Claude Bot" @@ -39,6 +46,9 @@ jobs: ISSUE_BODY=$(curl -s "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}" \ -H "Authorization: token ${GIT_TOKEN}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('body',''))") + echo "Issue: #${ISSUE_NUMBER} - ${ISSUE_TITLE}" + echo "Body: ${ISSUE_BODY}" + # Get comment body if triggered by comment COMMENT_BODY="" if [ "${{ github.event_name }}" = "issue_comment" ]; then @@ -57,13 +67,8 @@ jobs: -H "Content-Type: application/json" \ -d "{\"body\": \"Claude is working on this issue...\"}" - # Build the prompt - PROMPT=$(cat <<'PROMPT_EOF' - You are working on a code repository. A Gitea issue needs your attention. - PROMPT_EOF - ) - - PROMPT="You are working on the repository ${REPO}. + # Run Claude Code + CLAUDE_OUTPUT=$(claude -p "You are working on the repository ${REPO}. A Gitea issue needs your attention: Issue #${ISSUE_NUMBER}: ${ISSUE_TITLE} @@ -77,29 +82,31 @@ jobs: 3. Make sure the code is correct and complete 4. Commit all changes with a descriptive commit message - You are on branch ${BRANCH}. Work in the current directory." - - # Run Claude Code in non-interactive mode - claude -p "${PROMPT}" \ + You are on branch ${BRANCH}. Work in the current directory." \ --allowedTools "Bash,Read,Edit,Write,Glob,Grep" \ --mcp-config /home/claude-runner/.claude/mcp-gitea.json \ --max-turns 50 \ --permission-mode bypassPermissions \ - --output-format text > /tmp/claude-output.txt 2>&1 || true + --output-format text 2>&1) || true - echo "=== Claude Output ===" - cat /tmp/claude-output.txt - echo "=== End Output ===" + echo "=== CLAUDE OUTPUT START ===" + echo "${CLAUDE_OUTPUT}" + echo "=== CLAUDE OUTPUT END ===" + + # Also save to a persistent location for debugging + echo "${CLAUDE_OUTPUT}" > /home/claude-runner/last-claude-output.txt # Stage any remaining unstaged changes git add -A - # Check if there are changes - if ! git diff --cached --quiet 2>/dev/null || [ "$(git log origin/main..HEAD --oneline 2>/dev/null | wc -l)" -gt 0 ]; then - # Commit if there are staged changes - git diff --cached --quiet 2>/dev/null || git commit -m "Claude: Address issue #${ISSUE_NUMBER} - ${ISSUE_TITLE}" + echo "=== GIT STATUS ===" + git status + echo "=== GIT DIFF ===" + git diff --cached --stat - # Push + # Check if there are changes + if ! git diff --cached --quiet 2>/dev/null; then + git commit -m "Claude: Address issue #${ISSUE_NUMBER} - ${ISSUE_TITLE}" git push origin "${BRANCH}" # Create PR @@ -113,14 +120,14 @@ jobs: \"base\": \"main\" }") - PR_URL=$(echo "${PR_RESPONSE}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('html_url',''))" 2>/dev/null || echo "") + PR_URL=$(echo "${PR_RESPONSE}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('html_url',''))" 2>/dev/null || echo "unknown") - # Comment with PR link curl -s -X POST "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}/comments" \ -H "Authorization: token ${GIT_TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"body\": \"Claude has created a pull request: ${PR_URL}\"}" else + echo "No changes detected by Claude" curl -s -X POST "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}/comments" \ -H "Authorization: token ${GIT_TOKEN}" \ -H "Content-Type: application/json" \