command

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package command owns session-aware slash command projection and parsing.

Index

Constants

View Source
const (
	MaxSkillBytes        = 24_000
	MaxInvokedSkillBytes = 64_000
)

Variables

View Source
var (
	// ErrUnavailable reports a recognized slash command that is unavailable for the session.
	ErrUnavailable = errors.New("command: unavailable")
)

Functions

func BuildInvokedSkillsBlock

func BuildInvokedSkillsBlock(skills []InvokedSkill) string

BuildInvokedSkillsBlock renders verified explicit skill instructions for one turn. A body above MaxSkillBytes, or one that no longer fits the remaining MaxInvokedSkillBytes turn budget, is deferred instead of inlined: its entry keeps the source-bound identity and directs the agent to read the full body through compozy__skill_view, so an oversized skill never fails the prompt.

func Slug

func Slug(value string) string

Slug returns the canonical ASCII identifier used inside slash tokens.

Types

type AgentSpec

type AgentSpec struct {
	Name        string
	Description string
	InputHint   string
	SourceID    string
}

AgentSpec describes one ACP-advertised control command.

type BuiltinSpec

type BuiltinSpec struct {
	Name              string
	Description       string
	InputHint         string
	Available         bool
	UnavailableReason string
}

BuiltinSpec describes one daemon-owned control command.

func DefaultBuiltins

func DefaultBuiltins() []BuiltinSpec

DefaultBuiltins returns the complete reserved daemon command set.

type Catalog

type Catalog struct {
	Commands []Descriptor
	Revision string
	// contains filtered or unexported fields
}

Catalog is the deterministic command projection for one session snapshot.

func BuildCatalog

func BuildCatalog(builtins []BuiltinSpec, agents []AgentSpec, skills []SkillSpec) (Catalog, error)

BuildCatalog merges daemon, ACP, and skill commands using the accepted precedence rules.

func SetBuiltinAvailability

func SetBuiltinAvailability(catalog Catalog, name string, available bool, reason string) Catalog

SetBuiltinAvailability updates one visible daemon-owned command while preserving catalog ordering and parser refusal state.

type Descriptor

type Descriptor struct {
	ID                string      `json:"id"`
	CanonicalToken    string      `json:"canonical_token"`
	DisplayName       string      `json:"display_name"`
	Description       string      `json:"description"`
	Lane              Lane        `json:"lane"`
	Source            Source      `json:"source"`
	Placements        []Placement `json:"placements"`
	InputHint         string      `json:"input_hint,omitempty"`
	Available         bool        `json:"available"`
	UnavailableReason string      `json:"unavailable_reason,omitempty"`
	Skill             *SkillRef   `json:"-"`
}

Descriptor is one available slash command.

type Invocation

type Invocation struct {
	Ref   SkillRef `json:"ref"`
	Token string   `json:"token"`
	Start int      `json:"start"`
	End   int      `json:"end"`
}

Invocation records one exact skill marker found in authored text.

func ParseSkillInvocations

func ParseSkillInvocations(text string, catalog Catalog) ([]Invocation, error)

ParseSkillInvocations resolves skill markers anywhere at a whitespace boundary.

func ReconcileInvocations

func ReconcileInvocations(text string, admitted []Invocation) []Invocation

ReconcileInvocations narrows admitted refs to markers that survive a hook rewrite.

type InvokedSkill

type InvokedSkill struct {
	Ref     SkillRef
	Content string
}

InvokedSkill pairs an admitted reference with its verified instruction body.

type Lane

type Lane string

Lane groups commands by their runtime owner.

const (
	LaneBuiltin Lane = "builtin"
	LaneAgent   Lane = "agent"
	LaneSkill   Lane = "skill"
)

type Placement

type Placement string

Placement identifies where a command may be selected from authored text.

const (
	PlacementStandalone Placement = "standalone"
	PlacementInline     Placement = "inline"
)

type SkillRef

type SkillRef struct {
	CommandID string `json:"command_id"`
	Name      string `json:"name"`
	Source    Source `json:"source"`
}

SkillRef identifies one exact skill definition without exposing its path.

type SkillSpec

type SkillSpec struct {
	Name        string
	Description string
	Source      Source
	Available   bool
	Qualified   bool
}

SkillSpec describes one source-qualified skill candidate.

type Source

type Source struct {
	Kind   string `json:"kind"`
	ID     string `json:"id,omitempty"`
	Key    string `json:"key,omitempty"`
	Scope  string `json:"scope"`
	Origin string `json:"origin,omitempty"`
}

Source identifies the owner and scope of a projected command.

Jump to

Keyboard shortcuts

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