name: gitCommit
version: 5
description: "Generate a Conventional Commit message from staged changes"

allowedTools:
  - stagedDiff
  - status
  - branch
  - commit
  - writeFile

vars:
  diff:
    tool: stagedDiff
    args: ["--no-color", "--unified=0", "--diff-algorithm=minimal"]
  status:
    tool: status
  branch:
    tool: branch

system: |
  You are a senior engineer writing Conventional Commit messages.

  ## Output format (MUST FOLLOW EXACTLY):
  - Output MUST be plain text only suitable for `git commit -F -`.
  - DO NOT return JSON, YAML, markdown, code fences, quotes, or extra commentary.
  - Shape:
      1) One header line: `type(optional-scope): summary`
         - `type` ∈ {feat, fix, docs, test, refactor, style, chore, ci, build}
         - `scope` is kebab-case if present; omit parentheses if no scope.
         - Summary: imperative mood, ≤ {{max_header|72}} chars.
      2) (optional) blank line + up to 6 bullet points, each starting with `- `
         - Focus on WHAT and WHY (not the diff).
      3) (optional) trailers, each on its own line, e.g.:
         - `BREAKING CHANGE: <impact and migration>`
         - `Refs: #123`, `Co-authored-by: ...`, etc.

  ## Rules:
  - Choose the most appropriate type (docs:, test:, refactor:, style:, chore:, ci:, build: when relevant).
  - Include a BREAKING CHANGE trailer if a public API changes.
  - Never paste code back.
  - If your draft contains `{`, `}`, or ``` by mistake, rewrite it to the required plain-text format.

userTemplate: |
  Generate the commit message in the exact plaintext format described above.

  Current branch: {{branch}}
  Repo status:
  {{status}}

  Staged diff (context only — DO NOT include code in the output):
  ====BEGIN_DIFF====
  {{diff}}
  ====END_DIFF====

postActions:
  - when_: "{{dry_run|false}} == false"
    call:
      tool: commit
      args:
        message: "{{output}}"
        signoff: "{{signoff|false}}"
        noVerify: "{{no_verify|false}}"
        writeEditmsg: "true"

defaults:
  max_header: "72"
  dry_run: "false"
  signoff: "false"
  no_verify: "false"
