{
  "version": "3.16",
  "name": "VL_FullStack_CodeGen_3Files",
  "description": "Full-stack code generation using 3 auxiliary files: PRD -> default Theme/Theme.vth + VDB + ServiceMap + UIMap -> all VL files in parallel.",
  "_source": "DocCenter paths: 31-38 (agent prompts), 39 (aux spec), 1 (VL 3.7 syntax)",
  "registry": {
    "params": [
      "userRequest(STRING)",
      "targetLang(STRING)"
    ],
    "services": [],
    "apis": [],
    "components": [
      "ClearExisting"
    ],
    "vars": [
      "$prdJson(OBJECT)",
      "$prdJsonStr(STRING)",
      "$vdbContent(STRING)",
      "$serviceMapJson(OBJECT)",
      "$serviceMapJsonStr(STRING)",
      "$uiMapJson(OBJECT)",
      "$uiMapJsonStr(STRING)"
    ],
    "files": {
      "inputs": [
        "Process/Input/*",
        "Theme/Theme.vth"
      ],
      "artifacts": [
        "Process/Artifacts/*",
        "Database/*",
        "Services/*",
        "Sections/*",
        "ExtComponents/*",
        "Apps/*",
        "Theme/*"
      ]
    },
    "docs": {
      "1": "VL 3.7 Syntax Specification",
      "31": "Agent-100-PRD-Prompt",
      "32": "Agent-200-DB-Prompt",
      "33": "Agent-300-ServiceMap-Prompt",
      "34": "Agent-400-UIMap-Prompt",
      "35": "Agent-500-Component-Prompt",
      "36": "Agent-600-ServiceDomain-Prompt",
      "37": "Agent-700-Section-Prompt",
      "38": "Agent-800-AppEntry-Prompt"
    }
  },
  "steps": [
    {
      "id": "Component_ClearExisting",
      "meta": {
        "title": "0. Clear existing VL files before regeneration"
      },
      "in": {},
      "out": {},
      "next": "SeedTheme_050_DefaultTheme"
    },
    {
      "id": "SeedTheme_050_DefaultTheme",
      "meta": {
        "title": "0a. Seed default Theme/Theme.vth"
      },
      "in": {
        "path": "Theme/Theme.vth"
      },
      "out": {
        "/Theme/Theme.vth": "=_result"
      },
      "next": "LLM_100_PRD"
    },
    {
      "id": "LLM_100_PRD",
      "meta": {
        "title": "Agent-1 · PRD Analysis"
      },
      "in": {
        "docs": [
          "1",
          "31"
        ],
        "max_tokens": 8192,
        "messages": [
          {
            "role": "user",
            "content": "Requirement:"
          },
          {
            "role": "user",
            "content": "=userRequest"
          },
          {
            "role": "user",
            "content": "Target Language:"
          },
          {
            "role": "user",
            "content": "=targetLang"
          },
          {
            "role": "user",
            "content": "Naming contract: projectName must be PascalCase; database file is Database/<ProjectName>.vdb; theme file is Theme/Theme.vth."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$prdJson": "=_result",
        "$prdJsonStr": "=_result",
        "/Process/Artifacts/PRD.json": "=_result"
      },
      "next": "LLM_200_DB"
    },
    {
      "id": "LLM_200_DB",
      "meta": {
        "title": "Agent-2 · VDB Database Generation"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "32"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "PRD:"
          },
          {
            "role": "user",
            "content": "=$prdJsonStr"
          }
        ]
      },
      "out": {
        "$vdbContent": "=_result",
        "/Database/{$prdJson.projectName || 'Project'}.vdb": "=_result"
      },
      "next": "LLM_300_ServiceMap"
    },
    {
      "id": "LLM_300_ServiceMap",
      "meta": {
        "title": "Agent-3 · ServiceMap Service Contract"
      },
      "in": {
        "docs": [
          "1",
          "33"
        ],
        "max_tokens": 8192,
        "messages": [
          {
            "role": "user",
            "content": "PRD:"
          },
          {
            "role": "user",
            "content": "=$prdJsonStr"
          },
          {
            "role": "user",
            "content": "VDB:"
          },
          {
            "role": "user",
            "content": "=$vdbContent"
          },
          {
            "role": "user",
            "content": "Service naming contract: every generated service filePath must be Services/<DomainId>.vs."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$serviceMapJson": "=_result",
        "$serviceMapJsonStr": "=_result",
        "/Process/Artifacts/ServiceMap.json": "=_result"
      },
      "next": "LLM_400_UIMap"
    },
    {
      "id": "LLM_400_UIMap",
      "meta": {
        "title": "Agent-4 · UIMap UI Architecture"
      },
      "in": {
        "docs": [
          "1",
          "34"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "PRD:"
          },
          {
            "role": "user",
            "content": "=$prdJsonStr"
          },
          {
            "role": "user",
            "content": "ServiceMap:"
          },
          {
            "role": "user",
            "content": "=$serviceMapJsonStr"
          },
          {
            "role": "user",
            "content": "UI naming contract: theme file is Theme/Theme.vth; component filePath is ExtComponents/<Id>.cp; section filePath is Sections/<Id>.sc; app filePath is Apps/<Id>.vx."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$uiMapJson": "=_result",
        "$uiMapJsonStr": "=_result",
        "/Process/Artifacts/UIMap.json": "=_result"
      },
      "next": "Loop_Components"
    },
    {
      "id": "Loop_Components",
      "meta": {
        "title": "Phase-5 · Component Generation (.cp, parallel)"
      },
      "source": "=$uiMapJson.components",
      "mode": "parallel",
      "children": [
        "LLM_500_Component"
      ],
      "next": "Loop_ServiceDomains"
    },
    {
      "id": "LLM_500_Component",
      "meta": {
        "title": "Agent-5 · .cp Component"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "35"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "ComponentItem:"
          },
          {
            "role": "user",
            "content": "=_item + ''"
          },
          {
            "role": "user",
            "content": "UIMap:"
          },
          {
            "role": "user",
            "content": "=$uiMapJsonStr"
          }
        ]
      },
      "out": {
        "/{_item.filePath}": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "Loop_ServiceDomains",
      "meta": {
        "title": "Phase-6 · Service Generation (.vs)"
      },
      "source": "=$serviceMapJson.serviceDomains",
      "mode": "parallel",
      "children": [
        "LLM_600_ServiceDomain"
      ],
      "next": "Loop_Sections"
    },
    {
      "id": "LLM_600_ServiceDomain",
      "meta": {
        "title": "Agent-6 · .vs Service"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "36"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "DomainItem:"
          },
          {
            "role": "user",
            "content": "=_item + ''"
          },
          {
            "role": "user",
            "content": "ServiceMap:"
          },
          {
            "role": "user",
            "content": "=$serviceMapJsonStr"
          },
          {
            "role": "user",
            "content": "VDB:"
          },
          {
            "role": "user",
            "content": "=$vdbContent"
          }
        ]
      },
      "out": {
        "/{_item.filePath}": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "Loop_Sections",
      "meta": {
        "title": "Phase-7 · Section Generation (.sc, parallel)"
      },
      "source": "=$uiMapJson.sections",
      "mode": "parallel",
      "children": [
        "LLM_700_Section"
      ],
      "next": "Loop_Apps"
    },
    {
      "id": "LLM_700_Section",
      "meta": {
        "title": "Agent-7 · .sc Section"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "37"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "SectionItem:"
          },
          {
            "role": "user",
            "content": "=_item + ''"
          },
          {
            "role": "user",
            "content": "UIMap:"
          },
          {
            "role": "user",
            "content": "=$uiMapJsonStr"
          },
          {
            "role": "user",
            "content": "ServiceMap:"
          },
          {
            "role": "user",
            "content": "=$serviceMapJsonStr"
          },
          {
            "role": "user",
            "content": "Compile-safety rules: 1) style: values must be static string literals only; NEVER use ternary, concat, variables, or any expression inside style:. If appearance depends on data, split the node with If blocks or use StateStyle conditions; never write style:($cond ? \"a\" : \"b\"). 2) NEVER emit CSS-only skin properties such as border-collapse. 3) Use only services that actually exist in ServiceMap, and keep ServiceDomain / Service names aligned with the declared domainId and serviceId. 4) Prefer simple VL-safe layout props over raw CSS. 5) NEVER bind events directly on <For-*> nodes; bind the event on the interactive child inside the loop instead. 6) NEVER emit deprecated <StateStyle-*> trigger:\"hover\" blocks. Output only valid .sc source."
          }
        ]
      },
      "out": {
        "/{_item.filePath}": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "Loop_Apps",
      "meta": {
        "title": "Phase-8 · App Entry Generation (.vx)"
      },
      "source": "=$uiMapJson.apps",
      "mode": "parallel",
      "children": [
        "LLM_800_AppEntry"
      ],
      "next": "Stop_Done"
    },
    {
      "id": "LLM_800_AppEntry",
      "meta": {
        "title": "Agent-8 · .vx App Entry"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "38"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "AppItem:"
          },
          {
            "role": "user",
            "content": "=_item + ''"
          },
          {
            "role": "user",
            "content": "UIMap:"
          },
          {
            "role": "user",
            "content": "=$uiMapJsonStr"
          },
          {
            "role": "user",
            "content": "Compile-safety rules: generate only VL-valid .vx source. Do not invent raw CSS properties, and only reference sections/components that exist in UIMap."
          }
        ]
      },
      "out": {
        "/{_item.filePath}": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "Stop_Done",
      "meta": {
        "title": "✅ Code Generation Complete"
      }
    }
  ]
}
