mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54: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:
56
src/modes/types.ts
Normal file
56
src/modes/types.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import type { ParsedGitHubContext } from "../github/context";
|
||||
import type { ModeName } from "./registry";
|
||||
|
||||
export type ModeContext = {
|
||||
mode: ModeName;
|
||||
githubContext: ParsedGitHubContext;
|
||||
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.
|
||||
*
|
||||
* Future modes might include:
|
||||
* - 'review': Optimized for code reviews without tracking comments
|
||||
* - 'freeform': For automation with no trigger checking
|
||||
*/
|
||||
export type Mode = {
|
||||
name: ModeName;
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Determines if this mode should trigger based on the GitHub context
|
||||
*/
|
||||
shouldTrigger(context: ParsedGitHubContext): boolean;
|
||||
|
||||
/**
|
||||
* Prepares the mode context with any additional data needed for prompt generation
|
||||
*/
|
||||
prepareContext(context: ParsedGitHubContext, data?: ModeData): ModeContext;
|
||||
|
||||
/**
|
||||
* Returns additional tools that should be allowed for this mode
|
||||
* (base GitHub tools are always included)
|
||||
*/
|
||||
getAllowedTools(): string[];
|
||||
|
||||
/**
|
||||
* Returns tools that should be disallowed for this mode
|
||||
*/
|
||||
getDisallowedTools(): string[];
|
||||
|
||||
/**
|
||||
* Determines if this mode should create a tracking comment
|
||||
*/
|
||||
shouldCreateTrackingComment(): boolean;
|
||||
};
|
||||
Reference in New Issue
Block a user