questgiver

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Monitor

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

Monitor polls anvils for quests and executes them, creating beads on failure with deduplication.

func New

func New(db *state.DB, interval, timeout time.Duration, anvils map[string]string, newExec func() QuestExecutor) *Monitor

New creates a Monitor that polls anvils for quests at the given interval. The newExec function is called to create a QuestExecutor for each quest execution. Passing nil for newExec is permitted for testing but produces a warning — the resulting monitor will pass every quest without executing it.

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context) error

Run starts the quest polling loop. It blocks until ctx is cancelled. Returns an error if the configured interval is non-positive.

func (*Monitor) UpdateAnvilPaths

func (m *Monitor) UpdateAnvilPaths(paths map[string]string)

UpdateAnvilPaths replaces the set of anvils the monitor polls. Safe to call concurrently with Run.

type Quest

type Quest struct {
	Name        string   `yaml:"name"`
	Description string   `yaml:"description"`
	URL         string   `yaml:"url"`
	Tags        []string `yaml:"tags"`
	Steps       []Step   `yaml:"steps"`
	FilePath    string   `yaml:"-"` // populated at discovery time
}

Quest represents an E2E test scenario defined in YAML.

func DiscoverQuests

func DiscoverQuests(anvilPath string) ([]Quest, error)

DiscoverQuests finds all quest YAML files under <anvilPath>/.forge/quests/ and returns the parsed quests. Returns an empty slice if the directory does not exist.

func ParseQuest

func ParseQuest(path string) (*Quest, error)

ParseQuest reads a YAML file at path and returns the parsed Quest.

type QuestExecutor

type QuestExecutor interface {
	Execute(ctx context.Context, quest *Quest) *QuestResult
}

QuestExecutor executes a quest and returns the result. This interface decouples the monitor from the adventurer package to avoid an import cycle (adventurer imports questgiver for the Quest type).

type QuestResult

type QuestResult struct {
	Passed       bool
	FailedStep   int
	ErrorMessage string
	Duration     time.Duration
}

QuestResult holds the outcome of executing a quest, decoupled from the adventurer package to avoid an import cycle.

type Step

type Step struct {
	Action   string        `yaml:"action"` // navigate, fill, click, wait, assert, screenshot
	URL      string        `yaml:"url,omitempty"`
	Selector string        `yaml:"selector,omitempty"`
	Value    string        `yaml:"value,omitempty"`
	Contains string        `yaml:"contains,omitempty"`
	Timeout  time.Duration `yaml:"timeout,omitempty"`
}

Step represents a single action in a quest sequence.

Jump to

Keyboard shortcuts

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