skill

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIndex

func FormatIndex(skills []Skill) string

FormatIndex returns a pre-formatted skills index for the system prompt. Returns empty string if there are no skills.

Skills the model may not invoke are left out entirely: listing one would spend prompt tokens on every request of the session to advertise something the model cannot call. Those are reached by the user typing "/<name>".

func LaunchFork added in v0.35.0

func LaunchFork(ctx context.Context, s Skill, args []string, cfg ToolConfig, async bool, onUpdate func(core.Result)) (core.Result, error)

LaunchFork runs a forked skill as an isolated subagent. async is supplied by the caller so slash commands can stay async without holding the session lock, while load_skill foreground still blocks for the child result.

func Load

func Load(s Skill) (string, error)

Load reads the full SKILL.md content for a skill, without its frontmatter: the header configures moa, and feeding it to the model would spend tokens on keys it cannot act on.

Content past the cap is truncated with a marker rather than refused, so an oversized skill still works instead of failing at the moment it is invoked.

func NewTool

func NewTool(cwd string, cfg ...ToolConfig) core.Tool

NewTool creates the load_skill tool that lets the agent load skill content on demand, discovering skills from cwd on every call.

Reading disk per call rather than capturing a set keeps the tool honest about a workspace that changes while the session is open: a skill written minutes ago is loadable, and one deleted is gone.

Skills the model may not invoke are excluded, not just hidden from the prompt index: honouring a name it was not offered would leave "only the user invokes this" as a suggestion rather than a rule.

func RenderBody added in v0.35.0

func RenderBody(body string, args []string) string

RenderBody substitutes the invocation's arguments into the skill.

A skill that declares no placeholder still receives what the user typed, appended as a trailing line: dropping it silently would lose the only part of the invocation the user wrote by hand.

Types

type ForkFunc added in v0.35.0

type ForkFunc func(ctx context.Context, req ForkRequest, onUpdate func(core.Result)) (core.Result, error)

ForkFunc launches an isolated subagent for a forked skill. The implementation lives outside this package so skill does not import subagent.

type ForkRequest added in v0.35.0

type ForkRequest struct {
	Task          string
	Async         bool
	ReadOnlyFiles []string
}

ForkRequest is the isolated-child launch that load_skill and slash commands share. A background fork runs async so the parent keeps working, but its result still reaches the parent through the usual subagent completion path: the point of forking is to spare the parent the work, not the conclusion.

type Skill

type Skill struct {
	Name        string // directory name (e.g., "go-testing")
	DisplayName string // from first # heading in SKILL.md
	Description string // first paragraph after heading
	Dir         string // absolute path to skill directory

	// DisableModelInvocation keeps the skill out of the system prompt index and
	// out of the model's reach: only the user invokes it, with "/<name>". Use it
	// for skills that are occasionally useful but would otherwise cost tokens on
	// every request.
	DisableModelInvocation bool
	// UserInvocable is false for skills that are background knowledge rather than
	// an action worth offering in the slash menu. Defaults to true.
	UserInvocable bool

	// Context is "fork" to run the skill in an isolated subagent with no
	// inherited messages. Any other value (including empty) loads the body
	// inline, which is how every skill behaved before this field existed.
	Context string
	// Background, when true with Context=="fork", launches the child without
	// blocking: the parent keeps working and receives the child's result later,
	// through the usual subagent completion notification. Ignored for inline
	// skills. Defaults to false.
	Background bool
	// ParentTranscript is "snapshot" to freeze the parent's active transcript
	// branch and hand the child a path to that file. Defaults to none.
	ParentTranscript string
}

Skill represents a loadable knowledge pack.

func Discover

func Discover(cwd string) []Skill

Discover scans skill directories and returns available skills. Project-level skills (.moa/skills/) override global ones (~/.config/moa/skills/) when they share the same name. Results are sorted by name.

func (Skill) IsFork added in v0.35.0

func (s Skill) IsFork() bool

IsFork reports whether the skill runs as an isolated subagent.

func (Skill) ModelInvocable added in v0.35.0

func (s Skill) ModelInvocable() bool

ModelInvocable reports whether the model may load this skill on its own.

func (Skill) WantsParentSnapshot added in v0.35.0

func (s Skill) WantsParentSnapshot() bool

WantsParentSnapshot reports whether a forked skill should receive a frozen copy of the parent's active transcript branch.

type SnapshotFunc added in v0.35.0

type SnapshotFunc func() (path string, err error)

SnapshotFunc freezes the parent's active transcript branch and returns the absolute path of that file. Moa writes it once and does not rewrite it. Nil means this session cannot guarantee a complete history (the CLI); a skill that asked for a snapshot then errors instead of inventing evidence.

type ToolConfig added in v0.35.0

type ToolConfig struct {
	Fork     ForkFunc
	Snapshot SnapshotFunc
}

ToolConfig wires load_skill to the subagent runtime. Zero values keep the historical inline-only behaviour.

Jump to

Keyboard shortcuts

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