refactor: move allowedTools/disallowedTools parsing to parseGitHubContext

- Change allowedTools and disallowedTools from string to string[] in ParsedGitHubContext type
- Parse comma-separated environment variables into arrays in parseGitHubContext function
- Update create-prompt and install-mcp-server to use pre-parsed arrays
- Update all affected test files to use array syntax
- Eliminate duplicate parsing logic across the codebase
This commit is contained in:
Ashwin Bhat
2025-06-04 07:52:07 -07:00
parent 2c0d6b1a1e
commit c685888c3d
10 changed files with 89 additions and 90 deletions

View File

@@ -52,8 +52,10 @@ describe("prepareMcpConfig", () => {
owner: "test-owner",
repo: "test-repo",
branch: "test-branch",
allowedTools:
"mcp__github__create_issue,mcp__github_file_ops__commit_files",
allowedTools: [
"mcp__github__create_issue",
"mcp__github_file_ops__commit_files",
],
});
const parsed = JSON.parse(result);
@@ -71,8 +73,10 @@ describe("prepareMcpConfig", () => {
owner: "test-owner",
repo: "test-repo",
branch: "test-branch",
allowedTools:
"mcp__github_file_ops__commit_files,mcp__github_file_ops__update_claude_comment",
allowedTools: [
"mcp__github_file_ops__commit_files",
"mcp__github_file_ops__update_claude_comment",
],
});
const parsed = JSON.parse(result);
@@ -87,7 +91,7 @@ describe("prepareMcpConfig", () => {
owner: "test-owner",
repo: "test-repo",
branch: "test-branch",
allowedTools: "Edit,Read,Write",
allowedTools: ["Edit", "Read", "Write"],
});
const parsed = JSON.parse(result);
@@ -147,8 +151,10 @@ describe("prepareMcpConfig", () => {
repo: "test-repo",
branch: "test-branch",
additionalMcpConfig: additionalConfig,
allowedTools:
"mcp__github__create_issue,mcp__github_file_ops__commit_files",
allowedTools: [
"mcp__github__create_issue",
"mcp__github_file_ops__commit_files",
],
});
const parsed = JSON.parse(result);
@@ -182,8 +188,10 @@ describe("prepareMcpConfig", () => {
repo: "test-repo",
branch: "test-branch",
additionalMcpConfig: additionalConfig,
allowedTools:
"mcp__github__create_issue,mcp__github_file_ops__commit_files",
allowedTools: [
"mcp__github__create_issue",
"mcp__github_file_ops__commit_files",
],
});
const parsed = JSON.parse(result);