cli: wire code search into entire search --code (ENT-994)#1617
cli: wire code search into entire search --code (ENT-994)#1617evisdren wants to merge 4 commits into
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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] | ||
| } |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 23691c0. Configure here.
There was a problem hiding this comment.
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 byENTIRE_CODE_SEARCH=1) and--case-sensitiveflags toentire 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 |
| 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, | ||
| }) | ||
| } |
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>
|
Folding into #1616 — single PR for ENT-993. |


https://entire.io/gh/entireio/cli/trails/741
Summary
--codeand--case-sensitiveflags toentire search, gated behindENTIRE_CODE_SEARCH=1env varauth.NewEntireAPICellClient) matching existing patterns (onboarding, repo listing)repo:path:line: context_linerepo:filter parsing;repo:*and--all-repos→ search all reposDepends on: #1616
Files
cmd/entire/cli/search_cmd.go— command wiring, flags, output formatterscmd/entire/cli/search_cmd_test.go— tests: gate, flag validation, text/JSON output, empty resultsTest plan
go test ./cmd/entire/cli/ -run "TestSearchCmd|TestWriteCodeSearch|TestCodeSearch"passesmise run lintclean🤖 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
--codebranch and preview gating.Overview
Adds a preview code search path to
entire searchvia--code, gated onENTIRE_CODE_SEARCH=1, with--case-sensitiveallowed only in that mode.When
--codeis set, the command branches early: it parses inlinerepo:filters (and treatsrepo:*/--all-reposas no repo filter), authenticates with the cell API client, callscodesearch.Searchwith 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--codeis not used;--limithelp 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.