commands

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VarAddCmd = &cobra.Command{
	Use:   "add <repo-url> [branch] [spec-path]",
	Short: "Add a dependency",
	Long:  `Add an external specification dependency to your project. The dependency will be tracked in specledger.yaml and cached locally for offline use.`,
	Example: `  sl deps add git@github.com:org/api-spec
  sl deps add git@github.com:org/api-spec v1.0 github.com/specledger/specledger/api.md
  sl deps add git@github.com:org/api-spec main spec.md --alias api`,
	Args: cobra.MinimumNArgs(1),
	RunE: runAddDependency,
}

VarAddCmd represents the add command

View Source
var VarBootstrapCmd = &cobra.Command{
	Use:   "new",
	Short: "Create a new SpecLedger project",
	Long: `Create a new SpecLedger project with all necessary infrastructure:

Interactive mode:
  sl new

Non-interactive mode (for CI/CD):
  sl new --ci --project-name <name> --short-code <code> --project-dir <path>

The bootstrap creates:
- .claude/ directory with skills and commands
- .beads/ directory for issue tracking
- github.com/specledger/specledger/ directory for specifications
- github.com/specledger/specledger/specledger.yaml file for project metadata`,

	RunE: func(cmd *cobra.Command, args []string) error {

		cfg, err := config.Load()
		if err != nil {
			return fmt.Errorf("failed to load config: %w", err)
		}

		l := logger.New(logger.Debug)

		modeDetector := tui.NewModeDetector()
		if modeDetector.IsNonInteractive() || ciFlag {
			return runBootstrapNonInteractive(cmd, l, cfg)
		}

		return runBootstrapInteractive(l, cfg)
	},
}

VarBootstrapCmd is the bootstrap command

View Source
var VarCheckCmd = &cobra.Command{
	Use:   "check",
	Short: "Check for conflicts in the dependency graph",
	RunE:  runCheckConflicts,
}

VarCheckCmd represents the check command

View Source
var VarCleanCmd = &cobra.Command{
	Use:   "clean",
	Short: "Remove vendored dependencies",
	RunE:  runVendorClean,
}

VarCleanCmd represents the clean command

View Source
var VarConflictCmd = &cobra.Command{
	Use:   "conflict",
	Short: "Check for dependency conflicts",
	Long:  `Check the dependency graph for potential conflicts and circular dependencies.`,
}

VarConflictCmd represents the conflict command

View Source
var VarDepsCmd = &cobra.Command{
	Use:   "deps",
	Short: "Manage specification dependencies",
	Long: `Manage external specification dependencies for your project.

Dependencies are stored in github.com/specledger/specledger/specledger.yaml and cached locally for offline use.

Examples:
  sl deps list                           # List all dependencies
  sl deps add git@github.com:org/spec    # Add a dependency
  sl deps remove git@github.com:org/spec # Remove a dependency`,
}

VarDepsCmd represents the deps command

View Source
var VarDepsListCmd = &cobra.Command{
	Use:     "list",
	Short:   "List all dependencies",
	Long:    `List all declared dependencies from specledger.yaml, showing their repository, version, and resolved status.`,
	Example: `  sl deps list`,
	RunE:    runListDependencies,
}

VarDepsListCmd represents the list command

View Source
var VarDepsUpdateCmd = &cobra.Command{
	Use:   "update [repo-url]",
	Short: "Update dependencies to latest versions",
	Long:  `Update dependencies to their latest versions. If no URL is given, updates all dependencies.`,
	Example: `  sl deps update                    # Update all
  sl deps update git@github.com:org/spec # Update one`,
	RunE: runUpdateDependencies,
}

VarDepsUpdateCmd represents the update command

View Source
var VarDetectCmd = &cobra.Command{
	Use:   "detect",
	Short: "Detect potential conflicts",
	RunE:  runDetectConflicts,
}

VarDetectCmd represents the detect command

View Source
var VarDoctorCmd = &cobra.Command{
	Use:   "doctor",
	Short: "Check installation status of required and optional tools",
	Long: `Check the installation status of all tools required by SpecLedger.

This command verifies that:
- Core tools (mise, bd, perles) are installed and accessible
- Framework tools (specify, openspec) are installed (optional)

Use --json flag for machine-readable output suitable for CI/CD pipelines.`,
	Example: `  sl doctor           # Human-readable output
  sl doctor --json    # JSON output for CI/CD`,
	RunE:          runDoctor,
	SilenceUsage:  true,
	SilenceErrors: true,
}

VarDoctorCmd represents the doctor command

View Source
var VarExportCmd = &cobra.Command{
	Use:   "export --format <format> --output <file>",
	Short: "Export graph to file (coming soon)",
	Long: `Export the dependency graph to a file for visualization.

Supported formats will include: JSON, SVG, DOT (Graphviz)`,
	Example: "  sl graph export --format svg --output deps.svg",
	RunE:    runExportGraph,
}

VarExportCmd represents the export command

View Source
var VarGraphCmd = &cobra.Command{
	Use:   "graph",
	Short: "Display dependency graphs",
	Long: `Visualize dependencies and their relationships.

NOTE: This feature is coming soon. For now, use 'sl deps list' to see dependencies.`,
}

VarGraphCmd represents the graph command

View Source
var VarInitCmd = &cobra.Command{
	Use:   "init",
	Short: "Initialize SpecLedger in an existing repository",
	Long: `Initialize SpecLedger in the current repository directory.

This adds SpecLedger to an existing project without creating a new directory.

Usage:
  sl init
  sl init --short-code abc
  sl init --playbook specledger

The init creates:
- .claude/ directory with skills
- .beads/ directory for issue tracking
- github.com/specledger/specledger/ directory for specifications
- github.com/specledger/specledger/specledger.yaml file for project metadata`,
	RunE: func(cmd *cobra.Command, args []string) error {
		l := logger.New(logger.Debug)
		return runInit(l)
	},
}

VarInitCmd is the init command

View Source
var VarListCmd = &cobra.Command{
	Use:   "list [--spec-path <path>]",
	Short: "List all external references",
	RunE:  runListReferences,
}

VarListCmd represents the list command

View Source
var VarPlaybookCmd = &cobra.Command{
	Use:   "playbook",
	Short: "Manage SDD playbooks",
	Long: `Manage embedded SDD playbooks for SpecLedger.

Playbooks contain Claude Code commands, skills, scripts, and templates
for SpecLedger projects.

Examples:
  sl playbook list              List all available playbooks
  sl playbook list --json       List playbooks in JSON format`,
}

VarPlaybookCmd represents the playbook command

View Source
var VarPlaybookListCmd = &cobra.Command{
	Use:     "list",
	Short:   "List available SDD playbooks",
	Long:    `List all available embedded SDD playbooks with their names, descriptions, frameworks, and versions.`,
	Example: `  sl playbook list`,
	RunE:    runListPlaybooks,
}

VarPlaybookListCmd represents the list command

View Source
var VarRefsCmd = &cobra.Command{
	Use:   "refs",
	Short: "Validate external specification references",
}

VarRefsCmd represents the refs command

View Source
var VarRemoveCmd = &cobra.Command{
	Use:     "remove <repo-url>",
	Short:   "Remove a dependency",
	Long:    `Remove a dependency from specledger.yaml. The local cache will be kept for future use.`,
	Example: `  sl deps remove git@github.com:org/api-spec`,
	Args:    cobra.ExactArgs(1),
	RunE:    runRemoveDependency,
}

VarRemoveCmd represents the remove command

View Source
var VarResolveCmd = &cobra.Command{
	Use:     "resolve",
	Short:   "Download and cache dependencies",
	Long:    `Download all dependencies from specledger.yaml and cache them locally at ~/.github.com/specledger/specledger/cache/.`,
	Example: `  sl deps resolve`,
	RunE:    runResolveDependencies,
}

VarResolveCmd represents the resolve command

View Source
var VarShowCmd = &cobra.Command{
	Use:   "show",
	Short: "Show dependency graph (coming soon)",
	Long: `Display the complete dependency graph with all nodes and edges.

This will show how specifications depend on each other.`,
	Example: "  sl graph show",
	RunE:    runShowGraph,
}

VarShowCmd represents the show command

View Source
var VarTransitiveCmd = &cobra.Command{
	Use:   "transitive",
	Short: "Show transitive dependencies (coming soon)",
	Long: `Show all transitive dependencies up to a specified depth.

This helps understand the full dependency tree.`,
	Example: "  sl graph transitive --depth 3",
	RunE:    runTransitiveDependencies,
}

VarTransitiveCmd represents the transitive command

View Source
var VarUpdateCmd = &cobra.Command{
	Use:   "update",
	Short: "Update the SpecLedger CLI to the latest version",
	Long:  `Check for updates and upgrade the SpecLedger CLI to the latest version.`,
	RunE:  runUpdateSelf,
}

VarUpdateCmd represents the update command TODO: Implement self-update functionality

View Source
var VarValidateCmd = &cobra.Command{
	Use:   "validate [--strict] [--spec-path <path>]",
	Short: "Validate all external references in a specification",
	Long:  `Validate all external references in spec.md files against resolved dependencies.`,
	Args:  cobra.MaximumNArgs(1),
	RunE:  runValidateReferences,
}

VarValidateCmd represents the validate command

View Source
var VarVendorAllCmd = &cobra.Command{
	Use:   "vendor --output <path>",
	Short: "Copy all dependencies to vendor directory",
	Long:  `Copy all external dependencies to the local vendor directory for offline use.`,
	Args:  cobra.MaximumNArgs(1),
	RunE:  runVendorAll,
}

VarVendorAllCmd represents the vendor all command

View Source
var VarVendorCmd = &cobra.Command{
	Use:   "vendor",
	Short: "Vendor dependencies for offline use",
}

VarVendorCmd represents the vendor command

View Source
var VarVendorUpdateCmd = &cobra.Command{
	Use:   "update [--vendor-path <path>] [--force]",
	Short: "Update vendored dependencies",
	RunE:  runVendorUpdate,
}

VarVendorUpdateCmd represents the vendor update command

Functions

func ExitWithCode

func ExitWithCode(code int, err error)

ExitWithCode prints error message and exits with specific code

func ExitWithError

func ExitWithError(err error)

ExitWithError prints error message and exits

func ListVendorSpecs

func ListVendorSpecs(vendorPath string) ([]string, error)

ListVendorSpecs lists all vendored specs

func PrintSuccess

func PrintSuccess(title string, details ...string)

PrintSuccess prints success message

Types

type CLIError

type CLIError struct {
	Title       string
	Description string
	Suggestions []string
	ExitCode    int
}

CLIError represents a CLI error with actionable suggestions

func ErrCIRequired

func ErrCIRequired() *CLIError

ErrCIRequired indicates TUI is required in non-interactive environment

func ErrCommandNotFound

func ErrCommandNotFound(command string) *CLIError

ErrCommandNotFound indicates an invalid command

func ErrInvalidInput

func ErrInvalidInput(message string) *CLIError

ErrInvalidInput indicates invalid input

func ErrMissingDependency

func ErrMissingDependency(name string, installCmd string) *CLIError

ErrMissingDependency indicates a required dependency is not installed

func ErrNotAProject

func ErrNotAProject() *CLIError

ErrNotAProject indicates the current directory is not a SpecLedger project

func ErrPermissionDenied

func ErrPermissionDenied(path string) *CLIError

ErrPermissionDenied indicates permission error

func ErrProjectExists

func ErrProjectExists(projectName string) *CLIError

ErrProjectExists indicates the project directory already exists

func NewCLIError

func NewCLIError(title, description string, suggestions []string, exitCode int) *CLIError

NewCLIError creates a new CLI error with suggestions

func (*CLIError) Error

func (e *CLIError) Error() string

Error returns the error message

type DoctorOutput

type DoctorOutput struct {
	Status              string             `json:"status"`
	Tools               []DoctorToolStatus `json:"tools"`
	Missing             []string           `json:"missing,omitempty"`
	InstallInstructions string             `json:"install_instructions,omitempty"`
}

DoctorOutput represents the JSON output structure for doctor command

type DoctorToolStatus

type DoctorToolStatus struct {
	Name      string `json:"name"`
	Installed bool   `json:"installed"`
	Version   string `json:"version,omitempty"`
	Path      string `json:"path,omitempty"`
	Category  string `json:"category"`
}

DoctorToolStatus represents a tool's status in JSON output

Jump to

Keyboard shortcuts

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