framework

package
v3.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(userDir string) (map[string]*Description, error)

Load returns all framework descriptions keyed by name. It merges built-in descriptions (embedded at compile time) with user-provided descriptions from userDir (typically .linespec/frameworks/). User descriptions with the same name override built-ins; unknown names are added alongside them.

Types

type BoundaryCaptures

type BoundaryCaptures struct {
	// Target is the capture name for the dependency target (table name, URL base, topic name).
	Target string `yaml:"target"`
	// Direction is an optional capture name for a dynamically-determined direction.
	Direction string `yaml:"direction"`
}

BoundaryCaptures names the captures that carry semantic data from a BoundaryQuery match.

type BoundaryQuery

type BoundaryQuery struct {
	// Protocol identifies the dependency type: postgresql, mysql, redis, http, kafka, rabbitmq.
	Protocol string `yaml:"protocol"`
	// Direction is "read", "write", or "both".
	Direction string `yaml:"direction"`
	// Pattern is an S-expression tree-sitter query.
	Pattern string `yaml:"pattern"`
	// Captures describes which named captures carry the target and (optionally) direction.
	Captures BoundaryCaptures `yaml:"captures"`
}

BoundaryQuery is a tree-sitter query that matches a protocol boundary call site.

type Description

type Description struct {
	Name     string `yaml:"name"`
	Language string `yaml:"language"` // "go" or "ruby"

	// Detection describes how to identify this framework from project files.
	Detection []DetectionRule `yaml:"detection"`

	// RouteQueries match route registration patterns.
	RouteQueries []RouteQuery `yaml:"route_queries"`

	// MiddlewareQueries match middleware registration patterns.
	MiddlewareQueries []MiddlewareQuery `yaml:"middleware_queries"`

	// GroupQueries match route grouping / path prefix nesting patterns.
	GroupQueries []GroupQuery `yaml:"group_queries"`

	// GroupingStrategy controls how discovered routes are clustered into blueprint records.
	// Valid values: "package" (Go), "controller" (Rails), "file" (Sinatra).
	GroupingStrategy string `yaml:"grouping_strategy"`

	// BoundaryQueries match protocol boundary call patterns (DB, HTTP client, cache, MQ).
	BoundaryQueries []BoundaryQuery `yaml:"boundary_queries"`

	// Partial indicates that this framework uses metaprogramming or reflection-based
	// routing that cannot be fully expressed as tree-sitter queries. Discover will
	// report discovered routes alongside a warning about incomplete coverage.
	Partial bool `yaml:"partial"`
}

Description is a framework description loaded from a YAML file. It teaches discover (and Sedum's world state scanner) how to read a framework's source. Both tools consume the same file — discover uses it to scan, Sedum uses it to assess existing projects during `sedum graft`.

type DetectResult

type DetectResult struct {
	Language  string // "go" or "ruby"
	Framework string // e.g. "chi", "rails", "sinatra"
}

DetectResult holds the outcome of auto-detection.

func Detect

func Detect(dir string, descs map[string]*Description) *DetectResult

Detect scans dir for project files and matches them against the detection rules in the provided descriptions map. Returns the first match found. Returns nil if no framework is detected.

type DetectionRule

type DetectionRule struct {
	// Manifest is the filename to look for (e.g. "go.mod", "Gemfile").
	Manifest string `yaml:"manifest"`
	// Contains lists strings that must appear in the manifest for detection to succeed.
	// All strings must be present (AND semantics).
	Contains []string `yaml:"contains"`
}

DetectionRule describes how to identify this framework in a project directory.

type GroupQuery

type GroupQuery struct {
	Pattern string `yaml:"pattern"`
}

GroupQuery is a tree-sitter query that matches route grouping / path prefix nesting.

type MiddlewareQuery

type MiddlewareQuery struct {
	Pattern string `yaml:"pattern"`
}

MiddlewareQuery is a tree-sitter query that matches middleware registration.

type RouteQuery

type RouteQuery struct {
	// Pattern is an S-expression tree-sitter query pattern.
	// Expected captures: "method", "path", "handler". Additional captures are allowed.
	Pattern string `yaml:"pattern"`

	// Filter maps capture name to a regexp that the captured text must match.
	// Used to narrow overly-broad structural patterns (e.g. restrict @method to HTTP verbs).
	Filter map[string]string `yaml:"filter"`
}

RouteQuery is a tree-sitter query that matches route registration patterns.

Jump to

Keyboard shortcuts

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