actions

package
v0.10.8 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClipboardMethodAuto   = "auto"
	ClipboardMethodSystem = "system"
	ClipboardMethodOSC52  = "osc52"

	DefaultOSC52MaxPayloadBytes = 100_000
)
View Source
const (
	PRStatusUnknown = "unknown"
	PRMergeable     = "mergeable"
	PRConflicting   = "conflicting"
	PRChecksPassing = "passing"
	PRChecksFailing = "failing"
	PRChecksPending = "pending"
)
View Source
const UntrackedOwnerReleaseCommand = "untracked-owner-release"

UntrackedOwnerReleaseCommand is the internal process-exit callback used by phase-untracked Flow agents. It is not part of the interactive CLI surface.

Variables

View Source
var ErrEmbeddedTmuxUnavailable = errors.New("tmux is not available for embedded terminal detach")

ErrEmbeddedTmuxUnavailable tells callers they can use the direct embedded PTY path because tmux is not installed.

View Source
var ErrFlowBranchMissing = errors.New("branch does not exist")

ErrFlowBranchMissing reports that the branch a Flow record names does not exist in its repository, so there is nothing to attach a worktree to. It is a sentinel rather than a message because the caller's next move — allocate a fresh flow/<slug> pair instead — depends on this case and no other.

View Source
var ErrRepoTmuxUnavailable = errors.New("tmux is not available for tmux launch mode")

ErrRepoTmuxUnavailable reports that tmux mode cannot run this launch because tmux is not installed. Callers probe availability before routing here, so reaching this is a launch failure, not a fallback: no caller inspects it.

View Source
var ErrWorktreePruneFailed = errors.New("worktree removed but prune failed")

ErrWorktreePruneFailed reports that git removed the worktree but failed to prune stale admin references. Callers should treat the worktree as gone.

Functions

func AgentCommand

func AgentCommand(ctx AgentLaunchContext) (*exec.Cmd, error)

AgentCommand builds the direct command for launching a supported coding agent in ctx, including provider hook args, resume args, the trailing prompt, the working directory, and the APPROACH_* environment overrides. It does not wrap the command in a terminal transport; AgentLaunch does that.

func CopyToClipboard

func CopyToClipboard(text string) error

CopyToClipboard copies text using the native clipboard when available and otherwise falls back to OSC 52.

func CopyToClipboardWithOptions added in v0.10.8

func CopyToClipboardWithOptions(text string, opts ClipboardOptions) error

CopyToClipboardWithOptions copies text using the configured clipboard transport.

func CreateBranch

func CreateBranch(repoPath, name, startPoint string) error

CreateBranch creates a new branch without checking it out. When startPoint is empty, git creates the branch at HEAD.

func CreatePullRequestWorktree

func CreatePullRequestWorktree(repoPath, input string) (string, error)

CreatePullRequestWorktree fetches a pull request head into a local review branch, then creates a worktree for that branch.

func CreateWorktree

func CreateWorktree(repoPath, ref string) (string, error)

CreateWorktree creates a new worktree from an existing branch/tag/ref, or creates a new branch with that name from HEAD when the input does not resolve.

func DefaultWorktreePath

func DefaultWorktreePath(repoPath, ref string) string

DefaultWorktreePath returns the conventional sibling path used for new worktrees: <repo>-worktrees/<branch-or-tag>.

func DeleteBranch

func DeleteBranch(repoPath, name string) error

DeleteBranch runs `git branch -d`.

func DirectEmbeddedAgentCommand added in v0.10.8

func DirectEmbeddedAgentCommand(ctx AgentLaunchContext) (*exec.Cmd, error)

DirectEmbeddedAgentCommand builds a direct PTY/stream command whose outer process releases an exact durable phase-untracked owner on exit. Tmux and external-terminal transports install the same callback in their scripts; direct embedded processes need their own wrapper because the launching TUI may crash before it observes process completion.

func DropStash

func DropStash(repoPath string, index int) error

DropStash runs `git stash drop stash@{N}`.

func EmbeddedTmuxAgentIdentity added in v0.10.8

func EmbeddedTmuxAgentIdentity(ctx AgentLaunchContext) (socketName, sessionName string, err error)

EmbeddedTmuxAgentIdentity returns the deterministic private tmux identity an embedded launch will use, without creating its launch script or starting the session. Callers can durably publish the identity before spawning tmux.

func EmbeddedTmuxSessionOwnsProcess added in v0.10.8

func EmbeddedTmuxSessionOwnsProcess(socketName, sessionName string, pid int) bool

EmbeddedTmuxSessionOwnsProcess is the isolated-socket counterpart to RepoTmuxWindowOwnsProcess.

func Fetch

func Fetch(path string) error

Fetch runs `git fetch --prune` for the given repo or worktree path.

func ForceDeleteBranch

func ForceDeleteBranch(repoPath, name string) error

ForceDeleteBranch runs `git branch -D`.

func ForceRemoveWorktree

func ForceRemoveWorktree(repoPath, worktreePath string) error

ForceRemoveWorktree runs `git worktree remove --force`, then prunes stale references.

func InsideMultiplexer added in v0.10.6

func InsideMultiplexer() bool

InsideMultiplexer reports whether approach itself is running inside tmux or Zellij. tmux mode opens no terminal window there: the user already has a multiplexer in front of them, and a nested `tmux attach` refuses to run anyway. The model reads no environment of its own, so the read lives here.

func InsideTmux added in v0.10.8

func InsideTmux() bool

InsideTmux reports whether Approach's current renderer is hosted by tmux.

func IsFlowLaunchContext added in v0.10.7

func IsFlowLaunchContext(ctx AgentLaunchContext) bool

IsFlowLaunchContext reports whether this context carries any Flow identity at all. It is deliberately wider than a role check: a context may carry a Flow ID or the auto-launch marker without naming a launch role, and the lifecycle guard that reads this is a refusal guard, so it must fail closed on those rather than waving them onto the non-Flow route.

func MainWorktreePath added in v0.10.6

func MainWorktreePath(path string) (string, error)

MainWorktreePath resolves the primary worktree for the repository containing path. Git always lists the primary worktree first, including when path is a linked worktree.

func MoveWorktree

func MoveWorktree(repoPath, worktreePath, destination string) (string, error)

MoveWorktree runs `git worktree move` for a linked worktree and returns the resolved destination path on success.

func NormalizePullRequestWorktreeRef

func NormalizePullRequestWorktreeRef(input string) (string, error)

NormalizePullRequestWorktreeRef returns the stable PR ref value approach exposes to post-create integrations.

func OpenURL

func OpenURL(rawURL string) error

OpenURL opens an absolute http(s) URL in the system browser.

func OpenVSCode

func OpenVSCode(path string) error

OpenVSCode opens VSCode at the given path.

func PruneWorktree

func PruneWorktree(repoPath string) error

PruneWorktree runs `git worktree prune` to remove stale admin references.

func Pull

func Pull(path string) error

Pull runs `git pull --ff-only` for the given repo or worktree path.

func RemoveWorktree

func RemoveWorktree(repoPath, worktreePath string) error

RemoveWorktree runs `git worktree remove` for the given worktree path, then prunes stale references to ensure the worktree no longer appears in listings.

func RepoAgentSessionName added in v0.10.1

func RepoAgentSessionName(repoPath string) string

RepoAgentSessionName returns the tmux session name that holds every agent window for a repo. It is keyed on the repo, not the worktree, so all of a repo's Flows share one session.

Dots and colons are replaced because tmux reads them as target separators: `-t "=approach-foo.github.io-1a2b3c4d"` parses as session `approach-foo`, pane `github` and fails with "can't find pane", which would silently break has-session, attach, and the attach command shown to the user. The trailing path hash WorktreeSessionName appends keeps the substitution collision-free.

func RepoTmuxAttachCommand added in v0.10.1

func RepoTmuxAttachCommand(sessionName string) string

RepoTmuxAttachCommand is the attach command shown to the user in status text.

func RepoTmuxAttachExistingShellCommand added in v0.10.1

func RepoTmuxAttachExistingShellCommand(sessionName string) string

RepoTmuxAttachExistingShellCommand attaches to an existing session and fails when it is absent. It deliberately avoids `new-session -A`, which would create the session the caller is trying to report as missing.

func RepoTmuxLaunchWindowLive added in v0.10.1

func RepoTmuxLaunchWindowLive(repoPath string, launchIDs ...string) bool

RepoTmuxLaunchWindowLive reports whether any of these launches still has a running window in the repo's agent session. It is the one liveness signal a tmux launch has: window names carry the launch ID's trailing hex, so a live window can be matched back to the launch that created it.

It is variadic because one `list-windows` answers for every launch at once. Callers that own a whole phase or Flow should pass every launch ID it has rather than only the newest: an earlier launch's window can outlive a later one that already exited, and asking about the newest alone would miss it.

False means "no evidence of a live window" — tmux missing, session gone, probe failed or timed out, the window's pane already dead, or launch IDs with nothing to match on. Callers must treat it as permission to proceed, never as proof the agent is gone, and must only call it on a user-initiated action: it runs a tmux subprocess.

func RepoTmuxLaunchWindowStatus added in v0.10.8

func RepoTmuxLaunchWindowStatus(repoPath string, launchIDs ...string) (bool, error)

RepoTmuxLaunchWindowStatus reports whether any matching launch window is live and returns an error when tmux could not answer conclusively. Unlike the advisory boolean wrapper, a successful false result is safe to use as exit evidence.

func RepoTmuxSessionAttached added in v0.10.6

func RepoTmuxSessionAttached(repoPath string) bool

RepoTmuxSessionAttached reports whether a terminal is already watching a repo's agent session. tmux mode opens one terminal window per repo and adds tmux windows to it afterwards; this is what distinguishes the two cases, and it stays honest when the user closes that terminal or restarts the TUI, which an in-process flag alone cannot.

False means "no evidence of an attached client" — tmux missing, session gone, probe failed or timed out — matching the existing probes' convention. Here that error direction costs at most one extra terminal window, never a lost agent, so it is the safe way to be wrong.

It runs a tmux subprocess, so callers must keep it off the update loop.

func RepoTmuxSessionExists added in v0.10.1

func RepoTmuxSessionExists(repoPath string) bool

RepoTmuxSessionExists reports whether a repo's agent session is alive.

func RepoTmuxWindowOwnsProcess added in v0.10.8

func RepoTmuxWindowOwnsProcess(sessionName, windowIdentity string, pid int) bool

RepoTmuxWindowOwnsProcess reports whether pid is the pane shell for one exact repo-tmux window. The post-exit owner callback is a child of that shell; an agent process deeper in the pane is not.

func ResolveWorktreeCommit

func ResolveWorktreeCommit(path string) string

ResolveWorktreeCommit returns HEAD for path, or "" when path is not a git worktree. Launching agents should not fail just because metadata is missing.

func RunBootstrapHook

func RunBootstrapHook(ctx BootstrapContext, hook BootstrapHook) error

RunBootstrapHook executes a configured bootstrap script directly, with the created worktree as its working directory.

func ShouldPrefillEmbeddedPrompt

func ShouldPrefillEmbeddedPrompt(ctx AgentLaunchContext) bool

ShouldPrefillEmbeddedPrompt reports whether an embedded Flow launch fills the dock with its prompt instead of passing it as argv. Which launches prefill is the role's answer; the rest of the conjuncts are transport and payload — the three providers with a dock, the interactive embedded slot, and a prompt that is actually there to place.

The role has to be well formed as well as prefilling: a context that mixes markers — a repair carrying a phase, a phase-attached launch that declared itself untracked — is not the launch its role names, and the four hand-written predicates this replaced each refused those shapes by failing a conjunct. That refusal is now stated once, on the role.

func StripMultiplexerEnv added in v0.10.1

func StripMultiplexerEnv(cmd *exec.Cmd)

StripMultiplexerEnv clears TMUX and ZELLIJ from a command's environment. Attaching is the one tmux-mode action whose command approach does not build itself — it goes through the shared external-terminal seam — and a terminal that inherits TMUX spawns a tmux client that refuses to nest, which is exactly the case for a user running approach inside tmux.

func TmuxAvailable added in v0.10.1

func TmuxAvailable() bool

TmuxAvailable reports whether tmux mode can run launches right now.

func UnlockWorktree

func UnlockWorktree(repoPath, worktreePath string) error

UnlockWorktree runs `git worktree unlock` for the given worktree path.

func UsesStreamJSONOutput

func UsesStreamJSONOutput(ctx AgentLaunchContext) bool

UsesStreamJSONOutput reports whether an embedded launch emits claude stream-json that approach must render into readable terminal lines. Headless Claude and Cursor print modes stream stream-json; codex and interactive launches render their own output directly.

func ValidatePullRequestWorktreeInput

func ValidatePullRequestWorktreeInput(repoPath, input string) error

ValidatePullRequestWorktreeInput checks whether input is a supported PR number or URL for repoPath.

func WorktreeSessionName

func WorktreeSessionName(path string) string

WorktreeSessionName returns a tmux/Zellij-safe session name derived from the worktree directory name plus a stable path fingerprint.

Types

type AgentLaunchContext

type AgentLaunchContext struct {
	Command           string
	LaunchID          string
	RepoPath          string
	WorktreePath      string
	WorkingDir        string
	Branch            string
	Commit            string
	SessionStateRoot  string
	ResumeSessionID   string
	PlanID            string
	PlanPath          string
	PlanPhaseID       string
	PlanPhaseTitle    string
	PlanPhaseStatus   string
	FlowID            string
	FlowPhaseID       string
	FlowPhaseKind     string
	FlowLaunchTracked bool
	FlowAutoLaunch    bool
	// FlowRepair marks an untracked Flow-scoped repair session. Repair launches
	// deliberately carry no phase ID so provider hooks retain Flow
	// discoverability without attaching the session to a phase attempt.
	FlowRepair bool
	// FlowAgent marks the generic untracked Flow-scoped worktree agent started by
	// s. Its retained terminal is intentionally nondetachable.
	// Like repair it carries no phase ID, so provider hooks keep Flow
	// discoverability without attaching the session to a phase attempt.
	FlowAgent bool
	// FlowSavedSessionResume marks a phase-untracked resume whose authoritative
	// saved session belongs to a Flow. It is embedded-only and preserves the raw
	// provider session ID byte-for-byte.
	FlowSavedSessionResume bool
	// FlowAutofix marks the distinct prompted, PR-gated untracked agent started
	// by U. It shares prompt delivery mechanics with FlowAgent but not policy.
	FlowAutofix bool
	// FlowAutofixPRNumber is display-only typed metadata for the PR-gated
	// FlowAutofix role. It is not exported to providers.
	FlowAutofixPRNumber int
	// FlowPhaseTerminal records that the persisted phase kept a terminal
	// status (completed, skipped) when the launch was recorded, so launch
	// failures must not regress the phase to needs_attention.
	FlowPhaseTerminal bool
	Embedded          bool
	// DirectStartGate is an internal absent-file gate used by the direct
	// embedded fallback. Its wrapper waits until Approach durably publishes the
	// wrapper PID, then removes the gate before executing the agent.
	DirectStartGate string
	Headless        bool
	Model           string
	ReasoningEffort string
	// InitialPrompt is canonical launch metadata. It is delivered either as a
	// provider argv or by embedded PTY prefill, depending on launch mode.
	InitialPrompt string
	// Executable pins the approach binary this launch's agent must invoke,
	// exported as APPROACH_EXECUTABLE and baked into the provider session hook.
	// It is the launching build, not whatever `approach` ambient PATH resolves:
	// a phase launched by a schema-N build and reported by a schema-(N-1) CLI
	// cannot persist its result at all. Empty means "no pin" and leaves agents
	// on PATH, which is the pre-pin behaviour and still correct for a manually
	// started session.
	Executable string
	// BuildVersion and DBSchemaVersion describe the pinned build, exported as
	// APPROACH_BUILD_VERSION and APPROACH_DB_SCHEMA so an agent-side
	// compatibility refusal can name both binaries rather than one integer.
	BuildVersion    string
	DBSchemaVersion int
	// ControlEndpoint and ControlToken are the launch's registration with the
	// TUI's launch controller, exported as APPROACH_CONTROL_ENDPOINT and
	// APPROACH_CONTROL_TOKEN only when set. With them the agent's `approach
	// flow` writes are proxied over the per-root socket and logged before they
	// are acknowledged; without them the CLI opens the store directly, which is
	// the pre-controller behaviour. The token is per launch and lives only in
	// the agent's environment and the controller's memory.
	ControlEndpoint string
	ControlToken    string
}

AgentLaunchContext carries metadata Approach knows at launch time so provider hooks can associate later session records with the selected repo/worktree.

type BootstrapContext

type BootstrapContext struct {
	RepoPath     string
	WorktreePath string
	Ref          string
	Kind         WorktreeCreateKind
}

BootstrapContext describes the worktree creation that triggered a hook.

type BootstrapHook

type BootstrapHook struct {
	Script         string
	TimeoutSeconds int
}

BootstrapHook configures a script to run after a worktree is created.

type ClipboardOptions added in v0.10.8

type ClipboardOptions struct {
	Method               string
	OSC52MaxPayloadBytes int
}

ClipboardOptions selects the clipboard transport and bounds encoded OSC 52 payloads.

type CommandRunner

type CommandRunner interface {
	Run(name string, args ...string) ([]byte, []byte, error)
}

CommandRunner executes a command and returns stdout, stderr, and the command error.

type ContextCommandRunner added in v0.10.4

type ContextCommandRunner interface {
	RunContext(ctx context.Context, name string, args ...string) ([]byte, []byte, error)
}

ContextCommandRunner executes a command whose process is cancelled with ctx.

type EditorOptions

type EditorOptions struct {
	EditorCommand string
}

EditorOptions customizes how editable files are opened.

type EmbeddedTmuxAgentSpec

type EmbeddedTmuxAgentSpec struct {
	SocketName         string
	SessionName        string
	ScriptPath         string
	StatusPath         string
	DetachTarget       string
	HasSessionCommand  *exec.Cmd
	NewSessionCommand  *exec.Cmd
	AttachCommand      *exec.Cmd
	KillSessionCommand *exec.Cmd
	Cleanup            func()
}

EmbeddedTmuxAgentSpec describes a CLI agent launch that runs inside a tmux session while approach embeds only an attached tmux client.

func EmbeddedTmuxAgentCommand

func EmbeddedTmuxAgentCommand(ctx AgentLaunchContext) (EmbeddedTmuxAgentSpec, error)

EmbeddedTmuxAgentCommand builds the tmux lifecycle commands for a detachable embedded CLI agent launch. It does not start tmux.

type FlowLaunchRole added in v0.10.6

type FlowLaunchRole int

FlowLaunchRole names the kind of Flow-scoped launch a context represents. It is a closed enum: every Flow launch the TUI can start is exactly one of these seven, and the launch context's marker flags are the role's encoding rather than seven independent booleans a caller may combine freely.

It lives in actions rather than model because actions is the package model imports, not the other way round, and because the role's consumers — resume identity, tmux role validation, the tracked-lease branch — already live here.

const (
	// RoleTrackedPhase is a phase-attached launch that reserves the Flow lease
	// and writes phase attempt history.
	RoleTrackedPhase FlowLaunchRole = iota + 1
	// RolePhaseResume resumes a phase's saved provider session.
	RolePhaseResume
	// RoleRepair is the untracked Flow-scoped repair session.
	RoleRepair
	// RoleAutofix is the prompted, PR-gated untracked agent.
	RoleAutofix
	// RoleWorktreeAgent is the generic untracked worktree agent started by s.
	RoleWorktreeAgent
	// RoleSavedSessionResume is a phase-untracked resume of a Flow's saved
	// provider session.
	RoleSavedSessionResume
	// RoleCreatePhase is the first launch of a freshly created Flow's startup
	// root, started by Plan Now and by Ready-Bead F. It appends rather than
	// slotting in beside RoleTrackedPhase so the existing values keep their
	// numbers.
	RoleCreatePhase
)
const (
	// RoleNone is the zero value: a context that is not a Flow launch at all,
	// or one whose markers name no role. It is deliberately the zero value so a
	// context nobody classified reads as "not a Flow launch" rather than as the
	// first real role.
	RoleNone FlowLaunchRole = 0
)

func FlowLaunchRoleOf added in v0.10.7

func FlowLaunchRoleOf(ctx AgentLaunchContext) FlowLaunchRole

FlowLaunchRoleOf is the inverse of the builder: it recovers the role a finished launch context encodes. It is total — a context that names no role, including every non-Flow launch, classifies as RoleNone.

The order is precedence, not arbitrary sequence. Contexts that set more than one marker are malformed, but they do reach the consumers this classifier serves, and the ordering reproduces what those consumers' hand-written predicates answered: the repair / agent / saved-session chain first, then the phase-attached roles, then autofix.

One role is one answer, so on two malformed shapes the single answer cannot equal every old predicate's, and these are the deliberate divergences. A context setting FlowRepair alongside FlowAgent or FlowSavedSessionResume is repair here, so the detach policy allows detaching where the old marker-or-marker test refused. A phase-attached context without FlowLaunchTracked is a phase role here, so the reservation takes the Flow lease where the old test skipped it — the conservative direction, and the one that keeps the reservation agreeing with the failure update, which has always marked that shape's phase. Neither shape is emitted by any builder arm: the arms set exactly one marker each, and every phase-attached arm sets FlowLaunchTracked.

Embedded, Headless and FlowAutofixPRNumber are deliberately not inputs. They are transport and payload rather than role, and the one consumer that cares reads them itself alongside the role.

func (FlowLaunchRole) Prefills added in v0.10.7

func (role FlowLaunchRole) Prefills() bool

Prefills reports whether a launch in this role fills the embedded dock with its prompt rather than passing it as argv. The two resume roles carry no prompt to place, and RoleNone is not a Flow launch at all.

func (FlowLaunchRole) String added in v0.10.6

func (role FlowLaunchRole) String() string

String names the role for diagnostics. An unknown value names itself rather than masquerading as a real role.

func (FlowLaunchRole) Tracked added in v0.10.7

func (role FlowLaunchRole) Tracked() bool

Tracked reports whether this role reserves the Flow launch lease and writes phase attempt history. Stating it once here is what keeps the reservation and the failure-update refusal from each re-deriving "tracked" from raw markers and disagreeing.

type FlowWorktreeCreateResult

type FlowWorktreeCreateResult struct {
	WorktreePath string
	Branch       string
}

FlowWorktreeCreateResult describes the branch/worktree allocated for a Flow.

func AttachFlowWorktree added in v0.10.1

func AttachFlowWorktree(repoPath, branch string) (FlowWorktreeCreateResult, error)

AttachFlowWorktree gives an existing local branch a worktree at the conventional sibling path. It is the counterpart to CreateFlowWorktree for a Flow that already records the branch it means to run on: inventing a second branch there would strand the recorded one.

func CreateFlowWorktree

func CreateFlowWorktree(repoPath, title, baseRef string) (FlowWorktreeCreateResult, error)

CreateFlowWorktree creates a deterministic Flow branch/worktree pair: flow/<slug> at <repo>-worktrees/flow-<slug>. Branch and path suffixes move together on collision so the pair remains easy to recognize.

type LaunchOptions

type LaunchOptions struct {
	TerminalCommand string
}

LaunchOptions customizes external terminal transports without changing multiplexer/session selection.

type PullRequestMerge

type PullRequestMerge struct {
	Commit   string
	MergedAt time.Time
}

PullRequestMerge is the verified GitHub merge metadata for a PR.

func LookupGitHubPRMerge

func LookupGitHubPRMerge(number int, prURL string) (PullRequestMerge, error)

LookupGitHubPRMerge returns verified merge metadata for a GitHub PR.

func LookupGitHubPRMergeWithRunner

func LookupGitHubPRMergeWithRunner(number int, prURL string, runner CommandRunner) (PullRequestMerge, error)

LookupGitHubPRMergeWithRunner returns verified merge metadata using runner.

type PullRequestStatus added in v0.10.4

type PullRequestStatus struct {
	Mergeability string
	Checks       string
}

PullRequestStatus is the live GitHub status projected in the PR babysitter.

func LookupGitHubPRStatus added in v0.10.4

func LookupGitHubPRStatus(ctx context.Context, number int, prURL string) (PullRequestStatus, error)

LookupGitHubPRStatus returns live mergeability and checks for a GitHub PR.

func LookupGitHubPRStatusWithRunner added in v0.10.4

func LookupGitHubPRStatusWithRunner(ctx context.Context, number int, prURL string, runner ContextCommandRunner) (PullRequestStatus, error)

LookupGitHubPRStatusWithRunner returns live PR status using runner.

type RepoCreateOptions

type RepoCreateOptions struct {
	Root              string
	Name              string
	CreateGitHub      bool
	Visibility        RepoVisibility
	RemoteOnlyRetry   bool
	ExistingLocalPath string
}

RepoCreateOptions describes a local-first repository creation request.

type RepoCreateResult

type RepoCreateResult struct {
	DestinationPath   string
	LocalCreated      bool
	GitHubCreated     bool
	PartialSuccess    bool
	RetryAllowed      bool
	ExistingLocalPath string
}

RepoCreateResult reports what was created and whether a failed GitHub step can be retried against the already-created local path.

func CreateRepo

func CreateRepo(opts RepoCreateOptions) (RepoCreateResult, error)

CreateRepo creates a local git repository and optionally creates/wires a GitHub repository through gh.

type RepoTmuxAgentSpec added in v0.10.1

type RepoTmuxAgentSpec struct {
	SessionName string
	WindowName  string
	// WindowID reports tmux's stable window identity after Launch succeeds.
	// Before then it returns an empty string.
	WindowID func() string
	// AttachCommand is the command to show the user so they can reach the
	// session from their own terminal.
	AttachCommand string
	Launch        TerminalLaunchSpec
	// Terminate removes this exact window if post-spawn publication fails. The
	// launcher must not release its durable reservation while an unpublished
	// agent is still running.
	Terminate func() error
}

RepoTmuxAgentSpec is a CLI agent launch that runs as a window in the repo's tmux session on the user's default tmux server.

func RepoTmuxAgentLaunch added in v0.10.1

func RepoTmuxAgentLaunch(ctx AgentLaunchContext) (RepoTmuxAgentSpec, error)

RepoTmuxAgentLaunch builds a CLI agent launch that runs in the repo's tmux session. The agent itself runs from the same self-deleting script every other transport uses, so cwd, APPROACH_* exports, and provider hook wiring are identical to an embedded or external launch.

type RepoVisibility

type RepoVisibility string

RepoVisibility is the GitHub visibility requested for a new repository.

const (
	RepoVisibilityPublic  RepoVisibility = "public"
	RepoVisibilityPrivate RepoVisibility = "private"
)

type TerminalLaunchSpec

type TerminalLaunchSpec struct {
	Cmd         *exec.Cmd
	Interactive bool
	// Detached means the command hands the agent off to another terminal or
	// multiplexer session; provider hooks own completed-session metadata.
	Detached bool
	Cleanup  func()
	// ErrorDetail returns a transport-captured diagnostic for a failed run, or
	// "" when there is none. A transport that spawns through a wrapper script
	// sets it so the failure reads as more than the script's exit status; nil
	// leaves the process error as the whole message. Only read after the
	// command has exited.
	ErrorDetail func() string
}

TerminalLaunchSpec describes how approach should open an external process for a worktree. Interactive commands should be run with Bubble Tea's ExecProcess so the TUI releases the current terminal until the process exits.

func AgentLaunch

func AgentLaunch(ctx AgentLaunchContext) (TerminalLaunchSpec, error)

AgentLaunch builds a supported coding-agent command for ctx and wraps it in a terminal/multiplexer transport so the agent runs in its own window/session—matching the behavior of the `t` shortcut—instead of taking over the approach TTY. Detached transports leave the approach TUI usable; only transports that genuinely need the current TTY are returned as interactive.

func AgentLaunchWithOptions

func AgentLaunchWithOptions(ctx AgentLaunchContext, opts LaunchOptions) (TerminalLaunchSpec, error)

AgentLaunchWithOptions is AgentLaunch with configurable terminal transport selection.

func DetachedTerminalLaunch

func DetachedTerminalLaunch(targetShellCommand, cwd string, opts LaunchOptions) (TerminalLaunchSpec, error)

DetachedTerminalLaunch builds a non-interactive handoff command that opens an external terminal and runs targetShellCommand. It intentionally ignores active or installed multiplexers; the target command already attaches to the detached tmux-backed embedded terminal.

func EditFile

func EditFile(path string) (TerminalLaunchSpec, error)

EditFile builds an interactive editor command for path.

func EditFileWithOptions

func EditFileWithOptions(path string, opts EditorOptions) (TerminalLaunchSpec, error)

EditFileWithOptions is EditFile with configurable editor selection.

func PageText

func PageText(body string) (TerminalLaunchSpec, error)

PageText builds an interactive pager command for read-only text views.

func TerminalLaunch

func TerminalLaunch(path string) (TerminalLaunchSpec, error)

TerminalLaunch returns a command that opens or switches to a multiplexer session for path. It adapts to the current environment:

  • inside Zellij: switch to a Zellij session with the worktree name
  • inside tmux: create the tmux session if needed, then switch-client
  • outside a multiplexer: prefer $TERMINAL, configured terminal, tmux/Zellij, then a platform/shell fallback

func TerminalLaunchWithOptions

func TerminalLaunchWithOptions(path string, opts LaunchOptions) (TerminalLaunchSpec, error)

TerminalLaunchWithOptions is TerminalLaunch with configurable terminal transport selection.

type TransportLiveness added in v0.10.8

type TransportLiveness uint8

TransportLiveness is the result of an authoritative transport probe. Unknown must remain occupied; only Dead permits reclaiming durable ownership.

const (
	TransportLivenessUnknown TransportLiveness = iota
	TransportLivenessLive
	TransportLivenessDead
)

func EmbeddedTmuxSessionLiveness added in v0.10.8

func EmbeddedTmuxSessionLiveness(socketName, sessionName string) TransportLiveness

EmbeddedTmuxSessionLiveness probes one isolated socket and session identity.

func RepoTmuxWindowLiveness added in v0.10.8

func RepoTmuxWindowLiveness(sessionName, windowIdentity string) TransportLiveness

RepoTmuxWindowLiveness probes one persisted repo-tmux window identity.

type WorktreeCreateKind

type WorktreeCreateKind int

WorktreeCreateKind identifies which create flow produced the worktree.

const (
	WorktreeCreateGeneric WorktreeCreateKind = iota
	WorktreeCreatePullRequest
	WorktreeCreateFlow
)

func (WorktreeCreateKind) String

func (k WorktreeCreateKind) String() string

Jump to

Keyboard shortcuts

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