Simplify agent mode and re-add additional_permissions input

- Agent mode now only triggers when explicit prompt is provided
- Removed automatic triggering for workflow_dispatch/schedule without prompt
- Re-added additional_permissions input for requesting GitHub permissions
- Fixed TypeScript types for mock context helpers to properly handle partial inputs
- Updated documentation to reflect simplified mode behavior
This commit is contained in:
km-anthropic
2025-08-08 14:00:31 -07:00
parent e2aee89b4a
commit 1b4fc382c8
8 changed files with 75 additions and 41 deletions

View File

@@ -1,23 +1,22 @@
import * as core from "@actions/core";
import { mkdir, writeFile } from "fs/promises";
import type { Mode, ModeOptions, ModeResult } from "../types";
import { isAutomationContext } from "../../github/context";
import type { PreparedContext } from "../../create-prompt/types";
/**
* Agent mode implementation.
*
* This mode is specifically designed for automation events (workflow_dispatch and schedule).
* It bypasses the standard trigger checking and comment tracking used by tag mode,
* making it ideal for scheduled tasks and manual workflow runs.
* This mode runs whenever an explicit prompt is provided in the workflow configuration.
* It bypasses the standard @claude mention checking and comment tracking used by tag mode,
* providing direct access to Claude Code for automation workflows.
*/
export const agentMode: Mode = {
name: "agent",
description: "Automation mode for workflow_dispatch and schedule events",
description: "Direct automation mode for explicit prompts",
shouldTrigger(context) {
// Only trigger for automation events
return isAutomationContext(context);
// Only trigger when an explicit prompt is provided
return !!context.inputs?.prompt;
},
prepareContext(context) {
@@ -41,7 +40,7 @@ export const agentMode: Mode = {
},
async prepare({ context }: ModeOptions): Promise<ModeResult> {
// Agent mode handles automation events (workflow_dispatch, schedule) only
// Agent mode handles automation events and any event with explicit prompts
// TODO: handle by createPrompt (similar to tag and review modes)
// Create prompt directory

View File

@@ -9,13 +9,7 @@ import { checkContainsTrigger } from "../github/validation/trigger";
export type AutoDetectedMode = "tag" | "agent";
export function detectMode(context: GitHubContext): AutoDetectedMode {
// If prompt is provided, always use agent mode
// Reasoning: When users provide explicit instructions via the prompt parameter,
// they want Claude to execute those instructions immediately without waiting for
// @claude mentions or other triggers. This aligns with the v1.0 philosophy where
// Claude Code handles everything - the GitHub Action is just a thin wrapper that
// passes through prompts directly to Claude Code for native handling (including
// slash commands). This provides the most direct and flexible interaction model.
// If prompt is provided, use agent mode for direct execution
if (context.inputs?.prompt) {
return "agent";
}
@@ -38,7 +32,7 @@ export function detectMode(context: GitHubContext): AutoDetectedMode {
}
}
// Default to agent mode for everything else
// Default to agent mode (which won't trigger without a prompt)
return "agent";
}
@@ -47,7 +41,7 @@ export function getModeDescription(mode: AutoDetectedMode): string {
case "tag":
return "Interactive mode triggered by @claude mentions";
case "agent":
return "General automation mode for all events";
return "Direct automation mode for explicit prompts";
default:
return "Unknown mode";
}

View File

@@ -26,7 +26,7 @@ export type ModeData = {
*
* Current modes include:
* - 'tag': Interactive mode triggered by @claude mentions
* - 'agent': General automation mode for all events (default)
* - 'agent': Direct automation mode triggered by explicit prompts
*/
export type Mode = {
name: ModeName;