projectcfg

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package projectcfg loads <src>/ckv.yaml — the per-project hook for customizing how CKV indexes a repository. The file is optional; an absent file resolves to a zero-value Config that the build layer treats as "use defaults everywhere".

Today's fields:

schema_version: "1"
languages: [go, typescript, solidity, markdown]  # subset to index; empty → all
ignore: ["vendor/**", "**/*_test.go"]    # extra .ckvignore patterns
chunking:
  file_header_lines: 30                  # override default 50
build_roots: [./cmd/ckv]                 # Go entry packages; index
                                          # only files reachable from these
                                          # via `go list -deps`. Empty →
                                          # walk the whole srcRoot.

Reserved-for-future (no-op today; documented to stabilize the schema):

important_symbols: ["^Handle.*"]          # regex tags on chunks
skills_dir: ".claude/skills"              # per-project skills hook

Reserving these now means projects can adopt them without a schema bump later. Unknown future fields decode into IgnoredFields so we can surface a "your ckv.yaml has unknown fields X,Y" warning instead of silently dropping configuration.

Index

Constants

View Source
const FileName = "ckv.yaml"

FileName is the file name we look for at <src>/.

View Source
const SchemaVersionCurrent = "1"

SchemaVersionCurrent is the version this binary writes/accepts.

Variables

View Source
var ErrNotFound = errors.New("projectcfg: not found")

ErrNotFound is returned when <src>/ckv.yaml does not exist. Callers usually swallow this and continue with a zero-value Config.

Functions

This section is empty.

Types

type ChunkingOptions

type ChunkingOptions struct {
	FileHeaderLines int `yaml:"file_header_lines,omitempty"`
}

ChunkingOptions overrides specific chunker knobs. Pointer-valued would have been more correct ("nil = inherit default") but the YAML authoring story is cleaner with omitempty + zero-value-means-default. The build layer treats FileHeaderLines == 0 as "use default".

type Config

type Config struct {
	SchemaVersion    string          `yaml:"schema_version"`
	Languages        []string        `yaml:"languages,omitempty"`
	Ignore           []string        `yaml:"ignore,omitempty"`
	Chunking         ChunkingOptions `yaml:"chunking,omitempty"`
	ImportantSymbols []string        `yaml:"important_symbols,omitempty"`
	SkillsDir        string          `yaml:"skills_dir,omitempty"`

	// BuildRoots is a list of Go entry packages (e.g. ./cmd/ckv) whose
	// transitive dependency closure defines the corpus to index. Empty
	// means "walk the whole srcRoot" — the original behavior. The build
	// layer resolves each entry via `go list -json -deps`, collects the
	// .go files those packages own, and uses that file set as a filter
	// when walking. Entries must be repo-relative paths so ckv.yaml
	// stays portable across checkouts.
	//
	// Today BuildRoots filters Go files only; other languages (TS, Sol)
	// fall through unaffected. A multi-language analog (TS via tsconfig,
	// etc.) is a future-work item.
	BuildRoots []string `yaml:"build_roots,omitempty"`
	// contains filtered or unexported fields
}

Config is the parsed project hook. All fields are optional; zero values fall back to global defaults.

func Load

func Load(srcRoot string) (*Config, error)

Load reads <srcRoot>/ckv.yaml. Returns ErrNotFound when the file is absent. Other errors (yaml parse, schema mismatch, regex compile) are returned wrapped so callers can choose to fail-fast or fall back to defaults.

func LoadOrDefault

func LoadOrDefault(srcRoot string) (*Config, error)

LoadOrDefault returns Load's result, or a zero-value Config (and no error) when ErrNotFound. Convenience for the build path where "no ckv.yaml" is a perfectly valid state.

func (*Config) LanguageAllowed

func (c *Config) LanguageAllowed(lang string) bool

LanguageAllowed reports whether the given language is enabled by this config. Empty Languages list means "all languages allowed".

func (*Config) MatchesImportant

func (c *Config) MatchesImportant(symbolName string) bool

MatchesImportant reports whether the given symbol name matches any of the important_symbols patterns. Returns false on nil receiver or when no patterns are configured.

Jump to

Keyboard shortcuts

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