Documentation
¶
Index ¶
- Constants
- func RemoveSkill(path string) error
- func RenderSkill(meta SkillMetadata, commands []SkillCommand) string
- func Skill(ctx context.Context, v any) string
- func SkillPath(path string) string
- func WriteSkill(path string, meta SkillMetadata, commands []SkillCommand) error
- type ArgInfo
- type Catalog
- type CommandInfo
- type Completer
- type FlagInfo
- type Lister
- type Plugin
- type Provider
- type SkillCommand
- type SkillLister
- type SkillMetadata
- type SkillMetadataer
Constants ¶
const CatalogSchemaVersion = "3"
CatalogSchemaVersion is the current version of the Catalog shape.
const CatalogType = "posh.command_catalog"
CatalogType is the discriminator carried by Catalog.
const DefaultSkillPath = ".claude/skills/posh/SKILL.md"
DefaultSkillPath is where `posh agent skill install` writes the skill unless given an explicit path.
Variables ¶
This section is empty.
Functions ¶
func RemoveSkill ¶ added in v0.21.0
RemoveSkill deletes the skill file at path, falling back to DefaultSkillPath when empty. A missing file is not an error, so uninstall is idempotent.
func RenderSkill ¶ added in v0.21.0
func RenderSkill(meta SkillMetadata, commands []SkillCommand) string
RenderSkill renders a Claude Code SKILL.md from a command catalog.
The result is generated in full from the catalog every time, so it always reflects whatever commands a project's posh shell currently registers - there is no hand-maintained content to drift out of sync. A zero SkillMetadata renders posh's default frontmatter.
func Skill ¶ added in v0.21.0
Skill returns the extra SKILL.md markdown a command contributes, see command.Skill.
func SkillPath ¶ added in v0.21.0
SkillPath resolves a user supplied skill path, falling back to DefaultSkillPath when empty.
func WriteSkill ¶ added in v0.21.0
func WriteSkill(path string, meta SkillMetadata, commands []SkillCommand) error
WriteSkill renders commands as a Claude Code SKILL.md and writes it to path, creating any missing parent directories.
Passing an empty path writes to DefaultSkillPath. The file is regenerated in full every time, so re-running after a project's commands change always produces an up-to-date skill.
Types ¶
type Catalog ¶ added in v0.21.0
type Catalog struct {
Type string `json:"type"`
SchemaVersion string `json:"schema_version"`
Commands []CommandInfo `json:"commands"`
}
Catalog is the payload of `posh agent catalog`.
Unlike command results, which are emitted bare, the catalog keeps its type/schema_version discriminator: the shape is a published contract mirroring other agent-facing CLIs, and consumers dispatch on the marker.
func NewCatalog ¶ added in v0.21.0
func NewCatalog(commands []CommandInfo) Catalog
NewCatalog wraps commands in a Catalog with the current type and version.
type CommandInfo ¶ added in v0.21.0
type CommandInfo = command.CommandInfo
CommandInfo describes one command for the `posh agent catalog` catalog.
func Describe ¶ added in v0.21.0
func Describe(ctx context.Context, name, description string, v any) CommandInfo
Describe builds a CommandInfo for a single command, see command.Describe.
func List ¶ added in v0.21.0
func List(ctx context.Context, plg any) ([]CommandInfo, error)
List asks plg for its command catalog, requiring the optional Lister interface. It returns a descriptive error when the plugin does not implement it, rather than leaving callers to repeat the type assertion.
Resolving the plugin itself is the caller's job: the posh CLI holds its provider in package state, and a downstream shell may have one in hand already.
type Completer ¶ added in v0.19.0
type Completer interface {
Complete(ctx context.Context, args []string, toComplete string) []string
}
Completer is an optional Plugin extension that produces shell completion suggestions for `posh execute`. Returned strings use the cobra format: "value\tdescription" (description optional).
type Lister ¶ added in v0.21.0
type Lister interface {
List(ctx context.Context) []CommandInfo
}
Lister is an optional Plugin extension that exposes the catalog of commands, used by `posh agent catalog` to give an AI coding agent a machine-readable answer to "what can I run" without parsing human-formatted help text.
type SkillCommand ¶ added in v0.21.0
type SkillCommand struct {
CommandInfo
// Skill is the markdown contributed by command.Skiller, or empty.
Skill string
}
SkillCommand pairs a described command with the extra markdown its command.Skiller implementation contributed, if any.
The catalog shape stays untouched: skill prose is a rendering concern, so it rides alongside CommandInfo rather than inside it.
func ListSkill ¶ added in v0.21.0
func ListSkill(ctx context.Context, plg any) ([]SkillCommand, error)
ListSkill asks plg for its command catalog together with the extra SKILL.md markdown each command contributes.
A plugin implementing only Lister falls back to a catalog without prose, so the skill still renders for shells that have not opted in.
type SkillLister ¶ added in v0.21.0
type SkillLister interface {
ListSkill(ctx context.Context) []SkillCommand
}
SkillLister is an optional Plugin extension that lists commands together with the extra SKILL.md markdown each one contributes via command.Skiller.
A plugin implementing only Lister still renders a skill, just without the extra prose.
type SkillMetadata ¶ added in v0.21.0
type SkillMetadata struct {
// Name defaults to "posh".
Name string `yaml:"name"`
// Description defaults to a generic one. A project specific description is
// what makes the skill trigger on this project's vocabulary.
Description string `yaml:"description"`
// AllowedTools are granted without a permission prompt for the turn that
// invokes the skill, e.g. "Bash(posh execute:*)".
AllowedTools []string `yaml:"allowed-tools,omitempty"`
}
SkillMetadata is the SKILL.md frontmatter a project can override.
The fields are restricted to the Agent Skills spec allowlist (https://agentskills.io) so the generated skill stays valid if it is ever uploaded to claude.ai or the Skills API, both of which reject unknown keys.
func SkillMetadataOf ¶ added in v0.21.0
func SkillMetadataOf(ctx context.Context, plg any) SkillMetadata
SkillMetadataOf returns the SKILL.md frontmatter plg supplies, or the zero value - which renders posh's defaults - when it does not implement SkillMetadataer.
type SkillMetadataer ¶ added in v0.21.0
type SkillMetadataer interface {
SkillMetadata(ctx context.Context) SkillMetadata
}
SkillMetadataer is an optional Plugin extension supplying the generated SKILL.md frontmatter. Unset fields fall back to posh's defaults.