discovery

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetActiveChangeIDs

func GetActiveChangeIDs(
	projectRoot string,
) ([]string, error)

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

func GetActiveChanges(
	projectPath string,
) ([]string, error)

GetActiveChanges finds all active changes in spectr/changes/, excluding archive directory

func GetSpecIDs

func GetSpecIDs(
	projectRoot string,
) ([]string, error)

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 GetSpecs

func GetSpecs(
	projectPath string,
) ([]string, error)

GetSpecs finds all specs in spectr/specs/ that contain spec.md

func NormalizeItemPath added in v0.0.8

func NormalizeItemPath(
	input string,
) (id, inferredType string)

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

type ResolveResult struct {
	ChangeID     string
	PartialMatch bool
}

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:

  1. Exact match: returns immediately if partialID exactly matches a change ID
  2. Prefix match: finds all change IDs that start with partialID (case-insensitive)
  3. 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)

Jump to

Keyboard shortcuts

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