Skip to content

Add --exclude-template-repositories option#120

Merged
shouze merged 4 commits intomainfrom
feat/exclude-template-repositories
Mar 29, 2026
Merged

Add --exclude-template-repositories option#120
shouze merged 4 commits intomainfrom
feat/exclude-template-repositories

Conversation

@shouze
Copy link
Copy Markdown
Contributor

@shouze shouze commented Mar 29, 2026

Summary

Implements #116 — adds a --exclude-template-repositories flag to filter out GitHub template repositories from search results.

Template repositories (marked with is_template: true in the GitHub API) are often used for boilerplate and can clutter org-wide code searches. This flag allows excluding them, mirroring the existing --include-archived pattern.

Root cause / motivation

No built-in way existed to suppress template repos from results. The GitHub Code Search API returns is_template on the repository object, so the data is already available.

What changed

File Change
src/types.ts Added isTemplate: boolean to CodeMatch
src/api.ts Maps is_template from API response to isTemplate
src/aggregate.ts Added excludeTemplates = false parameter; filters template repos in the main loop
src/output.ts Added excludeTemplates? to ReplayOptions; appends --exclude-template-repositories to replay command; added to buildOutput
src/tui.ts Added excludeTemplates = false to runInteractive(), passes to buildOutput
github-code-search.ts Registered --exclude-template-repositories CLI flag, wired into aggregate() and runInteractive()
src/completions.ts Added shell completion entry
src/aggregate.test.ts Added two unit tests (filters when flag is true, keeps when false)
docs/usage/filtering.md New ## --exclude-template-repositories section
docs/reference/cli-options.md New table row for the flag
README.md New "Skip template repositories" usage example

How to reproduce (before the fix)

Template repositories always appeared in search results with no way to exclude them.

How to verify (after the fix)

github-code-search query "TODO" --org <your-org> --exclude-template-repositories

Template repos (those with is_template: true in the GitHub API) are omitted from results. Without the flag, they continue to appear as before.

The replay command correctly includes --exclude-template-repositories when the flag was used.

Checklist

  • bun test — 676 tests pass
  • bun run lint — 0 errors
  • bun run format:check — no diff
  • bun run knip — no unused exports
  • Aikido security scan — no issues

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
Copilot AI review requested due to automatic review settings March 29, 2026 20:06
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/exclude-template-repositories into main will be

96.37%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.40%100%100%99.34%264
   group.ts100%100%100%100%
   output.ts98.72%100%95%99.07%68, 96
   regex.ts99.26%100%100%99.21%251
   render.ts94.26%100%89.47%94.49%158, 182–187, 189–191, 193–194, 245–246, 267, 440–441, 523–527
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 29, 2026

🔦 Lighthouse Report

Page ⚡ Perf ♿ A11y 🛡️ BP 🔍 SEO Report
/github-code-search/getting-started/ 🟢 99 (≥97) 🟢 100 (≥99) 🟢 100 (≥99) 🟢 100 (≥99) 🔗 view
/github-code-search/ 🟢 98 (≥97) 🟢 100 (≥99) 🟢 100 (≥99) 🟢 100 (≥99) 🔗 view

Thresholds: Perf ≥ 97 · A11y ≥ 99 · BP ≥ 99 · SEO ≥ 99
commit c416aab · full workflow run

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CodeMatch with an isTemplate boolean and map repository.is_template from the GitHub API response.
  • Add --exclude-template-repositories to 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_templateisTemplate 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
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/exclude-template-repositories into main will be

96.41%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.40%100%100%99.34%264
   group.ts100%100%100%100%
   output.ts99.15%100%95%99.53%68
   regex.ts99.26%100%100%99.21%251
   render.ts94.26%100%89.47%94.49%158, 182–187, 189–191, 193–194, 245–246, 267, 440–441, 523–527
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

- 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
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/exclude-template-repositories into main will be

96.41%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.40%100%100%99.34%264
   group.ts100%100%100%100%
   output.ts99.16%100%95%99.54%70
   regex.ts99.26%100%100%99.21%251
   render.ts94.26%100%89.47%94.49%158, 182–187, 189–191, 193–194, 245–246, 267, 440–441, 523–527
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

- 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
@github-actions
Copy link
Copy Markdown

Coverage after merging feat/exclude-template-repositories into main will be

96.41%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   aggregate.ts100%100%100%100%
   api-utils.ts93.20%100%93.75%93.13%101–103, 65, 73, 86–87, 91–92
   api.ts94.57%100%100%93.89%319–323, 384, 401, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.40%100%100%99.34%264
   group.ts100%100%100%100%
   output.ts99.16%100%95%99.54%70
   regex.ts99.26%100%100%99.21%251
   render.ts94.26%100%89.47%94.49%158, 182–187, 189–191, 193–194, 245–246, 267, 440–441, 523–527
   upgrade.ts88.38%100%94.44%87.89%128, 131, 133, 153, 167–168, 188–195, 198–204, 209, 214, 250–253
src/render
   filter-match.ts97.44%100%92.31%100%
   filter.ts100%100%100%100%
   highlight.ts96.63%100%90.40%99.31%284–285
   rows.ts97.58%100%100%97.44%168, 54–55
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@shouze shouze merged commit fef097b into main Mar 29, 2026
13 checks passed
@shouze shouze deleted the feat/exclude-template-repositories branch March 29, 2026 21:34
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