action

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: GPL-3.0 Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Execute(ctx context.Context, execCtx *ExecutionContext) error
}

Action is the interface that all operation types implement.

func FromOperation

func FromOperation(op config.Operation) (Action, error)

FromOperation returns the appropriate Action for an Operation.

type ActionFactory

type ActionFactory func() Action

ActionFactory creates an Action from raw operation config.

type CommitPushAction

type CommitPushAction struct {
	Config config.CommitPush
}

CommitPushAction commits all changes and pushes to the remote.

func (*CommitPushAction) Execute

func (a *CommitPushAction) Execute(ctx context.Context, execCtx *ExecutionContext) error

type ExecutionContext

type ExecutionContext struct {
	// ModuleName is the metadata.name of the executing module.
	ModuleName string
	// ModuleDir is the path to the module directory containing loom.yaml.
	ModuleDir string
	// TargetDir is the path to the target repository working directory.
	TargetDir string
	// Params are the resolved template parameters.
	Params map[string]string
	// Excludes are glob patterns for files/dirs to exclude from template walking.
	Excludes []string
	// Includes are glob patterns that override excludes (including implicit ones).
	Includes []string
	// DryRun indicates whether to simulate operations.
	DryRun bool
	// LocalRun runs all operations locally but skips remote push and PR creation.
	LocalRun bool
	// ShowDiff displays file diffs during dry-run.
	ShowDiff bool
	// DiffWriter is the destination for diff output (bypasses the logger).
	// When nil, diff output is suppressed.
	DiffWriter io.Writer
	// GitAuthor is the default git author name for commitPush when not set in loom.yaml.
	GitAuthor string
	// GitEmail is the default git author email for commitPush when not set in loom.yaml.
	GitEmail string
	// Summary collects created PRs/MRs across the run. May be nil.
	Summary *RunSummary
	// Logger is the structured logger.
	Logger *slog.Logger
}

ExecutionContext holds runtime state shared across actions.

type InferFunc added in v0.2.0

type InferFunc func(ctx context.Context, opts llm.InferenceOptions) (string, error)

InferFunc is the signature for LLM inference. Defaults to llm.Infer.

type LLMAction added in v0.2.0

type LLMAction struct {
	Config config.LLM
	// Infer overrides the inference function (for testing). Nil uses llm.Infer.
	Infer InferFunc
}

LLMAction uses LLM inference to generate or modify a file.

func (*LLMAction) Execute added in v0.2.0

func (a *LLMAction) Execute(ctx context.Context, execCtx *ExecutionContext) error

type NewFilesAction

type NewFilesAction struct {
	Config config.NewFiles
}

NewFilesAction renders template files from the module directory and writes them to the target directory.

func (*NewFilesAction) Execute

func (a *NewFilesAction) Execute(ctx context.Context, execCtx *ExecutionContext) error

type PRAction

type PRAction struct {
	Config config.PR
}

PRAction opens a pull request or merge request.

func (*PRAction) Execute

func (a *PRAction) Execute(ctx context.Context, execCtx *ExecutionContext) error

type PRResult added in v0.3.0

type PRResult struct {
	// Module is the name of the module whose pr operation created it.
	Module string
	// Title is the rendered PR title.
	Title string
	// URL is the web URL of the created PR/MR.
	URL string
}

PRResult records one pull/merge request created during a run.

type PatchAction

type PatchAction struct {
	Config config.Patch
}

PatchAction applies patch operations to a target YAML file using the kustomize library. Two engines are supported:

  • "smp" (default): Strategic Merge Patch — a partial YAML document deep-merged into the target.
  • "json6902": RFC 6902 JSON Patch — an explicit list of add/remove/replace/move/copy/test operations.

func (*PatchAction) Execute

func (a *PatchAction) Execute(ctx context.Context, execCtx *ExecutionContext) error

type RunSummary added in v0.3.0

type RunSummary struct {
	PRs []PRResult
}

RunSummary collects outward-facing results across a whole run, shared by parent and child module executions. Execution is sequential, so no locking is needed.

func (*RunSummary) AddPR added in v0.3.0

func (s *RunSummary) AddPR(module, title, url string)

AddPR records a created PR/MR. Safe to call on a nil summary.

func (*RunSummary) Print added in v0.3.0

func (s *RunSummary) Print(w io.Writer)

Print writes the collected PR/MR list to w. Nothing is written when the summary is nil or empty.

type ShellAction

type ShellAction struct {
	Config config.Shell
}

ShellAction runs a shell command on the host.

func (*ShellAction) Execute

func (a *ShellAction) Execute(ctx context.Context, execCtx *ExecutionContext) error

Jump to

Keyboard shortcuts

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