Compare commits

..

2 Commits

Author SHA1 Message Date
Ashwin Bhat
851ffa401e tmp 2025-08-27 17:09:55 -07:00
Ashwin Bhat
4ebee54a00 Add debug logging to checkContainsTrigger for test debugging
Added console.log statements to trace execution flow in trigger validation:
- Log context and inputs at function entry
- Log issue content and regex pattern matching
- Log final return value
- Add logging to tagMode.shouldTrigger to trace delegation

These logs help debug the 'shouldTrigger delegates to checkContainsTrigger' test.
2025-08-27 17:05:29 -07:00
9 changed files with 81 additions and 33 deletions

View File

@@ -157,7 +157,7 @@ runs:
# Install Claude Code if no custom executable is provided
if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then
echo "Installing Claude Code..."
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.96
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.93
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
else
echo "Using custom Claude Code executable: ${{ inputs.path_to_claude_code_executable }}"

View File

@@ -99,7 +99,7 @@ runs:
run: |
if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then
echo "Installing Claude Code..."
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.96
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.93
else
echo "Using custom Claude Code executable: ${{ inputs.path_to_claude_code_executable }}"
# Add the directory containing the custom executable to PATH

View File

@@ -22,12 +22,7 @@ jobs:
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
Please review this pull request.
Note: The PR branch is already checked out in the current working directory.
Please review this pull request and provide comprehensive feedback.
Focus on:
- Code quality and best practices
@@ -39,10 +34,7 @@ jobs:
- Verify that README.md and docs are updated for any new features or config changes
Provide constructive feedback with specific suggestions for improvement.
Use `gh pr comment:*` for top-level comments.
Use `mcp__github_inline_comment__create_inline_comment` to highlight specific areas of concern.
Only your GitHub comments that you post will be seen, so don't submit your review as a normal message, just as comments.
If the PR has already been reviewed, or there are no noteworthy changes, don't post anything.
Use inline comments to highlight specific areas of concern.
claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*)"
--allowedTools "mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__get_pull_request_diff"

View File

@@ -0,0 +1,45 @@
name: Claude Experimental Review Mode
on:
pull_request:
types: [opened, synchronize]
issue_comment:
types: [created]
jobs:
code-review:
# Run on PR events, or when someone comments "@claude review" on a PR
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(github.event.comment.body, '@claude review'))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better diff analysis
- name: Code Review with Claude
uses: anthropics/claude-code-action@v1-dev
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# github_token not needed - uses default GITHUB_TOKEN for GitHub operations
prompt: |
Review this pull request comprehensively.
Focus on:
- Code quality and maintainability
- Security vulnerabilities
- Performance issues
- Best practices and design patterns
- Test coverage gaps
Be constructive and provide specific suggestions for improvements.
Use GitHub's suggestion format when proposing code changes.

View File

@@ -28,13 +28,7 @@ jobs:
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
Please review this pull request focusing on the changed files.
Note: The PR branch is already checked out in the current working directory.
Provide feedback on:
- Code quality and adherence to best practices
- Potential bugs or edge cases
@@ -44,6 +38,3 @@ jobs:
Since this PR touches critical source code paths, please be thorough
in your review and provide inline comments where appropriate.
claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*)"

View File

@@ -27,13 +27,8 @@ jobs:
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
Please provide a thorough review of this pull request.
Note: The PR branch is already checked out in the current working directory.
Since this is from a specific author that requires careful review,
please pay extra attention to:
- Adherence to project coding standards
@@ -43,6 +38,3 @@ jobs:
- Documentation
Provide detailed feedback and suggestions for improvement.
claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*)"

View File

@@ -12,10 +12,23 @@ import {
import type { ParsedGitHubContext } from "../context";
export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
console.log("checkContainsTrigger called with context:", {
eventName: context.eventName,
eventAction: context.eventAction,
inputs: context.inputs,
});
const {
inputs: { assigneeTrigger, labelTrigger, triggerPhrase, prompt },
} = context;
console.log("Extracted inputs:", {
assigneeTrigger,
labelTrigger,
triggerPhrase,
prompt,
});
// If prompt is provided, always trigger
if (prompt) {
console.log(`Prompt provided, triggering action`);
@@ -46,15 +59,21 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
// Check for issue body and title trigger on issue creation
if (isIssuesEvent(context) && context.eventAction === "opened") {
console.log("Checking issue opened trigger");
const issueBody = context.payload.issue.body || "";
const issueTitle = context.payload.issue.title || "";
console.log("Issue content:", { issueBody, issueTitle });
// Check for exact match with word boundaries or punctuation
const regex = new RegExp(
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
);
console.log("Regex pattern:", regex.toString());
// Check in body
if (regex.test(issueBody)) {
const bodyMatch = regex.test(issueBody);
console.log("Body match result:", bodyMatch);
if (bodyMatch) {
console.log(
`Issue body contains exact trigger phrase '${triggerPhrase}'`,
);
@@ -62,7 +81,9 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
}
// Check in title
if (regex.test(issueTitle)) {
const titleMatch = regex.test(issueTitle);
console.log("Title match result:", titleMatch);
if (titleMatch) {
console.log(
`Issue title contains exact trigger phrase '${triggerPhrase}'`,
);
@@ -133,6 +154,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
}
console.log(`No trigger was met for ${triggerPhrase}`);
console.log("Returning false from checkContainsTrigger");
return false;
}

View File

@@ -24,11 +24,16 @@ export const tagMode: Mode = {
description: "Traditional implementation mode triggered by @claude mentions",
shouldTrigger(context) {
console.log("tagMode.shouldTrigger called");
// Tag mode only handles entity events
if (!isEntityContext(context)) {
console.log("Not entity context, returning false");
return false;
}
return checkContainsTrigger(context);
console.log("Is entity context, calling checkContainsTrigger");
const result = checkContainsTrigger(context);
console.log("checkContainsTrigger returned:", result);
return result;
},
prepareContext(context, data) {

View File

@@ -23,6 +23,7 @@ describe("Tag Mode", () => {
});
test("shouldTrigger delegates to checkContainsTrigger", () => {
console.log("enter test");
const contextWithTrigger = createMockContext({
eventName: "issue_comment",
isPR: false,