Skip to content

fix: Centralize filename regex into shared patterns module#19

Merged
KHAEntertainment merged 2 commits intofeature/grok-swarm-agentfrom
copilot/sub-pr-16
Mar 21, 2026
Merged

fix: Centralize filename regex into shared patterns module#19
KHAEntertainment merged 2 commits intofeature/grok-swarm-agentfrom
copilot/sub-pr-16

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 21, 2026

grok_bridge.py and grok_agent.py had divergent filename_pattern regexes — the bridge included jsx|tsx|sh|bash while the agent did not, causing inconsistent code-block parsing across the two modules.

Changes

  • src/shared/patterns.py (new): Canonical SUPPORTED_EXTENSIONS string and get_filename_pattern_string() returning the unified regex
  • src/shared/__init__.py (new): Package marker for the shared module
  • Both grok_bridge.py and grok_agent.py were already updated (prior commits) to import from this module; this PR supplies the missing implementation

Result

# src/shared/patterns.py
SUPPORTED_EXTENSIONS = (
    "py|js|ts|jsx|tsx|go|rs|java|c|cpp|h|hpp|cs|rb|php|swift|kt|scala|sh|bash"
)

def get_filename_pattern_string() -> str:
    return r"^\s*#\s*([a-zA-Z_][a-zA-Z0-9_]*\.(?:" + SUPPORTED_EXTENSIONS + r"))\s*$"

Both modules now compile the identical regex from a single source; extension list changes need to be made in exactly one place.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…tern_string()

Co-authored-by: KHAEntertainment <43256680+KHAEntertainment@users.noreply.github.com>
Agent-Logs-Url: https://github.com/KHAEntertainment/grok-multiagent-plugin/sessions/c147bc88-9dac-4881-9e47-f0f87afc51d0
Copilot AI changed the title [WIP] [WIP] Fix filename pattern inconsistency in grok_bridge.py and grok_agent.py fix: Centralize filename regex into shared patterns module Mar 21, 2026
Copilot AI requested a review from KHAEntertainment March 21, 2026 05:21
@KHAEntertainment KHAEntertainment marked this pull request as ready for review March 21, 2026 05:23
@KHAEntertainment KHAEntertainment merged commit 4d460a4 into feature/grok-swarm-agent Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants