@wirecat/drive-cli 0.64.0 → 0.66.0

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 (228) hide show
  1. package/contracts/wirecat.json +2871 -0
  2. package/dist/bin/drive.js +2 -2
  3. package/dist/bin/drive.js.map +1 -1
  4. package/dist/browse.d.ts +1 -1
  5. package/dist/browse.d.ts.map +1 -1
  6. package/dist/browse.js +1 -1
  7. package/dist/bundle/{all-profiles-BPPT2AK5.js → all-profiles-WCQLIHUG.js} +14 -13
  8. package/dist/bundle/{anthropic-JW6GOJUD.js → anthropic-5RJMB6O7.js} +32 -16
  9. package/dist/bundle/{app-server-KAQIOJMZ.js → app-server-3RGYXPKG.js} +72 -58
  10. package/dist/bundle/{bun-UT7GNTPV.js → bun-L34VEKGG.js} +2 -2
  11. package/dist/bundle/{bun-sqlite-2OIVV3LS.js → bun-sqlite-H6IAXQXI.js} +12 -8
  12. package/dist/bundle/chunk-2AF77WMH.js +13 -0
  13. package/dist/bundle/{chunk-KVW4XNKB.js → chunk-2S3E2HVV.js} +107 -48
  14. package/dist/bundle/{chunk-IX7NQJLY.js → chunk-3NYH756U.js} +49 -116
  15. package/dist/bundle/chunk-3QFUDXMQ.js +53 -0
  16. package/dist/bundle/{chunk-5ZBR55US.js → chunk-3SDJIMZB.js} +1 -1
  17. package/dist/bundle/{chunk-AHB4OJCI.js → chunk-4UHBJSMI.js} +21735 -27143
  18. package/dist/bundle/chunk-5HVJK3ZJ.js +101 -0
  19. package/dist/bundle/{chunk-GSMYXGFR.js → chunk-5K54RZBK.js} +13 -5
  20. package/dist/bundle/{chunk-LOMW6F2E.js → chunk-5PLINHEY.js} +5403 -4847
  21. package/dist/bundle/{chunk-J62DI53V.js → chunk-5VDVGDOC.js} +1 -1
  22. package/dist/bundle/{chunk-66AF4FBW.js → chunk-5XLU4NN6.js} +4 -4
  23. package/dist/bundle/{chunk-4CNTID2X.js → chunk-6UJCCOZC.js} +4 -4
  24. package/dist/bundle/{chunk-G4KEKKDE.js → chunk-6X3KUFRQ.js} +60 -29
  25. package/dist/bundle/{chunk-QEAD2LF4.js → chunk-7EP4AU6A.js} +3 -3
  26. package/dist/bundle/{chunk-ZRZ4HTCK.js → chunk-7LT2G5BC.js} +171 -174
  27. package/dist/bundle/{chunk-2W464HAE.js → chunk-7ZGJRVBH.js} +7 -5
  28. package/dist/bundle/{chunk-FXBHOCJK.js → chunk-ADLS6FVG.js} +1 -1
  29. package/dist/bundle/{chunk-KG2XKEHL.js → chunk-ALE67WRR.js} +5 -5
  30. package/dist/bundle/{chunk-ZSZJLJIA.js → chunk-AP4MX247.js} +38 -28
  31. package/dist/bundle/{chunk-EWGVDFPT.js → chunk-BIJW6AYA.js} +41873 -36466
  32. package/dist/bundle/{chunk-B7XBIOMR.js → chunk-BQXSE645.js} +16 -16
  33. package/dist/bundle/{chunk-F2VDAG32.js → chunk-COGWKO2T.js} +3 -3
  34. package/dist/bundle/{chunk-EZ6O3ST3.js → chunk-D4MIMH2N.js} +12 -6
  35. package/dist/bundle/{chunk-4YRENUB5.js → chunk-D7KOAPG6.js} +2 -2
  36. package/dist/bundle/chunk-E2F2XIX6.js +224 -0
  37. package/dist/bundle/{chunk-36GPBPWM.js → chunk-FA2TNA5X.js} +3 -1
  38. package/dist/bundle/{chunk-SIOIMO62.js → chunk-FHBTQPA3.js} +69 -63
  39. package/dist/bundle/{chunk-34BIDKF4.js → chunk-FKKPVPZR.js} +649 -212
  40. package/dist/bundle/chunk-G4TNKBDX.js +185 -0
  41. package/dist/bundle/{chunk-2FEZ24DK.js → chunk-GVA3KTCD.js} +20 -20
  42. package/dist/bundle/chunk-GY4DAJSK.js +167 -0
  43. package/dist/bundle/{chunk-5OFA5EXE.js → chunk-H7XL6WTW.js} +2 -2
  44. package/dist/bundle/{chunk-K6BSB53R.js → chunk-HHRJPLFO.js} +1 -1
  45. package/dist/bundle/{chunk-P7DEGRZA.js → chunk-HPKE2GDP.js} +49 -28
  46. package/dist/bundle/{chunk-QXCKJUZY.js → chunk-HPSHQVJU.js} +633 -465
  47. package/dist/bundle/{chunk-BEZJA44H.js → chunk-HQBLJLYH.js} +7 -7
  48. package/dist/bundle/{chunk-JRXFW7HE.js → chunk-I5R5CMQR.js} +5 -5
  49. package/dist/bundle/{chunk-EJ4PNHPP.js → chunk-IIHZTV6V.js} +1 -1
  50. package/dist/bundle/{chunk-G3NULXOM.js → chunk-IRNDYNQX.js} +4 -4
  51. package/dist/bundle/{chunk-N622LRPM.js → chunk-JCHF7LZT.js} +4 -4
  52. package/dist/bundle/{chunk-WWCYTMAV.js → chunk-JHMEETXI.js} +2 -2
  53. package/dist/bundle/{chunk-ZF6GUZCE.js → chunk-JLCR24UM.js} +1 -1
  54. package/dist/bundle/{chunk-IDAK4DDK.js → chunk-JQXK3M5M.js} +1 -1
  55. package/dist/bundle/{chunk-KIN6PDFE.js → chunk-KOY5HUBY.js} +14 -5
  56. package/dist/bundle/{chunk-5HSRQ53R.js → chunk-KRG5X5PH.js} +2 -2
  57. package/dist/bundle/{chunk-VIJ6ACYB.js → chunk-LVAPSAHF.js} +8 -8
  58. package/dist/bundle/{chunk-OEVHZOHC.js → chunk-M7543RUJ.js} +50 -18
  59. package/dist/bundle/{chunk-BZ2ZKILM.js → chunk-MZWXTJ4O.js} +3 -3
  60. package/dist/bundle/{chunk-EC2XGDKJ.js → chunk-NK4GVFJH.js} +4 -4
  61. package/dist/bundle/chunk-NYECVHFH.js +10283 -0
  62. package/dist/bundle/{chunk-HW4UPST2.js → chunk-NYZS2LKF.js} +2 -2
  63. package/dist/bundle/chunk-O53WLYX3.js +72 -0
  64. package/dist/bundle/{chunk-IK6KH3RE.js → chunk-OIF4B526.js} +1 -1
  65. package/dist/bundle/{chunk-UJR272CP.js → chunk-OT7SQQJK.js} +359 -903
  66. package/dist/bundle/chunk-OZOQLAWK.js +72 -0
  67. package/dist/bundle/{chunk-VT2UFYPJ.js → chunk-P7HQFII6.js} +22 -15
  68. package/dist/bundle/{chunk-6G53ZFUT.js → chunk-PJGOQSE5.js} +1 -1
  69. package/dist/bundle/{chunk-OH3K2E7X.js → chunk-PKM55ZRR.js} +704 -1214
  70. package/dist/bundle/{chunk-GW3U6OLD.js → chunk-PUMDOCAF.js} +1 -1
  71. package/dist/bundle/{chunk-EQEGJVO2.js → chunk-QF7VL4C3.js} +1 -1
  72. package/dist/bundle/{chunk-CPMRM3GQ.js → chunk-QJ57PV55.js} +1941 -662
  73. package/dist/bundle/{chunk-O2QO5UZC.js → chunk-QSELSDWE.js} +13 -13
  74. package/dist/bundle/{chunk-BEUAICUD.js → chunk-SOOU5WO6.js} +2 -2
  75. package/dist/bundle/{chunk-46CD64J2.js → chunk-SZ6JFOL4.js} +269 -64
  76. package/dist/bundle/{chunk-UD55VB2N.js → chunk-T3ULDA7C.js} +3 -3
  77. package/dist/bundle/{chunk-E2LBCCTG.js → chunk-TAHISPDE.js} +5 -5
  78. package/dist/bundle/{chunk-6B37XO6B.js → chunk-TYLEICTX.js} +3 -3
  79. package/dist/bundle/{chunk-TNV2FXVK.js → chunk-UAKX6DP4.js} +5 -5
  80. package/dist/bundle/{chunk-VPLFD5RJ.js → chunk-UG3GHFGY.js} +4 -4
  81. package/dist/bundle/{chunk-B67BLRAI.js → chunk-ULXEW6FT.js} +3 -60
  82. package/dist/bundle/{chunk-C7WBNOYW.js → chunk-UNTIVT47.js} +26 -2
  83. package/dist/bundle/chunk-UQPW42HF.js +18 -0
  84. package/dist/bundle/{chunk-USLZE36C.js → chunk-V2WXTILT.js} +6 -6
  85. package/dist/bundle/{chunk-BDYWZ7JE.js → chunk-VQKNKJYL.js} +46 -7
  86. package/dist/bundle/{chunk-XPXKD63J.js → chunk-VR3YKXHL.js} +93 -31
  87. package/dist/bundle/{chunk-UIEA6FIV.js → chunk-VUUPFDRU.js} +27 -28
  88. package/dist/bundle/{chunk-KE4XPPRQ.js → chunk-WYTYHUFH.js} +1750 -138
  89. package/dist/bundle/{chunk-PBMSBCVB.js → chunk-XLGDNI4S.js} +1 -1
  90. package/dist/bundle/{chunk-3J5KAFNA.js → chunk-XVZNFA2P.js} +4935 -3623
  91. package/dist/bundle/chunk-Y5U4HIZS.js +71 -0
  92. package/dist/bundle/chunk-YTIPTHEE.js +47 -0
  93. package/dist/bundle/cli-KW6QQVS5.js +1101 -0
  94. package/dist/bundle/command-contract-CE543JBN.js +41 -0
  95. package/dist/bundle/command-server-entry-OC4E4DED.js +171 -0
  96. package/dist/bundle/{decode-HTOQ6S3V.js → decode-AH5ZLLDK.js} +8 -8
  97. package/dist/bundle/{dispatch-SH5SP6LA.js → dispatch-CDWZZ54Q.js} +9 -9
  98. package/dist/bundle/drive.js +13 -13
  99. package/dist/bundle/{echarts-KFHB6SLX.js → echarts-VC7MTXWY.js} +2 -2
  100. package/dist/bundle/{embed-YATFB2PN.js → embed-EPSQY6QG.js} +9 -9
  101. package/dist/bundle/{embedder-MQPDFGTJ.js → embedder-TK4U4TJR.js} +12 -12
  102. package/dist/bundle/entry-3VN23M7M.js +25 -0
  103. package/dist/bundle/{failure-4FQL4XJI.js → failure-WSVZOPFE.js} +4 -4
  104. package/dist/bundle/first-run-7ZYJ7EB3.js +30 -0
  105. package/dist/bundle/first-screen-CZDH7QY3.js +39 -0
  106. package/dist/bundle/google-OBZMWA7J.js +45 -0
  107. package/dist/bundle/{google-api-QMFGCXBM.js → google-api-AV4X2JH3.js} +68 -57
  108. package/dist/bundle/grants-WTRLN4ZI.js +111 -0
  109. package/dist/bundle/{identity-FYVDK4M2.js → identity-CGHHF7AK.js} +8 -6
  110. package/dist/bundle/{instructions-D3GF3B7M.js → instructions-24PHDBBE.js} +1 -1
  111. package/dist/bundle/{login-COFZ2IWP.js → login-XHFESAFM.js} +73 -64
  112. package/dist/bundle/{mcp-RKJG22KM.js → mcp-M5YCSWJJ.js} +2 -2
  113. package/dist/bundle/{node-OFICOKX3.js → node-GIDULTV5.js} +2 -2
  114. package/dist/bundle/{node-KM3CUABH.js → node-P4E63KXA.js} +9 -9
  115. package/dist/bundle/{node-sqlite-DNBTDOXD.js → node-sqlite-LINBOAWK.js} +13 -9
  116. package/dist/bundle/oauth-JHUX3KE3.js +22 -0
  117. package/dist/bundle/{open-PTPR2YWX.js → open-RYFKPNCJ.js} +8 -8
  118. package/dist/bundle/{openai-2KV5LUW4.js → openai-Q7YYUHJF.js} +28 -42
  119. package/dist/bundle/{process-EAW6NST2.js → process-VPIZTIJR.js} +1 -1
  120. package/dist/bundle/{program-6UV5Q5YN.js → program-IUXFRBZA.js} +419 -604
  121. package/dist/bundle/{prompt-634TPMJK.js → prompt-LF4KX3XL.js} +8 -8
  122. package/dist/bundle/{reasons-DDWCEYSQ.js → reasons-JPYOU5GV.js} +5 -5
  123. package/dist/bundle/{recognize-SJO6QUDW.js → recognize-KEWTJXFH.js} +7 -7
  124. package/dist/bundle/{remote-6JXZITKF.js → remote-HGGLB76S.js} +13 -10
  125. package/dist/bundle/{rerank-MD5VOPQ6.js → rerank-TDUKETFT.js} +10 -10
  126. package/dist/bundle/{serve-LZTROA2M.js → serve-XFYMKW5W.js} +12 -12
  127. package/dist/bundle/server-BDEV3CZJ.js +74 -0
  128. package/dist/bundle/{server-NSA3UAFY.js → server-PXIPSGFP.js} +48 -44
  129. package/dist/bundle/{services-F5A6XQCV.js → services-2BOCGMJU.js} +111 -41
  130. package/dist/bundle/{sqlite-runtime-7YF6REKS.js → sqlite-runtime-R7M5XUMW.js} +9 -9
  131. package/dist/bundle/{start-MUFLE6FA.js → start-YRLT4MQZ.js} +7 -7
  132. package/dist/bundle/{state-UC54F3YZ.js → state-NZ7WRJWH.js} +9 -9
  133. package/dist/bundle/{store-F5FJGWMR.js → store-7LCVDO7G.js} +63 -28
  134. package/dist/bundle/{store-J53YNAH6.js → store-ICDGPSEN.js} +27 -18
  135. package/dist/bundle/store-maintenance-command-SJPLY6IH.js +65 -0
  136. package/dist/bundle/tokens-FGTBE7VW.js +111 -0
  137. package/dist/commands/config.d.ts.map +1 -1
  138. package/dist/commands/config.js +6 -5
  139. package/dist/commands/config.js.map +1 -1
  140. package/dist/commands/context.d.ts +4 -2
  141. package/dist/commands/context.d.ts.map +1 -1
  142. package/dist/commands/context.js.map +1 -1
  143. package/dist/commands/discovery.d.ts +0 -1
  144. package/dist/commands/discovery.d.ts.map +1 -1
  145. package/dist/commands/discovery.js +6 -26
  146. package/dist/commands/discovery.js.map +1 -1
  147. package/dist/commands/documents.d.ts +2 -0
  148. package/dist/commands/documents.d.ts.map +1 -1
  149. package/dist/commands/documents.js +39 -3
  150. package/dist/commands/documents.js.map +1 -1
  151. package/dist/commands/knowledge.d.ts.map +1 -1
  152. package/dist/commands/knowledge.js +7 -6
  153. package/dist/commands/knowledge.js.map +1 -1
  154. package/dist/commands/search.d.ts.map +1 -1
  155. package/dist/commands/search.js +11 -8
  156. package/dist/commands/search.js.map +1 -1
  157. package/dist/config.d.ts +14 -0
  158. package/dist/config.d.ts.map +1 -1
  159. package/dist/config.js +35 -4
  160. package/dist/config.js.map +1 -1
  161. package/dist/contract-overrides.d.ts +16 -4
  162. package/dist/contract-overrides.d.ts.map +1 -1
  163. package/dist/contract-overrides.js +86 -410
  164. package/dist/contract-overrides.js.map +1 -1
  165. package/dist/documents-add.d.ts +49 -0
  166. package/dist/documents-add.d.ts.map +1 -0
  167. package/dist/documents-add.js +122 -0
  168. package/dist/documents-add.js.map +1 -0
  169. package/dist/errors.d.ts +1 -0
  170. package/dist/errors.d.ts.map +1 -1
  171. package/dist/errors.js +13 -1
  172. package/dist/errors.js.map +1 -1
  173. package/dist/google-api.d.ts.map +1 -1
  174. package/dist/google-api.js +4 -1
  175. package/dist/google-api.js.map +1 -1
  176. package/dist/identity.d.ts +4 -0
  177. package/dist/identity.d.ts.map +1 -1
  178. package/dist/identity.js +22 -0
  179. package/dist/identity.js.map +1 -1
  180. package/dist/knowledge.d.ts +1 -1
  181. package/dist/knowledge.d.ts.map +1 -1
  182. package/dist/knowledge.js +17 -19
  183. package/dist/knowledge.js.map +1 -1
  184. package/dist/login.d.ts.map +1 -1
  185. package/dist/login.js +2 -2
  186. package/dist/login.js.map +1 -1
  187. package/dist/model.d.ts +3 -0
  188. package/dist/model.d.ts.map +1 -1
  189. package/dist/model.js.map +1 -1
  190. package/dist/program.d.ts.map +1 -1
  191. package/dist/program.js +30 -21
  192. package/dist/program.js.map +1 -1
  193. package/dist/reasons.d.ts.map +1 -1
  194. package/dist/reasons.js +25 -1
  195. package/dist/reasons.js.map +1 -1
  196. package/dist/store-transition.js +2 -2
  197. package/dist/store-transition.js.map +1 -1
  198. package/dist/store.d.ts.map +1 -1
  199. package/dist/store.js +27 -7
  200. package/dist/store.js.map +1 -1
  201. package/dist/tokens.d.ts +9 -2
  202. package/dist/tokens.d.ts.map +1 -1
  203. package/dist/tokens.js +18 -15
  204. package/dist/tokens.js.map +1 -1
  205. package/dist/version.d.ts +1 -1
  206. package/dist/version.js +1 -1
  207. package/dist/wcat.d.ts +3 -0
  208. package/dist/wcat.d.ts.map +1 -0
  209. package/dist/wcat.js +4 -0
  210. package/dist/wcat.js.map +1 -0
  211. package/package.json +8 -8
  212. package/dist/bundle/chunk-3NULZGQU.js +0 -27
  213. package/dist/bundle/chunk-DD7EFG6B.js +0 -35
  214. package/dist/bundle/chunk-M73NNJ3X.js +0 -26
  215. package/dist/bundle/chunk-SBZB7HMU.js +0 -1055
  216. package/dist/bundle/command-contract-H5OYJOPF.js +0 -38
  217. package/dist/bundle/dist-PY3MVR3G.js +0 -21
  218. package/dist/bundle/entry-YZBB647C.js +0 -22
  219. package/dist/bundle/first-run-5JT3UQZB.js +0 -30
  220. package/dist/bundle/first-screen-BEMDEWO7.js +0 -36
  221. package/dist/bundle/google-DVADVICN.js +0 -36
  222. package/dist/bundle/grants-WKB2E4TA.js +0 -103
  223. package/dist/bundle/oauth-PDQHWFBF.js +0 -22
  224. package/dist/bundle/server-GT7X666D.js +0 -69
  225. package/dist/bundle/store-maintenance-command-GJVXLBAB.js +0 -58
  226. package/dist/bundle/tokens-H2EJKGA5.js +0 -101
  227. package/dist/bundle/{chunk-SW6C6WH5.js → chunk-HVJJWJYQ.js} +0 -0
  228. package/dist/bundle/{mdast-util-from-markdown-FXEPSNER.js → mdast-util-from-markdown-CE73EWJ2.js} +3 -3
@@ -1,17 +1,12 @@
1
1
  import { createRequire as __bundleRequire } from "node:module";
2
2
  const require = __bundleRequire(import.meta.url);
3
3
  import {
4
- ADDED_PROVIDER,
5
4
  MIGRATIONS,
6
5
  SnapshotBudget,
7
6
  assertReadCompatible,
8
7
  botNamed,
9
8
  canonicalTagNamed,
10
9
  decodeProjectAnnotationSnapshot,
11
- filesAccountSql,
12
- folderProviderOf,
13
- folderProviderSql,
14
- isDocumentAccountProvider,
15
10
  migrate,
16
11
  openSqlite,
17
12
  openStoreContext,
@@ -28,28 +23,48 @@ import {
28
23
  tagMemberIds,
29
24
  thingOf,
30
25
  write
31
- } from "./chunk-EWGVDFPT.js";
32
- import {
33
- damagedFile
34
- } from "./chunk-B67BLRAI.js";
26
+ } from "./chunk-BIJW6AYA.js";
35
27
  import {
36
28
  fold
37
- } from "./chunk-VIJ6ACYB.js";
29
+ } from "./chunk-LVAPSAHF.js";
30
+ import {
31
+ ADDED_PROVIDER,
32
+ filesAccountSql,
33
+ folderProviderOf,
34
+ folderProviderSql,
35
+ isDocumentAccountProvider
36
+ } from "./chunk-QJ57PV55.js";
37
+ import {
38
+ damagedFile
39
+ } from "./chunk-O53WLYX3.js";
38
40
  import {
39
41
  CliError
40
- } from "./chunk-EJ4PNHPP.js";
42
+ } from "./chunk-IIHZTV6V.js";
41
43
  import {
42
44
  __name
43
45
  } from "./chunk-ZVVMGPBJ.js";
44
46
 
45
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/damage.js
47
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/damage.js
46
48
  var DERIVED = /* @__PURE__ */ new Set(["mentions", "involvements", "embeddings"]);
47
49
  var named = /* @__PURE__ */ __name((tables) => tables.length <= 5 ? tables.join(", ") : `${tables.slice(0, 5).join(", ")} and ${tables.length - 5} more`, "named");
48
50
  var isDerivedTable = /* @__PURE__ */ __name((table, searchIndexes) => DERIVED.has(table) || table.startsWith("vector_index_") || searchIndexes.some((index) => table === index || table.startsWith(`${index}_`)), "isDerivedTable");
49
51
  var WIRECAT_UNITS = ["memo-*", "mail-*", "tg-*", "max-*", "wirecat-*"];
50
52
  var seen = /* @__PURE__ */ __name((mark) => `\`${mark.command}\` found the store damaged at ${mark.at} (${mark.error})`, "seen");
51
- var explainDamage = /* @__PURE__ */ __name((health, command, mark = null) => {
52
- if (health.ok && !mark)
53
+ var journalSeen = /* @__PURE__ */ __name((store, { seen: seen2, command, at }) => {
54
+ const wal = `${store.replace(/^.*\//, "")}-wal`;
55
+ return seen2 === "shm-without-wal" ? `the store's journal file (${wal}) was missing when \`${command}\` opened the store at ${at}: another program deleted it, or a tool crashed while closing` : `the store's journal file (${wal}) was deleted or replaced by another program while \`${command}\` had the store open (${at})`;
56
+ }, "journalSeen");
57
+ var lossUnknown = /* @__PURE__ */ __name((lastOkAt, gone = false) => {
58
+ const since = lastOkAt ? `since the last deep check that passed (${lastOkAt})` : "since the store was made (no deep check that passed is on record)";
59
+ return `${gone ? "more rows may be gone" : "how many rows were lost is unknown"}: damage can take rows written ${since} without leaving a trace; a sync fetches again what the servers still hold`;
60
+ }, "lossUnknown");
61
+ var stopWriters = /* @__PURE__ */ __name((timers) => ({
62
+ command: timers?.length ? `systemctl --user stop ${timers.join(" ")}` : `systemctl --user stop ${WIRECAT_UNITS.map((unit) => `'${unit}'`).join(" ")}`,
63
+ why: "a tool that writes while the store is recovered damages the new file too",
64
+ destructive: false
65
+ }), "stopWriters");
66
+ var storeDamageReport = /* @__PURE__ */ __name(({ health, command, mark = null, journal = null, lastOkAt = null, holders = null, timers = null, sqlite3Usable = true }) => {
67
+ if (health.ok && !mark && !journal)
53
68
  return null;
54
69
  const indexNames = (health.searchIndexes ?? []).map((index) => index.name);
55
70
  const badIndexes = (health.searchIndexes ?? []).filter((index) => !index.ok).map((index) => index.name);
@@ -58,42 +73,85 @@ var explainDamage = /* @__PURE__ */ __name((health, command, mark = null) => {
58
73
  const derived = [.../* @__PURE__ */ new Set([...tables.filter((table) => isDerivedTable(table, indexNames)), ...badIndexes])];
59
74
  const unopened = health.error !== void 0;
60
75
  const json = (health.invalidJson ?? []).map(({ table, column }) => `${table}.${column}`);
61
- const checked = health.ok ? `${seen(mark)}; the quick check reads too little to see it, and a deep check that passes clears it` : unopened ? `the store file cannot be opened: ${health.error}` : health.checked === "quick" ? "the store file's header or schema is damaged" : `the store file is damaged: ${health.problems ?? 0} problems` + (sources.length ? ` in the data of ${named(sources)}` : "") + (derived.length ? `${sources.length ? ", and" : " in"} the search data of ${named(derived)}` : "") + (json.length ? `; values that are not valid JSON in ${named(json)}` : "");
62
- const what = mark && !health.ok ? `${checked}; ${seen(mark)}` : checked;
76
+ const damaged = !health.ok || mark !== null;
77
+ const folder = health.path.replace(/\/[^/]*$/, "");
78
+ const checked = !damaged ? `every page of the store reads, but ${journalSeen(health.path, journal)}; what was written into it may be lost` : health.ok ? `${seen(mark)}; the quick check reads too little to see it, and a deep check that passes clears it` : unopened ? `the store file cannot be opened: ${health.error}` : health.checked === "quick" ? "the store file's header or schema is damaged" : `the store file is damaged: ${health.problems ?? 0} problems` + (sources.length ? ` in the data of ${named(sources)}` : "") + (derived.length ? `${sources.length ? ", and" : " in"} the search data of ${named(derived)}` : "") + (json.length ? `; values that are not valid JSON in ${named(json)}` : "");
79
+ const whatHappened = mark && !health.ok ? `${checked}; ${seen(mark)}` : checked;
63
80
  const impact = [
64
81
  ...sources.length ? [`some rows of ${named(sources)} cannot be read; a recovery keeps every row it can read and names the rest`] : [],
65
82
  ...derived.length ? [`searches may miss results or fail; ${named(derived)} hold nothing that is not elsewhere, and are rebuilt`] : [],
66
83
  ...json.length ? [`a read of a row with a broken JSON value fails ("malformed JSON"); a recovery clears those values`] : [],
67
- mark ? "reads that do not touch a damaged page work; every command that writes the store refuses until it is recovered" : "reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"
84
+ ...!damaged ? ["everything works; rows written while the journal was gone may be missing, and a sync fetches them again"] : mark ? [
85
+ "reads that do not touch a damaged page work; every command that writes the store refuses until it is recovered"
86
+ ] : ["reads that do not touch a damaged page work; a write that touches one fails until the store is recovered"]
87
+ ];
88
+ const likelyCauses = [
89
+ ...journal ? [{ cause: journalSeen(health.path, journal), check: `ls -li --time-style=full-iso ${folder}/` }] : [],
90
+ ...holders?.length ? [
91
+ {
92
+ cause: `two programs wrote the file without seeing each other: ${holders.map(({ name, pid }) => `${name} (process ${pid})`).join(", ")} still ${holders.length === 1 ? "has" : "have"} it open`,
93
+ check: `fuser -v ${health.path}`
94
+ }
95
+ ] : [],
96
+ ...damaged ? [
97
+ {
98
+ cause: "the computer lost power or crashed while a tool was writing",
99
+ check: `journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`
100
+ },
101
+ { cause: "the disk filled up while a tool was writing", check: `df -h ${folder}` },
102
+ {
103
+ cause: "the file was copied, restored or synced while a tool had it open, or it sits in a synced or network folder",
104
+ check: `findmnt -T ${folder}`
105
+ },
106
+ {
107
+ cause: "a fault of the disk itself",
108
+ check: "journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata"
109
+ }
110
+ ] : []
111
+ ];
112
+ const steps = [
113
+ stopWriters(timers),
114
+ ...(holders ?? []).map(({ pid, name }) => ({
115
+ command: `kill ${pid}`,
116
+ why: `${name} (process ${pid}) has the store open`,
117
+ destructive: true
118
+ })),
119
+ ...damaged && !sqlite3Usable ? [
120
+ {
121
+ command: "sudo apt install sqlite3",
122
+ why: "the recovery copies rows with the sqlite3 program, 3.43 or newer (on macOS: brew install sqlite)",
123
+ destructive: false
124
+ }
125
+ ] : [],
126
+ ...damaged ? [
127
+ {
128
+ command: `${command} store recover run`,
129
+ why: "copies every readable row into a new file and puts it in place of the store; the damaged file is kept beside it, and it prints the syncs that fetch again what was lost",
130
+ destructive: true
131
+ }
132
+ ] : [],
133
+ {
134
+ command: `${command} store recover`,
135
+ why: "checks every page again; a check that passes lifts the damage mark",
136
+ destructive: false
137
+ }
68
138
  ];
69
139
  return {
70
- what,
71
- causes: [
72
- "the computer lost power or crashed, or the disk filled up, while a tool was writing",
73
- "the file was copied, restored or synced while a tool had it open, or it sits in a synced or network folder",
74
- "a fault of the disk itself"
75
- ],
76
- investigate: [
77
- `journalctl --user ${WIRECAT_UNITS.map((unit) => `-u '${unit}'`).join(" ")} --since -14d | grep -i -e malformed -e corrupt -e 'disk full'`,
78
- "journalctl -k --since -14d | grep -i -e 'I/O error' -e nvme -e ata",
79
- `df -h ${health.path.replace(/\/[^/]*$/, "")}`,
80
- ...health.checked === "quick" || health.ok ? [`${command} store recover`] : []
81
- ],
140
+ whatHappened,
141
+ likelyCauses,
82
142
  impact,
83
- externalUnaffected: "only this computer's copy is damaged: Telegram, MAX, the mail servers and Google Drive keep their own data, so whatever is lost here can be fetched again by a sync",
84
- steps: [
85
- "stop every timer and server of the WireCat tools; `store recover run` lists the ones still running",
86
- `${command} store recover run`,
87
- "run the fetch commands it prints, then start the timers again"
88
- ]
143
+ externalDataSafe: "only this computer's copy is damaged: Telegram, MAX, WhatsApp, the mail servers and Google Drive keep their own data, so whatever is lost here can be fetched again by a sync",
144
+ lastOkAt,
145
+ loss: lossUnknown(lastOkAt),
146
+ steps
89
147
  };
90
- }, "explainDamage");
148
+ }, "storeDamageReport");
91
149
 
92
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/document-transfer/index.js
150
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/document-transfer/index.js
93
151
  import { realpathSync, statSync } from "node:fs";
94
152
  import { resolve } from "node:path";
95
153
 
96
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/people.js
154
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/people.js
97
155
  var planPeople = /* @__PURE__ */ __name((database, snapshot, mappings, bindings, conflicts) => {
98
156
  const creatable = /* @__PURE__ */ new Set();
99
157
  let people = 0, identities = 0;
@@ -156,11 +214,11 @@ var copyPeople = /* @__PURE__ */ __name((database, snapshot, mappings, now) => {
156
214
  }
157
215
  }, "copyPeople");
158
216
 
159
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/document-transfer/digest.js
217
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/document-transfer/digest.js
160
218
  import { createHash } from "node:crypto";
161
219
  var digest = /* @__PURE__ */ __name((value) => createHash("sha256").update(JSON.stringify(value)).digest("hex"), "digest");
162
220
 
163
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/collection.js
221
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/collection.js
164
222
  var documentsKeyOf = /* @__PURE__ */ __name((collection) => {
165
223
  const colon = collection.indexOf(":");
166
224
  const provider = collection.slice(0, colon);
@@ -204,7 +262,7 @@ var currentCollection = /* @__PURE__ */ __name((row) => {
204
262
  };
205
263
  }, "currentCollection");
206
264
 
207
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/plan.js
265
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/plan.js
208
266
  var planTransfer = /* @__PURE__ */ __name((database, snapshot, sourceKey, bindings) => {
209
267
  const mappings = /* @__PURE__ */ new Map();
210
268
  const missing = /* @__PURE__ */ new Set(), conflicts = /* @__PURE__ */ new Set();
@@ -371,7 +429,7 @@ var planTransfer = /* @__PURE__ */ __name((database, snapshot, sourceKey, bindin
371
429
  };
372
430
  }, "planTransfer");
373
431
 
374
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
432
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/snapshot.js
375
433
  var TRANSFER_TABLES = { document: "documents", note: "notes", memory: "memories", fact: "facts" };
376
434
  var MAX_ENTITIES = 1e3;
377
435
  var MAX_AUXILIARY = 1e4;
@@ -533,7 +591,7 @@ var transferSnapshot = /* @__PURE__ */ __name((database, collection) => read(dat
533
591
  };
534
592
  }), "transferSnapshot");
535
593
 
536
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/apply.js
594
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/sqlite/document-transfer/apply.js
537
595
  var providerHere = /* @__PURE__ */ __name(({ provider, name, settings }) => {
538
596
  if (provider !== "folder" || String(name ?? "").startsWith("google-drive:"))
539
597
  return provider ?? null;
@@ -705,7 +763,7 @@ var remapEntity = /* @__PURE__ */ __name((database, entity, id, mappings) => {
705
763
  database.prepare(`UPDATE ${TRANSFER_TABLES[entity.kind]} SET ${columns.join(",")} WHERE id=?`).run(...values, id);
706
764
  }, "remapEntity");
707
765
 
708
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/document-transfer/index.js
766
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/document-transfer/index.js
709
767
  var locations = /* @__PURE__ */ __name((options) => {
710
768
  for (const value of [options.source, options.destination, options.collection])
711
769
  if (typeof value !== "string" || !value.trim())
@@ -807,7 +865,7 @@ var applyWith = /* @__PURE__ */ __name(async (location, options) => {
807
865
  }
808
866
  }, "applyWith");
809
867
 
810
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/health.js
868
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/health.js
811
869
  import { existsSync, statSync as statSync2 } from "node:fs";
812
870
  var JSON_COLUMNS = {
813
871
  accounts: ["settings"],
@@ -949,7 +1007,7 @@ var storeHealth = /* @__PURE__ */ __name(async (path, { deep = false } = {}) =>
949
1007
  }
950
1008
  }, "storeHealth");
951
1009
 
952
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/project-transfer/preview.js
1010
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/project-transfer/preview.js
953
1011
  var previewProjectAnnotationSnapshot = /* @__PURE__ */ __name(async (options) => {
954
1012
  if (!options || typeof options !== "object" || Array.isArray(options))
955
1013
  throw new CliError("validation_error", "project preview options are required");
@@ -975,7 +1033,7 @@ var previewProjectAnnotationSnapshot = /* @__PURE__ */ __name(async (options) =>
975
1033
  });
976
1034
  }, "previewProjectAnnotationSnapshot");
977
1035
 
978
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot.js
1036
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot.js
979
1037
  var snapshotProjectAnnotations = /* @__PURE__ */ __name(async (options) => {
980
1038
  if (!options || typeof options !== "object" || Array.isArray(options))
981
1039
  throw new CliError("validation_error", "snapshot options are required");
@@ -997,7 +1055,8 @@ var snapshotProjectAnnotations = /* @__PURE__ */ __name(async (options) => {
997
1055
  }, "snapshotProjectAnnotations");
998
1056
 
999
1057
  export {
1000
- explainDamage,
1058
+ lossUnknown,
1059
+ storeDamageReport,
1001
1060
  invalidJson,
1002
1061
  QUICK_HEALTH_CHECKS,
1003
1062
  fts5Tables,
@@ -5,9 +5,8 @@ import {
5
5
  } from "./chunk-HTQTIKWP.js";
6
6
  import {
7
7
  commandPathOf,
8
- findCommand,
9
8
  outputOf
10
- } from "./chunk-TNV2FXVK.js";
9
+ } from "./chunk-UAKX6DP4.js";
11
10
  import {
12
11
  Command,
13
12
  Help,
@@ -18,122 +17,18 @@ import {
18
17
  environmentOf,
19
18
  metaOf,
20
19
  takesProfile
21
- } from "./chunk-LOMW6F2E.js";
20
+ } from "./chunk-5PLINHEY.js";
22
21
  import {
23
22
  writes
24
- } from "./chunk-BDYWZ7JE.js";
23
+ } from "./chunk-VQKNKJYL.js";
25
24
  import {
26
25
  CliError
27
- } from "./chunk-EJ4PNHPP.js";
26
+ } from "./chunk-IIHZTV6V.js";
28
27
  import {
29
28
  __name
30
29
  } from "./chunk-ZVVMGPBJ.js";
31
30
 
32
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/cli/help/sections.js
33
- var SECTIONS = {
34
- read: "Read",
35
- write: "Write",
36
- organise: "Organise",
37
- automate: "Automate",
38
- setup: "Set up",
39
- other: "Other"
40
- };
41
- var sections = /* @__PURE__ */ new WeakMap();
42
- var inSection = /* @__PURE__ */ __name((command, section) => {
43
- sections.set(command, section);
44
- return command;
45
- }, "inSection");
46
- var sectionOf = /* @__PURE__ */ __name((command) => {
47
- for (let at = command; at; at = at.parent) {
48
- const section = sections.get(at) ?? (at.parent && !at.parent.parent ? CORE_SECTIONS[at.name()] : void 0);
49
- if (section)
50
- return section;
51
- }
52
- return "other";
53
- }, "sectionOf");
54
- var CORE_SECTIONS = {
55
- attachments: "read",
56
- chats: "read",
57
- contacts: "read",
58
- conversations: "read",
59
- images: "read",
60
- inbox: "read",
61
- meetings: "read",
62
- mentions: "read",
63
- messages: "read",
64
- review: "read",
65
- search: "read",
66
- stats: "read",
67
- topics: "read",
68
- watch: "read",
69
- flood: "write",
70
- polls: "write",
71
- reactions: "write",
72
- recipients: "write",
73
- sends: "write",
74
- metadata: "organise",
75
- searches: "organise",
76
- tags: "organise",
77
- tasks: "organise",
78
- bot: "automate",
79
- mcp: "automate",
80
- replies: "automate",
81
- runs: "automate",
82
- schedule: "automate",
83
- serve: "automate",
84
- server: "automate",
85
- account: "setup",
86
- commands: "setup",
87
- complete: "setup",
88
- config: "setup",
89
- doctor: "setup",
90
- guide: "setup",
91
- models: "setup",
92
- skill: "setup",
93
- store: "setup",
94
- upgrade: "setup"
95
- };
96
-
97
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/cli/help/commands-text.js
98
- var DESCRIPTION = 90;
99
- var COLUMN = 52;
100
- var short = /* @__PURE__ */ __name((text) => {
101
- const line = text.replace(/\s+/g, " ").trim();
102
- if (line.length <= DESCRIPTION)
103
- return line;
104
- const cut = line.slice(0, DESCRIPTION);
105
- return `${cut.slice(0, Math.max(cut.lastIndexOf(" "), DESCRIPTION / 2))}\u2026`;
106
- }, "short");
107
- var commandsText = /* @__PURE__ */ __name((root, commands, scope) => {
108
- const cli = root.name();
109
- const runs = /* @__PURE__ */ __name((info) => [
110
- ...info.commands.length === 0 || info.runnable ? [info] : [],
111
- ...info.commands.flatMap(runs)
112
- ], "runs");
113
- const bySection = new Map(Object.keys(SECTIONS).map((key) => [key, []]));
114
- for (const info of commands.flatMap(runs))
115
- bySection.get(sectionOf(findCommand(root, info.path)))?.push(info);
116
- const where = scope ? `${cli} ${scope.join(" ")}` : cli;
117
- const lines = [
118
- `${where} commands, by section. One command's arguments and options: ${cli} <command> --help.`,
119
- `As JSON: ${cli} commands${scope ? ` ${scope.join(" ")}` : ""} --json. (writes) marks a command that changes something.`
120
- ];
121
- for (const [section, infos] of bySection) {
122
- if (infos.length === 0)
123
- continue;
124
- lines.push("", SECTIONS[section]);
125
- for (const { usage, summary, description, effects, availability } of infos) {
126
- const what = short(summary ?? description);
127
- const mark = effects === void 0 || writes(effects) ? " (writes)" : "";
128
- const access = availability?.available === false ? ` [unavailable: ${availability.reason}]` : "";
129
- lines.push(` ${usage.padEnd(COLUMN)} ${what}${mark}${access}`.trimEnd());
130
- }
131
- }
132
- return `${lines.join("\n")}
133
- `;
134
- }, "commandsText");
135
-
136
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/cli/help/command-help.js
31
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/help/command-help.js
137
32
  var ARGUMENT_KINDS = {
138
33
  chat: "chat",
139
34
  chats: "chat",
@@ -206,8 +101,13 @@ var SAMPLES = {
206
101
  };
207
102
  var MAX_NEXT = 3;
208
103
  var choices = /* @__PURE__ */ new WeakMap();
104
+ var nextUsually = /* @__PURE__ */ __name((command, choice) => {
105
+ choices.set(command, choice);
106
+ return command;
107
+ }, "nextUsually");
209
108
  var kindOfArgument = /* @__PURE__ */ __name((argument) => ARGUMENT_KINDS[argument.name()], "kindOfArgument");
210
- var leaves = /* @__PURE__ */ __name((command) => command.commands.filter((child) => !child._hidden).flatMap((child) => child.commands.length === 0 ? [child] : leaves(child)), "leaves");
109
+ var runs = /* @__PURE__ */ __name((command) => command.commands.length === 0 || Boolean(command._actionHandler), "runs");
110
+ var leaves = /* @__PURE__ */ __name((command) => command.commands.filter((child) => !child._hidden).flatMap((child) => [...runs(child) ? [child] : [], ...leaves(child)]), "leaves");
211
111
  var rootOf = /* @__PURE__ */ __name((command) => {
212
112
  let at = command;
213
113
  while (at.parent)
@@ -230,7 +130,7 @@ var returnsOf = /* @__PURE__ */ __name((command) => {
230
130
  const output = metaOf(command).output;
231
131
  const { item, coverage } = outputOf(command);
232
132
  if (!output || coverage !== "declared-entity")
233
- return short(command.summary() || command.description()) || "not declared";
133
+ return "";
234
134
  const fields = [...new Set(fieldsOf(item))];
235
135
  const noun = (output.view ? `${output.entity} ${output.view}` : output.entity).replaceAll("_", " ");
236
136
  const more = fields.length > 8 ? `, and ${fields.length - 8} more` : "";
@@ -312,20 +212,45 @@ var commandHelpText = /* @__PURE__ */ __name((command) => {
312
212
  return [
313
213
  "",
314
214
  ...access,
315
- ...rows("Returns:", [returns]),
215
+ ...rows("Returns:", returns ? [returns] : []),
316
216
  ...rows("Next usually:", next),
317
217
  ...rows("Example:", examples),
318
218
  ""
319
219
  ].join("\n");
320
220
  }, "commandHelpText");
221
+ var commandHelpMarkdown = /* @__PURE__ */ __name((root, path) => {
222
+ const command = commandAt(root, path.join(" "));
223
+ if (!command || !runs(command))
224
+ return [];
225
+ const { returns, next, examples } = commandHelp(command);
226
+ const code = /* @__PURE__ */ __name((values) => values.map((value) => `\`${value}\``).join(", "), "code");
227
+ return [
228
+ ...returns ? [`**Returns:** ${returns}`] : [],
229
+ ...next.length > 0 ? [`**Next usually:** ${code(next)}`] : [],
230
+ `**Example:** ${code(examples)}`
231
+ ];
232
+ }, "commandHelpMarkdown");
321
233
  var installCommandHelp = /* @__PURE__ */ __name((program, { profile = true } = {}) => {
322
234
  if (profile)
323
235
  profiled.add(program);
324
236
  for (const command of leaves(program))
325
237
  command.addHelpText("after", () => commandHelpText(command));
326
238
  }, "installCommandHelp");
239
+ var exampleReport = /* @__PURE__ */ __name((program) => {
240
+ const written = [];
241
+ const generated = [];
242
+ for (const command of leaves(program))
243
+ (commandHelp(command).origin === "written" ? written : generated).push(commandPathOf(command).join(" "));
244
+ const total = written.length + generated.length;
245
+ const text = [
246
+ `${program.name()}: ${written.length} of ${total} commands have a written example; ${generated.length} show a generated one:`,
247
+ ...generated.map((path) => ` ${program.name()} ${path}`),
248
+ ""
249
+ ].join("\n");
250
+ return { written, generated, text };
251
+ }, "exampleReport");
327
252
 
328
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/cli/help/first-screen.js
253
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/cli/help/first-screen.js
329
254
  var WIRECAT_TOOLS = [
330
255
  {
331
256
  command: "tg",
@@ -367,6 +292,11 @@ var WIRECAT_TOOLS = [
367
292
  command: "mail",
368
293
  package: "@wirecat/mail-cli",
369
294
  does: "IMAP mail in the same local store: search your mailbox offline, next to your other WireCat data"
295
+ },
296
+ {
297
+ command: "b24",
298
+ package: "@wirecat/bitrix24-cli",
299
+ does: "Bitrix24 CRM: deals, leads and pipelines, searchable with your other WireCat data"
370
300
  }
371
301
  ];
372
302
  var WIDTH = 100;
@@ -458,8 +388,11 @@ var installHelp = /* @__PURE__ */ __name((program, screen = {}) => {
458
388
  }, "installHelp");
459
389
 
460
390
  export {
461
- inSection,
462
- commandsText,
391
+ nextUsually,
392
+ commandHelp,
393
+ commandHelpText,
394
+ commandHelpMarkdown,
395
+ exampleReport,
463
396
  WIRECAT_TOOLS,
464
397
  firstScreen,
465
398
  installHelp
@@ -0,0 +1,53 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ resolvePaths
5
+ } from "./chunk-6X3KUFRQ.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-ZVVMGPBJ.js";
9
+
10
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/store/path.js
11
+ import { realpathSync } from "node:fs";
12
+ import { userInfo } from "node:os";
13
+ import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
14
+ var wirecatDirectory = /* @__PURE__ */ __name((env = process.env, platform) => resolvePaths({ appName: "WireCat", prefix: "WIRECAT", env, ...platform ? { platform } : {} }).state, "wirecatDirectory");
15
+ var storePath = /* @__PURE__ */ __name((env = process.env) => env.MESSAGING_STORE ?? join(wirecatDirectory(env), "wirecat.db"), "storePath");
16
+ var accountHome = /* @__PURE__ */ __name(() => {
17
+ try {
18
+ return userInfo().homedir;
19
+ } catch {
20
+ return void 0;
21
+ }
22
+ }, "accountHome");
23
+ var inOwnerFolder = /* @__PURE__ */ __name((file, home = accountHome()) => {
24
+ if (!home || file === ":memory:")
25
+ return false;
26
+ const owner = wirecatDirectory({ HOME: home, USERPROFILE: home });
27
+ const within = /* @__PURE__ */ __name((path, folder) => {
28
+ const inside = relative(folder, path);
29
+ return !(inside.startsWith("..") || isAbsolute(inside));
30
+ }, "within");
31
+ return within(resolve(file), owner) || within(settled(resolve(file)), settled(owner));
32
+ }, "inOwnerFolder");
33
+ var settled = /* @__PURE__ */ __name((path) => {
34
+ try {
35
+ return realpathSync(path);
36
+ } catch {
37
+ const parent = dirname(path);
38
+ return parent === path ? path : join(settled(parent), basename(path));
39
+ }
40
+ }, "settled");
41
+ var refuseOwnerStoreInTests = /* @__PURE__ */ __name((file, env = process.env, home = accountHome()) => {
42
+ if (!env.VITEST || !inOwnerFolder(file, home))
43
+ return;
44
+ throw new Error(`a test tried to open ${file}, in the owner's real WireCat folder; give it a MESSAGING_STORE or HOME of its own`);
45
+ }, "refuseOwnerStoreInTests");
46
+
47
+ export {
48
+ wirecatDirectory,
49
+ storePath,
50
+ accountHome,
51
+ inOwnerFolder,
52
+ refuseOwnerStoreInTests
53
+ };
@@ -4,7 +4,7 @@ import {
4
4
  __name
5
5
  } from "./chunk-ZVVMGPBJ.js";
6
6
 
7
- // node_modules/.pnpm/@wirecat+cli-core@0.614.0_@wirecat+cli-base@0.82.0_commander@15.0.0_esbuild@0.28.2_type_e0755e4bb52a6ea6d9033617574418d1/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.650.0_@wirecat+cli-base@0.98.0_commander@15.0.0_esbuild@0.28.2_type_7618ae642a1b316105e0e055c769f604/node_modules/@wirecat/cli-core/dist/mcp/instructions.js
8
8
  var instructions = /* @__PURE__ */ __name(({ command, name, profile, writes, skill }) => {
9
9
  const all = typeof profile !== "string";
10
10
  const offers = /* @__PURE__ */ __name((key) => all || writes.includes(key), "offers");