shortcuts

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package shortcuts provides AI-powered git workflow shortcut definitions and an execution engine. Shortcuts are concise aliases for multi-step git operations that execute through the AI git client middleware.

Index

Constants

View Source
const (
	OnFailStop     = "stop"
	OnFailContinue = "continue"
	OnFailAsk      = "ask"
)

OnFail policy constants.

View Source
const (
	OpStage        = "stage"
	OpUnstage      = "unstage"
	OpCommit       = "commit"
	OpPush         = "push"
	OpPull         = "pull"
	OpFetch        = "fetch"
	OpRebase       = "rebase"
	OpMerge        = "merge"
	OpCheckout     = "checkout"
	OpBranch       = "branch"
	OpReset        = "reset"
	OpDelete       = "delete_branch"
	OpStash        = "stash"
	OpStashPop     = "stash_pop"
	OpBranchRename = "branch_rename"
)

Operation name constants used in Step.Op.

Variables

View Source
var (
	ErrUnknownShortcut      = errors.New("unknown shortcut")
	ErrUnknownOperation     = errors.New("unknown operation")
	ErrUnsupportedResetMode = errors.New("unsupported reset mode")
)

Sentinel errors for testable error checking via errors.Is().

Functions

This section is empty.

Types

type Arg

type Arg struct {
	Name     string
	Default  string
	Prompt   string
	Required bool
}

Arg defines a user-supplied argument for a shortcut.

type Engine

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

Engine resolves and executes shortcut workflows.

func NewEngine

func NewEngine(gc git.GitClient) *Engine

NewEngine creates a new shortcut engine backed by the given git client.

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, name string, args map[string]string) (*ExecutionResult, error)

Execute runs the shortcut with the given arguments. Steps are executed sequentially through the git client.

func (*Engine) List

func (e *Engine) List() []Shortcut

List returns all available shortcuts (custom overrides merged with built-ins).

func (*Engine) Plan

func (e *Engine) Plan(name string, args map[string]string) ([]Step, error)

Plan returns the execution steps for a shortcut after resolving argument placeholders. This is useful for --dry-run previews.

func (*Engine) RegisterCustom

func (e *Engine) RegisterCustom(s Shortcut)

RegisterCustom adds a custom shortcut, overriding any built-in with the same name.

func (*Engine) Resolve

func (e *Engine) Resolve(name string) (Shortcut, bool)

Resolve looks up a shortcut by name. Custom shortcuts take precedence over built-ins.

type ExecutionResult

type ExecutionResult struct {
	Err         error
	StepResults []StepResult
	Shortcut    Shortcut
}

ExecutionResult captures the outcome of a full shortcut execution.

type Shortcut

type Shortcut struct {
	Name        string
	Description string
	Steps       []Step
	Args        []Arg
	Builtin     bool
	Confirm     bool // default true
}

Shortcut defines a named multi-step git workflow.

func Builtins

func Builtins() []Shortcut

Builtins returns all built-in shortcut definitions.

type Step

type Step struct {
	Op       string            // git operation name (e.g. "stage", "commit", "push")
	Params   map[string]string // operation parameters
	OnFail   string            // "stop" | "continue" | "ask" (default "stop")
	AIAssist bool              // use AI assistance for this step (default true)
}

Step represents a single operation within a shortcut workflow.

type StepResult

type StepResult struct {
	Err     error
	Output  string
	Step    Step
	Skipped bool
}

StepResult captures the outcome of executing a single step.

Jump to

Keyboard shortcuts

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