@wootsup/yt-builder-mcp 1.1.6 → 1.1.7

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 (397) hide show
  1. package/dist/auth.d.ts +119 -0
  2. package/dist/auth.d.ts.map +1 -0
  3. package/dist/auth.js +226 -0
  4. package/dist/auth.js.map +1 -0
  5. package/dist/client.d.ts +84 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +151 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/clients/claude-code.d.ts +18 -0
  10. package/dist/clients/claude-code.d.ts.map +1 -0
  11. package/dist/clients/claude-code.js +53 -0
  12. package/dist/clients/claude-code.js.map +1 -0
  13. package/dist/clients/claude-desktop.d.ts +19 -0
  14. package/dist/clients/claude-desktop.d.ts.map +1 -0
  15. package/dist/clients/claude-desktop.js +56 -0
  16. package/dist/clients/claude-desktop.js.map +1 -0
  17. package/dist/clients/cline.d.ts +26 -0
  18. package/dist/clients/cline.d.ts.map +1 -0
  19. package/dist/clients/cline.js +80 -0
  20. package/dist/clients/cline.js.map +1 -0
  21. package/dist/clients/codex-cli.d.ts +42 -0
  22. package/dist/clients/codex-cli.d.ts.map +1 -0
  23. package/dist/clients/codex-cli.js +194 -0
  24. package/dist/clients/codex-cli.js.map +1 -0
  25. package/dist/clients/continue.d.ts +13 -0
  26. package/dist/clients/continue.d.ts.map +1 -0
  27. package/dist/clients/continue.js +52 -0
  28. package/dist/clients/continue.js.map +1 -0
  29. package/dist/clients/cursor.d.ts +12 -0
  30. package/dist/clients/cursor.d.ts.map +1 -0
  31. package/dist/clients/cursor.js +38 -0
  32. package/dist/clients/cursor.js.map +1 -0
  33. package/dist/clients/gemini-cli.d.ts +18 -0
  34. package/dist/clients/gemini-cli.d.ts.map +1 -0
  35. package/dist/clients/gemini-cli.js +44 -0
  36. package/dist/clients/gemini-cli.js.map +1 -0
  37. package/dist/clients/home.d.ts +14 -0
  38. package/dist/clients/home.d.ts.map +1 -0
  39. package/dist/clients/home.js +20 -0
  40. package/dist/clients/home.js.map +1 -0
  41. package/dist/clients/index.d.ts +52 -0
  42. package/dist/clients/index.d.ts.map +1 -0
  43. package/dist/clients/index.js +72 -0
  44. package/dist/clients/index.js.map +1 -0
  45. package/dist/clients/roo-code.d.ts +23 -0
  46. package/dist/clients/roo-code.d.ts.map +1 -0
  47. package/dist/clients/roo-code.js +69 -0
  48. package/dist/clients/roo-code.js.map +1 -0
  49. package/dist/clients/zed.d.ts +12 -0
  50. package/dist/clients/zed.d.ts.map +1 -0
  51. package/dist/clients/zed.js +41 -0
  52. package/dist/clients/zed.js.map +1 -0
  53. package/dist/errors/hints.d.ts +51 -0
  54. package/dist/errors/hints.d.ts.map +1 -0
  55. package/dist/errors/hints.js +95 -0
  56. package/dist/errors/hints.js.map +1 -0
  57. package/dist/errors/mask.d.ts +35 -0
  58. package/dist/errors/mask.d.ts.map +1 -0
  59. package/dist/errors/mask.js +49 -0
  60. package/dist/errors/mask.js.map +1 -0
  61. package/dist/errors/sanitize.d.ts +31 -0
  62. package/dist/errors/sanitize.d.ts.map +1 -0
  63. package/dist/errors/sanitize.js +100 -0
  64. package/dist/errors/sanitize.js.map +1 -0
  65. package/dist/errors.d.ts +42 -0
  66. package/dist/errors.d.ts.map +1 -0
  67. package/dist/errors.js +61 -0
  68. package/dist/errors.js.map +1 -0
  69. package/dist/gateway/advanced-tool/discovery.d.ts +19 -0
  70. package/dist/gateway/advanced-tool/discovery.d.ts.map +1 -0
  71. package/dist/gateway/advanced-tool/discovery.js +53 -0
  72. package/dist/gateway/advanced-tool/discovery.js.map +1 -0
  73. package/dist/gateway/advanced-tool/domains.d.ts +47 -0
  74. package/dist/gateway/advanced-tool/domains.d.ts.map +1 -0
  75. package/dist/gateway/advanced-tool/domains.js +94 -0
  76. package/dist/gateway/advanced-tool/domains.js.map +1 -0
  77. package/dist/gateway/advanced-tool/execute.d.ts +29 -0
  78. package/dist/gateway/advanced-tool/execute.d.ts.map +1 -0
  79. package/dist/gateway/advanced-tool/execute.js +54 -0
  80. package/dist/gateway/advanced-tool/execute.js.map +1 -0
  81. package/dist/gateway/advanced-tool/index.d.ts +36 -0
  82. package/dist/gateway/advanced-tool/index.d.ts.map +1 -0
  83. package/dist/gateway/advanced-tool/index.js +39 -0
  84. package/dist/gateway/advanced-tool/index.js.map +1 -0
  85. package/dist/gateway/advanced-tool/register.d.ts +18 -0
  86. package/dist/gateway/advanced-tool/register.d.ts.map +1 -0
  87. package/dist/gateway/advanced-tool/register.js +69 -0
  88. package/dist/gateway/advanced-tool/register.js.map +1 -0
  89. package/dist/gateway/advanced-tool.d.ts +13 -0
  90. package/dist/gateway/advanced-tool.d.ts.map +1 -0
  91. package/dist/gateway/advanced-tool.js +13 -0
  92. package/dist/gateway/advanced-tool.js.map +1 -0
  93. package/dist/gateway/capturing-server.d.ts +117 -0
  94. package/dist/gateway/capturing-server.d.ts.map +1 -0
  95. package/dist/gateway/capturing-server.js +103 -0
  96. package/dist/gateway/capturing-server.js.map +1 -0
  97. package/dist/gateway/essentials.d.ts +50 -0
  98. package/dist/gateway/essentials.d.ts.map +1 -0
  99. package/dist/gateway/essentials.js +94 -0
  100. package/dist/gateway/essentials.js.map +1 -0
  101. package/dist/gateway/test-support.d.ts +41 -0
  102. package/dist/gateway/test-support.d.ts.map +1 -0
  103. package/dist/gateway/test-support.js +60 -0
  104. package/dist/gateway/test-support.js.map +1 -0
  105. package/dist/index.d.ts +29 -0
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.js +111 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/install-skill.d.ts +43 -0
  110. package/dist/install-skill.d.ts.map +1 -0
  111. package/dist/install-skill.js +118 -0
  112. package/dist/install-skill.js.map +1 -0
  113. package/dist/platform/detect.d.ts +64 -0
  114. package/dist/platform/detect.d.ts.map +1 -0
  115. package/dist/platform/detect.js +98 -0
  116. package/dist/platform/detect.js.map +1 -0
  117. package/dist/platform/index.d.ts +121 -0
  118. package/dist/platform/index.d.ts.map +1 -0
  119. package/dist/platform/index.js +176 -0
  120. package/dist/platform/index.js.map +1 -0
  121. package/dist/platform/joomla.d.ts +44 -0
  122. package/dist/platform/joomla.d.ts.map +1 -0
  123. package/dist/platform/joomla.js +46 -0
  124. package/dist/platform/joomla.js.map +1 -0
  125. package/dist/server.d.ts +110 -0
  126. package/dist/server.d.ts.map +1 -0
  127. package/dist/server.js +274 -0
  128. package/dist/server.js.map +1 -0
  129. package/dist/setup-cli-confirm.d.ts +36 -0
  130. package/dist/setup-cli-confirm.d.ts.map +1 -0
  131. package/dist/setup-cli-confirm.js +59 -0
  132. package/dist/setup-cli-confirm.js.map +1 -0
  133. package/dist/setup-cli.d.ts +152 -0
  134. package/dist/setup-cli.d.ts.map +1 -0
  135. package/dist/setup-cli.js +870 -0
  136. package/dist/setup-cli.js.map +1 -0
  137. package/dist/setup-prompts.d.ts +41 -0
  138. package/dist/setup-prompts.d.ts.map +1 -0
  139. package/dist/setup-prompts.js +146 -0
  140. package/dist/setup-prompts.js.map +1 -0
  141. package/dist/setup-token.d.ts +38 -0
  142. package/dist/setup-token.d.ts.map +1 -0
  143. package/dist/setup-token.js +106 -0
  144. package/dist/setup-token.js.map +1 -0
  145. package/dist/setup-wizard-defaults.d.ts +43 -0
  146. package/dist/setup-wizard-defaults.d.ts.map +1 -0
  147. package/dist/setup-wizard-defaults.js +160 -0
  148. package/dist/setup-wizard-defaults.js.map +1 -0
  149. package/dist/setup-wizard-handshake.d.ts +25 -0
  150. package/dist/setup-wizard-handshake.d.ts.map +1 -0
  151. package/dist/setup-wizard-handshake.js +103 -0
  152. package/dist/setup-wizard-handshake.js.map +1 -0
  153. package/dist/setup-wizard-types.d.ts +164 -0
  154. package/dist/setup-wizard-types.d.ts.map +1 -0
  155. package/dist/setup-wizard-types.js +11 -0
  156. package/dist/setup-wizard-types.js.map +1 -0
  157. package/dist/setup-wizard.d.ts +33 -0
  158. package/dist/setup-wizard.d.ts.map +1 -0
  159. package/dist/setup-wizard.js +199 -0
  160. package/dist/setup-wizard.js.map +1 -0
  161. package/dist/setup.d.ts +17 -0
  162. package/dist/setup.d.ts.map +1 -0
  163. package/dist/setup.js +33 -0
  164. package/dist/setup.js.map +1 -0
  165. package/dist/sites/cli/add-site.d.ts +106 -0
  166. package/dist/sites/cli/add-site.d.ts.map +1 -0
  167. package/dist/sites/cli/add-site.js +185 -0
  168. package/dist/sites/cli/add-site.js.map +1 -0
  169. package/dist/sites/cli/list-sites.d.ts +40 -0
  170. package/dist/sites/cli/list-sites.d.ts.map +1 -0
  171. package/dist/sites/cli/list-sites.js +116 -0
  172. package/dist/sites/cli/list-sites.js.map +1 -0
  173. package/dist/sites/cli/remove-site.d.ts +60 -0
  174. package/dist/sites/cli/remove-site.d.ts.map +1 -0
  175. package/dist/sites/cli/remove-site.js +120 -0
  176. package/dist/sites/cli/remove-site.js.map +1 -0
  177. package/dist/sites/cli/set-default.d.ts +47 -0
  178. package/dist/sites/cli/set-default.d.ts.map +1 -0
  179. package/dist/sites/cli/set-default.js +69 -0
  180. package/dist/sites/cli/set-default.js.map +1 -0
  181. package/dist/sites/cli/test-site.d.ts +77 -0
  182. package/dist/sites/cli/test-site.d.ts.map +1 -0
  183. package/dist/sites/cli/test-site.js +146 -0
  184. package/dist/sites/cli/test-site.js.map +1 -0
  185. package/dist/sites/client-pool.d.ts +124 -0
  186. package/dist/sites/client-pool.d.ts.map +1 -0
  187. package/dist/sites/client-pool.js +172 -0
  188. package/dist/sites/client-pool.js.map +1 -0
  189. package/dist/sites/env-bridge.d.ts +55 -0
  190. package/dist/sites/env-bridge.d.ts.map +1 -0
  191. package/dist/sites/env-bridge.js +94 -0
  192. package/dist/sites/env-bridge.js.map +1 -0
  193. package/dist/sites/paths.d.ts +21 -0
  194. package/dist/sites/paths.d.ts.map +1 -0
  195. package/dist/sites/paths.js +37 -0
  196. package/dist/sites/paths.js.map +1 -0
  197. package/dist/sites/probe.d.ts +60 -0
  198. package/dist/sites/probe.d.ts.map +1 -0
  199. package/dist/sites/probe.js +112 -0
  200. package/dist/sites/probe.js.map +1 -0
  201. package/dist/sites/registry.d.ts +142 -0
  202. package/dist/sites/registry.d.ts.map +1 -0
  203. package/dist/sites/registry.js +163 -0
  204. package/dist/sites/registry.js.map +1 -0
  205. package/dist/sites/schema.d.ts +90 -0
  206. package/dist/sites/schema.d.ts.map +1 -0
  207. package/dist/sites/schema.js +71 -0
  208. package/dist/sites/schema.js.map +1 -0
  209. package/dist/sites/secret-resolver.d.ts +115 -0
  210. package/dist/sites/secret-resolver.d.ts.map +1 -0
  211. package/dist/sites/secret-resolver.js +225 -0
  212. package/dist/sites/secret-resolver.js.map +1 -0
  213. package/dist/sites/store.d.ts +82 -0
  214. package/dist/sites/store.d.ts.map +1 -0
  215. package/dist/sites/store.js +198 -0
  216. package/dist/sites/store.js.map +1 -0
  217. package/dist/sites/tools/index.d.ts +28 -0
  218. package/dist/sites/tools/index.d.ts.map +1 -0
  219. package/dist/sites/tools/index.js +30 -0
  220. package/dist/sites/tools/index.js.map +1 -0
  221. package/dist/sites/tools/sites-list.d.ts +48 -0
  222. package/dist/sites/tools/sites-list.d.ts.map +1 -0
  223. package/dist/sites/tools/sites-list.js +137 -0
  224. package/dist/sites/tools/sites-list.js.map +1 -0
  225. package/dist/sites/tools/sites-test.d.ts +47 -0
  226. package/dist/sites/tools/sites-test.d.ts.map +1 -0
  227. package/dist/sites/tools/sites-test.js +148 -0
  228. package/dist/sites/tools/sites-test.js.map +1 -0
  229. package/dist/skill-loader.d.ts +111 -0
  230. package/dist/skill-loader.d.ts.map +1 -0
  231. package/dist/skill-loader.js +191 -0
  232. package/dist/skill-loader.js.map +1 -0
  233. package/dist/tools/elements/builders.d.ts +24 -0
  234. package/dist/tools/elements/builders.d.ts.map +1 -0
  235. package/dist/tools/elements/builders.js +199 -0
  236. package/dist/tools/elements/builders.js.map +1 -0
  237. package/dist/tools/elements/handlers-write.d.ts +49 -0
  238. package/dist/tools/elements/handlers-write.d.ts.map +1 -0
  239. package/dist/tools/elements/handlers-write.js +148 -0
  240. package/dist/tools/elements/handlers-write.js.map +1 -0
  241. package/dist/tools/elements/handlers.d.ts +70 -0
  242. package/dist/tools/elements/handlers.d.ts.map +1 -0
  243. package/dist/tools/elements/handlers.js +292 -0
  244. package/dist/tools/elements/handlers.js.map +1 -0
  245. package/dist/tools/elements/index.d.ts +28 -0
  246. package/dist/tools/elements/index.d.ts.map +1 -0
  247. package/dist/tools/elements/index.js +27 -0
  248. package/dist/tools/elements/index.js.map +1 -0
  249. package/dist/tools/elements.d.ts +13 -0
  250. package/dist/tools/elements.d.ts.map +1 -0
  251. package/dist/tools/elements.js +13 -0
  252. package/dist/tools/elements.js.map +1 -0
  253. package/dist/tools/elicitation.d.ts +87 -0
  254. package/dist/tools/elicitation.d.ts.map +1 -0
  255. package/dist/tools/elicitation.js +100 -0
  256. package/dist/tools/elicitation.js.map +1 -0
  257. package/dist/tools/format/elements-format.d.ts +40 -0
  258. package/dist/tools/format/elements-format.d.ts.map +1 -0
  259. package/dist/tools/format/elements-format.js +194 -0
  260. package/dist/tools/format/elements-format.js.map +1 -0
  261. package/dist/tools/format/health-format.d.ts +79 -0
  262. package/dist/tools/format/health-format.d.ts.map +1 -0
  263. package/dist/tools/format/health-format.js +181 -0
  264. package/dist/tools/format/health-format.js.map +1 -0
  265. package/dist/tools/format/inspection-format.d.ts +59 -0
  266. package/dist/tools/format/inspection-format.d.ts.map +1 -0
  267. package/dist/tools/format/inspection-format.js +303 -0
  268. package/dist/tools/format/inspection-format.js.map +1 -0
  269. package/dist/tools/format/pages-format.d.ts +57 -0
  270. package/dist/tools/format/pages-format.d.ts.map +1 -0
  271. package/dist/tools/format/pages-format.js +157 -0
  272. package/dist/tools/format/pages-format.js.map +1 -0
  273. package/dist/tools/format/sources-format.d.ts +44 -0
  274. package/dist/tools/format/sources-format.d.ts.map +1 -0
  275. package/dist/tools/format/sources-format.js +242 -0
  276. package/dist/tools/format/sources-format.js.map +1 -0
  277. package/dist/tools/health.d.ts +22 -0
  278. package/dist/tools/health.d.ts.map +1 -0
  279. package/dist/tools/health.js +220 -0
  280. package/dist/tools/health.js.map +1 -0
  281. package/dist/tools/index.d.ts +30 -0
  282. package/dist/tools/index.d.ts.map +1 -0
  283. package/dist/tools/index.js +39 -0
  284. package/dist/tools/index.js.map +1 -0
  285. package/dist/tools/inspection.d.ts +14 -0
  286. package/dist/tools/inspection.d.ts.map +1 -0
  287. package/dist/tools/inspection.js +208 -0
  288. package/dist/tools/inspection.js.map +1 -0
  289. package/dist/tools/layout-flatten.d.ts +75 -0
  290. package/dist/tools/layout-flatten.d.ts.map +1 -0
  291. package/dist/tools/layout-flatten.js +107 -0
  292. package/dist/tools/layout-flatten.js.map +1 -0
  293. package/dist/tools/multi-items/builders.d.ts +23 -0
  294. package/dist/tools/multi-items/builders.d.ts.map +1 -0
  295. package/dist/tools/multi-items/builders.js +78 -0
  296. package/dist/tools/multi-items/builders.js.map +1 -0
  297. package/dist/tools/multi-items/clean-implode-handler.d.ts +36 -0
  298. package/dist/tools/multi-items/clean-implode-handler.d.ts.map +1 -0
  299. package/dist/tools/multi-items/clean-implode-handler.js +57 -0
  300. package/dist/tools/multi-items/clean-implode-handler.js.map +1 -0
  301. package/dist/tools/multi-items/index.d.ts +18 -0
  302. package/dist/tools/multi-items/index.d.ts.map +1 -0
  303. package/dist/tools/multi-items/index.js +18 -0
  304. package/dist/tools/multi-items/index.js.map +1 -0
  305. package/dist/tools/multi-items/inspect-handler.d.ts +41 -0
  306. package/dist/tools/multi-items/inspect-handler.d.ts.map +1 -0
  307. package/dist/tools/multi-items/inspect-handler.js +50 -0
  308. package/dist/tools/multi-items/inspect-handler.js.map +1 -0
  309. package/dist/tools/multi-items/item-container-map.d.ts +41 -0
  310. package/dist/tools/multi-items/item-container-map.d.ts.map +1 -0
  311. package/dist/tools/multi-items/item-container-map.js +73 -0
  312. package/dist/tools/multi-items/item-container-map.js.map +1 -0
  313. package/dist/tools/pages/builders.d.ts +14 -0
  314. package/dist/tools/pages/builders.d.ts.map +1 -0
  315. package/dist/tools/pages/builders.js +136 -0
  316. package/dist/tools/pages/builders.js.map +1 -0
  317. package/dist/tools/pages/handlers-read.d.ts +33 -0
  318. package/dist/tools/pages/handlers-read.d.ts.map +1 -0
  319. package/dist/tools/pages/handlers-read.js +203 -0
  320. package/dist/tools/pages/handlers-read.js.map +1 -0
  321. package/dist/tools/pages/handlers-write.d.ts +21 -0
  322. package/dist/tools/pages/handlers-write.d.ts.map +1 -0
  323. package/dist/tools/pages/handlers-write.js +52 -0
  324. package/dist/tools/pages/handlers-write.js.map +1 -0
  325. package/dist/tools/pages/index.d.ts +17 -0
  326. package/dist/tools/pages/index.d.ts.map +1 -0
  327. package/dist/tools/pages/index.js +17 -0
  328. package/dist/tools/pages/index.js.map +1 -0
  329. package/dist/tools/pages/schemas.d.ts +45 -0
  330. package/dist/tools/pages/schemas.d.ts.map +1 -0
  331. package/dist/tools/pages/schemas.js +82 -0
  332. package/dist/tools/pages/schemas.js.map +1 -0
  333. package/dist/tools/pages.d.ts +13 -0
  334. package/dist/tools/pages.d.ts.map +1 -0
  335. package/dist/tools/pages.js +13 -0
  336. package/dist/tools/pages.js.map +1 -0
  337. package/dist/tools/pool-resolve-helper.d.ts +83 -0
  338. package/dist/tools/pool-resolve-helper.d.ts.map +1 -0
  339. package/dist/tools/pool-resolve-helper.js +148 -0
  340. package/dist/tools/pool-resolve-helper.js.map +1 -0
  341. package/dist/tools/progress-phases.d.ts +46 -0
  342. package/dist/tools/progress-phases.d.ts.map +1 -0
  343. package/dist/tools/progress-phases.js +48 -0
  344. package/dist/tools/progress-phases.js.map +1 -0
  345. package/dist/tools/shared-schemas.d.ts +25 -0
  346. package/dist/tools/shared-schemas.d.ts.map +1 -0
  347. package/dist/tools/shared-schemas.js +59 -0
  348. package/dist/tools/shared-schemas.js.map +1 -0
  349. package/dist/tools/sources/builders.d.ts +13 -0
  350. package/dist/tools/sources/builders.d.ts.map +1 -0
  351. package/dist/tools/sources/builders.js +118 -0
  352. package/dist/tools/sources/builders.js.map +1 -0
  353. package/dist/tools/sources/handlers-bind.d.ts +28 -0
  354. package/dist/tools/sources/handlers-bind.d.ts.map +1 -0
  355. package/dist/tools/sources/handlers-bind.js +129 -0
  356. package/dist/tools/sources/handlers-bind.js.map +1 -0
  357. package/dist/tools/sources/handlers.d.ts +47 -0
  358. package/dist/tools/sources/handlers.d.ts.map +1 -0
  359. package/dist/tools/sources/handlers.js +108 -0
  360. package/dist/tools/sources/handlers.js.map +1 -0
  361. package/dist/tools/sources/index.d.ts +19 -0
  362. package/dist/tools/sources/index.d.ts.map +1 -0
  363. package/dist/tools/sources/index.js +18 -0
  364. package/dist/tools/sources/index.js.map +1 -0
  365. package/dist/tools/sources.d.ts +14 -0
  366. package/dist/tools/sources.d.ts.map +1 -0
  367. package/dist/tools/sources.js +14 -0
  368. package/dist/tools/sources.js.map +1 -0
  369. package/dist/tools/sparse-fields.d.ts +106 -0
  370. package/dist/tools/sparse-fields.d.ts.map +1 -0
  371. package/dist/tools/sparse-fields.js +165 -0
  372. package/dist/tools/sparse-fields.js.map +1 -0
  373. package/dist/tools/tool-builder/annotations.d.ts +55 -0
  374. package/dist/tools/tool-builder/annotations.d.ts.map +1 -0
  375. package/dist/tools/tool-builder/annotations.js +86 -0
  376. package/dist/tools/tool-builder/annotations.js.map +1 -0
  377. package/dist/tools/tool-builder/define.d.ts +31 -0
  378. package/dist/tools/tool-builder/define.d.ts.map +1 -0
  379. package/dist/tools/tool-builder/define.js +31 -0
  380. package/dist/tools/tool-builder/define.js.map +1 -0
  381. package/dist/tools/tool-builder/index.d.ts +28 -0
  382. package/dist/tools/tool-builder/index.d.ts.map +1 -0
  383. package/dist/tools/tool-builder/index.js +27 -0
  384. package/dist/tools/tool-builder/index.js.map +1 -0
  385. package/dist/tools/tool-builder/results.d.ts +104 -0
  386. package/dist/tools/tool-builder/results.d.ts.map +1 -0
  387. package/dist/tools/tool-builder/results.js +224 -0
  388. package/dist/tools/tool-builder/results.js.map +1 -0
  389. package/dist/tools/tool-builder/types.d.ts +97 -0
  390. package/dist/tools/tool-builder/types.d.ts.map +1 -0
  391. package/dist/tools/tool-builder/types.js +9 -0
  392. package/dist/tools/tool-builder/types.js.map +1 -0
  393. package/dist/tools/tool-builder.d.ts +16 -0
  394. package/dist/tools/tool-builder.d.ts.map +1 -0
  395. package/dist/tools/tool-builder.js +16 -0
  396. package/dist/tools/tool-builder.js.map +1 -0
  397. package/package.json +2 -1
@@ -0,0 +1,870 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Top-level CLI dispatcher for `@wootsup/yt-builder-mcp`.
4
+ *
5
+ * Round-1 audit I5 fix (2026-05-22): the wizard implementation lives in
6
+ * `setup-wizard.ts`; this file is the thin dispatcher (`runCli`) plus
7
+ * the ESM main-guard. Both have their own deps-bag (`WizardDeps` /
8
+ * `RunCliDeps`) so unit tests can drive them independently.
9
+ *
10
+ * Subcommands:
11
+ *
12
+ * setup (default) — runWizard (see `setup-wizard.ts`)
13
+ * install-skill — copy the bundled skill into ~/.claude/skills/
14
+ * and append a marker block to ~/AGENTS.md.
15
+ * --help / help — print usage.
16
+ * --version / -v — print the package version.
17
+ *
18
+ * Re-exports `runWizard`, `majorMinor` and the wizard public types so
19
+ * existing callers (and tests that already import from `./setup-cli`)
20
+ * keep working with a one-line import.
21
+ *
22
+ * @license MIT
23
+ */
24
+ import { ALL_CLIENTS } from './clients/index.js';
25
+ import { installSkill as defaultInstallSkill } from './install-skill.js';
26
+ import { SERVER_VERSION } from './server.js';
27
+ import { confirmTTY as defaultConfirmTTY } from './setup-cli-confirm.js';
28
+ import { DEFAULT_WIZARD_DEPS, runWizard as runWizardImpl } from './setup-wizard.js';
29
+ import { addSiteCommand, AddSiteError, DEFAULT_ADD_SITE_DEPS, } from './sites/cli/add-site.js';
30
+ import { DEFAULT_LIST_SITES_DEPS, listSitesCommand, } from './sites/cli/list-sites.js';
31
+ import { DEFAULT_REMOVE_SITE_DEPS, removeSiteCommand, RemoveSiteError, } from './sites/cli/remove-site.js';
32
+ import { DEFAULT_SET_DEFAULT_DEPS, setDefaultCommand, SetDefaultError, } from './sites/cli/set-default.js';
33
+ import { DEFAULT_TEST_SITE_DEPS, renderTestSiteLines, testSiteCommand, TestSiteError, } from './sites/cli/test-site.js';
34
+ import { defaultSitesFilePath } from './sites/paths.js';
35
+ // Re-export the wizard surface so consumers that imported from
36
+ // `./setup-cli` before the I5 split keep working without changes.
37
+ export { DEFAULT_WIZARD_DEPS, majorMinor, runWizard, } from './setup-wizard.js';
38
+ const HELP_TEXT = `Usage: yt-builder-mcp <command> [flags]
39
+
40
+ Commands:
41
+ setup Interactive first-run wizard (default if no command)
42
+ install-skill Copy the bundled YOOtheme Builder skill into
43
+ ~/.claude/skills/ and register it in ~/AGENTS.md.
44
+ Note: ~/.claude/skills/ is the universal-marker path
45
+ recognised by Claude Desktop and other AI clients.
46
+
47
+ Multi-site commands (W9):
48
+ add-site Add a site to ~/.config/yt-builder-mcp/sites.json.
49
+ Flags: --url <url>, --token <bearer> OR --token-ref
50
+ <op://...>, --platform auto|wordpress|joomla,
51
+ --label "...", --site-id <slug>, --default, --yes.
52
+ list-sites Show the configured sites (no network calls).
53
+ remove-site <id> Remove a site; auto-promotes the next as default.
54
+ Flag: --yes to skip the confirmation prompt.
55
+ set-default <id> Flip is_default to the given site_id.
56
+ test-site <id> Probe /health (no auth) + /etag (auth) for one site.
57
+
58
+ --version, -v Print the package version.
59
+ --help, -h, help Show this message.
60
+
61
+ Setup flags (for non-interactive / CI usage):
62
+ --non-interactive Skip all prompts; fail-fast on missing input.
63
+ --url <site-url> Site base URL (required with --non-interactive).
64
+ WordPress or Joomla — the wizard auto-detects the
65
+ platform from the URL shape.
66
+ --token <bearer> Bearer key (required with --non-interactive).
67
+ --client <id> AI client id to configure; repeatable. Valid ids:
68
+ claude-desktop, claude-code, cursor, zed, continue,
69
+ cline, roo-code, codex-cli, gemini-cli.
70
+
71
+ Example (non-interactive):
72
+ npx -y @wootsup/yt-builder-mcp setup \\
73
+ --non-interactive \\
74
+ --client cursor --client claude-desktop \\
75
+ --url https://example.com \\
76
+ --token "$YTB_TOKEN"
77
+
78
+ Pickup mode (one-click setup from the admin "Setup wizard" flow):
79
+ --pickup <url> Pickup URL revealed by the host CMS admin (WordPress:
80
+ wp-admin → Tools → "YT Builder MCP"; Joomla:
81
+ Administrator → Components → "YT Builder MCP").
82
+ WordPress: https://example.com/wp-json/yt-builder-mcp/v1/setup/pickup
83
+ Joomla: https://example.com/api/index.php/v1/yt-builder-mcp/setup/pickup
84
+ --nonce <code> One-shot nonce revealed alongside the pickup URL.
85
+ Pairs 1:1 with --pickup (both or neither).
86
+
87
+ When --pickup + --nonce are passed, the wizard fetches the freshly-minted
88
+ Bearer + canonical URL from the plugin in a single POST and skips the
89
+ URL/token prompts entirely. The pickup is IP-bound, single-use, and
90
+ expires after 5 minutes. If --url or --token are also passed they are
91
+ ignored (a warning is printed to stderr).
92
+
93
+ Example (pickup — WordPress):
94
+ npx -y @wootsup/yt-builder-mcp setup \\
95
+ --pickup https://example.com/wp-json/yt-builder-mcp/v1/setup/pickup \\
96
+ --nonce "$NONCE" \\
97
+ --client claude-desktop
98
+
99
+ Example (pickup — Joomla):
100
+ npx -y @wootsup/yt-builder-mcp setup \\
101
+ --pickup https://example.com/api/index.php/v1/yt-builder-mcp/setup/pickup \\
102
+ --nonce "$NONCE" \\
103
+ --client claude-desktop
104
+
105
+ Environment (when launched by an AI client):
106
+ YTB_MCP_SITE_URL Host CMS base URL (e.g. https://example.com).
107
+ Works for BOTH WordPress and Joomla.
108
+ YTB_MCP_WP_URL DEPRECATED alias for YTB_MCP_SITE_URL — still
109
+ honoured for pre-Wave-7 configurations.
110
+ YTB_MCP_BEARER_TOKEN Bearer key from:
111
+ - WordPress: wp-admin → Tools → "YT Builder MCP"
112
+ - Joomla: Administrator → Components → "YT Builder MCP"
113
+ Format: ytb_(live|test)_<payload>.<signature>
114
+ YTB_MCP_PLATFORM Optional explicit platform: 'wordpress' or 'joomla'.
115
+ Set this to 'joomla' when YTB_MCP_SITE_URL is an
116
+ origin-only Joomla URL (no /api/index.php/ in path).
117
+ Defaults to URL-shape auto-detection.
118
+ YTB_MCP_TEST_MODE=1 Skip stdio loop (used by smoke tests).
119
+
120
+ Documentation: https://github.com/wootsup/yt-builder-mcp
121
+ `;
122
+ /**
123
+ * Parse the `setup` subcommand argv tail. Pure function; does no I/O.
124
+ *
125
+ * Accepts both `--key value` and `--key=value` styles. Unknown flags
126
+ * are reported as errors so typos don't silently disable validation.
127
+ */
128
+ export function parseSetupArgs(argv) {
129
+ let nonInteractive = false;
130
+ let url = '';
131
+ let token = '';
132
+ let pickup = '';
133
+ let nonce = '';
134
+ const clients = [];
135
+ const errors = [];
136
+ const warnings = [];
137
+ function consumeValue(name, inline, i) {
138
+ if (inline !== undefined) {
139
+ return { value: inline, nextIndex: i };
140
+ }
141
+ const next = argv[i + 1];
142
+ if (next === undefined || next.startsWith('--')) {
143
+ errors.push(`Flag ${name} requires a value.`);
144
+ return { value: '', nextIndex: i };
145
+ }
146
+ return { value: next, nextIndex: i + 1 };
147
+ }
148
+ for (let i = 0; i < argv.length; i++) {
149
+ const raw = argv[i];
150
+ const eq = raw.indexOf('=');
151
+ const flag = eq >= 0 ? raw.slice(0, eq) : raw;
152
+ const inline = eq >= 0 ? raw.slice(eq + 1) : undefined;
153
+ switch (flag) {
154
+ case '--non-interactive': {
155
+ nonInteractive = true;
156
+ if (inline !== undefined) {
157
+ errors.push('Flag --non-interactive does not take a value.');
158
+ }
159
+ break;
160
+ }
161
+ case '--url': {
162
+ const { value, nextIndex } = consumeValue('--url', inline, i);
163
+ url = value.trim().replace(/\/+$/, '');
164
+ i = nextIndex;
165
+ break;
166
+ }
167
+ case '--token': {
168
+ const { value, nextIndex } = consumeValue('--token', inline, i);
169
+ token = value.trim();
170
+ i = nextIndex;
171
+ break;
172
+ }
173
+ case '--pickup': {
174
+ const { value, nextIndex } = consumeValue('--pickup', inline, i);
175
+ pickup = value.trim();
176
+ i = nextIndex;
177
+ break;
178
+ }
179
+ case '--nonce': {
180
+ const { value, nextIndex } = consumeValue('--nonce', inline, i);
181
+ nonce = value.trim();
182
+ i = nextIndex;
183
+ break;
184
+ }
185
+ case '--client': {
186
+ const { value, nextIndex } = consumeValue('--client', inline, i);
187
+ if (value !== '')
188
+ clients.push(value.trim());
189
+ i = nextIndex;
190
+ break;
191
+ }
192
+ default: {
193
+ errors.push(`Unknown setup flag: ${flag}`);
194
+ }
195
+ }
196
+ }
197
+ // Pickup mode validation (Wave C). Pickup pairs 1:1 with nonce; when
198
+ // both are present, the wizard fetches token + URL from the plugin and
199
+ // ignores --url/--token (with a warning so typos don't go silent).
200
+ const pickupMode = pickup !== '' || nonce !== '';
201
+ if (pickupMode) {
202
+ if (pickup === '')
203
+ errors.push('--pickup is required when --nonce is given.');
204
+ if (nonce === '')
205
+ errors.push('--nonce is required when --pickup is given.');
206
+ if (url !== '')
207
+ warnings.push('--url is ignored in pickup mode (the plugin returns the canonical URL).');
208
+ if (token !== '')
209
+ warnings.push('--token is ignored in pickup mode (the plugin returns the Bearer token).');
210
+ if (clients.length === 0) {
211
+ errors.push('--client is required with --pickup (at least one).');
212
+ }
213
+ const knownIds = new Set(ALL_CLIENTS.map((c) => c.id));
214
+ for (const id of clients) {
215
+ if (!knownIds.has(id)) {
216
+ errors.push(`Unknown --client id "${id}". Valid: ${[...knownIds].sort().join(', ')}.`);
217
+ }
218
+ }
219
+ }
220
+ else if (nonInteractive) {
221
+ if (url === '')
222
+ errors.push('--url is required with --non-interactive.');
223
+ if (token === '')
224
+ errors.push('--token is required with --non-interactive.');
225
+ if (clients.length === 0)
226
+ errors.push('--client is required with --non-interactive (at least one).');
227
+ const knownIds = new Set(ALL_CLIENTS.map((c) => c.id));
228
+ for (const id of clients) {
229
+ if (!knownIds.has(id)) {
230
+ errors.push(`Unknown --client id "${id}". Valid: ${[...knownIds].sort().join(', ')}.`);
231
+ }
232
+ }
233
+ }
234
+ return { nonInteractive, url, token, pickup, nonce, clients, errors, warnings };
235
+ }
236
+ /**
237
+ * Build a `WizardDeps` bag that answers prompts from CLI flags instead
238
+ * of asking a human. Reuses every other dependency (probes, writes,
239
+ * handshake) from `DEFAULT_WIZARD_DEPS` so the wizard's exit-code
240
+ * contract (0/2/3/4/5) stays identical.
241
+ *
242
+ * `confirmContinue` always returns `false` — there is no human to ask,
243
+ * so a probe failure cleanly aborts with the documented exit code.
244
+ */
245
+ export function buildNonInteractiveDeps(parsed, base = DEFAULT_WIZARD_DEPS) {
246
+ const answers = {
247
+ wpUrl: parsed.url,
248
+ bearer: parsed.token,
249
+ selectedClients: parsed.clients,
250
+ };
251
+ return {
252
+ ...base,
253
+ prompt: async () => answers,
254
+ confirmContinue: async () => false,
255
+ };
256
+ }
257
+ /**
258
+ * Build a `WizardDeps` bag for the Wave-C pickup flow. The wizard's
259
+ * `prompt` step calls `base.fetchPickup(url, nonce)` once, then
260
+ * synthesises the `WizardAnswers` from the response — the actual answers
261
+ * (token + canonical WordPress URL) come straight from the plugin via
262
+ * a 256-bit one-shot nonce, never through chat history / provider logs.
263
+ *
264
+ * On `fetchPickup` failure the prompt resolves to `null` so the wizard
265
+ * exits cleanly with code 130 (user-cancel equivalent — we treat
266
+ * an unrecoverable pickup as "the conversation ends here"). The
267
+ * thrown error is logged via the `log` dep so the operator sees why.
268
+ *
269
+ * `confirmContinue` returns `false` (same rationale as non-interactive).
270
+ */
271
+ export function buildPickupDeps(parsed, base = DEFAULT_WIZARD_DEPS) {
272
+ const pickupUrl = parsed.pickup ?? '';
273
+ const nonce = parsed.nonce ?? '';
274
+ const fetchPickup = base.fetchPickup;
275
+ const logFn = base.log;
276
+ return {
277
+ ...base,
278
+ prompt: async () => {
279
+ if (fetchPickup === undefined) {
280
+ const msg = 'Pickup mode requested but no fetchPickup is wired in this WizardDeps bag.';
281
+ if (logFn !== undefined)
282
+ logFn(msg);
283
+ else
284
+ process.stderr.write(`${msg}\n`);
285
+ return null;
286
+ }
287
+ try {
288
+ const result = await fetchPickup(pickupUrl, nonce);
289
+ return {
290
+ wpUrl: result.siteurl,
291
+ bearer: result.token,
292
+ selectedClients: parsed.clients,
293
+ };
294
+ }
295
+ catch (e) {
296
+ const msg = e instanceof Error ? e.message : String(e);
297
+ if (logFn !== undefined)
298
+ logFn(`Pickup failed: ${msg}`);
299
+ else
300
+ process.stderr.write(`Pickup failed: ${msg}\n`);
301
+ return null;
302
+ }
303
+ },
304
+ confirmContinue: async () => false,
305
+ };
306
+ }
307
+ /**
308
+ * Parse `add-site` flags from the tail of argv. Accepts both
309
+ * `--key value` and `--key=value` styles. Unknown flags are reported
310
+ * as errors so typos never silently disable validation.
311
+ */
312
+ export function parseAddSiteArgs(argv) {
313
+ let url = '';
314
+ let token = '';
315
+ let tokenRef = '';
316
+ let label = '';
317
+ let siteId = '';
318
+ let platform;
319
+ let isDefault = false;
320
+ let yes = false;
321
+ let sitesFile;
322
+ const errors = [];
323
+ function consume(name, inline, i) {
324
+ if (inline !== undefined)
325
+ return { value: inline, nextIndex: i };
326
+ const next = argv[i + 1];
327
+ if (next === undefined || next.startsWith('--')) {
328
+ errors.push(`Flag ${name} requires a value.`);
329
+ return { value: '', nextIndex: i };
330
+ }
331
+ return { value: next, nextIndex: i + 1 };
332
+ }
333
+ for (let i = 0; i < argv.length; i++) {
334
+ const raw = argv[i];
335
+ const eq = raw.indexOf('=');
336
+ const flag = eq >= 0 ? raw.slice(0, eq) : raw;
337
+ const inline = eq >= 0 ? raw.slice(eq + 1) : undefined;
338
+ switch (flag) {
339
+ case '--url': {
340
+ const r = consume('--url', inline, i);
341
+ url = r.value.trim().replace(/\/+$/, '');
342
+ i = r.nextIndex;
343
+ break;
344
+ }
345
+ case '--token': {
346
+ const r = consume('--token', inline, i);
347
+ token = r.value.trim();
348
+ i = r.nextIndex;
349
+ break;
350
+ }
351
+ case '--token-ref': {
352
+ const r = consume('--token-ref', inline, i);
353
+ tokenRef = r.value.trim();
354
+ i = r.nextIndex;
355
+ break;
356
+ }
357
+ case '--platform': {
358
+ const r = consume('--platform', inline, i);
359
+ const v = r.value.trim();
360
+ if (v === 'auto' || v === 'wordpress' || v === 'joomla') {
361
+ platform = v;
362
+ }
363
+ else if (v.length > 0) {
364
+ errors.push(`--platform must be one of auto, wordpress, joomla (got "${v}").`);
365
+ }
366
+ i = r.nextIndex;
367
+ break;
368
+ }
369
+ case '--label': {
370
+ const r = consume('--label', inline, i);
371
+ label = r.value;
372
+ i = r.nextIndex;
373
+ break;
374
+ }
375
+ case '--site-id': {
376
+ const r = consume('--site-id', inline, i);
377
+ siteId = r.value.trim();
378
+ i = r.nextIndex;
379
+ break;
380
+ }
381
+ case '--default': {
382
+ isDefault = true;
383
+ if (inline !== undefined) {
384
+ errors.push('Flag --default does not take a value.');
385
+ }
386
+ break;
387
+ }
388
+ case '--yes':
389
+ case '-y': {
390
+ yes = true;
391
+ if (inline !== undefined) {
392
+ errors.push(`Flag ${flag} does not take a value.`);
393
+ }
394
+ break;
395
+ }
396
+ case '--sites-file': {
397
+ const r = consume('--sites-file', inline, i);
398
+ sitesFile = r.value.trim();
399
+ i = r.nextIndex;
400
+ break;
401
+ }
402
+ case '--help':
403
+ case '-h': {
404
+ errors.push('HELP_REQUESTED');
405
+ break;
406
+ }
407
+ default: {
408
+ errors.push(`Unknown add-site flag: ${flag}`);
409
+ }
410
+ }
411
+ }
412
+ const parsed = {
413
+ url,
414
+ token,
415
+ tokenRef,
416
+ label,
417
+ siteId: siteId.length > 0 ? siteId : 'default',
418
+ default: isDefault,
419
+ yes,
420
+ ...(platform !== undefined ? { platform } : {}),
421
+ ...(sitesFile !== undefined ? { sitesFile } : {}),
422
+ errors,
423
+ };
424
+ return parsed;
425
+ }
426
+ const ADD_SITE_HELP = `Usage: yt-builder-mcp add-site [flags]\n\n` +
427
+ `Flags:\n` +
428
+ ` --url <url> (required) Site base URL (WordPress or Joomla origin).\n` +
429
+ ` --token <bearer> Inline bearer (mutually exclusive with --token-ref).\n` +
430
+ ` --token-ref <op://...> 1Password Secret Reference for the bearer.\n` +
431
+ ` --platform <kind> auto|wordpress|joomla (default: auto).\n` +
432
+ ` --label "<text>" Human-readable label (≤120 chars).\n` +
433
+ ` --site-id <slug> Registry key (default: "default").\n` +
434
+ ` --default Mark this site as the default.\n` +
435
+ ` --yes, -y Overwrite an existing site_id without confirming.\n` +
436
+ ` --sites-file <path> Override sites.json location.\n\n` +
437
+ `Notes:\n` +
438
+ ` - The first site you add becomes the default automatically.\n` +
439
+ ` - Use --token OR --token-ref, not both.\n` +
440
+ ` - URL is normalised (trailing slashes stripped).\n\n` +
441
+ `Example:\n` +
442
+ ` yt-builder-mcp add-site --url https://acme.example.com \\\n` +
443
+ ` --token "$YTB_TOKEN" --site-id wp-acme --label "ACME WP"\n`;
444
+ const REMOVE_SITE_HELP = `Usage: yt-builder-mcp remove-site <site_id> [--yes] [--sites-file <path>]\n\n` +
445
+ `Removes the site from sites.json. If the default site is removed and at\n` +
446
+ `least one other site remains, the next site in insertion order becomes\n` +
447
+ `the new default. Removing the only site clears default_site_id and\n` +
448
+ `leaves an empty registry.\n\n` +
449
+ `Confirmation is required unless --yes is passed. In non-TTY contexts\n` +
450
+ `(CI, piped stdin) the subcommand fails with CONFIRM_REQUIRED rather\n` +
451
+ `than silently deleting.\n\n` +
452
+ `Example:\n` +
453
+ ` yt-builder-mcp remove-site wp-acme --yes\n`;
454
+ const SET_DEFAULT_HELP = `Usage: yt-builder-mcp set-default <site_id> [--yes] [--sites-file <path>]\n\n` +
455
+ `Changes which site every subsequent tool call routes to by default\n` +
456
+ `when site_id is omitted. Confirmation is required unless --yes is\n` +
457
+ `passed — in non-TTY contexts the subcommand fails with\n` +
458
+ `SET_DEFAULT_CONFIRM_REQUIRED rather than silently flipping.\n\n` +
459
+ `Example:\n` +
460
+ ` yt-builder-mcp set-default wp-beta --yes\n`;
461
+ const TEST_SITE_HELP = `Usage: yt-builder-mcp test-site <site_id> [--sites-file <path>]\n\n` +
462
+ `Probes /health (unauthenticated) and /etag (authenticated) in parallel\n` +
463
+ `against the configured Bearer. Returns plugin reachability + Bearer\n` +
464
+ `validity in one call. Does NOT mutate the registry or the site.\n\n` +
465
+ `Example:\n` +
466
+ ` yt-builder-mcp test-site wp-acme\n`;
467
+ const LIST_SITES_HELP = `Usage: yt-builder-mcp list-sites [--sites-file <path>]\n\n` +
468
+ `Prints the configured sites table (site_id, url, platform, label,\n` +
469
+ `bearer_source, is_default). No network calls — pure registry read.\n\n` +
470
+ `Example:\n` +
471
+ ` yt-builder-mcp list-sites\n`;
472
+ function parseIdArgs(argv, allowYes) {
473
+ let siteId = '';
474
+ let yes = false;
475
+ let sitesFile;
476
+ const errors = [];
477
+ let helpRequested = false;
478
+ for (let i = 0; i < argv.length; i++) {
479
+ const raw = argv[i];
480
+ const eq = raw.indexOf('=');
481
+ const flag = eq >= 0 ? raw.slice(0, eq) : raw;
482
+ const inline = eq >= 0 ? raw.slice(eq + 1) : undefined;
483
+ if (flag === '--help' || flag === '-h') {
484
+ helpRequested = true;
485
+ continue;
486
+ }
487
+ if (flag === '--yes' || flag === '-y') {
488
+ if (!allowYes) {
489
+ errors.push(`Unknown flag for this subcommand: ${flag}`);
490
+ }
491
+ else {
492
+ yes = true;
493
+ }
494
+ if (inline !== undefined)
495
+ errors.push(`Flag ${flag} does not take a value.`);
496
+ continue;
497
+ }
498
+ if (flag === '--sites-file') {
499
+ const next = inline ?? argv[i + 1];
500
+ if (next === undefined || next.startsWith('--')) {
501
+ errors.push('Flag --sites-file requires a value.');
502
+ continue;
503
+ }
504
+ sitesFile = next.trim();
505
+ if (inline === undefined)
506
+ i += 1;
507
+ continue;
508
+ }
509
+ if (flag.startsWith('--') || flag.startsWith('-')) {
510
+ errors.push(`Unknown flag: ${flag}`);
511
+ continue;
512
+ }
513
+ if (siteId !== '') {
514
+ errors.push(`Too many positional arguments; got "${siteId}" and "${flag}".`);
515
+ continue;
516
+ }
517
+ siteId = flag.trim();
518
+ }
519
+ return {
520
+ siteId,
521
+ yes,
522
+ ...(sitesFile !== undefined ? { sitesFile } : {}),
523
+ errors,
524
+ helpRequested,
525
+ };
526
+ }
527
+ export async function runCli(argv, deps) {
528
+ const out = deps?.log ?? ((s) => process.stdout.write(`${s}\n`));
529
+ const err = deps?.error ?? ((s) => process.stderr.write(`${s}\n`));
530
+ const wizard = deps?.runWizard ?? ((wizDeps) => runWizardImpl(wizDeps));
531
+ const install = deps?.installSkill ?? defaultInstallSkill;
532
+ const resolveSitesPath = deps?.resolveSitesPath ?? (() => defaultSitesFilePath());
533
+ const addSiteDeps = deps?.addSiteDeps ?? DEFAULT_ADD_SITE_DEPS;
534
+ const listSitesDeps = deps?.listSitesDeps ?? DEFAULT_LIST_SITES_DEPS;
535
+ // W12-R2A: wire a TTY confirm hook into the destructive-subcommand
536
+ // deps bags. Tests that supply `removeSiteDeps`/`setDefaultDeps`
537
+ // directly retain full control over the confirm channel (so the
538
+ // existing unit-tests keep working unchanged); only the default
539
+ // dispatcher path gets the `defaultConfirmTTY` injection.
540
+ const confirmHook = deps?.confirm ?? defaultConfirmTTY;
541
+ const removeSiteDeps = deps?.removeSiteDeps
542
+ ?? { ...DEFAULT_REMOVE_SITE_DEPS, confirm: confirmHook };
543
+ const setDefaultDeps = deps?.setDefaultDeps
544
+ ?? { ...DEFAULT_SET_DEFAULT_DEPS, confirm: confirmHook };
545
+ const testSiteDeps = deps?.testSiteDeps ?? DEFAULT_TEST_SITE_DEPS;
546
+ const addSiteFromWizard = deps?.addSiteFromWizard
547
+ ?? ((args, path) => addSiteCommand(args, path, addSiteDeps));
548
+ const [subcommand] = argv;
549
+ // Build a `persistSite` callback for the wizard that translates
550
+ // the collected WizardAnswers into an `addSiteCommand` call so the
551
+ // sites.json registry stays in sync with the env-var path. This is
552
+ // the W9 "wizard internally invokes add-site" wiring.
553
+ const buildPersistSite = () => {
554
+ return async (answers) => {
555
+ const siteId = (answers.siteId !== undefined && answers.siteId.length > 0)
556
+ ? answers.siteId
557
+ : 'default';
558
+ const path = resolveSitesPath();
559
+ const args = {
560
+ url: answers.wpUrl,
561
+ token: answers.bearer,
562
+ siteId,
563
+ default: true,
564
+ yes: true,
565
+ platform: 'auto',
566
+ };
567
+ await addSiteFromWizard(args, path);
568
+ };
569
+ };
570
+ if (subcommand === undefined || subcommand === 'setup') {
571
+ const setupArgs = argv[0] === 'setup' ? argv.slice(1) : argv;
572
+ const parsed = parseSetupArgs(setupArgs);
573
+ // Surface non-fatal warnings (e.g. "--url ignored in pickup mode").
574
+ for (const line of parsed.warnings)
575
+ err(`yt-builder-mcp: warning: ${line}`);
576
+ const pickupMode = (parsed.pickup ?? '') !== '' || (parsed.nonce ?? '') !== '';
577
+ const persistSite = buildPersistSite();
578
+ function withPersist(base) {
579
+ return { ...base, persistSite };
580
+ }
581
+ if (pickupMode) {
582
+ if (parsed.errors.length > 0) {
583
+ for (const line of parsed.errors)
584
+ err(`yt-builder-mcp: ${line}`);
585
+ err(HELP_TEXT);
586
+ return 2;
587
+ }
588
+ return wizard(withPersist(buildPickupDeps(parsed)));
589
+ }
590
+ if (parsed.nonInteractive) {
591
+ if (parsed.errors.length > 0) {
592
+ for (const line of parsed.errors)
593
+ err(`yt-builder-mcp: ${line}`);
594
+ err(HELP_TEXT);
595
+ return 2;
596
+ }
597
+ return wizard(withPersist(buildNonInteractiveDeps(parsed)));
598
+ }
599
+ if (parsed.errors.length > 0) {
600
+ for (const line of parsed.errors)
601
+ err(`yt-builder-mcp: ${line}`);
602
+ err(HELP_TEXT);
603
+ return 1;
604
+ }
605
+ return wizard(withPersist(DEFAULT_WIZARD_DEPS));
606
+ }
607
+ switch (subcommand) {
608
+ case 'install-skill':
609
+ case 'install': {
610
+ try {
611
+ const result = await install();
612
+ if (result.markerAlreadyPresent) {
613
+ out(`yt-builder-mcp: skill refreshed at ${result.skillTargetDir} (marker already in AGENTS.md).`);
614
+ }
615
+ else {
616
+ out(`yt-builder-mcp: skill installed at ${result.skillTargetDir}; ${result.agentsFile} updated.`);
617
+ }
618
+ return 0;
619
+ }
620
+ catch (e) {
621
+ const msg = e instanceof Error ? e.message : String(e);
622
+ err(`yt-builder-mcp: install-skill failed: ${msg}`);
623
+ return 2;
624
+ }
625
+ }
626
+ case 'add-site': {
627
+ const tail = argv.slice(1);
628
+ const parsed = parseAddSiteArgs(tail);
629
+ if (parsed.errors.some((e) => e === 'HELP_REQUESTED')) {
630
+ out(ADD_SITE_HELP);
631
+ return 0;
632
+ }
633
+ if (parsed.errors.length > 0) {
634
+ for (const line of parsed.errors)
635
+ err(`yt-builder-mcp: ${line}`);
636
+ err(ADD_SITE_HELP);
637
+ return 2;
638
+ }
639
+ const path = parsed.sitesFile ?? resolveSitesPath();
640
+ const args = {
641
+ url: parsed.url,
642
+ ...(parsed.token.length > 0 ? { token: parsed.token } : {}),
643
+ ...(parsed.tokenRef.length > 0 ? { tokenRef: parsed.tokenRef } : {}),
644
+ ...(parsed.platform !== undefined ? { platform: parsed.platform } : {}),
645
+ ...(parsed.label.length > 0 ? { label: parsed.label } : {}),
646
+ siteId: parsed.siteId,
647
+ default: parsed.default,
648
+ yes: parsed.yes,
649
+ };
650
+ try {
651
+ const result = await addSiteCommand(args, path, addSiteDeps);
652
+ const stateBits = [];
653
+ if (result.becameDefault)
654
+ stateBits.push('default — first site');
655
+ else if (result.defaultRequested)
656
+ stateBits.push('default');
657
+ if (result.overwritten)
658
+ stateBits.push('overwritten');
659
+ const state = stateBits.length > 0 ? ` (${stateBits.join(', ')})` : '';
660
+ const verb = result.overwritten ? 'updated' : 'added';
661
+ out(`✓ Site "${result.siteId}" ${verb}${state}.`);
662
+ out(` Path: ${result.path}`);
663
+ out('Restart your AI client to pick up the new site list.');
664
+ return 0;
665
+ }
666
+ catch (e) {
667
+ if (e instanceof AddSiteError) {
668
+ err(`yt-builder-mcp: add-site failed [${e.code}]: ${e.message}`);
669
+ return 2;
670
+ }
671
+ const msg = e instanceof Error ? e.message : String(e);
672
+ err(`yt-builder-mcp: add-site failed: ${msg}`);
673
+ return 2;
674
+ }
675
+ }
676
+ case 'list-sites': {
677
+ const tail = argv.slice(1);
678
+ const parsed = parseIdArgs(tail, false);
679
+ // list-sites takes no positional id; if one slipped in it's
680
+ // a usage error (parseIdArgs allows zero or one).
681
+ if (parsed.helpRequested) {
682
+ out(LIST_SITES_HELP);
683
+ return 0;
684
+ }
685
+ if (parsed.siteId !== '') {
686
+ err(`yt-builder-mcp: list-sites takes no positional argument (got "${parsed.siteId}").`);
687
+ err(LIST_SITES_HELP);
688
+ return 2;
689
+ }
690
+ if (parsed.errors.length > 0) {
691
+ for (const line of parsed.errors)
692
+ err(`yt-builder-mcp: ${line}`);
693
+ err(LIST_SITES_HELP);
694
+ return 2;
695
+ }
696
+ const path = parsed.sitesFile ?? resolveSitesPath();
697
+ try {
698
+ const lines = await listSitesCommand(path, listSitesDeps);
699
+ for (const line of lines)
700
+ out(line);
701
+ return 0;
702
+ }
703
+ catch (e) {
704
+ const msg = e instanceof Error ? e.message : String(e);
705
+ err(`yt-builder-mcp: list-sites failed: ${msg}`);
706
+ return 2;
707
+ }
708
+ }
709
+ case 'remove-site': {
710
+ const tail = argv.slice(1);
711
+ const parsed = parseIdArgs(tail, true);
712
+ if (parsed.helpRequested) {
713
+ out(REMOVE_SITE_HELP);
714
+ return 0;
715
+ }
716
+ if (parsed.siteId === '') {
717
+ err('yt-builder-mcp: remove-site requires a <site_id> argument.');
718
+ err(REMOVE_SITE_HELP);
719
+ return 2;
720
+ }
721
+ if (parsed.errors.length > 0) {
722
+ for (const line of parsed.errors)
723
+ err(`yt-builder-mcp: ${line}`);
724
+ err(REMOVE_SITE_HELP);
725
+ return 2;
726
+ }
727
+ const path = parsed.sitesFile ?? resolveSitesPath();
728
+ try {
729
+ const result = await removeSiteCommand(parsed.siteId, path, { yes: parsed.yes }, removeSiteDeps);
730
+ if (result.cancelled) {
731
+ out(`Cancelled — site "${result.siteId}" not removed.`);
732
+ return 0;
733
+ }
734
+ out(`✓ Site "${result.siteId}" removed.`);
735
+ if (result.promoted !== undefined) {
736
+ out(` Default promoted: ${result.promoted}`);
737
+ }
738
+ if (result.nowEmpty) {
739
+ out(' (registry is now empty)');
740
+ }
741
+ out(` Path: ${result.path}`);
742
+ out('Restart your AI client to pick up the new site list.');
743
+ return 0;
744
+ }
745
+ catch (e) {
746
+ if (e instanceof RemoveSiteError) {
747
+ err(`yt-builder-mcp: remove-site failed [${e.code}]: ${e.message}`);
748
+ return 2;
749
+ }
750
+ const msg = e instanceof Error ? e.message : String(e);
751
+ err(`yt-builder-mcp: remove-site failed: ${msg}`);
752
+ return 2;
753
+ }
754
+ }
755
+ case 'set-default': {
756
+ const tail = argv.slice(1);
757
+ // W12-R2A: set-default is a routing-destructive op (every
758
+ // subsequent default-routed tool call lands on a different
759
+ // site). Allow --yes so CI can flip without a prompt.
760
+ const parsed = parseIdArgs(tail, true);
761
+ if (parsed.helpRequested) {
762
+ out(SET_DEFAULT_HELP);
763
+ return 0;
764
+ }
765
+ if (parsed.siteId === '') {
766
+ err('yt-builder-mcp: set-default requires a <site_id> argument.');
767
+ err(SET_DEFAULT_HELP);
768
+ return 2;
769
+ }
770
+ if (parsed.errors.length > 0) {
771
+ for (const line of parsed.errors)
772
+ err(`yt-builder-mcp: ${line}`);
773
+ err(SET_DEFAULT_HELP);
774
+ return 2;
775
+ }
776
+ const path = parsed.sitesFile ?? resolveSitesPath();
777
+ try {
778
+ const result = await setDefaultCommand(parsed.siteId, path, { yes: parsed.yes }, setDefaultDeps);
779
+ if (result.cancelled) {
780
+ out(`Cancelled — default unchanged.`);
781
+ return 0;
782
+ }
783
+ const prior = result.previousDefault !== null
784
+ ? `(was: ${result.previousDefault})`
785
+ : '(no previous default)';
786
+ out(`✓ Default set to "${result.siteId}" ${prior}.`);
787
+ out(` Path: ${result.path}`);
788
+ out('Restart your AI client to pick up the new site list.');
789
+ return 0;
790
+ }
791
+ catch (e) {
792
+ if (e instanceof SetDefaultError) {
793
+ err(`yt-builder-mcp: set-default failed [${e.code}]: ${e.message}`);
794
+ return 2;
795
+ }
796
+ const msg = e instanceof Error ? e.message : String(e);
797
+ err(`yt-builder-mcp: set-default failed: ${msg}`);
798
+ return 2;
799
+ }
800
+ }
801
+ case 'test-site': {
802
+ const tail = argv.slice(1);
803
+ const parsed = parseIdArgs(tail, false);
804
+ if (parsed.helpRequested) {
805
+ out(TEST_SITE_HELP);
806
+ return 0;
807
+ }
808
+ if (parsed.siteId === '') {
809
+ err('yt-builder-mcp: test-site requires a <site_id> argument.');
810
+ err(TEST_SITE_HELP);
811
+ return 2;
812
+ }
813
+ if (parsed.errors.length > 0) {
814
+ for (const line of parsed.errors)
815
+ err(`yt-builder-mcp: ${line}`);
816
+ err(TEST_SITE_HELP);
817
+ return 2;
818
+ }
819
+ const path = parsed.sitesFile ?? resolveSitesPath();
820
+ try {
821
+ const result = await testSiteCommand(parsed.siteId, path, testSiteDeps);
822
+ for (const line of renderTestSiteLines(result))
823
+ out(line);
824
+ const exitCode = result.unknownSite
825
+ || !result.pluginReachable
826
+ || !result.bearerValid
827
+ ? 2
828
+ : 0;
829
+ return exitCode;
830
+ }
831
+ catch (e) {
832
+ if (e instanceof TestSiteError) {
833
+ err(`yt-builder-mcp: test-site failed [${e.code}]: ${e.message}`);
834
+ return 2;
835
+ }
836
+ const msg = e instanceof Error ? e.message : String(e);
837
+ err(`yt-builder-mcp: test-site failed: ${msg}`);
838
+ return 2;
839
+ }
840
+ }
841
+ case '--version':
842
+ case '-v': {
843
+ out(SERVER_VERSION);
844
+ return 0;
845
+ }
846
+ case 'help':
847
+ case '--help':
848
+ case '-h': {
849
+ out(HELP_TEXT);
850
+ return 0;
851
+ }
852
+ default: {
853
+ err(`yt-builder-mcp: unknown command "${subcommand}".`);
854
+ err(HELP_TEXT);
855
+ return 1;
856
+ }
857
+ }
858
+ }
859
+ // ── direct CLI entry ────────────────────────────────────────────────────
860
+ const isMain = typeof process !== 'undefined' &&
861
+ process.argv[1] !== undefined &&
862
+ import.meta.url === `file://${process.argv[1]}`;
863
+ if (isMain) {
864
+ runCli(process.argv.slice(2)).then((code) => process.exit(code), (err) => {
865
+ const msg = err instanceof Error ? err.message : String(err);
866
+ process.stderr.write(`yt-builder-mcp: fatal: ${msg}\n`);
867
+ process.exit(99);
868
+ });
869
+ }
870
+ //# sourceMappingURL=setup-cli.js.map