codeindex

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 13 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

This section is empty.

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")

	// ErrOutputLimit means git produced more metadata than the bounded indexer
	// was willing to retain in memory.
	ErrOutputLimit = errors.New("git output exceeds limit")
)

Functions

This section is empty.

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 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
}

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