@testmuai/kane-cli 0.8.3 → 0.8.5

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 (186) hide show
  1. package/dist/{ChatSurface-FJSO3IKR.js → ChatSurface-HAIVTS4J.js} +1 -1
  2. package/dist/{ChromeProfilePicker-NTZ2RN3L.js → ChromeProfilePicker-5ILSVC2K.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-BCHUH24C.js → CliFeedbackPrompt-LFKEYMKP.js} +1 -1
  4. package/dist/{CliUploadProgress-QVAJJRUW.js → CliUploadProgress-Y7ITY2I7.js} +1 -1
  5. package/dist/{ConfigView-LAKAQN7O.js → ConfigView-OECNNCXC.js} +1 -1
  6. package/dist/EvidenceViewOffer-FODRAS6Z.js +2 -0
  7. package/dist/FolderPicker-5U3RHHBE.js +2 -0
  8. package/dist/{InfoBox-46C7AHDE.js → InfoBox-HWMHNWPM.js} +1 -1
  9. package/dist/{LinksBox-KFJXZDUJ.js → LinksBox-TAGYCFFO.js} +1 -1
  10. package/dist/{ProfilesView-FV3KFVBX.js → ProfilesView-QJBR3RCM.js} +1 -1
  11. package/dist/{ProjectPicker-MCH35VEF.js → ProjectPicker-PP75ILZU.js} +1 -1
  12. package/dist/{SaveSessionPrompt-RXHP3YW6.js → SaveSessionPrompt-UCRET3II.js} +1 -1
  13. package/dist/SingleShotApp-XWOPGLKZ.js +2 -0
  14. package/dist/{SummaryBox-33K2MMUW.js → SummaryBox-SLM3OFS2.js} +1 -1
  15. package/dist/TestMdRunView-6BY3IUH5.js +2 -0
  16. package/dist/TestrunEvidenceTable-PTIBYAXO.js +2 -0
  17. package/dist/{WhoamiView-HUPBB5AQ.js → WhoamiView-WPHMNYUV.js} +1 -1
  18. package/dist/{app-download-3O7NJNGG.js → app-download-GYQYLGT3.js} +1 -1
  19. package/dist/{auth-OMWFVDL2.js → auth-3DLNMZC2.js} +1 -1
  20. package/dist/binary-XJ3RF3VO.js +2 -0
  21. package/dist/{bind-NXXKFJMA.js → bind-2N4Q6YKH.js} +2 -2
  22. package/dist/{bootstrap-MMRPAHWE.js → bootstrap-5IHKW5SE.js} +1 -1
  23. package/dist/bridge-LOBTHY3P.js +2 -0
  24. package/dist/{changelog-VZ5HFHYM.js → changelog-WCCTI47M.js} +1 -1
  25. package/dist/{chunk-4G4RWARU.js → chunk-2K2BX23I.js} +1 -1
  26. package/dist/{chunk-SQDKYSWT.js → chunk-2WSOPZJU.js} +1 -1
  27. package/dist/{chunk-ITTZYA2G.js → chunk-35EUIBYJ.js} +1 -1
  28. package/dist/chunk-3AJ3QSF5.js +15 -0
  29. package/dist/{chunk-AVH3BEEU.js → chunk-4D3DNCQY.js} +1 -1
  30. package/dist/{chunk-5OVEBP4D.js → chunk-4UMQDH52.js} +1 -1
  31. package/dist/{chunk-CJJXT5DO.js → chunk-5GUD3CIH.js} +1 -1
  32. package/dist/{chunk-KZVEFBH5.js → chunk-5NSYHRDN.js} +1 -1
  33. package/dist/{chunk-DVYO4CR2.js → chunk-5S46D5AJ.js} +1 -1
  34. package/dist/{chunk-CDB3SYZG.js → chunk-66BSTNLD.js} +1 -1
  35. package/dist/{chunk-2N4SZOWN.js → chunk-6BTZ2Q4P.js} +1 -1
  36. package/dist/{chunk-CJP7RX3E.js → chunk-6DTWVLSJ.js} +1 -1
  37. package/dist/{chunk-XO45NGSN.js → chunk-7JUUNZQP.js} +1 -1
  38. package/dist/chunk-7PADFQ5S.js +71 -0
  39. package/dist/{chunk-WMMJXI5O.js → chunk-AJPLHW4T.js} +1 -1
  40. package/dist/{chunk-5BVOF4UW.js → chunk-AMULIFC5.js} +1 -1
  41. package/dist/{chunk-EBJD2V4Z.js → chunk-BAL7E4OH.js} +1 -1
  42. package/dist/chunk-BG66IAO6.js +19 -0
  43. package/dist/{chunk-3S5DDQLP.js → chunk-BJHII5SD.js} +1 -1
  44. package/dist/chunk-BVKDHHPK.js +5 -0
  45. package/dist/chunk-CCUGKBIH.js +2 -0
  46. package/dist/{chunk-2ERQYYSJ.js → chunk-CGYSFLM2.js} +1 -1
  47. package/dist/{chunk-LP3BSP74.js → chunk-CNNJ4U2L.js} +1 -1
  48. package/dist/{chunk-FPAJURPL.js → chunk-DCUT3GJA.js} +1 -1
  49. package/dist/{chunk-VK3NU742.js → chunk-DEZ7CXGM.js} +1 -1
  50. package/dist/chunk-DJ7T7BMV.js +2 -0
  51. package/dist/{chunk-TRVB7RSW.js → chunk-E3BXNQYE.js} +1 -1
  52. package/dist/{chunk-DN42IM2Z.js → chunk-EFRJNPBZ.js} +2 -2
  53. package/dist/chunk-EKCGZXZE.js +2 -0
  54. package/dist/{chunk-2ZDXNTZT.js → chunk-FDWEL5HR.js} +1 -1
  55. package/dist/chunk-FRSHEJUS.js +2 -0
  56. package/dist/{chunk-WCF2Z4SE.js → chunk-FTZPWXF7.js} +1 -1
  57. package/dist/{chunk-IEOHAHZO.js → chunk-G4AFOZKU.js} +1 -1
  58. package/dist/{chunk-AF572MQG.js → chunk-GYF4CH62.js} +3 -3
  59. package/dist/{chunk-GR35ZFM2.js → chunk-GZ4X53ZA.js} +2 -2
  60. package/dist/{chunk-JANVTG62.js → chunk-HFCDUFV3.js} +1 -1
  61. package/dist/{chunk-6G5YKTVN.js → chunk-HQWLSA5M.js} +1 -1
  62. package/dist/{chunk-DJR3M7XO.js → chunk-JJWQUQJ2.js} +1 -1
  63. package/dist/chunk-JN2DP4R2.js +37 -0
  64. package/dist/{chunk-37ZWKLEN.js → chunk-JRQKUQWL.js} +1 -1
  65. package/dist/chunk-K2QV7FGP.js +2 -0
  66. package/dist/{chunk-7YZMUTJA.js → chunk-K7UYWAZH.js} +1 -1
  67. package/dist/chunk-KBMQGNKO.js +26 -0
  68. package/dist/{chunk-NWJOPZ7P.js → chunk-KWKUMBHS.js} +2 -2
  69. package/dist/{chunk-YJNGBZ42.js → chunk-KX2GOJ4C.js} +2 -2
  70. package/dist/{chunk-KOMKHFC4.js → chunk-LA2EMSHE.js} +1 -1
  71. package/dist/{chunk-LSZVSYAP.js → chunk-M335FQYJ.js} +2 -2
  72. package/dist/{chunk-LNQCZ5DS.js → chunk-MJ56GUKS.js} +1 -1
  73. package/dist/{chunk-NVGM5ISX.js → chunk-MUGMUKSZ.js} +1 -1
  74. package/dist/{chunk-ZNNRCUHH.js → chunk-NHOHQBIF.js} +1 -1
  75. package/dist/{chunk-3MFTTLOF.js → chunk-NLECZCMZ.js} +1 -1
  76. package/dist/{chunk-QJTXNQV5.js → chunk-NYSMQ7UY.js} +1 -1
  77. package/dist/{chunk-NNCMMV6P.js → chunk-O3AY6JHJ.js} +29 -23
  78. package/dist/{chunk-IVYXXZEE.js → chunk-OWTEHU6B.js} +1 -1
  79. package/dist/{chunk-6IA6QMPH.js → chunk-P7YZ3PU3.js} +1 -1
  80. package/dist/{chunk-UBTNWAKK.js → chunk-PB3GADUD.js} +1 -1
  81. package/dist/{chunk-APETOVZK.js → chunk-PCOSE5SW.js} +2 -2
  82. package/dist/{chunk-HJ6AXOCR.js → chunk-PEI2566X.js} +1 -1
  83. package/dist/{chunk-LCU2P3CH.js → chunk-PQUMOFT5.js} +1 -1
  84. package/dist/chunk-PUFJEU46.js +2 -0
  85. package/dist/{chunk-IWWQTXGK.js → chunk-PWYEOBXV.js} +1 -1
  86. package/dist/chunk-Q6JHBDW2.js +2 -0
  87. package/dist/chunk-R7OGNE3W.js +2 -0
  88. package/dist/{chunk-5CKQTZMG.js → chunk-RY6TFVAX.js} +1 -1
  89. package/dist/{chunk-GIQURCTO.js → chunk-T3XDMR5B.js} +1 -1
  90. package/dist/{chunk-ZH64GOBG.js → chunk-T5LKD2OB.js} +1 -1
  91. package/dist/{chunk-KGSVOTLG.js → chunk-TCK3QMKY.js} +1 -1
  92. package/dist/chunk-TJZMYU2W.js +2 -0
  93. package/dist/{chunk-NXXJ56QA.js → chunk-TYI4MLFJ.js} +1 -1
  94. package/dist/chunk-ULGZPRKU.js +2 -0
  95. package/dist/{chunk-BRIEBB2U.js → chunk-UOMRMCMI.js} +1 -1
  96. package/dist/{chunk-TUTDSX7T.js → chunk-UX3KPYTI.js} +1 -1
  97. package/dist/chunk-V444REBC.js +11 -0
  98. package/dist/{chunk-DSXSU5MH.js → chunk-VT2XNEOD.js} +4 -4
  99. package/dist/{chunk-L5LI2JF4.js → chunk-VZ7KXRXB.js} +11 -11
  100. package/dist/{chunk-4FQI643D.js → chunk-W27F2NWA.js} +1 -1
  101. package/dist/{chunk-CVCVBQP6.js → chunk-WLOGO44E.js} +1 -1
  102. package/dist/chunk-WYST42WI.js +7 -0
  103. package/dist/{chunk-XMYCRE5K.js → chunk-YFLKS4UV.js} +3 -3
  104. package/dist/{chunk-SPQPOUUR.js → chunk-Z2T7E5HM.js} +2 -2
  105. package/dist/{chunk-IHAHCFFG.js → chunk-ZFZ7YXEU.js} +1 -1
  106. package/dist/{chunk-SA2LQSYP.js → chunk-ZIRMSWKS.js} +1 -1
  107. package/dist/{chunk-KHU7C6EE.js → chunk-ZKSN2SJ7.js} +1 -1
  108. package/dist/{chunk-ZPDM6FO7.js → chunk-ZSXDZI56.js} +2 -2
  109. package/dist/{config-OTUKOTHM.js → config-OKTAPFOT.js} +1 -1
  110. package/dist/cover-cmd-7JILZJUK.js +3 -0
  111. package/dist/{credentials-A3RU25MJ.js → credentials-SO3DSQEM.js} +1 -1
  112. package/dist/{deps-bundle-RIBEQC2R.js → deps-bundle-FRM65BQO.js} +1 -1
  113. package/dist/{deps-resolve-7SWSUDRX.js → deps-resolve-RPZORKUN.js} +1 -1
  114. package/dist/{dispatch-RHSWJJLC.js → dispatch-OZRMWY25.js} +1 -1
  115. package/dist/doctor-VWGEQYBB.js +2 -0
  116. package/dist/evidence-5AUZMKE3.js +2 -0
  117. package/dist/evidence-presentation-XF23B7F2.js +2 -0
  118. package/dist/{evolve-cmd-FFF3F3HO.js → evolve-cmd-TWYJL4EG.js} +1 -1
  119. package/dist/{explain-cmd-3GEKR7O5.js → explain-cmd-2TKO7GRW.js} +1 -1
  120. package/dist/{extract-bind-VIPNGK2H.js → extract-bind-EW7XUDLQ.js} +2 -2
  121. package/dist/{extract-cmd-5J47Q4XU.js → extract-cmd-HOVGMBGM.js} +1 -1
  122. package/dist/{gaps-cmd-WPCJPLGB.js → gaps-cmd-3ZX3PZF4.js} +1 -1
  123. package/dist/{generate-headless-AJI2OVRG.js → generate-headless-FYTJULPG.js} +2 -2
  124. package/dist/index.js +168 -88
  125. package/dist/{ingest-cmd-2LK7DWDW.js → ingest-cmd-RJLTFNMN.js} +1 -1
  126. package/dist/install-46S4VOZ4.js +2 -0
  127. package/dist/{interactive-bind-PI3HY623.js → interactive-bind-PSEYAL54.js} +3 -3
  128. package/dist/{list-commands-7Y5XV5FK.js → list-commands-2SVSEAP6.js} +1 -1
  129. package/dist/login-flow-U43QVFPH.js +2 -0
  130. package/dist/{mobile-prompts-O5ALU3QU.js → mobile-prompts-T6HZ2YLY.js} +1 -1
  131. package/dist/{persist-recorded-session-TKSU4HOA.js → persist-recorded-session-O2NCYTSD.js} +1 -1
  132. package/dist/pipeline-BHEA7ODT.js +2 -0
  133. package/dist/prepare-target-27UN4KNO.js +2 -0
  134. package/dist/{reconcile-cmd-VHEW2DY5.js → reconcile-cmd-FU3JIHTO.js} +1 -1
  135. package/dist/{reconcile-deps-UJ6KVUIS.js → reconcile-deps-SUKZA2FL.js} +2 -2
  136. package/dist/{reconcile-engine-NUQJSIFX.js → reconcile-engine-ILL4M3NW.js} +1 -1
  137. package/dist/{recording-banner-GO2PP53Y.js → recording-banner-5VXVKCV4.js} +1 -1
  138. package/dist/{registry-KYPVINS2.js → registry-BKV3EDTK.js} +1 -1
  139. package/dist/replay-policy-CVQ6OJX5.js +2 -0
  140. package/dist/{require-project-folder-NUQMH224.js → require-project-folder-2IO6IX5W.js} +1 -1
  141. package/dist/resolve-run-intent-ZML3HKG7.js +2 -0
  142. package/dist/{resolver-HHLYRR5W.js → resolver-CBTWTZZR.js} +1 -1
  143. package/dist/run-EXIYK6PU.js +2 -0
  144. package/dist/{run-OPLOL3PZ.js → run-R7GND73C.js} +1 -1
  145. package/dist/{run-test-md-3BA56ZYF.js → run-test-md-664ASWRQ.js} +2 -2
  146. package/dist/{skill-installer-O7JYVZXD.js → skill-installer-QLQK4JJE.js} +1 -1
  147. package/dist/{spawner-OZ4OE44T.js → spawner-ANLF7OX3.js} +1 -1
  148. package/dist/tcg-generate-VBC5ODDI.js +2 -0
  149. package/dist/{testmd-actions-YJ7O43Z6.js → testmd-actions-QZD3N4EH.js} +1 -1
  150. package/dist/token-refresh-PIUX5OFA.js +2 -0
  151. package/dist/{types-6E2HTDKJ.js → types-VYEOJ6U2.js} +1 -1
  152. package/dist/{validate-basic-HWYK3CU6.js → validate-basic-D7IJUFUQ.js} +1 -1
  153. package/dist/{verdicts-KFPMRADV.js → verdicts-EO5TZ5BW.js} +1 -1
  154. package/dist/{version-check-3ECNG5V2.js → version-check-JRLPWQ6T.js} +1 -1
  155. package/dist/{walk-session-MZCMXVZB.js → walk-session-IODOH7QU.js} +1 -1
  156. package/dist/{with-telemetry-Q6V6THIF.js → with-telemetry-ASNQQBGP.js} +1 -1
  157. package/package.json +11 -11
  158. package/dist/EvidenceViewOffer-POKUWAPS.js +0 -2
  159. package/dist/FolderPicker-GR6FZMUJ.js +0 -2
  160. package/dist/HelpView-JFFVHQAW.js +0 -2
  161. package/dist/SingleShotApp-BK5QNXGG.js +0 -2
  162. package/dist/TestMdRunView-AT26LOSG.js +0 -2
  163. package/dist/bridge-UH32UGR5.js +0 -2
  164. package/dist/chunk-5NQ3TI4S.js +0 -13
  165. package/dist/chunk-A5FFLJVL.js +0 -26
  166. package/dist/chunk-C5UNZ6ZY.js +0 -2
  167. package/dist/chunk-D5VYMHSO.js +0 -2
  168. package/dist/chunk-D6FYCAIA.js +0 -2
  169. package/dist/chunk-DOG7S7R6.js +0 -2
  170. package/dist/chunk-DXI5TXNL.js +0 -19
  171. package/dist/chunk-IFIXY3YG.js +0 -2
  172. package/dist/chunk-IOD3HQVW.js +0 -11
  173. package/dist/chunk-RUCSRS4C.js +0 -5
  174. package/dist/chunk-ZUYPPPC5.js +0 -66
  175. package/dist/cover-cmd-HDZZWJXG.js +0 -3
  176. package/dist/doctor-XP7YDE3J.js +0 -2
  177. package/dist/evidence-K7R7OG2K.js +0 -2
  178. package/dist/login-flow-Z45G34DM.js +0 -2
  179. package/dist/pipeline-HZUV7IMT.js +0 -2
  180. package/dist/prepare-target-DBYKQ7HW.js +0 -2
  181. package/dist/replay-policy-6USQBT3E.js +0 -2
  182. package/dist/resolve-run-intent-H3HX5KUC.js +0 -7
  183. package/dist/run-67ONKMGR.js +0 -2
  184. package/dist/tcg-generate-EG2MXRJ7.js +0 -2
  185. package/dist/token-refresh-K7CANKFQ.js +0 -2
  186. /package/dist/{lifecycle-cmd-HO5VL7AM.js → lifecycle-cmd-O2324GN6.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ke}from"./chunk-KHU7C6EE.js";import{c as Ve}from"./chunk-IOD3HQVW.js";import{a as We,b as ue}from"./chunk-3Q6WAK6P.js";import{a as Ue,b as ze}from"./chunk-JZ26R6UL.js";import{a as Z,b as je,e as le,f as de,g as Me,h as He}from"./chunk-WMMJXI5O.js";import{a as Ne,c as Le,d as Be,e as me,f as Ge}from"./chunk-ZGBSGZZM.js";import{a as Ae,b as Ie,c as Pe}from"./chunk-4FQI643D.js";import{a as Ee,b as Ce,c as Te}from"./chunk-BB2W35TW.js";import{a as qe}from"./chunk-L2TV4G56.js";import{c as Oe}from"./chunk-6KPPGMO2.js";import{a as $e,e as Re}from"./chunk-GFKCTYCA.js";import{a as Fe}from"./chunk-IMR64OCZ.js";import{b as be,c as we,d as ve,e as ae,f as oe,g as ce}from"./chunk-ZPDM6FO7.js";import{a as ne}from"./chunk-L5LI2JF4.js";import{a as ye,b as re}from"./chunk-IDX3TOPY.js";import{A as U}from"./chunk-TH47OOBV.js";import{f as De}from"./chunk-DUAXZYAD.js";import{a as ke,e as xe,f as Se}from"./chunk-DBIBROYW.js";import{d as W,e as X}from"./chunk-WXHQYYD5.js";import{a as _e}from"./chunk-5EOX4MEY.js";import{mkdirSync as St,appendFileSync as Dt,rmdirSync as dt}from"fs";import{randomBytes as $t}from"crypto";import{dirname as mt,join as he}from"path";function Qe(t,e){let n=[];for(let i of e??[]){let g=t.resolve(i.ref)?.tip??null;g!==i.cid&&n.push({ref:i.ref,pinned:i.cid,now:g})}return n}import{existsSync as ge,readFileSync as pe,readdirSync as pt}from"fs";import{join as te}from"path";var Ye=`
2
+ import{a as Ke}from"./chunk-ZKSN2SJ7.js";import{a as ze,b as ue}from"./chunk-3Q6WAK6P.js";import{a as Ue,b as We}from"./chunk-JZ26R6UL.js";import{a as Z,b as Le,e as le,f as de,g as Be,h as He}from"./chunk-AJPLHW4T.js";import{a as Ne,c as je,d as Fe,e as me,f as Ge}from"./chunk-ZGBSGZZM.js";import{a as Ae,b as Ie,c as Oe}from"./chunk-W27F2NWA.js";import{a as Re,b as Ce,c as Te}from"./chunk-BB2W35TW.js";import{a as qe}from"./chunk-L2TV4G56.js";import{c as Pe}from"./chunk-6KPPGMO2.js";import{a as $e,e as Ee}from"./chunk-GFKCTYCA.js";import{a as Me}from"./chunk-IMR64OCZ.js";import{c as Ve}from"./chunk-V444REBC.js";import{b as ye,c as we,d as ve,e as ae,h as oe,i as ce}from"./chunk-ZSXDZI56.js";import{b as ne}from"./chunk-VZ7KXRXB.js";import{a as be,b as re}from"./chunk-IDX3TOPY.js";import{A as U}from"./chunk-TH47OOBV.js";import{f as De}from"./chunk-DUAXZYAD.js";import{a as ke,e as xe,f as Se}from"./chunk-DBIBROYW.js";import{d as z,e as X}from"./chunk-WXHQYYD5.js";import{a as _e}from"./chunk-5EOX4MEY.js";import{mkdirSync as St,appendFileSync as Dt,rmdirSync as dt}from"fs";import{randomBytes as $t}from"crypto";import{dirname as mt,join as he}from"path";function Qe(t,e){let n=[];for(let i of e??[]){let g=t.resolve(i.ref)?.tip??null;g!==i.cid&&n.push({ref:i.ref,pinned:i.cid,now:g})}return n}import{existsSync as ge,readFileSync as pe,readdirSync as pt}from"fs";import{join as te}from"path";var Ye=`
3
3
  version: 1
4
4
  techniques:
5
5
  - id: eqp
@@ -160,21 +160,21 @@ candidate_checks:
160
160
  `,"mobile-native":`
161
161
  id: mobile-native
162
162
  name: "Mobile native"
163
- version: 1
163
+ version: 2
164
164
  applies_when: >
165
165
  iOS/Android native surface.
166
166
  candidate_checks:
167
167
  - id: interruptions
168
168
  family: state_flow
169
- measurable_example: "Incoming call mid-flow \u2192 state preserved on return"
169
+ measurable_example: "Incoming call mid-flow \u2192 state preserved on return \u2014 no device control: promises here become gaps, not tests"
170
170
  emits: state-transition
171
171
  - id: network-transitions
172
172
  family: state_flow
173
- measurable_example: "wifi\u2192cellular\u21924G drop: no data loss, graceful retry"
173
+ measurable_example: "wifi\u2192cellular\u21924G drop: no data loss, graceful retry \u2014 no connectivity control: promises here become gaps, not tests"
174
174
  emits: state-transition
175
175
  - id: permissions
176
176
  family: negative
177
- measurable_example: "Deny camera \u2192 feature degrades, no crash"
177
+ measurable_example: "Deny camera \u2192 feature degrades, no crash \u2014 the OS dialog is tappable UI (exercise Allow/Deny on screen); only programmatic grant/deny or pre-seeded permission state has no control"
178
178
  emits: forbidden-presence
179
179
  - id: orientation
180
180
  family: persistence
@@ -182,7 +182,7 @@ candidate_checks:
182
182
  emits: absolute
183
183
  - id: deep-links
184
184
  family: state_flow
185
- measurable_example: "Cold-start deep link lands on the right screen with auth"
185
+ measurable_example: "Cold-start deep link lands on the right screen with auth \u2014 legal when the test states the exact link target"
186
186
  emits: state-transition
187
187
  - id: state-persistence
188
188
  family: persistence
@@ -190,7 +190,7 @@ candidate_checks:
190
190
  emits: absolute
191
191
  - id: localization
192
192
  family: i18n
193
- measurable_example: "Device locale switch reformats and re-translates"
193
+ measurable_example: "Device locale switch reformats and re-translates \u2014 no device control: promises here become gaps, not tests"
194
194
  emits: presence
195
195
  `,"stateful-flow":`
196
196
  id: stateful-flow
@@ -313,37 +313,43 @@ candidate_checks:
313
313
  measurable_example: "Locale-correct collation/casing"
314
314
  emits: presence
315
315
  `};var Xe=`
316
- version: 1
316
+ version: 2
317
317
  principles:
318
- - "Each step is one complete OBJECTIVE the browser agent achieves autonomously \u2014 state the goal and the path, never low-level actions (the agent emits its own actions)."
318
+ - "Each step is one complete OBJECTIVE the executing agent achieves autonomously \u2014 state the goal and the path, never low-level actions (the agent emits its own actions)."
319
319
  - "One objective (or tightly-related items of one goal) per step; unrelated goals split."
320
- - "Verbose path: name site, page, section, panel, control, state \u2014 'On the search results page for Noida, in the filter panel's Budget section, set min to 50L and max to 1Cr'."
320
+ - "Verbose path: name site or app, page or screen, section, panel, control, state \u2014 'On the search results page for Noida, in the filter panel's Budget section, set min to 50L and max to 1Cr'."
321
321
  - "Self-contained: concrete values inline; never 'as defined in the scenario' \u2014 the agent cannot see the graph."
322
- - "Browser-only: the agent authors/runs BROWSER tests. Direct API calls and the page's own network traffic ARE in scope; native-app-only behavior, out-of-band email/SMS, backend state with no browser surface are NOT."
322
+ - "Two surfaces: WEB tests run in the kane-cli browser agent; MOBILE tests run in the kane-cli mobile agent on a local Android emulator / iOS simulator (native app). One surface per test; imports/reuse only same-surface units."
323
+ - "In scope: web-browser behavior, mobile emulator/simulator native-app behavior, and direct API calls. NOT in scope: out-of-band email/SMS, backend state with no web, app-screen, or API surface."
323
324
  verification:
324
- - "Phrase checks against the analyzer that observes them:"
325
- - "Visual \u2014 visible text, labels, counts, prices ('verify the price is 29.99', 'the Sold out label is shown')."
326
- - "Textual/DOM \u2014 element states/attributes ('the Add button is disabled', 'the placeholder of the search box is \u2026')."
327
- - "URL \u2014 'URL contains /checkout', 'redirected to /login'. Title \u2014 'page title contains \u2026'."
328
- - "DevTools/Network \u2014 'no API calls returned 5xx', 'the POST /api/login returned 200' (covers direct API calls too)."
329
- - "DevTools/Console \u2014 'no console errors'. Performance \u2014 'LCP under 2500ms'. Cookies/localStorage \u2014 'a cookie named session_id exists'."
325
+ - "Phrase checks against what the test's own surface can observe:"
326
+ - "WEB Visual \u2014 visible text, labels, counts, prices ('verify the price is 29.99', 'the Sold out label is shown')."
327
+ - "WEB Textual/DOM \u2014 element states/attributes ('the Add button is disabled', 'the placeholder of the search box is \u2026')."
328
+ - "WEB URL \u2014 'URL contains /checkout'. Title \u2014 'page title contains \u2026'."
329
+ - "WEB DevTools/Network \u2014 'no API calls returned 5xx', 'the POST /api/login returned 200'. Console \u2014 'no console errors'. Performance \u2014 'LCP under 2500ms'. Cookies/localStorage \u2014 'a cookie named session_id exists'."
330
+ - "MOBILE Visual \u2014 on-screen text, labels, counts, states ('the Upcoming list shows 2 reservations', 'a Booking cancelled toast is shown')."
331
+ - "MOBILE Element \u2014 native accessibility-tree states ('the Pay button is disabled', 'the Remember me switch is on')."
332
+ - "MOBILE Network (environment-dependent) \u2014 the app's own captured traffic ('the POST /api/login returned 200') and direct API calls ('call GET /api/bookings and verify the cancelled booking is absent') need a capture/API-wired run environment; when the promise is observable on-screen, prefer the screen."
333
+ - "MOBILE Lifecycle \u2014 background/foreground, terminate/relaunch (only when the objective closes the app), orientation, deep links with a stated target ('background the app and return; the draft is preserved'). OS permission dialogs are tappable UI \u2014 exercising Allow/Deny on screen is legal."
334
+ - "MOBILE ILLEGAL \u2014 URL, page Title, browser console, page-performance: none exist on a native app. Cookies/localStorage: WebView-only AND write-only \u2014 never a read check. Keyboard-visibility: illegal on Android (default sessions suppress the soft keyboard); iOS renders it as ordinary elements. No control exists \u2192 gap, never a test: incoming call/SMS, posting notifications, wifi/airplane switches, locale/timezone, clipboard reads, on-device DB/file reads (the db-query tool reads a configured backend DB, never the device), geolocation, biometrics, programmatic permission pre-seeding. Platform-conditional: notification-shade observation and tab handling are Android-only \u2014 gap iOS notification promises."
330
335
  - "Assertions: 'Assert/Verify/Confirm \u2026'. Extractions: 'Store \u2026 as name' \u2014 vague verbs (read/tell/report) do NOT persist values."
331
- - "Baselines/deltas are EXTRACTIONS: 'store the result count as baseline_count' BEFORE the action; compare after. Never an abstract 'capture the state'."
336
+ - "Baselines/deltas are EXTRACTIONS on both surfaces: 'store the result count as baseline_count' BEFORE the action; compare after. Never an abstract 'capture the state'."
332
337
  variables:
333
338
  - "Credentials and environment values are {{name}} variables; concrete domain values from the source stay literal."
334
339
  - "A value no evidence supplies (start URL, test account, seed data) is ASKED for \u2014 actual value or a variable name \u2014 never invented."
335
340
  pitfalls:
336
- - "A test without a starting URL cannot run \u2014 the first step names it."
341
+ - "A WEB test without a starting URL cannot run \u2014 its first step names it."
342
+ - "A MOBILE test's first step BEGINS with its marker, then launches the app ('[mobile: emulator] Launch the <App> app; from its entry screen, \u2026') \u2014 never a URL. App data PERSISTS between runs (no reset): never assume first-install or signed-out state. The minted file needs target:/app: frontmatter attached before it can run on a device."
337
343
  - "'Test the checkout flow' has no end state \u2014 state what done looks like."
338
344
  - "Do not cram many unrelated operations into one step; do not reference data outside the step."
339
- `;var ft=["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"];function tt(t,e){for(let n of t)if(!ft.includes(n))throw new Error(`${e}: emits '${n}' is not an oracle kind`)}function Ze(t,e){let n=ne(t);if(!n||!Array.isArray(n.techniques))throw new Error(`${e}: expected { techniques: [...] }`);for(let i of n.techniques){if(!i.id||!i.name||!i.applies_hint||!Array.isArray(i.emits))throw new Error(`${e}: technique '${i?.id??"?"}' missing id/name/applies_hint/emits`);tt(i.emits,`${e}: technique '${i.id}'`)}return n.techniques}function et(t,e){let n=ne(t);if(!n||!n.id||!n.name||!n.applies_when||!Array.isArray(n.candidate_checks))throw new Error(`${e}: profile missing id/name/applies_when/candidate_checks`);for(let i of n.candidate_checks){if(!i.id||!i.family||!i.measurable_example||!i.emits)throw new Error(`${e}: candidate_check '${i?.id??"?"}' missing id/family/measurable_example/emits`);tt([i.emits],`${e}: check '${i.id}'`)}return n}function st(t){let e=new Map(Ze(Ye,"packaged techniques").map(i=>[i.id,i])),n=te(t,"design","techniques.yaml");if(ge(n))for(let i of Ze(pe(n,"utf8"),n))e.set(i.id,i);return[...e.values()]}function it(t){let e=new Map(Object.entries(Je).map(([i,g])=>[i,et(g,`packaged profile '${i}'`)])),n=te(t,"design","profiles");if(ge(n))for(let i of pt(n).filter(g=>g.endsWith(".yaml")||g.endsWith(".yml")).sort()){let g=et(pe(te(n,i),"utf8"),te(n,i));e.set(g.id,g)}return[...e.values()]}function nt(t){let e=te(t,"design","runner-grammar.yaml");return ge(e)?pe(e,"utf8"):Xe}function se(t,e){return!t.superseded.has(e)}function fe(t,e,n){return{cid:e,logical_id:t.nameOf.get(e)??null,content:n}}async function rt(t,e,n,i,g){let r=await je(t,"search_similar",{text:e,label:n,k:i},g);return r.ok&&Array.isArray(r.result)?r.result:[]}async function at(t,e,n={}){let i=U(t),g=i.resolve(e);if(!g)throw new Error(`assembleDesignContext: unknown use-case '${e}' (run designGate first)`);let r=g.tip,w=i.getNode(r);if(!w||w.label!==W.USECASE)throw new Error(`assembleDesignContext: '${e}' is not a use-case (run designGate first)`);let I=i.derivesInto(r).map(u=>({source_id:u.props.source_id??null,anchor:u.props.anchor??null})),k=[],T=new Set;for(let{cid:u,content:f}of i.byLabel(W.SCENARIO))se(i,u)&&i.edgesFrom(u).some(b=>b.type===X.BELONGS_TO&&b.dst===r)&&(k.push(fe(i,u,f)),T.add(u));let x=[];for(let{cid:u,content:f}of i.byLabel(W.AC)){if(!se(i,u))continue;let b=i.edgesFrom(u).find($=>$.type===X.SCOPED_TO);!b||b.dst!==r&&!T.has(b.dst)||x.push({...fe(i,u,f),scoped_to:b.dst})}let y=Array.isArray(w.content.criteria)?w.content.criteria:[],h=[w.content.title,w.content.description,...y].filter(Boolean).join(`
340
- `),F=(await rt(i,h,W.SCENARIO,10,n.embedSearch)).filter(u=>!T.has(u.cid)),L=[],S=new Set,O=[],c=[r],N=new Set([r]);for(;c.length>0;){let u=c.shift();for(let f of i.edgesFrom(u)){if(f.type!==X.DEPENDS_ON||i.nodeLabel.get(f.dst)!==W.USECASE)continue;let b=i.tipOf(f.dst);N.has(b)||(N.add(b),O.push(b),c.push(b))}}for(let u of O){let f=`depends_on ${i.nameOf.get(u)??u.slice(0,19)}`;for(let{cid:b}of i.byLabel(W.SCENARIO))if(se(i,b)&&i.edgesFrom(b).some($=>$.type===X.BELONGS_TO&&$.dst===u))for(let $ of i.edgesInto(b)){if($.type!==X.AUTOMATES||!se(i,$.src)||S.has($.src))continue;S.add($.src);let V=String(i.getNode($.src)?.content.title??"");L.push({cid:$.src,logical_id:i.nameOf.get($.src)??null,title:V,via:f})}}for(let u of await rt(i,h,W.TEST,5,n.embedSearch)){let{cid:f,title:b}=u;S.has(f)||(S.add(f),L.push({cid:f,logical_id:i.nameOf.get(f)??null,title:b??"",via:"similar"}))}let v=i.byLabel(W.STYLENOTE).filter(u=>se(i,u.cid)).sort((u,f)=>u.cid<f.cid?-1:1).slice(0,5).map(u=>`${String(u.content.statement)} [${String(u.content.learned_from_kind)}]`);return{usecase:fe(i,r,w.content),cites:I,committed_acs:x,existing:{scenarios:k,reuse_candidates:F},import_candidates:L,style_notes:v,techniques:st(t),profiles:it(t),runner_grammar:nt(t),budget:{...n.max!=null?{max_pairs:n.max}:{},...n.strength!=null?{strength_override:n.strength}:{}},design_of:(()=>{let u=Ue(i,r);return u?{engine:u.engine,seq:u.seq}:null})()}}function ot(t){let e=n=>{if(Array.isArray(n))return n.map(e);if(n!==null&&typeof n=="object"){let i={};for(let g of Object.keys(n).sort())i[g]=e(n[g]);return i}return n};return JSON.stringify(e(t),null,1)}import{basename as _t,dirname as yt,resolve as bt}from"path";var ht=oe,wt=new Set(["narrative","acs","scenarios","tests","exercises","gaps","scoped_to_repoints","judgements","phase"]);function vt(t){let e=/strength=(\d+)\s*(?:—|-)?\s*(.*)/.exec(t??"");return e?{strength:Number(e[1]),reason:e[2]||t||""}:{strength:2,reason:t??""}}function kt(t,e,n=new Set,i=0){return ht(e,ce(t),n,i)}function xt(t,e,n,i){let g=e.scenarios?.find(y=>y.temp_ref===n.automates)??(()=>{let y=t.resolve(n.automates),h=y?t.getNode(y.tip)?.content:void 0;return h?{title:String(h.title??""),intent:String(h.intent??""),technique_notes:String(h.technique_notes??"")}:{}})(),r=[...(e.acs??[]).map(y=>({ref:y.temp_ref,text:y.text})),...n.verifies.filter(y=>!(e.acs??[]).some(h=>h.temp_ref===y)).map(y=>{let h=t.resolve(y);return{ref:y,text:h?String(t.getNode(h.tip)?.content.text??""):""}})],{test_md:w,objectives_yaml:I}=ve({title:n.title,steps:n.steps,check:n.check,check_prose:n.check_prose,reuses:n.reuses},{title:g.title,intent:g.intent},r),k=ae(kt(t,w)),T=n.check,x={technique:g.technique_notes??"",profile_family:e.judgements?.find(y=>y.kind==="profile_family"&&(y.target===n.temp_ref||y.target===n.automates))?.rationale??"unspecified",anchor:T.verified_against,expected_how:e.judgements?.find(y=>y.kind==="expected_how"&&y.target===T.verified_against)?.rationale??`expected_mode: ${T.expected_mode??"inferred"}`,combinatorial:vt(g.technique_notes),surface_state:"absent",deferred_bindings:T.expected_mode==="runtime-derived"?1:0};return i.push({definitionId:k,rationale:x,anchorRef:T.verified_against,tempRef:n.temp_ref}),{temp_ref:n.temp_ref,title:n.title,automates:n.automates,verifies:n.verifies,check:n.check,definitionId:k,test_md_blob:w,objectives_blob:I,...n.reuses?.length?{reuses:n.reuses}:{},...n.surface_required!==void 0?{surface_required:n.surface_required}:{}}}function ct(t){let e=0,n=t.forceScope??null;return{terminalEventType:"design",async onProposalEvent(i){let g=a=>t.steer?(t.steer(`[auto-repair] ${a} \u2014 please re-finalize with this fixed.`),{proposal:null,error:null}):{proposal:null,error:a};if(i==null||typeof i!="object")return g("finalize_design payload is not an object");let r=i,w=Object.keys(r).filter(a=>!wt.has(a));if(w.length>0)return g(`finalize_design carries ungated/unknown section(s): ${w.join(", ")} \u2014 mintable here: acs, scenarios, tests (+gaps)`);let I=new Map;for(let a of r.tests??[]){let p=I.get(a.automates);if(p)return g(`strict 1:1 violated in-payload: ${p} and ${a.temp_ref} both automate ${a.automates}`);I.set(a.automates,a.temp_ref)}let k=U(t.contextDir);t.force&&!t.resuming&&e===0&&n===null&&(n=We(k,t.ucRef));let T=k.resolve(t.ucRef),x=T?String(k.getNode(T.tip)?.content.risk??"med"):"med",y=[],h=new Set([t.ucRef,T?.cid,T?.tip].filter(Boolean)),F=a=>{if(h.has(a))return!0;let p=k.resolve(a);return p!=null&&(h.has(p.cid)||h.has(p.tip))},L;try{L={...r.acs?.length?{acs:r.acs.map(a=>({temp_ref:a.temp_ref,text:a.text,kind:a.kind,risk:a.risk??x,...a.expected_answer?{expected_answer:a.expected_answer}:{},...a.scoped_to&&!F(a.scoped_to)?{scope:{type:"scenario",ref:a.scoped_to}}:{}}))}:{},...r.scenarios?.length?{scenarios:r.scenarios}:{},...r.tests?.length?{tests:r.tests.map(a=>xt(k,r,a,y))}:{},...r.exercises?.length?{exercises:r.exercises}:{},...r.gaps?.length?{gaps:r.gaps}:{},...r.scoped_to_repoints?.length?{scoped_to_repoints:r.scoped_to_repoints}:{},...r.judgements?.length?{judgements:r.judgements}:{}}}catch(a){return g(a instanceof Error?a.message:String(a))}let S=r.phase??(r.tests?.length?"tests":r.scenarios?.length?"scenarios":r.acs?.length?"acs":"design"),O=(a,p={})=>({contextDir:t.contextDir,graph:a,ucRef:t.ucRef,sections:L,by:t.by,phase:S,...p,...t.templateVersion?{templateVersion:t.templateVersion()}:{},...t.engine?{engine:t.engine}:{},...n?.length?{forceScope:n}:{},...t.because?{reason:t.because}:{},finalizeTestBody:(()=>{let R=new Map((L.tests??[]).map(A=>[A.temp_ref,A])),E=new Map,K=(A,B,P)=>{let G=R.get(A);if(!G?.test_md_blob)return null;let z=E.get(A);if(z!==void 0)return z;if(P.has(A))return G.test_md_blob;P.add(A);let Q=new Map;for(let q of G.reuses??[]){K(q,B,P);let J=B(q);J!==null&&J!==q&&Q.set(q,J)}let Y=G.verifies.map(B).filter(q=>q!==null),H=be(we(G.test_md_blob,Q),Y);return E.set(A,H),H};return(A,B)=>{if(!A.test_md_blob)return null;let P=K(A.temp_ref,B,new Set)??A.test_md_blob;if(P===A.test_md_blob)return null;let G=z=>{for(let Q of R.keys())if(B(Q)===z){let Y=K(Q,B,new Set);if(Y!==null)return{body:Y,cycleKey:`batch:${z}`,next:G}}return ce(k)(z)};return{test_md_blob:P,definitionId:ae(oe(P,G))}}})()}),c;if(t.protocol){let a=t.generationTicket,p=await Ae(t.protocol,{verb:"design",ucTargets:[{ref:t.ucRef}],newBuCandidates:[],sourcePins:[],readBasis:k.latestHash,...a?{generationTicket:a}:{}},R=>{let E=ue(O(R.graph,{eventIds:R.eventIds("design",1),sid:R.sid,...a&&!t.generationStamped?{generationTicket:a}:{}}));return E.errors!==null?{errors:E.errors}:{result:E,record:E.record}});p.ok&&"result"in p?(c=p.result,a&&!t.generationStamped&&(t.generationStamped=!0,t.generationTicket={...a,expected_prev_gen:a.next_gen})):p.ok?c={record:null,errors:null,minted:{},logicalIds:{},superseded:[],warnings:["commit already applied (recommit)"],finalizedTests:{}}:c={record:null,errors:p.kind==="validation"?p.errors:p.kind==="contended"?[{code:p.err.code,detail:`${t.ucRef} is held by ${p.err.holder?.owner_sid??"another session"}${p.err.holder?.alive?" (live)":" (stale)"} \u2014 try another use-case or wait for it to free`}]:p.kind==="drifted"?p.asks.map(E=>({code:"DRIFTED",detail:E.detail})):[{code:"UNSETTLED",detail:`concurrent activity kept moving the store (${p.attempts} attempts) \u2014 retry when the store is quieter`}],minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}}}else c=ue(O(k));if(c.errors)return g("design commit failed: "+c.errors.map(a=>`${a.code}: ${a.detail}`).join("; "));let N=c.warnings.filter(a=>a.includes("\u2014 committed anyway; approve"));for(let a of c.warnings)(!N.includes(a)||N.length===1)&&t.note(`warning: ${a}`);N.length>1&&t.note(`warning: ${N.length} test link(s) refer to items still awaiting approval \u2014 saved anyway; review and approve those items in chat or via kane-cli context review`);let v=(a,p)=>a?`${a} ${p}${a>1?"s":""}`:null,u=[v(r.acs?.length,"AC"),v(r.scenarios?.length,"scenario"),v(r.tests?.length,"test"),v(r.gaps?.length,"gap")].filter(Boolean);t.aliases?.(Object.entries(c.minted).map(([a,p])=>({ref:a,cid:p,...c.logicalIds[a]?{id:c.logicalIds[a]}:{}})));{let a=`saved ${u.join(" \xB7 ")||"judgements/wiring"} as drafts`;(t.commitLine??t.note)(a)}let f=U(t.contextDir);t.onCommitted?.(f);for(let a of y){let p=c.logicalIds[a.anchorRef]??c.minted[a.anchorRef];Ke(t.contextDir,c.finalizedTests[a.tempRef]??a.definitionId,{...a.rationale,anchor:p??a.rationale.anchor})}try{let a=Object.values(c.minted).filter(p=>f.getNode(p)?.label==="test");if(a.length>0){let p=yt(bt(t.contextDir)),R=Ve({graph:f,cids:a,cwd:p});R.wrote.length>0&&t.note(`\u2692 wrote ${R.wrote.map(E=>_t(E.path)).join(" \xB7 ")}`);for(let E of R.refused)t.note(`warning: could not create the test file for ${E.id} \u2014 ${E.reason}`)}}catch(a){t.note(`warning: the design was saved, but its test file could not be created (${a instanceof Error?a.message:String(a)})`)}t.event?.({type:"commit",acs:r.acs?.length??0,scenarios:r.scenarios?.length??0,tests:r.tests?.length??0,gaps:r.gaps?.length??0,warnings:c.warnings.length,minted:Object.entries(c.minted).map(([a,p])=>({temp_ref:a,cid:p,...c.logicalIds[a]?{logical_id:c.logicalIds[a]}:{}}))}),e+=1,n!==null&&(n=c.forceScopeRemaining??n,t.onForceScope?.(n));let b=qe({verb:"design",commitN:e,ucRef:t.ucRef,phase:S,committed:Object.entries(c.minted).map(([a,p])=>({temp_ref:a,cid:p,...c.logicalIds[a]?{logical_id:c.logicalIds[a]}:{}})),warnings:c.warnings},f),$=b.event.parity?.missing??[],V=!!r.tests?.length&&$.length===0;return{proposal:c,error:null,receipt:b,...V?{sessionComplete:V}:{}}}}}function lt(t,e){return{type:"run_config",version:1,session_id:e.session_id,mode:e.mode,source:{source_id:`design:${t.usecase.logical_id??e.ucCid.slice(0,19)}`,source_cid:e.ucCid,kind:"design_context",numbered_text:ot({...t,session_mode:e.mode})},existing_use_cases:[],read_basis:e.readBasis,max_free_text_rounds:2,graph_reads:!0,verb:"design",chat:!0,design_budget:t.budget,topology:e.topology}}var ut=Symbol("design-out-tee");function Rt(t,e,n,i){return{terminalEventType:"design",async onProposalEvent(g){let r=g??{},w=["acs","scenarios","tests","gaps"].map(I=>r[I]?.length?`${r[I].length} ${I}`:null).filter(Boolean).join(" \xB7 ");return n?.("plan_payload",{payload:r}),t(`plan: finalize_design \u2014 ${w||"wiring/judgements only"} (nothing committed${i?`; full payload: ${Z(i)}`:""})`),e?.({type:"plan",payload:r}),{proposal:r,error:null}}}}async function Rs(t,e){let n=U(e.contextDir),i=null,g=null,r=t.useCase;if(t.resume){try{{let m=await Ge(e.contextDir,t.resume,n,{deps:{onWarn:_=>e.out(`note: ${_}`)}});g=m,i=m.handle,m.drift.length>0&&(e.out(`note: sources changed since the pause: ${m.drift.map(_=>_.subject).join(", ")} \u2014 the design continues against the current versions`),e.emit?.({type:"stale_basis",sources:m.drift.map(_=>_.subject)}))}}catch(m){if(m instanceof ye||m instanceof me)return e.out(`error: ${m.message}`),e.emit?.({type:"error",message:`error: ${m.message}`}),m instanceof me||m.code==="SESSION_MISSING"||m.code==="SESSION_EXPIRED"?2:1;throw m}let s=i.state,d=Ne(s.verb,"design",t.resume);if(d)return e.out(d.message),e.emit?.({type:"error",message:d.message,code:d.code}),i.release(),2;if(r&&s.use_case&&r!==s.use_case){let m=`session ${t.resume} was designing ${s.use_case}; --use-case ${r} RETARGETS it`;if(!(t.confirmRetarget?await t.confirmRetarget(`${m} \u2014 continue with the new target?`):!1))return e.out(`error: ${m} \u2014 resume without --use-case to continue ${s.use_case}, or start a fresh session on ${r}`),e.emit?.({type:"error",code:"RETARGET_MISMATCH",message:m}),i.release(),2}if(r=r??s.use_case,s.uc_tip&&r){let m=n.resolve(r)?.tip;if(m&&m!==s.uc_tip){let _=`the use-case changed since the pause (${s.uc_tip.slice(0,19)}\u2026 \u2192 ${m.slice(0,19)}\u2026)`;if(!(t.confirmRetarget?await t.confirmRetarget(`${_} \u2014 re-ground and continue against the new version?`):!1))return e.out(`error: ${_} \u2014 resume interactively to re-ground, or abandon this session`),e.emit?.({type:"error",code:"UC_TIP_MOVED",message:_}),i.release(),2;e.emit?.({type:"stale_basis",usecase:r})}}let l=Qe(n,s.target_pins);if(l.length>0){let m=`items this session pinned have changed since it paused: ${l.map(C=>`${C.ref}${C.now===null?" (now gone)":""}`).join(", ")}`;if(!(t.confirmRetarget?await t.confirmRetarget(`${m} \u2014 re-ground and continue?`):!1))return e.out(`error: ${m} \u2014 resume interactively to re-ground, or abandon`),e.emit?.({type:"error",code:"TARGET_PIN_MOVED",message:m}),i.release(),2;i.save({target_pins:(s.target_pins??[]).map(C=>({ref:C.ref,cid:n.resolve(C.ref)?.tip??C.cid}))})}let o=[...new Set([...i.state.held_receipts??[],...g?.view.kane?.held_receipts??[]])];if(o.length>0)if(e.chat?.holdReceipt)for(let m of o)e.chat.holdReceipt(m);else e={...e,initialMessage:[o.join(`
345
+ `;var ft=["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"];function tt(t,e){for(let n of t)if(!ft.includes(n))throw new Error(`${e}: emits '${n}' is not an oracle kind`)}function Ze(t,e){let n=ne(t);if(!n||!Array.isArray(n.techniques))throw new Error(`${e}: expected { techniques: [...] }`);for(let i of n.techniques){if(!i.id||!i.name||!i.applies_hint||!Array.isArray(i.emits))throw new Error(`${e}: technique '${i?.id??"?"}' missing id/name/applies_hint/emits`);tt(i.emits,`${e}: technique '${i.id}'`)}return n.techniques}function et(t,e){let n=ne(t);if(!n||!n.id||!n.name||!n.applies_when||!Array.isArray(n.candidate_checks))throw new Error(`${e}: profile missing id/name/applies_when/candidate_checks`);for(let i of n.candidate_checks){if(!i.id||!i.family||!i.measurable_example||!i.emits)throw new Error(`${e}: candidate_check '${i?.id??"?"}' missing id/family/measurable_example/emits`);tt([i.emits],`${e}: check '${i.id}'`)}return n}function st(t){let e=new Map(Ze(Ye,"packaged techniques").map(i=>[i.id,i])),n=te(t,"design","techniques.yaml");if(ge(n))for(let i of Ze(pe(n,"utf8"),n))e.set(i.id,i);return[...e.values()]}function it(t){let e=new Map(Object.entries(Je).map(([i,g])=>[i,et(g,`packaged profile '${i}'`)])),n=te(t,"design","profiles");if(ge(n))for(let i of pt(n).filter(g=>g.endsWith(".yaml")||g.endsWith(".yml")).sort()){let g=et(pe(te(n,i),"utf8"),te(n,i));e.set(g.id,g)}return[...e.values()]}function nt(t){let e=te(t,"design","runner-grammar.yaml");return ge(e)?pe(e,"utf8"):Xe}function se(t,e){return!t.superseded.has(e)}function fe(t,e,n){return{cid:e,logical_id:t.nameOf.get(e)??null,content:n}}async function rt(t,e,n,i,g){let r=await Le(t,"search_similar",{text:e,label:n,k:i},g);return r.ok&&Array.isArray(r.result)?r.result:[]}async function at(t,e,n={}){let i=U(t),g=i.resolve(e);if(!g)throw new Error(`assembleDesignContext: unknown use-case '${e}' (run designGate first)`);let r=g.tip,w=i.getNode(r);if(!w||w.label!==z.USECASE)throw new Error(`assembleDesignContext: '${e}' is not a use-case (run designGate first)`);let I=i.derivesInto(r).map(u=>({source_id:u.props.source_id??null,anchor:u.props.anchor??null})),k=[],T=new Set;for(let{cid:u,content:f}of i.byLabel(z.SCENARIO))se(i,u)&&i.edgesFrom(u).some(y=>y.type===X.BELONGS_TO&&y.dst===r)&&(k.push(fe(i,u,f)),T.add(u));let x=[];for(let{cid:u,content:f}of i.byLabel(z.AC)){if(!se(i,u))continue;let y=i.edgesFrom(u).find($=>$.type===X.SCOPED_TO);!y||y.dst!==r&&!T.has(y.dst)||x.push({...fe(i,u,f),scoped_to:y.dst})}let b=Array.isArray(w.content.criteria)?w.content.criteria:[],h=[w.content.title,w.content.description,...b].filter(Boolean).join(`
346
+ `),M=(await rt(i,h,z.SCENARIO,10,n.embedSearch)).filter(u=>!T.has(u.cid)),j=[],S=new Set,P=[],c=[r],N=new Set([r]);for(;c.length>0;){let u=c.shift();for(let f of i.edgesFrom(u)){if(f.type!==X.DEPENDS_ON||i.nodeLabel.get(f.dst)!==z.USECASE)continue;let y=i.tipOf(f.dst);N.has(y)||(N.add(y),P.push(y),c.push(y))}}for(let u of P){let f=`depends_on ${i.nameOf.get(u)??u.slice(0,19)}`;for(let{cid:y}of i.byLabel(z.SCENARIO))if(se(i,y)&&i.edgesFrom(y).some($=>$.type===X.BELONGS_TO&&$.dst===u))for(let $ of i.edgesInto(y)){if($.type!==X.AUTOMATES||!se(i,$.src)||S.has($.src))continue;S.add($.src);let V=String(i.getNode($.src)?.content.title??"");j.push({cid:$.src,logical_id:i.nameOf.get($.src)??null,title:V,via:f})}}for(let u of await rt(i,h,z.TEST,5,n.embedSearch)){let{cid:f,title:y}=u;S.has(f)||(S.add(f),j.push({cid:f,logical_id:i.nameOf.get(f)??null,title:y??"",via:"similar"}))}let v=i.byLabel(z.STYLENOTE).filter(u=>se(i,u.cid)).sort((u,f)=>u.cid<f.cid?-1:1).slice(0,5).map(u=>`${String(u.content.statement)} [${String(u.content.learned_from_kind)}]`);return{usecase:fe(i,r,w.content),cites:I,committed_acs:x,existing:{scenarios:k,reuse_candidates:M},import_candidates:j,style_notes:v,techniques:st(t),profiles:it(t),runner_grammar:nt(t),budget:{...n.max!=null?{max_pairs:n.max}:{},...n.strength!=null?{strength_override:n.strength}:{}},design_of:(()=>{let u=Ue(i,r);return u?{engine:u.engine,seq:u.seq}:null})()}}function ot(t){let e=n=>{if(Array.isArray(n))return n.map(e);if(n!==null&&typeof n=="object"){let i={};for(let g of Object.keys(n).sort())i[g]=e(n[g]);return i}return n};return JSON.stringify(e(t),null,1)}import{basename as _t,dirname as bt,resolve as yt}from"path";var ht=oe,wt=new Set(["narrative","acs","scenarios","tests","exercises","gaps","scoped_to_repoints","judgements","phase"]);function vt(t){let e=/strength=(\d+)\s*(?:—|-)?\s*(.*)/.exec(t??"");return e?{strength:Number(e[1]),reason:e[2]||t||""}:{strength:2,reason:t??""}}function kt(t,e,n=new Set,i=0){return ht(e,ce(t),n,i)}function xt(t,e,n,i){let g=e.scenarios?.find(b=>b.temp_ref===n.automates)??(()=>{let b=t.resolve(n.automates),h=b?t.getNode(b.tip)?.content:void 0;return h?{title:String(h.title??""),intent:String(h.intent??""),technique_notes:String(h.technique_notes??"")}:{}})(),r=[...(e.acs??[]).map(b=>({ref:b.temp_ref,text:b.text})),...n.verifies.filter(b=>!(e.acs??[]).some(h=>h.temp_ref===b)).map(b=>{let h=t.resolve(b);return{ref:b,text:h?String(t.getNode(h.tip)?.content.text??""):""}})],{test_md:w,objectives_yaml:I}=ve({title:n.title,steps:n.steps,check:n.check,check_prose:n.check_prose,reuses:n.reuses},{title:g.title,intent:g.intent},r),k=ae(kt(t,w)),T=n.check,x={technique:g.technique_notes??"",profile_family:e.judgements?.find(b=>b.kind==="profile_family"&&(b.target===n.temp_ref||b.target===n.automates))?.rationale??"unspecified",anchor:T.verified_against,expected_how:e.judgements?.find(b=>b.kind==="expected_how"&&b.target===T.verified_against)?.rationale??`expected_mode: ${T.expected_mode??"inferred"}`,combinatorial:vt(g.technique_notes),surface_state:"absent",deferred_bindings:T.expected_mode==="runtime-derived"?1:0};return i.push({definitionId:k,rationale:x,anchorRef:T.verified_against,tempRef:n.temp_ref}),{temp_ref:n.temp_ref,title:n.title,automates:n.automates,verifies:n.verifies,check:n.check,definitionId:k,test_md_blob:w,objectives_blob:I,...n.reuses?.length?{reuses:n.reuses}:{},...n.surface_required!==void 0?{surface_required:n.surface_required}:{}}}function ct(t){let e=0,n=t.forceScope??null;return{terminalEventType:"design",async onProposalEvent(i){let g=a=>t.steer?(t.steer(`[auto-repair] ${a} \u2014 please re-finalize with this fixed.`),{proposal:null,error:null}):{proposal:null,error:a};if(i==null||typeof i!="object")return g("finalize_design payload is not an object");let r=i,w=Object.keys(r).filter(a=>!wt.has(a));if(w.length>0)return g(`finalize_design carries ungated/unknown section(s): ${w.join(", ")} \u2014 mintable here: acs, scenarios, tests (+gaps)`);let I=new Map;for(let a of r.tests??[]){let p=I.get(a.automates);if(p)return g(`strict 1:1 violated in-payload: ${p} and ${a.temp_ref} both automate ${a.automates}`);I.set(a.automates,a.temp_ref)}let k=U(t.contextDir);t.force&&!t.resuming&&e===0&&n===null&&(n=ze(k,t.ucRef));let T=k.resolve(t.ucRef),x=T?String(k.getNode(T.tip)?.content.risk??"med"):"med",b=[],h=new Set([t.ucRef,T?.cid,T?.tip].filter(Boolean)),M=a=>{if(h.has(a))return!0;let p=k.resolve(a);return p!=null&&(h.has(p.cid)||h.has(p.tip))},j;try{j={...r.acs?.length?{acs:r.acs.map(a=>({temp_ref:a.temp_ref,text:a.text,kind:a.kind,risk:a.risk??x,...a.expected_answer?{expected_answer:a.expected_answer}:{},...a.scoped_to&&!M(a.scoped_to)?{scope:{type:"scenario",ref:a.scoped_to}}:{}}))}:{},...r.scenarios?.length?{scenarios:r.scenarios}:{},...r.tests?.length?{tests:r.tests.map(a=>xt(k,r,a,b))}:{},...r.exercises?.length?{exercises:r.exercises}:{},...r.gaps?.length?{gaps:r.gaps}:{},...r.scoped_to_repoints?.length?{scoped_to_repoints:r.scoped_to_repoints}:{},...r.judgements?.length?{judgements:r.judgements}:{}}}catch(a){return g(a instanceof Error?a.message:String(a))}let S=r.phase??(r.tests?.length?"tests":r.scenarios?.length?"scenarios":r.acs?.length?"acs":"design"),P=(a,p={})=>({contextDir:t.contextDir,graph:a,ucRef:t.ucRef,sections:j,by:t.by,phase:S,...p,...t.templateVersion?{templateVersion:t.templateVersion()}:{},...t.engine?{engine:t.engine}:{},...n?.length?{forceScope:n}:{},...t.because?{reason:t.because}:{},finalizeTestBody:(()=>{let E=new Map((j.tests??[]).map(A=>[A.temp_ref,A])),R=new Map,K=(A,F,O)=>{let G=E.get(A);if(!G?.test_md_blob)return null;let W=R.get(A);if(W!==void 0)return W;if(O.has(A))return G.test_md_blob;O.add(A);let Q=new Map;for(let q of G.reuses??[]){K(q,F,O);let J=F(q);J!==null&&J!==q&&Q.set(q,J)}let Y=G.verifies.map(F).filter(q=>q!==null),H=ye(we(G.test_md_blob,Q),Y);return R.set(A,H),H};return(A,F)=>{if(!A.test_md_blob)return null;let O=K(A.temp_ref,F,new Set)??A.test_md_blob;if(O===A.test_md_blob)return null;let G=W=>{for(let Q of E.keys())if(F(Q)===W){let Y=K(Q,F,new Set);if(Y!==null)return{body:Y,cycleKey:`batch:${W}`,next:G}}return ce(k)(W)};return{test_md_blob:O,definitionId:ae(oe(O,G))}}})()}),c;if(t.protocol){let a=t.generationTicket,p=await Ae(t.protocol,{verb:"design",ucTargets:[{ref:t.ucRef}],newBuCandidates:[],sourcePins:[],readBasis:k.latestHash,...a?{generationTicket:a}:{}},E=>{let R=ue(P(E.graph,{eventIds:E.eventIds("design",1),sid:E.sid,...a&&!t.generationStamped?{generationTicket:a}:{}}));return R.errors!==null?{errors:R.errors}:{result:R,record:R.record}});p.ok&&"result"in p?(c=p.result,a&&!t.generationStamped&&(t.generationStamped=!0,t.generationTicket={...a,expected_prev_gen:a.next_gen})):p.ok?c={record:null,errors:null,minted:{},logicalIds:{},superseded:[],warnings:["commit already applied (recommit)"],finalizedTests:{}}:c={record:null,errors:p.kind==="validation"?p.errors:p.kind==="contended"?[{code:p.err.code,detail:`${t.ucRef} is held by ${p.err.holder?.owner_sid??"another session"}${p.err.holder?.alive?" (live)":" (stale)"} \u2014 try another use-case or wait for it to free`}]:p.kind==="drifted"?p.asks.map(R=>({code:"DRIFTED",detail:R.detail})):[{code:"UNSETTLED",detail:`concurrent activity kept moving the store (${p.attempts} attempts) \u2014 retry when the store is quieter`}],minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}}}else c=ue(P(k));if(c.errors)return g("design commit failed: "+c.errors.map(a=>`${a.code}: ${a.detail}`).join("; "));let N=c.warnings.filter(a=>a.includes("\u2014 committed anyway; approve"));for(let a of c.warnings)(!N.includes(a)||N.length===1)&&t.note(`warning: ${a}`);N.length>1&&t.note(`warning: ${N.length} test link(s) refer to items still awaiting approval \u2014 saved anyway; review and approve those items in chat or via kane-cli context review`);let v=(a,p)=>a?`${a} ${p}${a>1?"s":""}`:null,u=[v(r.acs?.length,"AC"),v(r.scenarios?.length,"scenario"),v(r.tests?.length,"test"),v(r.gaps?.length,"gap")].filter(Boolean);t.aliases?.(Object.entries(c.minted).map(([a,p])=>({ref:a,cid:p,...c.logicalIds[a]?{id:c.logicalIds[a]}:{}})));{let a=`saved ${u.join(" \xB7 ")||"judgements/wiring"} as drafts`;(t.commitLine??t.note)(a)}let f=U(t.contextDir);t.onCommitted?.(f);for(let a of b){let p=c.logicalIds[a.anchorRef]??c.minted[a.anchorRef];Ke(t.contextDir,c.finalizedTests[a.tempRef]??a.definitionId,{...a.rationale,anchor:p??a.rationale.anchor})}try{let a=Object.values(c.minted).filter(p=>f.getNode(p)?.label==="test");if(a.length>0){let p=bt(yt(t.contextDir)),E=Ve({graph:f,cids:a,cwd:p});E.wrote.length>0&&t.note(`\u2692 wrote ${E.wrote.map(R=>_t(R.path)).join(" \xB7 ")}`);for(let R of E.refused)t.note(`warning: could not create the test file for ${R.id} \u2014 ${R.reason}`)}}catch(a){t.note(`warning: the design was saved, but its test file could not be created (${a instanceof Error?a.message:String(a)})`)}t.event?.({type:"commit",acs:r.acs?.length??0,scenarios:r.scenarios?.length??0,tests:r.tests?.length??0,gaps:r.gaps?.length??0,warnings:c.warnings.length,minted:Object.entries(c.minted).map(([a,p])=>({temp_ref:a,cid:p,...c.logicalIds[a]?{logical_id:c.logicalIds[a]}:{}}))}),e+=1,n!==null&&(n=c.forceScopeRemaining??n,t.onForceScope?.(n));let y=qe({verb:"design",commitN:e,ucRef:t.ucRef,phase:S,committed:Object.entries(c.minted).map(([a,p])=>({temp_ref:a,cid:p,...c.logicalIds[a]?{logical_id:c.logicalIds[a]}:{}})),warnings:c.warnings},f),$=y.event.parity?.missing??[],V=!!r.tests?.length&&$.length===0;return{proposal:c,error:null,receipt:y,...V?{sessionComplete:V}:{}}}}}function lt(t,e){return{type:"run_config",version:1,session_id:e.session_id,mode:e.mode,source:{source_id:`design:${t.usecase.logical_id??e.ucCid.slice(0,19)}`,source_cid:e.ucCid,kind:"design_context",numbered_text:ot({...t,session_mode:e.mode})},existing_use_cases:[],read_basis:e.readBasis,max_free_text_rounds:2,graph_reads:!0,verb:"design",chat:!0,design_budget:t.budget,topology:e.topology}}var ut=Symbol("design-out-tee");function Et(t,e,n,i){return{terminalEventType:"design",async onProposalEvent(g){let r=g??{},w=["acs","scenarios","tests","gaps"].map(I=>r[I]?.length?`${r[I].length} ${I}`:null).filter(Boolean).join(" \xB7 ");return n?.("plan_payload",{payload:r}),t(`plan: finalize_design \u2014 ${w||"wiring/judgements only"} (nothing committed${i?`; full payload: ${Z(i)}`:""})`),e?.({type:"plan",payload:r}),{proposal:r,error:null}}}}async function Es(t,e){let n=U(e.contextDir),i=null,g=null,r=t.useCase;if(t.resume){try{{let m=await Ge(e.contextDir,t.resume,n,{deps:{onWarn:_=>e.out(`note: ${_}`)}});g=m,i=m.handle,m.drift.length>0&&(e.out(`note: sources changed since the pause: ${m.drift.map(_=>_.subject).join(", ")} \u2014 the design continues against the current versions`),e.emit?.({type:"stale_basis",sources:m.drift.map(_=>_.subject)}))}}catch(m){if(m instanceof be||m instanceof me)return e.out(`error: ${m.message}`),e.emit?.({type:"error",message:`error: ${m.message}`}),m instanceof me||m.code==="SESSION_MISSING"||m.code==="SESSION_EXPIRED"?2:1;throw m}let s=i.state,d=Ne(s.verb,"design",t.resume);if(d)return e.out(d.message),e.emit?.({type:"error",message:d.message,code:d.code}),i.release(),2;if(r&&s.use_case&&r!==s.use_case){let m=`session ${t.resume} was designing ${s.use_case}; --use-case ${r} RETARGETS it`;if(!(t.confirmRetarget?await t.confirmRetarget(`${m} \u2014 continue with the new target?`):!1))return e.out(`error: ${m} \u2014 resume without --use-case to continue ${s.use_case}, or start a fresh session on ${r}`),e.emit?.({type:"error",code:"RETARGET_MISMATCH",message:m}),i.release(),2}if(r=r??s.use_case,s.uc_tip&&r){let m=n.resolve(r)?.tip;if(m&&m!==s.uc_tip){let _=`the use-case changed since the pause (${s.uc_tip.slice(0,19)}\u2026 \u2192 ${m.slice(0,19)}\u2026)`;if(!(t.confirmRetarget?await t.confirmRetarget(`${_} \u2014 re-ground and continue against the new version?`):!1))return e.out(`error: ${_} \u2014 resume interactively to re-ground, or abandon this session`),e.emit?.({type:"error",code:"UC_TIP_MOVED",message:_}),i.release(),2;e.emit?.({type:"stale_basis",usecase:r})}}let l=Qe(n,s.target_pins);if(l.length>0){let m=`items this session pinned have changed since it paused: ${l.map(C=>`${C.ref}${C.now===null?" (now gone)":""}`).join(", ")}`;if(!(t.confirmRetarget?await t.confirmRetarget(`${m} \u2014 re-ground and continue?`):!1))return e.out(`error: ${m} \u2014 resume interactively to re-ground, or abandon`),e.emit?.({type:"error",code:"TARGET_PIN_MOVED",message:m}),i.release(),2;i.save({target_pins:(s.target_pins??[]).map(C=>({ref:C.ref,cid:n.resolve(C.ref)?.tip??C.cid}))})}let o=[...new Set([...i.state.held_receipts??[],...g?.view.kane?.held_receipts??[]])];if(o.length>0)if(e.chat?.holdReceipt)for(let m of o)e.chat.holdReceipt(m);else e={...e,initialMessage:[o.join(`
341
347
 
342
348
  `),e.initialMessage].filter(Boolean).join(`
343
349
 
344
- `)};if(!r)return e.out(`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`),e.emit?.({type:"error",message:`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`}),i.release(),2}let w=t.resume?void 0:t.phase,I=!1;if(w!==void 0){let{checkPhaseEntry:s,phaseEntryCmd:d,phaseLadderFor:l}=await import("./phase-seed-DIRETNU6.js");I=l(e.contextDir,n,r).length>0;let o=s(e.contextDir,n,r,w);if(!o.ok&&o.code==="UNKNOWN_PHASE")return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"UNKNOWN_PHASE",message:o.message}),i?.release(),2;if(!o.ok&&o.code==="PHASE_ORDER"){let m=t.askPhaseEntry?await t.askPhaseEntry({message:o.message,earliest:o.earliest}):"cancel";if(m==="earliest")e.out(`starting at ${o.earliest} instead (${o.missing.join(", ")} not committed yet)`),w=o.earliest;else if(m==="proceed")e.out(`note: entering at ${w} with ${o.missing.join(", ")} uncommitted \u2014 proceeding on your say-so`),e.emit?.({type:"phase_entry_override",phase:w,missing:o.missing});else{let _=(t.mode??"interactive")==="agent",C=d(r,o.earliest,_);return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"PHASE_ORDER",message:o.message,next:[{cmd:C,why:`${o.earliest} is the earliest uncommitted phase for ${r}`,title:`Start at ${o.earliest}`}]}),i?.release(),2}}}let k=!!(t.force||i?.state.force),T=!!(t.resume&&i),x=ze(n,r,k||T||I);if(!x.ok){let s=(t.mode??"interactive")==="interactive";if(x.wall&&s&&t.askDesignEntry){let{captureForceScope:d}=await import("./design-committer-VYT6NU3T.js"),l=d(n,r).length,o=await t.askDesignEntry({wall:x.wall.kind,message:x.message,display:x.wall.display,impactPairs:l});if(o.pick==="redesign"||o.pick==="proceed"){if(!o.because.trim())return e.out("a redesign needs a reason (--because) \u2014 nothing executed"),i?.release(),2;e.out(o.pick==="redesign"?`redesigning ${x.wall.display} (${l} pair(s) superseded) \u2014 because: ${o.because.trim()}`:`proceeding against the stale design (noted) \u2014 because: ${o.because.trim()}`),t={...t,force:!0,because:t.because??o.because.trim()},k=!0}else return o.pick==="view"?(e.out(`view the existing design: kane-cli context view ${x.wall.display}`),i?.release(),0):o.pick==="refresh"?(e.out(`refresh it first: kane-cli maintain evolve ${x.wall.display}`),i?.release(),0):(e.out("nothing executed \u2014 list use-cases: kane-cli context list"),i?.release(),0)}else{e.out(`design: ${x.message}`);let d=x.wall&&t.mode==="agent"?[{cmd:`kane-cli context view ${x.wall.display}`,why:"view the existing design",title:"View the design"},...x.wall.kind==="designed-stale"?[{cmd:`kane-cli maintain evolve ${x.wall.display}`,why:"the use-case moved since the design \u2014 evolve refreshes it",title:"Evolve the design"}]:[],{cmd:`kane-cli design tests --use-case ${x.wall.display} --force --mode agent`,why:"redesign \u2014 supersedes the live scenario+test pairs",title:"Redesign"}]:void 0;return e.emit?.({type:"gate_refused",message:x.message,...d?{next:d}:{}}),i?.release(),x.code}}if(e.preflightTurn){let s=await e.preflightTurn();if(!s.ok)return e.out(s.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:s.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),i?.release(),2}let y={contextDir:e.contextDir,resolveAlias:s=>Ie(s,{env:process.env,auth:e.auth}),embed:(s,d)=>Pe(s,d,{env:process.env,auth:e.auth})};e.chat?.setWorking?.("assembling context\u2026");let h=await at(e.contextDir,r,{max:t.max,strength:t.strength,embedSearch:y});if(t.priorDesign!==void 0&&(h.prior_design=t.priorDesign),t.changeDelta!==void 0&&(h.change_delta=t.changeDelta),t.because&&(h.because=t.because),w!==void 0){let{buildPhaseSeed:s}=await import("./phase-seed-DIRETNU6.js"),d=s(e.contextDir,n,r,w);h.prior_design===void 0&&d.priorDesign!==void 0&&(h.prior_design=d.priorDesign),h.entry_phase=w,d.phaseLadder.length>0&&(h.phase_ladder=d.phaseLadder)}let F=e.now?.()??new Date,L=`${F.toISOString().replace(/[-:]/g,"").slice(0,15)}-${$t(2).toString("hex")}`,S=t.mode??"interactive",O=S==="interactive"&&!!e.chat&&!e.nested,c=g?{...g.spawnConfig,mode:S}:lt(h,{session_id:t.resume??`design-${L}`,mode:S,ucCid:h.usecase.cid,readBasis:n.latestHash,topology:Fe("design")}),N={current:null};if(c.resume&&"schema"in c.resume){let s=c.resume.binding?.template_version;typeof s=="string"&&(N.current=s)}t.plan?c.chat=!1:c.chat=!0;let v=e.telemetry?.enabled?e.telemetry:void 0,u=v?_e(v.ids.context_instance_id??null,"design",v.ids.session_id):he(e.contextDir,"logs",`design-${L}.log`);St(mt(u),{recursive:!0}),O||e.out(`trace: ${Z(u)}`),e.emit?.({type:"run_start",mode:S,trace:u,use_case:r,...v?{session:v.ids.session_id}:{}});let f=(s,d,l)=>{try{Dt(u,JSON.stringify({ts:new Date().toISOString(),level:s==="error"?"error":"info",run_id:v?.ids.operation_id,...v?{user_session_id:v.ids.session_id}:{},kind:s,session_id:l,data:d})+`
350
+ `)};if(!r)return e.out(`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`),e.emit?.({type:"error",message:`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`}),i.release(),2}let w=t.resume?void 0:t.phase,I=!1;if(w!==void 0){let{checkPhaseEntry:s,phaseEntryCmd:d,phaseLadderFor:l}=await import("./phase-seed-DIRETNU6.js");I=l(e.contextDir,n,r).length>0;let o=s(e.contextDir,n,r,w);if(!o.ok&&o.code==="UNKNOWN_PHASE")return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"UNKNOWN_PHASE",message:o.message}),i?.release(),2;if(!o.ok&&o.code==="PHASE_ORDER"){let m=t.askPhaseEntry?await t.askPhaseEntry({message:o.message,earliest:o.earliest}):"cancel";if(m==="earliest")e.out(`starting at ${o.earliest} instead (${o.missing.join(", ")} not committed yet)`),w=o.earliest;else if(m==="proceed")e.out(`note: entering at ${w} with ${o.missing.join(", ")} uncommitted \u2014 proceeding on your say-so`),e.emit?.({type:"phase_entry_override",phase:w,missing:o.missing});else{let _=(t.mode??"interactive")==="agent",C=d(r,o.earliest,_);return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"PHASE_ORDER",message:o.message,next:[{cmd:C,why:`${o.earliest} is the earliest uncommitted phase for ${r}`,title:`Start at ${o.earliest}`}]}),i?.release(),2}}}let k=!!(t.force||i?.state.force),T=!!(t.resume&&i),x=We(n,r,k||T||I);if(!x.ok){let s=(t.mode??"interactive")==="interactive";if(x.wall&&s&&t.askDesignEntry){let{captureForceScope:d}=await import("./design-committer-VYT6NU3T.js"),l=d(n,r).length,o=await t.askDesignEntry({wall:x.wall.kind,message:x.message,display:x.wall.display,impactPairs:l});if(o.pick==="redesign"||o.pick==="proceed"){if(!o.because.trim())return e.out("a redesign needs a reason (--because) \u2014 nothing executed"),i?.release(),2;e.out(o.pick==="redesign"?`redesigning ${x.wall.display} (${l} pair(s) superseded) \u2014 because: ${o.because.trim()}`:`proceeding against the stale design (noted) \u2014 because: ${o.because.trim()}`),t={...t,force:!0,because:t.because??o.because.trim()},k=!0}else return o.pick==="view"?(e.out(`view the existing design: kane-cli context view ${x.wall.display}`),i?.release(),0):o.pick==="refresh"?(e.out(`refresh it first: kane-cli maintain evolve ${x.wall.display}`),i?.release(),0):(e.out("nothing executed \u2014 list use-cases: kane-cli context list"),i?.release(),0)}else{e.out(`design: ${x.message}`);let d=x.wall&&t.mode==="agent"?[{cmd:`kane-cli context view ${x.wall.display}`,why:"view the existing design",title:"View the design"},...x.wall.kind==="designed-stale"?[{cmd:`kane-cli maintain evolve ${x.wall.display}`,why:"the use-case moved since the design \u2014 evolve refreshes it",title:"Evolve the design"}]:[],{cmd:`kane-cli design tests --use-case ${x.wall.display} --force --mode agent`,why:"redesign \u2014 supersedes the live scenario+test pairs",title:"Redesign"}]:void 0;return e.emit?.({type:"gate_refused",message:x.message,...d?{next:d}:{}}),i?.release(),x.code}}if(e.preflightTurn){let s=await e.preflightTurn();if(!s.ok)return e.out(s.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:s.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),i?.release(),2}let b={contextDir:e.contextDir,resolveAlias:s=>Ie(s,{env:process.env,auth:e.auth}),embed:(s,d)=>Oe(s,d,{env:process.env,auth:e.auth})};e.chat?.setWorking?.("assembling context\u2026");let h=await at(e.contextDir,r,{max:t.max,strength:t.strength,embedSearch:b});if(t.priorDesign!==void 0&&(h.prior_design=t.priorDesign),t.changeDelta!==void 0&&(h.change_delta=t.changeDelta),t.because&&(h.because=t.because),w!==void 0){let{buildPhaseSeed:s}=await import("./phase-seed-DIRETNU6.js"),d=s(e.contextDir,n,r,w);h.prior_design===void 0&&d.priorDesign!==void 0&&(h.prior_design=d.priorDesign),h.entry_phase=w,d.phaseLadder.length>0&&(h.phase_ladder=d.phaseLadder)}let M=e.now?.()??new Date,j=`${M.toISOString().replace(/[-:]/g,"").slice(0,15)}-${$t(2).toString("hex")}`,S=t.mode??"interactive",P=S==="interactive"&&!!e.chat&&!e.nested,c=g?{...g.spawnConfig,mode:S}:lt(h,{session_id:t.resume??`design-${j}`,mode:S,ucCid:h.usecase.cid,readBasis:n.latestHash,topology:Me("design")}),N={current:null};if(c.resume&&"schema"in c.resume){let s=c.resume.binding?.template_version;typeof s=="string"&&(N.current=s)}t.plan?c.chat=!1:c.chat=!0;let v=e.telemetry?.enabled?e.telemetry:void 0,u=v?_e(v.ids.context_instance_id??null,"design",v.ids.session_id):he(e.contextDir,"logs",`design-${j}.log`);St(mt(u),{recursive:!0}),P||e.out(`trace: ${Z(u)}`),e.emit?.({type:"run_start",mode:S,trace:u,use_case:r,...v?{session:v.ids.session_id}:{}});let f=(s,d,l)=>{try{Dt(u,JSON.stringify({ts:new Date().toISOString(),level:s==="error"?"error":"info",run_id:v?.ids.operation_id,...v?{user_session_id:v.ids.session_id}:{},kind:s,session_id:l,data:d})+`
345
351
  `)}catch{}v?.wireTrace(s,d,l)};{let s=e.out;if(s[ut]!==!0){let d=l=>{f("transcript",{line:l}),s(l)};d[ut]=!0,e.out=d}}if(t.resume&&i){g||(c.resume={agent_state:i.state.agent_state}),e.out(`resuming design session ${t.resume}`),i.state.assumed.length>0&&e.out(`note: ${i.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${t.resume} lists them`);try{let{readRecords:s}=await import("./records-IOZTZUZV.js"),d=s(e.contextDir).records.filter(l=>l.sid===t.resume).map(l=>l.design_phase).filter(l=>l!=null&&typeof l.phase=="string");if(d.length>0){let l=d.map(m=>`${m.phase}${m.completeness==="partial"?" (partial)":""}`).join(" \u2192 "),o=`[kane] durable record for this session (${t.resume}) on ${r}: design phases already COMMITTED \u2014 ${l}. Those finalizes landed; do not re-send them. Continue from the next uncommitted phase, or finish if the design is complete.`;e={...e,initialMessage:[e.initialMessage,o].filter(Boolean).join(`
346
352
 
347
353
  `)}}}catch{}t.message&&(e={...e,initialMessage:[e.initialMessage,t.message].filter(Boolean).join(`
348
354
 
349
- `)})}let b=null,$={current:n},V={detach:null},a=()=>{let s=V.detach;V.detach=null,s&&s()},p=(s,d)=>{let l=i;if(!l)return{};let o=s.ask,m=Me({contextDir:s.contextDir,cwd:mt(s.contextDir),handle:l,note:_=>s.chat?s.chat.note(_):s.out(_),graphSlot:d,...s.now?{now:s.now}:{}});if(s.chat?.attachIngest){let _=s.chat;V.detach=_.attachIngest(async C=>{try{l.save({ingest_registry:de(l.state.ingest_registry,C,s.now?.()??new Date)});let j=await m({id:`attach-${l.state.sid}-${(l.state.ingest_registry??[]).length}`,ref:C,purpose:null});return j.ok?(_.deferBatch({source_id:j.result.source_id,cid:j.result.cid}),{ok:!0}):{ok:!1,error:j.error.message}}catch(j){return{ok:!1,error:j instanceof Error?j.message:String(j)}}})}return{ask:async _=>{let C=await o(_);if(Array.isArray(C)){let j=C.filter(M=>{if(M.free_text==null||M.free_text.trim()==="")return!1;let ie=_.find(gt=>gt.id===M.id);return M.selected_index!=null&&ie?.options[M.selected_index]?.input===!0}).map(M=>M.free_text.trim());if(j.length>0){let M=l.state.ingest_registry;for(let ie of j)M=de(M,ie,s.now?.()??new Date);l.save({ingest_registry:M})}}return C},ingest:m}};e.nested||e.chat?.attachOnCommitted?.(s=>{$.current=s});let R="";if(e.chat&&!t.plan&&!e.nested){let s=Oe({contextDir:e.contextDir,graph:U(e.contextDir),sessionStamp:c.session_id,by:e.by??{kind:"human",id:"owner"}});s.errors===null||s.errors[0]?.code==="CONV_SOURCE_EXISTS"?(R=s.sourceId,e.chat.attachConversationSource?.(R),$.current=U(e.contextDir)):e.out(`warning: notes you add in chat can't be saved to the context this session (${s.errors[0]?.detail})`)}let E=U(e.contextDir),K;if(!t.plan){let s=Ce(E,r);if(T&&s!==null&&s.live){let d=E.resolve(r);K={uc_root:Ee(E,d.cid),next_gen:s.gen,expected_prev_gen:s.gen}}else{let d=Te(E,r,{...k?{force:!0}:{},because:t.because??(k?"forced redesign (--force)":void 0)});if("error"in d)return e.out(`design: ${d.error.detail}`),e.emit?.({type:"gate_refused",message:d.error.detail,code:d.error.code}),i?.release(),2;K=d}}let A=xe(e.contextDir,c.session_id),B=null,P=()=>{try{B?.release()}catch{}};if(!t.plan)try{B=A.acquire([Se(E,r).key],{hold:"session",verb:"design"})}catch(s){if(s instanceof ke&&s.code==="UC_HELD"){let d=s.holder,l=`design: ${r} is being designed by another session${d?.alive===!1?` \u2014 that session looks stopped; resume it with kane-cli design tests --resume ${d?.owner_sid??"<session>"}`:""} \u2014 pick another use-case (kane-cli design tests) or wait for it to finish`;return e.out(l),e.emit?.({type:"error",code:"UC_HELD",message:l}),i?.release(),2}throw s}let G={contextDir:e.contextDir,rootSid:c.session_id,locks:A,probe:{batchSimilar:async()=>({hits:[],degraded:!1,probeBasis:null}),recheckLocal:()=>({hits:[],uncachedNewNodes:[]})}},z=!t.plan&&S!=="ci",Q=()=>Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(s=>s.type==="DERIVES"&&typeof s.props.source_id=="string").map(s=>[String(s.props.source_id),n.heads.get(String(s.props.source_id))??null])),Y=!1;z&&!i&&(Y=!0,i=re(e.contextDir,{sid:c.session_id,mode:"agent",created_at:F.toISOString(),expires_at:new Date(F.getTime()+1440*60*1e3).toISOString(),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},read_basis:Q(),assumed:[],corpus_cursor:{remaining:[]},conv_source:R,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...k?{force:!0}:{},...v?{user_session_id:v.ids.session_id}:{}}));let H;if(z&&i){let{resume:s,...d}=c;Re(e.contextDir,c.session_id,{schema:$e,kind:"base",sid:c.session_id,verb:"design",mode:S,created_at:F.toISOString(),run_config:d,conv_source:R||i.state.conv_source||"",...r?{use_case:r}:{},...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},store_watermark:De(e.contextDir)}),c.checkpoints=!0,t.resume&&f("resume_kind",{kind:g?g.view.pointer===null?"bare-base":g.view.pointer.at==="final"?"pause":"crash":"v1-shim"},c.session_id);let l=g?0:i.state.checkpoint?.seq??0,o=i;H=Be({contextDir:e.contextDir,handle:o,seqBase:()=>l,peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>Q(),corpusCursor:()=>({remaining:[]}),onSoftCap:_=>e.out(_),onStat:_=>f("ckpt_stat",_,c.session_id),...e.now?{now:e.now}:{}});let m=H;H={...m,persist:_=>{let C=_.binding?.template_version;return typeof C=="string"&&C&&(N.current=C),m.persist(_)}}}let q=()=>{if(!i)return;let s=i.state.checkpoint;if(s){let d=S!=="interactive"?` --mode ${S}`:"";e.out(`session ${i.state.sid} kept its last checkpoint (seq ${s.seq}, ${s.ts}) \u2014 resume with: kane-cli design tests --resume ${i.state.sid}${d}`),i.release()}else if(Y){try{i.complete()}catch{i.release()}try{dt(he(e.contextDir,"sessions"))}catch{}}else i.release();i=null},J=t.plan?Rt(e.out,e.emit,f,u):ct({templateVersion:()=>N.current,contextDir:e.contextDir,ucRef:r,by:{kind:"ai",id:"design-agent"},force:k,engine:"design@1",note:s=>e.chat?e.chat.note(s):e.out(s),commitLine:s=>e.chat?e.chat.ledger({kind:"commit",ok:!0,line:s}):e.out(s),steer:e.chat?s=>e.chat.submit(s):void 0,event:e.emit,resuming:T,...i?.state.force_scope?.length?{forceScope:i.state.force_scope}:{},onForceScope:s=>{b=s},...t.because?{because:t.because}:{},aliases:e.chat?s=>e.chat.registerAliases?.(s):void 0,onCommitted:s=>{$.current=s},protocol:G,...K?{generationTicket:K}:{},...T?{generationStamped:!0}:{}});e.chat||(f("design_budget",{max_pairs:h.budget.max_pairs??null,strength:h.budget.strength_override??null}),e.out(`designing: ${h.usecase.logical_id??r}`)),e.chat?.setWorking?.(`designing ${h.usecase.logical_id??r}\u2026`);let D;try{D=await le(c,{...e,graphSlot:$,...p(e,$),...H?{checkpoint:H}:{}},new Map,n,f,J)}catch(s){throw f("error",{message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0},c.session_id),q(),s}finally{e.chat?.setWorking?.(null),a()}if(D.errorCode==="binding_mismatch"&&g){let s=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(s)?s.find(o=>o.id==="binding-mismatch"):void 0)?.selected_index!==0){let o=`resume abandoned: binding mismatch on session ${c.session_id} \u2014 the session is preserved`;return e.out(o),e.emit?.({type:"error",message:o,code:"BINDING_MISMATCH"}),i?.release(),2}f("binding_migrate",{sid:c.session_id},c.session_id);let l=c.resume&&"schema"in c.resume?{...c.resume,binding:{}}:void 0;try{D=await le({...c,...l?{resume:l}:{}},{...e,graphSlot:$,...p(e,$),...H?{checkpoint:H}:{}},new Map,n,f,J)}catch(o){throw f("error",{message:o instanceof Error?o.message:String(o),stack:o instanceof Error?o.stack:void 0},c.session_id),q(),o}finally{e.chat?.setWorking?.(null),a()}}if(D.highRisk)return e.out(`error: ${D.highRisk.length} high-risk decision${D.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",message:`error: high-risk question(s) in ci mode (fail-closed): ${D.highRisk.map(s=>s.id).join(", ")}`,code:"HIGH_RISK_CI"}),q(),P(),1;if(D.paused){let s=i;s||(s=re(e.contextDir,{sid:c.session_id,mode:"agent",created_at:F.toISOString(),expires_at:new Date(F.getTime()+1440*60*1e3).toISOString(),agent_state:D.paused.agent_state,pending:{questions:[],proposals:[]},read_basis:Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(o=>o.type==="DERIVES"&&typeof o.props.source_id=="string").map(o=>[String(o.props.source_id),n.heads.get(String(o.props.source_id))??null])),assumed:[],corpus_cursor:{remaining:[]},conv_source:R,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...k?{force:!0}:{},...v?{user_session_id:v.ids.session_id}:{}}));try{k&&!s.state.force&&s.save({force:!0}),v&&s.state.user_session_id!==v.ids.session_id&&s.save({user_session_id:v.ids.session_id}),R&&s.state.conv_source!==R&&s.save({conv_source:R});let o=e.chat?.drainHeldReceipts?.()??[];(o.length>0||(s.state.held_receipts?.length??0)>0)&&s.save({held_receipts:o}),b!==null&&s.save({force_scope:b}),Le(s,D.paused)}catch(o){let m=s.state.checkpoint,_=`error: couldn't persist the pause for session ${s.state.sid}`+(m?` \u2014 last durable checkpoint: seq ${m.seq} @ ${m.ts}`:" \u2014 no durable checkpoint exists")+` (${o instanceof Error?o.message:String(o)})`;return e.out(_),e.emit?.({type:"error",message:_,code:"PAUSE_PERSIST_FAILED",sid:s.state.sid}),1}f("session_paused",{sid:s.state.sid},c.session_id);let d=S!=="interactive"?` --mode ${S}`:"",l=`kane-cli design tests --resume ${s.state.sid}${d}`;if(O||e.out(`paused \u2014 resume with: ${l}`),e.emit?.({type:"session_paused",sid:s.state.sid,mode:S,resume:l,expires_at:s.state.expires_at,pending_questions:D.paused.pending.questions}),O){let o=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:"ctrl+c",facts:[`session ${s.state.sid} saved \u2014 designing ${h.usecase.logical_id??r}`,...s.state.expires_at?[`expires: ${s.state.expires_at}`]:[],...o!==void 0?[`credits used: ${o.toFixed(1)}`]:[]],resume:l,resumeMessage:`${l} --message "<your words>"`,tracePath:Z(u)})}return P(),3}if(D.crashed&&i?.state.checkpoint){let s=i.state.checkpoint,d=S!=="interactive"?` --mode ${S}`:"",l=`kane-cli design tests --resume ${i.state.sid}${d}`;if(f("agent_crashed_resumable",{sid:i.state.sid,seq:s.seq},c.session_id),O||e.out(`agent crashed \u2014 session ${i.state.sid} is resumable at checkpoint seq ${s.seq} (at most the in-flight turn lost); resume with: ${l}`),e.emit?.({type:"session_paused",sid:i.state.sid,mode:S,resume:l,expires_at:i.state.expires_at,crashed:!0}),O){let o=e.chat?.state.credits?.total;e.onSummary?.({state:"crashed",facts:[`agent crashed \u2014 session ${i.state.sid} is resumable at checkpoint seq ${s.seq}`,"at most the in-flight turn was lost",...o!==void 0?[`credits used: ${o.toFixed(1)}`]:[]],resume:l,resumeMessage:`${l} --message "<your words>"`,tracePath:Z(u)})}return i.release(),i=null,3}if(D.error)return e.out(`error: design agent failed: ${D.error}`),e.emit?.({type:"error",message:`error: design agent failed: ${D.error}`}),q(),P(),1;if(D.proposal==null&&S!=="interactive")return e.out(`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${u})`),e.emit?.({type:"error",message:`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${u})`}),q(),P(),1;let ee=0;if(D.proposal==null)try{let{readRecords:s}=await import("./records-IOZTZUZV.js"),d=t.resume??c.session_id;ee=s(e.contextDir).records.filter(l=>l.sid===d).reduce((l,o)=>l+o.nodes.filter(m=>m.label!=="source").length,0)}catch{}if(D.proposal==null&&e.out(ee>0?`done \u2014 ${ee} item(s) committed in this session (earlier legs included); nothing new since the resume`:"done \u2014 nothing designed this session (no finalize before the session ended)"),D.assumedDefaults&&e.out(`assumed: ${D.assumedDefaults} default(s) taken while unattended`),i&&e.emit?.({type:"session_complete",sid:t.resume??c.session_id}),v?.event("ASR_SESSION_COMPLETE",{}),i?.complete(),Y)try{dt(he(e.contextDir,"sessions"))}catch{}if(O){let s=e.chat.state.ledger.filter(o=>o.kind==="answer"&&o.receipt.form==="assumed").length??0,d=(D.assumedDefaults??0)+s,l=e.chat.state.credits?.total??D.creditsTotal;e.onSummary?.({state:"complete",facts:[`designed: ${h.usecase.logical_id??r}${D.proposal==null?ee>0?` (${ee} item(s) committed across this session)`:" (nothing committed this session)":""}`,...d>0?[`${d} assumed default(s)`]:[],...l!==void 0?[`credits used: ${l.toFixed(1)}`]:[]],tracePath:Z(u)})}return t.plan||He(e.contextDir),P(),0}export{Rs as a};
355
+ `)})}let y=null,$={current:n},V={detach:null},a=()=>{let s=V.detach;V.detach=null,s&&s()},p=(s,d)=>{let l=i;if(!l)return{};let o=s.ask,m=Be({contextDir:s.contextDir,cwd:mt(s.contextDir),handle:l,note:_=>s.chat?s.chat.note(_):s.out(_),graphSlot:d,...s.now?{now:s.now}:{}});if(s.chat?.attachIngest){let _=s.chat;V.detach=_.attachIngest(async C=>{try{l.save({ingest_registry:de(l.state.ingest_registry,C,s.now?.()??new Date)});let L=await m({id:`attach-${l.state.sid}-${(l.state.ingest_registry??[]).length}`,ref:C,purpose:null});return L.ok?(_.deferBatch({source_id:L.result.source_id,cid:L.result.cid}),{ok:!0}):{ok:!1,error:L.error.message}}catch(L){return{ok:!1,error:L instanceof Error?L.message:String(L)}}})}return{ask:async _=>{let C=await o(_);if(Array.isArray(C)){let L=C.filter(B=>{if(B.free_text==null||B.free_text.trim()==="")return!1;let ie=_.find(gt=>gt.id===B.id);return B.selected_index!=null&&ie?.options[B.selected_index]?.input===!0}).map(B=>B.free_text.trim());if(L.length>0){let B=l.state.ingest_registry;for(let ie of L)B=de(B,ie,s.now?.()??new Date);l.save({ingest_registry:B})}}return C},ingest:m}};e.nested||e.chat?.attachOnCommitted?.(s=>{$.current=s});let E="";if(e.chat&&!t.plan&&!e.nested){let s=Pe({contextDir:e.contextDir,graph:U(e.contextDir),sessionStamp:c.session_id,by:e.by??{kind:"human",id:"owner"}});s.errors===null||s.errors[0]?.code==="CONV_SOURCE_EXISTS"?(E=s.sourceId,e.chat.attachConversationSource?.(E),$.current=U(e.contextDir)):e.out(`warning: notes you add in chat can't be saved to the context this session (${s.errors[0]?.detail})`)}let R=U(e.contextDir),K;if(!t.plan){let s=Ce(R,r);if(T&&s!==null&&s.live){let d=R.resolve(r);K={uc_root:Re(R,d.cid),next_gen:s.gen,expected_prev_gen:s.gen}}else{let d=Te(R,r,{...k?{force:!0}:{},because:t.because??(k?"forced redesign (--force)":void 0)});if("error"in d)return e.out(`design: ${d.error.detail}`),e.emit?.({type:"gate_refused",message:d.error.detail,code:d.error.code}),i?.release(),2;K=d}}let A=xe(e.contextDir,c.session_id),F=null,O=()=>{try{F?.release()}catch{}};if(!t.plan)try{F=A.acquire([Se(R,r).key],{hold:"session",verb:"design"})}catch(s){if(s instanceof ke&&s.code==="UC_HELD"){let d=s.holder,l=`design: ${r} is being designed by another session${d?.alive===!1?` \u2014 that session looks stopped; resume it with kane-cli design tests --resume ${d?.owner_sid??"<session>"}`:""} \u2014 pick another use-case (kane-cli design tests) or wait for it to finish`;return e.out(l),e.emit?.({type:"error",code:"UC_HELD",message:l}),i?.release(),2}throw s}let G={contextDir:e.contextDir,rootSid:c.session_id,locks:A,probe:{batchSimilar:async()=>({hits:[],degraded:!1,probeBasis:null}),recheckLocal:()=>({hits:[],uncachedNewNodes:[]})}},W=!t.plan&&S!=="ci",Q=()=>Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(s=>s.type==="DERIVES"&&typeof s.props.source_id=="string").map(s=>[String(s.props.source_id),n.heads.get(String(s.props.source_id))??null])),Y=!1;W&&!i&&(Y=!0,i=re(e.contextDir,{sid:c.session_id,mode:"agent",created_at:M.toISOString(),expires_at:new Date(M.getTime()+1440*60*1e3).toISOString(),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},read_basis:Q(),assumed:[],corpus_cursor:{remaining:[]},conv_source:E,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...k?{force:!0}:{},...v?{user_session_id:v.ids.session_id}:{}}));let H;if(W&&i){let{resume:s,...d}=c;Ee(e.contextDir,c.session_id,{schema:$e,kind:"base",sid:c.session_id,verb:"design",mode:S,created_at:M.toISOString(),run_config:d,conv_source:E||i.state.conv_source||"",...r?{use_case:r}:{},...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},store_watermark:De(e.contextDir)}),c.checkpoints=!0,t.resume&&f("resume_kind",{kind:g?g.view.pointer===null?"bare-base":g.view.pointer.at==="final"?"pause":"crash":"v1-shim"},c.session_id);let l=g?0:i.state.checkpoint?.seq??0,o=i;H=Fe({contextDir:e.contextDir,handle:o,seqBase:()=>l,peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>Q(),corpusCursor:()=>({remaining:[]}),onSoftCap:_=>e.out(_),onStat:_=>f("ckpt_stat",_,c.session_id),...e.now?{now:e.now}:{}});let m=H;H={...m,persist:_=>{let C=_.binding?.template_version;return typeof C=="string"&&C&&(N.current=C),m.persist(_)}}}let q=()=>{if(!i)return;let s=i.state.checkpoint;if(s){let d=S!=="interactive"?` --mode ${S}`:"";e.out(`session ${i.state.sid} kept its last checkpoint (seq ${s.seq}, ${s.ts}) \u2014 resume with: kane-cli design tests --resume ${i.state.sid}${d}`),i.release()}else if(Y){try{i.complete()}catch{i.release()}try{dt(he(e.contextDir,"sessions"))}catch{}}else i.release();i=null},J=t.plan?Et(e.out,e.emit,f,u):ct({templateVersion:()=>N.current,contextDir:e.contextDir,ucRef:r,by:{kind:"ai",id:"design-agent"},force:k,engine:"design@1",note:s=>e.chat?e.chat.note(s):e.out(s),commitLine:s=>e.chat?e.chat.ledger({kind:"commit",ok:!0,line:s}):e.out(s),steer:e.chat?s=>e.chat.submit(s):void 0,event:e.emit,resuming:T,...i?.state.force_scope?.length?{forceScope:i.state.force_scope}:{},onForceScope:s=>{y=s},...t.because?{because:t.because}:{},aliases:e.chat?s=>e.chat.registerAliases?.(s):void 0,onCommitted:s=>{$.current=s},protocol:G,...K?{generationTicket:K}:{},...T?{generationStamped:!0}:{}});e.chat||(f("design_budget",{max_pairs:h.budget.max_pairs??null,strength:h.budget.strength_override??null}),e.out(`designing: ${h.usecase.logical_id??r}`)),e.chat?.setWorking?.(`designing ${h.usecase.logical_id??r}\u2026`);let D;try{D=await le(c,{...e,graphSlot:$,...p(e,$),...H?{checkpoint:H}:{}},new Map,n,f,J)}catch(s){throw f("error",{message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0},c.session_id),q(),s}finally{e.chat?.setWorking?.(null),a()}if(D.errorCode==="binding_mismatch"&&g){let s=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(s)?s.find(o=>o.id==="binding-mismatch"):void 0)?.selected_index!==0){let o=`resume abandoned: binding mismatch on session ${c.session_id} \u2014 the session is preserved`;return e.out(o),e.emit?.({type:"error",message:o,code:"BINDING_MISMATCH"}),i?.release(),2}f("binding_migrate",{sid:c.session_id},c.session_id);let l=c.resume&&"schema"in c.resume?{...c.resume,binding:{}}:void 0;try{D=await le({...c,...l?{resume:l}:{}},{...e,graphSlot:$,...p(e,$),...H?{checkpoint:H}:{}},new Map,n,f,J)}catch(o){throw f("error",{message:o instanceof Error?o.message:String(o),stack:o instanceof Error?o.stack:void 0},c.session_id),q(),o}finally{e.chat?.setWorking?.(null),a()}}if(D.highRisk)return e.out(`error: ${D.highRisk.length} high-risk decision${D.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",message:`error: high-risk question(s) in ci mode (fail-closed): ${D.highRisk.map(s=>s.id).join(", ")}`,code:"HIGH_RISK_CI"}),q(),O(),1;if(D.paused){let s=i;s||(s=re(e.contextDir,{sid:c.session_id,mode:"agent",created_at:M.toISOString(),expires_at:new Date(M.getTime()+1440*60*1e3).toISOString(),agent_state:D.paused.agent_state,pending:{questions:[],proposals:[]},read_basis:Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(o=>o.type==="DERIVES"&&typeof o.props.source_id=="string").map(o=>[String(o.props.source_id),n.heads.get(String(o.props.source_id))??null])),assumed:[],corpus_cursor:{remaining:[]},conv_source:E,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...k?{force:!0}:{},...v?{user_session_id:v.ids.session_id}:{}}));try{k&&!s.state.force&&s.save({force:!0}),v&&s.state.user_session_id!==v.ids.session_id&&s.save({user_session_id:v.ids.session_id}),E&&s.state.conv_source!==E&&s.save({conv_source:E});let o=e.chat?.drainHeldReceipts?.()??[];(o.length>0||(s.state.held_receipts?.length??0)>0)&&s.save({held_receipts:o}),y!==null&&s.save({force_scope:y}),je(s,D.paused)}catch(o){let m=s.state.checkpoint,_=`error: couldn't persist the pause for session ${s.state.sid}`+(m?` \u2014 last durable checkpoint: seq ${m.seq} @ ${m.ts}`:" \u2014 no durable checkpoint exists")+` (${o instanceof Error?o.message:String(o)})`;return e.out(_),e.emit?.({type:"error",message:_,code:"PAUSE_PERSIST_FAILED",sid:s.state.sid}),1}f("session_paused",{sid:s.state.sid},c.session_id);let d=S!=="interactive"?` --mode ${S}`:"",l=`kane-cli design tests --resume ${s.state.sid}${d}`;if(P||e.out(`paused \u2014 resume with: ${l}`),e.emit?.({type:"session_paused",sid:s.state.sid,mode:S,resume:l,expires_at:s.state.expires_at,pending_questions:D.paused.pending.questions}),P){let o=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:"ctrl+c",facts:[`session ${s.state.sid} saved \u2014 designing ${h.usecase.logical_id??r}`,...s.state.expires_at?[`expires: ${s.state.expires_at}`]:[],...o!==void 0?[`credits used: ${o.toFixed(1)}`]:[]],resume:l,resumeMessage:`${l} --message "<your words>"`,tracePath:Z(u)})}return O(),3}if(D.crashed&&i?.state.checkpoint){let s=i.state.checkpoint,d=S!=="interactive"?` --mode ${S}`:"",l=`kane-cli design tests --resume ${i.state.sid}${d}`;if(f("agent_crashed_resumable",{sid:i.state.sid,seq:s.seq},c.session_id),P||e.out(`agent crashed \u2014 session ${i.state.sid} is resumable at checkpoint seq ${s.seq} (at most the in-flight turn lost); resume with: ${l}`),e.emit?.({type:"session_paused",sid:i.state.sid,mode:S,resume:l,expires_at:i.state.expires_at,crashed:!0}),P){let o=e.chat?.state.credits?.total;e.onSummary?.({state:"crashed",facts:[`agent crashed \u2014 session ${i.state.sid} is resumable at checkpoint seq ${s.seq}`,"at most the in-flight turn was lost",...o!==void 0?[`credits used: ${o.toFixed(1)}`]:[]],resume:l,resumeMessage:`${l} --message "<your words>"`,tracePath:Z(u)})}return i.release(),i=null,3}if(D.error)return e.out(`error: design agent failed: ${D.error}`),e.emit?.({type:"error",message:`error: design agent failed: ${D.error}`}),q(),O(),1;if(D.proposal==null&&S!=="interactive")return e.out(`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${u})`),e.emit?.({type:"error",message:`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${u})`}),q(),O(),1;let ee=0;if(D.proposal==null)try{let{readRecords:s}=await import("./records-IOZTZUZV.js"),d=t.resume??c.session_id;ee=s(e.contextDir).records.filter(l=>l.sid===d).reduce((l,o)=>l+o.nodes.filter(m=>m.label!=="source").length,0)}catch{}if(D.proposal==null&&e.out(ee>0?`done \u2014 ${ee} item(s) committed in this session (earlier legs included); nothing new since the resume`:"done \u2014 nothing designed this session (no finalize before the session ended)"),D.assumedDefaults&&e.out(`assumed: ${D.assumedDefaults} default(s) taken while unattended`),i&&e.emit?.({type:"session_complete",sid:t.resume??c.session_id}),v?.event("ASR_SESSION_COMPLETE",{}),i?.complete(),Y)try{dt(he(e.contextDir,"sessions"))}catch{}if(P){let s=e.chat.state.ledger.filter(o=>o.kind==="answer"&&o.receipt.form==="assumed").length??0,d=(D.assumedDefaults??0)+s,l=e.chat.state.credits?.total??D.creditsTotal;e.onSummary?.({state:"complete",facts:[`designed: ${h.usecase.logical_id??r}${D.proposal==null?ee>0?` (${ee} item(s) committed across this session)`:" (nothing committed this session)":""}`,...d>0?[`${d} assumed default(s)`]:[],...l!==void 0?[`credits used: ${l.toFixed(1)}`]:[]],tracePath:Z(u)})}return t.plan||He(e.contextDir),O(),0}export{Es as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-5BVOF4UW.js";import{b as rn,c as sn}from"./chunk-6IA6QMPH.js";import{m as X,o as P}from"./chunk-56PAQAX5.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,reject:o}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let o=new Promise((c,g)=>{this.pendingReady={resolve:c,reject:g}});this.writeCommand(on(e)),await o}async*run(e,o,c){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,o,c));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
2
+ import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-AMULIFC5.js";import{b as rn,c as sn}from"./chunk-P7YZ3PU3.js";import{m as X,o as P}from"./chunk-56PAQAX5.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,reject:o}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let o=new Promise((c,g)=>{this.pendingReady={resolve:c,reject:g}});this.writeCommand(on(e)),await o}async*run(e,o,c){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,o,c));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
3
3
  `;try{this.proc?.child.stdin?.write(o)}catch{}}async consume(){if(!this.proc)return;try{for await(let c of this.proc.events){if(c.type==="ready"){this.onReady();continue}this.routeEvent(c)}}catch(c){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:c instanceof Error?c.message:String(c)})}let{code:e,signal:o}=await this.proc.exited;this.onExit(e,o)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}routeEvent(e){let o=this.activeRun;if(!o){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}o.queue.push(e)}onExit(e,o){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:o},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:o}),this.pendingReady){let{reject:c}=this.pendingReady;this.pendingReady=null,c(new Error(`v16-runner exited before ready (code=${e}, signal=${o??"none"})`))}if(this.activeRun){let{queue:c}=this.activeRun;if(this.activeRun=null,this.shuttingDown)c.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";c.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${o??"none"})${g?`
4
4
  ${g}`:""}`))}}}}};var p=Pn(jn(),1);function cn(i){let e={cdp_endpoint:i.cdp_endpoint,ws_endpoint:i.ws_endpoint,width:i.width,height:i.height,headless:i.headless,model:i.model,max_steps:i.max_steps,network_ws:i.network_ws,network_sse:i.network_sse,session_id:i.session_id};return i.device&&(e.device=i.device),i.auth&&(e.auth=i.auth),i.username&&(e.username=i.username),i.access_key&&(e.access_key=i.access_key),e}function j(i,e){let o=null,c=(g,w)=>{for(let v=0;v<g.length;v++){let b=g[v],h=[...w,v];e(b)&&(o===null||h.length>o.length)&&(o=h),b.children&&b.children.length>0&&c(b.children,h)}};return c(i,[]),o}function N(i,e,o){if(e.length===0)return[...i];let c=e[0],g=[...i],w=g[c];if(e.length===1)g[c]=o(w);else{let v=e.slice(1),b=N(w.children??[],v,o);g[c]={...w,children:b}}return g}function pn(){return{steps:[],maxOrdinal:0}}function Nn(i,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...i,resolution:e.environment.resolution}:i;if(e.type==="run_start"){let o=sn(i.runnerEnvironment,rn(e.environment));if(o)return{...i,runnerEnvironment:o,...o.resolution?{resolution:o.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let o={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...i,steps:[...i.steps,o],maxOrdinal:Math.max(i.maxOrdinal,e.ordinal)}}return i}function V(i){let e=i.indexOf(": ");return e>0&&e<15?i.slice(e+2):i}function W(i){return i.map(e=>{let o=e.children?W(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:o}:o!==e.children?{...e,children:o}:e})}function Gn(i,e,o,c,g){let[w,v]=(0,p.useState)(!1),[b,h]=(0,p.useState)([]),[hn,T]=(0,p.useState)(null),[fn,B]=(0,p.useState)(null),[mn,I]=(0,p.useState)(null),[vn,J]=(0,p.useState)(null),[gn,H]=(0,p.useState)([]),[Rn,K]=(0,p.useState)(null),[Sn,yn]=(0,p.useState)(void 0),[wn,$]=(0,p.useState)(0),y=(0,p.useRef)(null),E=(0,p.useRef)(null),S=(0,p.useRef)(null),_=(0,p.useRef)(0),F=(0,p.useRef)(!1),U=(0,p.useRef)(pn()),O=(0,p.useRef)(null),xn=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),I(null),J(null),H([]),K(null),yn(m.max_steps),v(!0),S.current=null,_.current=0,U.current=pn();let k=y.current;if(k&&E.current!==m.session_id){try{k.kill()}catch{}y.current=null,E.current=null,$(n=>n+1),k=null}if(!k){let n=Y();if(!n){I("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let d=en({environment:x?.environment,mode:x?.mode,assertionMode:x?.assertionMode,finalValidation:x?.finalValidation,username:m.username,accessKey:m.access_key,sessionId:m.session_id});m.device?.platform&&await nn(d,m.device);let u=new D({env:d,runner:n,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,k=u,X("runner",()=>{try{u.kill()}catch{}});let s=cn(m);try{await u.start(s)}catch(a){I(a instanceof Error?a.message:String(a)),v(!1),P("runner","Runner start failed"),y.current=null,E.current=null,$(t=>t+1);return}}let M={...m};delete M.run_id,tn(M,{environment:x?.environment});let kn=`run-${m.run_index}`,Cn=m.mode==="replay"?"replay":"author",L=k,q=(async()=>{F.current=!1;for await(let n of L.run(kn,Cn,M)){if(F.current)break;switch(U.current=Nn(U.current,n),n.type){case"run_start":if(n.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=_.current;_.current++,h(u=>u.map((s,a)=>a===d?{...s,status:"running"}:s.status==="running"&&!s.children?.some(t=>t.status==="running")?{...s,status:s.children?.some(t=>t.status==="failed")?"failed":"passed"}:s))}break;case"bifurcation":{let d=n.flows??[],u=n.count??d.length,s={flows:d,isSingleFlow:n.is_single_flow??u<=1};J(s),S.current=s,_.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let d=n.index,u=n.objective??`Step ${d}`,s=n.child_id,a=S.current&&!S.current.isSingleFlow;if(s)h(t=>{let r=j(t,l=>l.branchChildId===s)??j(t,l=>l.status==="running");return r?N(t,r,l=>{let f=(l.children??[]).map(R=>R.status==="running"&&R.childId===s?{...R,status:"stopped",phase:void 0}:R);return f.push({index:d,objective:u,status:"running",childId:s}),{...l,children:f}}):t});else if(a){let t=Math.max(0,_.current-1);h(r=>{let l=[...r];if(t>=l.length)return r;let f={...l[t]},C=[...f.children??[]].map(A=>A.status==="running"&&A.childId===void 0?{...A,status:"stopped",phase:void 0}:A);return C.push({index:d,objective:u,status:"running"}),f.children=C,f.status="running",l[t]=f,l})}else h(t=>{let r=W(t);return r.some(f=>f.index===d)?r.map(f=>f.index===d?{...f,status:"running",objective:u}:f):[...r,{index:d,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){H(s=>[...s,n.checkpoint_count]);break}if(n.event==="replay_started"){K({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&o?.(n.detail),d){let s=t=>{if(t.index!==n.index||t.childId!==d)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}},a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,_.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=[...r.children??[]];if(!l.some(R=>R.index===n.index&&R.childId===void 0))l.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<l.length;R++){if(l[R].index!==n.index||l[R].childId!==void 0)continue;let C={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(C.objective=n.detail),n.action_type&&(C.actionType=n.action_type),l[R]={...l[R],...C}}return r.children=l,t[s]=r,t})}else h(s=>s.some(t=>t.index===n.index)?s.map(t=>{if(t.index!==n.index)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}}):[...W(s),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),c?.();let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let s=t=>t.index===n.index&&t.childId===d?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?V(n.summary||t.objective):t.objective}:t,a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,_.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=(r.children??[]).map(f=>f.index===n.index&&f.childId===void 0?{...f,status:n.status,duration:n.duration,phase:void 0,objective:f.objective.startsWith("Step ")?V(n.summary||f.objective):f.objective}:f);return r.children=l,t[s]=r,t})}else h(s=>s.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?V(n.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,_.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;i?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let d=n.objective??"",u=n.child_id;h(s=>{let a=j(s,t=>t.status==="running");return a?N(s,a,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):s});break}case"child_agent_end":{let d=n.child_id,u=`child ${n.success?"done":"failed"}`;h(s=>{let a=j(s,t=>t.branchChildId===d);return a?N(s,a,t=>({...t,phase:u})):s.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":T(n.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),I(n.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(y.current!==L)return;let u=[n instanceof Error?n.message:String(n)],s=L.stderr;s&&!u.join(`
5
5
  `).includes(s)&&u.push(s),I(u.join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- var c={darwin:"macOS",linux:"Linux",win32:"Windows"};function _(n){return c[n]??n}function r(n){return typeof n!="string"?void 0:n.trim()||void 0}function u(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:void 0}function s(n){return n==="emulator"||n==="simulator"?n:void 0}function f(n){if(!n||typeof n!="object")return;let i=n,t=i.device&&typeof i.device=="object"?i.device:void 0,e=t?{...r(t.model)?{model:r(t.model)}:{},...r(t.manufacturer)?{manufacturer:r(t.manufacturer)}:{},...r(t.os_version)?{os_version:r(t.os_version)}:{},...u(t.pixel_ratio)!==void 0?{pixel_ratio:u(t.pixel_ratio)}:{},...r(t.automation)?{automation:r(t.automation)}:{},...r(t.device_instance_id)?{device_instance_id:r(t.device_instance_id)}:{},...s(t.target_kind)?{target_kind:s(t.target_kind)}:{}}:void 0,d=r(i.resolution),o=r(i.native_platform),a=e&&Object.keys(e).length>0;if(!(!d&&!o&&!a))return{...d?{resolution:d}:{},...o?{native_platform:o}:{},...a?{device:e}:{}}}function v(n,i){if(!n)return i;if(!i)return n;let t={...n.device??{},...i.device??{}};return{...n,...i,...Object.keys(t).length?{device:t}:{}}}function m(n){if(n.startsWith("android"))return"Android";if(n.startsWith("ios"))return"iOS"}function l(n,i){let t=f(i);if(!t)return n;let e={...n};if(t.resolution&&(t.native_platform||!e.resolution)&&(e.resolution=t.resolution),!t.native_platform)return e;e.native_platform=t.native_platform,delete e.browser,delete e.browser_version;let d=m(t.native_platform);d&&(e.os=d);let o=t.device;return o?.model&&(e.device=o.model),o?.manufacturer&&(e.manufacturer=o.manufacturer),o?.os_version&&(e.os_version=o.os_version),o?.pixel_ratio!==void 0&&(e.pixel_ratio=o.pixel_ratio),o?.automation&&(e.automation=o.automation),o?.device_instance_id&&(e.device_instance_id=o.device_instance_id),o?.target_kind&&(e.target_kind=o.target_kind),e}function p(n,i,t){let d=!!f(i)?.native_platform;return{model:n,platform:d?"Mobile":"Desktop",platform_type:d?"app":"web",...t?{run_kind:t}:{}}}function g(n,i){let t={},e=(d,o)=>{o!==void 0&&o!==""&&(t[d]=o)};return e("model",i.model),e("os",n.os),e("browser",n.browser),e("browser_version",n.browser_version),e("resolution",n.resolution),e("platform",i.platform),e("platform_type",i.platform_type),e("run_kind",i.run_kind),e("os_version",n.os_version),e("native_platform",n.native_platform),e("manufacturer",n.manufacturer),e("pixel_ratio",n.pixel_ratio),e("automation",n.automation),e("device_instance_id",n.device_instance_id),e("target_kind",n.target_kind),n.device!==void 0&&n.device!==""?t.device=n.device:i.platform_type&&i.platform_type!=="web"&&(t.device=null),t}export{_ as a,f as b,v as c,l as d,p as e,g as f};
2
+ var c={darwin:"macOS",linux:"Linux",win32:"Windows"};function _(n){return c[n]??n}function r(n){return typeof n!="string"?void 0:n.trim()||void 0}function u(n){return typeof n=="number"&&Number.isFinite(n)&&n>0?n:void 0}function s(n){return n==="emulator"||n==="simulator"?n:void 0}function f(n){if(!n||typeof n!="object")return;let i=n,t=i.device&&typeof i.device=="object"?i.device:void 0,e=t?{...r(t.model)?{model:r(t.model)}:{},...r(t.manufacturer)?{manufacturer:r(t.manufacturer)}:{},...r(t.os_version)?{os_version:r(t.os_version)}:{},...u(t.pixel_ratio)!==void 0?{pixel_ratio:u(t.pixel_ratio)}:{},...r(t.automation)?{automation:r(t.automation)}:{},...r(t.device_instance_id)?{device_instance_id:r(t.device_instance_id)}:{},...s(t.target_kind)?{target_kind:s(t.target_kind)}:{}}:void 0,d=r(i.resolution),o=r(i.native_platform),a=e&&Object.keys(e).length>0;if(!(!d&&!o&&!a))return{...d?{resolution:d}:{},...o?{native_platform:o}:{},...a?{device:e}:{}}}function v(n,i){if(!n)return i;if(!i)return n;let t={...n.device??{},...i.device??{}};return{...n,...i,...Object.keys(t).length?{device:t}:{}}}function m(n){if(n.startsWith("android"))return"Android";if(n.startsWith("ios"))return"iOS"}function l(n,i){let t=f(i);if(!t)return n;let e={...n};if(t.resolution&&(t.native_platform||!e.resolution)&&(e.resolution=t.resolution),!t.native_platform)return e;e.native_platform=t.native_platform,delete e.browser,delete e.browser_version;let d=m(t.native_platform);d&&(e.os=d);let o=t.device;return o?.model&&(e.device=o.model),o?.manufacturer&&(e.manufacturer=o.manufacturer),o?.os_version?e.os_version=o.os_version:delete e.os_version,o?.pixel_ratio!==void 0&&(e.pixel_ratio=o.pixel_ratio),o?.automation&&(e.automation=o.automation),o?.device_instance_id&&(e.device_instance_id=o.device_instance_id),o?.target_kind&&(e.target_kind=o.target_kind),e}function p(n,i,t){let d=!!f(i)?.native_platform;return{model:n,platform:d?"Mobile":"Desktop",platform_type:d?"app":"web",...t?{run_kind:t}:{}}}function g(n,i){let t={},e=(d,o)=>{o!==void 0&&o!==""&&(t[d]=o)};return e("model",i.model),e("os",n.os),e("browser",n.browser),e("browser_version",n.browser_version),e("resolution",n.resolution),e("viewport",n.viewport),e("platform",i.platform),e("platform_type",i.platform_type),e("run_kind",i.run_kind),e("os_version",n.os_version),e("native_platform",n.native_platform),e("manufacturer",n.manufacturer),e("pixel_ratio",n.pixel_ratio),e("automation",n.automation),e("device_instance_id",n.device_instance_id),e("target_kind",n.target_kind),n.device!==void 0&&n.device!==""?t.device=n.device:i.platform_type&&i.platform_type!=="web"&&(t.device=null),e("device_slug",n.device_slug),t}export{_ as a,f as b,v as c,l as d,p as e,g as f};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-CVCVBQP6.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-D6FYCAIA.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
2
+ import{a as c}from"./chunk-WLOGO44E.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{u as s,v as a}from"./chunk-CCUGKBIH.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- function l(r){let{isAgent:c,log:m}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{c&&process.stdout.write(JSON.stringify(t)+`
3
- `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-AT26LOSG.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:d}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await d()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-QVAJJRUW.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-33K2MMUW.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-KFJXZDUJ.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onRetryAttempt(t){p({type:"test_md_retry_attempt",...t})},onAgentEvent(t){p(t)}}}export{l as a};
2
+ function l(r){let{isAgent:m,log:d}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{m&&process.stdout.write(JSON.stringify(t)+`
3
+ `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-6BY3IUH5.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:c}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await c()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-Y7ITY2I7.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-SLM3OFS2.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-TAGYCFFO.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onAdaptiveHeal(t){p({type:"test_md_adaptive_heal",...t})},onAgentEvent(t){p(t)}}}export{l as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j}from"./chunk-CLGC7VEO.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{y as s}from"./chunk-D6FYCAIA.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function V(e){let t=X(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function Ae(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(o=>o.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
2
+ import{a as j}from"./chunk-CLGC7VEO.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{x as s}from"./chunk-CCUGKBIH.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function V(e){let t=X(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function Ae(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(o=>o.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{y as o}from"./chunk-D6FYCAIA.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
2
+ import{x as o}from"./chunk-CCUGKBIH.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as S}from"./chunk-NHOHQBIF.js";import{x as o}from"./chunk-CCUGKBIH.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(l=>l.kind==="replay").length,r=e.decisions.filter(l=>l.kind==="author").length,p=e.outcomes.filter(l=>l.status==="passed").length,d=e.outcomes.filter(l=>l.status==="failed").length,f=e.outcomes.filter(l=>l.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${r} author`,C=e.retryTriggered,_="yes \u2014 healed after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let l=e.uploadResult?.testcaseId;u=l?`\u2713 pushed (testcase=${l})`:"\u2713 pushed",h=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,r=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:d,skipped:f,replay_decisions:t,author_decisions:r},adaptive_heal:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),r=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&r.push({label:"adaptive heal",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),r.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),r.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),r.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:r})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let r=setTimeout(()=>t(),50);return()=>clearTimeout(r)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ve}from"./chunk-CJP7RX3E.js";import{a as Ye}from"./chunk-37ZWKLEN.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-SA2LQSYP.js";import{a as Ge}from"./chunk-UBTNWAKK.js";import{a as He}from"./chunk-CVCVBQP6.js";import{c as Le,y as u}from"./chunk-D6FYCAIA.js";import{a as re}from"./chunk-HCBYKLMW.js";import{a as h,b as f,h as Fe,i as Se,k as Ne}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var je=$(we(),1);import{readFileSync as ct,writeFileSync as ut,mkdirSync as ft}from"fs";import{dirname as dt,join as ze}from"path";var mt=ze(Le,"command-history.json"),Dt=ze(Le,"generate-history.json"),ht=200,De=class{entries;filePath;max;constructor(t=mt,e=ht){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&o.push(this.entries[s]);return o}_load(){if(this.filePath===null)return[];try{let t=ct(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{ft(dt(this.filePath),{recursive:!0}),ut(this.filePath,JSON.stringify(this.entries)+`
2
+ import{a as Ve}from"./chunk-6DTWVLSJ.js";import{a as Ye}from"./chunk-JRQKUQWL.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-ZIRMSWKS.js";import{a as Ge}from"./chunk-PB3GADUD.js";import{a as He}from"./chunk-WLOGO44E.js";import{b as Le,x as u}from"./chunk-CCUGKBIH.js";import{a as re}from"./chunk-HCBYKLMW.js";import{a as h,b as f,h as Fe,i as Se,k as Ne}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var je=$(we(),1);import{readFileSync as ct,writeFileSync as ut,mkdirSync as ft}from"fs";import{dirname as dt,join as ze}from"path";var mt=ze(Le,"command-history.json"),Dt=ze(Le,"generate-history.json"),ht=200,De=class{entries;filePath;max;constructor(t=mt,e=ht){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&o.push(this.entries[s]);return o}_load(){if(this.filePath===null)return[];try{let t=ct(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{ft(dt(this.filePath),{recursive:!0}),ut(this.filePath,JSON.stringify(this.entries)+`
3
3
  `)}catch{}}};function kt(n){let t=(0,je.useRef)(null);return t.current||(t.current=new De(n)),t.current}var D=$(we(),1);var ke=$(we(),1);var Z=$(re(),1);function Xe({history:n,onSelect:t,onClose:e}){let[o,s]=(0,ke.useState)(""),[l,m]=(0,ke.useState)(0),v=o?n.search(o).slice(0,8):[];return Se((b,d)=>{if(d.escape){e();return}if(d.return){v.length>0&&v[l]?t(v[l]):e();return}if(d.upArrow){m(S=>Math.max(0,S-1));return}if(d.downArrow){m(S=>Math.min(v.length-1,S+1));return}if(d.backspace||d.delete){s(S=>S.slice(0,-1)),m(0);return}b&&!d.ctrl&&!d.meta&&(s(S=>S+b),m(0))}),(0,Z.jsxs)(h,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,Z.jsx)(f,{color:u.muted,bold:!0,children:"reverse search"}),(0,Z.jsxs)(h,{gap:1,children:[(0,Z.jsx)(f,{color:u.dim,children:"search:"}),(0,Z.jsx)(f,{children:o}),(0,Z.jsx)(f,{color:u.orange,children:"\u2588"})]}),v.length>0&&(0,Z.jsx)(f,{children:" "}),v.map((b,d)=>(0,Z.jsx)(h,{marginLeft:2,children:(0,Z.jsxs)(f,{color:d===l?u.orange:u.dim,bold:d===l,children:[d===l?"\u25B8 ":" ",b]})},`${d}-${b}`))]})}var X=$(re(),1);function Je({commands:n,selectedIndex:t}){return n.length===0?null:(0,X.jsx)(h,{flexDirection:"column",marginBottom:0,children:n.map((e,o)=>{let s=o===t;return e.disabled?(0,X.jsxs)(h,{children:[(0,X.jsx)(f,{color:u.dim,children:s?"\u276F ":" "}),(0,X.jsxs)(f,{color:u.dim,children:["/",e.name]}),(0,X.jsxs)(f,{color:u.dim,children:[" ",e.disabledReason??e.description]})]},e.name):(0,X.jsxs)(h,{children:[(0,X.jsx)(f,{color:s?u.orange:u.dim,children:s?"\u276F ":" "}),(0,X.jsxs)(f,{color:s?u.orange:void 0,bold:s,children:["/",e.name]}),e.args&&(0,X.jsxs)(f,{color:u.dim,children:[" ",e.args]}),(0,X.jsxs)(f,{color:u.dim,children:[" ",e.description]})]},e.name)})})}var Ze=$(we(),1);var q=$(re(),1),et={scenario:"Scenarios",case:"Test Cases",file:"Files",artifact:"Artifact candidates",installed:"Installed on device"};function Qe(n){let t={scenario:0,case:0,file:0,artifact:0,installed:0};for(let e of n)t[e.kind]++;return["scenario","case","file","artifact","installed"].filter(e=>t[e]>0).map(e=>`${t[e]} ${et[e]}`).join(" \xB7 ")}var Pe=7;function tt({items:n,selectedIndex:t,accent:e=u.orange}){let o=n.length;if(o===0)return null;let s=Math.floor(Pe/2),l=o<=Pe?0:Math.max(0,Math.min(t-s,o-Pe)),m=Math.min(o,l+Pe),v=l,b=o-m;return(0,q.jsxs)(h,{flexDirection:"column",marginBottom:0,children:[v>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${v} above \u2014 ${Qe(n.slice(0,l))}`})}),n.slice(l,m).map((d,S)=>{let U=l+S,F=d.selectable!==!1,E=U===t&&F,R=S===0||n[U-1].kind!==d.kind;return(0,q.jsxs)(Ze.default.Fragment,{children:[R&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:et[d.kind]})}),(0,q.jsxs)(h,{children:[(0,q.jsx)(f,{color:E?e:u.dim,children:E?"\u276F ":" "}),(0,q.jsxs)(f,{color:E?e:F?void 0:u.dim,bold:E,children:[d.label,d.reason?` \u2014 ${d.reason}`:""]})]})]},`${d.kind}:${d.value}:${U}`)}),b>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${b} more \u2014 ${Qe(n.slice(m))}`})})]})}var Be=$(we(),1);var gt=27,pt=127,xt=11;function bt(n){return n>=64&&n<=126}function Tt(n,t){n===xt&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(n)})}function vt(n,t){n===pt&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function wt(n,t){let e=n.map(s=>String.fromCharCode(s)).join(""),o=/^\[1;([0-9]+)([A-D])$/.exec(e);if(o){let s=parseInt(o[1],10),l=o[2],m={raw:"\x1B"+e};if(s===2)m.shift=!0;else if(s===3)m.meta=!0;else if(s===5)m.ctrl=!0;else return;l==="A"?m.arrowUp=!0:l==="B"?m.arrowDown=!0:l==="C"?m.arrowRight=!0:l==="D"&&(m.arrowLeft=!0),t(m);return}if(e==="[H"||e==="[1~"||e==="[7~"){t({home:!0,raw:"\x1B"+e});return}if(e==="[F"||e==="[4~"||e==="[8~"){t({end:!0,raw:"\x1B"+e});return}if(e==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+e});return}if(e==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+e});return}}function St(n,t){n===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(n)}):n===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(n)})}function Et(){let n="IDLE",t=[];function e(){n="IDLE",t=[]}return{feed(o,s){for(let l of o)n==="IDLE"?l===gt?(n="ESC",t=[]):Tt(l,s):n==="ESC"?l===91?(n="CSI",t=[]):l===79?(n="SS3",t=[]):(vt(l,s),e()):n==="CSI"?(t.push(l),bt(l)&&(wt([91,...t],s),e())):n==="SS3"&&(St(l,s),e())},flushIdle(o){n==="ESC"&&t.length===0&&o({raw:"\x1B"}),e()}}}function nt(n,t={}){let e=(0,Be.useRef)(n);e.current=n;let{stdin:o}=Fe();(0,Be.useEffect)(()=>{if(t.isActive===!1||!o)return;let s=Et(),l=null,m=v=>{l&&(clearTimeout(l),l=null);let b=Buffer.isBuffer(v)?v:Buffer.from(v,"binary");s.feed(b,d=>e.current(d)),l=setTimeout(()=>{s.flushIdle(d=>e.current(d)),l=null},50)};return o.on("data",m),()=>{o.removeListener("data",m),l&&clearTimeout(l)}},[t.isActive,o])}var w=$(re(),1);function yt(n,t){let e=t-1;for(;e>=0&&n[e]!=="@"&&n[e]!==" "&&n[e]!==`
4
4
  `;)e--;return e<0||n[e]!=="@"||e>0&&n[e-1]!==" "&&n[e-1]!==`
5
5
  `?null:{at:e,query:n.slice(e+1,t).join("")}}function rt(n,t,e){for(let o=t+e;o>=0&&o<n.length;o+=e)if(n[o]?.selectable!==!1)return o;return t}function At(n){let t=n.findIndex(e=>e.selectable!==!1);return t===-1?0:t}var Oe=10;function Rt(n){return n.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as t}from"./chunk-CCUGKBIH.js";import{join as i}from"path";function e(n=t){return i(n,"plugins")}function g(n,r=t){return i(e(r),n)}function c(n,r,o=t){return i(g(n,o),r)}function f(n,r=t){return i(g(n,r),"current")}function x(n,r=t){return i(g(n,r),"config.json")}function l(n,r=t){return i(g(n,r),".jobs")}function s(n=t){return i(n,"bin")}function h(n=t){return i(s(n),"hyperexecute")}export{e as a,g as b,c,f as d,x as e,l as f,s as g,h};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as B,c as S,d as T}from"./chunk-TJZMYU2W.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-PQUMOFT5.js";import{x as n}from"./chunk-CCUGKBIH.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-C44QQJR4.js";import{a as L}from"./chunk-6YGTRKDT.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-ZNNRCUHH.js";import{y as s}from"./chunk-D6FYCAIA.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
2
+ import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-NHOHQBIF.js";import{x as s}from"./chunk-CCUGKBIH.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-LCU2P3CH.js";import{y as u}from"./chunk-D6FYCAIA.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
2
+ import{a as k}from"./chunk-PQUMOFT5.js";import{x as u}from"./chunk-CCUGKBIH.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
3
3
  `),e}var c=p(f(),1),S=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},d=(a,l,r)=>(a===0||!S(t[a-1]))&&(l+r>=t.length||!S(t[l+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),l=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||d(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(l==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(l==="*"||l==="_"){let r=t.indexOf(l,n+1);if(r!==-1&&r>n+1&&(l==="*"||d(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=l,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?u.dim:void 0,children:e.text},o))}function T(t){return t.split(`
4
4
  `).map(e=>{if(e.trim()==="")return{kind:"blank"};let o=e.match(/^\s*[-*+]\s+(.*)$/);if(o)return{kind:"bullet",segs:x(o[1])};let i=e.match(/^\s*(\d+)\.\s+(.*)$/);if(i)return{kind:"numbered",n:i[1],segs:x(i[2])};let d=e.match(/^#{1,6}\s+(.*)$/);return d?{kind:"heading",segs:x(d[1])}:{kind:"para",segs:x(e)}})}function R(t,e,o=""){switch(t.kind){case"blank":return(0,c.jsx)(s,{children:o||" "},e);case"heading":return(0,c.jsxs)(s,{bold:!0,children:[o,h(t.segs)]},e);case"bullet":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,"\u2022 ",h(t.segs)]})},e);case"numbered":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,`${t.n}. `,h(t.segs)]})},e);default:return(0,c.jsxs)(s,{children:[o,h(t.segs)]},e)}}function $({text:t,accent:e=u.generateAccent}){let o=T(B(t)),{stdout:i}=b(),d=i?.columns??80;return(0,c.jsxs)(m,{marginBottom:1,children:[(0,c.jsx)(m,{width:2,flexShrink:0,children:(0,c.jsx)(s,{color:e,children:"\u2503"})}),(0,c.jsx)(m,{flexDirection:"column",width:d-2,children:o.map((n,a)=>R(n,a))})]})}var g=p(f(),1),I=5;function C({thinking:t,expanded:e,thinkingDone:o,maxLines:i=I}){if(!e)return(0,g.jsxs)(m,{paddingX:1,children:[(0,g.jsx)(s,{color:u.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,g.jsx)(s,{color:u.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let d=t.split(`
5
5
  `),n=Math.max(0,d.length-i),a=n>0?d.slice(-i).join(`