Accept multiline input for allowed_tools and disallowed_tools (#168)

This commit is contained in:
Hidetake Iwata
2025-06-13 23:19:36 +09:00
committed by GitHub
parent a8d323af27
commit 67d7753c80
3 changed files with 76 additions and 10 deletions

View File

@@ -52,14 +52,8 @@ export function parseGitHubContext(): ParsedGitHubContext {
inputs: {
triggerPhrase: process.env.TRIGGER_PHRASE ?? "@claude",
assigneeTrigger: process.env.ASSIGNEE_TRIGGER ?? "",
allowedTools: (process.env.ALLOWED_TOOLS ?? "")
.split(",")
.map((tool) => tool.trim())
.filter((tool) => tool.length > 0),
disallowedTools: (process.env.DISALLOWED_TOOLS ?? "")
.split(",")
.map((tool) => tool.trim())
.filter((tool) => tool.length > 0),
allowedTools: parseMultilineInput(process.env.ALLOWED_TOOLS ?? ""),
disallowedTools: parseMultilineInput(process.env.DISALLOWED_TOOLS ?? ""),
customInstructions: process.env.CUSTOM_INSTRUCTIONS ?? "",
directPrompt: process.env.DIRECT_PROMPT ?? "",
baseBranch: process.env.BASE_BRANCH,
@@ -116,6 +110,14 @@ export function parseGitHubContext(): ParsedGitHubContext {
}
}
export function parseMultilineInput(s: string): string[] {
return s
.split(/,|[\n\r]+/)
.map((tool) => tool.replace(/#.+$/, ""))
.map((tool) => tool.trim())
.filter((tool) => tool.length > 0);
}
export function isIssuesEvent(
context: ParsedGitHubContext,
): context is ParsedGitHubContext & { payload: IssuesEvent } {