slash

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: AGPL-3.0 Imports: 9 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. Project-scoped commands shadow user-scoped commands which shadow built-ins; for MVP we only have built-ins so we register everything via Register.

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.

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 (`~/.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
⌂ 换网址