glirastes 0.3.0 → 0.3.2

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 (310) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +154 -9
  3. package/codegen/package.json +5 -0
  4. package/dist/cjs/codegen/asset-sync.d.ts +20 -0
  5. package/dist/cjs/codegen/asset-sync.js +28 -0
  6. package/dist/cjs/codegen/coverage.d.ts +66 -0
  7. package/dist/cjs/codegen/coverage.js +408 -0
  8. package/dist/cjs/codegen/endpoint-scanner.d.ts +16 -0
  9. package/dist/cjs/codegen/endpoint-scanner.js +197 -0
  10. package/dist/cjs/codegen/format.d.ts +17 -0
  11. package/dist/cjs/codegen/format.js +34 -0
  12. package/dist/cjs/codegen/fs-utils.d.ts +45 -0
  13. package/dist/cjs/codegen/fs-utils.js +165 -0
  14. package/dist/cjs/codegen/index.d.ts +13 -0
  15. package/dist/cjs/codegen/index.js +33 -0
  16. package/dist/cjs/codegen/mcp-generator.d.ts +50 -0
  17. package/dist/cjs/codegen/mcp-generator.js +803 -0
  18. package/dist/cjs/codegen/module-generator.d.ts +11 -0
  19. package/dist/cjs/codegen/module-generator.js +353 -0
  20. package/dist/cjs/codegen/nestjs-scanner.d.ts +43 -0
  21. package/dist/cjs/codegen/nestjs-scanner.js +241 -0
  22. package/dist/cjs/codegen/output-recommender.d.ts +23 -0
  23. package/dist/cjs/codegen/output-recommender.js +33 -0
  24. package/dist/cjs/codegen/scaffolder.d.ts +36 -0
  25. package/dist/cjs/codegen/scaffolder.js +262 -0
  26. package/dist/cjs/codegen/skill-generator.d.ts +49 -0
  27. package/dist/cjs/codegen/skill-generator.js +967 -0
  28. package/dist/cjs/codegen/types.d.ts +52 -0
  29. package/dist/cjs/codegen/types.js +16 -0
  30. package/dist/cjs/codegen/ui-scanner.d.ts +24 -0
  31. package/dist/cjs/codegen/ui-scanner.js +202 -0
  32. package/dist/cjs/codegen/validator.d.ts +35 -0
  33. package/dist/cjs/codegen/validator.js +292 -0
  34. package/dist/cjs/index.d.ts +1 -0
  35. package/dist/cjs/index.js +23 -0
  36. package/dist/cjs/openapi/index.d.ts +78 -0
  37. package/dist/cjs/openapi/index.js +347 -0
  38. package/dist/cjs/package.json +1 -0
  39. package/dist/cjs/react/audio-worklet-processor.d.ts +16 -0
  40. package/dist/cjs/react/audio-worklet-processor.js +27 -0
  41. package/dist/cjs/react/bridges/rest-session-bridge.d.ts +113 -0
  42. package/dist/cjs/react/bridges/rest-session-bridge.js +209 -0
  43. package/dist/cjs/react/components/ai-chat-panel.d.ts +12 -0
  44. package/dist/cjs/react/components/ai-chat-panel.js +67 -0
  45. package/dist/cjs/react/components/ai-trigger-button.d.ts +2 -0
  46. package/dist/cjs/react/components/ai-trigger-button.js +239 -0
  47. package/dist/cjs/react/components/approval-card.d.ts +9 -0
  48. package/dist/cjs/react/components/approval-card.js +24 -0
  49. package/dist/cjs/react/components/bulk-approval-card.d.ts +9 -0
  50. package/dist/cjs/react/components/bulk-approval-card.js +36 -0
  51. package/dist/cjs/react/components/chat-input.d.ts +10 -0
  52. package/dist/cjs/react/components/chat-input.js +60 -0
  53. package/dist/cjs/react/components/chat-window.d.ts +2 -0
  54. package/dist/cjs/react/components/chat-window.js +134 -0
  55. package/dist/cjs/react/components/confirm-dialog.d.ts +32 -0
  56. package/dist/cjs/react/components/confirm-dialog.js +48 -0
  57. package/dist/cjs/react/components/floating-chat-ui.d.ts +90 -0
  58. package/dist/cjs/react/components/floating-chat-ui.js +163 -0
  59. package/dist/cjs/react/components/mention-chip.d.ts +16 -0
  60. package/dist/cjs/react/components/mention-chip.js +42 -0
  61. package/dist/cjs/react/components/mention-input.d.ts +8 -0
  62. package/dist/cjs/react/components/mention-input.js +117 -0
  63. package/dist/cjs/react/components/message-bubble.d.ts +11 -0
  64. package/dist/cjs/react/components/message-bubble.js +171 -0
  65. package/dist/cjs/react/components/message-list.d.ts +8 -0
  66. package/dist/cjs/react/components/message-list.js +52 -0
  67. package/dist/cjs/react/components/pipeline-timeline.d.ts +7 -0
  68. package/dist/cjs/react/components/pipeline-timeline.js +72 -0
  69. package/dist/cjs/react/components/recording-bar.d.ts +2 -0
  70. package/dist/cjs/react/components/recording-bar.js +81 -0
  71. package/dist/cjs/react/components/recording-controls.d.ts +18 -0
  72. package/dist/cjs/react/components/recording-controls.js +38 -0
  73. package/dist/cjs/react/components/rich-mention-input.d.ts +2 -0
  74. package/dist/cjs/react/components/rich-mention-input.js +571 -0
  75. package/dist/cjs/react/components/session-switcher.d.ts +14 -0
  76. package/dist/cjs/react/components/session-switcher.js +133 -0
  77. package/dist/cjs/react/components/suggestion-bar.d.ts +9 -0
  78. package/dist/cjs/react/components/suggestion-bar.js +47 -0
  79. package/dist/cjs/react/components/suggestion-chip.d.ts +9 -0
  80. package/dist/cjs/react/components/suggestion-chip.js +14 -0
  81. package/dist/cjs/react/components/voice-input-addon.d.ts +13 -0
  82. package/dist/cjs/react/components/voice-input-addon.js +31 -0
  83. package/dist/cjs/react/components/voice-input-button.d.ts +2 -0
  84. package/dist/cjs/react/components/voice-input-button.js +55 -0
  85. package/dist/cjs/react/components/wavesurfer-loader.d.ts +5 -0
  86. package/dist/cjs/react/components/wavesurfer-loader.js +36 -0
  87. package/dist/cjs/react/hooks/use-ai-chat.d.ts +22 -0
  88. package/dist/cjs/react/hooks/use-ai-chat.js +51 -0
  89. package/dist/cjs/react/hooks/use-approvals.d.ts +23 -0
  90. package/dist/cjs/react/hooks/use-approvals.js +63 -0
  91. package/dist/cjs/react/hooks/use-deepgram-transcription.d.ts +2 -0
  92. package/dist/cjs/react/hooks/use-deepgram-transcription.js +329 -0
  93. package/dist/cjs/react/hooks/use-drag-resize-panel.d.ts +48 -0
  94. package/dist/cjs/react/hooks/use-drag-resize-panel.js +308 -0
  95. package/dist/cjs/react/hooks/use-draggable-position.d.ts +25 -0
  96. package/dist/cjs/react/hooks/use-draggable-position.js +134 -0
  97. package/dist/cjs/react/hooks/use-keyboard-shortcut.d.ts +20 -0
  98. package/dist/cjs/react/hooks/use-keyboard-shortcut.js +93 -0
  99. package/dist/cjs/react/hooks/use-mentions.d.ts +23 -0
  100. package/dist/cjs/react/hooks/use-mentions.js +42 -0
  101. package/dist/cjs/react/hooks/use-suggestions.d.ts +22 -0
  102. package/dist/cjs/react/hooks/use-suggestions.js +39 -0
  103. package/dist/cjs/react/index.d.ts +43 -0
  104. package/dist/cjs/react/index.js +111 -0
  105. package/dist/cjs/react/provider/ai-chat-provider.d.ts +45 -0
  106. package/dist/cjs/react/provider/ai-chat-provider.js +1024 -0
  107. package/dist/cjs/react/provider/chat-context.d.ts +84 -0
  108. package/dist/cjs/react/provider/chat-context.js +13 -0
  109. package/dist/cjs/react/template.d.ts +84 -0
  110. package/dist/cjs/react/template.js +90 -0
  111. package/dist/cjs/react/themes.d.ts +24 -0
  112. package/dist/cjs/react/themes.js +273 -0
  113. package/dist/cjs/react/transports/langgraph/index.d.ts +2 -0
  114. package/dist/cjs/react/transports/langgraph/index.js +8 -0
  115. package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.d.ts +62 -0
  116. package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.js +94 -0
  117. package/dist/cjs/react/transports/langgraph.d.ts +71 -0
  118. package/dist/cjs/react/transports/langgraph.js +369 -0
  119. package/dist/cjs/react/transports/vercel/index.d.ts +2 -0
  120. package/dist/cjs/react/transports/vercel/index.js +8 -0
  121. package/dist/cjs/react/transports/vercel/vercel-ai-chat.d.ts +49 -0
  122. package/dist/cjs/react/transports/vercel/vercel-ai-chat.js +81 -0
  123. package/dist/cjs/react/transports/vercel.d.ts +30 -0
  124. package/dist/cjs/react/transports/vercel.js +69 -0
  125. package/dist/cjs/react/types.d.ts +760 -0
  126. package/dist/cjs/react/types.js +2 -0
  127. package/dist/cjs/react/ui.d.ts +73 -0
  128. package/dist/cjs/react/ui.js +183 -0
  129. package/dist/cjs/react/utils/create-approval-description.d.ts +53 -0
  130. package/dist/cjs/react/utils/create-approval-description.js +122 -0
  131. package/dist/cjs/react/utils/create-tool-result-handler.d.ts +90 -0
  132. package/dist/cjs/react/utils/create-tool-result-handler.js +168 -0
  133. package/dist/cjs/react/utils/mention-markup.d.ts +13 -0
  134. package/dist/cjs/react/utils/mention-markup.js +117 -0
  135. package/dist/cjs/react/utils/merge-pipeline-steps.d.ts +19 -0
  136. package/dist/cjs/react/utils/merge-pipeline-steps.js +81 -0
  137. package/dist/cjs/react/utils/sanitize-stored-messages.d.ts +23 -0
  138. package/dist/cjs/react/utils/sanitize-stored-messages.js +52 -0
  139. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +10 -0
  140. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.js +42 -0
  141. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +32 -0
  142. package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +4 -0
  143. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.d.ts +11 -0
  144. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.js +80 -0
  145. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.d.ts +9 -0
  146. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.js +119 -0
  147. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.d.ts +13 -0
  148. package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.js +131 -0
  149. package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +7 -0
  150. package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +52 -0
  151. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +19 -0
  152. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +108 -0
  153. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +8 -0
  154. package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.js +59 -0
  155. package/dist/cjs/server/adapters/nestjs/chat/dto/index.d.ts +3 -0
  156. package/dist/cjs/server/adapters/nestjs/chat/dto/index.js +9 -0
  157. package/dist/cjs/server/adapters/nestjs/chat/index.d.ts +3 -0
  158. package/dist/cjs/server/adapters/nestjs/chat/index.js +9 -0
  159. package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +4 -0
  160. package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.js +73 -0
  161. package/dist/cjs/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
  162. package/dist/cjs/server/adapters/nestjs/chat/ws-loader.js +72 -0
  163. package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +6 -0
  164. package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.js +13 -0
  165. package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +5 -0
  166. package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.js +15 -0
  167. package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +6 -0
  168. package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.js +22 -0
  169. package/dist/cjs/server/adapters/nestjs/decorators/constants.d.ts +4 -0
  170. package/dist/cjs/server/adapters/nestjs/decorators/constants.js +7 -0
  171. package/dist/cjs/server/adapters/nestjs/index.d.ts +14 -0
  172. package/dist/cjs/server/adapters/nestjs/index.js +42 -0
  173. package/dist/cjs/server/adapters/nestjs/metadata.d.ts +39 -0
  174. package/dist/cjs/server/adapters/nestjs/metadata.js +36 -0
  175. package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +36 -0
  176. package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.js +159 -0
  177. package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.d.ts +37 -0
  178. package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.js +44 -0
  179. package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.d.ts +28 -0
  180. package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.js +41 -0
  181. package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +16 -0
  182. package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.js +117 -0
  183. package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.d.ts +26 -0
  184. package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.js +259 -0
  185. package/dist/cjs/server/adapters/nestjs/swagger.d.ts +7 -0
  186. package/dist/cjs/server/adapters/nestjs/swagger.js +39 -0
  187. package/dist/cjs/server/adapters/nextjs/context-helpers.d.ts +22 -0
  188. package/dist/cjs/server/adapters/nextjs/context-helpers.js +60 -0
  189. package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.d.ts +94 -0
  190. package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.js +965 -0
  191. package/dist/cjs/server/adapters/nextjs/filter-fallback-error.d.ts +11 -0
  192. package/dist/cjs/server/adapters/nextjs/filter-fallback-error.js +41 -0
  193. package/dist/cjs/server/adapters/nextjs/index.d.ts +8 -0
  194. package/dist/cjs/server/adapters/nextjs/index.js +22 -0
  195. package/dist/cjs/server/adapters/nextjs/prepare-model-messages.d.ts +58 -0
  196. package/dist/cjs/server/adapters/nextjs/prepare-model-messages.js +114 -0
  197. package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.d.ts +64 -0
  198. package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.js +489 -0
  199. package/dist/cjs/server/adapters/nextjs/server-action-helper.d.ts +7 -0
  200. package/dist/cjs/server/adapters/nextjs/server-action-helper.js +40 -0
  201. package/dist/cjs/server/adapters/nextjs/types.d.ts +246 -0
  202. package/dist/cjs/server/adapters/nextjs/types.js +2 -0
  203. package/dist/cjs/server/adapters/nextjs/with-ai-tool.d.ts +9 -0
  204. package/dist/cjs/server/adapters/nextjs/with-ai-tool.js +12 -0
  205. package/dist/cjs/server/core/followup-tool.d.ts +9 -0
  206. package/dist/cjs/server/core/followup-tool.js +82 -0
  207. package/dist/cjs/server/core/index.d.ts +139 -0
  208. package/dist/cjs/server/core/index.js +818 -0
  209. package/dist/cjs/server/core/intent-classifier.d.ts +94 -0
  210. package/dist/cjs/server/core/intent-classifier.js +324 -0
  211. package/dist/cjs/server/core/model-selector.d.ts +12 -0
  212. package/dist/cjs/server/core/model-selector.js +48 -0
  213. package/dist/cjs/server/core/module-router.d.ts +14 -0
  214. package/dist/cjs/server/core/module-router.js +110 -0
  215. package/dist/cjs/server/core/zod-compact.d.ts +18 -0
  216. package/dist/cjs/server/core/zod-compact.js +129 -0
  217. package/dist/cjs/server/index.d.ts +6 -0
  218. package/dist/cjs/server/index.js +28 -0
  219. package/dist/cjs/server/lancer/cache.d.ts +9 -0
  220. package/dist/cjs/server/lancer/cache.js +33 -0
  221. package/dist/cjs/server/lancer/client.d.ts +2 -0
  222. package/dist/cjs/server/lancer/client.js +279 -0
  223. package/dist/cjs/server/lancer/errors.d.ts +13 -0
  224. package/dist/cjs/server/lancer/errors.js +21 -0
  225. package/dist/cjs/server/lancer/index.d.ts +3 -0
  226. package/dist/cjs/server/lancer/index.js +7 -0
  227. package/dist/cjs/server/lancer/telemetry-buffer.d.ts +15 -0
  228. package/dist/cjs/server/lancer/telemetry-buffer.js +64 -0
  229. package/dist/cjs/server/lancer/types.d.ts +201 -0
  230. package/dist/cjs/server/lancer/types.js +5 -0
  231. package/dist/cjs/server/pii-shield/aegis-detector.d.ts +26 -0
  232. package/dist/cjs/server/pii-shield/aegis-detector.js +26 -0
  233. package/dist/cjs/server/pii-shield/create-pii-shield.d.ts +2 -0
  234. package/dist/cjs/server/pii-shield/create-pii-shield.js +191 -0
  235. package/dist/cjs/server/pii-shield/deep-walk.d.ts +1 -0
  236. package/dist/cjs/server/pii-shield/deep-walk.js +19 -0
  237. package/dist/cjs/server/pii-shield/fake-data.d.ts +5 -0
  238. package/dist/cjs/server/pii-shield/fake-data.js +170 -0
  239. package/dist/cjs/server/pii-shield/index.d.ts +4 -0
  240. package/dist/cjs/server/pii-shield/index.js +9 -0
  241. package/dist/cjs/server/pii-shield/leakage.d.ts +1 -0
  242. package/dist/cjs/server/pii-shield/leakage.js +15 -0
  243. package/dist/cjs/server/pii-shield/session-mapping.d.ts +12 -0
  244. package/dist/cjs/server/pii-shield/session-mapping.js +70 -0
  245. package/dist/cjs/server/pipeline.d.ts +26 -0
  246. package/dist/cjs/server/pipeline.js +127 -0
  247. package/dist/cjs/server/testing/approvals.d.ts +11 -0
  248. package/dist/cjs/server/testing/approvals.js +41 -0
  249. package/dist/cjs/server/testing/combination.d.ts +3 -0
  250. package/dist/cjs/server/testing/combination.js +83 -0
  251. package/dist/cjs/server/testing/create-test-suite.d.ts +29 -0
  252. package/dist/cjs/server/testing/create-test-suite.js +81 -0
  253. package/dist/cjs/server/testing/edge-cases.d.ts +8 -0
  254. package/dist/cjs/server/testing/edge-cases.js +277 -0
  255. package/dist/cjs/server/testing/guardrails.d.ts +14 -0
  256. package/dist/cjs/server/testing/guardrails.js +152 -0
  257. package/dist/cjs/server/testing/helpers.d.ts +14 -0
  258. package/dist/cjs/server/testing/helpers.js +119 -0
  259. package/dist/cjs/server/testing/index.d.ts +12 -0
  260. package/dist/cjs/server/testing/index.js +37 -0
  261. package/dist/cjs/server/testing/mock-executor.d.ts +8 -0
  262. package/dist/cjs/server/testing/mock-executor.js +40 -0
  263. package/dist/cjs/server/testing/regression.d.ts +7 -0
  264. package/dist/cjs/server/testing/regression.js +27 -0
  265. package/dist/cjs/server/testing/routing.d.ts +12 -0
  266. package/dist/cjs/server/testing/routing.js +63 -0
  267. package/dist/cjs/server/testing/schema-consistency.d.ts +6 -0
  268. package/dist/cjs/server/testing/schema-consistency.js +56 -0
  269. package/dist/cjs/server/testing/smoke.d.ts +11 -0
  270. package/dist/cjs/server/testing/smoke.js +64 -0
  271. package/dist/cjs/server/testing/types.d.ts +156 -0
  272. package/dist/cjs/server/testing/types.js +2 -0
  273. package/dist/cjs/types.d.ts +696 -0
  274. package/dist/cjs/types.js +91 -0
  275. package/dist/cli/commands/install-skills.d.ts +17 -0
  276. package/dist/cli/commands/install-skills.js +185 -0
  277. package/dist/cli/commands/install-skills.js.map +1 -0
  278. package/dist/cli/index.js +25 -0
  279. package/dist/cli/index.js.map +1 -1
  280. package/dist/react/components/ai-trigger-button.js +4 -6
  281. package/dist/react/components/ai-trigger-button.js.map +1 -1
  282. package/dist/react/components/recording-bar.js +4 -6
  283. package/dist/react/components/recording-bar.js.map +1 -1
  284. package/dist/react/components/wavesurfer-loader.d.ts +5 -0
  285. package/dist/react/components/wavesurfer-loader.js +34 -0
  286. package/dist/react/components/wavesurfer-loader.js.map +1 -0
  287. package/dist/server/adapters/nestjs/chat/ai-chat.module.d.ts +1 -1
  288. package/dist/server/adapters/nestjs/chat/ai-chat.module.js +3 -2
  289. package/dist/server/adapters/nestjs/chat/ai-chat.module.js.map +1 -1
  290. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +1 -1
  291. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js +10 -8
  292. package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js.map +1 -1
  293. package/dist/server/adapters/nestjs/chat/ws-loader.d.ts +5 -0
  294. package/dist/server/adapters/nestjs/chat/ws-loader.js +37 -0
  295. package/dist/server/adapters/nestjs/chat/ws-loader.js.map +1 -0
  296. package/openapi/package.json +5 -0
  297. package/package.json +59 -16
  298. package/react/langgraph/package.json +5 -0
  299. package/react/package.json +5 -0
  300. package/react/vercel/package.json +5 -0
  301. package/server/nestjs/package.json +5 -0
  302. package/server/nextjs/package.json +5 -0
  303. package/server/package.json +5 -0
  304. package/server/testing/package.json +5 -0
  305. package/skills/README.md +107 -0
  306. package/skills/building-glirastes-chat-ui/SKILL.md +378 -0
  307. package/skills/integrating-glirastes-nestjs/SKILL.md +346 -0
  308. package/skills/integrating-glirastes-nextjs/SKILL.md +312 -0
  309. package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +359 -0
  310. package/skills/maintaining-glirastes-tools/SKILL.md +467 -0
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Configuration for code generation.
3
+ */
4
+ export interface GenerateOptions {
5
+ /** Root directory of the project (where src/ lives) */
6
+ rootDir: string;
7
+ /** Directory pattern for API routes (e.g., 'src/app/api') */
8
+ apiDir?: string;
9
+ /** Directory pattern for components (e.g., 'src/components') */
10
+ componentsDir?: string;
11
+ /** Output directory for generated files (e.g., 'src/generated/ai-tools') */
12
+ outputDir?: string;
13
+ /** File name for endpoint tool definitions (default: 'ai-tool.ts') */
14
+ endpointToolFileName?: string;
15
+ /** File name for UI tool definitions (default: 'ai-ui-tool.ts') */
16
+ uiToolFileName?: string;
17
+ /** Directories to scan for NestJS controllers with @AiTool decorators */
18
+ nestjsDirs?: string[];
19
+ /** API prefix for NestJS routes (default: '/api') */
20
+ nestjsApiPrefix?: string;
21
+ /** Quiet mode — suppress informational output */
22
+ quiet?: boolean;
23
+ }
24
+ export interface ScanResult {
25
+ /** Discovered files with their relative paths */
26
+ files: DiscoveredFile[];
27
+ /** Total number of tools found */
28
+ toolCount: number;
29
+ }
30
+ export interface DiscoveredFile {
31
+ /** Absolute path to the file */
32
+ absolutePath: string;
33
+ /** Path relative to rootDir */
34
+ relativePath: string;
35
+ /** Import path (e.g., '@/app/api/tasks/ai-tool') */
36
+ importPath: string;
37
+ /** Whether the file exports an array (aiTools) or single (aiTool) */
38
+ exportType: 'array' | 'single';
39
+ }
40
+ export interface ExtractedActionId {
41
+ actionId: string;
42
+ toolName: string;
43
+ payloadKeys: string[];
44
+ sourceFile: string;
45
+ }
46
+ export interface ExtractedToolMeta {
47
+ toolName: string;
48
+ module?: string;
49
+ sharedWith?: string[];
50
+ sourceFile: string;
51
+ }
52
+ export declare function resolveDefaults(options: GenerateOptions): Required<GenerateOptions>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveDefaults = resolveDefaults;
4
+ function resolveDefaults(options) {
5
+ return {
6
+ rootDir: options.rootDir,
7
+ apiDir: options.apiDir ?? 'src/app/api',
8
+ componentsDir: options.componentsDir ?? 'src/components',
9
+ outputDir: options.outputDir ?? 'src/generated/ai-tools',
10
+ endpointToolFileName: options.endpointToolFileName ?? 'ai-tool.ts',
11
+ uiToolFileName: options.uiToolFileName ?? 'ai-ui-tool.ts',
12
+ nestjsDirs: options.nestjsDirs ?? [],
13
+ nestjsApiPrefix: options.nestjsApiPrefix ?? '/api',
14
+ quiet: options.quiet ?? false,
15
+ };
16
+ }
@@ -0,0 +1,24 @@
1
+ import type { GenerateOptions, ScanResult, ExtractedActionId } from './types.js';
2
+ /**
3
+ * Scan for UI tool files (ai-ui-tool.ts) in the components directory.
4
+ */
5
+ export declare function scanUiTools(options: GenerateOptions): Promise<ScanResult>;
6
+ /**
7
+ * Extract actionIds from UI tool files using regex parsing.
8
+ */
9
+ export declare function extractActionIds(options: GenerateOptions): Promise<ExtractedActionId[]>;
10
+ /**
11
+ * Generate the UI tools registry file.
12
+ */
13
+ export declare function generateUiRegistry(options: GenerateOptions): Promise<{
14
+ outputPath: string;
15
+ toolCount: number;
16
+ }>;
17
+ /**
18
+ * Generate the action ID registry file.
19
+ * Merges duplicate actionIds from multiple tools and unions their payloadKeys.
20
+ */
21
+ export declare function generateActionIdRegistry(options: GenerateOptions): Promise<{
22
+ outputPath: string;
23
+ actionIdCount: number;
24
+ }>;
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scanUiTools = scanUiTools;
4
+ exports.extractActionIds = extractActionIds;
5
+ exports.generateUiRegistry = generateUiRegistry;
6
+ exports.generateActionIdRegistry = generateActionIdRegistry;
7
+ const promises_1 = require("node:fs/promises");
8
+ const node_path_1 = require("node:path");
9
+ const fs_utils_js_1 = require("./fs-utils.js");
10
+ const types_js_1 = require("./types.js");
11
+ /**
12
+ * Scan for UI tool files (ai-ui-tool.ts) in the components directory.
13
+ */
14
+ async function scanUiTools(options) {
15
+ const opts = (0, types_js_1.resolveDefaults)(options);
16
+ const componentsDir = (0, node_path_1.join)(opts.rootDir, opts.componentsDir);
17
+ const files = await (0, fs_utils_js_1.findFiles)(componentsDir, opts.uiToolFileName);
18
+ const discovered = [];
19
+ for (const absolutePath of files) {
20
+ const content = await (0, fs_utils_js_1.readFileSafe)(absolutePath);
21
+ if (content.includes('@ai-ignore'))
22
+ continue;
23
+ if (await (0, fs_utils_js_1.isDirAiIgnored)((0, node_path_1.dirname)(absolutePath)))
24
+ continue;
25
+ const hasExport = /export\s+const\s+aiUiTools\s*[=:]/m.test(content);
26
+ if (!hasExport)
27
+ continue;
28
+ // Use relative import when output dir is outside src/ (monorepo layout)
29
+ const outputDir = (0, node_path_1.join)(opts.rootDir, opts.outputDir);
30
+ const importPath = absolutePath.startsWith((0, node_path_1.join)(opts.rootDir, 'src'))
31
+ ? (0, fs_utils_js_1.toImportPath)(absolutePath, opts.rootDir)
32
+ : (0, fs_utils_js_1.toRelativeImportPath)(absolutePath, outputDir);
33
+ discovered.push({
34
+ absolutePath,
35
+ relativePath: absolutePath.replace(opts.rootDir + '/', ''),
36
+ importPath,
37
+ exportType: 'array',
38
+ });
39
+ }
40
+ let toolCount = 0;
41
+ for (const file of discovered) {
42
+ const content = await (0, fs_utils_js_1.readFileSafe)(file.absolutePath);
43
+ const matches = content.match(/define(?:Ai)?UiTool\(/g);
44
+ toolCount += matches?.length ?? 0;
45
+ }
46
+ return { files: discovered, toolCount };
47
+ }
48
+ /**
49
+ * Extract actionIds from UI tool files using regex parsing.
50
+ */
51
+ async function extractActionIds(options) {
52
+ const scan = await scanUiTools(options);
53
+ const actionIds = [];
54
+ for (const file of scan.files) {
55
+ const content = await (0, fs_utils_js_1.readFileSafe)(file.absolutePath);
56
+ // Match defineUiTool or defineAiUiTool blocks (brace-balanced)
57
+ const blocks = (0, fs_utils_js_1.extractBalancedBlocks)(content, /define(?:Ai)?UiTool\(\s*/);
58
+ for (const block of blocks) {
59
+ // Extract toolName
60
+ const toolNameMatch = block.match(/toolName\s*:\s*['"`]([^'"`]+)['"`]/);
61
+ if (!toolNameMatch)
62
+ continue;
63
+ const toolName = toolNameMatch[1];
64
+ // Extract all actionIds from uiAction templates (supports compound arrays)
65
+ const actionIdMatches = block.matchAll(/actionId\s*:\s*['"`]([^'"`]+)['"`]/g);
66
+ // Extract inputSchema keys as fallback payload keys (shared across all actions)
67
+ const fallbackPayloadKeys = [];
68
+ const schemaMatch = block.match(/inputSchema\s*:\s*z\.object\(\s*\{([^}]*)\}/);
69
+ if (schemaMatch) {
70
+ const schemaContent = schemaMatch[1];
71
+ const keyMatches = schemaContent.matchAll(/(\w+)\s*:/g);
72
+ for (const km of keyMatches) {
73
+ fallbackPayloadKeys.push(km[1]);
74
+ }
75
+ }
76
+ let hasActionId = false;
77
+ for (const actionIdMatch of actionIdMatches) {
78
+ hasActionId = true;
79
+ const actionId = actionIdMatch[1];
80
+ // Extract payload keys from the nearest payload block (best-effort)
81
+ const payloadKeys = [];
82
+ const payloadMatch = block.match(/payload\s*:\s*\{([^}]*)\}/);
83
+ if (payloadMatch) {
84
+ const payloadContent = payloadMatch[1];
85
+ const keyMatches = payloadContent.matchAll(/(\w+)\s*:/g);
86
+ for (const km of keyMatches) {
87
+ payloadKeys.push(km[1]);
88
+ }
89
+ }
90
+ actionIds.push({
91
+ actionId,
92
+ toolName,
93
+ payloadKeys: payloadKeys.length > 0 ? payloadKeys : fallbackPayloadKeys,
94
+ sourceFile: file.relativePath,
95
+ });
96
+ }
97
+ if (!hasActionId)
98
+ continue;
99
+ }
100
+ }
101
+ return actionIds;
102
+ }
103
+ /**
104
+ * Generate the UI tools registry file.
105
+ */
106
+ async function generateUiRegistry(options) {
107
+ const opts = (0, types_js_1.resolveDefaults)(options);
108
+ const scan = await scanUiTools(options);
109
+ const imports = [];
110
+ const spreadParts = [];
111
+ scan.files.forEach((file, index) => {
112
+ const alias = `uiTools${index}`;
113
+ imports.push(`import { aiUiTools as ${alias} } from '${file.importPath}';`);
114
+ spreadParts.push(`...${alias}`);
115
+ });
116
+ const code = `/* eslint-disable */
117
+ /**
118
+ * AUTO-GENERATED FILE — do not edit manually.
119
+ * Generated by glirastes
120
+ *
121
+ * Sources: ${scan.files.length} ai-ui-tool.ts files
122
+ * Tools: ${scan.toolCount}
123
+ */
124
+
125
+ ${imports.join('\n')}
126
+ import { uiToolsToRegistry } from 'glirastes/server';
127
+
128
+ const uiTools = [${spreadParts.join(', ')}] as const;
129
+
130
+ export { uiTools };
131
+ export const uiToolRegistry = uiToolsToRegistry(uiTools);
132
+ `;
133
+ const outputPath = (0, node_path_1.join)(opts.rootDir, opts.outputDir, 'ui.generated.ts');
134
+ await (0, promises_1.mkdir)((0, node_path_1.dirname)(outputPath), { recursive: true });
135
+ await (0, promises_1.writeFile)(outputPath, code, 'utf-8');
136
+ if (!opts.quiet) {
137
+ console.log(`✓ Generated ${outputPath} (${scan.toolCount} UI tools from ${scan.files.length} files)`);
138
+ }
139
+ return { outputPath, toolCount: scan.toolCount };
140
+ }
141
+ /**
142
+ * Generate the action ID registry file.
143
+ * Merges duplicate actionIds from multiple tools and unions their payloadKeys.
144
+ */
145
+ async function generateActionIdRegistry(options) {
146
+ const opts = (0, types_js_1.resolveDefaults)(options);
147
+ const actionIds = await extractActionIds(options);
148
+ // Merge by actionId
149
+ const merged = new Map();
150
+ for (const entry of actionIds) {
151
+ const existing = merged.get(entry.actionId);
152
+ if (existing) {
153
+ existing.tools.push({
154
+ toolName: entry.toolName,
155
+ sourceFile: entry.sourceFile,
156
+ });
157
+ for (const key of entry.payloadKeys) {
158
+ existing.payloadKeys.add(key);
159
+ }
160
+ }
161
+ else {
162
+ merged.set(entry.actionId, {
163
+ tools: [
164
+ { toolName: entry.toolName, sourceFile: entry.sourceFile },
165
+ ],
166
+ payloadKeys: new Set(entry.payloadKeys),
167
+ });
168
+ }
169
+ }
170
+ // Generate code
171
+ const entries = [];
172
+ for (const [actionId, data] of merged) {
173
+ const toolsStr = data.tools
174
+ .map((t) => `{ toolName: '${t.toolName}', sourceFile: '${t.sourceFile}' }`)
175
+ .join(', ');
176
+ const keysStr = Array.from(data.payloadKeys)
177
+ .map((k) => `'${k}'`)
178
+ .join(', ');
179
+ entries.push(` '${actionId}': {\n tools: [${toolsStr}],\n payloadKeys: [${keysStr}] as const,\n }`);
180
+ }
181
+ const code = `/* eslint-disable */
182
+ /**
183
+ * AUTO-GENERATED FILE — do not edit manually.
184
+ * Generated by glirastes
185
+ *
186
+ * Action IDs: ${merged.size}
187
+ */
188
+
189
+ export const REQUIRED_ACTION_IDS = {
190
+ ${entries.join(',\n')}
191
+ } as const;
192
+
193
+ export type ActionId = keyof typeof REQUIRED_ACTION_IDS;
194
+ `;
195
+ const outputPath = (0, node_path_1.join)(opts.rootDir, opts.outputDir, 'action-ids.generated.ts');
196
+ await (0, promises_1.mkdir)((0, node_path_1.dirname)(outputPath), { recursive: true });
197
+ await (0, promises_1.writeFile)(outputPath, code, 'utf-8');
198
+ if (!opts.quiet) {
199
+ console.log(`✓ Generated ${outputPath} (${merged.size} action IDs)`);
200
+ }
201
+ return { outputPath, actionIdCount: merged.size };
202
+ }
@@ -0,0 +1,35 @@
1
+ import type { GenerateOptions } from './types.js';
2
+ export type IssueSeverity = 'error' | 'warning' | 'info';
3
+ export interface ValidationIssue {
4
+ severity: IssueSeverity;
5
+ file: string;
6
+ message: string;
7
+ suggestion?: string;
8
+ }
9
+ export interface ValidationResult {
10
+ issues: ValidationIssue[];
11
+ errorCount: number;
12
+ warningCount: number;
13
+ infoCount: number;
14
+ passed: boolean;
15
+ }
16
+ /**
17
+ * Validate AI tool configuration across the project.
18
+ *
19
+ * Checks:
20
+ * 1. All API routes have an ai-tool.ts file (unless @ai-ignore)
21
+ * 2. All component directories with UI have ai-ui-tool.ts (unless @ai-ignore)
22
+ * 3. No orphaned ai-tool.ts files without corresponding route.ts
23
+ * 4. Tool files have required exports
24
+ * 5. Path consistency between file location and defined endpoint path
25
+ * 6. Module field is present in tool definitions
26
+ * 7. NestJS controllers have @AiTool decorators (unless @ai-ignore)
27
+ */
28
+ export declare function validateAiTools(options: GenerateOptions): Promise<ValidationResult>;
29
+ /**
30
+ * Format a validation result as a rich, color-coded human-readable string.
31
+ */
32
+ export declare function formatValidationReport(result: ValidationResult, options?: {
33
+ quiet?: boolean;
34
+ showFix?: boolean;
35
+ }): string;
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.validateAiTools = validateAiTools;
37
+ exports.formatValidationReport = formatValidationReport;
38
+ const node_path_1 = require("node:path");
39
+ const fs_utils_js_1 = require("./fs-utils.js");
40
+ const types_js_1 = require("./types.js");
41
+ const format_js_1 = require("./format.js");
42
+ /**
43
+ * Validate AI tool configuration across the project.
44
+ *
45
+ * Checks:
46
+ * 1. All API routes have an ai-tool.ts file (unless @ai-ignore)
47
+ * 2. All component directories with UI have ai-ui-tool.ts (unless @ai-ignore)
48
+ * 3. No orphaned ai-tool.ts files without corresponding route.ts
49
+ * 4. Tool files have required exports
50
+ * 5. Path consistency between file location and defined endpoint path
51
+ * 6. Module field is present in tool definitions
52
+ * 7. NestJS controllers have @AiTool decorators (unless @ai-ignore)
53
+ */
54
+ async function validateAiTools(options) {
55
+ const opts = (0, types_js_1.resolveDefaults)(options);
56
+ const issues = [];
57
+ // 1. Check routes have ai-tool.ts
58
+ const apiDir = (0, node_path_1.join)(opts.rootDir, opts.apiDir);
59
+ const routeFiles = await (0, fs_utils_js_1.findRouteFiles)(apiDir);
60
+ for (const routeFile of routeFiles) {
61
+ const routeContent = await (0, fs_utils_js_1.readFileSafe)(routeFile);
62
+ if (routeContent.includes('@ai-ignore'))
63
+ continue;
64
+ const routeDir = (0, node_path_1.dirname)(routeFile);
65
+ if (await (0, fs_utils_js_1.isDirAiIgnored)(routeDir))
66
+ continue;
67
+ const toolFile = (0, node_path_1.join)(routeDir, opts.endpointToolFileName);
68
+ const toolContent = await (0, fs_utils_js_1.readFileSafe)(toolFile);
69
+ const relFile = routeFile.replace(opts.rootDir + '/', '');
70
+ if (!toolContent && !routeContent.includes('withAiTool(')) {
71
+ issues.push({
72
+ severity: 'warning',
73
+ file: relFile,
74
+ message: `Route without ${opts.endpointToolFileName}`,
75
+ suggestion: `glirastes scaffold --route "${relFile}"`,
76
+ });
77
+ }
78
+ }
79
+ // 2. Check ai-tool.ts files have corresponding route.ts
80
+ const toolFiles = await (0, fs_utils_js_1.findFiles)(apiDir, opts.endpointToolFileName);
81
+ for (const toolFile of toolFiles) {
82
+ const toolDir = (0, node_path_1.dirname)(toolFile);
83
+ const routeFile = (0, node_path_1.join)(toolDir, 'route.ts');
84
+ const routeContent = await (0, fs_utils_js_1.readFileSafe)(routeFile);
85
+ const relFile = toolFile.replace(opts.rootDir + '/', '');
86
+ if (!routeContent) {
87
+ const routeRelFile = routeFile.replace(opts.rootDir + '/', '');
88
+ issues.push({
89
+ severity: 'error',
90
+ file: relFile,
91
+ message: `${opts.endpointToolFileName} has no corresponding route.ts`,
92
+ suggestion: `Create ${routeRelFile} or remove ${relFile}`,
93
+ });
94
+ }
95
+ }
96
+ // 3. Check tool files have required exports
97
+ for (const toolFile of toolFiles) {
98
+ const content = await (0, fs_utils_js_1.readFileSafe)(toolFile);
99
+ if (content.includes('@ai-ignore'))
100
+ continue;
101
+ const relFile = toolFile.replace(opts.rootDir + '/', '');
102
+ const hasArrayExport = /export\s+const\s+aiTools\s*[=:]/m.test(content);
103
+ const hasSingleExport = /export\s+const\s+aiTool\s*[=:]/m.test(content);
104
+ if (!hasArrayExport && !hasSingleExport) {
105
+ issues.push({
106
+ severity: 'error',
107
+ file: relFile,
108
+ message: `Missing export: expected 'export const aiTools' or 'export const aiTool'`,
109
+ suggestion: `Add 'export const aiTool = defineEndpointTool({...})'`,
110
+ });
111
+ }
112
+ // Check for description
113
+ if (!content.includes('description')) {
114
+ issues.push({
115
+ severity: 'warning',
116
+ file: relFile,
117
+ message: 'Tool definition is missing a description',
118
+ suggestion: `Add description with usage hints for the AI`,
119
+ });
120
+ }
121
+ }
122
+ // 4. Check path consistency and module field
123
+ for (const toolFile of toolFiles) {
124
+ const content = await (0, fs_utils_js_1.readFileSafe)(toolFile);
125
+ if (content.includes('@ai-ignore'))
126
+ continue;
127
+ const relPath = toolFile.replace(opts.rootDir + '/', '');
128
+ // Extract path values from tool definitions
129
+ const pathMatches = content.matchAll(/path\s*:\s*['"`]([^'"`]+)['"`]/g);
130
+ for (const match of pathMatches) {
131
+ const definedPath = match[1];
132
+ // Derive expected path from file location: src/app/api/tasks/[id]/subtasks/ai-tool.ts → /api/tasks/:id/subtasks
133
+ const expectedPath = '/' + (0, node_path_1.dirname)(relPath)
134
+ .replace(/^src\/app\//, '')
135
+ .replace(/\[([^\]]+)\]/g, ':$1'); // convert [param] to :param
136
+ // Check that the defined path starts with the expected base
137
+ if (!definedPath.startsWith(expectedPath.replace(/\/+$/, ''))) {
138
+ issues.push({
139
+ severity: 'warning',
140
+ file: relPath,
141
+ message: `Path '${definedPath}' doesn't match file location '${expectedPath}'`,
142
+ suggestion: `Update path to '${expectedPath}'`,
143
+ });
144
+ }
145
+ }
146
+ // Check for module field presence (brace-balanced)
147
+ const toolBlocksArr = (0, fs_utils_js_1.extractBalancedBlocks)(content, /define(?:Ai)?EndpointTool\(\s*/);
148
+ for (const block of toolBlocksArr) {
149
+ const hasModule = /module\s*:/.test(block);
150
+ if (!hasModule) {
151
+ const toolNameMatch = block.match(/toolName\s*:\s*['"`]([^'"`]+)['"`]/);
152
+ const toolName = toolNameMatch?.[1] ?? 'unknown';
153
+ issues.push({
154
+ severity: 'info',
155
+ file: relPath,
156
+ message: `Tool '${toolName}' has no module field`,
157
+ suggestion: `Add module: 'task_query' | 'task_mutation' | 'navigation' | ...`,
158
+ });
159
+ }
160
+ }
161
+ }
162
+ // 5. Check UI tool files have required exports
163
+ const componentsDir = (0, node_path_1.join)(opts.rootDir, opts.componentsDir);
164
+ const uiToolFiles = await (0, fs_utils_js_1.findFiles)(componentsDir, opts.uiToolFileName);
165
+ for (const uiToolFile of uiToolFiles) {
166
+ const content = await (0, fs_utils_js_1.readFileSafe)(uiToolFile);
167
+ if (content.includes('@ai-ignore'))
168
+ continue;
169
+ const relFile = uiToolFile.replace(opts.rootDir + '/', '');
170
+ const hasExport = /export\s+const\s+aiUiTools\s*[=:]/m.test(content);
171
+ if (!hasExport) {
172
+ issues.push({
173
+ severity: 'error',
174
+ file: relFile,
175
+ message: `Missing export: expected 'export const aiUiTools'`,
176
+ suggestion: `Add 'export const aiUiTools = [defineUiTool({...})]'`,
177
+ });
178
+ }
179
+ // Check module field in UI tool definitions (brace-balanced)
180
+ const uiToolBlocksArr = (0, fs_utils_js_1.extractBalancedBlocks)(content, /define(?:Ai)?UiTool\(\s*/);
181
+ for (const block of uiToolBlocksArr) {
182
+ const hasModule = /module\s*:/.test(block);
183
+ if (!hasModule) {
184
+ const toolNameMatch = block.match(/toolName\s*:\s*['"`]([^'"`]+)['"`]/);
185
+ const toolName = toolNameMatch?.[1] ?? 'unknown';
186
+ issues.push({
187
+ severity: 'info',
188
+ file: relFile,
189
+ message: `UI tool '${toolName}' has no module field`,
190
+ suggestion: `Add module field for intent-based routing`,
191
+ });
192
+ }
193
+ }
194
+ }
195
+ // 6. Check NestJS controllers have @AiTool decorators
196
+ if (opts.nestjsDirs.length > 0) {
197
+ const { scanNestControllers } = await Promise.resolve().then(() => __importStar(require('./nestjs-scanner.js')));
198
+ const nestResult = await scanNestControllers(opts.nestjsDirs, opts.nestjsApiPrefix);
199
+ for (const ctrl of nestResult.uncoveredControllers) {
200
+ const relFile = ctrl.controllerFile.replace(opts.rootDir + '/', '');
201
+ issues.push({
202
+ severity: 'warning',
203
+ file: relFile,
204
+ message: `${ctrl.controllerName} has ${ctrl.httpMethodCount} HTTP endpoint(s) but no @AiTool decorators`,
205
+ suggestion: `Add @AiModule + @AiTool decorators, or add // @ai-ignore to exclude`,
206
+ });
207
+ }
208
+ }
209
+ // Tally results
210
+ const errorCount = issues.filter((i) => i.severity === 'error').length;
211
+ const warningCount = issues.filter((i) => i.severity === 'warning').length;
212
+ const infoCount = issues.filter((i) => i.severity === 'info').length;
213
+ return {
214
+ issues,
215
+ errorCount,
216
+ warningCount,
217
+ infoCount,
218
+ passed: errorCount === 0,
219
+ };
220
+ }
221
+ /**
222
+ * Format a validation result as a rich, color-coded human-readable string.
223
+ */
224
+ function formatValidationReport(result, options) {
225
+ if (options?.quiet && result.issues.length === 0) {
226
+ return `${format_js_1.colors.green}\u2713${format_js_1.colors.reset} AI tools validation passed`;
227
+ }
228
+ const lines = [];
229
+ // Header
230
+ lines.push((0, format_js_1.header)('AI Tools Validation'));
231
+ // No issues
232
+ if (result.issues.length === 0) {
233
+ lines.push(`${format_js_1.colors.green}\u2705 All AI tools are properly configured!${format_js_1.colors.reset}`);
234
+ lines.push('');
235
+ return lines.join('\n');
236
+ }
237
+ const errors = result.issues.filter((i) => i.severity === 'error');
238
+ const warnings = result.issues.filter((i) => i.severity === 'warning');
239
+ const infos = result.issues.filter((i) => i.severity === 'info');
240
+ // Errors
241
+ if (errors.length > 0) {
242
+ lines.push(`${format_js_1.colors.red}${format_js_1.colors.bold}\u274C ${errors.length} Error(s):${format_js_1.colors.reset}\n`);
243
+ for (const issue of errors) {
244
+ lines.push(` ${format_js_1.colors.red}\u274C${format_js_1.colors.reset} ${format_js_1.colors.bold}${issue.file}${format_js_1.colors.reset}`);
245
+ lines.push(` ${issue.message}`);
246
+ if (issue.suggestion) {
247
+ lines.push(` ${format_js_1.colors.cyan}\u2192 ${issue.suggestion}${format_js_1.colors.reset}`);
248
+ }
249
+ lines.push('');
250
+ }
251
+ }
252
+ // Warnings
253
+ if (warnings.length > 0) {
254
+ lines.push(`${format_js_1.colors.yellow}${format_js_1.colors.bold}\u26A0\uFE0F ${warnings.length} Warning(s):${format_js_1.colors.reset}\n`);
255
+ for (const issue of warnings) {
256
+ lines.push(` ${format_js_1.colors.yellow}\u26A0\uFE0F${format_js_1.colors.reset} ${format_js_1.colors.bold}${issue.file}${format_js_1.colors.reset}`);
257
+ lines.push(` ${issue.message}`);
258
+ if (issue.suggestion) {
259
+ lines.push(` ${format_js_1.colors.cyan}\u2192 ${issue.suggestion}${format_js_1.colors.reset}`);
260
+ }
261
+ lines.push('');
262
+ }
263
+ }
264
+ // Info (only when not quiet)
265
+ if (infos.length > 0 && !options?.quiet) {
266
+ lines.push(`${format_js_1.colors.blue}${format_js_1.colors.bold}\u2139\uFE0F ${infos.length} Info(s):${format_js_1.colors.reset}\n`);
267
+ for (const issue of infos) {
268
+ lines.push(` ${format_js_1.colors.blue}\u2139\uFE0F${format_js_1.colors.reset} ${format_js_1.colors.bold}${issue.file}${format_js_1.colors.reset}`);
269
+ lines.push(` ${issue.message}`);
270
+ if (issue.suggestion) {
271
+ lines.push(` ${format_js_1.colors.cyan}\u2192 ${issue.suggestion}${format_js_1.colors.reset}`);
272
+ }
273
+ lines.push('');
274
+ }
275
+ }
276
+ // Quick fix section
277
+ if (options?.showFix) {
278
+ const missingAiTools = result.issues.filter((i) => i.severity === 'warning' && i.suggestion?.startsWith('glirastes scaffold'));
279
+ if (missingAiTools.length > 0) {
280
+ lines.push(`${format_js_1.colors.cyan}${format_js_1.colors.bold}Quick Fix:${format_js_1.colors.reset}`);
281
+ lines.push(`${format_js_1.colors.dim}Run scaffold command for missing ai-tool.ts files:${format_js_1.colors.reset}\n`);
282
+ for (const issue of missingAiTools) {
283
+ lines.push(` ${format_js_1.colors.cyan}${issue.suggestion}${format_js_1.colors.reset}`);
284
+ }
285
+ lines.push('');
286
+ }
287
+ }
288
+ // Summary line
289
+ lines.push(`${format_js_1.colors.dim}Summary: ${result.errorCount} errors, ${result.warningCount} warnings, ${result.infoCount} infos${format_js_1.colors.reset}`);
290
+ lines.push('');
291
+ return lines.join('\n');
292
+ }
@@ -0,0 +1 @@
1
+ export * from './types.js';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // glirastes — main entry point
18
+ //
19
+ // Re-exports all shared types, interfaces, and helpers that live in `types.ts`
20
+ // so consumers can do `import { ModuleMeta, defineUiTool } from 'glirastes'`.
21
+ // Subpath exports (`glirastes/server`, `glirastes/react`, etc.) remain the
22
+ // primary API surface for runtime functionality.
23
+ __exportStar(require("./types.js"), exports);