Skip to content

Add GCS_DEFAULT_ORG env var to avoid repeating --org on every invocation - #209

Merged
shouze merged 1 commit into
mainfrom
feat/gcs-default-org
Sep 19, 2026
Merged

shouze merged 1 commit into
mainfrom
feat/gcs-default-org

Conversation

@shouze

@shouze shouze commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Closes #207.

  • github-code-search.ts: switches --org from a Commander requiredOption to a regular Option using .env("GCS_DEFAULT_ORG") (native CLI > env var precedence). searchAction validates opts.org explicitly and exits with a clear error when neither --org nor GCS_DEFAULT_ORG is set.
  • Docs: docs/reference/environment.md (new GCS_DEFAULT_ORG row + section), docs/reference/cli-options.md (updated --org row/notes), README.md (quick-start tip), docs/getting-started/index.md / first-search.md (new "Default organization" section / prerequisite wording).

How did you verify your code works?

  • Manual smoke test: no --org/no GCS_DEFAULT_ORG → clear error; GCS_DEFAULT_ORG set + no --org → search proceeds (fails only on the fake token, confirming org resolution works); --help shows (env: GCS_DEFAULT_ORG).
  • bun test (1016 passing), bun run lint, bun run format:check, bun run knip, bun run build.ts all green.
  • bun run docs:build succeeds (VitePress dead-link check passes on the new #gcs_default_org anchor).

Copilot AI lite review requested due to automatic review settings September 19, 2026 11:08
@github-actions

Copy link
Copy Markdown
Contributor

Coverage after merging feat/gcs-default-org into main will be

96.86%

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.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.46%100%100%99.41%282
   group.ts98.92%100%98.33%99.03%263–265, 525, 531, 864
   output.ts99.38%100%95.83%99.66%88
   regex.ts99.42%100%100%99.38%360
   render.ts90.99%100%88.24%91.09%177, 201–206, 208–210, 212–213, 234, 427–428, 528–532, 562–569, 571–579, 581–584
   scroll-cooldown.ts100%100%100%100%
   style.ts100%100%100%100%
   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
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts99.42%100%100%99.38%239
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Documentation inaccurately claims an automatic gh auth token fallback and retains a mandatory --org synopsis.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 Low severity

Open (4)
What changed in this PR

Adds GCS_DEFAULT_ORG as a fallback for --org, with validation and documentation updates.

Changes:

  • Supports environment-based organization defaults.
  • Updates CLI, reference, README, and getting-started documentation.
  • Adjusts --org usage guidance and prerequisites.
File Summary
README.md Documents default-organization usage.
github-code-search.ts Adds environment fallback and validation.
docs/​reference/​environment.md Documents the new environment variable.
docs/​reference/​cli-options.md Updates --org behavior and examples.
docs/​getting-started/​index.md Adds default-organization guidance.
docs/​getting-started/​first-search.md Updates prerequisites.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md
```

> [!TIP]
> `GITHUB_TOKEN` falls back to `gh auth token` when unset and the [GitHub CLI](https://cli.github.com/) is installed and authenticated.

- `github-code-search` [installed](/getting-started/installation)
- `GITHUB_TOKEN` set in your environment ([see Prerequisites](/getting-started/))
- `GITHUB_TOKEN` set in your environment, or the [GitHub CLI](https://cli.github.com/) installed and authenticated ([see Prerequisites](/getting-started/))
:::

::: tip Already using the GitHub CLI?
If `GITHUB_TOKEN` isn't set and [`gh`](https://cli.github.com/) is installed and authenticated (`gh auth login`), `github-code-search` automatically retrieves a token via `gh auth token` — no extra setup needed.
| `public_repo` | Searching public repositories only |
| `read:org` | Using [`--group-by-team-prefix`](/usage/team-grouping) |

If `GITHUB_TOKEN` isn't set and the [GitHub CLI](https://cli.github.com/) (`gh`) is installed and authenticated, `github-code-search` automatically falls back to the token returned by `gh auth token` — no extra configuration needed.
--org is now a regular Commander option using .env("GCS_DEFAULT_ORG") for
CLI > env var precedence, instead of requiredOption. searchAction validates
presence explicitly and exits with a clear error when neither is set.

Closes #207
@shouze
shouze force-pushed the feat/gcs-default-org branch from d18ef90 to fb2f84b Compare September 19, 2026 11:10
@github-actions

Copy link
Copy Markdown
Contributor

Coverage after merging feat/gcs-default-org into main will be

96.86%

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.74%100%100%94.07%340–344, 405, 422, 63–69
   cache.ts94.67%100%100%94.29%139–141, 39
   completions.ts99.46%100%100%99.41%282
   group.ts98.92%100%98.33%99.03%263–265, 525, 531, 864
   output.ts99.38%100%95.83%99.66%88
   regex.ts99.42%100%100%99.38%360
   render.ts90.99%100%88.24%91.09%177, 201–206, 208–210, 212–213, 234, 427–428, 528–532, 562–569, 571–579, 581–584
   scroll-cooldown.ts100%100%100%100%
   style.ts100%100%100%100%
   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
   layout-constants.ts100%100%100%100%
   mouse-hit.ts100%100%100%100%
   mouse.ts100%100%100%100%
   rows.ts99.42%100%100%99.38%239
   selection.ts100%100%100%100%
   summary.ts100%100%100%100%
   team-pick.ts100%100%100%100%
   terminal.ts100%100%100%100%

@github-actions

Copy link
Copy Markdown
Contributor

🔦 Lighthouse Report

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

Thresholds: Perf ≥ 96 · A11y ≥ 99 · BP ≥ 99 · SEO ≥ 99
commit 5faddf0 · full workflow run

@shouze
shouze merged commit 3a937b3 into main Sep 19, 2026
8 checks passed
@shouze
shouze deleted the feat/gcs-default-org branch September 19, 2026 11:18
shouze added a commit that referenced this pull request Sep 19, 2026
…n rebase

These were silently reverted during the rebase onto post-#211 main (never
part of this PR's own diff before), since #211 removed the same wording
that was accidentally shared with #209. Re-add them here so they're
properly attributed to this PR.
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.

Add GCS_DEFAULT_ORG env var to avoid repeating --org on every invocation

2 participants