Documentation
¶
Overview ¶
Package discovery provides functions for finding active changes and specs in a spectr intialized project.
Package discovery provides test helpers for change and spec discovery.
Index ¶
- func GetActiveChangeIDs(projectRoot string) ([]string, error)
- func GetActiveChanges(projectPath string) ([]string, error)
- func GetSpecIDs(projectRoot string) ([]string, error)
- func GetSpecs(projectPath string) ([]string, error)
- func NormalizeItemPath(input string) (id, inferredType string)
- type ResolveResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetActiveChangeIDs ¶
GetActiveChangeIDs returns a list of active change IDs (directory names under spectr/changes/, excluding archive/) Returns empty slice (not error) if the directory doesn't exist Results are sorted alphabetically for consistency
func GetActiveChanges ¶
GetActiveChanges finds all active changes in spectr/changes/, excluding archive directory
func GetSpecIDs ¶
GetSpecIDs returns a list of spec IDs (directory names under spectr/specs/) Returns empty slice (not error) if the directory doesn't exist Results are sorted alphabetically for consistency
func NormalizeItemPath ¶ added in v0.0.8
NormalizeItemPath extracts the item ID and infers type from a path argument. Returns the normalized ID and inferred type: "change", "spec", or "" if not inferred from path.
Path patterns recognized:
- spectr/changes/<id> -> id, "change"
- spectr/changes/<id>/specs/foo/spec.md -> id, "change"
- spectr/specs/<id> -> id, "spec"
- spectr/specs/<id>/spec.md -> id, "spec"
- /absolute/path/spectr/changes/<id> -> id, "change"
- /absolute/path/spectr/specs/<id> -> id, "spec"
- simple-id -> simple-id, "" (no inferred type)
Types ¶
type ResolveResult ¶
ResolveResult contains the resolved change ID and whether it was a partial match.
func ResolveChangeID ¶
func ResolveChangeID( partialID, projectRoot string, ) (ResolveResult, error)
ResolveChangeID resolves a partial change ID to a full change ID.
The resolution algorithm:
- Exact match: returns immediately if partialID exactly matches a change ID
- Prefix match: finds all change IDs that start with partialID (case-insensitive)
- Substring match: if no prefix matches, finds all change IDs containing partialID (case-insensitive)
Returns an error if: - No changes match the partial ID - Multiple changes match the partial ID (ambiguous)