Parent epic: #146
Context and problem
Regex queries lose most of their expected results because the term sent to the GitHub API is too broad.
Reproduction: github-code-search '/"react":\s*"[~^]?[0-9]/' --org fulll returns only 2 results in the TUI, while the equivalent GitHub web search returns dozens of package.json files.
Root cause
longestLiteralSequence() in src/regex.ts only accumulates alphanumeric, underscore and hyphen characters. The double quote character always breaks the sequence, so the regex above currently yields the API term react, verified via direct API calls to return total_count 20288, mostly noise such as react-native, at-types react, docs and imports.
Solution
- Extend longestLiteralSequence() in src/regex.ts to accumulate the double quote character as a valid literal character.
- Before sending the extracted term to the API, escape each internal double quote and wrap the final term in double quotes, per GitHub's documented escaping syntax for quotes and backslashes.
- Keep the function pure, with no I/O, per AGENTS.md.
Acceptance criteria
- buildApiQuery for the pattern above produces an apiQuery equivalent to the escaped literal form, verified via direct API calls to return 117 to 126 results with zero noise.
- Existing cases without quotes remain unchanged, the existing src/regex.test.ts suite stays green.
- A new test covers the exact pattern from the reproduction and asserts the expected escaped apiQuery.
Definition of done
Files
- src/regex.ts
- src/regex.test.ts
Parent epic: #146
Context and problem
Regex queries lose most of their expected results because the term sent to the GitHub API is too broad.
Reproduction: github-code-search '/"react":\s*"[~^]?[0-9]/' --org fulll returns only 2 results in the TUI, while the equivalent GitHub web search returns dozens of package.json files.
Root cause
longestLiteralSequence() in src/regex.ts only accumulates alphanumeric, underscore and hyphen characters. The double quote character always breaks the sequence, so the regex above currently yields the API term react, verified via direct API calls to return total_count 20288, mostly noise such as react-native, at-types react, docs and imports.
Solution
Acceptance criteria
Definition of done
Files