* refactor: unify action into single composite step with run.ts entrypoint Consolidate the prepare and base-action phases into a single composite step that runs src/entrypoints/run.ts. This simplifies the action.yml from multiple steps to one execution step, while keeping the same behavior. Key changes: - Add src/entrypoints/run.ts as unified entrypoint - Simplify action.yml to single 'Run Claude Code Action' step - Pass all inputs via environment variables - Update base-action to accept inputs via env vars - Support agent mode auto-detection from prompt input * refactor: keep SSH signing cleanup and token revocation as separate action steps Move SSH signing key cleanup and app token revocation back to separate composite action steps in action.yml with always() conditions, rather than handling them inside run.ts. This keeps these cleanup concerns as independently visible steps in the workflow. * fix: address PR review feedback - Use path.dirname() instead of manual string slicing for executable path - Differentiate prepare vs execution errors in catch block so tracking comment accurately reflects which phase failed - Update CLAUDE.md architecture docs to reflect unified run.ts entrypoint and four-phase design * fix: address PR review feedback - Use path.dirname() instead of manual string slicing for executable path - Differentiate prepare vs execution errors in catch block so tracking comment accurately reflects which phase failed - Rewrite CLAUDE.md to focus on mental model, key concepts, and gotchas instead of exhaustive file listings
102 lines
2.6 KiB
TypeScript
102 lines
2.6 KiB
TypeScript
import type { GitHubContext } from "../github/context";
|
|
import type { PreparedContext } from "../create-prompt/types";
|
|
import type { FetchDataResult } from "../github/data/fetcher";
|
|
import type { Octokits } from "../github/api/client";
|
|
|
|
export type ModeName = "tag" | "agent";
|
|
|
|
export type ModeContext = {
|
|
mode: ModeName;
|
|
githubContext: GitHubContext;
|
|
commentId?: number;
|
|
baseBranch?: string;
|
|
claudeBranch?: string;
|
|
};
|
|
|
|
export type ModeData = {
|
|
commentId?: number;
|
|
baseBranch?: string;
|
|
claudeBranch?: string;
|
|
};
|
|
|
|
/**
|
|
* Mode interface for claude-code-action execution modes.
|
|
* Each mode defines its own behavior for trigger detection, prompt generation,
|
|
* and tracking comment creation.
|
|
*
|
|
* Current modes include:
|
|
* - 'tag': Interactive mode triggered by @claude mentions
|
|
* - 'agent': Direct automation mode triggered by explicit prompts
|
|
*/
|
|
export type Mode = {
|
|
name: ModeName;
|
|
description: string;
|
|
|
|
/**
|
|
* Determines if this mode should trigger based on the GitHub context
|
|
*/
|
|
shouldTrigger(context: GitHubContext): boolean;
|
|
|
|
/**
|
|
* Prepares the mode context with any additional data needed for prompt generation
|
|
*/
|
|
prepareContext(context: GitHubContext, data?: ModeData): ModeContext;
|
|
|
|
/**
|
|
* Returns the list of tools that should be allowed for this mode
|
|
*/
|
|
getAllowedTools(): string[];
|
|
|
|
/**
|
|
* Returns the list of tools that should be disallowed for this mode
|
|
*/
|
|
getDisallowedTools(): string[];
|
|
|
|
/**
|
|
* Determines if this mode should create a tracking comment
|
|
*/
|
|
shouldCreateTrackingComment(): boolean;
|
|
|
|
/**
|
|
* Generates the prompt for this mode.
|
|
* @returns The complete prompt string
|
|
*/
|
|
generatePrompt(
|
|
context: PreparedContext,
|
|
githubData: FetchDataResult,
|
|
useCommitSigning: boolean,
|
|
): string;
|
|
|
|
/**
|
|
* Prepares the GitHub environment for this mode.
|
|
* Each mode decides how to handle different event types.
|
|
* @returns PrepareResult with commentId, branchInfo, and mcpConfig
|
|
*/
|
|
prepare(options: ModeOptions): Promise<ModeResult>;
|
|
|
|
/**
|
|
* 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
|
|
export type ModeOptions = {
|
|
context: GitHubContext;
|
|
octokit: Octokits;
|
|
githubToken: string;
|
|
};
|
|
|
|
export type ModeResult = {
|
|
commentId?: number;
|
|
branchInfo: {
|
|
baseBranch: string;
|
|
claudeBranch?: string;
|
|
currentBranch: string;
|
|
};
|
|
mcpConfig: string;
|
|
claudeArgs: string;
|
|
};
|