kb

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package kb loads and queries the embedded TOML knowledge base.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasGlobPattern

func HasGlobPattern(pattern string) bool

HasGlobPattern checks if a pattern contains glob characters.

Types

type CIConfig

type CIConfig struct {
	Format     string            `toml:"format"`
	Files      []CIFilePattern   `toml:"files"`
	MatrixKeys map[string]string `toml:"matrix_keys"` // maps our key name to the CI matrix key
}

CIConfig holds CI parsing rules.

type CIConfigDef

type CIConfigDef struct {
	CI CIConfig `toml:"ci"`
}

CIConfigDef defines CI configuration for matrix parsing.

type CIFilePattern

type CIFilePattern struct {
	Pattern string `toml:"pattern"`
}

CIFilePattern defines a file pattern for CI configs.

type CommandInfo

type CommandInfo struct {
	Run          string   `toml:"run"`
	Alternatives []string `toml:"alternatives"`
}

CommandInfo holds the commands associated with a tool.

type ConfigInfo

type ConfigInfo struct {
	Files    []string `toml:"files"`
	Lockfile string   `toml:"lockfile"`
}

ConfigInfo holds paths to a tool's configuration files.

type DetectInfo

type DetectInfo struct {
	Files           []string            `toml:"files"`
	Dependencies    []string            `toml:"dependencies"`
	DevDependencies []string            `toml:"dev_dependencies"`
	FileContains    map[string][]string `toml:"file_contains"`
	KeyExists       map[string][]string `toml:"key_exists"`
	Ecosystems      []string            `toml:"ecosystems"`
}

DetectInfo holds the detection primitives for a tool.

type KnowledgeBase

type KnowledgeBase struct {
	Tools         []*ToolDef
	ByName        map[string]*ToolDef
	ByCategory    map[string][]*ToolDef
	Ecosystems    map[string][]*ToolDef
	ScriptSources []ScriptSourceDef
	Resources     []ResourceDef
	Layouts       *LayoutDef
	StyleConfig   *StyleConfigDef
	Runtimes      []RuntimeVersionDef
	ManifestFiles []string
	CIConfig      *CIConfigDef
}

KnowledgeBase holds all loaded definitions.

func Load

func Load(fsys embed.FS) (*KnowledgeBase, error)

Load reads all TOML files from the embedded filesystem and returns a KnowledgeBase.

func (*KnowledgeBase) AllEcosystems

func (base *KnowledgeBase) AllEcosystems() []string

AllEcosystems returns all known ecosystem names.

func (*KnowledgeBase) Categories

func (base *KnowledgeBase) Categories() []string

Categories returns all known tool categories.

func (*KnowledgeBase) ToolsForCategory

func (base *KnowledgeBase) ToolsForCategory(category string) []*ToolDef

ToolsForCategory returns all tools matching a category.

func (*KnowledgeBase) ToolsForEcosystem

func (base *KnowledgeBase) ToolsForEcosystem(ecosystem string) []*ToolDef

ToolsForEcosystem returns all tools for a given ecosystem.

type LayoutDef

type LayoutDef struct {
	Layout LayoutRules `toml:"layout"`
}

LayoutDef defines directory layout patterns to detect.

type LayoutRules

type LayoutRules struct {
	SourceDirs []string `toml:"source_dirs"` // directories that indicate source
	TestDirs   []string `toml:"test_dirs"`   // directories that indicate tests
}

LayoutRules holds the layout detection rules.

type ManifestFileDef

type ManifestFileDef struct {
	Manifests ManifestInfo `toml:"manifests"`
}

ManifestFileDef defines manifest files the dependency checker should look at.

type ManifestInfo

type ManifestInfo struct {
	Files []string `toml:"files"`
}

ManifestInfo lists manifest files for dependency detection.

type ResourceDef

type ResourceDef struct {
	Resource ResourceInfo `toml:"resource"`
}

ResourceDef defines a project resource to look for.

type ResourceInfo

type ResourceInfo struct {
	Name     string   `toml:"name"`
	Field    string   `toml:"field"`    // JSON field name in output
	Patterns []string `toml:"patterns"` // file patterns to match
}

ResourceInfo holds the detection rules for a resource file.

type RuntimeInfo

type RuntimeInfo struct {
	Name  string   `toml:"name"`  // e.g. "Ruby", "Node"
	Files []string `toml:"files"` // e.g. [".ruby-version", ".tool-versions"]
}

RuntimeInfo holds detection rules for runtime version files.

type RuntimeVersionDef

type RuntimeVersionDef struct {
	Runtime RuntimeInfo `toml:"runtime"`
}

RuntimeVersionDef defines runtime version files to detect.

type ScriptSourceDef

type ScriptSourceDef struct {
	Source SourceInfo `toml:"source"`
}

ScriptSourceDef defines how to extract scripts from a project file.

type SourceInfo

type SourceInfo struct {
	Name    string `toml:"name"`
	File    string `toml:"file"`
	Format  string `toml:"format"`  // "makefile", "json_scripts", "targets"
	Command string `toml:"command"` // prefix for run commands (e.g. "make", "just")
}

SourceInfo holds metadata about a script source.

type StyleConfigDef

type StyleConfigDef struct {
	Style StyleRules `toml:"style"`
}

StyleConfigDef defines style configuration files to check.

type StyleConfigFile

type StyleConfigFile struct {
	File       string `toml:"file"`
	Provides   string `toml:"provides"` // what it configures: "indentation", "all", etc.
	SourceName string `toml:"source_name"`
}

StyleConfigFile maps a config file to the style info it provides.

type StyleRules

type StyleRules struct {
	ConfigFiles []StyleConfigFile `toml:"config_files"`
	SampleExts  []string          `toml:"sample_extensions"` // extensions to sample for inference
	SampleLimit int               `toml:"sample_limit"`
}

StyleRules holds style detection rules.

type ToolDef

type ToolDef struct {
	Tool     ToolInfo    `toml:"tool"`
	Detect   DetectInfo  `toml:"detect"`
	Commands CommandInfo `toml:"commands"`
	Config   ConfigInfo  `toml:"config"`
}

ToolDef is the parsed representation of a tool TOML file.

type ToolInfo

type ToolInfo struct {
	Name        string `toml:"name"`
	Category    string `toml:"category"`
	Homepage    string `toml:"homepage"`
	Docs        string `toml:"docs"`
	Repo        string `toml:"repo"`
	Description string `toml:"description"`
}

ToolInfo holds metadata about a tool.

Jump to

Keyboard shortcuts

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