Skip to content

cli: wire code search into entire search --code (ENT-994)#1617

Closed
evisdren wants to merge 4 commits into
evis/ent-993-code-search-clientfrom
evis/ent-994-code-search-command
Closed

cli: wire code search into entire search --code (ENT-994)#1617
evisdren wants to merge 4 commits into
evis/ent-993-code-search-clientfrom
evis/ent-994-code-search-command

Conversation

@evisdren

@evisdren evisdren commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/741

Summary

  • Adds --code and --case-sensitive flags to entire search, gated behind ENTIRE_CODE_SEARCH=1 env var
  • Uses cell auth (auth.NewEntireAPICellClient) matching existing patterns (onboarding, repo listing)
  • Grep-style text output: repo:path:line: context_line
  • Structured JSON with query echo, results, stats, repo_stats (agent-friendly)
  • Inline repo: filter parsing; repo:* and --all-repos → search all repos

Depends on: #1616

Files

  • cmd/entire/cli/search_cmd.go — command wiring, flags, output formatters
  • cmd/entire/cli/search_cmd_test.go — tests: gate, flag validation, text/JSON output, empty results

Test plan

  • go test ./cmd/entire/cli/ -run "TestSearchCmd|TestWriteCodeSearch|TestCodeSearch" passes
  • mise run lint clean
  • CI passes

🤖 Generated with Claude Code


Note

Medium Risk
New authenticated API path and feature flag wiring in a user-facing command; scope is limited to the --code branch and preview gating.

Overview
Adds a preview code search path to entire search via --code, gated on ENTIRE_CODE_SEARCH=1, with --case-sensitive allowed only in that mode.

When --code is set, the command branches early: it parses inline repo: filters (and treats repo:* / --all-repos as no repo filter), authenticates with the cell API client, calls codesearch.Search with a 30s timeout, and prints grep-style lines (repo:path:line: context) or JSON (query echo, results, stats, repo_stats). Checkpoint search behavior is unchanged when --code is not used; --limit help text now distinguishes per-page vs total for code search.

Tests cover the env gate, flag validation, and text/JSON/empty output helpers.

Reviewed by Cursor Bugbot for commit 23691c0. Configure here.

Adds --code and --case-sensitive flags to `entire search`, gated behind
ENTIRE_CODE_SEARCH=1 env var. Uses the codesearch client package to
call peregrine's search endpoint via cell auth.

- Grep-style text output: repo:path:line: context_line
- Structured JSON with query echo, results, stats, repo_stats
- Inline repo: filter parsing and repo:* → all repos
- 30s timeout on search call (auth resolved separately)
- Tests: gate, flag validation, text/JSON output, empty results

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 2, 2026 20:43
@evisdren evisdren requested a review from a team as a code owner July 2, 2026 20:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 23691c0. Configure here.

codeRepo := repoFlag
if codeRepo == "" && len(parsed.Repos) > 0 {
codeRepo = parsed.Repos[0]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Multiple repo filters silently ignored

Medium Severity

With --code, inline repo: filters are parsed into parsed.Repos, but only parsed.Repos[0] is applied. Checkpoint search rejects multiple repo filters via ValidateRepoFilters; the code path never validates the full slice, so queries like repo:foo/bar repo:baz/qux or repo:foo/bar,baz/qux search a single repo without error.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 23691c0. Configure here.

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.

Pull request overview

Adds a preview-gated code search mode to the hidden entire search command, routing --code queries through the new codesearch client (peregrine) while preserving existing checkpoint/commit/session search behavior.

Changes:

  • Adds --code (preview-gated by ENTIRE_CODE_SEARCH=1) and --case-sensitive flags to entire search, branching into a new code-search execution path.
  • Implements grep-style text rendering and a structured JSON output shape for code search results.
  • Adds unit tests covering the env gate, basic flag validation, and text/JSON output helpers for code search.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/search_cmd.go Wires --code into entire search, adds code-search execution + output formatters
cmd/entire/cli/search_cmd_test.go Adds tests for the code-search gate, validation, and output helpers

Comment on lines +60 to +83
if caseSensitive && !codeFlag {
return errors.New("--case-sensitive can only be used with --code")
}

if codeFlag {
// Parse inline repo: filters from the query for --code too.
parsed := search.ParseSearchInput(query)
codeRepo := repoFlag
if codeRepo == "" && len(parsed.Repos) > 0 {
codeRepo = parsed.Repos[0]
}
// repo:* means "all repos" — treat as no filter for code search.
if codeRepo == search.AllReposFilter || allReposFlag {
codeRepo = ""
}
return runCodeSearch(ctx, cmd, codeSearchOpts{
query: parsed.Query,
repoFilter: codeRepo,
limit: limitFlag,
caseSensitive: caseSensitive,
jsonOutput: jsonOutput,
insecureHTTP: insecureHTTPAuth,
})
}
evisdren and others added 3 commits July 2, 2026 14:22
When a repo filter is specified (--repo or inline repo:owner/name),
resolve the repo's owning cell via NewAuthenticatedEntireAPICellClient
so cross-region searches land in the correct jurisdiction. Without a
filter (all-repos), fall back to home-jurisdiction routing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the two-branch auth (repo filter → repo-scoped, else → home)
with a single NewAuthenticatedEntireAPICellClient call. When repoFilter
is empty, resolveExpertsCellTarget returns nil and the auth layer falls
back to home-jurisdiction routing automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When no repo filter is specified, mirror the BFF's multi-region search
pattern: list repos from the control plane to discover which cells host
the user's repos, group by cell/jurisdiction, create a cell client per
jurisdiction (jurisdictional token exchange), search each cell in
parallel with per-cell timeouts, and merge results.

When a repo filter IS specified, route to that repo's owning cell via
NewAuthenticatedEntireAPICellClient (single-cell path, no fan-out).

One bad cell never sinks the search — errors are logged and the cell's
results are skipped. Wall-clock duration tracks the slowest cell.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@evisdren

evisdren commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Folding into #1616 — single PR for ENT-993.

@evisdren evisdren closed this Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants