@rotifer/playground 0.8.1 → 0.8.6

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 (453) hide show
  1. package/CHANGELOG.md +46 -11
  2. package/README.md +92 -58
  3. package/README.zh.md +90 -49
  4. package/dist/cloud/auth.d.ts +9 -3
  5. package/dist/cloud/auth.d.ts.map +1 -1
  6. package/dist/cloud/auth.js +28 -13
  7. package/dist/cloud/auth.js.map +1 -1
  8. package/dist/cloud/client.d.ts +4 -3
  9. package/dist/cloud/client.d.ts.map +1 -1
  10. package/dist/cloud/client.js +139 -68
  11. package/dist/cloud/client.js.map +1 -1
  12. package/dist/cloud/types.d.ts +3 -0
  13. package/dist/cloud/types.d.ts.map +1 -1
  14. package/dist/cloud/types.js.map +1 -1
  15. package/dist/commands/agent-create.d.ts +20 -0
  16. package/dist/commands/agent-create.d.ts.map +1 -1
  17. package/dist/commands/agent-create.js +91 -80
  18. package/dist/commands/agent-create.js.map +1 -1
  19. package/dist/commands/agent-list.d.ts.map +1 -1
  20. package/dist/commands/agent-list.js +27 -24
  21. package/dist/commands/agent-list.js.map +1 -1
  22. package/dist/commands/agent-run.d.ts +24 -0
  23. package/dist/commands/agent-run.d.ts.map +1 -1
  24. package/dist/commands/agent-run.js +166 -44
  25. package/dist/commands/agent-run.js.map +1 -1
  26. package/dist/commands/api-key.d.ts +3 -0
  27. package/dist/commands/api-key.d.ts.map +1 -0
  28. package/dist/commands/api-key.js +235 -0
  29. package/dist/commands/api-key.js.map +1 -0
  30. package/dist/commands/arena-list.d.ts.map +1 -1
  31. package/dist/commands/arena-list.js +113 -97
  32. package/dist/commands/arena-list.js.map +1 -1
  33. package/dist/commands/arena-submit.d.ts.map +1 -1
  34. package/dist/commands/arena-submit.js +114 -37
  35. package/dist/commands/arena-submit.js.map +1 -1
  36. package/dist/commands/arena-watch.d.ts.map +1 -1
  37. package/dist/commands/arena-watch.js +59 -87
  38. package/dist/commands/arena-watch.js.map +1 -1
  39. package/dist/commands/compare.d.ts.map +1 -1
  40. package/dist/commands/compare.js +40 -50
  41. package/dist/commands/compare.js.map +1 -1
  42. package/dist/commands/compile.d.ts.map +1 -1
  43. package/dist/commands/compile.js +80 -58
  44. package/dist/commands/compile.js.map +1 -1
  45. package/dist/commands/hello.d.ts +3 -0
  46. package/dist/commands/hello.d.ts.map +1 -0
  47. package/dist/commands/hello.js +575 -0
  48. package/dist/commands/hello.js.map +1 -0
  49. package/dist/commands/info.d.ts.map +1 -1
  50. package/dist/commands/info.js +130 -40
  51. package/dist/commands/info.js.map +1 -1
  52. package/dist/commands/init.d.ts.map +1 -1
  53. package/dist/commands/init.js +39 -60
  54. package/dist/commands/init.js.map +1 -1
  55. package/dist/commands/install.d.ts.map +1 -1
  56. package/dist/commands/install.js +35 -9
  57. package/dist/commands/install.js.map +1 -1
  58. package/dist/commands/list.d.ts.map +1 -1
  59. package/dist/commands/list.js +111 -58
  60. package/dist/commands/list.js.map +1 -1
  61. package/dist/commands/login.d.ts.map +1 -1
  62. package/dist/commands/login.js +23 -10
  63. package/dist/commands/login.js.map +1 -1
  64. package/dist/commands/network.d.ts.map +1 -1
  65. package/dist/commands/network.js +48 -67
  66. package/dist/commands/network.js.map +1 -1
  67. package/dist/commands/publish.d.ts.map +1 -1
  68. package/dist/commands/publish.js +152 -53
  69. package/dist/commands/publish.js.map +1 -1
  70. package/dist/commands/reputation.js +84 -85
  71. package/dist/commands/reputation.js.map +1 -1
  72. package/dist/commands/run.d.ts.map +1 -1
  73. package/dist/commands/run.js +32 -12
  74. package/dist/commands/run.js.map +1 -1
  75. package/dist/commands/scan.d.ts.map +1 -1
  76. package/dist/commands/scan.js +8 -9
  77. package/dist/commands/scan.js.map +1 -1
  78. package/dist/commands/search.d.ts.map +1 -1
  79. package/dist/commands/search.js +80 -54
  80. package/dist/commands/search.js.map +1 -1
  81. package/dist/commands/self-update.d.ts +7 -0
  82. package/dist/commands/self-update.d.ts.map +1 -0
  83. package/dist/commands/self-update.js +187 -0
  84. package/dist/commands/self-update.js.map +1 -0
  85. package/dist/commands/stats.d.ts.map +1 -1
  86. package/dist/commands/stats.js +20 -26
  87. package/dist/commands/stats.js.map +1 -1
  88. package/dist/commands/test.d.ts.map +1 -1
  89. package/dist/commands/test.js +104 -79
  90. package/dist/commands/test.js.map +1 -1
  91. package/dist/commands/user-config.d.ts +3 -0
  92. package/dist/commands/user-config.d.ts.map +1 -0
  93. package/dist/commands/user-config.js +82 -0
  94. package/dist/commands/user-config.js.map +1 -0
  95. package/dist/commands/versions.d.ts.map +1 -1
  96. package/dist/commands/versions.js +46 -33
  97. package/dist/commands/versions.js.map +1 -1
  98. package/dist/commands/vg.d.ts.map +1 -1
  99. package/dist/commands/vg.js +65 -63
  100. package/dist/commands/vg.js.map +1 -1
  101. package/dist/commands/whoami.d.ts.map +1 -1
  102. package/dist/commands/whoami.js +33 -23
  103. package/dist/commands/whoami.js.map +1 -1
  104. package/dist/commands/wrap.d.ts.map +1 -1
  105. package/dist/commands/wrap.js +57 -40
  106. package/dist/commands/wrap.js.map +1 -1
  107. package/dist/index.js +61 -1
  108. package/dist/index.js.map +1 -1
  109. package/dist/publish/pre-publish-check.d.ts +15 -0
  110. package/dist/publish/pre-publish-check.d.ts.map +1 -0
  111. package/dist/publish/pre-publish-check.js +228 -0
  112. package/dist/publish/pre-publish-check.js.map +1 -0
  113. package/dist/runtime/domain-failover.d.ts +1 -1
  114. package/dist/runtime/domain-failover.js +1 -1
  115. package/dist/runtime/network-gateway.d.ts +1 -1
  116. package/dist/runtime/network-gateway.d.ts.map +1 -1
  117. package/dist/runtime/network-gateway.js +10 -10
  118. package/dist/runtime/network-gateway.js.map +1 -1
  119. package/dist/scanner/scanner.js +3 -3
  120. package/dist/scanner/scanner.js.map +1 -1
  121. package/dist/utils/binding.d.ts +1 -0
  122. package/dist/utils/binding.d.ts.map +1 -1
  123. package/dist/utils/binding.js +37 -15
  124. package/dist/utils/binding.js.map +1 -1
  125. package/dist/utils/content-hash.d.ts +3 -0
  126. package/dist/utils/content-hash.d.ts.map +1 -0
  127. package/dist/utils/content-hash.js +25 -0
  128. package/dist/utils/content-hash.js.map +1 -0
  129. package/dist/utils/detect-source-language.d.ts +20 -0
  130. package/dist/utils/detect-source-language.d.ts.map +1 -0
  131. package/dist/utils/detect-source-language.js +83 -0
  132. package/dist/utils/detect-source-language.js.map +1 -0
  133. package/dist/utils/display.d.ts +44 -1
  134. package/dist/utils/display.d.ts.map +1 -1
  135. package/dist/utils/display.js +443 -14
  136. package/dist/utils/display.js.map +1 -1
  137. package/dist/utils/domain-suggest.d.ts.map +1 -1
  138. package/dist/utils/domain-suggest.js +3 -3
  139. package/dist/utils/domain-suggest.js.map +1 -1
  140. package/dist/utils/javy-compiler.d.ts.map +1 -1
  141. package/dist/utils/javy-compiler.js +10 -3
  142. package/dist/utils/javy-compiler.js.map +1 -1
  143. package/dist/utils/open-browser.d.ts +7 -3
  144. package/dist/utils/open-browser.d.ts.map +1 -1
  145. package/dist/utils/open-browser.js +15 -4
  146. package/dist/utils/open-browser.js.map +1 -1
  147. package/dist/utils/palette.d.ts +49 -0
  148. package/dist/utils/palette.d.ts.map +1 -0
  149. package/dist/utils/palette.js +80 -0
  150. package/dist/utils/palette.js.map +1 -0
  151. package/dist/utils/private-fs.d.ts +3 -0
  152. package/dist/utils/private-fs.d.ts.map +1 -0
  153. package/dist/utils/private-fs.js +25 -0
  154. package/dist/utils/private-fs.js.map +1 -0
  155. package/dist/utils/project-root.d.ts +2 -0
  156. package/dist/utils/project-root.d.ts.map +1 -0
  157. package/dist/utils/project-root.js +49 -0
  158. package/dist/utils/project-root.js.map +1 -0
  159. package/dist/utils/run-logger.d.ts +24 -0
  160. package/dist/utils/run-logger.d.ts.map +1 -0
  161. package/dist/utils/run-logger.js +70 -0
  162. package/dist/utils/run-logger.js.map +1 -0
  163. package/dist/utils/sandbox-defaults.d.ts +9 -0
  164. package/dist/utils/sandbox-defaults.d.ts.map +1 -0
  165. package/dist/utils/sandbox-defaults.js +12 -0
  166. package/dist/utils/sandbox-defaults.js.map +1 -0
  167. package/dist/utils/update-check.d.ts +20 -0
  168. package/dist/utils/update-check.d.ts.map +1 -0
  169. package/dist/utils/update-check.js +155 -0
  170. package/dist/utils/update-check.js.map +1 -0
  171. package/dist/utils/user-config.d.ts +10 -0
  172. package/dist/utils/user-config.d.ts.map +1 -0
  173. package/dist/utils/user-config.js +54 -0
  174. package/dist/utils/user-config.js.map +1 -0
  175. package/dist/utils/validate-gene-name.d.ts +7 -0
  176. package/dist/utils/validate-gene-name.d.ts.map +1 -0
  177. package/dist/utils/validate-gene-name.js +28 -0
  178. package/dist/utils/validate-gene-name.js.map +1 -0
  179. package/genes/genesis-code-format/phenotype.json +4 -3
  180. package/genes/genesis-file-read/phenotype.json +4 -3
  181. package/genes/genesis-l0-constraint/phenotype.json +4 -3
  182. package/genes/genesis-web-search/phenotype.json +5 -4
  183. package/genes/genesis-web-search-lite/phenotype.json +4 -3
  184. package/package.json +35 -8
  185. package/scripts/postinstall.js +38 -0
  186. package/dist/errors/formatter.d.ts +0 -25
  187. package/dist/errors/formatter.d.ts.map +0 -1
  188. package/dist/errors/formatter.js +0 -43
  189. package/dist/errors/formatter.js.map +0 -1
  190. package/genes/academic-writer/.cloud-manifest.json +0 -6
  191. package/genes/academic-writer/.gene-manifest.json +0 -8
  192. package/genes/academic-writer/SKILL.md +0 -274
  193. package/genes/academic-writer/phenotype.json +0 -28
  194. package/genes/ai-components/.cloud-manifest.json +0 -6
  195. package/genes/ai-components/.gene-manifest.json +0 -8
  196. package/genes/ai-components/SKILL.md +0 -381
  197. package/genes/ai-components/phenotype.json +0 -28
  198. package/genes/algorithmic-art/.cloud-manifest.json +0 -6
  199. package/genes/algorithmic-art/.gene-manifest.json +0 -8
  200. package/genes/algorithmic-art/SKILL.md +0 -405
  201. package/genes/algorithmic-art/phenotype.json +0 -28
  202. package/genes/answer-synthesizer/.cloud-manifest.json +0 -6
  203. package/genes/answer-synthesizer/index.ts +0 -194
  204. package/genes/answer-synthesizer/phenotype.json +0 -61
  205. package/genes/api-designer/.cloud-manifest.json +0 -6
  206. package/genes/api-designer/.gene-manifest.json +0 -8
  207. package/genes/api-designer/SKILL.md +0 -456
  208. package/genes/api-designer/phenotype.json +0 -28
  209. package/genes/auto-coder/.cloud-manifest.json +0 -6
  210. package/genes/auto-coder/.gene-manifest.json +0 -8
  211. package/genes/auto-coder/SKILL.md +0 -400
  212. package/genes/auto-coder/phenotype.json +0 -28
  213. package/genes/auto-writer/.cloud-manifest.json +0 -6
  214. package/genes/auto-writer/.gene-manifest.json +0 -8
  215. package/genes/auto-writer/SKILL.md +0 -361
  216. package/genes/auto-writer/phenotype.json +0 -28
  217. package/genes/brand-personality/.cloud-manifest.json +0 -6
  218. package/genes/brand-personality/.gene-manifest.json +0 -8
  219. package/genes/brand-personality/SKILL.md +0 -549
  220. package/genes/brand-personality/phenotype.json +0 -28
  221. package/genes/business-writer/.cloud-manifest.json +0 -6
  222. package/genes/business-writer/.gene-manifest.json +0 -8
  223. package/genes/business-writer/SKILL.md +0 -448
  224. package/genes/business-writer/phenotype.json +0 -28
  225. package/genes/citation-manager/.cloud-manifest.json +0 -6
  226. package/genes/citation-manager/.gene-manifest.json +0 -8
  227. package/genes/citation-manager/SKILL.md +0 -279
  228. package/genes/citation-manager/index.ts +0 -162
  229. package/genes/citation-manager/package.json +0 -1
  230. package/genes/citation-manager/phenotype.json +0 -50
  231. package/genes/code-complexity/.cloud-manifest.json +0 -6
  232. package/genes/code-complexity/README.md +0 -35
  233. package/genes/code-complexity/index.ts +0 -101
  234. package/genes/code-complexity/phenotype.json +0 -34
  235. package/genes/copywriter/.cloud-manifest.json +0 -6
  236. package/genes/copywriter/.gene-manifest.json +0 -8
  237. package/genes/copywriter/SKILL.md +0 -329
  238. package/genes/copywriter/phenotype.json +0 -28
  239. package/genes/creative-writer/.cloud-manifest.json +0 -6
  240. package/genes/creative-writer/.gene-manifest.json +0 -8
  241. package/genes/creative-writer/SKILL.md +0 -356
  242. package/genes/creative-writer/phenotype.json +0 -28
  243. package/genes/data-modeler/.cloud-manifest.json +0 -6
  244. package/genes/data-modeler/.gene-manifest.json +0 -8
  245. package/genes/data-modeler/SKILL.md +0 -486
  246. package/genes/data-modeler/phenotype.json +0 -28
  247. package/genes/debugger/.cloud-manifest.json +0 -6
  248. package/genes/debugger/.gene-manifest.json +0 -8
  249. package/genes/debugger/SKILL.md +0 -416
  250. package/genes/debugger/phenotype.json +0 -28
  251. package/genes/design-tokens/.cloud-manifest.json +0 -6
  252. package/genes/design-tokens/.gene-manifest.json +0 -8
  253. package/genes/design-tokens/SKILL.md +0 -222
  254. package/genes/design-tokens/index.ts +0 -128
  255. package/genes/design-tokens/package.json +0 -1
  256. package/genes/design-tokens/phenotype.json +0 -1
  257. package/genes/devops-automator/.cloud-manifest.json +0 -6
  258. package/genes/devops-automator/.gene-manifest.json +0 -8
  259. package/genes/devops-automator/SKILL.md +0 -490
  260. package/genes/devops-automator/phenotype.json +0 -28
  261. package/genes/doc-coauthoring/.cloud-manifest.json +0 -6
  262. package/genes/doc-coauthoring/.gene-manifest.json +0 -8
  263. package/genes/doc-coauthoring/SKILL.md +0 -375
  264. package/genes/doc-coauthoring/phenotype.json +0 -28
  265. package/genes/doc-retrieval/.cloud-manifest.json +0 -6
  266. package/genes/doc-retrieval/index.ts +0 -134
  267. package/genes/doc-retrieval/phenotype.json +0 -54
  268. package/genes/docs-writer/.cloud-manifest.json +0 -6
  269. package/genes/docs-writer/.gene-manifest.json +0 -8
  270. package/genes/docs-writer/SKILL.md +0 -492
  271. package/genes/docs-writer/phenotype.json +0 -28
  272. package/genes/evolve-life/.cloud-manifest.json +0 -6
  273. package/genes/evolve-life/.compile-result.json +0 -12
  274. package/genes/evolve-life/README.md +0 -52
  275. package/genes/evolve-life/gene.ir.wasm +0 -0
  276. package/genes/evolve-life/gene.wasm +0 -0
  277. package/genes/evolve-life/index.ts +0 -255
  278. package/genes/evolve-life/phenotype.json +0 -129
  279. package/genes/evolve-life-bitwise/.cloud-manifest.json +0 -6
  280. package/genes/evolve-life-bitwise/.compile-result.json +0 -12
  281. package/genes/evolve-life-bitwise/gene.ir.wasm +0 -0
  282. package/genes/evolve-life-bitwise/gene.wasm +0 -0
  283. package/genes/evolve-life-bitwise/index.ts +0 -273
  284. package/genes/evolve-life-bitwise/phenotype.json +0 -129
  285. package/genes/evolve-life-sparse/.cloud-manifest.json +0 -6
  286. package/genes/evolve-life-sparse/.compile-result.json +0 -12
  287. package/genes/evolve-life-sparse/gene.ir.wasm +0 -0
  288. package/genes/evolve-life-sparse/gene.wasm +0 -0
  289. package/genes/evolve-life-sparse/index.ts +0 -236
  290. package/genes/evolve-life-sparse/phenotype.json +0 -129
  291. package/genes/fact-checker/.cloud-manifest.json +0 -6
  292. package/genes/fact-checker/.gene-manifest.json +0 -8
  293. package/genes/fact-checker/SKILL.md +0 -373
  294. package/genes/fact-checker/phenotype.json +0 -28
  295. package/genes/git-workflow/.cloud-manifest.json +0 -6
  296. package/genes/git-workflow/.gene-manifest.json +0 -8
  297. package/genes/git-workflow/SKILL.md +0 -407
  298. package/genes/git-workflow/phenotype.json +0 -28
  299. package/genes/grammar-checker/.cloud-manifest.json +0 -6
  300. package/genes/grammar-checker/.gene-manifest.json +0 -8
  301. package/genes/grammar-checker/SKILL.md +0 -194
  302. package/genes/grammar-checker/index.ts +0 -168
  303. package/genes/grammar-checker/package.json +0 -1
  304. package/genes/grammar-checker/phenotype.json +0 -52
  305. package/genes/guard-balanced/.gene-manifest.json +0 -8
  306. package/genes/guard-balanced/phenotype.json +0 -105
  307. package/genes/guard-balanced/system-prompt.md +0 -23
  308. package/genes/guard-strict/.gene-manifest.json +0 -8
  309. package/genes/guard-strict/phenotype.json +0 -107
  310. package/genes/guard-strict/system-prompt.md +0 -18
  311. package/genes/json-validator/.cloud-manifest.json +0 -6
  312. package/genes/json-validator/README.md +0 -42
  313. package/genes/json-validator/index.ts +0 -112
  314. package/genes/json-validator/phenotype.json +0 -42
  315. package/genes/license-advisor/.cloud-manifest.json +0 -6
  316. package/genes/license-advisor/.gene-manifest.json +0 -8
  317. package/genes/license-advisor/SKILL.md +0 -117
  318. package/genes/license-advisor/phenotype.json +0 -28
  319. package/genes/logic-architect/.cloud-manifest.json +0 -6
  320. package/genes/logic-architect/.gene-manifest.json +0 -8
  321. package/genes/logic-architect/SKILL.md +0 -451
  322. package/genes/logic-architect/phenotype.json +0 -28
  323. package/genes/markdown-formatter/.cloud-manifest.json +0 -6
  324. package/genes/markdown-formatter/README.md +0 -34
  325. package/genes/markdown-formatter/index.ts +0 -86
  326. package/genes/markdown-formatter/phenotype.json +0 -32
  327. package/genes/orch/.cloud-manifest.json +0 -6
  328. package/genes/orch/.gene-manifest.json +0 -8
  329. package/genes/orch/SKILL.md +0 -504
  330. package/genes/orch/phenotype.json +0 -28
  331. package/genes/particle-barneshut/.cloud-manifest.json +0 -6
  332. package/genes/particle-barneshut/.compile-result.json +0 -12
  333. package/genes/particle-barneshut/README.md +0 -55
  334. package/genes/particle-barneshut/gene.ir.wasm +0 -0
  335. package/genes/particle-barneshut/gene.wasm +0 -0
  336. package/genes/particle-barneshut/index.ts +0 -486
  337. package/genes/particle-barneshut/phenotype.json +0 -137
  338. package/genes/particle-brute/.cloud-manifest.json +0 -6
  339. package/genes/particle-brute/.compile-result.json +0 -12
  340. package/genes/particle-brute/README.md +0 -55
  341. package/genes/particle-brute/gene.ir.wasm +0 -0
  342. package/genes/particle-brute/gene.wasm +0 -0
  343. package/genes/particle-brute/index.ts +0 -277
  344. package/genes/particle-brute/phenotype.json +0 -137
  345. package/genes/particle-spatial/.cloud-manifest.json +0 -6
  346. package/genes/particle-spatial/.compile-result.json +0 -12
  347. package/genes/particle-spatial/README.md +0 -53
  348. package/genes/particle-spatial/gene.ir.wasm +0 -0
  349. package/genes/particle-spatial/gene.wasm +0 -0
  350. package/genes/particle-spatial/index.ts +0 -352
  351. package/genes/particle-spatial/phenotype.json +0 -137
  352. package/genes/performance-optimizer/.cloud-manifest.json +0 -6
  353. package/genes/performance-optimizer/.gene-manifest.json +0 -8
  354. package/genes/performance-optimizer/SKILL.md +0 -480
  355. package/genes/performance-optimizer/phenotype.json +0 -28
  356. package/genes/plagiarism-checker/.cloud-manifest.json +0 -6
  357. package/genes/plagiarism-checker/.gene-manifest.json +0 -8
  358. package/genes/plagiarism-checker/SKILL.md +0 -342
  359. package/genes/plagiarism-checker/phenotype.json +0 -28
  360. package/genes/product-manager/.cloud-manifest.json +0 -6
  361. package/genes/product-manager/.gene-manifest.json +0 -8
  362. package/genes/product-manager/SKILL.md +0 -249
  363. package/genes/product-manager/phenotype.json +0 -28
  364. package/genes/project-reviewer/.cloud-manifest.json +0 -6
  365. package/genes/project-reviewer/.gene-manifest.json +0 -8
  366. package/genes/project-reviewer/SKILL.md +0 -312
  367. package/genes/project-reviewer/phenotype.json +0 -28
  368. package/genes/prompt-engineer/.cloud-manifest.json +0 -6
  369. package/genes/prompt-engineer/.gene-manifest.json +0 -8
  370. package/genes/prompt-engineer/SKILL.md +0 -411
  371. package/genes/prompt-engineer/phenotype.json +0 -28
  372. package/genes/prompt-review-perf/.gene-manifest.json +0 -8
  373. package/genes/prompt-review-perf/phenotype.json +0 -61
  374. package/genes/prompt-review-perf/system-prompt.md +0 -22
  375. package/genes/prompt-review-readability/.gene-manifest.json +0 -8
  376. package/genes/prompt-review-readability/phenotype.json +0 -60
  377. package/genes/prompt-review-readability/system-prompt.md +0 -21
  378. package/genes/prompt-review-security/.gene-manifest.json +0 -8
  379. package/genes/prompt-review-security/phenotype.json +0 -60
  380. package/genes/prompt-review-security/system-prompt.md +0 -21
  381. package/genes/readability-analyzer/.cloud-manifest.json +0 -6
  382. package/genes/readability-analyzer/.gene-manifest.json +0 -8
  383. package/genes/readability-analyzer/SKILL.md +0 -357
  384. package/genes/readability-analyzer/index.ts +0 -123
  385. package/genes/readability-analyzer/package.json +0 -1
  386. package/genes/readability-analyzer/phenotype.json +0 -35
  387. package/genes/rotifer-protocol/SKILL.md +0 -121
  388. package/genes/rule-router-frequency/.gene-manifest.json +0 -8
  389. package/genes/rule-router-frequency/phenotype.json +0 -76
  390. package/genes/rule-router-frequency/system-prompt.md +0 -26
  391. package/genes/rule-router-relevance/.gene-manifest.json +0 -8
  392. package/genes/rule-router-relevance/phenotype.json +0 -76
  393. package/genes/rule-router-relevance/system-prompt.md +0 -29
  394. package/genes/security-auditor/.cloud-manifest.json +0 -6
  395. package/genes/security-auditor/.gene-manifest.json +0 -8
  396. package/genes/security-auditor/SKILL.md +0 -494
  397. package/genes/security-auditor/phenotype.json +0 -28
  398. package/genes/seo-optimizer/.cloud-manifest.json +0 -6
  399. package/genes/seo-optimizer/.gene-manifest.json +0 -8
  400. package/genes/seo-optimizer/SKILL.md +0 -327
  401. package/genes/seo-optimizer/index.ts +0 -206
  402. package/genes/seo-optimizer/package.json +0 -1
  403. package/genes/seo-optimizer/phenotype.json +0 -1
  404. package/genes/source-linker/.cloud-manifest.json +0 -6
  405. package/genes/source-linker/index.ts +0 -88
  406. package/genes/source-linker/phenotype.json +0 -45
  407. package/genes/style-optimizer/.cloud-manifest.json +0 -6
  408. package/genes/style-optimizer/.gene-manifest.json +0 -8
  409. package/genes/style-optimizer/SKILL.md +0 -285
  410. package/genes/style-optimizer/phenotype.json +0 -28
  411. package/genes/tech-lead/.cloud-manifest.json +0 -6
  412. package/genes/tech-lead/.gene-manifest.json +0 -8
  413. package/genes/tech-lead/SKILL.md +0 -451
  414. package/genes/tech-lead/phenotype.json +0 -28
  415. package/genes/test-wrap/.cloud-manifest.json +0 -6
  416. package/genes/test-wrap/.gene-manifest.json +0 -8
  417. package/genes/test-wrap/phenotype.json +0 -28
  418. package/genes/testing-strategist/.cloud-manifest.json +0 -6
  419. package/genes/testing-strategist/.gene-manifest.json +0 -8
  420. package/genes/testing-strategist/SKILL.md +0 -500
  421. package/genes/testing-strategist/phenotype.json +0 -28
  422. package/genes/text-summarizer/.cloud-manifest.json +0 -6
  423. package/genes/text-summarizer/README.md +0 -34
  424. package/genes/text-summarizer/index.ts +0 -122
  425. package/genes/text-summarizer/phenotype.json +0 -32
  426. package/genes/tone-analyzer/.cloud-manifest.json +0 -6
  427. package/genes/tone-analyzer/.gene-manifest.json +0 -8
  428. package/genes/tone-analyzer/SKILL.md +0 -410
  429. package/genes/tone-analyzer/phenotype.json +0 -28
  430. package/genes/translator/.cloud-manifest.json +0 -6
  431. package/genes/translator/.gene-manifest.json +0 -8
  432. package/genes/translator/SKILL.md +0 -355
  433. package/genes/translator/phenotype.json +0 -28
  434. package/genes/ui-components/.cloud-manifest.json +0 -6
  435. package/genes/ui-components/.gene-manifest.json +0 -8
  436. package/genes/ui-components/SKILL.md +0 -467
  437. package/genes/ui-components/phenotype.json +0 -28
  438. package/genes/uiux-designer/.cloud-manifest.json +0 -6
  439. package/genes/uiux-designer/.gene-manifest.json +0 -8
  440. package/genes/uiux-designer/SKILL.md +0 -353
  441. package/genes/uiux-designer/phenotype.json +0 -28
  442. package/genes/url-extractor/.cloud-manifest.json +0 -6
  443. package/genes/url-extractor/README.md +0 -37
  444. package/genes/url-extractor/index.ts +0 -86
  445. package/genes/url-extractor/phenotype.json +0 -48
  446. package/genes/ux-patterns/.cloud-manifest.json +0 -6
  447. package/genes/ux-patterns/.gene-manifest.json +0 -8
  448. package/genes/ux-patterns/SKILL.md +0 -872
  449. package/genes/ux-patterns/phenotype.json +0 -28
  450. package/genes/web3-components/.cloud-manifest.json +0 -6
  451. package/genes/web3-components/.gene-manifest.json +0 -8
  452. package/genes/web3-components/SKILL.md +0 -390
  453. package/genes/web3-components/phenotype.json +0 -28
@@ -1,168 +0,0 @@
1
- interface GrammarInput {
2
- text: string;
3
- strict?: boolean;
4
- }
5
-
6
- interface GrammarIssue {
7
- rule: string;
8
- message: string;
9
- position: number;
10
- suggestion: string;
11
- }
12
-
13
- interface GrammarOutput {
14
- issues: GrammarIssue[];
15
- score: number;
16
- summary: string;
17
- }
18
-
19
- interface Rule {
20
- id: string;
21
- pattern: RegExp;
22
- message: string;
23
- suggestion: (match: RegExpExecArray) => string;
24
- strict?: boolean;
25
- }
26
-
27
- const RULES: Rule[] = [
28
- {
29
- id: "double-space",
30
- pattern: / +/g,
31
- message: "Multiple consecutive spaces",
32
- suggestion: () => "Use a single space",
33
- },
34
- {
35
- id: "sentence-capitalization",
36
- pattern: /(?:^|[.!?]\s+)([a-z])/gm,
37
- message: "Sentence should start with a capital letter",
38
- suggestion: (m) => `Capitalize "${m[1]}" → "${m[1].toUpperCase()}"`,
39
- },
40
- {
41
- id: "repeated-word",
42
- pattern: /\b(\w{2,})\s+\1\b/gi,
43
- message: "Repeated word",
44
- suggestion: (m) => `Remove duplicate "${m[1]}"`,
45
- },
46
- {
47
- id: "missing-period",
48
- pattern: /[a-zA-Z]\s*$/,
49
- message: "Text does not end with punctuation",
50
- suggestion: () => "Add a period at the end",
51
- },
52
- {
53
- id: "space-before-punctuation",
54
- pattern: /\s+[,;:!?.]/g,
55
- message: "Space before punctuation",
56
- suggestion: () => "Remove space before punctuation mark",
57
- },
58
- {
59
- id: "no-space-after-punctuation",
60
- pattern: /[,;:][^\s\n"')\]]/g,
61
- message: "Missing space after punctuation",
62
- suggestion: () => "Add a space after the punctuation mark",
63
- },
64
- {
65
- id: "a-an-mismatch",
66
- pattern: /\ba\s+(?=[aeiouAEIOU]\w)/g,
67
- message: '"a" before a vowel sound — should be "an"',
68
- suggestion: () => 'Use "an" before vowel sounds',
69
- },
70
- {
71
- id: "an-consonant-mismatch",
72
- pattern: /\ban\s+(?=[bcdfgjklmnpqrstvwxyzBCDFGJKLMNPQRSTVWXYZ]\w)/g,
73
- message: '"an" before a consonant sound — should be "a"',
74
- suggestion: () => 'Use "a" before consonant sounds',
75
- },
76
- {
77
- id: "its-confusion",
78
- pattern: /\bits\s+(?=a\b|the\b|not\b|been\b|going\b|time\b)/gi,
79
- message: 'Possible "it\'s" (it is) instead of "its" (possessive)',
80
- suggestion: () => 'Consider "it\'s" if you mean "it is"',
81
- },
82
- {
83
- id: "then-than",
84
- pattern: /\bmore\s+\w+\s+then\b/gi,
85
- message: '"then" should be "than" in comparisons',
86
- suggestion: () => 'Use "than" for comparisons',
87
- },
88
- {
89
- id: "double-negative",
90
- pattern: /\b(?:don't|doesn't|didn't|won't|wouldn't|can't|couldn't)\s+\w*\s*(?:no|nothing|nobody|nowhere|never)\b/gi,
91
- message: "Double negative detected",
92
- suggestion: () => "Rewrite to use a single negative",
93
- },
94
- {
95
- id: "oxford-comma",
96
- pattern: /,\s+\w+\s+and\s+/gi,
97
- message: "Consider Oxford comma before 'and' in a list",
98
- suggestion: () => "Add comma before 'and' in lists of three or more",
99
- strict: true,
100
- },
101
- {
102
- id: "passive-voice",
103
- pattern: /\b(?:is|are|was|were|been|being)\s+\w+ed\b/gi,
104
- message: "Passive voice detected",
105
- suggestion: () => "Consider rewriting in active voice",
106
- strict: true,
107
- },
108
- {
109
- id: "very-qualifier",
110
- pattern: /\bvery\s+\w+/gi,
111
- message: 'Weak qualifier "very" — consider a stronger word',
112
- suggestion: () => 'Replace "very + adjective" with a single stronger adjective',
113
- strict: true,
114
- },
115
- {
116
- id: "trailing-whitespace",
117
- pattern: /[ \t]+$/gm,
118
- message: "Trailing whitespace at end of line",
119
- suggestion: () => "Remove trailing whitespace",
120
- },
121
- ];
122
-
123
- /**
124
- * Grammar Checker Gene
125
- *
126
- * Rule-based English grammar checker with ~15 rules.
127
- * Detects common errors like double spaces, capitalization, repeated words, etc.
128
- */
129
- export async function express(input: GrammarInput): Promise<GrammarOutput> {
130
- const text = (input.text || "").trim();
131
- const strict = input.strict ?? false;
132
-
133
- if (!text) {
134
- return { issues: [], score: 100, summary: "No text provided." };
135
- }
136
-
137
- const issues: GrammarIssue[] = [];
138
-
139
- for (const rule of RULES) {
140
- if (rule.strict && !strict) continue;
141
-
142
- const regex = new RegExp(rule.pattern.source, rule.pattern.flags);
143
- let match: RegExpExecArray | null;
144
-
145
- while ((match = regex.exec(text)) !== null) {
146
- issues.push({
147
- rule: rule.id,
148
- message: rule.message,
149
- position: match.index,
150
- suggestion: rule.suggestion(match),
151
- });
152
- if (!regex.global) break;
153
- }
154
- }
155
-
156
- issues.sort((a, b) => a.position - b.position);
157
-
158
- const wordCount = text.split(/\s+/).filter((w) => w.length > 0).length;
159
- const penalty = Math.min(issues.length * 5, 100);
160
- const score = Math.max(0, 100 - penalty);
161
-
162
- const summary =
163
- issues.length === 0
164
- ? `No issues found in ${wordCount} words. Clean text!`
165
- : `Found ${issues.length} issue${issues.length > 1 ? "s" : ""} in ${wordCount} words.`;
166
-
167
- return { issues, score, summary };
168
- }
@@ -1 +0,0 @@
1
- {"type":"module"}
@@ -1,52 +0,0 @@
1
- {
2
- "domain": "content.grammar",
3
- "description": "Check grammar, spelling, and punctuation in written content. Identify common errors and provide corrections. Use when reviewing any written content for grammatical accuracy.",
4
- "inputSchema": {
5
- "type": "object",
6
- "properties": {
7
- "text": {
8
- "type": "string",
9
- "description": "English text to check for grammar issues"
10
- },
11
- "strict": {
12
- "type": "boolean",
13
- "description": "Enable additional rules (passive voice, excessive adverbs)",
14
- "default": false
15
- }
16
- },
17
- "required": ["text"]
18
- },
19
- "outputSchema": {
20
- "type": "object",
21
- "properties": {
22
- "issues": {
23
- "type": "array",
24
- "items": {
25
- "type": "object",
26
- "properties": {
27
- "rule": { "type": "string" },
28
- "message": { "type": "string" },
29
- "position": { "type": "number" },
30
- "suggestion": { "type": "string" }
31
- },
32
- "required": ["rule", "message", "position", "suggestion"]
33
- }
34
- },
35
- "score": {
36
- "type": "number",
37
- "description": "0-100, higher = fewer issues"
38
- },
39
- "summary": {
40
- "type": "string"
41
- }
42
- },
43
- "required": ["issues", "score", "summary"]
44
- },
45
- "dependencies": [],
46
- "version": "0.2.0",
47
- "author": "rotifer-team",
48
- "createdAt": 1771939397858,
49
- "fidelity": "Native",
50
- "transparency": "Open",
51
- "source": "skill"
52
- }
@@ -1,8 +0,0 @@
1
- {
2
- "geneId": "6ca9ed3958f3472001dcd416b50b756aacb4f0c299892b5a7571c5d7fda1368b",
3
- "name": "guard-balanced",
4
- "domain": "guard.code-review",
5
- "fidelity": "Wrapped",
6
- "wrappedAt": "2026-03-24T01:54:54.000Z",
7
- "fromSkill": null
8
- }
@@ -1,105 +0,0 @@
1
- {
2
- "domain": "guard.code-review",
3
- "description": "Balanced guard gene for code review output filtering. Equal weight on precision and recall — filters obvious false positives while preserving most true findings. Adds confidence scores without aggressive rejection. Part of the Code Review Assistant 3×2 arena competition.",
4
- "inputSchema": {
5
- "type": "object",
6
- "properties": {
7
- "reviewOutput": {
8
- "type": "object",
9
- "description": "Raw output from a Prompt Gene (code review findings)",
10
- "properties": {
11
- "findings": {
12
- "type": "array",
13
- "items": {
14
- "type": "object",
15
- "properties": {
16
- "severity": { "type": "string" },
17
- "category": { "type": "string" },
18
- "message": { "type": "string" },
19
- "line": { "type": "integer" },
20
- "fix": { "type": "string" }
21
- }
22
- }
23
- },
24
- "summary": { "type": "string" }
25
- }
26
- },
27
- "originalCode": {
28
- "type": "string",
29
- "description": "The original code being reviewed (for cross-checking)"
30
- }
31
- },
32
- "required": ["reviewOutput"]
33
- },
34
- "outputSchema": {
35
- "type": "object",
36
- "properties": {
37
- "filteredFindings": {
38
- "type": "array",
39
- "items": {
40
- "type": "object",
41
- "properties": {
42
- "severity": { "type": "string" },
43
- "category": { "type": "string" },
44
- "message": { "type": "string" },
45
- "line": { "type": "integer" },
46
- "fix": { "type": "string" },
47
- "confidence": { "type": "number" }
48
- }
49
- }
50
- },
51
- "rejected": {
52
- "type": "array",
53
- "items": {
54
- "type": "object",
55
- "properties": {
56
- "originalMessage": { "type": "string" },
57
- "rejectReason": { "type": "string" }
58
- }
59
- }
60
- },
61
- "guardStats": {
62
- "type": "object",
63
- "properties": {
64
- "inputCount": { "type": "integer" },
65
- "outputCount": { "type": "integer" },
66
- "rejectRate": { "type": "number" }
67
- }
68
- }
69
- }
70
- },
71
- "llmRequirements": {
72
- "templateFormat": "mustache",
73
- "templateVariables": ["reviewOutput", "originalCode"],
74
- "targetModels": ["claude-3", "gpt-4"],
75
- "minContextWindow": 8192,
76
- "expectedOutputFormat": "json",
77
- "temperatureHint": 0.1,
78
- "maxOutputTokens": 4096,
79
- "systemPromptPath": "system-prompt.md",
80
- "chainOfThought": false
81
- },
82
- "guardConfig": {
83
- "mode": "filter",
84
- "vgContribution": "Security_Leak_Risk",
85
- "strictness": "balanced",
86
- "targetFalsePositiveRate": 0.15,
87
- "targetFalseNegativeRate": 0.10
88
- },
89
- "fitnessConfig": {
90
- "evaluationMethod": "template-quality",
91
- "dimensions": {
92
- "precision": { "weight": 0.30, "description": "1 - false positive rate" },
93
- "recall": { "weight": 0.30, "description": "Fraction of true issues preserved" },
94
- "rejectQuality": { "weight": 0.20, "description": "Correctness of reject reasons" },
95
- "templateValidity": { "weight": 0.10, "description": "Template renders without error" },
96
- "resourceEfficiency": { "weight": 0.10, "description": "Token efficiency" }
97
- }
98
- },
99
- "dependencies": [],
100
- "version": "0.1.0",
101
- "author": "rotifer-team",
102
- "fidelity": "Wrapped",
103
- "transparency": "Open",
104
- "source": "development-genome"
105
- }
@@ -1,23 +0,0 @@
1
- You are a BALANCED code review guard. Your job is to filter code review findings while preserving most genuine issues.
2
-
3
- Your philosophy: **Catch obvious false positives, but err on the side of including uncertain findings with lower confidence scores.**
4
-
5
- For each finding in the review output, evaluate:
6
-
7
- 1. **Existence check**: If `originalCode` is provided, verify the described code pattern actually exists. REJECT only clear hallucinations.
8
- 2. **Confidence scoring**: Assign a confidence score (0-1):
9
- - 0.9-1.0: Finding references specific line and code pattern exists
10
- - 0.7-0.9: Finding is plausible but line reference is approximate
11
- - 0.5-0.7: Finding is generic but category is relevant to the code
12
- - Below 0.5: REJECT — too vague or unsupported
13
- 3. **Severity validation**: Only adjust severity if clearly wrong (e.g., "critical" for a style issue).
14
- 4. **Deduplication**: If multiple findings describe the same issue, keep the most specific one.
15
-
16
- Pass findings with confidence >= 0.4 (lower threshold than strict mode).
17
-
18
- Output valid JSON with:
19
- - `filteredFindings`: findings that survived (with confidence scores)
20
- - `rejected`: only clearly false findings (with brief reason)
21
- - `guardStats`: input/output counts and reject rate
22
-
23
- The reject rate should typically be 10-25%. If you're rejecting >40%, you're being too strict.
@@ -1,8 +0,0 @@
1
- {
2
- "geneId": "9140b1416a649930a950e345746bf68996ef8043ec2fd83ab73474a6f1fd5875",
3
- "name": "guard-strict",
4
- "domain": "guard.code-review",
5
- "fidelity": "Wrapped",
6
- "wrappedAt": "2026-03-24T01:54:54.000Z",
7
- "fromSkill": null
8
- }
@@ -1,107 +0,0 @@
1
- {
2
- "domain": "guard.code-review",
3
- "description": "Strict guard gene for code review output filtering. High precision, low recall — blocks false positives aggressively. Prefers missing a real issue over flagging a non-issue. Part of the Code Review Assistant 3×2 arena competition.",
4
- "inputSchema": {
5
- "type": "object",
6
- "properties": {
7
- "reviewOutput": {
8
- "type": "object",
9
- "description": "Raw output from a Prompt Gene (code review findings)",
10
- "properties": {
11
- "findings": {
12
- "type": "array",
13
- "items": {
14
- "type": "object",
15
- "properties": {
16
- "severity": { "type": "string" },
17
- "category": { "type": "string" },
18
- "message": { "type": "string" },
19
- "line": { "type": "integer" },
20
- "fix": { "type": "string" }
21
- }
22
- }
23
- },
24
- "summary": { "type": "string" }
25
- }
26
- },
27
- "originalCode": {
28
- "type": "string",
29
- "description": "The original code being reviewed (for cross-checking)"
30
- }
31
- },
32
- "required": ["reviewOutput"]
33
- },
34
- "outputSchema": {
35
- "type": "object",
36
- "properties": {
37
- "filteredFindings": {
38
- "type": "array",
39
- "items": {
40
- "type": "object",
41
- "properties": {
42
- "severity": { "type": "string" },
43
- "category": { "type": "string" },
44
- "message": { "type": "string" },
45
- "line": { "type": "integer" },
46
- "fix": { "type": "string" },
47
- "confidence": { "type": "number", "description": "0-1 confidence that this is a real issue" }
48
- }
49
- },
50
- "description": "Only findings that pass strict validation"
51
- },
52
- "rejected": {
53
- "type": "array",
54
- "items": {
55
- "type": "object",
56
- "properties": {
57
- "originalMessage": { "type": "string" },
58
- "rejectReason": { "type": "string" }
59
- }
60
- },
61
- "description": "Findings rejected with reason"
62
- },
63
- "guardStats": {
64
- "type": "object",
65
- "properties": {
66
- "inputCount": { "type": "integer" },
67
- "outputCount": { "type": "integer" },
68
- "rejectRate": { "type": "number" }
69
- }
70
- }
71
- }
72
- },
73
- "llmRequirements": {
74
- "templateFormat": "mustache",
75
- "templateVariables": ["reviewOutput", "originalCode"],
76
- "targetModels": ["claude-3", "gpt-4"],
77
- "minContextWindow": 8192,
78
- "expectedOutputFormat": "json",
79
- "temperatureHint": 0.0,
80
- "maxOutputTokens": 4096,
81
- "systemPromptPath": "system-prompt.md",
82
- "chainOfThought": true
83
- },
84
- "guardConfig": {
85
- "mode": "filter",
86
- "vgContribution": "Security_Leak_Risk",
87
- "strictness": "high",
88
- "targetFalsePositiveRate": 0.05,
89
- "targetFalseNegativeRate": 0.30
90
- },
91
- "fitnessConfig": {
92
- "evaluationMethod": "template-quality",
93
- "dimensions": {
94
- "precision": { "weight": 0.40, "description": "1 - false positive rate" },
95
- "recall": { "weight": 0.20, "description": "Fraction of true issues preserved" },
96
- "rejectQuality": { "weight": 0.20, "description": "Correctness of reject reasons" },
97
- "templateValidity": { "weight": 0.10, "description": "Template renders without error" },
98
- "resourceEfficiency": { "weight": 0.10, "description": "Token efficiency" }
99
- }
100
- },
101
- "dependencies": [],
102
- "version": "0.1.0",
103
- "author": "rotifer-team",
104
- "fidelity": "Wrapped",
105
- "transparency": "Open",
106
- "source": "development-genome"
107
- }
@@ -1,18 +0,0 @@
1
- You are a STRICT code review guard. Your job is to filter code review findings, removing likely false positives.
2
-
3
- Your philosophy: **Better to miss a real issue than to waste developer time on a false alarm.**
4
-
5
- For each finding in the review output, evaluate:
6
-
7
- 1. **Line reference check**: Does the finding reference a specific line? If the line number doesn't correspond to relevant code, REJECT.
8
- 2. **Category validity**: Is the category (e.g., "injection", "memory-leak") supported by the actual code pattern? Reject vague or generic warnings.
9
- 3. **Fix actionability**: Does the fix suggestion contain concrete code? Reject findings with only "consider reviewing" or "be careful" advice.
10
- 4. **Hallucination check**: If `originalCode` is provided, verify the finding references actual code constructs. Reject if the finding describes code that doesn't exist.
11
- 5. **Severity calibration**: Downgrade "critical" to "warning" if the exploit requires unlikely preconditions.
12
-
13
- Only pass findings with confidence >= 0.7.
14
-
15
- Output valid JSON with:
16
- - `filteredFindings`: findings that survived filtering (with confidence scores)
17
- - `rejected`: findings removed (with reject reasons for transparency)
18
- - `guardStats`: input/output counts and reject rate
@@ -1,6 +0,0 @@
1
- {
2
- "cloud_id": "2770db73-0925-435a-9cd7-f978b95c9e86",
3
- "owner": "Rotifer Protocol",
4
- "version": "0.1.0",
5
- "published_at": "2026-03-17T14:13:02.716Z"
6
- }
@@ -1,42 +0,0 @@
1
- # json-validator
2
-
3
- A Native Gene that validates JSON data against a JSON Schema definition.
4
-
5
- ## Usage
6
-
7
- ```bash
8
- rotifer test json-validator --input '{
9
- "data": {"name": "Alice", "age": "not-a-number"},
10
- "schema": {
11
- "type": "object",
12
- "properties": {
13
- "name": {"type": "string"},
14
- "age": {"type": "number"}
15
- },
16
- "required": ["name", "age"]
17
- }
18
- }'
19
- ```
20
-
21
- ## Features
22
-
23
- - Full JSON Schema Draft-07 validation
24
- - Detailed error messages with JSON path locations
25
- - Strict mode for disallowing extra properties
26
- - Nested schema support
27
-
28
- ## Input
29
-
30
- | Field | Type | Required | Description |
31
- |-------|------|----------|-------------|
32
- | `data` | any | Yes | The JSON data to validate |
33
- | `schema` | object | Yes | JSON Schema definition |
34
- | `strict` | boolean | No | Disallow additional properties (default: false) |
35
-
36
- ## Output
37
-
38
- | Field | Type | Description |
39
- |-------|------|-------------|
40
- | `valid` | boolean | Whether validation passed |
41
- | `errors` | array | Validation errors with path, message, keyword |
42
- | `errorCount` | number | Total error count |
@@ -1,112 +0,0 @@
1
- interface ValidatorInput {
2
- data: unknown;
3
- schema: Record<string, unknown>;
4
- strict?: boolean;
5
- }
6
-
7
- interface ValidationError {
8
- path: string;
9
- message: string;
10
- keyword: string;
11
- }
12
-
13
- interface ValidatorOutput {
14
- valid: boolean;
15
- errors: ValidationError[];
16
- errorCount: number;
17
- }
18
-
19
- function validate(
20
- data: unknown,
21
- schema: Record<string, unknown>,
22
- path: string,
23
- strict: boolean,
24
- ): ValidationError[] {
25
- const errors: ValidationError[] = [];
26
-
27
- if (schema.type) {
28
- const expected = schema.type as string;
29
- const actual = Array.isArray(data) ? "array" : data === null ? "null" : typeof data;
30
- if (expected !== actual) {
31
- errors.push({ path, message: `Expected ${expected}, got ${actual}`, keyword: "type" });
32
- return errors;
33
- }
34
- }
35
-
36
- if (schema.enum && Array.isArray(schema.enum)) {
37
- if (!schema.enum.includes(data)) {
38
- errors.push({ path, message: `Value must be one of: ${schema.enum.join(", ")}`, keyword: "enum" });
39
- }
40
- }
41
-
42
- if (typeof data === "number") {
43
- if (typeof schema.minimum === "number" && data < schema.minimum) {
44
- errors.push({ path, message: `Value ${data} is below minimum ${schema.minimum}`, keyword: "minimum" });
45
- }
46
- if (typeof schema.maximum === "number" && data > schema.maximum) {
47
- errors.push({ path, message: `Value ${data} exceeds maximum ${schema.maximum}`, keyword: "maximum" });
48
- }
49
- }
50
-
51
- if (typeof data === "string") {
52
- if (typeof schema.minLength === "number" && data.length < schema.minLength) {
53
- errors.push({ path, message: `String length ${data.length} is below minLength ${schema.minLength}`, keyword: "minLength" });
54
- }
55
- if (typeof schema.maxLength === "number" && data.length > schema.maxLength) {
56
- errors.push({ path, message: `String length ${data.length} exceeds maxLength ${schema.maxLength}`, keyword: "maxLength" });
57
- }
58
- if (schema.pattern) {
59
- const re = new RegExp(schema.pattern as string);
60
- if (!re.test(data)) {
61
- errors.push({ path, message: `String does not match pattern "${schema.pattern}"`, keyword: "pattern" });
62
- }
63
- }
64
- }
65
-
66
- if (Array.isArray(data) && schema.type === "array") {
67
- if (typeof schema.minItems === "number" && data.length < (schema.minItems as number)) {
68
- errors.push({ path, message: `Array has ${data.length} items, minimum is ${schema.minItems}`, keyword: "minItems" });
69
- }
70
- if (typeof schema.maxItems === "number" && data.length > (schema.maxItems as number)) {
71
- errors.push({ path, message: `Array has ${data.length} items, maximum is ${schema.maxItems}`, keyword: "maxItems" });
72
- }
73
- if (schema.items && typeof schema.items === "object") {
74
- for (let i = 0; i < data.length; i++) {
75
- errors.push(...validate(data[i], schema.items as Record<string, unknown>, `${path}[${i}]`, strict));
76
- }
77
- }
78
- }
79
-
80
- if (data !== null && typeof data === "object" && !Array.isArray(data) && schema.type === "object") {
81
- const obj = data as Record<string, unknown>;
82
- const props = (schema.properties || {}) as Record<string, Record<string, unknown>>;
83
- const required = (schema.required || []) as string[];
84
-
85
- for (const key of required) {
86
- if (!(key in obj)) {
87
- errors.push({ path: `${path}.${key}`, message: `Required property "${key}" is missing`, keyword: "required" });
88
- }
89
- }
90
-
91
- for (const [key, value] of Object.entries(obj)) {
92
- if (props[key]) {
93
- errors.push(...validate(value, props[key], `${path}.${key}`, strict));
94
- } else if (strict && schema.additionalProperties === false) {
95
- errors.push({ path: `${path}.${key}`, message: `Additional property "${key}" is not allowed`, keyword: "additionalProperties" });
96
- }
97
- }
98
- }
99
-
100
- return errors;
101
- }
102
-
103
- export async function express(input: ValidatorInput): Promise<ValidatorOutput> {
104
- const { data, schema, strict = false } = input;
105
-
106
- if (!schema || typeof schema !== "object") {
107
- return { valid: false, errors: [{ path: "$", message: "Invalid schema provided", keyword: "schema" }], errorCount: 1 };
108
- }
109
-
110
- const errors = validate(data, schema, "$", strict);
111
- return { valid: errors.length === 0, errors, errorCount: errors.length };
112
- }