launch

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package launch implements `sf claude` — a thin, generic launcher that starts the `claude` CLI for a project. Binding to the project's instructions is implicit: claude runs with cwd set to the project dir, so it loads that project's own root AGENTS.md/CLAUDE.md natively — sf doesn't maintain a separate instruction tree or inject one. The launcher's job is just the mechanics: resolve the project dir, assemble claude's argv, and hand off to the process (interactive) or run it headlessly (--task), propagating its exit code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForkSlug

func ForkSlug(sel string) string

ForkSlug normalizes a fork selector for `sf claude <project> <sel>`: a bare number N becomes "sN" (the s1..sN convention); any other token is used verbatim.

func InteractiveArgs

func InteractiveArgs(t Target, o Options) []string

InteractiveArgs assembles the claude argv for an interactive session.

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns the `claude` Cobra command (`sf claude`).

func ResolveDir

func ResolveDir(dirFlag, project string) (string, error)

ResolveDir resolves the project's working dir. Order: an explicit --dir override; else, given a bare project name, $SF_CLAUDE_DIR/<project> (error if $SF_CLAUDE_DIR is unset — there's no tree to search generically); else, with neither, the current directory. The result is validated to exist and be a directory, and returned absolute.

func ResolveFork

func ResolveFork(projectDir, sel string, dryRun bool) (string, error)

ResolveFork redirects a launch into an isolated worktree copy of the project, via the project's own dev/worktree.sh (that script owns the fork scheme — paths, ports, stack; the launcher only orchestrates it). Errors clearly if the project doesn't ship one. dryRun only resolves the fork's dir without creating or starting anything.

func Run

func Run(t Target, o Options, stdout io.Writer) (int, error)

Run dispatches to dry-run / task / interactive. For task mode it returns claude's exit code; interactive mode replaces the process (unix) and never returns on success.

func TaskArgs

func TaskArgs(t Target, o Options) []string

TaskArgs assembles the claude argv for a one-shot `-p` task run.

Types

type Options

type Options struct {
	Model      string
	Effort     string
	Permission string
	Task       string
	Out        string
	JSON       bool
	Quiet      bool
	DryRun     bool
	Extra      []string // passthrough args (after `--`)
}

Options carries everything resolved from flags before launch.

type Target

type Target struct {
	Name string
	Dir  string // claude's working dir (cwd) — may be a fork dir
}

Target is a resolved launch target: the project's working dir plus the name it's tagged with (passed to claude as `-n` and stamped into SOFIA_TAG). Name is fixed at resolution time and untouched by a fork selector, so `sf <proj> <tool>` calls made from inside a forked worktree still attribute to the main project.

func ResolveTarget

func ResolveTarget(dirFlag, project string) (Target, error)

ResolveTarget resolves the project dir (see ResolveDir) and names it after the resolved dir's basename.

Jump to

Keyboard shortcuts

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