diff --git a/action.yml b/action.yml index a23ff6afe..24f02113c 100644 --- a/action.yml +++ b/action.yml @@ -93,6 +93,10 @@ inputs: description: "Force tag mode with tracking comments for pull_request and issue events. Only applicable to pull_request (opened, synchronize, ready_for_review, reopened) and issue (opened, edited, labeled, assigned) events." required: false default: "false" + concise_comments: + description: "Use
blocks to collapse verbose content in comments (keeps PR threads clean)" + required: false + default: "true" path_to_claude_code_executable: description: "Optional path to a custom Claude Code executable. If provided, skips automatic installation and uses this executable instead. WARNING: Using an older version may cause problems if the action begins taking advantage of new Claude Code features. This input is typically not needed unless you're debugging something specific or have unique needs in your environment." required: false @@ -177,6 +181,7 @@ runs: BOT_ID: ${{ inputs.bot_id }} BOT_NAME: ${{ inputs.bot_name }} TRACK_PROGRESS: ${{ inputs.track_progress }} + CONCISE_COMMENTS: ${{ inputs.concise_comments }} ADDITIONAL_PERMISSIONS: ${{ inputs.additional_permissions }} CLAUDE_ARGS: ${{ inputs.claude_args }} ALL_INPUTS: ${{ toJson(inputs) }} diff --git a/bun.lock b/bun.lock index 76ce79475..8259f1627 100644 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "@anthropic-ai/claude-code-action", diff --git a/src/create-prompt/index.ts b/src/create-prompt/index.ts index 7a62e6ea5..78c817da3 100644 --- a/src/create-prompt/index.ts +++ b/src/create-prompt/index.ts @@ -392,6 +392,46 @@ export function getEventTypeAndContext(envVars: PreparedContext): { } } +function getConciseCommentsInstructions(): string { + return ` +COMMENT FORMATTING FOR CLEAN PR THREADS: +Your comments should be scannable and not clutter the PR thread. Follow this format: + +1. Keep the visible summary brief (1-3 sentences describing what you did or your answer) +2. Use
blocks for anything verbose: + - Detailed explanations or reasoning + - Code snippets longer than 10 lines + - Command output or logs + - Step-by-step breakdowns + - Full error messages or stack traces + - File lists or lengthy enumerations + +Example format: +\`\`\` +### Summary +Fixed the authentication bug by updating token validation in \`auth.ts\`. + +
+📝 Detailed changes + +The issue was in the \`validateToken()\` function which wasn't checking token expiry... + +
+ +
+📋 Files modified + +- \`src/auth/auth.ts\` - Updated token validation +- \`src/auth/types.ts\` - Added new error type +- \`tests/auth.test.ts\` - Added test coverage + +
+\`\`\` + +This keeps the PR thread readable while preserving all details for those who want them. +`; +} + function getCommitInstructions( eventData: EventData, githubData: FetchDataResult, @@ -559,6 +599,7 @@ Communication: - Use mcp__github_comment__update_claude_comment to update (only "body" param needed) - Use checklist format for tasks: - [ ] incomplete, - [x] complete - Use ### headers (not #) +${context.githubContext?.inputs.conciseComments ? getConciseCommentsInstructions() : ""} ${getCommitInstructions(eventData, githubData, context, useCommitSigning)} ${ eventData.claudeBranch @@ -801,6 +842,7 @@ ${ - REPOSITORY SETUP INSTRUCTIONS: The repository's CLAUDE.md file(s) contain critical repo-specific setup instructions, development guidelines, and preferences. Always read and follow these files, particularly the root CLAUDE.md, as they provide essential context for working with the codebase effectively. - Use h3 headers (###) for section titles in your comments, not h1 headers (#). - Your comment must always include the job run link in the format "[View job run](${GITHUB_SERVER_URL}/${context.repository}/actions/runs/${process.env.GITHUB_RUN_ID})" at the bottom of your response (branch link if there is one should also be included there). +${context.githubContext?.inputs.conciseComments ? getConciseCommentsInstructions() : ""} CAPABILITIES AND LIMITATIONS: When users ask you to do something, be aware of what you can and cannot do. This section helps you understand how to respond when users request actions outside your scope. diff --git a/src/github/context.ts b/src/github/context.ts index 92f272cb1..ac493933e 100644 --- a/src/github/context.ts +++ b/src/github/context.ts @@ -95,6 +95,7 @@ type BaseContext = { allowedBots: string; allowedNonWriteUsers: string; trackProgress: boolean; + conciseComments: boolean; }; }; @@ -150,6 +151,7 @@ export function parseGitHubContext(): GitHubContext { allowedBots: process.env.ALLOWED_BOTS ?? "", allowedNonWriteUsers: process.env.ALLOWED_NON_WRITE_USERS ?? "", trackProgress: process.env.TRACK_PROGRESS === "true", + conciseComments: (process.env.CONCISE_COMMENTS ?? "true") === "true", }, }; diff --git a/test/install-mcp-server.test.ts b/test/install-mcp-server.test.ts index 9d628504d..1e2f488ce 100644 --- a/test/install-mcp-server.test.ts +++ b/test/install-mcp-server.test.ts @@ -37,6 +37,7 @@ describe("prepareMcpConfig", () => { allowedBots: "", allowedNonWriteUsers: "", trackProgress: false, + conciseComments: true, }, }; diff --git a/test/mockContext.ts b/test/mockContext.ts index 060eb93ad..7dd119c6f 100644 --- a/test/mockContext.ts +++ b/test/mockContext.ts @@ -25,6 +25,7 @@ const defaultInputs = { allowedBots: "", allowedNonWriteUsers: "", trackProgress: false, + conciseComments: true, }; const defaultRepository = { diff --git a/test/modes/detector.test.ts b/test/modes/detector.test.ts index ed6a3a5da..46ca52e83 100644 --- a/test/modes/detector.test.ts +++ b/test/modes/detector.test.ts @@ -25,6 +25,7 @@ describe("detectMode with enhanced routing", () => { allowedBots: "", allowedNonWriteUsers: "", trackProgress: false, + conciseComments: true, }, }; diff --git a/test/permissions.test.ts b/test/permissions.test.ts index 9aeb3011a..da9299de1 100644 --- a/test/permissions.test.ts +++ b/test/permissions.test.ts @@ -73,6 +73,7 @@ describe("checkWritePermissions", () => { allowedBots: "", allowedNonWriteUsers: "", trackProgress: false, + conciseComments: true, }, });