Add --exclude-template-repositories option#120
Conversation
Adds a new CLI flag that filters out GitHub template repositories from search results. Template repos are marked with is_template in the GitHub API response. - Add isTemplate: boolean to CodeMatch in types.ts - Map is_template from GitHub API in api.ts - Add excludeTemplates param to aggregate() with guard - Thread excludeTemplates through output.ts (ReplayOptions, buildReplayCommand, buildOutput) - Add excludeTemplates param to runInteractive() in tui.ts - Register --exclude-template-repositories CLI flag and wire through searchAction in github-code-search.ts - Add shell completion entry in completions.ts - Add unit tests for the new filter in aggregate.test.ts - Update docs: filtering.md, cli-options.md, README.md Closes #116
|
Coverage after merging feat/exclude-template-repositories into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
🔦 Lighthouse Report
|
There was a problem hiding this comment.
Pull request overview
Adds a new CLI flag to exclude GitHub template repositories from results, wiring it through the fetch → aggregate → output/TUI pipeline and documenting the new behavior.
Changes:
- Extend
CodeMatchwith anisTemplateboolean and maprepository.is_templatefrom the GitHub API response. - Add
--exclude-template-repositoriesto CLI + shell completions, and filter template repos during aggregation. - Include the flag in the generated replay command and document it in README/docs.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Adds isTemplate to CodeMatch. |
| src/api.ts | Maps is_template → isTemplate when building CodeMatch. |
| src/aggregate.ts | Adds excludeTemplates parameter and filters template repos. |
| src/output.ts | Extends replay options/output to propagate excludeTemplates into replay command. |
| src/tui.ts | Threads excludeTemplates through interactive output generation. |
| src/completions.ts | Adds completion metadata for the new CLI flag. |
| github-code-search.ts | Registers CLI option and wires it into aggregation + TUI invocation. |
| src/aggregate.test.ts | Adds unit tests validating template filtering behavior. |
| docs/usage/filtering.md | Documents the new filtering flag and combining filters. |
| docs/reference/cli-options.md | Adds the new flag to the CLI options table. |
| README.md | Adds a usage example for skipping template repositories. |
- types.ts: make isTemplate optional (isTemplate?: boolean) to keep existing builders/fixtures valid without changes - output.ts: shell-quote groupByTeamPrefix in buildReplayCommand to prevent replay command breakage when the value contains spaces - output.test.ts: add tests for excludeTemplates flag in replay command; update groupByTeamPrefix assertion to reflect new shell-quoting - docs/usage/filtering.md: fix intro count (three → four filtering options); reword template info box to clarify filtering applies in both interactive and non-interactive mode
|
Coverage after merging feat/exclude-template-repositories into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- output.ts: shell-quote --org arg in buildReplayCommand for safety (org names with spaces/metacharacters could break the replay command) - output.test.ts: update --org assertion to expect quoted value - docs/usage/filtering.md: reword intro from 'pre-query filtering options' to 'result filtering options' since --include-archived and --exclude-template-repositories act after fetching, not before
|
Coverage after merging feat/exclude-template-repositories into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- aggregate.ts: use strict === true check for isTemplate (field is optional; falsy on undefined would silently skip the guard) - output.ts: shell-quote --exclude-extracts values in buildReplayCommand (file paths can contain spaces or shell metacharacters) - output.test.ts: update assertions to expect quoted values
|
Coverage after merging feat/exclude-template-repositories into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary
Implements #116 — adds a
--exclude-template-repositoriesflag to filter out GitHub template repositories from search results.Template repositories (marked with
is_template: truein the GitHub API) are often used for boilerplate and can clutter org-wide code searches. This flag allows excluding them, mirroring the existing--include-archivedpattern.Root cause / motivation
No built-in way existed to suppress template repos from results. The GitHub Code Search API returns
is_templateon the repository object, so the data is already available.What changed
src/types.tsisTemplate: booleantoCodeMatchsrc/api.tsis_templatefrom API response toisTemplatesrc/aggregate.tsexcludeTemplates = falseparameter; filters template repos in the main loopsrc/output.tsexcludeTemplates?toReplayOptions; appends--exclude-template-repositoriesto replay command; added tobuildOutputsrc/tui.tsexcludeTemplates = falsetorunInteractive(), passes tobuildOutputgithub-code-search.ts--exclude-template-repositoriesCLI flag, wired intoaggregate()andrunInteractive()src/completions.tssrc/aggregate.test.tsdocs/usage/filtering.md## --exclude-template-repositoriessectiondocs/reference/cli-options.mdREADME.mdHow to reproduce (before the fix)
Template repositories always appeared in search results with no way to exclude them.
How to verify (after the fix)
Template repos (those with
is_template: truein the GitHub API) are omitted from results. Without the flag, they continue to appear as before.The replay command correctly includes
--exclude-template-repositorieswhen the flag was used.Checklist
bun test— 676 tests passbun run lint— 0 errorsbun run format:check— no diffbun run knip— no unused exports