@@ -170,62 +170,11 @@ runs:
170170          PR_NUMBER="${{ github.event.issue.number }}" 
171171        fi 
172172
173-         # Get PR diff 
174-         gh pr diff $PR_NUMBER > pr_diff.txt 
175- 
176-         # Get PR details 
177-         PR_TITLE=$(gh pr view $PR_NUMBER --json title -q .title) 
178-         PR_AUTHOR=$(gh pr view $PR_NUMBER --json author -q .author.login) 
179-         PR_BODY=$(gh pr view $PR_NUMBER --json body -q .body) 
180-         FILES_CHANGED=$(gh pr view $PR_NUMBER --json files -q '.files | length') 
181-          
182-         # Create review prompt 
183-         cat > review_prompt.txt << EOF 
184-         You are reviewing a pull request. Please provide helpful, context-aware feedback. 
185- 
186-         CONTEXT: 
187-         - Repository: ${{ github.repository }} 
188-         - PR #$PR_NUMBER: $PR_TITLE 
189-         - Files Changed: $FILES_CHANGED 
190-         - Author: $PR_AUTHOR 
191- 
192-         REVIEW APPROACH: 
193-         1. First, understand what this PR is trying to accomplish 
194-         2. Check if similar patterns exist elsewhere in the codebase 
195-         3. Focus on actual issues that affect functionality 
196-         4. Be constructive and suggest solutions when possible 
197- 
198-         FOCUS ON: 
199-         - Bugs that will cause failures or incorrect behavior 
200-         - Security vulnerabilities (exposed secrets, injection risks) 
201-         - Breaking changes that affect other parts of the system 
202-         - Performance issues with real impact (memory leaks, O(n²) algorithms) 
203-         - Missing tests for new features or bug fixes 
204-         - Missing documentation for APIs or complex logic 
205- 
206-         SKIP COMMENTING ON: 
207-         - Style and formatting (handled by linters) 
208-         - Alternative approaches unless current is broken 
209-         - Minor naming unless genuinely confusing 
210-         - Trivial documentation for self-explanatory code 
211- 
212-         Be specific with line numbers and explain why something is an issue. 
213- 
214-         PR Description: ${PR_BODY:-No description provided} 
215- 
216-         Code Changes: 
217-         EOF 
218- 
219-         # Add the diff 
220-         cat pr_diff.txt >> review_prompt.txt 
221-          
222-         cat >> review_prompt.txt << 'EOF' 
223- 
224-         Your Review: 
225-         Please provide constructive feedback on the code changes. 
226-         Focus on issues that matter for functionality, security, and maintainability. 
227-         If the code looks good overall, acknowledge that while noting any minor suggestions. 
228-         EOF 
173+         # Gather PR context and build prompt without heredocs 
174+         gh pr diff "$PR_NUMBER" > pr_diff.txt 
175+         gh pr view "$PR_NUMBER" --json title,author,body,files > pr_data.json 
176+         node actions/general-review/scripts/buildPrompt.js "$PR_NUMBER" 
177+         rm -f pr_data.json 
229178
230179name : Run Continue CLI Review 
231180      if : env.SHOULD_RUN == 'true' 
@@ -247,15 +196,7 @@ runs:
247196        if [ -z "$CONTINUE_API_KEY" ]; then 
248197          echo "Warning: CONTINUE_API_KEY environment variable is not set" 
249198          # Create fallback review and continue 
250-           cat > code_review.md << 'EOF' 
251-           ## Code Review Summary 
252- 
253-           ⚠️ AI review skipped: CONTINUE_API_KEY not configured. 
254- 
255-           ### Configuration Required 
256-           - Please set the CONTINUE_API_KEY secret in repository settings 
257-           - Verify that the organization and config path are valid 
258-           EOF 
199+           node actions/general-review/scripts/writeMarkdown.js code_review.md missing_api_key 
259200          echo "SKIP_CLI=true" >> $GITHUB_ENV 
260201        else 
261202          echo "SKIP_CLI=false" >> $GITHUB_ENV 
@@ -277,15 +218,7 @@ runs:
277218          echo "Testing Continue CLI..." 
278219          if ! which cn > /dev/null 2>&1; then 
279220            echo "Warning: Continue CLI not found or not working" 
280-             cat > code_review.md << 'EOF' 
281-             ## Code Review Summary 
282- 
283-             ⚠️ AI review skipped: Continue CLI installation failed. 
284- 
285-             ### Troubleshooting 
286-             - Check that npm installation succeeded 
287-             - Verify @continuedev/cli package is available 
288-             EOF 
221+             node actions/general-review/scripts/writeMarkdown.js code_review.md cli_install_failed 
289222            echo "SKIP_CLI=true" >> $GITHUB_ENV 
290223          else 
291224            echo "Continue CLI found at: $(which cn)" 
@@ -321,11 +254,7 @@ runs:
321254            # Check if output is empty 
322255            if [ ! -s code_review.md ]; then 
323256              echo "Warning: Continue CLI returned empty output" 
324-               cat > code_review.md << 'EOF' 
325-           ## Code Review Summary 
326- 
327-           ⚠️ Continue CLI returned an empty response. Please check the configuration. 
328-           EOF 
257+               node actions/general-review/scripts/writeMarkdown.js code_review.md empty_output 
329258            fi 
330259          else 
331260            echo "Error: Continue CLI command failed with exit code $?" 
@@ -334,34 +263,13 @@ runs:
334263             
335264            # Check for specific error patterns 
336265            if grep -q "not found\|ENOENT" cli_error.log 2>/dev/null; then 
337-               cat > code_review.md << 'EOF' 
338-           ## Code Review Summary 
339- 
340-           ⚠️ Continue CLI is not properly installed. Please ensure @continuedev/cli is installed globally. 
341-           EOF 
266+               node actions/general-review/scripts/writeMarkdown.js code_review.md cli_not_found 
342267            elif grep -q "config\|assistant" cli_error.log 2>/dev/null; then 
343-               cat > code_review.md << 'EOF' 
344-           ## Code Review Summary 
345- 
346-           ⚠️ Continue configuration error. Please verify that the assistant exists in Continue Hub. 
347-           EOF 
268+               node actions/general-review/scripts/writeMarkdown.js code_review.md config_error 
348269            elif grep -q "api\|auth" cli_error.log 2>/dev/null; then 
349-               cat > code_review.md << 'EOF' 
350-           ## Code Review Summary 
351- 
352-           ⚠️ Continue API authentication failed. Please check your CONTINUE_API_KEY. 
353-           EOF 
270+               node actions/general-review/scripts/writeMarkdown.js code_review.md auth_error 
354271            else 
355-               cat > code_review.md << 'EOF' 
356-           ## Code Review Summary 
357- 
358-           ⚠️ AI review failed. Please check the Continue API key and configuration. 
359- 
360-           ### Troubleshooting 
361-           - Verify the CONTINUE_API_KEY secret is set correctly 
362-           - Check that the organization and config path are valid 
363-           - Ensure the Continue service is accessible 
364-           EOF 
272+               node actions/general-review/scripts/writeMarkdown.js code_review.md generic_failure 
365273            fi 
366274          fi 
367275           
0 commit comments