config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config manages DevSpecs configuration: global home directory, repo-local .devspecs/config.yaml, and sensible defaults.

Index

Constants

View Source
const (
	KindPlan             = "plan"
	KindSpec             = "spec"
	KindRequirements     = "requirements"
	KindDesign           = "design"
	KindContract         = "contract"
	KindDecision         = "decision"
	KindMarkdownArtifact = "markdown_artifact"
	KindSourceContext    = "source_context"
)

Canonical artifact kinds (closed vocabulary).

View Source
const (
	SubtypeADR                    = "adr"
	SubtypeOpenspecChange         = "openspec_change"
	SubtypeOpenspecCollection     = "openspec_collection"
	SubtypeOpenspecChangeBundle   = "openspec_change_bundle"
	SubtypeOpenspecChild          = "openspec_child"
	SubtypeOpenspecCapabilitySpec = "openspec_capability_spec"
	SubtypePRD                    = "prd"
	SubtypeAgentInstruction       = "agent_instruction"
	SubtypeSkill                  = "skill"
	SubtypeMaintainerPolicy       = "maintainer_policy"
	SubtypeOwnershipPolicy        = "ownership_policy"
	SubtypeGovernancePolicy       = "governance_policy"
	SubtypeContributionPolicy     = "contribution_policy"
	SubtypeSecurityPolicy         = "security_policy"
	SubtypeProcedure              = "procedure"
	SubtypeRunbook                = "runbook"
	SubtypeStandard               = "standard"
	SubtypeAPIContract            = "api_contract"
	SubtypeSchemaModel            = "schema_model"
	SubtypeConfiguration          = "configuration"
	SubtypeWorkflowDefinition     = "workflow_definition"
	SubtypeDocumentTemplate       = "document_template"
	SubtypePromptTemplate         = "prompt_template"
	SubtypeIssueTemplate          = "issue_template"
	SubtypePullRequestTemplate    = "pull_request_template"
	SubtypeTestCase               = "test_case"
	SubtypeCodeComment            = "code_comment"
)

Known subtypes per kind (empty subtype is always allowed).

Variables

This section is empty.

Functions

func DBPath

func DBPath() (string, error)

DBPath returns the path to the global SQLite database.

func HomeDir

func HomeDir() (string, error)

HomeDir returns the DevSpecs global directory (~/.devspecs or DEVSPECS_HOME override).

func RepoConfigPath

func RepoConfigPath(repoRoot string) string

RepoConfigPath returns the path to the repo config file for the given root.

func ValidateKind

func ValidateKind(kind string) error

ValidateKind returns an error if kind is not in the closed vocabulary.

func ValidateRepoConfig

func ValidateRepoConfig(cfg *RepoConfig) error

ValidateRepoConfig checks kinds in markdown source rules.

func ValidateSourceRules

func ValidateSourceRules(rules []SourceRule) error

ValidateSourceRules checks source rule kinds and subtypes.

func ValidateSubtype

func ValidateSubtype(kind, subtype string) error

ValidateSubtype returns an error if subtype is non-empty but not allowed for the given kind.

func WriteRepoConfig

func WriteRepoConfig(repoRoot string, cfg *RepoConfig) error

WriteRepoConfig writes the config to .devspecs/config.yaml, creating the directory if needed.

Types

type ArtifactConfig added in v0.1.0

type ArtifactConfig struct {
	TestCases    *bool `yaml:"test_cases,omitempty"`
	CodeComments *bool `yaml:"code_comments,omitempty"`
}

ArtifactConfig holds canonical opt-in artifact sources that can be expensive or noisy on large repositories.

type ExperimentConfig added in v0.1.0

type ExperimentConfig struct {
	IntentCandidateDiscovery *bool `yaml:"intent_candidate_discovery,omitempty"`
	TestCaseArtifacts        *bool `yaml:"test_case_artifacts,omitempty"`
	SupportDocDiscovery      *bool `yaml:"support_doc_discovery,omitempty"`
}

ExperimentConfig holds legacy opt-in scan/indexing experiments. New callers should prefer ArtifactConfig; these fields remain for config compatibility.

func (ExperimentConfig) IntentCandidateDiscoveryEnabled added in v0.1.0

func (e ExperimentConfig) IntentCandidateDiscoveryEnabled(defaultValue bool) bool

func (ExperimentConfig) SupportDocDiscoveryEnabled added in v0.1.0

func (e ExperimentConfig) SupportDocDiscoveryEnabled(defaultValue bool) bool

func (ExperimentConfig) TestCaseArtifactsEnabled added in v0.1.0

func (e ExperimentConfig) TestCaseArtifactsEnabled(defaultValue bool) bool

type RepoConfig

type RepoConfig struct {
	Version     int              `yaml:"version"`
	Sources     []SourceConfig   `yaml:"sources"`
	Artifacts   ArtifactConfig   `yaml:"artifacts,omitempty"`
	Experiments ExperimentConfig `yaml:"experiments,omitempty"`
}

RepoConfig represents the .devspecs/config.yaml file in a repository.

func CloneRepoConfig added in v0.1.0

func CloneRepoConfig(cfg *RepoConfig) *RepoConfig

CloneRepoConfig returns a deep-enough copy for scan-time option mutation.

func DefaultRepoConfig

func DefaultRepoConfig() *RepoConfig

DefaultRepoConfig returns sensible defaults per spec §10.

func LoadRepoConfig

func LoadRepoConfig(repoRoot string) (*RepoConfig, error)

LoadRepoConfig reads and parses .devspecs/config.yaml from the given repo root. Returns nil, nil if the file does not exist.

func WithCodeCommentArtifacts added in v0.1.0

func WithCodeCommentArtifacts(cfg *RepoConfig, enabled bool) *RepoConfig

WithCodeCommentArtifacts returns a config copy with code-comment artifact indexing set.

func WithDefaultIntentCandidateDiscovery added in v0.1.0

func WithDefaultIntentCandidateDiscovery(cfg *RepoConfig, enabled bool) *RepoConfig

WithDefaultIntentCandidateDiscovery enables broad intent discovery only when the repo config did not explicitly opt in or out.

func WithIntentCandidateDiscovery added in v0.1.0

func WithIntentCandidateDiscovery(cfg *RepoConfig, enabled bool) *RepoConfig

WithIntentCandidateDiscovery returns a config copy with the intent candidate discovery experiment set. A nil input starts from the default repo config.

func WithSupportDocDiscovery added in v0.1.0

func WithSupportDocDiscovery(cfg *RepoConfig, enabled bool) *RepoConfig

WithSupportDocDiscovery returns a config copy with bounded support-doc discovery set.

func WithTestCaseArtifacts added in v0.1.0

func WithTestCaseArtifacts(cfg *RepoConfig, enabled bool) *RepoConfig

WithTestCaseArtifacts returns a config copy with test-case artifact indexing set.

func (RepoConfig) CodeCommentArtifactsEnabled added in v0.1.0

func (c RepoConfig) CodeCommentArtifactsEnabled(defaultValue bool) bool

func (RepoConfig) TestCaseArtifactsEnabled added in v0.1.0

func (c RepoConfig) TestCaseArtifactsEnabled(defaultValue bool) bool

type SourceConfig

type SourceConfig struct {
	Type  string       `yaml:"type"`
	Path  string       `yaml:"path,omitempty"`
	Paths []string     `yaml:"paths,omitempty"`
	Rules []SourceRule `yaml:"rules,omitempty"`
}

SourceConfig defines a source type and its discovery paths.

type SourceRule

type SourceRule struct {
	Match   string   `yaml:"match"`
	Kind    string   `yaml:"kind"`
	Subtype string   `yaml:"subtype,omitempty"`
	Tags    []string `yaml:"tags,omitempty"`
}

SourceRule maps a glob (relative to configured markdown paths) to kind/subtype/tags.

Jump to

Keyboard shortcuts

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