@@ -32,6 +32,14 @@ AI_MAX_TOKENS="${AI_MAX_TOKENS:-64000}"
3232MAX_DIFF_SIZE=" ${MAX_DIFF_SIZE:- 5000000} " # 5MB default limit (allows large PRs while preventing excessive API usage)
3333EXCLUDE_FILE_PATTERNS=" ${EXCLUDE_FILE_PATTERNS:-* .lock,* .min.js,* .min.css,package-lock.json,yarn.lock} "
3434
35+ # Context inclusion options (set to 'false' to disable, reduces token usage)
36+ INCLUDE_PREVIOUS_REVIEWS=" ${INCLUDE_PREVIOUS_REVIEWS:- true} "
37+ INCLUDE_HUMAN_COMMENTS=" ${INCLUDE_HUMAN_COMMENTS:- true} "
38+ INCLUDE_CHECK_RUNS=" ${INCLUDE_CHECK_RUNS:- true} "
39+ INCLUDE_LABELS=" ${INCLUDE_LABELS:- true} "
40+ INCLUDE_PR_DESCRIPTION=" ${INCLUDE_PR_DESCRIPTION:- true} "
41+ INCLUDE_COMMIT_MESSAGES=" ${INCLUDE_COMMIT_MESSAGES:- true} "
42+
3543# Read diff content from stdin
3644DIFF_CONTENT=$( cat)
3745
6472
6573# Fetch previous AI review (only the most recent one) for context
6674PREVIOUS_REVIEWS=" "
67- if [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
75+ if [ " $INCLUDE_PREVIOUS_REVIEWS " = " true " ] && [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
6876 # Fetch only the most recent AI review comment
6977 PREVIOUS_REVIEWS=$( gh api " repos/$REPO_FULL_NAME /issues/$PR_NUMBER /comments" \
7078 --jq ' [.[] | select(.body | startswith("## AI Code Review"))] | last | if . then "### Previous AI Review (" + .created_at + "):\n" + .body + "\n---\n" else "" end' 2> /dev/null | head -c 10000 || echo " " )
7179fi
7280
7381# Fetch human comments for context
7482HUMAN_COMMENTS=" "
75- if [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
83+ if [ " $INCLUDE_HUMAN_COMMENTS " = " true " ] && [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
7684 # Fetch comments from humans (not the bot)
7785 HUMAN_COMMENTS=$( gh api " repos/$REPO_FULL_NAME /issues/$PR_NUMBER /comments" \
7886 --jq ' [.[] | select(.body | startswith("## AI Code Review") | not)] | map("**" + .user.login + "** (" + .created_at + "):\n" + .body) | join("\n\n---\n\n")' 2> /dev/null | head -c 20000 || echo " " )
7987fi
8088
8189# Fetch GitHub Actions check runs status (if PR_NUMBER and REPO_FULL_NAME are set)
8290CHECK_RUNS_STATUS=" "
83- if [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
91+ if [ " $INCLUDE_CHECK_RUNS " = " true " ] && [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
8492 # Get the head SHA of the PR
8593 HEAD_SHA=$( gh api " repos/$REPO_FULL_NAME /pulls/$PR_NUMBER " --jq ' .head.sha' 2> /dev/null || echo " " )
8694
93101
94102# Fetch available repository labels (if PR_NUMBER and REPO_FULL_NAME are set)
95103AVAILABLE_LABELS=" "
96- if [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
104+ if [ " $INCLUDE_LABELS " = " true " ] && [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
97105 # Fetch all labels from the repository
98106 if [ " $DEBUG_MODE " = " true" ]; then
99107 echo " 🔍 Fetching available labels from repository..." >&2
113121
114122# Fetch PR title and description
115123PR_DESCRIPTION=" "
116- if [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
124+ if [ " $INCLUDE_PR_DESCRIPTION " = " true " ] && [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
117125 if [ " $DEBUG_MODE " = " true" ]; then
118126 echo " 🔍 Fetching PR title and description..." >&2
119127 fi
127135
128136# Fetch commit messages (limit to 15 most recent, exclude merges)
129137COMMIT_MESSAGES=" "
130- if [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
138+ if [ " $INCLUDE_COMMIT_MESSAGES " = " true " ] && [ -n " $PR_NUMBER " ] && [ -n " $REPO_FULL_NAME " ] && [ -n " $GITHUB_TOKEN " ]; then
131139 if [ " $DEBUG_MODE " = " true" ]; then
132140 echo " 🔍 Fetching commit messages..." >&2
133141 fi
0 commit comments