spec

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package spec handles specification file loading, status management, and listing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeSpecFilename added in v0.26.0

func NormalizeSpecFilename(ctx context.Context, name string, dirs ...string) (string, error)

NormalizeSpecFilename assigns a sequential numeric prefix to name if it does not already have one. Scans all given dirs for .md files, finds the highest existing numeric prefix across all dirs, and returns fmt.Sprintf("%03d-%s", highest+1, name) for unnumbered names. If name already has a valid numeric prefix, it is returned unchanged.

Types

type AutoCompleter

type AutoCompleter interface {
	CheckAndComplete(ctx context.Context, specID string) error
}

AutoCompleter checks if all linked prompts are completed and marks the spec as completed.

func NewAutoCompleter

func NewAutoCompleter(
	queueDir, completedDir, specsInboxDir, specsInProgressDir, specsCompletedDir string,
) AutoCompleter

NewAutoCompleter creates a new AutoCompleter.

type Frontmatter

type Frontmatter struct {
	Status    string   `yaml:"status"`
	Tags      []string `yaml:"tags,omitempty"`
	Approved  string   `yaml:"approved,omitempty"`
	Prompted  string   `yaml:"prompted,omitempty"`
	Verifying string   `yaml:"verifying,omitempty"`
	Completed string   `yaml:"completed,omitempty"`
}

Frontmatter represents the YAML frontmatter in a spec file.

type Lister

type Lister interface {
	List(ctx context.Context) ([]*SpecFile, error)
	Summary(ctx context.Context) (*Summary, error)
}

Lister lists spec files from a directory.

func NewLister

func NewLister(dirs ...string) Lister

NewLister creates a new Lister that scans the given directories.

type SpecFile

type SpecFile struct {
	Path        string
	Frontmatter Frontmatter
	Name        string // filename without extension
	Body        []byte
	// contains filtered or unexported fields
}

SpecFile represents a loaded spec file with frontmatter and body.

func Load

func Load(ctx context.Context, path string) (*SpecFile, error)

Load reads a spec file from disk, parsing frontmatter and body.

func (*SpecFile) MarkCompleted

func (s *SpecFile) MarkCompleted()

MarkCompleted sets the spec status to completed.

func (*SpecFile) MarkVerifying added in v0.18.5

func (s *SpecFile) MarkVerifying()

MarkVerifying sets the spec status to verifying.

func (*SpecFile) Save

func (s *SpecFile) Save(ctx context.Context) error

Save writes the spec file back to disk.

func (*SpecFile) SetNowFunc added in v0.20.0

func (s *SpecFile) SetNowFunc(f func() time.Time)

SetNowFunc sets the time source for testability.

func (*SpecFile) SetStatus

func (s *SpecFile) SetStatus(status string)

SetStatus sets the status field in the frontmatter and stamps the matching timestamp once.

func (*SpecFile) SpecNumber added in v0.23.1

func (s *SpecFile) SpecNumber() int

SpecNumber returns the numeric prefix of the spec file name. Returns -1 if the name has no numeric prefix.

type Status

type Status string

Status represents the lifecycle state of a spec.

const (
	// StatusDraft indicates the spec has been written but not yet reviewed.
	StatusDraft Status = "draft"
	// StatusApproved indicates the spec has been reviewed and approved.
	StatusApproved Status = "approved"
	// StatusPrompted indicates prompts have been generated from the spec.
	StatusPrompted Status = "prompted"
	// StatusVerifying indicates all prompts completed, awaiting human verification.
	StatusVerifying Status = "verifying"
	// StatusCompleted indicates human verified all acceptance criteria.
	StatusCompleted Status = "completed"
)

type Summary

type Summary struct {
	Draft                  int
	Approved               int
	Prompted               int
	Verifying              int
	Completed              int
	Total                  int
	LinkedPromptsCompleted int `json:"linked_prompts_completed,omitempty"`
	LinkedPromptsTotal     int `json:"linked_prompts_total,omitempty"`
}

Summary holds counts of specs grouped by status.

Jump to

Keyboard shortcuts

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