skills

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSkillDirectory    = ".seshat/skills"
	DefaultCommandsDirectory = ".seshat/commands"
	BundledSkillExtractDir   = ".seshat/bundled-skills"
)
View Source
const DefaultMaxSkills = 50
View Source
const SkillToolName = "skill"

Variables

This section is empty.

Functions

func ActivateConditionalSkillsForPaths

func ActivateConditionalSkillsForPaths(filePaths []string, cwd string) []string

func ClearBundledSkills

func ClearBundledSkills()

func ClearSkillCaches

func ClearSkillCaches()

func CoerceDescriptionToString

func CoerceDescriptionToString(value interface{}, skillName string) *string

func DiscoverSkillDirsForPaths

func DiscoverSkillDirsForPaths(filePaths []string, cwd string) []string

func ExtractDescriptionFromMarkdown

func ExtractDescriptionFromMarkdown(content string, fallbackLabel string) string

func FormatSkillsList

func FormatSkillsList(skills []Skill) string

func GetBuiltinSkillsPath

func GetBuiltinSkillsPath() string

func GetBundledSkillsRoot

func GetBundledSkillsRoot() string

func GetMCPHealth

func GetMCPHealth() map[string]string

func GetMCPServers

func GetMCPServers() []string

func GetManagedSkillsPath

func GetManagedSkillsPath() string

GetManagedSkillsPath returns the directory for admin-managed (policy) skills. Respects SESHAT_RUNTIME_ROOT so the path moves with the deployment.

func GetProjectCommandsPath

func GetProjectCommandsPath(projectDir string) string

func GetProjectSkillsPath

func GetProjectSkillsPath(projectDir string) string

func GetPrompt

func GetPrompt() string

func GetPromptWithSkills

func GetPromptWithSkills(skillsList string) string

func GetSkillReposPath

func GetSkillReposPath() string

func GetSkillsRootPath

func GetSkillsRootPath() string

func GetUserSkillsPath

func GetUserSkillsPath() string

GetUserSkillsPath returns the default single-user skill path (legacy CLI mode).

func GetUserSkillsPathForUser

func GetUserSkillsPathForUser(userID string) string

func InvalidateSkillCache

func InvalidateSkillCache()

func IsMCPEnabled

func IsMCPEnabled() bool

func NotifySkillChange

func NotifySkillChange(added []string, removed []string)

func OnSkillChange

func OnSkillChange(callback SkillChangeCallback)

func ParseArgumentNames

func ParseArgumentNames(value interface{}) []string

func ParseBooleanFrontmatter

func ParseBooleanFrontmatter(value interface{}) bool

func ParseEffortValue

func ParseEffortValue(value string) string

func ParsePreambleTier

func ParsePreambleTier(value interface{}) int

ParsePreambleTier converts a frontmatter preamble-tier value to an int.

0 = unset (backward-compatible default: inject base dir)
1 = basic    — skill content only, no extra context
2 = standard — + working directory header
3 = full     — + working directory + full context hint

func ParseStringList

func ParseStringList(value interface{}) []string

func ReadSkillEnabled

func ReadSkillEnabled(path string) bool

ReadSkillEnabled reads the user-invocable value from a skill.md file on disk. Returns true if the file cannot be read or the field is absent.

func RegisterBundledSkill

func RegisterBundledSkill(def BundledSkillDefinition)

func RegisterMCPSkillBuilder

func RegisterMCPSkillBuilder(builder MCPSkillBuilder)

func RegisterSkillAlias

func RegisterSkillAlias(alias string, target string)

func ResolveSkillAlias

func ResolveSkillAlias(name string) string

func SetMCPManager

func SetMCPManager(manager *mcp.MCPClientManager)

func SplitPathInFrontmatter

func SplitPathInFrontmatter(paths interface{}) []string

func SubstituteArguments

func SubstituteArguments(content string, args string, argumentNames []string) string

func SubstituteSeshatVariables

func SubstituteSeshatVariables(content string, skillDir string, sessionID string) string

func ValidateSkillPath

func ValidateSkillPath(skillPath string) error

Types

type BundledSkillDefinition

type BundledSkillDefinition struct {
	Name                   string
	Description            string
	Aliases                []string
	WhenToUse              string
	ArgumentHint           string
	AllowedTools           []string
	Model                  string
	DisableModelInvocation bool
	UserInvocable          bool
	IsEnabled              func() bool
	Hooks                  *HooksSettings
	Context                ExecutionContext
	Agent                  string
	Effort                 string
	Files                  map[string]string
	Triggers               []string
	GetPromptForCommand    func(args string, ctx context.Context) ([]ContentBlock, error)
}

type ContentBlock

type ContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

func ExecuteSkillPrompt

func ExecuteSkillPrompt(skill Skill, args string, ctx context.Context) ([]ContentBlock, error)

type ExecutionContext

type ExecutionContext string
const (
	ExecutionContextInline ExecutionContext = "inline"
	ExecutionContextFork   ExecutionContext = "fork"
)

type FileSkillLoader

type FileSkillLoader struct {
	Directory string
	Source    SettingSource
	// CollectionRoot, when non-empty, is the repo root that owns this skill
	// collection. It is injected into skill prompts so the AI can resolve
	// paths relative to the repo root (e.g. data/, scripts/).
	CollectionRoot string
}

func NewCollectionSkillLoader

func NewCollectionSkillLoader(repoRoot string, source SettingSource) *FileSkillLoader

NewCollectionSkillLoader creates a loader for a skill repo whose skills reference files relative to the repo root (e.g. data/, scripts/). directory must be the repo root — each subdirectory containing a SKILL.md becomes one skill, and the repo root is injected as the base path.

func NewFileSkillLoader

func NewFileSkillLoader(directory string) *FileSkillLoader

func NewFileSkillLoaderWithSource

func NewFileSkillLoaderWithSource(directory string, source SettingSource) *FileSkillLoader

func (*FileSkillLoader) GetSkill

func (l *FileSkillLoader) GetSkill(name string) (*Skill, error)

func (*FileSkillLoader) GetSkillDirCommands

func (l *FileSkillLoader) GetSkillDirCommands(cwd string) ([]Skill, error)

func (*FileSkillLoader) GetSkillDirCommandsForUser

func (l *FileSkillLoader) GetSkillDirCommandsForUser(cwd string, userID string) ([]Skill, error)

func (*FileSkillLoader) LoadSkills

func (l *FileSkillLoader) LoadSkills() ([]Skill, error)

type FrontmatterData

type FrontmatterData struct {
	Name                   interface{} `yaml:"name"`
	Description            interface{} `yaml:"description"`
	WhenToUse              string      `yaml:"when_to_use"`
	ArgumentHint           string      `yaml:"argument-hint"`
	Arguments              interface{} `yaml:"arguments"`
	AllowedTools           interface{} `yaml:"allowed-tools"`
	Model                  string      `yaml:"model"`
	DisableModelInvocation interface{} `yaml:"disable-model-invocation"`
	UserInvocable          interface{} `yaml:"user-invocable"`
	Version                string      `yaml:"version"`
	Context                string      `yaml:"context"`
	Agent                  string      `yaml:"agent"`
	Effort                 string      `yaml:"effort"`
	Paths                  interface{} `yaml:"paths"`
	Hooks                  interface{} `yaml:"hooks"`
	Shell                  interface{} `yaml:"shell"`

	// Triggers is a list of natural-language phrases that should auto-activate
	// this skill (e.g. ["browse this page", "take a screenshot"]). Inspired by
	// gstack. When the user's prompt contains any trigger phrase, the skill is
	// expanded automatically — no /slash-command needed.
	Triggers interface{} `yaml:"triggers,omitempty"`

	// PreambleTier controls how much context is prepended to the expanded skill
	// prompt. Accepts int (1/2/3) or string ("basic"/"standard"/"full").
	//   1 / basic    — skill content only (default)
	//   2 / standard — + working directory info
	//   3 / full     — + working directory + user preferences block
	PreambleTier interface{} `yaml:"preamble-tier,omitempty"`

	// Requires lists external dependencies the skill needs (Node.js, Python
	// packages, system tools). The agent checks them at runtime and requests
	// user permission before installing any missing dependency.
	Requires interface{} `yaml:"requires,omitempty"`
}

func ParseFrontmatter

func ParseFrontmatter(content string, filePath string) (FrontmatterData, string)

type FrontmatterShell

type FrontmatterShell struct {
	Before     []string `yaml:"before,omitempty"`
	After      []string `yaml:"after,omitempty"`
	OnError    []string `yaml:"on_error,omitempty"`
	OnComplete []string `yaml:"on_complete,omitempty"`
}

func ParseShellFrontmatter

func ParseShellFrontmatter(value interface{}, skillName string) *FrontmatterShell

type HooksSettings

type HooksSettings struct {
	BeforeTool  []string `yaml:"before_tool,omitempty"`
	AfterTool   []string `yaml:"after_tool,omitempty"`
	Before      []string `yaml:"before,omitempty"`
	After       []string `yaml:"after,omitempty"`
	OnError     []string `yaml:"on_error,omitempty"`
	OnCancel    []string `yaml:"on_cancel,omitempty"`
	OnComplete  []string `yaml:"on_complete,omitempty"`
	ToolAllowed []string `yaml:"tool_allowed,omitempty"`
	ToolDenied  []string `yaml:"tool_denied,omitempty"`
}

func ParseHooksFromFrontmatter

func ParseHooksFromFrontmatter(value interface{}) *HooksSettings

type LoadedFrom

type LoadedFrom string
const (
	LoadedFromCommandsDeprecated LoadedFrom = "commands_DEPRECATED"
	LoadedFromSkills             LoadedFrom = "skills"
	LoadedFromPlugin             LoadedFrom = "plugin"
	LoadedFromManaged            LoadedFrom = "managed"
	LoadedFromBundled            LoadedFrom = "bundled"
	LoadedFromMCP                LoadedFrom = "mcp"
)

type MCPSkillBuilder

type MCPSkillBuilder struct {
	CreateSkillCommand     func() interface{}
	ParseFrontmatterFields func(interface{}, string, string) interface{}
}

type SettingSource

type SettingSource string
const (
	SettingSourcePolicySettings  SettingSource = "policySettings"
	SettingSourceUserSettings    SettingSource = "userSettings"
	SettingSourceProjectSettings SettingSource = "projectSettings"
	SettingSourcePlugin          SettingSource = "plugin"
)

type Skill

type Skill struct {
	Name                        string
	DisplayName                 string
	Description                 string
	HasUserSpecifiedDescription bool
	AllowedTools                []string
	ArgumentHint                string
	ArgNames                    []string
	WhenToUse                   string
	Version                     string
	Model                       string
	DisableModelInvocation      bool
	UserInvocable               bool
	Context                     ExecutionContext
	Agent                       string
	Effort                      string
	Paths                       []string
	Content                     string // raw markdown body, used by ExecuteSkillPrompt fallback
	ContentLength               int
	IsHidden                    bool
	ProgressMessage             string
	Source                      SkillSource
	LoadedFrom                  LoadedFrom
	SkillRoot                   string
	Hooks                       *HooksSettings
	Shell                       *FrontmatterShell

	// Triggers holds natural-language phrases that auto-activate this skill
	// without a slash command (e.g. "browse this page", "take a screenshot").
	Triggers []string
	// PreambleTier controls context injection depth: 0=default (base dir),
	// 1=basic (none), 2=standard (base dir), 3=full (base dir + context hint).
	PreambleTier int
	// Scope indicates the ownership/access level of this skill.
	Scope SkillScope
	// Requires lists external dependencies that must be present before the
	// skill runs. The agent verifies each and requests user permission to
	// install any that are missing.
	Requires []SkillRequirement

	GetPromptForCommand func(args string, ctx context.Context) ([]ContentBlock, error)
}

func CreateSkillFromFrontmatter

func CreateSkillFromFrontmatter(frontmatter FrontmatterData, markdownContent string, skillName string, baseDir string, loadedFrom string, source SettingSource) (Skill, error)

func DiscoverMCPSkills

func DiscoverMCPSkills(ctx context.Context) ([]Skill, error)

func GetAllSkills

func GetAllSkills(cwd string) ([]Skill, error)

func GetAllSkillsForUser

func GetAllSkillsForUser(cwd string, userID string) ([]Skill, error)

func GetBundledSkills

func GetBundledSkills() []Skill

func GetSkillsForContext

func GetSkillsForContext(cwd string, filePaths []string, userID string) ([]Skill, error)

GetSkillsForContext returns skills that are active for the given file context. Skills with no Paths restriction are always included. Skills with Paths are included only when at least one of the provided filePaths matches a pattern. When filePaths is empty, all skills are returned (no filtering).

func LoadMCPSkills

func LoadMCPSkills(serverName string) ([]Skill, error)

func MatchTrigger

func MatchTrigger(userInput string, skills []Skill) *Skill

MatchTrigger returns the first skill whose trigger phrases match userInput, or nil if no skill matches. Matching is case-insensitive substring search.

func (*Skill) MatchesTrigger

func (s *Skill) MatchesTrigger(userInput string) bool

MatchesTrigger reports whether userInput contains any of the skill's trigger phrases (case-insensitive substring match).

type SkillAlias

type SkillAlias struct {
	Alias  string
	Target string
}

func GetSkillAliases

func GetSkillAliases() []SkillAlias

type SkillChangeCallback

type SkillChangeCallback func(added []string, removed []string)

type SkillInput

type SkillInput struct {
	Skill string `json:"skill"`
	Args  string `json:"args,omitempty"`
}

type SkillLoader

type SkillLoader interface {
	LoadSkills() ([]Skill, error)
	GetSkill(name string) (*Skill, error)
	GetSkillDirCommands(cwd string) ([]Skill, error)
}

type SkillOutput

type SkillOutput struct {
	Skill   string `json:"skill"`
	Args    string `json:"args,omitempty"`
	Output  string `json:"output"`
	Success bool   `json:"success"`
}

type SkillRequirement

type SkillRequirement struct {
	// Type is a human-readable label: "node", "python", "system", etc.
	Type string `yaml:"type"`
	// Check is a shell command that exits 0 when the dep is satisfied.
	// Example: "node --version", "python3 -c 'import pptx'"
	Check string `yaml:"check"`
	// InstallCmd is run (with user permission) when Check fails.
	// Supports ${SESHAT_SKILL_DIR} substitution.
	InstallCmd string `yaml:"install-cmd"`
	// Packages lists the packages for display purposes only.
	Packages []string `yaml:"packages,omitempty"`
	// Optional marks the requirement as non-blocking: the skill runs even if
	// the dep is missing, but the agent is told some features may be degraded.
	Optional bool `yaml:"optional,omitempty"`
}

SkillRequirement declares an external dependency (Node.js, Python package…) that must be present before the skill can run. If any requirement fails its check command, the skill prompt includes a pre-flight section instructing the agent to request user permission before installing.

func ParseRequires

func ParseRequires(value interface{}) []SkillRequirement

ParseRequires converts a frontmatter requires value into a slice of SkillRequirement. Accepts either a YAML list of maps or a single map.

type SkillScope

type SkillScope string

SkillScope controls who can invoke a skill and what context it can access.

const (
	ScopeUser   SkillScope = "user"   // created/owned by the end-user
	ScopeRepo   SkillScope = "repo"   // scoped to the current project
	ScopeSystem SkillScope = "system" // platform-level (plugins, MCP)
	ScopeAdmin  SkillScope = "admin"  // policy-managed (admin-controlled)
)

type SkillSource

type SkillSource string
const (
	SourceBundled  SkillSource = "bundled"
	SourceCommands SkillSource = "commands"
	SourcePlugin   SkillSource = "plugin"
	SourceManaged  SkillSource = "managed"
	SourceMCP      SkillSource = "mcp"
)

type SkillTool

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

func NewSkillTool

func NewSkillTool(loader SkillLoader) *SkillTool

func (*SkillTool) BackfillInput

func (t *SkillTool) BackfillInput(ctx context.Context, input map[string]any) map[string]any

func (*SkillTool) Call

func (t *SkillTool) Call(ctx context.Context, input contract.CallInput, permissionCheck types.CanUseToolFn) (contract.CallResult, error)

func (*SkillTool) CheckPermissions

func (t *SkillTool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx contract.ToolUseContext) types.PermissionResult

func (*SkillTool) Definition

func (t *SkillTool) Definition() contract.Definition

func (*SkillTool) Description

func (t *SkillTool) Description(ctx context.Context) (string, error)

func (*SkillTool) FormatResult

func (t *SkillTool) FormatResult(data any) string

func (*SkillTool) IsConcurrencySafe

func (t *SkillTool) IsConcurrencySafe(input map[string]any) bool

func (*SkillTool) IsEnabled

func (t *SkillTool) IsEnabled() bool

func (*SkillTool) IsReadOnly

func (t *SkillTool) IsReadOnly(input map[string]any) bool

func (*SkillTool) SetCwd

func (t *SkillTool) SetCwd(cwd string)

func (*SkillTool) SetUserID

func (t *SkillTool) SetUserID(userID string)

func (*SkillTool) ValidateInput

func (t *SkillTool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)

type SkillWithPath

type SkillWithPath struct {
	Skill    Skill
	FilePath string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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