This commit is contained in:
km-anthropic
2025-08-07 15:48:07 -07:00
parent a7759cfcd1
commit f2775d66df
4 changed files with 21 additions and 15 deletions

View File

@@ -72,7 +72,7 @@ export function prepareRunConfig(
// Build arguments in correct order: // Build arguments in correct order:
// 1. -p flag for prompt via pipe // 1. -p flag for prompt via pipe
const claudeArgs = ["-p"]; const claudeArgs = ["-p"];
// 2. User's custom arguments (can override defaults) // 2. User's custom arguments (can override defaults)
if (options.claudeArgs && options.claudeArgs.trim() !== "") { if (options.claudeArgs && options.claudeArgs.trim() !== "") {
const parsed = parseShellArgs(options.claudeArgs); const parsed = parseShellArgs(options.claudeArgs);
@@ -81,7 +81,7 @@ export function prepareRunConfig(
); );
claudeArgs.push(...customArgs); claudeArgs.push(...customArgs);
} }
// 3. Legacy specific options for backward compatibility // 3. Legacy specific options for backward compatibility
// These will eventually be removed in favor of claudeArgs // These will eventually be removed in favor of claudeArgs
if (options.allowedTools) { if (options.allowedTools) {
@@ -108,7 +108,7 @@ export function prepareRunConfig(
if (options.model) { if (options.model) {
claudeArgs.push("--model", options.model); claudeArgs.push("--model", options.model);
} }
// 4. Base args always at the end // 4. Base args always at the end
claudeArgs.push(...BASE_ARGS); claudeArgs.push(...BASE_ARGS);

View File

@@ -4,7 +4,7 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
prompt: prompt:
description: 'Prompt for Claude' description: "Prompt for Claude"
required: true required: true
type: string type: string
@@ -13,14 +13,14 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Run Claude with custom arguments - name: Run Claude with custom arguments
uses: anthropics/claude-code-action@v1 uses: anthropics/claude-code-action@v1
with: with:
mode: agent mode: agent
prompt: ${{ github.event.inputs.prompt }} prompt: ${{ github.event.inputs.prompt }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# New claudeArgs input allows direct CLI argument control # New claudeArgs input allows direct CLI argument control
# Arguments are passed in the order: -p [claudeArgs] [legacy options] [BASE_ARGS] # Arguments are passed in the order: -p [claudeArgs] [legacy options] [BASE_ARGS]
claude_args: | claude_args: |
@@ -28,4 +28,4 @@ jobs:
--model claude-3-opus-20240229 --model claude-3-opus-20240229
--allowedTools Edit,Read,Write,Bash --allowedTools Edit,Read,Write,Bash
--disallowedTools WebSearch --disallowedTools WebSearch
--system-prompt "You are a senior engineer focused on code quality" --system-prompt "You are a senior engineer focused on code quality"

View File

@@ -41,10 +41,10 @@ export function buildAllowedToolsString(
): string { ): string {
// Tag mode needs these tools to function properly // Tag mode needs these tools to function properly
let baseTools = [...BASE_ALLOWED_TOOLS]; let baseTools = [...BASE_ALLOWED_TOOLS];
// Always include the comment update tool for tag mode // Always include the comment update tool for tag mode
baseTools.push("mcp__github_comment__update_claude_comment"); baseTools.push("mcp__github_comment__update_claude_comment");
// Add commit signing tools if enabled // Add commit signing tools if enabled
if (useCommitSigning) { if (useCommitSigning) {
baseTools.push( baseTools.push(
@@ -63,7 +63,7 @@ export function buildAllowedToolsString(
"Bash(git rm:*)", "Bash(git rm:*)",
); );
} }
// Add GitHub Actions MCP tools if enabled // Add GitHub Actions MCP tools if enabled
if (includeActionsTools) { if (includeActionsTools) {
baseTools.push( baseTools.push(
@@ -72,7 +72,7 @@ export function buildAllowedToolsString(
"mcp__github_ci__download_job_log", "mcp__github_ci__download_job_log",
); );
} }
let allAllowedTools = baseTools.join(","); let allAllowedTools = baseTools.join(",");
if (customAllowedTools && customAllowedTools.length > 0) { if (customAllowedTools && customAllowedTools.length > 0) {
allAllowedTools = `${allAllowedTools},${customAllowedTools.join(",")}`; allAllowedTools = `${allAllowedTools},${customAllowedTools.join(",")}`;
@@ -86,14 +86,14 @@ export function buildDisallowedToolsString(
): string { ): string {
// Tag mode: Disable WebSearch and WebFetch by default for security // Tag mode: Disable WebSearch and WebFetch by default for security
let disallowedTools = ["WebSearch", "WebFetch"]; let disallowedTools = ["WebSearch", "WebFetch"];
// If user has explicitly allowed some default disallowed tools, remove them // If user has explicitly allowed some default disallowed tools, remove them
if (allowedTools && allowedTools.length > 0) { if (allowedTools && allowedTools.length > 0) {
disallowedTools = disallowedTools.filter( disallowedTools = disallowedTools.filter(
(tool) => !allowedTools.includes(tool), (tool) => !allowedTools.includes(tool),
); );
} }
let allDisallowedTools = disallowedTools.join(","); let allDisallowedTools = disallowedTools.join(",");
if (customDisallowedTools && customDisallowedTools.length > 0) { if (customDisallowedTools && customDisallowedTools.length > 0) {
if (allDisallowedTools) { if (allDisallowedTools) {

View File

@@ -62,10 +62,16 @@ export const agentMode: Mode = {
// No default tools are enforced - Claude Code's defaults will apply // No default tools are enforced - Claude Code's defaults will apply
// Export user-specified tools only if provided // Export user-specified tools only if provided
if (context.inputs.allowedTools.length > 0) { if (context.inputs.allowedTools.length > 0) {
core.exportVariable("INPUT_ALLOWED_TOOLS", context.inputs.allowedTools.join(",")); core.exportVariable(
"INPUT_ALLOWED_TOOLS",
context.inputs.allowedTools.join(","),
);
} }
if (context.inputs.disallowedTools.length > 0) { if (context.inputs.disallowedTools.length > 0) {
core.exportVariable("INPUT_DISALLOWED_TOOLS", context.inputs.disallowedTools.join(",")); core.exportVariable(
"INPUT_DISALLOWED_TOOLS",
context.inputs.disallowedTools.join(","),
);
} }
// Agent mode uses a minimal MCP configuration // Agent mode uses a minimal MCP configuration