workspace

package
v1.14.8 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeKind

type ChangeKind string
const (
	ChangeModified ChangeKind = "modified"
	ChangeDeleted  ChangeKind = "deleted"
)

type Config

type Config struct {
	Root        string
	Extensions  []string
	IgnoreDirs  []string
	MaxFileSize int64
}

Config controls how a WorkspaceIndex scans a repository.

func DefaultConfig

func DefaultConfig(root string) Config

type Context

type Context struct {
	Query           string
	Files           []ContextFile
	Results         []SearchResult
	SemanticResults []SemanticResult
}

type ContextFile

type ContextFile struct {
	Path    string
	Content string
	Symbols []Symbol
}

type ContextRequest

type ContextRequest struct {
	Query      string
	MaxBytes   int
	MaxFiles   int
	MaxResults int
	Semantic   bool
}

type Edge

type Edge struct {
	From string
	To   string
}

type Embedder

type Embedder interface {
	Embed(ctx context.Context, text string) ([]float32, error)
}

Embedder turns source text into a vector. Implementations may use any local or remote embedding provider; the workspace package stays provider-agnostic.

type File

type File struct {
	Path    string
	Package string
	Bytes   int64
	Symbols []Symbol
	Imports []string
}

type FileChange

type FileChange struct {
	Path string
	Kind ChangeKind
}

FileChange describes a filesystem change observed since the last index update.

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index is an in-memory representation of a source tree. It combines a deterministic structural index with an optional semantic/vector index.

func NewIndex

func NewIndex(config Config) *Index

func (*Index) Build

func (i *Index) Build(ctx context.Context) error

func (*Index) BuildContext

func (i *Index) BuildContext(ctx context.Context, req ContextRequest) (Context, error)

BuildContext resolves a task to relevant source files using hybrid structural/semantic retrieval and a deterministic byte budget.

func (*Index) BuildEmbeddings

func (i *Index) BuildEmbeddings(ctx context.Context) error

BuildEmbeddings computes one vector per indexed file. It is intentionally explicit so callers control when embedding work and its cost occur.

func (*Index) Dependencies

func (i *Index) Dependencies(path string) []string

Dependencies returns source files imported by path when their import path belongs to the indexed Go module. External dependencies are omitted because they are not represented by source files in this index.

func (*Index) Dependents

func (i *Index) Dependents(path string) []string

Dependents returns indexed files that import the package containing path.

func (*Index) File

func (i *Index) File(path string) (File, bool)

func (*Index) Files

func (i *Index) Files() []File

func (*Index) Imports

func (i *Index) Imports(path string) []string

func (*Index) Module

func (i *Index) Module() string

func (*Index) SearchSemantic

func (i *Index) SearchSemantic(ctx context.Context, query string, limit int) ([]SemanticResult, error)

func (*Index) SearchSymbols

func (i *Index) SearchSymbols(_ context.Context, query string, limit int) []SearchResult

SearchSymbols performs lightweight lexical ranking over indexed symbols.

func (*Index) SetEmbedder

func (i *Index) SetEmbedder(e Embedder)

SetEmbedder configures the semantic retrieval provider. Embeddings are optional; structural search remains available without an embedder.

func (*Index) Symbols

func (i *Index) Symbols() []Symbol

func (*Index) Update

func (i *Index) Update(ctx context.Context, changes []FileChange) error

type SearchResult

type SearchResult struct {
	Symbol Symbol
	Score  int
}

type SemanticResult

type SemanticResult struct {
	Path  string
	Score float32
}

type Symbol

type Symbol struct {
	Name      string
	Kind      SymbolKind
	Package   string
	File      string
	StartLine int
	EndLine   int
	Receiver  string
}

type SymbolKind

type SymbolKind string
const (
	SymbolPackage SymbolKind = "package"
	SymbolType    SymbolKind = "type"
	SymbolFunc    SymbolKind = "function"
	SymbolMethod  SymbolKind = "method"
	SymbolVar     SymbolKind = "var"
	SymbolConst   SymbolKind = "const"
)

type Watcher

type Watcher struct {
	Index    *Index
	Interval time.Duration
}

Watcher is a dependency-free polling filesystem watcher. It keeps the workspace index synchronized without requiring an OS-specific dependency.

func (*Watcher) Run

func (w *Watcher) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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