From 85287e957da85d41d87fb98c923b81842e967d6c Mon Sep 17 00:00:00 2001 From: yoshikouki <53972292+yoshikouki@users.noreply.github.com> Date: Wed, 6 Aug 2025 03:14:28 +0900 Subject: [PATCH] fix: restore prompt file creation in agent mode (#405) - Restore prompt file creation logic that was accidentally removed in PR #374 - Agent mode now creates the prompt file directly in prepare() method - Uses override_prompt or direct_prompt if available, falls back to minimal prompt - Fixes 'Prompt file does not exist' error for workflow_dispatch and schedule events - Add TODO comment to refactor this to use createPrompt in the future Fixes #403 --- src/modes/agent/index.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/modes/agent/index.ts b/src/modes/agent/index.ts index 56f337f..9aeb8b3 100644 --- a/src/modes/agent/index.ts +++ b/src/modes/agent/index.ts @@ -1,4 +1,5 @@ import * as core from "@actions/core"; +import { mkdir, writeFile } from "fs/promises"; import type { Mode, ModeOptions, ModeResult } from "../types"; import { isAutomationContext } from "../../github/context"; import type { PreparedContext } from "../../create-prompt/types"; @@ -42,7 +43,23 @@ export const agentMode: Mode = { async prepare({ context }: ModeOptions): Promise { // Agent mode handles automation events (workflow_dispatch, schedule) only - // Agent mode doesn't need to create prompt files here - handled by createPrompt + // TODO: handle by createPrompt (similar to tag and review modes) + // Create prompt directory + await mkdir(`${process.env.RUNNER_TEMP}/claude-prompts`, { + recursive: true, + }); + // Write the prompt file - the base action requires a prompt_file parameter, + // so we must create this file even though agent mode typically uses + // override_prompt or direct_prompt. If neither is provided, we write + // a minimal prompt with just the repository information. + const promptContent = + context.inputs.overridePrompt || + context.inputs.directPrompt || + `Repository: ${context.repository.owner}/${context.repository.repo}`; + await writeFile( + `${process.env.RUNNER_TEMP}/claude-prompts/claude-prompt.txt`, + promptContent, + ); // Export tool environment variables for agent mode const baseTools = [