Documentation
¶
Overview ¶
Package cli provides a composable CLI for visionspec.
Organizations can import this package to build custom CLI tools that include visionspec commands alongside their own:
package main
import (
"github.com/spf13/cobra"
"github.com/ProductBuildersHQ/visionspec/pkg/cli"
)
func main() {
root := &cobra.Command{Use: "org-spec"}
cfg := cli.DefaultConfig()
cli.AddCommandsTo(root, cfg)
root.AddCommand(customCmd)
root.Execute()
}
Index ¶
- func AddCommandsTo(root *cobra.Command, cfg *Config)
- func WithConfig(ctx context.Context, cfg *Config) context.Context
- type CommandSet
- type Config
- func (c *Config) GetAppTypeLoader() apptypes.Loader
- func (c *Config) GetConstitutionLoader() constitution.Loader
- func (c *Config) GetRubricLoaderForWorkflow(methodology string) rubrics.Loader
- func (c *Config) GetSpecConfig() *types.SpecConfig
- func (c *Config) GetTemplateLoaderForWorkflow(methodology string) templates.Loader
- func (c *Config) GetWorkflowsRepo() (*workflows.Repo, error)
- func (c *Config) GetWorkflowsRepoPath() string
- func (c *Config) ListAvailableWorkflows() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCommandsTo ¶
AddCommandsTo adds all visionspec commands to a root command.
Types ¶
type CommandSet ¶
type CommandSet struct {
Init *cobra.Command
Create *cobra.Command
Lint *cobra.Command
Status *cobra.Command
Eval *cobra.Command
Render *cobra.Command
Synthesize *cobra.Command
Reconcile *cobra.Command
Approve *cobra.Command
Export *cobra.Command
Targets *cobra.Command
Graph *cobra.Command
Docs *cobra.Command
Serve *cobra.Command
Profiles *cobra.Command
Context *cobra.Command
Rules *cobra.Command
Generate *cobra.Command
Sync *cobra.Command
Drift *cobra.Command
Watch *cobra.Command
Workflows *cobra.Command
Version *cobra.Command
}
CommandSet contains all visionspec commands.
func Commands ¶
func Commands(cfg *Config) *CommandSet
Commands returns all visionspec commands. Use this for selective command inclusion.
type Config ¶
type Config struct {
// TemplateLoader loads spec templates.
// If nil, uses embedded templates.
TemplateLoader templates.Loader
// RubricLoader loads evaluation rubrics.
// If nil, uses embedded rubrics.
RubricLoader rubrics.Loader
// SpecConfig defines which specs are required and their settings.
// If nil, uses default visionspec requirements.
SpecConfig *types.SpecConfig
// ProfileLoader loads configuration profiles.
// If nil, uses default profiles.
ProfileLoader profiles.Loader
// ConstitutionLoader loads organization/team/project constitutions.
// If nil, no built-in constitutions are available.
// Organizations typically provide their own loader with prescriptive defaults.
ConstitutionLoader constitution.Loader
// AppTypeLoader loads app type specifications.
// If nil, uses built-in app type specs.
AppTypeLoader apptypes.Loader
// DefaultProfile is the profile to use when none is specified.
// If empty, uses no profile (default visionspec behavior).
DefaultProfile string
// WorkflowsRepoPath is the path to a spec-workflows repository.
// If set, templates and rubrics are loaded from this repo.
WorkflowsRepoPath string
// Version is the CLI version string.
Version string
}
Config allows customization of CLI behavior. Organizations can provide custom loaders to override defaults:
cfg := cli.DefaultConfig() cfg.TemplateLoader = templates.NewChainLoader( orgTemplates, // Organization-specific (prescriptive) cfg.TemplateLoader, // Fall back to visionspec defaults ) cfg.ConstitutionLoader = constitution.NewChainLoader( orgConstitutions, cfg.ConstitutionLoader, )
func ConfigFromContext ¶
ConfigFromContext returns the Config from a context.
func ConfigFromProfile ¶
ConfigFromProfile creates a Config from a profile.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration. This provides flexible, choice-based defaults suitable for open source use. Organizations should use NewOrgConfig() or customize loaders for prescriptive defaults.
func (*Config) GetAppTypeLoader ¶ added in v0.8.0
GetAppTypeLoader returns the AppTypeLoader, falling back to built-in specs if nil.
func (*Config) GetConstitutionLoader ¶ added in v0.8.0
func (c *Config) GetConstitutionLoader() constitution.Loader
GetConstitutionLoader returns the ConstitutionLoader. Returns nil if no loader is configured (organizations must provide their own).
func (*Config) GetRubricLoaderForWorkflow ¶ added in v0.9.0
GetRubricLoaderForWorkflow returns a rubric loader for a specific workflow. If a workflows repo is found (explicit or auto-discovered), it creates a chain loader that prioritizes the workflow's methodology-specific rubrics, then falls back to defaults.
func (*Config) GetSpecConfig ¶
func (c *Config) GetSpecConfig() *types.SpecConfig
GetSpecConfig returns the SpecConfig, falling back to defaults if nil.
func (*Config) GetTemplateLoaderForWorkflow ¶ added in v0.9.0
GetTemplateLoaderForWorkflow returns a template loader for a specific workflow. If a workflows repo is found (explicit or auto-discovered), it creates a chain loader that prioritizes the workflow's methodology-specific templates, then falls back to defaults.
func (*Config) GetWorkflowsRepo ¶ added in v0.9.0
GetWorkflowsRepo loads and returns the spec-workflows repository. Uses auto-discovery if no explicit path is configured. Returns nil, nil if no repository is found (not an error for optional usage).
func (*Config) GetWorkflowsRepoPath ¶ added in v0.9.0
GetWorkflowsRepoPath returns the path to the spec-workflows repository. Uses auto-discovery if no explicit path is configured. Returns empty string if no repository is found.
func (*Config) ListAvailableWorkflows ¶ added in v0.9.0
ListAvailableWorkflows returns all available workflow IDs from the workflows repo. Uses auto-discovery if no explicit path is configured. Returns nil if no workflows repo is found.