feat: simplify to two modes (tag and agent) for v1.0

BREAKING CHANGES:
- Remove review mode entirely - now handled via slash commands in agent mode
- Remove all deprecated backward compatibility fields (mode, anthropic_model, override_prompt, direct_prompt)
- Simplify mode detection: prompt overrides everything, then @claude mentions trigger tag mode, default is agent mode
- Remove slash command resolution from GitHub Action - Claude Code handles natively
- Remove variable substitution - prompts passed through as-is

Architecture changes:
- Only two modes now: tag (for @claude mentions) and agent (everything else)
- Agent mode is the default for all events including PRs
- Users configure behavior via prompts/slash commands (e.g. /review)
- GitHub Action is now a thin wrapper that passes prompts to Claude Code
- Mode names changed: 'experimental-review' → removed entirely

This aligns with the philosophy that the GitHub Action should do minimal work and delegate to Claude Code for all intelligent behavior.
This commit is contained in:
km-anthropic
2025-08-07 11:07:50 -07:00
parent da182b6afb
commit acbef8d08c
18 changed files with 125 additions and 728 deletions

View File

@@ -8,11 +8,10 @@
import type { Mode, ModeName } from "./types";
import { tagMode } from "./tag";
import { agentMode } from "./agent";
import { reviewMode } from "./review";
import type { GitHubContext } from "../github/context";
import { detectMode, type AutoDetectedMode } from "./detector";
export const VALID_MODES = ["tag", "agent", "review"] as const;
export const VALID_MODES = ["tag", "agent"] as const;
/**
* All available modes in v1.0
@@ -20,28 +19,19 @@ export const VALID_MODES = ["tag", "agent", "review"] as const;
const modes = {
tag: tagMode,
agent: agentMode,
review: reviewMode,
} as const satisfies Record<AutoDetectedMode, Mode>;
/**
* Automatically detects and retrieves the appropriate mode based on the GitHub context.
* In v1.0, modes are auto-selected based on event type.
* @param context The GitHub context
* @param explicitMode Optional explicit mode override (for backward compatibility)
* @returns The appropriate mode for the context
*/
export function getMode(context: GitHubContext, explicitMode?: string): Mode {
let modeName: AutoDetectedMode;
if (explicitMode && isValidModeV1(explicitMode)) {
console.log(`Using explicit mode: ${explicitMode}`);
modeName = mapLegacyMode(explicitMode);
} else {
modeName = detectMode(context);
console.log(
`Auto-detected mode: ${modeName} for event: ${context.eventName}`,
);
}
export function getMode(context: GitHubContext): Mode {
const modeName = detectMode(context);
console.log(
`Auto-detected mode: ${modeName} for event: ${context.eventName}`,
);
const mode = modes[modeName];
if (!mode) {
@@ -54,29 +44,11 @@ export function getMode(context: GitHubContext, explicitMode?: string): Mode {
}
/**
* Maps legacy mode names to v1.0 mode names
*/
function mapLegacyMode(name: string): AutoDetectedMode {
if (name === "experimental-review") {
return "review";
}
return name as AutoDetectedMode;
}
/**
* Type guard to check if a string is a valid v1.0 mode name.
* Type guard to check if a string is a valid mode name.
* @param name The string to check
* @returns True if the name is a valid mode name
*/
export function isValidModeV1(name: string): boolean {
const v1Modes = ["tag", "agent", "review", "experimental-review"];
return v1Modes.includes(name);
}
/**
* Legacy type guard for backward compatibility
* @deprecated Use auto-detection instead
*/
export function isValidMode(name: string): name is ModeName {
return isValidModeV1(name);
const validModes = ["tag", "agent"];
return validModes.includes(name);
}