search

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package search provides search functionality via the Entire search service.

Index

Constants

View Source
const (
	TypeCheckpoint = "checkpoint"
	TypeCommit     = "commit"
	TypeSession    = "session"
)

Result type constants.

View Source
const AllReposFilter = "*"

AllReposFilter is the inline repo filter value that disables repo scoping.

View Source
const DefaultLimit = 100

DefaultLimit is the default number of results to fetch per request, matching the UI.

View Source
const DefaultServiceURL = "https://entire.io"

DefaultServiceURL is the production search service URL.

View Source
const MaxLimit = 200

MaxLimit is the maximum number of results the search API will return per request.

View Source
const WildcardQuery = "*"

WildcardQuery is the query string used when only filters are provided (no search terms).

Variables

This section is empty.

Functions

func ParseGitHubRemote

func ParseGitHubRemote(remoteURL string) (owner, repo string, err error)

ParseGitHubRemote extracts owner and repo from a git remote URL that resolves to GitHub. It accepts direct GitHub remotes (SCP-style SSH, ssh://, and https://) as well as Entire mirror remotes (entire://host/gh/owner/repo), whose forge prefix maps back to github.com. Remotes resolving to any other host, or whose path holds extra segments beyond owner/repo, are rejected.

func ValidateRepoFilters

func ValidateRepoFilters(repos []string) error

ValidateRepoFilters ensures repo filters match backend semantics.

Types

type CheckpointResult

type CheckpointResult struct {
	ID             string   `json:"id"`
	Prompt         string   `json:"prompt"`
	CommitMessage  *string  `json:"commitMessage"`
	CommitSubject  *string  `json:"commitSubject"`
	CommitSHA      *string  `json:"commitSha"`
	Branch         string   `json:"branch"`
	Org            string   `json:"org"`
	Repo           string   `json:"repo"`
	Author         string   `json:"author"`
	AuthorUsername *string  `json:"authorUsername"`
	CreatedAt      string   `json:"createdAt"`
	FilesTouched   []string `json:"filesTouched"`
}

CheckpointResult represents a checkpoint returned by the search service.

type CommitResult added in v0.7.6

type CommitResult struct {
	ID             string  `json:"id"`
	CommitSHA      string  `json:"commitSha"`
	CommitMessage  string  `json:"commitMessage"`
	CommitSubject  string  `json:"commitSubject"`
	Branch         string  `json:"branch"`
	Org            string  `json:"org"`
	Repo           string  `json:"repo"`
	Author         string  `json:"author"`
	AuthorUsername *string `json:"authorUsername"`
	CreatedAt      string  `json:"createdAt"`
	Additions      int     `json:"additions"`
	Deletions      int     `json:"deletions"`
	FilesChanged   int     `json:"filesChanged"`
	HTMLUrl        *string `json:"htmlUrl"`
}

CommitResult represents a commit returned by the search service.

type Config

type Config struct {
	ServiceURL  string // Base URL of the search service
	GitHubToken string
	Owner       string
	Repo        string
	Repos       []string
	AllRepos    bool // When true, search all accessible repos (no repo scoping)
	Query       string
	Limit       int
	Author      string // Filter by author name
	Date        string // Filter by time period: "week" or "month"
	Branch      string // Filter by branch name
	Page        int    // 1-based page number (0 means omit, API defaults to 1)
}

Config holds the configuration for a search request.

func (Config) HasFilters

func (c Config) HasFilters() bool

HasFilters reports whether any filter fields are set on the config.

type Meta

type Meta struct {
	MatchType string   `json:"matchType"`
	Score     float64  `json:"score"`
	Tier      *int     `json:"tier,omitempty"`
	Snippet   string   `json:"snippet,omitempty"`
	Summary   string   `json:"summary,omitempty"`
	BM25Score *float64 `json:"bm25Score,omitempty"`
	ANNScore  *float64 `json:"annScore,omitempty"`
}

Meta contains search ranking metadata for a result.

type ParsedInput

type ParsedInput struct {
	Query  string
	Author string
	Date   string
	Branch string
	Repos  []string
}

ParsedInput holds the parsed query and optional filters extracted from search input.

func ParseSearchInput

func ParseSearchInput(raw string) ParsedInput

ParseSearchInput extracts filter prefixes from raw input. Supports quoted values for single-value filters, for example: author:"alice smith". Remaining tokens become the query.

type Response

type Response struct {
	Results  []Result    `json:"results"`
	Total    int         `json:"total"`
	Page     int         `json:"page"`
	Error    string      `json:"error,omitempty"`
	Timing   *Timing     `json:"timing,omitempty"`
	Reranked *bool       `json:"reranked,omitempty"`
	Counts   *TypeCounts `json:"counts,omitempty"`
}

Response is the search service response.

func Search(ctx context.Context, cfg Config) (*Response, error)

Search calls the search service to perform a hybrid search.

type Result

type Result struct {
	Type       string            `json:"-"`
	Meta       Meta              `json:"-"`
	Checkpoint *CheckpointResult `json:"-"`
	Commit     *CommitResult     `json:"-"`
	Session    *SessionResult    `json:"-"`
	// contains filtered or unexported fields
}

Result wraps a search result with its type and ranking metadata. Exactly one of Checkpoint, Commit, or Session is non-nil based on Type.

func (*Result) MarshalJSON added in v0.7.6

func (r *Result) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling to produce the API wire format.

func (*Result) ResultAuthor added in v0.7.6

func (r *Result) ResultAuthor() string

ResultAuthor returns the display author for any result type.

func (*Result) ResultBranch added in v0.7.6

func (r *Result) ResultBranch() string

ResultBranch returns the branch for any result type.

func (*Result) ResultCreatedAt added in v0.7.6

func (r *Result) ResultCreatedAt() string

ResultCreatedAt returns the createdAt for any result type.

func (*Result) ResultID added in v0.7.6

func (r *Result) ResultID() string

ResultID returns the primary ID for any result type.

func (*Result) ResultOrg added in v0.7.6

func (r *Result) ResultOrg() string

ResultOrg returns the org for any result type.

func (*Result) ResultRepo added in v0.7.6

func (r *Result) ResultRepo() string

ResultRepo returns the repo for any result type.

func (*Result) ResultTitle added in v0.7.6

func (r *Result) ResultTitle() string

ResultTitle returns the primary display text for any result type.

func (*Result) UnmarshalJSON added in v0.7.6

func (r *Result) UnmarshalJSON(b []byte) error

UnmarshalJSON implements custom JSON unmarshaling to parse typed data.

type SessionResult added in v0.7.6

type SessionResult struct {
	SessionID      string  `json:"sessionId"`
	DisplayName    string  `json:"displayName"`
	Prompt         *string `json:"prompt"`
	Agent          *string `json:"agent"`
	Model          *string `json:"model"`
	StepCount      int     `json:"stepCount"`
	Org            string  `json:"org"`
	Repo           string  `json:"repo"`
	Branch         *string `json:"branch"`
	AuthorUsername *string `json:"authorUsername"`
	CreatedAt      string  `json:"createdAt"`
}

SessionResult represents a session returned by the search service.

type Timing added in v0.7.6

type Timing struct {
	TotalMs            *float64 `json:"total_ms"`
	KeywordMs          *float64 `json:"keyword_ms"`
	EmbeddingMs        *float64 `json:"embedding_ms"`
	VectorMs           *float64 `json:"vector_ms"`
	RerankMs           *float64 `json:"rerank_ms"`
	FanoutMs           *float64 `json:"fanout_ms"`
	SessionHydrationMs *float64 `json:"session_hydration_ms"`
}

Timing holds search performance timing data.

type TypeCounts added in v0.7.6

type TypeCounts struct {
	Repos       int `json:"repos"`
	Checkpoints int `json:"checkpoints"`
	Commits     int `json:"commits"`
	PRs         int `json:"prs"`
	Sessions    int `json:"sessions"`
}

TypeCounts holds per-type result counts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL