diff --git a/src/create-prompt/types.ts b/src/create-prompt/types.ts
index 25e90064..ea9e4a22 100644
--- a/src/create-prompt/types.ts
+++ b/src/create-prompt/types.ts
@@ -1,6 +1,6 @@
export type CommonFields = {
repository: string;
- claudeCommentId: string;
+ claudeCommentId?: string;
triggerPhrase: string;
triggerUsername?: string;
customInstructions?: string;
diff --git a/test/create-prompt.test.ts b/test/create-prompt.test.ts
index fe5febd5..aaa7cb22 100644
--- a/test/create-prompt.test.ts
+++ b/test/create-prompt.test.ts
@@ -713,6 +713,78 @@ describe("generatePrompt", () => {
);
});
+ test("should generate prompt for workflow_dispatch event with null githubData", () => {
+ const envVars: PreparedContext = {
+ repository: "owner/repo",
+ triggerPhrase: "@claude",
+ eventData: {
+ eventName: "workflow_dispatch",
+ isPR: false,
+ baseBranch: "main",
+ },
+ };
+
+ const prompt = generatePrompt(envVars, null, false);
+
+ expect(prompt).toContain("WORKFLOW_DISPATCH");
+ expect(prompt).toContain("false");
+ expect(prompt).toContain(
+ "workflow dispatch event",
+ );
+ expect(prompt).toContain(
+ "You are running in an automated context without a specific issue or PR",
+ );
+ expect(prompt).not.toContain("");
+ expect(prompt).not.toContain("");
+ });
+
+ test("should generate prompt for schedule event with null githubData", () => {
+ const envVars: PreparedContext = {
+ repository: "owner/repo",
+ triggerPhrase: "@claude",
+ triggerUsername: "github-actions[bot]",
+ eventData: {
+ eventName: "schedule",
+ isPR: false,
+ baseBranch: "main",
+ },
+ };
+
+ const prompt = generatePrompt(envVars, null, false);
+
+ expect(prompt).toContain("SCHEDULE");
+ expect(prompt).toContain("false");
+ expect(prompt).toContain(
+ "scheduled automation event",
+ );
+ expect(prompt).toContain("scheduled automation");
+ expect(prompt).toContain(
+ "github-actions[bot]",
+ );
+ });
+
+ test("should include direct prompt for automation events", () => {
+ const envVars: PreparedContext = {
+ repository: "owner/repo",
+ triggerPhrase: "@claude",
+ directPrompt: "Run daily maintenance tasks",
+ eventData: {
+ eventName: "workflow_dispatch",
+ isPR: false,
+ baseBranch: "main",
+ },
+ };
+
+ const prompt = generatePrompt(envVars, null, false);
+
+ expect(prompt).toContain("");
+ expect(prompt).toContain("Run daily maintenance tasks");
+ expect(prompt).toContain("");
+ expect(prompt).toContain(
+ "IMPORTANT: The following are direct instructions from the automation workflow",
+ );
+ });
+
test("should handle pull_request event on closed PR with new branch", () => {
const envVars: PreparedContext = {
repository: "owner/repo",
diff --git a/test/prepare-context.test.ts b/test/prepare-context.test.ts
index fb2e9d02..123fb5c0 100644
--- a/test/prepare-context.test.ts
+++ b/test/prepare-context.test.ts
@@ -29,6 +29,88 @@ describe("parseEnvVarsWithContext", () => {
process.env = originalEnv;
});
+ describe("workflow_dispatch event", () => {
+ beforeEach(() => {
+ process.env = {
+ ...BASE_ENV,
+ BASE_BRANCH: "main",
+ };
+ });
+
+ test("should parse workflow_dispatch event correctly", () => {
+ const mockWorkflowDispatchContext = createMockContext({
+ eventName: "workflow_dispatch",
+ payload: {
+ inputs: {
+ task: "Run automated task",
+ },
+ repository: {
+ name: "test-repo",
+ owner: {
+ login: "test-owner",
+ },
+ },
+ sender: {
+ login: "test-user",
+ },
+ workflow: "test.yml",
+ },
+ });
+
+ const result = prepareContext(
+ mockWorkflowDispatchContext,
+ "",
+ "main",
+ undefined,
+ );
+
+ expect(result.repository).toBe("test-owner/test-repo");
+ expect(result.eventData.eventName).toBe("workflow_dispatch");
+ expect(result.eventData.isPR).toBe(false);
+ expect(result.eventData.baseBranch).toBe("main");
+ // triggerUsername is not extracted for workflow_dispatch events
+ expect(result.triggerUsername).toBeUndefined();
+ });
+ });
+
+ describe("schedule event", () => {
+ beforeEach(() => {
+ process.env = {
+ ...BASE_ENV,
+ BASE_BRANCH: "main",
+ };
+ });
+
+ test("should parse schedule event correctly", () => {
+ const mockScheduleContext = createMockContext({
+ eventName: "schedule",
+ payload: {
+ schedule: "0 0 * * *",
+ repository: {
+ name: "test-repo",
+ owner: {
+ login: "test-owner",
+ },
+ },
+ },
+ });
+
+ const result = prepareContext(
+ mockScheduleContext,
+ "",
+ "main",
+ undefined,
+ );
+
+ expect(result.repository).toBe("test-owner/test-repo");
+ expect(result.eventData.eventName).toBe("schedule");
+ expect(result.eventData.isPR).toBe(false);
+ expect(result.eventData.baseBranch).toBe("main");
+ // triggerUsername is not extracted for schedule events
+ expect(result.triggerUsername).toBeUndefined();
+ });
+ });
+
describe("issue_comment event", () => {
describe("on issue", () => {
beforeEach(() => {