wrkcli

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodGoInstall    Method = "go-install"
	MethodGoRunInstall Method = "go-run-install"
	ActionInstall      Action = "install"
	ActionSkip         Action = "skip"
)

Variables

This section is empty.

Functions

func Complete

func Complete(wrkHome string, req CompletionRequest) []string

Complete returns bash tab-completion candidates for the given request.

func FormatCompareBranches

func FormatCompareBranches(refA, refB string, result *git.CompareBranchesResult) string

FormatCompareBranches returns kool compare-branch text for refA vs refB.

func FormatMasterBrief

func FormatMasterBrief(result *git.CompareBranchesResult, colorEnabled bool) string

FormatMasterBrief returns a one-line master sync summary for --status linked worktrees.

func FormatRemoteBrief

func FormatRemoteBrief(result *git.CompareBranchesResult, colorEnabled bool) string

FormatRemoteBrief returns a one-line remote sync summary for --projects.

func IsWipSubject added in v0.0.2

func IsWipSubject(subject string) bool

IsWipSubject reports whether a commit subject is a WIP commit for sync pass-1. After trimming surrounding whitespace, match is case-insensitive prefix any of:

wip:  |  wip(  |  [wip]

Empty / whitespace-only subjects and mid-string-only occurrences are not WIP.

func NormalizeTaskSlug

func NormalizeTaskSlug(taskDesc string) (string, error)

NormalizeTaskSlug turns free-text task into a path slug. Empty or whitespace-only input yields empty slug (no task segment). Non-empty input that slugifies to empty is an error.

func RegisterWebServe

func RegisterWebServe(fn webServeFunc)

RegisterWebServe sets the implementation used by `wrk --web`. cmd/wrk calls this from init with wrkcli/web.Serve.

func ResolveReinstallScanRoot added in v0.0.6

func ResolveReinstallScanRoot(workDir string, useMain bool) (string, error)

ResolveReinstallScanRoot returns the absolute directory from which Go module discovery should begin for multi-module local reinstall planning.

Rules (priority):

  1. useMain == true: workDir must be inside a git checkout; scan root is the main repository path (ResolveMainRepo of ShowToplevel).
  2. useMain == false and inside git: scan root is ShowToplevel(workDir).
  3. Not in git: walk up from workDir looking for a go.mod; first hit is root.
  4. No scan root: not in git and no go.mod on the walk-up → error.

func ResolveWrkHome

func ResolveWrkHome(wrkHome string) (string, error)

ResolveWrkHome returns wrkHome when non-empty; otherwise WRK_HOME or ~/.wrk.

func Run

func Run(args []string) error

Run executes wrk logic with args. The first positional argument, if present, is the source directory for all modes.

func ShellSafeQuote

func ShellSafeQuote(s string) string

ShellSafeQuote encodes s as a single POSIX shell word using single quotes. Empty string becomes ”; embedded single quotes use the '\” join form.

func Version

func Version() string

Version returns the embedded build version (e.g. "v0.0.1").

Types

type Action added in v0.0.6

type Action string

type CompletionRequest

type CompletionRequest struct {
	Words []string
	CWord int
}

CompletionRequest carries bash COMP_WORDS and COMP_CWORD for tab completion.

type Config

type Config struct {
	Version int            `json:"version"`
	Create  *CreateSection `json:"create,omitempty"`
}

Config is the optional user config at $WRK_HOME/config.json.

type CreateAgent

type CreateAgent struct {
	Enabled        *bool    `json:"enabled,omitempty"`
	Runner         string   `json:"runner,omitempty"`
	PromptTemplate string   `json:"prompt_template,omitempty"`
	Args           []string `json:"args,omitempty"`
}

CreateAgent configures agent-run launch after create.

type CreateSection

type CreateSection struct {
	Window   *CreateWindow   `json:"window,omitempty"`
	Terminal *CreateTerminal `json:"terminal,omitempty"`
	Agent    *CreateAgent    `json:"agent,omitempty"`
}

CreateSection holds create-mode UX options. Legacy create.interceptor is deliberately omitted so leftover JSON is ignored.

type CreateTerminal

type CreateTerminal struct {
	// Mode is "new" | "reuse" | "smart"; absent/empty means terminal off.
	Mode string `json:"mode,omitempty"`
}

CreateTerminal configures iTerm2 open mode.

type CreateWindow

type CreateWindow struct {
	// Mode is "new" when window UX is on; absent/empty means off.
	Mode string `json:"mode,omitempty"`
}

CreateWindow configures Mission Control Desktop creation.

type CreateWorktreeResult

type CreateWorktreeResult struct {
	Path   string
	Branch string
}

CreateWorktreeResult is the structured outcome of default worktree creation.

func CreateDefaultWorktree

func CreateDefaultWorktree(projectPath, wrkHome, taskSlug string) (*CreateWorktreeResult, error)

CreateDefaultWorktree creates a linked worktree under wrkHome/worktrees using wrk default naming (basename-branchToken-date[-slug][-N]).

projectPath may be the main repo or any checkout that resolves to it. wrkHome must be non-empty (callers inject Options.WrkHome or ResolveWrkHome). taskSlug is an already-slugified task segment; empty means no task in names. Callers that accept free-text tasks should use NormalizeTaskSlug first.

type DirHintOptions

type DirHintOptions struct {
	RawArgs     []string
	Positionals []string
	DepMode     bool
}

DirHintOptions carries CLI context for reconstructing guided file-collision hints.

type Edge added in v0.0.6

type Edge struct {
	ConsumerProject string
	ConsumerModule  string
	DepPath         string
	DepVersion      string
	OwnerProject    string
}

Edge is a require from a consumer module to a dependency module path whose owner project is known in the inventory.

type ExitCodeError

type ExitCodeError struct {
	Code int
}

ExitCodeError signals a non-zero exit without stderr output.

func (ExitCodeError) Error

func (e ExitCodeError) Error() string

type Inventory added in v0.0.6

type Inventory struct {
	Projects     []ProjectEntry
	SkippedPaths []string
}

Inventory is the in-process model of registered projects, their modules, and soft-skipped registry paths.

func BuildInventory added in v0.0.6

func BuildInventory(wrkHome string) (Inventory, error)

BuildInventory loads WRK_HOME projects, soft-skips missing paths, scans modules, and builds ownership.

func (Inventory) CrossEdges added in v0.0.6

func (inv Inventory) CrossEdges() []Edge

CrossEdges returns require edges where consumer and owner projects both known and differ.

func (Inventory) FindOwner added in v0.0.6

func (inv Inventory) FindOwner(modulePath string) (projectPath string, ok bool)

FindOwner returns the registered project path that owns modulePath.

func (Inventory) IntraEdges added in v0.0.6

func (inv Inventory) IntraEdges() []Edge

IntraEdges returns require edges where consumer and owner projects both known and equal.

type LocalReinstallPlan added in v0.0.6

type LocalReinstallPlan struct {
	ModuleRoot string
	ModulePath string // full module path from go.mod
	ModuleName string // basename of module path from go.mod
	BinDir     string
	Items      []PlanItem // sorted lexicographically by BinName
}

LocalReinstallPlan is the pure discovery/filter result for local binary reinstalls.

func PlanLocalReinstalls added in v0.0.6

func PlanLocalReinstalls(moduleRoot, binDir string) (*LocalReinstallPlan, error)

PlanLocalReinstalls discovers package-main candidates under moduleRoot's cmd/ and script/ trees and filters them against binDir.

moduleRoot must contain a parseable go.mod with a module path. Callers resolve binDir (e.g. GOBIN); this function only stats entries there.

type Method added in v0.0.6

type Method string

Method and Action are string type aliases so harness code can use string(it.Method).

type ModuleEntry added in v0.0.6

type ModuleEntry struct {
	Dir      string // relative to project Path; "." for root
	Path     string // module path from go.mod
	Requires []RequireEntry
	Replaces []ReplaceEntry
}

ModuleEntry describes one go.mod under a project.

type ModuleReinstallPlan added in v0.0.6

type ModuleReinstallPlan struct {
	ModuleRoot string
	ModulePath string     // full module path from go.mod
	ModuleName string     // basename of module path from go.mod
	RelDir     string     // module root relative to scan root ("." or slash path); set by FromWorkDir
	Items      []PlanItem // sorted lexicographically by BinName
}

ModuleReinstallPlan is one module's contribution to a multi-module plan.

type MultiLocalReinstallPlan added in v0.0.6

type MultiLocalReinstallPlan struct {
	BinDir  string
	Modules []ModuleReinstallPlan
}

MultiLocalReinstallPlan is the multi-module discovery/filter result for a shared binDir. Modules are ordered lexicographically by absolute ModuleRoot.

func PlanLocalReinstallsFromWorkDir added in v0.0.6

func PlanLocalReinstallsFromWorkDir(workDir, binDir string, useMain bool) (*MultiLocalReinstallPlan, error)

PlanLocalReinstallsFromWorkDir resolves the scan root from workDir, discovers every Go module under that root via mod/scan, and builds a multi-module reinstall plan against binDir.

Zero modules under the scan root is a hard error (message mentions go.mod). Each ModuleReinstallPlan.RelDir is the scan-relative module dir (scan.Module.Dir).

func PlanLocalReinstallsMulti added in v0.0.6

func PlanLocalReinstallsMulti(moduleRoots []string, binDir string) (*MultiLocalReinstallPlan, error)

PlanLocalReinstallsMulti runs PlanLocalReinstalls for each module root and returns a multi-module plan sorted by absolute ModuleRoot path.

Empty moduleRoots yields an empty Modules list and nil error. After per-module planning, if the same BinName has Action=install from two or more modules, returns a hard error naming the bin and both modules. Skip-only (or install×skip) duplicates across modules are allowed.

type PlanItem added in v0.0.6

type PlanItem struct {
	BinName string
	RelPath string // "./cmd/foo" or "./script/foo/install"
	Method  Method // "go-install" | "go-run-install"
	Action  Action // "install" | "skip"
}

PlanItem is one candidate binary to install or skip.

type ProjectEntry added in v0.0.6

type ProjectEntry struct {
	Path    string
	Modules []ModuleEntry
}

ProjectEntry is one existing registered main-repo path and its Go modules.

type ReplaceEntry added in v0.0.6

type ReplaceEntry struct {
	OldPath    string
	NewPath    string
	NewVersion string
}

ReplaceEntry is a single replace directive from go.mod.

type RequireEntry added in v0.0.6

type RequireEntry struct {
	Path    string
	Version string
}

RequireEntry is a single require directive from go.mod.

type SourceRelease added in v0.0.6

type SourceRelease struct {
	ModulePath string
	Tag        string // full git tag, e.g. "v1.2.3" or "sub/v0.1.0"
	Version    string // go require version, e.g. "v1.2.3" or "v0.1.0"
}

SourceRelease is one module's resolved git tag and go require version.

type SourceReleasesResult added in v0.0.6

type SourceReleasesResult struct {
	Releases []SourceRelease
	Missing  []string
}

SourceReleasesResult maps modules under a source main repo to their latest numeric release tags (or lists modules with no such tag).

func ResolveSourceReleases added in v0.0.6

func ResolveSourceReleases(sourceMain string) (SourceReleasesResult, error)

ResolveSourceReleases scans sourceMain for modules and maps numeric release tags to go require versions. Modules without a numeric tag are listed in Missing; overall success is still returned when any/all modules are missing.

type StatusPathLists added in v0.0.5

type StatusPathLists struct {
	Primary  []string
	External []string
}

StatusPathLists holds ordered primary vs external status paths for main-repo status display planning.

func PartitionStatusPaths added in v0.0.5

func PartitionStatusPaths(mainRoot string, scanPaths, linkedOrdered []string) StatusPathLists

PartitionStatusPaths partitions status paths for main-repo status display planning. Primary: mainRoot first, then main-owned linked worktrees in linkedOrdered (ListLinked porcelain) order. External: scanPaths that are not primary, sorted by normalized path. Returned paths are storage.NormalizePath'd.

type WebServeOptions

type WebServeOptions struct {
	WrkHome string
	Port    int
	Dev     bool
}

WebServeOptions configures the local web UI started by `wrk --web`.

Directories

Path Synopsis
Package web serves the wrk React SPA (wrk-react) and mounts wrkserver.
Package web serves the wrk React SPA (wrk-react) and mounts wrkserver.

Jump to

Keyboard shortcuts

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