{
  name         = "Register Change",
  description  = "Record a meaningful change and synchronize reflection, ontology, and changelog. Run after writing code, before git commit.",
  display_mode = "complete",

  elements = [

    # ── Summary ──────────────────────────────────────────────────────────────
    { type = "section_header", name = "summary_header",
      title = "Change Summary", border_top = true, border_bottom = true },

    { type = "text", name = "summary",
      prompt      = "One-line summary of the change",
      required    = true,
      placeholder = "Add verifiable flag to mode step schema",
      help        = "Imperative present tense. This becomes the CHANGELOG entry title.",
      nickel_path = ["summary"] },

    { type = "select", name = "change_type",
      prompt  = "Change type",
      required = true,
      options = [
        { value = "feature",      label = "Feature — new capability or behavior" },
        { value = "fix",          label = "Fix — bug correction" },
        { value = "architectural", label = "Architectural — decision that touches invariants or shapes future choices" },
        { value = "refactor",     label = "Refactor — internal restructure, no behavior change" },
        { value = "tooling",      label = "Tooling — scripts, CI, reflection infrastructure" },
        { value = "docs",         label = "Docs — documentation only (no code change)" },
      ],
      nickel_path = ["change_type"] },

    { type = "editor", name = "detail",
      prompt         = "Detail (optional — expands the CHANGELOG entry)",
      required       = false,
      file_extension = "md",
      prefix_text    = "# What changed, why, and any caveats.\n\n",
      nickel_path    = ["detail"] },

    # ── Architectural decision ────────────────────────────────────────────────
    { type = "section_header", name = "adr_header",
      title = "Architectural Decision (if applicable)", border_top = true, border_bottom = true },

    { type = "section", name = "adr_note",
      content = "Fill only if change_type = architectural OR if this change formalizes a decision already embedded in the code." },

    { type = "confirm", name = "needs_adr",
      prompt  = "Does this change require a new ADR?",
      default = false,
      nickel_path = ["needs_adr"] },

    { type = "text", name = "adr_title",
      prompt      = "ADR title (if needs_adr)",
      required    = false,
      placeholder = "Reflection modes replace examples/ as verifiable knowledge source",
      help        = "Will be passed to /create-adr. Leave empty if needs_adr = false.",
      nickel_path = ["adr_title"] },

    { type = "confirm", name = "adr_accept_immediately",
      prompt  = "Accept ADR immediately? (-a flag)",
      default = false,
      help    = "Use when the decision is already implemented and there is no ambiguity.",
      nickel_path = ["adr_accept_immediately"] },

    # ── Ontology state ───────────────────────────────────────────────────────
    { type = "section_header", name = "ontology_header",
      title = "Ontology State (if applicable)", border_top = true, border_bottom = true },

    { type = "section", name = "ontology_note",
      content = "Fill if this change moves a dimension forward. Query current state: nickel export .ontology/state.ncl | jq '.dimensions[] | .id + \": \" + .current_state'" },

    { type = "confirm", name = "changes_ontology_state",
      prompt  = "Does this change move an ontology dimension to a new state?",
      default = false,
      nickel_path = ["changes_ontology_state"] },

    { type = "text", name = "ontology_dimension_id",
      prompt      = "Dimension ID (if changes_ontology_state)",
      required    = false,
      placeholder = "reflection-modes-coverage",
      nickel_path = ["ontology_dimension_id"] },

    { type = "text", name = "ontology_new_state",
      prompt      = "New current_state value",
      required    = false,
      placeholder = "active",
      nickel_path = ["ontology_new_state"] },

    # ── Capability / Mode ────────────────────────────────────────────────────
    { type = "section_header", name = "capability_header",
      title = "Capability / Mode (if applicable)", border_top = true, border_bottom = true },

    { type = "confirm", name = "affects_capability",
      prompt  = "Does this change add, modify, or remove a user-visible capability?",
      default = false,
      nickel_path = ["affects_capability"] },

    { type = "select", name = "capability_action",
      prompt  = "Capability action",
      default = "add",
      options = [
        { value = "add",    label = "Add — new capability" },
        { value = "modify", label = "Modify — existing capability changed" },
        { value = "remove", label = "Remove — capability no longer exists" },
      ],
      nickel_path = ["capability_action"] },

    { type = "text", name = "capability_mode_id",
      prompt      = "Mode ID to create or update (if affects_capability)",
      required    = false,
      placeholder = "ontoref-register",
      help        = "Matches filename in reflection/modes/<id>.ncl",
      nickel_path = ["capability_mode_id"] },

    # ── Config Profile ───────────────────────────────────────────────────────
    { type = "section_header", name = "config_header",
      title = "Config Profile (if applicable)", border_top = true, border_bottom = true },

    { type = "section", name = "config_note",
      content = "Fill if this change modified a sealed config profile (development, ci, staging, production).\nontoref config apply will seal the profile and write a history entry linked to this change." },

    { type = "confirm", name = "seals_config_profile",
      prompt  = "Does this change modify a config profile that should be resealed?",
      default = false,
      nickel_path = ["seals_config_profile"] },

    { type = "text", name = "config_profile",
      prompt      = "Profile name (if seals_config_profile)",
      required    = false,
      placeholder = "development",
      help        = "Lowercase profile name: development | ci | staging | production",
      nickel_path = ["config_profile"] },

    # ── Confirm ──────────────────────────────────────────────────────────────
    { type = "section_header", name = "confirm_header",
      title = "Confirm", border_top = true },

    { type = "section", name = "confirm_note",
      content = "register.nu will write:\n  - CHANGELOG entry (always)\n  - ADR stub if needs_adr = true\n  - Patch .ontology/state.ncl if changes_ontology_state = true\n  - Mode stub if affects_capability = true and capability_action = add\nAll files are typechecked before write." },

    { type = "confirm", name = "ready",
      prompt  = "Write all artifacts?",
      default = true,
      nickel_path = ["ready"] },
  ],
}
