mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
Format code with prettier
This commit is contained in:
@@ -68,7 +68,7 @@ export async function prepareMcpConfig(
|
||||
const hasGitHubMcpTools = allowedToolsList.some((tool) =>
|
||||
tool.startsWith("mcp__github__"),
|
||||
);
|
||||
|
||||
|
||||
const hasInlineCommentTools = allowedToolsList.some((tool) =>
|
||||
tool.startsWith("mcp__github_inline_comment__"),
|
||||
);
|
||||
@@ -115,9 +115,13 @@ export async function prepareMcpConfig(
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Include inline comment server for PRs when requested via allowed tools
|
||||
if (isEntityContext(context) && context.isPR && (hasGitHubMcpTools || hasInlineCommentTools)) {
|
||||
if (
|
||||
isEntityContext(context) &&
|
||||
context.isPR &&
|
||||
(hasGitHubMcpTools || hasInlineCommentTools)
|
||||
) {
|
||||
baseMcpConfig.mcpServers.github_inline_comment = {
|
||||
command: "bun",
|
||||
args: [
|
||||
|
||||
@@ -46,11 +46,12 @@ export const agentMode: Mode = {
|
||||
await mkdir(`${process.env.RUNNER_TEMP}/claude-prompts`, {
|
||||
recursive: true,
|
||||
});
|
||||
|
||||
|
||||
// Write the prompt file - use the user's prompt directly
|
||||
const promptContent = context.inputs.prompt ||
|
||||
const promptContent =
|
||||
context.inputs.prompt ||
|
||||
`Repository: ${context.repository.owner}/${context.repository.repo}`;
|
||||
|
||||
|
||||
await writeFile(
|
||||
`${process.env.RUNNER_TEMP}/claude-prompts/claude-prompt.txt`,
|
||||
promptContent,
|
||||
@@ -59,12 +60,11 @@ export const agentMode: Mode = {
|
||||
// Parse allowed tools from user's claude_args
|
||||
const userClaudeArgs = process.env.CLAUDE_ARGS || "";
|
||||
const allowedTools = parseAllowedTools(userClaudeArgs);
|
||||
|
||||
|
||||
// Detect current branch from GitHub environment
|
||||
const currentBranch = process.env.GITHUB_HEAD_REF ||
|
||||
process.env.GITHUB_REF_NAME ||
|
||||
"main";
|
||||
|
||||
const currentBranch =
|
||||
process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || "main";
|
||||
|
||||
// Get MCP configuration with GitHub servers when requested
|
||||
const additionalMcpConfig = process.env.MCP_CONFIG || "";
|
||||
const mcpConfig = await prepareMcpConfig({
|
||||
@@ -81,8 +81,9 @@ export const agentMode: Mode = {
|
||||
|
||||
// Build final claude_args
|
||||
const escapedMcpConfig = mcpConfig.replace(/'/g, "'\\''");
|
||||
const claudeArgs = `--mcp-config '${escapedMcpConfig}' ${userClaudeArgs}`.trim();
|
||||
|
||||
const claudeArgs =
|
||||
`--mcp-config '${escapedMcpConfig}' ${userClaudeArgs}`.trim();
|
||||
|
||||
core.setOutput("claude_args", claudeArgs);
|
||||
|
||||
return {
|
||||
|
||||
@@ -2,21 +2,21 @@ export function parseAllowedTools(claudeArgs: string): string[] {
|
||||
// Match --allowedTools followed by the value
|
||||
// Handle both quoted and unquoted values
|
||||
const patterns = [
|
||||
/--allowedTools\s+"([^"]+)"/, // Double quoted
|
||||
/--allowedTools\s+'([^']+)'/, // Single quoted
|
||||
/--allowedTools\s+([^\s]+)/, // Unquoted
|
||||
/--allowedTools\s+"([^"]+)"/, // Double quoted
|
||||
/--allowedTools\s+'([^']+)'/, // Single quoted
|
||||
/--allowedTools\s+([^\s]+)/, // Unquoted
|
||||
];
|
||||
|
||||
|
||||
for (const pattern of patterns) {
|
||||
const match = claudeArgs.match(pattern);
|
||||
if (match && match[1]) {
|
||||
// Don't return if the value starts with -- (another flag)
|
||||
if (match[1].startsWith('--')) {
|
||||
if (match[1].startsWith("--")) {
|
||||
return [];
|
||||
}
|
||||
return match[1].split(',').map(t => t.trim());
|
||||
return match[1].split(",").map((t) => t.trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user