mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
Add mode support (#333)
* Add mode support * update "as any" with proper "as unknwon as ModeName" casting * Add documentation to README and registry.ts * Add tests for differen event types, integration flows, and error conditions * Clean up some tests * Minor test fix * Minor formatting test + switch from interface to type * correct the order of mkdir call * always configureGitAuth as there's already a fallback to handle null users by using the bot ID * simplify registry setup --------- Co-authored-by: km-anthropic <km-anthropic@users.noreply.github.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
import type { ParsedGitHubContext } from "../github/context";
|
||||
import type { CommonFields, PreparedContext, EventData } from "./types";
|
||||
import { GITHUB_SERVER_URL } from "../github/api/config";
|
||||
import type { Mode, ModeContext } from "../modes/types";
|
||||
export type { CommonFields, PreparedContext } from "./types";
|
||||
|
||||
const BASE_ALLOWED_TOOLS = [
|
||||
@@ -788,25 +789,30 @@ f. If you are unable to complete certain steps, such as running a linter or test
|
||||
}
|
||||
|
||||
export async function createPrompt(
|
||||
claudeCommentId: number,
|
||||
baseBranch: string | undefined,
|
||||
claudeBranch: string | undefined,
|
||||
mode: Mode,
|
||||
modeContext: ModeContext,
|
||||
githubData: FetchDataResult,
|
||||
context: ParsedGitHubContext,
|
||||
) {
|
||||
try {
|
||||
// Tag mode requires a comment ID
|
||||
if (mode.name === "tag" && !modeContext.commentId) {
|
||||
throw new Error("Tag mode requires a comment ID for prompt generation");
|
||||
}
|
||||
|
||||
// Prepare the context for prompt generation
|
||||
const preparedContext = prepareContext(
|
||||
context,
|
||||
claudeCommentId.toString(),
|
||||
baseBranch,
|
||||
claudeBranch,
|
||||
modeContext.commentId?.toString() || "",
|
||||
modeContext.baseBranch,
|
||||
modeContext.claudeBranch,
|
||||
);
|
||||
|
||||
await mkdir(`${process.env.RUNNER_TEMP}/claude-prompts`, {
|
||||
recursive: true,
|
||||
});
|
||||
|
||||
// Generate the prompt
|
||||
// Generate the prompt directly
|
||||
const promptContent = generatePrompt(
|
||||
preparedContext,
|
||||
githubData,
|
||||
|
||||
Reference in New Issue
Block a user