cluaupp 1.4.1 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +10 -5
  3. package/api/CHANGELOG.md +3 -0
  4. package/api/chat.js +74 -0
  5. package/api/fixtures/roblox/README.md +6 -0
  6. package/api/fixtures/roblox/aux/sample.d.luau +6 -0
  7. package/api/fixtures/roblox/mini/Mini-API-Dump.json +72 -0
  8. package/api/generated/bench-latest.json +39 -0
  9. package/api/generated/capability-profile.json +76 -0
  10. package/api/generated/lsp-index.json +1 -0
  11. package/api/generated/luau/classes.d.luau +11221 -0
  12. package/api/generated/luau/datatypes.d.luau +327 -0
  13. package/api/generated/luau/enums.d.luau +4918 -0
  14. package/api/generated/luau/globals.d.luau +12 -0
  15. package/api/manifests/roblox-target.manifest.json +22 -0
  16. package/api/normalized/roblox-target.profile.json +237461 -0
  17. package/api/overrides/classes.json +8 -0
  18. package/api/overrides/compatibility.json +9 -0
  19. package/api/overrides/datatypes.json +1579 -0
  20. package/api/overrides/enums.json +8 -0
  21. package/api/overrides/globals.json +8 -0
  22. package/api/overrides/type-mappings.json +9 -0
  23. package/api/roblox-api.lock.json +9 -0
  24. package/data/Mini-API-Dump.json +1 -0
  25. package/editors/vscode/README.md +19 -0
  26. package/editors/vscode/extension.js +222 -21
  27. package/editors/vscode/icons/axiom.svg +4 -0
  28. package/editors/vscode/icons/bloom.svg +5 -0
  29. package/editors/vscode/icons/flare.svg +5 -0
  30. package/editors/vscode/icons/helm.svg +4 -0
  31. package/editors/vscode/icons/hive.svg +5 -0
  32. package/editors/vscode/icons/mint.svg +4 -0
  33. package/editors/vscode/icons/shift.svg +6 -0
  34. package/editors/vscode/language-configuration-schema.json +24 -0
  35. package/editors/vscode/language-configuration.json +21 -0
  36. package/editors/vscode/package.json +220 -6
  37. package/editors/vscode/snippets/axiom.json +12 -0
  38. package/editors/vscode/snippets/bloom.json +12 -0
  39. package/editors/vscode/snippets/flare.json +27 -0
  40. package/editors/vscode/snippets/helm.json +12 -0
  41. package/editors/vscode/snippets/hive.json +12 -0
  42. package/editors/vscode/snippets/mint.json +12 -0
  43. package/editors/vscode/snippets/shift.json +17 -0
  44. package/editors/vscode/syntaxes/axiom.tmLanguage.json +5 -0
  45. package/editors/vscode/syntaxes/bloom.tmLanguage.json +5 -0
  46. package/editors/vscode/syntaxes/flare.tmLanguage.json +75 -0
  47. package/editors/vscode/syntaxes/helm.tmLanguage.json +5 -0
  48. package/editors/vscode/syntaxes/hive.tmLanguage.json +5 -0
  49. package/editors/vscode/syntaxes/mint.tmLanguage.json +5 -0
  50. package/editors/vscode/syntaxes/schema.tmLanguage.json +89 -0
  51. package/editors/vscode/syntaxes/shift.tmLanguage.json +5 -0
  52. package/examples/game/.cluaupp/compile-cache/ReplicatedStorage__Shared__Constants__Datas__TemplateData.clh.json +1 -0
  53. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Boot__DataBoot.server.clpp.json +1 -0
  54. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Configuration__ServerConfig.clp.json +1 -0
  55. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__Guard.server.clpp.json +1 -0
  56. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__PlayerHandler.server.clpp.json +1 -0
  57. package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterCharacterScripts__Character__CharacterReady.client.clpp.json +1 -0
  58. package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterPlayerScripts__Controllers__DataController.client.clpp.json +1 -0
  59. package/examples/game/.cluaupp/compile-cache/index.json +12 -0
  60. package/examples/game/.cluaupp/datamodel-profile.json +94 -0
  61. package/examples/game/.vscode/extensions.json +3 -1
  62. package/examples/game/.vscode/settings.json +13 -1
  63. package/examples/game/include/clpp/datatypes.clh +337 -373
  64. package/examples/game/include/clpp/generated/datamodel.clh +25 -0
  65. package/examples/game/include/clpp/generated/enums.clh +1 -1
  66. package/examples/game/include/clpp/generated/instances.clh +41135 -41064
  67. package/examples/game/include/clpp/libs/axiom.clh +1 -1
  68. package/examples/game/include/clpp/libs/math.clh +14 -0
  69. package/examples/game/include/clpp/libs/roster.clh +6 -0
  70. package/examples/game/include/clpp/libs/spring.clh +17 -0
  71. package/examples/game/include/clpp/libs/ward.clh +1 -0
  72. package/examples/game/include/clpp/roblox.clh +3 -4
  73. package/examples/game/libs/ArrayIndexer/init.luau +209 -0
  74. package/examples/game/libs/Axiom/init.luau +608 -0
  75. package/examples/game/libs/Bloom/init.luau +433 -0
  76. package/examples/game/libs/Coil/init.luau +215 -0
  77. package/examples/game/libs/Crest/init.luau +426 -0
  78. package/examples/game/libs/Echo/init.luau +417 -0
  79. package/examples/game/libs/Ember/init.luau +365 -0
  80. package/examples/game/libs/Flare/init.luau +717 -0
  81. package/examples/game/libs/Gleam/init.luau +729 -0
  82. package/examples/game/libs/Guide/init.luau +215 -0
  83. package/examples/game/libs/Helm/init.luau +377 -0
  84. package/examples/game/libs/Hive/init.luau +241 -0
  85. package/examples/game/libs/Keep/Client.luau +114 -0
  86. package/examples/game/libs/Keep/Data.luau +883 -0
  87. package/examples/game/libs/Keep/Engine.luau +211 -0
  88. package/examples/game/libs/Keep/Enum.luau +6 -0
  89. package/examples/game/libs/Keep/Enums.luau +10 -0
  90. package/examples/game/libs/Keep/Path.luau +236 -0
  91. package/examples/game/libs/Keep/Replicator.luau +298 -0
  92. package/examples/game/libs/Keep/Server.luau +251 -0
  93. package/examples/game/libs/Keep/Store.luau +652 -0
  94. package/examples/game/libs/Keep/Trade.luau +455 -0
  95. package/examples/game/libs/Keep/init.luau +205 -0
  96. package/examples/game/libs/Lens/init.luau +609 -0
  97. package/examples/game/libs/Mint/init.luau +279 -0
  98. package/examples/game/libs/Net/init.luau +156 -0
  99. package/examples/game/libs/Net/src/codec.luau +224 -0
  100. package/examples/game/libs/Occlude/init.luau +117 -0
  101. package/examples/game/libs/Pin/init.luau +309 -0
  102. package/examples/game/libs/Promise/LICENSE +21 -0
  103. package/examples/game/libs/Promise/_impl/LICENSE +21 -0
  104. package/examples/game/libs/Promise/_impl/init.lua +1991 -0
  105. package/examples/game/libs/Promise/init.lua +1990 -0
  106. package/examples/game/libs/Promise/init.luau +13 -0
  107. package/examples/game/libs/Promise/types.luau +46 -0
  108. package/examples/game/libs/Roster/init.luau +686 -0
  109. package/examples/game/libs/SOURCES.md +31 -0
  110. package/examples/game/libs/Shift/init.luau +238 -0
  111. package/examples/game/libs/Spark/init.luau +487 -0
  112. package/examples/game/libs/Stage/init.luau +178 -0
  113. package/examples/game/libs/Sweep/init.luau +259 -0
  114. package/examples/game/libs/Trace/init.luau +213 -0
  115. package/examples/game/libs/Ward/init.luau +211 -0
  116. package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau +29 -0
  117. package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau.map.json +13 -0
  118. package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau +83 -0
  119. package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau.map.json +13 -0
  120. package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau +18 -0
  121. package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau.map.json +13 -0
  122. package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau +14 -0
  123. package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau.map.json +13 -0
  124. package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau +15 -0
  125. package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau.map.json +13 -0
  126. package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau +50 -0
  127. package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau.map.json +13 -0
  128. package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau +12 -0
  129. package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau.map.json +13 -0
  130. package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau +16 -0
  131. package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau.map.json +13 -0
  132. package/examples/game/src/ReplicatedStorage/Shared/Net/Net.clh +26 -0
  133. package/examples/game/src/ReplicatedStorage/Shared/Net/Net.flare +5 -0
  134. package/examples/game/src/ServerScriptService/Boot/DataBoot.server.clpp +2 -2
  135. package/examples/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
  136. package/examples/game/stylua.toml +9 -0
  137. package/generated/api/build-profile.js +115 -0
  138. package/generated/api/cache.js +44 -0
  139. package/generated/api/coverage.js +32 -0
  140. package/generated/api/diff.js +125 -0
  141. package/generated/api/generators/clpp-headers.js +353 -0
  142. package/generated/api/generators/docs-reference.js +7 -0
  143. package/generated/api/generators/lsp-index.js +81 -0
  144. package/generated/api/generators/luau-defs.js +94 -0
  145. package/generated/api/ide.js +76 -0
  146. package/generated/api/identifier.js +47 -0
  147. package/generated/api/index.js +324 -0
  148. package/generated/api/loader.js +57 -0
  149. package/generated/api/merge.js +88 -0
  150. package/generated/api/model.js +5 -0
  151. package/generated/api/normalize.js +231 -0
  152. package/generated/api/overrides-validate.js +58 -0
  153. package/generated/api/perf.js +12 -0
  154. package/generated/api/registry.js +136 -0
  155. package/generated/api/release.js +44 -0
  156. package/generated/api/resolver.js +250 -0
  157. package/generated/api/sources/aux-types-diff.js +75 -0
  158. package/generated/api/sources/client-tracker.js +11 -0
  159. package/generated/api/sources/creator-docs.js +42 -0
  160. package/generated/api/sources/luau-types.js +34 -0
  161. package/generated/api/sources/mini-dump.js +17 -0
  162. package/generated/api/sources/studio-api.js +8 -0
  163. package/generated/api/sources/studio-apiv2.js +11 -0
  164. package/generated/api/sources/studio-full-api.js +8 -0
  165. package/generated/api/studio-smoke.js +80 -0
  166. package/generated/api/type-parse.js +49 -0
  167. package/generated/api/understander.js +51 -0
  168. package/generated/api/validate.js +135 -0
  169. package/generated/api-cli.js +421 -0
  170. package/generated/cli.js +17 -6
  171. package/generated/clpp/contract.js +3 -3
  172. package/generated/clpp/format-luau.js +236 -0
  173. package/generated/clpp/index.js +13 -1
  174. package/generated/clpp/modules.js +227 -0
  175. package/generated/clpp/postprocess.js +86 -5
  176. package/generated/clpp/rewrite-janitor.js +145 -0
  177. package/generated/clpp/runner.js +14 -2
  178. package/generated/compile.js +82 -0
  179. package/generated/flare/index.js +15 -3
  180. package/generated/flare/language.js +561 -0
  181. package/generated/flare/parse.js +19 -7
  182. package/generated/intellisense.js +76 -2
  183. package/generated/lsp.js +118 -7
  184. package/generated/native/index.js +217 -16
  185. package/generated/target/authority-check.js +136 -0
  186. package/generated/target/authority-graph.js +74 -0
  187. package/generated/target/build-cache.js +112 -0
  188. package/generated/target/capabilities.js +89 -0
  189. package/generated/target/capability-profile.js +30 -0
  190. package/generated/target/component-contracts.js +60 -0
  191. package/generated/target/context-check.js +160 -0
  192. package/generated/target/datamodel-check.js +170 -0
  193. package/generated/target/datamodel-generate.js +74 -0
  194. package/generated/target/datamodel.js +233 -0
  195. package/generated/target/diagnostics.js +63 -0
  196. package/generated/target/doctor.js +152 -0
  197. package/generated/target/flare-version.js +58 -0
  198. package/generated/target/get-service.js +69 -0
  199. package/generated/target/lifetime-check.js +47 -0
  200. package/generated/target/luau-stamp.js +39 -0
  201. package/generated/target/optimizer-advise.js +88 -0
  202. package/generated/target/optimizer-apply.js +44 -0
  203. package/generated/target/optimizer-soa.js +254 -0
  204. package/generated/target/parallel-check.js +136 -0
  205. package/generated/target/pgo.js +148 -0
  206. package/generated/target/project-docs.js +69 -0
  207. package/generated/target/project-graph.js +71 -0
  208. package/generated/target/roblox.js +63 -0
  209. package/generated/target/security-check.js +41 -0
  210. package/generated/target/source-map.js +25 -0
  211. package/generated/target/studio-bridge.js +112 -0
  212. package/generated/utils/project.js +178 -8
  213. package/generated/utils/rojo-mapper.js +11 -3
  214. package/include/clpp/datatypes.clh +337 -373
  215. package/include/clpp/generated/enums.clh +1 -1
  216. package/include/clpp/generated/instances.clh +41135 -41064
  217. package/include/clpp/libs/axiom.clh +1 -1
  218. package/include/clpp/libs/hive.clh +1 -0
  219. package/include/clpp/libs/keep.clh +2 -0
  220. package/include/clpp/libs/math.clh +14 -0
  221. package/include/clpp/libs/roster.clh +6 -0
  222. package/include/clpp/libs/spring.clh +17 -0
  223. package/include/clpp/libs/ward.clh +1 -0
  224. package/include/clpp/roblox.clh +3 -4
  225. package/package.json +10 -3
  226. package/plugins/CluauppNav/Plugin.luau +207 -0
  227. package/plugins/CluauppNav/ProfileLogger.luau +27 -0
  228. package/plugins/CluauppNav/README.md +24 -0
  229. package/runtime/Axiom/init.luau +10 -7
  230. package/runtime/Coil/init.luau +8 -2
  231. package/runtime/Crest/init.luau +1 -0
  232. package/runtime/Flare/init.luau +2 -1
  233. package/runtime/Gleam/init.luau +15 -4
  234. package/runtime/Hive/init.luau +36 -14
  235. package/runtime/Pin/init.luau +5 -2
  236. package/runtime/Roster/init.luau +8 -0
  237. package/runtime/Spark/init.luau +3 -0
  238. package/runtime/Sweep/init.luau +2 -0
  239. package/runtime/Trace/init.luau +3 -0
  240. package/runtime/Ward/init.luau +38 -5
  241. package/scripts/postinstall-editor.js +17 -0
  242. package/skills/README.md +13 -0
  243. package/skills/clpp-hive-flare/SKILL.md +79 -0
  244. package/skills/clpp-language/SKILL.md +123 -0
  245. package/skills/clpp-language/compiler.md +89 -0
  246. package/skills/clpp-style/SKILL.md +95 -0
  247. package/src/api/build-profile.ts +138 -0
  248. package/src/api/cache.ts +45 -0
  249. package/src/api/coverage.ts +46 -0
  250. package/src/api/diff.ts +143 -0
  251. package/src/api/generators/clpp-headers.ts +377 -0
  252. package/src/api/generators/docs-reference.ts +11 -0
  253. package/src/api/generators/lsp-index.ts +106 -0
  254. package/src/api/generators/luau-defs.ts +98 -0
  255. package/src/api/ide.ts +87 -0
  256. package/src/api/identifier.ts +47 -0
  257. package/src/api/index.ts +269 -0
  258. package/src/api/loader.ts +60 -0
  259. package/src/api/merge.ts +126 -0
  260. package/src/api/model.ts +283 -0
  261. package/src/api/normalize.ts +257 -0
  262. package/src/api/overrides-validate.ts +58 -0
  263. package/src/api/perf.ts +15 -0
  264. package/src/api/registry.ts +162 -0
  265. package/src/api/release.ts +47 -0
  266. package/src/api/resolver.ts +255 -0
  267. package/src/api/sources/aux-types-diff.ts +81 -0
  268. package/src/api/sources/client-tracker.ts +10 -0
  269. package/src/api/sources/creator-docs.ts +37 -0
  270. package/src/api/sources/luau-types.ts +30 -0
  271. package/src/api/sources/mini-dump.ts +50 -0
  272. package/src/api/sources/studio-api.ts +7 -0
  273. package/src/api/sources/studio-apiv2.ts +10 -0
  274. package/src/api/sources/studio-full-api.ts +7 -0
  275. package/src/api/studio-smoke.ts +82 -0
  276. package/src/api/type-parse.ts +48 -0
  277. package/src/api/understander.ts +72 -0
  278. package/src/api/validate.ts +160 -0
  279. package/src/api-cli.ts +493 -0
  280. package/src/api.generated.js +37 -22
  281. package/src/cli.ts +22 -7
  282. package/src/clpp/contract.ts +34 -3
  283. package/src/clpp/format-luau.ts +262 -0
  284. package/src/clpp/index.ts +13 -2
  285. package/src/clpp/modules.ts +252 -0
  286. package/src/clpp/postprocess.ts +100 -5
  287. package/src/clpp/rewrite-janitor.ts +156 -0
  288. package/src/clpp/runner.ts +14 -2
  289. package/src/compile.ts +87 -0
  290. package/src/flare/index.ts +20 -1
  291. package/src/flare/language.ts +708 -0
  292. package/src/flare/parse.ts +20 -7
  293. package/src/flare/types.ts +2 -0
  294. package/src/intellisense.ts +76 -2
  295. package/src/lsp.ts +151 -8
  296. package/src/native/index.ts +225 -16
  297. package/src/target/authority-check.ts +162 -0
  298. package/src/target/authority-graph.ts +80 -0
  299. package/src/target/build-cache.ts +129 -0
  300. package/src/target/capabilities.ts +115 -0
  301. package/src/target/capability-profile.ts +25 -0
  302. package/src/target/component-contracts.ts +64 -0
  303. package/src/target/context-check.ts +177 -0
  304. package/src/target/datamodel-check.ts +188 -0
  305. package/src/target/datamodel-generate.ts +78 -0
  306. package/src/target/datamodel.ts +261 -0
  307. package/src/target/diagnostics.ts +67 -0
  308. package/src/target/doctor.ts +171 -0
  309. package/src/target/flare-version.ts +61 -0
  310. package/src/target/get-service.ts +85 -0
  311. package/src/target/lifetime-check.ts +45 -0
  312. package/src/target/luau-stamp.ts +33 -0
  313. package/src/target/optimizer-advise.ts +93 -0
  314. package/src/target/optimizer-apply.ts +63 -0
  315. package/src/target/optimizer-soa.ts +270 -0
  316. package/src/target/parallel-check.ts +135 -0
  317. package/src/target/pgo.ts +157 -0
  318. package/src/target/project-docs.ts +68 -0
  319. package/src/target/project-graph.ts +75 -0
  320. package/src/target/roblox.ts +78 -0
  321. package/src/target/security-check.ts +40 -0
  322. package/src/target/source-map.ts +36 -0
  323. package/src/target/studio-bridge.ts +140 -0
  324. package/src/types.ts +14 -0
  325. package/src/utils/project.ts +183 -9
  326. package/src/utils/rojo-mapper.ts +12 -3
  327. package/stylua.toml +9 -0
  328. package/templates/game/.vscode/extensions.json +3 -1
  329. package/templates/game/.vscode/settings.json +8 -1
  330. package/templates/game/include/clpp/datatypes.clh +337 -373
  331. package/templates/game/include/clpp/generated/enums.clh +1 -1
  332. package/templates/game/include/clpp/generated/instances.clh +41135 -41064
  333. package/templates/game/include/clpp/libs/axiom.clh +1 -1
  334. package/templates/game/include/clpp/libs/roster.clh +6 -0
  335. package/templates/game/include/clpp/libs/ward.clh +1 -0
  336. package/templates/game/include/clpp/roblox.clh +3 -4
  337. package/templates/game/src/ReplicatedStorage/Shared/Net/Net.flare +5 -0
  338. package/templates/game/src/ServerScriptService/Boot/DataBoot.server.clpp +2 -2
  339. package/templates/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
  340. package/templates/game/stylua.toml +9 -0
@@ -0,0 +1,47 @@
1
+ /** Deterministic identifier escaping for CL++ headers. */
2
+
3
+ const CLPP_RESERVED = new Set([
4
+ "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break",
5
+ "case", "catch", "char", "class", "compl", "concept", "const", "consteval", "constexpr",
6
+ "const_cast", "continue", "co_await", "co_return", "co_yield", "decltype", "default",
7
+ "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern",
8
+ "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable",
9
+ "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator", "or", "or_eq",
10
+ "private", "protected", "public", "register", "reinterpret_cast", "requires", "return",
11
+ "short", "signed", "sizeof", "static", "static_assert", "static_cast", "struct", "switch",
12
+ "template", "this", "thread_local", "throw", "true", "try", "typedef", "typeid", "typename",
13
+ "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "xor", "xor_eq",
14
+ "NULL", "string",
15
+ ]);
16
+
17
+ const MEMBER_COLLISIONS: Record<string, Set<string>> = {
18
+ Instance: new Set(["class"]),
19
+ };
20
+
21
+ export function escapeIdent(name: string): string {
22
+ let out = String(name || "");
23
+ if (!out) {
24
+ return "_";
25
+ }
26
+ if (/^\d/.test(out)) {
27
+ out = `_${out}`;
28
+ }
29
+ out = out.replace(/[^A-Za-z0-9_]/g, "_");
30
+ if (CLPP_RESERVED.has(out)) {
31
+ out = `${out}_`;
32
+ }
33
+ return out;
34
+ }
35
+
36
+ export function escapeMember(owner: string, name: string): string {
37
+ const escaped = escapeIdent(name);
38
+ const collisions = MEMBER_COLLISIONS[owner];
39
+ if (collisions?.has(name) || collisions?.has(escaped)) {
40
+ return `${escaped}_`;
41
+ }
42
+ return escaped;
43
+ }
44
+
45
+ export function isReserved(name: string): boolean {
46
+ return CLPP_RESERVED.has(name);
47
+ }
@@ -0,0 +1,269 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { projectRoot } from "../package-info.js";
4
+ import { pkg } from "../package-info.js";
5
+ import { buildRobloxTargetProfile, profileContentHash, writeProfileCache } from "./build-profile.js";
6
+ import { computeCoverage } from "./coverage.js";
7
+ import { diffProfiles } from "./diff.js";
8
+ import { generateClppHeaders } from "./generators/clpp-headers.js";
9
+ import { generateLuauDefs, tryLuauAnalyze } from "./generators/luau-defs.js";
10
+ import { generateReferenceDocs } from "./generators/docs-reference.js";
11
+ import { writeLspIndex } from "./generators/lsp-index.js";
12
+ import { writeCapabilityProfile } from "../target/capability-profile.js";
13
+ import { overridesHash } from "./loader.js";
14
+ import type { RobloxTargetProfile } from "./model.js";
15
+ import { ROBLOX_TARGET_SCHEMA_VERSION } from "./model.js";
16
+ import { buildRegistry, searchRegistry } from "./registry.js";
17
+ import { hashBuffer } from "./resolver.js";
18
+ import { validateProfile } from "./validate.js";
19
+
20
+ export * from "./model.js";
21
+ export * from "./resolver.js";
22
+ export * from "./identifier.js";
23
+ export * from "./registry.js";
24
+ export * from "./diff.js";
25
+ export * from "./coverage.js";
26
+ export { buildRobloxTargetProfile, writeProfileCache, profileContentHash } from "./build-profile.js";
27
+ export { generateClppHeaders } from "./generators/clpp-headers.js";
28
+ export { generateLuauDefs } from "./generators/luau-defs.js";
29
+ export { generateReferenceDocs } from "./generators/docs-reference.js";
30
+ export { buildLspIndex, writeLspIndex, LSP_INDEX_SCHEMA_VERSION } from "./generators/lsp-index.js";
31
+ export { loadMiniDump } from "./sources/mini-dump.js";
32
+ export { loadStudioApi } from "./sources/studio-api.js";
33
+ export { loadStudioFullApi } from "./sources/studio-full-api.js";
34
+ export { loadStudioApiV2 } from "./sources/studio-apiv2.js";
35
+ export { loadLuauTypes } from "./sources/luau-types.js";
36
+ export { loadCreatorDocs } from "./sources/creator-docs.js";
37
+ export { loadClientTrackerDump } from "./sources/client-tracker.js";
38
+ export { diffAgainstAuxTypes } from "./sources/aux-types-diff.js";
39
+ export { escapeIdent, escapeMember, isReserved } from "./identifier.js";
40
+ export {
41
+ listMembers,
42
+ describeSymbol,
43
+ similarSymbols,
44
+ completeMember,
45
+ hoverSymbol,
46
+ suggestDidYouMean,
47
+ getApiRegistry,
48
+ } from "./ide.js";
49
+ export { runStudioSmoke, RUNTIME_SUITE } from "./studio-smoke.js";
50
+ export { matchIntents, understandSymbol, INTENT_RULES } from "./understander.js";
51
+ export { computeCacheKey, cacheKeyHash, readCache, writeCache } from "./cache.js";
52
+ export { resolveGetServiceType, runContextFromFileName, defaultRobloxProject, isRegisteredService } from "../target/roblox.js";
53
+ export { checkGetService, assertGetServiceSafe, collectGetServiceUses, rewriteGetServiceLuau } from "../target/get-service.js";
54
+ export { builtinCapabilityProfile, capabilitiesForContext, CAPABILITY_PROFILE_SCHEMA_VERSION } from "../target/capabilities.js";
55
+ export { checkContextSafety, assertContextSafe, stripNoise } from "../target/context-check.js";
56
+ export { writeCapabilityProfile, loadCapabilityProfile, capabilityProfilePath } from "../target/capability-profile.js";
57
+ export {
58
+ buildDatamodelProfile,
59
+ findProjectJson,
60
+ DATAMODEL_SCHEMA_VERSION,
61
+ } from "../target/datamodel.js";
62
+ export { checkDatamodelPaths, assertDatamodelSafe } from "../target/datamodel-check.js";
63
+ export { writeDatamodelArtifacts, generateDatamodelHeader } from "../target/datamodel-generate.js";
64
+ export { checkParallelSafety, assertParallelSafe } from "../target/parallel-check.js";
65
+ export { checkAuthority, assertAuthoritySafe, loadPlatformPolicy } from "../target/authority-check.js";
66
+ export { checkAuthorityGraph } from "../target/authority-graph.js";
67
+ export { checkComponentContracts } from "../target/component-contracts.js";
68
+ export { checkSecurity } from "../target/security-check.js";
69
+ export { checkLifetime } from "../target/lifetime-check.js";
70
+ export { adviseOptimizer, adviceAsDiagnostics } from "../target/optimizer-advise.js";
71
+ export { buildProjectGraph } from "../target/project-graph.js";
72
+ export { checkFlareVersions } from "../target/flare-version.js";
73
+ export { writeSourceMap } from "../target/source-map.js";
74
+ export { stampLuauFromClpp } from "../target/luau-stamp.js";
75
+ export { runDoctor } from "../target/doctor.js";
76
+ export { applyOptimizerHints } from "../target/optimizer-apply.js";
77
+ export {
78
+ generateSoaLuau,
79
+ applyLayoutPragmas,
80
+ writeSoaArtifacts,
81
+ collectSoaPlansFromProject,
82
+ planSoa,
83
+ listLayoutTargets,
84
+ } from "../target/optimizer-soa.js";
85
+ export { startStudioBridge, BRIDGE_DEFAULT_PORT } from "../target/studio-bridge.js";
86
+ export {
87
+ loadProfile,
88
+ writeProfileTemplate,
89
+ rankAdvice,
90
+ defaultProfilePath,
91
+ ingestProfile,
92
+ PGO_SCHEMA_VERSION,
93
+ } from "../target/pgo.js";
94
+ export { generateProjectDocs } from "../target/project-docs.js";
95
+ export {
96
+ fingerprintSource,
97
+ readCachedJob,
98
+ writeCachedJob,
99
+ mapPool,
100
+ defaultJobCount,
101
+ COMPILE_CACHE_SCHEMA,
102
+ } from "../target/build-cache.js";
103
+ export { buildReleaseChecklist, writeApiChangelog } from "./release.js";
104
+ export { timeCall, formatPerf } from "./perf.js";
105
+ export { validateOverrides, diffOverrideFiles } from "./overrides-validate.js";
106
+
107
+ export interface ManifestDocument {
108
+ schemaVersion: typeof ROBLOX_TARGET_SCHEMA_VERSION;
109
+ generatorVersion: string;
110
+ profileHash: string;
111
+ overridesHash: string;
112
+ sources: RobloxTargetProfile["sources"];
113
+ generatedAt: string;
114
+ }
115
+
116
+ export interface LockDocument {
117
+ schemaVersion: typeof ROBLOX_TARGET_SCHEMA_VERSION;
118
+ profileHash: string;
119
+ overridesHash: string;
120
+ robloxApiVersion?: string;
121
+ files: Record<string, string>;
122
+ }
123
+
124
+ export function generateAll(options: {
125
+ dumpPath?: string;
126
+ skipHeaders?: boolean;
127
+ skipLuau?: boolean;
128
+ skipDocs?: boolean;
129
+ skipLspIndex?: boolean;
130
+ } = {}): {
131
+ profile: RobloxTargetProfile;
132
+ manifestPath: string;
133
+ lockPath: string;
134
+ headerFiles: string[];
135
+ luauFiles: string[];
136
+ docFiles: string[];
137
+ lspIndexPath: string | null;
138
+ } {
139
+ const profile = buildRobloxTargetProfile({ dumpPath: options.dumpPath });
140
+ writeProfileCache(profile);
141
+ const headerFiles = options.skipHeaders ? [] : generateClppHeaders(profile).files;
142
+ const luauFiles = options.skipLuau ? [] : generateLuauDefs(profile);
143
+ const docFiles = options.skipDocs !== false ? [] : generateReferenceDocs(profile);
144
+ const lspIndexPath = options.skipLspIndex ? null : writeLspIndex(profile);
145
+ writeCapabilityProfile();
146
+
147
+ const fileHashes: Record<string, string> = {};
148
+ for (const file of [...headerFiles, ...luauFiles, ...(lspIndexPath ? [lspIndexPath] : [])]) {
149
+ fileHashes[path.relative(projectRoot, file).replace(/\\/g, "/")] = hashBuffer(fs.readFileSync(file));
150
+ }
151
+
152
+ const profileHash = profileContentHash(profile);
153
+ const oHash = overridesHash();
154
+ const manifest: ManifestDocument = {
155
+ schemaVersion: ROBLOX_TARGET_SCHEMA_VERSION,
156
+ generatorVersion: pkg.version,
157
+ profileHash,
158
+ overridesHash: oHash,
159
+ sources: profile.sources,
160
+ generatedAt: new Date().toISOString(),
161
+ };
162
+ const lock: LockDocument = {
163
+ schemaVersion: ROBLOX_TARGET_SCHEMA_VERSION,
164
+ profileHash,
165
+ overridesHash: oHash,
166
+ robloxApiVersion: profile.robloxApiVersion,
167
+ files: fileHashes,
168
+ };
169
+
170
+ const manifestsDir = path.join(projectRoot, "api", "manifests");
171
+ fs.mkdirSync(manifestsDir, { recursive: true });
172
+ const manifestPath = path.join(manifestsDir, "roblox-target.manifest.json");
173
+ const lockPath = path.join(projectRoot, "api", "roblox-api.lock.json");
174
+ atomicWriteJson(manifestPath, manifest);
175
+ atomicWriteJson(lockPath, lock);
176
+
177
+ return { profile, manifestPath, lockPath, headerFiles, luauFiles, docFiles, lspIndexPath };
178
+ }
179
+
180
+ function atomicWriteJson(file: string, value: unknown): void {
181
+ fs.mkdirSync(path.dirname(file), { recursive: true });
182
+ const tmp = `${file}.${process.pid}.tmp`;
183
+ fs.writeFileSync(tmp, `${JSON.stringify(value, null, "\t")}\n`, "utf8");
184
+ fs.renameSync(tmp, file);
185
+ }
186
+
187
+ export function verifyLock(): { ok: boolean; messages: string[] } {
188
+ const lockPath = path.join(projectRoot, "api", "roblox-api.lock.json");
189
+ const messages: string[] = [];
190
+ if (!fs.existsSync(lockPath)) {
191
+ return { ok: false, messages: ["roblox-api.lock.json missing — run cluaupp api generate"] };
192
+ }
193
+ const lock = JSON.parse(fs.readFileSync(lockPath, "utf8")) as LockDocument;
194
+ const profile = buildRobloxTargetProfile({ skipValidate: true });
195
+ const profileHash = profileContentHash(profile);
196
+ if (lock.profileHash !== profileHash) {
197
+ messages.push(`profile hash mismatch: lock=${lock.profileHash.slice(0, 12)}… current=${profileHash.slice(0, 12)}…`);
198
+ }
199
+ if (lock.overridesHash !== overridesHash()) {
200
+ messages.push("overrides hash mismatch");
201
+ }
202
+ for (const [rel, expected] of Object.entries(lock.files || {})) {
203
+ const full = path.join(projectRoot, rel);
204
+ if (!fs.existsSync(full)) {
205
+ messages.push(`missing generated file ${rel}`);
206
+ continue;
207
+ }
208
+ const actual = hashBuffer(fs.readFileSync(full));
209
+ if (actual !== expected) {
210
+ messages.push(`hash mismatch ${rel}`);
211
+ }
212
+ }
213
+ return { ok: messages.length === 0, messages };
214
+ }
215
+
216
+ export function inspectSymbol(symbol: string): unknown {
217
+ const profile = buildRobloxTargetProfile({ skipValidate: true });
218
+ const registry = buildRegistry(profile);
219
+ if (registry.classes.has(symbol)) {
220
+ return registry.classes.get(symbol);
221
+ }
222
+ if (registry.enums.has(symbol)) {
223
+ return registry.enums.get(symbol);
224
+ }
225
+ if (registry.datatypes.has(symbol)) {
226
+ return registry.datatypes.get(symbol);
227
+ }
228
+ if (registry.members.has(symbol)) {
229
+ return registry.members.get(symbol);
230
+ }
231
+ return searchRegistry(registry, symbol, 20);
232
+ }
233
+
234
+ export function apiCoverage(): ReturnType<typeof computeCoverage> {
235
+ const profile = buildRobloxTargetProfile({ skipValidate: true });
236
+ return computeCoverage(buildRegistry(profile));
237
+ }
238
+
239
+ export function apiDiffAgainstSnapshot(snapshotPath: string): ReturnType<typeof diffProfiles> {
240
+ const before = JSON.parse(fs.readFileSync(snapshotPath, "utf8")) as RobloxTargetProfile;
241
+ const after = buildRobloxTargetProfile({ skipValidate: true });
242
+ return diffProfiles(before, after);
243
+ }
244
+
245
+ export function writeSnapshot(outPath?: string): string {
246
+ const profile = buildRobloxTargetProfile();
247
+ const target = outPath || path.join(projectRoot, "api", "snapshots", "latest.profile.json");
248
+ writeProfileCache(profile, target);
249
+ return target;
250
+ }
251
+
252
+ export function validateCurrent(): ReturnType<typeof validateProfile> {
253
+ return validateProfile(buildRobloxTargetProfile({ skipValidate: true }));
254
+ }
255
+
256
+ export function analyzeLuauOutput(): Array<{ file: string; ok: boolean; output: string }> {
257
+ const dir = path.join(projectRoot, "api", "generated", "luau");
258
+ if (!fs.existsSync(dir)) {
259
+ return [];
260
+ }
261
+ return fs
262
+ .readdirSync(dir)
263
+ .filter((f) => f.endsWith(".luau"))
264
+ .map((f) => {
265
+ const file = path.join(dir, f);
266
+ const result = tryLuauAnalyze(file);
267
+ return { file, ...result };
268
+ });
269
+ }
@@ -0,0 +1,60 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { projectRoot } from "../package-info.js";
4
+ import { hashBuffer } from "./resolver.js";
5
+ import type { OverrideEntry, SourceMeta } from "./model.js";
6
+
7
+ export interface LoadedSource<T = unknown> {
8
+ meta: SourceMeta;
9
+ data: T;
10
+ }
11
+
12
+ export function loadJsonFile<T>(id: string, filePath: string): LoadedSource<T> {
13
+ const absolute = path.isAbsolute(filePath) ? filePath : path.join(projectRoot, filePath);
14
+ if (!fs.existsSync(absolute)) {
15
+ throw new Error(`API source not found: ${absolute}`);
16
+ }
17
+ const raw = fs.readFileSync(absolute);
18
+ const text = raw.toString("utf8");
19
+ const data = JSON.parse(text) as T;
20
+ return {
21
+ meta: {
22
+ id,
23
+ path: absolute,
24
+ hash: hashBuffer(raw),
25
+ loadedAt: new Date().toISOString(),
26
+ version: typeof (data as { Version?: unknown }).Version !== "undefined"
27
+ ? (data as { Version: string | number }).Version
28
+ : undefined,
29
+ },
30
+ data,
31
+ };
32
+ }
33
+
34
+ export function readOverrideFile<T extends Record<string, unknown>>(
35
+ relativeName: string,
36
+ ): { meta: OverrideEntry | null; data: T } {
37
+ const filePath = path.join(projectRoot, "api", "overrides", relativeName);
38
+ if (!fs.existsSync(filePath)) {
39
+ return { meta: null, data: {} as T };
40
+ }
41
+ const parsed = JSON.parse(fs.readFileSync(filePath, "utf8")) as T & { _meta?: OverrideEntry };
42
+ const meta = parsed._meta || null;
43
+ const { _meta: _, ...rest } = parsed as T & { _meta?: OverrideEntry };
44
+ return { meta, data: rest as T };
45
+ }
46
+
47
+ export function overridesHash(): string {
48
+ const dir = path.join(projectRoot, "api", "overrides");
49
+ if (!fs.existsSync(dir)) {
50
+ return hashBuffer("");
51
+ }
52
+ const parts: string[] = [];
53
+ for (const name of fs.readdirSync(dir).sort()) {
54
+ if (!name.endsWith(".json")) {
55
+ continue;
56
+ }
57
+ parts.push(name, fs.readFileSync(path.join(dir, name), "utf8"));
58
+ }
59
+ return hashBuffer(parts.join("\n"));
60
+ }
@@ -0,0 +1,126 @@
1
+ import type {
2
+ CanonicalType,
3
+ ConstructorDefinition,
4
+ DatatypeDefinition,
5
+ GlobalDefinition,
6
+ LibraryDefinition,
7
+ MethodDefinition,
8
+ OverrideEntry,
9
+ ParameterDefinition,
10
+ RobloxTargetProfile,
11
+ } from "./model.js";
12
+ import { mapNamedTypeLike, parseClppTypeString } from "./type-parse.js";
13
+
14
+ export interface DatatypeOverrideFile {
15
+ _meta?: OverrideEntry;
16
+ datatypes?: Record<string, RawDatatypeOverride>;
17
+ }
18
+
19
+ export interface RawDatatypeOverride {
20
+ summary?: string;
21
+ fields?: string[];
22
+ ctors?: string[][];
23
+ statics?: string[];
24
+ staticMethods?: Array<[string, string, string[]]>;
25
+ methods?: Array<[string, string, string[]]>;
26
+ custom?: boolean;
27
+ }
28
+
29
+ export function applyDatatypeOverrides(
30
+ existing: Record<string, DatatypeDefinition>,
31
+ raw: Record<string, RawDatatypeOverride>,
32
+ ): Record<string, DatatypeDefinition> {
33
+ const out = { ...existing };
34
+ for (const [name, spec] of Object.entries(raw)) {
35
+ out[name] = convertDatatypeOverride(name, spec);
36
+ }
37
+ return out;
38
+ }
39
+
40
+ function convertDatatypeOverride(name: string, spec: RawDatatypeOverride): DatatypeDefinition {
41
+ const fields = (spec.fields || []).map((f) => {
42
+ const parts = f.trim().split(/\s+/);
43
+ const fieldName = parts.pop() || "value";
44
+ const typeStr = parts.join(" ") || "auto";
45
+ return { name: fieldName, type: parseClppTypeString(typeStr) };
46
+ });
47
+ const constructors: ConstructorDefinition[] = (spec.ctors || []).map((params, i) => ({
48
+ owner: name,
49
+ overloadIndex: i,
50
+ parameters: params.map((p, idx) => parseParamString(p, idx)),
51
+ tags: [],
52
+ }));
53
+ const staticMethods: MethodDefinition[] = (spec.staticMethods || []).map((m, i) => ({
54
+ name: m[0],
55
+ owner: name,
56
+ overloadIndex: i,
57
+ parameters: (m[2] || []).map((p, idx) => parseParamString(p, idx)),
58
+ returnTypes: [parseClppTypeString(m[1])],
59
+ canYield: false,
60
+ tags: ["static"],
61
+ }));
62
+ const instanceMethods: MethodDefinition[] = (spec.methods || []).map((m, i) => ({
63
+ name: m[0],
64
+ owner: name,
65
+ overloadIndex: i,
66
+ parameters: (m[2] || []).map((p, idx) => parseParamString(p, idx)),
67
+ returnTypes: [parseClppTypeString(m[1])],
68
+ canYield: false,
69
+ tags: [],
70
+ }));
71
+ return {
72
+ name,
73
+ summary: spec.summary,
74
+ fields,
75
+ constructors,
76
+ staticProperties: spec.statics || [],
77
+ staticMethods,
78
+ instanceMethods,
79
+ source: "override",
80
+ };
81
+ }
82
+
83
+ function parseParamString(raw: string, index: number): ParameterDefinition {
84
+ const parts = raw.trim().split(/\s+/);
85
+ const name = parts.pop() || `arg${index}`;
86
+ const typeStr = parts.join(" ") || "auto";
87
+ const type = parseClppTypeString(typeStr);
88
+ return { name, type, optional: type.kind === "Optional" };
89
+ }
90
+
91
+ export function applyGlobalsOverrides(
92
+ existing: Record<string, GlobalDefinition>,
93
+ raw: Record<string, { type?: string; layer?: GlobalDefinition["layer"]; description?: string }>,
94
+ ): Record<string, GlobalDefinition> {
95
+ const out = { ...existing };
96
+ for (const [name, g] of Object.entries(raw)) {
97
+ out[name] = {
98
+ name,
99
+ type: g.type ? parseClppTypeString(g.type) : { kind: "Any" },
100
+ layer: g.layer || "roblox-engine",
101
+ description: g.description,
102
+ };
103
+ }
104
+ return out;
105
+ }
106
+
107
+ export function applyLibraryOverrides(
108
+ existing: Record<string, LibraryDefinition>,
109
+ raw: Record<string, LibraryDefinition>,
110
+ ): Record<string, LibraryDefinition> {
111
+ return { ...existing, ...raw };
112
+ }
113
+
114
+ export function applyClassOverrides(
115
+ classes: RobloxTargetProfile["classes"],
116
+ raw: Record<string, Partial<RobloxTargetProfile["classes"][string]>>,
117
+ ): void {
118
+ for (const [name, patch] of Object.entries(raw)) {
119
+ if (!classes[name]) {
120
+ continue;
121
+ }
122
+ Object.assign(classes[name], patch, { name });
123
+ }
124
+ }
125
+
126
+ export { mapNamedTypeLike };