mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
Format code with prettier
This commit is contained in:
@@ -117,7 +117,11 @@ 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: [
|
||||
|
||||
@@ -48,7 +48,8 @@ export const agentMode: Mode = {
|
||||
});
|
||||
|
||||
// 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(
|
||||
@@ -61,9 +62,8 @@ export const agentMode: Mode = {
|
||||
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 || "";
|
||||
@@ -81,7 +81,8 @@ 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);
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ export function parseAllowedTools(claudeArgs: string): string[] {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ describe("parseAllowedTools", () => {
|
||||
});
|
||||
|
||||
test("handles multiple flags with allowedTools in middle", () => {
|
||||
const args = '--flag1 value1 --allowedTools "mcp__github__*" --flag2 value2';
|
||||
const args =
|
||||
'--flag1 value1 --allowedTools "mcp__github__*" --flag2 value2';
|
||||
expect(parseAllowedTools(args)).toEqual(["mcp__github__*"]);
|
||||
});
|
||||
|
||||
@@ -60,7 +61,8 @@ describe("parseAllowedTools", () => {
|
||||
});
|
||||
|
||||
test("handles tools with special characters", () => {
|
||||
const args = '--allowedTools "mcp__github__create_issue,mcp__github_comment__update"';
|
||||
const args =
|
||||
'--allowedTools "mcp__github__create_issue,mcp__github_comment__update"';
|
||||
expect(parseAllowedTools(args)).toEqual([
|
||||
"mcp__github__create_issue",
|
||||
"mcp__github_comment__update",
|
||||
|
||||
Reference in New Issue
Block a user