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

workflows

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 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/visionspec/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 added in v0.16.0

func All() map[string]*LoadedWorkflow

All returns all loaded workflows.

func List added in v0.16.0

func List() []string

List returns the names of all available workflows.

Example
package main

import (
	"fmt"

	"github.com/ProductBuildersHQ/visionspec/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 added in v0.16.0

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 added in v0.16.0

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

ChainLoader tries multiple loaders in order.

func NewChainLoader added in v0.16.0

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 added in v0.16.0

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

func (*ChainLoader) Load added in v0.16.0

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

type FSLoader added in v0.16.0

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

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

func NewFSLoader added in v0.16.0

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

NewFSLoader creates a loader from an fs.FS.

func (*FSLoader) Available added in v0.16.0

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

func (*FSLoader) Load added in v0.16.0

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

type FileLoader added in v0.16.0

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

FileLoader loads workflows from a filesystem directory.

func NewFileLoader added in v0.16.0

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 added in v0.16.0

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

func (*FileLoader) Load added in v0.16.0

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

type LoadedWorkflow added in v0.16.0

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 added in v0.16.0

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

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

func MustGet added in v0.16.0

func MustGet(name string) *LoadedWorkflow

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

type Loader added in v0.16.0

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 added in v0.16.0

func DefaultLoader() Loader

DefaultLoader returns the default loader using embedded workflows.

type NotFoundError added in v0.16.0

type NotFoundError struct {
	Name string
}

NotFoundError is returned when a workflow is not found.

func (*NotFoundError) Error added in v0.16.0

func (e *NotFoundError) Error() string

type ResolvingLoader added in v0.16.0

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

ResolvingLoader resolves workflow inheritance (extends).

func NewResolvingLoader added in v0.16.0

func NewResolvingLoader(base Loader) *ResolvingLoader

NewResolvingLoader creates a loader that resolves workflow inheritance.

func (*ResolvingLoader) Available added in v0.16.0

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

func (*ResolvingLoader) Load added in v0.16.0

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