clikcode 1.0.4 → 1.0.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.
- package/README.md +25 -14
- package/dist/chunk-23TDEBGZ.js +71 -0
- package/dist/chunk-25T3GVS7.js +425 -0
- package/dist/chunk-2BBELGHY.js +11 -0
- package/dist/chunk-2EOL5PZL.js +208 -0
- package/dist/chunk-2GAB36IE.js +26 -0
- package/dist/chunk-2OLS7V66.js +2440 -0
- package/dist/chunk-2QFO2URB.js +179 -0
- package/dist/chunk-2QWPQRSU.js +254 -0
- package/dist/chunk-2YPAPAR3.js +184 -0
- package/dist/chunk-2ZAG5372.js +33 -0
- package/dist/chunk-32IKAIZC.js +12507 -0
- package/dist/chunk-34AZEGYW.js +95 -0
- package/dist/chunk-34JQYQCA.js +175 -0
- package/dist/chunk-34ZISPAO.js +67 -0
- package/dist/chunk-3AAAARE6.js +46 -0
- package/dist/chunk-3AJ6Q3OY.js +510 -0
- package/dist/chunk-3B2CHX7M.js +884 -0
- package/dist/chunk-3BUFORRX.js +59 -0
- package/dist/chunk-3QLHYYFK.js +30 -0
- package/dist/chunk-3RXBMYKZ.js +140 -0
- package/dist/chunk-3TFNIJWS.js +52 -0
- package/dist/chunk-3W3IPDFP.js +119 -0
- package/dist/chunk-3WMS7SEE.js +417 -0
- package/dist/chunk-435ZNSZ3.js +23 -0
- package/dist/chunk-4AQ5NINV.js +39 -0
- package/dist/chunk-4GVEJ5FK.js +168 -0
- package/dist/chunk-4GXAO3UY.js +262 -0
- package/dist/chunk-4L2ZZM4Q.js +332 -0
- package/dist/chunk-4LPDG57B.js +17 -0
- package/dist/chunk-4NN3XQQT.js +223 -0
- package/dist/chunk-4QZEZME7.js +54 -0
- package/dist/chunk-4R6CSC3S.js +38 -0
- package/dist/chunk-4RHXTL3W.js +514 -0
- package/dist/chunk-4SJMPTVQ.js +18 -0
- package/dist/chunk-4VY7G6TX.js +114 -0
- package/dist/chunk-5642PBF7.js +124 -0
- package/dist/chunk-5B6TVO4A.js +33 -0
- package/dist/chunk-5BJLDUPL.js +62 -0
- package/dist/chunk-5HMFFJWU.js +19 -0
- package/dist/chunk-5IKLK33T.js +69 -0
- package/dist/chunk-5NQ5FFMX.js +44 -0
- package/dist/chunk-5QNNW5L6.js +176 -0
- package/dist/chunk-5SM5UAWN.js +239 -0
- package/dist/chunk-5WYJTA6O.js +74 -0
- package/dist/chunk-5ZSR2Y5T.js +227 -0
- package/dist/chunk-5ZWUM5GH.js +39 -0
- package/dist/chunk-64E7D4HY.js +364 -0
- package/dist/chunk-6CK466BC.js +99 -0
- package/dist/chunk-6ES45HHO.js +138 -0
- package/dist/chunk-6HYEZFGL.js +277 -0
- package/dist/chunk-6Y7HLXGW.js +29 -0
- package/dist/chunk-6YKK4FYR.js +258 -0
- package/dist/chunk-74WNMLMS.js +117 -0
- package/dist/chunk-7AULZ7OD.js +55 -0
- package/dist/chunk-7DOKGSUN.js +101 -0
- package/dist/chunk-7IH5LTIZ.js +195 -0
- package/dist/chunk-7ISTS5NS.js +21 -0
- package/dist/chunk-7NMUTGOW.js +527 -0
- package/dist/chunk-7PNHUZEL.js +153 -0
- package/dist/chunk-7TSQLONI.js +88 -0
- package/dist/chunk-AE7TOLD5.js +30 -0
- package/dist/chunk-AEMHSXKA.js +130 -0
- package/dist/chunk-AKRYTS2D.js +211 -0
- package/dist/chunk-AMNSE36L.js +59 -0
- package/dist/chunk-AZVD74ZV.js +23 -0
- package/dist/chunk-B35DVOTK.js +1981 -0
- package/dist/chunk-B4HNJRAH.js +626 -0
- package/dist/chunk-B5WYPPHS.js +13 -0
- package/dist/chunk-BBOVDXQM.js +59 -0
- package/dist/chunk-BD3ECZLK.js +62 -0
- package/dist/chunk-BDGSOT74.js +4578 -0
- package/dist/chunk-BF5VEOPK.js +31 -0
- package/dist/chunk-BFFRW4XH.js +47 -0
- package/dist/chunk-BFPC6PEW.js +208 -0
- package/dist/chunk-BGEMY2JJ.js +376 -0
- package/dist/chunk-BISGNHKD.js +35 -0
- package/dist/chunk-BMRAEBRY.js +21 -0
- package/dist/chunk-BNTXAZXW.js +127 -0
- package/dist/chunk-BOQBXGSN.js +75 -0
- package/dist/chunk-BTJDSTQP.js +213 -0
- package/dist/chunk-BUOPJQP5.js +218 -0
- package/dist/chunk-BXFJS65Q.js +52 -0
- package/dist/chunk-BXPQFSX5.js +59 -0
- package/dist/chunk-C57LIWNY.js +1269 -0
- package/dist/chunk-C6YVCCWR.js +74 -0
- package/dist/chunk-CAADDF6M.js +167 -0
- package/dist/chunk-CBANJFBO.js +69 -0
- package/dist/chunk-CERF3RIB.js +597 -0
- package/dist/chunk-COAS5ETR.js +46 -0
- package/dist/chunk-CQ7J6UQ7.js +78 -0
- package/dist/chunk-CRUVYGO2.js +26 -0
- package/dist/chunk-CVFVFRGN.js +58 -0
- package/dist/chunk-D2UK66HM.js +37 -0
- package/dist/chunk-D2W7SA4R.js +18 -0
- package/dist/chunk-DA44ZENT.js +501 -0
- package/dist/chunk-DAJ76TOC.js +99 -0
- package/dist/chunk-DCZ6CIUM.js +147 -0
- package/dist/chunk-DF35KMXM.js +1314 -0
- package/dist/chunk-DGASQT26.js +151 -0
- package/dist/chunk-DJT57C5P.js +55 -0
- package/dist/chunk-DKDPZTD3.js +44 -0
- package/dist/chunk-DQYVQ2N7.js +77 -0
- package/dist/chunk-DRTP2RTY.js +266 -0
- package/dist/chunk-DW2BMUKY.js +61 -0
- package/dist/chunk-DW5T5ZVU.js +307 -0
- package/dist/chunk-DXKNDNFC.js +164 -0
- package/dist/chunk-DZEQ7UYR.js +291 -0
- package/dist/chunk-E4F4OUAC.js +463 -0
- package/dist/chunk-EE4B6A7W.js +69 -0
- package/dist/chunk-EISKIYWG.js +23 -0
- package/dist/chunk-EKAQK7UQ.js +235 -0
- package/dist/chunk-EOBTJV32.js +123 -0
- package/dist/chunk-ESF3DIZY.js +325 -0
- package/dist/chunk-EVOHOZ4U.js +45 -0
- package/dist/chunk-EXN4KHLB.js +110 -0
- package/dist/chunk-F252T6Y3.js +78 -0
- package/dist/chunk-F3DP4ZA2.js +40 -0
- package/dist/chunk-F6F47QAY.js +58 -0
- package/dist/chunk-FA3Y23ZW.js +57 -0
- package/dist/chunk-FBKXE4EJ.js +640 -0
- package/dist/chunk-FCGEB3H6.js +23 -0
- package/dist/chunk-FF7ZVYJF.js +3732 -0
- package/dist/chunk-FFGKN6L3.js +39 -0
- package/dist/chunk-FFGU4GCC.js +94 -0
- package/dist/chunk-FSFDAOVP.js +74 -0
- package/dist/chunk-FT5TX7OX.js +1573 -0
- package/dist/chunk-G3QP67Z7.js +232 -0
- package/dist/chunk-G5ORJKV2.js +179 -0
- package/dist/chunk-GFNC62PE.js +111 -0
- package/dist/chunk-GGK43Q3N.js +67 -0
- package/dist/chunk-GGYKY4GF.js +11537 -0
- package/dist/chunk-GGYNHGNJ.js +55 -0
- package/dist/chunk-GLY7RM3C.js +354 -0
- package/dist/chunk-GQBZU6EO.js +20 -0
- package/dist/chunk-GSXENUZL.js +9 -0
- package/dist/chunk-GTOAT5D3.js +40 -0
- package/dist/chunk-GWCMDPQU.js +1007 -0
- package/dist/chunk-GXYSMYHJ.js +152 -0
- package/dist/chunk-GYMAI5NY.js +14 -0
- package/dist/chunk-H2VZMKPE.js +30 -0
- package/dist/chunk-H4THUNBM.js +2091 -0
- package/dist/chunk-HGRVSNUZ.js +361 -0
- package/dist/chunk-HI4VY473.js +27 -0
- package/dist/chunk-HOJRSD3Q.js +447 -0
- package/dist/chunk-HRX25W35.js +82 -0
- package/dist/chunk-HSE4AQYV.js +55 -0
- package/dist/chunk-HU5SSUFX.js +383 -0
- package/dist/chunk-I3GDBJLH.js +196 -0
- package/dist/chunk-I75EDU75.js +684 -0
- package/dist/chunk-IBA7DMIO.js +20 -0
- package/dist/chunk-IC6N4NZA.js +231 -0
- package/dist/chunk-IF43HIGV.js +284 -0
- package/dist/chunk-IGZ6C2MC.js +439 -0
- package/dist/chunk-IMLTL2MY.js +192 -0
- package/dist/chunk-IMZL6SGR.js +33 -0
- package/dist/chunk-IS4USJPY.js +516 -0
- package/dist/chunk-ISFSPN2F.js +82 -0
- package/dist/chunk-IXE7GTFI.js +55 -0
- package/dist/chunk-IZ77QJQG.js +36 -0
- package/dist/chunk-J2PACWRQ.js +34 -0
- package/dist/chunk-J6EGFVQX.js +180 -0
- package/dist/chunk-JEKOD43D.js +22 -0
- package/dist/chunk-JGIWATSG.js +30 -0
- package/dist/chunk-JYBONKD4.js +43 -0
- package/dist/chunk-K2NLG2HK.js +454 -0
- package/dist/chunk-KCQ4TBLS.js +164 -0
- package/dist/chunk-KD5KIVMS.js +176 -0
- package/dist/chunk-KHW6TX6I.js +63 -0
- package/dist/chunk-KI5GZFCE.js +520 -0
- package/dist/chunk-KN34B7NO.js +105 -0
- package/dist/chunk-KYUHIFP3.js +136 -0
- package/dist/chunk-KZL5VS4B.js +300 -0
- package/dist/chunk-L3VW3QIH.js +48 -0
- package/dist/chunk-LA6MG4ET.js +2110 -0
- package/dist/chunk-LAVFOA3S.js +66 -0
- package/dist/chunk-LB4OA77N.js +13 -0
- package/dist/chunk-LBFRF2K4.js +196 -0
- package/dist/chunk-LM6EIA4B.js +93 -0
- package/dist/chunk-LPCNRGJ7.js +692 -0
- package/dist/chunk-LSLNL5T3.js +168 -0
- package/dist/chunk-LVRRWP4W.js +568 -0
- package/dist/chunk-LWCFBRHL.js +33 -0
- package/dist/chunk-LXFTMGZZ.js +166 -0
- package/dist/chunk-M33LVA4M.js +151 -0
- package/dist/chunk-M3FO5UMK.js +4944 -0
- package/dist/chunk-M5QNDBAY.js +66 -0
- package/dist/chunk-M6ND6KBE.js +1291 -0
- package/dist/chunk-M7H3WQTE.js +76 -0
- package/dist/chunk-MCBRVPA7.js +191 -0
- package/dist/chunk-MCSDWZET.js +91 -0
- package/dist/chunk-MDT5XDXL.js +289 -0
- package/dist/chunk-MJG3IQY4.js +91 -0
- package/dist/chunk-MOU3N2UL.js +44 -0
- package/dist/chunk-MP4KZOQC.js +3451 -0
- package/dist/chunk-MPAJ446F.js +66 -0
- package/dist/chunk-MVJZZ6AL.js +16 -0
- package/dist/chunk-MXS6S2PY.js +253 -0
- package/dist/chunk-N3SFDYM7.js +291 -0
- package/dist/chunk-NAOX3JUB.js +13 -0
- package/dist/chunk-NEKKIBCX.js +283 -0
- package/dist/chunk-NKDATMEM.js +133 -0
- package/dist/chunk-NR4FMC4K.js +395 -0
- package/dist/chunk-NSOHOJBR.js +221 -0
- package/dist/chunk-NTDB6QKF.js +29 -0
- package/dist/chunk-NWEYRBWK.js +25 -0
- package/dist/chunk-O2YSNYWD.js +23 -0
- package/dist/chunk-O3EW7LAY.js +54 -0
- package/dist/chunk-O7BNJIXU.js +366 -0
- package/dist/chunk-OARL2NXZ.js +116 -0
- package/dist/chunk-OHKZUEJW.js +351 -0
- package/dist/chunk-OKU45BXA.js +647 -0
- package/dist/chunk-OL4JBD3J.js +59 -0
- package/dist/chunk-OLUO5DDR.js +192 -0
- package/dist/chunk-OQ245JLA.js +196 -0
- package/dist/chunk-P72UZAQI.js +289 -0
- package/dist/chunk-PAL2ENB6.js +20 -0
- package/dist/chunk-PAXYQZH7.js +53 -0
- package/dist/chunk-PDPEM5VW.js +51 -0
- package/dist/chunk-PEWCDI2C.js +668 -0
- package/dist/chunk-PGZ54EDX.js +27 -0
- package/dist/chunk-PRWVLDZF.js +73 -0
- package/dist/chunk-PSQQ75VJ.js +52 -0
- package/dist/chunk-PUOVIFHW.js +118 -0
- package/dist/chunk-PWBF2X3V.js +107 -0
- package/dist/chunk-PWXII6HF.js +43 -0
- package/dist/chunk-Q35VLJRT.js +80 -0
- package/dist/chunk-QJP7EYGL.js +128 -0
- package/dist/chunk-QPQKX2MK.js +8836 -0
- package/dist/chunk-QQRLPY25.js +1053 -0
- package/dist/chunk-QUS4ER2W.js +407 -0
- package/dist/chunk-QYHI3YET.js +29 -0
- package/dist/chunk-QYRU2UQI.js +32 -0
- package/dist/chunk-R6XVVQGC.js +13 -0
- package/dist/chunk-R7QN6ONS.js +483 -0
- package/dist/chunk-RD23MPGC.js +221 -0
- package/dist/chunk-RDDWQBEM.js +185 -0
- package/dist/chunk-RDLLDYFO.js +104 -0
- package/dist/chunk-RE4TGORR.js +84 -0
- package/dist/chunk-RJLHVYQY.js +217 -0
- package/dist/chunk-RJLPTWHW.js +905 -0
- package/dist/chunk-RKUVLRZI.js +295 -0
- package/dist/chunk-ROGXPGYR.js +37 -0
- package/dist/chunk-RSZGEL5U.js +163 -0
- package/dist/chunk-RVUOIJXN.js +909 -0
- package/dist/chunk-RW7F4JRP.js +11 -0
- package/dist/chunk-S4UO3AO3.js +53 -0
- package/dist/chunk-S5JAAF6S.js +585 -0
- package/dist/chunk-SNU37TQI.js +56 -0
- package/dist/chunk-SQVUDO2O.js +31 -0
- package/dist/chunk-SYVHIYQT.js +66 -0
- package/dist/chunk-SZBQMTG2.js +85 -0
- package/dist/chunk-T5VCXA3J.js +25 -0
- package/dist/chunk-TK6NSP56.js +30 -0
- package/dist/chunk-TKWVMA6L.js +22 -0
- package/dist/chunk-TQDKJHWX.js +59 -0
- package/dist/chunk-TQDM7S5N.js +127 -0
- package/dist/chunk-TULAXS77.js +23 -0
- package/dist/chunk-TVT45XNH.js +4625 -0
- package/dist/chunk-TWCVV2JO.js +467 -0
- package/dist/chunk-U4DKAD6S.js +47 -0
- package/dist/chunk-UA5K2BTI.js +564 -0
- package/dist/chunk-UAMKCMOK.js +40 -0
- package/dist/chunk-UBMVADBF.js +51 -0
- package/dist/chunk-UFQ5A5PW.js +645 -0
- package/dist/chunk-UOD2SOLL.js +1301 -0
- package/dist/chunk-UTSB4LOW.js +156 -0
- package/dist/chunk-UVXNIUTN.js +412 -0
- package/dist/chunk-UXVPXYPE.js +90 -0
- package/dist/chunk-UYEEMIWR.js +374 -0
- package/dist/chunk-VBGM5ZBW.js +54 -0
- package/dist/chunk-VEWPCZPG.js +762 -0
- package/dist/chunk-VIRDLZ5E.js +108 -0
- package/dist/chunk-VMPO7WKN.js +52 -0
- package/dist/chunk-W2NVSDO5.js +5122 -0
- package/dist/chunk-W3YYPBEA.js +176 -0
- package/dist/chunk-W5AYOICN.js +280 -0
- package/dist/chunk-W5GZOIUF.js +27 -0
- package/dist/chunk-WHKNLZ3C.js +76 -0
- package/dist/chunk-WKBEPPQ5.js +1409 -0
- package/dist/chunk-WM3Z6QKQ.js +151 -0
- package/dist/chunk-WMI2TPMA.js +31 -0
- package/dist/chunk-WNX5VD7S.js +150 -0
- package/dist/chunk-WOVTYST3.js +60 -0
- package/dist/chunk-WPB5WEZJ.js +546 -0
- package/dist/chunk-WUO5EOAT.js +44 -0
- package/dist/chunk-WWLJMP6D.js +133 -0
- package/dist/chunk-WZMLH3XP.js +58 -0
- package/dist/chunk-WZYVLUVQ.js +79 -0
- package/dist/chunk-X2OCPVU5.js +135 -0
- package/dist/chunk-X3CL6DTR.js +95 -0
- package/dist/chunk-X6WF7JEV.js +354 -0
- package/dist/chunk-XAHGBPWT.js +44 -0
- package/dist/chunk-XCKQ5BM2.js +228 -0
- package/dist/chunk-XIBYREEY.js +106 -0
- package/dist/chunk-XKW5NDMR.js +378 -0
- package/dist/chunk-XRDALAO3.js +100 -0
- package/dist/chunk-XUP22EAS.js +41 -0
- package/dist/chunk-XWAC3MKW.js +243 -0
- package/dist/chunk-Y3R7JMXB.js +59 -0
- package/dist/chunk-Y54LTP4W.js +82 -0
- package/dist/chunk-Y7UECI4M.js +99 -0
- package/dist/chunk-YACGDFHC.js +47 -0
- package/dist/chunk-YHNIQPKY.js +71 -0
- package/dist/chunk-YMBR6HYP.js +111 -0
- package/dist/chunk-YMCH3L2S.js +26 -0
- package/dist/chunk-Z4ZU6T7V.js +99 -0
- package/dist/chunk-ZDPF67ZZ.js +173 -0
- package/dist/chunk-ZFC2Q67K.js +101 -0
- package/dist/chunk-ZGHNNSCT.js +114 -0
- package/dist/chunk-ZGX3ERAT.js +173 -0
- package/dist/chunk-ZI3YHEBY.js +37 -0
- package/dist/chunk-ZN7G6JLS.js +639 -0
- package/dist/chunk-ZNPFQMXT.js +47 -0
- package/dist/chunk-ZOU3LV4U.js +63 -0
- package/dist/chunk-ZT7B4H2V.js +117 -0
- package/dist/chunk-ZZCBDNZI.js +58 -0
- package/dist/cli.js +494 -112923
- package/dist/computer-tools.js +36642 -21259
- package/dist/harness-catalog.cjs +88 -43
- package/dist/index.js +1 -1
- package/dist/local-model-supervisor.cjs +555 -0
- package/package.json +3 -4
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
sanitizeTerminalText
|
|
5
|
+
} from "./chunk-4QZEZME7.js";
|
|
6
|
+
|
|
7
|
+
// src/tui/inline.ts
|
|
8
|
+
function inlineHistoryMode(env = process.env) {
|
|
9
|
+
if (env.CLIKDEPLOY_CLIENT === "mobile") return false;
|
|
10
|
+
return env.CLIKCODE_INLINE === "1";
|
|
11
|
+
}
|
|
12
|
+
function swallowsAlternateScreen(env = process.env) {
|
|
13
|
+
return Boolean(env.STY) && !env.TMUX;
|
|
14
|
+
}
|
|
15
|
+
var CLEAR_SCREEN_AND_SCROLLBACK = "\x1B[2J\x1B[3J\x1B[H";
|
|
16
|
+
var CLEAR_SCREEN = "\x1B[H\x1B[K\x1B[2;1H\x1B[J\x1B[H";
|
|
17
|
+
var inlineBlock = {
|
|
18
|
+
rows: 0,
|
|
19
|
+
cursorRow: 0,
|
|
20
|
+
clearNext: false,
|
|
21
|
+
last: "",
|
|
22
|
+
liveRows: [],
|
|
23
|
+
columns: 0,
|
|
24
|
+
/** The blank rows above the conversation (a conversation shorter than the screen, drawn on the last rows at the start) that
|
|
25
|
+
* retired rows have not yet used. Only true while the block ends on the last row: a resize or a shrinking block zeroes it. */
|
|
26
|
+
pad: 0,
|
|
27
|
+
/** The screen row the block's first row is on: measured after a change of height, otherwise followed from where it was drawn. */
|
|
28
|
+
top: 0,
|
|
29
|
+
/** The screen height the block was last drawn for. */
|
|
30
|
+
height: 0,
|
|
31
|
+
/** After a settled change of height, the screen row the block's first row is on, from the terminal's cursor report
|
|
32
|
+
* (negative: its top rows went into the saved lines); undefined when nothing was asked. The next frame consumes it.
|
|
33
|
+
* `measuring` holds frames back while the question is out. */
|
|
34
|
+
found: void 0,
|
|
35
|
+
measuring: false,
|
|
36
|
+
/** The cursor report never came back after a change of height: the block is erased and drawn again relative to where
|
|
37
|
+
* it was last left (see anchorBlock). */
|
|
38
|
+
lost: false,
|
|
39
|
+
/** A modal surface (the board, the palette, a picker) is on screen: it is drawn on the ALTERNATE screen (`?1049h`), from its
|
|
40
|
+
* top row, so no saved lines exist behind it in any client and the main screen (the conversation and its live block) is not
|
|
41
|
+
* touched; closing it (`?1049l`) shows that screen again as it was. `main` is the block's state on the main screen, kept while
|
|
42
|
+
* the page is up and put back when it closes. `tail` is every row the conversation retired meanwhile: written above the block
|
|
43
|
+
* once the page is gone. `resized`: the size changed while it was up, so the main screen is measured again on close.
|
|
44
|
+
* `wipe`: the conversation was rewritten (a new width) while it was up, so the main screen is cleared and it is written whole. */
|
|
45
|
+
page: false,
|
|
46
|
+
tail: [],
|
|
47
|
+
resized: false,
|
|
48
|
+
wipe: false,
|
|
49
|
+
main: void 0
|
|
50
|
+
};
|
|
51
|
+
var ENTER_PAGE_SCREEN = `\x1B[?1049h${CLEAR_SCREEN}`;
|
|
52
|
+
var LEAVE_PAGE_SCREEN = "\x1B[?1049l";
|
|
53
|
+
function restoreMainBlock() {
|
|
54
|
+
const main = inlineBlock.main;
|
|
55
|
+
inlineBlock.main = void 0;
|
|
56
|
+
inlineBlock.page = false;
|
|
57
|
+
if (main) Object.assign(inlineBlock, main, { found: void 0, lost: false });
|
|
58
|
+
}
|
|
59
|
+
function eraseInlineBlock() {
|
|
60
|
+
const out = inlineBlock.rows ? `${inlineBlock.cursorRow > 0 ? `\x1B[${inlineBlock.cursorRow}A` : ""}\r\x1B[J` : "";
|
|
61
|
+
inlineBlock.rows = 0;
|
|
62
|
+
inlineBlock.cursorRow = 0;
|
|
63
|
+
inlineBlock.last = "";
|
|
64
|
+
inlineBlock.liveRows = [];
|
|
65
|
+
inlineBlock.pad = 0;
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/tui/voice-reply.ts
|
|
70
|
+
import { stdout } from "node:process";
|
|
71
|
+
var writesVoiceReply = (env = process.env) => env.CLIKDEPLOY_CLIENT === "mobile";
|
|
72
|
+
var osc = (body) => `\x1B]7702;${body}\x1B\\`;
|
|
73
|
+
var voicePresence = (here, env = process.env) => writesVoiceReply(env) ? osc(here ? "h" : "q") : "";
|
|
74
|
+
var VoiceReply = class {
|
|
75
|
+
constructor(write = (sequence) => void stdout.write(sequence), on = writesVoiceReply()) {
|
|
76
|
+
this.write = write;
|
|
77
|
+
this.on = on;
|
|
78
|
+
}
|
|
79
|
+
write;
|
|
80
|
+
on;
|
|
81
|
+
open = false;
|
|
82
|
+
sent = "";
|
|
83
|
+
start() {
|
|
84
|
+
if (!this.on) return;
|
|
85
|
+
this.open = true;
|
|
86
|
+
this.sent = "";
|
|
87
|
+
this.write(osc("s"));
|
|
88
|
+
}
|
|
89
|
+
/** The answer so far, whole. */
|
|
90
|
+
answer(text) {
|
|
91
|
+
if (!this.on || !this.open || text.length <= this.sent.length) return;
|
|
92
|
+
const grows = text.startsWith(this.sent);
|
|
93
|
+
const piece = grows ? text.slice(this.sent.length) : "";
|
|
94
|
+
this.sent = text;
|
|
95
|
+
if (piece) this.write(osc(`d;${Buffer.from(piece, "utf8").toString("base64")}`));
|
|
96
|
+
}
|
|
97
|
+
end(stopped) {
|
|
98
|
+
if (!this.on || !this.open) return;
|
|
99
|
+
this.open = false;
|
|
100
|
+
this.write(osc(stopped ? "x" : "e"));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/tui/restore.ts
|
|
105
|
+
import { writeSync } from "node:fs";
|
|
106
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
107
|
+
|
|
108
|
+
// src/tui/keys.ts
|
|
109
|
+
function environmentFlag(...values) {
|
|
110
|
+
return values.some((value) => {
|
|
111
|
+
const normalized = (value ?? "").trim().toLowerCase();
|
|
112
|
+
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
var PASTE_START = "\x1B[200~";
|
|
116
|
+
var PASTE_END = "\x1B[201~";
|
|
117
|
+
function pastedText(key) {
|
|
118
|
+
return key.startsWith(PASTE_START) && key.endsWith(PASTE_END) ? sanitizeTerminalText(key.slice(PASTE_START.length, key.length - PASTE_END.length), { keepTabs: true }) : void 0;
|
|
119
|
+
}
|
|
120
|
+
var PUSH_KITTY_KEYBOARD = "\x1B[>1u";
|
|
121
|
+
var POP_KITTY_KEYBOARD = "\x1B[<u";
|
|
122
|
+
var NEWLINE_KEY = "\x1B\r";
|
|
123
|
+
function kittyKeyboardSafe(environment = process.env) {
|
|
124
|
+
if (environmentFlag(environment.CLIKCODE_NO_KITTY_KEYBOARD)) return false;
|
|
125
|
+
if (environment.TMUX || environment.STY || /^(?:screen|tmux)/.test(environment.TERM ?? "")) return false;
|
|
126
|
+
const program = (environment.TERM_PROGRAM ?? "").toLowerCase();
|
|
127
|
+
return Boolean(environment.KITTY_WINDOW_ID || environment.GHOSTTY_RESOURCES_DIR || environment.WEZTERM_PANE || /^(?:xterm-kitty|xterm-ghostty|foot|alacritty|wezterm)/.test(environment.TERM ?? "") || program === "wezterm" || program === "ghostty" || program === "kitty");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/tui/terminal-signals.ts
|
|
131
|
+
var PUSH_TITLE = "\x1B[22;0t";
|
|
132
|
+
var POP_TITLE = "\x1B[23;0t";
|
|
133
|
+
var FOCUS_REPORTING_ON = "\x1B[?1004h";
|
|
134
|
+
var FOCUS_REPORTING_OFF = "\x1B[?1004l";
|
|
135
|
+
var NOTIFY_AFTER_UNFOCUSED_MS = 3e3;
|
|
136
|
+
function oscText(text, limit) {
|
|
137
|
+
const clean = text.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
138
|
+
return [...clean].slice(0, limit).join("");
|
|
139
|
+
}
|
|
140
|
+
function titleSequence(title) {
|
|
141
|
+
return `\x1B]0;${oscText(title, 80)}\x07`;
|
|
142
|
+
}
|
|
143
|
+
function progressSequence(running) {
|
|
144
|
+
return running ? "\x1B]9;4;3;\x07" : "\x1B]9;4;0;\x07";
|
|
145
|
+
}
|
|
146
|
+
function notifySequence(message) {
|
|
147
|
+
const text = oscText(message, 200).replace(/^(\d+);/, "$1:");
|
|
148
|
+
return `\x1B]9;${text}\x07\x07`;
|
|
149
|
+
}
|
|
150
|
+
function shouldNotify(focus, now) {
|
|
151
|
+
return focus.focused === false && now - focus.since >= NOTIFY_AFTER_UNFOCUSED_MS;
|
|
152
|
+
}
|
|
153
|
+
function windowTitle(state) {
|
|
154
|
+
const name = state.name?.trim() || "ClikCode";
|
|
155
|
+
if (!state.running) return name;
|
|
156
|
+
return `${state.asking ? "waiting for you" : "working"} \xB7 ${name}`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/tui/restore.ts
|
|
160
|
+
var REEXEC_TERMINAL_ENV = "CLIKCODE_KEEP_TERMINAL_ON_REEXEC";
|
|
161
|
+
function reexecHandover(env = process.env) {
|
|
162
|
+
return inlineHistoryMode(env) ? "inline" : "alt";
|
|
163
|
+
}
|
|
164
|
+
function parseReexecHandover(value) {
|
|
165
|
+
return value === "inline" || value === "alt" || value === "1" ? value : void 0;
|
|
166
|
+
}
|
|
167
|
+
function reconcileScreen(handover, inline, rows) {
|
|
168
|
+
const inlineStart = `${CLEAR_SCREEN_AND_SCROLLBACK}\x1B[${Math.max(1, rows)};1H`;
|
|
169
|
+
if (inline) return { write: `${handover === "alt" || handover === "1" ? "\x1B[?1049l" : ""}${inlineStart}`, inherited: handover !== void 0 };
|
|
170
|
+
if (handover === void 0) return { write: enterAlternateScreenSequence(), inherited: false };
|
|
171
|
+
if (handover === "alt") return { write: "", inherited: true };
|
|
172
|
+
return { write: `${CLEAR_SCREEN_AND_SCROLLBACK}${enterAlternateScreenSequence()}`, inherited: true };
|
|
173
|
+
}
|
|
174
|
+
function enterAlternateScreenSequence() {
|
|
175
|
+
if (!swallowsAlternateScreen()) return "\x1B[?1049h\x1B[2J\x1B[H";
|
|
176
|
+
return `\x1B[?1049h${"\r\n".repeat(Math.max(1, output.rows || 24))}${CLEAR_SCREEN}`;
|
|
177
|
+
}
|
|
178
|
+
var historyDump = { source: void 0, suppressed: false };
|
|
179
|
+
function historyDumpSequence() {
|
|
180
|
+
if (historyDump.suppressed || !historyDump.source || inlineHistoryMode()) return "";
|
|
181
|
+
let text = "";
|
|
182
|
+
try {
|
|
183
|
+
text = historyDump.source();
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
const wipe = swallowsAlternateScreen() ? `${CLEAR_SCREEN}` : "";
|
|
187
|
+
return text || wipe ? `${wipe}${text}` : "";
|
|
188
|
+
}
|
|
189
|
+
var HISTORY_DUMP_CHUNK_BYTES = 64 * 1024;
|
|
190
|
+
function dumpChunks(text) {
|
|
191
|
+
const chunks = [];
|
|
192
|
+
let at = 0;
|
|
193
|
+
while (at < text.length) {
|
|
194
|
+
let end = Math.min(text.length, at + HISTORY_DUMP_CHUNK_BYTES);
|
|
195
|
+
if (end < text.length) {
|
|
196
|
+
const row = text.indexOf("\n", end);
|
|
197
|
+
end = row < 0 ? text.length : row + 1;
|
|
198
|
+
}
|
|
199
|
+
chunks.push(text.slice(at, end));
|
|
200
|
+
at = end;
|
|
201
|
+
}
|
|
202
|
+
return chunks;
|
|
203
|
+
}
|
|
204
|
+
var terminalModes = {
|
|
205
|
+
bracketedPaste: false,
|
|
206
|
+
kittyKeyboard: false,
|
|
207
|
+
wheelReporting: false,
|
|
208
|
+
alternateScroll: false,
|
|
209
|
+
alternateScreen: false,
|
|
210
|
+
rawMode: false,
|
|
211
|
+
painted: false,
|
|
212
|
+
uiStarted: false,
|
|
213
|
+
titlePushed: false,
|
|
214
|
+
progress: false
|
|
215
|
+
};
|
|
216
|
+
function enterAlternateScreen() {
|
|
217
|
+
if (terminalModes.alternateScreen || inlineHistoryMode()) return;
|
|
218
|
+
output.write(enterAlternateScreenSequence());
|
|
219
|
+
terminalModes.alternateScreen = true;
|
|
220
|
+
}
|
|
221
|
+
function leavePage() {
|
|
222
|
+
if (!inlineBlock.page) return "";
|
|
223
|
+
restoreMainBlock();
|
|
224
|
+
inlineBlock.tail = [];
|
|
225
|
+
inlineBlock.resized = false;
|
|
226
|
+
inlineBlock.wipe = false;
|
|
227
|
+
terminalModes.alternateScreen = false;
|
|
228
|
+
return LEAVE_PAGE_SCREEN;
|
|
229
|
+
}
|
|
230
|
+
function pushShellTitle() {
|
|
231
|
+
if (!output.isTTY || terminalModes.titlePushed) return false;
|
|
232
|
+
output.write(PUSH_TITLE);
|
|
233
|
+
terminalModes.titlePushed = true;
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
function giveBackTerminal(readModesOff) {
|
|
237
|
+
const dump = historyDumpSequence();
|
|
238
|
+
output.write(`${readModesOff}` + terminalTeardown(terminalModes.alternateScreen) + signalsTeardown());
|
|
239
|
+
for (const chunk of dumpChunks(dump)) output.write(chunk);
|
|
240
|
+
terminalModes.alternateScreen = false;
|
|
241
|
+
terminalModes.painted = false;
|
|
242
|
+
}
|
|
243
|
+
function signalsTeardown() {
|
|
244
|
+
const sequence = `${terminalModes.progress ? progressSequence(false) : ""}${terminalModes.titlePushed ? POP_TITLE : ""}`;
|
|
245
|
+
terminalModes.progress = false;
|
|
246
|
+
terminalModes.titlePushed = false;
|
|
247
|
+
return sequence;
|
|
248
|
+
}
|
|
249
|
+
function terminalPrepare() {
|
|
250
|
+
const kitty = kittyKeyboardSafe() ? CLEAR_KITTY_KEYBOARD : "";
|
|
251
|
+
return `${kitty}${MOUSE_MODES_OFF}${READ_MODES_OFF}${LATCHED_OFF}`;
|
|
252
|
+
}
|
|
253
|
+
var CLEAR_KITTY_KEYBOARD = "\x1B[<99u";
|
|
254
|
+
var MOUSE_MODES_OFF = "\x1B[?1006l\x1B[?1016l\x1B[?1003l\x1B[?1002l\x1B[?1000l";
|
|
255
|
+
var READ_MODES_OFF = `\x1B[?2004l\x1B[?2031l${FOCUS_REPORTING_OFF}`;
|
|
256
|
+
var LATCHED_OFF = "\x1B[>4m\x1B(B\x1B7\x1B[r\x1B8";
|
|
257
|
+
function terminalTeardown(leavingAlternateScreen) {
|
|
258
|
+
const scroll = terminalModes.alternateScroll ? "\x1B[?1007l" : "";
|
|
259
|
+
terminalModes.alternateScroll = false;
|
|
260
|
+
const modesOff = `${MOUSE_MODES_OFF}${READ_MODES_OFF}${scroll}`;
|
|
261
|
+
return `${leavingAlternateScreen ? `${modesOff}\x1B[?1049l` : ""}${modesOff}${LATCHED_OFF}\x1B[?7h\x1B[?25h`;
|
|
262
|
+
}
|
|
263
|
+
function restoreTerminal(options = {}) {
|
|
264
|
+
try {
|
|
265
|
+
const touched = terminalModes.uiStarted || terminalModes.painted || terminalModes.kittyKeyboard || terminalModes.bracketedPaste || terminalModes.wheelReporting || terminalModes.alternateScroll || terminalModes.alternateScreen || terminalModes.rawMode || terminalModes.titlePushed || terminalModes.progress;
|
|
266
|
+
if (!touched) {
|
|
267
|
+
if (input.isRaw && input.isTTY && typeof input.setRawMode === "function") input.setRawMode(false);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
let sequence = "";
|
|
271
|
+
if (terminalModes.painted) sequence += "\x1B[?2026l";
|
|
272
|
+
if (terminalModes.kittyKeyboard) sequence += "\x1B[<u";
|
|
273
|
+
const leavingAlternate = terminalModes.alternateScreen;
|
|
274
|
+
sequence += terminalTeardown(leavingAlternate);
|
|
275
|
+
if (terminalModes.uiStarted) sequence += voicePresence(false);
|
|
276
|
+
sequence += signalsTeardown();
|
|
277
|
+
const dump = leavingAlternate ? historyDumpSequence() : "";
|
|
278
|
+
const wasRaw = terminalModes.rawMode;
|
|
279
|
+
terminalModes.uiStarted = false;
|
|
280
|
+
terminalModes.painted = false;
|
|
281
|
+
terminalModes.kittyKeyboard = false;
|
|
282
|
+
terminalModes.bracketedPaste = false;
|
|
283
|
+
terminalModes.wheelReporting = false;
|
|
284
|
+
terminalModes.alternateScreen = false;
|
|
285
|
+
terminalModes.rawMode = false;
|
|
286
|
+
if (sequence && output.isTTY) {
|
|
287
|
+
if (options.sync) {
|
|
288
|
+
try {
|
|
289
|
+
writeSync(output.fd, sequence);
|
|
290
|
+
} catch {
|
|
291
|
+
output.write(sequence);
|
|
292
|
+
}
|
|
293
|
+
} else output.write(sequence);
|
|
294
|
+
for (const chunk of dumpChunks(dump)) {
|
|
295
|
+
if (options.sync) {
|
|
296
|
+
try {
|
|
297
|
+
writeSync(output.fd, chunk);
|
|
298
|
+
} catch {
|
|
299
|
+
output.write(chunk);
|
|
300
|
+
}
|
|
301
|
+
} else output.write(chunk);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if ((wasRaw || input.isRaw) && input.isTTY && typeof input.setRawMode === "function") input.setRawMode(false);
|
|
305
|
+
} catch {
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
var RESTORE_SIGNALS = ["SIGHUP", "SIGTERM", "SIGQUIT"];
|
|
309
|
+
var restoreSignalsInstalled = false;
|
|
310
|
+
function installTerminalRestoreSignals() {
|
|
311
|
+
if (restoreSignalsInstalled) return;
|
|
312
|
+
restoreSignalsInstalled = true;
|
|
313
|
+
for (const signal of RESTORE_SIGNALS) {
|
|
314
|
+
process.on(signal, () => {
|
|
315
|
+
restoreTerminal({ sync: true });
|
|
316
|
+
process.removeAllListeners(signal);
|
|
317
|
+
process.kill(process.pid, signal);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export {
|
|
323
|
+
PASTE_START,
|
|
324
|
+
PASTE_END,
|
|
325
|
+
pastedText,
|
|
326
|
+
PUSH_KITTY_KEYBOARD,
|
|
327
|
+
POP_KITTY_KEYBOARD,
|
|
328
|
+
NEWLINE_KEY,
|
|
329
|
+
kittyKeyboardSafe,
|
|
330
|
+
inlineHistoryMode,
|
|
331
|
+
swallowsAlternateScreen,
|
|
332
|
+
CLEAR_SCREEN_AND_SCROLLBACK,
|
|
333
|
+
CLEAR_SCREEN,
|
|
334
|
+
inlineBlock,
|
|
335
|
+
ENTER_PAGE_SCREEN,
|
|
336
|
+
LEAVE_PAGE_SCREEN,
|
|
337
|
+
restoreMainBlock,
|
|
338
|
+
eraseInlineBlock,
|
|
339
|
+
FOCUS_REPORTING_ON,
|
|
340
|
+
titleSequence,
|
|
341
|
+
progressSequence,
|
|
342
|
+
notifySequence,
|
|
343
|
+
shouldNotify,
|
|
344
|
+
windowTitle,
|
|
345
|
+
voicePresence,
|
|
346
|
+
VoiceReply,
|
|
347
|
+
REEXEC_TERMINAL_ENV,
|
|
348
|
+
reexecHandover,
|
|
349
|
+
parseReexecHandover,
|
|
350
|
+
reconcileScreen,
|
|
351
|
+
historyDump,
|
|
352
|
+
historyDumpSequence,
|
|
353
|
+
terminalModes,
|
|
354
|
+
enterAlternateScreen,
|
|
355
|
+
leavePage,
|
|
356
|
+
pushShellTitle,
|
|
357
|
+
giveBackTerminal,
|
|
358
|
+
signalsTeardown,
|
|
359
|
+
terminalPrepare,
|
|
360
|
+
MOUSE_MODES_OFF,
|
|
361
|
+
terminalTeardown,
|
|
362
|
+
restoreTerminal,
|
|
363
|
+
installTerminalRestoreSignals
|
|
364
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
localMachineName
|
|
5
|
+
} from "./chunk-Z4ZU6T7V.js";
|
|
6
|
+
import {
|
|
7
|
+
UPDATE_STEPS,
|
|
8
|
+
localRunner,
|
|
9
|
+
runManagedUpdate,
|
|
10
|
+
stepper
|
|
11
|
+
} from "./chunk-UFQ5A5PW.js";
|
|
12
|
+
import {
|
|
13
|
+
failureText
|
|
14
|
+
} from "./chunk-CQ7J6UQ7.js";
|
|
15
|
+
import {
|
|
16
|
+
CLIKCODE_COMMIT,
|
|
17
|
+
CLIKCODE_VERSION
|
|
18
|
+
} from "./chunk-NAOX3JUB.js";
|
|
19
|
+
|
|
20
|
+
// src/remote/self-update.ts
|
|
21
|
+
import { realpath, stat } from "node:fs/promises";
|
|
22
|
+
import { homedir } from "node:os";
|
|
23
|
+
import { basename, dirname, join, sep } from "node:path";
|
|
24
|
+
var exists = (path) => stat(path).then(() => true, () => false);
|
|
25
|
+
var real = (path) => realpath(path).catch(() => path);
|
|
26
|
+
var inside = (path, folder) => path === folder || path.startsWith(`${folder}${sep}`);
|
|
27
|
+
async function detectInstall(entry, home = homedir()) {
|
|
28
|
+
const share = join(home, ".local", "share", "clikcode");
|
|
29
|
+
const release = await real(join(share, "release"));
|
|
30
|
+
const clone = join(share, "src");
|
|
31
|
+
const running = await real(entry);
|
|
32
|
+
const packageRoot = dirname(dirname(running));
|
|
33
|
+
if (inside(running, release)) {
|
|
34
|
+
const modules = join(release, "node_modules");
|
|
35
|
+
const linked = await exists(modules) ? await real(modules) : void 0;
|
|
36
|
+
if (await exists(join(clone, ".git")) && (!linked || inside(linked, await real(clone)))) return { kind: "managed" };
|
|
37
|
+
const repo = linked ? dirname(linked) : void 0;
|
|
38
|
+
return { kind: "checkout", ...repo && await exists(join(repo, ".git")) ? { repo } : {} };
|
|
39
|
+
}
|
|
40
|
+
if (basename(packageRoot) === "clikcode" && basename(dirname(packageRoot)) === "node_modules") return { kind: "npm", packageRoot };
|
|
41
|
+
return { kind: "checkout", ...await exists(join(packageRoot, ".git")) ? { repo: packageRoot } : {} };
|
|
42
|
+
}
|
|
43
|
+
var short = (commit) => commit ? commit.slice(0, 8) : "unknown";
|
|
44
|
+
var SWITCH = "chats switch over once they are quiet";
|
|
45
|
+
function parseCommitArgument(args) {
|
|
46
|
+
const typed = args.trim();
|
|
47
|
+
if (!typed) return void 0;
|
|
48
|
+
if (!/^[0-9a-f]{7,40}$/i.test(typed)) throw new Error(`/update takes a commit (7 to 40 hex characters), not "${typed}".`);
|
|
49
|
+
return typed.toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
function stepReporter(line) {
|
|
52
|
+
let current = 0;
|
|
53
|
+
let total = 0;
|
|
54
|
+
return {
|
|
55
|
+
start: (_step, index, count) => {
|
|
56
|
+
current = index;
|
|
57
|
+
total = count;
|
|
58
|
+
},
|
|
59
|
+
done: (step, detail) => line(`\u2713 ${current}/${total} ${step}${detail ? ` \xB7 ${detail}` : ""}`)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function updateThisMachine(options) {
|
|
63
|
+
const where = options.hostName ?? localMachineName();
|
|
64
|
+
const run = options.run ?? localRunner;
|
|
65
|
+
const running = options.running ?? { version: CLIKCODE_VERSION, ...CLIKCODE_COMMIT ? { commit: CLIKCODE_COMMIT } : {} };
|
|
66
|
+
const install = await detectInstall(options.entry ?? process.argv[1] ?? "", options.home);
|
|
67
|
+
if (install.kind === "checkout") {
|
|
68
|
+
return {
|
|
69
|
+
kind: "checkout",
|
|
70
|
+
updated: false,
|
|
71
|
+
text: install.repo ? `This ClikCode on ${where} is built from a developer checkout (${install.repo}); /update does not touch a checkout. To update it, run \`git pull && pnpm run install-local\` in ${install.repo}.` : `This ClikCode on ${where} was not installed by ClikCode Remote or npm, and is not a checkout /update could name; it is left alone. Update it the way it was installed.`
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (install.kind === "npm") {
|
|
75
|
+
if (options.commit) throw new Error("This ClikCode is the npm package, which installs published versions, not commits. Run /update without a commit for the latest version.");
|
|
76
|
+
const view = await run("npm view clikcode version", { timeoutMs: 12e4 });
|
|
77
|
+
const latest = view.stdout.trim().split("\n").pop()?.trim();
|
|
78
|
+
if (view.code !== 0 || !latest) throw new Error(`Checking npm: \`npm view clikcode version\` failed: ${failureText(view.stderr) || `exit ${view.code}`}.`);
|
|
79
|
+
options.line(`\u2713 1/2 Checking npm \xB7 clikcode ${latest} is the latest`);
|
|
80
|
+
if (latest === running.version) return { kind: "npm", updated: false, text: `ClikCode ${running.version} on ${where} is already up to date.` };
|
|
81
|
+
const installed = await run("npm install -g clikcode@latest", { timeoutMs: 20 * 6e4 });
|
|
82
|
+
if (installed.code !== 0) throw new Error(`Installing clikcode@latest: \`npm install -g clikcode@latest\` failed: ${failureText(installed.stderr) || `exit ${installed.code}`}.`);
|
|
83
|
+
options.line(`\u2713 2/2 Installing clikcode@latest \xB7 ${install.packageRoot}`);
|
|
84
|
+
return { kind: "npm", updated: true, text: `ClikCode ${running.version} \u2192 ${latest} on ${where}; ${SWITCH}.` };
|
|
85
|
+
}
|
|
86
|
+
const progress = stepper(stepReporter(options.line), UPDATE_STEPS.length);
|
|
87
|
+
const outcome = await runManagedUpdate(run, where, progress, { ...options.commit ? { commit: options.commit } : {}, running: running.commit ?? "" });
|
|
88
|
+
if (!outcome.ok) throw new Error(`${outcome.step}: ${outcome.message}`);
|
|
89
|
+
if (outcome.upToDate) return { kind: "managed", updated: false, text: `ClikCode ${short(outcome.to)} on ${where} is already up to date.` };
|
|
90
|
+
const from = outcome.from ?? running.commit;
|
|
91
|
+
if (from === outcome.to) return { kind: "managed", updated: true, text: `ClikCode ${short(outcome.to)} on ${where} is built and installed again; ${SWITCH}.` };
|
|
92
|
+
return { kind: "managed", updated: true, text: `ClikCode ${short(from)} \u2192 ${short(outcome.to)} on ${where}; ${SWITCH}.` };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
detectInstall,
|
|
97
|
+
parseCommitArgument,
|
|
98
|
+
updateThisMachine
|
|
99
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { createRequire as __clikcodeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __clikcodeCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
savedTurnRanks
|
|
5
|
+
} from "./chunk-QPQKX2MK.js";
|
|
6
|
+
import {
|
|
7
|
+
approvalDecision
|
|
8
|
+
} from "./chunk-T5VCXA3J.js";
|
|
9
|
+
import {
|
|
10
|
+
isTranscriptActivity
|
|
11
|
+
} from "./chunk-UBMVADBF.js";
|
|
12
|
+
import {
|
|
13
|
+
isApprovalWaitPhase,
|
|
14
|
+
upsertMark
|
|
15
|
+
} from "./chunk-FF7ZVYJF.js";
|
|
16
|
+
import {
|
|
17
|
+
backgroundWorkOf
|
|
18
|
+
} from "./chunk-BUOPJQP5.js";
|
|
19
|
+
|
|
20
|
+
// src/worker/approval-answer.ts
|
|
21
|
+
async function answerWorkerApproval(rl, request, signal, respond) {
|
|
22
|
+
const answer = await rl.approval(request.title, request.detail, request.preview, request.rule, signal, request.callId);
|
|
23
|
+
if (signal.aborted) return;
|
|
24
|
+
rl.markDrawn(`outcome:${request.id}`);
|
|
25
|
+
respond(approvalDecision(answer));
|
|
26
|
+
if (typeof answer === "object") rl.submitWaiting(answer.told, false);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/turn/live-answer.ts
|
|
30
|
+
function joinedAnswerText(durable, live) {
|
|
31
|
+
const saved = durable ?? "";
|
|
32
|
+
const streamed = live ?? "";
|
|
33
|
+
return saved.length >= streamed.length ? saved : streamed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/worker/joined-turn.ts
|
|
37
|
+
function newLiveTurnState() {
|
|
38
|
+
return { running: false, liveText: "", activities: [], plan: [], marks: [], unsequenced: [] };
|
|
39
|
+
}
|
|
40
|
+
function joinLive(state, live, session) {
|
|
41
|
+
const journal = session.pendingTurn;
|
|
42
|
+
const sameTurn = journal && (live.prompt === void 0 || journal.prompt.trim() === live.prompt.trim());
|
|
43
|
+
Object.assign(state, {
|
|
44
|
+
running: true,
|
|
45
|
+
prompt: live.prompt ?? state.prompt,
|
|
46
|
+
liveText: joinedAnswerText(sameTurn ? journal.response : void 0, live.text),
|
|
47
|
+
...live.activities ? { activities: [...live.activities] } : {},
|
|
48
|
+
...live.plan ? { plan: live.plan } : {},
|
|
49
|
+
marks: live.marks ? [...live.marks] : [],
|
|
50
|
+
unsequenced: [],
|
|
51
|
+
thought: live.thought,
|
|
52
|
+
phase: live.phase,
|
|
53
|
+
background: backgroundWorkOf(live),
|
|
54
|
+
vendorWork: live.vendorWork === true
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function applyLiveEvent(state, event) {
|
|
58
|
+
switch (event.type) {
|
|
59
|
+
case "waiting-start":
|
|
60
|
+
Object.assign(state, {
|
|
61
|
+
running: true,
|
|
62
|
+
prompt: event.prompt,
|
|
63
|
+
liveText: "",
|
|
64
|
+
activities: [],
|
|
65
|
+
plan: [],
|
|
66
|
+
marks: [],
|
|
67
|
+
unsequenced: [],
|
|
68
|
+
thought: void 0,
|
|
69
|
+
phase: void 0,
|
|
70
|
+
usage: void 0,
|
|
71
|
+
vendorWork: event.vendorWork === true
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
case "waiting-stop":
|
|
75
|
+
state.running = false;
|
|
76
|
+
return;
|
|
77
|
+
case "snapshot":
|
|
78
|
+
if (event.live) joinLive(state, event.live, event.session);
|
|
79
|
+
else state.running = false;
|
|
80
|
+
state.background = event.background ?? backgroundWorkOf(event.live);
|
|
81
|
+
return;
|
|
82
|
+
case "delta":
|
|
83
|
+
state.liveText = event.mode === "replace" ? event.text : state.liveText + event.text;
|
|
84
|
+
return;
|
|
85
|
+
case "activity":
|
|
86
|
+
if (state.running && isTranscriptActivity(event.event)) state.activities.push({ event: event.event, responseOffset: state.liveText.length });
|
|
87
|
+
return;
|
|
88
|
+
case "plan":
|
|
89
|
+
if (state.running) state.plan = event.entries;
|
|
90
|
+
return;
|
|
91
|
+
case "note":
|
|
92
|
+
if (state.running && event.seq !== void 0) {
|
|
93
|
+
state.marks = upsertMark(state.marks, { kind: "notice", id: `notice:${event.seq}`, seq: event.seq, responseOffset: event.responseOffset ?? state.liveText.length, message: event.message });
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
case "phase":
|
|
97
|
+
if (state.running) state.phase = event.message;
|
|
98
|
+
return;
|
|
99
|
+
case "background":
|
|
100
|
+
if (state.running) state.background = backgroundWorkOf({ background: event.work, pendingBackground: event.pending });
|
|
101
|
+
return;
|
|
102
|
+
default:
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function recordDecision(tracker, event) {
|
|
106
|
+
if (!tracker.running || !event.outcome || !event.label) return void 0;
|
|
107
|
+
const id = `outcome:${event.id}`;
|
|
108
|
+
const existing = tracker.marks.find((mark2) => mark2.id === id);
|
|
109
|
+
if (existing) return void 0;
|
|
110
|
+
const mark = { kind: "outcome", id, seq: 0, responseOffset: tracker.liveText.length, outcome: event.outcome, label: event.label, ...event.callId ? { callId: event.callId } : {} };
|
|
111
|
+
tracker.marks = [...tracker.marks, mark];
|
|
112
|
+
tracker.unsequenced.push(id);
|
|
113
|
+
return mark;
|
|
114
|
+
}
|
|
115
|
+
function drawJoinedTurn(rl, turn) {
|
|
116
|
+
if (turn.liveText) rl.response(turn.liveText, "replace");
|
|
117
|
+
const marks = turn.marks.filter((mark) => mark.kind !== "plan");
|
|
118
|
+
const ranks = savedTurnRanks(turn.activities, marks, { marksHaveSeq: !turn.unsequenced?.length });
|
|
119
|
+
const order = marks.map((mark, index) => ({ mark, rank: ranks.marks[index] })).sort((a, b) => a.rank - b.rank);
|
|
120
|
+
let next = 0;
|
|
121
|
+
turn.activities.forEach((item, index) => {
|
|
122
|
+
while (next < order.length && order[next].rank < ranks.activities[index]) rl.joinMark(order[next++].mark);
|
|
123
|
+
rl.activityEvent(item.event, { index, responseOffset: item.responseOffset });
|
|
124
|
+
});
|
|
125
|
+
while (next < order.length) rl.joinMark(order[next++].mark);
|
|
126
|
+
if (turn.thought) rl.joinThought(turn.thought);
|
|
127
|
+
if (turn.plan.length) rl.setPlan(turn.plan);
|
|
128
|
+
if (turn.phase && !isApprovalWaitPhase(turn.phase)) rl.phase(turn.phase);
|
|
129
|
+
if (turn.background) rl.setBackgroundWork?.(turn.background);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
answerWorkerApproval,
|
|
134
|
+
newLiveTurnState,
|
|
135
|
+
applyLiveEvent,
|
|
136
|
+
recordDecision,
|
|
137
|
+
drawJoinedTurn
|
|
138
|
+
};
|