@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,358 @@
1
+ /**
2
+ * Test Results UI for MCP Connection Testing and Tool Validation.
3
+ * Provides a minimalistic, easy-to-read display of connection test results
4
+ * and tool validation results.
5
+ */
6
+ import { getVersionDisplayString } from '../utils/version-display.js';
7
+ import { log } from '../utils/logger.js';
8
+ /**
9
+ * Get human-readable explanation for capability properties.
10
+ */
11
+ function explainCapabilityProperty(capabilityName, propertyName) {
12
+ const explanations = {
13
+ tools: {
14
+ listChanged: 'Server sends notifications when the list of available tools changes',
15
+ },
16
+ prompts: {
17
+ listChanged: 'Server sends notifications when the list of available prompts changes',
18
+ },
19
+ resources: {
20
+ listChanged: 'Server sends notifications when the list of available resources changes',
21
+ subscribe: 'Server supports subscribing to resource updates',
22
+ },
23
+ tasks: {
24
+ list: 'Server supports listing tasks',
25
+ cancel: 'Server supports cancelling tasks',
26
+ 'requests.tools.call': 'Server supports task-augmented tool calls (long-running operations)',
27
+ },
28
+ completions: {
29
+ '*': 'Server supports LLM completion requests',
30
+ },
31
+ logging: {
32
+ '*': 'Server supports logging messages',
33
+ },
34
+ experimental: {
35
+ '*': 'Server supports experimental features',
36
+ },
37
+ };
38
+ return (explanations[capabilityName]?.[propertyName] ||
39
+ explanations[capabilityName]?.['*'] ||
40
+ '');
41
+ }
42
+ /**
43
+ * Display test results using plain console output.
44
+ * This avoids Ink taking control of stdin, which disables terminal history.
45
+ */
46
+ export async function displayTestResults(options) {
47
+ const { result, transport } = options;
48
+ // Get version info for display
49
+ const versionDisplayString = await getVersionDisplayString();
50
+ const details = result.details;
51
+ const success = result.success;
52
+ // Version display
53
+ log.blank();
54
+ log.label(`Syrin ${versionDisplayString}`);
55
+ log.blank();
56
+ // Header
57
+ if (success) {
58
+ log.checkmark('Connection successful');
59
+ }
60
+ else {
61
+ log.xmark('Connection failed');
62
+ }
63
+ // Error message if failed
64
+ if (result.error) {
65
+ log.error(` Error: ${result.error}`);
66
+ }
67
+ // Connection details
68
+ if (details) {
69
+ log.blank();
70
+ log.heading(' Connection Details:');
71
+ if (transport === 'http' && details.mcpUrl) {
72
+ const status = success ? ` ${log.tick()}` : '';
73
+ log.labelValue(' MCP URL:', `${details.mcpUrl}${status}`);
74
+ }
75
+ else if (transport === 'stdio' && details.command) {
76
+ const status = success ? ` ${log.tick()}` : '';
77
+ log.labelValue(' Command:', `${details.command}${status}`);
78
+ }
79
+ if (details.protocolVersion) {
80
+ log.labelValue(' Protocol Version:', details.protocolVersion);
81
+ }
82
+ if (details.sessionId) {
83
+ log.labelValue(' Session ID:', details.sessionId);
84
+ }
85
+ }
86
+ // Initialize Handshake details (only for HTTP transport and successful connections)
87
+ if (details?.initializeRequest && success && transport === 'http') {
88
+ log.blank();
89
+ log.heading(' Initialize Handshake:');
90
+ log.label(' Note: MCP uses Server-Sent Events (SSE) transport. Messages are sent via HTTP POST');
91
+ log.label(' and responses are received via HTTP GET with text/event-stream.');
92
+ log.blank();
93
+ // Request details
94
+ log.plain(` ${log.styleText('Request:', 'bold')}`);
95
+ if (details.initializeRequest.method) {
96
+ log.labelValue(' HTTP Method:', details.initializeRequest.method);
97
+ }
98
+ if (details.initializeRequest.url) {
99
+ log.labelValue(' URL:', details.initializeRequest.url);
100
+ }
101
+ if (details.initializeRequest.headers &&
102
+ Object.keys(details.initializeRequest.headers).length > 0) {
103
+ log.label(' Headers:');
104
+ for (const [key, val] of Object.entries(details.initializeRequest.headers)) {
105
+ log.labelValue(` ${key}:`, String(val));
106
+ }
107
+ }
108
+ if (details.initializeRequest.body) {
109
+ const body = details.initializeRequest.body;
110
+ if (body.method) {
111
+ log.labelValue(' JSON-RPC Method:', body.method);
112
+ }
113
+ if (body.params?.protocolVersion) {
114
+ log.labelValue(' Protocol Version:', body.params.protocolVersion);
115
+ }
116
+ if (body.params?.clientInfo) {
117
+ log.labelValue(' Client Info:', `${body.params.clientInfo.name || ''} v${body.params.clientInfo.version || ''}`);
118
+ }
119
+ }
120
+ // Response details
121
+ if (details.initializeResponse) {
122
+ log.blank();
123
+ log.plain(` ${log.styleText('Response:', 'bold')}`);
124
+ if (details.initializeResponse.statusCode) {
125
+ log.labelValue(' Status:', String(details.initializeResponse.statusCode));
126
+ }
127
+ if (details.initializeResponse.headers &&
128
+ Object.keys(details.initializeResponse.headers).length > 0) {
129
+ log.label(' Response Headers:');
130
+ for (const [key, val] of Object.entries(details.initializeResponse.headers)) {
131
+ log.labelValue(` ${key}:`, String(val));
132
+ }
133
+ }
134
+ log.label(' Note: Server capabilities are returned in the initialize response');
135
+ }
136
+ }
137
+ // Capabilities
138
+ const getValidCapabilityKeys = (caps) => {
139
+ if (!caps)
140
+ return [];
141
+ return Object.keys(caps).filter(key => {
142
+ const val = caps[key];
143
+ return val !== undefined && val !== null && val !== false;
144
+ });
145
+ };
146
+ const validCapabilityKeys = getValidCapabilityKeys(details?.capabilities);
147
+ if (details?.capabilities && validCapabilityKeys.length > 0) {
148
+ const capabilityCount = validCapabilityKeys.length;
149
+ log.blank();
150
+ log.heading(` Server Capabilities (${capabilityCount}):`);
151
+ log.label(' Note: Capabilities are obtained from the initialize response');
152
+ const capabilities = details.capabilities;
153
+ const capabilityNames = validCapabilityKeys;
154
+ for (const capabilityName of capabilityNames) {
155
+ const capability = capabilities[capabilityName];
156
+ if (capability &&
157
+ typeof capability === 'object' &&
158
+ !Array.isArray(capability)) {
159
+ const capabilityObj = capability;
160
+ const props = Object.keys(capabilityObj).filter(prop => capabilityObj[prop] !== undefined &&
161
+ capabilityObj[prop] !== null &&
162
+ capabilityObj[prop] !== false);
163
+ if (props.length > 0) {
164
+ log.plain(` ${log.styleText(capabilityName + ':', 'bold', 'cyan')}`);
165
+ for (const prop of props) {
166
+ const explanation = explainCapabilityProperty(capabilityName, prop);
167
+ if (explanation) {
168
+ log.plain(` ${log.styleText('•', 'dim')} ${log.styleText(prop, 'cyan')} ${log.styleText(`- ${explanation}`, 'dim')}`);
169
+ }
170
+ else {
171
+ log.plain(` ${log.styleText('•', 'dim')} ${log.styleText(prop, 'cyan')}`);
172
+ }
173
+ }
174
+ }
175
+ else {
176
+ log.plain(` ${log.styleText('•', 'dim')} ${log.styleText(capabilityName, 'cyan')}`);
177
+ }
178
+ }
179
+ else {
180
+ const explanation = explainCapabilityProperty(capabilityName, '*');
181
+ if (explanation) {
182
+ log.plain(` ${log.styleText('•', 'dim')} ${log.styleText(capabilityName, 'cyan')} ${log.styleText(`- ${explanation}`, 'dim')}`);
183
+ }
184
+ else {
185
+ log.plain(` ${log.styleText('•', 'dim')} ${log.styleText(capabilityName, 'cyan')}`);
186
+ }
187
+ }
188
+ }
189
+ }
190
+ log.blank();
191
+ }
192
+ /**
193
+ * Format test results for CI output (minimal).
194
+ */
195
+ export function formatCIResults(result) {
196
+ const errors = result.diagnostics.filter(d => d.severity === 'error');
197
+ const warnings = result.diagnostics.filter(d => d.severity === 'warning');
198
+ // CI mode: minimal output, exit codes handled by caller
199
+ if (result.verdict === 'fail') {
200
+ console.log(`✗ Test failed: ${result.toolsFailed} tool(s) failed, ${errors.length} error(s), ${warnings.length} warning(s)`);
201
+ // Print errors only (no warnings in CI)
202
+ for (const error of errors) {
203
+ console.log(`${error.code}: ${error.message}`);
204
+ }
205
+ }
206
+ else {
207
+ console.log(`✓ Test passed: ${result.toolsTested} tool(s) tested, ${result.toolsPassed} passed`);
208
+ if (warnings.length > 0) {
209
+ console.log(` ${warnings.length} warning(s) (non-blocking)`);
210
+ }
211
+ }
212
+ }
213
+ /**
214
+ * Format test results for CLI output.
215
+ */
216
+ export function formatCLIResults(result) {
217
+ log.blank();
218
+ log.heading('Tool Validation Results');
219
+ log.blank();
220
+ // Overall verdict
221
+ if (result.verdict === 'pass') {
222
+ log.checkmark('All tools passed validation');
223
+ }
224
+ else if (result.verdict === 'pass-with-warnings') {
225
+ log.warn('Tools passed with warnings');
226
+ }
227
+ else {
228
+ log.xmark('Tool validation failed');
229
+ }
230
+ log.blank();
231
+ // Summary
232
+ log.heading('Summary:');
233
+ log.labelValue(' Tools tested:', String(result.toolsTested));
234
+ log.labelValue(' Tools passed:', String(result.toolsPassed));
235
+ log.labelValue(' Tools failed:', String(result.toolsFailed));
236
+ const errors = result.diagnostics.filter(d => d.severity === 'error');
237
+ const warnings = result.diagnostics.filter(d => d.severity === 'warning');
238
+ if (errors.length > 0) {
239
+ log.labelValue(' Errors:', String(errors.length));
240
+ }
241
+ if (warnings.length > 0) {
242
+ log.labelValue(' Warnings:', String(warnings.length));
243
+ }
244
+ log.blank();
245
+ // Tool results
246
+ if (result.toolResults.length > 0) {
247
+ log.heading('Tool Results:');
248
+ for (const toolResult of result.toolResults) {
249
+ log.blank();
250
+ const status = toolResult.passed ? log.tick() : log.cross();
251
+ log.plain(` ${status} ${log.styleText(toolResult.toolName, 'bold')}`);
252
+ // Summary
253
+ log.labelValue(' Executions:', `${toolResult.summary.successfulExecutions}/${toolResult.summary.totalExecutions} successful`);
254
+ if (toolResult.summary.testsPassed !== undefined &&
255
+ toolResult.summary.testsFailed !== undefined) {
256
+ const totalTests = toolResult.summary.testsPassed + toolResult.summary.testsFailed;
257
+ log.labelValue(' Tests:', `${toolResult.summary.testsPassed}/${totalTests} passed (expectations matched)`);
258
+ }
259
+ if (toolResult.summary.failedExecutions > 0) {
260
+ log.labelValue(' Failed:', String(toolResult.summary.failedExecutions));
261
+ }
262
+ if (toolResult.summary.timedOutExecutions > 0) {
263
+ log.labelValue(' Timed out:', String(toolResult.summary.timedOutExecutions));
264
+ }
265
+ // Diagnostics
266
+ if (toolResult.diagnostics.length > 0) {
267
+ const toolErrors = toolResult.diagnostics.filter(d => d.severity === 'error');
268
+ const toolWarnings = toolResult.diagnostics.filter(d => d.severity === 'warning');
269
+ if (toolErrors.length > 0) {
270
+ log.plain(' Errors:');
271
+ for (const error of toolErrors) {
272
+ log.error(` ${error.code}: ${error.message}`);
273
+ // Show test context if available
274
+ const context = error.context;
275
+ if (context?.testName) {
276
+ log.plain(` Test: ${context.testName}`);
277
+ }
278
+ if (context?.testInput &&
279
+ Object.keys(context.testInput).length > 0) {
280
+ const inputStr = JSON.stringify(context.testInput, null, 2)
281
+ .split('\n')
282
+ .map((line, idx) => (idx === 0 ? line : ` ${line}`))
283
+ .join('\n');
284
+ log.plain(` Input: ${inputStr}`);
285
+ }
286
+ if (context?.expectedOutputSchema) {
287
+ log.plain(` Expected output schema: ${context.expectedOutputSchema}`);
288
+ }
289
+ // Show parsed error details if available
290
+ if (context?.parsedError) {
291
+ const parsed = context.parsedError;
292
+ if (parsed.field) {
293
+ if (parsed.errorType === 'missing_argument') {
294
+ log.plain(` Field "${parsed.field}" is required but was not provided`);
295
+ }
296
+ else if (parsed.inputType) {
297
+ log.plain(` Field "${parsed.field}" received ${parsed.inputType}${parsed.inputValue && parsed.inputValue !== '{}' ? ` (${parsed.inputValue})` : ''}`);
298
+ }
299
+ }
300
+ }
301
+ if (error.suggestion) {
302
+ log.plain(` Suggestion: ${error.suggestion}`);
303
+ }
304
+ log.blank();
305
+ }
306
+ }
307
+ if (toolWarnings.length > 0) {
308
+ log.plain(' Warnings:');
309
+ for (const warning of toolWarnings) {
310
+ log.warn(` ${warning.code}: ${warning.message}`);
311
+ if (warning.suggestion) {
312
+ log.plain(` Suggestion: ${warning.suggestion}`);
313
+ }
314
+ }
315
+ }
316
+ }
317
+ }
318
+ }
319
+ log.blank();
320
+ }
321
+ /**
322
+ * Format test results as JSON.
323
+ */
324
+ export function formatJSONResults(result) {
325
+ const json = {
326
+ verdict: result.verdict,
327
+ summary: {
328
+ toolsTested: result.toolsTested,
329
+ toolsPassed: result.toolsPassed,
330
+ toolsFailed: result.toolsFailed,
331
+ errors: result.diagnostics.filter(d => d.severity === 'error').length,
332
+ warnings: result.diagnostics.filter(d => d.severity === 'warning').length,
333
+ },
334
+ diagnostics: result.diagnostics.map(d => ({
335
+ code: d.code,
336
+ severity: d.severity,
337
+ message: d.message,
338
+ tool: d.tool,
339
+ field: d.field,
340
+ suggestion: d.suggestion,
341
+ context: d.context,
342
+ })),
343
+ tools: result.toolResults.map(tr => ({
344
+ toolName: tr.toolName,
345
+ passed: tr.passed,
346
+ summary: tr.summary,
347
+ diagnostics: tr.diagnostics.map(d => ({
348
+ code: d.code,
349
+ severity: d.severity,
350
+ message: d.message,
351
+ suggestion: d.suggestion,
352
+ context: d.context,
353
+ })),
354
+ })),
355
+ };
356
+ return JSON.stringify(json, null, 2);
357
+ }
358
+ //# sourceMappingURL=test-ui.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Analysis orchestrator.
3
+ * Main entry point for static analysis of MCP tools.
4
+ */
5
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
6
+ import type { AnalysisResult } from './types.js';
7
+ /**
8
+ * Perform static analysis on MCP tools.
9
+ *
10
+ * @param client - Connected MCP client
11
+ * @returns Analysis result
12
+ */
13
+ export declare function analyseTools(client: Client): Promise<AnalysisResult>;
14
+ //# sourceMappingURL=analyser.d.ts.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Analysis orchestrator.
3
+ * Main entry point for static analysis of MCP tools.
4
+ */
5
+ import { loadMCPTools } from './loader.js';
6
+ import { normalizeTools } from './normalizer.js';
7
+ import { buildIndexes } from './indexer.js';
8
+ import { inferDependencies } from './dependencies.js';
9
+ import { ALL_RULES } from './rules/index.js';
10
+ import { logger } from '../../utils/logger.js';
11
+ /**
12
+ * Analyze MCP tools and return diagnostics.
13
+ * Executes all registered rules.
14
+ *
15
+ * @param tools - Normalized tool specifications
16
+ * @param dependencies - Inferred dependencies
17
+ * @param indexes - Built indexes
18
+ * @returns Array of diagnostics
19
+ */
20
+ function runRules(tools, dependencies, indexes) {
21
+ const diagnostics = [];
22
+ const context = {
23
+ tools,
24
+ dependencies,
25
+ indexes,
26
+ };
27
+ // Run all registered rules
28
+ for (const rule of ALL_RULES) {
29
+ try {
30
+ const ruleDiagnostics = rule.check(context);
31
+ diagnostics.push(...ruleDiagnostics);
32
+ }
33
+ catch (error) {
34
+ // If a rule fails, log error but don't crash the analysis
35
+ logger.error(`Rule ${rule.id} failed`, error instanceof Error ? error : new Error(String(error)), {
36
+ ruleId: rule.id,
37
+ ruleName: rule.ruleName,
38
+ });
39
+ }
40
+ }
41
+ return diagnostics;
42
+ }
43
+ /**
44
+ * Compute verdict from diagnostics.
45
+ */
46
+ function computeVerdict(diagnostics) {
47
+ const errors = diagnostics.filter(d => d.severity === 'error');
48
+ const warnings = diagnostics.filter(d => d.severity === 'warning');
49
+ if (errors.length > 0) {
50
+ return 'fail';
51
+ }
52
+ if (warnings.length > 0) {
53
+ return 'pass-with-warnings';
54
+ }
55
+ return 'pass';
56
+ }
57
+ /**
58
+ * Perform static analysis on MCP tools.
59
+ *
60
+ * @param client - Connected MCP client
61
+ * @returns Analysis result
62
+ */
63
+ export async function analyseTools(client) {
64
+ // Step 1: Load raw tools
65
+ const rawTools = await loadMCPTools(client);
66
+ // Step 2: Normalize tools
67
+ const tools = await normalizeTools(rawTools);
68
+ // Step 3: Build indexes
69
+ const indexes = buildIndexes(tools);
70
+ // Step 4: Infer dependencies
71
+ const dependencies = inferDependencies(tools);
72
+ // Step 5: Run rules
73
+ const diagnostics = runRules(tools, dependencies, indexes);
74
+ // Step 6: Compute verdict
75
+ const verdict = computeVerdict(diagnostics);
76
+ // Separate errors and warnings
77
+ const errors = diagnostics.filter(d => d.severity === 'error');
78
+ const warnings = diagnostics.filter(d => d.severity === 'warning');
79
+ return {
80
+ verdict,
81
+ diagnostics,
82
+ errors,
83
+ warnings,
84
+ dependencies,
85
+ toolCount: tools.length,
86
+ };
87
+ }
88
+ //# sourceMappingURL=analyser.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Dependency inference.
3
+ * Infers tool dependencies using deterministic heuristics.
4
+ */
5
+ import type { ToolSpec, Dependency } from './types.js';
6
+ /**
7
+ * Infer dependencies between tools.
8
+ */
9
+ export declare function inferDependencies(tools: ToolSpec[]): Dependency[];
10
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Dependency inference.
3
+ * Infers tool dependencies using deterministic heuristics.
4
+ */
5
+ /**
6
+ * Confidence threshold for dependencies.
7
+ */
8
+ const DEPENDENCY_THRESHOLD = 0.6;
9
+ /**
10
+ * Calculate name similarity between two strings.
11
+ * Returns a score between 0.0 and 1.0.
12
+ */
13
+ function nameSimilarity(name1, name2) {
14
+ const n1 = name1.toLowerCase().trim();
15
+ const n2 = name2.toLowerCase().trim();
16
+ // Exact match
17
+ if (n1 === n2) {
18
+ return 1.0;
19
+ }
20
+ // Partial match (common substring) - check length first to apply substring rule
21
+ const longer = n1.length > n2.length ? n1 : n2;
22
+ const shorter = n1.length > n2.length ? n2 : n1;
23
+ // Check if shorter is a significant substring of longer (>=3 chars = higher confidence)
24
+ if (shorter.length >= 3 && longer.includes(shorter)) {
25
+ return 0.8;
26
+ }
27
+ // One contains the other (but shorter is less than 3 chars, so lower confidence)
28
+ if (n1.includes(n2) || n2.includes(n1)) {
29
+ return 0.7;
30
+ }
31
+ // Word overlap
32
+ const words1 = new Set(n1.split(/\W+/).filter(w => w.length > 2));
33
+ const words2 = new Set(n2.split(/\W+/).filter(w => w.length > 2));
34
+ if (words1.size === 0 || words2.size === 0) {
35
+ return 0.0;
36
+ }
37
+ const intersection = new Set([...words1].filter(w => words2.has(w)));
38
+ const union = new Set([...words1, ...words2]);
39
+ if (union.size === 0) {
40
+ return 0.0;
41
+ }
42
+ return intersection.size / union.size;
43
+ }
44
+ /**
45
+ * Check if two types are compatible.
46
+ */
47
+ function typeCompatible(fromType, toType) {
48
+ // Exact match
49
+ if (fromType === toType) {
50
+ return 0.3;
51
+ }
52
+ // Compatible types
53
+ const compatiblePairs = [
54
+ ['string', 'string'],
55
+ ['number', 'string'],
56
+ ['integer', 'string'],
57
+ ['string', 'enum'],
58
+ ['array', 'string'],
59
+ ['object', 'string'],
60
+ ];
61
+ for (const [from, to] of compatiblePairs) {
62
+ if (fromType === from && (toType === to || toType === 'string')) {
63
+ return 0.2;
64
+ }
65
+ }
66
+ // Incompatible
67
+ if ((fromType === 'string' && toType === 'number') ||
68
+ (fromType === 'number' && toType === 'boolean')) {
69
+ return -0.5;
70
+ }
71
+ return 0.0;
72
+ }
73
+ /**
74
+ * Calculate description token overlap.
75
+ */
76
+ function descriptionOverlap(tokens1, tokens2) {
77
+ if (tokens1.size === 0 || tokens2.size === 0) {
78
+ return 0.0;
79
+ }
80
+ const intersection = new Set([...tokens1].filter(t => tokens2.has(t)));
81
+ const union = new Set([...tokens1, ...tokens2]);
82
+ if (union.size === 0) {
83
+ return 0.0;
84
+ }
85
+ return (intersection.size / union.size) * 0.3;
86
+ }
87
+ /**
88
+ * Infer dependencies between tools.
89
+ */
90
+ export function inferDependencies(tools) {
91
+ const dependencies = [];
92
+ for (const toTool of tools) {
93
+ for (const toField of toTool.inputs) {
94
+ // Check all output fields from all tools
95
+ for (const fromTool of tools) {
96
+ if (fromTool.name === toTool.name) {
97
+ continue; // Skip same tool
98
+ }
99
+ for (const fromField of fromTool.outputs) {
100
+ // Calculate confidence score
101
+ let confidence = 0.0;
102
+ // Name similarity (weight: 0.4)
103
+ const nameSim = nameSimilarity(fromField.name, toField.name);
104
+ confidence += nameSim * 0.4;
105
+ // Type compatibility (weight: 0.3)
106
+ const typeCompat = typeCompatible(fromField.type, toField.type);
107
+ const weightedType = typeCompat * 0.3;
108
+ confidence += weightedType;
109
+ // Description token overlap (weight: 0.3)
110
+ const descOverlap = descriptionOverlap(fromTool.descriptionTokens, toTool.descriptionTokens);
111
+ confidence += descOverlap;
112
+ // Bonus for exact field name match + compatible types
113
+ // This allows confidence to reach >= 0.8 for high-confidence rules
114
+ // Exact name match (1.0) + exact type (0.3) = 0.4 + 0.09 = 0.49
115
+ // With description overlap of 0.2, we get 0.49 + 0.2 = 0.69
116
+ // Bonus derived from type compatibility brings it to 0.8+
117
+ if (nameSim === 1.0 && typeCompat >= 0.2) {
118
+ // Bonus scales with type compatibility (not description overlap, which is already counted)
119
+ const bonus = Math.min(0.15, typeCompat * 0.1 + 0.05);
120
+ confidence += bonus;
121
+ }
122
+ // Clamp confidence to [0.0, 1.0]
123
+ confidence = Math.max(0.0, Math.min(1.0, confidence));
124
+ // Only include if above threshold
125
+ if (confidence >= DEPENDENCY_THRESHOLD) {
126
+ dependencies.push({
127
+ fromTool: fromTool.name,
128
+ fromField: fromField.name,
129
+ toTool: toTool.name,
130
+ toField: toField.name,
131
+ confidence,
132
+ });
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ return dependencies;
139
+ }
140
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Analysis engine exports.
3
+ */
4
+ export * from './types.js';
5
+ export * from './loader.js';
6
+ export * from './normalizer.js';
7
+ export * from './indexer.js';
8
+ export * from './dependencies.js';
9
+ export * from './analyser.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Analysis engine exports.
3
+ */
4
+ export * from './types.js';
5
+ export * from './loader.js';
6
+ export * from './normalizer.js';
7
+ export * from './indexer.js';
8
+ export * from './dependencies.js';
9
+ export * from './analyser.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Index builder.
3
+ * Builds fast lookup indexes for analysis rules.
4
+ */
5
+ import type { ToolSpec, Indexes } from './types.js';
6
+ /**
7
+ * Build indexes from normalized tools.
8
+ */
9
+ export declare function buildIndexes(tools: ToolSpec[]): Indexes;
10
+ //# sourceMappingURL=indexer.d.ts.map