slash

package
v2.13.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(line string) (name, args string, ok bool)

Parse splits a `/foo bar baz` line into (name, rest). Returns ok=false if the line does not start with `/`.

Types

type Command

type Command interface {
	Name() string
	Description() string
	Run(ctx context.Context, args string) error
}

Command is a slash-command handler. Run is called with the trimmed arg string (everything after `/<name>`).

type Registry

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

Registry maps names to commands. Built-ins are registered first via Register and always win: user/project skills are added with RegisterIfAbsent so a cloned repo's `./.enso/skills/quit.md` can't silently hijack the built-in `/quit` (a trust/safety concern).

func NewRegistry

func NewRegistry() *Registry

NewRegistry constructs an empty registry.

func (*Registry) Get

func (r *Registry) Get(name string) Command

Get looks up a command by name (without leading slash).

func (*Registry) List

func (r *Registry) List() []Command

List returns all registered commands sorted by name.

func (*Registry) Register

func (r *Registry) Register(c Command)

Register adds (or replaces) a command by name. Use only for trusted, first-party commands (the built-ins); untrusted skills go through RegisterIfAbsent so they can't overwrite a built-in.

func (*Registry) RegisterIfAbsent

func (r *Registry) RegisterIfAbsent(c Command) bool

RegisterIfAbsent adds c only if no command with its name already exists, returning false on collision (the existing command is kept). Used for user/project skills so they shadow nothing already registered — built-ins, registered first, take precedence.

type Skill

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

Skill is a user-defined slash command loaded from disk. Frontmatter fields are surfaced via Description(); the body is a `text/template` rendered against `{ Args }` and submitted as the next user message.

The submitter receives both the rendered text AND the skill's `allowed-tools` list so the host can apply a per-turn registry restriction in addition to forwarding the message. Empty list = no restriction.

func LoadSkills

func LoadSkills(projectCwd string) ([]*Skill, error)

LoadSkills scans the user dir (`$XDG_CONFIG_HOME/enso/skills`) and the project dir (`./.enso/skills`) for `*.md` files and returns parsed Skill values. Project skills shadow user skills on name collision.

func (*Skill) AllowedTools

func (s *Skill) AllowedTools() []string

func (*Skill) Description

func (s *Skill) Description() string

func (*Skill) Name

func (s *Skill) Name() string

func (*Skill) Run

func (s *Skill) Run(ctx context.Context, args string) error

func (*Skill) SetSubmitter

func (s *Skill) SetSubmitter(submit func(text string, allowedTools []string)) *Skill

SetSubmitter binds the skill to a callback that injects the rendered text as the next user message and, if non-empty, applies the skill's `allowed-tools` restriction for that turn. Returns the same skill for chaining.

type SkillFrontmatter

type SkillFrontmatter struct {
	Name         string   `yaml:"name"`
	Description  string   `yaml:"description"`
	AllowedTools []string `yaml:"allowed-tools"`
	Model        string   `yaml:"model"`
}

SkillFrontmatter is the YAML schema parsed from each skill file.

Jump to

Keyboard shortcuts

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