cli

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: GPL-3.0 Imports: 56 Imported by: 0

Documentation

Overview

Package cli implements leather's command dispatch and serve loop.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDevtoolsHandler

func NewDevtoolsHandler(deps DevtoolsHandlerDeps) http.Handler

NewDevtoolsHandler builds all /api/devtools routes.

func ResolveBuildVersion added in v0.5.0

func ResolveBuildVersion(version, commit string) (string, string)

ResolveBuildVersion fills in version/commit from the embedded Go build info when the Makefile's -ldflags stamps are absent — i.e. for binaries built by plain `go install module@tag`, which previously self-identified as "dev (none)" (issues #49/#50). The module version covers @tag installs; vcs.revision covers plain `go build` from a git checkout.

func Run

func Run(args []string, stdout, stderr io.Writer, version, commit string) int

Run is leather's main entry point. It parses the first argument as a subcommand and dispatches to the appropriate handler, returning an exit code. version and commit are set by -ldflags at build time.

func RunAttach

func RunAttach(args []string, stdout, stderr io.Writer) int

RunAttach connects to a running serve instance and streams pretty-printed DevTools events to stdout.

func RunCompletion

func RunCompletion(args []string, stdout, stderr io.Writer) int

RunCompletion prints a shell completion script for the requested shell to stdout. Usage: leather completion <bash|zsh|fish>

The scripts below are static and hand-maintained: they mirror the subcommand table in cli.go's Run dispatcher and the flag registrations in each cmd_*.go file. Update them alongside those when commands or flags change, the same way the `usage` string in help.go is kept in sync.

func RunDLQ

func RunDLQ(args []string, stdout, stderr io.Writer) int

RunDLQ is the entry point for the "leather dlq" sub-command. It dispatches to inspect or requeue based on the first positional argument.

func RunDoctor

func RunDoctor(args []string, stdout, stderr io.Writer) int

RunDoctor prints the effective configuration with source attribution and redacts secret-bearing values.

Usage: leather doctor [flags]

func RunIngest

func RunIngest(args []string, stdout, stderr io.Writer) int

RunIngest implements the "leather ingest" subcommand. Returns exit code: 0 success, 1 error, 2 usage error.

func RunInit

func RunInit(args []string, stdout, stderr io.Writer) int

RunInit scaffolds a new leather project directory with a config, example agent, and Makefile. Fails closed on existing files unless --overwrite is set.

Usage: leather init [--dir <path>] [--overwrite]

func RunOnce

func RunOnce(args []string, stdout, stderr io.Writer) int

RunOnce loads and executes a single agent definition, then exits. Usage: leather run [flags] <path-to-agent.agent.md>

func RunReplay

func RunReplay(args []string, stdout, stderr io.Writer, version, commit string) int

RunReplay implements `leather replay <file> [serve flags...]` as a thin wrapper around `leather serve --replay <file> --api`. The replay subsystem runs inside the serve loop; exposing a top-level `replay` subcommand makes the entry point discoverable (T6.8).

Usage:

leather replay <snapshot.json> [--addr 127.0.0.1:7749] [other serve flags]
leather replay --live <dir>     [other serve flags]

func RunServe

func RunServe(args []string, stdout, stderr io.Writer, version, commit string) int

RunServe starts the leather scheduler loop and blocks until signalled. It exits cleanly on SIGINT or SIGTERM, draining in-flight jobs first.

func RunSnapshot

func RunSnapshot(args []string, stdout, stderr io.Writer) int

RunSnapshot dispatches to save or restore sub-subcommands.

func RunSnapshotRestore

func RunSnapshotRestore(args []string, stdout, stderr io.Writer) int

RunSnapshotRestore extracts a snapshot archive into the configured state directory.

Usage: leather snapshot restore --input <path> [--force]

func RunSnapshotSave

func RunSnapshotSave(args []string, stdout, stderr io.Writer) int

RunSnapshotSave creates a point-in-time tar.gz archive of runtime state.

Usage: leather snapshot save [--output <path>]

func RunStatus

func RunStatus(args []string, stdout, stderr io.Writer) int

RunStatus prints scheduler state and token budget information.

func RunTestAgent

func RunTestAgent(args []string, stdout, stderr io.Writer) int

RunTestAgent implements the "leather test-agent" subcommand. It loads an agent definition, runs it using a MockLLM (no real LLM calls), prints the turn transcript, and exits 0 on success, 1 on error, 2 on usage error.

Usage: leather test-agent <agent-file> [flags]

--lifecycle <file>            apply a *.lifecycle.yaml before running
--mock-response <text>        LLM response text (default: "mock response")
--tool-response <name>=<text> tool name to response text (repeatable, reserved for future use)
--max-tokens <n>              token budget (default 8192)

func RunValidate

func RunValidate(args []string, stdout, stderr io.Writer) int

RunValidate parses and validates all agent, skill, and worker definition files. Exits 0 if all files are valid, 1 if any have errors, 2 on usage errors.

Output format:

ok:     <name>  (<path>)           — file parsed and schema-clean
error:  <file>: <message>          — parse or semantic error
schema: <file>:  field "<name>": <msg>  — schema violation

func RunVersion

func RunVersion(_ []string, stdout, _ io.Writer, version, commit string) int

RunVersion prints build version and platform information to stdout.

func RunWorkflow

func RunWorkflow(args []string, stdout, stderr io.Writer) int

RunWorkflow implements the "leather workflow" subcommand dispatcher.

func RunWorkflowRun

func RunWorkflowRun(args []string, stdout, stderr io.Writer) int

RunWorkflowRun implements "leather workflow run". Returns exit code: 0 success, 1 error, 2 usage error.

Types

type DevtoolsHandlerDeps

type DevtoolsHandlerDeps struct {
	Bus          *bus.Bus
	Causality    *causality.Engine
	QueueMgr     *queue.Manager
	GetWorkerSup func() *worker.Supervisor
	StartedAt    time.Time
	Version      string
	Commit       string
}

DevtoolsHandlerDeps provides data dependencies for DevTools handlers.

Jump to

Keyboard shortcuts

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