checks

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package checks provides the ComplianceChecker interface and implementations for validating skill readiness across multiple dimensions.

Index

Constants

View Source
const (
	// FallbackLimit is the default token limit when no pattern matches.
	FallbackLimit = 2000
)

Variables

View Source
var DefaultLimits = TokenLimitsConfig{
	Defaults: map[string]int{
		"SKILL.md":           500,
		"references/**/*.md": 1000,
		"docs/**/*.md":       1500,
		"*.md":               2000,
	},
	Overrides: map[string]int{
		"README.md":       3000,
		"CONTRIBUTING.md": 2500,
	},
}

DefaultLimits is the built-in fallback when neither .waza.yaml nor .token-limits.json provides limits.

Functions

This section is empty.

Types

type BodyStructureChecker

type BodyStructureChecker struct{}

BodyStructureChecker scans SKILL.md body for actionable structure.

func (*BodyStructureChecker) Check

func (*BodyStructureChecker) Name

func (*BodyStructureChecker) Name() string

type BodyStructureData

type BodyStructureData struct {
	Status           CheckStatus
	HasExamples      bool
	HasCodeBlocks    bool
	HasErrorHandling bool
	Findings         []string
}

BodyStructureData holds the structured output.

func (*BodyStructureData) GetStatus

func (d *BodyStructureData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type CheckResult

type CheckResult struct {
	// Name is a stable check identifier used in output and downstream processing.
	Name string
	// Passed indicates whether the check met its acceptance criteria.
	Passed bool
	// Summary is a human-readable one-line result intended for concise display.
	Summary string
	// Details provides optional supporting lines for diagnostics or remediation.
	Details []string
	// Data carries an optional checker-specific payload for structured consumers.
	Data any
}

CheckResult holds the outcome of a single compliance check.

func RunChecks

func RunChecks(checkers []ComplianceChecker, sk skill.Skill) ([]*CheckResult, error)

RunChecks executes each checker against sk, collecting results and errors.

type CheckStatus

type CheckStatus string

CheckStatus represents the three-tier status model used by score checks.

const (
	// StatusOK indicates the check passes.
	StatusOK CheckStatus = "ok"
	// StatusOptimal indicates the check meets recommended best practice.
	StatusOptimal CheckStatus = "optimal"
	// StatusWarning indicates a potential issue was detected.
	StatusWarning CheckStatus = "warning"
)

type ComplexityChecker

type ComplexityChecker struct{}

ComplexityChecker classifies the skill based on token count and module count.

func (*ComplexityChecker) Check

func (*ComplexityChecker) Name

func (*ComplexityChecker) Name() string

type ComplexityData

type ComplexityData struct {
	Status         CheckStatus
	Classification string // "compact", "detailed", or "comprehensive"
	TokenCount     int
	ModuleCount    int
}

ComplexityData holds the structured output of a complexity check.

func (*ComplexityData) GetStatus

func (d *ComplexityData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type ComplianceChecker

type ComplianceChecker interface {
	Name() string
	Check(skill.Skill) (*CheckResult, error)
}

ComplianceChecker runs a single compliance check.

func AdvisoryCheckers

func AdvisoryCheckers() []ComplianceChecker

AdvisoryCheckers returns all advisory checkers in display order.

func SpecCheckers

func SpecCheckers() []ComplianceChecker

SpecCheckers returns all spec compliance checkers in display order.

type ComplianceScoreChecker

type ComplianceScoreChecker struct {
	Scorer           scoring.Scorer
	TokenLimit       int // overrides the default token hard limit when > 0
	WarningThreshold int // overrides the default token warning threshold when > 0
}

ComplianceScoreChecker validates skill frontmatter quality using heuristic scoring.

func (*ComplianceScoreChecker) Check

func (*ComplianceScoreChecker) Name

func (c *ComplianceScoreChecker) Name() string

func (*ComplianceScoreChecker) Score

Score is a convenience wrapper that returns the typed data directly.

type ComplianceScoreData

type ComplianceScoreData struct {
	Score *scoring.ScoreResult
	Level scoring.AdherenceLevel
}

ComplianceScoreData holds the structured output of a compliance score check.

type CrossModelDensityChecker

type CrossModelDensityChecker struct{}

CrossModelDensityChecker checks description word count and action verb usage.

func (*CrossModelDensityChecker) Check

func (*CrossModelDensityChecker) Name

type CrossModelDensityData

type CrossModelDensityData struct {
	Status           CheckStatus
	WordCount        int
	HasActionVerb    bool
	ActionVerbIssues []string
}

CrossModelDensityData holds the structured output.

func (*CrossModelDensityData) GetStatus

func (d *CrossModelDensityData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type EvalSuiteChecker

type EvalSuiteChecker struct {
	WorkDir string
}

EvalSuiteChecker checks for the presence of an eval.yaml file.

func (*EvalSuiteChecker) Check

func (c *EvalSuiteChecker) Check(sk skill.Skill) (*CheckResult, error)

func (*EvalSuiteChecker) Eval

Eval is a convenience wrapper that returns the typed data directly.

func (*EvalSuiteChecker) Name

func (c *EvalSuiteChecker) Name() string

type EvalSuiteData

type EvalSuiteData struct {
	Found bool
}

EvalSuiteData holds the structured output of an eval suite check.

type LimitResult

type LimitResult struct {
	Limit   int
	Pattern string
}

LimitResult holds a resolved limit and the pattern that matched.

func GetLimitForFile

func GetLimitForFile(filePath string, cfg TokenLimitsConfig, workspaceRelPrefix ...string) LimitResult

GetLimitForFile determines the token limit for a file. An optional workspaceRelPrefix (e.g. "plugin/skills/azure-deploy") is prepended to filePath so workspace-root-relative patterns such as "plugin/skills/**/SKILL.md" can match alongside skill-relative patterns. Patterns are tried in specificity order; for each pattern both the skill-relative and workspace-relative paths are checked.

type ModuleCountChecker

type ModuleCountChecker struct{}

ModuleCountChecker counts .md files in the skill's references/ directory.

func (*ModuleCountChecker) Check

func (*ModuleCountChecker) Name

func (*ModuleCountChecker) Name() string

type ModuleCountData

type ModuleCountData struct {
	Status CheckStatus
	Count  int
}

ModuleCountData holds the structured output of a module count check.

func (*ModuleCountData) GetStatus

func (d *ModuleCountData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type NegativeDeltaRiskChecker

type NegativeDeltaRiskChecker struct{}

NegativeDeltaRiskChecker scans SKILL.md content for patterns that degrade performance.

func (*NegativeDeltaRiskChecker) Check

func (*NegativeDeltaRiskChecker) Name

type NegativeDeltaRiskData

type NegativeDeltaRiskData struct {
	Status CheckStatus
	Risks  []string
}

NegativeDeltaRiskData holds the structured output.

func (*NegativeDeltaRiskData) GetStatus

func (d *NegativeDeltaRiskData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type OverSpecificityChecker

type OverSpecificityChecker struct{}

OverSpecificityChecker detects hardcoded, instance-specific content.

func (*OverSpecificityChecker) Check

func (*OverSpecificityChecker) Name

type OverSpecificityData

type OverSpecificityData struct {
	Status     CheckStatus
	Categories []string
}

OverSpecificityData holds the structured output.

func (*OverSpecificityData) GetStatus

func (d *OverSpecificityData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type ProceduralContentChecker

type ProceduralContentChecker struct{}

ProceduralContentChecker checks whether the description contains procedural language.

func (*ProceduralContentChecker) Check

func (*ProceduralContentChecker) Name

type ProceduralContentData

type ProceduralContentData struct {
	Status             CheckStatus
	HasCommonLeadWords bool
	HasProcedureKWs    bool
}

ProceduralContentData holds the structured output.

func (*ProceduralContentData) GetStatus

func (d *ProceduralContentData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type ProgressiveDisclosureChecker

type ProgressiveDisclosureChecker struct{}

ProgressiveDisclosureChecker flags large inline content.

func (*ProgressiveDisclosureChecker) Check

func (*ProgressiveDisclosureChecker) Name

type ProgressiveDisclosureData

type ProgressiveDisclosureData struct {
	Status          CheckStatus
	BodyLines       int
	LargeCodeBlocks int
	Recommendations []string
}

ProgressiveDisclosureData holds the structured output.

func (*ProgressiveDisclosureData) GetStatus

func (d *ProgressiveDisclosureData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type ScoreCheckData

type ScoreCheckData struct {
	Status   CheckStatus
	Evidence string
}

ScoreCheckData carries the status and optional evidence for score-style checks.

func (*ScoreCheckData) GetStatus

func (d *ScoreCheckData) GetStatus() CheckStatus

GetStatus implements StatusHolder.

type SpecAllowedFieldsChecker

type SpecAllowedFieldsChecker struct{}

SpecAllowedFieldsChecker ensures all top-level frontmatter keys are spec-allowed.

func (*SpecAllowedFieldsChecker) Check

func (*SpecAllowedFieldsChecker) Name

type SpecCompatibilityChecker

type SpecCompatibilityChecker struct{}

SpecCompatibilityChecker validates the optional compatibility field.

func (*SpecCompatibilityChecker) Check

func (*SpecCompatibilityChecker) Name

type SpecDescriptionChecker

type SpecDescriptionChecker struct{}

SpecDescriptionChecker validates the description field.

func (*SpecDescriptionChecker) Check

func (*SpecDescriptionChecker) Name

type SpecDirMatchChecker

type SpecDirMatchChecker struct{}

SpecDirMatchChecker checks that the skill directory's basename matches the name field.

func (*SpecDirMatchChecker) Check

func (*SpecDirMatchChecker) Name

func (*SpecDirMatchChecker) Name() string

type SpecFrontmatterChecker

type SpecFrontmatterChecker struct{}

SpecFrontmatterChecker validates that the file has YAML frontmatter with required fields.

func (*SpecFrontmatterChecker) Check

func (*SpecFrontmatterChecker) Name

type SpecLicenseChecker

type SpecLicenseChecker struct{}

SpecLicenseChecker recommends including a license field.

func (*SpecLicenseChecker) Check

func (*SpecLicenseChecker) Name

func (*SpecLicenseChecker) Name() string

type SpecNameChecker

type SpecNameChecker struct{}

SpecNameChecker validates the name field against the spec's naming rules.

func (*SpecNameChecker) Check

func (*SpecNameChecker) Check(sk skill.Skill) (*CheckResult, error)

func (*SpecNameChecker) Name

func (*SpecNameChecker) Name() string

type SpecSecurityChecker

type SpecSecurityChecker struct{}

SpecSecurityChecker flags security risks in frontmatter string values.

func (*SpecSecurityChecker) Check

func (*SpecSecurityChecker) Name

func (*SpecSecurityChecker) Name() string

type SpecVersionChecker

type SpecVersionChecker struct{}

SpecVersionChecker recommends including a metadata.version field.

func (*SpecVersionChecker) Check

func (*SpecVersionChecker) Name

func (*SpecVersionChecker) Name() string

type StatusHolder

type StatusHolder interface {
	GetStatus() CheckStatus
}

StatusHolder is implemented by check Data types that carry a CheckStatus.

type TokenBudgetChecker

type TokenBudgetChecker struct {
	// Limit for SKILL.md tokens; 0 means use scoring.TokenSoftLimit
	Limit int
}

TokenBudgetChecker validates that SKILL.md is within its token budget.

func (*TokenBudgetChecker) Budget

Budget is a convenience wrapper that returns the typed data directly.

func (*TokenBudgetChecker) Check

func (c *TokenBudgetChecker) Check(sk skill.Skill) (*CheckResult, error)

func (*TokenBudgetChecker) Name

func (c *TokenBudgetChecker) Name() string

type TokenBudgetData

type TokenBudgetData struct {
	TokenCount int
	TokenLimit int
	Exceeded   bool
}

TokenBudgetData holds the structured output of a token budget check.

type TokenLimitFileResult

type TokenLimitFileResult struct {
	File     string
	Tokens   int
	Limit    int
	Pattern  string
	Exceeded bool
}

TokenLimitFileResult holds check results for a single file.

type TokenLimitsChecker

type TokenLimitsChecker struct {
	Config             TokenLimitsConfig // zero value triggers auto-loading from skill dir
	Paths              []string          // specific paths to check; nil scans skill dir
	Tokenizer          tokens.Tokenizer  // empty means use TokenizerDefault
	WorkspaceRelPrefix string            // skill dir relative to workspace root (e.g. "plugin/skills/azure-deploy")
}

TokenLimitsChecker validates that markdown files are within configured token limits.

func (*TokenLimitsChecker) Check

func (c *TokenLimitsChecker) Check(sk skill.Skill) (*CheckResult, error)

func (*TokenLimitsChecker) Limits

Limits is a convenience wrapper that returns the typed data directly.

func (*TokenLimitsChecker) Name

func (c *TokenLimitsChecker) Name() string

type TokenLimitsConfig

type TokenLimitsConfig struct {
	Description string         `json:"description,omitempty"`
	Defaults    map[string]int `json:"defaults"`
	Overrides   map[string]int `json:"overrides"`
}

TokenLimitsConfig holds token limit configuration.

func LoadLimitsConfig

func LoadLimitsConfig(dir string) (TokenLimitsConfig, error)

LoadLimitsConfig unmarshals dir/.token-limits.json or returns DefaultLimits. Note: callers should prefer .waza.yaml tokens.limits; this is the fallback path.

type TokenLimitsData

type TokenLimitsData struct {
	Results       []TokenLimitFileResult
	TotalFiles    int
	ExceededCount int
}

TokenLimitsData holds the structured output of a token limits check.

Jump to

Keyboard shortcuts

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