{
  "version": "3.16",
  "name": "VL_FullStack_CodeGen_9Files",
  "description": "Full-stack code generation using 9 auxiliary files, default Theme/Theme.vth, and fully parallel VL file generation.",
  "_source": "DocCenter paths: 91-107 (agent prompts), 109 (9-file aux spec), 1 (VL 3.7 syntax)",
  "registry": {
    "params": [
      "userRequest(STRING)",
      "userRequirement(STRING)",
      "targetLang(STRING)"
    ],
    "services": [],
    "apis": [],
    "components": [
      "ClearExisting"
    ],
    "vars": [
      "$intentSpec(OBJECT)",
      "$intentSpecStr(STRING)",
      "$domainSchema(OBJECT)",
      "$domainSchemaStr(STRING)",
      "$serviceContractMap(OBJECT)",
      "$serviceContractMapStr(STRING)",
      "$uiContractMap(OBJECT)",
      "$uiContractMapStr(STRING)",
      "$moduleManifest(OBJECT)",
      "$moduleManifestStr(STRING)",
      "$dependencyGraph(OBJECT)",
      "$qualityGateSpec(OBJECT)",
      "$specValidation(OBJECT)",
      "$executionPlan(OBJECT)",
      "$vdbCode(STRING)",
      "$vthCode(STRING)",
      "$codeValidation(OBJECT)",
      "$repairPlan(OBJECT)",
      "$runState(OBJECT)"
    ],
    "files": {
      "inputs": [],
      "artifacts": [
        "Process/Specs/*",
        "Process/Run/*",
        "Database/*",
        "Theme/*",
        "Services/*",
        "Sections/*",
        "ExtComponents/*",
        "Apps/*"
      ]
    },
    "docs": {
      "1": "VL 3.7 Syntax Specification",
      "91": "Agent-100-IntentSpec-Prompt",
      "92": "Agent-200-DomainSchema-Prompt",
      "93": "Agent-300-ServiceContractMap-Prompt",
      "94": "Agent-400-UIContractMap-Prompt",
      "95": "Agent-500-ModuleManifest-Prompt",
      "96": "Agent-600-DependencyGraph-Prompt",
      "97": "Agent-700-QualityGateSpec-Prompt",
      "98": "Agent-800-ExecutionPlan-Prompt",
      "99": "Agent-900-RepairSpecs-Prompt",
      "100": "Agent-GenDatabase-Prompt",
      "101": "Agent-GenTheme-Prompt",
      "102": "Agent-GenServiceDomain-Prompt",
      "103": "Agent-GenComponent-Prompt",
      "104": "Agent-GenSection-Prompt",
      "105": "Agent-GenApp-Prompt",
      "106": "Agent-RepairPlan-Prompt",
      "107": "Agent-RepairVLFile-Prompt",
      "109": "VL-Aux-9File-Spec"
    }
  },
  "steps": [
    {
      "id": "Component_ClearExisting",
      "meta": {
        "title": "0. Clear existing VL files before regeneration"
      },
      "in": {},
      "out": {},
      "next": "Set_InitRunState"
    },
    {
      "id": "Set_InitRunState",
      "target": "$runState",
      "value": "={\"phase\":\"init\",\"status\":\"running\"}",
      "next": "LLM_GenIntentSpec",
      "meta": {
        "title": "Initialize RunState"
      }
    },
    {
      "id": "LLM_GenIntentSpec",
      "meta": {
        "title": "Agent-100 Generate IntentSpec"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "91"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "User Requirement:"
          },
          {
            "role": "user",
            "content": "=userRequest || userRequirement"
          },
          {
            "role": "user",
            "content": "Target Language:"
          },
          {
            "role": "user",
            "content": "=targetLang || 'zh-CN'"
          },
          {
            "role": "user",
            "content": "Generate Process/Specs/IntentSpec.json. Follow the spec precisely. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$intentSpec": "=_result",
        "$intentSpecStr": "=_result",
        "/Process/Specs/IntentSpec.json": "=_result"
      },
      "next": "LLM_GenDomainSchema"
    },
    {
      "id": "LLM_GenDomainSchema",
      "meta": {
        "title": "Agent-200 Generate DomainSchema"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "92"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "IntentSpec:"
          },
          {
            "role": "user",
            "content": "=$intentSpecStr"
          },
          {
            "role": "user",
            "content": "Generate Process/Specs/DomainSchema.json. Use exact VL types and canonical valueDomains. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$domainSchema": "=_result",
        "$domainSchemaStr": "=_result",
        "/Process/Specs/DomainSchema.json": "=_result"
      },
      "next": "Set_FanoutContractDesign"
    },
    {
      "id": "Set_FanoutContractDesign",
      "target": "$runState.phase",
      "value": "\"contract_design\"",
      "children": [
        "LLM_GenServiceContractMap",
        "LLM_GenQualityGateSpec"
      ],
      "next": "LLM_GenUIContractMap",
      "meta": {
        "title": "Parallel: ServiceContractMap + QualityGateSpec"
      }
    },
    {
      "id": "LLM_GenServiceContractMap",
      "meta": {
        "title": "Agent-300 ServiceContractMap"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "93"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "IntentSpec:"
          },
          {
            "role": "user",
            "content": "=$intentSpecStr"
          },
          {
            "role": "user",
            "content": "DomainSchema:"
          },
          {
            "role": "user",
            "content": "=$domainSchemaStr"
          },
          {
            "role": "user",
            "content": "Generate Process/Specs/ServiceContractMap.json. Keep strict DomainId.ServiceName format. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$serviceContractMap": "=_result",
        "$serviceContractMapStr": "=_result",
        "/Process/Specs/ServiceContractMap.json": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "LLM_GenQualityGateSpec",
      "meta": {
        "title": "Agent-700 QualityGateSpec"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "97"
        ],
        "max_tokens": 8192,
        "messages": [
          {
            "role": "user",
            "content": "IntentSpec:"
          },
          {
            "role": "user",
            "content": "=$intentSpecStr"
          },
          {
            "role": "user",
            "content": "DomainSchema:"
          },
          {
            "role": "user",
            "content": "=$domainSchemaStr"
          },
          {
            "role": "user",
            "content": "Generate Process/Specs/QualityGateSpec.json. Include spec integrity and VL code safety gate rules. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$qualityGateSpec": "=_result",
        "/Process/Specs/QualityGateSpec.json": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "LLM_GenUIContractMap",
      "meta": {
        "title": "Agent-400 UIContractMap"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "94"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "IntentSpec:"
          },
          {
            "role": "user",
            "content": "=$intentSpecStr"
          },
          {
            "role": "user",
            "content": "DomainSchema:"
          },
          {
            "role": "user",
            "content": "=$domainSchemaStr"
          },
          {
            "role": "user",
            "content": "ServiceContractMap:"
          },
          {
            "role": "user",
            "content": "=$serviceContractMapStr"
          },
          {
            "role": "user",
            "content": "Generate Process/Specs/UIContractMap.json. Enforce section cohesion, event wiring completeness, and app/section/component boundaries. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$uiContractMap": "=_result",
        "$uiContractMapStr": "=_result",
        "/Process/Specs/UIContractMap.json": "=_result"
      },
      "next": "Set_FanoutManifestGraph"
    },
    {
      "id": "Set_FanoutManifestGraph",
      "target": "$runState.phase",
      "value": "\"manifest_graph\"",
      "children": [
        "LLM_GenModuleManifest",
        "LLM_GenDependencyGraph"
      ],
      "next": "Set_320_SkipSpecValidation",
      "meta": {
        "title": "Parallel: ModuleManifest + DependencyGraph"
      }
    },
    {
      "id": "LLM_GenModuleManifest",
      "meta": {
        "title": "Agent-500 ModuleManifest"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "95"
        ],
        "max_tokens": 8192,
        "messages": [
          {
            "role": "user",
            "content": "IntentSpec:"
          },
          {
            "role": "user",
            "content": "=$intentSpecStr"
          },
          {
            "role": "user",
            "content": "ServiceContractMap:"
          },
          {
            "role": "user",
            "content": "=$serviceContractMapStr"
          },
          {
            "role": "user",
            "content": "UIContractMap:"
          },
          {
            "role": "user",
            "content": "=$uiContractMapStr"
          },
          {
            "role": "user",
            "content": "Generate Process/Specs/ModuleManifest.json. REQUIRED top-level fields: databaseFile({path,name}), themeFile({path,name}), serviceFiles([{path,name,domainId}]), componentFiles([{path,name,componentId}]), sectionFiles([{path,name,sectionId}]), appFiles([{path,name,appId}]). CRITICAL naming rules: databaseFile.path MUST be Database/<ProjectName>.vdb and themeFile.path MUST be Theme/Theme.vth. Every service/component/section/app file must use its exact final path. Paths must be relative. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$moduleManifest": "=_result",
        "$moduleManifestStr": "=_result",
        "/Process/Specs/ModuleManifest.json": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "LLM_GenDependencyGraph",
      "meta": {
        "title": "Agent-600 DependencyGraph"
      },
      "in": {
        "stream": true,
        "docs": [
          "109",
          "96"
        ],
        "max_tokens": 8192,
        "messages": [
          {
            "role": "user",
            "content": "ServiceContractMap:"
          },
          {
            "role": "user",
            "content": "=$serviceContractMapStr"
          },
          {
            "role": "user",
            "content": "UIContractMap:"
          },
          {
            "role": "user",
            "content": "=$uiContractMapStr"
          },
          {
            "role": "user",
            "content": "Generate Process/Specs/DependencyGraph.json. Build accurate module/service/state dependency edges. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$dependencyGraph": "=_result",
        "/Process/Specs/DependencyGraph.json": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "Set_320_SkipSpecValidation",
      "meta": {
        "title": "Skip spec validation (generation-only mode)"
      },
      "target": "$specValidation",
      "value": "={\"success\":true,\"skipped\":true,\"reason\":\"validation disabled\"}",
      "next": "LLM_BuildExecutionPlan"
    },
    {
      "id": "LLM_BuildExecutionPlan",
      "meta": {
        "title": "Build ExecutionPlan"
      },
      "in": {
        "stream": true,
        "docs": [
          "109",
          "98"
        ],
        "max_tokens": 8192,
        "messages": [
          {
            "role": "user",
            "content": "ModuleManifest:"
          },
          {
            "role": "user",
            "content": "=$moduleManifestStr"
          },
          {
            "role": "user",
            "content": "DependencyGraph:"
          },
          {
            "role": "user",
            "content": "=$dependencyGraph"
          },
          {
            "role": "user",
            "content": "QualityGateSpec:"
          },
          {
            "role": "user",
            "content": "=$qualityGateSpec"
          },
          {
            "role": "user",
            "content": "Generate Process/Run/ExecutionPlan.json. Build DAG tasks and parallel groups from module dependencies. Output ONLY valid JSON."
          }
        ],
        "output_config": {
          "format": {
            "type": "json_object"
          }
        }
      },
      "out": {
        "$executionPlan": "=_result",
        "/Process/Run/ExecutionPlan.json": "=_result"
      },
      "next": "Set_GenerationStart"
    },
    {
      "id": "Set_GenerationStart",
      "target": "$runState.phase",
      "value": "\"generation\"",
      "children": [
        "LLM_GenDatabase",
        "SeedTheme_GenTheme",
        "Loop_GenServiceDomains",
        "Loop_GenComponents",
        "Loop_GenSections",
        "Loop_GenApps"
      ],
      "next": "Set_560_SkipCodeValidation",
      "meta": {
        "title": "Code Generation Fanout (parallel)"
      }
    },
    {
      "id": "LLM_GenDatabase",
      "meta": {
        "title": "Generate .vdb Database"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "100"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "DomainSchema:"
          },
          {
            "role": "user",
            "content": "=$domainSchemaStr"
          },
          {
            "role": "user",
            "content": "ModuleManifest database file:"
          },
          {
            "role": "user",
            "content": "=$moduleManifest.databaseFile"
          },
          {
            "role": "user",
            "content": "Generate complete VL .vdb source code. Output ONLY VL source code, no markdown fences."
          }
        ]
      },
      "out": {
        "$vdbCode": "=_result",
        "/{$moduleManifest.databaseFile.path}": "=_result"
      },
      "onError": "skip",
      "next": "RETURN"
    },
    {
      "id": "SeedTheme_GenTheme",
      "meta": {
        "title": "Seed default Theme/Theme.vth"
      },
      "in": {
        "path": "Theme/Theme.vth"
      },
      "out": {
        "$vthCode": "=_result",
        "/{$moduleManifest.themeFile.path || 'Theme/Theme.vth'}": "=_result"
      },
      "next": "RETURN"
    },
    {
      "id": "Loop_GenServiceDomains",
      "meta": {
        "title": "Generate all .vs (parallel)"
      },
      "mode": "parallel",
      "source": "=$moduleManifest.serviceFiles",
      "children": [
        "LLM_GenServiceDomainFile"
      ],
      "next": "RETURN"
    },
    {
      "id": "LLM_GenServiceDomainFile",
      "meta": {
        "title": "Generate .vs Service"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "102"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "Target file:"
          },
          {
            "role": "user",
            "content": "=_item"
          },
          {
            "role": "user",
            "content": "ServiceContractMap:"
          },
          {
            "role": "user",
            "content": "=$serviceContractMapStr"
          },
          {
            "role": "user",
            "content": "DomainSchema:"
          },
          {
            "role": "user",
            "content": "=$domainSchemaStr"
          },
          {
            "role": "user",
            "content": "Generate complete VL .vs source code for this service domain. Output ONLY VL source code, no markdown fences."
          }
        ]
      },
      "out": {
        "/{_item.path}": "=_result"
      },
      "onError": "skip",
      "next": "RETURN"
    },
    {
      "id": "Loop_GenComponents",
      "meta": {
        "title": "Generate all .cp (parallel)"
      },
      "mode": "parallel",
      "source": "=$moduleManifest.componentFiles",
      "children": [
        "LLM_GenComponentFile"
      ],
      "next": "RETURN"
    },
    {
      "id": "LLM_GenComponentFile",
      "meta": {
        "title": "Generate .cp Component"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "103"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "Target file:"
          },
          {
            "role": "user",
            "content": "=_item"
          },
          {
            "role": "user",
            "content": "UIContractMap:"
          },
          {
            "role": "user",
            "content": "=$uiContractMapStr"
          },
          {
            "role": "user",
            "content": "IntentSpec:"
          },
          {
            "role": "user",
            "content": "=$intentSpecStr"
          },
          {
            "role": "user",
            "content": "Generate complete VL .cp source code. Pure UI only, no service calls. Output ONLY VL source code, no markdown fences."
          }
        ]
      },
      "out": {
        "/{_item.path}": "=_result"
      },
      "onError": "skip",
      "next": "RETURN"
    },
    {
      "id": "Loop_GenSections",
      "meta": {
        "title": "Generate all .sc (parallel)"
      },
      "mode": "parallel",
      "source": "=$moduleManifest.sectionFiles",
      "children": [
        "LLM_GenSectionFile"
      ],
      "next": "RETURN"
    },
    {
      "id": "LLM_GenSectionFile",
      "meta": {
        "title": "Generate .sc Section"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "104"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "Target file:"
          },
          {
            "role": "user",
            "content": "=_item"
          },
          {
            "role": "user",
            "content": "UIContractMap:"
          },
          {
            "role": "user",
            "content": "=$uiContractMapStr"
          },
          {
            "role": "user",
            "content": "ServiceContractMap:"
          },
          {
            "role": "user",
            "content": "=$serviceContractMapStr"
          },
          {
            "role": "user",
            "content": "DomainSchema:"
          },
          {
            "role": "user",
            "content": "=$domainSchemaStr"
          },
          {
            "role": "user",
            "content": "Generate complete VL .sc source code. Section handles business logic and service calls. Output ONLY VL source code, no markdown fences."
          }
        ]
      },
      "out": {
        "/{_item.path}": "=_result"
      },
      "onError": "skip",
      "next": "RETURN"
    },
    {
      "id": "Loop_GenApps",
      "meta": {
        "title": "Generate all .vx (parallel)"
      },
      "mode": "parallel",
      "source": "=$moduleManifest.appFiles",
      "children": [
        "LLM_GenAppFile"
      ],
      "next": "RETURN"
    },
    {
      "id": "LLM_GenAppFile",
      "meta": {
        "title": "Generate .vx App"
      },
      "in": {
        "stream": true,
        "docs": [
          "1",
          "109",
          "105"
        ],
        "max_tokens": 16000,
        "messages": [
          {
            "role": "user",
            "content": "Target file:"
          },
          {
            "role": "user",
            "content": "=_item"
          },
          {
            "role": "user",
            "content": "UIContractMap:"
          },
          {
            "role": "user",
            "content": "=$uiContractMapStr"
          },
          {
            "role": "user",
            "content": "Generate complete VL .vx source code. App controls routing, section orchestration, and app-level state/event wiring. Output ONLY VL source code, no markdown fences."
          }
        ]
      },
      "out": {
        "/{_item.path}": "=_result"
      },
      "onError": "skip",
      "next": "RETURN"
    },
    {
      "id": "Set_560_SkipCodeValidation",
      "meta": {
        "title": "Skip generated-code validation (generation-only mode)"
      },
      "target": "$codeValidation",
      "value": "={\"success\":true,\"skipped\":true,\"reason\":\"validation disabled\"}",
      "next": "Stop_Success"
    },
    {
      "id": "Stop_Success",
      "meta": {
        "title": "Code Generation Complete"
      }
    }
  ]
}
