Format code with prettier

This commit is contained in:
km-anthropic
2025-08-13 09:54:57 -07:00
parent e3b5697276
commit d24561da51
4 changed files with 31 additions and 24 deletions

View File

@@ -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: [

View File

@@ -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);

View File

@@ -2,19 +2,19 @@ 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());
}
}

View File

@@ -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",