command

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Skill added in v0.21.0

func Skill(ctx context.Context, v any) string

Skill returns the extra SKILL.md markdown v contributes, or an empty string if it does not implement Skiller.

Types

type AdditionalArgsCompleter

type AdditionalArgsCompleter interface {
	CompleteAdditionalArgs(ctx context.Context, r *readline.Readline) []goprompt.Suggest
}

type ArgInfo added in v0.21.0

type ArgInfo = tree.ArgInfo

ArgInfo describes a single positional argument of a command.

type ArgumentCompleter

type ArgumentCompleter interface {
	CompleteArguments(ctx context.Context, r *readline.Readline) []goprompt.Suggest
}

type Cache

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

func NewCache

func NewCache(l log.Logger, cache cache.Cache) *Cache

func (*Cache) Complete

func (c *Cache) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Cache) Describe added in v0.21.0

func (c *Cache) Describe(ctx context.Context) CommandInfo

Describe implements the optional Describer interface, letting `posh agent catalog` describe this command's subtree.

func (*Cache) Description

func (c *Cache) Description() string

func (*Cache) Execute

func (c *Cache) Execute(ctx context.Context, r *readline.Readline) error

func (*Cache) Help

func (c *Cache) Help(ctx context.Context, r *readline.Readline) string

func (*Cache) Name

func (c *Cache) Name() string

func (*Cache) Skill added in v0.21.0

func (c *Cache) Skill(ctx context.Context) string

Skill implements the optional Skiller interface. The catalog already carries the structure; what it cannot show is that the namespaces are populated at runtime, which is what makes `cache list` the necessary first step.

type CacheGet added in v0.21.0

type CacheGet struct {
	Namespace string `json:"namespace"`
	Key       string `json:"key"`
	Value     any    `json:"value"`
}

CacheGet is the result of `cache get`. Value is nil when the key is unset.

type CacheList added in v0.21.0

type CacheList struct {
	Namespaces []CacheNamespace `json:"namespaces"`
}

CacheList is the result of `cache list`.

type CacheNamespace added in v0.21.0

type CacheNamespace struct {
	Namespace string   `json:"namespace"`
	Keys      []string `json:"keys"`
}

CacheNamespace is a single cache namespace and the keys it holds. Values are deliberately excluded - use `cache get` to read one.

type Check added in v0.5.4

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

func NewCheck added in v0.5.4

func NewCheck(l log.Logger, checkers ...check.Checker) *Check

func (*Check) Complete added in v0.5.4

func (c *Check) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Check) Describe added in v0.21.0

func (c *Check) Describe(ctx context.Context) CommandInfo

Describe implements the optional Describer interface, letting `posh agent catalog` describe this command's subtree.

func (*Check) Description added in v0.5.4

func (c *Check) Description() string

func (*Check) Execute added in v0.5.4

func (c *Check) Execute(ctx context.Context, r *readline.Readline) error

func (*Check) Help added in v0.5.4

func (c *Check) Help(ctx context.Context, r *readline.Readline) string

func (*Check) Name added in v0.5.4

func (c *Check) Name() string

func (*Check) Skill added in v0.21.0

func (c *Check) Skill(ctx context.Context) string

Skill implements the optional Skiller interface. The command takes no arguments, so its structure says nothing - what an agent needs is that this is the diagnostic to reach for first, and that the checks are project defined.

type Command

type Command interface {
	Name() string
	Description() string
	Execute(ctx context.Context, r *readline.Readline) error
}

type CommandInfo added in v0.21.0

type CommandInfo = tree.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. Commands implementing the optional Describer interface describe themselves; anything else becomes a leaf carrying only its name and description.

type Commands

type Commands map[string]Command

func (Commands) Add

func (c Commands) Add(commands ...Command)

func (Commands) Get

func (c Commands) Get(name string) Command

func (Commands) Has

func (c Commands) Has(name string) bool

func (Commands) List

func (c Commands) List() []Command

func (Commands) Load

func (c Commands) Load(paths ...string) error

func (Commands) MustAdd added in v0.4.0

func (c Commands) MustAdd(command Command, err error)

func (Commands) TryAdd added in v0.3.0

func (c Commands) TryAdd(command Command, err error) error

type Completer

type Completer interface {
	Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest
}

type Describer added in v0.21.0

type Describer interface {
	Describe(ctx context.Context) CommandInfo
}

Describer is an optional Command extension: a command that describes its own structure for `posh agent catalog`, so an AI coding agent gets a machine-readable answer to "what can I run" without parsing help text.

The contract is CommandInfo, not a command tree: a command is free to model its structure however it likes and stays free to change that later. Tree based commands delegate to tree.Root.Describe like any other tree method:

func (c *Cache) Describe(ctx context.Context) command.CommandInfo {
	return c.tree.Describe(ctx)
}

Commands that do not implement it are still listed, just without subcommand detail.

type Env added in v0.5.0

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

func NewEnv added in v0.5.0

func NewEnv(l log.Logger) *Env

func (*Env) Complete added in v0.5.0

func (c *Env) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Env) Describe added in v0.21.0

func (c *Env) Describe(ctx context.Context) CommandInfo

Describe implements the optional Describer interface, letting `posh agent catalog` describe this command's subtree.

func (*Env) Description added in v0.5.0

func (c *Env) Description() string

func (*Env) Execute added in v0.5.0

func (c *Env) Execute(ctx context.Context, r *readline.Readline) error

func (*Env) Help added in v0.5.0

func (c *Env) Help(ctx context.Context, r *readline.Readline) string

func (*Env) Name added in v0.5.0

func (c *Env) Name() string

func (*Env) Skill added in v0.21.0

func (c *Env) Skill(ctx context.Context) string

Skill implements the optional Skiller interface. The scope of a `set` - this process only - is the thing an agent gets wrong, and no amount of structure conveys it.

type EnvGet added in v0.21.0

type EnvGet struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

EnvGet is the result of `env get`.

type EnvList added in v0.21.0

type EnvList struct {
	Values []EnvVar `json:"values"`
}

EnvList is the result of `env list`.

type EnvVar added in v0.21.0

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value,omitempty"`
}

EnvVar is a single environment variable. Value is omitted unless the listing was requested with values.

type Exit

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

func NewExit

func NewExit(l log.Logger) *Exit

func (*Exit) Description

func (c *Exit) Description() string

func (*Exit) Execute

func (c *Exit) Execute(ctx context.Context, args *readline.Readline) error

func (*Exit) Help

func (c *Exit) Help(ctx context.Context, r *readline.Readline) string

func (*Exit) Name

func (c *Exit) Name() string

func (*Exit) Skill added in v0.21.0

func (c *Exit) Skill(ctx context.Context) string

Skill implements the optional Skiller interface. It exists to say the command is pointless outside the interactive shell, which its description implies to a human but not to an agent.

type FlagCompleter

type FlagCompleter interface {
	CompleteFlags(ctx context.Context, r *readline.Readline) []goprompt.Suggest
}

type FlagInfo added in v0.21.0

type FlagInfo = tree.FlagInfo

FlagInfo describes a single flag of a command.

type Help

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

func NewHelp

func NewHelp(l log.Logger, commands Commands) *Help

func (*Help) Complete

func (c *Help) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Help) Describe added in v0.21.0

func (c *Help) Describe(ctx context.Context) CommandInfo

Describe implements the optional Describer interface. Help is not tree based, so it builds its own CommandInfo - otherwise it would be listed as a bare leaf and its optional command argument would not show up at all.

func (*Help) Description

func (c *Help) Description() string

func (*Help) Execute

func (c *Help) Execute(ctx context.Context, r *readline.Readline) error

func (*Help) Name

func (c *Help) Name() string

func (*Help) Skill added in v0.21.0

func (c *Help) Skill(ctx context.Context) string

Skill implements the optional Skiller interface, mainly to steer an agent away from this command: the catalog it already has is strictly better structured than the prose this prints.

func (*Help) Validate

func (c *Help) Validate(ctx context.Context, r *readline.Readline) error

type Helper

type Helper interface {
	Help(ctx context.Context, r *readline.Readline) string
}

type History added in v0.4.0

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

func NewHistory added in v0.4.0

func NewHistory(l log.Logger, history history.History) *History

func (*History) Description added in v0.4.0

func (c *History) Description() string

func (*History) Execute added in v0.4.0

func (c *History) Execute(ctx context.Context, r *readline.Readline) error

func (*History) Name added in v0.4.0

func (c *History) Name() string

func (*History) Skill added in v0.21.0

func (c *History) Skill(ctx context.Context) string

Skill implements the optional Skiller interface. What the one-line description cannot say is whose history this is, and that it is a record of intent rather than of success.

type Option added in v0.5.4

type Option func(*Check)

type PassThroughFlagsCompleter

type PassThroughFlagsCompleter interface {
	CompletePassTroughFlags(ctx context.Context, r *readline.Readline) []goprompt.Suggest
}

type Shutdowner added in v0.17.0

type Shutdowner interface {
	Shutdown(ctx context.Context) error
}

type Skiller added in v0.21.0

type Skiller interface {
	Skill(ctx context.Context) string
}

Skiller is an optional Command extension: a command that contributes extra markdown to the generated SKILL.md, beyond the structure Describer already provides - extended instructions, worked configuration examples, links to further docs.

The contract is deliberately a free-form string rather than a struct: what is worth telling an agent varies per command, and a fixed shape would constrain that without buying anything, since the destination is markdown either way.

The returned markdown is appended verbatim under the command's heading in SKILL.md, after its arguments, flags and subcommands. Use heading level 4 (####) or deeper - level 3 is the command heading itself.

Commands that do not implement it render exactly as they did before.

type Validator

type Validator interface {
	Validate(ctx context.Context, r *readline.Readline) error
}

type Version added in v0.21.0

type Version struct {
	Version   string `json:"version"`
	Commit    string `json:"commit,omitempty"`
	BuildTime string `json:"build_time,omitempty"`
}

Version is the result of `posh version`. Commit and BuildTime are only populated at debug level, matching the fields the human output prints there.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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