mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
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:
@@ -1,7 +1,7 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { getMode, isValidMode } from "../../src/modes/registry";
|
||||
import { agentMode } from "../../src/modes/agent";
|
||||
import { reviewMode } from "../../src/modes/review";
|
||||
import { tagMode } from "../../src/modes/tag";
|
||||
import { createMockContext, createMockAutomationContext } from "../mockContext";
|
||||
|
||||
describe("Mode Registry", () => {
|
||||
@@ -36,11 +36,7 @@ describe("Mode Registry", () => {
|
||||
expect(mode.name).toBe("agent");
|
||||
});
|
||||
|
||||
test("getMode can use explicit mode override for review", () => {
|
||||
const mode = getMode(mockContext, "review");
|
||||
expect(mode).toBe(reviewMode);
|
||||
expect(mode.name).toBe("experimental-review");
|
||||
});
|
||||
// Removed test - explicit mode override no longer supported in v1.0
|
||||
|
||||
test("getMode auto-detects agent for workflow_dispatch", () => {
|
||||
const mode = getMode(mockWorkflowDispatchContext);
|
||||
@@ -54,37 +50,64 @@ describe("Mode Registry", () => {
|
||||
expect(mode.name).toBe("agent");
|
||||
});
|
||||
|
||||
test("getMode supports legacy experimental-review mode name", () => {
|
||||
const mode = getMode(mockContext, "experimental-review");
|
||||
expect(mode).toBe(reviewMode);
|
||||
expect(mode.name).toBe("experimental-review");
|
||||
});
|
||||
// Removed test - legacy mode names no longer supported in v1.0
|
||||
|
||||
test("getMode auto-detects review mode for PR opened", () => {
|
||||
test("getMode auto-detects agent mode for PR opened", () => {
|
||||
const prContext = createMockContext({
|
||||
eventName: "pull_request",
|
||||
payload: { action: "opened" } as any,
|
||||
isPR: true,
|
||||
});
|
||||
const mode = getMode(prContext);
|
||||
expect(mode).toBe(reviewMode);
|
||||
expect(mode.name).toBe("experimental-review");
|
||||
});
|
||||
|
||||
test("getMode falls back to auto-detection for invalid mode override", () => {
|
||||
const mode = getMode(mockContext, "invalid");
|
||||
// Should fall back to auto-detection, which returns agent for issue_comment without trigger
|
||||
expect(mode).toBe(agentMode);
|
||||
expect(mode.name).toBe("agent");
|
||||
});
|
||||
|
||||
test("getMode uses agent mode when prompt is provided, even with @claude mention", () => {
|
||||
const contextWithPrompt = createMockContext({
|
||||
eventName: "issue_comment",
|
||||
payload: {
|
||||
action: "created",
|
||||
comment: {
|
||||
body: "@claude please help",
|
||||
},
|
||||
} as any,
|
||||
inputs: {
|
||||
prompt: "/review",
|
||||
} as any,
|
||||
});
|
||||
const mode = getMode(contextWithPrompt);
|
||||
expect(mode).toBe(agentMode);
|
||||
expect(mode.name).toBe("agent");
|
||||
});
|
||||
|
||||
test("getMode uses tag mode for @claude mention without prompt", () => {
|
||||
const contextWithMention = createMockContext({
|
||||
eventName: "issue_comment",
|
||||
payload: {
|
||||
action: "created",
|
||||
comment: {
|
||||
body: "@claude please help",
|
||||
},
|
||||
} as any,
|
||||
inputs: {
|
||||
triggerPhrase: "@claude",
|
||||
} as any,
|
||||
});
|
||||
const mode = getMode(contextWithMention);
|
||||
expect(mode).toBe(tagMode);
|
||||
expect(mode.name).toBe("tag");
|
||||
});
|
||||
|
||||
// Removed test - explicit mode override no longer supported in v1.0
|
||||
|
||||
test("isValidMode returns true for all valid modes", () => {
|
||||
expect(isValidMode("tag")).toBe(true);
|
||||
expect(isValidMode("agent")).toBe(true);
|
||||
expect(isValidMode("experimental-review")).toBe(true);
|
||||
});
|
||||
|
||||
test("isValidMode returns false for invalid mode", () => {
|
||||
expect(isValidMode("invalid")).toBe(false);
|
||||
expect(isValidMode("review")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user