fix: allow direct_prompt with issue assignment without requiring assignee_trigger (#192)

- Modified validation logic to only require assignee_trigger when direct_prompt is not provided
- Made assigneeTrigger optional in IssueAssignedEvent type definition
- Enhanced context generation to handle missing assigneeTrigger gracefully
- Added comprehensive test coverage for the new behavior

This enables direct_prompt workflows on issue assignment events without
requiring assignee_trigger configuration, fixing the error:
"ASSIGNEE_TRIGGER is required for issue assigned event"

Fixes #113

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

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Tomohiro Ishibashi
2025-06-24 09:41:25 +09:00
committed by GitHub
parent 882586e496
commit 38254908ae
4 changed files with 78 additions and 4 deletions

View File

@@ -242,7 +242,7 @@ export function prepareContext(
}
if (eventAction === "assigned") {
if (!assigneeTrigger) {
if (!assigneeTrigger && !directPrompt) {
throw new Error(
"ASSIGNEE_TRIGGER is required for issue assigned event",
);
@@ -254,7 +254,7 @@ export function prepareContext(
issueNumber,
baseBranch,
claudeBranch,
assigneeTrigger,
...(assigneeTrigger && { assigneeTrigger }),
};
} else if (eventAction === "opened") {
eventData = {
@@ -331,7 +331,9 @@ export function getEventTypeAndContext(envVars: PreparedContext): {
}
return {
eventType: "ISSUE_ASSIGNED",
triggerContext: `issue assigned to '${eventData.assigneeTrigger}'`,
triggerContext: eventData.assigneeTrigger
? `issue assigned to '${eventData.assigneeTrigger}'`
: `issue assigned event`,
};
case "pull_request":

View File

@@ -65,7 +65,7 @@ type IssueAssignedEvent = {
issueNumber: string;
baseBranch: string;
claudeBranch: string;
assigneeTrigger: string;
assigneeTrigger?: string;
};
type PullRequestEvent = {