@syrin/cli 1.3.0

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 (438) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +302 -0
  3. package/dist/cli/commands/analyse.d.ts +16 -0
  4. package/dist/cli/commands/analyse.js +61 -0
  5. package/dist/cli/commands/dev.d.ts +23 -0
  6. package/dist/cli/commands/dev.js +419 -0
  7. package/dist/cli/commands/doctor.d.ts +10 -0
  8. package/dist/cli/commands/doctor.js +195 -0
  9. package/dist/cli/commands/index.d.ts +12 -0
  10. package/dist/cli/commands/index.js +12 -0
  11. package/dist/cli/commands/init.d.ts +16 -0
  12. package/dist/cli/commands/init.js +90 -0
  13. package/dist/cli/commands/list.d.ts +15 -0
  14. package/dist/cli/commands/list.js +50 -0
  15. package/dist/cli/commands/rollback.d.ts +12 -0
  16. package/dist/cli/commands/rollback.js +101 -0
  17. package/dist/cli/commands/test.d.ts +31 -0
  18. package/dist/cli/commands/test.js +88 -0
  19. package/dist/cli/commands/update.d.ts +9 -0
  20. package/dist/cli/commands/update.js +76 -0
  21. package/dist/cli/index.d.ts +13 -0
  22. package/dist/cli/index.js +342 -0
  23. package/dist/cli/prompts/index.d.ts +5 -0
  24. package/dist/cli/prompts/index.js +5 -0
  25. package/dist/cli/prompts/init-prompt.d.ts +17 -0
  26. package/dist/cli/prompts/init-prompt.js +263 -0
  27. package/dist/cli/utils/command-error-handler.d.ts +14 -0
  28. package/dist/cli/utils/command-error-handler.js +35 -0
  29. package/dist/cli/utils/common-types.d.ts +24 -0
  30. package/dist/cli/utils/common-types.js +6 -0
  31. package/dist/cli/utils/connection-handler.d.ts +37 -0
  32. package/dist/cli/utils/connection-handler.js +90 -0
  33. package/dist/cli/utils/index.d.ts +11 -0
  34. package/dist/cli/utils/index.js +11 -0
  35. package/dist/cli/utils/option-parsers.d.ts +41 -0
  36. package/dist/cli/utils/option-parsers.js +92 -0
  37. package/dist/cli/utils/output-utils.d.ts +12 -0
  38. package/dist/cli/utils/output-utils.js +21 -0
  39. package/dist/cli/utils/transport-resolver.d.ts +33 -0
  40. package/dist/cli/utils/transport-resolver.js +82 -0
  41. package/dist/cli/utils/version-banner.d.ts +10 -0
  42. package/dist/cli/utils/version-banner.js +26 -0
  43. package/dist/config/env-checker.d.ts +37 -0
  44. package/dist/config/env-checker.js +136 -0
  45. package/dist/config/generator.d.ts +19 -0
  46. package/dist/config/generator.js +196 -0
  47. package/dist/config/index.d.ts +9 -0
  48. package/dist/config/index.js +9 -0
  49. package/dist/config/loader.d.ts +19 -0
  50. package/dist/config/loader.js +57 -0
  51. package/dist/config/schema.d.ts +42 -0
  52. package/dist/config/schema.js +181 -0
  53. package/dist/config/syrin.template.yaml +127 -0
  54. package/dist/config/types.d.ts +87 -0
  55. package/dist/config/types.js +6 -0
  56. package/dist/constants/app.d.ts +9 -0
  57. package/dist/constants/app.js +9 -0
  58. package/dist/constants/commands.d.ts +43 -0
  59. package/dist/constants/commands.js +43 -0
  60. package/dist/constants/defaults.d.ts +18 -0
  61. package/dist/constants/defaults.js +18 -0
  62. package/dist/constants/env-vars.d.ts +11 -0
  63. package/dist/constants/env-vars.js +11 -0
  64. package/dist/constants/icons.d.ts +23 -0
  65. package/dist/constants/icons.js +23 -0
  66. package/dist/constants/index.d.ts +17 -0
  67. package/dist/constants/index.js +17 -0
  68. package/dist/constants/labels.d.ts +38 -0
  69. package/dist/constants/labels.js +42 -0
  70. package/dist/constants/links.d.ts +10 -0
  71. package/dist/constants/links.js +11 -0
  72. package/dist/constants/list.d.ts +10 -0
  73. package/dist/constants/list.js +9 -0
  74. package/dist/constants/llm.d.ts +26 -0
  75. package/dist/constants/llm.js +25 -0
  76. package/dist/constants/messages.d.ts +107 -0
  77. package/dist/constants/messages.js +138 -0
  78. package/dist/constants/paths.d.ts +29 -0
  79. package/dist/constants/paths.js +29 -0
  80. package/dist/constants/transport.d.ts +9 -0
  81. package/dist/constants/transport.js +8 -0
  82. package/dist/events/emitter.d.ts +64 -0
  83. package/dist/events/emitter.js +142 -0
  84. package/dist/events/event-type.d.ts +66 -0
  85. package/dist/events/event-type.js +81 -0
  86. package/dist/events/payloads/diagnostics.d.ts +24 -0
  87. package/dist/events/payloads/diagnostics.js +5 -0
  88. package/dist/events/payloads/index.d.ts +15 -0
  89. package/dist/events/payloads/index.js +6 -0
  90. package/dist/events/payloads/llm.d.ts +58 -0
  91. package/dist/events/payloads/llm.js +6 -0
  92. package/dist/events/payloads/registry.d.ts +28 -0
  93. package/dist/events/payloads/registry.js +5 -0
  94. package/dist/events/payloads/session.d.ts +32 -0
  95. package/dist/events/payloads/session.js +5 -0
  96. package/dist/events/payloads/testing.d.ts +17 -0
  97. package/dist/events/payloads/testing.js +5 -0
  98. package/dist/events/payloads/tool.d.ts +29 -0
  99. package/dist/events/payloads/tool.js +5 -0
  100. package/dist/events/payloads/transport.d.ts +30 -0
  101. package/dist/events/payloads/transport.js +5 -0
  102. package/dist/events/payloads/validation.d.ts +37 -0
  103. package/dist/events/payloads/validation.js +5 -0
  104. package/dist/events/payloads/workflow.d.ts +45 -0
  105. package/dist/events/payloads/workflow.js +5 -0
  106. package/dist/events/store/file-store.d.ts +37 -0
  107. package/dist/events/store/file-store.js +113 -0
  108. package/dist/events/store/index.d.ts +7 -0
  109. package/dist/events/store/index.js +6 -0
  110. package/dist/events/store/memory-store.d.ts +26 -0
  111. package/dist/events/store/memory-store.js +39 -0
  112. package/dist/events/store.d.ts +11 -0
  113. package/dist/events/store.js +2 -0
  114. package/dist/events/types.d.ts +14 -0
  115. package/dist/events/types.js +2 -0
  116. package/dist/index.d.ts +8 -0
  117. package/dist/index.js +30 -0
  118. package/dist/presentation/analysis-ui.d.ts +24 -0
  119. package/dist/presentation/analysis-ui.js +158 -0
  120. package/dist/presentation/dev/chat-ui-types.d.ts +68 -0
  121. package/dist/presentation/dev/chat-ui-types.js +5 -0
  122. package/dist/presentation/dev/chat-ui.d.ts +61 -0
  123. package/dist/presentation/dev/chat-ui.js +714 -0
  124. package/dist/presentation/dev/components/assistant-message.d.ts +19 -0
  125. package/dist/presentation/dev/components/assistant-message.js +36 -0
  126. package/dist/presentation/dev/components/header.d.ts +16 -0
  127. package/dist/presentation/dev/components/header.js +22 -0
  128. package/dist/presentation/dev/components/index.d.ts +13 -0
  129. package/dist/presentation/dev/components/index.js +13 -0
  130. package/dist/presentation/dev/components/input-panel.d.ts +22 -0
  131. package/dist/presentation/dev/components/input-panel.js +43 -0
  132. package/dist/presentation/dev/components/message-component.d.ts +16 -0
  133. package/dist/presentation/dev/components/message-component.js +51 -0
  134. package/dist/presentation/dev/components/messages-list.d.ts +24 -0
  135. package/dist/presentation/dev/components/messages-list.js +48 -0
  136. package/dist/presentation/dev/components/system-message.d.ts +16 -0
  137. package/dist/presentation/dev/components/system-message.js +26 -0
  138. package/dist/presentation/dev/components/user-message.d.ts +21 -0
  139. package/dist/presentation/dev/components/user-message.js +35 -0
  140. package/dist/presentation/dev/components/welcome-banner.d.ts +24 -0
  141. package/dist/presentation/dev/components/welcome-banner.js +146 -0
  142. package/dist/presentation/dev/goodbye-messages.d.ts +31 -0
  143. package/dist/presentation/dev/goodbye-messages.js +100 -0
  144. package/dist/presentation/dev/index.d.ts +5 -0
  145. package/dist/presentation/dev/index.js +5 -0
  146. package/dist/presentation/dev/text-wrapper.d.ts +30 -0
  147. package/dist/presentation/dev/text-wrapper.js +74 -0
  148. package/dist/presentation/dev-ui.d.ts +33 -0
  149. package/dist/presentation/dev-ui.js +246 -0
  150. package/dist/presentation/doctor-ui.d.ts +40 -0
  151. package/dist/presentation/doctor-ui.js +157 -0
  152. package/dist/presentation/init-ui.d.ts +14 -0
  153. package/dist/presentation/init-ui.js +41 -0
  154. package/dist/presentation/list-ui.d.ts +44 -0
  155. package/dist/presentation/list-ui.js +139 -0
  156. package/dist/presentation/test-ui.d.ts +49 -0
  157. package/dist/presentation/test-ui.js +358 -0
  158. package/dist/runtime/analysis/analyser.d.ts +14 -0
  159. package/dist/runtime/analysis/analyser.js +88 -0
  160. package/dist/runtime/analysis/dependencies.d.ts +10 -0
  161. package/dist/runtime/analysis/dependencies.js +140 -0
  162. package/dist/runtime/analysis/index.d.ts +10 -0
  163. package/dist/runtime/analysis/index.js +10 -0
  164. package/dist/runtime/analysis/indexer.d.ts +10 -0
  165. package/dist/runtime/analysis/indexer.js +62 -0
  166. package/dist/runtime/analysis/loader.d.ts +15 -0
  167. package/dist/runtime/analysis/loader.js +47 -0
  168. package/dist/runtime/analysis/normalizer.d.ts +14 -0
  169. package/dist/runtime/analysis/normalizer.js +184 -0
  170. package/dist/runtime/analysis/rules/__test-helpers__.d.ts +18 -0
  171. package/dist/runtime/analysis/rules/__test-helpers__.js +40 -0
  172. package/dist/runtime/analysis/rules/base.d.ts +38 -0
  173. package/dist/runtime/analysis/rules/base.js +23 -0
  174. package/dist/runtime/analysis/rules/error-codes.d.ts +64 -0
  175. package/dist/runtime/analysis/rules/error-codes.js +73 -0
  176. package/dist/runtime/analysis/rules/errors/e000-tool-not-found.d.ts +35 -0
  177. package/dist/runtime/analysis/rules/errors/e000-tool-not-found.js +32 -0
  178. package/dist/runtime/analysis/rules/errors/e001-missing-output-schema.d.ts +22 -0
  179. package/dist/runtime/analysis/rules/errors/e001-missing-output-schema.js +30 -0
  180. package/dist/runtime/analysis/rules/errors/e002-underspecified-input.d.ts +24 -0
  181. package/dist/runtime/analysis/rules/errors/e002-underspecified-input.js +52 -0
  182. package/dist/runtime/analysis/rules/errors/e003-type-mismatch.d.ts +23 -0
  183. package/dist/runtime/analysis/rules/errors/e003-type-mismatch.js +73 -0
  184. package/dist/runtime/analysis/rules/errors/e004-free-text-propagation.d.ts +23 -0
  185. package/dist/runtime/analysis/rules/errors/e004-free-text-propagation.js +47 -0
  186. package/dist/runtime/analysis/rules/errors/e005-tool-ambiguity.d.ts +25 -0
  187. package/dist/runtime/analysis/rules/errors/e005-tool-ambiguity.js +73 -0
  188. package/dist/runtime/analysis/rules/errors/e006-param-not-in-description.d.ts +22 -0
  189. package/dist/runtime/analysis/rules/errors/e006-param-not-in-description.js +57 -0
  190. package/dist/runtime/analysis/rules/errors/e007-output-not-guaranteed.d.ts +23 -0
  191. package/dist/runtime/analysis/rules/errors/e007-output-not-guaranteed.js +56 -0
  192. package/dist/runtime/analysis/rules/errors/e008-circular-dependency.d.ts +22 -0
  193. package/dist/runtime/analysis/rules/errors/e008-circular-dependency.js +84 -0
  194. package/dist/runtime/analysis/rules/errors/e009-implicit-user-input.d.ts +23 -0
  195. package/dist/runtime/analysis/rules/errors/e009-implicit-user-input.js +89 -0
  196. package/dist/runtime/analysis/rules/errors/e010-non-serializable.d.ts +25 -0
  197. package/dist/runtime/analysis/rules/errors/e010-non-serializable.js +46 -0
  198. package/dist/runtime/analysis/rules/errors/e011-missing-tool-description.d.ts +24 -0
  199. package/dist/runtime/analysis/rules/errors/e011-missing-tool-description.js +33 -0
  200. package/dist/runtime/analysis/rules/errors/e012-side-effect-detected.d.ts +39 -0
  201. package/dist/runtime/analysis/rules/errors/e012-side-effect-detected.js +40 -0
  202. package/dist/runtime/analysis/rules/errors/e013-non-deterministic-output.d.ts +37 -0
  203. package/dist/runtime/analysis/rules/errors/e013-non-deterministic-output.js +34 -0
  204. package/dist/runtime/analysis/rules/errors/e013-output-explosion.d.ts +39 -0
  205. package/dist/runtime/analysis/rules/errors/e013-output-explosion.js +36 -0
  206. package/dist/runtime/analysis/rules/errors/e014-hidden-dependency.d.ts +42 -0
  207. package/dist/runtime/analysis/rules/errors/e014-hidden-dependency.js +46 -0
  208. package/dist/runtime/analysis/rules/errors/e014-output-explosion.d.ts +39 -0
  209. package/dist/runtime/analysis/rules/errors/e014-output-explosion.js +36 -0
  210. package/dist/runtime/analysis/rules/errors/e015-hidden-dependency.d.ts +42 -0
  211. package/dist/runtime/analysis/rules/errors/e015-hidden-dependency.js +46 -0
  212. package/dist/runtime/analysis/rules/errors/e015-unbounded-execution.d.ts +44 -0
  213. package/dist/runtime/analysis/rules/errors/e015-unbounded-execution.js +66 -0
  214. package/dist/runtime/analysis/rules/errors/e016-output-validation-failed.d.ts +43 -0
  215. package/dist/runtime/analysis/rules/errors/e016-output-validation-failed.js +42 -0
  216. package/dist/runtime/analysis/rules/errors/e016-unbounded-execution.d.ts +44 -0
  217. package/dist/runtime/analysis/rules/errors/e016-unbounded-execution.js +66 -0
  218. package/dist/runtime/analysis/rules/errors/e017-input-validation-failed.d.ts +57 -0
  219. package/dist/runtime/analysis/rules/errors/e017-input-validation-failed.js +80 -0
  220. package/dist/runtime/analysis/rules/errors/e017-output-validation-failed.d.ts +43 -0
  221. package/dist/runtime/analysis/rules/errors/e017-output-validation-failed.js +42 -0
  222. package/dist/runtime/analysis/rules/errors/e018-input-validation-failed.d.ts +57 -0
  223. package/dist/runtime/analysis/rules/errors/e018-input-validation-failed.js +80 -0
  224. package/dist/runtime/analysis/rules/errors/e018-tool-execution-failed.d.ts +38 -0
  225. package/dist/runtime/analysis/rules/errors/e018-tool-execution-failed.js +37 -0
  226. package/dist/runtime/analysis/rules/errors/e019-tool-execution-failed.d.ts +38 -0
  227. package/dist/runtime/analysis/rules/errors/e019-tool-execution-failed.js +37 -0
  228. package/dist/runtime/analysis/rules/errors/e019-unexpected-test-result.d.ts +65 -0
  229. package/dist/runtime/analysis/rules/errors/e019-unexpected-test-result.js +109 -0
  230. package/dist/runtime/analysis/rules/errors/e020-unexpected-test-result.d.ts +65 -0
  231. package/dist/runtime/analysis/rules/errors/e020-unexpected-test-result.js +109 -0
  232. package/dist/runtime/analysis/rules/errors/e100-missing-output-schema.d.ts +22 -0
  233. package/dist/runtime/analysis/rules/errors/e100-missing-output-schema.js +30 -0
  234. package/dist/runtime/analysis/rules/errors/e101-missing-tool-description.d.ts +24 -0
  235. package/dist/runtime/analysis/rules/errors/e101-missing-tool-description.js +33 -0
  236. package/dist/runtime/analysis/rules/errors/e102-underspecified-input.d.ts +24 -0
  237. package/dist/runtime/analysis/rules/errors/e102-underspecified-input.js +52 -0
  238. package/dist/runtime/analysis/rules/errors/e103-type-mismatch.d.ts +23 -0
  239. package/dist/runtime/analysis/rules/errors/e103-type-mismatch.js +72 -0
  240. package/dist/runtime/analysis/rules/errors/e104-param-not-in-description.d.ts +22 -0
  241. package/dist/runtime/analysis/rules/errors/e104-param-not-in-description.js +57 -0
  242. package/dist/runtime/analysis/rules/errors/e105-free-text-propagation.d.ts +23 -0
  243. package/dist/runtime/analysis/rules/errors/e105-free-text-propagation.js +47 -0
  244. package/dist/runtime/analysis/rules/errors/e106-output-not-guaranteed.d.ts +23 -0
  245. package/dist/runtime/analysis/rules/errors/e106-output-not-guaranteed.js +58 -0
  246. package/dist/runtime/analysis/rules/errors/e107-circular-dependency.d.ts +22 -0
  247. package/dist/runtime/analysis/rules/errors/e107-circular-dependency.js +84 -0
  248. package/dist/runtime/analysis/rules/errors/e108-implicit-user-input.d.ts +23 -0
  249. package/dist/runtime/analysis/rules/errors/e108-implicit-user-input.js +94 -0
  250. package/dist/runtime/analysis/rules/errors/e109-non-serializable.d.ts +25 -0
  251. package/dist/runtime/analysis/rules/errors/e109-non-serializable.js +44 -0
  252. package/dist/runtime/analysis/rules/errors/e110-tool-ambiguity.d.ts +25 -0
  253. package/dist/runtime/analysis/rules/errors/e110-tool-ambiguity.js +73 -0
  254. package/dist/runtime/analysis/rules/errors/e200-input-validation-failed.d.ts +57 -0
  255. package/dist/runtime/analysis/rules/errors/e200-input-validation-failed.js +71 -0
  256. package/dist/runtime/analysis/rules/errors/e300-output-validation-failed.d.ts +43 -0
  257. package/dist/runtime/analysis/rules/errors/e300-output-validation-failed.js +44 -0
  258. package/dist/runtime/analysis/rules/errors/e301-output-explosion.d.ts +39 -0
  259. package/dist/runtime/analysis/rules/errors/e301-output-explosion.js +36 -0
  260. package/dist/runtime/analysis/rules/errors/e400-tool-execution-failed.d.ts +38 -0
  261. package/dist/runtime/analysis/rules/errors/e400-tool-execution-failed.js +37 -0
  262. package/dist/runtime/analysis/rules/errors/e403-unbounded-execution.d.ts +44 -0
  263. package/dist/runtime/analysis/rules/errors/e403-unbounded-execution.js +66 -0
  264. package/dist/runtime/analysis/rules/errors/e500-side-effect-detected.d.ts +39 -0
  265. package/dist/runtime/analysis/rules/errors/e500-side-effect-detected.js +40 -0
  266. package/dist/runtime/analysis/rules/errors/e501-hidden-dependency.d.ts +47 -0
  267. package/dist/runtime/analysis/rules/errors/e501-hidden-dependency.js +46 -0
  268. package/dist/runtime/analysis/rules/errors/e600-unexpected-test-result.d.ts +65 -0
  269. package/dist/runtime/analysis/rules/errors/e600-unexpected-test-result.js +109 -0
  270. package/dist/runtime/analysis/rules/index.d.ts +18 -0
  271. package/dist/runtime/analysis/rules/index.js +94 -0
  272. package/dist/runtime/analysis/rules/warnings/w001-implicit-dependency.d.ts +22 -0
  273. package/dist/runtime/analysis/rules/warnings/w001-implicit-dependency.js +39 -0
  274. package/dist/runtime/analysis/rules/warnings/w002-free-text-without-normalization.d.ts +24 -0
  275. package/dist/runtime/analysis/rules/warnings/w002-free-text-without-normalization.js +40 -0
  276. package/dist/runtime/analysis/rules/warnings/w003-missing-examples.d.ts +22 -0
  277. package/dist/runtime/analysis/rules/warnings/w003-missing-examples.js +84 -0
  278. package/dist/runtime/analysis/rules/warnings/w004-overloaded-responsibility.d.ts +23 -0
  279. package/dist/runtime/analysis/rules/warnings/w004-overloaded-responsibility.js +96 -0
  280. package/dist/runtime/analysis/rules/warnings/w005-generic-description.d.ts +53 -0
  281. package/dist/runtime/analysis/rules/warnings/w005-generic-description.js +108 -0
  282. package/dist/runtime/analysis/rules/warnings/w006-optional-as-required.d.ts +22 -0
  283. package/dist/runtime/analysis/rules/warnings/w006-optional-as-required.js +44 -0
  284. package/dist/runtime/analysis/rules/warnings/w007-broad-output-schema.d.ts +23 -0
  285. package/dist/runtime/analysis/rules/warnings/w007-broad-output-schema.js +37 -0
  286. package/dist/runtime/analysis/rules/warnings/w008-multiple-entry-points.d.ts +22 -0
  287. package/dist/runtime/analysis/rules/warnings/w008-multiple-entry-points.js +97 -0
  288. package/dist/runtime/analysis/rules/warnings/w009-hidden-side-effects.d.ts +23 -0
  289. package/dist/runtime/analysis/rules/warnings/w009-hidden-side-effects.js +88 -0
  290. package/dist/runtime/analysis/rules/warnings/w010-output-not-reusable.d.ts +22 -0
  291. package/dist/runtime/analysis/rules/warnings/w010-output-not-reusable.js +81 -0
  292. package/dist/runtime/analysis/rules/warnings/w021-weak-schema.d.ts +40 -0
  293. package/dist/runtime/analysis/rules/warnings/w021-weak-schema.js +32 -0
  294. package/dist/runtime/analysis/rules/warnings/w022-high-entropy-output.d.ts +39 -0
  295. package/dist/runtime/analysis/rules/warnings/w022-high-entropy-output.js +36 -0
  296. package/dist/runtime/analysis/rules/warnings/w023-unstable-defaults.d.ts +38 -0
  297. package/dist/runtime/analysis/rules/warnings/w023-unstable-defaults.js +36 -0
  298. package/dist/runtime/analysis/rules/warnings/w100-implicit-dependency.d.ts +22 -0
  299. package/dist/runtime/analysis/rules/warnings/w100-implicit-dependency.js +89 -0
  300. package/dist/runtime/analysis/rules/warnings/w101-free-text-without-normalization.d.ts +24 -0
  301. package/dist/runtime/analysis/rules/warnings/w101-free-text-without-normalization.js +40 -0
  302. package/dist/runtime/analysis/rules/warnings/w102-missing-examples.d.ts +22 -0
  303. package/dist/runtime/analysis/rules/warnings/w102-missing-examples.js +76 -0
  304. package/dist/runtime/analysis/rules/warnings/w103-overloaded-responsibility.d.ts +23 -0
  305. package/dist/runtime/analysis/rules/warnings/w103-overloaded-responsibility.js +91 -0
  306. package/dist/runtime/analysis/rules/warnings/w104-generic-description.d.ts +53 -0
  307. package/dist/runtime/analysis/rules/warnings/w104-generic-description.js +108 -0
  308. package/dist/runtime/analysis/rules/warnings/w105-optional-as-required.d.ts +22 -0
  309. package/dist/runtime/analysis/rules/warnings/w105-optional-as-required.js +45 -0
  310. package/dist/runtime/analysis/rules/warnings/w106-broad-output-schema.d.ts +23 -0
  311. package/dist/runtime/analysis/rules/warnings/w106-broad-output-schema.js +37 -0
  312. package/dist/runtime/analysis/rules/warnings/w107-multiple-entry-points.d.ts +22 -0
  313. package/dist/runtime/analysis/rules/warnings/w107-multiple-entry-points.js +97 -0
  314. package/dist/runtime/analysis/rules/warnings/w108-hidden-side-effects.d.ts +23 -0
  315. package/dist/runtime/analysis/rules/warnings/w108-hidden-side-effects.js +94 -0
  316. package/dist/runtime/analysis/rules/warnings/w109-output-not-reusable.d.ts +22 -0
  317. package/dist/runtime/analysis/rules/warnings/w109-output-not-reusable.js +63 -0
  318. package/dist/runtime/analysis/rules/warnings/w110-weak-schema.d.ts +40 -0
  319. package/dist/runtime/analysis/rules/warnings/w110-weak-schema.js +32 -0
  320. package/dist/runtime/analysis/rules/warnings/w300-high-entropy-output.d.ts +39 -0
  321. package/dist/runtime/analysis/rules/warnings/w300-high-entropy-output.js +47 -0
  322. package/dist/runtime/analysis/rules/warnings/w301-unstable-defaults.d.ts +38 -0
  323. package/dist/runtime/analysis/rules/warnings/w301-unstable-defaults.js +36 -0
  324. package/dist/runtime/analysis/strict-mode.d.ts +21 -0
  325. package/dist/runtime/analysis/strict-mode.js +44 -0
  326. package/dist/runtime/analysis/types.d.ts +133 -0
  327. package/dist/runtime/analysis/types.js +6 -0
  328. package/dist/runtime/analysis/utils.d.ts +19 -0
  329. package/dist/runtime/analysis/utils.js +21 -0
  330. package/dist/runtime/dev/data-manager.d.ts +55 -0
  331. package/dist/runtime/dev/data-manager.js +87 -0
  332. package/dist/runtime/dev/event-mapper.d.ts +100 -0
  333. package/dist/runtime/dev/event-mapper.js +400 -0
  334. package/dist/runtime/dev/formatter.d.ts +94 -0
  335. package/dist/runtime/dev/formatter.js +236 -0
  336. package/dist/runtime/dev/index.d.ts +9 -0
  337. package/dist/runtime/dev/index.js +9 -0
  338. package/dist/runtime/dev/repl.d.ts +114 -0
  339. package/dist/runtime/dev/repl.js +310 -0
  340. package/dist/runtime/dev/session.d.ts +86 -0
  341. package/dist/runtime/dev/session.js +447 -0
  342. package/dist/runtime/dev/stack-trace.d.ts +77 -0
  343. package/dist/runtime/dev/stack-trace.js +286 -0
  344. package/dist/runtime/dev/types.d.ts +54 -0
  345. package/dist/runtime/dev/types.js +5 -0
  346. package/dist/runtime/llm/claude.d.ts +27 -0
  347. package/dist/runtime/llm/claude.js +150 -0
  348. package/dist/runtime/llm/factory.d.ts +30 -0
  349. package/dist/runtime/llm/factory.js +78 -0
  350. package/dist/runtime/llm/index.d.ts +10 -0
  351. package/dist/runtime/llm/index.js +10 -0
  352. package/dist/runtime/llm/ollama.d.ts +45 -0
  353. package/dist/runtime/llm/ollama.js +449 -0
  354. package/dist/runtime/llm/openai.d.ts +27 -0
  355. package/dist/runtime/llm/openai.js +170 -0
  356. package/dist/runtime/llm/provider.d.ts +32 -0
  357. package/dist/runtime/llm/provider.js +6 -0
  358. package/dist/runtime/llm/types.d.ts +55 -0
  359. package/dist/runtime/llm/types.js +6 -0
  360. package/dist/runtime/mcp/client/base.d.ts +40 -0
  361. package/dist/runtime/mcp/client/base.js +157 -0
  362. package/dist/runtime/mcp/client/manager.d.ts +91 -0
  363. package/dist/runtime/mcp/client/manager.js +248 -0
  364. package/dist/runtime/mcp/client/process.d.ts +31 -0
  365. package/dist/runtime/mcp/client/process.js +82 -0
  366. package/dist/runtime/mcp/connection.d.ts +63 -0
  367. package/dist/runtime/mcp/connection.js +449 -0
  368. package/dist/runtime/mcp/index.d.ts +9 -0
  369. package/dist/runtime/mcp/index.js +9 -0
  370. package/dist/runtime/mcp/list.d.ts +50 -0
  371. package/dist/runtime/mcp/list.js +65 -0
  372. package/dist/runtime/mcp/stdio-transport.d.ts +23 -0
  373. package/dist/runtime/mcp/stdio-transport.js +71 -0
  374. package/dist/runtime/mcp/types.d.ts +85 -0
  375. package/dist/runtime/mcp/types.js +6 -0
  376. package/dist/runtime/sandbox/executor.d.ts +102 -0
  377. package/dist/runtime/sandbox/executor.js +537 -0
  378. package/dist/runtime/sandbox/index.d.ts +9 -0
  379. package/dist/runtime/sandbox/index.js +9 -0
  380. package/dist/runtime/sandbox/io-monitor.d.ts +78 -0
  381. package/dist/runtime/sandbox/io-monitor.js +98 -0
  382. package/dist/runtime/sandbox/time-parser.d.ts +19 -0
  383. package/dist/runtime/sandbox/time-parser.js +67 -0
  384. package/dist/runtime/sandbox/types.d.ts +58 -0
  385. package/dist/runtime/sandbox/types.js +23 -0
  386. package/dist/runtime/test/behavior-observer.d.ts +61 -0
  387. package/dist/runtime/test/behavior-observer.js +140 -0
  388. package/dist/runtime/test/contract-loader.d.ts +41 -0
  389. package/dist/runtime/test/contract-loader.js +158 -0
  390. package/dist/runtime/test/contract-schema.d.ts +46 -0
  391. package/dist/runtime/test/contract-schema.js +107 -0
  392. package/dist/runtime/test/contract-types.d.ts +106 -0
  393. package/dist/runtime/test/contract-types.js +6 -0
  394. package/dist/runtime/test/dependency-tracker.d.ts +66 -0
  395. package/dist/runtime/test/dependency-tracker.js +80 -0
  396. package/dist/runtime/test/formatters.d.ts +18 -0
  397. package/dist/runtime/test/formatters.js +172 -0
  398. package/dist/runtime/test/index.d.ts +12 -0
  399. package/dist/runtime/test/index.js +13 -0
  400. package/dist/runtime/test/input-generator.d.ts +33 -0
  401. package/dist/runtime/test/input-generator.js +498 -0
  402. package/dist/runtime/test/mcp-root-detector.d.ts +31 -0
  403. package/dist/runtime/test/mcp-root-detector.js +105 -0
  404. package/dist/runtime/test/orchestrator.d.ts +131 -0
  405. package/dist/runtime/test/orchestrator.js +738 -0
  406. package/dist/runtime/test/output-validator.d.ts +44 -0
  407. package/dist/runtime/test/output-validator.js +262 -0
  408. package/dist/runtime/test/retry-tester.d.ts +44 -0
  409. package/dist/runtime/test/retry-tester.js +103 -0
  410. package/dist/runtime/test/runner.d.ts +28 -0
  411. package/dist/runtime/test/runner.js +55 -0
  412. package/dist/runtime/test/synthetic-input-generator.d.ts +11 -0
  413. package/dist/runtime/test/synthetic-input-generator.js +154 -0
  414. package/dist/runtime/test/test-runner.d.ts +28 -0
  415. package/dist/runtime/test/test-runner.js +55 -0
  416. package/dist/types/factories.d.ts +16 -0
  417. package/dist/types/factories.js +43 -0
  418. package/dist/types/ids.d.ts +16 -0
  419. package/dist/types/ids.js +2 -0
  420. package/dist/types/opaque.d.ts +4 -0
  421. package/dist/types/opaque.js +2 -0
  422. package/dist/utils/errors.d.ts +92 -0
  423. package/dist/utils/errors.js +97 -0
  424. package/dist/utils/gitignore.d.ts +11 -0
  425. package/dist/utils/gitignore.js +59 -0
  426. package/dist/utils/json-file-saver.d.ts +17 -0
  427. package/dist/utils/json-file-saver.js +81 -0
  428. package/dist/utils/json-formatter.d.ts +63 -0
  429. package/dist/utils/json-formatter.js +344 -0
  430. package/dist/utils/logger.d.ts +184 -0
  431. package/dist/utils/logger.js +330 -0
  432. package/dist/utils/package-manager.d.ts +30 -0
  433. package/dist/utils/package-manager.js +157 -0
  434. package/dist/utils/version-checker.d.ts +47 -0
  435. package/dist/utils/version-checker.js +167 -0
  436. package/dist/utils/version-display.d.ts +10 -0
  437. package/dist/utils/version-display.js +20 -0
  438. package/package.json +106 -0
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Utilities for saving large JSON data to external files.
3
+ */
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
6
+ import * as os from 'os';
7
+ /**
8
+ * Save JSON data to a file.
9
+ * Returns the file path.
10
+ */
11
+ export function saveJSONToFile(data, toolName, outputDir) {
12
+ const dir = outputDir || path.join(os.tmpdir(), 'syrin-json-exports');
13
+ // Ensure directory exists
14
+ if (!fs.existsSync(dir)) {
15
+ fs.mkdirSync(dir, { recursive: true });
16
+ }
17
+ // Sanitize toolName to ensure valid filename
18
+ // Remove or replace invalid filesystem characters: / \ : * ? " < > |
19
+ let sanitizedToolName = toolName
20
+ .replace(/[/\\:*?"<>|]/g, '-') // Replace invalid chars with hyphen
21
+ .replace(/-+/g, '-') // Collapse repeated hyphens
22
+ .trim(); // Remove leading/trailing whitespace
23
+ // Ensure non-empty and limit length
24
+ if (!sanitizedToolName || sanitizedToolName.length === 0) {
25
+ sanitizedToolName = 'tool';
26
+ }
27
+ else if (sanitizedToolName.length > 100) {
28
+ sanitizedToolName = sanitizedToolName.substring(0, 100);
29
+ }
30
+ // Generate filename with timestamp
31
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
32
+ const filename = `${sanitizedToolName}-${timestamp}.json`;
33
+ const filePath = path.join(dir, filename);
34
+ // Parse if data is already a JSON string to avoid double-escaping
35
+ let parsedData = data;
36
+ if (typeof data === 'string') {
37
+ try {
38
+ // Try to parse as JSON - if it's already a JSON string, parse it first
39
+ parsedData = JSON.parse(data);
40
+ }
41
+ catch {
42
+ // If parsing fails, it's not JSON, keep as string
43
+ parsedData = data;
44
+ }
45
+ }
46
+ // Write JSON with pretty formatting (no escape sequences)
47
+ const jsonString = JSON.stringify(parsedData, null, 2);
48
+ fs.writeFileSync(filePath, jsonString, 'utf-8');
49
+ return filePath;
50
+ }
51
+ /**
52
+ * Get the size of a file in human-readable format.
53
+ */
54
+ export function getFileSize(filePath) {
55
+ try {
56
+ const stats = fs.statSync(filePath);
57
+ const bytes = stats.size;
58
+ if (bytes < 1024)
59
+ return `${bytes} B`;
60
+ if (bytes < 1024 * 1024)
61
+ return `${(bytes / 1024).toFixed(2)} KB`;
62
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
63
+ }
64
+ catch {
65
+ return 'unknown';
66
+ }
67
+ }
68
+ /**
69
+ * Format a file path for display (shorten if too long).
70
+ */
71
+ export function formatFilePath(filePath, maxLength = 60) {
72
+ if (filePath.length <= maxLength)
73
+ return filePath;
74
+ // Try to show just the filename
75
+ const filename = path.basename(filePath);
76
+ if (filename.length <= maxLength)
77
+ return filename;
78
+ // Truncate filename
79
+ return `...${filename.slice(-(maxLength - 3))}`;
80
+ }
81
+ //# sourceMappingURL=json-file-saver.js.map
@@ -0,0 +1,63 @@
1
+ /**
2
+ * JSON formatting utilities for displaying large JSON data efficiently.
3
+ * Provides tree view formatting and pagination for arrays.
4
+ */
5
+ export interface JSONTreeOptions {
6
+ /** Maximum depth to expand by default */
7
+ maxDepth?: number;
8
+ /** Maximum items to show in arrays before pagination */
9
+ maxArrayItems?: number;
10
+ /** Items per page for pagination */
11
+ itemsPerPage?: number;
12
+ /** Current page for pagination (0-indexed) */
13
+ currentPage?: number;
14
+ /** Whether to show line numbers */
15
+ showLineNumbers?: boolean;
16
+ /** Indentation string */
17
+ indent?: string;
18
+ }
19
+ export interface JSONTreeNode {
20
+ key?: string;
21
+ value: unknown;
22
+ type: 'object' | 'array' | 'primitive';
23
+ expanded: boolean;
24
+ children?: JSONTreeNode[];
25
+ /** For arrays: total count and pagination info */
26
+ arrayInfo?: {
27
+ total: number;
28
+ start: number;
29
+ end: number;
30
+ currentPage: number;
31
+ totalPages: number;
32
+ };
33
+ }
34
+ /**
35
+ * Convert JSON value to tree structure with pagination support.
36
+ */
37
+ export declare function jsonToTree(data: unknown, options?: JSONTreeOptions): JSONTreeNode;
38
+ /**
39
+ * Format JSON tree as a string with tree structure.
40
+ */
41
+ export declare function formatJSONTree(node: JSONTreeNode, options?: JSONTreeOptions): string;
42
+ /**
43
+ * Format JSON with pagination for large arrays.
44
+ * Returns formatted string with pagination info.
45
+ */
46
+ export declare function formatJSONWithPagination(data: unknown, options?: JSONTreeOptions): string;
47
+ /**
48
+ * Get summary information about JSON structure.
49
+ * Optimized to avoid expensive stringification for large data.
50
+ */
51
+ export declare function getJSONSummary(data: unknown): {
52
+ type: string;
53
+ size: number;
54
+ itemCount?: number;
55
+ keyCount?: number;
56
+ depth: number;
57
+ hasLargeArrays: boolean;
58
+ };
59
+ /**
60
+ * Estimate object size without full stringification (much faster for large objects).
61
+ */
62
+ export declare function estimateObjectSize(obj: unknown): number;
63
+ //# sourceMappingURL=json-formatter.d.ts.map
@@ -0,0 +1,344 @@
1
+ /**
2
+ * JSON formatting utilities for displaying large JSON data efficiently.
3
+ * Provides tree view formatting and pagination for arrays.
4
+ */
5
+ /**
6
+ * Convert JSON value to tree structure with pagination support.
7
+ */
8
+ export function jsonToTree(data, options = {}) {
9
+ const { maxDepth = 3, maxArrayItems = 50, itemsPerPage = 20, currentPage = 0, } = options;
10
+ function buildNode(value, depth, key) {
11
+ if (value === null) {
12
+ return {
13
+ key,
14
+ value: null,
15
+ type: 'primitive',
16
+ expanded: depth < maxDepth,
17
+ };
18
+ }
19
+ if (Array.isArray(value)) {
20
+ const total = value.length;
21
+ const totalPages = Math.ceil(total / itemsPerPage);
22
+ const start = currentPage * itemsPerPage;
23
+ const end = Math.min(start + itemsPerPage, total);
24
+ const paginatedItems = value.slice(start, end);
25
+ return {
26
+ key,
27
+ value: paginatedItems,
28
+ type: 'array',
29
+ expanded: depth < maxDepth && total <= maxArrayItems,
30
+ arrayInfo: {
31
+ total,
32
+ start: start + 1, // 1-indexed for display
33
+ end,
34
+ currentPage,
35
+ totalPages,
36
+ },
37
+ children: depth < maxDepth && total <= maxArrayItems
38
+ ? paginatedItems.map((item, idx) => buildNode(item, depth + 1, `[${start + idx}]`))
39
+ : undefined,
40
+ };
41
+ }
42
+ if (typeof value === 'object' && value !== null) {
43
+ const obj = value;
44
+ const keys = Object.keys(obj);
45
+ const expanded = depth < maxDepth;
46
+ return {
47
+ key,
48
+ value: obj,
49
+ type: 'object',
50
+ expanded,
51
+ children: expanded
52
+ ? keys.map(k => buildNode(obj[k], depth + 1, k))
53
+ : undefined,
54
+ };
55
+ }
56
+ // Primitive value
57
+ return {
58
+ key,
59
+ value,
60
+ type: 'primitive',
61
+ expanded: true,
62
+ };
63
+ }
64
+ return buildNode(data, 0);
65
+ }
66
+ /**
67
+ * Format JSON tree as a string with tree structure.
68
+ */
69
+ export function formatJSONTree(node, options = {}) {
70
+ const { showLineNumbers = false } = options;
71
+ const lines = [];
72
+ let lineNumber = 1;
73
+ function formatNode(node, prefix, isLast, depth) {
74
+ const connector = isLast ? '└─' : '├─';
75
+ const nextPrefix = isLast ? ' ' : '│ ';
76
+ // Format key
77
+ if (node.key !== undefined) {
78
+ const keyPart = `${prefix}${connector} ${node.key}: `;
79
+ const lineNum = showLineNumbers ? `${lineNumber++}. `.padStart(6) : '';
80
+ lines.push(`${lineNum}${keyPart}`);
81
+ }
82
+ // Format value based on type
83
+ if (node.type === 'primitive') {
84
+ const valueStr = formatPrimitive(node.value);
85
+ const lastLine = lines[lines.length - 1] || '';
86
+ if (lastLine.includes(':')) {
87
+ lines[lines.length - 1] = lastLine + valueStr;
88
+ }
89
+ else {
90
+ lines.push(`${prefix}${connector} ${valueStr}`);
91
+ }
92
+ }
93
+ else if (node.type === 'array') {
94
+ const arrayInfo = node.arrayInfo;
95
+ if (arrayInfo && arrayInfo.total > arrayInfo.end - arrayInfo.start + 1) {
96
+ // Paginated array
97
+ const info = `[Array: ${arrayInfo.total} items, showing ${arrayInfo.start}-${arrayInfo.end} (page ${arrayInfo.currentPage + 1}/${arrayInfo.totalPages})]`;
98
+ const lastLine = lines[lines.length - 1] || '';
99
+ if (lastLine.includes(':')) {
100
+ lines[lines.length - 1] = lastLine + info;
101
+ }
102
+ else {
103
+ lines.push(`${prefix}${connector} ${info}`);
104
+ }
105
+ }
106
+ else {
107
+ const lastLine = lines[lines.length - 1] || '';
108
+ if (lastLine.includes(':')) {
109
+ lines[lines.length - 1] =
110
+ lastLine + `[Array: ${arrayInfo?.total || 0} items]`;
111
+ }
112
+ }
113
+ if (node.expanded && node.children) {
114
+ node.children.forEach((child, idx) => {
115
+ const isLastChild = idx === node.children.length - 1;
116
+ formatNode(child, prefix + (node.key !== undefined ? nextPrefix : ''), isLastChild, depth + 1);
117
+ });
118
+ }
119
+ else if (!node.expanded && arrayInfo) {
120
+ lines.push(`${prefix}${nextPrefix}... (${arrayInfo.total} items, use /expand to view)`);
121
+ }
122
+ }
123
+ else if (node.type === 'object') {
124
+ const obj = node.value;
125
+ const keyCount = Object.keys(obj).length;
126
+ const lastLine = lines[lines.length - 1] || '';
127
+ if (lastLine.includes(':')) {
128
+ lines[lines.length - 1] = lastLine + `{Object: ${keyCount} keys}`;
129
+ }
130
+ if (node.expanded && node.children) {
131
+ node.children.forEach((child, idx) => {
132
+ const isLastChild = idx === node.children.length - 1;
133
+ formatNode(child, prefix + (node.key !== undefined ? nextPrefix : ''), isLastChild, depth + 1);
134
+ });
135
+ }
136
+ else if (!node.expanded) {
137
+ lines.push(`${prefix}${nextPrefix}... (${keyCount} keys, use /expand to view)`);
138
+ }
139
+ }
140
+ }
141
+ formatNode(node, '', true, 0);
142
+ return lines.join('\n');
143
+ }
144
+ /**
145
+ * Format primitive value for display.
146
+ */
147
+ function formatPrimitive(value) {
148
+ if (value === null)
149
+ return 'null';
150
+ if (typeof value === 'string') {
151
+ // Truncate long strings
152
+ if (value.length > 100) {
153
+ return `"${value.substring(0, 97)}..." (${value.length} chars)`;
154
+ }
155
+ return JSON.stringify(value);
156
+ }
157
+ if (typeof value === 'number')
158
+ return String(value);
159
+ if (typeof value === 'boolean')
160
+ return String(value);
161
+ if (typeof value === 'undefined')
162
+ return 'undefined';
163
+ if (typeof value === 'function')
164
+ return '[Function]';
165
+ if (typeof value === 'symbol')
166
+ return value.toString();
167
+ if (typeof value === 'object' && value !== null) {
168
+ // For objects, show a summary instead of stringifying
169
+ return '[Object]';
170
+ }
171
+ // Fallback for any other types
172
+ return '[Unknown]';
173
+ }
174
+ /**
175
+ * Format JSON with pagination for large arrays.
176
+ * Returns formatted string with pagination info.
177
+ */
178
+ export function formatJSONWithPagination(data, options = {}) {
179
+ const tree = jsonToTree(data, options);
180
+ return formatJSONTree(tree, options);
181
+ }
182
+ /**
183
+ * Get summary information about JSON structure.
184
+ * Optimized to avoid expensive stringification for large data.
185
+ */
186
+ export function getJSONSummary(data) {
187
+ // Fast size estimation without full stringification for large data
188
+ let size;
189
+ try {
190
+ // For small data, use actual stringification
191
+ // For large data, estimate to avoid blocking
192
+ if (typeof data === 'string') {
193
+ size = Buffer.byteLength(data, 'utf8');
194
+ }
195
+ else {
196
+ // Quick check: if it's a large array/object, estimate instead
197
+ const isLarge = (Array.isArray(data) && data.length > 1000) ||
198
+ (typeof data === 'object' &&
199
+ data !== null &&
200
+ !Array.isArray(data) &&
201
+ Object.keys(data).length > 100);
202
+ if (isLarge) {
203
+ // Estimate size without full stringification
204
+ // Create a small sample by taking a slice/portion of the data
205
+ let sample;
206
+ if (Array.isArray(data)) {
207
+ // Sample first 10 items
208
+ sample = data.slice(0, 10);
209
+ }
210
+ else {
211
+ // Sample first 10 keys
212
+ const keys = Object.keys(data).slice(0, 10);
213
+ sample = Object.fromEntries(keys.map(key => [key, data[key]]));
214
+ }
215
+ const sampleString = JSON.stringify(sample);
216
+ const estimatedSizePerChar = Buffer.byteLength(sampleString, 'utf8') / sampleString.length;
217
+ const estimatedChars = estimateObjectSize(data);
218
+ size = Math.floor(estimatedChars * estimatedSizePerChar);
219
+ }
220
+ else {
221
+ // Small data: use actual stringification
222
+ const jsonString = JSON.stringify(data);
223
+ size = Buffer.byteLength(jsonString, 'utf8');
224
+ }
225
+ }
226
+ }
227
+ catch {
228
+ // Fallback: estimate
229
+ size = estimateObjectSize(data) * 2; // Rough estimate
230
+ }
231
+ function analyze(value, depth) {
232
+ if (value === null || typeof value !== 'object') {
233
+ return {
234
+ maxDepth: depth,
235
+ itemCount: 0,
236
+ keyCount: 0,
237
+ hasLargeArrays: false,
238
+ };
239
+ }
240
+ if (Array.isArray(value)) {
241
+ const itemCount = value.length;
242
+ let maxDepth = depth;
243
+ let totalKeys = 0;
244
+ let hasLargeArrays = itemCount > 100;
245
+ for (const item of value.slice(0, 10)) {
246
+ // Sample first 10 items
247
+ const result = analyze(item, depth + 1);
248
+ maxDepth = Math.max(maxDepth, result.maxDepth);
249
+ totalKeys += result.keyCount;
250
+ hasLargeArrays = hasLargeArrays || result.hasLargeArrays;
251
+ }
252
+ return {
253
+ maxDepth,
254
+ itemCount,
255
+ keyCount: totalKeys,
256
+ hasLargeArrays,
257
+ };
258
+ }
259
+ const obj = value;
260
+ const keys = Object.keys(obj);
261
+ let maxDepth = depth;
262
+ let totalItems = 0;
263
+ let totalKeys = keys.length;
264
+ let hasLargeArrays = false;
265
+ for (const key of keys) {
266
+ const result = analyze(obj[key], depth + 1);
267
+ maxDepth = Math.max(maxDepth, result.maxDepth);
268
+ totalItems += result.itemCount;
269
+ totalKeys += result.keyCount;
270
+ hasLargeArrays = hasLargeArrays || result.hasLargeArrays;
271
+ }
272
+ return {
273
+ maxDepth,
274
+ itemCount: totalItems,
275
+ keyCount: totalKeys,
276
+ hasLargeArrays,
277
+ };
278
+ }
279
+ const analysis = analyze(data, 0);
280
+ const type = Array.isArray(data)
281
+ ? 'array'
282
+ : typeof data === 'object' && data !== null
283
+ ? 'object'
284
+ : typeof data;
285
+ return {
286
+ type,
287
+ size,
288
+ itemCount: Array.isArray(data) ? data.length : analysis.itemCount,
289
+ keyCount: typeof data === 'object' && data !== null && !Array.isArray(data)
290
+ ? Object.keys(data).length
291
+ : undefined,
292
+ depth: analysis.maxDepth,
293
+ hasLargeArrays: analysis.hasLargeArrays || (Array.isArray(data) && data.length > 100),
294
+ };
295
+ }
296
+ /**
297
+ * Estimate object size without full stringification (much faster for large objects).
298
+ */
299
+ export function estimateObjectSize(obj) {
300
+ if (obj === null || obj === undefined)
301
+ return 4; // "null"
302
+ if (typeof obj === 'string')
303
+ return obj.length + 2; // quotes
304
+ if (typeof obj === 'number')
305
+ return 10; // average number length
306
+ if (typeof obj === 'boolean')
307
+ return 5; // "true"/"false"
308
+ if (Array.isArray(obj)) {
309
+ // Estimate: brackets + commas + items
310
+ let size = 2; // brackets
311
+ for (let i = 0; i < Math.min(obj.length, 100); i++) {
312
+ // Sample first 100 items
313
+ size += estimateObjectSize(obj[i]) + 1; // +1 for comma
314
+ }
315
+ if (obj.length > 100) {
316
+ // Extrapolate for remaining items
317
+ const avgItemSize = size / Math.min(obj.length, 100);
318
+ size += (obj.length - 100) * avgItemSize;
319
+ }
320
+ return size;
321
+ }
322
+ if (typeof obj === 'object') {
323
+ const SAMPLE_LIMIT = 100;
324
+ const keys = Object.keys(obj);
325
+ const sampleCount = Math.min(keys.length, SAMPLE_LIMIT);
326
+ let accumulatedSize = 0;
327
+ // Sample first sampleCount keys
328
+ for (let i = 0; i < sampleCount; i++) {
329
+ const key = keys[i]; // Safe: i < sampleCount <= keys.length
330
+ accumulatedSize += key.length + 3; // key + quotes + colon
331
+ accumulatedSize +=
332
+ estimateObjectSize(obj[key]) + 1; // +1 for comma
333
+ }
334
+ // If all keys were sampled, return exact size
335
+ if (sampleCount === keys.length) {
336
+ return 2 + accumulatedSize; // +2 for braces
337
+ }
338
+ // Extrapolate for remaining keys
339
+ const extrapolatedSize = accumulatedSize * (keys.length / sampleCount);
340
+ return 2 + extrapolatedSize; // +2 for braces
341
+ }
342
+ return 10; // fallback estimate
343
+ }
344
+ //# sourceMappingURL=json-formatter.js.map
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Unified logging utility for Syrin.
3
+ * Combines structured logging with styled console output.
4
+ */
5
+ export declare enum LogLevel {
6
+ DEBUG = 0,
7
+ INFO = 1,
8
+ WARN = 2,
9
+ ERROR = 3,
10
+ SILENT = 4
11
+ }
12
+ export declare const Icon: {
13
+ readonly ERROR: "❌";
14
+ readonly WARNING: "⚠️";
15
+ readonly TIP: "💡";
16
+ readonly SUCCESS: "✓";
17
+ readonly FAILURE: "✗";
18
+ readonly CHECK: "✅";
19
+ readonly FOLDER: "📁";
20
+ readonly DOCUMENT: "📝";
21
+ };
22
+ export type IconType = (typeof Icon)[keyof typeof Icon];
23
+ export interface LogEntry {
24
+ timestamp: string;
25
+ level: LogLevel;
26
+ message: string;
27
+ context?: Record<string, unknown>;
28
+ error?: Error;
29
+ }
30
+ declare const colors: {
31
+ readonly reset: "\u001B[0m";
32
+ readonly bold: "\u001B[1m";
33
+ readonly dim: "\u001B[2m";
34
+ readonly green: "\u001B[32m";
35
+ readonly yellow: "\u001B[33m";
36
+ readonly red: "\u001B[31m";
37
+ readonly cyan: "\u001B[36m";
38
+ readonly blue: "\u001B[34m";
39
+ };
40
+ type ColorKey = keyof typeof colors;
41
+ /**
42
+ * Unified logger class with structured logging and styled output.
43
+ */
44
+ export declare class Log {
45
+ private level;
46
+ private context;
47
+ private useStructuredLogging;
48
+ constructor(level?: LogLevel, context?: Record<string, unknown>, useStructuredLogging?: boolean);
49
+ /**
50
+ * Create a child logger with additional context.
51
+ */
52
+ child(additionalContext: Record<string, unknown>): Log;
53
+ /**
54
+ * Set the log level.
55
+ */
56
+ setLevel(level: LogLevel): void;
57
+ /**
58
+ * Enable or disable structured logging.
59
+ */
60
+ setStructuredLogging(enabled: boolean): void;
61
+ /**
62
+ * Style text with colors and formatting.
63
+ */
64
+ private style;
65
+ /**
66
+ * Internal structured logging method.
67
+ */
68
+ private structuredLog;
69
+ /**
70
+ * Print styled text to console.
71
+ */
72
+ private print;
73
+ /**
74
+ * Print a heading (green, bold).
75
+ */
76
+ heading(text: string): void;
77
+ /**
78
+ * Print a label (dim).
79
+ */
80
+ label(text: string): void;
81
+ /**
82
+ * Print a value (cyan).
83
+ */
84
+ value(text: string): void;
85
+ /**
86
+ * Log/print success message (green) with success icon.
87
+ * For structured logging: logs at INFO level
88
+ * For styled output: prints with green color and success icon
89
+ */
90
+ success(text: string, icon?: IconType): void;
91
+ /**
92
+ * Log/print error message (red) with error icon.
93
+ * For structured logging: logs at ERROR level (can include Error object)
94
+ * For styled output: prints with red color and error icon
95
+ */
96
+ error(message: string, errorOrIcon?: Error | IconType, contextOrIcon?: Record<string, unknown> | IconType): void;
97
+ /**
98
+ * Log/print warning message (yellow) with warning icon.
99
+ * For structured logging: logs at WARN level
100
+ * For styled output: prints with yellow color and warning icon
101
+ */
102
+ warning(text: string, context?: Record<string, unknown>): void;
103
+ warning(text: string, icon?: IconType): void;
104
+ /**
105
+ * Alias for warning() to match standard logging convention (warn).
106
+ * For structured logging: logs at WARN level
107
+ * For styled output: prints with yellow color and warning icon
108
+ */
109
+ warn(text: string, context?: Record<string, unknown>): void;
110
+ warn(text: string, icon?: IconType): void;
111
+ /**
112
+ * Log/print info message (cyan) with tip icon.
113
+ * For structured logging: logs at INFO level
114
+ * For styled output: prints with cyan color and tip icon
115
+ */
116
+ info(text: string, context?: Record<string, unknown>): void;
117
+ info(text: string, icon?: IconType): void;
118
+ /**
119
+ * Log/print debug message (dim).
120
+ * For structured logging: logs at DEBUG level
121
+ * For styled output: prints with dim color
122
+ */
123
+ debug(text: string, context?: Record<string, unknown>): void;
124
+ debug(text: string, icon?: IconType): void;
125
+ /**
126
+ * Print a line with label and value.
127
+ */
128
+ labelValue(labelText: string, valueText: string): void;
129
+ /**
130
+ * Print a numbered item.
131
+ */
132
+ numberedItem(number: number, text: string, ...additionalStyles: ColorKey[]): void;
133
+ /**
134
+ * Print a checkmark with text.
135
+ */
136
+ checkmark(text: string): void;
137
+ /**
138
+ * Print an X mark with text.
139
+ */
140
+ xmark(text: string): void;
141
+ /**
142
+ * Get a styled tick/checkmark (✓) in green.
143
+ * Returns a styled string that can be used in other messages.
144
+ */
145
+ tick(): string;
146
+ /**
147
+ * Get a styled cross/X mark (✗) in red.
148
+ * Returns a styled string that can be used in other messages.
149
+ */
150
+ cross(): string;
151
+ /**
152
+ * Print a warning symbol with text.
153
+ */
154
+ warnSymbol(text: string): void;
155
+ /**
156
+ * Print plain text (no styling).
157
+ */
158
+ plain(text: string): void;
159
+ /**
160
+ * Print an empty line.
161
+ */
162
+ blank(): void;
163
+ /**
164
+ * Style text with colors and formatting (returns styled string).
165
+ * This is a public method that can be used to get styled strings without printing.
166
+ */
167
+ styleText(text: string, ...styles: ColorKey[]): string;
168
+ }
169
+ /**
170
+ * Default logger instance for styled output (non-structured).
171
+ * Use this for UI/presentation output.
172
+ */
173
+ export declare const log: Log;
174
+ /**
175
+ * Default structured logger instance.
176
+ * Use this for application logging with levels and context.
177
+ */
178
+ export declare const logger: Log;
179
+ /**
180
+ * Create a logger with a specific context.
181
+ */
182
+ export declare function createLogger(context: Record<string, unknown>): Log;
183
+ export {};
184
+ //# sourceMappingURL=logger.d.ts.map