spec

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveSpec

func ArchiveSpec(ctx context.Context, basePath, slug string) error

ArchiveSpec moves a specification from the specs directory to the archive directory.

func CheckTriadArtifacts

func CheckTriadArtifacts(projectRoot, slug string) (bool, []string)

CheckTriadArtifacts verifies if requirements.md, design.md, and tasks.md exist.

func FindProjectRoot

func FindProjectRoot() (string, error)

FindProjectRoot looks for the .specforce directory in the current or parent directories.

func GetContextFiles

func GetContextFiles(projectRoot, slug string) ([]string, error)

GetContextFiles returns absolute paths for all files in the spec directory and global docs.

func SpecExists

func SpecExists(projectRoot string, slug string) (bool, string)

SpecExists checks if a spec slug already exists in either specs or archive.

Types

type Artifact

type Artifact struct {
	Name        string `json:"name" yaml:"-"`
	Description string `json:"description" yaml:"description"`
	Instruction string `json:"instruction" yaml:"instruction"`
	Template    string `json:"template" yaml:"template"`
	Dependency  string `json:"dependency" yaml:"dependency"`
}

Artifact represents a specification document type.

type ArtifactStatus

type ArtifactStatus struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Path        string `json:"path"`
	Exists      bool   `json:"exists"`
	Blocked     bool   `json:"blocked"`
	Dependency  string `json:"dependency"`
}

ArtifactStatus represents the presence and description of a single spec document.

type ConfigProvider

type ConfigProvider interface {
	GetConfig(ctx context.Context) (*core.ProjectConfig, error)
}

ConfigProvider defines the contract for project configuration access.

type ImplementationReport

type ImplementationReport struct {
	Name                  string   `json:"name"`
	Status                string   `json:"status"` // ready | blocked
	MissingArtifacts      []string `json:"missing_artifacts,omitempty"`
	ContextFiles          []string `json:"context_files"`
	Instructions          []string `json:"instructions,omitempty"`
	Phases                []Phase  `json:"phases"`
	ExecutionStrategy     string   `json:"execution_strategy"`
	PreemptiveMitigations string   `json:"preemptive_mitigations"`
}

func ParseTasks

func ParseTasks(ctx context.Context, projectRoot, slug string) (*ImplementationReport, error)

ParseTasks extracts implementation details from tasks.md.

func (*ImplementationReport) Tasks

Tasks returns a flat list of tasks across all phases for backward compatibility.

type ImplementationTask

type ImplementationTask struct {
	ID           string   `json:"id"`
	Title        string   `json:"title"`
	State        string   `json:"state"`
	Target       string   `json:"target"`
	Context      string   `json:"context"`
	ActionSteps  []string `json:"action_steps"`
	Verification string   `json:"verification"`
}

type Phase

type Phase struct {
	ID    string               `json:"id"`
	Title string               `json:"title"`
	Tasks []ImplementationTask `json:"tasks"`
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages the collection of spec artifacts.

func NewRegistry

func NewRegistry(artifactsFS fs.FS) (*Registry, error)

NewRegistry initializes a new registry by loading YAML files from the provided filesystem.

func (*Registry) Get

func (r *Registry) Get(name string) (Artifact, bool)

Get returns an artifact by its name.

func (*Registry) List

func (r *Registry) List() []Artifact

List returns all loaded artifacts.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service orchestrates specification management logic.

func NewService

func NewService(registry *Registry, configProvider ConfigProvider) *Service

NewService creates a new instance of the spec service.

func (*Service) GetArtifact

func (s *Service) GetArtifact(ctx context.Context, name string) (*Artifact, error)

GetArtifact retrieves a specific artifact by name, injecting custom project instructions if present.

func (*Service) GetImplementationStatus

func (s *Service) GetImplementationStatus(ctx context.Context, projectRoot, slug string) (*ImplementationReport, error)

GetImplementationStatus retrieves the status and details for implementing a specific feature.

func (*Service) GetStatus

func (s *Service) GetStatus(ctx context.Context, projectRoot string, slug string) (SpecStatus, error)

GetStatus retrieves the status of a specific feature spec.

func (*Service) UpdateTaskStatus

func (s *Service) UpdateTaskStatus(ctx context.Context, projectRoot, slug, taskID, status string) error

UpdateTaskStatus handles task status updates with event hooks.

type SpecInfo

type SpecInfo struct {
	Slug string `json:"slug"`
}

SpecInfo contains basic information about a specification.

func ListActiveSpecs

func ListActiveSpecs(ctx context.Context, projectRoot string) ([]SpecInfo, error)

ListActiveSpecs returns a list of all non-archived specs.

type SpecStatus

type SpecStatus struct {
	Slug      string           `json:"slug"`
	Artifacts []ArtifactStatus `json:"artifacts"`
	Progress  int              `json:"progress"`
	Total     int              `json:"total"`
	Found     int              `json:"found"`
}

SpecStatus represents the overall completion state of a specific feature spec.

func GetStatus

func GetStatus(ctx context.Context, projectRoot string, slug string, registry *Registry) (SpecStatus, error)

GetStatus checks the filesystem for the required artifacts from the registry and returns a progress summary.

type StateCategory

type StateCategory string

StateCategory defines the top-level grouping for project state items.

const (
	CategoryConstitution    StateCategory = "Constitution"
	CategoryActiveSpecs     StateCategory = "Active Specs"
	CategoryImplementations StateCategory = "Active Implementations"
	CategoryArchived        StateCategory = "Archived"
)

type StateItem

type StateItem struct {
	Slug           string        `json:"slug"`
	Name           string        `json:"name"`
	Path           string        `json:"path"`
	Category       StateCategory `json:"category"`
	Status         string        `json:"status"` // PENDING | IN-PROGRESS | FINISHED
	Progress       int           `json:"progress"`
	Description    string        `json:"description"`
	ArtifactCount  int           `json:"artifact_count"`
	ArtifactTotal  int           `json:"artifact_total"`
	TaskCount      int           `json:"task_count"`
	TaskTotal      int           `json:"task_total"`
	AnyTaskWorking bool          `json:"any_task_working"`
	CurrentTaskID  string        `json:"current_task_id"`
	CurrentTask    string        `json:"current_task"`
	ArchivedDate   string        `json:"archived_date"`
	Worktree       string        `json:"worktree"`
}

StateItem represents a single navigatable entry in the Specforce Console.

type StateTree

type StateTree struct {
	Categories map[StateCategory][]StateItem `json:"categories"`
}

StateTree represents the full hierarchical state of a Specforce project.

func NewStateTree

func NewStateTree() *StateTree

NewStateTree initializes a new, empty state tree.

func ScanProject

func ScanProject(ctx context.Context, projectRoot string, registry *Registry) (*StateTree, error)

ScanProject synchronously parses the .specforce directory to populate a StateTree.

Jump to

Keyboard shortcuts

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