rules

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractRuleFrontmatterDescription

func ExtractRuleFrontmatterDescription(path string) string

ExtractRuleFrontmatterDescription parses YAML-style frontmatter at the head of a rule file and returns the `description:` value (case-insensitive). Returns the empty string if no frontmatter, no closing fence, no description key, or the file is unreadable. Exported so the parent-package shim and its tests can reach it.

func FindRuleSpec

func FindRuleSpec(deps Deps, agentsHome, scope, name string) (*platform.RuleFileSpec, error)

FindRuleSpec resolves <scope>/<name> to a platform.RuleFileSpec, emitting hint-aware errors via deps.UsageError / deps.ErrorWithHints for the empty and not-found cases. Exported so the parent-package shim and its tests can reach it.

func NewListCmd

func NewListCmd(deps Deps) *cobra.Command

NewListCmd / NewShowCmd / NewRemoveCmd build each subcommand standalone. Exported so the parent-package shim can wire them for cross-cutting RunE coverage tests.

func NewRemoveCmd

func NewRemoveCmd(deps Deps) *cobra.Command

func NewRulesCmd

func NewRulesCmd(deps Deps) *cobra.Command

NewRulesCmd builds the `da rules` command tree from injected dependencies. Mirrors agents.NewAgentsCmd / skills.NewSkillsCmd: helpers come from Deps so the subpackage stays independent of the parent commands/ package. The cobra-tree assembly lives in cmdutil so mcp/settings/rules share one implementation; the per-resource description lives in a single CanonicalFileSpec built by canonicalSpec (see list.go).

func NewShowCmd

func NewShowCmd(deps Deps) *cobra.Command

func RunList

func RunList(deps Deps, scope string) error

RunList lists canonical rule files for the given scope. Exported so the shim in commands/rules.go can delegate to it.

func RunRemove

func RunRemove(deps Deps, scope, name string) error

RunRemove deletes a canonical rule file from ~/.agents/rules/. Exported so the shim in commands/rules.go can delegate to it.

func RunShow

func RunShow(deps Deps, scope, name string) error

RunShow renders metadata for a single canonical rule file. Exported so the shim in commands/rules.go can delegate to it.

Types

type Deps

type Deps struct {
	Flags                 GlobalFlags
	ErrorWithHints        func(message string, hints ...string) error
	UsageError            func(message string, hints ...string) error
	MaximumNArgsWithHints func(n int, hints ...string) cobra.PositionalArgs
	ExactArgsWithHints    func(n int, hints ...string) cobra.PositionalArgs
}

Deps carries UX helpers from the commands package without an import cycle. Mirrors agents.Deps / skills.Deps so the extracted subpackages share the same shape. Only fields actually consumed by rules subcommands are present.

type GlobalFlags

type GlobalFlags struct {
	DryRun bool
	Yes    bool
	Force  bool
}

GlobalFlags mirrors the subset of commands.Flags used by rules subcommands. Kept as a parallel type to commands.GlobalFlags so the rules subpackage has no import on the parent commands/ package. Mirrors agents.GlobalFlags / skills.GlobalFlags.

Jump to

Keyboard shortcuts

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