index

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildDirtyIndex added in v0.5.0

func BuildDirtyIndex(ctx context.Context, localPath, dirtyPath string, opts IndexOptions) (int, error)

BuildDirtyIndex creates an on-disk Bleve index of dirty (uncommitted) files. Uses git status to identify dirty files (fast) rather than walking the full tree. The dirty index at dirtyPath is fully rebuilt on each call via atomic swap (write to .tmp, then rename) so CLI readers never see a partially-written index. Files are indexed as "dirty_<relPath>" for enrichment without SQL.

func CloneOrFetch

func CloneOrFetch(url, repoPath string) (*git.Repository, error)

CloneOrFetch clones a bare repo at repoPath, or fetches if it already exists. Returns the opened go-git Repository.

func DirtyIndexPath added in v0.5.0

func DirtyIndexPath(codedbDir, worktreePath string) string

DirtyIndexPath returns the on-disk path for a worktree's dirty overlay index. The path is deterministic based on the worktree's absolute path, allowing the CLI to find the daemon-built dirty index without IPC.

func IndexLocalRepo

func IndexLocalRepo(ctx context.Context, s *store.Store, localPath string, opts IndexOptions) error

IndexLocalRepo indexes a local git repository in-place (no clone). It indexes all committed history AND the current working tree, including uncommitted (dirty) files.

func IndexRepo

func IndexRepo(ctx context.Context, s *store.Store, url string, opts IndexOptions) error

IndexRepo indexes a git repository into the store.

func RepoDirFromURL

func RepoDirFromURL(url string) (string, error)

RepoDirFromURL derives a local directory name from a repo URL. "https://github.com/user/repo/" -> "github.com/user/repo.git"

func RepoNameFromURL

func RepoNameFromURL(url string) (string, error)

RepoNameFromURL derives a human-readable name from a URL. "https://github.com/user/repo" -> "github.com/user/repo"

Types

type BleveCodeDoc

type BleveCodeDoc struct {
	Content string `json:"content"`
}

BleveCodeDoc is the document indexed into the code Bleve index.

type BleveCommentDoc added in v0.5.0

type BleveCommentDoc struct {
	Content string `json:"content"`
}

BleveCommentDoc is the document indexed into the comment Bleve index.

type BleveDiffDoc

type BleveDiffDoc struct {
	Content string `json:"content"`
}

BleveDiffDoc is the document indexed into the diff Bleve index.

type CommentStats added in v0.5.0

type CommentStats struct {
	BlobsParsed       uint64
	CommentsExtracted uint64
}

CommentStats holds statistics from the comment parsing phase.

func ParseComments added in v0.5.0

func ParseComments(ctx context.Context, s *store.Store, progress ProgressFunc) (CommentStats, error)

ParseComments extracts comments from all blobs that haven't been comment-parsed yet and inserts them into the comments table and CommentIndex.

type GitHubIndexStats added in v0.5.0

type GitHubIndexStats struct {
	PRsIndexed    int
	IssuesIndexed int
}

GitHubIndexStats tracks how many PRs and issues were indexed.

func IndexGitHubData added in v0.5.0

func IndexGitHubData(ctx context.Context, s *store.Store, ledgerPath string, progress ProgressFunc) (*GitHubIndexStats, error)

IndexGitHubData reads PR and issue JSON files from the ledger and upserts them into CodeDB's pull_requests/issues tables with their comments.

The ledger stores data in time-partitioned directories:

data/github/YYYY/MM/DD/pr/NNN.json
data/github/YYYY/MM/DD/issue/NNN.json

Each file is a self-contained JSON blob that we upsert by number. Existing records are replaced (delete + insert) to pick up state changes, new comments, etc.

Incremental: files are skipped if their mtime hasn't changed since the last successful index. This reduces steady-state cost from O(all files) to O(changed files) per run.

type IndexOptions

type IndexOptions struct {
	MaxHistoryDepth int // 0 = unlimited
	Progress        ProgressFunc
	SkipDirs        map[string]bool // directories to skip in worktree indexing; nil = use defaultSkipDirs
}

IndexOptions configures the indexing process.

type ParseStats

type ParseStats struct {
	BlobsParsed      uint64
	SymbolsExtracted uint64
}

ParseStats holds statistics from the symbol parsing phase.

func ParseSymbols

func ParseSymbols(ctx context.Context, s *store.Store, progress ProgressFunc) (ParseStats, error)

ParseSymbols extracts symbols and references from all unparsed blobs with supported languages and inserts them into the symbols and symbol_refs tables.

type ProgressFunc

type ProgressFunc func(msg string)

ProgressFunc is called with status messages during indexing.

Jump to

Keyboard shortcuts

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