spec

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SkillsRulesPromptLoadOnly = skillsToolsLoadOnly + "\n" + skillsRulesCommon

	SkillsRulesPromptWithoutRunScript = skillsToolsBase + "\n" + skillsRulesCommon

	SkillsRulesPromptAll = skillsToolsAllWithRunScript + "\n" + skillsRulesCommon
)
View Source
const FuncIDSkillsLoad llmtoolsgoSpec.FuncID = "github.com/flexigpt/agentskills-go/skills-load"
View Source
const FuncIDSkillsReadResource llmtoolsgoSpec.FuncID = "github.com/flexigpt/agentskills-go/skills-readresource"
View Source
const FuncIDSkillsRunScript llmtoolsgoSpec.FuncID = "github.com/flexigpt/agentskills-go/skills-runscript"
View Source
const FuncIDSkillsUnload llmtoolsgoSpec.FuncID = "github.com/flexigpt/agentskills-go/skills-unload"
View Source
const MaxSkillResourceLocations = 1024

MaxSkillResourceLocations is the maximum number of provider-defined resource locations included in skill metadata. TotalCount still reports the full provider-reported count.

Variables

View Source
var (
	// ErrInvalidArgument indicates the caller provided an invalid/missing argument.
	ErrInvalidArgument = errors.New("invalid argument")

	// ErrSkillNotFound indicates the requested skill does not exist in the catalog/session.
	ErrSkillNotFound = errors.New("skill not found")

	// ErrSkillAlreadyExists indicates a skill with the same key already exists.
	ErrSkillAlreadyExists = errors.New("skill already exists")

	// ErrProviderNotFound indicates no provider is registered for the requested provider type.
	ErrProviderNotFound = errors.New("provider not found")

	// ErrSkillNotActive indicates the requested skill is not currently active/loaded in the session.
	ErrSkillNotActive = errors.New("skill not active")

	// ErrRunScriptUnsupported indicates the selected provider does not support running scripts.
	ErrRunScriptUnsupported = errors.New("runScript unsupported")

	// ErrSessionNotFound indicates the requested session does not exist.
	ErrSessionNotFound = errors.New("session not found")

	// ErrSkillNotAllowed indicates the requested skill is not permitted by the session allowlist.
	ErrSkillNotAllowed = errors.New("skill not allowed")
)

Package-level sentinel errors returned by catalog/session/provider operations.

Functions

func SkillsLoadTool

func SkillsLoadTool() llmtoolsgoSpec.Tool

func SkillsReadResourceTool added in v0.3.0

func SkillsReadResourceTool() llmtoolsgoSpec.Tool

func SkillsRunScriptTool

func SkillsRunScriptTool() llmtoolsgoSpec.Tool

func SkillsUnloadTool

func SkillsUnloadTool() llmtoolsgoSpec.Tool

Types

type LoadArgs

type LoadArgs struct {
	Skills []SkillHandle `json:"skills"`
	Mode   LoadMode      `json:"mode,omitempty"` // default: replace
}

type LoadMode

type LoadMode string

LoadMode controls how skills-load updates the active list.

const (
	LoadModeReplace LoadMode = "replace"
	LoadModeAdd     LoadMode = "add"
)

type LoadOut added in v0.2.0

type LoadOut struct {
	ActiveSkills []SkillHandle `json:"activeSkills"`
}

type ProviderSkillIndexRecord added in v0.7.0

type ProviderSkillIndexRecord struct {
	Key ProviderSkillKey `json:"key"`

	Name        string `json:"name"`
	Description string `json:"description"`
	DisplayName string `json:"displayName,omitempty"`

	// Insert is parsed from SKILL.md frontmatter field "insert".
	// Missing/empty defaults to "instructions".
	Insert SkillInsert `json:"insert"`

	Arguments []SkillArgument `json:"arguments,omitempty"`

	Resources SkillResourceInfo `json:"resources"`

	RawFrontmatter map[string]any `json:"rawFrontmatter,omitempty"`

	Warnings []string `json:"warnings,omitempty"`

	Digest    string `json:"digest,omitempty"`
	SkillBody string `json:"skillBody,omitempty"` // optional cached body (e.g. SKILL.md without frontmatter)
}

ProviderSkillIndexRecord is the INTERNAL catalog record returned by providers during indexing. It carries the canonical ProviderSkillKey used internally.

type ProviderSkillKey added in v0.7.0

type ProviderSkillKey struct {
	Type     string `json:"type"`
	Name     string `json:"name"`
	Location string `json:"location"`
}

ProviderSkillKey is the INTERNAL canonical identity used by the catalog/session/provider plumbing.

Providers may canonicalize Location (e.g. abs+EvalSymlinks for fs). This canonical form MUST NOT be exposed to host/lifecycle APIs.

type ReadResourceArgs added in v0.3.0

type ReadResourceArgs struct {
	SkillName     string `json:"skillName"`
	SkillLocation string `json:"skillLocation"`

	// ResourceLocation is provider-defined; for fs providers this is typically a relative file path.
	ResourceLocation string `json:"resourceLocation"`

	Encoding ReadResourceEncoding `json:"encoding,omitempty"` // default: text
}

type ReadResourceEncoding added in v0.3.0

type ReadResourceEncoding string
const (
	ReadResourceEncodingText   ReadResourceEncoding = "text"
	ReadResourceEncodingBinary ReadResourceEncoding = "binary"
)

type RenderSkillBodyResult added in v0.17.0

type RenderSkillBodyResult struct {
	Text string `json:"text"`

	AppliedArguments    map[string]string `json:"appliedArguments,omitempty"`
	UnknownPlaceholders []string          `json:"unknownPlaceholders,omitempty"`
	Warnings            []string          `json:"warnings,omitempty"`
}

RenderSkillBodyResult is the low-level result of rendering declared arguments into a skill body.

type RenderSkillOut added in v0.17.0

type RenderSkillOut struct {
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	DisplayName string      `json:"displayName,omitempty"`
	Insert      SkillInsert `json:"insert"`

	Resources SkillResourceInfo `json:"resources"`

	Text string `json:"text"`

	Arguments        []SkillArgument   `json:"arguments,omitempty"`
	AppliedArguments map[string]string `json:"appliedArguments,omitempty"`

	RawFrontmatter map[string]any `json:"rawFrontmatter,omitempty"`
	Warnings       []string       `json:"warnings,omitempty"`
}

RenderSkillOut is returned by Runtime.RenderSkill.

type RunScriptArgs

type RunScriptArgs struct {
	SkillName     string `json:"skillName"`
	SkillLocation string `json:"skillLocation"`

	// ScriptLocation is provider-defined; for fs providers this is typically a relative script file path.
	ScriptLocation string `json:"scriptLocation"`

	Args []string          `json:"args,omitempty"`
	Env  map[string]string `json:"env,omitempty"`

	// WorkDir is provider-defined; for fs providers this is typically a relative directory under the skill base.
	WorkDir string `json:"workDir,omitempty"`
}

type RunScriptOut added in v0.2.0

type RunScriptOut struct {
	Location   string `json:"location"`
	ExitCode   int    `json:"exitCode"`
	Stdout     string `json:"stdout,omitempty"`
	Stderr     string `json:"stderr,omitempty"`
	TimedOut   bool   `json:"timedOut,omitempty"`
	DurationMS int64  `json:"durationMS,omitempty"`
}

type SessionID

type SessionID string

SessionID identifies a runtime session (UUIDv7 string).

type SkillActivity added in v0.8.0

type SkillActivity string

SkillActivity controls whether SkillsPrompt includes active, inactive, or both sets.

const (
	// SkillActivityAny returns both:
	//   - <activeSkills> (if SessionID is set)
	//   - <availableSkills> (inactive skills if SessionID is set; otherwise all skills)
	SkillActivityAny SkillActivity = "any"

	// SkillActivityActive returns only <activeSkills>. Requires SessionID.
	SkillActivityActive SkillActivity = "active"

	// SkillActivityInactive returns only <availableSkills> for inactive skills. If SessionID
	// is empty, all skills are treated as inactive.
	SkillActivityInactive SkillActivity = "inactive"
)

type SkillArgument added in v0.17.0

type SkillArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Default     string `json:"default,omitempty"`
}

SkillArgument is a named string argument supported by the FlexiGPT skill extension.

Values are intentionally string-only. Consumers may build richer UI validation on top, but the runtime only renders strings into the skill body.

type SkillDef added in v0.7.0

type SkillDef struct {
	Type     string `json:"type"`
	Name     string `json:"name"`
	Location string `json:"location"`
}

SkillDef is the host/lifecycle-facing skill definition.

This is the ONLY type that should be used in lifecycle events: add/remove/list skills and session creation configuration.

Location is the exact user-provided base location string (not canonicalized).

type SkillHandle

type SkillHandle struct {
	// Name is the catalog-computed LLM-visible name (usually the real name;
	// may be disambiguated with an opaque suffix like "my-skill#1a2b3c4d").
	Name string `json:"name"`

	// Location is the user-provided and provider-interpreted base location for the skill.
	Location string `json:"location"`
}

SkillHandle is the LLM-facing selector for a skill.

IMPORTANT CONTRACT:

  • This is ONLY for LLM prompt/tooling APIs (load/read/run/unload).
  • It MUST NOT be used for host/lifecycle operations (add/remove/list).
  • It MUST NOT leak internal canonicalization.

Name is computed by the catalog (may include an opaque suffix to disambiguate). Location is the user-provided base location string as registered (not canonicalized).

type SkillInsert added in v0.17.0

type SkillInsert string

SkillInsert describes where a rendered SKILL.md body should be inserted by the consumer.

The default is SkillInsertInstructions. This keeps normal Agent Skills behavior: a skill body is instruction/context material unless it explicitly opts into user insertion.

const (
	// SkillInsertInstructions means the rendered body is instruction/context material.
	SkillInsertInstructions SkillInsert = "instructions"
	// SkillInsertUserMessage means the rendered body should be placed in the user-message body.
	SkillInsertUserMessage SkillInsert = "user-message"
)

type SkillProvider

type SkillProvider interface {
	// Type returns the provider type key (e.g. "fs", "s3").
	Type() string

	// Index validates and returns metadata for the skill identified by def.
	// Providers may canonicalize Location in the returned ProviderSkillIndexRecord.Key.
	Index(ctx context.Context, def SkillDef) (ProviderSkillIndexRecord, error)

	// LoadBody returns the prompt-injectable SKILL.md body (frontmatter removed).
	LoadBody(ctx context.Context, key ProviderSkillKey) (string, error)

	// ReadResource reads a resource relative to the skill base location.
	// The meaning/format of resourceLocation is provider-defined (for fs it's typically a relative file path).
	ReadResource(
		ctx context.Context,
		key ProviderSkillKey,
		resourceLocation string,
		encoding ReadResourceEncoding,
	) ([]llmtoolsgoSpec.ToolOutputUnion, error)

	// RunScript executes a provider-scoped script identified by scriptLocation.
	// Providers define/enforce constraints (e.g. must be under scripts/).
	RunScript(
		ctx context.Context,
		key ProviderSkillKey,
		scriptLocation string,
		args []string,
		env map[string]string,
		workDir string,
	) (RunScriptOut, error)
}

type SkillRecord

type SkillRecord struct {
	Def SkillDef `json:"def"`

	Name        string `json:"name"`
	Description string `json:"description"`
	DisplayName string `json:"displayName,omitempty"`

	// Insert is the FlexiGPT insertion hint parsed from SKILL.md.
	// Defaults to "instructions".
	Insert SkillInsert `json:"insert"`

	Arguments []SkillArgument `json:"arguments,omitempty"`

	Resources SkillResourceInfo `json:"resources"`

	// RawFrontmatter preserves the parsed SKILL.md YAML frontmatter for callers that want
	// compatibility metadata that this runtime does not interpret.
	RawFrontmatter map[string]any `json:"rawFrontmatter,omitempty"`

	Warnings []string `json:"warnings,omitempty"`

	Digest string `json:"digest,omitempty"`
}

SkillRecord is the catalog record for a skill.

type SkillResourceInfo added in v0.18.0

type SkillResourceInfo struct {
	// HasResources is true when the provider advertises at least one additional resource.
	HasResources bool `json:"hasResources"`

	// TotalCount is the total number of additional resources found, even when Locations is truncated.
	TotalCount int `json:"totalCount"`

	// Locations contains up to MaxSkillResourceLocations provider-defined resource locations.
	Locations []string `json:"locations,omitempty"`

	// MoreLocations is true when more locations exist than are included in Locations.
	MoreLocations bool `json:"moreLocations"`
}

SkillResourceInfo describes additional provider-defined resources associated with a skill.

Locations are provider-defined values intended to be passed back as resourceLocation to skills-readresource. For an fs provider they are typically slash-separated relative file paths, but non-fs providers may use repository paths, embedded resource names, object IDs, VM resource handles, or any other provider-defined location format.

type UnloadArgs

type UnloadArgs struct {
	Skills []SkillHandle `json:"skills,omitempty"`
	All    bool          `json:"all,omitempty"`
}

type UnloadOut added in v0.2.0

type UnloadOut struct {
	ActiveSkills []SkillHandle `json:"activeSkills"`
}

Jump to

Keyboard shortcuts

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