diff --git a/action.yml b/action.yml index 0fd6567..8bde037 100644 --- a/action.yml +++ b/action.yml @@ -201,7 +201,7 @@ runs: INPUT_MCP_CONFIG: ${{ steps.prepare.outputs.mcp_config }} INPUT_SETTINGS: ${{ inputs.settings }} INPUT_SYSTEM_PROMPT: "" - INPUT_APPEND_SYSTEM_PROMPT: "" + INPUT_APPEND_SYSTEM_PROMPT: ${{ env.APPEND_SYSTEM_PROMPT }} INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }} INPUT_CLAUDE_ENV: ${{ inputs.claude_env }} INPUT_FALLBACK_MODEL: ${{ inputs.fallback_model }} diff --git a/src/entrypoints/prepare.ts b/src/entrypoints/prepare.ts index 20373f2..b9995df 100644 --- a/src/entrypoints/prepare.ts +++ b/src/entrypoints/prepare.ts @@ -81,6 +81,19 @@ async function run() { // Set the MCP config output core.setOutput("mcp_config", result.mcpConfig); + + // Step 6: Get system prompt from mode if available + if (mode.getSystemPrompt) { + const modeContext = mode.prepareContext(context, { + commentId: result.commentId, + baseBranch: result.branchInfo.baseBranch, + claudeBranch: result.branchInfo.claudeBranch, + }); + const systemPrompt = mode.getSystemPrompt(modeContext); + if (systemPrompt) { + core.exportVariable("APPEND_SYSTEM_PROMPT", systemPrompt); + } + } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); core.setFailed(`Prepare step failed with error: ${errorMessage}`); diff --git a/src/modes/agent/index.ts b/src/modes/agent/index.ts index 94d247c..56f337f 100644 --- a/src/modes/agent/index.ts +++ b/src/modes/agent/index.ts @@ -112,4 +112,9 @@ export const agentMode: Mode = { // Minimal fallback - repository is a string in PreparedContext return `Repository: ${context.repository}`; }, + + getSystemPrompt() { + // Agent mode doesn't need additional system prompts + return undefined; + }, }; diff --git a/src/modes/review/index.ts b/src/modes/review/index.ts index fdc2033..4213c1c 100644 --- a/src/modes/review/index.ts +++ b/src/modes/review/index.ts @@ -349,4 +349,10 @@ This ensures users get value from the review even before checking individual inl mcpConfig, }; }, + + getSystemPrompt() { + // Review mode doesn't need additional system prompts + // The review-specific instructions are included in the main prompt + return undefined; + }, }; diff --git a/src/modes/tag/index.ts b/src/modes/tag/index.ts index 027682c..f9aabaf 100644 --- a/src/modes/tag/index.ts +++ b/src/modes/tag/index.ts @@ -130,4 +130,9 @@ export const tagMode: Mode = { ): string { return generateDefaultPrompt(context, githubData, useCommitSigning); }, + + getSystemPrompt() { + // Tag mode doesn't need additional system prompts + return undefined; + }, }; diff --git a/src/modes/types.ts b/src/modes/types.ts index a2344a9..f51f7fc 100644 --- a/src/modes/types.ts +++ b/src/modes/types.ts @@ -73,6 +73,13 @@ export type Mode = { * @returns PrepareResult with commentId, branchInfo, and mcpConfig */ prepare(options: ModeOptions): Promise; + + /** + * Returns an optional system prompt to append to Claude's base system prompt. + * This allows modes to add mode-specific instructions. + * @returns The system prompt string or undefined if no additional prompt is needed + */ + getSystemPrompt?(context: ModeContext): string | undefined; }; // Define types for mode prepare method