@ultrst-armada/krnl 1.0.1 → 1.0.3

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 (235) hide show
  1. package/README.md +67 -65
  2. package/package.json +13 -9
  3. package/packages/cli/dist/bin/krnl.cjs +1535 -9508
  4. package/packages/cli/dist/bin/krnl.js +55 -1915
  5. package/packages/cli/dist/chunk-6SHSECXR.js +1628 -0
  6. package/packages/cli/dist/index.cjs +1244 -7373
  7. package/packages/cli/dist/index.d.cts +45 -2
  8. package/packages/cli/dist/index.d.ts +45 -2
  9. package/packages/cli/dist/index.js +5 -20
  10. package/packages/cli/package.json +17 -10
  11. package/packages/core/dist/index.cjs +3039 -141
  12. package/packages/core/dist/index.d.cts +633 -27
  13. package/packages/core/dist/index.d.ts +633 -27
  14. package/packages/core/dist/index.js +3028 -139
  15. package/packages/core/package.json +15 -7
  16. package/packages/create-krnl/dist/index.cjs +322 -316
  17. package/packages/create-krnl/dist/index.js +322 -316
  18. package/packages/create-krnl/package.json +5 -3
  19. package/packages/eslint-plugin/dist/index.cjs +17 -55
  20. package/packages/eslint-plugin/dist/index.d.cts +8 -43
  21. package/packages/eslint-plugin/dist/index.d.ts +8 -43
  22. package/packages/eslint-plugin/dist/index.js +17 -55
  23. package/packages/eslint-plugin/package.json +5 -4
  24. package/packages/validate/dist/index.cjs +692 -361
  25. package/packages/validate/dist/index.d.cts +12 -14
  26. package/packages/validate/dist/index.d.ts +12 -14
  27. package/packages/validate/dist/index.js +692 -361
  28. package/packages/validate/package.json +14 -7
  29. package/packages/cli/dist/K_ENT_Entity-PQ5MURQY-ZG6FZXXX.js +0 -13
  30. package/packages/cli/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-K4CRQYA5.js +0 -8
  31. package/packages/cli/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-LNPXZYOE.js +0 -110
  32. package/packages/cli/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-3ALZPNX4.js +0 -11
  33. package/packages/cli/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-PJTICYSW.js +0 -11
  34. package/packages/cli/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-M5TYU55O.js +0 -8
  35. package/packages/cli/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-H6STOXRK.js +0 -20
  36. package/packages/cli/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-XPJXSF7D.js +0 -19
  37. package/packages/cli/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-CUYGTWOW.js +0 -7
  38. package/packages/cli/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-VR6T4N6J.js +0 -17
  39. package/packages/cli/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-RLJ4QWDP.js +0 -58
  40. package/packages/cli/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-BOQGUASC.js +0 -22
  41. package/packages/cli/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-XJI7KIT5.js +0 -8
  42. package/packages/cli/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-K5VCWAFW.js +0 -9
  43. package/packages/cli/dist/chunk-3TRM6CYL.js +0 -152
  44. package/packages/cli/dist/chunk-5JDK35TG.js +0 -3872
  45. package/packages/cli/dist/chunk-63PTK33I.js +0 -997
  46. package/packages/cli/dist/chunk-6NIKAMUZ.js +0 -82
  47. package/packages/cli/dist/chunk-BOXWWXQG.js +0 -400
  48. package/packages/cli/dist/chunk-EEKLK7QJ.js +0 -565
  49. package/packages/cli/dist/chunk-EG7T2IAD.js +0 -107
  50. package/packages/cli/dist/chunk-F5EHXE2O.js +0 -1036
  51. package/packages/cli/dist/chunk-F65ANSQG.js +0 -269
  52. package/packages/cli/dist/chunk-FDNCADFE.js +0 -71
  53. package/packages/cli/dist/chunk-GDLRMDAN.js +0 -127
  54. package/packages/cli/dist/chunk-HWMTCMOS.js +0 -656
  55. package/packages/cli/dist/chunk-I74QIQOD.js +0 -5536
  56. package/packages/cli/dist/chunk-JTLSTO25.js +0 -71
  57. package/packages/cli/dist/chunk-JULBBJ27.js +0 -1033
  58. package/packages/cli/dist/chunk-OHVMVRBP.js +0 -117
  59. package/packages/cli/dist/chunk-P2PCLEKX.js +0 -666
  60. package/packages/cli/dist/chunk-PJQIUOX2.js +0 -7767
  61. package/packages/cli/dist/chunk-PPOF3DJW.js +0 -471
  62. package/packages/cli/dist/chunk-Q45257P6.js +0 -173
  63. package/packages/cli/dist/chunk-QNROWGBI.js +0 -1036
  64. package/packages/cli/dist/chunk-RJNYUXZD.js +0 -977
  65. package/packages/cli/dist/chunk-SRTOPJ5W.js +0 -104
  66. package/packages/cli/dist/chunk-TCEX3MPS.js +0 -702
  67. package/packages/cli/dist/chunk-TNOAJO2J.js +0 -675
  68. package/packages/cli/dist/chunk-UR2SUCSF.js +0 -701
  69. package/packages/cli/dist/chunk-X5LOIFM7.js +0 -68
  70. package/packages/cli/dist/chunk-XIRFOO3H.js +0 -589
  71. package/packages/cli/dist/chunk-ZAAV3JXQ.js +0 -809
  72. package/packages/core/dist/K_ENT_Entity-4MB7CU4A.js +0 -12
  73. package/packages/core/dist/K_ENT_Entity-DEJGIDGH.js +0 -12
  74. package/packages/core/dist/K_ENT_Entity-FXZO5UZ2.js +0 -12
  75. package/packages/core/dist/K_ENT_Entity-HDSCXC5F.js +0 -12
  76. package/packages/core/dist/K_ENT_Entity-JILABHLW.js +0 -12
  77. package/packages/core/dist/K_ENT_Entity-PQ5MURQY.js +0 -13
  78. package/packages/core/dist/K_ENT_Entity-ROAKDIHW.js +0 -12
  79. package/packages/core/dist/K_ENT_Entity-TBVFSKDV.js +0 -12
  80. package/packages/core/dist/K_ENT_Entity-ZFLKG3JO.js +0 -12
  81. package/packages/core/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW.js +0 -8
  82. package/packages/core/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF.js +0 -110
  83. package/packages/core/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF.js +0 -9
  84. package/packages/core/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X.js +0 -9
  85. package/packages/core/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW.js +0 -8
  86. package/packages/core/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2.js +0 -20
  87. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-4C6GBQAG.js +0 -18
  88. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-6V23A6F6.js +0 -18
  89. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK.js +0 -19
  90. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-DYLLC5G2.js +0 -18
  91. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-F4FOFAUP.js +0 -18
  92. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-FBOXXMI3.js +0 -18
  93. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-Q73BWLNP.js +0 -18
  94. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QM2C4MVA.js +0 -18
  95. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-QUGI6SMP.js +0 -18
  96. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RGMTBHNP.js +0 -18
  97. package/packages/core/dist/K_LIB_Krnl_SubApp_Registry-RWR7UNDW.js +0 -18
  98. package/packages/core/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7.js +0 -7
  99. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-32MFJJ5Z.js +0 -17
  100. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-4J4CEWRY.js +0 -17
  101. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-A366YHF2.js +0 -17
  102. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-LK4LYJHI.js +0 -17
  103. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU.js +0 -17
  104. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-NW3K63II.js +0 -17
  105. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-QDHTI5ZV.js +0 -17
  106. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-VHCT6VIW.js +0 -17
  107. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-WBRKF24R.js +0 -17
  108. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-XKYQYT6Q.js +0 -17
  109. package/packages/core/dist/K_LIB_Krnl_System_App_Adapter-Z2PWZYDZ.js +0 -17
  110. package/packages/core/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5.js +0 -58
  111. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-2EZU7QF4.js +0 -21
  112. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-6G3AQNAV.js +0 -21
  113. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-B2NZMQUG.js +0 -21
  114. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-C2RABMZP.js +0 -21
  115. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-HHE3NZ4F.js +0 -21
  116. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-LHFGR6WK.js +0 -21
  117. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-M74BLM3N.js +0 -21
  118. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-PT6ZA6EA.js +0 -21
  119. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-SP52V3CX.js +0 -21
  120. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF.js +0 -22
  121. package/packages/core/dist/K_LIB_Krnl_System_Magnetic_Loader-YNSEUHJJ.js +0 -21
  122. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-M6SBHIVA.js +0 -8
  123. package/packages/core/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG.js +0 -8
  124. package/packages/core/dist/K_LIB_Krnl_Telemetry-77FRZ3KV.js +0 -9
  125. package/packages/core/dist/chunk-33L2J7V7.js +0 -82
  126. package/packages/core/dist/chunk-3ES4K2ZP.js +0 -817
  127. package/packages/core/dist/chunk-3SMHVVLL.js +0 -82
  128. package/packages/core/dist/chunk-3UEZ7JQA.js +0 -4877
  129. package/packages/core/dist/chunk-3XIE6KBD.js +0 -4877
  130. package/packages/core/dist/chunk-46ZLCML6.js +0 -107
  131. package/packages/core/dist/chunk-4UEL3DWJ.js +0 -107
  132. package/packages/core/dist/chunk-54GWZ5PC.js +0 -82
  133. package/packages/core/dist/chunk-6QCYRS5L.js +0 -127
  134. package/packages/core/dist/chunk-6ULMHNXR.js +0 -104
  135. package/packages/core/dist/chunk-7WUETJEV.js +0 -117
  136. package/packages/core/dist/chunk-A5KRAYDB.js +0 -107
  137. package/packages/core/dist/chunk-ANEAZ3PO.js +0 -107
  138. package/packages/core/dist/chunk-BE76RL6F.js +0 -82
  139. package/packages/core/dist/chunk-CIARVYDO.js +0 -107
  140. package/packages/core/dist/chunk-CR2ANE62.js +0 -107
  141. package/packages/core/dist/chunk-DI27MOR7.js +0 -173
  142. package/packages/core/dist/chunk-E6RLFHM5.js +0 -596
  143. package/packages/core/dist/chunk-EELAPMNV.js +0 -4877
  144. package/packages/core/dist/chunk-ENZ2RQVJ.js +0 -107
  145. package/packages/core/dist/chunk-F2U6CX4F.js +0 -4877
  146. package/packages/core/dist/chunk-FKG64OHL.js +0 -82
  147. package/packages/core/dist/chunk-FYAZJYM5.js +0 -772
  148. package/packages/core/dist/chunk-G4NP4RDQ.js +0 -82
  149. package/packages/core/dist/chunk-GADIRLRS.js +0 -473
  150. package/packages/core/dist/chunk-GR6CSLQJ.js +0 -772
  151. package/packages/core/dist/chunk-HDS7AT6O.js +0 -772
  152. package/packages/core/dist/chunk-HIMEZUU2.js +0 -71
  153. package/packages/core/dist/chunk-IB4UHG5I.js +0 -596
  154. package/packages/core/dist/chunk-J7ZYNVRS.js +0 -772
  155. package/packages/core/dist/chunk-JVLZU4K7.js +0 -604
  156. package/packages/core/dist/chunk-JYXXI7Q3.js +0 -82
  157. package/packages/core/dist/chunk-K54K2KZW.js +0 -192
  158. package/packages/core/dist/chunk-K6VHLBNH.js +0 -3316
  159. package/packages/core/dist/chunk-KCBP7ZYA.js +0 -596
  160. package/packages/core/dist/chunk-KFQGP6VL.js +0 -33
  161. package/packages/core/dist/chunk-KIUEUI7K.js +0 -82
  162. package/packages/core/dist/chunk-LB67NIZP.js +0 -949
  163. package/packages/core/dist/chunk-LDTYFUNW.js +0 -596
  164. package/packages/core/dist/chunk-MLVWARD4.js +0 -596
  165. package/packages/core/dist/chunk-MPYVXHKO.js +0 -2777
  166. package/packages/core/dist/chunk-MRQ3MITU.js +0 -772
  167. package/packages/core/dist/chunk-MVUN7I7O.js +0 -107
  168. package/packages/core/dist/chunk-NDDOIRW7.js +0 -596
  169. package/packages/core/dist/chunk-O3KDB5MH.js +0 -3330
  170. package/packages/core/dist/chunk-OEINUDSE.js +0 -400
  171. package/packages/core/dist/chunk-OPDENPT4.js +0 -4877
  172. package/packages/core/dist/chunk-P6XEM2LA.js +0 -429
  173. package/packages/core/dist/chunk-QKMRSQV4.js +0 -82
  174. package/packages/core/dist/chunk-R6CCWALL.js +0 -4877
  175. package/packages/core/dist/chunk-RAMMOO73.js +0 -774
  176. package/packages/core/dist/chunk-S3FTZFG6.js +0 -772
  177. package/packages/core/dist/chunk-T2ZVN434.js +0 -4877
  178. package/packages/core/dist/chunk-TFHLDMIA.js +0 -107
  179. package/packages/core/dist/chunk-TI3QUCIJ.js +0 -107
  180. package/packages/core/dist/chunk-TR2BAIGI.js +0 -107
  181. package/packages/core/dist/chunk-UGVVJKC6.js +0 -4877
  182. package/packages/core/dist/chunk-V2DX7YIU.js +0 -984
  183. package/packages/core/dist/chunk-W4IHYUYD.js +0 -772
  184. package/packages/core/dist/chunk-W6WBG5OY.js +0 -4877
  185. package/packages/core/dist/chunk-WN3M7O7H.js +0 -3312
  186. package/packages/core/dist/chunk-WR3NCU7U.js +0 -4877
  187. package/packages/core/dist/chunk-XC6B6L27.js +0 -82
  188. package/packages/core/dist/chunk-XNSE64ZY.js +0 -3316
  189. package/packages/core/dist/chunk-XROES2WN.js +0 -634
  190. package/packages/core/dist/chunk-XSCKNRCZ.js +0 -5020
  191. package/packages/core/dist/chunk-XVABPAUZ.js +0 -82
  192. package/packages/core/dist/chunk-YOBCB5C5.js +0 -596
  193. package/packages/core/dist/chunk-YUK6Q563.js +0 -666
  194. package/packages/core/dist/chunk-YXGL3ZEU.js +0 -1030
  195. package/packages/core/dist/chunk-ZINJ5OUX.js +0 -596
  196. package/packages/core/dist/chunk-ZPFD4BIQ.js +0 -604
  197. package/packages/core/dist/chunk-ZQZBFG6F.js +0 -4826
  198. package/packages/core/dist/chunk-ZZFRJGXM.js +0 -4877
  199. package/packages/create-krnl/dist/K_ENT_Entity-PQ5MURQY-R2OH4VXE.js +0 -14
  200. package/packages/create-krnl/dist/K_LIB_Krnl_Aiko_Client-OPZAVZCW-AZM5HF4M.js +0 -9
  201. package/packages/create-krnl/dist/K_LIB_Krnl_Ep_Tools-ROOE2TQF-X5N6SV2S.js +0 -111
  202. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Builder-2ZDUH6PF-5PFHF4JU.js +0 -12
  203. package/packages/create-krnl/dist/K_LIB_Krnl_Frontend_Generator-UYNRNX2X-ED33OQPH.js +0 -12
  204. package/packages/create-krnl/dist/K_LIB_Krnl_Registry_Client-NXV6D2QW-YGQLVR4P.js +0 -9
  205. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Engine-7HR5HWW2-VM7CTU2L.js +0 -21
  206. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Registry-7XYGDKJK-Y2GQFJ7I.js +0 -21
  207. package/packages/create-krnl/dist/K_LIB_Krnl_SubApp_Worker_Host-CQVTGGG7-L3JQWO54.js +0 -8
  208. package/packages/create-krnl/dist/K_LIB_Krnl_System_App_Adapter-M6FJKLGU-KQARASPR.js +0 -19
  209. package/packages/create-krnl/dist/K_LIB_Krnl_System_Base_Functionality_APIs-ZZUZ6ZG5-OF3IGLVL.js +0 -59
  210. package/packages/create-krnl/dist/K_LIB_Krnl_System_Magnetic_Loader-XBQO2KXF-JOLHKOEX.js +0 -24
  211. package/packages/create-krnl/dist/K_LIB_Krnl_System_Unified_Http_Adapter-RCEGP3OG-L46LSHKQ.js +0 -10
  212. package/packages/create-krnl/dist/K_LIB_Krnl_Telemetry-77FRZ3KV-4JUPRR3X.js +0 -10
  213. package/packages/create-krnl/dist/chunk-3TRM6CYL.js +0 -152
  214. package/packages/create-krnl/dist/chunk-3URCB3QS.js +0 -127
  215. package/packages/create-krnl/dist/chunk-5JDK35TG.js +0 -3872
  216. package/packages/create-krnl/dist/chunk-A2XAXDOW.js +0 -812
  217. package/packages/create-krnl/dist/chunk-AN6TMQHG.js +0 -1033
  218. package/packages/create-krnl/dist/chunk-BOXWWXQG.js +0 -400
  219. package/packages/create-krnl/dist/chunk-BPTBREBG.js +0 -38
  220. package/packages/create-krnl/dist/chunk-FDNCADFE.js +0 -71
  221. package/packages/create-krnl/dist/chunk-JTLSTO25.js +0 -71
  222. package/packages/create-krnl/dist/chunk-M3NCUIPL.js +0 -107
  223. package/packages/create-krnl/dist/chunk-N2EONSOC.js +0 -7769
  224. package/packages/create-krnl/dist/chunk-OHVMVRBP.js +0 -117
  225. package/packages/create-krnl/dist/chunk-Q45257P6.js +0 -173
  226. package/packages/create-krnl/dist/chunk-QGM4M3NI.js +0 -37
  227. package/packages/create-krnl/dist/chunk-RJNYUXZD.js +0 -977
  228. package/packages/create-krnl/dist/chunk-SRTOPJ5W.js +0 -104
  229. package/packages/create-krnl/dist/chunk-UPBIGEC3.js +0 -666
  230. package/packages/create-krnl/dist/chunk-V2DB7UD7.js +0 -82
  231. package/packages/create-krnl/dist/chunk-WMHLIUI6.js +0 -3644
  232. package/packages/create-krnl/dist/chunk-XIRFOO3H.js +0 -589
  233. package/packages/create-krnl/dist/chunk-Y2CEEVZP.js +0 -5536
  234. package/packages/create-krnl/dist/main-DXUMPBND.js +0 -2217
  235. package/packages/create-krnl/dist/wrapper-SDF2VKX3.js +0 -31
@@ -1,471 +0,0 @@
1
- // ../validate/dist/index.js
2
- import * as fs from "fs";
3
- import * as path from "path";
4
- import { Project, SyntaxKind } from "ts-morph";
5
- var KrnlValidatorEngine = class {
6
- project;
7
- projectRoot;
8
- maxFileLineLimit;
9
- maxMainLogicLimit;
10
- maxHelperLineLimit;
11
- constructor(options) {
12
- this.projectRoot = path.resolve(options.projectRoot);
13
- this.maxFileLineLimit = options.maxFileLineLimit ?? 200;
14
- this.maxMainLogicLimit = options.maxMainLogicLimit ?? 20;
15
- this.maxHelperLineLimit = options.maxHelperLineLimit ?? 30;
16
- const tsConfigPath = path.join(this.projectRoot, "tsconfig.json");
17
- if (fs.existsSync(tsConfigPath)) {
18
- this.project = new Project({ tsConfigFilePath: tsConfigPath, skipAddingFilesFromTsConfig: true });
19
- } else {
20
- this.project = new Project({ compilerOptions: {
21
- target: 99
22
- /* ESNext */
23
- } });
24
- }
25
- }
26
- /**
27
- * Scans and validates all source files in the project.
28
- */
29
- validateAll() {
30
- const files = this.collectSourceFiles(this.projectRoot);
31
- const errors = [];
32
- const warnings = [];
33
- for (const f of files) {
34
- const sf = this.project.addSourceFileAtPath(f);
35
- const fileReport = this.validateSourceFile(sf);
36
- errors.push(...fileReport.errors);
37
- warnings.push(...fileReport.warnings);
38
- }
39
- return {
40
- valid: errors.length === 0,
41
- totalFiles: files.length,
42
- errors,
43
- warnings
44
- };
45
- }
46
- /**
47
- * Validates a single SourceFile.
48
- */
49
- validateSourceFile(sf) {
50
- const errors = [];
51
- const warnings = [];
52
- const filePath = sf.getFilePath();
53
- const sourceText = sf.getText();
54
- const baseName = path.basename(filePath);
55
- if (baseName.includes("_pb.") || baseName.endsWith(".d.ts")) {
56
- return { errors, warnings };
57
- }
58
- const lines = sourceText.split("\n");
59
- if (lines.length > this.maxFileLineLimit) {
60
- errors.push({
61
- ruleId: "krnl/file-line-limit",
62
- filePath,
63
- message: `File exceeds maximum length of ${this.maxFileLineLimit} lines (currently ${lines.length} lines).`,
64
- severity: "error"
65
- });
66
- }
67
- for (const decl of sf.getImportDeclarations()) {
68
- const moduleSpec = decl.getModuleSpecifierValue();
69
- if (moduleSpec.startsWith(".") && !moduleSpec.endsWith(".js") && !moduleSpec.endsWith(".json")) {
70
- const line = decl.getStartLineNumber();
71
- errors.push({
72
- ruleId: "krnl/import-suffix",
73
- filePath,
74
- line,
75
- message: `Relative import '${moduleSpec}' must end with '.js' for NodeNext module resolution.`,
76
- severity: "error"
77
- });
78
- }
79
- }
80
- const isHelper = filePath.includes("helper_functions") || filePath.includes("/helpers/") || filePath.includes("\\helpers\\");
81
- const isMainLogic = filePath.endsWith("logic.ts") || filePath.endsWith("logic.js");
82
- const isRootConcept = filePath.includes("libraries/") || filePath.includes("Concepts.ts");
83
- if (isHelper) {
84
- for (const decl of sf.getImportDeclarations()) {
85
- const spec = decl.getModuleSpecifierValue();
86
- if (["fs", "node:fs", "http", "node:http", "ws"].includes(spec)) {
87
- errors.push({
88
- ruleId: "krnl/helper-purity",
89
- filePath,
90
- line: decl.getStartLineNumber(),
91
- message: `Helper functions (Layer 1) cannot directly import I/O modules ('${spec}'). Delegate to Layer 0 libraries or Entity context.`,
92
- severity: "error"
93
- });
94
- }
95
- }
96
- for (const fn of sf.getFunctions()) {
97
- const fnLines = fn.getText().split("\n").length;
98
- if (fnLines > this.maxHelperLineLimit && !sourceText.includes("Concepts.")) {
99
- errors.push({
100
- ruleId: "krnl/helper-line-limit",
101
- filePath,
102
- line: fn.getStartLineNumber(),
103
- message: `Helper function '${fn.getName() || "anonymous"}' exceeds ${this.maxHelperLineLimit} lines (${fnLines} lines). Must delegate to a root libraries/{Domain}Concepts.ts library.`,
104
- severity: "error"
105
- });
106
- }
107
- }
108
- }
109
- if (isMainLogic) {
110
- const substantiveLines = lines.filter((l) => {
111
- const trimmed = l.trim();
112
- return trimmed.length > 0 && !trimmed.startsWith("//") && !trimmed.startsWith("/*") && !trimmed.startsWith("*");
113
- });
114
- if (substantiveLines.length > this.maxMainLogicLimit && !sourceText.includes("helpers") && !sourceText.includes("Concepts") && !sourceText.includes("state")) {
115
- errors.push({
116
- ruleId: "krnl/main-delegation",
117
- filePath,
118
- message: `Main logic function has ${substantiveLines.length} substantive lines without delegating to Layer 1 helper functions or Layer 0 libraries.`,
119
- severity: "error"
120
- });
121
- }
122
- }
123
- if (sourceText.includes("main = async") || sourceText.includes("export const main = async")) {
124
- const match = sourceText.match(/main\s*=\s*async\s*\([^,]+,\s*\{([^}]*)\}\s*\)/);
125
- if (match) {
126
- const destructured = match[1];
127
- if (/\bsystem\b/.test(destructured) && !/\bentity\b/.test(destructured)) {
128
- errors.push({
129
- ruleId: "krnl/context-destructuring",
130
- filePath,
131
- message: `Functionality context parameter destructures 'system'. Functionality passes { state, entity }. Always destructure 'entity'.`,
132
- severity: "error"
133
- });
134
- }
135
- }
136
- }
137
- const calls = sf.getDescendantsOfKind(SyntaxKind.CallExpression);
138
- for (const call of calls) {
139
- const exprText = call.getExpression().getText();
140
- if (exprText === "setInterval" || exprText === "window.setInterval") {
141
- errors.push({
142
- ruleId: "krnl/no-polling",
143
- filePath,
144
- line: call.getStartLineNumber(),
145
- message: `Prohibited use of 'setInterval'. Krnl applications must use reactive event streams (entity.emitEvent / entity.on).`,
146
- severity: "error"
147
- });
148
- }
149
- }
150
- const isEntityClass = sf.getClasses().some((c) => {
151
- const ext = c.getExtends();
152
- return ext && (ext.getText().includes("Entity") || ext.getText().includes("krnlEntityBase"));
153
- });
154
- if (isEntityClass) {
155
- let loadAllLine = -1;
156
- const addLocalLines = [];
157
- for (const call of calls) {
158
- const txt = call.getText();
159
- if (txt.includes("MagneticLoader.loadAll") || txt.includes("KrnlMagneticLoader.loadAll")) {
160
- loadAllLine = call.getStartLineNumber();
161
- } else if (txt.startsWith("this.addLocal(")) {
162
- const hasUiSpec = txt.includes("uiSpec");
163
- const idMatch = txt.match(/id\s*:\s*["']([^"']+)["']/);
164
- addLocalLines.push({
165
- line: call.getStartLineNumber(),
166
- hasUiSpec,
167
- id: idMatch ? idMatch[1] : "unknown"
168
- });
169
- }
170
- }
171
- if (loadAllLine !== -1) {
172
- for (const al of addLocalLines) {
173
- if (al.hasUiSpec && al.line > loadAllLine) {
174
- errors.push({
175
- ruleId: "krnl/boot-order",
176
- filePath,
177
- line: al.line,
178
- message: `addLocal('${al.id}') with uiSpec at line ${al.line} appears AFTER loadAll() at line ${loadAllLine}. All addLocal() with UI must precede loadAll().`,
179
- severity: "error"
180
- });
181
- }
182
- }
183
- }
184
- }
185
- return { errors, warnings };
186
- }
187
- collectSourceFiles(dir, collected = []) {
188
- if (!fs.existsSync(dir)) return collected;
189
- const entries = fs.readdirSync(dir, { withFileTypes: true });
190
- for (const entry of entries) {
191
- if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
192
- const full = path.join(dir, entry.name);
193
- if (entry.isDirectory()) {
194
- this.collectSourceFiles(full, collected);
195
- } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js"))) {
196
- collected.push(full);
197
- }
198
- }
199
- return collected;
200
- }
201
- };
202
-
203
- // src/commands/validate.ts
204
- async function runValidate(projectRoot = process.cwd()) {
205
- console.log(`
206
- \u{1F50D} [Krnl Validate] Scanning project at: ${projectRoot}
207
- `);
208
- const validator = new KrnlValidatorEngine({ projectRoot });
209
- const report = validator.validateAll();
210
- if (report.warnings.length > 0) {
211
- console.warn(`\u26A0\uFE0F [WARNINGS] Found ${report.warnings.length} warning(s):`);
212
- for (const w of report.warnings) {
213
- console.warn(` - [${w.ruleId}] ${w.filePath}${w.line ? `:${w.line}` : ""}: ${w.message}`);
214
- }
215
- }
216
- if (!report.valid) {
217
- console.error(`
218
- \u274C [VALIDATION FAILED] Found ${report.errors.length} error(s):
219
- `);
220
- for (const err of report.errors) {
221
- console.error(` \u274C [${err.ruleId}] ${err.filePath}${err.line ? `:${err.line}` : ""}`);
222
- console.error(` ${err.message}
223
- `);
224
- }
225
- return false;
226
- }
227
- console.log(`\u2705 [VALIDATION PASSED] ${report.totalFiles} source files verified clean against Krnl paradigms.
228
- `);
229
- return true;
230
- }
231
-
232
- // src/commands/generate.ts
233
- import * as fs2 from "fs";
234
- import * as path2 from "path";
235
- async function runGenerate(type, name, parentEntity, projectRoot = process.cwd()) {
236
- if (!name) {
237
- console.error("\u274C Error: Resource name is required. Usage: krnl generate <entity|functionality|library|subapp> <Name> [ParentEntity]");
238
- process.exit(1);
239
- }
240
- switch (type.toLowerCase()) {
241
- case "entity":
242
- generateEntity(name, projectRoot);
243
- break;
244
- case "functionality":
245
- if (!parentEntity) {
246
- console.error("\u274C Error: Parent entity name is required for functionality. Usage: krnl generate functionality <Name> <ParentEntity>");
247
- process.exit(1);
248
- }
249
- generateFunctionality(name, parentEntity, projectRoot);
250
- break;
251
- case "library":
252
- generateLibrary(name, projectRoot);
253
- break;
254
- case "subapp":
255
- generateSubApp(name, projectRoot);
256
- break;
257
- default:
258
- console.error(`\u274C Unknown resource type '${type}'. Valid types: entity, functionality, library, subapp`);
259
- process.exit(1);
260
- }
261
- }
262
- function generateEntity(name, projectRoot) {
263
- const entityDir = path2.join(projectRoot, "src", "entities", name);
264
- fs2.mkdirSync(entityDir, { recursive: true });
265
- fs2.mkdirSync(path2.join(entityDir, "functionalities"), { recursive: true });
266
- const entityFile = path2.join(entityDir, `${name}.ts`);
267
- const content = `import { Entity, KrnlMagneticLoader } from '@dinilmusick/krnl-core';
268
-
269
- export class ${name} extends Entity {
270
- constructor() {
271
- super({
272
- id: '${name}',
273
- version: '1.0.0',
274
- description: '${name} root entity'
275
- });
276
- }
277
-
278
- async boot(): Promise<void> {
279
- // 1. Local functionalities with UI must precede loadAll
280
-
281
- // 2. Discover magnetic functionalities, child entities, and subapps
282
- await KrnlMagneticLoader.loadAll(this, import.meta.url);
283
- }
284
- }
285
-
286
- export default ${name};
287
- `;
288
- fs2.writeFileSync(entityFile, content);
289
- console.log(`\u2705 Created Entity: src/entities/${name}/${name}.ts`);
290
- }
291
- function generateFunctionality(name, entityName, projectRoot) {
292
- const funcDir = path2.join(projectRoot, "src", "entities", entityName, "functionalities", name);
293
- fs2.mkdirSync(path2.join(funcDir, "main_function"), { recursive: true });
294
- fs2.mkdirSync(path2.join(funcDir, "state_data"), { recursive: true });
295
- fs2.mkdirSync(path2.join(funcDir, "helper_functions"), { recursive: true });
296
- fs2.mkdirSync(path2.join(funcDir, "events"), { recursive: true });
297
- fs2.writeFileSync(path2.join(funcDir, `${name}Atom.ts`), `export interface ${name}Input {
298
- message?: string;
299
- }
300
-
301
- export interface ${name}Output {
302
- success: boolean;
303
- timestamp: number;
304
- }
305
- `);
306
- fs2.writeFileSync(path2.join(funcDir, "main_function", "logic.ts"), `import { ${name}Input, ${name}Output } from '../${name}Atom.js';
307
- import { formatTimestamp } from '../helper_functions/formatTimestamp.js';
308
-
309
- export const main = async (input: ${name}Input, { state, entity }: any): Promise<${name}Output> => {
310
- const timestamp = formatTimestamp();
311
- return {
312
- success: true,
313
- timestamp
314
- };
315
- };
316
- `);
317
- fs2.writeFileSync(path2.join(funcDir, "state_data", "state.ts"), `export interface ${name}State {
318
- executionCount: number;
319
- }
320
-
321
- export const initialState: ${name}State = {
322
- executionCount: 0
323
- };
324
- `);
325
- fs2.writeFileSync(path2.join(funcDir, "helper_functions", "formatTimestamp.ts"), `export function formatTimestamp(): number {
326
- return Date.now();
327
- }
328
- `);
329
- console.log(`\u2705 Created Quad-Unit Functionality: src/entities/${entityName}/functionalities/${name}/`);
330
- }
331
- function generateLibrary(name, projectRoot) {
332
- const libDir = path2.join(projectRoot, "src", "libraries");
333
- fs2.mkdirSync(libDir, { recursive: true });
334
- const fileName = `${name}Concepts.ts`;
335
- fs2.writeFileSync(path2.join(libDir, fileName), `/**
336
- * @file ${fileName}
337
- * @role component
338
- * @description Layer 0 pure domain concept library for ${name}.
339
- */
340
-
341
- export class ${name}Concepts {
342
- static pureTransform<T>(data: T): T {
343
- return data;
344
- }
345
- }
346
- `);
347
- console.log(`\u2705 Created Domain Concept Library: src/libraries/${fileName}`);
348
- }
349
- function generateSubApp(name, projectRoot) {
350
- const subappDir = path2.join(projectRoot, "src", "subapps", name);
351
- fs2.mkdirSync(subappDir, { recursive: true });
352
- fs2.writeFileSync(path2.join(subappDir, "subapp.json"), JSON.stringify({
353
- name,
354
- version: "1.0.0",
355
- description: `${name} self-contained sub-app`,
356
- registrationEntry: "./register.js"
357
- }, null, 2));
358
- fs2.writeFileSync(path2.join(subappDir, "register.ts"), `export function register(context: any) {
359
- context.logger.log('Registering ${name} sub-app');
360
- return {
361
- name: '${name}',
362
- operations: []
363
- };
364
- }
365
- export default register;
366
- `);
367
- console.log(`\u2705 Created Sub-App: src/subapps/${name}/`);
368
- }
369
-
370
- // src/commands/watch.ts
371
- import * as fs3 from "fs";
372
- import * as path3 from "path";
373
- function generateMagneticDeclarations(projectRoot = process.cwd()) {
374
- const functionalities = scanDirectory(projectRoot);
375
- let dtsContent = `// Automatically generated by Krnl Magnetic Watcher. Do not edit manually.
376
-
377
- `;
378
- dtsContent += `import { Entity } from '@dinilmusick/krnl-core';
379
-
380
- `;
381
- const globalDeclarations = [];
382
- for (const func of functionalities) {
383
- const helpersDir = path3.join(func.funcPath, "helper_functions");
384
- if (fs3.existsSync(helpersDir)) {
385
- const files = fs3.readdirSync(helpersDir);
386
- for (const file of files) {
387
- if (file.endsWith(".js") || file.endsWith(".ts")) {
388
- const filePath = path3.join(helpersDir, file);
389
- const baseName = path3.basename(file, path3.extname(file));
390
- const importPath = `./${path3.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
391
- const { named, hasDefault } = parseExports(filePath, baseName);
392
- if (hasDefault) {
393
- globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
394
- }
395
- for (const name of named) {
396
- globalDeclarations.push(` const ${name}: typeof import('${importPath}')['${name}'];`);
397
- }
398
- }
399
- }
400
- }
401
- const eventsDir = path3.join(func.funcPath, "events");
402
- if (fs3.existsSync(eventsDir)) {
403
- const files = fs3.readdirSync(eventsDir);
404
- for (const file of files) {
405
- if (file.endsWith(".js") || file.endsWith(".ts")) {
406
- const filePath = path3.join(eventsDir, file);
407
- const baseName = path3.basename(file, path3.extname(file));
408
- const importPath = `./${path3.relative(projectRoot, filePath).replace(/\\/g, "/")}`;
409
- const { named, hasDefault } = parseExports(filePath, baseName);
410
- if (hasDefault) {
411
- globalDeclarations.push(` const ${baseName}: typeof import('${importPath}')['default'];`);
412
- }
413
- for (const name of named) {
414
- globalDeclarations.push(` const ${name}: typeof import('${importPath}')['${name}'];`);
415
- }
416
- }
417
- }
418
- }
419
- }
420
- if (globalDeclarations.length > 0) {
421
- dtsContent += `declare global {
422
- ${Array.from(new Set(globalDeclarations)).join("\n")}
423
- }
424
- `;
425
- }
426
- const outPath = path3.join(projectRoot, "krnl-magnetic.d.ts");
427
- fs3.writeFileSync(outPath, dtsContent);
428
- console.log(`[Krnl Watch] Updated ambient declarations: ${outPath}`);
429
- }
430
- function scanDirectory(dir, results = []) {
431
- if (!fs3.existsSync(dir)) return results;
432
- const list = fs3.readdirSync(dir, { withFileTypes: true });
433
- for (const entry of list) {
434
- if (entry.isDirectory()) {
435
- if (entry.name === "node_modules" || entry.name === "dist" || entry.name === ".git") continue;
436
- const fullPath = path3.join(dir, entry.name);
437
- if (entry.name === "functionalities") {
438
- const funcs = fs3.readdirSync(fullPath, { withFileTypes: true });
439
- for (const f of funcs) {
440
- if (f.isDirectory()) {
441
- results.push({ funcPath: path3.join(fullPath, f.name), funcName: f.name });
442
- }
443
- }
444
- } else {
445
- scanDirectory(fullPath, results);
446
- }
447
- }
448
- }
449
- return results;
450
- }
451
- function parseExports(filePath, defaultName) {
452
- const content = fs3.readFileSync(filePath, "utf8");
453
- const named = [];
454
- let hasDefault = false;
455
- const namedRegex = /export\s+(?:const|let|var|function|class|async\s+function)\s+([a-zA-Z0-9_$]+)/g;
456
- let match;
457
- while ((match = namedRegex.exec(content)) !== null) {
458
- if (match[1]) named.push(match[1]);
459
- }
460
- if (content.includes("export default")) {
461
- hasDefault = true;
462
- }
463
- return { named, hasDefault };
464
- }
465
-
466
- export {
467
- KrnlValidatorEngine,
468
- runValidate,
469
- runGenerate,
470
- generateMagneticDeclarations
471
- };
@@ -1,173 +0,0 @@
1
- // ../core/dist/chunk-DI27MOR7.js
2
- var KrnlTelemetry = class {
3
- metrics;
4
- callLogs;
5
- libraryUsage;
6
- dataUsage;
7
- enabled;
8
- ringBufferSize;
9
- aiTraces;
10
- totalAiCalls;
11
- totalAiRetries;
12
- avgAiLatencyMs;
13
- runtimeStore = null;
14
- constructor() {
15
- this.metrics = /* @__PURE__ */ new Map();
16
- this.callLogs = /* @__PURE__ */ new Map();
17
- this.libraryUsage = /* @__PURE__ */ new Map();
18
- this.dataUsage = /* @__PURE__ */ new Map();
19
- this.enabled = false;
20
- this.ringBufferSize = 100;
21
- this.aiTraces = [];
22
- this.totalAiCalls = 0;
23
- this.totalAiRetries = 0;
24
- this.avgAiLatencyMs = 0;
25
- }
26
- setRuntimeStore(store) {
27
- this.runtimeStore = store;
28
- }
29
- recordAiTrace(trace) {
30
- if (this.aiTraces.length >= this.ringBufferSize) {
31
- this.aiTraces.shift();
32
- }
33
- this.aiTraces.push(trace);
34
- this.totalAiCalls++;
35
- this.totalAiRetries += trace.retryCount || 0;
36
- this.avgAiLatencyMs = (this.avgAiLatencyMs * (this.totalAiCalls - 1) + trace.latencyMs) / this.totalAiCalls;
37
- if (this.runtimeStore) {
38
- this.runtimeStore.appendTelemetry({
39
- type: "ai_trace",
40
- endpointId: trace.endpointId,
41
- timestamp: trace.timestamp,
42
- latencyMs: trace.latencyMs,
43
- retryCount: trace.retryCount,
44
- success: !trace.failureReason,
45
- failures: trace.validationFailures
46
- }).catch(() => {
47
- });
48
- }
49
- }
50
- /**
51
- * Starts a telemetry trace for a specific functionality.
52
- * @param fid
53
- * @returns Trace data
54
- */
55
- startTrace(fid) {
56
- return {
57
- startTime: process.hrtime.bigint(),
58
- startMemory: process.memoryUsage ? process.memoryUsage().heapUsed : 0
59
- };
60
- }
61
- /**
62
- * Ends a telemetry trace and updates aggregated metrics.
63
- * @param fid
64
- * @param trace
65
- */
66
- endTrace(fid, trace, success = true) {
67
- const endTime = process.hrtime.bigint();
68
- const endMemory = process.memoryUsage ? process.memoryUsage().heapUsed : 0;
69
- const latencyNs = Number(endTime - trace.startTime);
70
- const memoryDelta = endMemory - trace.startMemory;
71
- const latencyMs = latencyNs / 1e6;
72
- let stats = this.metrics.get(fid);
73
- if (!stats) {
74
- stats = {
75
- calls: 0,
76
- errors: 0,
77
- totalLatencyNs: 0,
78
- avgLatencyMs: 0,
79
- peakLatencyMs: 0,
80
- totalMemoryDelta: 0,
81
- avgMemoryDelta: 0,
82
- lastUpdated: 0
83
- };
84
- this.metrics.set(fid, stats);
85
- }
86
- stats.calls++;
87
- if (!success) stats.errors++;
88
- stats.totalLatencyNs += latencyNs;
89
- stats.totalMemoryDelta += memoryDelta;
90
- stats.avgLatencyMs = stats.totalLatencyNs / stats.calls / 1e6;
91
- stats.avgMemoryDelta = stats.totalMemoryDelta / stats.calls;
92
- if (latencyMs > stats.peakLatencyMs) stats.peakLatencyMs = latencyMs;
93
- stats.lastUpdated = Date.now();
94
- if (this.enabled) {
95
- let logs = this.callLogs.get(fid);
96
- if (!logs) {
97
- logs = [];
98
- this.callLogs.set(fid, logs);
99
- }
100
- logs.push({
101
- timestamp: Date.now(),
102
- durationMs: latencyMs,
103
- success
104
- });
105
- if (logs.length > this.ringBufferSize) {
106
- logs.shift();
107
- }
108
- }
109
- if (this.runtimeStore) {
110
- this.runtimeStore.appendTelemetry({
111
- type: "standard_call",
112
- endpointId: fid,
113
- timestamp: Date.now(),
114
- durationMs: latencyMs,
115
- success
116
- }).catch(() => {
117
- });
118
- }
119
- }
120
- /**
121
- * Record library usage (functions/helpers).
122
- */
123
- recordLibraryCall(libraryId, durationMs) {
124
- if (!this.enabled) return;
125
- let stats = this.libraryUsage.get(libraryId);
126
- if (!stats) {
127
- stats = { calls: 0, totalDurationMs: 0, avgDurationMs: 0 };
128
- this.libraryUsage.set(libraryId, stats);
129
- }
130
- stats.calls++;
131
- stats.totalDurationMs += durationMs;
132
- stats.avgDurationMs = stats.totalDurationMs / stats.calls;
133
- }
134
- /**
135
- * Record library data access.
136
- */
137
- recordDataAccess(dataKey, type = "read") {
138
- if (!this.enabled) return;
139
- let stats = this.dataUsage.get(dataKey);
140
- if (!stats) {
141
- stats = { reads: 0, writes: 0 };
142
- this.dataUsage.set(dataKey, stats);
143
- }
144
- if (type === "read") stats.reads++;
145
- else stats.writes++;
146
- }
147
- /**
148
- * Returns a snapshot of all metrics.
149
- */
150
- getSummary() {
151
- return {
152
- metrics: Object.fromEntries(this.metrics),
153
- callLogs: Object.fromEntries(this.callLogs),
154
- libraryUsage: Object.fromEntries(this.libraryUsage),
155
- dataUsage: Object.fromEntries(this.dataUsage)
156
- };
157
- }
158
- /**
159
- * Clears all collected metrics.
160
- */
161
- reset() {
162
- this.metrics.clear();
163
- this.callLogs.clear();
164
- this.libraryUsage.clear();
165
- this.dataUsage.clear();
166
- }
167
- };
168
- var telemetry = new KrnlTelemetry();
169
-
170
- export {
171
- KrnlTelemetry,
172
- telemetry
173
- };