cobracmd

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cobracmd exposes optional Cobra wiring for skillsync. It owns command input, target selection, aggregation, and host error mapping; the core package remains command-framework free.

Index

Constants

This section is empty.

Variables

View Source
var DefaultHarnesses = []Harness{
	{ID: "claude", Aliases: []string{"claude-code"}, ConfigRel: ".claude", ConfigEnv: "CLAUDE_CONFIG_DIR"},
	{ID: "cursor", ConfigRel: ".cursor"},
	{ID: "codex", ConfigRel: ".codex", ConfigEnv: "CODEX_HOME"},
	{ID: "deepseek", Aliases: []string{"dsh", "deepseek-harness"}, ConfigRel: ".dsh", ConfigEnv: "DSH_HOME"},
	{ID: "agents", Aliases: []string{"amp", "zed"}, ConfigRel: ".agents"},
	{ID: "copilot", ConfigRel: ".copilot"},
	{ID: "gemini", ConfigRel: ".gemini", HomeEnv: "GEMINI_CLI_HOME"},
	{ID: "antigravity", ConfigRel: filepath.Join(".gemini", "config")},
	{ID: "opencode", ConfigRel: filepath.Join(".config", "opencode")},
	{ID: "cline", ConfigRel: ".cline"},
	{ID: "roo", ConfigRel: ".roo"},
	{ID: "kiro", ConfigRel: ".kiro"},
	{ID: "windsurf", ConfigRel: filepath.Join(".codeium", "windsurf")},
	{ID: "junie", ConfigRel: ".junie", ConfigEnv: "JUNIE_HOME"},
}

DefaultHarnesses holds the user-level Agent Skills roots this package knows about. Each entry resolves to <config root>/skills; see Harness for how ConfigEnv and HomeEnv relocate that root, and for why an additive variable such as OpenCode's is deliberately unset.

Order is part of the observable contract: callers that select by position and the discovery fallback both read harnesses[0], so Claude, Cursor, and Codex keep their existing slots and new harnesses are appended.

The "agents" entry is the cross-client ~/.agents/skills convention rather than one vendor's directory. Amp and Zed are aliases of it because it is the only user skill root either one reads. Several other harnesses here (Copilot, Cursor, Codex, Gemini, DeepSeek) also scan it, so "all" installs the same skills into both a native and a shared root; that is redundant but safe, since every target is independently owned. A caller who wants one shared install selects "agents" alone.

Two entries are worth flagging as version-sensitive:

  • Antigravity. Google's own docs published three different global roots: ~/.gemini/config/skills (flagship 2.0 and the official codelab, which calls it available across all Antigravity products), the older ~/.gemini/antigravity/skills (IDE doc only), and ~/.gemini/antigravity-cli/skills (CLI doc). The cross-product path is used here; revisit if the IDE-only path turns out to be the live one.
  • Windsurf. ~/.codeium/windsurf/skills is the stable channel; the CLI documents ~/.codeium/<channel>/skills and ~/.config/devin/skills alongside it, and the product is now branded Devin Desktop.

Functions

func New

New builds a convenience `skills` parent containing NewSync.

func NewSync

func NewSync(cfg skillsync.Config, opts CommandOptions) *cobra.Command

NewSync builds only the reusable sync leaf, allowing a host such as WB to retain its existing `skills` parent and sibling hook command.

Types

type AggregateError

type AggregateError struct{ Results []TargetResult }

AggregateError exposes every target error through errors.Is/As.

func (*AggregateError) Error

func (e *AggregateError) Error() string

func (*AggregateError) Unwrap

func (e *AggregateError) Unwrap() []error

type CommandOptions

type CommandOptions struct {
	Use, Short string
	Harnesses  []Harness
	Home       func() (string, error)
	Getenv     func(string) string
	Errors     ErrorMapper
	Resolver   skillsync.Resolver
	Renderer   Renderer
	// Legacy enables a host's one-time verified marker import for every
	// selected target (for example WB's .wb-skills-sync.json marker).
	Legacy      skillsync.LegacyImport
	LockTimeout time.Duration
}

type ConflictError

type ConflictError struct{ Report skillsync.Report }

ConflictError is returned even with no ErrorMapper, so conflicts do not accidentally become a successful command.

func (*ConflictError) Error

func (e *ConflictError) Error() string

type ErrorMapper

type ErrorMapper interface {
	Failure(error) error
	Conflict(skillsync.Report) error
}

ErrorMapper lets a host retain its own exit-code and error convention.

type Harness

type Harness struct {
	ID        string
	Aliases   []string
	ConfigRel string
	ConfigEnv string
	HomeEnv   string
}

Harness describes one Agent Skills configuration root.

ConfigEnv and HomeEnv express the two different ways vendors let a variable relocate that root. Choosing the wrong one installs skills where the harness never looks, so each is set only against a vendor statement of its actual semantics:

  • ConfigEnv replaces the config root outright, giving <ConfigEnv>/skills. Claude's CLAUDE_CONFIG_DIR, Codex's CODEX_HOME, DeepSeek's DSH_HOME, and Junie's JUNIE_HOME ("overrides the default ~/.junie") all work this way.
  • HomeEnv replaces the user home the config root is resolved under, giving <HomeEnv>/<ConfigRel>/skills. Gemini's GEMINI_CLI_HOME is this case: it "specifies the root directory for Gemini CLI's user-level configuration and storage", and the CLI creates its own .gemini folder inside it.

Variables that only ever add a search path rather than replacing one belong in neither field. OpenCode's OPENCODE_CONFIG_DIR is additive -- the default ~/.config/opencode keeps being read -- so it is deliberately unset here.

func (Harness) Present

func (h Harness) Present(home string, getenv func(string) string) bool

func (Harness) SkillsDir

func (h Harness) SkillsDir(home string, getenv func(string) string) string

type Renderer

type Renderer func(io.Writer, []TargetResult, string) error

Renderer receives all completed target outcomes after attempts finish.

type TargetResult

type TargetResult struct {
	Harness string
	Dir     string
	Report  skillsync.Report
	Err     error
}

TargetResult retains both an attempted target's complete core report and its error. A host renderer can preserve a legacy JSON contract without reimplementing selection or synchronization.

type UsageError

type UsageError struct{ Err error }

UsageError identifies invalid Cobra input before source preparation or any target write. It preserves its cause for hosts using errors.Is/As.

func (*UsageError) Error

func (e *UsageError) Error() string

func (*UsageError) Unwrap

func (e *UsageError) Unwrap() error

Jump to

Keyboard shortcuts

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