#compdef discipline

autoload -U is-at-least

_discipline() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_discipline_commands" \
"*::: :->discipline" \
&& ret=0
    case $state in
    (discipline)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-command-$line[1]:"
        case $line[1] in
            (check)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config=[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config-override=[Inline TOML merged over the file (tables merge, lists append, scalars replace)]:CONFIG_OVERRIDE:_default' \
'*--enable=[Gate ids to force on (comma separated)]:ENABLE:_default' \
'*--disable=[Gate ids to force off (comma separated)]:DISABLE:_default' \
'-s+[Which check suite to run]:SUITE:(all agent-guard hygiene integrity quality verification bench)' \
'--suite=[Which check suite to run]:SUITE:(all agent-guard hygiene integrity quality verification bench)' \
'-b+[Base branch or commit to measure the change against (auto-detected in CI if omitted)]:BASE:_default' \
'--base=[Base branch or commit to measure the change against (auto-detected in CI if omitted)]:BASE:_default' \
'(--commit-range --staged)--commit=[Specific commit to inspect, against its parent <sha>~1; it must be the commit checked out (exit 2 otherwise)]:COMMIT:_default' \
'(--commit --staged)--commit-range=[Commit range to inspect (<before>..<after> or <before>...<after>); <after>, when given, must be the commit checked out (exit 2 otherwise)]:COMMIT_RANGE:_default' \
'--pr-body-file=[File holding the PR body or commit message (override directives, hygiene scanning). With neither this flag nor DISCIPLINE_PR_BODY_FILE, the body is read from the PR_BODY environment variable]:PR_BODY_FILE:_files' \
'--commit-msg-file=[File holding the PR body or commit message (override directives, hygiene scanning). With neither this flag nor DISCIPLINE_PR_BODY_FILE, the body is read from the PR_BODY environment variable]:PR_BODY_FILE:_files' \
'--pr-title=[PR title for PR-level hygiene checks (e.g. issue-link). Falls back to the PR_TITLE environment variable]:PR_TITLE:_default' \
'--policy-from=[Which side'\''s discipline.toml judges the change. \`base\` reads it from the base ref, so a policy edit takes effect once merged; \`config-integrity\` still reports it]:POLICY_FROM:((head\:"The configuration in the working tree (the change'\''s own copy)"
base\:"The configuration on the base ref"))' \
'--actor=[Actor executing the check (for actor-aware override authorization). Falls back to DISCIPLINE_ACTOR, GITHUB_ACTOR, GITEA_ACTOR, FORGEJO_ACTOR, GITLAB_USER_LOGIN]:ACTOR:_default' \
'*--directive-sources=[Comma-separated list of allowed directive sources (pr-body, commits, merged-pr-body)]:DIRECTIVE_SOURCES:_default' \
'-f+[Output format]:FORMAT:(terminal github-summary json junit sarif gitlab agent-prompt)' \
'--format=[Output format]:FORMAT:(terminal github-summary json junit sarif gitlab agent-prompt)' \
'--json-out=[Also write the JSON report to this path, whatever --format is]:JSON_OUT:_files' \
'-o+[Write the formatted report to this path]:OUTPUT_FILE:_files' \
'--output-file=[Write the formatted report to this path]:OUTPUT_FILE:_files' \
'--max-report-lines=[Print at most this many lines of the terminal report on stdout, then one line saying how many were left out. Only the terminal format'\''s stdout is cut; --json-out, --output-file and the other report files stay complete]:MAX_REPORT_LINES:_default' \
'--report-gitlab=[Write GitLab Code Quality JSON report to this path]:REPORT_GITLAB:_files' \
'--report-junit=[Write JUnit XML report to this path]:REPORT_JUNIT:_files' \
'--report-sarif=[Write SARIF report to this path]:REPORT_SARIF:_files' \
'--bench-provenance=[Expected host or runner provenance tag for benchmark artifacts]:BENCH_PROVENANCE:_default' \
'--bench-base-file=[In-job base benchmark result file for bench-regression dual-mode]:BENCH_BASE_FILE:_files' \
'--bench-head-file=[In-job head benchmark result file for bench-regression dual-mode]:BENCH_HEAD_FILE:_files' \
'--test-base-report=[In-job base test report XML file for test-floor identity ratcheting]:TEST_BASE_REPORT:_files' \
'--test-head-report=[In-job head test report XML file for test-floor identity ratcheting]:TEST_HEAD_REPORT:_files' \
'--test-report=[Test report XML file path (relative to repo root) for test-floor identity ratcheting]:TEST_REPORT:_files' \
'--baseline-file=[Path to grandfathering baseline file (defaults to discipline-baseline.toml if present)]:BASELINE_FILE:_files' \
'(--commit --commit-range)--staged[Inspect the index against HEAD instead (pre-commit hook mode)]' \
'--fail-on-warnings[Treat warnings as failures]' \
'--fail-on-overrides[Treat the overrides a change writes as failures (requires human sign-off)]' \
'--advisory[Advisory mode\: run all checks and emit reports, but exit code 0 even if violations occur]' \
'--comment[Post the report as one pull-request comment, edited on every run (needs a token that can write comments; off by default)]' \
'--trust-workspace[Trust the workspace and disable libgit2 repository owner validation (off by default, or set DISCIPLINE_TRUST_WORKSPACE=1)]' \
'-q[Suppress output on success (only print output when violations are found)]' \
'--quiet[Suppress output on success (only print output when violations are found)]' \
'--timings[Add a \`timings\` object to the JSON report\: wall time per gate and per shared phase, and counts of the work behind it (or set DISCIPLINE_TIMINGS=1). Never part of a verdict, a baseline or a replay comparison]' \
'--allow-cross-host-bench[Allow benchmark comparison across mismatched host/runner provenance tags]' \
'--no-baseline[Ignore grandfathering baseline even if present]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(diff)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config=[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config-override=[Inline TOML merged over the file (tables merge, lists append, scalars replace)]:CONFIG_OVERRIDE:_default' \
'*--enable=[Gate ids to force on (comma separated)]:ENABLE:_default' \
'*--disable=[Gate ids to force off (comma separated)]:DISABLE:_default' \
'-s+[Which check suite to run]:SUITE:(all agent-guard hygiene integrity quality verification bench)' \
'--suite=[Which check suite to run]:SUITE:(all agent-guard hygiene integrity quality verification bench)' \
'-b+[Base branch or commit ref to compare against (defaults to HEAD for uncommitted changes)]:BASE:_default' \
'--base=[Base branch or commit ref to compare against (defaults to HEAD for uncommitted changes)]:BASE:_default' \
'-f+[Output format]:FORMAT:(terminal github-summary json junit sarif gitlab agent-prompt)' \
'--format=[Output format]:FORMAT:(terminal github-summary json junit sarif gitlab agent-prompt)' \
'--json-out=[Also write the JSON report to this path, whatever --format is]:JSON_OUT:_files' \
'-o+[Write the formatted report to this path]:OUTPUT_FILE:_files' \
'--output-file=[Write the formatted report to this path]:OUTPUT_FILE:_files' \
'--report-gitlab=[Write GitLab Code Quality JSON report to this path]:REPORT_GITLAB:_files' \
'--report-junit=[Write JUnit XML report to this path]:REPORT_JUNIT:_files' \
'--report-sarif=[Write SARIF report to this path]:REPORT_SARIF:_files' \
'--baseline-file=[Path to grandfathering baseline file (defaults to discipline-baseline.toml if present)]:BASELINE_FILE:_files' \
'--no-baseline[Ignore grandfathering baseline even if present]' \
'--trust-workspace[Trust the workspace and disable libgit2 repository owner validation (off by default, or set DISCIPLINE_TRUST_WORKSPACE=1)]' \
'--advisory[Advisory mode\: run checks and emit reports, but exit 0 even if violations are found]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(baseline)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config=[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config-override=[Inline TOML merged over the file (tables merge, lists append, scalars replace)]:CONFIG_OVERRIDE:_default' \
'*--enable=[Gate ids to force on (comma separated)]:ENABLE:_default' \
'*--disable=[Gate ids to force off (comma separated)]:DISABLE:_default' \
'--baseline-file=[Path to grandfathering baseline file (defaults to discipline-baseline.toml)]:BASELINE_FILE:_files' \
'-b+[Base branch or commit ref to compare against]:BASE:_default' \
'--base=[Base branch or commit ref to compare against]:BASE:_default' \
'-s+[Specific suite to run\: all, agent-guard, hygiene, integrity ...]:SUITE:(all agent-guard hygiene integrity quality verification bench)' \
'--suite=[Specific suite to run\: all, agent-guard, hygiene, integrity ...]:SUITE:(all agent-guard hygiene integrity quality verification bench)' \
'--write[Record current findings to the baseline file]' \
'(--write -b --base --whole-tree)--migrate[Rewrite an older baseline to version 3\: a version-1 file'\''s entries that a current finding still matches are kept under their finding codes and stale ones dropped, a version-2 file'\''s entries are kept, and the per-file assertion counts are seeded. Commit the result in a change of its own, which \`config-integrity\` accepts without a directive. With no baseline file there is nothing to migrate\: it says so and exits 0; a file that cannot be read exits 2]' \
'(-b --base)--whole-tree[Record every pre-existing finding in the tree, not just the diff. Use when adopting discipline on an existing repository; conflicts with --base]' \
'--all-severities[Also record warnings and notes. By default only findings that would block under the current configuration are recorded\: \`error\`, plus \`warning\` under --fail-on-warnings]' \
'--fail-on-warnings[Treat warnings as blocking when choosing what to record (same switch as \`check --fail-on-warnings\`)]' \
'--trust-workspace[Trust the workspace and disable libgit2 repository owner validation]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" : \
'-n+[Name of the project (defaults to current directory name)]:NAME:_default' \
'--name=[Name of the project (defaults to current directory name)]:NAME:_default' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(gates)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config=[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config-override=[Inline TOML merged over the file (tables merge, lists append, scalars replace)]:CONFIG_OVERRIDE:_default' \
'*--enable=[Gate ids to force on (comma separated)]:ENABLE:_default' \
'*--disable=[Gate ids to force off (comma separated)]:DISABLE:_default' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(schema)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(self-test)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell -- Target shell for completion script:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(docs)
_arguments "${_arguments_options[@]}" : \
'(--write)--check[Check that reference documentation is up to date with sources]' \
'(--check)--write[Regenerate and write reference documentation across the repository]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(install-hooks)
_arguments "${_arguments_options[@]}" : \
'-f[Overwrite existing pre-commit hook if present]' \
'--force[Overwrite existing pre-commit hook if present]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(hook)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_discipline__subcmd__hook_commands" \
"*::: :->hook" \
&& ret=0

    case $state in
    (hook)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-hook-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
'--agent=[The agent whose hook contract to answer in]:AGENT:((claude-code\:"Claude Code (\`.claude/settings.json\`, SessionStart + PreToolUse + PostToolUse + Stop)"
codex\:"OpenAI Codex CLI (\`.codex/hooks.json\`, SessionStart + PreToolUse + PostToolUse + Stop)"
cursor\:"Cursor (\`.cursor/hooks.json\`, stop)"
aider\:"Aider (\`.aider.conf.yml\`, lint-cmd)"
copilot\:"GitHub Copilot CLI (\`.github/hooks/discipline.json\`, sessionStart + preToolUse + postToolUse + agentStop)"
agy\:"Antigravity CLI (\`.agents/hooks.json\`, SessionStart + PreToolUse + Stop)"
qwen\:"Qwen Code (\`.qwen/settings.json\`, SessionStart + PreToolUse + PostToolUse + Stop)"
opencode\:"OpenCode (\`.opencode/plugins/discipline.js\`, a plugin on session start, before tools and after edit tools)"))' \
'-b+[Base to measure the change against (default\: DISCIPLINE_BASE_REF or the CI base, else the merge base with origin'\''s default branch, else main / master / trunk)]:BASE:_default' \
'--base=[Base to measure the change against (default\: DISCIPLINE_BASE_REF or the CI base, else the merge base with origin'\''s default branch, else main / master / trunk)]:BASE:_default' \
'--event=[The hook event\: \`pre-tool\` checks the tool call on stdin before it runs (an edit into another worktree, into a worktree another session leases, or into forbidden_paths is refused); \`session-start\` takes this worktree'\''s lease for the session on stdin (never blocks); \`stop\` judges the end of a turn on stdin (the OpenCode plugin'\''s payload); the default checks the change so far]:EVENT:((check\:"After an edit or at the end of a turn\: check the change so far"
pre-tool\:"Before a tool runs\: refuse an edit outside this session'\''s worktree or a repeated loop call"
post-tool\:"After a tool runs\: record a passing verification command on the current working-tree digest"
session-start\:"When a session starts\: take this worktree'\''s lease for it (never blocks)"
stop\:"At the end of a turn\: judge the turn on stdin (the OpenCode plugin sends the final message it read from the event stream)"))' \
'--if-configured[Pass silently unless the working directory (for the pre-tool and session-start events, the payload'\''s directory) is in a git repository with a discipline.toml at its root (for a user-level hook, which runs in every folder)]' \
'--observe[Observe mode\: run the check but never block; what would have blocked is said on stderr and appended to <git dir>/discipline/hook-observe.log]' \
'-v[Print every non-blocking warning in full instead of eliding warnings unchanged since the previous report in the same session]' \
'--verbose[Print every non-blocking warning in full instead of eliding warnings unchanged since the previous report in the same session]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::files -- Files an agent appends to the command (Aider'\''s lint-cmd); ignored, the whole change is checked:_default' \
&& ret=0
;;
(install)
_arguments "${_arguments_options[@]}" : \
'--agent=[The agent to configure]:AGENT:((claude-code\:"Claude Code (\`.claude/settings.json\`, SessionStart + PreToolUse + PostToolUse + Stop)"
codex\:"OpenAI Codex CLI (\`.codex/hooks.json\`, SessionStart + PreToolUse + PostToolUse + Stop)"
cursor\:"Cursor (\`.cursor/hooks.json\`, stop)"
aider\:"Aider (\`.aider.conf.yml\`, lint-cmd)"
copilot\:"GitHub Copilot CLI (\`.github/hooks/discipline.json\`, sessionStart + preToolUse + postToolUse + agentStop)"
agy\:"Antigravity CLI (\`.agents/hooks.json\`, SessionStart + PreToolUse + Stop)"
qwen\:"Qwen Code (\`.qwen/settings.json\`, SessionStart + PreToolUse + PostToolUse + Stop)"
opencode\:"OpenCode (\`.opencode/plugins/discipline.js\`, a plugin on session start, before tools and after edit tools)"))' \
'--timeout=[Seconds the agent gives each check before killing it (agy, qwen, copilot; default\: agy 300, the others 120). Raise it on a machine where a check can run long]:SECONDS:_default' \
'(--user)--pin-sums=[A release'\''s SHA256SUMS, verified (\`gh attestation verify\`)\: the Claude Code bootstrap checks its download against the linux-musl digests in it instead of fetching SHA256SUMS from the release (claude-code only)]:FILE:_files' \
'--user[Write the user-level hook instead (copilot\: ~/.copilot/hooks/discipline.json, or under COPILOT_HOME), which runs in every folder but checks only repositories with a discipline.toml]' \
'(--enforce)--observe[Write the hook commands in observe mode (hook run --observe)\: the agent is never blocked while a hook is rolled out]' \
'(--observe)--enforce[Write the hook commands in enforcing mode\: rewrites a file an earlier release generated in observe mode to enforcing mode (refuses an edited file without --force)]' \
'(--user)--cloud-agent[Also write .github/workflows/copilot-setup-steps.yml, which installs discipline for Copilot cloud agent (copilot only)]' \
'--upgrade[Rewrite a file an earlier discipline release generated to this release\: one with the \`Written by \\\`discipline hook install\\\`\` header (the Claude Code bootstrap, the Copilot setup step, the OpenCode plugin) whose digest line matches its content, or a JSON hook file holding only the entries a release writes. A hook file keeps its mode (observe or enforcing; --observe can only turn observe mode on; --enforce switches to enforcing) and a JSON file its longer check timeout. Any other file is left as it is, with the difference printed and exit 1\: one edited after it was written, one an earlier release wrote without a digest, and a JSON file with hooks or settings of its own whose discipline entries differ (see --force). With --user, the same for the user-level file]' \
'--force[With --upgrade or --enforce, also rewrite a file that cannot be told from an edited one, and print what was discarded. In a JSON hook file with hooks or settings of its own, only the discipline entries are replaced. A bootstrap pinned with --pin-sums is still never replaced by an unpinned one]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(log)
_arguments "${_arguments_options[@]}" : \
'--last=[Print only the last N records]:N:_default' \
'--json[Print each record as one JSON object per line]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_discipline__subcmd__hook__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-hook-help-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(install)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(log)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(explain)
_arguments "${_arguments_options[@]}" : \
'-c+[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config=[Path to discipline.toml. An absent default file = built-in defaults (\`discipline gates\` lists them); any other path that does not exist is an error (exit 2)]:CONFIG:_files' \
'--config-override=[Inline TOML merged over the file (tables merge, lists append, scalars replace)]:CONFIG_OVERRIDE:_default' \
'*--enable=[Gate ids to force on (comma separated)]:ENABLE:_default' \
'*--disable=[Gate ids to force off (comma separated)]:DISABLE:_default' \
'-h[Print help]' \
'--help[Print help]' \
':query -- A gate id (`assertion-reduction`) or a finding line naming `\[gate-id\]`:_default' \
&& ret=0
;;
(replay)
_arguments "${_arguments_options[@]}" : \
'--last=[Number of first-parent commits (merged changes) to replay, newest first]:LAST:_default' \
'--ref=[Branch whose history is replayed (default\: origin'\''s default branch, else main / master)]:REFERENCE:_default' \
'-c+[Configuration under test (default\: discipline.toml in the working tree)]:CONFIG:_files' \
'--config=[Configuration under test (default\: discipline.toml in the working tree)]:CONFIG:_files' \
'--jobs=[Changes checked at once (default\: one per core, at most 4)]:N:_default' \
'--json[Print the summary as JSON]' \
'--no-cache[Check every change again\: read no verdict from the replay cache and record none]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(audit)
_arguments "${_arguments_options[@]}" : \
'--last=[Number of first-parent commits (merged changes) to audit, newest first]:LAST:_default' \
'--ref=[Branch whose history is audited (default\: origin'\''s default branch, else main / master)]:REFERENCE:_default' \
'--format=[Output format\: \`text\`, \`json\`, or \`html\` (one self-contained page)]:FORMAT:(text json html)' \
'-o+[Write the output to this file instead of stdout]:OUTPUT:_files' \
'--output=[Write the output to this file instead of stdout]:OUTPUT:_files' \
'--replay=[A \`discipline replay --json\` report of the same history\: says which waivers lifted a finding and which lifted nothing]:FILE:_files' \
'--json[Print the records as JSON (the same as \`--format json\`)]' \
'--forge[Read each change'\''s merged pull request from the forge (its body'\''s directives, and whether another login approved it); needs a token that can read pull requests]' \
'--reasons[Include each directive'\''s reason text (by default only its SHA-256 and length)]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(mcp)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(bench)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_discipline__subcmd__bench_commands" \
"*::: :->bench" \
&& ret=0

    case $state in
    (bench)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-bench-command-$line[1]:"
        case $line[1] in
            (derive)
_arguments "${_arguments_options[@]}" : \
'--baseline=[Merge the derived platform entry into this ratio baseline file (created if absent)]:BASELINE:_files' \
'--ceiling-pct=[Derived cell floors above this percentage are reported but not gated]:CEILING_PCT:_default' \
'--allow-mixed-commits[Accept runs of different commits (recorded in the baseline); only when the differences cannot move a number]' \
'-h[Print help]' \
'--help[Print help]' \
'*::runs -- `discipline-bench-ratio/v1` run files of the same code (at least two):_files' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_discipline__subcmd__bench__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-bench-help-command-$line[1]:"
        case $line[1] in
            (derive)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(doctor)
_arguments "${_arguments_options[@]}" : \
'--branch=[Branch whose protection is checked (default\: the repository'\''s default branch)]:BRANCH:_default' \
'--repo=[Repository path on the forge, e.g. OWNER/NAME (default\: from the CI environment or the \`origin\` remote; set DISCIPLINE_FORGE for a self-hosted forge)]:REPO:_default' \
'-f+[Output format]:FORMAT:(text json)' \
'--format=[Output format]:FORMAT:(text json)' \
'--local-only[Check only local files; skip the platform API]' \
'--strict[Treat warnings as failures]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(lease)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
":: :_discipline__subcmd__lease_commands" \
"*::: :->lease" \
&& ret=0

    case $state in
    (lease)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-lease-command-$line[1]:"
        case $line[1] in
            (take)
_arguments "${_arguments_options[@]}" : \
'*--branch=[A branch to claim (repeatable; default\: the branch checked out here)]:BRANCHES:_default' \
'--agent=[The agent working here (claude-code, copilot, agy, ...)]:AGENT:_default' \
'--session=[The agent'\''s session id]:SESSION:_default' \
'--ttl=[Seconds the lease stays live without a refresh]:TTL:_default' \
'--steal[Take branches another worktree'\''s live lease claims, removing them from that lease (it is said, never silent)]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(release)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'--json[Print the leases as JSON]' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
'--branch=[The branch to check]:BRANCH:_default' \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(install-guard)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(guard)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':state -- The transaction state git passes (prepared, committed, aborted); only `prepared` is checked:_default' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_discipline__subcmd__lease__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-lease-help-command-$line[1]:"
        case $line[1] in
            (take)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(release)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(install-guard)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(guard)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_discipline__subcmd__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-help-command-$line[1]:"
        case $line[1] in
            (check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(diff)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(baseline)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(gates)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(schema)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(self-test)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(docs)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(install-hooks)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(hook)
_arguments "${_arguments_options[@]}" : \
":: :_discipline__subcmd__help__subcmd__hook_commands" \
"*::: :->hook" \
&& ret=0

    case $state in
    (hook)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-help-hook-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(install)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(log)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(explain)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(replay)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(audit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(mcp)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(bench)
_arguments "${_arguments_options[@]}" : \
":: :_discipline__subcmd__help__subcmd__bench_commands" \
"*::: :->bench" \
&& ret=0

    case $state in
    (bench)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-help-bench-command-$line[1]:"
        case $line[1] in
            (derive)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(doctor)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(lease)
_arguments "${_arguments_options[@]}" : \
":: :_discipline__subcmd__help__subcmd__lease_commands" \
"*::: :->lease" \
&& ret=0

    case $state in
    (lease)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:discipline-help-lease-command-$line[1]:"
        case $line[1] in
            (take)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(release)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(check)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(install-guard)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(guard)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_discipline_commands] )) ||
_discipline_commands() {
    local commands; commands=(
'check:Run the configured gates. Exit 0 = pass, 1 = violations, 2 = could not check' \
'diff:Shorthand for checking uncommitted or working tree changes against HEAD' \
'baseline:Record or manage grandfathered finding baselines' \
'init:Write a minimal discipline.toml\: gates run at their built-in defaults; commented examples show what to change' \
'gates:List every gate\: id, suite, availability, and effective state' \
'schema:Print the JSON Schema for discipline.toml' \
'self-test:Run the embedded negative / positive controls against this binary' \
'completions:Generate shell completion script to stdout (bash, zsh, fish, powershell, elvish)' \
'docs:Generate or check reference docs and schemas against sources of truth' \
'install-hooks:Install pre-commit hook in the local git repository' \
'hook:Run the gates inside a coding agent'\''s edit loop (Claude Code, Codex, Cursor, Aider, Copilot CLI, agy, Qwen Code, OpenCode)' \
'explain:Explain a gate\: what it checks, its state here, and the directive that lifts a finding' \
'replay:Replay the last N merged changes through a configuration\: what it would have blocked' \
'audit:List the escape hatches the last N merged changes carried\: directives, configuration loosenings, baseline growth, inline markers' \
'mcp:Serve the gates to an MCP client over stdio (read-only tools\: check_diff, list_gates, explain_finding)' \
'bench:Benchmark tooling for the bench-regression gate' \
'doctor:Check that the repository and its platform enforce discipline\: workflows, CODEOWNERS, branch protection, and the local agent settings. Exit 0 = healthy, 1 = a failing check, 2 = could not check' \
'lease:Claim this worktree'\''s branches for one agent session, so other worktrees'\'' sessions do not move them (kept in the common git directory, never committed)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline commands' commands "$@"
}
(( $+functions[_discipline__subcmd__audit_commands] )) ||
_discipline__subcmd__audit_commands() {
    local commands; commands=()
    _describe -t commands 'discipline audit commands' commands "$@"
}
(( $+functions[_discipline__subcmd__baseline_commands] )) ||
_discipline__subcmd__baseline_commands() {
    local commands; commands=()
    _describe -t commands 'discipline baseline commands' commands "$@"
}
(( $+functions[_discipline__subcmd__bench_commands] )) ||
_discipline__subcmd__bench_commands() {
    local commands; commands=(
'derive:Derive paired-ratio noise floors and baseline ratios from repeated same-commit runs' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline bench commands' commands "$@"
}
(( $+functions[_discipline__subcmd__bench__subcmd__derive_commands] )) ||
_discipline__subcmd__bench__subcmd__derive_commands() {
    local commands; commands=()
    _describe -t commands 'discipline bench derive commands' commands "$@"
}
(( $+functions[_discipline__subcmd__bench__subcmd__help_commands] )) ||
_discipline__subcmd__bench__subcmd__help_commands() {
    local commands; commands=(
'derive:Derive paired-ratio noise floors and baseline ratios from repeated same-commit runs' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline bench help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__bench__subcmd__help__subcmd__derive_commands] )) ||
_discipline__subcmd__bench__subcmd__help__subcmd__derive_commands() {
    local commands; commands=()
    _describe -t commands 'discipline bench help derive commands' commands "$@"
}
(( $+functions[_discipline__subcmd__bench__subcmd__help__subcmd__help_commands] )) ||
_discipline__subcmd__bench__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'discipline bench help help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__check_commands] )) ||
_discipline__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'discipline check commands' commands "$@"
}
(( $+functions[_discipline__subcmd__completions_commands] )) ||
_discipline__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'discipline completions commands' commands "$@"
}
(( $+functions[_discipline__subcmd__diff_commands] )) ||
_discipline__subcmd__diff_commands() {
    local commands; commands=()
    _describe -t commands 'discipline diff commands' commands "$@"
}
(( $+functions[_discipline__subcmd__docs_commands] )) ||
_discipline__subcmd__docs_commands() {
    local commands; commands=()
    _describe -t commands 'discipline docs commands' commands "$@"
}
(( $+functions[_discipline__subcmd__doctor_commands] )) ||
_discipline__subcmd__doctor_commands() {
    local commands; commands=()
    _describe -t commands 'discipline doctor commands' commands "$@"
}
(( $+functions[_discipline__subcmd__explain_commands] )) ||
_discipline__subcmd__explain_commands() {
    local commands; commands=()
    _describe -t commands 'discipline explain commands' commands "$@"
}
(( $+functions[_discipline__subcmd__gates_commands] )) ||
_discipline__subcmd__gates_commands() {
    local commands; commands=()
    _describe -t commands 'discipline gates commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help_commands] )) ||
_discipline__subcmd__help_commands() {
    local commands; commands=(
'check:Run the configured gates. Exit 0 = pass, 1 = violations, 2 = could not check' \
'diff:Shorthand for checking uncommitted or working tree changes against HEAD' \
'baseline:Record or manage grandfathered finding baselines' \
'init:Write a minimal discipline.toml\: gates run at their built-in defaults; commented examples show what to change' \
'gates:List every gate\: id, suite, availability, and effective state' \
'schema:Print the JSON Schema for discipline.toml' \
'self-test:Run the embedded negative / positive controls against this binary' \
'completions:Generate shell completion script to stdout (bash, zsh, fish, powershell, elvish)' \
'docs:Generate or check reference docs and schemas against sources of truth' \
'install-hooks:Install pre-commit hook in the local git repository' \
'hook:Run the gates inside a coding agent'\''s edit loop (Claude Code, Codex, Cursor, Aider, Copilot CLI, agy, Qwen Code, OpenCode)' \
'explain:Explain a gate\: what it checks, its state here, and the directive that lifts a finding' \
'replay:Replay the last N merged changes through a configuration\: what it would have blocked' \
'audit:List the escape hatches the last N merged changes carried\: directives, configuration loosenings, baseline growth, inline markers' \
'mcp:Serve the gates to an MCP client over stdio (read-only tools\: check_diff, list_gates, explain_finding)' \
'bench:Benchmark tooling for the bench-regression gate' \
'doctor:Check that the repository and its platform enforce discipline\: workflows, CODEOWNERS, branch protection, and the local agent settings. Exit 0 = healthy, 1 = a failing check, 2 = could not check' \
'lease:Claim this worktree'\''s branches for one agent session, so other worktrees'\'' sessions do not move them (kept in the common git directory, never committed)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__audit_commands] )) ||
_discipline__subcmd__help__subcmd__audit_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help audit commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__baseline_commands] )) ||
_discipline__subcmd__help__subcmd__baseline_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help baseline commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__bench_commands] )) ||
_discipline__subcmd__help__subcmd__bench_commands() {
    local commands; commands=(
'derive:Derive paired-ratio noise floors and baseline ratios from repeated same-commit runs' \
    )
    _describe -t commands 'discipline help bench commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__bench__subcmd__derive_commands] )) ||
_discipline__subcmd__help__subcmd__bench__subcmd__derive_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help bench derive commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__check_commands] )) ||
_discipline__subcmd__help__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help check commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__completions_commands] )) ||
_discipline__subcmd__help__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help completions commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__diff_commands] )) ||
_discipline__subcmd__help__subcmd__diff_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help diff commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__docs_commands] )) ||
_discipline__subcmd__help__subcmd__docs_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help docs commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__doctor_commands] )) ||
_discipline__subcmd__help__subcmd__doctor_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help doctor commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__explain_commands] )) ||
_discipline__subcmd__help__subcmd__explain_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help explain commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__gates_commands] )) ||
_discipline__subcmd__help__subcmd__gates_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help gates commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__help_commands] )) ||
_discipline__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__hook_commands] )) ||
_discipline__subcmd__help__subcmd__hook_commands() {
    local commands; commands=(
'run:Check the change so far and answer in the agent'\''s hook contract (reads the hook payload on stdin)' \
'install:Write the agent'\''s hook configuration at the repository root (or, with --user, the user-level one); an existing file is never rewritten' \
'log:Print this repository'\''s hook records (<git dir>/discipline/hook-observe.log)\: time, agent, event, mode, binary version, decision, exit code and finding counts, oldest first' \
    )
    _describe -t commands 'discipline help hook commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__hook__subcmd__install_commands] )) ||
_discipline__subcmd__help__subcmd__hook__subcmd__install_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help hook install commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__hook__subcmd__log_commands] )) ||
_discipline__subcmd__help__subcmd__hook__subcmd__log_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help hook log commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__hook__subcmd__run_commands] )) ||
_discipline__subcmd__help__subcmd__hook__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help hook run commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__init_commands] )) ||
_discipline__subcmd__help__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help init commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__install-hooks_commands] )) ||
_discipline__subcmd__help__subcmd__install-hooks_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help install-hooks commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__lease_commands] )) ||
_discipline__subcmd__help__subcmd__lease_commands() {
    local commands; commands=(
'take:Take or refresh this worktree'\''s lease. A branch another worktree'\''s live lease claims is refused unless --steal' \
'release:Remove this worktree'\''s lease' \
'list:List every worktree'\''s lease and whether it is live' \
'check:Whether a branch is claimed by another worktree'\''s live lease. Exit 0 = free (or ours), 1 = claimed by another worktree, 2 = could not check' \
'install-guard:Install the reference-transaction git hook that refuses a branch update another worktree'\''s live lease claims (an existing hook is never rewritten)' \
'guard:The reference-transaction hook'\''s body\: reads the updates on stdin and exits 1, aborting the transaction, when one moves a branch another worktree'\''s live lease claims' \
    )
    _describe -t commands 'discipline help lease commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__lease__subcmd__check_commands] )) ||
_discipline__subcmd__help__subcmd__lease__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help lease check commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__lease__subcmd__guard_commands] )) ||
_discipline__subcmd__help__subcmd__lease__subcmd__guard_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help lease guard commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__lease__subcmd__install-guard_commands] )) ||
_discipline__subcmd__help__subcmd__lease__subcmd__install-guard_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help lease install-guard commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__lease__subcmd__list_commands] )) ||
_discipline__subcmd__help__subcmd__lease__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help lease list commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__lease__subcmd__release_commands] )) ||
_discipline__subcmd__help__subcmd__lease__subcmd__release_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help lease release commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__lease__subcmd__take_commands] )) ||
_discipline__subcmd__help__subcmd__lease__subcmd__take_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help lease take commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__mcp_commands] )) ||
_discipline__subcmd__help__subcmd__mcp_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help mcp commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__replay_commands] )) ||
_discipline__subcmd__help__subcmd__replay_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help replay commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__schema_commands] )) ||
_discipline__subcmd__help__subcmd__schema_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help schema commands' commands "$@"
}
(( $+functions[_discipline__subcmd__help__subcmd__self-test_commands] )) ||
_discipline__subcmd__help__subcmd__self-test_commands() {
    local commands; commands=()
    _describe -t commands 'discipline help self-test commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook_commands] )) ||
_discipline__subcmd__hook_commands() {
    local commands; commands=(
'run:Check the change so far and answer in the agent'\''s hook contract (reads the hook payload on stdin)' \
'install:Write the agent'\''s hook configuration at the repository root (or, with --user, the user-level one); an existing file is never rewritten' \
'log:Print this repository'\''s hook records (<git dir>/discipline/hook-observe.log)\: time, agent, event, mode, binary version, decision, exit code and finding counts, oldest first' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline hook commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__help_commands] )) ||
_discipline__subcmd__hook__subcmd__help_commands() {
    local commands; commands=(
'run:Check the change so far and answer in the agent'\''s hook contract (reads the hook payload on stdin)' \
'install:Write the agent'\''s hook configuration at the repository root (or, with --user, the user-level one); an existing file is never rewritten' \
'log:Print this repository'\''s hook records (<git dir>/discipline/hook-observe.log)\: time, agent, event, mode, binary version, decision, exit code and finding counts, oldest first' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline hook help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__help__subcmd__help_commands] )) ||
_discipline__subcmd__hook__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'discipline hook help help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__help__subcmd__install_commands] )) ||
_discipline__subcmd__hook__subcmd__help__subcmd__install_commands() {
    local commands; commands=()
    _describe -t commands 'discipline hook help install commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__help__subcmd__log_commands] )) ||
_discipline__subcmd__hook__subcmd__help__subcmd__log_commands() {
    local commands; commands=()
    _describe -t commands 'discipline hook help log commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__help__subcmd__run_commands] )) ||
_discipline__subcmd__hook__subcmd__help__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'discipline hook help run commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__install_commands] )) ||
_discipline__subcmd__hook__subcmd__install_commands() {
    local commands; commands=()
    _describe -t commands 'discipline hook install commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__log_commands] )) ||
_discipline__subcmd__hook__subcmd__log_commands() {
    local commands; commands=()
    _describe -t commands 'discipline hook log commands' commands "$@"
}
(( $+functions[_discipline__subcmd__hook__subcmd__run_commands] )) ||
_discipline__subcmd__hook__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'discipline hook run commands' commands "$@"
}
(( $+functions[_discipline__subcmd__init_commands] )) ||
_discipline__subcmd__init_commands() {
    local commands; commands=()
    _describe -t commands 'discipline init commands' commands "$@"
}
(( $+functions[_discipline__subcmd__install-hooks_commands] )) ||
_discipline__subcmd__install-hooks_commands() {
    local commands; commands=()
    _describe -t commands 'discipline install-hooks commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease_commands] )) ||
_discipline__subcmd__lease_commands() {
    local commands; commands=(
'take:Take or refresh this worktree'\''s lease. A branch another worktree'\''s live lease claims is refused unless --steal' \
'release:Remove this worktree'\''s lease' \
'list:List every worktree'\''s lease and whether it is live' \
'check:Whether a branch is claimed by another worktree'\''s live lease. Exit 0 = free (or ours), 1 = claimed by another worktree, 2 = could not check' \
'install-guard:Install the reference-transaction git hook that refuses a branch update another worktree'\''s live lease claims (an existing hook is never rewritten)' \
'guard:The reference-transaction hook'\''s body\: reads the updates on stdin and exits 1, aborting the transaction, when one moves a branch another worktree'\''s live lease claims' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline lease commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__check_commands] )) ||
_discipline__subcmd__lease__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease check commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__guard_commands] )) ||
_discipline__subcmd__lease__subcmd__guard_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease guard commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help_commands] )) ||
_discipline__subcmd__lease__subcmd__help_commands() {
    local commands; commands=(
'take:Take or refresh this worktree'\''s lease. A branch another worktree'\''s live lease claims is refused unless --steal' \
'release:Remove this worktree'\''s lease' \
'list:List every worktree'\''s lease and whether it is live' \
'check:Whether a branch is claimed by another worktree'\''s live lease. Exit 0 = free (or ours), 1 = claimed by another worktree, 2 = could not check' \
'install-guard:Install the reference-transaction git hook that refuses a branch update another worktree'\''s live lease claims (an existing hook is never rewritten)' \
'guard:The reference-transaction hook'\''s body\: reads the updates on stdin and exits 1, aborting the transaction, when one moves a branch another worktree'\''s live lease claims' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'discipline lease help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help__subcmd__check_commands] )) ||
_discipline__subcmd__lease__subcmd__help__subcmd__check_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease help check commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help__subcmd__guard_commands] )) ||
_discipline__subcmd__lease__subcmd__help__subcmd__guard_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease help guard commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help__subcmd__help_commands] )) ||
_discipline__subcmd__lease__subcmd__help__subcmd__help_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease help help commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help__subcmd__install-guard_commands] )) ||
_discipline__subcmd__lease__subcmd__help__subcmd__install-guard_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease help install-guard commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help__subcmd__list_commands] )) ||
_discipline__subcmd__lease__subcmd__help__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease help list commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help__subcmd__release_commands] )) ||
_discipline__subcmd__lease__subcmd__help__subcmd__release_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease help release commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__help__subcmd__take_commands] )) ||
_discipline__subcmd__lease__subcmd__help__subcmd__take_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease help take commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__install-guard_commands] )) ||
_discipline__subcmd__lease__subcmd__install-guard_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease install-guard commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__list_commands] )) ||
_discipline__subcmd__lease__subcmd__list_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease list commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__release_commands] )) ||
_discipline__subcmd__lease__subcmd__release_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease release commands' commands "$@"
}
(( $+functions[_discipline__subcmd__lease__subcmd__take_commands] )) ||
_discipline__subcmd__lease__subcmd__take_commands() {
    local commands; commands=()
    _describe -t commands 'discipline lease take commands' commands "$@"
}
(( $+functions[_discipline__subcmd__mcp_commands] )) ||
_discipline__subcmd__mcp_commands() {
    local commands; commands=()
    _describe -t commands 'discipline mcp commands' commands "$@"
}
(( $+functions[_discipline__subcmd__replay_commands] )) ||
_discipline__subcmd__replay_commands() {
    local commands; commands=()
    _describe -t commands 'discipline replay commands' commands "$@"
}
(( $+functions[_discipline__subcmd__schema_commands] )) ||
_discipline__subcmd__schema_commands() {
    local commands; commands=()
    _describe -t commands 'discipline schema commands' commands "$@"
}
(( $+functions[_discipline__subcmd__self-test_commands] )) ||
_discipline__subcmd__self-test_commands() {
    local commands; commands=()
    _describe -t commands 'discipline self-test commands' commands "$@"
}

if [ "$funcstack[1]" = "_discipline" ]; then
    _discipline "$@"
else
    compdef _discipline discipline
fi
