@testmuai/kane-cli 0.8.14 → 0.8.15

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 (189) hide show
  1. package/dist/{ChatSurface-AVL3TJA2.js → ChatSurface-2GPR4S7I.js} +1 -1
  2. package/dist/{ChromeProfilePicker-WJZJOZ6Z.js → ChromeProfilePicker-XAZGCJKR.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-65BQF5G5.js → CliFeedbackPrompt-4SILDU7S.js} +1 -1
  4. package/dist/{CliUploadProgress-HEBZYKGN.js → CliUploadProgress-OAQBY55Y.js} +1 -1
  5. package/dist/{ConfigView-JEVQ2SO4.js → ConfigView-FDBMJC26.js} +1 -1
  6. package/dist/EvidenceViewOffer-YSNRKKPC.js +2 -0
  7. package/dist/FolderPicker-XCTJ5447.js +2 -0
  8. package/dist/{InfoBox-KM5DLBCV.js → InfoBox-ZPUBB7J4.js} +1 -1
  9. package/dist/{LinksBox-FQA36GTV.js → LinksBox-MNNNOH23.js} +1 -1
  10. package/dist/{ProfilesView-76KGHTMK.js → ProfilesView-GY5QCIT3.js} +1 -1
  11. package/dist/{ProjectPicker-65YOU46H.js → ProjectPicker-UCHMCNFV.js} +1 -1
  12. package/dist/{SaveSessionPrompt-QD6BNTWO.js → SaveSessionPrompt-ATVHKAHN.js} +1 -1
  13. package/dist/SingleShotApp-IPNZBFXB.js +2 -0
  14. package/dist/{SummaryBox-N2B6DUDD.js → SummaryBox-2DTNE25L.js} +1 -1
  15. package/dist/TestMdRunView-2FQIEI5W.js +2 -0
  16. package/dist/{TestrunEvidenceTable-3WLQVTF4.js → TestrunEvidenceTable-6UE5EMON.js} +1 -1
  17. package/dist/{WhoamiView-T26HA4ZZ.js → WhoamiView-TFCHIOW5.js} +1 -1
  18. package/dist/{app-download-XKZWFMEK.js → app-download-N7MLJQ42.js} +1 -1
  19. package/dist/{auth-PPJANIMZ.js → auth-IQPCVCZK.js} +1 -1
  20. package/dist/{binary-DKWWODT2.js → binary-VML7EGV4.js} +1 -1
  21. package/dist/{bind-62AZYFAY.js → bind-YV6V5AI6.js} +2 -2
  22. package/dist/{bootstrap-6IJNZIPT.js → bootstrap-KCPWDBLX.js} +1 -1
  23. package/dist/bridge-5UKX7YIO.js +2 -0
  24. package/dist/{changelog-UTGJ7FSP.js → changelog-CJFWGRIL.js} +1 -1
  25. package/dist/chunk-27ERHOW3.js +2 -0
  26. package/dist/{chunk-WR42Q3HU.js → chunk-2WRBCTNM.js} +1 -1
  27. package/dist/{chunk-73ULUGBM.js → chunk-3D5MKSG3.js} +1 -1
  28. package/dist/{chunk-2BFXT7VQ.js → chunk-3GELV4IN.js} +3 -3
  29. package/dist/{chunk-O6U2HU5M.js → chunk-4TMQTSIO.js} +1 -1
  30. package/dist/{chunk-X74PP5NJ.js → chunk-5HTSKF5K.js} +1 -1
  31. package/dist/{chunk-MLRO7OH3.js → chunk-6DHEOPXX.js} +1 -1
  32. package/dist/{chunk-WBHSPN55.js → chunk-6GLFQHSW.js} +2 -2
  33. package/dist/chunk-6K4FDYMH.js +89 -0
  34. package/dist/{chunk-3BHRGHIZ.js → chunk-6L5RV62W.js} +1 -1
  35. package/dist/{chunk-N7ZRF5K3.js → chunk-74FHTDEE.js} +1 -1
  36. package/dist/{chunk-CGT4NFQN.js → chunk-7EGIX6Y4.js} +2 -2
  37. package/dist/{chunk-3YX3RQXO.js → chunk-7WDPU33M.js} +1 -1
  38. package/dist/{chunk-JKX57HA7.js → chunk-7X4R6464.js} +1 -1
  39. package/dist/{chunk-RQLU4NDG.js → chunk-A557OSRS.js} +1 -1
  40. package/dist/{chunk-3SPOJWRA.js → chunk-AYJ2YZP5.js} +1 -1
  41. package/dist/{chunk-YHVG7V3E.js → chunk-BMVE73M7.js} +1 -1
  42. package/dist/chunk-CAOZKSQ3.js +8 -0
  43. package/dist/{chunk-L6MOO4WT.js → chunk-CNPIJFZM.js} +1 -1
  44. package/dist/{chunk-EMSLJTYN.js → chunk-D6GBOFK5.js} +1 -1
  45. package/dist/{chunk-FFFB5BXL.js → chunk-DMCEGMGB.js} +1 -1
  46. package/dist/{chunk-J7NRD4Q7.js → chunk-DMT3W26F.js} +1 -1
  47. package/dist/{chunk-NOLYYHVG.js → chunk-EDQZIEPJ.js} +1 -1
  48. package/dist/{chunk-K7K23DIQ.js → chunk-EFTRH35G.js} +1 -1
  49. package/dist/{chunk-LL5DQO6V.js → chunk-EJXBKCNF.js} +1 -1
  50. package/dist/{chunk-OH2NSBO6.js → chunk-EPE2ELDH.js} +1 -1
  51. package/dist/{chunk-42FHKRPA.js → chunk-FXO7JKMZ.js} +3 -3
  52. package/dist/{chunk-VNFCX2SH.js → chunk-GSDXZS4U.js} +1 -1
  53. package/dist/{chunk-4K5XTIJ6.js → chunk-GZ65ZA4C.js} +1 -1
  54. package/dist/{chunk-Q7XBMBMR.js → chunk-HLCETZ73.js} +1 -1
  55. package/dist/{chunk-B2ZGG7WM.js → chunk-HYTBEPC2.js} +1 -1
  56. package/dist/{chunk-AC7BPO4X.js → chunk-IAHOLH5W.js} +1 -1
  57. package/dist/{chunk-GESG672R.js → chunk-JCMHB4KH.js} +1 -1
  58. package/dist/{chunk-XGHMZJGI.js → chunk-JFUFWICY.js} +2 -2
  59. package/dist/{chunk-JH6E632O.js → chunk-JGAMMOUC.js} +1 -1
  60. package/dist/{chunk-KOL6ZWOQ.js → chunk-JL3L6KOG.js} +1 -1
  61. package/dist/chunk-JQCOKL6U.js +15 -0
  62. package/dist/{chunk-M7DN6FO3.js → chunk-JSS22MFY.js} +9 -9
  63. package/dist/chunk-JVEZBJJ7.js +2 -0
  64. package/dist/{chunk-ZWHPIR2Z.js → chunk-KALEPJAV.js} +2 -2
  65. package/dist/{chunk-O2APH6TZ.js → chunk-KUS324VE.js} +1 -1
  66. package/dist/{chunk-NDCRJXYF.js → chunk-LJGAXIDU.js} +1 -1
  67. package/dist/{chunk-ZKEOPIQ3.js → chunk-M36MOFJW.js} +1 -1
  68. package/dist/{chunk-O5AS2ZIX.js → chunk-MLYNVJNH.js} +1 -1
  69. package/dist/{chunk-GKZ2KVE6.js → chunk-N3CVR4Z2.js} +1 -1
  70. package/dist/{chunk-6F6YI3ZG.js → chunk-NLEA6NPU.js} +1 -1
  71. package/dist/{chunk-SGHP44WS.js → chunk-NUJVYAI4.js} +1 -1
  72. package/dist/{chunk-IQ7NGOAT.js → chunk-NWNG5UWD.js} +1 -1
  73. package/dist/{chunk-IICQ5KRD.js → chunk-O66WXOOC.js} +3 -3
  74. package/dist/{chunk-ZA4M4O7E.js → chunk-OFWJBOGT.js} +2 -2
  75. package/dist/{chunk-MNE5VMHT.js → chunk-OGDAWNFY.js} +1 -1
  76. package/dist/{chunk-75I46VTM.js → chunk-ORQGQSWG.js} +2 -2
  77. package/dist/{chunk-YHR2YAN5.js → chunk-OWGFFJKK.js} +1 -1
  78. package/dist/{chunk-SQDQADWD.js → chunk-PGXJ275T.js} +1 -1
  79. package/dist/{chunk-P3JUE2RM.js → chunk-Q77QO3PC.js} +4 -4
  80. package/dist/{chunk-JJJSDDQ2.js → chunk-QVLYK5JL.js} +1 -1
  81. package/dist/{chunk-UXH3RMQ7.js → chunk-QXRT6HSV.js} +1 -1
  82. package/dist/{chunk-RH6KFHJB.js → chunk-R7QMZBBH.js} +1 -1
  83. package/dist/{chunk-BJYGWXVP.js → chunk-RI4ILZZC.js} +1 -1
  84. package/dist/{chunk-PGU64EWQ.js → chunk-RQILLYSP.js} +1 -1
  85. package/dist/chunk-S4JUCBCT.js +7 -0
  86. package/dist/{chunk-4BBDKWM3.js → chunk-SHSXOYKT.js} +1 -1
  87. package/dist/{chunk-7RAI77XD.js → chunk-SIYSKT6I.js} +1 -1
  88. package/dist/{chunk-22QIVSQR.js → chunk-SWTJMTBY.js} +1 -1
  89. package/dist/{chunk-X5276I5H.js → chunk-T4R26WER.js} +2 -2
  90. package/dist/{chunk-BAKJPQGU.js → chunk-TEHZUSUY.js} +1 -1
  91. package/dist/{chunk-RBHQXWR7.js → chunk-TVELOH5A.js} +1 -1
  92. package/dist/{chunk-6LGED4FC.js → chunk-UHSNUUX3.js} +2 -2
  93. package/dist/{chunk-QPUVOVD7.js → chunk-UZIMYV5U.js} +1 -1
  94. package/dist/{chunk-WILT62DP.js → chunk-VOTIGXQ4.js} +1 -1
  95. package/dist/{chunk-SFTFHFG3.js → chunk-VZDLRJ5N.js} +1 -1
  96. package/dist/{chunk-2RMHDOP4.js → chunk-W77SZLFC.js} +1 -1
  97. package/dist/{chunk-QJ5O27SJ.js → chunk-WFBJNVMQ.js} +1 -1
  98. package/dist/{chunk-SX56MVUO.js → chunk-WNB2IYHY.js} +1 -1
  99. package/dist/chunk-XSUJJB7Z.js +11 -0
  100. package/dist/{chunk-NBMLBCJ3.js → chunk-XUJXGE42.js} +1 -1
  101. package/dist/{chunk-ARG56PJG.js → chunk-XXE7W5AV.js} +1 -1
  102. package/dist/{chunk-DA57DXCF.js → chunk-YAAQER2L.js} +1 -1
  103. package/dist/{chunk-7L25ZNNP.js → chunk-YGMUNNKH.js} +1 -1
  104. package/dist/{chunk-OO5GMBVI.js → chunk-YKYKOV6U.js} +1 -1
  105. package/dist/{chunk-C74ABM24.js → chunk-YZVR7ESF.js} +1 -1
  106. package/dist/{chunk-GPIXV7AV.js → chunk-Z3YYMZHT.js} +1 -1
  107. package/dist/{chunk-WOA7VCGA.js → chunk-Z73ZYROU.js} +1 -1
  108. package/dist/{chunk-LR5DJ6EN.js → chunk-ZCSEBT2W.js} +1 -1
  109. package/dist/{chunk-KOPP4CJW.js → chunk-ZEVU2OT3.js} +1 -1
  110. package/dist/{chunk-IQ7GPETF.js → chunk-ZKCCG3GK.js} +1 -1
  111. package/dist/{config-3AKWRTFS.js → config-UGCWZGH5.js} +1 -1
  112. package/dist/{cover-cmd-ZLAWMEC2.js → cover-cmd-SWJ2NZUZ.js} +1 -1
  113. package/dist/{credentials-Q4WH5CBN.js → credentials-GWLYYRTL.js} +1 -1
  114. package/dist/{deps-bundle-RVZK6LZJ.js → deps-bundle-VNGC2UG6.js} +1 -1
  115. package/dist/{deps-resolve-6F2U4TJP.js → deps-resolve-YLCEU6I7.js} +1 -1
  116. package/dist/{dispatch-46BETGXY.js → dispatch-OMQCT7WO.js} +1 -1
  117. package/dist/{doctor-WRPG56HH.js → doctor-B4Z6RPKQ.js} +1 -1
  118. package/dist/{evidence-XWR32HWP.js → evidence-XJGXVLO5.js} +1 -1
  119. package/dist/{evolve-cmd-27ZQN6YB.js → evolve-cmd-QQQPPGL3.js} +1 -1
  120. package/dist/{explain-cmd-JCJTXVZY.js → explain-cmd-XVE6Z67Q.js} +1 -1
  121. package/dist/{extract-bind-D5BYYGYA.js → extract-bind-7IDQS4QP.js} +2 -2
  122. package/dist/{extract-cmd-CCYW7FIY.js → extract-cmd-KIEOBRIT.js} +1 -1
  123. package/dist/{gaps-cmd-3VJKQ25D.js → gaps-cmd-RGIPUSIR.js} +1 -1
  124. package/dist/{generate-headless-2M6UT3IK.js → generate-headless-XGRIDD6O.js} +2 -2
  125. package/dist/index.js +134 -136
  126. package/dist/{ingest-cmd-HVTUK264.js → ingest-cmd-R5H5SF5K.js} +1 -1
  127. package/dist/install-W3VPVPAQ.js +2 -0
  128. package/dist/{interactive-bind-OJCYNQPI.js → interactive-bind-X5DVLRRW.js} +3 -3
  129. package/dist/{lifecycle-cmd-GWFGUGTC.js → lifecycle-cmd-6R2PR2HM.js} +1 -1
  130. package/dist/{list-cmd-AXDW64OY.js → list-cmd-QCIYKWYQ.js} +1 -1
  131. package/dist/{list-commands-YNZ6EFIF.js → list-commands-VRRCVWKO.js} +1 -1
  132. package/dist/login-flow-5HL2QYEL.js +2 -0
  133. package/dist/{maintenance-cmd-QEMK6YNV.js → maintenance-cmd-GZ4EMT3V.js} +1 -1
  134. package/dist/{mobile-prompts-OXHA5GHJ.js → mobile-prompts-CMIVWDHQ.js} +1 -1
  135. package/dist/objective-variable-gate-EEYJ6B3X.js +2 -0
  136. package/dist/{open-provider-E5VUGFNE.js → open-provider-UFSCTIQQ.js} +1 -1
  137. package/dist/{persist-recorded-session-KWPH37HI.js → persist-recorded-session-JXL5E53A.js} +1 -1
  138. package/dist/pipeline-RSCRNNPW.js +2 -0
  139. package/dist/prepare-target-XZ3FTVBW.js +2 -0
  140. package/dist/{reconcile-cmd-V7TDYETT.js → reconcile-cmd-4VRTUM2D.js} +1 -1
  141. package/dist/{reconcile-deps-X6IGH4CA.js → reconcile-deps-ZCJ2QCK5.js} +2 -2
  142. package/dist/{reconcile-engine-OGXSIE7O.js → reconcile-engine-IVLZCYZB.js} +1 -1
  143. package/dist/{recording-banner-IZWN2XFY.js → recording-banner-SRLPSTFP.js} +1 -1
  144. package/dist/registry-CPQHW2L2.js +2 -0
  145. package/dist/{require-project-folder-PEEUITK6.js → require-project-folder-SKEZMSN7.js} +1 -1
  146. package/dist/{resolve-run-intent-JGXXE45Y.js → resolve-run-intent-THC3EPAX.js} +1 -1
  147. package/dist/{resolver-TY7XLJBN.js → resolver-2NUNLK7N.js} +1 -1
  148. package/dist/{review-cmd-74YTPT7E.js → review-cmd-BMJQZ6XJ.js} +1 -1
  149. package/dist/{run-GRYWYKIH.js → run-TURFDLC6.js} +1 -1
  150. package/dist/{run-DN4XARP2.js → run-UDP5VPYS.js} +1 -1
  151. package/dist/{run-test-md-DFCKCQ4T.js → run-test-md-MRYNFNPO.js} +2 -2
  152. package/dist/{skill-installer-GRU3HOYF.js → skill-installer-CVJ5VTEJ.js} +1 -1
  153. package/dist/{spawner-LNMD4NJF.js → spawner-7FUA3JXA.js} +1 -1
  154. package/dist/{store-guard-Q4MYZQHF.js → store-guard-XQ5MSUB2.js} +1 -1
  155. package/dist/{sync-cmd-H6Y5EB3L.js → sync-cmd-5INKTZN2.js} +1 -1
  156. package/dist/{sync-setup-THGRBKTA.js → sync-setup-4R54VRAO.js} +1 -1
  157. package/dist/tcg-generate-2BOPGRM6.js +2 -0
  158. package/dist/testmd-actions-2CPJZAC2.js +2 -0
  159. package/dist/testmd-sync-HYZI6NRM.js +2 -0
  160. package/dist/token-refresh-NTE4LQRN.js +2 -0
  161. package/dist/{validate-basic-RCBEELSB.js → validate-basic-OKLJLDML.js} +1 -1
  162. package/dist/{variable-receipt-JHRW73Z6.js → variable-receipt-CMCDUJI2.js} +1 -1
  163. package/dist/{verdicts-XFXDRND4.js → verdicts-EMCYGQWM.js} +1 -1
  164. package/dist/{version-check-Z774UWW3.js → version-check-4DQJBSXW.js} +1 -1
  165. package/dist/{view-cmd-I4LQGJ2X.js → view-cmd-P3XRFORJ.js} +1 -1
  166. package/dist/{walk-session-FP52IGLB.js → walk-session-MUGS6CZY.js} +1 -1
  167. package/dist/{with-telemetry-P6RUPWBH.js → with-telemetry-3T53GIQC.js} +1 -1
  168. package/package.json +11 -11
  169. package/dist/EvidenceViewOffer-5MB4ZXKM.js +0 -2
  170. package/dist/FolderPicker-SYFXH6D5.js +0 -2
  171. package/dist/SingleShotApp-U54ETXS3.js +0 -2
  172. package/dist/TestMdRunView-WA4TC5PT.js +0 -2
  173. package/dist/bridge-X5DEJL6F.js +0 -2
  174. package/dist/chunk-53MPG2J3.js +0 -11
  175. package/dist/chunk-KN65CUNT.js +0 -15
  176. package/dist/chunk-L4M7753M.js +0 -2
  177. package/dist/chunk-LBNADEQN.js +0 -8
  178. package/dist/chunk-LNV7C2YO.js +0 -6
  179. package/dist/chunk-ZZTZJPT2.js +0 -88
  180. package/dist/install-5WJLE7XT.js +0 -2
  181. package/dist/login-flow-PRXFPRYZ.js +0 -2
  182. package/dist/objective-variable-gate-76GYUHEP.js +0 -2
  183. package/dist/pipeline-A2OGF4XW.js +0 -2
  184. package/dist/prepare-target-P6BWJZBZ.js +0 -2
  185. package/dist/registry-GOLIFVK5.js +0 -2
  186. package/dist/tcg-generate-SZZ7MJXY.js +0 -2
  187. package/dist/testmd-actions-MRIUOOXO.js +0 -2
  188. package/dist/testmd-sync-UYVJ47BN.js +0 -2
  189. package/dist/token-refresh-KN5JK2U4.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R,b as Y,g as _,o as N}from"./chunk-ZKEOPIQ3.js";import"./chunk-OPL2MIQG.js";import"./chunk-TU6IMGWO.js";import"./chunk-TNBF5OMZ.js";import"./chunk-HOA4VWSD.js";import"./chunk-YYYQ5MVD.js";import"./chunk-KZG4E5RM.js";import"./chunk-BZAGVBCX.js";import"./chunk-52WM3XYO.js";import"./chunk-BB2W35TW.js";import"./chunk-427OQS2N.js";import"./chunk-AHXOKBVE.js";import"./chunk-ALCE5RLK.js";import"./chunk-Q2F5QB2W.js";import{a as T,b as O,c as U,d as j}from"./chunk-YHVG7V3E.js";import{N as E,O as H,S as L,c as P,e as I}from"./chunk-6LGED4FC.js";import"./chunk-C74ABM24.js";import{c as G,h as A}from"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-WILT62DP.js";import"./chunk-22QIVSQR.js";import"./chunk-IE3OO5GI.js";import{a as f}from"./chunk-CH273NAE.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-YCCUBQY4.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-B2ZGG7WM.js";import"./chunk-DFS4RMVP.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";import{existsSync as y}from"fs";import{resolve as $}from"path";import{spawn as D}from"child_process";var w=class extends Error{},m=e=>{if(e===null)throw new w;return e},u=(e,t,o)=>({value:e,label:t,detail:o});async function p(e,t,o,n=!1){for(;;){let h=m(await e.input(t,o,n)).trim();if(h)return h;e.out("Enter a value, or press Esc to leave setup.")}}async function S(e,t){e.out(`Open in your browser: ${t}`);try{await e.open(t)}catch{e.out("The browser could not open automatically. Open that address yourself, then continue here.")}}async function b(e,t){let o=await e.gitRead(t);return o.ok||e.out(j(o.diagnostic,t)),o.ok}var x=u("change","Use a different address"),C=u("storage","Choose a different storage");async function z(e,t){for(;;)try{await e.checkGit();break}catch(n){e.out(n instanceof Error?n.message:"Git 2.31 or newer is required."),m(await e.choose("Install Git, then return here",[u("open","Open Git installation instructions"),u("retry","Check again")]))==="open"&&await S(e,"https://git-scm.com/downloads")}if(await b(e,t.gitUrl))return"ok";if(!/^https:\/\/github\.com\//i.test(t.gitUrl))for(e.out("Set up Git access for this repository with your server's SSH key or credential helper. kane-cli uses the same access as Git.");;){let n=m(await e.choose("Git cannot read this repository yet.",[u("retry","Check again"),x,C]));if(n==="change"||n==="storage")return n;if(await b(e,t.gitUrl))return"ok"}for(e.out("Sign in below if you have not, or ask the owner to grant your GitHub account access.");;){let n=m(await e.choose("Sign in to access this GitHub repository",[u("login","Sign in with your browser","Use or create your GitHub account."),u("retry","I've fixed my access \u2014 check again","Ask the owner to grant your account access, or check your existing Git login."),x,C]));if(n==="change"||n==="storage")return n;if(n==="login"){if((await e.gh(["--version"])).code){e.out("Browser sign-in uses GitHub CLI, a small GitHub tool. Install it once, then return to this step. GitHub CLI is optional if you already use SSH or another Git credential helper."),m(await e.choose("GitHub CLI is not installed",[u("open","Open installation instructions"),u("retry","Check again")]))==="open"&&await S(e,"https://cli.github.com/");continue}if((await e.gh(["auth","login","--hostname","github.com","--git-protocol","https","--web"],!0)).code){e.out("Sign-in did not finish. Your repository address is still saved in this setup.");continue}for(;(await e.gh(["auth","setup-git","--hostname","github.com"])).code&&(e.out("GitHub sign-in finished, but Git could not be told to use it."),m(await e.choose("Configure Git to use your GitHub sign-in",[u("retry","Try the configuration again"),u("skip","Skip; I use SSH or another credential helper")]))!=="skip"););}if(await b(e,t.gitUrl))return"ok";e.out("A browser login alone does not grant repository permission: ask the owner to grant your GitHub account access.")}}async function k(e){if(m(await e.choose("Access to the bucket",[u("existing","Use credentials already configured on this computer","Existing kane-cli credentials or KANE_SYNC_S3_ACCESS_KEY_ID and KANE_SYNC_S3_SECRET_ACCESS_KEY."),u("keys","Enter the access keys from my storage administrator","Saved in your local kane-cli configuration, never in the shared context.")]))!=="existing")return e.out("These are bucket access keys, not your cloud account password. Your administrator must grant access to the bucket and folder you selected."),{accessKeyId:await p(e,"Access key ID"),secretAccessKey:await p(e,"Secret access key (hidden)",void 0,!0)}}async function W(e,t){let o=t?.kind??m(await e.choose("Where should your team's shared context live?",[u("github","GitHub \u2014 Recommended","Guided setup for a repository: a storage space on GitHub."),u("s3","S3-compatible storage","Use your team's existing cloud bucket and access keys."),u("folder","Folder","A local folder stays on this computer. A mounted shared drive can serve your team.")]));if(o==="github"){t||(e.out("GitHub will hold the requirements, documents and test information you publish from kane-cli. Each teammate signs in with their own account."),m(await e.choose("Choose a GitHub repository",[u("existing","Use an existing repository"),u("create","Create a repository on GitHub","Use a dedicated repository. Choose Private to limit who can see your context.")]))==="create"&&(await S(e,"https://github.com/new"),e.out("On GitHub: choose the owner and repository name, choose Private, and create the repository. Return here and paste its HTTPS address. No code or Git knowledge is needed.")));let d=await p(e,"Repository address (for example https://github.com/my-team/team-context.git)",t?.address);return{location:d,journey:{kind:o,address:d}}}if(o==="folder"){t||e.out("Everyone needs access to the same mounted drive to share through a folder. Sending a local path does not share its contents. Dropbox, iCloud, OneDrive and Google Drive sync folders are not supported.");let d=await p(e,"Folder path",t?.address);return{location:d,journey:{kind:o,address:d}}}t||e.out("Ask your storage administrator for an existing bucket and access keys. kane-cli does not create buckets or cloud permissions.");let n=t?.s3,h=await p(e,"Bucket name",n?.bucket);for(;!/^[a-zA-Z0-9.-]+$/.test(h);)e.out("Use the bucket's name, not a URL."),h=await p(e,"Bucket name");let c=await p(e,"Region",n?.region??"us-east-1"),s=m(await e.input("Folder inside the bucket (optional)",n?.prefix??"")),i=[u("aws","Amazon S3"),u("compatible","Another S3-compatible service")];n&&i.sort((d,g)=>+(g.value===n.service)-+(d.value===n.service));let l=m(await e.choose("Which storage service?",i)),r=new URLSearchParams({region:c}),a=l==="compatible"?await p(e,"Service endpoint (https://host, with an optional port)",n?.service===l?n.endpoint:void 0):void 0;return a&&r.set("endpoint",a),{location:`s3://${h}/${s.split("/").map(encodeURIComponent).join("/")}?${r}`,journey:{kind:"s3",s3:{bucket:h,region:c,prefix:s,service:l,endpoint:a}}}}function K(e){return e.kind==="dir"?"A location address contains no password: everyone who can open this folder can read it; sending the path does not send its contents.":e.kind==="s3"?"A location address contains no keys and does not grant access: grant teammates access to the bucket in your storage's console.":U(e.gitUrl??"")==="github.com"?"A location address contains no password and does not grant access. Invite teammates on GitHub.":"A location address contains no password and does not grant access: grant teammates access on your Git server."}async function J(e,t){try{e.out("Share your context: the requirements, documents and test information you add to kane-cli. A location is where your team's shared copy lives.");let o=m(await e.choose("What do you want to do?",[u("share","Share my context with my team"),u("join","Join my team's context")]));if(o==="share"&&!y(f(t)))return e.out("There is no context here to share yet. Add your documents with kane-cli context ingest <files>, then run kane-cli context sync setup again."),2;let n,h=async()=>{for(;;){let r;for(;;){let a;if(o==="join")a=await p(e,"Paste the location your teammate shared",n?.address),n={kind:"join",address:a};else{let d=await W(e,n);a=d.location,n=d.journey}try{r=E(a,t);break}catch(d){e.out(d instanceof Error?d.message:"That location could not be read.")}}if(r.kind==="fake")throw new Error("This location is only available to tests.");if(r.kind==="git"){let a=await z(e,r);if(a==="storage"&&(n=void 0),a!=="ok")continue;if(/^https:\/\/github\.com\//i.test(r.gitUrl)){let d=await e.gh(["repo","view",r.gitUrl,"--json","nameWithOwner,visibility"]),g;try{let v=JSON.parse(d.text);["PUBLIC","PRIVATE","INTERNAL"].includes(v.visibility)&&(g=v.visibility)}catch{}e.out(g?`Repository visibility: ${g.toLowerCase()}.`:"Repository visibility could not be checked automatically. Check Public/Private on GitHub before publishing.")}}return r}},c=await h(),s=c.kind==="s3"?await k(e):void 0,i="origin",l;if(o==="join")for(;l=$(t,await p(e,"Download into a new folder","team-context")),!!y(l);)e.out("That folder already exists. Choose a new folder so your current context and files stay untouched.");else{let r=P(f(t)).locations;for(;r.some(a=>a.name===i)||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(i);)i=await p(e,"Choose a new name for this connection","team")}for(e.out(`Location: ${c.gitUrl??c.path??c.location}`),e.out(c.kind==="git"?"Connection checks add small permanent files, commits and a scratch reference to this repository. Your own context is uploaded only by a separate publish command.":"Connection checks add small permanent files to this location. Your own context is uploaded only by a separate publish command."),m(await e.choose(o==="join"?"Connect and download team context?":"Connect this location? Your context will not be uploaded.",[u("connect",o==="join"?"Connect and download":"Connect location")]));e.out(o==="join"?"Checking access and downloading verified team context\u2026":"Checking read access and safe publishing\u2026"),(o==="join"?await e.clone(c.location,l,s):await e.add(i,c.location,s))!==0;){if(o==="join"&&y(l)){e.out(`The destination ${l} now exists after the interrupted attempt. Keep it; choose a new folder for a fresh download.`);do l=$(t,await p(e,"New download folder"));while(y(l))}let a=[u("retry","Retry this connection"),...c.kind==="s3"?[u("keys","Enter different keys")]:[],x,...o==="share"?[C]:[]],d=m(await e.choose("The connection did not finish. Your choices are kept; fix the reported issue and retry.",a));d==="keys"&&(s=await k(e)),(d==="change"||d==="storage")&&(d==="storage"&&(n=void 0),c=await h(),s=c.kind==="s3"?await k(e):void 0)}if(o==="join")e.out(`Team context downloaded into ${l}. Your previous local files were not replaced.`),e.out("Next: open that folder and run kane-cli context sync status.");else{let r=e.access(i);e.out(`Connected to ${c.gitUrl??c.path??c.location}. ${r==="write"?"You can download and publish changes.":"You can download context, but cannot publish changes."}`),e.out("Your context has not been uploaded yet."),e.out(r==="write"?`When ready, publish with kane-cli context push ${i}. This shares your context records and their referenced source documents with everyone who can read the location.`:"Ask the location owner for write access before publishing, then check the connection again."),e.out(`Share this location with teammates: ${H(c)}`),e.out(K(c))}return 0}catch(o){return o instanceof w?(e.out("Setup left. Your context has not been published. Any completed connection checks remain in the location."),3):(e.out(o instanceof Error?o.message:"Setup could not finish."),2)}}async function q(e,t=!1){return new Promise(o=>{let n=D("gh",e,{stdio:t?"inherit":["ignore","pipe","pipe"],windowsHide:!0}),h="";n.stdout?.on("data",s=>{h.length<64e3&&(h+=String(s))}),n.stderr?.on("data",()=>{});let c=setTimeout(()=>n.kill("SIGKILL"),t?3e5:2e4);n.on("error",()=>{clearTimeout(c),o({code:1,text:"GitHub CLI is unavailable"})}),n.on("close",s=>{clearTimeout(c),o({code:s??1,text:h})})})}async function ie(e,t=L(),o=process.cwd()){if(e.mode&&e.mode!=="interactive"||!G())return Y(R(e,t),t,new A("TTY_REQUIRED","guided setup needs an interactive terminal; for automation use kane-cli context sync add <name> <location> or kane-cli context clone <location> <new-folder>","run kane-cli context sync setup in a terminal"),2);let{promptSetup:n}=await import("./sync-setup-ui-RC727VK6.js"),h=(s,i)=>i(s?{credentials:s}:{}),c=async s=>{let i=[],l=await s({...t,out:r=>i.push(r),err:r=>i.push(r)});if(l!==0)for(let r of i){if(r.startsWith("next: ")||r.startsWith("checking "))continue;let a=r.startsWith("error: ")?r.slice(7):r,d=/^([a-z][a-z0-9+.-]*:\/\/|[a-z0-9._-]+@[a-z0-9.-]+[:/]|[\/~.])/i.test(a);t.out(/^[a-z]/.test(a)&&!d?a.charAt(0).toUpperCase()+a.slice(1)+(/[.!?]$/.test(a)?"":"."):a)}return l};return J({out:t.out,choose:(s,i)=>n({title:s,choices:i}),input:(s,i,l)=>n({title:s,initial:i,secret:l}),open:async s=>{let{default:i}=await import("./open-MQLQKFAW.js");await i(s)},checkGit:()=>O(),gitRead:async s=>{try{let i=await T(["ls-remote",s],{timeout:2e4});return{ok:i.code===0,diagnostic:i.stderr}}catch(i){return{ok:!1,diagnostic:i instanceof Error?i.message:String(i)}}},gh:q,add:(s,i,l)=>h(l,r=>c(a=>_(s,i,r,a,o))),clone:(s,i,l)=>h(l,r=>c(a=>N(s,i,r,a,o))),access:s=>I(f(o)).entries[s]?.tier===1?"write":"read"},o)}export{J as runSetup,ie as setupCommand};
2
+ import{a as R,b as Y,g as _,o as N}from"./chunk-M36MOFJW.js";import"./chunk-OPL2MIQG.js";import"./chunk-TU6IMGWO.js";import"./chunk-TNBF5OMZ.js";import"./chunk-HOA4VWSD.js";import"./chunk-YYYQ5MVD.js";import"./chunk-KZG4E5RM.js";import"./chunk-BZAGVBCX.js";import"./chunk-52WM3XYO.js";import"./chunk-BB2W35TW.js";import"./chunk-427OQS2N.js";import"./chunk-AHXOKBVE.js";import"./chunk-ALCE5RLK.js";import"./chunk-Q2F5QB2W.js";import{a as T,b as O,c as U,d as j}from"./chunk-BMVE73M7.js";import{N as E,O as H,S as L,c as P,e as I}from"./chunk-UHSNUUX3.js";import"./chunk-YZVR7ESF.js";import{c as G,h as A}from"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-VOTIGXQ4.js";import"./chunk-SWTJMTBY.js";import"./chunk-IE3OO5GI.js";import{a as f}from"./chunk-CH273NAE.js";import"./chunk-CAOZKSQ3.js";import"./chunk-VZ7KXRXB.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-YCCUBQY4.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-HYTBEPC2.js";import"./chunk-DFS4RMVP.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";import{existsSync as y}from"fs";import{resolve as $}from"path";import{spawn as D}from"child_process";var w=class extends Error{},m=e=>{if(e===null)throw new w;return e},u=(e,t,o)=>({value:e,label:t,detail:o});async function p(e,t,o,n=!1){for(;;){let h=m(await e.input(t,o,n)).trim();if(h)return h;e.out("Enter a value, or press Esc to leave setup.")}}async function S(e,t){e.out(`Open in your browser: ${t}`);try{await e.open(t)}catch{e.out("The browser could not open automatically. Open that address yourself, then continue here.")}}async function b(e,t){let o=await e.gitRead(t);return o.ok||e.out(j(o.diagnostic,t)),o.ok}var x=u("change","Use a different address"),C=u("storage","Choose a different storage");async function z(e,t){for(;;)try{await e.checkGit();break}catch(n){e.out(n instanceof Error?n.message:"Git 2.31 or newer is required."),m(await e.choose("Install Git, then return here",[u("open","Open Git installation instructions"),u("retry","Check again")]))==="open"&&await S(e,"https://git-scm.com/downloads")}if(await b(e,t.gitUrl))return"ok";if(!/^https:\/\/github\.com\//i.test(t.gitUrl))for(e.out("Set up Git access for this repository with your server's SSH key or credential helper. kane-cli uses the same access as Git.");;){let n=m(await e.choose("Git cannot read this repository yet.",[u("retry","Check again"),x,C]));if(n==="change"||n==="storage")return n;if(await b(e,t.gitUrl))return"ok"}for(e.out("Sign in below if you have not, or ask the owner to grant your GitHub account access.");;){let n=m(await e.choose("Sign in to access this GitHub repository",[u("login","Sign in with your browser","Use or create your GitHub account."),u("retry","I've fixed my access \u2014 check again","Ask the owner to grant your account access, or check your existing Git login."),x,C]));if(n==="change"||n==="storage")return n;if(n==="login"){if((await e.gh(["--version"])).code){e.out("Browser sign-in uses GitHub CLI, a small GitHub tool. Install it once, then return to this step. GitHub CLI is optional if you already use SSH or another Git credential helper."),m(await e.choose("GitHub CLI is not installed",[u("open","Open installation instructions"),u("retry","Check again")]))==="open"&&await S(e,"https://cli.github.com/");continue}if((await e.gh(["auth","login","--hostname","github.com","--git-protocol","https","--web"],!0)).code){e.out("Sign-in did not finish. Your repository address is still saved in this setup.");continue}for(;(await e.gh(["auth","setup-git","--hostname","github.com"])).code&&(e.out("GitHub sign-in finished, but Git could not be told to use it."),m(await e.choose("Configure Git to use your GitHub sign-in",[u("retry","Try the configuration again"),u("skip","Skip; I use SSH or another credential helper")]))!=="skip"););}if(await b(e,t.gitUrl))return"ok";e.out("A browser login alone does not grant repository permission: ask the owner to grant your GitHub account access.")}}async function k(e){if(m(await e.choose("Access to the bucket",[u("existing","Use credentials already configured on this computer","Existing kane-cli credentials or KANE_SYNC_S3_ACCESS_KEY_ID and KANE_SYNC_S3_SECRET_ACCESS_KEY."),u("keys","Enter the access keys from my storage administrator","Saved in your local kane-cli configuration, never in the shared context.")]))!=="existing")return e.out("These are bucket access keys, not your cloud account password. Your administrator must grant access to the bucket and folder you selected."),{accessKeyId:await p(e,"Access key ID"),secretAccessKey:await p(e,"Secret access key (hidden)",void 0,!0)}}async function W(e,t){let o=t?.kind??m(await e.choose("Where should your team's shared context live?",[u("github","GitHub \u2014 Recommended","Guided setup for a repository: a storage space on GitHub."),u("s3","S3-compatible storage","Use your team's existing cloud bucket and access keys."),u("folder","Folder","A local folder stays on this computer. A mounted shared drive can serve your team.")]));if(o==="github"){t||(e.out("GitHub will hold the requirements, documents and test information you publish from kane-cli. Each teammate signs in with their own account."),m(await e.choose("Choose a GitHub repository",[u("existing","Use an existing repository"),u("create","Create a repository on GitHub","Use a dedicated repository. Choose Private to limit who can see your context.")]))==="create"&&(await S(e,"https://github.com/new"),e.out("On GitHub: choose the owner and repository name, choose Private, and create the repository. Return here and paste its HTTPS address. No code or Git knowledge is needed.")));let d=await p(e,"Repository address (for example https://github.com/my-team/team-context.git)",t?.address);return{location:d,journey:{kind:o,address:d}}}if(o==="folder"){t||e.out("Everyone needs access to the same mounted drive to share through a folder. Sending a local path does not share its contents. Dropbox, iCloud, OneDrive and Google Drive sync folders are not supported.");let d=await p(e,"Folder path",t?.address);return{location:d,journey:{kind:o,address:d}}}t||e.out("Ask your storage administrator for an existing bucket and access keys. kane-cli does not create buckets or cloud permissions.");let n=t?.s3,h=await p(e,"Bucket name",n?.bucket);for(;!/^[a-zA-Z0-9.-]+$/.test(h);)e.out("Use the bucket's name, not a URL."),h=await p(e,"Bucket name");let c=await p(e,"Region",n?.region??"us-east-1"),s=m(await e.input("Folder inside the bucket (optional)",n?.prefix??"")),i=[u("aws","Amazon S3"),u("compatible","Another S3-compatible service")];n&&i.sort((d,g)=>+(g.value===n.service)-+(d.value===n.service));let l=m(await e.choose("Which storage service?",i)),r=new URLSearchParams({region:c}),a=l==="compatible"?await p(e,"Service endpoint (https://host, with an optional port)",n?.service===l?n.endpoint:void 0):void 0;return a&&r.set("endpoint",a),{location:`s3://${h}/${s.split("/").map(encodeURIComponent).join("/")}?${r}`,journey:{kind:"s3",s3:{bucket:h,region:c,prefix:s,service:l,endpoint:a}}}}function K(e){return e.kind==="dir"?"A location address contains no password: everyone who can open this folder can read it; sending the path does not send its contents.":e.kind==="s3"?"A location address contains no keys and does not grant access: grant teammates access to the bucket in your storage's console.":U(e.gitUrl??"")==="github.com"?"A location address contains no password and does not grant access. Invite teammates on GitHub.":"A location address contains no password and does not grant access: grant teammates access on your Git server."}async function J(e,t){try{e.out("Share your context: the requirements, documents and test information you add to kane-cli. A location is where your team's shared copy lives.");let o=m(await e.choose("What do you want to do?",[u("share","Share my context with my team"),u("join","Join my team's context")]));if(o==="share"&&!y(f(t)))return e.out("There is no context here to share yet. Add your documents with kane-cli context ingest <files>, then run kane-cli context sync setup again."),2;let n,h=async()=>{for(;;){let r;for(;;){let a;if(o==="join")a=await p(e,"Paste the location your teammate shared",n?.address),n={kind:"join",address:a};else{let d=await W(e,n);a=d.location,n=d.journey}try{r=E(a,t);break}catch(d){e.out(d instanceof Error?d.message:"That location could not be read.")}}if(r.kind==="fake")throw new Error("This location is only available to tests.");if(r.kind==="git"){let a=await z(e,r);if(a==="storage"&&(n=void 0),a!=="ok")continue;if(/^https:\/\/github\.com\//i.test(r.gitUrl)){let d=await e.gh(["repo","view",r.gitUrl,"--json","nameWithOwner,visibility"]),g;try{let v=JSON.parse(d.text);["PUBLIC","PRIVATE","INTERNAL"].includes(v.visibility)&&(g=v.visibility)}catch{}e.out(g?`Repository visibility: ${g.toLowerCase()}.`:"Repository visibility could not be checked automatically. Check Public/Private on GitHub before publishing.")}}return r}},c=await h(),s=c.kind==="s3"?await k(e):void 0,i="origin",l;if(o==="join")for(;l=$(t,await p(e,"Download into a new folder","team-context")),!!y(l);)e.out("That folder already exists. Choose a new folder so your current context and files stay untouched.");else{let r=P(f(t)).locations;for(;r.some(a=>a.name===i)||!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(i);)i=await p(e,"Choose a new name for this connection","team")}for(e.out(`Location: ${c.gitUrl??c.path??c.location}`),e.out(c.kind==="git"?"Connection checks add small permanent files, commits and a scratch reference to this repository. Your own context is uploaded only by a separate publish command.":"Connection checks add small permanent files to this location. Your own context is uploaded only by a separate publish command."),m(await e.choose(o==="join"?"Connect and download team context?":"Connect this location? Your context will not be uploaded.",[u("connect",o==="join"?"Connect and download":"Connect location")]));e.out(o==="join"?"Checking access and downloading verified team context\u2026":"Checking read access and safe publishing\u2026"),(o==="join"?await e.clone(c.location,l,s):await e.add(i,c.location,s))!==0;){if(o==="join"&&y(l)){e.out(`The destination ${l} now exists after the interrupted attempt. Keep it; choose a new folder for a fresh download.`);do l=$(t,await p(e,"New download folder"));while(y(l))}let a=[u("retry","Retry this connection"),...c.kind==="s3"?[u("keys","Enter different keys")]:[],x,...o==="share"?[C]:[]],d=m(await e.choose("The connection did not finish. Your choices are kept; fix the reported issue and retry.",a));d==="keys"&&(s=await k(e)),(d==="change"||d==="storage")&&(d==="storage"&&(n=void 0),c=await h(),s=c.kind==="s3"?await k(e):void 0)}if(o==="join")e.out(`Team context downloaded into ${l}. Your previous local files were not replaced.`),e.out("Next: open that folder and run kane-cli context sync status.");else{let r=e.access(i);e.out(`Connected to ${c.gitUrl??c.path??c.location}. ${r==="write"?"You can download and publish changes.":"You can download context, but cannot publish changes."}`),e.out("Your context has not been uploaded yet."),e.out(r==="write"?`When ready, publish with kane-cli context push ${i}. This shares your context records and their referenced source documents with everyone who can read the location.`:"Ask the location owner for write access before publishing, then check the connection again."),e.out(`Share this location with teammates: ${H(c)}`),e.out(K(c))}return 0}catch(o){return o instanceof w?(e.out("Setup left. Your context has not been published. Any completed connection checks remain in the location."),3):(e.out(o instanceof Error?o.message:"Setup could not finish."),2)}}async function q(e,t=!1){return new Promise(o=>{let n=D("gh",e,{stdio:t?"inherit":["ignore","pipe","pipe"],windowsHide:!0}),h="";n.stdout?.on("data",s=>{h.length<64e3&&(h+=String(s))}),n.stderr?.on("data",()=>{});let c=setTimeout(()=>n.kill("SIGKILL"),t?3e5:2e4);n.on("error",()=>{clearTimeout(c),o({code:1,text:"GitHub CLI is unavailable"})}),n.on("close",s=>{clearTimeout(c),o({code:s??1,text:h})})})}async function ie(e,t=L(),o=process.cwd()){if(e.mode&&e.mode!=="interactive"||!G())return Y(R(e,t),t,new A("TTY_REQUIRED","guided setup needs an interactive terminal; for automation use kane-cli context sync add <name> <location> or kane-cli context clone <location> <new-folder>","run kane-cli context sync setup in a terminal"),2);let{promptSetup:n}=await import("./sync-setup-ui-RC727VK6.js"),h=(s,i)=>i(s?{credentials:s}:{}),c=async s=>{let i=[],l=await s({...t,out:r=>i.push(r),err:r=>i.push(r)});if(l!==0)for(let r of i){if(r.startsWith("next: ")||r.startsWith("checking "))continue;let a=r.startsWith("error: ")?r.slice(7):r,d=/^([a-z][a-z0-9+.-]*:\/\/|[a-z0-9._-]+@[a-z0-9.-]+[:/]|[\/~.])/i.test(a);t.out(/^[a-z]/.test(a)&&!d?a.charAt(0).toUpperCase()+a.slice(1)+(/[.!?]$/.test(a)?"":"."):a)}return l};return J({out:t.out,choose:(s,i)=>n({title:s,choices:i}),input:(s,i,l)=>n({title:s,initial:i,secret:l}),open:async s=>{let{default:i}=await import("./open-MQLQKFAW.js");await i(s)},checkGit:()=>O(),gitRead:async s=>{try{let i=await T(["ls-remote",s],{timeout:2e4});return{ok:i.code===0,diagnostic:i.stderr}}catch(i){return{ok:!1,diagnostic:i instanceof Error?i.message:String(i)}}},gh:q,add:(s,i,l)=>h(l,r=>c(a=>_(s,i,r,a,o))),clone:(s,i,l)=>h(l,r=>c(a=>N(s,i,r,a,o))),access:s=>I(f(o)).entries[s]?.tier===1?"write":"read"},o)}export{J as runSetup,ie as setupCommand};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{f as a}from"./chunk-3GELV4IN.js";import"./chunk-3MSXQU2C.js";import"./chunk-ZEVU2OT3.js";import"./chunk-EFTRH35G.js";import"./chunk-2WRBCTNM.js";import"./chunk-XUJXGE42.js";import"./chunk-6K4FDYMH.js";import"./chunk-S4JUCBCT.js";import"./chunk-UHSNUUX3.js";import"./chunk-YZVR7ESF.js";import"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-OFWJBOGT.js";import"./chunk-KALEPJAV.js";import"./chunk-7X4R6464.js";import"./chunk-WD52ZNQY.js";import"./chunk-UZIMYV5U.js";import"./chunk-HLCETZ73.js";import"./chunk-4TMQTSIO.js";import"./chunk-RQILLYSP.js";import"./chunk-BHSHGWBL.js";import"./chunk-S3DAAAE5.js";import"./chunk-WNB2IYHY.js";import"./chunk-O66WXOOC.js";import"./chunk-PDXZROJM.js";import"./chunk-XSUJJB7Z.js";import"./chunk-JVEZBJJ7.js";import"./chunk-ZKCCG3GK.js";import"./chunk-7EGIX6Y4.js";import"./chunk-GSDXZS4U.js";import"./chunk-7O54QURK.js";import"./chunk-5GUD3CIH.js";import"./chunk-VOTIGXQ4.js";import"./chunk-YMLC55J4.js";import"./chunk-EHN5HTUD.js";import"./chunk-SWTJMTBY.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-AYJ2YZP5.js";import"./chunk-YAAQER2L.js";import"./chunk-JSS22MFY.js";import"./chunk-27ERHOW3.js";import"./chunk-R7QMZBBH.js";import"./chunk-JQCOKL6U.js";import"./chunk-NBXYL2JT.js";import"./chunk-CAOZKSQ3.js";import"./chunk-VZ7KXRXB.js";import"./chunk-JCMHB4KH.js";import"./chunk-Z3YYMZHT.js";import"./chunk-JL3L6KOG.js";import"./chunk-5HTSKF5K.js";import"./chunk-5Y2G4NC7.js";import"./chunk-P7YZ3PU3.js";import"./chunk-TDPWFYTJ.js";import"./chunk-MLYNVJNH.js";import"./chunk-4PMZ5FCD.js";import"./chunk-2YEHV2CX.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import"./chunk-SHSXOYKT.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-NLEA6NPU.js";import"./chunk-6L5RV62W.js";import"./chunk-Z73ZYROU.js";import"./chunk-OWGFFJKK.js";import"./chunk-YCCUBQY4.js";import"./chunk-TVELOH5A.js";import"./chunk-NUJVYAI4.js";import"./chunk-BPMSNGXQ.js";import"./chunk-VE3SUJMA.js";import"./chunk-OGDAWNFY.js";import"./chunk-RFHMDQXZ.js";import"./chunk-QVLYK5JL.js";import"./chunk-A557OSRS.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-6GLFQHSW.js";import"./chunk-MSGW4JDG.js";import"./chunk-TZXXJWHA.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-IAHOLH5W.js";import"./chunk-TAOHYWEO.js";import"./chunk-WFBJNVMQ.js";import"./chunk-EJXBKCNF.js";import"./chunk-YKYKOV6U.js";import"./chunk-Z7S3IWUX.js";import"./chunk-4JOD47QI.js";import"./chunk-74FHTDEE.js";import"./chunk-TEHZUSUY.js";import"./chunk-EPE2ELDH.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-E47GFYXA.js";import"./chunk-EYOCNMUM.js";import"./chunk-NWNG5UWD.js";import"./chunk-YGMUNNKH.js";import"./chunk-XXE7W5AV.js";import"./chunk-HYTBEPC2.js";import{a as o}from"./chunk-DFS4RMVP.js";import{a as t}from"./chunk-HCBYKLMW.js";import{c as n}from"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var e=r(t(),1);async function p(i){let c=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,e.jsx)(o,{children:(0,e.jsx)(a,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:c})}),{exitOnCtrlC:!1});await m()}export{p as runGenerate};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m}from"./chunk-OFWJBOGT.js";import"./chunk-KALEPJAV.js";import"./chunk-7X4R6464.js";import"./chunk-WD52ZNQY.js";import"./chunk-PDXZROJM.js";import"./chunk-R7QMZBBH.js";import"./chunk-JQCOKL6U.js";import"./chunk-NBXYL2JT.js";import"./chunk-CAOZKSQ3.js";import"./chunk-VZ7KXRXB.js";import"./chunk-MLYNVJNH.js";import"./chunk-SHSXOYKT.js";import"./chunk-TVELOH5A.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-YKYKOV6U.js";import"./chunk-74FHTDEE.js";import"./chunk-TEHZUSUY.js";import"./chunk-EPE2ELDH.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-NWNG5UWD.js";import"./chunk-HYTBEPC2.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{i as ExportError,c as assertOrgMatchOrExit,j as exportTestmd,b as metaMatchesOrg,a as readMetaIfExists,d as resolveCurrentOrgId,l as resolveSyncAuth,h as runDeleteAction,k as runExportAction,e as runListAction,f as runListTui,g as runStatusAction,m as runSyncAction};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-R7QMZBBH.js";import"./chunk-JQCOKL6U.js";import"./chunk-NBXYL2JT.js";import"./chunk-CAOZKSQ3.js";import"./chunk-VZ7KXRXB.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-HYTBEPC2.js";import"./chunk-UR6MHSHU.js";export{a as buildBundleZip,c as runBundleSync,d as shouldSyncBundle,e as shouldSyncPersistedBundle,f as syncPersistedBundle,b as syncTestmdBundle};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a}from"./chunk-74FHTDEE.js";import"./chunk-TEHZUSUY.js";import"./chunk-EPE2ELDH.js";import"./chunk-RZ4F3BHX.js";import"./chunk-HYTBEPC2.js";import"./chunk-UR6MHSHU.js";export{a as refreshOAuthToken};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as t}from"./chunk-OH2NSBO6.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";async function l(n,o,r){let{ControllerClient:e}=await import("./controller-client-ZF5IXRUV.js");await new e(t(n).controllerBaseUrl,{username:o,accessKey:r}).getTmsCredentials()}export{l as validateBasicAuth};
2
+ import{a as t}from"./chunk-EPE2ELDH.js";import"./chunk-HYTBEPC2.js";import"./chunk-UR6MHSHU.js";async function l(n,o,r){let{ControllerClient:e}=await import("./controller-client-ZF5IXRUV.js");await new e(t(n).controllerBaseUrl,{username:o,accessKey:r}).getTmsCredentials()}export{l as validateBasicAuth};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c}from"./chunk-53MPG2J3.js";import"./chunk-L4M7753M.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{b as formatUnresolvedReceipt,a as suggestedVariablesFile,c as unresolvedVariablesEvent};
2
+ import{a,b,c}from"./chunk-XSUJJB7Z.js";import"./chunk-JVEZBJJ7.js";import"./chunk-HYTBEPC2.js";import"./chunk-UR6MHSHU.js";export{b as formatUnresolvedReceipt,a as suggestedVariablesFile,c as unresolvedVariablesEvent};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c}from"./chunk-2RMHDOP4.js";import"./chunk-I7TIGB7K.js";import"./chunk-FFFB5BXL.js";import"./chunk-BB2W35TW.js";import"./chunk-YKTYVJBN.js";import"./chunk-ALCE5RLK.js";import"./chunk-IE3OO5GI.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{b as requiresBecause,a as reviewProtocolCtx,c as submitReview};
2
+ import{a,b,c}from"./chunk-W77SZLFC.js";import"./chunk-I7TIGB7K.js";import"./chunk-DMCEGMGB.js";import"./chunk-BB2W35TW.js";import"./chunk-YKTYVJBN.js";import"./chunk-ALCE5RLK.js";import"./chunk-IE3OO5GI.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-HYTBEPC2.js";import"./chunk-UR6MHSHU.js";export{b as requiresBecause,a as reviewProtocolCtx,c as submitReview};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d}from"./chunk-EMSLJTYN.js";import"./chunk-RZ4F3BHX.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{d as checkForUpdate,b as compareVersions,c as getSeverity,a as getUpdateCommand};
2
+ import{a,b,c,d}from"./chunk-D6GBOFK5.js";import"./chunk-RZ4F3BHX.js";import"./chunk-HYTBEPC2.js";import"./chunk-UR6MHSHU.js";export{d as checkForUpdate,b as compareVersions,c as getSeverity,a as getUpdateCommand};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{Q as T}from"./chunk-6LGED4FC.js";import"./chunk-C74ABM24.js";import"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-22QIVSQR.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import{C as V}from"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import{F as I}from"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import{d as f,e as x}from"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-YCCUBQY4.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-B2ZGG7WM.js";import"./chunk-DFS4RMVP.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";import{writeFileSync as ce,mkdirSync as pe}from"fs";import{tmpdir as ue}from"os";import{dirname as fe,join as ge}from"path";var F={DERIVES:"derivation",automates:"linkage",exercises:"mesh",verifies:"mesh",depends_on:"crosslink",reuses:"crosslink",belongs_to:"containment",scoped_to:"containment",annotates:"annotation"},re=(t,r)=>t===f.SOURCE?String(r.source_id??""):t===f.AC?String(r.text??""):t===f.STYLENOTE?String(r.statement??r.text??""):t===f.GAP?String(r.text??r.question??""):String(r.title??"");function H(t){let r=[];for(let[o,p]of t.nodeLabel){let g=t.getNode(o)?.content??{};r.push({cid:o,label:p,slug:p===f.SOURCE?String(g.source_id??""):t.displayNameOf?.(o)??t.nameOf.get(o)??o.slice(0,19),trust:t.trust.get(o)??"derived",fresh:t.stale(o),title:re(p,g),content:g,superseded:t.superseded.has(o)})}let e=new Map;for(let[o]of t.nodeLabel)for(let p of t.edgesFrom(o)){let g=`${p.type}|${p.src}|${p.dst}`,v=typeof p.props?.anchor=="string"?p.props.anchor:void 0,w=e.get(g);w?(w.count++,v&&w.anchors.push(v)):e.set(g,{key:g,type:p.type,family:F[p.type]??"mesh",src:p.src,dst:p.dst,count:1,anchors:v?[v]:[],container:F[p.type]==="containment"})}let s=[...e.values()],i={},l={trusted:0,derived:0,archived:0},d={fresh:0,stale:0,orphaned:0,superseded:0},a=0;for(let o of r)o.superseded||(a++,i[o.label]=(i[o.label]??0)+1,o.label!==f.SOURCE&&l[o.trust]++,d[o.fresh]++);return{nodes:r,edges:s,summary:{nodes:a,edges:s.reduce((o,p)=>o+p.count,0),byLabel:i,trust:l,fresh:d,usecases:i[f.USECASE]??0,designed:0}}}var P=/^([a-z]+)-(\d+)$/,E=(t,r)=>{let e=P.exec(t),s=P.exec(r);return e&&s&&e[1]===s[1]?Number(e[2])-Number(s[2]):t<r?-1:t>r?1:0};function se(t,r,e){let s=new Set,i=d=>{let a=e.nodeLabel.get(d);if(a===f.USECASE)s.add(d);else if(a===f.SCENARIO)for(let o of e.edgesFrom(d))o.type===x.BELONGS_TO&&s.add(o.dst)},l=e.edgesFrom(t);if(r===f.SCENARIO)for(let d of l)d.type===x.BELONGS_TO&&s.add(d.dst);if(r===f.AC)for(let d of l)d.type===x.SCOPED_TO&&i(d.dst);if(r===f.TEST)for(let d of l)d.type===x.AUTOMATES&&i(d.dst);return s}function G(t,r){let e=new Map,s=t.nodes.filter(a=>a.label===f.USECASE).map(a=>a.cid),i=s.map(a=>({ucCid:a,slug:r.nameOf.get(a)??a.slice(0,19),designed:r.designOf.has(a),nodeCids:[a]})).sort((a,o)=>E(a.slug,o.slug)),l={ucCid:"__shared__",slug:"cross-cutting",designed:!1,nodeCids:[]},d=new Map(i.map(a=>[a.ucCid,a]));for(let a of s)e.set(a,a);for(let a of t.nodes){if(a.label===f.SOURCE||a.label===f.USECASE)continue;let o=se(a.cid,a.label,r);if(o.size===1){let p=[...o][0];e.set(a.cid,p),d.get(p).nodeCids.push(a.cid)}else e.set(a.cid,"__shared__"),l.nodeCids.push(a.cid)}return{laneOf:e,lanes:[...i,l]}}var N={source:0,usecase:1,scenario:2,ac:3,test:4,stylenote:5,gap:5},ie=6,z=260,R=64,B=28;function U(t,r,e){let{lanes:s}=r,i=new Map(t.nodes.map(n=>[n.cid,n])),l=new Map,d=[],a=[],o=n=>{let m=n.map(h=>l.get(h)).filter(h=>h!==void 0);return m.length?m.reduce((h,S)=>h+S,0)/m.length:Number.MAX_SAFE_INTEGER},p=s.filter(n=>n.ucCid!=="__shared__"||n.nodeCids.length>0),g=t.nodes.filter(n=>n.label===f.SOURCE).sort((n,m)=>E(n.slug,m.slug)),v=0;for(let n of p){let m=n.nodeCids.map(c=>i.get(c)).filter(Boolean),h=c=>m.filter(u=>u.label===c),S=h(f.USECASE).sort((c,u)=>E(c.slug,u.slug));S.forEach((c,u)=>l.set(c.cid,u));let D=h(f.SCENARIO).sort((c,u)=>E(c.slug,u.slug));D.forEach((c,u)=>l.set(c.cid,u));let M=h(f.AC).sort((c,u)=>{let _=o(e.edgesInto(c.cid).filter(b=>b.type===x.EXERCISES).map(b=>b.src)),O=o(e.edgesInto(u.cid).filter(b=>b.type===x.EXERCISES).map(b=>b.src));return _-O||E(c.slug,u.slug)});M.forEach((c,u)=>l.set(c.cid,u));let j=h(f.TEST).sort((c,u)=>{let _=o(e.edgesFrom(c.cid).filter(b=>b.type===x.VERIFIES).map(b=>b.dst)),O=o(e.edgesFrom(u.cid).filter(b=>b.type===x.VERIFIES).map(b=>b.dst));return _-O||E(c.slug,u.slug)});j.forEach((c,u)=>l.set(c.cid,u));let q=m.filter(c=>N[c.label]===void 0||N[c.label]>=5).sort((c,u)=>E(c.slug,u.slug));q.forEach((c,u)=>l.set(c.cid,u));let A=Math.max(1,S.length,D.length,M.length,j.length,q.length)*R+B;for(let c of m){let u=N[c.label]??4,_=l.get(c.cid)??0;d.push({...c,lane:n.ucCid,col:u,x:u*z,y:v+B/2+_*R})}a.push({...n,y0:v,y1:v+A}),v+=A}let w=Math.max(v,R);g.forEach((n,m)=>d.push({...n,lane:"__spine__",col:0,x:0,y:w/(g.length+1)*(m+1)}));let L=ie*z;return{nodes:d,lanes:a,width:L,height:w}}function ae(t){return t.design_of?"design":t.review.length>0?"review":t.nodes.some(r=>r.label==="source")?"ingest":t.nodes.length>0?"extract":"other"}function $(t){let r=new Map,e=new Map,s=[];for(let i of t){for(let n of i.nodes)r.has(n.cid)||r.set(n.cid,i.seq);let l=new Map(e);for(let n of i.nodes)n.content?.derived===!0&&!e.has(n.cid)&&e.set(n.cid,"derived");for(let n of i.review)n.resolution==="approved"||n.resolution==="edited"?e.set(n.id,"trusted"):n.resolution==="rejected"?e.set(n.id,"archived"):n.resolution==="reset"&&e.set(n.id,"derived");let d=n=>{let m=0;for(let[h,S]of e)S===n&&l.get(h)!==n&&m++;return m},a=0;for(let[n,m]of e){let h=l.get(n);m==="derived"&&(h==="trusted"||h==="archived")&&a++}let o={trusted:d("trusted"),archived:d("archived"),reset:a},p=ae(i),g=i.nodes.map(n=>n.cid),v=i.edges.map(n=>`${n.type}|${n.src}|${n.dst}`),w=i.review.map(n=>n.id),L=p==="review"?"review \xB7 +"+o.trusted+" trusted"+(o.archived?", +"+o.archived+" archived":""):p+" \xB7 +"+g.length+" nodes";s.push({seq:i.seq,ts:i.ts,kind:p,label:L,mintedNodeCids:g,mintedEdgeKeys:v,reviewedNodeCids:w,trustDelta:o})}return{commits:s,bornSeq:r}}function Y(t,r,e){let s=[];for(let i of t){i.nodes.some(l=>l.cid===r)&&s.push({seq:i.seq,ts:i.ts,kind:"minted",detail:"minted here"});for(let l of i.review)l.id===r&&s.push({seq:i.seq,ts:i.ts,kind:"review",detail:l.resolution+(l.reason?": "+l.reason:"")})}return e.length&&s.push({seq:0,ts:"",kind:"derived_from",detail:"source lines "+e.join(", ")}),s}var oe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function k(t){return String(t).replace(/[&<>"']/g,r=>oe[r])}var W=t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"),de=new RegExp("[\u2028\u2029]","g");function X(t){return t.replace(/[<>&]/g,W).replace(de,W)}var K=t=>t.replace("sha256:","").slice(0,12);function J(t){if(!t||typeof t!="object")return"";let r=String(t.operator??""),e=t.operand!=null?String(t.operand):"",s=t.unit!=null?" "+String(t.unit):"",i=t.baseline!=null?String(t.baseline):"",l=t.within&&typeof t.within=="object"?t.within:null,d;switch(r){case"exists":d="exists: "+e;break;case"forall":d="for all "+e;break;case"contains":d="contains "+e;break;case"gte":d=">= "+e+s;break;case"lte":d="<= "+e+s;break;case"equals":d="= "+e+s+(i?" (was "+i+")":"");break;case"changed-by":d="changed by "+e+s;break;default:d=(r+" "+e+s).trim()}if(l){let a=l.threshold!=null?String(l.threshold):"",o=l.unit!=null?String(l.unit):"";(a||o)&&(d+=" within "+a+o)}return d.trim()}var C=t=>t==null||t===""?"":`<span class="chip">${k(t)}</span>`,y=(t,r)=>r==null||r===""?"":`<div class="kv"><span class="k">${k(t)}</span><span class="v">${k(r)}</span></div>`,le=t=>Array.isArray(t)&&t.length?`<ul class="crit">${t.map(r=>`<li>${k(r)}</li>`).join("")}</ul>`:"";function Q(t,r){let e=r??{};switch(t){case"usecase":return[y("description",e.description),y("value",e.value),[C(e.risk?"risk: "+e.risk:""),...Array.isArray(e.actors)?e.actors.map(s=>C(s)):[]].join(""),le(e.criteria)].join("");case"scenario":return[y("intent",e.intent),[C(e.case_type)].join(""),e.parameters&&typeof e.parameters=="object"?Object.entries(e.parameters).map(([s,i])=>y(s,i)).join(""):"",y("techniques",e.technique_notes)].join("");case"ac":return[y("",e.text),[C(e.kind),C(e.risk?"risk: "+e.risk:"")].join(""),(()=>{let s=J(e.expected_answer);return s?`<div class="pred">${k(s)}</div>`:""})()].join("");case"test":{let s=J(e.check),i=e.test_md_blob!=null?`<pre class="md">${k(String(e.test_md_blob))}</pre>`:"";return[s?`<div class="pred">${k(s)}</div>`:"",y("definitionId",e.definitionId),i].join("")}case"source":return[y("source_id",e.source_id),y("blob",e.blob)].join("");case"stylenote":return[e.statement?`<div class="pred">${k(e.statement)}</div>`:"",[C(e.learned_from_kind?"learned from: "+e.learned_from_kind:"")].join(""),y("",e.text),Array.isArray(e.tags)?e.tags.map(s=>C(s)).join(""):""].join("");case"gap":return[y("",e.text??e.question),[C(e.kind),C(e.risk?"risk: "+e.risk:"")].join(""),y("why",e.risk_rationale),y("ref",e.ref)].join("");default:return""}}function Z(t,r,e,s){let i=H(t),l=G(i,t),d=U(i,l,t),{commits:a}=$(r);i.summary.designed=l.lanes.filter(n=>n.designed&&n.ucCid!=="__shared__").length;let o={},p={};for(let n of i.nodes){o[n.cid]=Q(n.label,n.content);let m=t.edgesInto(n.cid).filter(h=>h.type===x.DERIVES&&typeof h.props?.anchor=="string").map(h=>h.props.anchor);p[n.cid]=Y(r,n.cid,m)}let g=d.nodes.map(n=>({cid:n.cid,slug:n.slug,label:n.label,trust:n.trust,fresh:n.fresh,title:n.title,superseded:n.superseded,lane:n.lane,col:n.col,x:n.x,y:n.y})),v=d.lanes.map(n=>({ucCid:n.ucCid,slug:n.slug,designed:n.designed,y0:n.y0,y1:n.y1})),L=i.nodes.some(n=>n.label===f.SOURCE)?{}:void 0;return{meta:{fromSeq:r[0]?.seq??0,tipHash:e[e.length-1]??null,storePath:s,schema:"assurance/context@1",asOf:r[r.length-1]?.ts??null},summary:i.summary,lanes:v,nodes:g,edges:i.edges,commits:a,lineage:p,contentHtml:o,width:d.width,height:d.height,source:L}}var ee="__PAYLOAD__",te=`<!doctype html>
2
+ import{Q as T}from"./chunk-UHSNUUX3.js";import"./chunk-YZVR7ESF.js";import"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-SWTJMTBY.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-CAOZKSQ3.js";import"./chunk-VZ7KXRXB.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import{C as V}from"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import{F as I}from"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import{d as f,e as x}from"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-YCCUBQY4.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-HYTBEPC2.js";import"./chunk-DFS4RMVP.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";import{writeFileSync as ce,mkdirSync as pe}from"fs";import{tmpdir as ue}from"os";import{dirname as fe,join as ge}from"path";var F={DERIVES:"derivation",automates:"linkage",exercises:"mesh",verifies:"mesh",depends_on:"crosslink",reuses:"crosslink",belongs_to:"containment",scoped_to:"containment",annotates:"annotation"},re=(t,r)=>t===f.SOURCE?String(r.source_id??""):t===f.AC?String(r.text??""):t===f.STYLENOTE?String(r.statement??r.text??""):t===f.GAP?String(r.text??r.question??""):String(r.title??"");function H(t){let r=[];for(let[o,p]of t.nodeLabel){let g=t.getNode(o)?.content??{};r.push({cid:o,label:p,slug:p===f.SOURCE?String(g.source_id??""):t.displayNameOf?.(o)??t.nameOf.get(o)??o.slice(0,19),trust:t.trust.get(o)??"derived",fresh:t.stale(o),title:re(p,g),content:g,superseded:t.superseded.has(o)})}let e=new Map;for(let[o]of t.nodeLabel)for(let p of t.edgesFrom(o)){let g=`${p.type}|${p.src}|${p.dst}`,v=typeof p.props?.anchor=="string"?p.props.anchor:void 0,w=e.get(g);w?(w.count++,v&&w.anchors.push(v)):e.set(g,{key:g,type:p.type,family:F[p.type]??"mesh",src:p.src,dst:p.dst,count:1,anchors:v?[v]:[],container:F[p.type]==="containment"})}let s=[...e.values()],i={},l={trusted:0,derived:0,archived:0},d={fresh:0,stale:0,orphaned:0,superseded:0},a=0;for(let o of r)o.superseded||(a++,i[o.label]=(i[o.label]??0)+1,o.label!==f.SOURCE&&l[o.trust]++,d[o.fresh]++);return{nodes:r,edges:s,summary:{nodes:a,edges:s.reduce((o,p)=>o+p.count,0),byLabel:i,trust:l,fresh:d,usecases:i[f.USECASE]??0,designed:0}}}var P=/^([a-z]+)-(\d+)$/,E=(t,r)=>{let e=P.exec(t),s=P.exec(r);return e&&s&&e[1]===s[1]?Number(e[2])-Number(s[2]):t<r?-1:t>r?1:0};function se(t,r,e){let s=new Set,i=d=>{let a=e.nodeLabel.get(d);if(a===f.USECASE)s.add(d);else if(a===f.SCENARIO)for(let o of e.edgesFrom(d))o.type===x.BELONGS_TO&&s.add(o.dst)},l=e.edgesFrom(t);if(r===f.SCENARIO)for(let d of l)d.type===x.BELONGS_TO&&s.add(d.dst);if(r===f.AC)for(let d of l)d.type===x.SCOPED_TO&&i(d.dst);if(r===f.TEST)for(let d of l)d.type===x.AUTOMATES&&i(d.dst);return s}function G(t,r){let e=new Map,s=t.nodes.filter(a=>a.label===f.USECASE).map(a=>a.cid),i=s.map(a=>({ucCid:a,slug:r.nameOf.get(a)??a.slice(0,19),designed:r.designOf.has(a),nodeCids:[a]})).sort((a,o)=>E(a.slug,o.slug)),l={ucCid:"__shared__",slug:"cross-cutting",designed:!1,nodeCids:[]},d=new Map(i.map(a=>[a.ucCid,a]));for(let a of s)e.set(a,a);for(let a of t.nodes){if(a.label===f.SOURCE||a.label===f.USECASE)continue;let o=se(a.cid,a.label,r);if(o.size===1){let p=[...o][0];e.set(a.cid,p),d.get(p).nodeCids.push(a.cid)}else e.set(a.cid,"__shared__"),l.nodeCids.push(a.cid)}return{laneOf:e,lanes:[...i,l]}}var N={source:0,usecase:1,scenario:2,ac:3,test:4,stylenote:5,gap:5},ie=6,z=260,R=64,B=28;function U(t,r,e){let{lanes:s}=r,i=new Map(t.nodes.map(n=>[n.cid,n])),l=new Map,d=[],a=[],o=n=>{let m=n.map(h=>l.get(h)).filter(h=>h!==void 0);return m.length?m.reduce((h,S)=>h+S,0)/m.length:Number.MAX_SAFE_INTEGER},p=s.filter(n=>n.ucCid!=="__shared__"||n.nodeCids.length>0),g=t.nodes.filter(n=>n.label===f.SOURCE).sort((n,m)=>E(n.slug,m.slug)),v=0;for(let n of p){let m=n.nodeCids.map(c=>i.get(c)).filter(Boolean),h=c=>m.filter(u=>u.label===c),S=h(f.USECASE).sort((c,u)=>E(c.slug,u.slug));S.forEach((c,u)=>l.set(c.cid,u));let D=h(f.SCENARIO).sort((c,u)=>E(c.slug,u.slug));D.forEach((c,u)=>l.set(c.cid,u));let M=h(f.AC).sort((c,u)=>{let _=o(e.edgesInto(c.cid).filter(b=>b.type===x.EXERCISES).map(b=>b.src)),O=o(e.edgesInto(u.cid).filter(b=>b.type===x.EXERCISES).map(b=>b.src));return _-O||E(c.slug,u.slug)});M.forEach((c,u)=>l.set(c.cid,u));let j=h(f.TEST).sort((c,u)=>{let _=o(e.edgesFrom(c.cid).filter(b=>b.type===x.VERIFIES).map(b=>b.dst)),O=o(e.edgesFrom(u.cid).filter(b=>b.type===x.VERIFIES).map(b=>b.dst));return _-O||E(c.slug,u.slug)});j.forEach((c,u)=>l.set(c.cid,u));let q=m.filter(c=>N[c.label]===void 0||N[c.label]>=5).sort((c,u)=>E(c.slug,u.slug));q.forEach((c,u)=>l.set(c.cid,u));let A=Math.max(1,S.length,D.length,M.length,j.length,q.length)*R+B;for(let c of m){let u=N[c.label]??4,_=l.get(c.cid)??0;d.push({...c,lane:n.ucCid,col:u,x:u*z,y:v+B/2+_*R})}a.push({...n,y0:v,y1:v+A}),v+=A}let w=Math.max(v,R);g.forEach((n,m)=>d.push({...n,lane:"__spine__",col:0,x:0,y:w/(g.length+1)*(m+1)}));let L=ie*z;return{nodes:d,lanes:a,width:L,height:w}}function ae(t){return t.design_of?"design":t.review.length>0?"review":t.nodes.some(r=>r.label==="source")?"ingest":t.nodes.length>0?"extract":"other"}function $(t){let r=new Map,e=new Map,s=[];for(let i of t){for(let n of i.nodes)r.has(n.cid)||r.set(n.cid,i.seq);let l=new Map(e);for(let n of i.nodes)n.content?.derived===!0&&!e.has(n.cid)&&e.set(n.cid,"derived");for(let n of i.review)n.resolution==="approved"||n.resolution==="edited"?e.set(n.id,"trusted"):n.resolution==="rejected"?e.set(n.id,"archived"):n.resolution==="reset"&&e.set(n.id,"derived");let d=n=>{let m=0;for(let[h,S]of e)S===n&&l.get(h)!==n&&m++;return m},a=0;for(let[n,m]of e){let h=l.get(n);m==="derived"&&(h==="trusted"||h==="archived")&&a++}let o={trusted:d("trusted"),archived:d("archived"),reset:a},p=ae(i),g=i.nodes.map(n=>n.cid),v=i.edges.map(n=>`${n.type}|${n.src}|${n.dst}`),w=i.review.map(n=>n.id),L=p==="review"?"review \xB7 +"+o.trusted+" trusted"+(o.archived?", +"+o.archived+" archived":""):p+" \xB7 +"+g.length+" nodes";s.push({seq:i.seq,ts:i.ts,kind:p,label:L,mintedNodeCids:g,mintedEdgeKeys:v,reviewedNodeCids:w,trustDelta:o})}return{commits:s,bornSeq:r}}function Y(t,r,e){let s=[];for(let i of t){i.nodes.some(l=>l.cid===r)&&s.push({seq:i.seq,ts:i.ts,kind:"minted",detail:"minted here"});for(let l of i.review)l.id===r&&s.push({seq:i.seq,ts:i.ts,kind:"review",detail:l.resolution+(l.reason?": "+l.reason:"")})}return e.length&&s.push({seq:0,ts:"",kind:"derived_from",detail:"source lines "+e.join(", ")}),s}var oe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function k(t){return String(t).replace(/[&<>"']/g,r=>oe[r])}var W=t=>"\\u"+t.charCodeAt(0).toString(16).padStart(4,"0"),de=new RegExp("[\u2028\u2029]","g");function X(t){return t.replace(/[<>&]/g,W).replace(de,W)}var K=t=>t.replace("sha256:","").slice(0,12);function J(t){if(!t||typeof t!="object")return"";let r=String(t.operator??""),e=t.operand!=null?String(t.operand):"",s=t.unit!=null?" "+String(t.unit):"",i=t.baseline!=null?String(t.baseline):"",l=t.within&&typeof t.within=="object"?t.within:null,d;switch(r){case"exists":d="exists: "+e;break;case"forall":d="for all "+e;break;case"contains":d="contains "+e;break;case"gte":d=">= "+e+s;break;case"lte":d="<= "+e+s;break;case"equals":d="= "+e+s+(i?" (was "+i+")":"");break;case"changed-by":d="changed by "+e+s;break;default:d=(r+" "+e+s).trim()}if(l){let a=l.threshold!=null?String(l.threshold):"",o=l.unit!=null?String(l.unit):"";(a||o)&&(d+=" within "+a+o)}return d.trim()}var C=t=>t==null||t===""?"":`<span class="chip">${k(t)}</span>`,y=(t,r)=>r==null||r===""?"":`<div class="kv"><span class="k">${k(t)}</span><span class="v">${k(r)}</span></div>`,le=t=>Array.isArray(t)&&t.length?`<ul class="crit">${t.map(r=>`<li>${k(r)}</li>`).join("")}</ul>`:"";function Q(t,r){let e=r??{};switch(t){case"usecase":return[y("description",e.description),y("value",e.value),[C(e.risk?"risk: "+e.risk:""),...Array.isArray(e.actors)?e.actors.map(s=>C(s)):[]].join(""),le(e.criteria)].join("");case"scenario":return[y("intent",e.intent),[C(e.case_type)].join(""),e.parameters&&typeof e.parameters=="object"?Object.entries(e.parameters).map(([s,i])=>y(s,i)).join(""):"",y("techniques",e.technique_notes)].join("");case"ac":return[y("",e.text),[C(e.kind),C(e.risk?"risk: "+e.risk:"")].join(""),(()=>{let s=J(e.expected_answer);return s?`<div class="pred">${k(s)}</div>`:""})()].join("");case"test":{let s=J(e.check),i=e.test_md_blob!=null?`<pre class="md">${k(String(e.test_md_blob))}</pre>`:"";return[s?`<div class="pred">${k(s)}</div>`:"",y("definitionId",e.definitionId),i].join("")}case"source":return[y("source_id",e.source_id),y("blob",e.blob)].join("");case"stylenote":return[e.statement?`<div class="pred">${k(e.statement)}</div>`:"",[C(e.learned_from_kind?"learned from: "+e.learned_from_kind:"")].join(""),y("",e.text),Array.isArray(e.tags)?e.tags.map(s=>C(s)).join(""):""].join("");case"gap":return[y("",e.text??e.question),[C(e.kind),C(e.risk?"risk: "+e.risk:"")].join(""),y("why",e.risk_rationale),y("ref",e.ref)].join("");default:return""}}function Z(t,r,e,s){let i=H(t),l=G(i,t),d=U(i,l,t),{commits:a}=$(r);i.summary.designed=l.lanes.filter(n=>n.designed&&n.ucCid!=="__shared__").length;let o={},p={};for(let n of i.nodes){o[n.cid]=Q(n.label,n.content);let m=t.edgesInto(n.cid).filter(h=>h.type===x.DERIVES&&typeof h.props?.anchor=="string").map(h=>h.props.anchor);p[n.cid]=Y(r,n.cid,m)}let g=d.nodes.map(n=>({cid:n.cid,slug:n.slug,label:n.label,trust:n.trust,fresh:n.fresh,title:n.title,superseded:n.superseded,lane:n.lane,col:n.col,x:n.x,y:n.y})),v=d.lanes.map(n=>({ucCid:n.ucCid,slug:n.slug,designed:n.designed,y0:n.y0,y1:n.y1})),L=i.nodes.some(n=>n.label===f.SOURCE)?{}:void 0;return{meta:{fromSeq:r[0]?.seq??0,tipHash:e[e.length-1]??null,storePath:s,schema:"assurance/context@1",asOf:r[r.length-1]?.ts??null},summary:i.summary,lanes:v,nodes:g,edges:i.edges,commits:a,lineage:p,contentHtml:o,width:d.width,height:d.height,source:L}}var ee="__PAYLOAD__",te=`<!doctype html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="utf-8">
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as ve}from"./chunk-TU6IMGWO.js";import{c as he}from"./chunk-FFVNISYH.js";import{a as Z}from"./chunk-A2SQD2AY.js";import{k as ge}from"./chunk-75I46VTM.js";import{a as ie,c as ne,d as pe}from"./chunk-SQDQADWD.js";import"./chunk-O3XBIURC.js";import{a as re,b as ce,c as le,d as N,f as G,g as de,i as ue,k as me,l as fe}from"./chunk-3YX3RQXO.js";import{a as ee,b as te}from"./chunk-UJZZDPDY.js";import"./chunk-RKXHVP2Z.js";import{a as Y}from"./chunk-TCAHDVII.js";import"./chunk-YYYQ5MVD.js";import"./chunk-BZAGVBCX.js";import"./chunk-CRZUBDJ3.js";import"./chunk-JUJ4SAGH.js";import"./chunk-ALCE5RLK.js";import"./chunk-6LGED4FC.js";import{b as Q}from"./chunk-C74ABM24.js";import"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-YMLC55J4.js";import"./chunk-22QIVSQR.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-5Y2G4NC7.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import{C as _}from"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import{a as se}from"./chunk-YCCUBQY4.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import{y as h}from"./chunk-B2ZGG7WM.js";import"./chunk-DFS4RMVP.js";import{a as K}from"./chunk-HCBYKLMW.js";import{a as F,b as x,k as ae}from"./chunk-C44QQJR4.js";import{a as Ie}from"./chunk-6YGTRKDT.js";import{e as U}from"./chunk-UR6MHSHU.js";var R=U(Ie(),1);function ke(t){let v=t.by??{kind:"human",id:process.env.USER??"operator"},k=t.mode==="interactive"?"override":t.mode,A=k==="override"?{note:"override \xB7 auto-answers, won't ask"}:{},M=(r,n)=>ee(t.onChild,{verb:"design",subject:r,...A,fixCmd:`kane-cli design tests --use-case ${r}`},n,l=>({ok:l===0,exitCode:l})),P=(r,n,l)=>ee(t.onChild,{verb:"evolve",subject:r,...A,fixCmd:`kane-cli maintain evolve ${n}`},l,a=>({ok:a.outcome==="evolved",exitCode:a.code})),S={out:()=>{},err:()=>{},isTTY:!1,confirm:async()=>!0},u={applied:0,committed:0,retired:0,skipped:0,deferred:0,failed:0},w=new Map;for(let r of t.planRows)if(r.held_ref&&t.held){let n=t.held.rows.find(a=>a.temp_ref===r.held_ref);if(!n)continue;let l={kind:n.kind,ref:n.temp_ref,title:n.title,why:n.why,origin:"content-change",...r.impact?{impact:r.impact}:{}};w.set(l.ref,{card:l,source:"held",heldRef:n.temp_ref})}else if(r.kind==="MODIFY"){let n={kind:"MODIFY",ref:r.ref,title:r.ref,why:`${r.reason}: ${r.provenance}`,origin:r.origin??"structural-stale",...r.impact?{impact:r.impact}:{}};w.set(n.ref,{card:n,source:"row",row:r})}else if(r.kind==="ADD"){let n={kind:"ADD",ref:r.ref,title:r.ref,why:r.reason,origin:r.origin??"content-change"};w.set(n.ref,{card:n,source:"row",row:r})}for(let r of t.archive){if(r.kind!=="ARCHIVE")continue;let n={kind:"ARCHIVE",ref:r.ref,title:r.ref,why:r.why,provenance:r.why,...r.impact?{impact:r.impact}:{}};w.set(n.ref,{card:n,source:"archive",row:r})}for(let r of t.reviewFeeder?.()??[]){if(w.has(r.ref))continue;let n={kind:r.kind==="MODIFY_HELD"?"MODIFY":r.kind,ref:r.ref,title:r.title,why:r.why,...r.impact?{impact:r.impact}:{},...r.pair?{pair:r.pair}:{},...r.held?{held:!0}:{},...r.kind==="MODIFY_HELD"?{heldPayload:!0}:{}};w.set(n.ref,{card:n,source:"review",reviewCard:r})}let y=r=>(u.failed++,{outcome:"failed",detail:r});return{cards:()=>[...w.values()].map(r=>r.card),async submit(r,n){let l=w.get(r);if(!l)return y(`no card ${r}`);if(l.source==="review"){if(l.reviewCard.kind==="PAIR"&&n.v==="approve")return y(`${r} is a PAIR card \u2014 approve is not in its grammar (merge / keep both / defer); words ride a defer note`);let{submitReview:s}=await import("./verdicts-XFXDRND4.js"),b=n.v==="approve"?{v:"approve"}:n.v==="archive"?{v:"archive",because:n.because??""}:n.v==="skip"&&l.reviewCard.kind==="MODIFY_HELD"?{v:"keep_current"}:n.v==="defer"||n.v==="skip"?{v:"defer"}:n.v==="merge"?{v:"merge"}:{v:"keep_both"},g=await s({contextDir:t.contextDir,signals:o=>t.signals({ref:o.ref,verdict:o.verdict,...o.reason?{reason:o.reason}:{}})},l.reviewCard,b,v);return g.outcome==="failed"?(u.failed++,g):g.outcome==="deferred"?(u.deferred++,n.v==="defer"&&n.note?(t.signals({ref:r,verdict:"deferred-with-note",reason:n.note}),{...g,detail:`steering noted: "${n.note}" \u2014 decide ${l.reviewCard.kind==="PAIR"?"merge / keep both":"the verdict"} when it re-offers`}):g):g.outcome==="retired"?(u.retired++,g):g.outcome==="committed"?(u.committed++,g):(u.applied++,g)}if(n.v==="merge"||n.v==="keep_both")return y(`${r} is a ${l.card.kind} card \u2014 ${n.v} applies to review cards only`);if(n.v==="skip")return u.skipped++,t.signals({ref:r,verdict:"gap-dismissed"}),{outcome:"skipped"};if(n.v==="defer")return u.deferred++,n.note?(t.signals({ref:r,verdict:"deferred-with-note",reason:n.note}),{outcome:"deferred",detail:`steering noted: "${n.note}"`}):{outcome:"deferred"};if(n.v==="archive"){if(l.source!=="archive")return y(`${r} is not an ARCHIVE card`);let s=_(t.contextDir),b=s.resolve(l.row.ref);if(b&&s.superseded.has(s.tipOf(b.cid)))return u.skipped++,{outcome:"skipped",detail:"already retired \u2014 nothing to do"};let g=ve(t.contextDir,_(t.contextDir),{ref:l.row.ref,reason:`reconcile retire: ${l.row.why}`,by:v});return g.errors?y(g.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")):(u.retired++,t.signals({ref:r,verdict:"gap-resolved-archive",reason:l.row.why}),{outcome:"retired"})}if(l.source==="archive")return y(`${r} takes archive/skip/defer, not approve`);if(l.source==="held"){let s=ge(t.contextDir,t.held,l.heldRef,v,n.edits);if(!s.ok)return y(s.message);if(s.kind==="ADD"){let b=await M(s.ref,()=>t.runDesign(s.ref,{yes:!0,mode:k,...n.steering?{because:n.steering}:{}}));return b!==0?(u.failed++,{outcome:"failed",landed:!0,detail:`committed ${s.ref}, but its design run exited ${b} \u2014 finish with kane-cli design tests --use-case ${s.ref}`}):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-create",...n.steering?{reason:n.steering}:{}}),{outcome:"applied",detail:s.ref})}if(n.steering){let b=_(t.contextDir),g=ie(b,s.ref);if(!g.ok)return u.committed++,{outcome:"committed",detail:`committed ${s.ref}, but steering could not resolve it (${g.message}) \u2014 steer via kane-cli maintain evolve ${s.ref}`};let o=await P(g.target.display,s.ref,()=>ne(t.contextDir,g.target,{yes:!0,mode:k,because:n.steering},S,t.runDesign,"batch"));if(o.outcome==="no-design"){let c=await M(g.target.seamRef,()=>t.runDesign(g.target.seamRef,{yes:!0,mode:k,because:n.steering}));return c!==0?(u.failed++,{outcome:"failed",landed:!0,detail:`committed ${s.ref}, but its steered design run exited ${c} \u2014 finish with kane-cli design tests --use-case ${g.target.seamRef}`}):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-create",reason:n.steering}),{outcome:"applied",detail:s.ref})}return o.outcome==="failed"||o.outcome==="paused"?(u.failed++,{outcome:"failed",landed:!0,detail:`committed ${s.ref}, but the steering evolve ${o.outcome} (exit ${o.code}) \u2014 finish with kane-cli maintain evolve ${s.ref}`}):o.outcome==="declined"?(u.committed++,{outcome:"committed",detail:`committed ${s.ref} \u2014 the steering evolve was declined; re-run kane-cli maintain evolve ${s.ref}`}):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-evolve",reason:n.steering}),{outcome:"applied",detail:s.ref})}return u.committed++,t.signals({ref:r,verdict:"gap-resolved-evolve"}),{outcome:"committed",detail:s.ref}}let a=_(t.contextDir),d=ie(a,l.row.ref);if(!d.ok)return y(d.message);if(l.card.kind==="ADD"){let s=await M(d.target.seamRef,()=>t.runDesign(d.target.seamRef,{yes:!0,mode:k}));return s!==0?y(`design run exited ${s}`):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-create"}),{outcome:"applied"})}let D=await P(d.target.display,l.row.ref,()=>ne(t.contextDir,d.target,{yes:!0,mode:k,...n.steering?{because:n.steering}:{}},S,t.runDesign,"batch"));return D.outcome==="evolved"?(u.applied++,t.signals({ref:r,verdict:"gap-resolved-evolve",...n.steering?{reason:n.steering}:{}}),{outcome:"applied"}):D.outcome==="failed"||D.outcome==="paused"?y(`evolve ${D.outcome} (exit ${D.code})`):(u.skipped++,{outcome:"skipped",detail:D.outcome})},summary:()=>({...u})}}var j=U(K(),1);function q({mark:t,markColor:v,color:k,indent:A=2,reserve:M=0,children:P}){let{stdout:S}=ae(),u=(S?.columns??80)-M,w=A+t.length+1;return(0,j.jsxs)(F,{children:[(0,j.jsx)(F,{width:w,flexShrink:0,children:(0,j.jsx)(x,{color:v,children:`${" ".repeat(A)}${t}`})}),(0,j.jsx)(F,{width:Math.max(20,u-w),children:(0,j.jsx)(x,{color:k,children:P})})]})}var p=U(K(),1);function be(t){return t.landed?"committed":t.outcome}var We={applied:{mark:"\u2714",color:"green"},committed:{mark:"\u2714",color:"green"},retired:{mark:"\u2714",color:"green"},skipped:{mark:"\xB7",color:"dim"},deferred:{mark:"\u2013",color:"dim"},failed:{mark:"\u2717",color:"red"}};function Ae(t){return t.v==="archive"?"Retiring\u2026":t.v==="approve"&&t.steering?"Approving with your changes \u2014 committing, then re-designing\u2026":"Applying \u2014 committing\u2026"}function Pe({controller:t,cards:v,note:k,markOutcome:A,routeChat:M,listEvolveTargets:P,barSubject:S,meta:u,resumeCmd:w,activeChild:y,onFinish:r,onCtrlC:n,pauseRef:l}){let[a,d]=(0,R.useState)(v.length>0?{at:"card",idx:0,sel:0,editor:null}:{at:"done-panel",sel:0}),D=(0,R.useRef)(0),s=(0,R.useRef)(a);s.current=a;let b=(0,R.useRef)([]),[,g]=(0,R.useState)(0),o=a.at==="busy"||a.at==="evolving";(0,R.useEffect)(()=>{if(!o)return;let e=setInterval(()=>g(i=>i+1),120);return()=>clearInterval(e)},[o]);let c=()=>{let e=t.summary();return`${e.applied+e.committed} applied \xB7 ${e.retired} retired \xB7 ${e.skipped} skipped \xB7 ${e.deferred} deferred`+(e.failed>0?` \xB7 ${e.failed} failed`:"")},E=()=>({state:"complete",facts:[c()]}),C=()=>({state:"walk-paused",reason:"ctrl+c",facts:[c(),"every verdict so far is committed \u2014 re-run the same reconcile command to continue"],...w?{resume:w}:{}}),$=()=>r(D.current,E()),T=(0,R.useRef)(!1),W=()=>{r(3,C())},I=()=>{if(T.current)return;T.current=!0;let e=s.current;if(e.at==="busy"||e.at==="evolving"){k((0,p.jsx)(x,{color:h.dim,children:"finishing the current item, then pausing\u2026"}));return}if(e.at==="done-panel"||e.at==="picker"||e.at==="why"||e.at==="view"){$();return}W()};l&&(l.current=I);let V=a.at==="card"||a.at==="busy"?v[a.idx]:null,O=()=>[{key:"finish",label:"finish"},...P?[{key:"evolve",label:"evolve another use-case\u2026"}]:[],...b.current.length>0?[{key:"view",label:"view what changed"}]:[]],H=()=>{let e=P?.()??[];if(e.length===0){k((0,p.jsx)(x,{color:h.dim,children:"nothing is stale \u2014 no evolve targets right now"})),d({at:"done-panel",sel:0});return}d({at:"picker",items:e,sel:0})},we=e=>{let i=e+1;i<v.length?d({at:"card",idx:i,sel:0,editor:null}):d({at:"done-panel",sel:0})},X=(0,R.useRef)(!1),L=(e,i)=>{if(X.current)return;X.current=!0;let m=v[e];d({at:"busy",idx:e,label:Ae(i),startedAt:Date.now()}),t.submit(m.ref,i).catch(f=>({outcome:"failed",detail:f instanceof Error?f.message:String(f)})).then(f=>{let B=We[f.outcome]??{mark:"\xB7",color:"dim"},Te=f.outcome!=="failed"&&f.outcome!=="skipped"&&f.outcome!=="deferred"&&m.impact&&"stale_refs"in m.impact&&m.impact.stale_refs.length>0?` \xB7 ${m.impact.stale_refs.length} item(s) now stale`:"",oe=`${f.outcome} [${m.kind}] ${Y(m.title)}${f.detail?` \u2014 ${Y(f.detail)}`:""}${Te}`;if(b.current.push({mark:B.mark,color:B.color,line:oe}),k((0,p.jsx)(q,{mark:B.mark,markColor:B.color==="green"?h.green:B.color==="red"?h.red:h.dim,color:B.color==="dim"?h.dim:void 0,children:oe})),f.outcome==="failed"&&(D.current=D.current===0?1:D.current),A(m.ref,be(f)),X.current=!1,T.current){W();return}we(e)})},ye=(e,i)=>{d({at:"evolving",title:e.title,startedAt:Date.now()}),M(`${e.key} ${i}`).catch(m=>`\u2717 evolve failed: ${m instanceof Error?m.message:String(m)}`).then(m=>{let f=m.startsWith("\u2713");if(b.current.push({mark:f?"\u2714":"\u2717",color:f?"green":"red",line:m.replace(/^[✓✗]\s*/,"")}),k((0,p.jsx)(q,{mark:f?"\u2714":"\u2717",markColor:f?h.green:h.red,children:m.replace(/^[✓✗]\s*/,"")})),T.current){$();return}d({at:"done-panel",sel:0})})},xe=(0,R.useMemo)(()=>({isFocused:()=>{let e=s.current;return e.at==="card"&&e.editor===null||e.at==="done-panel"||e.at==="picker"||e.at==="view"},onMove:e=>{d(i=>{if(i.at==="card"){let m=v[i.idx],f=G(m)??N(m).length-1;return{...i,sel:Math.max(0,Math.min(f,i.sel+e))}}return i.at==="done-panel"?{...i,sel:Math.max(0,Math.min(O().length-1,i.sel+e))}:i.at==="picker"?{...i,sel:Math.max(0,Math.min(i.items.length-1,i.sel+e))}:i})},onSelect:()=>{let e=s.current;if(e.at==="card"){let i=v[e.idx],m=G(i);if(m!==null&&e.sel===m){d({...e,editor:"",editorIntent:"steer"});return}let f=N(i)[e.sel];if(f?.v==="archive"&&i.kind==="REVIEW"){d({...e,editor:"",editorIntent:"because"});return}f&&L(e.idx,{v:f.v});return}if(e.at==="done-panel"){let i=O()[e.sel];i?.key==="finish"?$():i?.key==="evolve"?H():i?.key==="view"&&d({at:"view"});return}if(e.at==="picker"){let i=e.items[e.sel];i&&d({at:"why",item:i,text:""});return}},onDigit:e=>{let i=s.current;if(i.at==="card"){let m=v[i.idx],f=N(m)[e-1];if(f?.v==="archive"&&m.kind==="REVIEW"){d({...i,editor:"",editorIntent:"because"});return}f&&L(i.idx,{v:f.v});return}i.at==="done-panel"&&e-1<O().length&&d({...i,sel:e-1}),i.at==="picker"&&e-1<i.items.length&&d({...i,sel:e-1})},onType:e=>{d(i=>i.at!=="card"||G(v[i.idx])===null?i:{...i,editor:(i.editor??"")+e,editorIntent:i.editorIntent??"steer"})},isMulti:()=>!1,onSpace:()=>{},onBack:()=>{let e=s.current;(e.at==="picker"||e.at==="view")&&d({at:"done-panel",sel:0})}}),[v]);(0,R.useEffect)(()=>{a.at==="done"&&$()},[a.at]);let Ce=e=>Math.floor((Date.now()-e)/1e3),z=y?.current??null,$e=a.at==="card"?{kind:"card",n:a.idx+1,m:v.length}:a.at==="busy"?z?{kind:"child-working",step:re(a.label)}:{kind:"working",step:re(a.label),elapsedS:Ce(a.startedAt)}:a.at==="evolving"?{kind:"child-working",step:`evolving ${a.title}`}:{kind:"idle"},Re=a.at==="card"||a.at==="busy"?v.length-a.idx:0,Ee=a.at==="done-panel"||a.at==="picker"||a.at==="why"||a.at==="view",De=[...a.at==="card"?a.editor!==null?["\u23CE submit","esc back"]:fe(v[a.idx]).keys:a.at==="done-panel"?me(O(),{escBack:!1}).keys:a.at==="picker"?["\u2191\u2193 select","\u23CE confirm","esc back"]:a.at==="why"?["\u23CE submit","esc back"]:a.at==="view"?["esc back"]:[],"ctrl+c exit"],J=u??{verb:"reconcile",sid:"",env:""},Se=`view \xB7 this run's changes \xB7 ${b.current.length}`;return(0,p.jsxs)(F,{flexDirection:"column",children:[(0,p.jsx)(le,{onToggleThinking:()=>{},onCtrlC:()=>{n(),I()},panel:xe}),a.at==="card"&&V?(0,p.jsx)(de,{card:V,position:{n:a.idx+1,of:v.length},sel:a.sel,focused:a.editor===null,editorIntent:a.editorIntent??"steer",freeText:a.editor!==null?{value:a.editor,onChange:e=>d(i=>i.at==="card"?{...i,editor:e}:i),onSubmit:e=>{let i=s.current;if(i.at!=="card")return;let m=e.trim();if(!m){d({...i,editor:null,editorIntent:void 0});return}let f=v[i.idx];i.editorIntent==="because"?L(i.idx,{v:"archive",because:m}):f.kind==="PAIR"?L(i.idx,{v:"defer",note:m}):L(i.idx,{v:"approve",steering:m})},onCancel:()=>d(e=>e.at==="card"?{...e,editor:null,editorIntent:void 0}:e)}:null}):null,a.at==="done-panel"?(0,p.jsx)(Q,{headline:(()=>{let e=t.summary();return`reconcile done \u2014 ${e.applied+e.committed} applied \xB7 ${e.retired} retired \xB7 ${e.skipped} skipped \xB7 ${e.deferred} deferred${e.failed>0?` \xB7 ${e.failed} failed`:""}`})(),rows:O(),sel:a.sel,focused:!0}):null,a.at==="picker"?(0,p.jsx)(Q,{ask:!0,headline:"evolve which use-case?",rows:a.items.map(e=>({key:e.key,label:e.title,detail:e.badge})),sel:a.sel,focused:!0}):null,a.at==="why"?(0,p.jsxs)(F,{flexDirection:"column",borderStyle:"round",borderColor:h.assuranceAccent,paddingX:1,children:[(0,p.jsxs)(F,{children:[(0,p.jsxs)(x,{children:[(0,p.jsx)(x,{color:h.assuranceAccent,children:"\u25B8"})," ",(0,p.jsx)(x,{color:h.dim,children:"\u270E "})]}),(0,p.jsx)(se,{value:a.text,onChange:e=>d(i=>i.at==="why"?{...i,text:e}:i),onSubmit:e=>{let i=s.current;i.at==="why"&&(e.trim()?ye(i.item,e.trim()):d({at:"picker",items:[i.item],sel:0}))},onCancel:()=>{s.current.at==="why"&&H()},placeholder:`what should change about ${a.item.title}?`})]}),(0,p.jsx)(x,{color:h.muted,children:" \u23CE submit \xB7 esc back"})]}):null,a.at==="view"?(0,p.jsxs)(F,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,p.jsx)(x,{bold:!0,color:h.assuranceAccent,children:Se}),(0,p.jsx)(x,{children:" "}),b.current.map((e,i)=>(0,p.jsx)(q,{mark:e.mark,markColor:e.color==="green"?h.green:e.color==="red"?h.red:h.dim,color:e.color==="dim"?h.dim:void 0,indent:0,reserve:0,children:e.line},`vc-${i}`))]}):null,(0,p.jsx)(ce,{status:$e,meta:{...J,...S??J.subject?{subject:S??J.subject}:{}},tallies:ue(t.summary(),Re),keys:De,child:a.at==="evolving"?{verb:"evolve"}:z?{verb:z.verb}:void 0})]})}async function at(t){let v={current:null},k=o=>{v.current?.append(o)},A=null,M=async(o,c)=>{let[{runDesign:E},{resolveAgentAuthEnv:C},{runAgent:$},{preflightTurn:T}]=await Promise.all([import("./run-DN4XARP2.js"),import("./spawner-LNMD4NJF.js"),import("./bridge-X5DEJL6F.js"),import("./turn-preflight-JGYT7LXP.js")]);A??=await C();let W=A;return E({useCase:o,force:!0,mode:c.mode??"override",...c.because?{because:c.because}:{},...c.changeDelta!==void 0?{changeDelta:c.changeDelta}:{},...c.priorDesign!==void 0?{priorDesign:c.priorDesign}:{}},{contextDir:t.dir,agent:$,preflightTurn:()=>T(W),ask:async()=>[],out:()=>{},progress:()=>{},isTTY:!1,auth:W})},P=t.runDesign??M,S={current:null},u="",w=o=>{if(o.kind==="start")S.current={verb:o.verb},u=o.subject,k((0,p.jsxs)(x,{color:h.assuranceAccent,children:[`\u25CF ${te(o.verb).ing} ${Y(o.subject)}`,o.note?(0,p.jsx)(x,{color:h.dim,children:` ${o.note}`}):null]}));else if(o.kind==="end"){let c=S.current?.verb??"design";S.current=null,k(o.ok?(0,p.jsx)(x,{color:h.green,children:`\u25CF ${te(c).ed} ${Y(u)} \u2014 ${o.durS}s`}):(0,p.jsx)(x,{color:h.red,children:`\u25CF ${c} failed \u2014 ${o.exitCode!=null?`exited ${o.exitCode}`:"error"}${o.fixCmd?` \xB7 ${o.fixCmd}`:""}`}))}},y=ke({contextDir:t.dir,held:t.held,archive:t.archive,planRows:t.rows,runDesign:P,mode:"interactive",signals:t.signals,onChild:w,reviewFeeder:()=>{try{return he({contextDir:t.dir},_(t.dir))}catch{return[]}}}),r=new Set(t.rows.filter(o=>o.applied!==void 0).map(o=>o.held_ref??o.ref)),n=y.cards().filter(o=>!r.has(o.ref)&&!(o.kind==="ARCHIVE"&&t.archiveState?.[o.ref]!==void 0)),l=o=>t.rows.findIndex(c=>(c.held_ref??c.ref)===o),a=(o,c)=>{try{if(n.find($=>$.ref===o)?.kind==="ARCHIVE"){c==="retired"?t.markA?.(o,"retired"):c==="skipped"&&t.markA?.(o,"skipped");return}let C=l(o);if(C<0)return;c==="applied"||c==="committed"?t.mark?.(C,"approved"):c==="skipped"&&t.mark?.(C,"skipped")}catch{}},d=async o=>{let[{openGraph:c},{resolveParentUc:E,evolveOneUc:C}]=await Promise.all([import("./readmodel-IBFRM6EO.js"),import("./evolve-cmd-27ZQN6YB.js")]),[$,...T]=o.split(/\s+/),W=c(t.dir),I=E(W,$);if(!I.ok)return`couldn't resolve '${$}' \u2014 start with a use-case id (uc-\u2026): ${I.message}`;if(T.length===0)return`say what to change: \`${$} <your words>\` \u2014 the words become the redesign's change delta`;let V=T.join(" "),O={out:()=>{},err:()=>{},isTTY:!1,confirm:async()=>!0},H=await C(t.dir,I.target,{yes:!0,mode:"override",because:V},O,P,"batch");return H.outcome==="evolved"?(t.signals({ref:I.target.display,verdict:"gap-resolved-evolve",reason:V}),`\u2713 redesigned ${I.target.display} \u2014 "${V}"`):`\u2717 evolve ${H.outcome} for ${I.target.display} (exit ${H.code})`},D=t.listEvolveTargets??(()=>{let o=_(t.dir);return pe(o).targets.map(c=>({key:c.display,title:c.display,badge:"stale"}))});if(t.script){let o=0;for(let c of n){let E=await t.script(c),C=await y.submit(c.ref,E);C.outcome==="failed"&&o===0&&(o=1),a(c.ref,be(C))}return o}let[{render:s},{ScrollbackProvider:b},{ScrollbackTap:g}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./scrollback-JLPJR25X.js"),import("./ScrollbackTap-QHJOFYMC.js")]);return new Promise(o=>{let c=!1,E=(V,O)=>{c||(c=!0,(async()=>{process.removeListener("SIGINT",W),await v.current?.flush();try{I.unmount()}catch{}O&&Z(O),o(V)})())},C=0,$={current:null},T=()=>{if(C+=1,C>=2){if(c)return;c=!0,process.removeListener("SIGINT",W);try{I.unmount()}catch{}Z({state:"interrupted",reason:"ctrl+c \xD72",facts:["forced quit \u2014 every committed verdict is safe in the store"]}),o(130)}},W=()=>{T(),$.current?.()};process.on("SIGINT",W);let I=s((0,p.jsxs)(b,{children:[(0,p.jsx)(g,{into:v}),(0,p.jsx)(Pe,{controller:y,cards:n,note:k,markOutcome:a,routeChat:d,listEvolveTargets:D,barSubject:t.barSubject,meta:t.meta,resumeCmd:t.resumeCmd,activeChild:S,onFinish:E,onCtrlC:T,pauseRef:$})]}),{exitOnCtrlC:!1})})}export{Pe as WalkSessionSurface,be as outcomeToMark,at as runWalkSession};
2
+ import{a as ve}from"./chunk-TU6IMGWO.js";import{c as he}from"./chunk-FFVNISYH.js";import{a as Z}from"./chunk-A2SQD2AY.js";import{k as ge}from"./chunk-ORQGQSWG.js";import{a as ie,c as ne,d as pe}from"./chunk-PGXJ275T.js";import"./chunk-O3XBIURC.js";import{a as re,b as ce,c as le,d as N,f as G,g as de,i as ue,k as me,l as fe}from"./chunk-7WDPU33M.js";import{a as ee,b as te}from"./chunk-UJZZDPDY.js";import"./chunk-RKXHVP2Z.js";import{a as Y}from"./chunk-TCAHDVII.js";import"./chunk-YYYQ5MVD.js";import"./chunk-BZAGVBCX.js";import"./chunk-CRZUBDJ3.js";import"./chunk-JUJ4SAGH.js";import"./chunk-ALCE5RLK.js";import"./chunk-UHSNUUX3.js";import{b as Q}from"./chunk-YZVR7ESF.js";import"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-YMLC55J4.js";import"./chunk-SWTJMTBY.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-CAOZKSQ3.js";import"./chunk-VZ7KXRXB.js";import"./chunk-5Y2G4NC7.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import{C as _}from"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import{a as se}from"./chunk-YCCUBQY4.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import{y as h}from"./chunk-HYTBEPC2.js";import"./chunk-DFS4RMVP.js";import{a as K}from"./chunk-HCBYKLMW.js";import{a as F,b as x,k as ae}from"./chunk-C44QQJR4.js";import{a as Ie}from"./chunk-6YGTRKDT.js";import{e as U}from"./chunk-UR6MHSHU.js";var R=U(Ie(),1);function ke(t){let v=t.by??{kind:"human",id:process.env.USER??"operator"},k=t.mode==="interactive"?"override":t.mode,A=k==="override"?{note:"override \xB7 auto-answers, won't ask"}:{},M=(r,n)=>ee(t.onChild,{verb:"design",subject:r,...A,fixCmd:`kane-cli design tests --use-case ${r}`},n,l=>({ok:l===0,exitCode:l})),P=(r,n,l)=>ee(t.onChild,{verb:"evolve",subject:r,...A,fixCmd:`kane-cli maintain evolve ${n}`},l,a=>({ok:a.outcome==="evolved",exitCode:a.code})),S={out:()=>{},err:()=>{},isTTY:!1,confirm:async()=>!0},u={applied:0,committed:0,retired:0,skipped:0,deferred:0,failed:0},w=new Map;for(let r of t.planRows)if(r.held_ref&&t.held){let n=t.held.rows.find(a=>a.temp_ref===r.held_ref);if(!n)continue;let l={kind:n.kind,ref:n.temp_ref,title:n.title,why:n.why,origin:"content-change",...r.impact?{impact:r.impact}:{}};w.set(l.ref,{card:l,source:"held",heldRef:n.temp_ref})}else if(r.kind==="MODIFY"){let n={kind:"MODIFY",ref:r.ref,title:r.ref,why:`${r.reason}: ${r.provenance}`,origin:r.origin??"structural-stale",...r.impact?{impact:r.impact}:{}};w.set(n.ref,{card:n,source:"row",row:r})}else if(r.kind==="ADD"){let n={kind:"ADD",ref:r.ref,title:r.ref,why:r.reason,origin:r.origin??"content-change"};w.set(n.ref,{card:n,source:"row",row:r})}for(let r of t.archive){if(r.kind!=="ARCHIVE")continue;let n={kind:"ARCHIVE",ref:r.ref,title:r.ref,why:r.why,provenance:r.why,...r.impact?{impact:r.impact}:{}};w.set(n.ref,{card:n,source:"archive",row:r})}for(let r of t.reviewFeeder?.()??[]){if(w.has(r.ref))continue;let n={kind:r.kind==="MODIFY_HELD"?"MODIFY":r.kind,ref:r.ref,title:r.title,why:r.why,...r.impact?{impact:r.impact}:{},...r.pair?{pair:r.pair}:{},...r.held?{held:!0}:{},...r.kind==="MODIFY_HELD"?{heldPayload:!0}:{}};w.set(n.ref,{card:n,source:"review",reviewCard:r})}let y=r=>(u.failed++,{outcome:"failed",detail:r});return{cards:()=>[...w.values()].map(r=>r.card),async submit(r,n){let l=w.get(r);if(!l)return y(`no card ${r}`);if(l.source==="review"){if(l.reviewCard.kind==="PAIR"&&n.v==="approve")return y(`${r} is a PAIR card \u2014 approve is not in its grammar (merge / keep both / defer); words ride a defer note`);let{submitReview:s}=await import("./verdicts-EMCYGQWM.js"),b=n.v==="approve"?{v:"approve"}:n.v==="archive"?{v:"archive",because:n.because??""}:n.v==="skip"&&l.reviewCard.kind==="MODIFY_HELD"?{v:"keep_current"}:n.v==="defer"||n.v==="skip"?{v:"defer"}:n.v==="merge"?{v:"merge"}:{v:"keep_both"},g=await s({contextDir:t.contextDir,signals:o=>t.signals({ref:o.ref,verdict:o.verdict,...o.reason?{reason:o.reason}:{}})},l.reviewCard,b,v);return g.outcome==="failed"?(u.failed++,g):g.outcome==="deferred"?(u.deferred++,n.v==="defer"&&n.note?(t.signals({ref:r,verdict:"deferred-with-note",reason:n.note}),{...g,detail:`steering noted: "${n.note}" \u2014 decide ${l.reviewCard.kind==="PAIR"?"merge / keep both":"the verdict"} when it re-offers`}):g):g.outcome==="retired"?(u.retired++,g):g.outcome==="committed"?(u.committed++,g):(u.applied++,g)}if(n.v==="merge"||n.v==="keep_both")return y(`${r} is a ${l.card.kind} card \u2014 ${n.v} applies to review cards only`);if(n.v==="skip")return u.skipped++,t.signals({ref:r,verdict:"gap-dismissed"}),{outcome:"skipped"};if(n.v==="defer")return u.deferred++,n.note?(t.signals({ref:r,verdict:"deferred-with-note",reason:n.note}),{outcome:"deferred",detail:`steering noted: "${n.note}"`}):{outcome:"deferred"};if(n.v==="archive"){if(l.source!=="archive")return y(`${r} is not an ARCHIVE card`);let s=_(t.contextDir),b=s.resolve(l.row.ref);if(b&&s.superseded.has(s.tipOf(b.cid)))return u.skipped++,{outcome:"skipped",detail:"already retired \u2014 nothing to do"};let g=ve(t.contextDir,_(t.contextDir),{ref:l.row.ref,reason:`reconcile retire: ${l.row.why}`,by:v});return g.errors?y(g.errors.map(o=>`${o.code}: ${o.detail}`).join("; ")):(u.retired++,t.signals({ref:r,verdict:"gap-resolved-archive",reason:l.row.why}),{outcome:"retired"})}if(l.source==="archive")return y(`${r} takes archive/skip/defer, not approve`);if(l.source==="held"){let s=ge(t.contextDir,t.held,l.heldRef,v,n.edits);if(!s.ok)return y(s.message);if(s.kind==="ADD"){let b=await M(s.ref,()=>t.runDesign(s.ref,{yes:!0,mode:k,...n.steering?{because:n.steering}:{}}));return b!==0?(u.failed++,{outcome:"failed",landed:!0,detail:`committed ${s.ref}, but its design run exited ${b} \u2014 finish with kane-cli design tests --use-case ${s.ref}`}):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-create",...n.steering?{reason:n.steering}:{}}),{outcome:"applied",detail:s.ref})}if(n.steering){let b=_(t.contextDir),g=ie(b,s.ref);if(!g.ok)return u.committed++,{outcome:"committed",detail:`committed ${s.ref}, but steering could not resolve it (${g.message}) \u2014 steer via kane-cli maintain evolve ${s.ref}`};let o=await P(g.target.display,s.ref,()=>ne(t.contextDir,g.target,{yes:!0,mode:k,because:n.steering},S,t.runDesign,"batch"));if(o.outcome==="no-design"){let c=await M(g.target.seamRef,()=>t.runDesign(g.target.seamRef,{yes:!0,mode:k,because:n.steering}));return c!==0?(u.failed++,{outcome:"failed",landed:!0,detail:`committed ${s.ref}, but its steered design run exited ${c} \u2014 finish with kane-cli design tests --use-case ${g.target.seamRef}`}):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-create",reason:n.steering}),{outcome:"applied",detail:s.ref})}return o.outcome==="failed"||o.outcome==="paused"?(u.failed++,{outcome:"failed",landed:!0,detail:`committed ${s.ref}, but the steering evolve ${o.outcome} (exit ${o.code}) \u2014 finish with kane-cli maintain evolve ${s.ref}`}):o.outcome==="declined"?(u.committed++,{outcome:"committed",detail:`committed ${s.ref} \u2014 the steering evolve was declined; re-run kane-cli maintain evolve ${s.ref}`}):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-evolve",reason:n.steering}),{outcome:"applied",detail:s.ref})}return u.committed++,t.signals({ref:r,verdict:"gap-resolved-evolve"}),{outcome:"committed",detail:s.ref}}let a=_(t.contextDir),d=ie(a,l.row.ref);if(!d.ok)return y(d.message);if(l.card.kind==="ADD"){let s=await M(d.target.seamRef,()=>t.runDesign(d.target.seamRef,{yes:!0,mode:k}));return s!==0?y(`design run exited ${s}`):(u.applied++,t.signals({ref:r,verdict:"gap-resolved-create"}),{outcome:"applied"})}let D=await P(d.target.display,l.row.ref,()=>ne(t.contextDir,d.target,{yes:!0,mode:k,...n.steering?{because:n.steering}:{}},S,t.runDesign,"batch"));return D.outcome==="evolved"?(u.applied++,t.signals({ref:r,verdict:"gap-resolved-evolve",...n.steering?{reason:n.steering}:{}}),{outcome:"applied"}):D.outcome==="failed"||D.outcome==="paused"?y(`evolve ${D.outcome} (exit ${D.code})`):(u.skipped++,{outcome:"skipped",detail:D.outcome})},summary:()=>({...u})}}var j=U(K(),1);function q({mark:t,markColor:v,color:k,indent:A=2,reserve:M=0,children:P}){let{stdout:S}=ae(),u=(S?.columns??80)-M,w=A+t.length+1;return(0,j.jsxs)(F,{children:[(0,j.jsx)(F,{width:w,flexShrink:0,children:(0,j.jsx)(x,{color:v,children:`${" ".repeat(A)}${t}`})}),(0,j.jsx)(F,{width:Math.max(20,u-w),children:(0,j.jsx)(x,{color:k,children:P})})]})}var p=U(K(),1);function be(t){return t.landed?"committed":t.outcome}var We={applied:{mark:"\u2714",color:"green"},committed:{mark:"\u2714",color:"green"},retired:{mark:"\u2714",color:"green"},skipped:{mark:"\xB7",color:"dim"},deferred:{mark:"\u2013",color:"dim"},failed:{mark:"\u2717",color:"red"}};function Ae(t){return t.v==="archive"?"Retiring\u2026":t.v==="approve"&&t.steering?"Approving with your changes \u2014 committing, then re-designing\u2026":"Applying \u2014 committing\u2026"}function Pe({controller:t,cards:v,note:k,markOutcome:A,routeChat:M,listEvolveTargets:P,barSubject:S,meta:u,resumeCmd:w,activeChild:y,onFinish:r,onCtrlC:n,pauseRef:l}){let[a,d]=(0,R.useState)(v.length>0?{at:"card",idx:0,sel:0,editor:null}:{at:"done-panel",sel:0}),D=(0,R.useRef)(0),s=(0,R.useRef)(a);s.current=a;let b=(0,R.useRef)([]),[,g]=(0,R.useState)(0),o=a.at==="busy"||a.at==="evolving";(0,R.useEffect)(()=>{if(!o)return;let e=setInterval(()=>g(i=>i+1),120);return()=>clearInterval(e)},[o]);let c=()=>{let e=t.summary();return`${e.applied+e.committed} applied \xB7 ${e.retired} retired \xB7 ${e.skipped} skipped \xB7 ${e.deferred} deferred`+(e.failed>0?` \xB7 ${e.failed} failed`:"")},E=()=>({state:"complete",facts:[c()]}),C=()=>({state:"walk-paused",reason:"ctrl+c",facts:[c(),"every verdict so far is committed \u2014 re-run the same reconcile command to continue"],...w?{resume:w}:{}}),$=()=>r(D.current,E()),T=(0,R.useRef)(!1),W=()=>{r(3,C())},I=()=>{if(T.current)return;T.current=!0;let e=s.current;if(e.at==="busy"||e.at==="evolving"){k((0,p.jsx)(x,{color:h.dim,children:"finishing the current item, then pausing\u2026"}));return}if(e.at==="done-panel"||e.at==="picker"||e.at==="why"||e.at==="view"){$();return}W()};l&&(l.current=I);let V=a.at==="card"||a.at==="busy"?v[a.idx]:null,O=()=>[{key:"finish",label:"finish"},...P?[{key:"evolve",label:"evolve another use-case\u2026"}]:[],...b.current.length>0?[{key:"view",label:"view what changed"}]:[]],H=()=>{let e=P?.()??[];if(e.length===0){k((0,p.jsx)(x,{color:h.dim,children:"nothing is stale \u2014 no evolve targets right now"})),d({at:"done-panel",sel:0});return}d({at:"picker",items:e,sel:0})},we=e=>{let i=e+1;i<v.length?d({at:"card",idx:i,sel:0,editor:null}):d({at:"done-panel",sel:0})},X=(0,R.useRef)(!1),L=(e,i)=>{if(X.current)return;X.current=!0;let m=v[e];d({at:"busy",idx:e,label:Ae(i),startedAt:Date.now()}),t.submit(m.ref,i).catch(f=>({outcome:"failed",detail:f instanceof Error?f.message:String(f)})).then(f=>{let B=We[f.outcome]??{mark:"\xB7",color:"dim"},Te=f.outcome!=="failed"&&f.outcome!=="skipped"&&f.outcome!=="deferred"&&m.impact&&"stale_refs"in m.impact&&m.impact.stale_refs.length>0?` \xB7 ${m.impact.stale_refs.length} item(s) now stale`:"",oe=`${f.outcome} [${m.kind}] ${Y(m.title)}${f.detail?` \u2014 ${Y(f.detail)}`:""}${Te}`;if(b.current.push({mark:B.mark,color:B.color,line:oe}),k((0,p.jsx)(q,{mark:B.mark,markColor:B.color==="green"?h.green:B.color==="red"?h.red:h.dim,color:B.color==="dim"?h.dim:void 0,children:oe})),f.outcome==="failed"&&(D.current=D.current===0?1:D.current),A(m.ref,be(f)),X.current=!1,T.current){W();return}we(e)})},ye=(e,i)=>{d({at:"evolving",title:e.title,startedAt:Date.now()}),M(`${e.key} ${i}`).catch(m=>`\u2717 evolve failed: ${m instanceof Error?m.message:String(m)}`).then(m=>{let f=m.startsWith("\u2713");if(b.current.push({mark:f?"\u2714":"\u2717",color:f?"green":"red",line:m.replace(/^[✓✗]\s*/,"")}),k((0,p.jsx)(q,{mark:f?"\u2714":"\u2717",markColor:f?h.green:h.red,children:m.replace(/^[✓✗]\s*/,"")})),T.current){$();return}d({at:"done-panel",sel:0})})},xe=(0,R.useMemo)(()=>({isFocused:()=>{let e=s.current;return e.at==="card"&&e.editor===null||e.at==="done-panel"||e.at==="picker"||e.at==="view"},onMove:e=>{d(i=>{if(i.at==="card"){let m=v[i.idx],f=G(m)??N(m).length-1;return{...i,sel:Math.max(0,Math.min(f,i.sel+e))}}return i.at==="done-panel"?{...i,sel:Math.max(0,Math.min(O().length-1,i.sel+e))}:i.at==="picker"?{...i,sel:Math.max(0,Math.min(i.items.length-1,i.sel+e))}:i})},onSelect:()=>{let e=s.current;if(e.at==="card"){let i=v[e.idx],m=G(i);if(m!==null&&e.sel===m){d({...e,editor:"",editorIntent:"steer"});return}let f=N(i)[e.sel];if(f?.v==="archive"&&i.kind==="REVIEW"){d({...e,editor:"",editorIntent:"because"});return}f&&L(e.idx,{v:f.v});return}if(e.at==="done-panel"){let i=O()[e.sel];i?.key==="finish"?$():i?.key==="evolve"?H():i?.key==="view"&&d({at:"view"});return}if(e.at==="picker"){let i=e.items[e.sel];i&&d({at:"why",item:i,text:""});return}},onDigit:e=>{let i=s.current;if(i.at==="card"){let m=v[i.idx],f=N(m)[e-1];if(f?.v==="archive"&&m.kind==="REVIEW"){d({...i,editor:"",editorIntent:"because"});return}f&&L(i.idx,{v:f.v});return}i.at==="done-panel"&&e-1<O().length&&d({...i,sel:e-1}),i.at==="picker"&&e-1<i.items.length&&d({...i,sel:e-1})},onType:e=>{d(i=>i.at!=="card"||G(v[i.idx])===null?i:{...i,editor:(i.editor??"")+e,editorIntent:i.editorIntent??"steer"})},isMulti:()=>!1,onSpace:()=>{},onBack:()=>{let e=s.current;(e.at==="picker"||e.at==="view")&&d({at:"done-panel",sel:0})}}),[v]);(0,R.useEffect)(()=>{a.at==="done"&&$()},[a.at]);let Ce=e=>Math.floor((Date.now()-e)/1e3),z=y?.current??null,$e=a.at==="card"?{kind:"card",n:a.idx+1,m:v.length}:a.at==="busy"?z?{kind:"child-working",step:re(a.label)}:{kind:"working",step:re(a.label),elapsedS:Ce(a.startedAt)}:a.at==="evolving"?{kind:"child-working",step:`evolving ${a.title}`}:{kind:"idle"},Re=a.at==="card"||a.at==="busy"?v.length-a.idx:0,Ee=a.at==="done-panel"||a.at==="picker"||a.at==="why"||a.at==="view",De=[...a.at==="card"?a.editor!==null?["\u23CE submit","esc back"]:fe(v[a.idx]).keys:a.at==="done-panel"?me(O(),{escBack:!1}).keys:a.at==="picker"?["\u2191\u2193 select","\u23CE confirm","esc back"]:a.at==="why"?["\u23CE submit","esc back"]:a.at==="view"?["esc back"]:[],"ctrl+c exit"],J=u??{verb:"reconcile",sid:"",env:""},Se=`view \xB7 this run's changes \xB7 ${b.current.length}`;return(0,p.jsxs)(F,{flexDirection:"column",children:[(0,p.jsx)(le,{onToggleThinking:()=>{},onCtrlC:()=>{n(),I()},panel:xe}),a.at==="card"&&V?(0,p.jsx)(de,{card:V,position:{n:a.idx+1,of:v.length},sel:a.sel,focused:a.editor===null,editorIntent:a.editorIntent??"steer",freeText:a.editor!==null?{value:a.editor,onChange:e=>d(i=>i.at==="card"?{...i,editor:e}:i),onSubmit:e=>{let i=s.current;if(i.at!=="card")return;let m=e.trim();if(!m){d({...i,editor:null,editorIntent:void 0});return}let f=v[i.idx];i.editorIntent==="because"?L(i.idx,{v:"archive",because:m}):f.kind==="PAIR"?L(i.idx,{v:"defer",note:m}):L(i.idx,{v:"approve",steering:m})},onCancel:()=>d(e=>e.at==="card"?{...e,editor:null,editorIntent:void 0}:e)}:null}):null,a.at==="done-panel"?(0,p.jsx)(Q,{headline:(()=>{let e=t.summary();return`reconcile done \u2014 ${e.applied+e.committed} applied \xB7 ${e.retired} retired \xB7 ${e.skipped} skipped \xB7 ${e.deferred} deferred${e.failed>0?` \xB7 ${e.failed} failed`:""}`})(),rows:O(),sel:a.sel,focused:!0}):null,a.at==="picker"?(0,p.jsx)(Q,{ask:!0,headline:"evolve which use-case?",rows:a.items.map(e=>({key:e.key,label:e.title,detail:e.badge})),sel:a.sel,focused:!0}):null,a.at==="why"?(0,p.jsxs)(F,{flexDirection:"column",borderStyle:"round",borderColor:h.assuranceAccent,paddingX:1,children:[(0,p.jsxs)(F,{children:[(0,p.jsxs)(x,{children:[(0,p.jsx)(x,{color:h.assuranceAccent,children:"\u25B8"})," ",(0,p.jsx)(x,{color:h.dim,children:"\u270E "})]}),(0,p.jsx)(se,{value:a.text,onChange:e=>d(i=>i.at==="why"?{...i,text:e}:i),onSubmit:e=>{let i=s.current;i.at==="why"&&(e.trim()?ye(i.item,e.trim()):d({at:"picker",items:[i.item],sel:0}))},onCancel:()=>{s.current.at==="why"&&H()},placeholder:`what should change about ${a.item.title}?`})]}),(0,p.jsx)(x,{color:h.muted,children:" \u23CE submit \xB7 esc back"})]}):null,a.at==="view"?(0,p.jsxs)(F,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,p.jsx)(x,{bold:!0,color:h.assuranceAccent,children:Se}),(0,p.jsx)(x,{children:" "}),b.current.map((e,i)=>(0,p.jsx)(q,{mark:e.mark,markColor:e.color==="green"?h.green:e.color==="red"?h.red:h.dim,color:e.color==="dim"?h.dim:void 0,indent:0,reserve:0,children:e.line},`vc-${i}`))]}):null,(0,p.jsx)(ce,{status:$e,meta:{...J,...S??J.subject?{subject:S??J.subject}:{}},tallies:ue(t.summary(),Re),keys:De,child:a.at==="evolving"?{verb:"evolve"}:z?{verb:z.verb}:void 0})]})}async function at(t){let v={current:null},k=o=>{v.current?.append(o)},A=null,M=async(o,c)=>{let[{runDesign:E},{resolveAgentAuthEnv:C},{runAgent:$},{preflightTurn:T}]=await Promise.all([import("./run-UDP5VPYS.js"),import("./spawner-7FUA3JXA.js"),import("./bridge-5UKX7YIO.js"),import("./turn-preflight-JGYT7LXP.js")]);A??=await C();let W=A;return E({useCase:o,force:!0,mode:c.mode??"override",...c.because?{because:c.because}:{},...c.changeDelta!==void 0?{changeDelta:c.changeDelta}:{},...c.priorDesign!==void 0?{priorDesign:c.priorDesign}:{}},{contextDir:t.dir,agent:$,preflightTurn:()=>T(W),ask:async()=>[],out:()=>{},progress:()=>{},isTTY:!1,auth:W})},P=t.runDesign??M,S={current:null},u="",w=o=>{if(o.kind==="start")S.current={verb:o.verb},u=o.subject,k((0,p.jsxs)(x,{color:h.assuranceAccent,children:[`\u25CF ${te(o.verb).ing} ${Y(o.subject)}`,o.note?(0,p.jsx)(x,{color:h.dim,children:` ${o.note}`}):null]}));else if(o.kind==="end"){let c=S.current?.verb??"design";S.current=null,k(o.ok?(0,p.jsx)(x,{color:h.green,children:`\u25CF ${te(c).ed} ${Y(u)} \u2014 ${o.durS}s`}):(0,p.jsx)(x,{color:h.red,children:`\u25CF ${c} failed \u2014 ${o.exitCode!=null?`exited ${o.exitCode}`:"error"}${o.fixCmd?` \xB7 ${o.fixCmd}`:""}`}))}},y=ke({contextDir:t.dir,held:t.held,archive:t.archive,planRows:t.rows,runDesign:P,mode:"interactive",signals:t.signals,onChild:w,reviewFeeder:()=>{try{return he({contextDir:t.dir},_(t.dir))}catch{return[]}}}),r=new Set(t.rows.filter(o=>o.applied!==void 0).map(o=>o.held_ref??o.ref)),n=y.cards().filter(o=>!r.has(o.ref)&&!(o.kind==="ARCHIVE"&&t.archiveState?.[o.ref]!==void 0)),l=o=>t.rows.findIndex(c=>(c.held_ref??c.ref)===o),a=(o,c)=>{try{if(n.find($=>$.ref===o)?.kind==="ARCHIVE"){c==="retired"?t.markA?.(o,"retired"):c==="skipped"&&t.markA?.(o,"skipped");return}let C=l(o);if(C<0)return;c==="applied"||c==="committed"?t.mark?.(C,"approved"):c==="skipped"&&t.mark?.(C,"skipped")}catch{}},d=async o=>{let[{openGraph:c},{resolveParentUc:E,evolveOneUc:C}]=await Promise.all([import("./readmodel-IBFRM6EO.js"),import("./evolve-cmd-QQQPPGL3.js")]),[$,...T]=o.split(/\s+/),W=c(t.dir),I=E(W,$);if(!I.ok)return`couldn't resolve '${$}' \u2014 start with a use-case id (uc-\u2026): ${I.message}`;if(T.length===0)return`say what to change: \`${$} <your words>\` \u2014 the words become the redesign's change delta`;let V=T.join(" "),O={out:()=>{},err:()=>{},isTTY:!1,confirm:async()=>!0},H=await C(t.dir,I.target,{yes:!0,mode:"override",because:V},O,P,"batch");return H.outcome==="evolved"?(t.signals({ref:I.target.display,verdict:"gap-resolved-evolve",reason:V}),`\u2713 redesigned ${I.target.display} \u2014 "${V}"`):`\u2717 evolve ${H.outcome} for ${I.target.display} (exit ${H.code})`},D=t.listEvolveTargets??(()=>{let o=_(t.dir);return pe(o).targets.map(c=>({key:c.display,title:c.display,badge:"stale"}))});if(t.script){let o=0;for(let c of n){let E=await t.script(c),C=await y.submit(c.ref,E);C.outcome==="failed"&&o===0&&(o=1),a(c.ref,be(C))}return o}let[{render:s},{ScrollbackProvider:b},{ScrollbackTap:g}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./scrollback-JLPJR25X.js"),import("./ScrollbackTap-QHJOFYMC.js")]);return new Promise(o=>{let c=!1,E=(V,O)=>{c||(c=!0,(async()=>{process.removeListener("SIGINT",W),await v.current?.flush();try{I.unmount()}catch{}O&&Z(O),o(V)})())},C=0,$={current:null},T=()=>{if(C+=1,C>=2){if(c)return;c=!0,process.removeListener("SIGINT",W);try{I.unmount()}catch{}Z({state:"interrupted",reason:"ctrl+c \xD72",facts:["forced quit \u2014 every committed verdict is safe in the store"]}),o(130)}},W=()=>{T(),$.current?.()};process.on("SIGINT",W);let I=s((0,p.jsxs)(b,{children:[(0,p.jsx)(g,{into:v}),(0,p.jsx)(Pe,{controller:y,cards:n,note:k,markOutcome:a,routeChat:d,listEvolveTargets:D,barSubject:t.barSubject,meta:t.meta,resumeCmd:t.resumeCmd,activeChild:S,onFinish:E,onCtrlC:T,pauseRef:$})]}),{exitOnCtrlC:!1})})}export{Pe as WalkSessionSurface,be as outcomeToMark,at as runWalkSession};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-73ULUGBM.js";import"./chunk-H6TNBKGR.js";import"./chunk-O2APH6TZ.js";import"./chunk-4PMZ5FCD.js";import"./chunk-KBM3XHAM.js";import"./chunk-2YEHV2CX.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{a as withTelemetry};
2
+ import{a}from"./chunk-3D5MKSG3.js";import"./chunk-H6TNBKGR.js";import"./chunk-KUS324VE.js";import"./chunk-4PMZ5FCD.js";import"./chunk-KBM3XHAM.js";import"./chunk-2YEHV2CX.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-HYTBEPC2.js";import"./chunk-UR6MHSHU.js";export{a as withTelemetry};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testmuai/kane-cli",
3
- "version": "0.8.14",
3
+ "version": "0.8.15",
4
4
  "description": "KaneAI Terminal UI — browser automation testing agent",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,16 +33,16 @@
33
33
  "ws": "^8.20.0"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@testmuai/kane-cli-assurance-darwin-arm64": "0.8.14",
37
- "@testmuai/kane-cli-assurance-darwin-x64": "0.8.14",
38
- "@testmuai/kane-cli-assurance-linux-arm64": "0.8.14",
39
- "@testmuai/kane-cli-assurance-linux-x64": "0.8.14",
40
- "@testmuai/kane-cli-assurance-win-x64": "0.8.14",
41
- "@testmuai/kane-cli-darwin-arm64": "0.8.14",
42
- "@testmuai/kane-cli-darwin-x64": "0.8.14",
43
- "@testmuai/kane-cli-linux-x64": "0.8.14",
44
- "@testmuai/kane-cli-linux-arm64": "0.8.14",
45
- "@testmuai/kane-cli-win-x64": "0.8.14",
36
+ "@testmuai/kane-cli-assurance-darwin-arm64": "0.8.15",
37
+ "@testmuai/kane-cli-assurance-darwin-x64": "0.8.15",
38
+ "@testmuai/kane-cli-assurance-linux-arm64": "0.8.15",
39
+ "@testmuai/kane-cli-assurance-linux-x64": "0.8.15",
40
+ "@testmuai/kane-cli-assurance-win-x64": "0.8.15",
41
+ "@testmuai/kane-cli-darwin-arm64": "0.8.15",
42
+ "@testmuai/kane-cli-darwin-x64": "0.8.15",
43
+ "@testmuai/kane-cli-linux-x64": "0.8.15",
44
+ "@testmuai/kane-cli-linux-arm64": "0.8.15",
45
+ "@testmuai/kane-cli-win-x64": "0.8.15",
46
46
  "@testmuai/kane-cli-node-darwin-arm64": "24.18.0",
47
47
  "@testmuai/kane-cli-node-darwin-x64": "24.18.0",
48
48
  "@testmuai/kane-cli-node-linux-x64": "24.18.0",
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-IQ7GPETF.js";import"./chunk-CGT4NFQN.js";import"./chunk-VNFCX2SH.js";import"./chunk-7O54QURK.js";import"./chunk-5GUD3CIH.js";import"./chunk-WILT62DP.js";import"./chunk-YMLC55J4.js";import"./chunk-EHN5HTUD.js";import"./chunk-22QIVSQR.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-P7YZ3PU3.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-3BHRGHIZ.js";import"./chunk-RFHMDQXZ.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-WBHSPN55.js";import"./chunk-MSGW4JDG.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-4JOD47QI.js";import"./chunk-OH2NSBO6.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-B2ZGG7WM.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as EvidenceViewOffer};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b}from"./chunk-YHR2YAN5.js";import"./chunk-YCCUBQY4.js";import"./chunk-RBHQXWR7.js";import"./chunk-BPMSNGXQ.js";import"./chunk-OO5GMBVI.js";import"./chunk-OH2NSBO6.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-B2ZGG7WM.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as FolderPicker,a as formatFolderLine};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-JH6E632O.js";import"./chunk-3SPOJWRA.js";import"./chunk-DA57DXCF.js";import"./chunk-M7DN6FO3.js";import"./chunk-VZ7KXRXB.js";import"./chunk-TDPWFYTJ.js";import"./chunk-O5AS2ZIX.js";import"./chunk-4BBDKWM3.js";import"./chunk-WOA7VCGA.js";import"./chunk-YHR2YAN5.js";import"./chunk-YCCUBQY4.js";import"./chunk-RBHQXWR7.js";import"./chunk-BPMSNGXQ.js";import"./chunk-VE3SUJMA.js";import"./chunk-TZXXJWHA.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-AC7BPO4X.js";import"./chunk-TAOHYWEO.js";import"./chunk-OO5GMBVI.js";import"./chunk-Z7S3IWUX.js";import"./chunk-BAKJPQGU.js";import"./chunk-OH2NSBO6.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-IQ7NGOAT.js";import"./chunk-B2ZGG7WM.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as SingleShotApp};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as a}from"./chunk-GESG672R.js";import"./chunk-GPIXV7AV.js";import"./chunk-KOL6ZWOQ.js";import"./chunk-X74PP5NJ.js";import"./chunk-5Y2G4NC7.js";import"./chunk-P7YZ3PU3.js";import"./chunk-TDPWFYTJ.js";import"./chunk-O5AS2ZIX.js";import"./chunk-RQLU4NDG.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-WBHSPN55.js";import"./chunk-MSGW4JDG.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-Z7S3IWUX.js";import"./chunk-4JOD47QI.js";import"./chunk-OH2NSBO6.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-7L25ZNNP.js";import"./chunk-ARG56PJG.js";import"./chunk-B2ZGG7WM.js";import"./chunk-DFS4RMVP.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as TestMdRunView};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-NDCRJXYF.js";import"./chunk-4K5XTIJ6.js";import"./chunk-J7NRD4Q7.js";import"./chunk-UD7KKHPW.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{a as runAgent};
@@ -1,11 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as d,e as g}from"./chunk-L4M7753M.js";import{existsSync as p}from"fs";import{isAbsolute as h,join as l,relative as v}from"path";function u(n){let t=p(l(n,".context"))?"assurance.json":"variables.json";return l(".testmuai","variables",t)}function f(n,t){if(!h(n))return n;let e=v(t,n);return e.startsWith("..")?n:e}function m(n,t){let e=n.used_by;if(e.length===0||e.every(r=>r.file===g))return"";if(t===void 0||!e.every(r=>r.file===t))return e.map(r=>`${r.file} step ${r.step}`).join(" \xB7 ");let a=[...new Set(e.map(r=>r.step))].sort((r,i)=>r-i);return a.length===1?`step ${a[0]}`:`steps ${a.join(", ")}`}function b(n,t){let e=new Map,a={header:"Not in any variables file",rows:[],declare:!0};for(let r of n){if(r.reason!=="value_missing"){a.rows.push(r);continue}let i=f(r.file??u(t),t),s=e.get(i);s||(s={header:i===d?"Waiting for a value passed with --variables":`Waiting for a value in ${i}`,rows:[],declare:!1},e.set(i,s)),s.rows.push(r)}return[...e.values(),...a.rows.length>0?[a]:[]]}function w(n,t){let e=u(t);if(p(l(t,e)))return["",` Add ${n.length===1?"it":"them"} to ${e}`];let a=n.map(s=>`${JSON.stringify(s.name)}:`),r=Math.max(...a.map(s=>s.length))+1,i=a.map((s,o)=>` ${s.padEnd(r)}{ "value": "" }${o<a.length-1?",":""}`);return["",` Create ${e}:`,""," {",...i," }"]}function E(n,t){let e=n.length,a=`\u2717 ${e} variable${e===1?" has":"s have"} no value \u2014 nothing was dispatched`,r=Math.max(...n.map(s=>s.name.length),8)+2,i=b(n,t.cwd).map(s=>{let o=[` ${s.header}`];for(let c of s.rows)o.push(` ${c.name.padEnd(r)}${m(c,t.entryFile)}`.trimEnd());return s.declare&&o.push(...w(s.rows,t.cwd)),o.join(`
3
- `)});return`${a}
4
-
5
- ${i.join(`
6
-
7
- `)}
8
-
9
- If {{name}} is literal page text, write \\{{name}} to keep it as-is.
10
- Fill the values and run again.
11
- `}function x(n,t){return{type:"error",code:"unresolved_variables",message:`${n.length} variable(s) have no value \u2014 nothing was dispatched`,suggested_file:u(t.cwd),variables:n.map(e=>({...e,...e.file?{file:f(e.file,t.cwd)}:{}}))}}export{u as a,E as b,x as c};
@@ -1,15 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as S,c as M}from"./chunk-LBNADEQN.js";import{dirname as W,basename as N,join as d}from"path";function G(t){let e=N(t);return e.endsWith("_test.md")?e.slice(0,-8):e.endsWith("_module.md")?e.slice(0,-10):e.endsWith(".md")?e.slice(0,-3):e}function f(t){return d(W(t),`output-${G(t)}`)}function rt(t){return d(f(t),"Result.md")}function _(t){return d(f(t),".internal")}function w(t){return d(_(t),"meta.json")}function ot(t){return d(_(t),"execution.json")}function st(t,e,n){return d(f(t),`${e}-${n}-code`)}function dt(t){return d(f(t),"generated-code")}function at(t){return f(t)+".staging"}function J(t){return d(_(t),"steps")}function ct(t,e,n){return d(J(t),`${e}-${n}`)}import{writeFileSync as L,mkdirSync as H,readFileSync as U}from"fs";import{dirname as k}from"path";function j(t){try{return JSON.parse(U(w(t),"utf8"))}catch{return null}}function ft(t){let e=w(t.sourcePath);try{H(k(e),{recursive:!0})}catch(r){return process.stderr.write(`
3
- \u26A0 Failed to create output directory.
4
- ${r.message}
5
- Path: ${k(e)}
6
-
7
- `),e}let n={commit_id:t.commitId};t.testId!==void 0&&(n.test_id=t.testId),t.testcaseId!==void 0&&(n.testcase_id=t.testcaseId),t.projectId!==void 0&&(n.project_id=t.projectId),t.folderId!==void 0&&(n.folder_id=t.folderId),t.orgId!==void 0&&(n.org_id=t.orgId),t.sessionName!==void 0&&(n.session_name=t.sessionName),t.plan!==void 0&&(n.plan=t.plan);try{L(e,JSON.stringify(n,null,2)+`
8
- `,"utf8")}catch(r){process.stderr.write(`
9
- \u26A0 Failed to write meta.json.
10
- ${r.message}
11
- Path: ${e}
12
-
13
- `)}return e}import{readFileSync as z,existsSync as q}from"fs";import{basename as C,dirname as B,isAbsolute as Q,resolve as F}from"path";import{createHash as O}from"crypto";function h(t){if(t==null)return null;if(Array.isArray(t))return t.map(h);if(typeof t=="object"){let e={};for(let n of Object.keys(t).sort()){let r=t[n];r!==void 0&&(e[n]=h(r))}return e}return t}function Y(t){if(t.body.kind!=="objective")throw new Error("stepMd5: only objective steps have an md5; @import rows do not");let e={...t.config??{},optional:t.optional??!1},n=JSON.stringify(h(e));return O("md5").update(t.body.text).update(`
14
- `).update(n).digest("hex")}function I(t){let e={};for(let[r,o]of Object.entries(t.bindings??{}))e[r]={value:o.value,...o.secret===!0?{secret:!0}:{},...o.syntax?{syntax:o.syntax}:{}};let n=JSON.stringify(h({bindings:e,optional:t.optional}));return O("md5").update(t.path).update(`
15
- `).update(n).digest("hex")}function bt(t){return Y({index:t.trace[t.trace.length-1].stepIndex,heading:t.trace[t.trace.length-1].heading,verifies:[],body:{kind:"objective",text:t.objective},config:t.parsedConfig,headingLine:1,optional:t.optional})}var T=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"],X=["app","no_reset","os_version","device_name"],Z=["mode","on_lock_conflict","tags","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","app","no_reset","os_version","device_name"],g=class extends Error{constructor(e){super(e),this.name="TestMdResolveError"}};function v(t){let e=C(t);return e.endsWith("_test.md")?"test":e.endsWith("_module.md")?"module":"helper"}function St(t){let e=F(t),n=E(e),r=tt(n.global),o=[],a=[],s=[{file:e,kind:v(e)}],c=[];return $(n,a,o,[],e,{},s,c,{}),o.forEach((u,b)=>u.flatIndex=b+1),{rootPath:e,rootTitle:n.title,rootGlobal:n.global,rootSteps:n.steps,chrome:r,steps:o,unitFiles:s,warnings:c}}function Mt(t){let e=[];for(let n of t.unitFiles){if(n.kind!=="test")continue;let r=j(n.file);r&&e.push({file:n.file,...r.project_id?{project_id:String(r.project_id)}:{},...r.org_id?{org_id:String(r.org_id)}:{}})}return e}function E(t){if(!q(t))throw new g(`@import path not found: ${t}`);let e=z(t,"utf8");return S(t,e)}function $(t,e,n,r,o,a,s,c,p){if(e.includes(t.path)){let i=[...e,t.path].map(l=>C(l)).join(" \u2192 ");throw new g(`cyclic reference: ${i}`)}e.push(t.path);let u=r.length===0,b=t.global.variables??{};for(let i of Object.keys(a))if(Object.hasOwn(b,i))throw new g(`callsite binding '${i}' collides with a declared variable in ${t.path} (frontmatter variables are pinned; parameters are its undeclared names)`);let x=t.global;if(!u){let i={...t.global};for(let l of Z)i[l]!==void 0&&(c.push(`${t.path}: '${l}' is root-governed on imported units \u2014 ignored`),delete i[l]);i.url!==void 0&&(p.pending=String(i.url),delete i.url),x=i}let P=new Map;for(let i of t.steps){let l=i.body.kind!=="objective";if(i.optional&&l&&!u)throw new g(`intermediate-ref 'optional' is not supported in v1: ${t.path}:${i.headingLine}`);if(i.body.kind==="objective"){let y={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1},K=et(x,i.config,a),R={flatIndex:0,objective:i.body.text,sourceFile:t.path,trace:[...r,y],config:K,parsedConfig:i.config,optional:i.optional??!1,verifies:i.verifies,owningFile:t.path,unitKind:v(t.path),...i.replayOnly?{replayOnly:i.replayOnly}:{},...i.controlFlow?{controlFlow:i.controlFlow}:{},...i.block?{block:{...i.block,id:nt(i,n.length+1,P)}}:{}};p.pending&&(R.unitEntryUrl=p.pending,p.pending=void 0),n.push(R);continue}let V={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1,rowMd5:I({path:i.body.path,bindings:i.body.bindings,optional:i.optional??!1})},A=B(t.path),m=Q(i.body.path)?i.body.path:F(A,i.body.path),D=E(m);s.some(y=>y.file===m)||s.push({file:m,kind:v(m)}),$(D,e,n,[...r,V],o,i.body.bindings??{},s,c,p)}u||(p.pending=void 0),e.pop()}function tt(t){let e={};for(let n of T){if(n==="target"){let r=M(t);r!==void 0&&(e.target=r);continue}t[n]!==void 0&&(e[n]=t[n])}return e}function et(t,e,n){let r={};for(let[s,c]of Object.entries(t))T.includes(s)||X.includes(s)||(r[s]=c);let o={...r,...e??{}},a={...n,...t.variables??{},...e?.variables??{}};return Object.keys(a).length>0?o.variables=a:delete o.variables,o}function nt(t,e,n){let r=t.block.id;if(t.controlFlow==="if"||t.controlFlow==="while")return n.set(r,e),e;let o=n.get(r);if(o===void 0)throw new g(`block member before its opener in ${t.heading}`);return o}export{G as a,f as b,rt as c,_ as d,w as e,ot as f,st as g,dt as h,at as i,J as j,ct as k,I as l,bt as m,j as n,ft as o,g as p,v as q,St as r,Mt as s};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as y}from"./chunk-B2ZGG7WM.js";import{existsSync as V,readdirSync as N,readFileSync as w}from"fs";import{join as g}from"path";var U="--variables",R=["smart","environment","secrets","totp"],O=/^[a-z][a-z0-9_]*$/;function D(e){return typeof e=="string"?e.trim().length>0:typeof e=="number"&&Number.isFinite(e)}function p(e,r,n){let t=JSON.parse(e);if(!(!t||typeof t!="object")){for(let[o,l]of Object.entries(t))if(l&&typeof l=="object"&&"value"in l){let c={has_value:D(l.value),source:r},i=/^(?:global|secrets\.user|environment)\.(.+)$/.exec(o);n.set(i?i[1]:o,c)}}}function h(e,r){if(!V(e))return;let n;try{n=N(e).filter(t=>t.endsWith(".json")).sort()}catch{return}for(let t of n){let o=g(e,t);try{p(w(o,"utf-8"),o,r)}catch{}}}function G(e){return{globalDir:g(y,"variables"),localDir:g(e,".testmuai","variables")}}function L(e){let r=new Map;if(h(e.globalDir,r),h(e.localDir,r),e.file&&V(e.file))try{p(w(e.file,"utf-8"),e.file,r)}catch{}if(e.inline)try{p(e.inline,U,r)}catch{}return r}function u(e){let r=e.trim();if(!r)return null;let n=r.split(/[.[]/).map(t=>t.trim()).filter(Boolean);return n.length===0||R.includes(n[0])?null:n[0]==="global"?n[1]??null:n[0]}function P(e){if(!e||!e.trim())return"variable name is empty";let r=e.split(".")[0];return r==="global"||R.includes(r)?`'${e}' starts with a runtime namespace (global/secrets/smart/environment/totp) \u2014 declare the bare name`:O.test(e)?null:`'${e}' is not lower_snake_case (letters, digits, underscores; starts with a letter)`}import{basename as T}from"path";var K="objective",F=/(\\?)\{\{\s*([^{}]+?)\s*\}\}/g;function m(e){let r=[];if(!e)return r;for(let n of e.matchAll(F)){if(n[1])continue;let t=u(n[2]??"");t&&!r.includes(t)&&r.push(t)}return r}var M=/\b(?:store|save|extract|remember|capture)\b/i,z=/\bas\s+(?:['"`]([A-Za-z_][A-Za-z0-9_]*)['"`]|([A-Za-z_][A-Za-z0-9_]*)(?=\s*(?:,|$)))/gi,C=new Set(["a","an","the"]);function S(e){let r=[];if(!e)return r;for(let n of e.split(/[.;\n]/))if(M.test(n))for(let t of n.matchAll(z)){let o=t[1]??t[2];!o||C.has(o.toLowerCase())||r.includes(o)||r.push(o)}return r}function E(e,r,n){let t=r.get(e);return t?t.has_value?null:{name:e,reason:"value_missing",file:t.source,used_by:[n]}:{name:e,reason:"not_declared",used_by:[n]}}function Q(e,r,n,t=[]){let o=new Set([...t,...S(e)]),l=[];for(let c of m(e)){if(o.has(c))continue;let i=E(c,r,n);i&&l.push(i)}return l}function X(e,r,n={}){let t=e.rootGlobal.variables??{},o=new Set(n.produced??[]),l=n.authorFrom??0,c=[];for(let i of e.steps){let I=i.flatIndex-1>=l,f=S(i.objective);if(!I){for(let s of f)o.add(s);continue}let k={file:T(i.sourceFile),step:i.flatIndex},j=i.config.variables??{},d=new Map;for(let[s,a]of Object.entries(t))d.set(u(s)??s,a.value);for(let[s,a]of Object.entries(j))d.set(u(s)??s,a.value);let b=new Set,v=(s,a)=>{if(o.has(s)||f.includes(s))return;let x=d.get(s);if(x===void 0){b.add(s);return}if(a.has(s)){b.add(s);return}a.add(s);for(let A of m(x))v(A,a);a.delete(s)};for(let s of m(i.objective))v(s,new Set);let _=[];for(let s of b){let a=E(s,r,k);a&&_.push(a)}c.push(_);for(let s of f)o.add(s)}return $(c)}function Y(e){let r=new Set,n=e&&typeof e=="object"?e:null;for(let t of n?.prior_runs??[])for(let o of Object.keys(t.variables??{}))r.add(o);return[...r]}function $(e){let r=new Map;for(let n of e)for(let t of n){let o=r.get(t.name);o?o.used_by.push(...t.used_by):r.set(t.name,{...t,used_by:[...t.used_by]})}return[...r.values()].sort((n,t)=>n.name<t.name?-1:1)}export{U as a,G as b,L as c,P as d,K as e,m as f,Q as g,X as h,Y as i,$ as j};
@@ -1,8 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as h}from"./chunk-VZ7KXRXB.js";import{c as _}from"./chunk-EYOCNMUM.js";import{dirname as F,isAbsolute as T,resolve as j}from"path";var k=["db","api","js","smartui","network_query","network_assertion"];var a=class extends Error{constructor(r,o,e){super(`[${o}${e!=null?`:${e}`:""}] ${r}`);this.file=o;this.line=e;this.name="TestMdParseError"}};var R=["if","elif","else","end-if","while","end-while"];var C={"end-if":"if","end-while":"while"};function v(n,t){let r=[],o=()=>r[r.length-1];for(let i of t){let s=i.controlFlow;if(s==="if"||s==="while"){r.push({kind:s,id:i.index,branch:0,elseSeen:!1}),i.block={id:i.index,branch:0,depth:r.length};continue}if(s==="elif"||s==="else"){let l=o();if(!l||l.kind!=="if")throw new a(`@${s} outside an open @if`,n,i.headingLine);if(l.elseSeen)throw new a(`@${s} after @else`,n,i.headingLine);l.branch+=1,l.elseSeen=s==="else",i.block={id:l.id,branch:l.branch,depth:r.length};continue}if(s==="end-if"||s==="end-while"){let l=o(),f=C[s];if(!l||l.kind!==f)throw new a(`@${s} without an open @${f}`,n,i.headingLine);i.block={id:l.id,branch:-1,depth:r.length},r.pop();continue}let c=o();c&&(i.block={id:c.id,branch:c.branch,depth:r.length})}let e=o();if(e){let i=t.find(s=>s.index===e.id);throw new a(`unclosed @${e.kind} block`,n,i?.headingLine)}}var P=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),$=new Set(["mode","max_steps","timeout","global_context","local_context","variables","session_context","code_export","code_language","url","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","app","no_reset","os_version","device_name","on_lock_conflict","tags","assurance"]),O=new Set(["optional"]),Y=new Set(["optional","variables"]),M=new Set(["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"]),N=new Set(["app","no_reset","os_version","device_name"]),B=new Set(["mode","on_lock_conflict","tags","assurance"]);function we(n,t){let r=t.split(`
3
- `),{global:o,bodyStartLine:e}=I(n,r),{title:i,steps:s}=oe(n,r,e);return{path:n,title:i,global:o,steps:s}}function I(n,t){if(t[0]?.trim()!=="---")return{global:{},bodyStartLine:0};let r=-1;for(let c=1;c<t.length;c++)if(t[c].trim()==="---"){r=c;break}if(r===-1)throw new a("frontmatter is missing closing '---'",n,1);let o=t.slice(1,r).join(`
4
- `),e;try{e=h(o)??{}}catch(c){throw new a(`invalid YAML in frontmatter: ${c.message}`,n,1)}if(E(n,e,"frontmatter",1),e.on_lock_conflict!==void 0){let c=e.on_lock_conflict;if(c!=="readonly"&&c!=="fail"&&c!=="wait")throw new a(`on_lock_conflict must be 'readonly' | 'fail' | 'wait', got: ${JSON.stringify(c)}`,n,1)}if(L(n,e,1),e.assurance!==void 0){let c=e.assurance;if(c===null||typeof c!="object"||Array.isArray(c))throw new a("assurance must be a mapping with sub-keys {id, base}",n,1);let l=c;for(let f of Object.keys(l))if(f!=="id"&&f!=="base")throw new a(`unknown assurance sub-key '${f}' \u2014 the engine block allows only {id, base}`,n,1);if(typeof l.id!="string"||l.id.length===0)throw new a("assurance.id must be a non-empty string (logical id)",n,1);if(l.base!==void 0&&!(typeof l.base=="string"&&/^sha256:[0-9a-f]+$/.test(l.base)))throw new a("assurance.base must be a 'sha256:<hex>' string",n,1)}if(e.tags!==void 0){let c=e.tags,l=Array.isArray(c)?c.map(f=>String(f)).join(","):String(c);e.tags=G(l,n,1)}if(e.target!==void 0&&(e.target=q(e.target,n,1)),e.app!==void 0&&(e.app=H(e.app,n,1)),e.no_reset!==void 0&&typeof e.no_reset!="boolean")throw new a(`no_reset must be boolean: got ${typeof e.no_reset}`,n,1);if(e.os_version!==void 0&&typeof e.os_version!="string")if(typeof e.os_version=="number")e.os_version=String(e.os_version);else throw new a(`os_version must be a string: got ${typeof e.os_version}`,n,1);let i=e.target,s=i==="emulator"||i==="simulator";if(s&&e.app===void 0)throw new a(`target: ${String(i)} needs an app \u2014 add \`app: <path-to-build | AppId>\``,n,1);if(!s&&e.app!==void 0)throw new a("app requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(!s&&e.no_reset!==void 0)throw new a("no_reset requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(!s&&e.os_version!==void 0)throw new a("os_version requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(e.device_name!==void 0&&typeof e.device_name!="string")throw new a(`device_name must be a string: got ${typeof e.device_name}`,n,1);if(!s&&e.device_name!==void 0)throw new a("device_name requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);return{global:e,bodyStartLine:r+1}}function G(n,t,r){let e=n.trim().replace(/^\[/,"").replace(/\]$/,"").split(",").map(i=>i.trim().toLowerCase());if(e.length===0||e.some(i=>i.length===0))throw new a("tags must be a non-empty list of non-empty strings",t,r);return[...new Set(e)]}var V=new Set(["chrome","cdp","ws","emulator","simulator"]),W="target must be one of 'chrome' | 'cdp' | 'ws' (web) or 'emulator' | 'simulator' (mobile, with a root `app:` key)";function q(n,t,r){if(typeof n=="string"&&V.has(n))return n;throw n!==null&&typeof n=="object"&&!Array.isArray(n)?new a(`the mapping form of target is no longer accepted \u2014 write flat keys:
5
- target: emulator | simulator
6
- app: <path-to-build | AppId>`,t,r):new a(`${W} \u2014 got: ${JSON.stringify(n)}`,t,r)}function H(n,t,r){if(typeof n!="string"||n.trim().length===0)throw new a("app must be a build (e.g. ./builds/app-debug.apk) or an app id from your cloud uploads",t,r);let o=n.trim();if(!/\.(apk|zip)$/i.test(o)&&!/^APP\d{6,}$/.test(o))throw new a(`app '${o}' is not a build \u2014 expected a path ending in .apk or .zip, or an app id from your cloud uploads.`,t,r);return z(o,t)}function z(n,t){return/^APP[0-9A-Za-z_-]+$/.test(n)||T(n)?n:j(F(t),n)}function be(n){let t=n.target;if(!(t!=="emulator"&&t!=="simulator"))return{platform:_(t)??"",app:n.app??"",...n.no_reset!==void 0?{no_reset:n.no_reset}:{},...n.os_version!==void 0?{os_version:n.os_version}:{},...n.device_name!==void 0?{device_name:n.device_name}:{}}}function ye(n){let t=n.target;return t==="chrome"||t==="cdp"||t==="ws"?t:void 0}var D=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/;function J(n,t,r){let o=D.exec(t);if(o)return{label:t.slice(0,o.index).trim(),verifies:o[1].split(",").map(i=>i.trim())};let e=t.lastIndexOf("@verifies");if(e>0&&/\s/.test(t[e-1])){let i=t.slice(e+9).split(/[\s,]+/).filter(s=>s.length>0);if(i.length===0||i.every(s=>s.startsWith("ac-")))throw new a("malformed @verifies directive \u2014 expected '@verifies ac-<id>[, ac-<id>\u2026]' at the end of the heading",n,r)}return{label:t,verifies:[]}}var S=k.join("|"),U=new RegExp(`^(.*\\S)\\s+@(${S})\\s*$`),Z=new RegExp(`^@(${S})\\s*$`);function Q(n,t,r,o){let e=Z.exec(t);if(e)throw new a(`replay-only marker @${e[1]} needs a step label before it (e.g. '## Step 3 @${e[1]}')`,n,r);let i=U.exec(t);if(!i)return null;let s=i[2];if(o)throw new a(`only one replay-only marker per step \u2014 found @${o} and @${s}`,n,r);return{label:i[1].trim(),replayOnly:s}}var x=R.join("|"),X=new RegExp(`^(.*\\S)\\s+@(${x})\\s*$`),ee=new RegExp(`^@(${x})\\s*$`);function ne(n,t,r,o){let e=ee.exec(t);if(e)throw new a(`control-flow marker @${e[1]} needs a step label before it (e.g. '## banner is visible @${e[1]}')`,n,r);let i=X.exec(t);if(!i)return null;let s=i[2];if(o)throw new a(`only one control-flow marker per step \u2014 found @${o} and @${s}`,n,r);return{label:i[1].trim(),controlFlow:s}}function te(n,t,r){let o=t,e,i,s=()=>{let l=Q(n,o,r,e);l&&({label:o,replayOnly:e}=l);let f=ne(n,o,r,i);f&&({label:o,controlFlow:i}=f)};s();let c=J(n,o,r);if(o=c.label,s(),e&&i)throw new a(`@${i} is a control-flow marker and @${e} a replay-only marker \u2014 a step carries one or the other`,n,r);return{label:o,verifies:c.verifies,...e?{replayOnly:e}:{},...i?{controlFlow:i}:{}}}function oe(n,t,r){let o,e=r;for(;e<t.length&&t[e].trim()==="";)e++;let i=e<t.length?/^#\s+(.+?)\s*$/.exec(t[e]):null;i&&(o=i[1],e++);let s=[];for(let l=e;l<t.length;l++)/^##\s/.test(t[l])&&s.push(l);let c=[];for(let l=0;l<s.length;l++){let f=s[l],g=s[l+1]??t.length,m=t[f].replace(/^##\s+/,"").trim(),{label:w,verifies:d,replayOnly:p,controlFlow:u}=te(n,m,f+1),b=t.slice(f+1,g),{config:A,body:y,optional:K}=re(n,f+1,b);if(p&&y.kind==="import_ref")throw new a(`@${p} is a replay-only marker for objective steps \u2014 it cannot mark an @import row`,n,f+1);if(u&&y.kind==="import_ref")throw new a(`@${u} is a control-flow marker for objective steps \u2014 it cannot mark an @import row`,n,f+1);c.push({index:l+1,heading:w,verifies:d,config:A,body:y,headingLine:f+1,optional:K,...p?{replayOnly:p}:{},...u?{controlFlow:u}:{}})}return v(n,c),{title:o,steps:c}}function re(n,t,r){let o=0;for(;o<r.length&&r[o].trim()==="";)o++;let e,i=t;if(o<r.length&&/^```yaml\s*$/.test(r[o])){let d=o;i=t+d,o++;let p=-1;for(;o<r.length;){if(/^```\s*$/.test(r[o])){p=o;break}o++}if(p===-1)throw new a("step-config fenced ```yaml block is not closed",n,i);let u=r.slice(d+1,p).join(`
7
- `);try{e=h(u)??{}}catch(b){throw new a(`invalid YAML in step config: ${b.message}`,n,i)}o=p+1}let s=ie(r.slice(o)),c=s.filter(d=>d.trim()!=="");if(c.length>0&&/^@session\s+/.test(c[0].trim()))throw new a("@session is no longer supported (iteration 3); use @import instead",n,t);let l=/^@import\s+(\S.*)$/,g=s.filter(d=>l.test(d.trim())).length>0;if(g&&c.length!==1)throw new a("step body must be exactly one of prose / @import",n,t);let m=!1,w;if(e){if(E(n,e,g?"step config (ref)":"step config (objective)",i),L(n,e,i),typeof e.optional=="boolean")m=e.optional;else if(e.optional!==void 0)throw new a(`step config 'optional' must be boolean: got ${typeof e.optional}`,n,i);let d={...e};delete d.optional,g&&delete d.variables,!g&&Object.keys(d).length>0&&(w=d)}if(g){let p=l.exec(c[0].trim())[1].trim(),u=e?.variables;return{body:{kind:"import_ref",path:p,...u&&Object.keys(u).length>0?{bindings:u}:{}},optional:m}}return{body:{kind:"objective",text:s.join(`
8
- `).trim()},config:w,optional:m}}function ie(n){let t=0,r=n.length;for(;t<r&&n[t].trim()==="";)t++;for(;r>t&&n[r-1].trim()==="";)r--;return n.slice(t,r)}function L(n,t,r){let o=t.variables;if(o==null)return;if(typeof o!="object"||Array.isArray(o))throw new a("variables must be an object map",n,r);let e={};for(let[i,s]of Object.entries(o))if(typeof s=="string")e[i]={value:s};else if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.value=="string")e[i]=s;else throw new a(`variable '${i}' must be a string or { value: ... } object`,n,r);t.variables=e}function E(n,t,r,o){for(let e of Object.keys(t)){if(P.has(e))throw new a(`auth/identity keys are CLI-only: ${e}`,n,o);if(r==="frontmatter"){if(O.has(e))throw new a(`step-only key in frontmatter: ${e}`,n,o);if(!$.has(e))throw new a(`unknown config key: ${e}`,n,o)}else if(r==="step config (objective)"){if(!$.has(e)&&!O.has(e))throw new a(`unknown config key: ${e}`,n,o);if(M.has(e))throw new a(`chrome config is global-only: ${e}`,n,o);if(N.has(e))throw new a(`'${e}' is global-only: the whole run drives one app`,n,o);if(B.has(e))throw new a(`'${e}' is run-level and cannot be set per-step`,n,o)}else if(!Y.has(e))throw new a(`step config on @import may only contain 'optional' / 'variables': got ${e}`,n,o)}}export{we as a,be as b,ye as c,D as d};
@@ -1,6 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as U}from"./chunk-EHN5HTUD.js";import{b as J,c as P,e as q,i as z,j as Q,k as X,l as Y,m as A}from"./chunk-KN65CUNT.js";import{a as G}from"./chunk-LBNADEQN.js";import{copyFileSync as le,cpSync as ue,existsSync as $,mkdirSync as pe,readFileSync as Oe,readdirSync as ce,rmSync as Te,writeFileSync as Ae}from"fs";import{dirname as _e,isAbsolute as Ee,join as y,relative as Le,resolve as Ke}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as ye}from"fs";import{dirname as Re,basename as Z}from"path";function te(e){let t=e.outPath??P(e.sourcePath);Se(Re(t),{recursive:!0});let s=[];s.push("---"),s.push(`test: ../${Z(e.sourcePath)}`),s.push(`status: ${e.overallStatus}`),s.push(`started: ${e.startedISO}`),s.push(`duration_s: ${e.durationS}`),s.push(`session_id: ${e.sessionId}`),s.push("---",""),s.push(`# ${e.title??Z(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let d=e.rootSteps[l],r=e.outcomes.find(p=>p.rootStepIndex===l+1);if(s.push(xe(d,r)),r?.stepMd5&&s.push(`md5: ${r.stepMd5}`),r?.status==="failed"&&r.reason&&s.push(`Reason: ${r.reason}`),r?.softFailures?.length)for(let p of r.softFailures){let o=p.reason?`: ${p.reason}`:"";s.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${o}`)}d.body.kind==="objective"&&r?.status!=="skipped"&&s.push(d.body.text),s.push("")}return ge(t,s.join(`
3
- `),"utf8"),t}function xe(e,t){if(!t)return`## ${e.heading} (no outcome)`;let s=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let d=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${s}${d})`}if(t.refKind&&t.status==="failed"){let d=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",r=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${d}, ${s}${r})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${s})`:`## ${e.heading} \u2717 failed${l} (${s})`}var Ie=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,ke=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,be=/^md5:\s+([a-f0-9]{32})\s*$/;function ee(e,t){for(let s=t;s<e.length&&!/^##\s/.test(e[s]);s++){if(e[s].trim()==="")continue;let l=be.exec(e[s]);return l?l[1]:null}return null}function M(e){let s=ye(e,"utf8").split(`
4
- `),l="passed";if(s[0]?.trim()==="---")for(let r=1;r<s.length&&s[r].trim()!=="---";r++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(s[r]);p&&(l=p[1])}let d=[];for(let r=0;r<s.length;r++){let p=Ie.exec(s[r]);if(!p)continue;let o=p[1],n=p[2],c=p[3]??"",m=n.startsWith("\u2713")?"passed":n.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=ke.exec(c),v=f?.[1]??"",x=f?.[2]??null;d.push({kind:"import",heading:o,status:m,md5:ee(s,r+1),importPath:v,helperResultRelPath:x})}else d.push({kind:"objective",heading:o,status:m,md5:ee(s,r+1)})}return{overallStatus:l,steps:d}}import{copyFileSync as se,existsSync as H,mkdirSync as ve,writeFileSync as ne,promises as Ue}from"fs";import{join as F,dirname as re,basename as we}from"path";async function ie(e){for(let t=0;t<e.totalRunDirs;t++){let s=e.runIndex+t,l=F(e.sessionDir,"runs",String(s)),d=F(e.stagingStepDir,"flows",String(t));ve(d,{recursive:!0});let r=F(d,"actions.ndjson");if(e.packTestDir){let n=F(e.packTestDir,"logs",`${s}-actions.ndjson`);if(H(n)){se(n,r);continue}let c=re(re(e.packTestDir)),m=we(e.packTestDir),R=H(c)?await U(c,`tests/${m}/logs/${s}-actions.ndjson`).catch(()=>null):null;ne(r,R??"");continue}let p=[F(l,"run-test","actions.ndjson"),F(l,"actions.ndjson")],o=!1;for(let n of p)if(H(n)){se(n,r),o=!0;break}o||ne(r,"")}}import{existsSync as _,readdirSync as Pe}from"fs";import{dirname as $e,join as j,basename as W}from"path";function et(e,t){let s=[];return e.steps.forEach((l,d)=>{let r=t[d];l.block||!l.replayOnly||!r||r.kind!=="author"||s.push({flatIndex:l.flatIndex,file:l.owningFile,heading:l.trace[l.trace.length-1].heading,kind:l.replayOnly,reason:r.reason})}),s}function tt(e){let t=[],s=new Set,l=new Map;function d(n){if(l.has(n))return l.get(n);let c=P(n),m=_(c)?M(c):null;return l.set(n,m),m}let r=new Map;function p(n){if(r.has(n))return r.get(n);let c=j(n,"Result.md"),m=_(c)?M(c):null;return r.set(n,m),m}function o(n){for(let c=1;c<n.trace.length;c++){let m=n.trace[c-1],R=d(m.file);if(!R)continue;let f=R.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(W(f.importPath)!==W(n.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let n of e.steps){let c=n.trace[n.trace.length-1].stepIndex,m=n.replayOnly;if(n.block){let h=d(n.owningFile)?.steps[c-1],D=n.controlFlow!==void 0,O=h?.kind==="objective"&&h.status==="skipped";if(D||O){t.push({kind:"replay",recordingDir:"",flowCount:0,unrecorded:!0,...m?{replayOnly:m}:{}});continue}}let R=s.has(n.owningFile);for(let h=0;h<n.trace.length-1&&!R;h++)s.has(n.trace[h].file)&&(R=!0);if(R&&!m){t.push({kind:"author",reason:d(n.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let f=o(n);if(f){for(let h=0;h<n.trace.length;h++)s.add(n.trace[h].file);if(!m){t.push(f);continue}}let v=d(n.owningFile),x;if(v===null&&n.trace.length>1){let h=V(n.trace);x=oe(n,p(h),c,h)}else x=oe(n,v,c);if(m&&x.kind==="replay"&&(x={...x,replayOnly:m}),t.push(x),x.kind==="author"){s.add(n.owningFile);for(let h=0;h<n.trace.length-1;h++)s.add(n.trace[h].file)}}return t}function oe(e,t,s,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let d=t.steps[s-1];if(!d)return{kind:"author",reason:"no-result-md"};if(d.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(d.status!=="passed")return{kind:"author",reason:"recorded-failed"};let r=A(e);if(r!==d.md5)return{kind:"author",reason:"md5-mismatch"};let p=l===null?X(e.owningFile,s,r.slice(0,8)):j(l,".internal","steps",`${s}-${r.slice(0,8)}`),o=De(p);return o===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:p,flowCount:o}}function De(e){let t=j(e,"flows");if(!_(t))return 0;let s;try{s=Pe(t,{withFileTypes:!0}).filter(d=>d.isDirectory()&&/^\d+$/.test(d.name)).map(d=>parseInt(d.name,10))}catch{return 0}if(s.length===0)return 0;let l=Math.max(...s);for(let d=0;d<=l;d++)if(!_(j(t,String(d),"actions.ndjson")))return 0;return l+1}function st(e){return e.some(t=>t.kind==="author")}function nt(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function V(e){let t=r=>{let p=W(r);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},s=t(e[0].file),l=t(e[e.length-1].file),d=e.slice(0,-1).map(r=>String(r.stepIndex));return j($e(e[e.length-1].file),`helper-output-${l}-${s}-${d.join("-")}`)}function rt(e){return Array.from({length:e.flowCount},(t,s)=>j(e.recordingDir,"flows",String(s),"actions.ndjson"))}import{existsSync as de,mkdirSync as Me,rmSync as Fe,cpSync as je}from"fs";function ae(e,t){de(e)&&(de(t)&&Fe(t,{recursive:!0,force:!0}),Me(t,{recursive:!0}),je(e,t,{recursive:!0}))}async function St(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let s=e.authoredFlatIdx??new Set,l=[],d=[],r=new Map,p=o=>{if(r.has(o))return r.get(o);let n=y(o,"Result.md"),c=$(n)?M(n):null;return r.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let n=o.file===e.resolvedTest.rootPath,c=G(o.file,Oe(o.file,"utf8")),m=P(o.file),R=$(m)?M(m):null,f=[],v=[],x=[],h=[];if(!n)for(let a of e.resolvedTest.steps){if(a.owningFile!==o.file||a.trace.length<2)continue;let i=V(a.trace);h.includes(i)||h.push(i)}let D=a=>{if(R!==null)return null;for(let i of h){let w=p(i)?.steps[a-1];if(w)return{row:w,dir:i}}return null},O=[],E=!1,B=!1,L=!1,K=!1;for(let a of c.steps){let i=a.index,u=R?.steps[i-1];if(a.body.kind==="objective"){let g=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===i&&t.has(S.flatIndex)),I=g.length>0?g[g.length-1]:null;if(I){E=!0,s.has(I.flatIndex)&&(B=!0);let S=A(I),k;n?k=e.outcomes.find(he=>he.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}:k={rootStepIndex:i,status:fe(I,e.outcomes)},k.status==="failed"&&(L=!0),k.stepMd5==null&&(k.stepMd5=S),f.push(k),v.push({stepIndex:i,md5:S,rec:t.get(I.flatIndex)}),(!u||u.kind!=="objective"||u.status!==k.status||k.status==="passed"&&u.md5!==S)&&(K=!0)}else if(u&&u.kind==="objective")f.push({rootStepIndex:i,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),x.push(i);else if(!n&&D(i)?.row.kind==="objective"){let S=D(i),k=S.row;f.push({rootStepIndex:i,status:k.status,...k.md5?{stepMd5:k.md5}:{}}),O.push({psIdx:i,dir:S.dir})}else n?f.push(e.outcomes.find(S=>S.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}):f.push({rootStepIndex:i,status:"skipped"});continue}let w=Ee(a.body.path)?a.body.path:Ke(_e(o.file),a.body.path),T=Y({path:a.body.path,bindings:a.body.bindings,optional:a.optional??!1}),N=Le(J(o.file),P(w)),C=e.resolvedTest.steps.filter(g=>g.trace.some((I,S)=>S<g.trace.length-1&&I.file===o.file&&I.stepIndex===i)&&t.has(g.flatIndex));if(C.length>0){E=!0;let g;if(n)g=e.outcomes.find(I=>I.rootStepIndex===i)??{rootStepIndex:i,status:"passed",refKind:"import",refLabel:a.body.path};else{let I=C.some(S=>fe(S,e.outcomes)==="failed");g={rootStepIndex:i,status:I?"failed":"passed",refKind:"import",refLabel:a.body.path,inlinedCount:C.length}}g.status==="failed"&&(L=!0),g.stepMd5==null&&(g.stepMd5=T),g.helperResultRelPath==null&&(g.helperResultRelPath=N),f.push(g),(!u||u.kind!=="import"||u.status!==g.status||u.md5!==T)&&(K=!0)}else if(u&&u.kind==="import")f.push({rootStepIndex:i,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!n&&D(i)?.row.kind==="import"){let g=D(i).row;f.push({rootStepIndex:i,status:g.status,refKind:"import",refLabel:a.body.path})}else n?f.push(e.outcomes.find(g=>g.rootStepIndex===i)??{rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path}):f.push({rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path})}if(!(n||E&&(B||L||R===null||K)))continue;l.push(o.file);let b=z(o.file);pe(y(b,".internal"),{recursive:!0});for(let a of v){let i=y(b,".internal","steps",`${a.stepIndex}-${a.md5.slice(0,8)}`);pe(i,{recursive:!0}),await ie({sessionDir:e.sessionDir,runIndex:a.rec.runIndex,totalRunDirs:a.rec.totalRunDirs,stagingStepDir:i,packTestDir:e.packTestDir})}if(x.length>0){let a=Q(o.file);if($(a))for(let i of ce(a)){let u=parseInt(i.split("-")[0]??"",10);!Number.isNaN(u)&&x.includes(u)&&ue(y(a,i),y(b,".internal","steps",i),{recursive:!0})}}for(let a of O){let i=y(a.dir,".internal","steps");if($(i))for(let u of ce(i))parseInt(u.split("-")[0]??"",10)===a.psIdx&&ue(y(i,u),y(b,".internal","steps",u),{recursive:!0})}let me=f.some(a=>a.status==="failed");if(te({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:n?e.overallStatus:me?"failed":"passed",startedISO:e.startedISO,durationS:n?e.durationS:0,sessionId:e.sessionId,outPath:y(b,"Result.md")}),n){let a={};e.commitId&&(a.commit_id=e.commitId),e.tmsIds.testId&&(a.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(a.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(a.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(a.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(a.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(a.session_name=e.tmsIds.sessionName),Ae(y(b,".internal","meta.json"),JSON.stringify(a,null,2)+`
5
- `,"utf8");let i=y(e.sessionDir,"execution.json");if($(i))try{le(i,y(b,".internal","execution.json"))}catch{}if(e.codeExportDir){let u=e.codeExportLanguage??"python",w=e.codeExportFramework??"playwright",T=y(b,`${w}-${u}-code`);try{ae(e.codeExportDir,T)}catch(N){process.stderr.write(`warn: codegen copy failed: ${N.message}
6
- `)}}}else if(o.kind==="test"||o.kind==="module"){let a=q(o.file);if($(a))try{le(a,y(b,".internal","meta.json"))}catch{}}!n&&h.length>0&&f.every(i=>i.status!=="skipped")&&d.push({unitFile:o.file,dirs:h.filter(i=>$(i))})}return{changedUnitFiles:l,legacySweep:d}}function yt(e){for(let t of e)try{Te(t,{recursive:!0,force:!0})}catch{}}function fe(e,t){let s=e.trace[0].stepIndex,l=t.find(o=>o.rootStepIndex===s);if(!l)return"skipped";if(l.status==="passed")return"passed";if(l.status==="skipped")return"skipped";let d=e.trace.slice(1).map(o=>o.stepIndex),r=l.failedSubStepIndex??[],p=Math.min(d.length,r.length);for(let o=0;o<p;o++)if(d[o]!==r[o])return d[o]<r[o]?"passed":"skipped";return d.length===r.length?"failed":d.length<r.length?"passed":"skipped"}export{te as a,et as b,tt as c,st as d,nt as e,rt as f,ae as g,St as h,yt as i};