ir

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveCatalog

func SaveCatalog(path string, cat *Catalog) error

SaveCatalog writes the catalog to a YAML file.

Types

type Capability

type Capability struct {
	Verbs  []string `yaml:"verbs"`
	Params []string `yaml:"params"`
	Source string   `yaml:"source,omitempty"` // "seed" or "llm"
	Added  string   `yaml:"added,omitempty"`  // timestamp for LLM-generated entries
}

Capability represents a single atomic capability in the IR taxonomy.

type Catalog

type Catalog struct {
	Version int                              `yaml:"version"`
	Domains map[string]map[string]Capability `yaml:"domains"`
}

Catalog is the top-level IR catalog structure.

func DefaultCatalog

func DefaultCatalog() (*Catalog, error)

DefaultCatalog returns the built-in seed IR catalog.

func LoadCatalog

func LoadCatalog(path string) (*Catalog, error)

LoadCatalog reads an IR catalog from a YAML file.

func (*Catalog) AllEntries

func (c *Catalog) AllEntries() []CatalogEntry

AllEntries returns a flat list of all capabilities across all domains.

type CatalogEntry

type CatalogEntry struct {
	Domain       string
	CapabilityID string
	Capability
}

CatalogEntry is a flattened view of a single capability with its domain and ID.

type IRMatch

type IRMatch struct {
	Domain       string
	CapabilityID string
	Params       []string // parameter spec from the capability
	VerbLen      int      // number of words in the matched verb
}

IRMatch is the result of matching a command against the IR catalog.

func (*IRMatch) IRNodeID

func (m *IRMatch) IRNodeID() uint64

IRNodeID computes a stable hash for an IR match, analogous to trace.NodeID.

func (*IRMatch) ParamShape

func (m *IRMatch) ParamShape() string

ParamShape returns a normalized string representing the structural shape of this match. Used for NodeID generation — commands with same capability and same number of remaining args produce the same shape.

type Matcher

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

Matcher matches preprocessed Bash commands against the IR catalog.

func NewMatcher

func NewMatcher(cat *Catalog) *Matcher

NewMatcher builds a Matcher from a catalog. It precomputes a sorted verb index for efficient longest-prefix matching.

func (*Matcher) Match

func (m *Matcher) Match(command string) *IRMatch

Match tries to match a preprocessed command against the catalog. Returns nil if no verb matches.

Jump to

Keyboard shortcuts

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