@caspian2026/agent-sdk 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/dist/chunk-018smjq7.js +26 -0
  2. package/dist/chunk-055q0a2m.js +146 -0
  3. package/dist/chunk-07069jq1.js +30 -0
  4. package/dist/chunk-0731m51q.js +8 -0
  5. package/dist/chunk-0awwmrwr.js +46 -0
  6. package/dist/chunk-0htx82k2.js +64 -0
  7. package/dist/chunk-0jmt5sx1.js +104 -0
  8. package/dist/chunk-0kj8bq80.js +252 -0
  9. package/dist/chunk-0kxcq8h9.js +86 -0
  10. package/dist/chunk-0paqc2yw.js +15 -0
  11. package/dist/chunk-0vkfrmqm.js +690 -0
  12. package/dist/chunk-0xjaqda8.js +1124 -0
  13. package/dist/chunk-10qhq6f8.js +458 -0
  14. package/dist/chunk-15m49c67.js +121 -0
  15. package/dist/chunk-15sfg4bs.js +65 -0
  16. package/dist/chunk-162ewhvy.js +869 -0
  17. package/dist/chunk-177s15bv.js +120 -0
  18. package/dist/chunk-19e603rv.js +284 -0
  19. package/dist/chunk-1ax1znzj.js +537 -0
  20. package/dist/chunk-1c4j7qn2.js +319 -0
  21. package/dist/chunk-1gx78081.js +66 -0
  22. package/dist/chunk-1h2famwb.js +49 -0
  23. package/dist/chunk-1nk93fqz.js +357 -0
  24. package/dist/chunk-1xct96nd.js +2520 -0
  25. package/dist/chunk-1xvcvdef.js +90 -0
  26. package/dist/chunk-1yrcnrs7.js +261 -0
  27. package/dist/chunk-21bcvwr7.js +660 -0
  28. package/dist/chunk-2352ts05.js +667 -0
  29. package/dist/chunk-23jzrwsw.js +43 -0
  30. package/dist/chunk-26hg7303.js +62 -0
  31. package/dist/chunk-2f21meep.js +122 -0
  32. package/dist/chunk-2fwze72g.js +24 -0
  33. package/dist/chunk-2gzv8nrw.js +205 -0
  34. package/dist/chunk-2h05vtpv.js +83 -0
  35. package/dist/chunk-2h0y6m16.js +465 -0
  36. package/dist/chunk-2n7bbxm6.js +168 -0
  37. package/dist/chunk-2nv3d0he.js +108 -0
  38. package/dist/chunk-2vqrdwx9.js +1811 -0
  39. package/dist/chunk-3389cj3w.js +120 -0
  40. package/dist/chunk-35sgv3er.js +231 -0
  41. package/dist/chunk-3c25bcsw.js +17 -0
  42. package/dist/chunk-3e20cj49.js +443 -0
  43. package/dist/chunk-3mr5ryx4.js +122 -0
  44. package/dist/chunk-3nk79af8.js +8 -0
  45. package/dist/chunk-3qbdzsvm.js +120 -0
  46. package/dist/chunk-3yprydpw.js +213 -0
  47. package/dist/chunk-430yrtmk.js +492 -0
  48. package/dist/chunk-46hd1gyd.js +140 -0
  49. package/dist/chunk-46hdszda.js +63 -0
  50. package/dist/chunk-46n7byh8.js +102 -0
  51. package/dist/chunk-4cp6193g.js +9076 -0
  52. package/dist/chunk-4dn3n459.js +409 -0
  53. package/dist/chunk-4hv90qcz.js +8 -0
  54. package/dist/chunk-4jm600zv.js +13 -0
  55. package/dist/chunk-4nspekjp.js +69 -0
  56. package/dist/chunk-505mxxa9.js +19 -0
  57. package/dist/chunk-50bay5qy.js +224 -0
  58. package/dist/chunk-537qfvn5.js +345 -0
  59. package/dist/chunk-55raexh7.js +14358 -0
  60. package/dist/chunk-572vjq78.js +56 -0
  61. package/dist/chunk-5apfzkpy.js +87 -0
  62. package/dist/chunk-5ccdsxgy.js +74 -0
  63. package/dist/chunk-5dmhsqap.js +32 -0
  64. package/dist/chunk-5fs6nkjr.js +98 -0
  65. package/dist/chunk-5nchekqe.js +87 -0
  66. package/dist/chunk-5pp28k2r.js +120 -0
  67. package/dist/chunk-5rt4b8q9.js +116 -0
  68. package/dist/chunk-5rv9c8yd.js +1072 -0
  69. package/dist/chunk-5z28bqne.js +6748 -0
  70. package/dist/chunk-64c1avct.js +13 -0
  71. package/dist/chunk-66zry909.js +11 -0
  72. package/dist/chunk-682qgta2.js +102 -0
  73. package/dist/chunk-68ffk5qa.js +14 -0
  74. package/dist/chunk-68w91pzt.js +79 -0
  75. package/dist/chunk-69fgaak0.js +654 -0
  76. package/dist/chunk-69n11zng.js +436 -0
  77. package/dist/chunk-6dj5t602.js +341 -0
  78. package/dist/chunk-6gh20s05.js +146 -0
  79. package/dist/chunk-6maej1hh.js +502 -0
  80. package/dist/chunk-6nsd9606.js +790 -0
  81. package/dist/chunk-6p4cyhb3.js +16 -0
  82. package/dist/chunk-6t4a9cgj.js +877 -0
  83. package/dist/chunk-6t8yqfks.js +227 -0
  84. package/dist/chunk-6vthy0fj.js +213 -0
  85. package/dist/chunk-70cw4cg9.js +1026 -0
  86. package/dist/chunk-70eey1nh.js +164 -0
  87. package/dist/chunk-76j2e9vy.js +68 -0
  88. package/dist/chunk-7acgdm7x.js +93 -0
  89. package/dist/chunk-7aw745vx.js +40175 -0
  90. package/dist/chunk-7gvwg1v9.js +122 -0
  91. package/dist/chunk-7h2ybnf3.js +636 -0
  92. package/dist/chunk-7kcm5hn2.js +155 -0
  93. package/dist/chunk-7m2hp89m.js +73 -0
  94. package/dist/chunk-7mqab3z7.js +31 -0
  95. package/dist/chunk-7sgtxrsc.js +1059 -0
  96. package/dist/chunk-7wm5s02e.js +216 -0
  97. package/dist/chunk-7xyswgjh.js +8 -0
  98. package/dist/chunk-7yxvpj5j.js +1452 -0
  99. package/dist/chunk-80a8vabn.js +93 -0
  100. package/dist/chunk-83e71kz6.js +180 -0
  101. package/dist/chunk-83hfzbx3.js +10 -0
  102. package/dist/chunk-8g5pe1gr.js +37 -0
  103. package/dist/chunk-8g747a8x.js +26 -0
  104. package/dist/chunk-8hj8ms5q.js +111 -0
  105. package/dist/chunk-8mkwsdk1.js +61 -0
  106. package/dist/chunk-8n42zyfx.js +40 -0
  107. package/dist/chunk-8qhxyqj9.js +1155 -0
  108. package/dist/chunk-8y30k9pz.js +38 -0
  109. package/dist/chunk-960ze3jj.js +124 -0
  110. package/dist/chunk-97wgdsab.js +35 -0
  111. package/dist/chunk-9grztvcg.js +93 -0
  112. package/dist/chunk-9x5zgy22.js +12 -0
  113. package/dist/chunk-a8792r1c.js +620 -0
  114. package/dist/chunk-ahr1r7c6.js +4275 -0
  115. package/dist/chunk-ase86y73.js +15 -0
  116. package/dist/chunk-b0kf00ff.js +637 -0
  117. package/dist/chunk-b0qptb1k.js +640 -0
  118. package/dist/chunk-b1kcd3ss.js +27 -0
  119. package/dist/chunk-b2fd462a.js +54 -0
  120. package/dist/chunk-bdrjvs5k.js +157 -0
  121. package/dist/chunk-beg7bdyz.js +90 -0
  122. package/dist/chunk-bg4x9ex0.js +21 -0
  123. package/dist/chunk-bktfq0ns.js +95 -0
  124. package/dist/chunk-bmbq6nt1.js +145 -0
  125. package/dist/chunk-bvf2z3g6.js +1003 -0
  126. package/dist/chunk-bxcfz5gy.js +56 -0
  127. package/dist/chunk-c11swzas.js +5368 -0
  128. package/dist/chunk-c37j5zxe.js +57 -0
  129. package/dist/chunk-c5mz5vw2.js +117 -0
  130. package/dist/chunk-c6sjhj89.js +1284 -0
  131. package/dist/chunk-c7jwbe76.js +29030 -0
  132. package/dist/chunk-cc2tg4q8.js +311 -0
  133. package/dist/chunk-cdhmrbj4.js +6353 -0
  134. package/dist/chunk-cdz5yb0r.js +57 -0
  135. package/dist/chunk-cfv996bs.js +22 -0
  136. package/dist/chunk-cgfdkzhb.js +12 -0
  137. package/dist/chunk-chakj069.js +310 -0
  138. package/dist/chunk-chsyvavm.js +3435 -0
  139. package/dist/chunk-cnsj3vq2.js +35 -0
  140. package/dist/chunk-ctdg0qxh.js +1386 -0
  141. package/dist/chunk-cxq7gc42.js +386 -0
  142. package/dist/chunk-d1pyf9as.js +8586 -0
  143. package/dist/chunk-d4kwjqjy.js +308 -0
  144. package/dist/chunk-d4mdda98.js +94 -0
  145. package/dist/chunk-d7886r6a.js +13870 -0
  146. package/dist/chunk-d7f1pzkq.js +95 -0
  147. package/dist/chunk-ddsjkqs4.js +39 -0
  148. package/dist/chunk-dm3n2qgd.js +24 -0
  149. package/dist/chunk-e2mv8ts8.js +115 -0
  150. package/dist/chunk-e4bhfc6d.js +2720 -0
  151. package/dist/chunk-e4p1jbs4.js +58 -0
  152. package/dist/chunk-e7h4qxgw.js +21 -0
  153. package/dist/chunk-e8p3fy6v.js +202 -0
  154. package/dist/chunk-e97mp86b.js +111 -0
  155. package/dist/chunk-ebqwkhyf.js +145 -0
  156. package/dist/chunk-eenq3avg.js +69 -0
  157. package/dist/chunk-efgjfast.js +61 -0
  158. package/dist/chunk-ehtwnxpg.js +1591 -0
  159. package/dist/chunk-en8wkxh7.js +173 -0
  160. package/dist/chunk-enkdxqas.js +33 -0
  161. package/dist/chunk-eqp1rfft.js +17 -0
  162. package/dist/chunk-ercvcek8.js +266 -0
  163. package/dist/chunk-etgh9xvt.js +369 -0
  164. package/dist/chunk-ev3qkf76.js +106 -0
  165. package/dist/chunk-evp5pb9x.js +3567 -0
  166. package/dist/chunk-ewadzrm8.js +103 -0
  167. package/dist/chunk-exah13mz.js +94 -0
  168. package/dist/chunk-f0rzvqmq.js +87 -0
  169. package/dist/chunk-f1m9pect.js +258 -0
  170. package/dist/chunk-fajg8x36.js +8158 -0
  171. package/dist/chunk-fbv4apne.js +51 -0
  172. package/dist/chunk-fbvw6wq9.js +116 -0
  173. package/dist/chunk-feyzykye.js +10 -0
  174. package/dist/chunk-fn1vvj8k.js +894 -0
  175. package/dist/chunk-fshfxw2q.js +183 -0
  176. package/dist/chunk-fyc5fepv.js +10 -0
  177. package/dist/chunk-g9f19ttm.js +15 -0
  178. package/dist/chunk-gcpfxk0c.js +644 -0
  179. package/dist/chunk-gdg6411p.js +106 -0
  180. package/dist/chunk-gkyzz8er.js +849 -0
  181. package/dist/chunk-gxahdggv.js +71 -0
  182. package/dist/chunk-h6fsks9j.js +220 -0
  183. package/dist/chunk-h9n54swm.js +27 -0
  184. package/dist/chunk-hakdhagh.js +16606 -0
  185. package/dist/chunk-hchy0hq6.js +159 -0
  186. package/dist/chunk-hh3k5s1s.js +180 -0
  187. package/dist/chunk-hqqkj5pg.js +202 -0
  188. package/dist/chunk-htpehq9t.js +251 -0
  189. package/dist/chunk-hwfknpxv.js +39 -0
  190. package/dist/chunk-hwn8vetn.js +394 -0
  191. package/dist/chunk-hx3j6n92.js +178 -0
  192. package/dist/chunk-hyb749hd.js +194 -0
  193. package/dist/chunk-hzgnejb1.js +90 -0
  194. package/dist/chunk-hzknr99c.js +477 -0
  195. package/dist/chunk-j3zhb8vv.js +152 -0
  196. package/dist/chunk-j5bth84e.js +97 -0
  197. package/dist/chunk-j64ga6ta.js +8035 -0
  198. package/dist/chunk-jaaxk89e.js +113 -0
  199. package/dist/chunk-jd32zbps.js +15 -0
  200. package/dist/chunk-jfja8q7w.js +91 -0
  201. package/dist/chunk-jgjqa49s.js +27 -0
  202. package/dist/chunk-jgpmpgx6.js +19 -0
  203. package/dist/chunk-jgwd85hp.js +91 -0
  204. package/dist/chunk-jk69qtzx.js +277 -0
  205. package/dist/chunk-jr1xm1dd.js +147 -0
  206. package/dist/chunk-jss0azv7.js +2337 -0
  207. package/dist/chunk-jxpmkae9.js +108 -0
  208. package/dist/chunk-jy9rxxqe.js +102 -0
  209. package/dist/chunk-jyw3np47.js +264 -0
  210. package/dist/chunk-jzthz1bx.js +15 -0
  211. package/dist/chunk-k0p9w03v.js +4957 -0
  212. package/dist/chunk-k2rybwww.js +92 -0
  213. package/dist/chunk-k3939ggz.js +168 -0
  214. package/dist/chunk-k591cwbg.js +345 -0
  215. package/dist/chunk-k5ez1h65.js +108 -0
  216. package/dist/chunk-k8vp0atq.js +2331 -0
  217. package/dist/chunk-kajf3jgq.js +694 -0
  218. package/dist/chunk-kbm69rtz.js +276 -0
  219. package/dist/chunk-kjh11txh.js +419 -0
  220. package/dist/chunk-kqggbte3.js +326 -0
  221. package/dist/chunk-kr6qfwq0.js +95 -0
  222. package/dist/chunk-kvfg8eeg.js +150 -0
  223. package/dist/chunk-kwekc97v.js +18 -0
  224. package/dist/chunk-m1cehfta.js +861 -0
  225. package/dist/chunk-m87bhhqv.js +61 -0
  226. package/dist/chunk-mg7pbk0r.js +151 -0
  227. package/dist/chunk-mpbfkp8j.js +418 -0
  228. package/dist/chunk-mpk1sjyk.js +117 -0
  229. package/dist/chunk-msecaxyj.js +74 -0
  230. package/dist/chunk-mswx2nma.js +103 -0
  231. package/dist/chunk-mw1kpeg9.js +6895 -0
  232. package/dist/chunk-mxr2s6d1.js +89 -0
  233. package/dist/chunk-my40g5hp.js +560 -0
  234. package/dist/chunk-n0kmh4ra.js +338 -0
  235. package/dist/chunk-n18q5yqs.js +397 -0
  236. package/dist/chunk-n7pnyq43.js +131 -0
  237. package/dist/chunk-naybw0p0.js +32 -0
  238. package/dist/chunk-nb6abcch.js +83 -0
  239. package/dist/chunk-ne5r3k03.js +350 -0
  240. package/dist/chunk-nebezy1d.js +997 -0
  241. package/dist/chunk-netzwgv1.js +154 -0
  242. package/dist/chunk-nhapyawz.js +32994 -0
  243. package/dist/chunk-npnvheft.js +156 -0
  244. package/dist/chunk-nrtksr2p.js +51 -0
  245. package/dist/chunk-nw9t5pq9.js +132 -0
  246. package/dist/chunk-nxgsnh2y.js +735 -0
  247. package/dist/chunk-p11xp4xp.js +266 -0
  248. package/dist/chunk-p1hwrf72.js +74 -0
  249. package/dist/chunk-p1zj9mg9.js +567 -0
  250. package/dist/chunk-p39a677r.js +115 -0
  251. package/dist/chunk-p7vkh4wx.js +15 -0
  252. package/dist/chunk-p8na2wwp.js +14 -0
  253. package/dist/chunk-pcb7fbyg.js +259 -0
  254. package/dist/chunk-pckwmrzd.js +409 -0
  255. package/dist/chunk-ped973jn.js +111 -0
  256. package/dist/chunk-phd1qfpc.js +5971 -0
  257. package/dist/chunk-pkkngdv0.js +524 -0
  258. package/dist/chunk-ppwjyveh.js +8 -0
  259. package/dist/chunk-pqvr8jq7.js +324 -0
  260. package/dist/chunk-prcah3ys.js +106 -0
  261. package/dist/chunk-ps49ymvj.js +43 -0
  262. package/dist/chunk-pwwa7s62.js +11 -0
  263. package/dist/chunk-pxdzy0jh.js +134 -0
  264. package/dist/chunk-q3jr5t07.js +62 -0
  265. package/dist/chunk-q6cfkntd.js +675 -0
  266. package/dist/chunk-q6m26rc8.js +88 -0
  267. package/dist/chunk-q6xs51jj.js +332 -0
  268. package/dist/chunk-q7jnesv8.js +74 -0
  269. package/dist/chunk-q7zpf4r2.js +440 -0
  270. package/dist/chunk-q8c88vjm.js +24 -0
  271. package/dist/chunk-qajrkk97.js +298 -0
  272. package/dist/chunk-qatfdxvd.js +34 -0
  273. package/dist/chunk-qb6k2afy.js +153 -0
  274. package/dist/chunk-qfk94vcn.js +329 -0
  275. package/dist/chunk-qj2e1apf.js +471 -0
  276. package/dist/chunk-qj2mk79w.js +111 -0
  277. package/dist/chunk-qk7dfae6.js +267 -0
  278. package/dist/chunk-qnfx3qtx.js +617 -0
  279. package/dist/chunk-qp2qdcda.js +100 -0
  280. package/dist/chunk-qq0phwn8.js +458 -0
  281. package/dist/chunk-qwqjesx7.js +258 -0
  282. package/dist/chunk-qygmcg7w.js +60 -0
  283. package/dist/chunk-qz2x630m.js +49145 -0
  284. package/dist/chunk-qzj4e8fn.js +357 -0
  285. package/dist/chunk-ratvcbmn.js +255 -0
  286. package/dist/chunk-rkg741k3.js +37 -0
  287. package/dist/chunk-rn0v1hk8.js +34 -0
  288. package/dist/chunk-rsq0h0rz.js +91 -0
  289. package/dist/chunk-rvnb2gn6.js +1053 -0
  290. package/dist/chunk-rx278zpa.js +75 -0
  291. package/dist/chunk-s3hsqf80.js +473 -0
  292. package/dist/chunk-s4cb0bcb.js +655 -0
  293. package/dist/chunk-s8kj6ajy.js +32 -0
  294. package/dist/chunk-sd36yzx8.js +954 -0
  295. package/dist/chunk-sfcpjh4r.js +98 -0
  296. package/dist/chunk-spybh2dy.js +175 -0
  297. package/dist/chunk-sw9ax3ym.js +92 -0
  298. package/dist/chunk-szj5wvdy.js +28 -0
  299. package/dist/chunk-t29a6zb5.js +45 -0
  300. package/dist/chunk-t9p85zff.js +24 -0
  301. package/dist/chunk-tc1aazk4.js +131 -0
  302. package/dist/chunk-tdbz9gbm.js +1030 -0
  303. package/dist/chunk-tjcfpk38.js +208 -0
  304. package/dist/chunk-tp2jxmcx.js +8427 -0
  305. package/dist/chunk-tqmtkm0k.js +92 -0
  306. package/dist/chunk-tvgvt220.js +22820 -0
  307. package/dist/chunk-v0qraze5.js +291 -0
  308. package/dist/chunk-v1kzp02e.js +785 -0
  309. package/dist/chunk-v78fj8by.js +145 -0
  310. package/dist/chunk-v8g3kad0.js +101 -0
  311. package/dist/chunk-v9smspw2.js +4301 -0
  312. package/dist/chunk-vawgyev5.js +157 -0
  313. package/dist/chunk-vb3x3cxe.js +375 -0
  314. package/dist/chunk-vf612n57.js +472 -0
  315. package/dist/chunk-vjn8mbcw.js +198 -0
  316. package/dist/chunk-vmbfv1y5.js +295 -0
  317. package/dist/chunk-vrf54kmt.js +321 -0
  318. package/dist/chunk-vyjeh50y.js +2149 -0
  319. package/dist/chunk-vzgkedm9.js +159745 -0
  320. package/dist/chunk-w004kfw0.js +245 -0
  321. package/dist/chunk-w0yhbmxn.js +132 -0
  322. package/dist/chunk-w4yn8cq7.js +123 -0
  323. package/dist/chunk-waqwgprq.js +1164 -0
  324. package/dist/chunk-wayfjcwt.js +447 -0
  325. package/dist/chunk-wby6yd4m.js +91 -0
  326. package/dist/chunk-wha6v7za.js +705 -0
  327. package/dist/chunk-wjcq2vkf.js +641 -0
  328. package/dist/chunk-wtjt9qyk.js +2670 -0
  329. package/dist/chunk-x2pvw7xw.js +42 -0
  330. package/dist/chunk-x6r4v44b.js +8 -0
  331. package/dist/chunk-x8d2ehd7.js +19 -0
  332. package/dist/chunk-xd6kmmb1.js +95 -0
  333. package/dist/chunk-xp61y5ba.js +125 -0
  334. package/dist/chunk-xv3era3s.js +8 -0
  335. package/dist/chunk-xxw9a0bq.js +58 -0
  336. package/dist/chunk-xzhaa7gd.js +112 -0
  337. package/dist/chunk-y1784krc.js +19 -0
  338. package/dist/chunk-y4ca9kqz.js +3830 -0
  339. package/dist/chunk-yff68ex1.js +113 -0
  340. package/dist/chunk-yg4vgpxs.js +436 -0
  341. package/dist/chunk-yk62vxj2.js +2964 -0
  342. package/dist/chunk-ym5r3jnk.js +2007 -0
  343. package/dist/chunk-ysanv95x.js +225 -0
  344. package/dist/chunk-yvtzznds.js +63 -0
  345. package/dist/chunk-yyex5gsf.js +269 -0
  346. package/dist/chunk-yyf72f78.js +456 -0
  347. package/dist/chunk-z19sd3bt.js +1648 -0
  348. package/dist/chunk-z2dp53wn.js +17 -0
  349. package/dist/chunk-z9n0183s.js +39 -0
  350. package/dist/chunk-zb8f6h5g.js +9174 -0
  351. package/dist/chunk-zctfbr1v.js +594 -0
  352. package/dist/chunk-zesnmkg3.js +2840 -0
  353. package/dist/chunk-zf47r1b7.js +94 -0
  354. package/dist/chunk-zghtdbat.js +253 -0
  355. package/dist/chunk-zpmwvd09.js +275 -0
  356. package/dist/chunk-zqncgyf6.js +127 -0
  357. package/dist/chunk-zr6mz36s.js +281 -0
  358. package/dist/chunk-zshzdw1n.js +141 -0
  359. package/dist/chunk-zx5kw7z4.js +40 -0
  360. package/dist/chunk-zzm33q8x.js +8 -0
  361. package/dist/cli.js +91 -0
  362. package/dist/download-ripgrep.js +24821 -0
  363. package/dist/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
  364. package/dist/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
  365. package/dist/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
  366. package/dist/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
  367. package/dist/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
  368. package/dist/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
  369. package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
  370. package/package.json +122 -0
  371. package/scripts/postinstall.cjs +319 -0
@@ -0,0 +1,2520 @@
1
+ // @bun
2
+ import {
3
+ ConfigurableShortcutHint,
4
+ OAuthService,
5
+ Select,
6
+ SelectMulti,
7
+ Spinner,
8
+ TextInput,
9
+ init_ConfigurableShortcutHint,
10
+ init_CustomSelect,
11
+ init_SelectMulti,
12
+ init_Spinner,
13
+ init_TextInput,
14
+ init_oauth,
15
+ init_useTerminalSize
16
+ } from "./chunk-vzgkedm9.js";
17
+ import"./chunk-46hdszda.js";
18
+ import"./chunk-hwfknpxv.js";
19
+ import"./chunk-4nspekjp.js";
20
+ import"./chunk-jzthz1bx.js";
21
+ import"./chunk-1gx78081.js";
22
+ import"./chunk-2gzv8nrw.js";
23
+ import"./chunk-ehtwnxpg.js";
24
+ import"./chunk-68w91pzt.js";
25
+ import"./chunk-s4cb0bcb.js";
26
+ import"./chunk-cgfdkzhb.js";
27
+ import"./chunk-bxcfz5gy.js";
28
+ import"./chunk-nebezy1d.js";
29
+ import"./chunk-wayfjcwt.js";
30
+ import {
31
+ init_useExitOnCtrlCDWithKeybindings,
32
+ useExitOnCtrlCDWithKeybindings
33
+ } from "./chunk-kbm69rtz.js";
34
+ import"./chunk-j5bth84e.js";
35
+ import"./chunk-nxgsnh2y.js";
36
+ import {
37
+ init_useKeybinding
38
+ } from "./chunk-68ffk5qa.js";
39
+ import"./chunk-ps49ymvj.js";
40
+ import"./chunk-bmbq6nt1.js";
41
+ import"./chunk-15sfg4bs.js";
42
+ import"./chunk-p7vkh4wx.js";
43
+ import"./chunk-b0qptb1k.js";
44
+ import {
45
+ init_browser,
46
+ openBrowser
47
+ } from "./chunk-m87bhhqv.js";
48
+ import"./chunk-j3zhb8vv.js";
49
+ import"./chunk-b2fd462a.js";
50
+ import"./chunk-c11swzas.js";
51
+ import"./chunk-chsyvavm.js";
52
+ import"./chunk-5rv9c8yd.js";
53
+ import {
54
+ getAnthropicApiKey,
55
+ init_auth,
56
+ init_config,
57
+ init_stringUtils,
58
+ isAnthropicAuthEnabled,
59
+ plural,
60
+ saveGlobalConfig,
61
+ saveOAuthTokensIfNeeded
62
+ } from "./chunk-tp2jxmcx.js";
63
+ import"./chunk-z19sd3bt.js";
64
+ import"./chunk-1ax1znzj.js";
65
+ import"./chunk-wha6v7za.js";
66
+ import"./chunk-6nsd9606.js";
67
+ import"./chunk-xp61y5ba.js";
68
+ import"./chunk-64c1avct.js";
69
+ import"./chunk-8g5pe1gr.js";
70
+ import"./chunk-4cp6193g.js";
71
+ import"./chunk-8g747a8x.js";
72
+ import"./chunk-d7886r6a.js";
73
+ import"./chunk-yvtzznds.js";
74
+ import"./chunk-4jm600zv.js";
75
+ import"./chunk-qz2x630m.js";
76
+ import"./chunk-2f21meep.js";
77
+ import"./chunk-nrtksr2p.js";
78
+ import"./chunk-3c25bcsw.js";
79
+ import"./chunk-s3hsqf80.js";
80
+ import"./chunk-yyf72f78.js";
81
+ import"./chunk-cdz5yb0r.js";
82
+ import {
83
+ Byline,
84
+ Dialog,
85
+ KeyboardShortcutHint,
86
+ Link,
87
+ ThemedBox_default,
88
+ ThemedText,
89
+ color,
90
+ init_src,
91
+ setClipboard,
92
+ useKeybinding,
93
+ useKeybindings,
94
+ useTerminalSize,
95
+ useTheme
96
+ } from "./chunk-c7jwbe76.js";
97
+ import"./chunk-0vkfrmqm.js";
98
+ import {
99
+ require_jsx_dev_runtime,
100
+ require_react
101
+ } from "./chunk-7sgtxrsc.js";
102
+ import"./chunk-0xjaqda8.js";
103
+ import {
104
+ init_analytics,
105
+ logEvent
106
+ } from "./chunk-x8d2ehd7.js";
107
+ import"./chunk-15m49c67.js";
108
+ import {
109
+ getGithubRepo,
110
+ init_git
111
+ } from "./chunk-tdbz9gbm.js";
112
+ import"./chunk-0awwmrwr.js";
113
+ import"./chunk-qnfx3qtx.js";
114
+ import {
115
+ execFileNoThrow,
116
+ init_execFileNoThrow
117
+ } from "./chunk-70eey1nh.js";
118
+ import {
119
+ init_log,
120
+ logError
121
+ } from "./chunk-1nk93fqz.js";
122
+ import"./chunk-s8kj6ajy.js";
123
+ import"./chunk-eenq3avg.js";
124
+ import"./chunk-7mqab3z7.js";
125
+ import {
126
+ execa,
127
+ init_execa
128
+ } from "./chunk-5z28bqne.js";
129
+ import {
130
+ figures_default,
131
+ init_figures
132
+ } from "./chunk-qajrkk97.js";
133
+ import"./chunk-phd1qfpc.js";
134
+ import"./chunk-fbv4apne.js";
135
+ import"./chunk-jaaxk89e.js";
136
+ import"./chunk-k8vp0atq.js";
137
+ import"./chunk-vf612n57.js";
138
+ import"./chunk-07069jq1.js";
139
+ import"./chunk-d4mdda98.js";
140
+ import"./chunk-55raexh7.js";
141
+ import"./chunk-v9smspw2.js";
142
+ import"./chunk-v1kzp02e.js";
143
+ import"./chunk-7wm5s02e.js";
144
+ import"./chunk-b0kf00ff.js";
145
+ import"./chunk-netzwgv1.js";
146
+ import {
147
+ __esm,
148
+ __toESM
149
+ } from "./chunk-qp2qdcda.js";
150
+
151
+ // src/components/WorkflowMultiselectDialog.tsx
152
+ function renderInputGuide(exitState) {
153
+ if (exitState.pending) {
154
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
155
+ children: [
156
+ "Press ",
157
+ exitState.keyName,
158
+ " again to exit"
159
+ ]
160
+ }, undefined, true, undefined, this);
161
+ }
162
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Byline, {
163
+ children: [
164
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(KeyboardShortcutHint, {
165
+ shortcut: "\u2191\u2193",
166
+ action: "navigate"
167
+ }, undefined, false, undefined, this),
168
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(KeyboardShortcutHint, {
169
+ shortcut: "Space",
170
+ action: "toggle"
171
+ }, undefined, false, undefined, this),
172
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(KeyboardShortcutHint, {
173
+ shortcut: "Enter",
174
+ action: "confirm"
175
+ }, undefined, false, undefined, this),
176
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ConfigurableShortcutHint, {
177
+ action: "confirm:no",
178
+ context: "Confirmation",
179
+ fallback: "Esc",
180
+ description: "cancel"
181
+ }, undefined, false, undefined, this)
182
+ ]
183
+ }, undefined, true, undefined, this);
184
+ }
185
+ function WorkflowMultiselectDialog({
186
+ onSubmit,
187
+ defaultSelections
188
+ }) {
189
+ const [showError, setShowError] = import_react.useState(false);
190
+ const handleSubmit = import_react.useCallback((selectedValues) => {
191
+ if (selectedValues.length === 0) {
192
+ setShowError(true);
193
+ return;
194
+ }
195
+ setShowError(false);
196
+ onSubmit(selectedValues);
197
+ }, [onSubmit]);
198
+ const handleChange = import_react.useCallback(() => {
199
+ setShowError(false);
200
+ }, []);
201
+ const handleCancel = import_react.useCallback(() => {
202
+ setShowError(true);
203
+ }, []);
204
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Dialog, {
205
+ title: "Select GitHub workflows to install",
206
+ subtitle: "We'll create a workflow file in your repository for each one you select.",
207
+ onCancel: handleCancel,
208
+ inputGuide: renderInputGuide,
209
+ children: [
210
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
211
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
212
+ dimColor: true,
213
+ children: [
214
+ "More workflow examples (issue triage, CI fixes, etc.) at:",
215
+ " ",
216
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(Link, {
217
+ url: "https://github.com/anthropics/claude-code-action/blob/main/examples/",
218
+ children: "https://github.com/anthropics/claude-code-action/blob/main/examples/"
219
+ }, undefined, false, undefined, this)
220
+ ]
221
+ }, undefined, true, undefined, this)
222
+ }, undefined, false, undefined, this),
223
+ /* @__PURE__ */ jsx_dev_runtime.jsxDEV(SelectMulti, {
224
+ options: WORKFLOWS.map((workflow) => ({
225
+ label: workflow.label,
226
+ value: workflow.value
227
+ })),
228
+ defaultValue: defaultSelections,
229
+ onSubmit: handleSubmit,
230
+ onChange: handleChange,
231
+ onCancel: handleCancel,
232
+ hideIndexes: true
233
+ }, undefined, false, undefined, this),
234
+ showError && /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedBox_default, {
235
+ children: /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ThemedText, {
236
+ color: "error",
237
+ children: "You must select at least one workflow to continue"
238
+ }, undefined, false, undefined, this)
239
+ }, undefined, false, undefined, this)
240
+ ]
241
+ }, undefined, true, undefined, this);
242
+ }
243
+ var import_react, jsx_dev_runtime, WORKFLOWS;
244
+ var init_WorkflowMultiselectDialog = __esm(() => {
245
+ init_src();
246
+ init_ConfigurableShortcutHint();
247
+ init_SelectMulti();
248
+ import_react = __toESM(require_react(), 1);
249
+ jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
250
+ WORKFLOWS = [
251
+ {
252
+ value: "claude",
253
+ label: "@Claude Code - Tag @claude in issues and PR comments"
254
+ },
255
+ {
256
+ value: "claude-review",
257
+ label: "Claude Code Review - Automated code review on new PRs"
258
+ }
259
+ ];
260
+ });
261
+
262
+ // src/constants/github-app.ts
263
+ var PR_TITLE = "Add Claude Code GitHub Workflow", GITHUB_ACTION_SETUP_DOCS_URL = "https://github.com/anthropics/claude-code-action/blob/main/docs/setup.md", WORKFLOW_CONTENT = `name: Claude Code
264
+
265
+ on:
266
+ issue_comment:
267
+ types: [created]
268
+ pull_request_review_comment:
269
+ types: [created]
270
+ issues:
271
+ types: [opened, assigned]
272
+ pull_request_review:
273
+ types: [submitted]
274
+
275
+ jobs:
276
+ claude:
277
+ if: |
278
+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
279
+ (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
280
+ (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
281
+ (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
282
+ runs-on: ubuntu-latest
283
+ permissions:
284
+ contents: read
285
+ pull-requests: read
286
+ issues: read
287
+ id-token: write
288
+ actions: read # Required for Claude to read CI results on PRs
289
+ steps:
290
+ - name: Checkout repository
291
+ uses: actions/checkout@v4
292
+ with:
293
+ fetch-depth: 1
294
+
295
+ - name: Run Claude Code
296
+ id: claude
297
+ uses: anthropics/claude-code-action@v1
298
+ with:
299
+ anthropic_api_key: \${{ secrets.ANTHROPIC_API_KEY }}
300
+
301
+ # This is an optional setting that allows Claude to read CI results on PRs
302
+ additional_permissions: |
303
+ actions: read
304
+
305
+ # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
306
+ # prompt: 'Update the pull request description to include a summary of changes.'
307
+
308
+ # Optional: Add claude_args to customize behavior and configuration
309
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
310
+ # or https://code.claude.com/docs/en/cli-reference for available options
311
+ # claude_args: '--allowed-tools Bash(gh pr:*)'
312
+
313
+ `, PR_BODY = `## \uD83E\uDD16 Installing Claude Code GitHub App
314
+
315
+ This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.
316
+
317
+ ### What is Claude Code?
318
+
319
+ [Claude Code](https://claude.com/claude-code) is an AI coding agent that can help with:
320
+ - Bug fixes and improvements
321
+ - Documentation updates
322
+ - Implementing new features
323
+ - Code reviews and suggestions
324
+ - Writing tests
325
+ - And more!
326
+
327
+ ### How it works
328
+
329
+ Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
330
+ Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.
331
+
332
+ ### Important Notes
333
+
334
+ - **This workflow won't take effect until this PR is merged**
335
+ - **@claude mentions won't work until after the merge is complete**
336
+ - The workflow runs automatically whenever Claude is mentioned in PR or issue comments
337
+ - Claude gets access to the entire PR or issue context including files, diffs, and previous comments
338
+
339
+ ### Security
340
+
341
+ - Our Anthropic API key is securely stored as a GitHub Actions secret
342
+ - Only users with write access to the repository can trigger the workflow
343
+ - All Claude runs are stored in the GitHub Actions run history
344
+ - Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
345
+ - We can add more allowed tools by adding them to the workflow file like:
346
+
347
+ \`\`\`
348
+ allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)
349
+ \`\`\`
350
+
351
+ There's more information in the [Claude Code action repo](https://github.com/anthropics/claude-code-action).
352
+
353
+ After merging this PR, let's try mentioning @claude in a comment on any PR to get started!`, CODE_REVIEW_PLUGIN_WORKFLOW_CONTENT = `name: Claude Code Review
354
+
355
+ on:
356
+ pull_request:
357
+ types: [opened, synchronize, ready_for_review, reopened]
358
+ # Optional: Only run on specific file changes
359
+ # paths:
360
+ # - "src/**/*.ts"
361
+ # - "src/**/*.tsx"
362
+ # - "src/**/*.js"
363
+ # - "src/**/*.jsx"
364
+
365
+ jobs:
366
+ claude-review:
367
+ # Optional: Filter by PR author
368
+ # if: |
369
+ # github.event.pull_request.user.login == 'external-contributor' ||
370
+ # github.event.pull_request.user.login == 'new-developer' ||
371
+ # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
372
+
373
+ runs-on: ubuntu-latest
374
+ permissions:
375
+ contents: read
376
+ pull-requests: read
377
+ issues: read
378
+ id-token: write
379
+
380
+ steps:
381
+ - name: Checkout repository
382
+ uses: actions/checkout@v4
383
+ with:
384
+ fetch-depth: 1
385
+
386
+ - name: Run Claude Code Review
387
+ id: claude-review
388
+ uses: anthropics/claude-code-action@v1
389
+ with:
390
+ anthropic_api_key: \${{ secrets.ANTHROPIC_API_KEY }}
391
+ plugin_marketplaces: 'https://github.com/anthropics/claude-code.git'
392
+ plugins: 'code-review@claude-code-plugins'
393
+ prompt: '/code-review:code-review \${{ github.repository }}/pull/\${{ github.event.pull_request.number }}'
394
+ # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
395
+ # or https://code.claude.com/docs/en/cli-reference for available options
396
+
397
+ `;
398
+ var init_github_app = () => {};
399
+
400
+ // src/commands/install-github-app/ApiKeyStep.tsx
401
+ function ApiKeyStep({
402
+ existingApiKey,
403
+ apiKeyOrOAuthToken,
404
+ onApiKeyChange,
405
+ onSubmit,
406
+ onToggleUseExistingKey,
407
+ onCreateOAuthToken,
408
+ selectedOption = existingApiKey ? "existing" : onCreateOAuthToken ? "oauth" : "new",
409
+ onSelectOption
410
+ }) {
411
+ const [cursorOffset, setCursorOffset] = import_react2.useState(0);
412
+ const terminalSize = useTerminalSize();
413
+ const [theme] = useTheme();
414
+ const handlePrevious = import_react2.useCallback(() => {
415
+ if (selectedOption === "new" && onCreateOAuthToken) {
416
+ onSelectOption?.("oauth");
417
+ } else if (selectedOption === "oauth" && existingApiKey) {
418
+ onSelectOption?.("existing");
419
+ onToggleUseExistingKey(true);
420
+ }
421
+ }, [
422
+ selectedOption,
423
+ onCreateOAuthToken,
424
+ existingApiKey,
425
+ onSelectOption,
426
+ onToggleUseExistingKey
427
+ ]);
428
+ const handleNext = import_react2.useCallback(() => {
429
+ if (selectedOption === "existing") {
430
+ onSelectOption?.(onCreateOAuthToken ? "oauth" : "new");
431
+ onToggleUseExistingKey(false);
432
+ } else if (selectedOption === "oauth") {
433
+ onSelectOption?.("new");
434
+ }
435
+ }, [
436
+ selectedOption,
437
+ onCreateOAuthToken,
438
+ onSelectOption,
439
+ onToggleUseExistingKey
440
+ ]);
441
+ const handleConfirm = import_react2.useCallback(() => {
442
+ if (selectedOption === "oauth" && onCreateOAuthToken) {
443
+ onCreateOAuthToken();
444
+ } else {
445
+ onSubmit();
446
+ }
447
+ }, [selectedOption, onCreateOAuthToken, onSubmit]);
448
+ const isTextInputVisible = selectedOption === "new";
449
+ useKeybindings({
450
+ "confirm:previous": handlePrevious,
451
+ "confirm:next": handleNext,
452
+ "confirm:yes": handleConfirm
453
+ }, { context: "Confirmation", isActive: !isTextInputVisible });
454
+ useKeybindings({
455
+ "confirm:previous": handlePrevious,
456
+ "confirm:next": handleNext
457
+ }, { context: "Confirmation", isActive: isTextInputVisible });
458
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(jsx_dev_runtime2.Fragment, {
459
+ children: [
460
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
461
+ flexDirection: "column",
462
+ borderStyle: "round",
463
+ paddingX: 1,
464
+ children: [
465
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
466
+ flexDirection: "column",
467
+ marginBottom: 1,
468
+ children: [
469
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
470
+ bold: true,
471
+ children: "Install GitHub App"
472
+ }, undefined, false, undefined, this),
473
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
474
+ dimColor: true,
475
+ children: "Choose API key"
476
+ }, undefined, false, undefined, this)
477
+ ]
478
+ }, undefined, true, undefined, this),
479
+ existingApiKey && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
480
+ marginBottom: 1,
481
+ children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
482
+ children: [
483
+ selectedOption === "existing" ? color("success", theme)("> ") : " ",
484
+ "Use your existing Claude Code API key"
485
+ ]
486
+ }, undefined, true, undefined, this)
487
+ }, undefined, false, undefined, this),
488
+ onCreateOAuthToken && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
489
+ marginBottom: 1,
490
+ children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
491
+ children: [
492
+ selectedOption === "oauth" ? color("success", theme)("> ") : " ",
493
+ "Create a long-lived token with your Claude subscription"
494
+ ]
495
+ }, undefined, true, undefined, this)
496
+ }, undefined, false, undefined, this),
497
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
498
+ marginBottom: 1,
499
+ children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
500
+ children: [
501
+ selectedOption === "new" ? color("success", theme)("> ") : " ",
502
+ "Enter a new API key"
503
+ ]
504
+ }, undefined, true, undefined, this)
505
+ }, undefined, false, undefined, this),
506
+ selectedOption === "new" && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(TextInput, {
507
+ value: apiKeyOrOAuthToken,
508
+ onChange: onApiKeyChange,
509
+ onSubmit,
510
+ onPaste: onApiKeyChange,
511
+ focus: true,
512
+ placeholder: "sk-ant\u2026 (Create a new key at https://platform.claude.com/settings/keys)",
513
+ mask: "*",
514
+ columns: terminalSize.columns,
515
+ cursorOffset,
516
+ onChangeCursorOffset: setCursorOffset,
517
+ showCursor: true
518
+ }, undefined, false, undefined, this)
519
+ ]
520
+ }, undefined, true, undefined, this),
521
+ /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedBox_default, {
522
+ marginLeft: 3,
523
+ children: /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ThemedText, {
524
+ dimColor: true,
525
+ children: "\u2191/\u2193 to select \xB7 Enter to continue"
526
+ }, undefined, false, undefined, this)
527
+ }, undefined, false, undefined, this)
528
+ ]
529
+ }, undefined, true, undefined, this);
530
+ }
531
+ var import_react2, jsx_dev_runtime2;
532
+ var init_ApiKeyStep = __esm(() => {
533
+ init_TextInput();
534
+ init_useTerminalSize();
535
+ init_src();
536
+ init_useKeybinding();
537
+ import_react2 = __toESM(require_react(), 1);
538
+ jsx_dev_runtime2 = __toESM(require_jsx_dev_runtime(), 1);
539
+ });
540
+
541
+ // src/commands/install-github-app/CheckExistingSecretStep.tsx
542
+ function CheckExistingSecretStep({
543
+ useExistingSecret,
544
+ secretName,
545
+ onToggleUseExistingSecret,
546
+ onSecretNameChange,
547
+ onSubmit
548
+ }) {
549
+ const [cursorOffset, setCursorOffset] = import_react3.useState(0);
550
+ const terminalSize = useTerminalSize();
551
+ const [theme] = useTheme();
552
+ const handlePrevious = import_react3.useCallback(() => onToggleUseExistingSecret(true), [onToggleUseExistingSecret]);
553
+ const handleNext = import_react3.useCallback(() => onToggleUseExistingSecret(false), [onToggleUseExistingSecret]);
554
+ useKeybindings({
555
+ "confirm:previous": handlePrevious,
556
+ "confirm:next": handleNext,
557
+ "confirm:yes": onSubmit
558
+ }, { context: "Confirmation", isActive: useExistingSecret });
559
+ useKeybindings({
560
+ "confirm:previous": handlePrevious,
561
+ "confirm:next": handleNext
562
+ }, { context: "Confirmation", isActive: !useExistingSecret });
563
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(jsx_dev_runtime3.Fragment, {
564
+ children: [
565
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
566
+ flexDirection: "column",
567
+ borderStyle: "round",
568
+ paddingX: 1,
569
+ children: [
570
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
571
+ flexDirection: "column",
572
+ marginBottom: 1,
573
+ children: [
574
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
575
+ bold: true,
576
+ children: "Install GitHub App"
577
+ }, undefined, false, undefined, this),
578
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
579
+ dimColor: true,
580
+ children: "Setup API key secret"
581
+ }, undefined, false, undefined, this)
582
+ ]
583
+ }, undefined, true, undefined, this),
584
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
585
+ marginBottom: 1,
586
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
587
+ color: "warning",
588
+ children: "ANTHROPIC_API_KEY already exists in repository secrets!"
589
+ }, undefined, false, undefined, this)
590
+ }, undefined, false, undefined, this),
591
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
592
+ marginBottom: 1,
593
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
594
+ children: "Would you like to:"
595
+ }, undefined, false, undefined, this)
596
+ }, undefined, false, undefined, this),
597
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
598
+ marginBottom: 1,
599
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
600
+ children: [
601
+ useExistingSecret ? color("success", theme)("> ") : " ",
602
+ "Use the existing API key"
603
+ ]
604
+ }, undefined, true, undefined, this)
605
+ }, undefined, false, undefined, this),
606
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
607
+ marginBottom: 1,
608
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
609
+ children: [
610
+ !useExistingSecret ? color("success", theme)("> ") : " ",
611
+ "Create a new secret with a different name"
612
+ ]
613
+ }, undefined, true, undefined, this)
614
+ }, undefined, false, undefined, this),
615
+ !useExistingSecret && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(jsx_dev_runtime3.Fragment, {
616
+ children: [
617
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
618
+ marginBottom: 1,
619
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
620
+ children: "Enter new secret name (alphanumeric with underscores):"
621
+ }, undefined, false, undefined, this)
622
+ }, undefined, false, undefined, this),
623
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(TextInput, {
624
+ value: secretName,
625
+ onChange: onSecretNameChange,
626
+ onSubmit,
627
+ focus: true,
628
+ placeholder: "e.g., CLAUDE_API_KEY",
629
+ columns: terminalSize.columns,
630
+ cursorOffset,
631
+ onChangeCursorOffset: setCursorOffset,
632
+ showCursor: true
633
+ }, undefined, false, undefined, this)
634
+ ]
635
+ }, undefined, true, undefined, this)
636
+ ]
637
+ }, undefined, true, undefined, this),
638
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedBox_default, {
639
+ marginLeft: 3,
640
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ThemedText, {
641
+ dimColor: true,
642
+ children: "\u2191/\u2193 to select \xB7 Enter to continue"
643
+ }, undefined, false, undefined, this)
644
+ }, undefined, false, undefined, this)
645
+ ]
646
+ }, undefined, true, undefined, this);
647
+ }
648
+ var import_react3, jsx_dev_runtime3;
649
+ var init_CheckExistingSecretStep = __esm(() => {
650
+ init_TextInput();
651
+ init_useTerminalSize();
652
+ init_src();
653
+ init_useKeybinding();
654
+ import_react3 = __toESM(require_react(), 1);
655
+ jsx_dev_runtime3 = __toESM(require_jsx_dev_runtime(), 1);
656
+ });
657
+
658
+ // src/commands/install-github-app/CheckGitHubStep.tsx
659
+ function CheckGitHubStep() {
660
+ return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(ThemedText, {
661
+ children: "Checking GitHub CLI installation\u2026"
662
+ }, undefined, false, undefined, this);
663
+ }
664
+ var jsx_dev_runtime4;
665
+ var init_CheckGitHubStep = __esm(() => {
666
+ init_src();
667
+ jsx_dev_runtime4 = __toESM(require_jsx_dev_runtime(), 1);
668
+ });
669
+
670
+ // src/commands/install-github-app/ChooseRepoStep.tsx
671
+ function ChooseRepoStep({
672
+ currentRepo,
673
+ useCurrentRepo,
674
+ repoUrl,
675
+ onRepoUrlChange,
676
+ onSubmit,
677
+ onToggleUseCurrentRepo
678
+ }) {
679
+ const [cursorOffset, setCursorOffset] = import_react4.useState(0);
680
+ const [showEmptyError, setShowEmptyError] = import_react4.useState(false);
681
+ const terminalSize = useTerminalSize();
682
+ const textInputColumns = terminalSize.columns;
683
+ const handleSubmit = import_react4.useCallback(() => {
684
+ const repoName = useCurrentRepo ? currentRepo : repoUrl;
685
+ if (!repoName?.trim()) {
686
+ setShowEmptyError(true);
687
+ return;
688
+ }
689
+ onSubmit();
690
+ }, [useCurrentRepo, currentRepo, repoUrl, onSubmit]);
691
+ const isTextInputVisible = !useCurrentRepo || !currentRepo;
692
+ const handlePrevious = import_react4.useCallback(() => {
693
+ onToggleUseCurrentRepo(true);
694
+ setShowEmptyError(false);
695
+ }, [onToggleUseCurrentRepo]);
696
+ const handleNext = import_react4.useCallback(() => {
697
+ onToggleUseCurrentRepo(false);
698
+ setShowEmptyError(false);
699
+ }, [onToggleUseCurrentRepo]);
700
+ useKeybindings({
701
+ "confirm:previous": handlePrevious,
702
+ "confirm:next": handleNext,
703
+ "confirm:yes": handleSubmit
704
+ }, { context: "Confirmation", isActive: !isTextInputVisible });
705
+ useKeybindings({
706
+ "confirm:previous": handlePrevious,
707
+ "confirm:next": handleNext
708
+ }, { context: "Confirmation", isActive: isTextInputVisible });
709
+ return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(jsx_dev_runtime5.Fragment, {
710
+ children: [
711
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
712
+ flexDirection: "column",
713
+ borderStyle: "round",
714
+ paddingX: 1,
715
+ children: [
716
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
717
+ flexDirection: "column",
718
+ marginBottom: 1,
719
+ children: [
720
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
721
+ bold: true,
722
+ children: "Install GitHub App"
723
+ }, undefined, false, undefined, this),
724
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
725
+ dimColor: true,
726
+ children: "Select GitHub repository"
727
+ }, undefined, false, undefined, this)
728
+ ]
729
+ }, undefined, true, undefined, this),
730
+ currentRepo && /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
731
+ marginBottom: 1,
732
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
733
+ bold: useCurrentRepo,
734
+ color: useCurrentRepo ? "permission" : undefined,
735
+ children: [
736
+ useCurrentRepo ? "> " : " ",
737
+ "Use current repository: ",
738
+ currentRepo
739
+ ]
740
+ }, undefined, true, undefined, this)
741
+ }, undefined, false, undefined, this),
742
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
743
+ marginBottom: 1,
744
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
745
+ bold: !useCurrentRepo || !currentRepo,
746
+ color: !useCurrentRepo || !currentRepo ? "permission" : undefined,
747
+ children: [
748
+ !useCurrentRepo || !currentRepo ? "> " : " ",
749
+ currentRepo ? "Enter a different repository" : "Enter repository"
750
+ ]
751
+ }, undefined, true, undefined, this)
752
+ }, undefined, false, undefined, this),
753
+ (!useCurrentRepo || !currentRepo) && /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
754
+ marginLeft: 2,
755
+ marginBottom: 1,
756
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(TextInput, {
757
+ value: repoUrl,
758
+ onChange: (value) => {
759
+ onRepoUrlChange(value);
760
+ setShowEmptyError(false);
761
+ },
762
+ onSubmit: handleSubmit,
763
+ focus: true,
764
+ placeholder: "Enter a repo as owner/repo or https://github.com/owner/repo\u2026",
765
+ columns: textInputColumns,
766
+ cursorOffset,
767
+ onChangeCursorOffset: setCursorOffset,
768
+ showCursor: true
769
+ }, undefined, false, undefined, this)
770
+ }, undefined, false, undefined, this)
771
+ ]
772
+ }, undefined, true, undefined, this),
773
+ showEmptyError && /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
774
+ marginLeft: 3,
775
+ marginBottom: 1,
776
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
777
+ color: "error",
778
+ children: "Please enter a repository name to continue"
779
+ }, undefined, false, undefined, this)
780
+ }, undefined, false, undefined, this),
781
+ /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedBox_default, {
782
+ marginLeft: 3,
783
+ children: /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(ThemedText, {
784
+ dimColor: true,
785
+ children: [
786
+ currentRepo ? "\u2191/\u2193 to select \xB7 " : "",
787
+ "Enter to continue"
788
+ ]
789
+ }, undefined, true, undefined, this)
790
+ }, undefined, false, undefined, this)
791
+ ]
792
+ }, undefined, true, undefined, this);
793
+ }
794
+ var import_react4, jsx_dev_runtime5;
795
+ var init_ChooseRepoStep = __esm(() => {
796
+ init_TextInput();
797
+ init_useTerminalSize();
798
+ init_src();
799
+ init_useKeybinding();
800
+ import_react4 = __toESM(require_react(), 1);
801
+ jsx_dev_runtime5 = __toESM(require_jsx_dev_runtime(), 1);
802
+ });
803
+
804
+ // src/commands/install-github-app/CreatingStep.tsx
805
+ function CreatingStep({
806
+ currentWorkflowInstallStep,
807
+ secretExists,
808
+ useExistingSecret,
809
+ secretName,
810
+ skipWorkflow = false,
811
+ selectedWorkflows
812
+ }) {
813
+ const progressSteps = skipWorkflow ? [
814
+ "Getting repository information",
815
+ secretExists && useExistingSecret ? "Using existing API key secret" : `Setting up ${secretName} secret`
816
+ ] : [
817
+ "Getting repository information",
818
+ "Creating branch",
819
+ selectedWorkflows.length > 1 ? "Creating workflow files" : "Creating workflow file",
820
+ secretExists && useExistingSecret ? "Using existing API key secret" : `Setting up ${secretName} secret`,
821
+ "Opening pull request page"
822
+ ];
823
+ return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(jsx_dev_runtime6.Fragment, {
824
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedBox_default, {
825
+ flexDirection: "column",
826
+ borderStyle: "round",
827
+ paddingX: 1,
828
+ children: [
829
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedBox_default, {
830
+ flexDirection: "column",
831
+ marginBottom: 1,
832
+ children: [
833
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedText, {
834
+ bold: true,
835
+ children: "Install GitHub App"
836
+ }, undefined, false, undefined, this),
837
+ /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedText, {
838
+ dimColor: true,
839
+ children: "Create GitHub Actions workflow"
840
+ }, undefined, false, undefined, this)
841
+ ]
842
+ }, undefined, true, undefined, this),
843
+ progressSteps.map((stepText, index) => {
844
+ let status = "pending";
845
+ if (index < currentWorkflowInstallStep) {
846
+ status = "completed";
847
+ } else if (index === currentWorkflowInstallStep) {
848
+ status = "in-progress";
849
+ }
850
+ return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedBox_default, {
851
+ children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(ThemedText, {
852
+ color: status === "completed" ? "success" : status === "in-progress" ? "warning" : undefined,
853
+ children: [
854
+ status === "completed" ? "\u2713 " : "",
855
+ stepText,
856
+ status === "in-progress" ? "\u2026" : ""
857
+ ]
858
+ }, undefined, true, undefined, this)
859
+ }, index, false, undefined, this);
860
+ })
861
+ ]
862
+ }, undefined, true, undefined, this)
863
+ }, undefined, false, undefined, this);
864
+ }
865
+ var jsx_dev_runtime6;
866
+ var init_CreatingStep = __esm(() => {
867
+ init_src();
868
+ jsx_dev_runtime6 = __toESM(require_jsx_dev_runtime(), 1);
869
+ });
870
+
871
+ // src/commands/install-github-app/ErrorStep.tsx
872
+ function ErrorStep({
873
+ error,
874
+ errorReason,
875
+ errorInstructions
876
+ }) {
877
+ return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(jsx_dev_runtime7.Fragment, {
878
+ children: [
879
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
880
+ flexDirection: "column",
881
+ borderStyle: "round",
882
+ paddingX: 1,
883
+ children: [
884
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
885
+ flexDirection: "column",
886
+ marginBottom: 1,
887
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
888
+ bold: true,
889
+ children: "Install GitHub App"
890
+ }, undefined, false, undefined, this)
891
+ }, undefined, false, undefined, this),
892
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
893
+ color: "error",
894
+ children: [
895
+ "Error: ",
896
+ error
897
+ ]
898
+ }, undefined, true, undefined, this),
899
+ errorReason && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
900
+ marginTop: 1,
901
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
902
+ dimColor: true,
903
+ children: [
904
+ "Reason: ",
905
+ errorReason
906
+ ]
907
+ }, undefined, true, undefined, this)
908
+ }, undefined, false, undefined, this),
909
+ errorInstructions && errorInstructions.length > 0 && /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
910
+ flexDirection: "column",
911
+ marginTop: 1,
912
+ children: [
913
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
914
+ dimColor: true,
915
+ children: "How to fix:"
916
+ }, undefined, false, undefined, this),
917
+ errorInstructions.map((instruction, index) => /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
918
+ marginLeft: 2,
919
+ children: [
920
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
921
+ dimColor: true,
922
+ children: "\u2022 "
923
+ }, undefined, false, undefined, this),
924
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
925
+ children: instruction
926
+ }, undefined, false, undefined, this)
927
+ ]
928
+ }, index, true, undefined, this))
929
+ ]
930
+ }, undefined, true, undefined, this),
931
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
932
+ marginTop: 1,
933
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
934
+ dimColor: true,
935
+ children: [
936
+ "For manual setup instructions, see:",
937
+ " ",
938
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
939
+ color: "claude",
940
+ children: GITHUB_ACTION_SETUP_DOCS_URL
941
+ }, undefined, false, undefined, this)
942
+ ]
943
+ }, undefined, true, undefined, this)
944
+ }, undefined, false, undefined, this)
945
+ ]
946
+ }, undefined, true, undefined, this),
947
+ /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedBox_default, {
948
+ marginLeft: 3,
949
+ children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV(ThemedText, {
950
+ dimColor: true,
951
+ children: "Press any key to exit"
952
+ }, undefined, false, undefined, this)
953
+ }, undefined, false, undefined, this)
954
+ ]
955
+ }, undefined, true, undefined, this);
956
+ }
957
+ var jsx_dev_runtime7;
958
+ var init_ErrorStep = __esm(() => {
959
+ init_github_app();
960
+ init_src();
961
+ jsx_dev_runtime7 = __toESM(require_jsx_dev_runtime(), 1);
962
+ });
963
+
964
+ // src/commands/install-github-app/ExistingWorkflowStep.tsx
965
+ function ExistingWorkflowStep({
966
+ repoName,
967
+ onSelectAction
968
+ }) {
969
+ const options = [
970
+ {
971
+ label: "Update workflow file with latest version",
972
+ value: "update"
973
+ },
974
+ {
975
+ label: "Skip workflow update (configure secrets only)",
976
+ value: "skip"
977
+ },
978
+ {
979
+ label: "Exit without making changes",
980
+ value: "exit"
981
+ }
982
+ ];
983
+ const handleSelect = (value) => {
984
+ onSelectAction(value);
985
+ };
986
+ const handleCancel = () => {
987
+ onSelectAction("exit");
988
+ };
989
+ return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedBox_default, {
990
+ flexDirection: "column",
991
+ borderStyle: "round",
992
+ borderDimColor: true,
993
+ paddingX: 1,
994
+ children: [
995
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedBox_default, {
996
+ flexDirection: "column",
997
+ marginBottom: 1,
998
+ children: [
999
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedText, {
1000
+ bold: true,
1001
+ children: "Existing Workflow Found"
1002
+ }, undefined, false, undefined, this),
1003
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedText, {
1004
+ dimColor: true,
1005
+ children: [
1006
+ "Repository: ",
1007
+ repoName
1008
+ ]
1009
+ }, undefined, true, undefined, this)
1010
+ ]
1011
+ }, undefined, true, undefined, this),
1012
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedBox_default, {
1013
+ flexDirection: "column",
1014
+ marginBottom: 1,
1015
+ children: [
1016
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedText, {
1017
+ children: [
1018
+ "A Claude workflow file already exists at",
1019
+ " ",
1020
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedText, {
1021
+ color: "claude",
1022
+ children: ".github/workflows/claude.yml"
1023
+ }, undefined, false, undefined, this)
1024
+ ]
1025
+ }, undefined, true, undefined, this),
1026
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedText, {
1027
+ dimColor: true,
1028
+ children: "What would you like to do?"
1029
+ }, undefined, false, undefined, this)
1030
+ ]
1031
+ }, undefined, true, undefined, this),
1032
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedBox_default, {
1033
+ flexDirection: "column",
1034
+ children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Select, {
1035
+ options,
1036
+ onChange: handleSelect,
1037
+ onCancel: handleCancel
1038
+ }, undefined, false, undefined, this)
1039
+ }, undefined, false, undefined, this),
1040
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedBox_default, {
1041
+ marginTop: 1,
1042
+ children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedText, {
1043
+ dimColor: true,
1044
+ children: [
1045
+ "View the latest workflow template at:",
1046
+ " ",
1047
+ /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(ThemedText, {
1048
+ color: "claude",
1049
+ children: "https://github.com/anthropics/claude-code-action/blob/main/examples/claude.yml"
1050
+ }, undefined, false, undefined, this)
1051
+ ]
1052
+ }, undefined, true, undefined, this)
1053
+ }, undefined, false, undefined, this)
1054
+ ]
1055
+ }, undefined, true, undefined, this);
1056
+ }
1057
+ var jsx_dev_runtime8;
1058
+ var init_ExistingWorkflowStep = __esm(() => {
1059
+ init_CustomSelect();
1060
+ init_src();
1061
+ jsx_dev_runtime8 = __toESM(require_jsx_dev_runtime(), 1);
1062
+ });
1063
+
1064
+ // src/commands/install-github-app/InstallAppStep.tsx
1065
+ function InstallAppStep({ repoUrl, onSubmit }) {
1066
+ useKeybinding("confirm:yes", onSubmit, { context: "Confirmation" });
1067
+ return /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1068
+ flexDirection: "column",
1069
+ borderStyle: "round",
1070
+ borderDimColor: true,
1071
+ paddingX: 1,
1072
+ children: [
1073
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1074
+ flexDirection: "column",
1075
+ marginBottom: 1,
1076
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1077
+ bold: true,
1078
+ children: "Install the Claude GitHub App"
1079
+ }, undefined, false, undefined, this)
1080
+ }, undefined, false, undefined, this),
1081
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1082
+ marginBottom: 1,
1083
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1084
+ children: "Opening browser to install the Claude GitHub App\u2026"
1085
+ }, undefined, false, undefined, this)
1086
+ }, undefined, false, undefined, this),
1087
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1088
+ marginBottom: 1,
1089
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1090
+ children: "If your browser doesn't open automatically, visit:"
1091
+ }, undefined, false, undefined, this)
1092
+ }, undefined, false, undefined, this),
1093
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1094
+ marginBottom: 1,
1095
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1096
+ underline: true,
1097
+ children: "https://github.com/apps/claude"
1098
+ }, undefined, false, undefined, this)
1099
+ }, undefined, false, undefined, this),
1100
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1101
+ marginBottom: 1,
1102
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1103
+ children: [
1104
+ "Please install the app for repository: ",
1105
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1106
+ bold: true,
1107
+ children: repoUrl
1108
+ }, undefined, false, undefined, this)
1109
+ ]
1110
+ }, undefined, true, undefined, this)
1111
+ }, undefined, false, undefined, this),
1112
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1113
+ marginBottom: 1,
1114
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1115
+ dimColor: true,
1116
+ children: "Important: Make sure to grant access to this specific repository"
1117
+ }, undefined, false, undefined, this)
1118
+ }, undefined, false, undefined, this),
1119
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1120
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1121
+ bold: true,
1122
+ color: "permission",
1123
+ children: [
1124
+ "Press Enter once you've installed the app",
1125
+ figures_default.ellipsis
1126
+ ]
1127
+ }, undefined, true, undefined, this)
1128
+ }, undefined, false, undefined, this),
1129
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedBox_default, {
1130
+ marginTop: 1,
1131
+ children: /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1132
+ dimColor: true,
1133
+ children: [
1134
+ "Having trouble? See manual setup instructions at:",
1135
+ " ",
1136
+ /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(ThemedText, {
1137
+ color: "claude",
1138
+ children: GITHUB_ACTION_SETUP_DOCS_URL
1139
+ }, undefined, false, undefined, this)
1140
+ ]
1141
+ }, undefined, true, undefined, this)
1142
+ }, undefined, false, undefined, this)
1143
+ ]
1144
+ }, undefined, true, undefined, this);
1145
+ }
1146
+ var jsx_dev_runtime9;
1147
+ var init_InstallAppStep = __esm(() => {
1148
+ init_figures();
1149
+ init_github_app();
1150
+ init_src();
1151
+ init_useKeybinding();
1152
+ jsx_dev_runtime9 = __toESM(require_jsx_dev_runtime(), 1);
1153
+ });
1154
+
1155
+ // src/commands/install-github-app/OAuthFlowStep.tsx
1156
+ function OAuthFlowStep({
1157
+ onSuccess,
1158
+ onCancel
1159
+ }) {
1160
+ const [oauthStatus, setOAuthStatus] = import_react5.useState({
1161
+ state: "starting"
1162
+ });
1163
+ const [oauthService] = import_react5.useState(() => new OAuthService);
1164
+ const [pastedCode, setPastedCode] = import_react5.useState("");
1165
+ const [cursorOffset, setCursorOffset] = import_react5.useState(0);
1166
+ const [showPastePrompt, setShowPastePrompt] = import_react5.useState(false);
1167
+ const [urlCopied, setUrlCopied] = import_react5.useState(false);
1168
+ const timersRef = import_react5.useRef(new Set);
1169
+ const urlCopiedTimerRef = import_react5.useRef(undefined);
1170
+ const terminalSize = useTerminalSize();
1171
+ const textInputColumns = Math.max(50, terminalSize.columns - PASTE_HERE_MSG.length - 4);
1172
+ function handleKeyDown(e) {
1173
+ if (oauthStatus.state !== "error")
1174
+ return;
1175
+ e.preventDefault();
1176
+ if (e.key === "return" && oauthStatus.toRetry) {
1177
+ setPastedCode("");
1178
+ setCursorOffset(0);
1179
+ setOAuthStatus({
1180
+ state: "about_to_retry",
1181
+ nextState: oauthStatus.toRetry
1182
+ });
1183
+ } else {
1184
+ onCancel();
1185
+ }
1186
+ }
1187
+ async function handleSubmitCode(value, url) {
1188
+ try {
1189
+ const [authorizationCode, state] = value.split("#");
1190
+ if (!authorizationCode || !state) {
1191
+ setOAuthStatus({
1192
+ state: "error",
1193
+ message: "Invalid code. Please make sure the full code was copied",
1194
+ toRetry: { state: "waiting_for_login", url }
1195
+ });
1196
+ return;
1197
+ }
1198
+ logEvent("tengu_oauth_manual_entry", {});
1199
+ oauthService.handleManualAuthCodeInput({
1200
+ authorizationCode,
1201
+ state
1202
+ });
1203
+ } catch (err) {
1204
+ logError(err);
1205
+ setOAuthStatus({
1206
+ state: "error",
1207
+ message: err.message,
1208
+ toRetry: { state: "waiting_for_login", url }
1209
+ });
1210
+ }
1211
+ }
1212
+ const startOAuth = import_react5.useCallback(async () => {
1213
+ timersRef.current.forEach((timer) => clearTimeout(timer));
1214
+ timersRef.current.clear();
1215
+ try {
1216
+ const result = await oauthService.startOAuthFlow(async (url) => {
1217
+ setOAuthStatus({ state: "waiting_for_login", url });
1218
+ const timer = setTimeout(setShowPastePrompt, 3000, true);
1219
+ timersRef.current.add(timer);
1220
+ }, {
1221
+ loginWithClaudeAi: true,
1222
+ inferenceOnly: true,
1223
+ expiresIn: 365 * 24 * 60 * 60
1224
+ });
1225
+ setOAuthStatus({ state: "processing" });
1226
+ saveOAuthTokensIfNeeded(result);
1227
+ const timer1 = setTimeout((setOAuthStatus2, accessToken, onSuccess2, timersRef2) => {
1228
+ setOAuthStatus2({ state: "success", token: accessToken });
1229
+ const timer2 = setTimeout(onSuccess2, 1000, accessToken);
1230
+ timersRef2.current.add(timer2);
1231
+ }, 100, setOAuthStatus, result.accessToken, onSuccess, timersRef);
1232
+ timersRef.current.add(timer1);
1233
+ } catch (err) {
1234
+ const errorMessage = err.message;
1235
+ setOAuthStatus({
1236
+ state: "error",
1237
+ message: errorMessage,
1238
+ toRetry: { state: "starting" }
1239
+ });
1240
+ logError(err);
1241
+ logEvent("tengu_oauth_error", {
1242
+ error: errorMessage
1243
+ });
1244
+ }
1245
+ }, [oauthService, onSuccess]);
1246
+ import_react5.useEffect(() => {
1247
+ if (oauthStatus.state === "starting") {
1248
+ startOAuth();
1249
+ }
1250
+ }, [oauthStatus.state, startOAuth]);
1251
+ import_react5.useEffect(() => {
1252
+ if (oauthStatus.state === "about_to_retry") {
1253
+ const timer = setTimeout((nextState, setShowPastePrompt2, setOAuthStatus2) => {
1254
+ setShowPastePrompt2(nextState.state === "waiting_for_login");
1255
+ setOAuthStatus2(nextState);
1256
+ }, 500, oauthStatus.nextState, setShowPastePrompt, setOAuthStatus);
1257
+ timersRef.current.add(timer);
1258
+ }
1259
+ }, [oauthStatus]);
1260
+ import_react5.useEffect(() => {
1261
+ if (pastedCode === "c" && oauthStatus.state === "waiting_for_login" && showPastePrompt && !urlCopied) {
1262
+ setClipboard(oauthStatus.url).then((raw) => {
1263
+ if (raw)
1264
+ process.stdout.write(raw);
1265
+ setUrlCopied(true);
1266
+ clearTimeout(urlCopiedTimerRef.current);
1267
+ urlCopiedTimerRef.current = setTimeout(setUrlCopied, 2000, false);
1268
+ });
1269
+ setPastedCode("");
1270
+ }
1271
+ }, [pastedCode, oauthStatus, showPastePrompt, urlCopied]);
1272
+ import_react5.useEffect(() => {
1273
+ const timers = timersRef.current;
1274
+ return () => {
1275
+ oauthService.cleanup();
1276
+ timers.forEach((timer) => clearTimeout(timer));
1277
+ timers.clear();
1278
+ clearTimeout(urlCopiedTimerRef.current);
1279
+ };
1280
+ }, [oauthService]);
1281
+ function renderStatusMessage() {
1282
+ switch (oauthStatus.state) {
1283
+ case "starting":
1284
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1285
+ children: [
1286
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Spinner, {}, undefined, false, undefined, this),
1287
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1288
+ children: "Starting authentication\u2026"
1289
+ }, undefined, false, undefined, this)
1290
+ ]
1291
+ }, undefined, true, undefined, this);
1292
+ case "waiting_for_login":
1293
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1294
+ flexDirection: "column",
1295
+ gap: 1,
1296
+ children: [
1297
+ !showPastePrompt && /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1298
+ children: [
1299
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Spinner, {}, undefined, false, undefined, this),
1300
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1301
+ children: "Opening browser to sign in with your Claude account\u2026"
1302
+ }, undefined, false, undefined, this)
1303
+ ]
1304
+ }, undefined, true, undefined, this),
1305
+ showPastePrompt && /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1306
+ children: [
1307
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1308
+ children: PASTE_HERE_MSG
1309
+ }, undefined, false, undefined, this),
1310
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(TextInput, {
1311
+ value: pastedCode,
1312
+ onChange: setPastedCode,
1313
+ onSubmit: (value) => handleSubmitCode(value, oauthStatus.url),
1314
+ cursorOffset,
1315
+ onChangeCursorOffset: setCursorOffset,
1316
+ columns: textInputColumns
1317
+ }, undefined, false, undefined, this)
1318
+ ]
1319
+ }, undefined, true, undefined, this)
1320
+ ]
1321
+ }, undefined, true, undefined, this);
1322
+ case "processing":
1323
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1324
+ children: [
1325
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Spinner, {}, undefined, false, undefined, this),
1326
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1327
+ children: "Processing authentication\u2026"
1328
+ }, undefined, false, undefined, this)
1329
+ ]
1330
+ }, undefined, true, undefined, this);
1331
+ case "success":
1332
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1333
+ flexDirection: "column",
1334
+ gap: 1,
1335
+ children: [
1336
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1337
+ color: "success",
1338
+ children: "\u2713 Authentication token created successfully!"
1339
+ }, undefined, false, undefined, this),
1340
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1341
+ dimColor: true,
1342
+ children: "Using token for GitHub Actions setup\u2026"
1343
+ }, undefined, false, undefined, this)
1344
+ ]
1345
+ }, undefined, true, undefined, this);
1346
+ case "error":
1347
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1348
+ flexDirection: "column",
1349
+ gap: 1,
1350
+ children: [
1351
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1352
+ color: "error",
1353
+ children: [
1354
+ "OAuth error: ",
1355
+ oauthStatus.message
1356
+ ]
1357
+ }, undefined, true, undefined, this),
1358
+ oauthStatus.toRetry ? /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1359
+ dimColor: true,
1360
+ children: "Press Enter to try again, or any other key to cancel"
1361
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1362
+ dimColor: true,
1363
+ children: "Press any key to return to API key selection"
1364
+ }, undefined, false, undefined, this)
1365
+ ]
1366
+ }, undefined, true, undefined, this);
1367
+ case "about_to_retry":
1368
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1369
+ flexDirection: "column",
1370
+ gap: 1,
1371
+ children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1372
+ color: "permission",
1373
+ children: "Retrying\u2026"
1374
+ }, undefined, false, undefined, this)
1375
+ }, undefined, false, undefined, this);
1376
+ default:
1377
+ return null;
1378
+ }
1379
+ }
1380
+ return /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1381
+ flexDirection: "column",
1382
+ gap: 1,
1383
+ tabIndex: 0,
1384
+ autoFocus: true,
1385
+ onKeyDown: handleKeyDown,
1386
+ children: [
1387
+ oauthStatus.state === "starting" && /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1388
+ flexDirection: "column",
1389
+ gap: 1,
1390
+ paddingBottom: 1,
1391
+ children: [
1392
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1393
+ bold: true,
1394
+ children: "Create Authentication Token"
1395
+ }, undefined, false, undefined, this),
1396
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1397
+ dimColor: true,
1398
+ children: "Creating a long-lived token for GitHub Actions"
1399
+ }, undefined, false, undefined, this)
1400
+ ]
1401
+ }, undefined, true, undefined, this),
1402
+ oauthStatus.state !== "success" && oauthStatus.state !== "starting" && oauthStatus.state !== "processing" && /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1403
+ flexDirection: "column",
1404
+ gap: 1,
1405
+ paddingBottom: 1,
1406
+ children: [
1407
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1408
+ bold: true,
1409
+ children: "Create Authentication Token"
1410
+ }, undefined, false, undefined, this),
1411
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1412
+ dimColor: true,
1413
+ children: "Creating a long-lived token for GitHub Actions"
1414
+ }, undefined, false, undefined, this)
1415
+ ]
1416
+ }, "header", true, undefined, this),
1417
+ oauthStatus.state === "waiting_for_login" && showPastePrompt && /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1418
+ flexDirection: "column",
1419
+ gap: 1,
1420
+ paddingBottom: 1,
1421
+ children: [
1422
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1423
+ paddingX: 1,
1424
+ children: [
1425
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1426
+ dimColor: true,
1427
+ children: [
1428
+ "Browser didn't open? Use the url below to sign in",
1429
+ " "
1430
+ ]
1431
+ }, undefined, true, undefined, this),
1432
+ urlCopied ? /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1433
+ color: "success",
1434
+ children: "(Copied!)"
1435
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1436
+ dimColor: true,
1437
+ children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(KeyboardShortcutHint, {
1438
+ shortcut: "c",
1439
+ action: "copy",
1440
+ parens: true
1441
+ }, undefined, false, undefined, this)
1442
+ }, undefined, false, undefined, this)
1443
+ ]
1444
+ }, undefined, true, undefined, this),
1445
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(Link, {
1446
+ url: oauthStatus.url,
1447
+ children: /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedText, {
1448
+ dimColor: true,
1449
+ children: oauthStatus.url
1450
+ }, undefined, false, undefined, this)
1451
+ }, undefined, false, undefined, this)
1452
+ ]
1453
+ }, "urlToCopy", true, undefined, this),
1454
+ /* @__PURE__ */ jsx_dev_runtime10.jsxDEV(ThemedBox_default, {
1455
+ paddingLeft: 1,
1456
+ flexDirection: "column",
1457
+ gap: 1,
1458
+ children: renderStatusMessage()
1459
+ }, undefined, false, undefined, this)
1460
+ ]
1461
+ }, undefined, true, undefined, this);
1462
+ }
1463
+ var import_react5, jsx_dev_runtime10, PASTE_HERE_MSG = "Paste code here if prompted > ";
1464
+ var init_OAuthFlowStep = __esm(() => {
1465
+ init_analytics();
1466
+ init_src();
1467
+ init_Spinner();
1468
+ init_TextInput();
1469
+ init_useTerminalSize();
1470
+ init_src();
1471
+ init_oauth();
1472
+ init_auth();
1473
+ init_log();
1474
+ import_react5 = __toESM(require_react(), 1);
1475
+ jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
1476
+ });
1477
+
1478
+ // src/commands/install-github-app/SuccessStep.tsx
1479
+ function SuccessStep({
1480
+ secretExists,
1481
+ useExistingSecret,
1482
+ secretName,
1483
+ skipWorkflow = false
1484
+ }) {
1485
+ return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(jsx_dev_runtime11.Fragment, {
1486
+ children: [
1487
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedBox_default, {
1488
+ flexDirection: "column",
1489
+ borderStyle: "round",
1490
+ paddingX: 1,
1491
+ children: [
1492
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedBox_default, {
1493
+ flexDirection: "column",
1494
+ marginBottom: 1,
1495
+ children: [
1496
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1497
+ bold: true,
1498
+ children: "Install GitHub App"
1499
+ }, undefined, false, undefined, this),
1500
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1501
+ dimColor: true,
1502
+ children: "Success"
1503
+ }, undefined, false, undefined, this)
1504
+ ]
1505
+ }, undefined, true, undefined, this),
1506
+ !skipWorkflow && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1507
+ color: "success",
1508
+ children: "\u2713 GitHub Actions workflow created!"
1509
+ }, undefined, false, undefined, this),
1510
+ secretExists && useExistingSecret && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedBox_default, {
1511
+ marginTop: 1,
1512
+ children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1513
+ color: "success",
1514
+ children: "\u2713 Using existing ANTHROPIC_API_KEY secret"
1515
+ }, undefined, false, undefined, this)
1516
+ }, undefined, false, undefined, this),
1517
+ (!secretExists || !useExistingSecret) && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedBox_default, {
1518
+ marginTop: 1,
1519
+ children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1520
+ color: "success",
1521
+ children: [
1522
+ "\u2713 API key saved as ",
1523
+ secretName,
1524
+ " secret"
1525
+ ]
1526
+ }, undefined, true, undefined, this)
1527
+ }, undefined, false, undefined, this),
1528
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedBox_default, {
1529
+ marginTop: 1,
1530
+ children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1531
+ children: "Next steps:"
1532
+ }, undefined, false, undefined, this)
1533
+ }, undefined, false, undefined, this),
1534
+ skipWorkflow ? /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(jsx_dev_runtime11.Fragment, {
1535
+ children: [
1536
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1537
+ children: "1. Install the Claude GitHub App if you haven't already"
1538
+ }, undefined, false, undefined, this),
1539
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1540
+ children: "2. Your workflow file was kept unchanged"
1541
+ }, undefined, false, undefined, this),
1542
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1543
+ children: "3. API key is configured and ready to use"
1544
+ }, undefined, false, undefined, this)
1545
+ ]
1546
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(jsx_dev_runtime11.Fragment, {
1547
+ children: [
1548
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1549
+ children: "1. A pre-filled PR page has been created"
1550
+ }, undefined, false, undefined, this),
1551
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1552
+ children: "2. Install the Claude GitHub App if you haven't already"
1553
+ }, undefined, false, undefined, this),
1554
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1555
+ children: "3. Merge the PR to enable Claude PR assistance"
1556
+ }, undefined, false, undefined, this)
1557
+ ]
1558
+ }, undefined, true, undefined, this)
1559
+ ]
1560
+ }, undefined, true, undefined, this),
1561
+ /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedBox_default, {
1562
+ marginLeft: 3,
1563
+ children: /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(ThemedText, {
1564
+ dimColor: true,
1565
+ children: "Press any key to exit"
1566
+ }, undefined, false, undefined, this)
1567
+ }, undefined, false, undefined, this)
1568
+ ]
1569
+ }, undefined, true, undefined, this);
1570
+ }
1571
+ var jsx_dev_runtime11;
1572
+ var init_SuccessStep = __esm(() => {
1573
+ init_src();
1574
+ jsx_dev_runtime11 = __toESM(require_jsx_dev_runtime(), 1);
1575
+ });
1576
+
1577
+ // src/commands/install-github-app/setupGitHubActions.ts
1578
+ async function createWorkflowFile(repoName, branchName, workflowPath, workflowContent, secretName, message, context) {
1579
+ const checkFileResult = await execFileNoThrow("gh", [
1580
+ "api",
1581
+ `repos/${repoName}/contents/${workflowPath}`,
1582
+ "--jq",
1583
+ ".sha"
1584
+ ]);
1585
+ let fileSha = null;
1586
+ if (checkFileResult.code === 0) {
1587
+ fileSha = checkFileResult.stdout.trim();
1588
+ }
1589
+ let content = workflowContent;
1590
+ if (secretName === "CLAUDE_CODE_OAUTH_TOKEN") {
1591
+ content = workflowContent.replace(/anthropic_api_key: \$\{\{ secrets\.ANTHROPIC_API_KEY \}\}/g, `claude_code_oauth_token: \${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}`);
1592
+ } else if (secretName !== "ANTHROPIC_API_KEY") {
1593
+ content = workflowContent.replace(/anthropic_api_key: \$\{\{ secrets\.ANTHROPIC_API_KEY \}\}/g, `anthropic_api_key: \${{ secrets.${secretName} }}`);
1594
+ }
1595
+ const base64Content = Buffer.from(content).toString("base64");
1596
+ const apiParams = [
1597
+ "api",
1598
+ "--method",
1599
+ "PUT",
1600
+ `repos/${repoName}/contents/${workflowPath}`,
1601
+ "-f",
1602
+ `message=${fileSha ? `"Update ${message}"` : `"${message}"`}`,
1603
+ "-f",
1604
+ `content=${base64Content}`,
1605
+ "-f",
1606
+ `branch=${branchName}`
1607
+ ];
1608
+ if (fileSha) {
1609
+ apiParams.push("-f", `sha=${fileSha}`);
1610
+ }
1611
+ const createFileResult = await execFileNoThrow("gh", apiParams);
1612
+ if (createFileResult.code !== 0) {
1613
+ if (createFileResult.stderr.includes("422") && createFileResult.stderr.includes("sha")) {
1614
+ logEvent("tengu_setup_github_actions_failed", {
1615
+ reason: "failed_to_create_workflow_file",
1616
+ exit_code: createFileResult.code,
1617
+ ...context
1618
+ });
1619
+ throw new Error(`Failed to create workflow file ${workflowPath}: A Claude workflow file already exists in this repository. Please remove it first or update it manually.`);
1620
+ }
1621
+ logEvent("tengu_setup_github_actions_failed", {
1622
+ reason: "failed_to_create_workflow_file",
1623
+ exit_code: createFileResult.code,
1624
+ ...context
1625
+ });
1626
+ const helpText = `
1627
+
1628
+ Need help? Common issues:
1629
+ ` + `\xB7 Permission denied \u2192 Run: gh auth refresh -h github.com -s repo,workflow
1630
+ ` + `\xB7 Not authorized \u2192 Ensure you have admin access to the repository
1631
+ ` + "\xB7 For manual setup \u2192 Visit: https://github.com/anthropics/claude-code-action";
1632
+ throw new Error(`Failed to create workflow file ${workflowPath}: ${createFileResult.stderr}${helpText}`);
1633
+ }
1634
+ }
1635
+ async function setupGitHubActions(repoName, apiKeyOrOAuthToken, secretName, updateProgress, skipWorkflow = false, selectedWorkflows, authType, context) {
1636
+ try {
1637
+ logEvent("tengu_setup_github_actions_started", {
1638
+ skip_workflow: skipWorkflow,
1639
+ has_api_key: !!apiKeyOrOAuthToken,
1640
+ using_default_secret_name: secretName === "ANTHROPIC_API_KEY",
1641
+ selected_claude_workflow: selectedWorkflows.includes("claude"),
1642
+ selected_claude_review_workflow: selectedWorkflows.includes("claude-review"),
1643
+ ...context
1644
+ });
1645
+ const repoCheckResult = await execFileNoThrow("gh", [
1646
+ "api",
1647
+ `repos/${repoName}`,
1648
+ "--jq",
1649
+ ".id"
1650
+ ]);
1651
+ if (repoCheckResult.code !== 0) {
1652
+ logEvent("tengu_setup_github_actions_failed", {
1653
+ reason: "repo_not_found",
1654
+ exit_code: repoCheckResult.code,
1655
+ ...context
1656
+ });
1657
+ throw new Error(`Failed to access repository ${repoName}: ${repoCheckResult.stderr}`);
1658
+ }
1659
+ const defaultBranchResult = await execFileNoThrow("gh", [
1660
+ "api",
1661
+ `repos/${repoName}`,
1662
+ "--jq",
1663
+ ".default_branch"
1664
+ ]);
1665
+ if (defaultBranchResult.code !== 0) {
1666
+ logEvent("tengu_setup_github_actions_failed", {
1667
+ reason: "failed_to_get_default_branch",
1668
+ exit_code: defaultBranchResult.code,
1669
+ ...context
1670
+ });
1671
+ throw new Error(`Failed to get default branch: ${defaultBranchResult.stderr}`);
1672
+ }
1673
+ const defaultBranch = defaultBranchResult.stdout.trim();
1674
+ const shaResult = await execFileNoThrow("gh", [
1675
+ "api",
1676
+ `repos/${repoName}/git/ref/heads/${defaultBranch}`,
1677
+ "--jq",
1678
+ ".object.sha"
1679
+ ]);
1680
+ if (shaResult.code !== 0) {
1681
+ logEvent("tengu_setup_github_actions_failed", {
1682
+ reason: "failed_to_get_branch_sha",
1683
+ exit_code: shaResult.code,
1684
+ ...context
1685
+ });
1686
+ throw new Error(`Failed to get branch SHA: ${shaResult.stderr}`);
1687
+ }
1688
+ const sha = shaResult.stdout.trim();
1689
+ let branchName = null;
1690
+ if (!skipWorkflow) {
1691
+ updateProgress();
1692
+ branchName = `add-claude-github-actions-${Date.now()}`;
1693
+ const createBranchResult = await execFileNoThrow("gh", [
1694
+ "api",
1695
+ "--method",
1696
+ "POST",
1697
+ `repos/${repoName}/git/refs`,
1698
+ "-f",
1699
+ `ref=refs/heads/${branchName}`,
1700
+ "-f",
1701
+ `sha=${sha}`
1702
+ ]);
1703
+ if (createBranchResult.code !== 0) {
1704
+ logEvent("tengu_setup_github_actions_failed", {
1705
+ reason: "failed_to_create_branch",
1706
+ exit_code: createBranchResult.code,
1707
+ ...context
1708
+ });
1709
+ throw new Error(`Failed to create branch: ${createBranchResult.stderr}`);
1710
+ }
1711
+ updateProgress();
1712
+ const workflows = [];
1713
+ if (selectedWorkflows.includes("claude")) {
1714
+ workflows.push({
1715
+ path: ".github/workflows/claude.yml",
1716
+ content: WORKFLOW_CONTENT,
1717
+ message: "Claude PR Assistant workflow"
1718
+ });
1719
+ }
1720
+ if (selectedWorkflows.includes("claude-review")) {
1721
+ workflows.push({
1722
+ path: ".github/workflows/claude-code-review.yml",
1723
+ content: CODE_REVIEW_PLUGIN_WORKFLOW_CONTENT,
1724
+ message: "Claude Code Review workflow"
1725
+ });
1726
+ }
1727
+ for (const workflow of workflows) {
1728
+ await createWorkflowFile(repoName, branchName, workflow.path, workflow.content, secretName, workflow.message, context);
1729
+ }
1730
+ }
1731
+ updateProgress();
1732
+ if (apiKeyOrOAuthToken) {
1733
+ const setSecretResult = await execFileNoThrow("gh", [
1734
+ "secret",
1735
+ "set",
1736
+ secretName,
1737
+ "--body",
1738
+ apiKeyOrOAuthToken,
1739
+ "--repo",
1740
+ repoName
1741
+ ]);
1742
+ if (setSecretResult.code !== 0) {
1743
+ logEvent("tengu_setup_github_actions_failed", {
1744
+ reason: "failed_to_set_api_key_secret",
1745
+ exit_code: setSecretResult.code,
1746
+ ...context
1747
+ });
1748
+ const helpText = `
1749
+
1750
+ Need help? Common issues:
1751
+ ` + `\xB7 Permission denied \u2192 Run: gh auth refresh -h github.com -s repo
1752
+ ` + `\xB7 Not authorized \u2192 Ensure you have admin access to the repository
1753
+ ` + "\xB7 For manual setup \u2192 Visit: https://github.com/anthropics/claude-code-action";
1754
+ throw new Error(`Failed to set API key secret: ${setSecretResult.stderr || "Unknown error"}${helpText}`);
1755
+ }
1756
+ }
1757
+ if (!skipWorkflow && branchName) {
1758
+ updateProgress();
1759
+ const compareUrl = `https://github.com/${repoName}/compare/${defaultBranch}...${branchName}?quick_pull=1&title=${encodeURIComponent(PR_TITLE)}&body=${encodeURIComponent(PR_BODY)}`;
1760
+ await openBrowser(compareUrl);
1761
+ }
1762
+ logEvent("tengu_setup_github_actions_completed", {
1763
+ skip_workflow: skipWorkflow,
1764
+ has_api_key: !!apiKeyOrOAuthToken,
1765
+ auth_type: authType,
1766
+ using_default_secret_name: secretName === "ANTHROPIC_API_KEY",
1767
+ selected_claude_workflow: selectedWorkflows.includes("claude"),
1768
+ selected_claude_review_workflow: selectedWorkflows.includes("claude-review"),
1769
+ ...context
1770
+ });
1771
+ saveGlobalConfig((current) => ({
1772
+ ...current,
1773
+ githubActionSetupCount: (current.githubActionSetupCount ?? 0) + 1
1774
+ }));
1775
+ } catch (error) {
1776
+ if (!error || !(error instanceof Error) || !error.message.includes("Failed to")) {
1777
+ logEvent("tengu_setup_github_actions_failed", {
1778
+ reason: "unexpected_error",
1779
+ ...context
1780
+ });
1781
+ }
1782
+ if (error instanceof Error) {
1783
+ logError(error);
1784
+ }
1785
+ throw error;
1786
+ }
1787
+ }
1788
+ var init_setupGitHubActions = __esm(() => {
1789
+ init_analytics();
1790
+ init_config();
1791
+ init_github_app();
1792
+ init_browser();
1793
+ init_execFileNoThrow();
1794
+ init_log();
1795
+ });
1796
+
1797
+ // src/commands/install-github-app/WarningsStep.tsx
1798
+ function WarningsStep({ warnings, onContinue }) {
1799
+ useKeybinding("confirm:yes", onContinue, { context: "Confirmation" });
1800
+ return /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(jsx_dev_runtime12.Fragment, {
1801
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
1802
+ flexDirection: "column",
1803
+ borderStyle: "round",
1804
+ paddingX: 1,
1805
+ children: [
1806
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
1807
+ flexDirection: "column",
1808
+ marginBottom: 1,
1809
+ children: [
1810
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1811
+ bold: true,
1812
+ children: [
1813
+ figures_default.warning,
1814
+ " Setup Warnings"
1815
+ ]
1816
+ }, undefined, true, undefined, this),
1817
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1818
+ dimColor: true,
1819
+ children: "We found some potential issues, but you can continue anyway"
1820
+ }, undefined, false, undefined, this)
1821
+ ]
1822
+ }, undefined, true, undefined, this),
1823
+ warnings.map((warning, index) => /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
1824
+ flexDirection: "column",
1825
+ marginBottom: 1,
1826
+ children: [
1827
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1828
+ color: "warning",
1829
+ bold: true,
1830
+ children: warning.title
1831
+ }, undefined, false, undefined, this),
1832
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1833
+ children: warning.message
1834
+ }, undefined, false, undefined, this),
1835
+ warning.instructions.length > 0 && /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
1836
+ flexDirection: "column",
1837
+ marginLeft: 2,
1838
+ marginTop: 1,
1839
+ children: warning.instructions.map((instruction, i) => /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1840
+ dimColor: true,
1841
+ children: [
1842
+ "\u2022 ",
1843
+ instruction
1844
+ ]
1845
+ }, i, true, undefined, this))
1846
+ }, undefined, false, undefined, this)
1847
+ ]
1848
+ }, index, true, undefined, this)),
1849
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
1850
+ marginTop: 1,
1851
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1852
+ bold: true,
1853
+ color: "permission",
1854
+ children: "Press Enter to continue anyway, or Ctrl+C to exit and fix issues"
1855
+ }, undefined, false, undefined, this)
1856
+ }, undefined, false, undefined, this),
1857
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedBox_default, {
1858
+ marginTop: 1,
1859
+ children: /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1860
+ dimColor: true,
1861
+ children: [
1862
+ "You can also try the manual setup steps if needed:",
1863
+ " ",
1864
+ /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(ThemedText, {
1865
+ color: "claude",
1866
+ children: GITHUB_ACTION_SETUP_DOCS_URL
1867
+ }, undefined, false, undefined, this)
1868
+ ]
1869
+ }, undefined, true, undefined, this)
1870
+ }, undefined, false, undefined, this)
1871
+ ]
1872
+ }, undefined, true, undefined, this)
1873
+ }, undefined, false, undefined, this);
1874
+ }
1875
+ var jsx_dev_runtime12;
1876
+ var init_WarningsStep = __esm(() => {
1877
+ init_figures();
1878
+ init_github_app();
1879
+ init_src();
1880
+ init_useKeybinding();
1881
+ jsx_dev_runtime12 = __toESM(require_jsx_dev_runtime(), 1);
1882
+ });
1883
+
1884
+ // src/commands/install-github-app/install-github-app.tsx
1885
+ function InstallGitHubApp(props) {
1886
+ const [existingApiKey] = import_react6.useState(() => getAnthropicApiKey());
1887
+ const [state, setState] = import_react6.useState({
1888
+ ...INITIAL_STATE,
1889
+ useExistingKey: !!existingApiKey,
1890
+ selectedApiKeyOption: existingApiKey ? "existing" : isAnthropicAuthEnabled() ? "oauth" : "new"
1891
+ });
1892
+ useExitOnCtrlCDWithKeybindings();
1893
+ import_react6.default.useEffect(() => {
1894
+ logEvent("tengu_install_github_app_started", {});
1895
+ }, []);
1896
+ const checkGitHubCLI = import_react6.useCallback(async () => {
1897
+ const warnings = [];
1898
+ const ghVersionResult = await execa("gh --version", {
1899
+ shell: true,
1900
+ reject: false
1901
+ });
1902
+ if (ghVersionResult.exitCode !== 0) {
1903
+ warnings.push({
1904
+ title: "GitHub CLI not found",
1905
+ message: "GitHub CLI (gh) does not appear to be installed or accessible.",
1906
+ instructions: [
1907
+ "Install GitHub CLI from https://cli.github.com/",
1908
+ "macOS: brew install gh",
1909
+ "Windows: winget install --id GitHub.cli",
1910
+ "Linux: See installation instructions at https://github.com/cli/cli#installation"
1911
+ ]
1912
+ });
1913
+ }
1914
+ const authResult = await execa("gh auth status -a", {
1915
+ shell: true,
1916
+ reject: false
1917
+ });
1918
+ if (authResult.exitCode !== 0) {
1919
+ warnings.push({
1920
+ title: "GitHub CLI not authenticated",
1921
+ message: "GitHub CLI does not appear to be authenticated.",
1922
+ instructions: [
1923
+ "Run: gh auth login",
1924
+ "Follow the prompts to authenticate with GitHub",
1925
+ "Or set up authentication using environment variables or other methods"
1926
+ ]
1927
+ });
1928
+ } else {
1929
+ const tokenScopesMatch = authResult.stdout.match(/Token scopes:.*$/m);
1930
+ if (tokenScopesMatch) {
1931
+ const scopes = tokenScopesMatch[0];
1932
+ const missingScopes = [];
1933
+ if (!scopes.includes("repo")) {
1934
+ missingScopes.push("repo");
1935
+ }
1936
+ if (!scopes.includes("workflow")) {
1937
+ missingScopes.push("workflow");
1938
+ }
1939
+ if (missingScopes.length > 0) {
1940
+ setState((prev) => ({
1941
+ ...prev,
1942
+ step: "error",
1943
+ error: `GitHub CLI is missing required permissions: ${missingScopes.join(", ")}.`,
1944
+ errorReason: "Missing required scopes",
1945
+ errorInstructions: [
1946
+ `Your GitHub CLI authentication is missing the "${missingScopes.join('" and "')}" ${plural(missingScopes.length, "scope")} needed to manage GitHub Actions and secrets.`,
1947
+ "",
1948
+ "To fix this, run:",
1949
+ " gh auth refresh -h github.com -s repo,workflow",
1950
+ "",
1951
+ "This will add the necessary permissions to manage workflows and secrets."
1952
+ ]
1953
+ }));
1954
+ return;
1955
+ }
1956
+ }
1957
+ }
1958
+ const currentRepo = await getGithubRepo() ?? "";
1959
+ logEvent("tengu_install_github_app_step_completed", {
1960
+ step: "check-gh"
1961
+ });
1962
+ setState((prev) => ({
1963
+ ...prev,
1964
+ warnings,
1965
+ currentRepo,
1966
+ selectedRepoName: currentRepo,
1967
+ useCurrentRepo: !!currentRepo,
1968
+ step: warnings.length > 0 ? "warnings" : "choose-repo"
1969
+ }));
1970
+ }, []);
1971
+ import_react6.default.useEffect(() => {
1972
+ if (state.step === "check-gh") {
1973
+ checkGitHubCLI();
1974
+ }
1975
+ }, [state.step, checkGitHubCLI]);
1976
+ const runSetupGitHubActions = import_react6.useCallback(async (apiKeyOrOAuthToken, secretName) => {
1977
+ setState((prev) => ({
1978
+ ...prev,
1979
+ step: "creating",
1980
+ currentWorkflowInstallStep: 0
1981
+ }));
1982
+ try {
1983
+ await setupGitHubActions(state.selectedRepoName, apiKeyOrOAuthToken, secretName, () => {
1984
+ setState((prev) => ({
1985
+ ...prev,
1986
+ currentWorkflowInstallStep: prev.currentWorkflowInstallStep + 1
1987
+ }));
1988
+ }, state.workflowAction === "skip", state.selectedWorkflows, state.authType, {
1989
+ useCurrentRepo: state.useCurrentRepo,
1990
+ workflowExists: state.workflowExists,
1991
+ secretExists: state.secretExists
1992
+ });
1993
+ logEvent("tengu_install_github_app_step_completed", {
1994
+ step: "creating"
1995
+ });
1996
+ setState((prev) => ({ ...prev, step: "success" }));
1997
+ } catch (error) {
1998
+ const errorMessage = error instanceof Error ? error.message : "Failed to set up GitHub Actions";
1999
+ if (errorMessage.includes("workflow file already exists")) {
2000
+ logEvent("tengu_install_github_app_error", {
2001
+ reason: "workflow_file_exists"
2002
+ });
2003
+ setState((prev) => ({
2004
+ ...prev,
2005
+ step: "error",
2006
+ error: "A Claude workflow file already exists in this repository.",
2007
+ errorReason: "Workflow file conflict",
2008
+ errorInstructions: [
2009
+ "The file .github/workflows/claude.yml already exists",
2010
+ "You can either:",
2011
+ " 1. Delete the existing file and run this command again",
2012
+ " 2. Update the existing file manually using the template from:",
2013
+ ` ${GITHUB_ACTION_SETUP_DOCS_URL}`
2014
+ ]
2015
+ }));
2016
+ } else {
2017
+ logEvent("tengu_install_github_app_error", {
2018
+ reason: "setup_github_actions_failed"
2019
+ });
2020
+ setState((prev) => ({
2021
+ ...prev,
2022
+ step: "error",
2023
+ error: errorMessage,
2024
+ errorReason: "GitHub Actions setup failed",
2025
+ errorInstructions: []
2026
+ }));
2027
+ }
2028
+ }
2029
+ }, [
2030
+ state.selectedRepoName,
2031
+ state.workflowAction,
2032
+ state.selectedWorkflows,
2033
+ state.useCurrentRepo,
2034
+ state.workflowExists,
2035
+ state.secretExists,
2036
+ state.authType
2037
+ ]);
2038
+ async function openGitHubAppInstallation() {
2039
+ const installUrl = "https://github.com/apps/claude";
2040
+ await openBrowser(installUrl);
2041
+ }
2042
+ async function checkRepositoryPermissions(repoName) {
2043
+ try {
2044
+ const result = await execFileNoThrow("gh", [
2045
+ "api",
2046
+ `repos/${repoName}`,
2047
+ "--jq",
2048
+ ".permissions.admin"
2049
+ ]);
2050
+ if (result.code === 0) {
2051
+ const hasAdmin = result.stdout.trim() === "true";
2052
+ return { hasAccess: hasAdmin };
2053
+ }
2054
+ if (result.stderr.includes("404") || result.stderr.includes("Not Found")) {
2055
+ return {
2056
+ hasAccess: false,
2057
+ error: "repository_not_found"
2058
+ };
2059
+ }
2060
+ return { hasAccess: false };
2061
+ } catch {
2062
+ return { hasAccess: false };
2063
+ }
2064
+ }
2065
+ async function checkExistingWorkflowFile(repoName) {
2066
+ const checkFileResult = await execFileNoThrow("gh", [
2067
+ "api",
2068
+ `repos/${repoName}/contents/.github/workflows/claude.yml`,
2069
+ "--jq",
2070
+ ".sha"
2071
+ ]);
2072
+ return checkFileResult.code === 0;
2073
+ }
2074
+ async function checkExistingSecret() {
2075
+ const checkSecretsResult = await execFileNoThrow("gh", [
2076
+ "secret",
2077
+ "list",
2078
+ "--app",
2079
+ "actions",
2080
+ "--repo",
2081
+ state.selectedRepoName
2082
+ ]);
2083
+ if (checkSecretsResult.code === 0) {
2084
+ const lines = checkSecretsResult.stdout.split(`
2085
+ `);
2086
+ const hasAnthropicKey = lines.some((line) => {
2087
+ return /^ANTHROPIC_API_KEY\s+/.test(line);
2088
+ });
2089
+ if (hasAnthropicKey) {
2090
+ setState((prev) => ({
2091
+ ...prev,
2092
+ secretExists: true,
2093
+ step: "check-existing-secret"
2094
+ }));
2095
+ } else {
2096
+ if (existingApiKey) {
2097
+ setState((prev) => ({
2098
+ ...prev,
2099
+ apiKeyOrOAuthToken: existingApiKey,
2100
+ useExistingKey: true
2101
+ }));
2102
+ await runSetupGitHubActions(existingApiKey, state.secretName);
2103
+ } else {
2104
+ setState((prev) => ({ ...prev, step: "api-key" }));
2105
+ }
2106
+ }
2107
+ } else {
2108
+ if (existingApiKey) {
2109
+ setState((prev) => ({
2110
+ ...prev,
2111
+ apiKeyOrOAuthToken: existingApiKey,
2112
+ useExistingKey: true
2113
+ }));
2114
+ await runSetupGitHubActions(existingApiKey, state.secretName);
2115
+ } else {
2116
+ setState((prev) => ({ ...prev, step: "api-key" }));
2117
+ }
2118
+ }
2119
+ }
2120
+ const handleSubmit = async () => {
2121
+ if (state.step === "warnings") {
2122
+ logEvent("tengu_install_github_app_step_completed", {
2123
+ step: "warnings"
2124
+ });
2125
+ setState((prev) => ({ ...prev, step: "install-app" }));
2126
+ setTimeout(openGitHubAppInstallation, 0);
2127
+ } else if (state.step === "choose-repo") {
2128
+ let repoName = state.useCurrentRepo ? state.currentRepo : state.selectedRepoName;
2129
+ if (!repoName.trim()) {
2130
+ return;
2131
+ }
2132
+ const repoWarnings = [];
2133
+ if (repoName.includes("github.com")) {
2134
+ const match = repoName.match(/github\.com[:/]([^/]+\/[^/]+)(\.git)?$/);
2135
+ if (!match) {
2136
+ repoWarnings.push({
2137
+ title: "Invalid GitHub URL format",
2138
+ message: "The repository URL format appears to be invalid.",
2139
+ instructions: [
2140
+ "Use format: owner/repo or https://github.com/owner/repo",
2141
+ "Example: anthropics/claude-cli"
2142
+ ]
2143
+ });
2144
+ } else {
2145
+ repoName = match[1]?.replace(/\.git$/, "") || "";
2146
+ }
2147
+ }
2148
+ if (!repoName.includes("/")) {
2149
+ repoWarnings.push({
2150
+ title: "Repository format warning",
2151
+ message: 'Repository should be in format "owner/repo"',
2152
+ instructions: [
2153
+ "Use format: owner/repo",
2154
+ "Example: anthropics/claude-cli"
2155
+ ]
2156
+ });
2157
+ }
2158
+ const permissionCheck = await checkRepositoryPermissions(repoName);
2159
+ if (permissionCheck.error === "repository_not_found") {
2160
+ repoWarnings.push({
2161
+ title: "Repository not found",
2162
+ message: `Repository ${repoName} was not found or you don't have access.`,
2163
+ instructions: [
2164
+ `Check that the repository name is correct: ${repoName}`,
2165
+ "Ensure you have access to this repository",
2166
+ 'For private repositories, make sure your GitHub token has the "repo" scope',
2167
+ "You can add the repo scope with: gh auth refresh -h github.com -s repo,workflow"
2168
+ ]
2169
+ });
2170
+ } else if (!permissionCheck.hasAccess) {
2171
+ repoWarnings.push({
2172
+ title: "Admin permissions required",
2173
+ message: `You might need admin permissions on ${repoName} to set up GitHub Actions.`,
2174
+ instructions: [
2175
+ "Repository admins can install GitHub Apps and set secrets",
2176
+ "Ask a repository admin to run this command if setup fails",
2177
+ "Alternatively, you can use the manual setup instructions"
2178
+ ]
2179
+ });
2180
+ }
2181
+ const workflowExists = await checkExistingWorkflowFile(repoName);
2182
+ if (repoWarnings.length > 0) {
2183
+ const allWarnings = [...state.warnings, ...repoWarnings];
2184
+ setState((prev) => ({
2185
+ ...prev,
2186
+ selectedRepoName: repoName,
2187
+ workflowExists,
2188
+ warnings: allWarnings,
2189
+ step: "warnings"
2190
+ }));
2191
+ } else {
2192
+ logEvent("tengu_install_github_app_step_completed", {
2193
+ step: "choose-repo"
2194
+ });
2195
+ setState((prev) => ({
2196
+ ...prev,
2197
+ selectedRepoName: repoName,
2198
+ workflowExists,
2199
+ step: "install-app"
2200
+ }));
2201
+ setTimeout(openGitHubAppInstallation, 0);
2202
+ }
2203
+ } else if (state.step === "install-app") {
2204
+ logEvent("tengu_install_github_app_step_completed", {
2205
+ step: "install-app"
2206
+ });
2207
+ if (state.workflowExists) {
2208
+ setState((prev) => ({ ...prev, step: "check-existing-workflow" }));
2209
+ } else {
2210
+ setState((prev) => ({ ...prev, step: "select-workflows" }));
2211
+ }
2212
+ } else if (state.step === "check-existing-workflow") {
2213
+ return;
2214
+ } else if (state.step === "select-workflows") {
2215
+ return;
2216
+ } else if (state.step === "check-existing-secret") {
2217
+ logEvent("tengu_install_github_app_step_completed", {
2218
+ step: "check-existing-secret"
2219
+ });
2220
+ if (state.useExistingSecret) {
2221
+ await runSetupGitHubActions(null, state.secretName);
2222
+ } else {
2223
+ await runSetupGitHubActions(state.apiKeyOrOAuthToken, state.secretName);
2224
+ }
2225
+ } else if (state.step === "api-key") {
2226
+ if (state.selectedApiKeyOption === "oauth") {
2227
+ return;
2228
+ }
2229
+ const apiKeyToUse = state.selectedApiKeyOption === "existing" ? existingApiKey : state.apiKeyOrOAuthToken;
2230
+ if (!apiKeyToUse) {
2231
+ logEvent("tengu_install_github_app_error", {
2232
+ reason: "api_key_missing"
2233
+ });
2234
+ setState((prev) => ({
2235
+ ...prev,
2236
+ step: "error",
2237
+ error: "API key is required"
2238
+ }));
2239
+ return;
2240
+ }
2241
+ setState((prev) => ({
2242
+ ...prev,
2243
+ apiKeyOrOAuthToken: apiKeyToUse,
2244
+ useExistingKey: state.selectedApiKeyOption === "existing"
2245
+ }));
2246
+ const checkSecretsResult = await execFileNoThrow("gh", [
2247
+ "secret",
2248
+ "list",
2249
+ "--app",
2250
+ "actions",
2251
+ "--repo",
2252
+ state.selectedRepoName
2253
+ ]);
2254
+ if (checkSecretsResult.code === 0) {
2255
+ const lines = checkSecretsResult.stdout.split(`
2256
+ `);
2257
+ const hasAnthropicKey = lines.some((line) => {
2258
+ return /^ANTHROPIC_API_KEY\s+/.test(line);
2259
+ });
2260
+ if (hasAnthropicKey) {
2261
+ logEvent("tengu_install_github_app_step_completed", {
2262
+ step: "api-key"
2263
+ });
2264
+ setState((prev) => ({
2265
+ ...prev,
2266
+ secretExists: true,
2267
+ step: "check-existing-secret"
2268
+ }));
2269
+ } else {
2270
+ logEvent("tengu_install_github_app_step_completed", {
2271
+ step: "api-key"
2272
+ });
2273
+ await runSetupGitHubActions(apiKeyToUse, state.secretName);
2274
+ }
2275
+ } else {
2276
+ logEvent("tengu_install_github_app_step_completed", {
2277
+ step: "api-key"
2278
+ });
2279
+ await runSetupGitHubActions(apiKeyToUse, state.secretName);
2280
+ }
2281
+ }
2282
+ };
2283
+ const handleRepoUrlChange = (value) => {
2284
+ setState((prev) => ({ ...prev, selectedRepoName: value }));
2285
+ };
2286
+ const handleApiKeyChange = (value) => {
2287
+ setState((prev) => ({ ...prev, apiKeyOrOAuthToken: value }));
2288
+ };
2289
+ const handleApiKeyOptionChange = (option) => {
2290
+ setState((prev) => ({ ...prev, selectedApiKeyOption: option }));
2291
+ };
2292
+ const handleCreateOAuthToken = import_react6.useCallback(() => {
2293
+ logEvent("tengu_install_github_app_step_completed", {
2294
+ step: "api-key"
2295
+ });
2296
+ setState((prev) => ({ ...prev, step: "oauth-flow" }));
2297
+ }, []);
2298
+ const handleOAuthSuccess = import_react6.useCallback((token) => {
2299
+ logEvent("tengu_install_github_app_step_completed", {
2300
+ step: "oauth-flow"
2301
+ });
2302
+ setState((prev) => ({
2303
+ ...prev,
2304
+ apiKeyOrOAuthToken: token,
2305
+ useExistingKey: false,
2306
+ secretName: "CLAUDE_CODE_OAUTH_TOKEN",
2307
+ authType: "oauth_token"
2308
+ }));
2309
+ runSetupGitHubActions(token, "CLAUDE_CODE_OAUTH_TOKEN");
2310
+ }, [runSetupGitHubActions]);
2311
+ const handleOAuthCancel = import_react6.useCallback(() => {
2312
+ setState((prev) => ({ ...prev, step: "api-key" }));
2313
+ }, []);
2314
+ const handleSecretNameChange = (value) => {
2315
+ if (value && !/^[a-zA-Z0-9_]+$/.test(value))
2316
+ return;
2317
+ setState((prev) => ({ ...prev, secretName: value }));
2318
+ };
2319
+ const handleToggleUseCurrentRepo = (useCurrentRepo) => {
2320
+ setState((prev) => ({
2321
+ ...prev,
2322
+ useCurrentRepo,
2323
+ selectedRepoName: useCurrentRepo ? prev.currentRepo : ""
2324
+ }));
2325
+ };
2326
+ const handleToggleUseExistingKey = (useExistingKey) => {
2327
+ setState((prev) => ({ ...prev, useExistingKey }));
2328
+ };
2329
+ const handleToggleUseExistingSecret = (useExistingSecret) => {
2330
+ setState((prev) => ({
2331
+ ...prev,
2332
+ useExistingSecret,
2333
+ secretName: useExistingSecret ? "ANTHROPIC_API_KEY" : ""
2334
+ }));
2335
+ };
2336
+ const handleWorkflowAction = async (action) => {
2337
+ if (action === "exit") {
2338
+ props.onDone("Installation cancelled by user");
2339
+ return;
2340
+ }
2341
+ logEvent("tengu_install_github_app_step_completed", {
2342
+ step: "check-existing-workflow"
2343
+ });
2344
+ setState((prev) => ({ ...prev, workflowAction: action }));
2345
+ if (action === "skip" || action === "update") {
2346
+ if (existingApiKey) {
2347
+ await checkExistingSecret();
2348
+ } else {
2349
+ setState((prev) => ({ ...prev, step: "api-key" }));
2350
+ }
2351
+ }
2352
+ };
2353
+ function handleDismissKeyDown(e) {
2354
+ e.preventDefault();
2355
+ if (state.step === "success") {
2356
+ logEvent("tengu_install_github_app_completed", {});
2357
+ }
2358
+ props.onDone(state.step === "success" ? "GitHub Actions setup complete!" : state.error ? `Couldn't install GitHub App: ${state.error}
2359
+ For manual setup instructions, see: ${GITHUB_ACTION_SETUP_DOCS_URL}` : `GitHub App installation failed
2360
+ For manual setup instructions, see: ${GITHUB_ACTION_SETUP_DOCS_URL}`);
2361
+ }
2362
+ switch (state.step) {
2363
+ case "check-gh":
2364
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(CheckGitHubStep, {}, undefined, false, undefined, this);
2365
+ case "warnings":
2366
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(WarningsStep, {
2367
+ warnings: state.warnings,
2368
+ onContinue: handleSubmit
2369
+ }, undefined, false, undefined, this);
2370
+ case "choose-repo":
2371
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(ChooseRepoStep, {
2372
+ currentRepo: state.currentRepo,
2373
+ useCurrentRepo: state.useCurrentRepo,
2374
+ repoUrl: state.selectedRepoName,
2375
+ onRepoUrlChange: handleRepoUrlChange,
2376
+ onToggleUseCurrentRepo: handleToggleUseCurrentRepo,
2377
+ onSubmit: handleSubmit
2378
+ }, undefined, false, undefined, this);
2379
+ case "install-app":
2380
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(InstallAppStep, {
2381
+ repoUrl: state.selectedRepoName,
2382
+ onSubmit: handleSubmit
2383
+ }, undefined, false, undefined, this);
2384
+ case "check-existing-workflow":
2385
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(ExistingWorkflowStep, {
2386
+ repoName: state.selectedRepoName,
2387
+ onSelectAction: handleWorkflowAction
2388
+ }, undefined, false, undefined, this);
2389
+ case "check-existing-secret":
2390
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(CheckExistingSecretStep, {
2391
+ useExistingSecret: state.useExistingSecret,
2392
+ secretName: state.secretName,
2393
+ onToggleUseExistingSecret: handleToggleUseExistingSecret,
2394
+ onSecretNameChange: handleSecretNameChange,
2395
+ onSubmit: handleSubmit
2396
+ }, undefined, false, undefined, this);
2397
+ case "api-key":
2398
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(ApiKeyStep, {
2399
+ existingApiKey,
2400
+ useExistingKey: state.useExistingKey,
2401
+ apiKeyOrOAuthToken: state.apiKeyOrOAuthToken,
2402
+ onApiKeyChange: handleApiKeyChange,
2403
+ onToggleUseExistingKey: handleToggleUseExistingKey,
2404
+ onSubmit: handleSubmit,
2405
+ onCreateOAuthToken: isAnthropicAuthEnabled() ? handleCreateOAuthToken : undefined,
2406
+ selectedOption: state.selectedApiKeyOption,
2407
+ onSelectOption: handleApiKeyOptionChange
2408
+ }, undefined, false, undefined, this);
2409
+ case "creating":
2410
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(CreatingStep, {
2411
+ currentWorkflowInstallStep: state.currentWorkflowInstallStep,
2412
+ secretExists: state.secretExists,
2413
+ useExistingSecret: state.useExistingSecret,
2414
+ secretName: state.secretName,
2415
+ skipWorkflow: state.workflowAction === "skip",
2416
+ selectedWorkflows: state.selectedWorkflows
2417
+ }, undefined, false, undefined, this);
2418
+ case "success":
2419
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(ThemedBox_default, {
2420
+ tabIndex: 0,
2421
+ autoFocus: true,
2422
+ onKeyDown: handleDismissKeyDown,
2423
+ children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(SuccessStep, {
2424
+ secretExists: state.secretExists,
2425
+ useExistingSecret: state.useExistingSecret,
2426
+ secretName: state.secretName,
2427
+ skipWorkflow: state.workflowAction === "skip"
2428
+ }, undefined, false, undefined, this)
2429
+ }, undefined, false, undefined, this);
2430
+ case "error":
2431
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(ThemedBox_default, {
2432
+ tabIndex: 0,
2433
+ autoFocus: true,
2434
+ onKeyDown: handleDismissKeyDown,
2435
+ children: /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(ErrorStep, {
2436
+ error: state.error,
2437
+ errorReason: state.errorReason,
2438
+ errorInstructions: state.errorInstructions
2439
+ }, undefined, false, undefined, this)
2440
+ }, undefined, false, undefined, this);
2441
+ case "select-workflows":
2442
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(WorkflowMultiselectDialog, {
2443
+ defaultSelections: state.selectedWorkflows,
2444
+ onSubmit: (selectedWorkflows) => {
2445
+ logEvent("tengu_install_github_app_step_completed", {
2446
+ step: "select-workflows"
2447
+ });
2448
+ setState((prev) => ({
2449
+ ...prev,
2450
+ selectedWorkflows
2451
+ }));
2452
+ if (existingApiKey) {
2453
+ checkExistingSecret();
2454
+ } else {
2455
+ setState((prev) => ({ ...prev, step: "api-key" }));
2456
+ }
2457
+ }
2458
+ }, undefined, false, undefined, this);
2459
+ case "oauth-flow":
2460
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(OAuthFlowStep, {
2461
+ onSuccess: handleOAuthSuccess,
2462
+ onCancel: handleOAuthCancel
2463
+ }, undefined, false, undefined, this);
2464
+ }
2465
+ }
2466
+ async function call(onDone) {
2467
+ return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(InstallGitHubApp, {
2468
+ onDone
2469
+ }, undefined, false, undefined, this);
2470
+ }
2471
+ var import_react6, jsx_dev_runtime13, INITIAL_STATE;
2472
+ var init_install_github_app = __esm(() => {
2473
+ init_execa();
2474
+ init_analytics();
2475
+ init_WorkflowMultiselectDialog();
2476
+ init_github_app();
2477
+ init_useExitOnCtrlCDWithKeybindings();
2478
+ init_src();
2479
+ init_auth();
2480
+ init_browser();
2481
+ init_execFileNoThrow();
2482
+ init_git();
2483
+ init_stringUtils();
2484
+ init_ApiKeyStep();
2485
+ init_CheckExistingSecretStep();
2486
+ init_CheckGitHubStep();
2487
+ init_ChooseRepoStep();
2488
+ init_CreatingStep();
2489
+ init_ErrorStep();
2490
+ init_ExistingWorkflowStep();
2491
+ init_InstallAppStep();
2492
+ init_OAuthFlowStep();
2493
+ init_SuccessStep();
2494
+ init_setupGitHubActions();
2495
+ init_WarningsStep();
2496
+ import_react6 = __toESM(require_react(), 1);
2497
+ jsx_dev_runtime13 = __toESM(require_jsx_dev_runtime(), 1);
2498
+ INITIAL_STATE = {
2499
+ step: "check-gh",
2500
+ selectedRepoName: "",
2501
+ currentRepo: "",
2502
+ useCurrentRepo: false,
2503
+ apiKeyOrOAuthToken: "",
2504
+ useExistingKey: true,
2505
+ currentWorkflowInstallStep: 0,
2506
+ warnings: [],
2507
+ secretExists: false,
2508
+ secretName: "ANTHROPIC_API_KEY",
2509
+ useExistingSecret: true,
2510
+ workflowExists: false,
2511
+ selectedWorkflows: ["claude", "claude-review"],
2512
+ selectedApiKeyOption: "new",
2513
+ authType: "api_key"
2514
+ };
2515
+ });
2516
+ init_install_github_app();
2517
+
2518
+ export {
2519
+ call
2520
+ };