config

package
v0.9.2 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config defines the on-disk configuration and the repository registry, their defaults, and the rules that decide where each one lives.

Index

Constants

View Source
const (
	// CurrentSchemaVersion is the configuration schema understood by Kivgraph.
	CurrentSchemaVersion = 1
)

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the expanded default config path.

func DefaultRepositoriesPath

func DefaultRepositoriesPath() (string, error)

DefaultRepositoriesPath returns the expanded default repository registry path.

func HasSourceExtension added in v0.8.2

func HasSourceExtension(set map[string]struct{}, path string) bool

HasSourceExtension reports whether a path is written in one of the languages a set was built from.

func RegisterRepositories

func RegisterRepositories(path string, additions []Repository) error

RegisterRepositories appends repositories to the validated registry. Paths are resolved relative to the registry file and duplicate names or paths are rejected before the file is replaced.

func SaveRepositories

func SaveRepositories(path string, repositories RepositoriesFile) error

SaveRepositories validates and atomically replaces a repository registry. Callers use this when a candidate registry has already been validated in memory and must become durable without exposing a partially written YAML document.

func SourceExtensionSet added in v0.8.2

func SourceExtensionSet(languages []string) map[string]struct{}

SourceExtensionSet is SourceExtensions as a set, for a caller that asks about one path at a time.

The watcher asks once per file of every scan, so it builds this once per repository rather than walking a switch on every question.

func SourceExtensions added in v0.8.2

func SourceExtensions(languages []string) []string

SourceExtensions is every file extension the named languages are written in, lowercase and sorted, with duplicates removed.

A language it does not recognise contributes nothing rather than everything: a configuration naming one is refused by validation long before this, and answering with the whole set would make a typo index the world.

func SupportedLanguage

func SupportedLanguage(language string) bool

SupportedLanguage reports whether the indexer can analyse a repository that declares this language. The comparison ignores case and surrounding space, which is what every consumer of the field already does.

func SupportedLanguages

func SupportedLanguages() []string

SupportedLanguages is the vocabulary an indexed repository may declare, in the order an error lists them.

It lives here, next to the registry that stores the value, because the registry is where a language is written: a name the indexer cannot analyse used to be accepted by `init` and only rejected by the rebuild, hours later and in another process.

Types

type CSharpConfig added in v0.9.2

type CSharpConfig struct {
	IndexerCommand string `yaml:"indexer_command"`
	// Project names the .sln or .csproj to index. Empty discovers one, and a
	// solution wins over a project because it is what the compiler builds.
	Project          string `yaml:"project"`
	MaximumWorkers   int    `yaml:"maximum_workers"`
	IncludeTests     bool   `yaml:"include_tests"`
	IncludeGenerated bool   `yaml:"include_generated"`
	// SkipRestore is off by default. An index built without a restore loses
	// every symbol that comes from a package, which reads as a repository
	// with fewer dependencies rather than an index that could not resolve
	// them.
	SkipRestore      bool     `yaml:"skip_restore"`
	TargetDirectory  string   `yaml:"target_directory"`
	MaximumIndexTime Duration `yaml:"maximum_index_time"`
}

CSharpConfig controls the scip-dotnet based indexer.

Like Java, C# is indexed by building it: scip-dotnet runs `dotnet restore` and drives Roslyn over a solution or project.

type Config

type Config struct {
	Version    int              `yaml:"version"`
	Workspace  WorkspaceConfig  `yaml:"workspace"`
	Storage    StorageConfig    `yaml:"storage"`
	Web        WebConfig        `yaml:"web"`
	MCP        MCPConfig        `yaml:"mcp"`
	Indexing   IndexingConfig   `yaml:"indexing"`
	Watcher    WatcherConfig    `yaml:"watcher"`
	TypeScript TypeScriptConfig `yaml:"typescript"`
	Go         GoConfig         `yaml:"go"`
	Rust       RustConfig       `yaml:"rust"`
	Python     PythonConfig     `yaml:"python"`
	Dart       DartConfig       `yaml:"dart"`
	Java       JavaConfig       `yaml:"java"`
	CSharp     CSharpConfig     `yaml:"csharp"`
	Telemetry  TelemetryConfig  `yaml:"telemetry"`
	Logging    LoggingConfig    `yaml:"logging"`
}

Config is the complete Kivgraph configuration document.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the explicit defaults from the configuration contract. Paths use the documented home-directory notation until Load expands them.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig reads and validates only the main configuration document.

type DartConfig added in v0.3.3

type DartConfig struct {
	AnalyzerCommand     string   `yaml:"analyzer_command"`
	MaximumWorkers      int      `yaml:"maximum_workers"`
	SDKPath             string   `yaml:"sdk_path"`
	IncludeTests        bool     `yaml:"include_tests"`
	IncludeGenerated    bool     `yaml:"include_generated"`
	IncludeExternal     bool     `yaml:"include_external_packages"`
	IncludeSDK          bool     `yaml:"include_sdk"`
	PackageConfig       string   `yaml:"package_config"`
	WaitForAnalysis     bool     `yaml:"wait_for_analysis"`
	MaximumAnalysisTime Duration `yaml:"maximum_analysis_time"`
}

DartConfig controls the Dart analysis-server based indexer.

type Duration

type Duration time.Duration

Duration is a YAML duration such as 10m or 30s.

func (Duration) MarshalYAML

func (duration Duration) MarshalYAML() (interface{}, error)

MarshalYAML emits durations in the same form accepted by UnmarshalYAML.

func (Duration) String

func (duration Duration) String() string

String returns the duration in Go's standard representation.

func (*Duration) UnmarshalYAML

func (duration *Duration) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML parses a Go duration from a YAML scalar.

type GoConfig

type GoConfig struct {
	SyntheticWorkFile string `yaml:"synthetic_work_file"`
	IncludeTests      bool   `yaml:"include_tests"`
	// GOOS and GOARCH select the build platform. Empty values use the
	// platform of the configured Go toolchain.
	GOOS       string `yaml:"goos"`
	GOARCH     string `yaml:"goarch"`
	CGOEnabled *bool  `yaml:"cgo_enabled"`
	// BuildTags are the build constraints every Go load satisfies. A
	// package guarded by a tag that is absent here contributes no symbol to
	// the graph and is reported as unresolved.
	BuildTags []string `yaml:"build_tags"`
	// AllowNetwork lets the go command reach a module proxy while loading.
	// Indexing is hermetic by default: a module the local cache does not
	// hold is reported, not fetched. A multi-repository workspace resolves
	// one shared build list, so its selection can need a version no member
	// downloaded on its own.
	AllowNetwork bool `yaml:"allow_network"`
	// MaximumLoads bounds concurrent Go loads. Each load holds a complete
	// type universe, so this trades memory for speed. Zero uses the
	// processor count, capped.
	MaximumLoads int `yaml:"maximum_loads"`
}

GoConfig controls Go-specific synthetic workspace behavior.

type IndexingConfig

type IndexingConfig struct {
	GeneratedFiles            string `yaml:"generated_files"`
	UnresolvedReferences      string `yaml:"unresolved_references"`
	SyntaxAcceleration        bool   `yaml:"syntax_acceleration"`
	FullRebuildOnSchemaChange bool   `yaml:"full_rebuild_on_schema_change"`
	// FactCache decides whether an analysis unit may be served from the
	// facts a previous pass stored for it. `off` analyses everything,
	// `on` serves an entry whose recorded inputs all still match, and
	// `verify` analyses everything and fails the pass when a servable
	// entry disagrees with what the analysis produced.
	FactCache string `yaml:"fact_cache"`
	// FactCachePath holds one entry per analysis unit, outside every
	// indexed repository.
	FactCachePath string `yaml:"fact_cache_path"`
}

IndexingConfig controls which facts and references are retained.

type InitOptions

type InitOptions struct {
	ConfigPath       string
	RepositoriesPath string
	Force            bool
}

InitOptions controls creation of the local configuration files.

type InitResult

type InitResult struct {
	ConfigPath          string
	RepositoriesPath    string
	ConfigCreated       bool
	RepositoriesCreated bool
}

InitResult reports what Initialize created.

func Initialize

func Initialize(options InitOptions) (InitResult, error)

Initialize creates the default configuration and repository registry without replacing existing files unless Force is set. It also creates every local state directory named by the configuration.

type JavaConfig added in v0.9.2

type JavaConfig struct {
	IndexerCommand string `yaml:"indexer_command"`
	// BuildTool is empty by default: scip-java detects Maven, Gradle, sbt and
	// mill on its own, and naming one is for a repository that carries two.
	BuildTool        string `yaml:"build_tool"`
	MaximumWorkers   int    `yaml:"maximum_workers"`
	IncludeTests     bool   `yaml:"include_tests"`
	IncludeGenerated bool   `yaml:"include_generated"`
	// TargetDirectory is where the indexer writes its SemanticDB output and
	// its index. It defaults outside every indexed repository, like
	// rust.target_directory, because a pass must not modify what it reads.
	TargetDirectory  string   `yaml:"target_directory"`
	MaximumIndexTime Duration `yaml:"maximum_index_time"`
}

JavaConfig controls the scip-java based indexer.

Java is indexed by building it: scip-java drives the repository's own build tool with the SemanticDB javac plugin attached. That is what makes its edges type-checked, and it is why this configuration has a target directory and a time limit that the other semantic languages do not need.

type Loaded

type Loaded struct {
	Config           Config
	Repositories     RepositoriesFile
	ConfigPath       string
	RepositoriesPath string
	// RetiredKeys are the dotted names of keys the file carries that this
	// build no longer implements. They are reported rather than rejected, so
	// something has to be able to say they were there. See ADR 0062.
	RetiredKeys []string
}

Loaded combines the validated configuration and its repository registry.

func Load

func Load(path string) (Loaded, error)

Load reads, validates, and combines config.yaml with its repositories.yaml. An empty path selects ~/.config/kivgraph/config.yaml.

type LoggingConfig

type LoggingConfig struct {
	Format string `yaml:"format"`
	Level  string `yaml:"level"`
	// EventLogPath is the append-only record of indexing passes, tool calls
	// and server lifecycle that `kivgraph logs` and `kivgraph tool-stats`
	// read. It lives in the state directory rather than beside the
	// configuration because it is derived data: losing it costs history, not
	// a working installation.
	EventLogPath string `yaml:"event_log_path"`
}

LoggingConfig controls the process log output.

type MCPConfig

type MCPConfig struct {
	Transport           string `yaml:"transport"`
	DefaultLimit        int    `yaml:"default_limit"`
	MaximumLimit        int    `yaml:"maximum_limit"`
	MaximumDepth        int    `yaml:"maximum_depth"`
	MaximumVisitedNodes int    `yaml:"maximum_visited_nodes"`
}

MCPConfig controls transport and query limits.

type PythonConfig added in v0.3.3

type PythonConfig struct {
	IndexerCommand string `yaml:"indexer_command"`
	// AnalyzerCommand is an optional type-aware producer. It must emit the
	// versioned semantic payload understood by Kivgraph. The bundled AST
	// worker remains the fallback when AnalyzerMode is `fallback`.
	AnalyzerCommand  string `yaml:"analyzer_command"`
	AnalyzerMode     string `yaml:"analyzer_mode"`
	MaximumWorkers   int    `yaml:"maximum_workers"`
	PythonPath       string `yaml:"python_path"`
	IncludeTests     bool   `yaml:"include_tests"`
	IncludeGenerated bool   `yaml:"include_generated"`
	IncludeExternal  bool   `yaml:"include_external_packages"`
}

PythonConfig controls the external Python semantic indexer.

The command is deliberately configurable: Python projects may use different interpreters, environments and Pyright-derived indexers. The indexer must emit Kivgraph's versioned Python facts payload.

type RepositoriesFile

type RepositoriesFile struct {
	Version      int          `yaml:"version"`
	Repositories []Repository `yaml:"repositories"`
}

RepositoriesFile is the repository registry document referenced by Config.

func LoadRepositories

func LoadRepositories(path string) (RepositoriesFile, error)

LoadRepositories reads and validates a repository registry document. An empty path selects ~/.config/kivgraph/repositories.yaml.

type Repository

type Repository struct {
	Name       string   `yaml:"name"`
	Path       string   `yaml:"path"`
	Languages  []string `yaml:"languages"`
	Manifests  []string `yaml:"manifests,omitempty"`
	Roots      []string `yaml:"roots,omitempty"`
	Exclusions []string `yaml:"exclusions,omitempty"`
}

Repository identifies one source repository to index.

type RustConfig

type RustConfig struct {
	AnalyzerCommand string `yaml:"analyzer_command"`
	// MaximumWorkspaces bounds concurrent rust-analyzer invocations. Each
	// one holds a whole Cargo workspace and its sysroot in memory, so this
	// trades memory for speed. Zero uses the processor count, capped.
	MaximumWorkspaces int `yaml:"maximum_workspaces"`
	// Features, AllFeatures and NoDefaultFeatures decide which code exists
	// at all: a symbol behind an inactive feature is absent from the graph
	// and reported as unresolved.
	Features          []string `yaml:"features"`
	AllFeatures       bool     `yaml:"all_features"`
	NoDefaultFeatures bool     `yaml:"no_default_features"`
	// Cfgs are the additional `--cfg` values the analysis assumes.
	Cfgs []string `yaml:"cfgs"`
	// BuildScripts and ProcMacros keep generated code and derive expansions
	// in the graph. Disabling them is faster and declares what it lost.
	BuildScripts bool `yaml:"build_scripts"`
	ProcMacros   bool `yaml:"proc_macros"`
	// IncludeTests sets `cfg(test)` for the crates of the workspace, which
	// is the analyzer's own default. Turning it off removes every test item
	// from the graph, and the grammar then reports each one as a
	// declaration the index does not carry.
	IncludeTests bool `yaml:"include_tests"`
	// AllowNetwork lets cargo reach a registry while the analyzer loads a
	// workspace. Indexing is hermetic by default: a crate the local cache
	// does not hold is reported, not fetched.
	AllowNetwork bool `yaml:"allow_network"`
	// TargetDirectory holds the build artifacts of the analysis. It lives
	// outside every indexed repository: rust-analyzer runs build scripts,
	// and a pass never writes inside the code it indexes.
	TargetDirectory string `yaml:"target_directory"`
	// Sysroot is `discover`, `none`, or a path. Without a sysroot the
	// standard library is absent and the proc-macro server cannot start.
	//
	// It says where the standard library is, never whether it enters the
	// graph: loading it is what lets the analyzer resolve `Vec` at all, and
	// that is needed even when nothing about `core` is published.
	Sysroot string `yaml:"sysroot"`
	// IndexSysroot publishes the standard library as a synthetic provider
	// repository named after the toolchain release. It is off by default
	// because it multiplies the symbols of a graph by an order of magnitude:
	// one toolchain is around 350.000 monikers and half a minute of indexing.
	//
	// With it off, a `#[derive]`, an overloaded operator, a `?` and every call
	// into the standard library leave no edge, and the pass says so. With it
	// on, they resolve to the crate that declares them.
	IndexSysroot bool `yaml:"index_sysroot"`
}

RustConfig controls the external rust-analyzer batch indexer.

Rust is analysed by a process Kivgraph does not ship, so the command, the build configuration it is given and the directory its build artifacts land in all belong to the configuration rather than to the code.

type StorageConfig

type StorageConfig struct {
	DatabasePath string `yaml:"database_path"`
	BackupsPath  string `yaml:"backups_path"`
}

StorageConfig controls persistent graph locations.

It used to carry snapshots_path and retain_snapshots. Neither did anything: nothing was ever written to the first, and nothing read the second. They are accepted and reported rather than rejected, because a configuration that was valid yesterday must not stop a server today. See ADR 0062.

type TelemetryConfig

type TelemetryConfig struct {
	Metrics bool `yaml:"metrics"`
	Traces  bool `yaml:"traces"`
}

TelemetryConfig controls metrics and tracing.

type TypeScriptConfig

type TypeScriptConfig struct {
	WorkerCommand      string   `yaml:"worker_command"`
	MaximumWorkers     int      `yaml:"maximum_workers"`
	ProjectIdleTimeout Duration `yaml:"project_idle_timeout"`
	// IncludeUnclaimedSources indexes the repository's TypeScript files that
	// no tsconfig claims. A file no project's "files"/"include" reaches
	// belongs to no program, so it is invisible by construction: nothing
	// type-checks it and nothing reports it absent. Enabling this loads
	// those files into TypeScript's inferred project, whose compiler
	// options are Kivgraph's choice and not the ones the project declaring
	// them would have applied -- there is no project declaring them. It is
	// off by default: what it adds is real, and what it adds it under an
	// authority weaker than a configured project's.
	IncludeUnclaimedSources bool `yaml:"include_unclaimed_sources"`
}

TypeScriptConfig controls the persistent TypeScript worker.

type WatcherConfig

type WatcherConfig struct {
	Enabled                  bool     `yaml:"enabled"`
	DebounceMilliseconds     int      `yaml:"debounce_ms"`
	MaximumBatchMilliseconds int      `yaml:"maximum_batch_ms"`
	ReconciliationInterval   Duration `yaml:"reconciliation_interval"`
}

WatcherConfig controls incremental file watching.

type WebConfig

type WebConfig struct {
	Address string `yaml:"address"`
}

WebConfig controls the explicit local HTTP viewer command.

type WorkspaceConfig

type WorkspaceConfig struct {
	RepositoriesFile string `yaml:"repositories_file"`
}

WorkspaceConfig points to the repository registry.

Jump to

Keyboard shortcuts

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