wrkcli

package
v0.0.93 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 58 Imported by: 0

Documentation

Index

Constants

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

	DiagLevelNotice  = "notice"
	DiagLevelWarning = "warning"

	DiagKindPreferScript    = "prefer-script"
	DiagKindAmbiguousCmd    = "ambiguous-cmd"
	DiagKindAmbiguousScript = "ambiguous-script"
)

Variables

This section is empty.

Functions

func ApplyUnwind added in v0.0.33

func ApplyUnwind(workDir, wrkHome string, members []StackMember, edges []RepoEdge, plan *UnwindPlan, flags UnwindFlags) error

ApplyUnwind peels free-first dirty stack repos with explicit ship/land flags. With --tag-next (B1): peel free deps first → free-module cascade (tag + pin consumers, selective pin commits) → peel remaining dirty consumers (feature gen-commit sees pinned go.mod). Without --tag-next: land peels and legacy pinConsumersOfPeeled (latest tags). Preflight (cycle + flags) must already have passed; this mutates.

Ship tail (--push / --sync): after all peels, cascade, and deferred tags — when each touched main is final (no further commits in this session) — run once per main: optional final branch push, then optional linked-worktree sync. Peel-time sync/push are not used (mid-cascade C-PUSH1 tag publish for network pin stays).

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 FormatStderrError added in v0.0.17

func FormatStderrError(msg string) string

FormatStderrError colors a leading "Error:" prefix red when color is on. Prefer prefix-only coloring so the body stays plain.

func FormatStderrWarning added in v0.0.17

func FormatStderrWarning(msg string) string

FormatStderrWarning colors a leading "warning:" prefix yellow/orange when color is on.

func FormatUnwindDryRun added in v0.0.33

func FormatUnwindDryRun(plan *UnwindPlan, members []StackMember, workDir string, flags ...UnwindFlags) string

FormatUnwindDryRun returns the dry-run plan text (trailing newline). Peel lines use statusDirLine-style relative checkout paths vs workDir. When members is non-nil, gen-commit plans reflect --add-all and leave-N based on each peel checkout's porcelain (not flags alone).

With --tag-next, peel/cascade order matches B1 apply (splitPeelOrderB1): early free peels → global cascade tag/pin → deferred pure pin-consumer peels. Without --tag-next, peels print free-first only (no cascade).

Ship tail (--push / --sync): planned once after peels/cascade (not under each peel), matching applyUnwindShipTail — push then sync per touched main.

func FormatUnwindGraphHuman added in v0.0.52

func FormatUnwindGraphHuman(report *UnwindGraphReport, colorOn bool) string

FormatUnwindGraphHuman renders the human show-graph body (trailing newline). colorOn gates ANSI on stdout tokens (banners gray; dirty/replaced/drift orange; owned-changed/next green). Callers pass false for JSON / --no-color / non-TTY auto.

func FormatUnwindGraphJSON added in v0.0.52

func FormatUnwindGraphJSON(report *UnwindGraphReport) ([]byte, error)

FormatUnwindGraphJSON renders the show-graph report as pure JSON (trailing newline).

func FormatUnwindVerifyHuman added in v0.0.56

func FormatUnwindVerifyHuman(report *UnwindVerifyReport, colorOn bool) string

FormatUnwindVerifyHuman renders the human verify body (trailing newline). colorOn: green pass/result pass; red FAIL/result fail; gray banners.

func FormatUnwindVerifyJSON added in v0.0.56

func FormatUnwindVerifyJSON(report *UnwindVerifyReport) ([]byte, error)

FormatUnwindVerifyJSON renders pure JSON (trailing newline, no ANSI).

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 PeelOrder added in v0.0.33

func PeelOrder(pending []string, edges []RepoEdge) ([]string, error)

PeelOrder returns free-first (Kahn) peel order among pending labels. Edge From→To means From depends on To; free nodes have no deps to other pending.

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 RepoDAGHasCycle added in v0.0.33

func RepoDAGHasCycle(labels []string, edges []RepoEdge) bool

RepoDAGHasCycle reports whether the directed repo graph has a cycle.

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 RunWithOpts added in v0.0.34

func RunWithOpts(opts RunOpts) error

RunWithOpts is like Run but accepts optional in-process test/runtime opts (passed down the call stack; no env or package globals).

func RunWithWriters added in v0.0.25

func RunWithWriters(stdout, stderr io.Writer, opts CaptureOpts) error

RunWithWriters runs wrk in-process, writing primary output to the given writers (nil → discard). Env/Dir isolation matches Capture. Prefer Capture when you need the full CLI exit-code + formatted-stderr contract.

Note: non-ExitCodeError return values are not auto-printed to stderr (unlike Capture / main); callers that need main's formatting should use Capture.

func SetForceStderrColor added in v0.0.17

func SetForceStderrColor(v bool)

SetForceStderrColor records --color for top-level Error:/warning: printing.

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 ValidateUnwindFlags added in v0.0.33

func ValidateUnwindFlags(plan *UnwindPlan, flags UnwindFlags) error

ValidateUnwindFlags checks pin/land flags required by the plan.

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 CaptureOpts added in v0.0.25

type CaptureOpts struct {
	// Args are CLI args after the program name (same as wrkcli.Run).
	Args []string
	// Dir, when non-empty, is the virtual process cwd for the duration of the
	// call (via processCwd / captureDir under the capture mutex — no os.Chdir,
	// so parallel test Setup/git keep a valid real getcwd). Prefer absolute
	// paths. Omit when cwd is irrelevant (most short paths).
	Dir string
	// WrkHome, when non-empty, overrides WRK_HOME without os.Setenv (Parallel-safe).
	WrkHome string
	// Env are additional KEY=VAL entries. WRK_HOME and WRK_DATE are peeled into
	// capture overrides (no Setenv). Other keys still use temporary Setenv under
	// the capture mutex — avoid those when mixing with parallel Environ readers.
	Env []string
	// Stdin, when non-empty, replaces os.Stdin with a pipe containing this
	// data for the duration of the call (restored afterward). Use for
	// --confirm-from-stdin and similar non-TTY prompt paths. Empty leaves
	// the process stdin unchanged (typically not a pipe under go test).
	Stdin string
	// ScanTestPauseAfterFirstPrint is passed through to RunWithOpts (not env).
	// See RunOpts.ScanTestPauseAfterFirstPrint for docs and supporting tests.
	ScanTestPauseAfterFirstPrint time.Duration
	// WithGo is the injectable Go SDK resolver for dep-update versioned tidy.
	// Production leaves this zero; Capture tests set InstallDir + Download:false.
	WithGo withgo.ResolveOptions
}

CaptureOpts configures an in-process CLI invocation that mirrors main's stdout/stderr/exit-code contract without spawning the wrk binary.

type CaptureResult added in v0.0.25

type CaptureResult struct {
	Stdout   string
	Stderr   string
	ExitCode int
}

CaptureResult is the CLI-shaped outcome of Capture / RunWithWriters.

func Capture added in v0.0.25

func Capture(opts CaptureOpts) CaptureResult

Capture runs wrk in-process, capturing stdout and stderr like a subprocess. Errors are formatted onto stderr the same way as cmd/wrk main (except ExitCodeError, which stays silent and only sets ExitCode).

Capture holds an internal mutex for the duration of the call (stdout/stderr swap, optional virtual cwd). Prefer for short paths (help, skill, version, flag reject) and dual-mode InProcess leaves.

func RunCapture added in v0.0.25

func RunCapture(args ...string) CaptureResult

RunCapture is a convenience wrapper: Capture with only Args set.

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 DepUpdateAllAction added in v0.0.64

type DepUpdateAllAction struct {
	ConsumerModDir string
	ConsumerPath   string
	CheckoutPath   string // stack member Path containing the consumer
	DepModule      string
	DepDir         string // owner module dir on registered main path
	OldVersion     string
	NewVersion     string
	Tag            string
}

DepUpdateAllAction is one planned pin under --dep-update --all.

type DepUpdateAllPlan added in v0.0.64

type DepUpdateAllPlan struct {
	Actions   []DepUpdateAllAction
	Already   int
	Skipped   int
	Warnings  []string // may include warning: prefix
	Checkouts int      // stack member count (used when there are no pin actions)
}

DepUpdateAllPlan is the pure plan for wrk --dep-update --all.

func PlanDepUpdateAll added in v0.0.64

func PlanDepUpdateAll(workDir, wrkHome string) (*DepUpdateAllPlan, error)

PlanDepUpdateAll builds pin actions for inventory-owned requires on the unwind stack (CollectStackInventory). External (non-inventory) requires are silent. Same-checkout local filesystem replaces and no-tag owners count as skipped. --all still requires a git repo.

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
	Diagnostics []ReinstallDiagnostic // sorted by BinName, then Kind
}

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.

Merge rules (per BinName):

  • Collect all cmd and script package-main paths keyed by BinName.
  • If a tree has multiple paths for the same BinName, emit an ambiguous-* warning and that tree contributes nothing for the name.
  • Unique cmd + unique script → script item + prefer-script notice.
  • Unique on one side only → that side; ambiguous other side keeps its warning.
  • Ambiguous alone / both ambiguous → omit bin from Items (not a skip row).

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
	Diagnostics []ReinstallDiagnostic // per-module; sorted by BinName, then Kind
}

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 PinLocalsAction added in v0.0.53

type PinLocalsAction struct {
	ConsumerModDir string
	ConsumerPath   string
	DepPath        string
	DepModDir      string
	RelPath        string // ./ or ../ slash form
	Kind           string // add | rewrite | already
}

PinLocalsAction is one planned relative replace for a consumer→dep edge.

type PinLocalsPlan added in v0.0.53

type PinLocalsPlan struct {
	Actions  []PinLocalsAction
	Warnings []string // soft multi-owner etc. (may include warning: prefix)
}

PinLocalsPlan is the pure plan for wrk --pin-locals.

func PlanPinLocals added in v0.0.53

func PlanPinLocals(workDir string) (*PinLocalsPlan, error)

PlanPinLocals builds relative-replace actions from the unwind stack inventory. Inventory = CollectStackInventory only (no WRK_HOME project universe). Wanted set per consumer = require paths ∪ replace OldPaths that have a stack owner.

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 ReinstallDiagnostic added in v0.0.8

type ReinstallDiagnostic struct {
	Level   string // "notice" | "warning"
	Kind    string // "prefer-script" | "ambiguous-cmd" | "ambiguous-script"
	BinName string
	Paths   []string // sorted ./ relative paths involved
}

ReinstallDiagnostic is a non-fatal notice or warning produced while merging cmd/ and script/ candidates for the same BinName.

type ReinstallExecStats added in v0.0.53

type ReinstallExecStats struct {
	Reinstalled int
	Skipped     int
	Failed      int
}

ReinstallExecStats counts execute-path outcomes for --reinstall-local.

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 RepoEdge added in v0.0.33

type RepoEdge struct {
	From string // consumer label
	To   string // dependency label
}

RepoEdge is a depends-on edge in the stack repo DAG: From depends on To (module require/replace contracted to main-repo labels).

func BuildRepoDAG added in v0.0.33

func BuildRepoDAG(members []StackMember) ([]RepoEdge, error)

BuildRepoDAG contracts module require/replace edges among stack-owned modules into a repo-level DAG keyed by peel labels. Edge From→To means From depends on To.

type RequireEntry added in v0.0.6

type RequireEntry struct {
	Path    string
	Version string
}

RequireEntry is a single require directive from go.mod.

type RunOpts added in v0.0.34

type RunOpts struct {
	// Args are CLI args after the program name (same as Run).
	Args []string

	// ScanTestPauseAfterFirstPrint, when > 0, pauses after the first path
	// printed by --scan-git-repos so mid-scan interrupt tests can cancel
	// while the walk is still open. Production leaves this zero.
	//
	// Supporting tests:
	//   - cmd/wrk/tests/scan-git-repos/interrupt/sigint-after-first-path
	//   - (other leaves under scan-git-repos/interrupt/ if added)
	ScanTestPauseAfterFirstPrint time.Duration

	// WithGo is the injectable Go SDK resolver for dep-update versioned tidy.
	// Zero value: production defaults (userHomeDir()/installed, Download:true).
	WithGo withgo.ResolveOptions
}

RunOpts configures an in-process wrk invocation. CLI main uses Run (zero opts).

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 StackInventory added in v0.0.49

type StackInventory struct {
	Members        []StackMember
	SyntheticEdges []RepoEdge // C→D when follow maps consumer C into dep checkout D
	Warnings       []string   // warning: lines (missing/non-git replaces; skipped broken nested checkouts)
}

StackInventory is the expanded checkout stack for --unwind, including synthetic follow edges and soft warnings from local filesystem replaces.

func CollectStackInventory added in v0.0.49

func CollectStackInventory(workDir string) (StackInventory, error)

CollectStackInventory is BuildStackInventory plus synthetic follow edges and soft warnings from missing/non-git local replace targets.

type StackMember added in v0.0.33

type StackMember struct {
	// Path is the checkout toplevel path (linked worktree or main).
	Path string
	// MainRepo is the main repository directory for this checkout.
	MainRepo string
	// Label is filepath.Base(MainRepo) — DAG/pin short name (not peel display path).
	Label string
	// Dirty is true when porcelain status is non-empty (untracked counts).
	Dirty bool
	// Linked is true when Path is a linked worktree (not the main checkout).
	Linked bool
}

StackMember is one git checkout in the consumer stack (primary or nested external).

func BuildStackInventory added in v0.0.33

func BuildStackInventory(workDir string) ([]StackMember, error)

BuildStackInventory discovers the checkout stack under workDir: primary git toplevel plus nested independent repos (status-like scan), expanded via local filesystem replace BFS, with dirtiness and stable main-repo labels.

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 SyncResult added in v0.0.53

type SyncResult struct {
	IntoMain int
	IntoWT   int
	Skipped  int
}

SyncResult is the outcome of one runSync / runSyncOpts pass.

type UnwindApplyStats added in v0.0.53

type UnwindApplyStats struct {
	HadPeels    bool // true when PeelOrder was non-empty
	Peeled      int
	Tagged      int
	Pinned      int
	Pushed      int
	Reinstalled int
}

UnwindApplyStats counts successful apply stages for the end summary line.

type UnwindCascadePlan added in v0.0.52

type UnwindCascadePlan struct {
	Steps []UnwindCascadeStep
}

UnwindCascadePlan is the free-first module cascade over the stack module DAG.

func PlanUnwindCascade added in v0.0.52

func PlanUnwindCascade(members []StackMember) (*UnwindCascadePlan, error)

PlanUnwindCascade builds a free-first module cascade from stack inventory: owned-changed modules (tagscope next tags) plus consumers that need pin / require-drift. Testdata / forever-skip scopes never emit tag-next steps. Does not mutate the workspace.

func PlanUnwindCascadeCached added in v0.0.60

func PlanUnwindCascadeCached(members []StackMember, tagCache tagScopePlanCache) (*UnwindCascadePlan, error)

PlanUnwindCascadeCached is PlanUnwindCascade with an optional tagscope cache shared across one ApplyUnwind (pinReady + cascade + split peels).

type UnwindCascadeStep added in v0.0.52

type UnwindCascadeStep struct {
	Kind UnwindCascadeStepKind
	// ModulePath is the tagged module (tag-next) or consumer module (pin).
	ModulePath string
	// DepModulePath is set for pin steps (dependency module path).
	DepModulePath string
	// TagOrVersion is the full next tag for tag-next, or go require version for pin.
	TagOrVersion string
}

UnwindCascadeStep is one dry-run cascade action (tag-next or pin).

type UnwindCascadeStepKind added in v0.0.52

type UnwindCascadeStepKind string

UnwindCascadeStepKind is a free-module cascade plan step kind.

const (
	// CascadeTagNext plans a tagscope next release for a free/pending module.
	CascadeTagNext UnwindCascadeStepKind = "tag-next"
	// CascadePin plans pinning a consumer module require onto a dep version.
	CascadePin UnwindCascadeStepKind = "pin"
)

type UnwindFlags added in v0.0.33

type UnwindFlags struct {
	DryRun         bool
	TagNext        bool
	Push           bool
	Force          bool // with Push: force-with-lease branch push
	Done           bool
	MergeBack      bool
	ReinstallLocal bool
	Color          bool
	NoColor        bool // --no-color: force plain stdout (mutually exclusive with Color)
	Sync           bool
	GenCommitMsg   bool
	GenCommitArgs  []string
	// AddAll stages all changes when cascade pin commits (and gen-commit when set).
	// Top-level --add-all is accepted with --unwind without requiring --commit.
	AddAll bool
	// ShowGraph is the read-only inspect path (--unwind --show-graph).
	ShowGraph bool
	// Verify is the read-only post-job audit path (--unwind --verify).
	Verify bool
	// JSON requests machine-readable show-graph / verify output.
	JSON bool
}

UnwindFlags are ship/land modifiers composed with --unwind.

type UnwindGraphModuleEdge added in v0.0.52

type UnwindGraphModuleEdge struct {
	From    string `json:"from"`
	To      string `json:"to"`
	Kind    string `json:"kind"` // require | replace
	Version string `json:"version,omitempty"`
	NewPath string `json:"new_path,omitempty"`
}

UnwindGraphModuleEdge is a require or replace edge among stack-owned modules.

type UnwindGraphModuleNode added in v0.0.52

type UnwindGraphModuleNode struct {
	Path         string `json:"path"`
	Dir          string `json:"dir"`
	RepoLabel    string `json:"repo_label"`
	LatestTag    string `json:"latest_tag,omitempty"`
	NextTag      string `json:"next_tag,omitempty"`
	OwnedChanged bool   `json:"owned_changed,omitempty"`
	SkipReason   string `json:"skip_reason,omitempty"`
}

UnwindGraphModuleNode is one go.mod under the unwind stack.

type UnwindGraphModules added in v0.0.52

type UnwindGraphModules struct {
	Nodes []UnwindGraphModuleNode
	Edges []UnwindGraphModuleEdge
}

UnwindGraphModules is the full-stack module layer.

type UnwindGraphRepoNode added in v0.0.52

type UnwindGraphRepoNode struct {
	Display   string `json:"display"`
	Label     string `json:"label"`
	Linked    bool   `json:"linked"`
	Dirty     bool   `json:"dirty"`
	Branch    string `json:"branch,omitempty"`
	HeadShort string `json:"head_short,omitempty"`
	PeelIndex int    `json:"peel_index,omitempty"` // 1-based; 0 = not in peel
	Land      bool   `json:"land,omitempty"`
}

UnwindGraphRepoNode is one stack checkout in the repo graph.

type UnwindGraphReport added in v0.0.52

type UnwindGraphReport struct {
	WorkDir  string
	Repos    UnwindGraphRepos
	Modules  UnwindGraphModules
	Summary  UnwindGraphSummary
	Warnings []string
}

UnwindGraphReport is the read-only unwind stack graph (repo + module + summary).

func BuildUnwindGraphReport added in v0.0.52

func BuildUnwindGraphReport(workDir string) (*UnwindGraphReport, error)

BuildUnwindGraphReport collects inventory, repo DAG, peel plan, module graph, and tagscope status for a read-only show-graph inspect. Does not mutate.

type UnwindGraphRepos added in v0.0.52

type UnwindGraphRepos struct {
	Nodes           []UnwindGraphRepoNode
	Edges           []RepoEdge
	PeelOrder       []string // display paths, free-first
	HasPendingEdges bool
	NeedsLand       bool
}

UnwindGraphRepos is the stack-repo layer of the show-graph report.

type UnwindGraphSummary added in v0.0.52

type UnwindGraphSummary struct {
	Repos       int    `json:"repos"`
	DirtyRepos  int    `json:"dirty_repos"`
	Modules     int    `json:"modules"`
	RepoEdges   int    `json:"repo_edges"`
	ModuleEdges int    `json:"module_edges"`
	PeelSteps   int    `json:"peel_steps"`
	Cycle       string `json:"cycle"`
	ApplyHint   string `json:"apply_hint,omitempty"`
}

UnwindGraphSummary aggregates counts and an optional apply hint.

type UnwindPlan added in v0.0.33

type UnwindPlan struct {
	PeelOrder []string // labels, free-first
	// HasPendingEdges is true when residual pending graph has any edge.
	HasPendingEdges bool
	// NeedsLand is true when any pending member is a linked worktree.
	NeedsLand bool
}

UnwindPlan is the free-first peel plan for dirty pending stack members.

func PlanUnwind added in v0.0.33

func PlanUnwind(members []StackMember, edges []RepoEdge) (*UnwindPlan, error)

PlanUnwind builds the free-first peel plan for dirty stack members. Cycle detection uses the full stack-repo DAG (not only dirty pending).

type UnwindVerifyCheck added in v0.0.56

type UnwindVerifyCheck struct {
	ID       string   `json:"id"`
	Severity string   `json:"severity"`
	Status   string   `json:"status"` // pass | fail
	Count    *int     `json:"count,omitempty"`
	Details  []string `json:"details,omitempty"`
}

UnwindVerifyCheck is one catalog audit line.

type UnwindVerifyReport added in v0.0.56

type UnwindVerifyReport struct {
	WorkDir  string              `json:"work_dir"`
	Checks   []UnwindVerifyCheck `json:"checks"`
	Summary  UnwindVerifySummary `json:"summary"`
	Warnings []string            `json:"warnings"`
}

UnwindVerifyReport is the read-only post-job audit for --unwind --verify.

func BuildUnwindVerifyReport added in v0.0.56

func BuildUnwindVerifyReport(workDir string) (*UnwindVerifyReport, error)

BuildUnwindVerifyReport collects inventory, peel plan, module graph, cascade plan, and materializes the six error-severity checks. Does not mutate.

type UnwindVerifySummary added in v0.0.56

type UnwindVerifySummary struct {
	Checks int    `json:"checks"`
	Pass   int    `json:"pass"`
	Fail   int    `json:"fail"`
	Warn   int    `json:"warn"`
	Result string `json:"result"` // pass | fail
}

UnwindVerifySummary aggregates check outcomes.

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 teapre must be imported before bubbletea so OSC background probes do not hang on PTYs that never answer (tty-watch, some CI harnesses).
Package teapre must be imported before bubbletea so OSC background probes do not hang on PTYs that never answer (tty-watch, some CI harnesses).
Package tui implements the interactive Bubble Tea dashboard for bare `wrk`.
Package tui implements the interactive Bubble Tea dashboard for bare `wrk`.
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