simplify3x-connect 0.0.0-stage → 0.28.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 (363) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -3
  3. package/dist/acText.d.ts +12 -0
  4. package/dist/acText.d.ts.map +1 -0
  5. package/dist/acText.js +44 -0
  6. package/dist/acText.js.map +1 -0
  7. package/dist/adapters/factory.d.ts +25 -0
  8. package/dist/adapters/factory.d.ts.map +1 -0
  9. package/dist/adapters/factory.js +55 -0
  10. package/dist/adapters/factory.js.map +1 -0
  11. package/dist/adapters/http.d.ts +62 -0
  12. package/dist/adapters/http.d.ts.map +1 -0
  13. package/dist/adapters/http.js +138 -0
  14. package/dist/adapters/http.js.map +1 -0
  15. package/dist/adapters/remoteMcp/adapter.d.ts +112 -0
  16. package/dist/adapters/remoteMcp/adapter.d.ts.map +1 -0
  17. package/dist/adapters/remoteMcp/adapter.js +259 -0
  18. package/dist/adapters/remoteMcp/adapter.js.map +1 -0
  19. package/dist/adapters/simplifyqa/adapter.d.ts +1390 -0
  20. package/dist/adapters/simplifyqa/adapter.d.ts.map +1 -0
  21. package/dist/adapters/simplifyqa/adapter.js +9126 -0
  22. package/dist/adapters/simplifyqa/adapter.js.map +1 -0
  23. package/dist/adapters/simplifyqa/apiFailureReason.d.ts +11 -0
  24. package/dist/adapters/simplifyqa/apiFailureReason.d.ts.map +1 -0
  25. package/dist/adapters/simplifyqa/apiFailureReason.js +35 -0
  26. package/dist/adapters/simplifyqa/apiFailureReason.js.map +1 -0
  27. package/dist/adapters/simplifyqa/desktopConditions.d.ts +50 -0
  28. package/dist/adapters/simplifyqa/desktopConditions.d.ts.map +1 -0
  29. package/dist/adapters/simplifyqa/desktopConditions.js +95 -0
  30. package/dist/adapters/simplifyqa/desktopConditions.js.map +1 -0
  31. package/dist/adapters/simplifyqa/executionFailures.d.ts +59 -0
  32. package/dist/adapters/simplifyqa/executionFailures.d.ts.map +1 -0
  33. package/dist/adapters/simplifyqa/executionFailures.js +641 -0
  34. package/dist/adapters/simplifyqa/executionFailures.js.map +1 -0
  35. package/dist/adapters/simplifyqa/failureCategory.d.ts +26 -0
  36. package/dist/adapters/simplifyqa/failureCategory.d.ts.map +1 -0
  37. package/dist/adapters/simplifyqa/failureCategory.js +208 -0
  38. package/dist/adapters/simplifyqa/failureCategory.js.map +1 -0
  39. package/dist/adapters/simplifyqa/failureReport.d.ts +50 -0
  40. package/dist/adapters/simplifyqa/failureReport.d.ts.map +1 -0
  41. package/dist/adapters/simplifyqa/failureReport.js +383 -0
  42. package/dist/adapters/simplifyqa/failureReport.js.map +1 -0
  43. package/dist/adapters/simplifyqa/failureTypes.d.ts +193 -0
  44. package/dist/adapters/simplifyqa/failureTypes.d.ts.map +1 -0
  45. package/dist/adapters/simplifyqa/failureTypes.js +8 -0
  46. package/dist/adapters/simplifyqa/failureTypes.js.map +1 -0
  47. package/dist/adapters/simplifyqa/flow.d.ts +58 -0
  48. package/dist/adapters/simplifyqa/flow.d.ts.map +1 -0
  49. package/dist/adapters/simplifyqa/flow.js +335 -0
  50. package/dist/adapters/simplifyqa/flow.js.map +1 -0
  51. package/dist/adapters/simplifyqa/functionMatch.d.ts +53 -0
  52. package/dist/adapters/simplifyqa/functionMatch.d.ts.map +1 -0
  53. package/dist/adapters/simplifyqa/functionMatch.js +110 -0
  54. package/dist/adapters/simplifyqa/functionMatch.js.map +1 -0
  55. package/dist/adapters/simplifyqa/heal/apply.d.ts +59 -0
  56. package/dist/adapters/simplifyqa/heal/apply.d.ts.map +1 -0
  57. package/dist/adapters/simplifyqa/heal/apply.js +213 -0
  58. package/dist/adapters/simplifyqa/heal/apply.js.map +1 -0
  59. package/dist/adapters/simplifyqa/heal/diagnose.d.ts +24 -0
  60. package/dist/adapters/simplifyqa/heal/diagnose.d.ts.map +1 -0
  61. package/dist/adapters/simplifyqa/heal/diagnose.js +211 -0
  62. package/dist/adapters/simplifyqa/heal/diagnose.js.map +1 -0
  63. package/dist/adapters/simplifyqa/heal/index.d.ts +37 -0
  64. package/dist/adapters/simplifyqa/heal/index.d.ts.map +1 -0
  65. package/dist/adapters/simplifyqa/heal/index.js +83 -0
  66. package/dist/adapters/simplifyqa/heal/index.js.map +1 -0
  67. package/dist/adapters/simplifyqa/heal/plan.d.ts +67 -0
  68. package/dist/adapters/simplifyqa/heal/plan.d.ts.map +1 -0
  69. package/dist/adapters/simplifyqa/heal/plan.js +338 -0
  70. package/dist/adapters/simplifyqa/heal/plan.js.map +1 -0
  71. package/dist/adapters/simplifyqa/heal/store.d.ts +10 -0
  72. package/dist/adapters/simplifyqa/heal/store.d.ts.map +1 -0
  73. package/dist/adapters/simplifyqa/heal/store.js +40 -0
  74. package/dist/adapters/simplifyqa/heal/store.js.map +1 -0
  75. package/dist/adapters/simplifyqa/mapLimit.d.ts +3 -0
  76. package/dist/adapters/simplifyqa/mapLimit.d.ts.map +1 -0
  77. package/dist/adapters/simplifyqa/mapLimit.js +14 -0
  78. package/dist/adapters/simplifyqa/mapLimit.js.map +1 -0
  79. package/dist/adapters/simplifyqa/mapper.d.ts +159 -0
  80. package/dist/adapters/simplifyqa/mapper.d.ts.map +1 -0
  81. package/dist/adapters/simplifyqa/mapper.js +1767 -0
  82. package/dist/adapters/simplifyqa/mapper.js.map +1 -0
  83. package/dist/adapters/simplifyqa/planTree.d.ts +31 -0
  84. package/dist/adapters/simplifyqa/planTree.d.ts.map +1 -0
  85. package/dist/adapters/simplifyqa/planTree.js +110 -0
  86. package/dist/adapters/simplifyqa/planTree.js.map +1 -0
  87. package/dist/adapters/simplifyqa/searchEngine.d.ts +254 -0
  88. package/dist/adapters/simplifyqa/searchEngine.d.ts.map +1 -0
  89. package/dist/adapters/simplifyqa/searchEngine.js +1248 -0
  90. package/dist/adapters/simplifyqa/searchEngine.js.map +1 -0
  91. package/dist/adapters/simplifyqa/searchRegistry.d.ts +117 -0
  92. package/dist/adapters/simplifyqa/searchRegistry.d.ts.map +1 -0
  93. package/dist/adapters/simplifyqa/searchRegistry.js +1664 -0
  94. package/dist/adapters/simplifyqa/searchRegistry.js.map +1 -0
  95. package/dist/adapters/simplifyqa/searchResolve.d.ts +84 -0
  96. package/dist/adapters/simplifyqa/searchResolve.d.ts.map +1 -0
  97. package/dist/adapters/simplifyqa/searchResolve.js +319 -0
  98. package/dist/adapters/simplifyqa/searchResolve.js.map +1 -0
  99. package/dist/adapters/simplifyqa/stepDiagnostics.d.ts +25 -0
  100. package/dist/adapters/simplifyqa/stepDiagnostics.d.ts.map +1 -0
  101. package/dist/adapters/simplifyqa/stepDiagnostics.js +89 -0
  102. package/dist/adapters/simplifyqa/stepDiagnostics.js.map +1 -0
  103. package/dist/adapters/simplifyqa/stepRules.d.ts +91 -0
  104. package/dist/adapters/simplifyqa/stepRules.d.ts.map +1 -0
  105. package/dist/adapters/simplifyqa/stepRules.js +228 -0
  106. package/dist/adapters/simplifyqa/stepRules.js.map +1 -0
  107. package/dist/adapters/types.d.ts +514 -0
  108. package/dist/adapters/types.d.ts.map +1 -0
  109. package/dist/adapters/types.js +2 -0
  110. package/dist/adapters/types.js.map +1 -0
  111. package/dist/adapters/walnut/actionTypes.d.ts +16 -0
  112. package/dist/adapters/walnut/actionTypes.d.ts.map +1 -0
  113. package/dist/adapters/walnut/actionTypes.js +178 -0
  114. package/dist/adapters/walnut/actionTypes.js.map +1 -0
  115. package/dist/adapters/walnut/adapter.d.ts +235 -0
  116. package/dist/adapters/walnut/adapter.d.ts.map +1 -0
  117. package/dist/adapters/walnut/adapter.js +1120 -0
  118. package/dist/adapters/walnut/adapter.js.map +1 -0
  119. package/dist/adapters/walnut/mapper.d.ts +55 -0
  120. package/dist/adapters/walnut/mapper.d.ts.map +1 -0
  121. package/dist/adapters/walnut/mapper.js +364 -0
  122. package/dist/adapters/walnut/mapper.js.map +1 -0
  123. package/dist/cli.d.ts +3 -0
  124. package/dist/cli.d.ts.map +1 -0
  125. package/dist/cli.js +38 -0
  126. package/dist/cli.js.map +1 -0
  127. package/dist/config.d.ts +109 -0
  128. package/dist/config.d.ts.map +1 -0
  129. package/dist/config.js +272 -0
  130. package/dist/config.js.map +1 -0
  131. package/dist/connection.d.ts +105 -0
  132. package/dist/connection.d.ts.map +1 -0
  133. package/dist/connection.js +255 -0
  134. package/dist/connection.js.map +1 -0
  135. package/dist/domain/heal.d.ts +163 -0
  136. package/dist/domain/heal.d.ts.map +1 -0
  137. package/dist/domain/heal.js +55 -0
  138. package/dist/domain/heal.js.map +1 -0
  139. package/dist/domain/types.d.ts +1328 -0
  140. package/dist/domain/types.d.ts.map +1 -0
  141. package/dist/domain/types.js +8 -0
  142. package/dist/domain/types.js.map +1 -0
  143. package/dist/domain/validate.d.ts +3 -0
  144. package/dist/domain/validate.d.ts.map +1 -0
  145. package/dist/domain/validate.js +67 -0
  146. package/dist/domain/validate.js.map +1 -0
  147. package/dist/drafts/apiPatch.d.ts +9 -0
  148. package/dist/drafts/apiPatch.d.ts.map +1 -0
  149. package/dist/drafts/apiPatch.js +27 -0
  150. package/dist/drafts/apiPatch.js.map +1 -0
  151. package/dist/drafts/bulk.d.ts +24 -0
  152. package/dist/drafts/bulk.d.ts.map +1 -0
  153. package/dist/drafts/bulk.js +44 -0
  154. package/dist/drafts/bulk.js.map +1 -0
  155. package/dist/drafts/duplicate.d.ts +12 -0
  156. package/dist/drafts/duplicate.d.ts.map +1 -0
  157. package/dist/drafts/duplicate.js +59 -0
  158. package/dist/drafts/duplicate.js.map +1 -0
  159. package/dist/drafts/store.d.ts +91 -0
  160. package/dist/drafts/store.d.ts.map +1 -0
  161. package/dist/drafts/store.js +244 -0
  162. package/dist/drafts/store.js.map +1 -0
  163. package/dist/gateway.d.ts +37 -0
  164. package/dist/gateway.d.ts.map +1 -0
  165. package/dist/gateway.js +71 -0
  166. package/dist/gateway.js.map +1 -0
  167. package/dist/httpMain.d.ts +3 -0
  168. package/dist/httpMain.d.ts.map +1 -0
  169. package/dist/httpMain.js +20 -0
  170. package/dist/httpMain.js.map +1 -0
  171. package/dist/index.d.ts +3 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +46 -0
  174. package/dist/index.js.map +1 -0
  175. package/dist/initAgents.d.ts +2 -0
  176. package/dist/initAgents.d.ts.map +1 -0
  177. package/dist/initAgents.js +508 -0
  178. package/dist/initAgents.js.map +1 -0
  179. package/dist/log.d.ts +17 -0
  180. package/dist/log.d.ts.map +1 -0
  181. package/dist/log.js +49 -0
  182. package/dist/log.js.map +1 -0
  183. package/dist/mcpResult.d.ts +39 -0
  184. package/dist/mcpResult.d.ts.map +1 -0
  185. package/dist/mcpResult.js +19 -0
  186. package/dist/mcpResult.js.map +1 -0
  187. package/dist/mount.d.ts +33 -0
  188. package/dist/mount.d.ts.map +1 -0
  189. package/dist/mount.js +213 -0
  190. package/dist/mount.js.map +1 -0
  191. package/dist/paramTokens.d.ts +18 -0
  192. package/dist/paramTokens.d.ts.map +1 -0
  193. package/dist/paramTokens.js +50 -0
  194. package/dist/paramTokens.js.map +1 -0
  195. package/dist/projectStore.d.ts +5 -0
  196. package/dist/projectStore.d.ts.map +1 -0
  197. package/dist/projectStore.js +60 -0
  198. package/dist/projectStore.js.map +1 -0
  199. package/dist/requestConnection.d.ts +22 -0
  200. package/dist/requestConnection.d.ts.map +1 -0
  201. package/dist/requestConnection.js +50 -0
  202. package/dist/requestConnection.js.map +1 -0
  203. package/dist/serve.d.ts +10 -0
  204. package/dist/serve.d.ts.map +1 -0
  205. package/dist/serve.js +37 -0
  206. package/dist/serve.js.map +1 -0
  207. package/dist/server.d.ts +41 -0
  208. package/dist/server.d.ts.map +1 -0
  209. package/dist/server.js +370 -0
  210. package/dist/server.js.map +1 -0
  211. package/dist/tools/actionCatalog.d.ts +24 -0
  212. package/dist/tools/actionCatalog.d.ts.map +1 -0
  213. package/dist/tools/actionCatalog.js +56 -0
  214. package/dist/tools/actionCatalog.js.map +1 -0
  215. package/dist/tools/attachment.tools.d.ts +15 -0
  216. package/dist/tools/attachment.tools.d.ts.map +1 -0
  217. package/dist/tools/attachment.tools.js +104 -0
  218. package/dist/tools/attachment.tools.js.map +1 -0
  219. package/dist/tools/backlog.tools.d.ts +13 -0
  220. package/dist/tools/backlog.tools.d.ts.map +1 -0
  221. package/dist/tools/backlog.tools.js +690 -0
  222. package/dist/tools/backlog.tools.js.map +1 -0
  223. package/dist/tools/connection.tools.d.ts +16 -0
  224. package/dist/tools/connection.tools.d.ts.map +1 -0
  225. package/dist/tools/connection.tools.js +120 -0
  226. package/dist/tools/connection.tools.js.map +1 -0
  227. package/dist/tools/defects.tools.d.ts +7 -0
  228. package/dist/tools/defects.tools.d.ts.map +1 -0
  229. package/dist/tools/defects.tools.js +108 -0
  230. package/dist/tools/defects.tools.js.map +1 -0
  231. package/dist/tools/discovery.tools.d.ts +23 -0
  232. package/dist/tools/discovery.tools.d.ts.map +1 -0
  233. package/dist/tools/discovery.tools.js +1746 -0
  234. package/dist/tools/discovery.tools.js.map +1 -0
  235. package/dist/tools/executionPlan.tools.d.ts +14 -0
  236. package/dist/tools/executionPlan.tools.d.ts.map +1 -0
  237. package/dist/tools/executionPlan.tools.js +184 -0
  238. package/dist/tools/executionPlan.tools.js.map +1 -0
  239. package/dist/tools/failure.tools.d.ts +14 -0
  240. package/dist/tools/failure.tools.d.ts.map +1 -0
  241. package/dist/tools/failure.tools.js +65 -0
  242. package/dist/tools/failure.tools.js.map +1 -0
  243. package/dist/tools/formulas.tools.d.ts +7 -0
  244. package/dist/tools/formulas.tools.d.ts.map +1 -0
  245. package/dist/tools/formulas.tools.js +84 -0
  246. package/dist/tools/formulas.tools.js.map +1 -0
  247. package/dist/tools/functionReuse.d.ts +77 -0
  248. package/dist/tools/functionReuse.d.ts.map +1 -0
  249. package/dist/tools/functionReuse.js +384 -0
  250. package/dist/tools/functionReuse.js.map +1 -0
  251. package/dist/tools/gapAnalysis.tools.d.ts +31 -0
  252. package/dist/tools/gapAnalysis.tools.d.ts.map +1 -0
  253. package/dist/tools/gapAnalysis.tools.js +287 -0
  254. package/dist/tools/gapAnalysis.tools.js.map +1 -0
  255. package/dist/tools/heal.tools.d.ts +20 -0
  256. package/dist/tools/heal.tools.d.ts.map +1 -0
  257. package/dist/tools/heal.tools.js +268 -0
  258. package/dist/tools/heal.tools.js.map +1 -0
  259. package/dist/tools/impactAnalysis.tools.d.ts +17 -0
  260. package/dist/tools/impactAnalysis.tools.d.ts.map +1 -0
  261. package/dist/tools/impactAnalysis.tools.js +352 -0
  262. package/dist/tools/impactAnalysis.tools.js.map +1 -0
  263. package/dist/tools/markdown.d.ts +13 -0
  264. package/dist/tools/markdown.d.ts.map +1 -0
  265. package/dist/tools/markdown.js +145 -0
  266. package/dist/tools/markdown.js.map +1 -0
  267. package/dist/tools/objects.tools.d.ts +7 -0
  268. package/dist/tools/objects.tools.d.ts.map +1 -0
  269. package/dist/tools/objects.tools.js +458 -0
  270. package/dist/tools/objects.tools.js.map +1 -0
  271. package/dist/tools/pipeline.tools.d.ts +11 -0
  272. package/dist/tools/pipeline.tools.d.ts.map +1 -0
  273. package/dist/tools/pipeline.tools.js +100 -0
  274. package/dist/tools/pipeline.tools.js.map +1 -0
  275. package/dist/tools/preference.tools.d.ts +15 -0
  276. package/dist/tools/preference.tools.d.ts.map +1 -0
  277. package/dist/tools/preference.tools.js +114 -0
  278. package/dist/tools/preference.tools.js.map +1 -0
  279. package/dist/tools/privileges.tools.d.ts +65 -0
  280. package/dist/tools/privileges.tools.d.ts.map +1 -0
  281. package/dist/tools/privileges.tools.js +186 -0
  282. package/dist/tools/privileges.tools.js.map +1 -0
  283. package/dist/tools/project.tools.d.ts +13 -0
  284. package/dist/tools/project.tools.d.ts.map +1 -0
  285. package/dist/tools/project.tools.js +199 -0
  286. package/dist/tools/project.tools.js.map +1 -0
  287. package/dist/tools/query.tools.d.ts +23 -0
  288. package/dist/tools/query.tools.d.ts.map +1 -0
  289. package/dist/tools/query.tools.js +368 -0
  290. package/dist/tools/query.tools.js.map +1 -0
  291. package/dist/tools/recording.tools.d.ts +58 -0
  292. package/dist/tools/recording.tools.d.ts.map +1 -0
  293. package/dist/tools/recording.tools.js +1050 -0
  294. package/dist/tools/recording.tools.js.map +1 -0
  295. package/dist/tools/recordingNames.d.ts +3 -0
  296. package/dist/tools/recordingNames.d.ts.map +1 -0
  297. package/dist/tools/recordingNames.js +16 -0
  298. package/dist/tools/recordingNames.js.map +1 -0
  299. package/dist/tools/report.tools.d.ts +12 -0
  300. package/dist/tools/report.tools.d.ts.map +1 -0
  301. package/dist/tools/report.tools.js +104 -0
  302. package/dist/tools/report.tools.js.map +1 -0
  303. package/dist/tools/run.tools.d.ts +25 -0
  304. package/dist/tools/run.tools.d.ts.map +1 -0
  305. package/dist/tools/run.tools.js +1295 -0
  306. package/dist/tools/run.tools.js.map +1 -0
  307. package/dist/tools/schemas.d.ts +860 -0
  308. package/dist/tools/schemas.d.ts.map +1 -0
  309. package/dist/tools/schemas.js +220 -0
  310. package/dist/tools/schemas.js.map +1 -0
  311. package/dist/tools/storySync.tools.d.ts +167 -0
  312. package/dist/tools/storySync.tools.d.ts.map +1 -0
  313. package/dist/tools/storySync.tools.js +678 -0
  314. package/dist/tools/storySync.tools.js.map +1 -0
  315. package/dist/tools/suiteManage.tools.d.ts +14 -0
  316. package/dist/tools/suiteManage.tools.d.ts.map +1 -0
  317. package/dist/tools/suiteManage.tools.js +112 -0
  318. package/dist/tools/suiteManage.tools.js.map +1 -0
  319. package/dist/tools/tasks.tools.d.ts +7 -0
  320. package/dist/tools/tasks.tools.d.ts.map +1 -0
  321. package/dist/tools/tasks.tools.js +101 -0
  322. package/dist/tools/tasks.tools.js.map +1 -0
  323. package/dist/tools/tcEditPublisher.d.ts +29 -0
  324. package/dist/tools/tcEditPublisher.d.ts.map +1 -0
  325. package/dist/tools/tcEditPublisher.js +61 -0
  326. package/dist/tools/tcEditPublisher.js.map +1 -0
  327. package/dist/tools/testCaseLint.d.ts +5 -0
  328. package/dist/tools/testCaseLint.d.ts.map +1 -0
  329. package/dist/tools/testCaseLint.js +112 -0
  330. package/dist/tools/testCaseLint.js.map +1 -0
  331. package/dist/tools/testPlan.tools.d.ts +12 -0
  332. package/dist/tools/testPlan.tools.d.ts.map +1 -0
  333. package/dist/tools/testPlan.tools.js +104 -0
  334. package/dist/tools/testPlan.tools.js.map +1 -0
  335. package/dist/tools/testcase.tools.d.ts +86 -0
  336. package/dist/tools/testcase.tools.d.ts.map +1 -0
  337. package/dist/tools/testcase.tools.js +1591 -0
  338. package/dist/tools/testcase.tools.js.map +1 -0
  339. package/dist/tools/testdata.tools.d.ts +7 -0
  340. package/dist/tools/testdata.tools.d.ts.map +1 -0
  341. package/dist/tools/testdata.tools.js +636 -0
  342. package/dist/tools/testdata.tools.js.map +1 -0
  343. package/dist/tools/xlsx.d.ts +8 -0
  344. package/dist/tools/xlsx.d.ts.map +1 -0
  345. package/dist/tools/xlsx.js +113 -0
  346. package/dist/tools/xlsx.js.map +1 -0
  347. package/dist/vendor/actionSignatures.d.ts +117 -0
  348. package/dist/vendor/actionSignatures.d.ts.map +1 -0
  349. package/dist/vendor/actionSignatures.js +420 -0
  350. package/dist/vendor/actionSignatures.js.map +1 -0
  351. package/dist/vendor/logger.d.ts +43 -0
  352. package/dist/vendor/logger.d.ts.map +1 -0
  353. package/dist/vendor/logger.js +184 -0
  354. package/dist/vendor/logger.js.map +1 -0
  355. package/dist/version.d.ts +10 -0
  356. package/dist/version.d.ts.map +1 -0
  357. package/dist/version.js +10 -0
  358. package/dist/version.js.map +1 -0
  359. package/dist/versionName.d.ts +21 -0
  360. package/dist/versionName.d.ts.map +1 -0
  361. package/dist/versionName.js +48 -0
  362. package/dist/versionName.js.map +1 -0
  363. package/package.json +62 -6
@@ -0,0 +1,690 @@
1
+ import { z } from 'zod';
2
+ import { ok, err } from '../mcpResult.js';
3
+ const NOT_CONNECTED = 'Not connected to a product. Use qa_connect first — backlog CRUD needs a live backend.';
4
+ function describeError(e) {
5
+ return e instanceof Error ? e.message : String(e);
6
+ }
7
+ function escCell(v) {
8
+ return String(v ?? '').replace(/\|/g, '\\|').replace(/\r?\n/g, ' ');
9
+ }
10
+ function totalOf(rows) {
11
+ const t = rows.totalCount;
12
+ return typeof t === 'number' ? t : undefined;
13
+ }
14
+ function countHeader(rows, singular, plural = singular + 's') {
15
+ const shown = rows.length;
16
+ const total = totalOf(rows) ?? shown;
17
+ const word = total === 1 ? singular : plural;
18
+ return total > shown ? `Showing ${shown} of ${total} ${word}` : `${total} ${word}`;
19
+ }
20
+ // ---------------------------------------------------------------------------
21
+ // Shared user-filter fields (matches story_list) — passed to every list tool.
22
+ // ---------------------------------------------------------------------------
23
+ const userFilterShape = {
24
+ createdBy: z.string().optional().describe('Numeric userId of the creator. Pass "me" to filter by the current caller. Resolve names via list_users first.'),
25
+ updatedBy: z.string().optional().describe('Numeric userId of the last updater. Pass "me" for the current caller. Resolve names via list_users first.'),
26
+ ownerId: z.string().optional().describe('Numeric userId of the owner (assignee). Pass "me" for the current caller. Resolve names via list_users first.'),
27
+ };
28
+ export function registerBacklogTools(server, deps) {
29
+ // ------------------------------------------------------------------------- Epics
30
+ server.registerTool('epic_list', {
31
+ title: 'List / search epics',
32
+ description: 'Pull up EPICS in the connected project — id, key (EP_…), name, state. Top of the backlog ' +
33
+ 'hierarchy: epic → feature → story. Use `search` for keyword matches on name. Requires a live ' +
34
+ 'connection. Read-only.',
35
+ inputSchema: {
36
+ search: z.string().optional().describe('Keyword match on epic name.'),
37
+ state: z.string().optional().describe('Filter by state (must match the project state config).'),
38
+ limit: z.number().int().positive().optional(),
39
+ offset: z.number().int().nonnegative().optional(),
40
+ ...userFilterShape,
41
+ },
42
+ annotations: { readOnlyHint: true },
43
+ }, async ({ search, state, limit, offset, createdBy, updatedBy, ownerId }) => {
44
+ const adapter = deps.getAdapter();
45
+ if (!adapter)
46
+ return err(NOT_CONNECTED);
47
+ if (!adapter.listEpics)
48
+ return err('This product does not expose epics.');
49
+ try {
50
+ const rows = await adapter.listEpics({
51
+ ...(search ? { search } : {}),
52
+ ...(state ? { state } : {}),
53
+ ...(limit != null ? { limit } : {}),
54
+ ...(offset != null ? { offset } : {}),
55
+ ...(createdBy ? { createdBy } : {}),
56
+ ...(updatedBy ? { updatedBy } : {}),
57
+ ...(ownerId ? { ownerId } : {}),
58
+ });
59
+ if (!rows.length)
60
+ return ok('No epics found.', { epics: [], totalCount: totalOf(rows) ?? 0 });
61
+ const text = `${countHeader(rows, 'epic')}:\n\n` +
62
+ '| key | name | state |\n|---|---|---|\n' +
63
+ rows.map((e) => `| ${escCell(e.key ?? e.id)} | ${escCell(e.name)} | ${escCell(e.state ?? '-')} |`).join('\n');
64
+ return ok(text, { epics: rows, totalCount: totalOf(rows) ?? rows.length });
65
+ }
66
+ catch (e) {
67
+ return err(describeError(e));
68
+ }
69
+ });
70
+ server.registerTool('epic_get', {
71
+ title: 'Read one epic',
72
+ description: 'Read a single EPIC — name, state, description, dates, effort — by id or business key (EP_123). ' +
73
+ 'Requires a live connection. Read-only.',
74
+ inputSchema: { id: z.string().describe('Epic id or business key (EP_123).') },
75
+ annotations: { readOnlyHint: true },
76
+ }, async ({ id }) => {
77
+ const adapter = deps.getAdapter();
78
+ if (!adapter)
79
+ return err(NOT_CONNECTED);
80
+ if (!adapter.getEpic)
81
+ return err('This product does not expose epics.');
82
+ try {
83
+ const epic = await adapter.getEpic(id);
84
+ const header = `**${epic.name}**${epic.key ? ` · ${epic.key}` : ''}${epic.state ? ` · ${epic.state}` : ''}`;
85
+ const desc = epic.description ? `\n\n${epic.description}` : '';
86
+ const dates = (epic.plannedStartDate || epic.plannedEndDate)
87
+ ? `\n\n_Planned:_ ${epic.plannedStartDate ?? '—'} → ${epic.plannedEndDate ?? '—'}`
88
+ : '';
89
+ return ok(`${header}${desc}${dates}`, { epic });
90
+ }
91
+ catch (e) {
92
+ return err(describeError(e));
93
+ }
94
+ });
95
+ server.registerTool('epic_create', {
96
+ title: 'Create an epic',
97
+ description: 'Create a new EPIC in the connected project. `projectIds` defaults to the current project when ' +
98
+ 'omitted. `state` defaults to the project-configured default state when omitted; pass it only ' +
99
+ 'when overriding (must match an existing state in the project config — see epic_list / epic_get). ' +
100
+ 'Backend requires `name`, `estimatedEffort`, `plannedStartDate`, `plannedEndDate`. ' +
101
+ '**`description` must be a DETAILED epic write-up as HTML (NOT markdown) derived from the ' +
102
+ 'source document (BRD, spec, user request). SQA UI renders this via a Tiptap editor and stores ' +
103
+ 'raw HTML — see the description field docstring for the exact allowed tags and required ' +
104
+ 'section structure. One-line summaries are not acceptable.** `customFields` may be omitted — ' +
105
+ 'an empty object is sent automatically.',
106
+ inputSchema: {
107
+ name: z.string().min(3).max(500).describe('Epic name (3–500 chars).'),
108
+ estimatedEffort: z.number().nonnegative().describe('Estimated effort (hours).'),
109
+ plannedStartDate: z.string().describe('ISO date/datetime for planned start.'),
110
+ plannedEndDate: z.string().describe('ISO date/datetime for planned end.'),
111
+ state: z.string().optional().describe('Optional. Defaults to the project-configured default epic state when omitted.'),
112
+ projectIds: z.array(z.number()).optional().describe('Project ids the epic belongs to. Defaults to [currentProject].'),
113
+ ownerId: z.number().optional().describe('Numeric userId of the epic owner.'),
114
+ description: z.string().optional().describe([
115
+ 'REQUIRED-QUALITY: rich HTML write-up sourced from the BRD/spec. NOT markdown — the SQA UI ',
116
+ 'renders this through a Tiptap editor and stores the raw HTML string. Minimum 300 words when ',
117
+ 'a BRD is available; NEVER a one-line summary.',
118
+ '',
119
+ 'ALLOWED tags ONLY (anything else is stripped by the editor sanitizer): <p>, <br>, <h1>–<h6>, ',
120
+ '<strong>, <em>, <u>, <s>, <mark>, <code>, <pre>, <blockquote>, <hr>, <ul>, <ol>, <li>, <a>, ',
121
+ '<img>, <table>, <thead>, <tbody>, <tr>, <th>, <td>, <span>. Do NOT emit markdown syntax ',
122
+ '(`##`, `**`, `- `, backtick-code-fences) — the editor will not render it.',
123
+ '',
124
+ 'Follow this structure — omit a section only if the BRD has nothing for it. Every heading is ',
125
+ 'an <h2>; every bulleted point is an <li> inside <ul>:',
126
+ '',
127
+ '<h2>Overview</h2><p>2–4 sentences framing the epic — the business capability it delivers.</p>',
128
+ '<h2>Business Goals</h2><ul><li>One goal per bullet, quoting BRD numbers/targets verbatim.</li></ul>',
129
+ '<h2>Scope</h2><ul><li>In-scope items. Preserve requirement IDs like <code>REQ-4.2</code>.</li></ul>',
130
+ '<h2>Out of Scope</h2><ul><li>Explicit exclusions from the BRD.</li></ul>',
131
+ '<h2>Stakeholders</h2><ul><li>Owner, sponsor, impacted teams.</li></ul>',
132
+ '<h2>Success Metrics</h2><ul><li>KPIs, thresholds, deadlines copied verbatim.</li></ul>',
133
+ '<h2>Dependencies</h2><ul><li>Upstream systems, other epics, external teams.</li></ul>',
134
+ '<h2>Risks</h2><ul><li>Risk — mitigation.</li></ul>',
135
+ '',
136
+ 'Emphasise with <strong>, quote APIs/config keys with <code>, escape a real requirement in ',
137
+ '<blockquote> when it carries contractual weight.',
138
+ ].join('\n')),
139
+ tags: z.array(z.string()).optional(),
140
+ teamId: z.array(z.number()).optional(),
141
+ actualStartDate: z.string().optional(),
142
+ actualEndDate: z.string().optional(),
143
+ actualEffort: z.number().optional(),
144
+ remainingEffort: z.number().optional(),
145
+ plannedBudget: z.number().optional(),
146
+ watchList: z.array(z.union([z.string(), z.number()])).optional().describe('Watch List (the UI email button): emails, full names or numeric userIds to receive notifications. Applied after creation.'),
147
+ customFields: z.record(z.string(), z.unknown()).optional().describe('Optional. Empty object `{}` sent automatically when omitted.'),
148
+ },
149
+ }, async (input) => {
150
+ const adapter = deps.getAdapter();
151
+ if (!adapter)
152
+ return err(NOT_CONNECTED);
153
+ if (!adapter.createEpic)
154
+ return err('This product does not expose epic creation.');
155
+ try {
156
+ const { watchList, ...payload } = input;
157
+ const ref = await adapter.createEpic(payload);
158
+ if (watchList?.length && adapter.addWatchListUsers) {
159
+ await adapter.addWatchListUsers({ entityType: 'epic', itemId: ref.id, users: watchList });
160
+ }
161
+ return ok(`Created epic \`${ref.id}\`${watchList?.length ? ' with the Watch List set' : ''}.`, { savedRef: ref });
162
+ }
163
+ catch (e) {
164
+ return err(describeError(e));
165
+ }
166
+ });
167
+ server.registerTool('epic_update', {
168
+ title: 'Update an epic (partial)',
169
+ description: 'PATCH an existing EPIC — pass only the fields to change plus `updateVersion` (optimistic ' +
170
+ 'concurrency, from the last epic_get). Accepts id or business key (EP_123). ' +
171
+ 'Cannot rename the epic to a duplicate of another epic in the same customer.',
172
+ inputSchema: {
173
+ id: z.string().describe('Epic id or business key (EP_123).'),
174
+ name: z.string().min(3).max(500).optional(),
175
+ state: z.string().optional(),
176
+ estimatedEffort: z.number().optional(),
177
+ plannedStartDate: z.string().optional(),
178
+ plannedEndDate: z.string().optional(),
179
+ projectIds: z.array(z.number()).optional(),
180
+ ownerId: z.number().optional(),
181
+ description: z.string().optional(),
182
+ tags: z.array(z.string()).optional(),
183
+ teamId: z.array(z.number()).optional(),
184
+ actualStartDate: z.string().optional(),
185
+ actualEndDate: z.string().optional(),
186
+ actualEffort: z.number().optional(),
187
+ remainingEffort: z.number().optional(),
188
+ plannedBudget: z.number().optional(),
189
+ customFields: z.record(z.string(), z.unknown()).optional(),
190
+ updateVersion: z.number().optional().describe('Optimistic-concurrency version from the last read.'),
191
+ },
192
+ }, async ({ id, ...patch }) => {
193
+ const adapter = deps.getAdapter();
194
+ if (!adapter)
195
+ return err(NOT_CONNECTED);
196
+ if (!adapter.updateEpic)
197
+ return err('This product does not expose epic updates.');
198
+ try {
199
+ const ref = await adapter.updateEpic(id, patch);
200
+ return ok(`Updated epic \`${ref.id || id}\`.`, { savedRef: ref });
201
+ }
202
+ catch (e) {
203
+ return err(describeError(e));
204
+ }
205
+ });
206
+ // ------------------------------------------------------------------------- Features
207
+ server.registerTool('feature_list', {
208
+ title: 'List / search features',
209
+ description: 'Pull up FEATURES in the connected project — id, key (FT_…), name, state, parent epic. Middle ' +
210
+ 'of the backlog hierarchy. Pass `epicId` to list features under a specific epic. Requires a ' +
211
+ 'live connection. Read-only.',
212
+ inputSchema: {
213
+ search: z.string().optional().describe('Keyword match on feature name.'),
214
+ state: z.string().optional(),
215
+ epicId: z.string().optional().describe('Only features under this parent epic id.'),
216
+ limit: z.number().int().positive().optional(),
217
+ offset: z.number().int().nonnegative().optional(),
218
+ ...userFilterShape,
219
+ },
220
+ annotations: { readOnlyHint: true },
221
+ }, async ({ search, state, epicId, limit, offset, createdBy, updatedBy, ownerId }) => {
222
+ const adapter = deps.getAdapter();
223
+ if (!adapter)
224
+ return err(NOT_CONNECTED);
225
+ if (!adapter.listFeatures)
226
+ return err('This product does not expose features.');
227
+ try {
228
+ const rows = await adapter.listFeatures({
229
+ ...(search ? { search } : {}),
230
+ ...(state ? { state } : {}),
231
+ ...(epicId ? { epicId } : {}),
232
+ ...(limit != null ? { limit } : {}),
233
+ ...(offset != null ? { offset } : {}),
234
+ ...(createdBy ? { createdBy } : {}),
235
+ ...(updatedBy ? { updatedBy } : {}),
236
+ ...(ownerId ? { ownerId } : {}),
237
+ });
238
+ if (!rows.length)
239
+ return ok('No features found.', { features: [], totalCount: totalOf(rows) ?? 0 });
240
+ const text = `${countHeader(rows, 'feature')}:\n\n` +
241
+ '| key | name | state | epicId |\n|---|---|---|---|\n' +
242
+ rows.map((f) => `| ${escCell(f.key ?? f.id)} | ${escCell(f.name)} | ${escCell(f.state ?? '-')} | ${escCell(f.epicId ?? '-')} |`).join('\n');
243
+ return ok(text, { features: rows, totalCount: totalOf(rows) ?? rows.length });
244
+ }
245
+ catch (e) {
246
+ return err(describeError(e));
247
+ }
248
+ });
249
+ server.registerTool('feature_get', {
250
+ title: 'Read one feature',
251
+ description: 'Read a single FEATURE by id or business key (FT_123). Requires a live connection. Read-only.',
252
+ inputSchema: { id: z.string().describe('Feature id or business key (FT_123).') },
253
+ annotations: { readOnlyHint: true },
254
+ }, async ({ id }) => {
255
+ const adapter = deps.getAdapter();
256
+ if (!adapter)
257
+ return err(NOT_CONNECTED);
258
+ if (!adapter.getFeature)
259
+ return err('This product does not expose features.');
260
+ try {
261
+ const feature = await adapter.getFeature(id);
262
+ const header = `**${feature.name}**${feature.key ? ` · ${feature.key}` : ''}${feature.state ? ` · ${feature.state}` : ''}`;
263
+ const desc = feature.description ? `\n\n${feature.description}` : '';
264
+ const parent = feature.epicId ? `\n\n_Parent epic:_ ${feature.epicId}` : '';
265
+ return ok(`${header}${desc}${parent}`, { feature });
266
+ }
267
+ catch (e) {
268
+ return err(describeError(e));
269
+ }
270
+ });
271
+ server.registerTool('feature_create', {
272
+ title: 'Create a feature',
273
+ description: 'Create a new FEATURE. `projectIds` defaults to the current project when omitted.\n\n' +
274
+ '**HIERARCHY — ALWAYS RESOLVE BEFORE CALLING.** Features live under Epics. Before calling ' +
275
+ 'this tool, confirm with the user which `epicId` this feature belongs to. If the user has ' +
276
+ 'not told you: (1) ask them directly, or (2) if they name an epic, resolve the id via ' +
277
+ '`epic_list`. When creating MULTIPLE features from a BRD, group them under the correct ' +
278
+ 'epic — do not scatter them. Skip epic linking only if the user explicitly says "no epic" or ' +
279
+ '"standalone feature".\n\n' +
280
+ '`state` and `priority` default to the project-configured defaults when omitted; pass them ' +
281
+ 'only when overriding. Backend requires `name`, `estimatedEffort`, `plannedStartDate`, ' +
282
+ '`plannedEndDate`. **`description` must be a DETAILED feature write-up as HTML (NOT ' +
283
+ 'markdown) — SQA UI renders it via a Tiptap editor. See the description field docstring for ' +
284
+ 'the exact allowed tags and required section structure. One-line summaries are not ' +
285
+ 'acceptable.** `customFields` may be omitted — an empty object is sent automatically.',
286
+ inputSchema: {
287
+ name: z.string().min(3).max(500),
288
+ estimatedEffort: z.number().nonnegative(),
289
+ plannedStartDate: z.string(),
290
+ plannedEndDate: z.string(),
291
+ projectIds: z.array(z.number()).optional(),
292
+ epicId: z.number().optional().describe('Parent epic numeric id. RESOLVE VIA `epic_list` OR ASK THE USER before creating — do not ' +
293
+ 'leave a feature parent-less unless the user explicitly says "no epic".'),
294
+ orphan: z.boolean().optional().describe('Set true ONLY if the user has explicitly said the feature has no parent epic ("standalone", ' +
295
+ '"no epic"). Required when `epicId` is omitted — the tool refuses otherwise.'),
296
+ state: z.string().optional().describe('Optional. Defaults to the project-configured default feature state when omitted.'),
297
+ priority: z.string().optional().describe('Optional. Defaults to the project-configured default feature priority when omitted.'),
298
+ ownerId: z.number().optional(),
299
+ description: z.string().optional().describe([
300
+ 'REQUIRED-QUALITY: rich HTML write-up sourced from the BRD/spec. NOT markdown — the SQA UI ',
301
+ 'renders through a Tiptap editor and stores raw HTML. Minimum 250 words when the BRD covers ',
302
+ 'this feature; NEVER a one-line summary.',
303
+ '',
304
+ 'ALLOWED tags ONLY: <p>, <br>, <h1>–<h6>, <strong>, <em>, <u>, <s>, <mark>, <code>, <pre>, ',
305
+ '<blockquote>, <hr>, <ul>, <ol>, <li>, <a>, <img>, <table>, <thead>, <tbody>, <tr>, <th>, ',
306
+ '<td>, <span>. Do NOT emit markdown syntax (`##`, `**`, `- `, code fences).',
307
+ '',
308
+ 'Structure (each heading as <h2>, bullets as <ul><li>…):',
309
+ '<h2>Overview</h2><p>2–3 sentences on what the feature is and who it is for.</p>',
310
+ '<h2>User Value</h2><ul><li>Why users need this. Preserve BRD phrasing.</li></ul>',
311
+ '<h2>Functional Requirements</h2><ul><li>Every requirement the BRD spells out — one per <li>. Do not ',
312
+ 'summarise multiple into one bullet.</li></ul>',
313
+ '<h2>UI / UX Notes</h2><ul><li>Screens, fields, empty states, error surfaces from the BRD.</li></ul>',
314
+ '<h2>Non-Functional Requirements</h2><ul><li>Performance, security, a11y, i18n — quote thresholds verbatim (e.g. <code>&lt; 200ms p95</code>).</li></ul>',
315
+ '<h2>Acceptance Signals</h2><ul><li>High-level "done when …" — leave fine-grained Given/When/Then for story acceptanceCriteria.</li></ul>',
316
+ '<h2>Dependencies</h2><ul><li>APIs, other features, third-party services.</li></ul>',
317
+ '',
318
+ '<code> for API paths / field names, <strong> for defined terms, <blockquote> for contractual quotes.',
319
+ ].join('\n')),
320
+ tags: z.array(z.number()).optional(),
321
+ teamId: z.array(z.number()).optional(),
322
+ actualStartDate: z.string().optional(),
323
+ actualEndDate: z.string().optional(),
324
+ actualEffort: z.number().optional(),
325
+ remainingEffort: z.number().optional(),
326
+ customFields: z.record(z.string(), z.unknown()).optional().describe('Optional. Empty object `{}` sent automatically when omitted.'),
327
+ watchList: z.array(z.union([z.string(), z.number()])).optional().describe('Watch List (the UI email button): emails, full names or numeric userIds to receive notifications. Applied after creation.'),
328
+ },
329
+ }, async (input) => {
330
+ const adapter = deps.getAdapter();
331
+ if (!adapter)
332
+ return err(NOT_CONNECTED);
333
+ if (!adapter.createFeature)
334
+ return err('This product does not expose feature creation.');
335
+ if (input.epicId == null && input.orphan !== true) {
336
+ return err('HIERARCHY REQUIRED: no `epicId` provided. Before creating, ASK the user which epic this ' +
337
+ 'feature belongs to — offer (a) create a new epic first via `epic_create`, or (b) pick an ' +
338
+ 'existing one (list by name via `epic_list`). Only re-call with `orphan: true` if the user ' +
339
+ 'explicitly says "no epic" / "standalone".');
340
+ }
341
+ try {
342
+ const { orphan: _orphan, watchList, ...payload } = input;
343
+ const ref = await adapter.createFeature(payload);
344
+ if (watchList?.length && adapter.addWatchListUsers) {
345
+ await adapter.addWatchListUsers({ entityType: 'feature', itemId: ref.id, users: watchList });
346
+ }
347
+ return ok(`Created feature \`${ref.id}\`${watchList?.length ? ' with the Watch List set' : ''}.`, { savedRef: ref });
348
+ }
349
+ catch (e) {
350
+ return err(describeError(e));
351
+ }
352
+ });
353
+ server.registerTool('feature_update', {
354
+ title: 'Update a feature (partial)',
355
+ description: 'PATCH an existing FEATURE — pass only the fields to change plus `updateVersion` (optimistic ' +
356
+ 'concurrency, from the last feature_get). Accepts id or business key (FT_123).',
357
+ inputSchema: {
358
+ id: z.string().describe('Feature id or business key (FT_123).'),
359
+ name: z.string().min(3).max(500).optional(),
360
+ estimatedEffort: z.number().optional(),
361
+ plannedStartDate: z.string().optional(),
362
+ plannedEndDate: z.string().optional(),
363
+ projectIds: z.array(z.number()).optional(),
364
+ epicId: z.number().optional(),
365
+ state: z.string().optional(),
366
+ priority: z.string().optional(),
367
+ ownerId: z.number().optional(),
368
+ description: z.string().optional(),
369
+ tags: z.array(z.number()).optional(),
370
+ teamId: z.array(z.number()).optional(),
371
+ actualStartDate: z.string().optional(),
372
+ actualEndDate: z.string().optional(),
373
+ actualEffort: z.number().optional(),
374
+ remainingEffort: z.number().optional(),
375
+ customFields: z.record(z.string(), z.unknown()).optional(),
376
+ updateVersion: z.number().optional(),
377
+ },
378
+ }, async ({ id, ...patch }) => {
379
+ const adapter = deps.getAdapter();
380
+ if (!adapter)
381
+ return err(NOT_CONNECTED);
382
+ if (!adapter.updateFeature)
383
+ return err('This product does not expose feature updates.');
384
+ try {
385
+ const ref = await adapter.updateFeature(id, patch);
386
+ return ok(`Updated feature \`${ref.id || id}\`.`, { savedRef: ref });
387
+ }
388
+ catch (e) {
389
+ return err(describeError(e));
390
+ }
391
+ });
392
+ // ------------------------------------------------------------------------- Stories (write)
393
+ server.registerTool('story_create', {
394
+ title: 'Create a user story',
395
+ description: 'Create a new USER STORY under the connected project. `projectId` defaults to the current ' +
396
+ 'project.\n\n' +
397
+ '**HIERARCHY — ALWAYS RESOLVE BEFORE CALLING.** A story lives under Epic → Feature → Story. ' +
398
+ 'Do NOT create orphan stories. Before calling this tool, confirm with the user which ' +
399
+ '`epicId` and/or `featureId` the story belongs to. If the user has not told you: (1) ask ' +
400
+ 'them directly, or (2) if they name a parent, resolve the id via `epic_list` / `feature_list` ' +
401
+ 'first. When creating MULTIPLE stories from a BRD, group them under the same parent unless ' +
402
+ 'the BRD clearly splits them across features. Only skip parent linking if the user explicitly ' +
403
+ 'says "no parent" or "standalone".\n\n' +
404
+ '`state` and `priority` default to the project-configured defaults when omitted; pass them ' +
405
+ 'only when overriding. Backend requires `name`, `estimatedEffort`. **`description` and ' +
406
+ '`acceptanceCriteria` must BOTH be HTML (NOT markdown) — SQA UI renders them via a Tiptap ' +
407
+ 'editor and persists raw HTML. See each field docstring below for the exact allowed tags, ' +
408
+ 'required section structure, and Given/When/Then format for AC. One-line descriptions and ' +
409
+ '3-line AC lists are not acceptable.** `customFields` may be omitted — an empty object is ' +
410
+ 'sent automatically.',
411
+ inputSchema: {
412
+ name: z.string().min(3).max(500),
413
+ estimatedEffort: z.number().nonnegative(),
414
+ state: z.string().optional().describe('Optional. Defaults to the project-configured default story state when omitted.'),
415
+ projectId: z.number().optional().describe('Defaults to the connected project.'),
416
+ epicId: z.number().optional().describe('Parent epic numeric id. RESOLVE VIA `epic_list` OR ASK THE USER before creating — do not ' +
417
+ 'leave a story parent-less unless the user explicitly says "no parent".'),
418
+ featureId: z.number().optional().describe('Parent feature numeric id. RESOLVE VIA `feature_list` OR ASK THE USER before creating — a ' +
419
+ 'story typically lives under a feature. Skip only if the user explicitly says "no feature".'),
420
+ orphan: z.boolean().optional().describe('Set true ONLY if the user has explicitly said the story has no parent ("standalone", "no ' +
421
+ 'epic/feature"). Required when BOTH `epicId` and `featureId` are omitted — the tool refuses ' +
422
+ 'otherwise so orphan stories cannot be created silently from a BRD/BRS prompt.'),
423
+ moduleId: z.number().optional(),
424
+ releaseId: z.number().optional(),
425
+ iterationId: z.number().optional().describe('Sprint numeric id (SQA `iterationId`).'),
426
+ acceptanceCriteria: z.string().optional().describe([
427
+ 'REQUIRED-QUALITY: comprehensive Given/When/Then criteria as HTML (SQA UI renders through a ',
428
+ 'Tiptap editor). Use <ul><li>…</li></ul> — one AC per <li>. Aim for 5–15 criteria; a BRD ',
429
+ 'with 3 acceptance lines is a smell — expand implicit signals. Cover happy path, at least ',
430
+ 'one alternative flow, error/validation cases, permission/role edges, boundary values.',
431
+ '',
432
+ 'Format per <li>: "<strong>Given</strong> &lt;precondition&gt; <strong>When</strong> ',
433
+ '&lt;action&gt; <strong>Then</strong> &lt;observable outcome&gt;". Concrete example:',
434
+ '',
435
+ '<ul>',
436
+ ' <li><strong>Given</strong> a user with an unverified email <strong>When</strong> they submit the login form <strong>Then</strong> the system displays <code>Verify your email</code> and does not create a session</li>',
437
+ ' <li><strong>Given</strong> a user with 5 failed login attempts in the last 15 minutes <strong>When</strong> they submit valid credentials <strong>Then</strong> the system responds <code>429</code> and locks the account for 30 minutes</li>',
438
+ '</ul>',
439
+ '',
440
+ 'Do NOT emit markdown. Allowed tags: same allowlist as description. AVOID vague criteria ',
441
+ '("Login works", "Errors are handled") — every <li> must be independently testable.',
442
+ ].join('\n')),
443
+ description: z.string().optional().describe([
444
+ 'REQUIRED-QUALITY: rich HTML write-up sourced from the BRD/spec. NOT markdown — SQA UI ',
445
+ 'stores raw HTML from a Tiptap editor. Minimum 200 words when the BRD covers this story.',
446
+ '',
447
+ 'ALLOWED tags ONLY: <p>, <br>, <h1>–<h6>, <strong>, <em>, <u>, <s>, <mark>, <code>, <pre>, ',
448
+ '<blockquote>, <hr>, <ul>, <ol>, <li>, <a>, <img>, <table>, <thead>, <tbody>, <tr>, <th>, ',
449
+ '<td>, <span>. No markdown syntax.',
450
+ '',
451
+ 'Structure:',
452
+ '<h2>Context</h2><p>2–3 sentences framing the story within its feature/epic.</p>',
453
+ '<h2>User Story</h2><p>As a <strong>&lt;persona&gt;</strong> I want <strong>&lt;capability&gt;</strong> so that <strong>&lt;benefit&gt;</strong>.</p>',
454
+ '<h2>Functional Details</h2><ul><li>Every requirement the BRD spells out — one per <li>. Include input formats, validation rules, downstream side effects.</li></ul>',
455
+ '<h2>Edge Cases</h2><ul><li>Empty state, offline, permission denied, concurrent edits, boundary values.</li></ul>',
456
+ '<h2>Non-Functional Requirements</h2><ul><li>Performance / security / a11y constraints, verbatim.</li></ul>',
457
+ '',
458
+ '<code> for field/API/config names, <strong> for defined terms. Preserve BRD numbers.',
459
+ ].join('\n')),
460
+ priority: z.string().optional().describe('Optional. Defaults to the project-configured default story priority when omitted.'),
461
+ ownerId: z.array(z.number()).optional().describe('Numeric userIds of story owners.'),
462
+ tags: z.array(z.number()).optional(),
463
+ teamId: z.array(z.number()).optional(),
464
+ type: z.string().optional(),
465
+ plannedStartDate: z.string().optional(),
466
+ plannedEndDate: z.string().optional(),
467
+ watchList: z.array(z.union([z.string(), z.number()])).optional().describe('Watch List (the UI email button): emails, full names or numeric userIds to receive notifications. Applied after creation.'),
468
+ customFields: z.record(z.string(), z.unknown()).optional().describe('Optional. Empty object `{}` sent automatically when omitted.'),
469
+ },
470
+ }, async (input) => {
471
+ const adapter = deps.getAdapter();
472
+ if (!adapter)
473
+ return err(NOT_CONNECTED);
474
+ if (!adapter.createStory)
475
+ return err('This product does not expose story creation.');
476
+ if (input.epicId == null && input.featureId == null && input.orphan !== true) {
477
+ return err('HIERARCHY REQUIRED: no `epicId` or `featureId` provided. Before creating, ASK the user ' +
478
+ 'which parents this story belongs to — offer two paths: (a) generate the full Epic → ' +
479
+ 'Feature → Story hierarchy (call `epic_create` then `feature_create` then this tool), or ' +
480
+ '(b) pick existing parents (list by NAME via `epic_list` / `feature_list`, then pass their ' +
481
+ 'ids). Only re-call with `orphan: true` if the user explicitly says "no parent" / ' +
482
+ '"standalone". Apply the same ask to sibling stories in this batch — do not create some ' +
483
+ 'linked and some orphaned silently.');
484
+ }
485
+ try {
486
+ const { orphan: _orphan, watchList, ...payload } = input;
487
+ const ref = await adapter.createStory(payload);
488
+ if (watchList?.length && adapter.addWatchListUsers) {
489
+ await adapter.addWatchListUsers({ entityType: 'userstory', itemId: ref.id, users: watchList });
490
+ }
491
+ return ok(`Created story \`${ref.id}\`${watchList?.length ? ' with the Watch List set' : ''}.`, { savedRef: ref });
492
+ }
493
+ catch (e) {
494
+ return err(describeError(e));
495
+ }
496
+ });
497
+ server.registerTool('story_update', {
498
+ title: 'Update a user story (partial)',
499
+ description: 'PATCH an existing USER STORY — pass only the fields to change plus `updateVersion` ' +
500
+ '(optimistic concurrency, from the last story_get). Accepts id or business key (US_123). ' +
501
+ 'Pass `acceptanceCriteria` as a newline-separated string when replacing AC lines.',
502
+ inputSchema: {
503
+ id: z.string().describe('Story id or business key (US_123).'),
504
+ name: z.string().min(3).max(500).optional(),
505
+ state: z.string().optional(),
506
+ estimatedEffort: z.number().optional(),
507
+ projectId: z.number().optional(),
508
+ epicId: z.number().optional(),
509
+ featureId: z.number().optional(),
510
+ moduleId: z.number().optional(),
511
+ releaseId: z.number().optional(),
512
+ iterationId: z.number().optional(),
513
+ acceptanceCriteria: z.string().optional(),
514
+ description: z.string().optional(),
515
+ priority: z.string().optional(),
516
+ ownerId: z.array(z.number()).optional(),
517
+ tags: z.array(z.number()).optional(),
518
+ teamId: z.array(z.number()).optional(),
519
+ type: z.string().optional(),
520
+ plannedStartDate: z.string().optional(),
521
+ plannedEndDate: z.string().optional(),
522
+ customFields: z.record(z.string(), z.unknown()).optional(),
523
+ updateVersion: z.number().optional(),
524
+ },
525
+ }, async ({ id, ...patch }) => {
526
+ const adapter = deps.getAdapter();
527
+ if (!adapter)
528
+ return err(NOT_CONNECTED);
529
+ if (!adapter.updateStory)
530
+ return err('This product does not expose story updates.');
531
+ try {
532
+ const ref = await adapter.updateStory(id, patch);
533
+ return ok(`Updated story \`${ref.id || id}\`.`, { savedRef: ref });
534
+ }
535
+ catch (e) {
536
+ return err(describeError(e));
537
+ }
538
+ });
539
+ const norm = (v) => v.trim().toLowerCase().replace(/[-\s]+/g, '_');
540
+ /** Resolve a name / id / business key to the rows that match EXACTLY, via the kind's list tool. */
541
+ async function findRows(adapter, kind, ref) {
542
+ let rows;
543
+ const q = { search: ref, limit: 50 };
544
+ if (kind === 'epic') {
545
+ if (!adapter.listEpics)
546
+ return 'This product does not expose epics.';
547
+ rows = (await adapter.listEpics(q)).map((r) => ({ id: r.id, label: r.name, keys: [r.id, r.key ?? '', r.name] }));
548
+ }
549
+ else if (kind === 'feature') {
550
+ if (!adapter.listFeatures)
551
+ return 'This product does not expose features.';
552
+ rows = (await adapter.listFeatures(q)).map((r) => ({ id: r.id, label: r.name, keys: [r.id, r.key ?? '', r.name] }));
553
+ }
554
+ else if (kind === 'story') {
555
+ if (!adapter.listStories)
556
+ return 'This product does not expose user stories.';
557
+ rows = (await adapter.listStories(q)).map((r) => ({ id: r.id, label: r.title, keys: [r.id, r.key ?? '', r.title] }));
558
+ }
559
+ else if (kind === 'defect') {
560
+ if (!adapter.listDefects)
561
+ return 'This product does not expose defects.';
562
+ rows = (await adapter.listDefects(q)).map((r) => ({ id: r.id, label: r.title, keys: [r.id, r.code ?? '', r.title] }));
563
+ }
564
+ else {
565
+ if (!adapter.listTasks)
566
+ return 'This product does not expose tasks.';
567
+ rows = (await adapter.listTasks(q)).map((r) => ({ id: r.id, label: r.title, keys: [r.id, r.code ?? '', r.title] }));
568
+ }
569
+ const want = norm(ref);
570
+ const exact = rows.filter((r) => r.keys.some((k) => k && norm(k) === want));
571
+ return { exact, near: rows.filter((r) => !exact.includes(r)).slice(0, 10) };
572
+ }
573
+ server.registerTool('backlog_delete', {
574
+ title: 'Delete an epic / feature / user story / defect / task',
575
+ description: 'DESTRUCTIVE. Delete ONE epic, feature, user story, defect or task. `ref` is the item\'s NAME, ' +
576
+ 'business key (EP_12, FT_3, US_5, DF_7 …) or numeric id — resolved here, the user never supplies an ' +
577
+ 'internal id. TWO-STEP: call WITHOUT `confirm` to get a preview (what will be deleted + anything that ' +
578
+ 'depends on it); show it to the user and ASK; only then call again with `confirm:true`. An item that ' +
579
+ 'still has dependents (an epic with features/stories, a feature/story with children or test cases, ' +
580
+ 'a defect with test cases/tasks) is REFUSED with the blockers listed — nothing cascades. An ambiguous ' +
581
+ 'name lists the matches and deletes nothing. Needs the user\'s delete permission; no agent required. ' +
582
+ 'Requires a live connection.',
583
+ inputSchema: {
584
+ kind: z.enum(['epic', 'feature', 'story', 'defect', 'task']).describe('Which kind of item to delete.'),
585
+ ref: z.string().min(1).describe('Name, business key (EP_/FT_/US_/DF_…) or numeric id of the item.'),
586
+ confirm: z.boolean().optional().describe('Set true ONLY after the user has seen the preview and explicitly confirmed the delete.'),
587
+ },
588
+ annotations: { readOnlyHint: false, destructiveHint: true },
589
+ }, async ({ kind, ref, confirm }) => {
590
+ const adapter = deps.getAdapter();
591
+ if (!adapter)
592
+ return err(NOT_CONNECTED);
593
+ if (!adapter.deleteBacklogItem)
594
+ return err('This product does not support deleting backlog items.');
595
+ try {
596
+ const found = await findRows(adapter, kind, ref);
597
+ if (typeof found === 'string')
598
+ return err(found);
599
+ if (found.exact.length === 0) {
600
+ const hint = found.near.length
601
+ ? `\n\nClosest matches:\n${found.near.map((r) => `- ${r.label} (id ${r.id})`).join('\n')}\n\nNothing was deleted.`
602
+ : ' Nothing was deleted.';
603
+ return err(`No ${kind} matching "${ref}" was found.${hint}`);
604
+ }
605
+ if (found.exact.length > 1) {
606
+ return err(`"${ref}" matches ${found.exact.length} ${kind}s — ambiguous, nothing was deleted. Ask the user which one:\n` +
607
+ found.exact.map((r) => `- ${r.label} (id ${r.id})`).join('\n'));
608
+ }
609
+ const item = found.exact[0];
610
+ const what = `${kind} **${item.label}** (id ${item.id})`;
611
+ const probe = await adapter.deleteBacklogItem({ kind, id: item.id, confirm: false });
612
+ const blockers = probe.dependencies.flatMap((d) => Object.entries(d.counts));
613
+ if (blockers.length) {
614
+ return err(`Cannot delete ${what} — other items still depend on it:\n` +
615
+ blockers.map(([k, ids]) => `- ${k.replace(/Arr$/, '')}: ${ids.length} (ids ${ids.slice(0, 15).join(', ')}${ids.length > 15 ? ', …' : ''})`).join('\n') +
616
+ '\n\nMove or delete those first. Nothing was deleted.');
617
+ }
618
+ if (confirm !== true) {
619
+ return ok(`About to delete ${what}. Nothing else depends on it.\n\n` +
620
+ '**Ask the user to confirm**, then call `backlog_delete` again with `confirm:true`. This cannot be undone from here.', { preview: true, needs: 'confirm', item: { kind, id: item.id, name: item.label } });
621
+ }
622
+ const res = await adapter.deleteBacklogItem({ kind, id: item.id, confirm: true });
623
+ if (!res.deleted) {
624
+ return err(`The product refused to delete ${what} (it reported dependents). Nothing was deleted.`);
625
+ }
626
+ return ok(`Deleted ${what}.`, { deleted: { kind, id: item.id, name: item.label } });
627
+ }
628
+ catch (e) {
629
+ const msg = describeError(e);
630
+ return err(/privilege|authori[sz]|forbidden|401|403/i.test(msg)
631
+ ? `You don't have permission to delete this ${kind}. (${msg})`
632
+ : msg);
633
+ }
634
+ });
635
+ server.registerTool('watch_list_add', {
636
+ title: 'Add members to the Watch List of an epic, feature or user story',
637
+ description: 'Add people to an item\'s WATCH LIST — the same list the UI\'s email button edits. `users` takes ' +
638
+ 'emails, full names or numeric userIds (e.g. ["rohini.k@simplify3x.com"]). Existing watchers are ' +
639
+ 'kept; the item is re-read to confirm. Use it after creating an item, or for an existing one.',
640
+ inputSchema: {
641
+ entityType: z.enum(['epic', 'feature', 'userstory']).describe('Which backlog item.'),
642
+ itemId: z.string().describe('Item id or business key (EP-66, FT-266, US-1326).'),
643
+ users: z.array(z.union([z.string(), z.number()])).min(1)
644
+ .describe('Emails, full names or numeric userIds to add to the Watch List.'),
645
+ },
646
+ }, async ({ entityType, itemId, users }) => {
647
+ const adapter = deps.getAdapter();
648
+ if (!adapter)
649
+ return err(NOT_CONNECTED);
650
+ if (!adapter.addWatchListUsers)
651
+ return err('Watch Lists are available only on a SimplifyQA connection.');
652
+ try {
653
+ const res = await adapter.addWatchListUsers({ entityType, itemId, users });
654
+ return ok(`Watch List of ${entityType} ${itemId} now has user id(s): ${res.users.join(', ') || '(none)'}.`, { entityType, itemId, users: res.users, mailersList: res.mailersList });
655
+ }
656
+ catch (e) {
657
+ return err(describeError(e));
658
+ }
659
+ });
660
+ server.registerTool('backlog_link', {
661
+ title: 'Link an epic / feature / user story to another item (Linkages)',
662
+ description: 'Create a LINK between an epic, feature or user story and another backlog item (defect, epic, ' +
663
+ 'feature, story, task) — the UI\'s Linkages section. `linkType` is a link type name/key such as ' +
664
+ '"Clones" (case-insensitive; the available types are read from the project\'s link-type config ' +
665
+ 'and an unknown one is refused with the list). `destType` is the DESTINATION issue type ' +
666
+ '(e.g. "defect"). The link is saved on the SOURCE item and read back from /pm/linkages to confirm.',
667
+ inputSchema: {
668
+ sourceType: z.enum(['epic', 'feature', 'userstory']).describe('Item that owns the Linkages section.'),
669
+ sourceId: z.string().describe('Source item id or business key (EP-64, FT-266, US-1326).'),
670
+ destType: z.enum(['epic', 'feature', 'userstory', 'defect', 'task']).describe('Destination issue type.'),
671
+ destId: z.string().describe('Destination id or business key (DE-2293).'),
672
+ linkType: z.string().min(1).describe('Link type name or key, e.g. "Clones".'),
673
+ },
674
+ }, async ({ sourceType, sourceId, destType, destId, linkType }) => {
675
+ const adapter = deps.getAdapter();
676
+ if (!adapter)
677
+ return err(NOT_CONNECTED);
678
+ if (!adapter.linkBacklogItem)
679
+ return err('Linkages are available only on a SimplifyQA connection.');
680
+ try {
681
+ const res = await adapter.linkBacklogItem({ sourceType, sourceId, destType, destId, linkType });
682
+ return ok(`Linked ${sourceType} ${sourceId} → ${destType} ${res.destinationCode ?? destId} (${linkType}, key ${res.linkTypeKey}). ` +
683
+ `Links now: ${res.linkedIssues.map((l) => `${l['destinationCode'] ?? l['destinationId']} (${l['linkTypeKey']})`).join(', ') || '(none)'}`, { sourceType, sourceId, destType, destId, linkTypeKey: res.linkTypeKey, links: res.linkedIssues });
684
+ }
685
+ catch (e) {
686
+ return err(describeError(e));
687
+ }
688
+ });
689
+ }
690
+ //# sourceMappingURL=backlog.tools.js.map