enable track_progress for comments, fix mcp config (#558)

* enable track_progress for comments

* refactor: pass mode explicitly to prepareMcpConfig

Update prepareMcpConfig to receive the mode parameter from its callers
instead of detecting agent mode by checking context.inputs.prompt.
This makes mode determination explicit and controlled by the caller.

Also update all test cases to include the required mode parameter
and fix agent mode test expectations to match new behavior where
MCP config is only included when tools are explicitly allowed.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix test

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Ashwin Bhat
2025-09-09 09:19:14 -07:00
committed by GitHub
parent 1b7eb924f1
commit a3ff61d47a
7 changed files with 34 additions and 9 deletions

View File

@@ -13,6 +13,7 @@ type PrepareConfigParams = {
claudeCommentId?: string;
allowedTools: string[];
context: GitHubContext;
mode: "tag" | "agent";
};
async function checkActionsReadPermission(
@@ -59,12 +60,12 @@ export async function prepareMcpConfig(
claudeCommentId,
allowedTools,
context,
mode,
} = params;
try {
const allowedToolsList = allowedTools || [];
// Detect if we're in agent mode (explicit prompt provided)
const isAgentMode = !!context.inputs?.prompt;
const isAgentMode = mode === "agent";
const hasGitHubMcpTools = allowedToolsList.some((tool) =>
tool.startsWith("mcp__github__"),

View File

@@ -136,6 +136,7 @@ export const agentMode: Mode = {
claudeCommentId: undefined, // No tracking comment in agent mode
allowedTools,
context,
mode: "agent",
});
// Build final claude_args with multiple --mcp-config flags

View File

@@ -19,7 +19,13 @@ export function detectMode(context: GitHubContext): AutoDetectedMode {
// If track_progress is set for PR/issue events, force tag mode
if (context.inputs.trackProgress && isEntityContext(context)) {
if (isPullRequestEvent(context) || isIssuesEvent(context)) {
if (
isPullRequestEvent(context) ||
isIssuesEvent(context) ||
isIssueCommentEvent(context) ||
isPullRequestReviewCommentEvent(context) ||
isPullRequestReviewEvent(context)
) {
return "tag";
}
}
@@ -87,10 +93,16 @@ export function getModeDescription(mode: AutoDetectedMode): string {
function validateTrackProgressEvent(context: GitHubContext): void {
// track_progress is only valid for pull_request and issue events
const validEvents = ["pull_request", "issues"];
const validEvents = [
"pull_request",
"issues",
"issue_comment",
"pull_request_review_comment",
"pull_request_review",
];
if (!validEvents.includes(context.eventName)) {
throw new Error(
`track_progress is only supported for pull_request and issue events. ` +
`track_progress is only supported for events: ${validEvents.join(", ")}. ` +
`Current event: ${context.eventName}`,
);
}

View File

@@ -122,6 +122,7 @@ export const tagMode: Mode = {
claudeCommentId: commentId.toString(),
allowedTools: [],
context,
mode: "tag",
});
// Don't output mcp_config separately anymore - include in claude_args