skills

package
v1.130.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolNameReadSkill     = "read_skill"
	ToolNameReadSkillFile = "read_skill_file"
	ToolNameRunSkill      = "run_skill"
)

Variables

This section is empty.

Functions

func BuildSkillSystemMessage added in v1.62.0

func BuildSkillSystemMessage(prepared *PreparedSkillFork, attachedFiles []string) string

BuildSkillSystemMessage returns the system prompt of a forked skill sub-session. It avoids the task-delegation boilerplate from buildTaskSystemMessage (which references <task> / "team of agents") since skills aren't delegations. attachedFiles, when non-empty, exposes parent-attached files by absolute path.

func BuildSkillUserMessage added in v1.62.0

func BuildSkillUserMessage(prepared *PreparedSkillFork) string

BuildSkillUserMessage formats a PreparedSkillFork as the implicit user message of a forked sub-session. It mirrors the inline `<skill name=...>` envelope used by ResolveSkillCommand for non-fork skills, strips the YAML frontmatter (already consumed by the runtime), and surfaces a non-empty Task as a "User's request:" header.

Types

type PreparedSkillFork

type PreparedSkillFork struct {
	// SkillName is the validated skill name, suitable for span attributes,
	// log fields, and sub-session titles ("Skill: <name>").
	SkillName string
	// Task is the caller-supplied task description, intended to be used as
	// the implicit user message of the child session.
	Task string
	// Content is the expanded SKILL.md content. Wrap with
	// BuildSkillUserMessage to use as the child's first user message.
	Content string
	// Model is the optional model override declared in the SKILL.md
	// frontmatter. Empty means "use the parent agent's current model".
	Model string
	// AllowedTools, when non-empty, restricts the sub-session to the parent
	// agent's tools whose names match an entry (glob or exact). Empty means
	// the parent agent's full tool set is inherited.
	AllowedTools []string
	// ToolSets holds the additional toolsets the skill exposes in its
	// sub-session, on top of the (optionally filtered) inherited tools.
	ToolSets []tools.ToolSet
}

PreparedSkillFork carries the validated and expanded data needed to launch a skill as an isolated sub-agent. Callers (typically the runtime) use it to build the child session; this lets the skill-specific business rules (lookup, fork validation, content expansion) live with the toolset rather than the runtime.

type RunSkillArgs

type RunSkillArgs struct {
	Name string `json:"name" jsonschema:"The name of the skill to run in a forked context"`
	Task string `json:"task" jsonschema:"A clear description of the task the skill should achieve"`
}

RunSkillArgs specifies the parameters for the run_skill tool.

type ToolSet added in v1.60.0

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

ToolSet provides the read_skill and read_skill_file tools that let an agent load skill content and supporting resources by name. It hides whether a skill is local or remote — the agent just sees a name and description.

func New added in v1.60.0

func New(loadedSkills []skills.Skill, workingDir string) *ToolSet

func (*ToolSet) FindSkill added in v1.60.0

func (s *ToolSet) FindSkill(name string) *skills.Skill

FindSkill returns the skill with the given name, or nil if not found.

func (*ToolSet) Instructions added in v1.60.0

func (s *ToolSet) Instructions() string

func (*ToolSet) Name added in v1.98.0

func (s *ToolSet) Name() string

Name implements tools.Named; loader-created, so no registry WithName wrapper.

func (*ToolSet) PrepareForkSubSession added in v1.60.0

func (s *ToolSet) PrepareForkSubSession(ctx context.Context, args RunSkillArgs, rt tools.Runtime) (*PreparedSkillFork, *tools.ToolCallResult, error)

PrepareForkSubSession validates a run_skill request and loads the expanded skill content. It returns either a populated PreparedSkillFork, or a ToolCallResult describing why the call cannot proceed (skill missing, skill not configured for fork mode, content read failure). rt gates the commands the skill body embeds — see ToolSet.ReadSkillContent. The caller is responsible for the runtime-specific orchestration (sub-session creation, tracing, event forwarding).

func (*ToolSet) ReadSkillContent added in v1.60.0

func (s *ToolSet) ReadSkillContent(ctx context.Context, name string, rt tools.Runtime) (string, error)

ReadSkillContent returns the content of a skill's SKILL.md by name, or the body carried in the agent config for an inline skill. For local and inline skills, it expands any !`command` patterns in the content by executing the commands and replacing the patterns with their stdout output. Every command is submitted to rt for approval first: a skill body is data, not agent config, so a command hidden in one must never run unannounced. Command expansion is disabled for remote skills to prevent arbitrary code execution on behalf of a third-party server.

func (*ToolSet) ReadSkillFile added in v1.60.0

func (s *ToolSet) ReadSkillFile(skillName, relativePath string) (string, error)

ReadSkillFile returns the content of a supporting file within a skill. The path is relative to the skill's base directory (e.g. "references/FORMS.md").

func (*ToolSet) SetForkToolSets added in v1.89.0

func (s *ToolSet) SetForkToolSets(m map[string][]tools.ToolSet)

SetForkToolSets records the additional toolsets each fork skill exposes while running in its sub-session, keyed by skill name. Called by the loader after resolving the skills' declared toolset names.

func (*ToolSet) Skills added in v1.60.0

func (s *ToolSet) Skills() []skills.Skill

Skills returns the loaded skills (used by the app layer for slash commands).

func (*ToolSet) Tools added in v1.60.0

func (s *ToolSet) Tools(context.Context) ([]tools.Tool, error)

Jump to

Keyboard shortcuts

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