Documentation
¶
Index ¶
- Constants
- func Complete(wrkHome string, req CompletionRequest) []string
- func FormatCompareBranches(refA, refB string, result *git.CompareBranchesResult) string
- func FormatMasterBrief(result *git.CompareBranchesResult, colorEnabled bool) string
- func FormatRemoteBrief(result *git.CompareBranchesResult, colorEnabled bool) string
- func FormatStderrError(msg string) string
- func FormatStderrWarning(msg string) string
- func IsWipSubject(subject string) bool
- func NormalizeTaskSlug(taskDesc string) (string, error)
- func RegisterWebServe(fn webServeFunc)
- func ResolveReinstallScanRoot(workDir string, useMain bool) (string, error)
- func ResolveWrkHome(wrkHome string) (string, error)
- func Run(args []string) error
- func RunWithOpts(opts RunOpts) error
- func RunWithWriters(stdout, stderr io.Writer, opts CaptureOpts) error
- func SetForceStderrColor(v bool)
- func ShellSafeQuote(s string) string
- func Version() string
- type Action
- type CaptureOpts
- type CaptureResult
- type CompletionRequest
- type Config
- type CreateAgent
- type CreateSection
- type CreateTerminal
- type CreateWindow
- type CreateWorktreeResult
- type DepUpdateAllAction
- type DepUpdateAllPlan
- type DirHintOptions
- type Edge
- type ExitCodeError
- type Inventory
- type LocalReinstallPlan
- type Method
- type ModuleEntry
- type ModuleReinstallPlan
- type MultiLocalReinstallPlan
- type PinLocalsAction
- type PinLocalsPlan
- type PlanItem
- type ProjectEntry
- type ReinstallDiagnostic
- type ReinstallExecStats
- type ReplaceEntry
- type RequireEntry
- type RunOpts
- type SourceRelease
- type SourceReleasesResult
- type StatusPathLists
- type SyncResult
- type WebServeOptions
Constants ¶
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 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
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
FormatStderrWarning colors a leading "warning:" prefix yellow/orange when color is on.
func IsWipSubject ¶ added in v0.0.2
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 ¶
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
ResolveReinstallScanRoot returns the absolute directory from which Go module discovery should begin for multi-module local reinstall planning.
Rules (priority):
- useMain == true: workDir must be inside a git checkout; scan root is the main repository path (ResolveMainRepo of ShowToplevel).
- useMain == false and inside git: scan root is ShowToplevel(workDir).
- Not in git: walk up from workDir looking for a go.mod; first hit is root.
- No scan root: not in git and no go.mod on the walk-up → error.
func ResolveWrkHome ¶
ResolveWrkHome returns wrkHome when non-empty; otherwise WRK_HOME or ~/.wrk.
func Run ¶
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
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 ¶
ShellSafeQuote encodes s as a single POSIX shell word using single quotes. Empty string becomes ”; embedded single quotes use the '\” join form.
Types ¶
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
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 ¶
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 ¶
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 ¶
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
BuildInventory loads WRK_HOME projects, soft-skips missing paths, scans modules, and builds ownership.
func (Inventory) CrossEdges ¶ added in v0.0.6
CrossEdges returns require edges where consumer and owner projects both known and differ.
func (Inventory) FindOwner ¶ added in v0.0.6
FindOwner returns the registered project path that owns modulePath.
func (Inventory) IntraEdges ¶ added in v0.0.6
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
ReinstallExecStats counts execute-path outcomes for --reinstall-local.
type ReplaceEntry ¶ added in v0.0.6
ReplaceEntry is a single replace directive from go.mod.
type RequireEntry ¶ added in v0.0.6
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 StatusPathLists ¶ added in v0.0.5
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
SyncResult is the outcome of one runSync / runSyncOpts pass.
type WebServeOptions ¶
WebServeOptions configures the local web UI started by `wrk --web`.
Source Files
¶
- basename.go
- bashintegration.go
- cd.go
- color.go
- commit_manual.go
- compare_format.go
- config.go
- create_api.go
- create_ux.go
- dashboard.go
- dashboard_pipeline.go
- dashboard_preview.go
- dashboard_tui.go
- dep_ops.go
- dep_update_all.go
- exec_cmd.go
- followup.go
- gen_commit_msg.go
- gitexec.go
- invocation.go
- main.go
- name_budget.go
- pin_locals.go
- plan_local_reinstall.go
- pr.go
- projects_dep_graph.go
- projects_gather.go
- projects_github.go
- projects_inventory.go
- projects_perf.go
- propagate_tags.go
- push_main.go
- push_same_name.go
- run.go
- run_capture.go
- set_config.go
- set_task_replace.go
- shared_branch.go
- shell_safe.go
- skill.go
- status.go
- status_partition.go
- sync.go
- tag_next.go
- task_like.go
- unwind_host.go
- version.go
- web_serve.go
- where.go
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. |