codebaseindex

package
v0.0.239 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxFiles is the number of source files included in an index unless
	// callers override Config.MaxFiles. 0 or a negative value means unlimited.
	DefaultMaxFiles = 10000
)
View Source
const (

	// DefaultMaxFilesPerDir caps how many files are listed per directory in the
	// Repository Layout tree. Overridable via Config.MaxFilesPerDir / the
	// --max-files-per-dir CLI flag. 0 or negative means unlimited.
	DefaultMaxFilesPerDir = 200
)

Variables

This section is empty.

Functions

func BuildSymbolCache added in v0.0.217

func BuildSymbolCache(candidates []*FileEntry) map[string]SymbolCacheEntry

BuildSymbolCache turns an extracted candidate list into a cache that can be serialized alongside a graph. Callers should only reuse it with the same repository root.

func CombinedExtensions

func CombinedExtensions(adapters []Adapter) []string

CombinedExtensions returns all file extensions from the given adapters

func CombinedIgnoreDirs

func CombinedIgnoreDirs(adapters []Adapter) []string

CombinedIgnoreDirs returns all ignore dirs from the given adapters

func CombinedIgnoreGlobs

func CombinedIgnoreGlobs(adapters []Adapter) []string

CombinedIgnoreGlobs returns all ignore globs from the given adapters

func CompressAggregatedContent added in v0.0.149

func CompressAggregatedContent(contents []string) string

CompressAggregatedContent deduplicates sections across multiple index contents. It splits each content by ## markdown headers, hashes each section after whitespace normalization, and removes duplicate sections (keeping the first occurrence). This is useful when aggregating multiple codebase indexes that share common boilerplate sections like "Repository Layout" or "Key Entry Points".

func Decrypt

func Decrypt(data []byte, password string) ([]byte, error)

Decrypt decrypts encrypted data

func DecryptFromFile

func DecryptFromFile(inputPath string, password string) ([]byte, error)

DecryptFromFile decrypts content from an encrypted file

func IsEncrypted

func IsEncrypted(data []byte) bool

IsEncrypted checks if data appears to be encrypted

func LoadIndexSymbolCache added in v0.0.238

func LoadIndexSymbolCache(indexPath, root string) map[string]SymbolCacheEntry

LoadIndexSymbolCache reuses the structured part of an index without requiring callers to understand its markdown format. Legacy indexes are cache misses.

func LoadSymbolCache added in v0.0.217

func LoadSymbolCache(root, namespace string) map[string]SymbolCacheEntry

LoadSymbolCache returns a cache only when it belongs to this exact root and schema version. A missing or malformed cache is a cache miss, never a graph build failure.

func SaveSymbolCache added in v0.0.217

func SaveSymbolCache(root, namespace string, candidates []*FileEntry) error

SaveSymbolCache atomically persists the reusable extracted symbols from a successful graph scan.

func SymbolCachePath added in v0.0.217

func SymbolCachePath(root, namespace string) string

SymbolCachePath is the project-local sidecar used by graph builds to avoid re-extracting unchanged source symbols. It is deliberately separate from an index's metadata because graph builds can run without generating markdown.

Types

type Adapter

type Adapter interface {
	// Name returns the adapter identifier (e.g., "go", "python")
	Name() string

	// DetectionFiles returns files that indicate this language is used
	// (e.g., "go.mod", "requirements.txt")
	DetectionFiles() []string

	// FileExtensions returns file extensions this adapter handles
	// (e.g., ".go", ".py")
	FileExtensions() []string

	// IgnoreDirs returns directories to ignore for this language
	// (e.g., "vendor", "node_modules")
	IgnoreDirs() []string

	// IgnoreGlobs returns glob patterns to ignore
	// (e.g., "*.generated.go", "*.min.js")
	IgnoreGlobs() []string

	// EntrypointPatterns returns file patterns that indicate entrypoints
	// (e.g., "main.go", "index.ts")
	EntrypointPatterns() []string

	// ConfigPatterns returns file patterns that indicate config files
	// (e.g., "go.mod", "package.json")
	ConfigPatterns() []string

	// ExtractSymbols extracts symbols from file content
	// Only first maxBytes of content is provided for performance
	ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

	// ScoreFile returns a score modifier for file prioritization
	// Higher scores = more important files
	ScoreFile(path string, depth int, isEntrypoint, isConfig bool) int
}

Adapter defines the interface for language-specific indexing adapters

type AdapterOverride

type AdapterOverride struct {
	IgnoreDirs      []string
	IgnoreGlobs     []string
	PriorityFiles   []string
	ReplaceDefaults bool
}

AdapterOverride allows customization of adapter behavior

type ChangeSet

type ChangeSet struct {
	Added    []*FileEntry
	Modified []*FileEntry
	Deleted  []string
}

ChangeSet represents files that changed since last index

type CodeConvention added in v0.0.182

type CodeConvention struct {
	Language   string
	Name       string
	Rationale  string
	Guidance   string
	Evidence   []string
	Confidence float64
}

CodeConvention captures the deeper "why" layer of a codebase index: the conventions, architectural patterns, and change guidance agents should follow.

type CodebaseComponent added in v0.0.183

type CodebaseComponent struct {
	Name        string
	Root        string
	Language    string
	Kind        string // frontend, backend, cli, mobile, shared-library, infrastructure, unknown
	Frameworks  []string
	ConfigFiles []string
	EntryPoints []string
	KeyDirs     []string
	FileCount   int
	Evidence    []string
}

CodebaseComponent describes a logical app/package inside a repository. In a monorepo this usually maps to a frontend, backend, worker, mobile app, CLI, or shared library rooted at a subdirectory with its own manifest/config file.

type Config

type Config struct {
	// Root path to scan (defaults to current directory)
	Root string

	// Output configuration
	OutputPath    string
	OutputFormat  OutputFormat // summary, structured, or full
	Store         StoreLocation
	Encrypt       bool
	EncryptionKey string

	// Expose configuration
	ExposeVariable bool
	MemoryEnabled  bool
	MemoryKey      string

	// Adapter overrides per language
	AdapterOverrides map[string]*AdapterOverride

	// ParserPlugins adds local executable parsers for project-specific source
	// formats. Plugins are opt-in and run only on the machine indexing the repo.
	ParserPlugins     []ParserPluginConfig
	ParserPluginPaths []string

	// Processing options
	MaxOutputKB   int
	HashAlgorithm HashAlgorithm
	Incremental   bool
	Verbose       bool
	// SkipFileHash avoids reading source contents only to compute metadata that
	// a caller does not consume. Graph scans use file size and modification time
	// to validate their symbol cache, so hashing every source file is redundant.
	SkipFileHash bool

	// SymbolCache lets repeat consumers reuse symbols for unchanged files. The
	// cache is validated against path, language, size, and hash or modification time;
	// missing or stale entries are extracted normally.
	SymbolCache map[string]SymbolCacheEntry

	// Progress receives deterministic scan milestones. It is optional so index
	// generation stays quiet and script-friendly unless a CLI or UI opts in.
	Progress func(ProgressEvent)

	// MaxFilesPerDir caps how many files are listed per directory in the
	// Repository Layout tree. 0 or negative means unlimited (list every file).
	MaxFilesPerDir int

	// MaxFiles caps markdown candidate selection. Structural extraction covers
	// all scanned files for graph consumers. 0 or negative means unlimited.
	MaxFiles int

	// Optional second-pass AI enhancement. The normal high-performance scan still
	// runs first; when enabled, EnhancementFunc receives a bounded macro-analysis
	// prompt and returns additional markdown insights for future agents.
	EnhanceIndex     bool
	EnhancementModel string
	EnhancementFunc  func(prompt string) (string, error)

	// qmd integration (optional)
	Qmd *QmdConfig

	// Derived values (computed at runtime)
	RepoFileSlug string // lowercase slug for filenames
	RepoVarSlug  string // uppercase slug for variables
}

Config represents the parsed configuration for codebase indexing

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with sensible defaults

type DiffResult added in v0.0.143

type DiffResult struct {
	Added      []string
	Modified   []string
	Deleted    []string
	Unchanged  int
	StoredAt   time.Time
	StoredHash string
}

DiffResult contains the results of comparing current state to stored index

type DirNode

type DirNode struct {
	Name     string
	Path     string
	Children []*DirNode
	Files    []string // File names only (not full entries)
	Depth    int
}

DirNode represents a directory in the tree structure

type FileEntry

type FileEntry struct {
	// PackagePath is a repository-resolved package identity, when available.
	PackagePath string `json:",omitempty"`
	// Relative path from repo root
	Path string

	// File metadata
	Size    int64
	ModTime time.Time
	Hash    string // xxhash or sha256 depending on config

	// Token estimation (Size / 4 as rough approximation)
	EstimatedTokens int

	// Scoring
	Score        int
	Depth        int
	IsEntrypoint bool
	IsConfig     bool
	IsGenerated  bool

	// Language association
	Language string

	// Extracted symbols (populated during extraction phase)
	Symbols *SymbolInfo
}

FileEntry represents a single file in the repository

func (*FileEntry) TokenBudgetCategory added in v0.0.111

func (f *FileEntry) TokenBudgetCategory() string

TokenBudgetCategory returns the token budget category for a file Uses shared thresholds from filescan package

type FileMetadata added in v0.0.143

type FileMetadata struct {
	PackagePath string      `json:"package_path,omitempty"`
	ModTimeNano int64       `json:"mod_time_nano,omitempty"`
	Language    string      `json:"language,omitempty"`
	Symbols     *SymbolInfo `json:"symbols,omitempty"`
	Path        string      `json:"path"`
	Hash        string      `json:"hash"`
	Size        int64       `json:"size"`
	ModTime     int64       `json:"mod_time"` // Unix timestamp
}

FileMetadata stores per-file metadata for diffing

type FlutterAdapter

type FlutterAdapter struct{}

FlutterAdapter handles Flutter/Dart codebases

func (*FlutterAdapter) ConfigPatterns

func (a *FlutterAdapter) ConfigPatterns() []string

func (*FlutterAdapter) DetectionFiles

func (a *FlutterAdapter) DetectionFiles() []string

func (*FlutterAdapter) EntrypointPatterns

func (a *FlutterAdapter) EntrypointPatterns() []string

func (*FlutterAdapter) ExtractSymbols

func (a *FlutterAdapter) ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

func (*FlutterAdapter) FileExtensions

func (a *FlutterAdapter) FileExtensions() []string

func (*FlutterAdapter) IgnoreDirs

func (a *FlutterAdapter) IgnoreDirs() []string

func (*FlutterAdapter) IgnoreGlobs

func (a *FlutterAdapter) IgnoreGlobs() []string

func (*FlutterAdapter) Name

func (a *FlutterAdapter) Name() string

func (*FlutterAdapter) ScoreFile

func (a *FlutterAdapter) ScoreFile(path string, depth int, isEntrypoint, isConfig bool) int

type FunctionInfo

type FunctionInfo struct {
	Name       string
	Signature  string
	IsExported bool
	IsMethod   bool
	Receiver   string // For methods
	Comments   string
}

FunctionInfo describes a function or method

type GoAdapter

type GoAdapter struct{}

GoAdapter handles Go codebases

func (*GoAdapter) ConfigPatterns

func (a *GoAdapter) ConfigPatterns() []string

func (*GoAdapter) DetectionFiles

func (a *GoAdapter) DetectionFiles() []string

func (*GoAdapter) EntrypointPatterns

func (a *GoAdapter) EntrypointPatterns() []string

func (*GoAdapter) ExtractSymbols

func (a *GoAdapter) ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

func (*GoAdapter) FileExtensions

func (a *GoAdapter) FileExtensions() []string

func (*GoAdapter) IgnoreDirs

func (a *GoAdapter) IgnoreDirs() []string

func (*GoAdapter) IgnoreGlobs

func (a *GoAdapter) IgnoreGlobs() []string

func (*GoAdapter) Name

func (a *GoAdapter) Name() string

func (*GoAdapter) ScoreFile

func (a *GoAdapter) ScoreFile(path string, depth int, isEntrypoint, isConfig bool) int

type HashAlgorithm

type HashAlgorithm string

HashAlgorithm specifies the hashing algorithm to use

const (
	HashXXHash  HashAlgorithm = "xxhash"
	HashSHA256  HashAlgorithm = "sha256"
	DefaultHash HashAlgorithm = HashXXHash
)

type IndexMetadata added in v0.0.143

type IndexMetadata struct {
	MaxFiles       int            `json:"max_files"`
	MaxFilesPerDir int            `json:"max_files_per_dir"`
	Format         OutputFormat   `json:"format,omitempty"`
	Version        int            `json:"version,omitempty"`
	Root           string         `json:"root,omitempty"`
	GeneratedAt    time.Time      `json:"generated_at"`
	RepoName       string         `json:"repo_name"`
	ContentHash    string         `json:"content_hash"`
	FileCount      int            `json:"file_count"`
	Files          []FileMetadata `json:"files"`
	Languages      []string       `json:"languages"`
}

IndexMetadata stores metadata about an index for diffing

type JavaAdapter added in v0.0.179

type JavaAdapter struct{}

JavaAdapter handles Java codebases (Maven, Gradle)

func (*JavaAdapter) ConfigPatterns added in v0.0.179

func (a *JavaAdapter) ConfigPatterns() []string

func (*JavaAdapter) DetectionFiles added in v0.0.179

func (a *JavaAdapter) DetectionFiles() []string

func (*JavaAdapter) EntrypointPatterns added in v0.0.179

func (a *JavaAdapter) EntrypointPatterns() []string

func (*JavaAdapter) ExtractSymbols added in v0.0.179

func (a *JavaAdapter) ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

func (*JavaAdapter) FileExtensions added in v0.0.179

func (a *JavaAdapter) FileExtensions() []string

func (*JavaAdapter) IgnoreDirs added in v0.0.179

func (a *JavaAdapter) IgnoreDirs() []string

func (*JavaAdapter) IgnoreGlobs added in v0.0.179

func (a *JavaAdapter) IgnoreGlobs() []string

func (*JavaAdapter) Name added in v0.0.179

func (a *JavaAdapter) Name() string

func (*JavaAdapter) ScoreFile added in v0.0.179

func (a *JavaAdapter) ScoreFile(path string, depth int, isEntrypoint, isConfig bool) int

type Manager

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

Manager orchestrates the codebase indexing process

func NewManager

func NewManager(config *Config, verbose bool) (*Manager, error)

NewManager creates a new index manager with the given configuration

func (*Manager) ComputeChangeSet added in v0.0.143

func (m *Manager) ComputeChangeSet(diff *DiffResult) *ChangeSet

ComputeChangeSet builds a ChangeSet from diff result for incremental updates

func (*Manager) Diff added in v0.0.143

func (m *Manager) Diff(storedIndexPath string) (*DiffResult, error)

Diff compares the current state of the repository against a stored index

func (*Manager) Generate

func (m *Manager) Generate() (*Result, error)

Generate creates the codebase index

func (*Manager) GenerateIncremental added in v0.0.152

func (m *Manager) GenerateIncremental(storedIndexPath string) (*Result, bool, error)

GenerateIncremental performs an incremental update based on file changes

func (*Manager) GetConfig

func (m *Manager) GetConfig() *Config

GetConfig returns the current configuration

func (*Manager) SaveMetadata added in v0.0.143

func (m *Manager) SaveMetadata(result *Result, candidates []*FileEntry) error

SaveMetadata saves index metadata for future diffing

func (*Manager) Scan added in v0.0.203

func (m *Manager) Scan() (*ScanResult, []string, error)

Scan runs the deterministic front half of index generation — adapter detection, repository scan, symbol extraction, and component analysis — without synthesizing markdown. It returns the populated ScanResult and the detected language names. Knowledge-graph building and other consumers use this to get structured data without producing an index file.

type OutputFormat added in v0.0.135

type OutputFormat string

OutputFormat specifies the format/verbosity of the generated index

const (
	// FormatSummary generates a compact overview (1-2KB)
	// Contains: repo purpose, main areas, key entry points
	// Best for: quick context, agent system prompts
	FormatSummary OutputFormat = "summary"

	// FormatStructured generates a categorized index (10-50KB)
	// Contains: files grouped by domain/purpose, semantic sections
	// Best for: agentic loops that need to understand codebase areas
	FormatStructured OutputFormat = "structured"

	// FormatFull generates the complete index (50-200KB)
	// Contains: all files, symbols, detailed tree structure
	// Best for: comprehensive analysis, initial exploration
	FormatFull OutputFormat = "full"

	// DefaultFormat is the default output format
	DefaultFormat OutputFormat = FormatStructured
)

type ParserPluginAdapter added in v0.0.237

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

ParserPluginAdapter adapts a local executable to the normal indexing adapter interface. Commands are always invoked directly, never via a shell.

func NewParserPluginAdapter added in v0.0.237

func NewParserPluginAdapter(config ParserPluginConfig, root string) (*ParserPluginAdapter, error)

NewParserPluginAdapter validates and initializes one local parser plugin.

func (*ParserPluginAdapter) ConfigPatterns added in v0.0.237

func (a *ParserPluginAdapter) ConfigPatterns() []string

func (*ParserPluginAdapter) DetectionFiles added in v0.0.237

func (a *ParserPluginAdapter) DetectionFiles() []string

func (*ParserPluginAdapter) DisableSymbolCache added in v0.0.237

func (a *ParserPluginAdapter) DisableSymbolCache() bool

func (*ParserPluginAdapter) EntrypointPatterns added in v0.0.237

func (a *ParserPluginAdapter) EntrypointPatterns() []string

func (*ParserPluginAdapter) ExtractSymbols added in v0.0.237

func (a *ParserPluginAdapter) ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

ExtractSymbols asks the plugin to extract a SymbolInfo value for one file.

func (*ParserPluginAdapter) FailOnExtractionError added in v0.0.237

func (a *ParserPluginAdapter) FailOnExtractionError() bool

func (*ParserPluginAdapter) FileExtensions added in v0.0.237

func (a *ParserPluginAdapter) FileExtensions() []string

func (*ParserPluginAdapter) IgnoreDirs added in v0.0.237

func (a *ParserPluginAdapter) IgnoreDirs() []string

func (*ParserPluginAdapter) IgnoreGlobs added in v0.0.237

func (a *ParserPluginAdapter) IgnoreGlobs() []string

func (*ParserPluginAdapter) Name added in v0.0.237

func (a *ParserPluginAdapter) Name() string

func (*ParserPluginAdapter) ScoreFile added in v0.0.237

func (a *ParserPluginAdapter) ScoreFile(_ string, _ int, isEntrypoint, isConfig bool) int

type ParserPluginConfig added in v0.0.237

type ParserPluginConfig struct {
	Name               string   `yaml:"name" json:"name"`
	Command            string   `yaml:"command" json:"command"`
	Args               []string `yaml:"args,omitempty" json:"args,omitempty"`
	Extensions         []string `yaml:"extensions" json:"extensions"`
	DetectionFiles     []string `yaml:"detection_files,omitempty" json:"detection_files,omitempty"`
	IgnoreDirs         []string `yaml:"ignore_dirs,omitempty" json:"ignore_dirs,omitempty"`
	IgnoreGlobs        []string `yaml:"ignore_globs,omitempty" json:"ignore_globs,omitempty"`
	EntrypointPatterns []string `yaml:"entrypoint_patterns,omitempty" json:"entrypoint_patterns,omitempty"`
	ConfigPatterns     []string `yaml:"config_patterns,omitempty" json:"config_patterns,omitempty"`
	Priority           int      `yaml:"priority,omitempty" json:"priority,omitempty"`
	TimeoutMS          int      `yaml:"timeout_ms,omitempty" json:"timeout_ms,omitempty"`
}

ParserPluginConfig declares a locally installed parser plugin. The command is executed directly (never through a shell) once per matching source file. It receives a JSON request on stdin and must write one JSON response on stdout; see docs for the protocol.

func LoadParserPluginManifests added in v0.0.237

func LoadParserPluginManifests(paths []string) ([]ParserPluginConfig, error)

LoadParserPluginManifests reads plugin declarations from local YAML files. The manifests contain only launch configuration; parser source code remains wherever the caller keeps it and is never copied into an index.

type ParserPluginRequest added in v0.0.237

type ParserPluginRequest struct {
	Version  int    `json:"version"`
	Root     string `json:"root"`
	Path     string `json:"path"`
	Content  string `json:"content"`
	MaxBytes int64  `json:"max_bytes"`
}

ParserPluginRequest is sent to a parser plugin on standard input. Content is intentionally capped by the indexer's normal symbol-read limit.

type ParserPluginResponse added in v0.0.237

type ParserPluginResponse struct {
	Symbols *SymbolInfo `json:"symbols"`
	Error   string      `json:"error,omitempty"`
}

ParserPluginResponse is the single JSON object a parser plugin must write to standard output. Error lets a plugin return a per-file diagnostic without relying on stderr parsing.

type ProgressEvent added in v0.0.215

type ProgressEvent struct {
	Phase     string
	Current   string
	Completed int
	Total     int
}

ProgressEvent describes the current deterministic indexing operation. Total is zero while a phase has no meaningful bounded total.

type PythonAdapter

type PythonAdapter struct{}

PythonAdapter handles Python codebases

func (*PythonAdapter) ConfigPatterns

func (a *PythonAdapter) ConfigPatterns() []string

func (*PythonAdapter) DetectionFiles

func (a *PythonAdapter) DetectionFiles() []string

func (*PythonAdapter) EntrypointPatterns

func (a *PythonAdapter) EntrypointPatterns() []string

func (*PythonAdapter) ExtractSymbols

func (a *PythonAdapter) ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

func (*PythonAdapter) FileExtensions

func (a *PythonAdapter) FileExtensions() []string

func (*PythonAdapter) IgnoreDirs

func (a *PythonAdapter) IgnoreDirs() []string

func (*PythonAdapter) IgnoreGlobs

func (a *PythonAdapter) IgnoreGlobs() []string

func (*PythonAdapter) Name

func (a *PythonAdapter) Name() string

func (*PythonAdapter) ScoreFile

func (a *PythonAdapter) ScoreFile(path string, depth int, isEntrypoint, isConfig bool) int

type QmdConfig added in v0.0.129

type QmdConfig struct {
	// Collection name to register with qmd
	Collection string `yaml:"collection"`

	// Whether to run qmd embed after registration
	Embed bool `yaml:"embed"`

	// Context description for the collection
	Context string `yaml:"context"`

	// File mask for indexing (default: "**/*.md")
	Mask string `yaml:"mask"`

	// Enable TurboQuant vector quantization on embeddings
	Quantize bool `yaml:"quantize,omitempty"`

	// Quantization bit width: 1-4 (default: 2)
	QuantizeBits int `yaml:"quantize_bits,omitempty"`
}

QmdConfig holds configuration for qmd integration

type Registry

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

Registry manages available adapters and language detection

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new adapter registry with default adapters

func (*Registry) All

func (r *Registry) All() []Adapter

All returns all registered adapters

func (*Registry) Detect

func (r *Registry) Detect(repoPath string) []Adapter

Detect identifies which adapters apply to the given repository

func (*Registry) Get

func (r *Registry) Get(name string) (Adapter, bool)

Get retrieves an adapter by name

func (*Registry) GetByNames

func (r *Registry) GetByNames(names []string) []Adapter

GetByNames retrieves adapters by name, returning only those found

func (*Registry) Register

func (r *Registry) Register(a Adapter)

Register adds an adapter to the registry

type Result

type Result struct {
	// The generated markdown content (primary format)
	Content string

	// Additional format outputs (generated on demand)
	Summary    string // Always generated - compact overview for agents
	Structured string // Categorized index if format != summary
	Full       string // Complete index if format == full

	// Path where the index was written
	OutputPath string

	// Hash of the plaintext content
	ContentHash string

	// Whether the index was updated (for incremental mode)
	Updated bool

	// Format used for Content
	Format OutputFormat

	// Metadata
	GeneratedAt time.Time
	RepoName    string
	Languages   []string
	FileCount   int
	Duration    time.Duration

	// Categorization (populated during structured/full generation)
	Categories map[string][]string // category -> file paths
}

Result represents the output of index generation

type ScanResult

type ScanResult struct {
	// GraphFiles contains all scanned files, independent of markdown limits.
	GraphFiles []*FileEntry
	// All files found (before candidate selection)
	Files []*FileEntry

	// Selected candidate files for indexing
	Candidates []*FileEntry

	// Directory structure summary
	DirTree *DirNode

	// Macro structure inferred from config files, language roots, and framework
	// indicators. This helps monorepos expose distinct frontend/backend/mobile/CLI
	// components instead of flattening everything into one generic file list.
	IsMonorepo bool
	Components []*CodebaseComponent

	// Statistics
	TotalFiles    int
	TotalDirs     int
	IgnoredFiles  int
	IgnoredDirs   int
	TotalBytes    int64
	ProcessedTime time.Duration
}

ScanResult holds the results of repository scanning

type StoreLocation

type StoreLocation string

StoreLocation specifies where to store the index

const (
	StoreRepo   StoreLocation = "repo"
	StoreConfig StoreLocation = "config"
	StoreBoth   StoreLocation = "both"
)

type SymbolCacheEntry added in v0.0.217

type SymbolCacheEntry struct {
	Hash     string      `json:"hash,omitempty"`
	Language string      `json:"language"`
	Size     int64       `json:"size"`
	ModTime  int64       `json:"mod_time"`
	Symbols  *SymbolInfo `json:"symbols"`
}

SymbolCacheEntry is the durable, content-derived portion of a file scan. Index updates validate the content hash; graph-only scans can use size and modification time when no hash is requested.

type SymbolInfo

type SymbolInfo struct {
	// Package/module declaration
	Package string

	// Imports/dependencies
	Imports []string

	// Functions and methods
	Functions []FunctionInfo

	// Types (structs, classes, interfaces)
	Types []TypeInfo

	// Constants and variables
	Constants []string
	Variables []string

	// References are resolved, language-level references to other symbols.
	// Unlike text in a signature, these preserve qualified names such as
	// aws_s3_bucket.logs and can therefore form precise graph edges.
	References []string

	// Framework/library indicators
	Frameworks []string

	// Risk indicators (auth, crypto, db, concurrency)
	RiskTags []string
}

SymbolInfo holds extracted symbols from a file

type TerraformAdapter added in v0.0.227

type TerraformAdapter struct{}

TerraformAdapter handles native HCL Terraform configurations. State and variable-value files are deliberately excluded: they are generated or can contain secrets, while .tf files describe the deployable topology.

func (*TerraformAdapter) ConfigPatterns added in v0.0.227

func (a *TerraformAdapter) ConfigPatterns() []string

func (*TerraformAdapter) DetectionFiles added in v0.0.227

func (a *TerraformAdapter) DetectionFiles() []string

func (*TerraformAdapter) EntrypointPatterns added in v0.0.227

func (a *TerraformAdapter) EntrypointPatterns() []string

func (*TerraformAdapter) ExtractSymbols added in v0.0.227

func (a *TerraformAdapter) ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

func (*TerraformAdapter) FileExtensions added in v0.0.227

func (a *TerraformAdapter) FileExtensions() []string

func (*TerraformAdapter) IgnoreDirs added in v0.0.227

func (a *TerraformAdapter) IgnoreDirs() []string

func (*TerraformAdapter) IgnoreGlobs added in v0.0.227

func (a *TerraformAdapter) IgnoreGlobs() []string

func (*TerraformAdapter) Name added in v0.0.227

func (a *TerraformAdapter) Name() string

func (*TerraformAdapter) ScoreFile added in v0.0.227

func (a *TerraformAdapter) ScoreFile(path string, depth int, isEntrypoint, isConfig bool) int

type TypeInfo

type TypeInfo struct {
	Name       string
	Kind       string // struct, interface, class, enum, etc.
	IsExported bool
	Fields     []string
	Methods    []string
	Comments   string
}

TypeInfo describes a type definition

type TypeScriptAdapter

type TypeScriptAdapter struct{}

TypeScriptAdapter handles TypeScript/JavaScript codebases

func (*TypeScriptAdapter) ConfigPatterns

func (a *TypeScriptAdapter) ConfigPatterns() []string

func (*TypeScriptAdapter) DetectionFiles

func (a *TypeScriptAdapter) DetectionFiles() []string

func (*TypeScriptAdapter) EntrypointPatterns

func (a *TypeScriptAdapter) EntrypointPatterns() []string

func (*TypeScriptAdapter) ExtractSymbols

func (a *TypeScriptAdapter) ExtractSymbols(path string, content []byte) (*SymbolInfo, error)

func (*TypeScriptAdapter) FileExtensions

func (a *TypeScriptAdapter) FileExtensions() []string

func (*TypeScriptAdapter) IgnoreDirs

func (a *TypeScriptAdapter) IgnoreDirs() []string

func (*TypeScriptAdapter) IgnoreGlobs

func (a *TypeScriptAdapter) IgnoreGlobs() []string

func (*TypeScriptAdapter) Name

func (a *TypeScriptAdapter) Name() string

func (*TypeScriptAdapter) ScoreFile

func (a *TypeScriptAdapter) ScoreFile(path string, depth int, isEntrypoint, isConfig bool) int

Jump to

Keyboard shortcuts

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