Issue Title
parseAllowedTools() regex pattern order causes wrong flag to be matched with mixed quotes
Issue Body
Bug Description
parseAllowedTools() in src/modes/agent/parse-tools.ts checks regex patterns in a specific order:
- Double-quoted:
--allowed-tools "value"
- Single-quoted:
--allowed-tools 'value'
- Unquoted:
--allowed-tools value
This means if the input has mixed quote styles, it matches the first occurrence of the quote style checked first, not the first --allowed-tools flag in the string.
Reproduction
const input = `--allowed-tools 'mcp__github_inline_comment__create_inline_comment'
--allowed-tools 'mcp__context7__*'
--allowed-tools "Write,Edit,MultiEdit"`;
parseAllowedTools(input);
// Expected: ['mcp__github_inline_comment__create_inline_comment']
// Actual: ['Write', 'Edit', 'MultiEdit']
Even though mcp__github_inline_comment__* is the FIRST flag in the string, the double-quoted pattern is checked first and matches "Write,Edit,MultiEdit".
Impact
This breaks the workaround for #800 (putting mcp__github_* tools first). Users must also ensure they use double quotes for the first flag, which is non-obvious.
The MCP server initialization depends on parseAllowedTools() finding mcp__github_* tools. When it finds the wrong value, the github_inline_comment server is not configured, and the tool becomes unavailable.
Workaround
Use double quotes for the mcp__github_* tools:
claude_args: |
--allowed-tools "mcp__github_inline_comment__create_inline_comment" # Double quotes!
--allowed-tools 'mcp__context7__*'
--allowed-tools "Write,Edit,MultiEdit"
Suggested Fix
Option 1: Find the actual first --allowed-tools in the string regardless of quote style:
const allPatterns = /--(?:allowedTools|allowed-tools)\s+(?:"([^"]+)"|'([^']+)'|([^\s]+))/g;
// Find the match with the smallest index
Option 2: The fix in PR #801 (parsing ALL flags) would also solve this, since all values would be accumulated.
Related Issues
Issue Title
parseAllowedTools() regex pattern order causes wrong flag to be matched with mixed quotes
Issue Body
Bug Description
parseAllowedTools()insrc/modes/agent/parse-tools.tschecks regex patterns in a specific order:--allowed-tools "value"--allowed-tools 'value'--allowed-tools valueThis means if the input has mixed quote styles, it matches the first occurrence of the quote style checked first, not the first
--allowed-toolsflag in the string.Reproduction
Even though
mcp__github_inline_comment__*is the FIRST flag in the string, the double-quoted pattern is checked first and matches"Write,Edit,MultiEdit".Impact
This breaks the workaround for #800 (putting
mcp__github_*tools first). Users must also ensure they use double quotes for the first flag, which is non-obvious.The MCP server initialization depends on
parseAllowedTools()findingmcp__github_*tools. When it finds the wrong value, thegithub_inline_commentserver is not configured, and the tool becomes unavailable.Workaround
Use double quotes for the
mcp__github_*tools:Suggested Fix
Option 1: Find the actual first
--allowed-toolsin the string regardless of quote style:Option 2: The fix in PR #801 (parsing ALL flags) would also solve this, since all values would be accumulated.
Related Issues
parseAllowedTools()only parses first--allowed-toolsflag, breaking GitHub MCP server initialization #800 - Original report about only parsing first flag