bridge

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package bridge runs legacy Kite script tasks through the standalone github.com/gookit/taskrun library.

The legacy runner in pkg/kscript stays in place as the rollback point. This package only converts what the legacy configuration already loaded and runs a single task or script file with the new engine; command aliases, extensions, plugins and system command fallback remain owned by Kite.

Index

Constants

This section is empty.

Variables

View Source
var BaseVarNames = []string{
	"gvs", "paths", "kite", "time", "workdir", "dirname", "cur_dir", "@", "*",
}

BaseVarNames lists the runtime variable names Kite injects in addition to the caller supplied variables. They mirror the legacy render context.

Functions

This section is empty.

Types

type Bridge

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

Bridge converts the legacy runner configuration and runs tasks with the new engine.

func New

func New(legacy *kscript.Runner, opts ...Option) *Bridge

New creates a bridge over an initialized or not yet initialized legacy runner.

func (*Bridge) Definition

func (b *Bridge) Definition(shell string, varNames, envNames []string) (taskrun.Definition, []string, error)

Definition converts the loaded legacy configuration. The shell argument is the legacy per-run shell wrapper (RunCtx.Type); an empty value keeps the definition time conversion.

func (*Bridge) Run

func (b *Bridge) Run(ctx context.Context, name string, args []string, lctx *kscript.RunCtx) error

Run is TryRun with the legacy error message when nothing matched.

func (*Bridge) TryRun

func (b *Bridge) TryRun(ctx context.Context, name string, args []string, lctx *kscript.RunCtx) (bool, error)

TryRun runs a script task or script file by name. It reports found=false only when the name matches neither, mirroring the legacy TryRun contract so the caller can continue with system command fallback.

type Option

type Option func(*Bridge)

Option configures a Bridge.

func WithBaseDir

func WithBaseDir(dir string) Option

WithBaseDir sets the absolute directory used by the converted definition. It defaults to the current working directory, matching the legacy behavior of resolving relative paths against the process directory.

func WithEnvNames

func WithEnvNames(names ...string) Option

WithEnvNames adds environment names for ParseEnv substitution.

func WithEventObserver

func WithEventObserver(observer taskrun.Observer) Option

WithEventObserver receives execution events instead of the default debug logger. Kite binds it when it wants to render progress itself.

func WithHandler

func WithHandler(name string, handler taskrun.Handler) Option

WithHandler registers a host action for converted definitions.

func WithIO

func WithIO(io taskrun.IO) Option

WithIO sets the streams used for runs. It defaults to the process streams.

func WithLegacyFallback

func WithLegacyFallback(enabled bool) Option

WithLegacyFallback makes TryRun fall back to the legacy runner when the conversion fails, so a partially converted configuration never regresses. It logs the conversion error at warning level.

func WithParseEnv

func WithParseEnv(enabled bool) Option

WithParseEnv enables the legacy ParseEnv behavior, where a bare $NAME that matches an environment variable is replaced by its value at render time. When disabled, such references are left for the shell to expand.

func WithVarNames

func WithVarNames(names ...string) Option

WithVarNames adds runtime variable names beyond BaseVarNames, so legacy $name and ${name} references to them are rewritten.

Jump to

Keyboard shortcuts

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