mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
- Agent mode now only triggers when explicit prompt is provided - Removed automatic triggering for workflow_dispatch/schedule without prompt - Re-added additional_permissions input for requesting GitHub permissions - Fixed TypeScript types for mock context helpers to properly handle partial inputs - Updated documentation to reflect simplified mode behavior
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import type { GitHubContext } from "../github/context";
|
|
import {
|
|
isEntityContext,
|
|
isIssueCommentEvent,
|
|
isPullRequestReviewCommentEvent,
|
|
} from "../github/context";
|
|
import { checkContainsTrigger } from "../github/validation/trigger";
|
|
|
|
export type AutoDetectedMode = "tag" | "agent";
|
|
|
|
export function detectMode(context: GitHubContext): AutoDetectedMode {
|
|
// If prompt is provided, use agent mode for direct execution
|
|
if (context.inputs?.prompt) {
|
|
return "agent";
|
|
}
|
|
|
|
// Check for @claude mentions (tag mode)
|
|
if (isEntityContext(context)) {
|
|
if (
|
|
isIssueCommentEvent(context) ||
|
|
isPullRequestReviewCommentEvent(context)
|
|
) {
|
|
if (checkContainsTrigger(context)) {
|
|
return "tag";
|
|
}
|
|
}
|
|
|
|
if (context.eventName === "issues") {
|
|
if (checkContainsTrigger(context)) {
|
|
return "tag";
|
|
}
|
|
}
|
|
}
|
|
|
|
// Default to agent mode (which won't trigger without a prompt)
|
|
return "agent";
|
|
}
|
|
|
|
export function getModeDescription(mode: AutoDetectedMode): string {
|
|
switch (mode) {
|
|
case "tag":
|
|
return "Interactive mode triggered by @claude mentions";
|
|
case "agent":
|
|
return "Direct automation mode for explicit prompts";
|
|
default:
|
|
return "Unknown mode";
|
|
}
|
|
}
|
|
|
|
export function shouldUseTrackingComment(mode: AutoDetectedMode): boolean {
|
|
return mode === "tag";
|
|
}
|
|
|
|
export function getDefaultPromptForMode(
|
|
mode: AutoDetectedMode,
|
|
context: GitHubContext,
|
|
): string | undefined {
|
|
switch (mode) {
|
|
case "tag":
|
|
return undefined;
|
|
case "agent":
|
|
return context.inputs?.prompt;
|
|
default:
|
|
return undefined;
|
|
}
|
|
}
|