diff --git a/action.yml b/action.yml index e5e4231..27df515 100644 --- a/action.yml +++ b/action.yml @@ -37,6 +37,10 @@ inputs: description: "Max diff size in bytes before truncation (0 = unlimited)" required: false default: "80000" + debug: + description: "Include agent tool log in the review comment (shows which files were read)" + required: false + default: "false" runs: using: "docker" diff --git a/entrypoint.sh b/entrypoint.sh index 35336c8..e5589de 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,6 +16,7 @@ export PI_REVIEW_PROMPT="${INPUT_REVIEW_PROMPT:-}" export PI_EXCLUDE="${INPUT_EXCLUDE_PATTERNS:-*.lock package-lock.json yarn.lock pnpm-lock.yaml *.min.js *.min.css *.map}" export PI_MAX_DIFF="${INPUT_MAX_DIFF_BYTES:-80000}" export PI_TOKEN="${INPUT_TOKEN}" +export PI_DEBUG="${INPUT_DEBUG:-false}" # The calling repo is mounted at GITHUB_WORKSPACE by both GitHub and Gitea. # cd into it so git commands work against the right repo. diff --git a/scripts/review.sh b/scripts/review.sh index 9237c99..43ebb64 100755 --- a/scripts/review.sh +++ b/scripts/review.sh @@ -125,18 +125,40 @@ PROMPT="${PROMPT} The git diff is at /tmp/pi-diff.txt. Start by reading it, then read any files you need for full context." # Run Pi in print mode (non-interactive, no session persistence) +# Capture stderr (tool call log) always — only show it when debug is on pi --no-session \ ${PROVIDER_FLAG} \ --model "${PI_MODEL}" \ --tools "${PI_TOOLS}" \ -p "${PROMPT}" \ - > /tmp/pi-review.md 2>/dev/null + > /tmp/pi-review.md 2>/tmp/pi-agent.log if [ ! -s /tmp/pi-review.md ]; then echo "::error::Pi generated no output" + echo "Agent log (last 30 lines):" + tail -30 /tmp/pi-agent.log exit 1 fi +# If debug mode, append the agent's tool log to the review +if [ "${PI_DEBUG}" = "true" ]; then + AGENT_LOG=$(sed 's/\x1b\[[0-9;]*m//g' /tmp/pi-agent.log | head -200) + cat >> /tmp/pi-review.md << LOGEOF + +--- + +
+🔍 Agent Tool Log (debug) + +\`\`\` +${AGENT_LOG} +\`\`\` + +
+LOGEOF + echo "Debug: agent log appended to review" +fi + echo "Review generated successfully." echo "::endgroup::"