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
- Variables
- func BuildConfigurationPaths(root string) []string
- func CreateProfile(configPath, name string) error
- func DefaultConfigPath() (string, error)
- func DefaultRepositoriesPath() (string, error)
- func DefaultStateDirectory() (string, error)
- func DetectLanguages(root string) ([]string, error)
- func HasSourceExtension(set map[string]struct{}, path string) bool
- func IsBuildConfigurationFile(path string) bool
- func MigrateProjectSyntheticWorkFile(configPath string) (bool, error)
- func RegisterRepositories(path string, additions []Repository) error
- func RemoveProfile(configPath, name string) error
- func SaveRepositories(path string, repositories RepositoriesFile) error
- func SetPythonAnalyzer(path, command, mode string) error
- func SetPythonAnalyzerIfCurrent(path, expectedCommand, command, mode string) (bool, error)
- func SourceExtensionSet(languages []string) map[string]struct{}
- func SourceExtensions(languages []string) []string
- func SupportedLanguage(language string) bool
- func SupportedLanguages() []string
- func UseProfile(configPath, name string) error
- func ValidateProfileName(name string) error
- type CSharpConfig
- type Config
- type DartConfig
- type Duration
- type GoConfig
- type IndexingConfig
- type InitOptions
- type InitResult
- type JavaConfig
- type Loaded
- type LoggingConfig
- type MCPConfig
- type Profile
- type ProfilesConfig
- type PythonConfig
- type RepositoriesFile
- type Repository
- type RustConfig
- type StorageConfig
- type TelemetryConfig
- type TypeScriptConfig
- type WatcherConfig
- type WebConfig
- type WorkspaceConfig
Constants ¶
const ( // CurrentSchemaVersion is the configuration schema understood by Kivgraph. CurrentSchemaVersion = 1 // DefaultPythonAnalyzerCommand names the bundled Python analyzer adapter. DefaultPythonAnalyzerCommand = "kivgraph-python-pyright" )
Variables ¶
Functions ¶
func BuildConfigurationPaths ¶ added in v0.9.9
BuildConfigurationPaths returns the named analyzer configuration paths that are checked as explicit file inputs. The returned paths are rooted at root; patterned files are covered by IsBuildConfigurationFile while walking.
func CreateProfile ¶ added in v0.9.4
CreateProfile creates an empty repository registry without indexing it.
func DefaultConfigPath ¶
DefaultConfigPath returns the expanded default config path.
func DefaultRepositoriesPath ¶
DefaultRepositoriesPath returns the expanded default repository registry path.
func DefaultStateDirectory ¶ added in v0.9.9
DefaultStateDirectory returns the installation-level state directory used when no configuration exists yet. Read-only commands use this instead of creating a configuration merely to answer a status question.
func DetectLanguages ¶ added in v0.9.3
DetectLanguages walks root and returns the supported languages declared by source files or project manifests. It never follows symlinked files or directories, and it ignores generated/dependency trees so autodetection cannot widen an index from a vendored artifact.
func HasSourceExtension ¶ added in v0.8.2
HasSourceExtension reports whether a path is written in one of the languages a set was built from.
func IsBuildConfigurationFile ¶ added in v0.9.9
IsBuildConfigurationFile reports whether the basename of path belongs to a build configuration consumed by one of the supported analyzers. Matching is case-insensitive because repository paths and the analyzers' manifest names are both treated that way by the workspace discovery code.
func MigrateProjectSyntheticWorkFile ¶ added in v0.9.4
MigrateProjectSyntheticWorkFile moves the invalid workspace path written by older project-local configurations. A different value is user-owned and is never changed.
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 RemoveProfile ¶ added in v0.9.4
RemoveProfile removes one non-default profile and refuses to leave none.
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 SetPythonAnalyzer ¶ added in v0.9.9
SetPythonAnalyzer changes only the Python analyzer settings in an existing configuration. It is used by managed toolchains to activate an analyzer without replacing repositories, paths or settings the user owns.
func SetPythonAnalyzerIfCurrent ¶ added in v0.9.9
SetPythonAnalyzerIfCurrent changes the analyzer only when its command still equals expectedCommand. The compare and replacement happen under the same configuration lock, so a remove operation cannot disable a setting another process changed after it read the file.
func SourceExtensionSet ¶ added in v0.8.2
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
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 ¶
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.
func UseProfile ¶ added in v0.9.4
UseProfile moves the default pointer only after proving the target exists.
func ValidateProfileName ¶ added in v0.9.4
ValidateProfileName refuses names that are unsafe or ambiguous as one path element. The all-profiles selector is reserved and is never a profile name.
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"`
Profiles ProfilesConfig `yaml:"profiles"`
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 ¶
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 ¶
Duration is a YAML duration such as 10m or 30s.
func (Duration) MarshalYAML ¶
MarshalYAML emits durations in the same form accepted by UnmarshalYAML.
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 ¶
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
// Profile is empty only for callers using the legacy unscoped Load seam.
Profile 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 ¶
Load reads, validates, and combines config.yaml with its repositories.yaml. An empty path selects ~/.config/kivgraph/config.yaml.
func LoadProfile ¶ added in v0.9.4
LoadProfile loads one profile and rewrites only the state that belongs to its independently published graph. Analyzer targets and the event log remain shared at installation scope.
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 Profile ¶ added in v0.9.4
Profile describes one independently indexed repository registry.
func ListProfiles ¶ added in v0.9.4
ListProfiles returns profiles in canonical name order.
type ProfilesConfig ¶ added in v0.9.4
ProfilesConfig selects the profile used when an operation does not name one. The profile itself is ordinary; only this pointer supplies a default.
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 ¶
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.