codeindex

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package codeindex indexes a bounded snapshot of tracked UTF-8 text files from a clean Git checkout using the native git executable and the standard library. File bytes come from immutable Git blobs at the captured commit, not from mutable worktree paths.

Index

Constants

View Source
const (
	FormatVersion = "codeindex-v1"
)

Variables

View Source
var (
	// ErrDirtyWorktree means the checkout has uncommitted or untracked changes.
	ErrDirtyWorktree = errors.New("worktree is not clean")

	// ErrNoCommit means the repository has no HEAD commit.
	ErrNoCommit = errors.New("no commit found")

	// ErrNotARepository means repoPath is not inside a non-bare git worktree.
	ErrNotARepository = errors.New("not a git repository")
)

Functions

func Probe added in v0.13.0

func Probe(ctx context.Context, repoPath string) (string, string, error)

Probe validates a repository for indexing and returns its canonical root and current commit without reading any blobs.

Types

type Document

type Document struct {
	Path         string
	Content      string
	Bytes        int
	LanguageHint string
}

Document is one bounded, tracked text file from a snapshot.

type Manifest added in v0.10.0

type Manifest struct {
	FormatVersion      string `json:"format_version,omitempty"`
	CoverageKnown      bool   `json:"coverage_known"`
	TrackedEntries     int    `json:"tracked_entries"`
	IndexedFiles       int    `json:"indexed_files"`
	SkippedInvalidPath int    `json:"skipped_invalid_path"`
	SkippedExcluded    int    `json:"skipped_excluded"`
	SkippedNonRegular  int    `json:"skipped_non_regular"`
	SkippedOversize    int    `json:"skipped_oversize"`
	SkippedTotalBudget int    `json:"skipped_total_budget"`
	SkippedNonText     int    `json:"skipped_non_text"`
	SkippedFileLimit   int    `json:"skipped_file_limit"`
	Truncated          bool   `json:"truncated"`
}

Manifest makes indexing coverage and every skip category explicit.

type Options

type Options struct {
	MaxFiles        int
	MaxBytesPerFile int
	MaxTotalBytes   int
	Exclusions      []string
}

Options bounds the index operation.

type Snapshot

type Snapshot struct {
	RepoPath   string
	Commit     string
	CreatedAt  time.Time
	Documents  []Document
	TotalBytes int
	Manifest   Manifest
}

Snapshot identifies a repository checkout and the documents indexed from it.

func Index

func Index(ctx context.Context, repoPath string, opts Options) (Snapshot, error)

Index enumerates tracked files in repoPath and returns a bounded Snapshot. It requires a clean, non-bare checkout and rejects paths that escape the repository root. Only regular tracked files are read; symlinks, binaries, non-UTF-8 content, and files exceeding the configured limits are skipped.

Jump to

Keyboard shortcuts

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