workflow

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultClaudeActionVersion is the default version of the Claude Code base action
	DefaultClaudeActionVersion = "v0.0.56"
)

Variables

This section is empty.

Functions

func ConvertToFloat added in v0.0.22

func ConvertToFloat(val interface{}) float64

ConvertToFloat safely converts interface{} to float64

func ConvertToInt added in v0.0.22

func ConvertToInt(val interface{}) int

ConvertToInt safely converts interface{} to int

func ExtractFirstMatch added in v0.0.22

func ExtractFirstMatch(text, pattern string) string

ExtractFirstMatch extracts the first regex match from a string

func ExtractJSONCost added in v0.0.22

func ExtractJSONCost(data map[string]interface{}) float64

ExtractJSONCost extracts cost information from JSON data

func ExtractJSONTokenUsage added in v0.0.22

func ExtractJSONTokenUsage(data map[string]interface{}) int

ExtractJSONTokenUsage extracts token usage from JSON data

func GenerateConcurrencyConfig

func GenerateConcurrencyConfig(workflowData *WorkflowData, isAliasTrigger bool) string

GenerateConcurrencyConfig generates the concurrency configuration for a workflow based on its trigger types and characteristics.

func ResolveWorkflowName

func ResolveWorkflowName(workflowInput string) (string, error)

ResolveWorkflowName converts an agentic workflow ID to the GitHub Actions workflow name. It normalizes the input by removing .md and .lock.yml extensions, then finds the corresponding workflow files and extracts the actual workflow name from the lock.yml file.

The agentic workflow ID is the basename of the markdown file without the .md extension. The GitHub Actions workflow name is extracted from the "name:" field in the corresponding .lock.yml file.

Examples:

  • "weekly-research" -> "Weekly Research" (from weekly-research.lock.yml name field)
  • "weekly-research.md" -> "Weekly Research" (from weekly-research.lock.yml name field)
  • "weekly-research.lock.yml" -> "Weekly Research" (from weekly-research.lock.yml name field)

func ValidateMCPConfigs

func ValidateMCPConfigs(tools map[string]any) error

validateMCPConfigs validates all MCP configurations in the tools section using JSON schema

Types

type AgenticEngine

type AgenticEngine interface {
	// GetID returns the unique identifier for this engine
	GetID() string

	// GetDisplayName returns the human-readable name for this engine
	GetDisplayName() string

	// GetDescription returns a description of this engine's capabilities
	GetDescription() string

	// IsExperimental returns true if this engine is experimental
	IsExperimental() bool

	// SupportsToolsWhitelist returns true if this engine supports MCP tool allow-listing
	SupportsToolsWhitelist() bool

	// SupportsHTTPTransport returns true if this engine supports HTTP transport for MCP servers
	SupportsHTTPTransport() bool

	// GetInstallationSteps returns the GitHub Actions steps needed to install this engine
	GetInstallationSteps(engineConfig *EngineConfig) []GitHubActionStep

	// GetExecutionConfig returns the configuration for executing this engine
	GetExecutionConfig(workflowName string, logFile string, engineConfig *EngineConfig) ExecutionConfig

	// RenderMCPConfig renders the MCP configuration for this engine to the given YAML builder
	RenderMCPConfig(yaml *strings.Builder, tools map[string]any, mcpTools []string)

	// ParseLogMetrics extracts metrics from engine-specific log content
	ParseLogMetrics(logContent string, verbose bool) LogMetrics
}

AgenticEngine represents an AI engine that can be used to execute agentic workflows

type AndNode

type AndNode struct {
	Left, Right ConditionNode
}

AndNode represents an AND operation between two conditions

func (*AndNode) Render

func (a *AndNode) Render() string

type BaseEngine

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

BaseEngine provides common functionality for agentic engines

func (*BaseEngine) GetDescription

func (e *BaseEngine) GetDescription() string

func (*BaseEngine) GetDisplayName

func (e *BaseEngine) GetDisplayName() string

func (*BaseEngine) GetID

func (e *BaseEngine) GetID() string

func (*BaseEngine) IsExperimental

func (e *BaseEngine) IsExperimental() bool

func (*BaseEngine) SupportsHTTPTransport

func (e *BaseEngine) SupportsHTTPTransport() bool

func (*BaseEngine) SupportsToolsWhitelist

func (e *BaseEngine) SupportsToolsWhitelist() bool

type BooleanLiteralNode

type BooleanLiteralNode struct {
	Value bool
}

BooleanLiteralNode represents a boolean literal value

func BuildBooleanLiteral

func BuildBooleanLiteral(value bool) *BooleanLiteralNode

BuildBooleanLiteral creates a boolean literal node

func (*BooleanLiteralNode) Render

func (b *BooleanLiteralNode) Render() string

type ClaudeEngine

type ClaudeEngine struct {
	BaseEngine
}

ClaudeEngine represents the Claude Code agentic engine

func NewClaudeEngine

func NewClaudeEngine() *ClaudeEngine

func (*ClaudeEngine) GetExecutionConfig

func (e *ClaudeEngine) GetExecutionConfig(workflowName string, logFile string, engineConfig *EngineConfig) ExecutionConfig

func (*ClaudeEngine) GetInstallationSteps

func (e *ClaudeEngine) GetInstallationSteps(engineConfig *EngineConfig) []GitHubActionStep

func (*ClaudeEngine) ParseLogMetrics added in v0.0.22

func (e *ClaudeEngine) ParseLogMetrics(logContent string, verbose bool) LogMetrics

ParseLogMetrics implements engine-specific log parsing for Claude

func (*ClaudeEngine) RenderMCPConfig

func (e *ClaudeEngine) RenderMCPConfig(yaml *strings.Builder, tools map[string]any, mcpTools []string)

type CodexEngine

type CodexEngine struct {
	BaseEngine
}

CodexEngine represents the Codex agentic engine (experimental)

func NewCodexEngine

func NewCodexEngine() *CodexEngine

func (*CodexEngine) GetExecutionConfig

func (e *CodexEngine) GetExecutionConfig(workflowName string, logFile string, engineConfig *EngineConfig) ExecutionConfig

func (*CodexEngine) GetInstallationSteps

func (e *CodexEngine) GetInstallationSteps(engineConfig *EngineConfig) []GitHubActionStep

func (*CodexEngine) ParseLogMetrics added in v0.0.22

func (e *CodexEngine) ParseLogMetrics(logContent string, verbose bool) LogMetrics

ParseLogMetrics implements engine-specific log parsing for Codex

func (*CodexEngine) RenderMCPConfig

func (e *CodexEngine) RenderMCPConfig(yaml *strings.Builder, tools map[string]any, mcpTools []string)

type ComparisonNode

type ComparisonNode struct {
	Left     ConditionNode
	Operator string
	Right    ConditionNode
}

ComparisonNode represents comparison operations like ==, !=, <, >, <=, >=

func BuildActionEquals

func BuildActionEquals(action string) *ComparisonNode

BuildActionEquals creates a condition to check if the event action equals a specific value

func BuildComparison

func BuildComparison(left ConditionNode, operator string, right ConditionNode) *ComparisonNode

BuildComparison creates a comparison node with the specified operator

func BuildEquals

func BuildEquals(left ConditionNode, right ConditionNode) *ComparisonNode

BuildEquals creates an equality comparison

func BuildEventTypeEquals

func BuildEventTypeEquals(eventType string) *ComparisonNode

BuildEventTypeEquals creates a condition to check if the event type equals a specific value

func BuildNotEquals

func BuildNotEquals(left ConditionNode, right ConditionNode) *ComparisonNode

BuildNotEquals creates an inequality comparison

func (*ComparisonNode) Render

func (c *ComparisonNode) Render() string

type Compiler

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

Compiler handles converting markdown workflows to GitHub Actions YAML

func NewCompiler

func NewCompiler(verbose bool, engineOverride string, version string) *Compiler

NewCompiler creates a new workflow compiler with optional configuration

func NewCompilerWithCustomOutput

func NewCompilerWithCustomOutput(verbose bool, engineOverride string, customOutput string, version string) *Compiler

NewCompilerWithCustomOutput creates a new workflow compiler with custom output path

func (*Compiler) CompileWorkflow

func (c *Compiler) CompileWorkflow(markdownPath string) error

CompileWorkflow converts a markdown workflow to GitHub Actions YAML

func (*Compiler) SetFileTracker added in v0.0.22

func (c *Compiler) SetFileTracker(tracker FileTracker)

SetFileTracker sets the file tracker for tracking created files

func (*Compiler) SetSkipValidation

func (c *Compiler) SetSkipValidation(skip bool)

SetSkipValidation configures whether to skip schema validation

type ConditionNode

type ConditionNode interface {
	Render() string
}

ConditionNode represents a node in a condition expression tree

type ContainsNode

type ContainsNode struct {
	Array ConditionNode
	Value ConditionNode
}

ContainsNode represents array membership checks using contains() function

func BuildContains

func BuildContains(array ConditionNode, value ConditionNode) *ContainsNode

BuildContains creates a contains() function call node

func BuildLabelContains

func BuildLabelContains(labelName string) *ContainsNode

BuildLabelContains creates a condition to check if an issue/PR contains a specific label

func (*ContainsNode) Render

func (c *ContainsNode) Render() string

type DisjunctionNode

type DisjunctionNode struct {
	Terms     []ConditionNode
	Multiline bool // If true, render each term on separate line with comments
}

DisjunctionNode represents an OR operation with multiple terms to avoid deep nesting

func BuildMultilineDisjunction

func BuildMultilineDisjunction(terms ...ConditionNode) *DisjunctionNode

BuildMultilineDisjunction creates a disjunction node with multiline rendering enabled

func (*DisjunctionNode) Render

func (d *DisjunctionNode) Render() string

func (*DisjunctionNode) RenderMultiline

func (d *DisjunctionNode) RenderMultiline() string

RenderMultiline renders the disjunction with each term on a separate line, including comments for expressions that have descriptions

type EngineConfig

type EngineConfig struct {
	ID      string
	Version string
	Model   string
}

EngineConfig represents the parsed engine configuration

type EngineRegistry

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

EngineRegistry manages available agentic engines

func GetGlobalEngineRegistry added in v0.0.22

func GetGlobalEngineRegistry() *EngineRegistry

GetGlobalEngineRegistry returns the singleton engine registry

func NewEngineRegistry

func NewEngineRegistry() *EngineRegistry

NewEngineRegistry creates a new engine registry with built-in engines

func (*EngineRegistry) GetAllEngines added in v0.0.22

func (r *EngineRegistry) GetAllEngines() []AgenticEngine

GetAllEngines returns all registered engines

func (*EngineRegistry) GetDefaultEngine

func (r *EngineRegistry) GetDefaultEngine() AgenticEngine

GetDefaultEngine returns the default engine (Claude)

func (*EngineRegistry) GetEngine

func (r *EngineRegistry) GetEngine(id string) (AgenticEngine, error)

GetEngine retrieves an engine by ID

func (*EngineRegistry) GetEngineByPrefix

func (r *EngineRegistry) GetEngineByPrefix(prefix string) (AgenticEngine, error)

GetEngineByPrefix returns an engine that matches the given prefix This is useful for backward compatibility with strings like "codex-experimental"

func (*EngineRegistry) GetSupportedEngines

func (r *EngineRegistry) GetSupportedEngines() []string

GetSupportedEngines returns a list of all supported engine IDs

func (*EngineRegistry) IsValidEngine

func (r *EngineRegistry) IsValidEngine(id string) bool

IsValidEngine checks if an engine ID is valid

func (*EngineRegistry) Register

func (r *EngineRegistry) Register(engine AgenticEngine)

Register adds an engine to the registry

type ExecutionConfig

type ExecutionConfig struct {
	// StepName is the name of the GitHub Actions step
	StepName string

	// Command is the shell command to execute (for CLI-based engines)
	Command string

	// Action is the GitHub Action to use (for action-based engines)
	Action string

	// Inputs are the inputs to pass to the action
	Inputs map[string]string

	// Environment variables needed for execution
	Environment map[string]string
}

ExecutionConfig contains the configuration for executing an agentic engine

type ExpressionNode

type ExpressionNode struct {
	Expression  string
	Description string // Optional comment/description for the expression
}

ExpressionNode represents a leaf expression

func BuildExpressionWithDescription

func BuildExpressionWithDescription(expression, description string) *ExpressionNode

BuildExpressionWithDescription creates an expression node with an optional description

func (*ExpressionNode) Render

func (e *ExpressionNode) Render() string

type FileTracker added in v0.0.22

type FileTracker interface {
	TrackCreated(filePath string)
}

FileTracker interface for tracking files created during compilation

type FunctionCallNode

type FunctionCallNode struct {
	FunctionName string
	Arguments    []ConditionNode
}

FunctionCallNode represents a function call expression like contains(array, value)

func BuildFunctionCall

func BuildFunctionCall(functionName string, args ...ConditionNode) *FunctionCallNode

BuildFunctionCall creates a function call node

func BuildRefStartsWith

func BuildRefStartsWith(prefix string) *FunctionCallNode

BuildRefStartsWith creates a condition to check if github.ref starts with a prefix

func (*FunctionCallNode) Render

func (f *FunctionCallNode) Render() string

type GitHubActionStep

type GitHubActionStep []string

GitHubActionStep represents the YAML lines for a single step in a GitHub Actions workflow

type Job

type Job struct {
	Name        string
	RunsOn      string
	If          string
	Permissions string
	Steps       []string
	Depends     []string // Job dependencies (needs clause)
	Outputs     map[string]string
}

Job represents a GitHub Actions job with all its properties

type JobManager

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

JobManager manages a collection of jobs and handles dependency validation

func NewJobManager

func NewJobManager() *JobManager

NewJobManager creates a new JobManager instance

func (*JobManager) AddJob

func (jm *JobManager) AddJob(job *Job) error

AddJob adds a job to the manager

func (*JobManager) GetAllJobs

func (jm *JobManager) GetAllJobs() map[string]*Job

GetAllJobs returns all jobs in the manager

func (*JobManager) GetJob

func (jm *JobManager) GetJob(name string) (*Job, bool)

GetJob retrieves a job by name

func (*JobManager) GetTopologicalOrder

func (jm *JobManager) GetTopologicalOrder() ([]string, error)

GetTopologicalOrder returns jobs in topological order (dependencies before dependents)

func (*JobManager) RenderToYAML

func (jm *JobManager) RenderToYAML() string

RenderToYAML generates the jobs section of a GitHub Actions workflow

func (*JobManager) ValidateDependencies

func (jm *JobManager) ValidateDependencies() error

ValidateDependencies checks that all job dependencies exist and there are no cycles

type LogMetrics added in v0.0.22

type LogMetrics struct {
	TokenUsage    int
	EstimatedCost float64
	ErrorCount    int
	WarningCount  int
}

LogMetrics represents extracted metrics from log files

func ExtractJSONMetrics added in v0.0.22

func ExtractJSONMetrics(line string, verbose bool) LogMetrics

ExtractJSONMetrics extracts metrics from streaming JSON log lines

type MCPConfigRenderer

type MCPConfigRenderer struct {
	// IndentLevel controls the indentation level for properties (e.g., "                " for JSON, "          " for TOML)
	IndentLevel string
	// Format specifies the output format ("json" for JSON-like, "toml" for TOML-like)
	Format string
}

MCPConfigRenderer contains configuration options for rendering MCP config

type NotNode

type NotNode struct {
	Child ConditionNode
}

NotNode represents a NOT operation on a condition

func (*NotNode) Render

func (n *NotNode) Render() string

type NumberLiteralNode

type NumberLiteralNode struct {
	Value string
}

NumberLiteralNode represents a numeric literal value

func BuildNumberLiteral

func BuildNumberLiteral(value string) *NumberLiteralNode

BuildNumberLiteral creates a number literal node

func (*NumberLiteralNode) Render

func (n *NumberLiteralNode) Render() string

type OrNode

type OrNode struct {
	Left, Right ConditionNode
}

OrNode represents an OR operation between two conditions

func (*OrNode) Render

func (o *OrNode) Render() string

type PropertyAccessNode

type PropertyAccessNode struct {
	PropertyPath string
}

PropertyAccessNode represents property access like github.event.action

func BuildPropertyAccess

func BuildPropertyAccess(path string) *PropertyAccessNode

BuildPropertyAccess creates a property access node for GitHub context properties

func (*PropertyAccessNode) Render

func (p *PropertyAccessNode) Render() string

type StringLiteralNode

type StringLiteralNode struct {
	Value string
}

StringLiteralNode represents a string literal value

func BuildStringLiteral

func BuildStringLiteral(value string) *StringLiteralNode

BuildStringLiteral creates a string literal node

func (*StringLiteralNode) Render

func (s *StringLiteralNode) Render() string

type TernaryNode

type TernaryNode struct {
	Condition  ConditionNode
	TrueValue  ConditionNode
	FalseValue ConditionNode
}

TernaryNode represents ternary conditional expressions like condition ? true_value : false_value

func BuildTernary

func BuildTernary(condition ConditionNode, trueValue ConditionNode, falseValue ConditionNode) *TernaryNode

BuildTernary creates a ternary conditional expression

func (*TernaryNode) Render

func (t *TernaryNode) Render() string

type WorkflowData

type WorkflowData struct {
	Name             string
	On               string
	Permissions      string
	Concurrency      string
	RunName          string
	Env              string
	If               string
	TimeoutMinutes   string
	CustomSteps      string
	PostSteps        string // steps to run after AI execution
	RunsOn           string
	Tools            map[string]any
	MarkdownContent  string
	AllowedTools     string
	AI               string        // "claude" or "codex" (for backwards compatibility)
	EngineConfig     *EngineConfig // Extended engine configuration
	MaxRuns          string
	StopTime         string
	Alias            string         // for @alias trigger support
	AliasOtherEvents map[string]any // for merging alias with other events
	AIReaction       string         // AI reaction type like "eyes", "heart", etc.
	Jobs             map[string]any // custom job configurations with dependencies
	Cache            string         // cache configuration
	NeedsTextOutput  bool           // whether the workflow uses ${{ needs.task.outputs.text }}
}

WorkflowData holds all the data needed to generate a GitHub Actions workflow

Jump to

Keyboard shortcuts

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