{
  "version": "3.16",
  "name": "BatchAdjust",
  "description": "Apply multiple small adjustments in one pass — e.g., rename fields, add buttons across pages, fix multiple UI issues. Decomposes the request into atomic changes, executes each, and finalizes the project without validation gating.",
  "sectionMerge": true,
  "registry": {
    "params": [
      "batchRequest(STRING)",
      "currentMeta(OBJECT)"
    ],
    "services": [],
    "apis": [],
    "components": [],
    "vars": [
      "$changeList(ARRAY)",
      "$changeResults(ARRAY)",
      "$updatedMeta(OBJECT)"
    ],
    "files": {
      "inputs": [
        ".vl-code/ProjectMeta.json",
        "Sections/*",
        "Services/*",
        "Database/*",
        "Apps/*"
      ],
      "artifacts": [
        ".vl-code/ProjectMeta.json",
        "Sections/*",
        "Services/*",
        "Database/*",
        "Apps/*",
        "ExtComponents/*"
      ]
    },
    "docs": {
      "1": "VL 3.7 Syntax Rules"
    }
  },
  "steps": [
    {
      "id": "LLM_010_Decompose",
      "meta": {
        "title": "1. Decompose batch request into atomic changes"
      },
      "in": {
        "docs": [
          "1"
        ],
        "max_tokens": 32768,
        "messages": [
          {
            "role": "user",
            "content": "You are a VL project architect. Break down the following batch change request into a list of atomic, independent changes.\n\nCurrent ProjectMeta:"
          },
          {
            "role": "user",
            "content": "=currentMeta"
          },
          {
            "role": "user",
            "content": "Batch request:"
          },
          {
            "role": "user",
            "content": "=batchRequest"
          },
          {
            "role": "user",
            "content": "Return JSON with:\n- updatedMeta: FULL updated ProjectMeta reflecting ALL changes\n- changes: [{id: \"change_01\", type: \"editSection\"|\"editService\"|\"editDatabase\"|\"editApp\"|\"newComponent\", file: \"path/to/file\", description: \"what to change\", priority: 1-5}]\n\nSort changes by priority (1=highest). Group related changes into single atomic operations where possible. Each change must be independently executable."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        },
        "stream": true
      },
      "out": {
        "$changeList": "=_result.changes",
        "$updatedMeta": "=_result.updatedMeta"
      },
      "next": "Pause_020_ReviewChanges"
    },
    {
      "id": "Pause_020_ReviewChanges",
      "meta": {
        "title": "2. Review change list (developer checkpoint)"
      },
      "resumeResultTarget": "$approved",
      "next": "Branch_025_CheckApproval"
    },
    {
      "id": "Branch_025_CheckApproval",
      "meta": {
        "title": "Check approval"
      },
      "cases": [
        {
          "condition": "=$approved === false",
          "next": "Stop_Cancelled"
        }
      ],
      "default": "Loop_030_ExecuteChanges"
    },
    {
      "id": "Loop_030_ExecuteChanges",
      "meta": {
        "title": "3. Execute each atomic change"
      },
      "source": "=$changeList",
      "mode": "serial",
      "children": [
        "LLM_031_ApplyChange"
      ],
      "next": "Set_040_UpdateMeta",
      "onError": "skip"
    },
    {
      "id": "LLM_031_ApplyChange",
      "meta": {
        "title": "Apply change: =_item.id — =_item.description"
      },
      "in": {
        "docs": [
          "1"
        ],
        "max_tokens": 32768,
        "stream": true,
        "readFiles": [
          "=_item.file"
        ],
        "messages": [
          {
            "role": "user",
            "content": "Apply the following change to a VL file.\n\nChange spec:"
          },
          {
            "role": "user",
            "content": "=_item"
          },
          {
            "role": "user",
            "content": "Updated project metadata (for reference):"
          },
          {
            "role": "user",
            "content": "=$updatedMeta"
          },
          {
            "role": "user",
            "content": "IMPORTANT: Output the COMPLETE updated file. Preserve everything that isn't being changed. Use VL 3.7 syntax with hyphen indentation.\n\nIMPORTANT: The file MUST start with '// VL_VERSION:3.7' as the first non-empty line."
          }
        ]
      },
      "out": {
        "/{_item.file}": "=_result"
      },
      "onError": "skip"
    },
    {
      "id": "Set_040_UpdateMeta",
      "meta": {
        "title": "4. Update ProjectMeta"
      },
      "in": {},
      "out": {
        "/.vl-code/ProjectMeta.json": "=$updatedMeta"
      },
      "next": "Set_050_SkipValidation"
    },
    {
      "id": "Set_050_SkipValidation",
      "meta": {
        "title": "5. Skip validation (generation-only mode)"
      },
      "target": "$validationSkipped",
      "value": "=true",
      "next": "Stop_Done"
    },
    {
      "id": "Stop_Done",
      "meta": {
        "title": "Batch adjustment complete"
      }
    },
    {
      "id": "Stop_Cancelled",
      "meta": {
        "title": "Batch adjustment cancelled by developer"
      }
    }
  ]
}
