Help us shape the future of Go! Take the 2026 Go Developer Survey

workflows

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package workflows provides embedded default workflows with templates and rubrics.

Workflows are loaded at init time from embedded filesystem and accessible via the registry without any filesystem I/O at runtime.

Usage:

w, err := workflows.Get("aws-two-way-door")
if err != nil {
    // handle error
}
fmt.Println(w.Workflow.Name)
fmt.Println(w.Templates["press"].Content)
fmt.Println(w.Rubrics["press"].Categories)
Example
package main

import (
	"fmt"

	"github.com/ProductBuildersHQ/specification-workflow-spec/pkg/workflows"
)

func main() {
	// Load a workflow by name - no filesystem access needed
	w, err := workflows.Get("aws-two-way-door")
	if err != nil {
		panic(err)
	}

	// Access workflow metadata
	fmt.Printf("Workflow: %s\n", w.Workflow.Name)
	fmt.Printf("Extends: %s\n", w.Workflow.Extends)
	fmt.Printf("Methodology: %s\n", w.Workflow.Methodology.Name)

	// Access template content directly
	press := w.Templates["press"]
	fmt.Printf("Press template length: %d chars\n", len(press.Content))

	// Access rubric categories
	pressRubric := w.Rubrics["press"]
	fmt.Printf("Press rubric categories: %d\n", len(pressRubric.Categories))

	// Check required specs
	required := w.Workflow.RequiredSpecs()
	fmt.Printf("Required specs count: %d\n", len(required))

}
Output:
Workflow: aws-two-way-door
Extends: enterprise
Methodology: Amazon Working Backwards (Feature)
Press template length: 6338 chars
Press rubric categories: 9
Required specs count: 2

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() map[string]*LoadedWorkflow

All returns all loaded workflows.

func List

func List() []string

List returns the names of all available workflows.

Example
package main

import (
	"fmt"

	"github.com/ProductBuildersHQ/specification-workflow-spec/pkg/workflows"
)

func main() {
	// List all available workflows
	names := workflows.List()
	fmt.Printf("Available workflows: %d\n", len(names))

}
Output:
Available workflows: 25

func Register

func Register(name string, w *LoadedWorkflow)

Register adds a workflow to the registry. This is typically called from init() in embed.go.

Types

type ChainLoader

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

ChainLoader tries multiple loaders in order.

func NewChainLoader

func NewChainLoader(loaders ...Loader) *ChainLoader

NewChainLoader creates a loader that tries multiple loaders in order. The first loader to successfully load a workflow wins.

func (*ChainLoader) Available

func (l *ChainLoader) Available() []string

func (*ChainLoader) Load

func (l *ChainLoader) Load(name string) (*LoadedWorkflow, error)

type FSLoader

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

FSLoader loads workflows from an fs.FS (for embed or testing).

func NewFSLoader

func NewFSLoader(fsys fs.FS, dir string) *FSLoader

NewFSLoader creates a loader from an fs.FS.

func (*FSLoader) Available

func (l *FSLoader) Available() []string

func (*FSLoader) Load

func (l *FSLoader) Load(name string) (*LoadedWorkflow, error)

type FileLoader

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

FileLoader loads workflows from a filesystem directory.

func NewFileLoader

func NewFileLoader(dir string) *FileLoader

NewFileLoader creates a loader that reads workflows from a directory. Each workflow is a subdirectory containing profile.yaml, templates/, and rubrics/.

func (*FileLoader) Available

func (l *FileLoader) Available() []string

func (*FileLoader) Load

func (l *FileLoader) Load(name string) (*LoadedWorkflow, error)

type LoadedWorkflow

type LoadedWorkflow struct {
	// Workflow is the parsed workflow configuration.
	Workflow *workflow.Workflow

	// Templates maps spec type ID to its template (e.g., "press" -> press template).
	Templates map[string]*template.Template

	// Rubrics maps spec type ID to its rubric definition (e.g., "press" -> press rubric).
	// Rubrics use structured-evaluation's canonical RubricSet type.
	Rubrics map[string]*rubric.RubricSet
}

LoadedWorkflow contains a fully loaded workflow with all associated templates and rubrics.

func Get

func Get(name string) (*LoadedWorkflow, error)

Get returns a loaded workflow by name. Returns an error if the workflow is not found.

func MustGet

func MustGet(name string) *LoadedWorkflow

MustGet returns a loaded workflow by name, panicking if not found.

type Loader

type Loader interface {
	// Load returns a workflow by name.
	Load(name string) (*LoadedWorkflow, error)

	// Available returns all available workflow names.
	Available() []string
}

Loader loads workflows by name.

func DefaultLoader

func DefaultLoader() Loader

DefaultLoader returns the default loader using embedded workflows.

type NotFoundError

type NotFoundError struct {
	Name string
}

NotFoundError is returned when a workflow is not found.

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type ResolvingLoader

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

ResolvingLoader resolves workflow inheritance (extends).

func NewResolvingLoader

func NewResolvingLoader(base Loader) *ResolvingLoader

NewResolvingLoader creates a loader that resolves workflow inheritance.

func (*ResolvingLoader) Available

func (l *ResolvingLoader) Available() []string

func (*ResolvingLoader) Load

func (l *ResolvingLoader) Load(name string) (*LoadedWorkflow, error)

Jump to

Keyboard shortcuts

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