agent

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package agent defines the pluggable per-agent behavior gskill installs into, plus a registry of adapters. Concrete adapters (Claude Code, Codex, Cursor, and the shared-location agents such as Antigravity CLI) live in sibling files and register themselves with a Registry.

Index

Constants

View Source
const DefaultID = "claude"

DefaultID is the agent used when none is specified on the command line and none is detected in the project. Installs default to Claude.

Variables

View Source
var ErrInvalidAgent = errors.New("invalid agent")

ErrInvalidAgent is returned when registering an agent with an empty ID.

Functions

func UsesSharedDir added in v0.7.3

func UsesSharedDir(a Agent, projectRoot string) bool

UsesSharedDir reports whether a reads project skills straight from gskill's repo-owned store (.agents/skills), so its project target is the active entry itself. Such a target must never be linked, copied, or deleted on the agent's behalf (spec 027 FR-005, FR-010).

Types

type Advisor added in v0.7.3

type Advisor interface {
	// Advise returns one line per problem with the skill installed as
	// skillName at skillDir.
	Advise(skillName, skillDir string) []string
}

Advisor is implemented by agents that can spot problems with an installed skill's content that would stop the agent from loading it. Advice is non-fatal guidance for the user and never fails an install (spec 027 FR-011).

type Agent

type Agent interface {
	// ID is the stable, lowercase identifier (e.g. "claude").
	ID() string
	// DisplayName is the human-facing name.
	DisplayName() string
	// Detect reports whether this agent is configured for the given project.
	Detect(ctx context.Context, projectRoot string) (bool, error)
	// ProjectSkillDir is the per-project directory skills install into.
	ProjectSkillDir(projectRoot string) string
	// GlobalSkillDir is the user-global directory skills install into.
	GlobalSkillDir(home string) string
	// SupportsSymlinks reports whether the agent tolerates symlinked skills.
	SupportsSymlinks() bool
	// ValidateInstallation checks that a skill installed at skillDir is usable
	// by the agent.
	ValidateInstallation(ctx context.Context, skillDir string) error
}

Agent is the behavior gskill needs from a target AI agent to detect it and place skills into its skill directory (FR-027, FR-031, SC-009).

func NewAntigravity added in v0.7.3

func NewAntigravity() Agent

NewAntigravity returns the Antigravity CLI (agy) adapter. It reads project skills from the shared store and global skills from the CLI's own folder; the ~/.gemini/config/skills folder shared with the Antigravity IDE is deliberately not used. It has no project marker, so it is only ever targeted explicitly (spec 027 FR-008, FR-009).

func NewClaudeCode

func NewClaudeCode() Agent

NewClaudeCode returns the Claude adapter, which stores skills under .claude/skills/<name> (FR-027).

func NewCodex

func NewCodex() Agent

NewCodex returns the Codex adapter, which stores skills under .codex/skills/<name> (FR-027).

func NewCursor

func NewCursor() Agent

NewCursor returns the Cursor adapter, which stores skills under .cursor/skills/<name> (FR-031, SC-009).

func NewHermes added in v0.7.3

func NewHermes() Agent

NewHermes returns the Hermes Agent adapter. It reads project skills from the shared store and global skills from ~/.hermes/skills, and is detected by a .hermes/ directory (spec 027 FR-008, FR-009).

func NewOpenClaw added in v0.7.3

func NewOpenClaw() Agent

NewOpenClaw returns the OpenClaw adapter. It reads global skills from ~/.openclaw/skills and project skills from the shared store, which OpenClaw sees only when the repository is its workspace. It has no project marker, so it is only ever targeted explicitly (spec 027 FR-008, FR-009).

func NewOpenCode added in v0.7.3

func NewOpenCode() Agent

NewOpenCode returns the OpenCode adapter. It reads project skills from the shared store and global skills from ~/.config/opencode/skills, and is detected by .opencode/, opencode.json, or opencode.jsonc (spec 027 FR-008, FR-009).

type ProjectNoter added in v0.7.3

type ProjectNoter interface {
	ProjectNote() string
}

ProjectNoter is implemented by agents that need one environment note after a project-scope install targets them, such as a trust step the agent requires before it loads project skills (spec 027 FR-012).

type Registry

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

Registry holds the known agent adapters in registration order.

func NewDefaultRegistry

func NewDefaultRegistry() *Registry

NewDefaultRegistry returns a registry populated with the built-in agent adapters in priority order.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) All

func (r *Registry) All() []Agent

All returns every registered agent in registration order.

func (*Registry) Detect

func (r *Registry) Detect(ctx context.Context, projectRoot string) ([]Agent, error)

Detect returns the registered agents that report being configured for projectRoot, preserving registration order.

func (*Registry) Get

func (r *Registry) Get(id string) (Agent, bool)

Get returns the agent with the given ID.

func (*Registry) Register

func (r *Registry) Register(a Agent) error

Register adds a to the registry. It errors on an empty ID or a duplicate.

Jump to

Keyboard shortcuts

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