clispec

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package clispec is the single declarative source of awf's CLI command set: every command's flags, positional bounds, gating, help text, and (for a group command) its subcommands. cmd/awf builds its runtime dispatcher by attaching handler funcs to these specs; internal/project reads the gated set to generate docs. Data only — no handler funcs and no import of cmd/awf or internal/project, so it stays an importable leaf.

Index

Constants

This section is empty.

Variables

View Source
var Commands = []Command{
	{
		Name: "init", Summary: "Scaffold .awf/ and render the workflow-core set",
		BoolFlags: []string{"--force", "--describe"}, ValueFlags: []string{"--set", "--answers"},
		Repeatable: []string{"--set"}, MaxPos: 0, Gating: Ungated,
		HelpBody: `Usage: awf init [flags]

Scaffold a .awf/ config tree and render the workflow-core set into the project.

Flags:
  --force        overwrite colliding files, backing each up to <path>.awf-bak
  --describe     print the fillable value descriptors as JSON and exit
  --set k=v      set a value non-interactively (repeatable)
  --answers FILE read values from a JSON/YAML answers file: a flat key→value map
                 of descriptor keys (see --describe); multiselect answers
                 (skills, docs) are comma-joined name lists
`,
	},
	{
		Name: "sync", Summary: "Re-render after a template or config change",
		MaxPos: 0, Gating: Gated,
		HelpBody: `Usage: awf sync

Re-render every enabled target after a template or config change and update .awf/awf.lock.
`,
	},
	{
		Name: "check", Summary: "Fail on stale or hand-edited rendered output",
		MaxPos: 0, Gating: Gated,
		HelpBody: `Usage: awf check

Re-render in memory and fail if any rendered file is stale or hand-edited (drift).
`,
	},
	{
		Name: "invariants", Summary: "Report Implemented-ADR invariant slugs lacking a backing comment",
		MaxPos: 0, Gating: Gated,
		HelpBody: `Usage: awf invariants

Report each Implemented-ADR ` + "`inv:`" + ` slug lacking a backing ` + "`<marker> invariant:`" + ` comment.
`,
	},
	{
		Name: "audit", Summary: "Report workflow-conformance findings over the branch (advisory)",
		ValueFlags: []string{"--base"}, MaxPos: 0, Gating: Gated,
		HelpBody: `Usage: awf audit [--base <ref>]

Report advisory workflow-conformance findings over the branch's commits; never gates.

Flags:
  --base <ref>   compare against <ref> instead of the configured base branch
`,
	},
	{
		Name: "commit-gate", Summary: "Validate one commit message (Conventional Commits), blocking",
		MaxPos: 1, Gating: Ungated,
		HelpBody: `Usage: awf commit-gate [FILE]

Validate one commit message against the Conventional Commits rules (type, scope,
72-char subject) and exit non-zero on a violation — the commit-side analog of the
gate. Reads FILE (the path a commit-msg hook passes as $1) or stdin; cleans the
message git-style and exempts merge/autosquash subjects. awf installs no hook —
wire this into your own commit-msg hook (the rendered .awf/hooks/commit-msg.sh
payload runs it when the hooks artifact is enabled).
`,
	},
	{
		Name: "list", Summary: "Show targets and their per-project state (all kinds, or one)",
		MaxPos: 1, Gating: Gated,
		HelpBody: `Usage: awf list [<kind>]

Show targets and their per-project enabled state, for all kinds or one (skill|agent|doc|domain|target|bootstrap|hooks).
`,
	},
	{
		Name: "config", Summary: "Describe config keys and vars (live state inside a project)",
		MaxPos: 1, Gating: GatedInHandler,
		HelpBody: `Usage: awf config [<key-or-var>]

Print the configuration reference: every config key, var, sidecar field, and
data key with descriptions, defaults, and availability. Inside an awf project
the output adds live state (current values; which enabled artifacts consume
each var; dormant hints). Outside one, a static catalog-wide reference prints.
With an argument, print just that entry (a config key path like
audit.diffThreshold, a var name like gateCmd, a sidecar field like
sidecar.local, or a data key name).
`,
	},
	{
		Name: "context", Summary: "Report owning domains, invariants, and ADRs for paths",
		BoolFlags: []string{"--json", "--staged"}, ValueFlags: []string{"--range"}, MaxPos: -1, Gating: GatedInHandler,
		HelpBody: `Usage: awf context <path>... [--json] [--staged] [--range <a>..<b>]

Report the committed context awf holds for a set of repo-relative paths: owning
domain(s), the invariant slugs backed under those paths, related ADRs, and each
domain's current-state doc. Read-only. Inside an awf project the output reflects
live config; outside one, a static pre-adoption notice prints.

Provide paths explicitly, or resolve them from git with --staged (the staged
changes) or --range <a>..<b> (the diff between two revisions). Explicit paths
take precedence over the git selectors.

Flags:
  --json               emit the context as JSON
  --staged             use the staged changed paths
  --range <a>..<b>     use the paths changed between revisions a and b
`,
	},
	{
		Name: "new", Summary: "Scaffold a new artifact — kind ∈ {adr, skill, agent, doc}",
		MaxPos: -1, Gating: GatedInHandler,
		HelpBody: `Usage: awf new <kind> <args>

Scaffold a new artifact. <kind> is adr, skill, agent, or doc.

- awf new adr "Some Decision Title"
- awf new skill <name> "<description>"   (a project-local skill)
- awf new agent <name> "<description>"   (a project-local agent)
- awf new doc <name> "<description>"     (a project-local doc; name may be nested, e.g. guides/ci)
`,
		Children: []Command{
			{
				Name: "adr", Summary: "Scaffold a new ADR", MinPos: 0, MaxPos: -1,
				HelpBody: `Usage: awf new adr <title>

Scaffold a new ADR under docs/decisions with the next sequential number, from
the rendered template with its date and title heading filled in.
`,
			},
			{
				Name: "skill", Summary: "Scaffold a project-local skill", MinPos: 0, MaxPos: -1,
				HelpBody: `Usage: awf new skill <name> "<description>"

Scaffold a project-local skill: a declaring sidecar carrying the description, a
starter content part, the enable, and a re-render.
`,
			},
			{
				Name: "agent", Summary: "Scaffold a project-local agent", MinPos: 0, MaxPos: -1,
				HelpBody: `Usage: awf new agent <name> "<description>"

Scaffold a project-local agent: a declaring sidecar carrying the description, a
starter content part, the enable, and a re-render.
`,
			},
			{
				Name: "doc", Summary: "Scaffold a project-local doc", MinPos: 0, MaxPos: -1,
				HelpBody: `Usage: awf new doc <name> "<description>"

Scaffold a project-local doc; the name may be nested, e.g. guides/ci. Writes a
declaring sidecar with a derived title and the description, a starter content
part, the enable, and a re-render.
`,
			},
		},
	},
	{
		Name: "enable", Summary: "Enable an artifact — kind ∈ {skill, agent, doc, domain, target, bootstrap, hooks}",
		BoolFlags: []string{"--dry-run"}, MaxPos: -1, Gating: Gated,
		HelpBody: `Usage: awf enable <kind> <name> [--dry-run]

Enable an artifact in this project. <kind> is skill, agent, doc, domain, target,
bootstrap, or hooks. For skill/agent/doc, the full requirement closure is enabled
in one edit, printed as a plan (ADR-0081).

Flags:
  --dry-run    print the closure plan without changing the config
`,
	},
	{
		Name: "disable", Summary: "Disable an artifact (a catalog skill/agent/doc, a freeform domain, or a target)",
		BoolFlags: []string{"--with-dependents", "--dry-run"}, MaxPos: -1, Gating: Gated,
		HelpBody: `Usage: awf disable <kind> <name> [--with-dependents] [--dry-run]

Disable an artifact — a catalog skill/agent/doc, a freeform domain, an adapter target, the bootstrap, or the hooks.
For skill/agent/doc, disabling refuses while enabled artifacts still require
<name>, printing the dependent plan (ADR-0081).

Flags:
  --with-dependents    also disable every enabled artifact that transitively requires <name>
  --dry-run            print the plan without changing the config
`,
	},
	{
		Name: "upgrade", Summary: "Migrate the .awf/ config tree to the current schema",
		MaxPos: 0, Gating: Ungated,
		HelpBody: `Usage: awf upgrade

Migrate the .awf/ config tree to the current schema version.
`,
	},
	{
		Name: "uninstall", Summary: "Remove awf's generated files (keeps .awf/)",
		MaxPos: 0, Gating: Ungated,
		HelpBody: `Usage: awf uninstall

Remove every awf-generated file recorded in the lock (keeps your authored .awf/ config).
`,
	},
	{
		Name: "changelog", Summary: "Print the embedded changelog, or one version/range of it",
		ValueFlags: []string{"--version", "--since", "--range"}, MaxPos: 0, Gating: Ungated,
		HelpBody: `Usage: awf changelog [--version <v> | --since <v> | --range <from>..<to>]

Print the embedded awf changelog. With no flags, print the whole file. The three
flags are mutually exclusive.

Flags:
  --version <v>          print only version v's entry
  --since <v>            print every version released after v (exclusive)
  --range <from>..<to>   print every version in [from, to] (inclusive both ends)
`,
	},
	{
		Name: "version", Summary: "Print the awf version",
		MaxPos: 0, Gating: Ungated,
		HelpBody: `Usage: awf version

Print the awf version.
`,
	},
}

Commands is the ordered command table — the sole source of the command set, `awf help` order, the usage line, and the gated-command list. invariant: cli-command-spec-single-source

Functions

func GatedCommandNames

func GatedCommandNames() []string

GatedCommandNames returns, in table order, every top-level command that runs the binary-version gate — the driver-gated commands plus the ones that gate in-handler (config/context after their static fallback, new after name validation). Ungated commands are excluded; a group contributes only its own token. This is the single source of the doc-published gated-command list.

func Names

func Names() []string

Names returns every top-level command name in table order.

func UsageLine

func UsageLine() string

UsageLine renders the `awf <a|b|...>` usage token list from the table.

Types

type Command

type Command struct {
	Name       string
	Summary    string // one-line, for `awf help`
	HelpBody   string // full `awf <cmd> --help` text
	BoolFlags  []string
	ValueFlags []string // includes repeatables
	Repeatable []string // subset of ValueFlags collected into invocation.Multi
	MinPos     int
	MaxPos     int
	Gating     Gating
	Children   []Command
}

Command is one CLI command (or subcommand). A command with Children is a group: the driver dispatches on the next positional to a child; a leaf carries no Children and is run by its attached handler. MaxPos < 0 means unbounded.

func Lookup

func Lookup(name string) (Command, bool)

Lookup returns the top-level command named name.

func (Command) Child

func (c Command) Child(name string) (Command, bool)

Child returns c's subcommand named name (for a group command like new).

type Gating

type Gating int

Gating classifies when a command runs the binary-version gate (ADR-0094 Decision 3).

const (
	Ungated        Gating = iota // never gates (version, changelog, upgrade, uninstall, commit-gate, init)
	Gated                        // the driver gates before the handler
	GatedInHandler               // the handler gates itself (config/context after their static-fallback check; new after name validation)
)

Jump to

Keyboard shortcuts

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