meta-direct-codegen.json 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. {
  2. "version": "3.16",
  3. "name": "MetaDirect-CodeGen",
  4. "description": "Small-project code generation: ProjectMeta -> default Theme/Theme.vth + project database -> all VL files in parallel.",
  5. "registry": {
  6. "params": [
  7. "userRequest(STRING)",
  8. "targetLang(STRING)"
  9. ],
  10. "services": [],
  11. "apis": [],
  12. "components": [],
  13. "vars": [
  14. "$projectMeta(OBJECT)",
  15. "$projectMetaStr(STRING)",
  16. "$vdbContent(STRING)",
  17. "$vthContent(STRING)",
  18. "$codeValidation(OBJECT)",
  19. "$repairPlan(OBJECT)"
  20. ],
  21. "files": {
  22. "inputs": [],
  23. "artifacts": [
  24. ".vl-code/ProjectMeta.json",
  25. "Database/*",
  26. "Theme/*",
  27. "Services/*",
  28. "ExtComponents/*",
  29. "Sections/*",
  30. "Apps/*"
  31. ]
  32. },
  33. "docs": {
  34. "1": "VL Syntax Rules",
  35. "100": "Agent-GenDatabase: .vdb generation",
  36. "101": "Agent-GenTheme: .vth generation",
  37. "102": "Agent-GenServiceDomain: .vs generation",
  38. "103": "Agent-GenComponent: .cp generation",
  39. "104": "Agent-GenSection: .sc generation",
  40. "105": "Agent-GenApp: .vx generation",
  41. "107": "Agent-RepairVLFile: Targeted repair for failed VL files",
  42. "111": "Agent-MetaDirect: Generate ProjectMeta directly from user request"
  43. }
  44. },
  45. "steps": [
  46. {
  47. "id": "ClearFiles_005_ClearExisting",
  48. "meta": {
  49. "title": "0. Clear existing VL files before regeneration"
  50. },
  51. "in": {},
  52. "out": {},
  53. "next": "LLM_010_GenMeta"
  54. },
  55. {
  56. "id": "LLM_010_GenMeta",
  57. "meta": {
  58. "title": "1. Generate ProjectMeta directly from user request"
  59. },
  60. "in": {
  61. "docs": [
  62. "1",
  63. "111"
  64. ],
  65. "max_tokens": 16000,
  66. "stream": true,
  67. "messages": [
  68. {
  69. "role": "user",
  70. "content": "User Request:"
  71. },
  72. {
  73. "role": "user",
  74. "content": "=userRequest"
  75. },
  76. {
  77. "role": "user",
  78. "content": "Target Language: =targetLang"
  79. },
  80. {
  81. "role": "user",
  82. "content": "Generate the complete ProjectMeta JSON. REQUIRED structure:\n{\n \"specVersion\": \"ProjectMeta/1.0\",\n \"projectName\": \"<PascalCase name>\",\n \"projectDescription\": \"...\",\n \"vlVersion\": \"3.5\",\n \"config\": { \"defaultDevice\": \"Phone\", \"defaultResolution\": \"375x812\", \"themeFile\": \"Theme/Theme.vth\", \"colorScheme\": \"light\" },\n \"database\": { \"file\": \"Database/<ProjectName>.vdb\" },\n \"theme\": { \"file\": \"Theme/Theme.vth\" },\n \"dataSchema\": { \"tables\": [{ \"id\": \"<TableName>\", \"fields\": [{ \"name\": \"...\", \"type\": \"INT|STRING|BOOL|TIMESTAMP|FLOAT\", \"constraints\": [\"PK\",\"autoIncrement\",\"notNull\"] }], \"indexes\": [] }], \"relations\": [] },\n \"services\": [{ \"domainId\": \"<ServiceName>\", \"filePath\": \"Services/<ServiceName>.vs\", \"methods\": [{ \"id\": \"<MethodName>\", \"isPublic\": false, \"params\": \"paramName(TYPE)\", \"description\": \"...\" }], \"virtualTables\": [{ \"id\": \"<TableName>\", \"alias\": \"<alias>\" }] }],\n \"components\": [{ \"id\": \"<CompName>\", \"filePath\": \"ExtComponents/<CompName>.cp\", \"props\": [{ \"name\": \"...\", \"type\": \"...\", \"default\": \"...\" }], \"slots\": [] }],\n \"sections\": [{ \"id\": \"<SectionName>\", \"filePath\": \"Sections/<SectionName>.sc\", \"consumesServices\": [\"<ServiceName>\"], \"usesComponents\": [\"<CompName>\"], \"bindings\": [{ \"var\": \"$varName\", \"source\": \"<ServiceName>.<MethodName>\" }], \"events\": [{ \"trigger\": \"...\", \"action\": \"<ServiceName>.<MethodName>\", \"params\": \"...\" }] }],\n \"apps\": [{ \"id\": \"<AppName>\", \"filePath\": \"Apps/<AppName>.vx\", \"routes\": [{ \"path\": \"/<path>\", \"section\": \"<SectionName>\" }], \"layout\": { \"type\": \"tabs|stack|drawer\", \"items\": [\"<SectionName>\"] } }]\n}\nCRITICAL: Every section MUST have consumesServices and usesComponents arrays linking to actual services/components. Every entity MUST have filePath. Output ONLY valid JSON."
  83. }
  84. ],
  85. "output_config": {
  86. "format": {
  87. "type": "json_object"
  88. }
  89. }
  90. },
  91. "out": {
  92. "$projectMeta": "=_result",
  93. "$projectMetaStr": "=_result",
  94. "/.vl-code/ProjectMeta.json": "=_result"
  95. },
  96. "next": "Fork_DBTheme"
  97. },
  98. {
  99. "id": "Fork_DBTheme",
  100. "meta": {
  101. "title": "2. Generate Database + seed default Theme in parallel"
  102. },
  103. "children": [
  104. "LLM_020_GenDB",
  105. "SeedTheme_030_DefaultTheme"
  106. ],
  107. "next": "Loop_Services"
  108. },
  109. {
  110. "id": "LLM_020_GenDB",
  111. "meta": {
  112. "title": "2a. Generate Database Schema (.vdb)"
  113. },
  114. "in": {
  115. "docs": [
  116. "1",
  117. "100"
  118. ],
  119. "max_tokens": 8192,
  120. "stream": true,
  121. "messages": [
  122. {
  123. "role": "user",
  124. "content": "ProjectMeta:"
  125. },
  126. {
  127. "role": "user",
  128. "content": "=$projectMetaStr"
  129. },
  130. {
  131. "role": "user",
  132. "content": "Generate the .vdb database schema file based on the databases defined in ProjectMeta."
  133. }
  134. ]
  135. },
  136. "out": {
  137. "$vdbContent": "=_result",
  138. "/{$projectMeta.database.file || ('Database/' + $projectMeta.projectName + '.vdb')}": "=_result"
  139. }
  140. },
  141. {
  142. "id": "SeedTheme_030_DefaultTheme",
  143. "meta": {
  144. "title": "2b. Seed default Theme/Theme.vth"
  145. },
  146. "in": {
  147. "path": "Theme/Theme.vth"
  148. },
  149. "out": {
  150. "$vthContent": "=_result",
  151. "/Theme/Theme.vth": "=_result"
  152. },
  153. "next": "RETURN"
  154. },
  155. {
  156. "id": "Loop_Services",
  157. "meta": {
  158. "title": "3. Generate Service Domains (parallel)"
  159. },
  160. "source": "=$projectMeta.services",
  161. "mode": "parallel",
  162. "children": [
  163. "LLM_040_GenService"
  164. ],
  165. "next": "Loop_Components"
  166. },
  167. {
  168. "id": "LLM_040_GenService",
  169. "meta": {
  170. "title": "Generate Service: =_item.domainId"
  171. },
  172. "in": {
  173. "docs": [
  174. "1",
  175. "102"
  176. ],
  177. "max_tokens": 8192,
  178. "stream": true,
  179. "messages": [
  180. {
  181. "role": "user",
  182. "content": "ProjectMeta:"
  183. },
  184. {
  185. "role": "user",
  186. "content": "=$projectMetaStr"
  187. },
  188. {
  189. "role": "user",
  190. "content": "Database Schema:"
  191. },
  192. {
  193. "role": "user",
  194. "content": "=$vdbContent"
  195. },
  196. {
  197. "role": "user",
  198. "content": "Generate the .vs service domain file for:"
  199. },
  200. {
  201. "role": "user",
  202. "content": "=_item"
  203. },
  204. {
  205. "role": "user",
  206. "content": "Backend query-safety rules: build filter arrays incrementally. If an optional STRING/INT filter is empty, null, 0, or -1 (used as 'all'), DO NOT include that condition in select/count queries. Never generate conditions like [\"field\",\"*eq\",\"\"] or [\"field\",\"*contains\",\"\"] for optional filters. Prefer `_conditions([]) = []` plus IF checks and `_conditions.push(...)`."
  207. }
  208. ]
  209. },
  210. "out": {
  211. "/{_item.filePath}": "=_result"
  212. },
  213. "onError": "skip"
  214. },
  215. {
  216. "id": "Loop_Components",
  217. "meta": {
  218. "title": "4. Generate Components"
  219. },
  220. "source": "=$projectMeta.components",
  221. "mode": "parallel",
  222. "children": [
  223. "LLM_050_GenComponent"
  224. ],
  225. "next": "Loop_Sections"
  226. },
  227. {
  228. "id": "LLM_050_GenComponent",
  229. "meta": {
  230. "title": "Generate Component: =_item.id"
  231. },
  232. "in": {
  233. "docs": [
  234. "1",
  235. "103"
  236. ],
  237. "max_tokens": 8192,
  238. "stream": true,
  239. "messages": [
  240. {
  241. "role": "user",
  242. "content": "ProjectMeta:"
  243. },
  244. {
  245. "role": "user",
  246. "content": "=$projectMetaStr"
  247. },
  248. {
  249. "role": "user",
  250. "content": "Theme:"
  251. },
  252. {
  253. "role": "user",
  254. "content": "=$vthContent"
  255. },
  256. {
  257. "role": "user",
  258. "content": "Generate the .cp component file for:"
  259. },
  260. {
  261. "role": "user",
  262. "content": "=_item"
  263. }
  264. ]
  265. },
  266. "out": {
  267. "/{_item.filePath}": "=_result"
  268. },
  269. "onError": "skip"
  270. },
  271. {
  272. "id": "Loop_Sections",
  273. "meta": {
  274. "title": "5. Generate Sections (parallel)"
  275. },
  276. "source": "=$projectMeta.sections",
  277. "mode": "parallel",
  278. "children": [
  279. "LLM_060_GenSection"
  280. ],
  281. "next": "Loop_Apps"
  282. },
  283. {
  284. "id": "LLM_060_GenSection",
  285. "meta": {
  286. "title": "Generate Section: =_item.id"
  287. },
  288. "in": {
  289. "docs": [
  290. "1",
  291. "104"
  292. ],
  293. "max_tokens": 16000,
  294. "stream": true,
  295. "messages": [
  296. {
  297. "role": "user",
  298. "content": "ProjectMeta:"
  299. },
  300. {
  301. "role": "user",
  302. "content": "=$projectMetaStr"
  303. },
  304. {
  305. "role": "user",
  306. "content": "Database Schema:"
  307. },
  308. {
  309. "role": "user",
  310. "content": "=$vdbContent"
  311. },
  312. {
  313. "role": "user",
  314. "content": "Theme:"
  315. },
  316. {
  317. "role": "user",
  318. "content": "=$vthContent"
  319. },
  320. {
  321. "role": "user",
  322. "content": "Generate the .sc section file for:"
  323. },
  324. {
  325. "role": "user",
  326. "content": "=_item"
  327. },
  328. {
  329. "role": "user",
  330. "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 ProjectMeta / generated services, and keep ServiceDomain / Service names aligned with declared ids. 4) Prefer 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."
  331. }
  332. ]
  333. },
  334. "out": {
  335. "/{_item.filePath}": "=_result"
  336. },
  337. "onError": "retry",
  338. "retryCount": 1
  339. },
  340. {
  341. "id": "Loop_Apps",
  342. "meta": {
  343. "title": "6. Generate Apps (parallel)"
  344. },
  345. "source": "=$projectMeta.apps",
  346. "mode": "parallel",
  347. "children": [
  348. "LLM_070_GenApp"
  349. ],
  350. "next": "Set_080_SkipValidation"
  351. },
  352. {
  353. "id": "LLM_070_GenApp",
  354. "meta": {
  355. "title": "Generate App: =_item.id"
  356. },
  357. "in": {
  358. "docs": [
  359. "1",
  360. "105"
  361. ],
  362. "max_tokens": 8192,
  363. "stream": true,
  364. "messages": [
  365. {
  366. "role": "user",
  367. "content": "ProjectMeta:"
  368. },
  369. {
  370. "role": "user",
  371. "content": "=$projectMetaStr"
  372. },
  373. {
  374. "role": "user",
  375. "content": "Generate the .vx app file for:"
  376. },
  377. {
  378. "role": "user",
  379. "content": "=_item"
  380. }
  381. ]
  382. },
  383. "out": {
  384. "/{_item.filePath}": "=_result"
  385. },
  386. "onError": "retry",
  387. "retryCount": 1
  388. },
  389. {
  390. "id": "Set_080_SkipValidation",
  391. "meta": {
  392. "title": "7. Skip validation (generation-only mode)"
  393. },
  394. "target": "$codeValidation",
  395. "value": "={\"success\":true,\"skipped\":true,\"reason\":\"validation disabled\"}",
  396. "next": "Stop_Done"
  397. },
  398. {
  399. "id": "Stop_Done",
  400. "meta": {
  401. "title": "Done"
  402. }
  403. }
  404. ]
  405. }