mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
* feat: add unified update_claude_comment tool - Add new update_claude_comment tool that automatically handles both issue and PR comments - Remove individual update_issue_comment and update_pull_request_comment tools - Pass CLAUDE_COMMENT_ID, GITHUB_EVENT_NAME, and IS_PR to MCP server environment - Simplify Claude's comment update workflow by removing need for owner/repo/commentId params - Update prompts and tests to use the new unified tool * feat: add unified update_claude_comment tool - Add new update_claude_comment tool that automatically handles both issue and PR comments - Remove individual update_issue_comment and update_pull_request_comment tools - Pass CLAUDE_COMMENT_ID, GITHUB_EVENT_NAME, and IS_PR to MCP server environment - Use Octokit instead of raw fetch for better type safety and error handling - Simplify Claude's comment update workflow by removing need for owner/repo/commentId params - Update prompts and tests to use the new unified tool * refactor: extract update_claude_comment logic to standalone testable function - Create new updateClaudeComment function in operations/comments - Add comprehensive unit tests following image-downloader pattern - Update MCP server to use extracted function - Refactor update-comment-link.ts and update-with-branch.ts to eliminate duplication - All tests passing (10 new tests for update-claude-comment) Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com> * prettier * tsc * clean up comments --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: ashwin-ant <ashwin-ant@users.noreply.github.com>
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
#!/usr/bin/env bun
|
|
|
|
/**
|
|
* Update the initial tracking comment with branch link
|
|
* This happens after the branch is created for issues
|
|
*/
|
|
|
|
import {
|
|
createJobRunLink,
|
|
createBranchLink,
|
|
createCommentBody,
|
|
} from "./common";
|
|
import { type Octokits } from "../../api/client";
|
|
import {
|
|
isPullRequestReviewCommentEvent,
|
|
type ParsedGitHubContext,
|
|
} from "../../context";
|
|
import { updateClaudeComment } from "./update-claude-comment";
|
|
|
|
export async function updateTrackingComment(
|
|
octokit: Octokits,
|
|
context: ParsedGitHubContext,
|
|
commentId: number,
|
|
branch?: string,
|
|
) {
|
|
const { owner, repo } = context.repository;
|
|
|
|
const jobRunLink = createJobRunLink(owner, repo, context.runId);
|
|
|
|
// Add branch link for issues (not PRs)
|
|
let branchLink = "";
|
|
if (branch && !context.isPR) {
|
|
branchLink = createBranchLink(owner, repo, branch);
|
|
}
|
|
|
|
const updatedBody = createCommentBody(jobRunLink, branchLink);
|
|
|
|
// Update the existing comment with the branch link
|
|
try {
|
|
const isPRReviewComment = isPullRequestReviewCommentEvent(context);
|
|
|
|
await updateClaudeComment(octokit.rest, {
|
|
owner,
|
|
repo,
|
|
commentId,
|
|
body: updatedBody,
|
|
isPullRequestReviewComment: isPRReviewComment,
|
|
});
|
|
|
|
console.log(
|
|
`✅ Updated ${isPRReviewComment ? "PR review" : "issue"} comment ${commentId} with branch link`,
|
|
);
|
|
} catch (error) {
|
|
console.error("Error updating comment with branch link:", error);
|
|
throw error;
|
|
}
|
|
}
|