Help us shape the future of Go! Take the 2026 Go Developer Survey

fork

package
v0.0.207 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fork

func Fork(opts *Options, sessionID, newSessionID, dir string) error

Fork launches grok --resume --fork-session in dir via opts.RunForeground.

func Main

func Main(args []string, opts *Options) error

Main parses argv (no binary name) and runs Mode A (new window) or Mode B (current-terminal grok --resume --fork-session). It does not os.Exit and does not print an Error: prefix.

func ResolveGrokBin

func ResolveGrokBin(grokBin string, lookPath func(file string) (string, error)) (string, error)

ResolveGrokBin returns grokBin if set, otherwise lookPath("grok").

func ResumeForkArgv

func ResumeForkArgv(sessionID, newSessionID string) []string

ResumeForkArgv returns argv for `grok --resume <id> --fork-session` (no binary name). newSessionID, when set, appends `--session-id`.

func Run

func Run(args []string, opts *Options) error

Run is an alias for Main.

Types

type Options

type Options struct {
	Stdout, Stderr    io.Writer
	PID               int
	GrokHome          string
	ListProcs         func() []procresolve.Proc
	Lsof              func(pid int) []string
	OpenInNewTerminal func(dir, followUp string) error
	RunForeground     func(bin string, argv []string, dir string, env []string) error
	GrokBin           string
	LookPath          func(file string) (string, error)
	Executable        func() (string, error)
	Env               []string
}

Options configures Main. Hooks and homes are injectable; Main does not read GROK_HOME from the process environment.

type SessionLaunch

type SessionLaunch struct {
	SessionID    string
	NewSessionID string
	Dir          string
	Bin          string
	Env          []string
}

SessionLaunch is the shared in-process grok --resume --fork-session plan used by grok-fork Mode B and `agent-pro grok session fork`.

func (SessionLaunch) Argv

func (s SessionLaunch) Argv() []string

Argv is ResumeForkArgv(SessionID, NewSessionID).

func (SessionLaunch) CommandLine

func (s SessionLaunch) CommandLine() string

CommandLine is the unquoted display form `<bin> --resume <id> --fork-session`.

func (SessionLaunch) QuotedCommandLine

func (s SessionLaunch) QuotedCommandLine() string

QuotedCommandLine quotes each token for an iTerm follow-up or dry-run.

func (SessionLaunch) Run

func (s SessionLaunch) Run(runForeground func(bin string, argv []string, dir string, env []string) error) error

Run invokes runForeground with the grok fork argv. runForeground must be non-nil (Main / Fork apply production defaults).

Jump to

Keyboard shortcuts

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