core

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigFileName is the default name for the configuration file
	ConfigFileName = "ccmd.yaml"
	// LockFileName is the default name for the lock file
	LockFileName = "ccmd-lock.yaml"
)

Variables

This section is empty.

Functions

func ExtractRepoPath

func ExtractRepoPath(gitURL string) string

ExtractRepoPath extracts the owner/repo path from a Git URL

func FormatCommandInfoJSON

func FormatCommandInfoJSON(info *CommandInfo) (string, error)

FormatCommandInfoJSON formats command info as indented JSON

func FormatTags

func FormatTags(tags []string) string

FormatTags formats a slice of tags as comma-separated string

func GenerateConfigPreview

func GenerateConfigPreview(opts InitOptions, existingCommands interface{}) (string, error)

GenerateConfigPreview generates a YAML preview of the configuration

func GetInstallCommand

func GetInstallCommand(repository string) string

GetInstallCommand generates the install command for the repository

func InitPlugin added in v1.2.0

func InitPlugin(opts InitOptions) error

InitPlugin creates a new Claude Code plugin project with the given options.

func InitProject

func InitProject(opts InitOptions) error

InitProject creates a new ccmd project with the given options

func InitProjectWithCommands

func InitProjectWithCommands(opts InitOptions, existingCommands interface{}) error

InitProjectWithCommands creates a project with existing commands preserved

func Install

func Install(_ context.Context, opts InstallOptions) (string, bool, error)

Install installs a command from a Git repository

func InstallFromConfig

func InstallFromConfig(ctx context.Context, projectPath string, force bool) error

InstallFromConfig installs all commands and plugins from project's ccmd.yaml

func ListCommands

func ListCommands(projectPath string) ([]string, error)

ListCommands returns a list of all command names

func LockFileExists

func LockFileExists(projectPath string) bool

LockFileExists checks if ccmd-lock.yaml exists in the project

func NormalizeRepositoryURL

func NormalizeRepositoryURL(url string) string

func ParseCommandSpec

func ParseCommandSpec(spec string) (repo, version string)

ParseCommandSpec parses a command specification (e.g., "owner/repo@version")

func ParseRepositorySpec

func ParseRepositorySpec(spec string) (repository, version string)

func ParseTags

func ParseTags(input string) []string

ParseTags parses a comma-separated string of tags

func ProjectConfigExists

func ProjectConfigExists(projectPath string) bool

ProjectConfigExists checks if ccmd.yaml exists in the project

func ReadCommandContentPreview

func ReadCommandContentPreview(commandName, baseDir string, filesystem fs.FileSystem, lines int) (string, int, error)

ReadCommandContentPreview reads a preview of the command's index.md file

func Remove

func Remove(opts RemoveOptions) error

Remove removes an installed command

func SaveProjectConfig

func SaveProjectConfig(projectPath string, config *ProjectConfig) error

SaveProjectConfig saves the project configuration to ccmd.yaml

func WriteClaudeSettings added in v1.2.0

func WriteClaudeSettings(claudeDir string, s *ClaudeSettings) error

WriteClaudeSettings writes the .claude/settings.json file.

func WriteLockFile

func WriteLockFile(path string, lockFile *LockFile) error

WriteLockFile writes the lock file to disk

Types

type ClaudeSettings added in v1.2.0

type ClaudeSettings struct {
	EnabledPlugins         map[string]bool             `json:"enabledPlugins,omitempty"`
	ExtraKnownMarketplaces map[string]MarketplaceEntry `json:"extraKnownMarketplaces,omitempty"`
}

ClaudeSettings represents the .claude/settings.json structure

func ReadClaudeSettings added in v1.2.0

func ReadClaudeSettings(claudeDir string) (*ClaudeSettings, error)

ReadClaudeSettings reads the .claude/settings.json file.

type CommandDetail

type CommandDetail struct {
	Name            string
	Version         string
	Description     string
	Author          string
	Repository      string
	UpdatedAt       string
	InstalledAt     string
	BrokenStructure bool
	StructureError  string
	Type            string // "command" or "plugin"
	// Additional metadata from ccmd.yaml
	Tags     []string
	License  string
	Homepage string
	Entry    string
	Requires string
	Resolved string
}

CommandDetail represents detailed information about an installed command or plugin

func GetCommandInfo

func GetCommandInfo(name, projectPath string) (*CommandDetail, error)

GetCommandInfo returns detailed information about a specific command

func List

func List(opts ListOptions) ([]CommandDetail, error)

List returns a list of all installed commands

type CommandInfo

type CommandInfo struct {
	Name        string            `json:"name"`
	Version     string            `json:"version"`
	Author      string            `json:"author"`
	Description string            `json:"description"`
	Repository  string            `json:"repository"`
	License     string            `json:"license,omitempty"`
	Homepage    string            `json:"homepage,omitempty"`
	Tags        []string          `json:"tags,omitempty"`
	Entry       string            `json:"entry,omitempty"`
	Source      string            `json:"source"`
	InstalledAt string            `json:"installed_at"`
	UpdatedAt   string            `json:"updated_at"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	Structure   StructureInfo     `json:"structure"`
}

CommandInfo represents the structured information about a command

func GetCommandDetails

func GetCommandDetails(commandName, projectPath string, filesystem fs.FileSystem) (*CommandInfo, error)

GetCommandDetails retrieves detailed information about an installed command

type ConfigCommand

type ConfigCommand struct {
	Repo    string `yaml:"repo"`
	Version string `yaml:"version,omitempty"`
	Name    string `yaml:"name,omitempty"`
}

ConfigCommand represents a command in the configuration

type InitOptions

type InitOptions struct {
	Name        string
	Version     string
	Description string
	Author      string
	Repository  string
	Entry       string
	Tags        []string
	ProjectPath string
	CommandMode bool // true for command mode, false for project mode
	Plugin      bool // true to initialize as a Claude Code plugin
}

InitOptions represents options for initializing a project

func InitDefaults

func InitDefaults(projectPath string) InitOptions

InitDefaults returns default values for init based on current directory

func LoadExistingConfig

func LoadExistingConfig(projectPath string) (InitOptions, interface{}, error)

LoadExistingConfig attempts to load existing ccmd.yaml and returns defaults

type InstallOptions

type InstallOptions struct {
	Repository string // Git repository URL or shorthand
	Version    string // Version/tag to install (optional)
	Commit     string // Specific commit to install (used when different from Version)
	Name       string // Override command name (optional)
	Force      bool   // Force reinstall if already exists
}

InstallOptions represents options for installing a command

type InstalledCommand

type InstalledCommand struct {
	Name        string
	Version     string
	Description string
	Author      string
	Repository  string
	Path        string
}

InstalledCommand represents an installed command

type ListOptions

type ListOptions struct {
	ProjectPath string // Path to project root
}

ListOptions represents options for listing commands

type LockCommand

type LockCommand struct {
	Name        string    `yaml:"name"`
	Version     string    `yaml:"version"`
	Source      string    `yaml:"source"`
	Resolved    string    `yaml:"resolved"`
	Commit      string    `yaml:"commit"`
	InstalledAt time.Time `yaml:"installed_at"`
	UpdatedAt   time.Time `yaml:"updated_at"`
}

LockCommand represents a command entry in the lock file

type LockFile

type LockFile struct {
	Version         string                  `yaml:"version"`
	LockfileVersion int                     `yaml:"lockfileVersion"`
	Commands        map[string]*LockCommand `yaml:"commands"`
	Plugins         map[string]*LockPlugin  `yaml:"plugins,omitempty"`
}

LockFile represents the ccmd-lock.yaml structure

func ReadLockFile

func ReadLockFile(path string) (*LockFile, error)

ReadLockFile reads and parses the ccmd-lock.yaml file

type LockPlugin added in v1.2.0

type LockPlugin struct {
	Name        string    `yaml:"name"`
	Version     string    `yaml:"version"`
	Source      string    `yaml:"source"`
	Resolved    string    `yaml:"resolved"`
	Commit      string    `yaml:"commit"`
	InstalledAt time.Time `yaml:"installed_at"`
	UpdatedAt   time.Time `yaml:"updated_at"`
}

LockPlugin represents a plugin entry in the lock file

type MarketplaceEntry added in v1.2.0

type MarketplaceEntry struct {
	Source MarketplaceSource `json:"source"`
}

MarketplaceEntry represents an entry in extraKnownMarketplaces

type MarketplaceSource added in v1.2.0

type MarketplaceSource struct {
	Source string `json:"source"`
	Path   string `json:"path,omitempty"`
	Repo   string `json:"repo,omitempty"`
	URL    string `json:"url,omitempty"`
}

MarketplaceSource represents the source configuration for a plugin marketplace

type ProjectConfig

type ProjectConfig struct {
	// Project metadata (when ccmd.yaml is for a command)
	Name        string   `yaml:"name,omitempty" json:"name,omitempty"`
	Version     string   `yaml:"version,omitempty" json:"version,omitempty"`
	Description string   `yaml:"description" json:"description"`
	Author      string   `yaml:"author" json:"author"`
	Repository  string   `yaml:"repository" json:"repository"`
	Entry       string   `yaml:"entry,omitempty" json:"entry,omitempty"`
	Tags        []string `yaml:"tags,omitempty" json:"tags,omitempty"`
	License     string   `yaml:"license,omitempty" json:"license,omitempty"`
	Homepage    string   `yaml:"homepage,omitempty" json:"homepage,omitempty"`

	// Type indicates whether this is a "plugin" or command (default)
	Type string `yaml:"type,omitempty" json:"type,omitempty"`

	// Commands list (when ccmd.yaml is for a project)
	Commands []string `yaml:"commands,omitempty" json:"commands,omitempty"`

	// Plugins list (when ccmd.yaml is for a project)
	Plugins []string `yaml:"plugins,omitempty" json:"plugins,omitempty"`
}

ProjectConfig represents the ccmd.yaml configuration file

func LoadProjectConfig

func LoadProjectConfig(projectPath string) (*ProjectConfig, error)

LoadProjectConfig loads the project configuration from ccmd.yaml

func (*ProjectConfig) GetConfigCommands

func (pc *ProjectConfig) GetConfigCommands() []ConfigCommand

GetConfigCommands returns the commands from the configuration

func (*ProjectConfig) MarshalJSON

func (pc *ProjectConfig) MarshalJSON() ([]byte, error)

MarshalJSON marshals ProjectConfig to JSON

func (*ProjectConfig) MarshalYAML

func (pc *ProjectConfig) MarshalYAML() ([]byte, error)

MarshalYAML marshals ProjectConfig to YAML

func (*ProjectConfig) UnmarshalJSON

func (pc *ProjectConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into ProjectConfig

func (*ProjectConfig) UnmarshalYAML

func (pc *ProjectConfig) UnmarshalYAML(data []byte) error

UnmarshalYAML unmarshals YAML data into ProjectConfig

func (*ProjectConfig) Validate

func (pc *ProjectConfig) Validate() error

Validate validates the project config when used as command metadata

type RemoveOptions

type RemoveOptions struct {
	Name        string
	Force       bool
	UpdateFiles bool
}

RemoveOptions represents options for removing a command

type SearchOptions

type SearchOptions struct {
	Keyword string
	Tags    []string
	Author  string
	ShowAll bool
}

SearchOptions contains options for searching commands

type SearchResult

type SearchResult struct {
	Name        string
	Version     string
	Description string
	Author      string
	Tags        []string
	Repository  string
}

SearchResult represents a command found in the search

func Search(opts SearchOptions) ([]SearchResult, error)

Search searches for installed commands based on the provided options

type StructureInfo

type StructureInfo struct {
	DirectoryExists bool     `json:"directory_exists"`
	MarkdownExists  bool     `json:"markdown_exists"`
	HasCcmdYaml     bool     `json:"has_ccmd_yaml"`
	HasIndexMd      bool     `json:"has_index_md"`
	IsValid         bool     `json:"is_valid"`
	Issues          []string `json:"issues,omitempty"`
}

StructureInfo contains information about command structure integrity

type SyncAnalysis

type SyncAnalysis struct {
	ToInstall []ConfigCommand
	ToRemove  []string
	InSync    bool
}

SyncAnalysis represents the analysis of what needs to be synced

func AnalyzeSync

func AnalyzeSync(projectPath string) (*SyncAnalysis, error)

AnalyzeSync analyzes what needs to be synced between config and installed commands

type SyncError

type SyncError struct {
	Command   string
	Operation string // "install" or "remove"
	Error     error
}

SyncError represents an error during sync operation

type SyncOptions

type SyncOptions struct {
	ProjectPath string
	DryRun      bool
	Force       bool
}

SyncOptions represents options for syncing commands

type SyncResult

type SyncResult struct {
	Installed []string
	Removed   []string
	Failed    []SyncError
}

SyncResult represents the result of a sync operation

func Sync

func Sync(ctx context.Context, opts SyncOptions) (*SyncResult, error)

Sync synchronizes installed commands with the project configuration

type UpdateOptions

type UpdateOptions struct {
	Name      string // Command name (empty for all)
	All       bool   // Update all commands
	CheckOnly bool   // Only check for updates without installing
	Force     bool   // Force update even if version appears current
}

UpdateOptions represents options for updating commands

type UpdateResult

type UpdateResult struct {
	UpdatedCount int
	FailedCount  int
	CheckedCount int
}

UpdateResult represents the result of an update operation

func Update

func Update(ctx context.Context, opts UpdateOptions) (*UpdateResult, error)

Update updates one or more installed commands

Jump to

Keyboard shortcuts

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