Documentation
¶
Index ¶
- Constants
- Variables
- func ExitWithCode(code int, err error)
- func ExitWithError(err error)
- func IsConstitutionPopulated(path string) bool
- func ListVendorSpecs(vendorPath string) ([]string, error)
- func PrintSuccess(title string, details ...string)
- func ReadAgentPreference(path string) (string, error)
- func WriteDefaultConstitution(path string, principles []ConstitutionPrinciple, agentPref string) error
- type CLIError
- func ErrCIRequired() *CLIError
- func ErrCommandNotFound(command string) *CLIError
- func ErrInvalidInput(message string) *CLIError
- func ErrMissingDependency(name string, installCmd string) *CLIError
- func ErrNotAProject() *CLIError
- func ErrPermissionDenied(path string) *CLIError
- func ErrProjectExists(projectName string) *CLIError
- func NewCLIError(title, description string, suggestions []string, exitCode int) *CLIError
- type ConstitutionPrinciple
- type DoctorOutput
- type DoctorToolStatus
Constants ¶
const ( // ProductionAuthURL is the production SpecLedger authentication URL ProductionAuthURL = "https://app.specledger.io/cli/auth" // DevAuthURL is the development authentication URL DevAuthURL = "http://localhost:3000/cli/auth" // AuthTimeout is the maximum time to wait for browser authentication AuthTimeout = 5 * time.Minute )
Variables ¶
var VarAddCmd = &cobra.Command{ Use: "add <repo-url> [branch] --alias <name> [--artifact-path <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. The --alias flag is required and will be used as the reference path when accessing artifacts from this dependency. For SpecLedger repositories, the artifact_path will be auto-detected from the dependency's specledger.yaml. For non-SpecLedger repositories, use --artifact-path to manually specify where artifacts are located.`, Example: ` sl deps add git@github.com:org/api-spec --alias api sl deps add git@github.com:org/api-spec develop --alias api sl deps add https://github.com/org/api-docs --alias docs --artifact-path docs/openapi/`, Args: cobra.MinimumNArgs(1), RunE: runAddDependency, }
VarAddCmd represents the add command
var VarAuthCmd = &cobra.Command{
Use: "auth",
Short: "Manage authentication",
Long: `Manage authentication for SpecLedger CLI.
Authentication is required for accessing protected features like
private specifications and remote synchronization.
Examples:
sl auth login # Sign in via browser
sl auth logout # Sign out and clear tokens
sl auth status # Check authentication status`,
}
VarAuthCmd represents the auth command group
var VarAuthLoginCmd = &cobra.Command{
Use: "login",
Short: "Sign in via browser",
Long: `Open your browser to sign in to SpecLedger.
This command will:
1. Start a temporary local server to receive authentication
2. Open your default browser to the SpecLedger sign-in page
3. Wait for you to complete authentication
4. Store your credentials securely
If the browser doesn't open automatically, you can manually navigate
to the URL shown in the terminal.`,
RunE: runLogin,
}
VarAuthLoginCmd represents the login command
var VarAuthLogoutCmd = &cobra.Command{
Use: "logout",
Short: "Sign out and clear tokens",
Long: `Sign out of SpecLedger and remove stored credentials.`,
RunE: runLogout,
}
VarAuthLogoutCmd represents the logout command
var VarAuthRefreshCmd = &cobra.Command{
Use: "refresh",
Short: "Refresh access token",
Long: `Manually refresh the access token using the stored refresh token.`,
RunE: runRefresh,
}
VarAuthRefreshCmd represents the refresh command
var VarAuthStatusCmd = &cobra.Command{
Use: "status",
Short: "Check authentication status",
Long: `Display the current authentication status and user information.`,
RunE: runStatus,
}
VarAuthStatusCmd represents the status command
var VarAuthSupabaseCmd = &cobra.Command{
Use: "supabase",
Short: "Show Supabase configuration",
Long: `Display Supabase URL and anon key for API access.`,
RunE: runSupabase,
}
VarAuthSupabaseCmd represents the supabase config command
var VarAuthTokenCmd = &cobra.Command{
Use: "token",
Short: "Print access token (for scripts)",
Long: `Print the current access token to stdout.
This command is designed for use in scripts and automation.
It outputs only the token with no other text, making it easy
to capture in a variable:
ACCESS_TOKEN=$(sl auth token)
The token is automatically refreshed if expired.`,
RunE: runToken,
}
VarAuthTokenCmd represents the token command (for scripts)
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 - Built-in issue tracking via sl issue commands - 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
var VarCheckCmd = &cobra.Command{
Use: "check",
Short: "Check for conflicts in the dependency graph",
RunE: runCheckConflicts,
}
VarCheckCmd represents the check command
var VarCleanCmd = &cobra.Command{
Use: "clean",
Short: "Remove vendored dependencies",
RunE: runVendorClean,
}
VarCleanCmd represents the clean command
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
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
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
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
var VarDetectCmd = &cobra.Command{
Use: "detect",
Short: "Detect potential conflicts",
RunE: runDetectConflicts,
}
VarDetectCmd represents the detect command
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
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
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
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 - Built-in issue tracking via sl issue commands - 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
var VarIssueCmd = &cobra.Command{
Use: "issue",
Short: "Manage issues for the current spec",
Long: `Manage issues for tracking work within a spec.
Issues are stored in JSONL format at specledger/<spec>/issues.jsonl.
Each issue has a globally unique ID (SL-xxxxxx format).
Commands:
sl issue create Create a new issue
sl issue list List issues
sl issue show Show issue details
sl issue update Update an issue
sl issue close Close an issue
sl issue link Link issues with dependencies
sl issue unlink Remove dependency links
sl issue migrate Migrate from Beads format
sl issue repair Repair corrupted issues.jsonl
Examples:
sl issue create --title "Add validation" --type task
sl issue list --status open
sl issue show SL-a3f5d8
sl issue update SL-a3f5d8 --status in_progress
sl issue close SL-a3f5d8`,
}
VarIssueCmd is the issue command group
var VarLinkCmd = &cobra.Command{
Use: "link",
Short: "Create symlinks from cached dependencies to project artifacts directory",
Long: `Create symlinks from cached dependencies to the project's artifacts directory, making them available for Claude Code and other tools.
This command creates symlinks from ~/.specledger/cache/<alias>/ to <project.artifact_path>/deps/<alias>/, allowing reference paths like "alias:artifact.md" to resolve to actual files.
Example: sl deps link`,
RunE: runLinkDependencies,
}
VarLinkCmd represents the link command
var VarListCmd = &cobra.Command{
Use: "list [--spec-path <path>]",
Short: "List all external references",
RunE: runListReferences,
}
VarListCmd represents the list command
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
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
var VarRefsCmd = &cobra.Command{
Use: "refs",
Short: "Validate external specification references",
}
VarRefsCmd represents the refs command
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
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
var VarReviseCmd = &cobra.Command{ Use: "revise [branch-name]", Short: "Fetch and address review comments for a spec", Long: `Fetch unresolved review comments from Supabase and guide you through addressing them with an AI coding agent. Flow: 1. Detect or select the target branch 2. Fetch unresolved comments from Supabase 3. Select artifacts to work on (multi-select) 4. Process each comment (provide guidance or skip) 5. Generate a combined revision prompt 6. Open the prompt in your editor for refinement 7. Launch the configured AI coding agent 8. Offer to commit/push changes and resolve comments Examples: sl revise # Interactive: detect branch, fetch comments sl revise 136-revise-comments # Use the specified branch directly sl revise --summary # Print compact comment listing and exit sl revise --auto fixture.json # Non-interactive: fixture-driven prompt generation sl revise --dry-run # Interactive flow but write prompt to file instead of launching agent`, Args: cobra.MaximumNArgs(1), RunE: runRevise, SilenceUsage: true, }
VarReviseCmd is the sl revise command.
var VarSessionCaptureCmd = &cobra.Command{ Use: "capture", Short: "Capture session from hook input", Long: `Capture an AI session from Claude Code hook input. This command is designed to be called by Claude Code hooks, not manually. It reads hook JSON from stdin, detects git commits, and captures the conversation delta since the last commit. Test mode (for manual testing): sl session capture --test-mode Exit codes: 0 - Success (session captured/queued) or no-op (not a commit) 1 - Fatal error (logged to stderr)`, RunE: runSessionCapture, SilenceUsage: true, }
VarSessionCaptureCmd represents the capture command (called by hooks)
var VarSessionCmd = &cobra.Command{
Use: "session",
Short: "Manage AI session captures",
Long: `Manage AI session captures for checkpoints and tasks.
Sessions are automatically captured when you commit changes while working
with Claude Code. They provide a record of the AI conversation that led
to each commit.
Examples:
sl session list # List sessions for current branch
sl session get abc123 # Get session by commit hash
sl session sync # Upload queued sessions`,
}
VarSessionCmd represents the session command group
var VarSessionGetCmd = &cobra.Command{ Use: "get <session-id|commit-hash|task-id>", Short: "Retrieve a session's content", Long: `Retrieve and display a session's conversation content. You can look up a session by: - Session ID (UUID) - Commit hash (full or partial) - Task ID (e.g., SL-42)`, Args: cobra.ExactArgs(1), RunE: runSessionGet, }
VarSessionGetCmd represents the get command
var VarSessionListCmd = &cobra.Command{
Use: "list",
Short: "List sessions for a feature",
Long: `List sessions for a feature branch.
By default, lists sessions for the current git branch.
Use --feature to specify a different branch.`,
RunE: runSessionList,
}
VarSessionListCmd represents the list command
var VarSessionSyncCmd = &cobra.Command{
Use: "sync",
Short: "Upload queued sessions",
Long: `Upload sessions that were queued due to network failures.
When session capture fails (e.g., network down), sessions are stored
locally and can be uploaded later with this command.`,
RunE: runSessionSync,
}
VarSessionSyncCmd represents the sync command
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
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
var VarUnlinkCmd = &cobra.Command{ Use: "unlink [alias]", Short: "Remove symlinks for dependencies", Long: `Remove symlinks for dependencies from the project's artifacts directory. If no alias is specified, removes all dependency symlinks. If an alias is specified, only removes that dependency's symlink. Example: sl deps unlink # Unlink all sl deps unlink api # Unlink specific dependency`, Args: cobra.MaximumNArgs(1), RunE: runUnlinkDependencies, }
VarUnlinkCmd represents the unlink command
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
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
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
var VarVendorCmd = &cobra.Command{
Use: "vendor",
Short: "Vendor dependencies for offline use",
}
VarVendorCmd represents the vendor command
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 ¶
ExitWithCode prints error message and exits with specific code
func IsConstitutionPopulated ¶ added in v1.0.17
IsConstitutionPopulated checks if the constitution file exists and is populated (no placeholder tokens remaining). Returns false if the file is missing, empty, or still contains [PLACEHOLDER] style tokens.
func ListVendorSpecs ¶
ListVendorSpecs lists all vendored specs
func PrintSuccess ¶
PrintSuccess prints success message
func ReadAgentPreference ¶ added in v1.0.17
ReadAgentPreference extracts the preferred agent from a populated constitution file. Returns empty string and nil error if the file exists but has no agent preference.
func WriteDefaultConstitution ¶ added in v1.0.17
func WriteDefaultConstitution(path string, principles []ConstitutionPrinciple, agentPref string) error
WriteDefaultConstitution writes a populated constitution file with the given principles and agent preference, replacing template placeholders.
Types ¶
type CLIError ¶
CLIError represents a CLI error with actionable suggestions
func ErrCIRequired ¶
func ErrCIRequired() *CLIError
ErrCIRequired indicates TUI is required in non-interactive environment
func ErrCommandNotFound ¶
ErrCommandNotFound indicates an invalid command
func ErrInvalidInput ¶
ErrInvalidInput indicates invalid input
func ErrMissingDependency ¶
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 ¶
ErrPermissionDenied indicates permission error
func ErrProjectExists ¶
ErrProjectExists indicates the project directory already exists
func NewCLIError ¶
NewCLIError creates a new CLI error with suggestions
type ConstitutionPrinciple ¶ added in v1.0.17
ConstitutionPrinciple represents a selectable guiding principle for the project constitution.
func DefaultPrinciples ¶ added in v1.0.17
func DefaultPrinciples() []ConstitutionPrinciple
DefaultPrinciples returns the default set of constitution principles presented during sl new.
type DoctorOutput ¶
type DoctorOutput struct {
Status string `json:"status"`
Tools []DoctorToolStatus `json:"tools"`
Missing []string `json:"missing,omitempty"`
InstallInstructions string `json:"install_instructions,omitempty"`
// CLI version info
CLIVersion string `json:"cli_version"`
CLILatestVersion string `json:"cli_latest_version,omitempty"`
CLIUpdateAvailable bool `json:"cli_update_available"`
CLIUpdateInstructions string `json:"cli_update_instructions,omitempty"`
CLICheckError string `json:"cli_check_error,omitempty"`
// Template version info
TemplateVersion string `json:"template_version,omitempty"`
TemplateUpdateAvailable bool `json:"template_update_available"`
TemplateCustomizedFiles []string `json:"template_customized_files,omitempty"`
}
DoctorOutput represents the JSON output structure for doctor command