tenjin-cli 0.1.0-alpha.15 → 0.1.0-alpha.16

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 (267) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +41 -310
  3. package/dist/{_esm-N4KAVXQR.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/{ccip-ZGGWQN4X.js → ccip-7RMRLAGV.js} +4 -4
  5. package/dist/{ccip-RPPPKTJR.js → ccip-NLCSCHKI.js} +5 -5
  6. package/dist/chunk-25TJPVBF.js +353 -0
  7. package/dist/chunk-25TJPVBF.js.map +1 -0
  8. package/dist/chunk-2BKS2FVE.js +93 -0
  9. package/dist/chunk-2BKS2FVE.js.map +1 -0
  10. package/dist/chunk-2QYORQBF.js +55 -0
  11. package/dist/chunk-2QYORQBF.js.map +1 -0
  12. package/dist/{chunk-NIKXHWOL.js → chunk-2U5ZVEV3.js} +16 -16
  13. package/dist/chunk-2U5ZVEV3.js.map +1 -0
  14. package/dist/{chunk-HPJGOLTN.js → chunk-3AJS6LLN.js} +13 -8
  15. package/dist/chunk-3AJS6LLN.js.map +1 -0
  16. package/dist/{chunk-KINZ23CV.js → chunk-3AUDA53C.js} +4740 -23
  17. package/dist/chunk-3AUDA53C.js.map +1 -0
  18. package/dist/{chunk-MJZZTKCC.js → chunk-56MOAIP5.js} +5 -10
  19. package/dist/chunk-56MOAIP5.js.map +1 -0
  20. package/dist/{chunk-U5S527PP.js → chunk-5IEP5EGE.js} +3 -3
  21. package/dist/chunk-5X4SZ5BF.js +227 -0
  22. package/dist/chunk-5X4SZ5BF.js.map +1 -0
  23. package/dist/chunk-7WEQQJLG.js +68 -0
  24. package/dist/chunk-7WEQQJLG.js.map +1 -0
  25. package/dist/{chunk-7FK2UN2T.js → chunk-AWQPGIR6.js} +65 -67
  26. package/dist/{chunk-7FK2UN2T.js.map → chunk-AWQPGIR6.js.map} +1 -1
  27. package/dist/{chunk-ZFJJ3EXC.js → chunk-BBVUVBUO.js} +516 -185
  28. package/dist/chunk-BBVUVBUO.js.map +1 -0
  29. package/dist/{chunk-JBIKAAT3.js → chunk-BFFM2WFK.js} +8 -8
  30. package/dist/chunk-BFFM2WFK.js.map +1 -0
  31. package/dist/{chunk-KYQVEKP5.js → chunk-BPMWXTFX.js} +8 -8
  32. package/dist/chunk-DMZZLPZN.js +205 -0
  33. package/dist/chunk-DMZZLPZN.js.map +1 -0
  34. package/dist/{chunk-47PP7TAG.js → chunk-EGELTSPU.js} +1356 -1356
  35. package/dist/chunk-EGELTSPU.js.map +1 -0
  36. package/dist/chunk-GULLJQXA.js +698 -0
  37. package/dist/chunk-GULLJQXA.js.map +1 -0
  38. package/dist/{chunk-S5RYMCV6.js → chunk-HPWO4O6S.js} +3 -3
  39. package/dist/chunk-HVRC33OL.js +174 -0
  40. package/dist/chunk-HVRC33OL.js.map +1 -0
  41. package/dist/{chunk-W6R3HAAG.js → chunk-JRGFKVAZ.js} +2 -2
  42. package/dist/{chunk-XJN5WUKL.js → chunk-KG3D7FIF.js} +2 -2
  43. package/dist/chunk-L3PVMIYQ.js +10328 -0
  44. package/dist/chunk-L3PVMIYQ.js.map +1 -0
  45. package/dist/{chunk-QW2Q2KAH.js → chunk-LHHMV4GU.js} +2 -2
  46. package/dist/{chunk-ZOBNS7CX.js → chunk-MEFB5KHA.js} +4 -18
  47. package/dist/chunk-MEFB5KHA.js.map +1 -0
  48. package/dist/{chunk-M2O56UK7.js → chunk-N35E6CM2.js} +293 -163
  49. package/dist/chunk-N35E6CM2.js.map +1 -0
  50. package/dist/chunk-OCBHUHWB.js +69 -0
  51. package/dist/chunk-OCBHUHWB.js.map +1 -0
  52. package/dist/chunk-OIM4HLN6.js +1405 -0
  53. package/dist/chunk-OIM4HLN6.js.map +1 -0
  54. package/dist/{chunk-VYOJOX4Z.js → chunk-OJLYNM4Z.js} +54 -33
  55. package/dist/chunk-OJLYNM4Z.js.map +1 -0
  56. package/dist/{chunk-POJRB2AE.js → chunk-POUWHWID.js} +2 -2
  57. package/dist/chunk-PZEN5PHN.js +285 -0
  58. package/dist/chunk-PZEN5PHN.js.map +1 -0
  59. package/dist/chunk-SKAHDQH7.js +1785 -0
  60. package/dist/chunk-SKAHDQH7.js.map +1 -0
  61. package/dist/{chunk-KZAAWQNP.js → chunk-TTNESUPQ.js} +3 -3
  62. package/dist/chunk-U5DXNFJC.js +137 -0
  63. package/dist/chunk-U5DXNFJC.js.map +1 -0
  64. package/dist/chunk-USS336NF.js +165 -0
  65. package/dist/chunk-USS336NF.js.map +1 -0
  66. package/dist/{chunk-UO22YNY4.js → chunk-WH7OWT6G.js} +49 -1
  67. package/dist/chunk-WH7OWT6G.js.map +1 -0
  68. package/dist/chunk-WXC57XGG.js +29 -0
  69. package/dist/chunk-WXC57XGG.js.map +1 -0
  70. package/dist/{chunk-YLYINX2H.js → chunk-XZKD7DIF.js} +3 -3
  71. package/dist/{chunk-CPCX67TI.js → chunk-YEETV6IW.js} +1079 -1039
  72. package/dist/chunk-YEETV6IW.js.map +1 -0
  73. package/dist/{chunk-OLWTRUTS.js → chunk-YJHHCWM3.js} +35 -16
  74. package/dist/chunk-YJHHCWM3.js.map +1 -0
  75. package/dist/{cli-KKRKBU5T.js → cli-M3XCSOU6.js} +289 -374
  76. package/dist/cli-M3XCSOU6.js.map +1 -0
  77. package/dist/config-MXOX7XDR.js +41 -0
  78. package/dist/{dist-U4M6QCKE.js → dist-3LOO6M4U.js} +10 -10
  79. package/dist/doctor-LU4YIZWM.js +349 -0
  80. package/dist/doctor-LU4YIZWM.js.map +1 -0
  81. package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  82. package/dist/{chunk-KAJZHIQ4.js → fund-A54P2QFK.js} +80 -24
  83. package/dist/fund-A54P2QFK.js.map +1 -0
  84. package/dist/hook-command-U6KWPEDQ.js +377 -0
  85. package/dist/hook-command-U6KWPEDQ.js.map +1 -0
  86. package/dist/index.js +8 -3
  87. package/dist/index.js.map +1 -1
  88. package/dist/install-XUM2XSHW.js +53 -0
  89. package/dist/install-wallet-QIOFORTX.js +105 -0
  90. package/dist/install-wallet-QIOFORTX.js.map +1 -0
  91. package/dist/{run-XYTQ5TWQ.js → mcp-HJC2PLRV.js} +3727 -10670
  92. package/dist/mcp-HJC2PLRV.js.map +1 -0
  93. package/dist/paths-P2N4JTDZ.js +49 -0
  94. package/dist/pay-SBXZEPEP.js +37 -0
  95. package/dist/redact-46ZHF2NH.js +17 -0
  96. package/dist/{secp256k1-XRPVBC6V.js → secp256k1-ZZZT2CAX.js} +3 -3
  97. package/dist/{send-G746D7PQ.js → send-ASD2ZXJD.js} +28 -29
  98. package/dist/send-ASD2ZXJD.js.map +1 -0
  99. package/dist/{chunk-QZ6ROAJU.js → skill-placement-NFVHY6A3.js} +157 -11
  100. package/dist/skill-placement-NFVHY6A3.js.map +1 -0
  101. package/dist/status-T2SDB57A.js +63 -0
  102. package/dist/status-T2SDB57A.js.map +1 -0
  103. package/dist/status-line-CGPUSDMC.js +71 -0
  104. package/dist/status-line-CGPUSDMC.js.map +1 -0
  105. package/dist/status-line-wiring-BYPHTYZE.js +30 -0
  106. package/dist/tenjin-daemon.mjs +20060 -0
  107. package/dist/tenjin-shim.mjs +251 -0
  108. package/dist/tenjin-vitest-reporter.mjs +49 -0
  109. package/dist/uninstall-FKYZHAM3.js +144 -0
  110. package/dist/uninstall-FKYZHAM3.js.map +1 -0
  111. package/dist/{update-R76LHOZW.js → update-ANJ2AOTN.js} +133 -16
  112. package/dist/update-ANJ2AOTN.js.map +1 -0
  113. package/dist/{viemAdapter-By13KInL-TUQJBMHM.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  114. package/dist/wallet-PWAHVKWW.js +31 -0
  115. package/dist/wallet-kdf-worker.mjs +980 -0
  116. package/docs/agent-permissions.md +65 -354
  117. package/docs/safety-model.md +16 -6
  118. package/package.json +8 -7
  119. package/LICENSE +0 -21
  120. package/dist/buy-VIRNSYGN.js +0 -47
  121. package/dist/chunk-2MYQN7HM.js +0 -247
  122. package/dist/chunk-2MYQN7HM.js.map +0 -1
  123. package/dist/chunk-2RF2GIJQ.js +0 -1188
  124. package/dist/chunk-2RF2GIJQ.js.map +0 -1
  125. package/dist/chunk-3GL2Z5QK.js +0 -57
  126. package/dist/chunk-3GL2Z5QK.js.map +0 -1
  127. package/dist/chunk-47PP7TAG.js.map +0 -1
  128. package/dist/chunk-4CQIDQOT.js +0 -167
  129. package/dist/chunk-4CQIDQOT.js.map +0 -1
  130. package/dist/chunk-4KG27W2S.js +0 -614
  131. package/dist/chunk-4KG27W2S.js.map +0 -1
  132. package/dist/chunk-5QQTYWEU.js +0 -199
  133. package/dist/chunk-5QQTYWEU.js.map +0 -1
  134. package/dist/chunk-65DTCCJ7.js +0 -21
  135. package/dist/chunk-65DTCCJ7.js.map +0 -1
  136. package/dist/chunk-A5DKHMUN.js +0 -173
  137. package/dist/chunk-A5DKHMUN.js.map +0 -1
  138. package/dist/chunk-B63XPWQ4.js +0 -246
  139. package/dist/chunk-B63XPWQ4.js.map +0 -1
  140. package/dist/chunk-CAR6FHK6.js +0 -105
  141. package/dist/chunk-CAR6FHK6.js.map +0 -1
  142. package/dist/chunk-CPCX67TI.js.map +0 -1
  143. package/dist/chunk-CQBVCYI2.js +0 -162
  144. package/dist/chunk-CQBVCYI2.js.map +0 -1
  145. package/dist/chunk-DBU5CXBV.js +0 -4731
  146. package/dist/chunk-DBU5CXBV.js.map +0 -1
  147. package/dist/chunk-DHJD77OW.js +0 -81
  148. package/dist/chunk-DHJD77OW.js.map +0 -1
  149. package/dist/chunk-EDZSNPE5.js +0 -35
  150. package/dist/chunk-EDZSNPE5.js.map +0 -1
  151. package/dist/chunk-EFWZPUTC.js +0 -65
  152. package/dist/chunk-EFWZPUTC.js.map +0 -1
  153. package/dist/chunk-EPFL6CTE.js +0 -448
  154. package/dist/chunk-EPFL6CTE.js.map +0 -1
  155. package/dist/chunk-GHLVXVZD.js +0 -142
  156. package/dist/chunk-GHLVXVZD.js.map +0 -1
  157. package/dist/chunk-H3SOOJ2I.js +0 -580
  158. package/dist/chunk-H3SOOJ2I.js.map +0 -1
  159. package/dist/chunk-HPJGOLTN.js.map +0 -1
  160. package/dist/chunk-HRGBS2PA.js +0 -203
  161. package/dist/chunk-HRGBS2PA.js.map +0 -1
  162. package/dist/chunk-ITUXPJIS.js +0 -314
  163. package/dist/chunk-ITUXPJIS.js.map +0 -1
  164. package/dist/chunk-JBIKAAT3.js.map +0 -1
  165. package/dist/chunk-KAJZHIQ4.js.map +0 -1
  166. package/dist/chunk-KINZ23CV.js.map +0 -1
  167. package/dist/chunk-LRYV3SK7.js +0 -235
  168. package/dist/chunk-LRYV3SK7.js.map +0 -1
  169. package/dist/chunk-M2O56UK7.js.map +0 -1
  170. package/dist/chunk-MJZZTKCC.js.map +0 -1
  171. package/dist/chunk-NIKXHWOL.js.map +0 -1
  172. package/dist/chunk-OKDRDT74.js +0 -209
  173. package/dist/chunk-OKDRDT74.js.map +0 -1
  174. package/dist/chunk-OKYSNAS3.js +0 -2144
  175. package/dist/chunk-OKYSNAS3.js.map +0 -1
  176. package/dist/chunk-OLWTRUTS.js.map +0 -1
  177. package/dist/chunk-QQ6ELLSA.js +0 -143
  178. package/dist/chunk-QQ6ELLSA.js.map +0 -1
  179. package/dist/chunk-QZ6ROAJU.js.map +0 -1
  180. package/dist/chunk-R7RSCBI7.js +0 -794
  181. package/dist/chunk-R7RSCBI7.js.map +0 -1
  182. package/dist/chunk-SGK2B724.js +0 -67
  183. package/dist/chunk-SGK2B724.js.map +0 -1
  184. package/dist/chunk-U6VPKMGC.js +0 -390
  185. package/dist/chunk-U6VPKMGC.js.map +0 -1
  186. package/dist/chunk-UHTVXQ2O.js +0 -140
  187. package/dist/chunk-UHTVXQ2O.js.map +0 -1
  188. package/dist/chunk-UO22YNY4.js.map +0 -1
  189. package/dist/chunk-US456VUI.js +0 -149
  190. package/dist/chunk-US456VUI.js.map +0 -1
  191. package/dist/chunk-V44J2MXV.js +0 -400
  192. package/dist/chunk-V44J2MXV.js.map +0 -1
  193. package/dist/chunk-VJQKL3YH.js +0 -216
  194. package/dist/chunk-VJQKL3YH.js.map +0 -1
  195. package/dist/chunk-VJSQSLBM.js +0 -1442
  196. package/dist/chunk-VJSQSLBM.js.map +0 -1
  197. package/dist/chunk-VYOJOX4Z.js.map +0 -1
  198. package/dist/chunk-WY2K35OL.js +0 -269
  199. package/dist/chunk-WY2K35OL.js.map +0 -1
  200. package/dist/chunk-ZFJJ3EXC.js.map +0 -1
  201. package/dist/chunk-ZOBNS7CX.js.map +0 -1
  202. package/dist/cli-KKRKBU5T.js.map +0 -1
  203. package/dist/config-JMRUNYE6.js +0 -37
  204. package/dist/discover-B5HF6SHM.js +0 -102
  205. package/dist/discover-B5HF6SHM.js.map +0 -1
  206. package/dist/doctor-ZBG7X66D.js +0 -32
  207. package/dist/edit-PZJIILQE.js +0 -40
  208. package/dist/fund-EUDH5KPA.js +0 -40
  209. package/dist/inspect-QC6WEQPN.js +0 -37
  210. package/dist/install-GNK2W3PI.js +0 -972
  211. package/dist/install-GNK2W3PI.js.map +0 -1
  212. package/dist/outcome-KSGWZHUS.js +0 -24
  213. package/dist/pay-BC4UICPA.js +0 -361
  214. package/dist/pay-BC4UICPA.js.map +0 -1
  215. package/dist/publish-LXWFDIKF.js +0 -42
  216. package/dist/read-JMNUQ56P.js +0 -160
  217. package/dist/read-JMNUQ56P.js.map +0 -1
  218. package/dist/run-XYTQ5TWQ.js.map +0 -1
  219. package/dist/search-TSQAB45E.js +0 -25
  220. package/dist/secp256k1-XRPVBC6V.js.map +0 -1
  221. package/dist/send-G746D7PQ.js.map +0 -1
  222. package/dist/session-JBKWMJ24.js +0 -89
  223. package/dist/session-JBKWMJ24.js.map +0 -1
  224. package/dist/skill-heal-WKD67SLJ.js +0 -92
  225. package/dist/skill-heal-WKD67SLJ.js.map +0 -1
  226. package/dist/skill-placement-RIU4AMC2.js +0 -20
  227. package/dist/skill-placement-RIU4AMC2.js.map +0 -1
  228. package/dist/uninstall-5E263VTS.js +0 -73
  229. package/dist/uninstall-5E263VTS.js.map +0 -1
  230. package/dist/update-R76LHOZW.js.map +0 -1
  231. package/dist/usdc-4VCDHFWX.js +0 -38
  232. package/dist/usdc-4VCDHFWX.js.map +0 -1
  233. package/dist/viemAdapter-By13KInL-TUQJBMHM.js.map +0 -1
  234. package/dist/wallet-TQ7D5EQ7.js +0 -41
  235. package/dist/wallet-TQ7D5EQ7.js.map +0 -1
  236. package/dist/wallet-ZAVXWLWP.js +0 -32
  237. package/dist/wallet-ZAVXWLWP.js.map +0 -1
  238. package/docs/command-reference.md +0 -303
  239. package/skills/tenjin/SKILL.md +0 -373
  240. package/skills/tenjin-pay/SKILL.md +0 -76
  241. package/skills/tenjin-publish/SKILL.md +0 -227
  242. package/skills/tenjin-publish/references/maintain.md +0 -39
  243. package/skills/tenjin-search/SKILL.md +0 -154
  244. package/skills/tenjin-search/references/permissions.md +0 -112
  245. /package/dist/{_esm-N4KAVXQR.js.map → _esm-CE7KNONL.js.map} +0 -0
  246. /package/dist/{buy-VIRNSYGN.js.map → ccip-7RMRLAGV.js.map} +0 -0
  247. /package/dist/{ccip-RPPPKTJR.js.map → ccip-NLCSCHKI.js.map} +0 -0
  248. /package/dist/{chunk-U5S527PP.js.map → chunk-5IEP5EGE.js.map} +0 -0
  249. /package/dist/{chunk-KYQVEKP5.js.map → chunk-BPMWXTFX.js.map} +0 -0
  250. /package/dist/{chunk-S5RYMCV6.js.map → chunk-HPWO4O6S.js.map} +0 -0
  251. /package/dist/{chunk-W6R3HAAG.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  252. /package/dist/{chunk-XJN5WUKL.js.map → chunk-KG3D7FIF.js.map} +0 -0
  253. /package/dist/{chunk-QW2Q2KAH.js.map → chunk-LHHMV4GU.js.map} +0 -0
  254. /package/dist/{chunk-POJRB2AE.js.map → chunk-POUWHWID.js.map} +0 -0
  255. /package/dist/{chunk-KZAAWQNP.js.map → chunk-TTNESUPQ.js.map} +0 -0
  256. /package/dist/{chunk-YLYINX2H.js.map → chunk-XZKD7DIF.js.map} +0 -0
  257. /package/dist/{ccip-ZGGWQN4X.js.map → config-MXOX7XDR.js.map} +0 -0
  258. /package/dist/{dist-U4M6QCKE.js.map → dist-3LOO6M4U.js.map} +0 -0
  259. /package/dist/{config-JMRUNYE6.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  260. /package/dist/{doctor-ZBG7X66D.js.map → install-XUM2XSHW.js.map} +0 -0
  261. /package/dist/{edit-PZJIILQE.js.map → paths-P2N4JTDZ.js.map} +0 -0
  262. /package/dist/{ethersCompat-Df4a6QIZ-WHYKB6HA.js.map → pay-SBXZEPEP.js.map} +0 -0
  263. /package/dist/{fund-EUDH5KPA.js.map → redact-46ZHF2NH.js.map} +0 -0
  264. /package/dist/{inspect-QC6WEQPN.js.map → secp256k1-ZZZT2CAX.js.map} +0 -0
  265. /package/dist/{outcome-KSGWZHUS.js.map → status-line-wiring-BYPHTYZE.js.map} +0 -0
  266. /package/dist/{publish-LXWFDIKF.js.map → viemAdapter-By13KInL-X2VY6CY3.js.map} +0 -0
  267. /package/dist/{search-TSQAB45E.js.map → wallet-PWAHVKWW.js.map} +0 -0
@@ -1,614 +0,0 @@
1
- import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import {
3
- buildPostUpdateBody,
4
- dedupeFindings,
5
- deriveCard,
6
- deriveProjectMarkers,
7
- describeFindings,
8
- getOwnPost,
9
- missingSentences,
10
- needsConfirmation,
11
- parseAppliesToFlags,
12
- parseFrontmatter,
13
- publicFinding,
14
- resolveWriteAuth,
15
- scan,
16
- updatePost,
17
- writeModeNotices
18
- } from "./chunk-VJSQSLBM.js";
19
- import {
20
- describeWallet,
21
- resolveWalletProvider
22
- } from "./chunk-CPCX67TI.js";
23
- import {
24
- sanitizeForTerminal
25
- } from "./chunk-OLWTRUTS.js";
26
- import {
27
- resolveContextSettings,
28
- resolvePublishSettings
29
- } from "./chunk-VYOJOX4Z.js";
30
- import {
31
- UUID_RE,
32
- parseUsdToAtomic,
33
- toMoney
34
- } from "./chunk-EFWZPUTC.js";
35
- import {
36
- parsePublishModeFlag
37
- } from "./chunk-U6VPKMGC.js";
38
- import {
39
- CliError
40
- } from "./chunk-ZFJJ3EXC.js";
41
-
42
- // src/commands/edit.ts
43
- import { readFile } from "fs/promises";
44
- import { dirname, resolve } from "path";
45
- async function runEdit(args, ctx, deps = {}) {
46
- const env = deps.env ?? process.env;
47
- const cwd = deps.cwd ?? process.cwd();
48
- if (!UUID_RE.test(args.postId)) {
49
- throw new CliError("USAGE", `Invalid post id: ${JSON.stringify(args.postId)}`, {
50
- fix: "Pass the post uuid from `tenjin publish`\u2019s receipt or your desk."
51
- });
52
- }
53
- if (args.mode !== void 0) parsePublishModeFlag(args.mode, "--mode");
54
- rejectEmptyValues(args);
55
- assertAppendExclusivity(args);
56
- const clears = parseClears(args);
57
- const cardFlags = cardFlagsFrom(args);
58
- const priceAtomic = args.price !== void 0 ? parseUsdToAtomic(args.price) : void 0;
59
- const bodyFile = args.body !== void 0 ? await readBodyFile(args.body) : void 0;
60
- const wantsChange = hasChangeFlags(args);
61
- const runtime = await resolveContextSettings(ctx);
62
- const provider = resolveWalletProvider(
63
- ctx,
64
- deps.provider !== void 0 ? { provider: deps.provider } : {}
65
- );
66
- await describeWallet(provider);
67
- const signer = await provider.getSigner();
68
- const auth = resolveWriteAuth({
69
- signer,
70
- baseUrl: runtime.baseUrl,
71
- dataDir: ctx.dataDir,
72
- scope: wantsChange ? "read+write" : "read",
73
- ...deps.useSession !== void 0 ? { useSession: deps.useSession } : {},
74
- env
75
- });
76
- const client = {
77
- baseUrl: runtime.baseUrl,
78
- timeoutMs: ctx.flags.timeout,
79
- ...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
80
- };
81
- const stored = await getOwnPost(args.postId, auth, client);
82
- if (!wantsChange) return showReceipt(stored);
83
- if (args.addQuestion !== void 0 && args.addQuestion.length > 0) {
84
- cardFlags.question = appendUnique(storedList(stored, "questionsAnswered"), args.addQuestion);
85
- }
86
- if (args.addTask !== void 0 && args.addTask.length > 0) {
87
- cardFlags.task = appendUnique(storedList(stored, "tasksSupported"), args.addTask);
88
- }
89
- const intent = {
90
- ...args.title !== void 0 ? { title: args.title } : {},
91
- ...bodyFile !== void 0 ? { bodyMd: bodyFile.body } : {},
92
- ...args.excerpt !== void 0 ? { excerpt: args.excerpt } : {},
93
- ...priceAtomic !== void 0 ? { priceAtomic } : {},
94
- ...withClears(deriveCard({}, cardFlags), clears, stored.resource)
95
- };
96
- const { input, lines: changes } = diffUpdate(stored, intent);
97
- if (changes.length === 0) return noChangeReceipt(stored);
98
- buildPostUpdateBody(input);
99
- const settings = await resolvePublishSettings({
100
- dataDir: ctx.dataDir,
101
- cwd,
102
- ...args.mode !== void 0 ? { flag: args.mode } : {},
103
- env
104
- });
105
- writeModeNotices(
106
- ctx.io.stderr,
107
- settings,
108
- env,
109
- "each edit asks you once. Set auto to apply clean edits automatically"
110
- );
111
- const markerRoot = args.body !== void 0 ? dirname(resolve(cwd, args.body)) : cwd;
112
- const scanContext = { projectMarkers: await deriveProjectMarkers(markerRoot) };
113
- const findings = dedupeFindings([
114
- ...input.bodyMd !== void 0 ? scan(bodyFile?.raw ?? "", scanContext) : [],
115
- ...scan(shippedTypedText(args, input), scanContext)
116
- ]);
117
- const blocking = findings.filter((f) => f.severity === "block");
118
- const warns = findings.filter((f) => f.severity === "warn");
119
- if (blocking.length > 0) {
120
- throw new CliError("PUBLISH_BLOCKED", blockMessage(blocking), {
121
- fix: "Remove the secret from the new content (it is never masked away by --yes), then re-run.",
122
- details: { mode: settings.mode, findings: blocking.map(publicFinding) }
123
- });
124
- }
125
- const notes = editNotes(args, stored, bodyFile, clears);
126
- for (const line of [...notes, ...changes]) ctx.io.stderr.write(`${line}
127
- `);
128
- if (needsConfirmation(settings.mode, warns.length) && args.yes !== true) {
129
- throw new CliError("NEEDS_CONFIRMATION", confirmMessage(warns.length, changes.length), {
130
- fix: "Review the changes, then re-run with --yes.",
131
- details: {
132
- mode: settings.mode,
133
- postId: stored.id,
134
- title: sanitizeForTerminal(stored.title),
135
- changes,
136
- ...notes.length > 0 ? { notes } : {},
137
- findings: warns.map(publicFinding)
138
- }
139
- });
140
- }
141
- const updated = await updatePost(args.postId, input, auth, client);
142
- return updateReceipt(updated, changes, notes, settings.mode);
143
- }
144
- function showReceipt(post) {
145
- const price = toMoney(post.price);
146
- const card = post.resource;
147
- const lines = [
148
- `${sanitizeForTerminal(post.title)} (${sanitizeForTerminal(post.status)}), ${price.usd} USD (${price.atomic} atomic)`,
149
- `url: ${sanitizeForTerminal(post.url)}`,
150
- ...hasText(post.excerpt) ? [`excerpt: ${preview(post.excerpt)}`] : [],
151
- ...cardLines(card),
152
- eligibilityLine(card)
153
- ];
154
- return { data: post, humanLines: lines };
155
- }
156
- function updateReceipt(post, changes, notes, mode) {
157
- const card = post.resource;
158
- const lines = [
159
- `Updated ${sanitizeForTerminal(post.title)} \u2192 ${sanitizeForTerminal(post.url)}`,
160
- eligibilityLine(card),
161
- ...(post.warnings ?? []).map((w) => `warning: ${sanitizeForTerminal(w)}`)
162
- ];
163
- return {
164
- // `mode` is echoed because a per-call --mode (or the MCP `mode` argument) is
165
- // otherwise invisible in a transcript: the receipt would look identical
166
- // whether the caller loosened the gate for this run or not.
167
- data: { ...post, mode, changes, ...notes.length > 0 ? { notes } : {} },
168
- humanLines: lines
169
- };
170
- }
171
- function noChangeReceipt(post) {
172
- return {
173
- data: { ...post, changes: [] },
174
- humanLines: [
175
- `No changes: every value given already matches ${sanitizeForTerminal(post.title)}. Nothing was written.`
176
- ]
177
- };
178
- }
179
- function cardLines(card) {
180
- if (card === void 0) return [];
181
- const lines = [];
182
- const list = (label, values) => {
183
- if (values !== void 0 && values !== null && values.length > 0) {
184
- lines.push(
185
- `${label} (${values.length}): ${values.map((v) => sanitizeForTerminal(v)).join(" | ")}`
186
- );
187
- }
188
- };
189
- list("questionsAnswered", card.questionsAnswered);
190
- list("tasksSupported", card.tasksSupported);
191
- for (const [label, value] of [
192
- ["scope", card.scope],
193
- ["exclusions", card.exclusions],
194
- ["artifactType", card.artifactType],
195
- ["temporalMode", card.temporalMode],
196
- ["asOf", card.asOf],
197
- ["validUntil", card.validUntil],
198
- ["provenance", card.provenanceSummary],
199
- ["methodology", card.methodologySummary],
200
- ["supersedesPostId", card.supersedesPostId]
201
- ]) {
202
- if (hasText(value)) lines.push(`${label}: ${preview(value)}`);
203
- }
204
- if (card.appliesTo !== void 0 && card.appliesTo !== null) {
205
- for (const [key, values] of Object.entries(card.appliesTo)) {
206
- lines.push(
207
- `appliesTo ${sanitizeForTerminal(key)}: ${values.map((v) => sanitizeForTerminal(v)).join(", ")}`
208
- );
209
- }
210
- }
211
- return lines;
212
- }
213
- function eligibilityLine(card) {
214
- if (card === void 0) return "No answer card: ranks below every carded piece in agent search.";
215
- const missing = missingSentences(card.cacheEligibleMissing).map(sanitizeForTerminal);
216
- if (card.cacheEligible) return "Answer card is search-eligible.";
217
- return missing.length > 0 ? `Answer card incomplete, ranks below every complete card in agent search. To fix: ${missing.join(" ")}` : "Answer card incomplete, ranks below every complete card in agent search.";
218
- }
219
- function diffUpdate(stored, intent) {
220
- const lines = [];
221
- const input = {};
222
- const title = intent.title?.trim();
223
- if (title !== void 0 && title !== stored.title) {
224
- input.title = title;
225
- lines.push(`title: ${preview(stored.title)} \u2192 ${preview(title)}`);
226
- }
227
- if (intent.priceAtomic !== void 0 && intent.priceAtomic !== stored.price) {
228
- const before = toMoney(stored.price);
229
- const after = toMoney(intent.priceAtomic);
230
- input.priceAtomic = intent.priceAtomic;
231
- lines.push(
232
- `price: ${before.usd} USD (${before.atomic} atomic) \u2192 ${after.usd} USD (${after.atomic} atomic)`
233
- );
234
- }
235
- if (intent.bodyMd !== void 0 && intent.bodyMd !== stored.bodyMd) {
236
- input.bodyMd = intent.bodyMd;
237
- lines.push(`body: ${(stored.bodyMd ?? "").length} \u2192 ${intent.bodyMd.length} characters`);
238
- }
239
- const excerpt = intent.excerpt?.trim();
240
- if (excerpt !== void 0 && excerpt !== (stored.excerpt ?? "")) {
241
- input.excerpt = excerpt;
242
- lines.push(`excerpt: ${preview(stored.excerpt)} \u2192 ${preview(excerpt)}`);
243
- }
244
- const card = diffCard(stored.resource, intent.resource);
245
- lines.push(...card.lines);
246
- if (card.card !== void 0) input.resource = card.card;
247
- return { input, lines };
248
- }
249
- var CARD_PASS = {
250
- questionsAnswered: "list",
251
- tasksSupported: "list",
252
- asOf: "iso",
253
- validUntil: "iso",
254
- scope: "scalar",
255
- exclusions: "scalar",
256
- artifactType: "scalar",
257
- temporalMode: "scalar",
258
- provenanceSummary: "scalar",
259
- methodologySummary: "scalar",
260
- supersedesPostId: "scalar",
261
- appliesTo: "map",
262
- mediaType: "none",
263
- maintenanceCadence: "none",
264
- reproductionMinutes: "none",
265
- estimatedPaidInputCost: "none"
266
- };
267
- function keysIn(pass) {
268
- return Object.entries(CARD_PASS).filter(([, value]) => value === pass).map(([key]) => key);
269
- }
270
- var CARD_LABEL = {
271
- provenanceSummary: "provenance",
272
- methodologySummary: "methodology"
273
- };
274
- function cardLabel(key) {
275
- return CARD_LABEL[key] ?? key;
276
- }
277
- function diffCard(stored, next) {
278
- const lines = [];
279
- const card = {};
280
- const keep = (key, value, line) => {
281
- card[key] = value;
282
- lines.push(line);
283
- };
284
- if (next === void 0) return { lines };
285
- for (const key of keysIn("list")) {
286
- const after = next[key];
287
- if (after === void 0) continue;
288
- const old = stored?.[key] ?? [];
289
- if (sameList(old, after)) continue;
290
- const added = after.filter((v) => !old.includes(v));
291
- const detail = after.length === 0 ? " (cleared)" : added.length > 0 ? ` (new: ${previewList(added)})` : "";
292
- keep(key, after, `${key}: ${old.length} \u2192 ${after.length}${detail}`);
293
- }
294
- for (const key of keysIn("iso")) {
295
- const after = next[key];
296
- if (after === void 0) continue;
297
- const from = isoInstant(stored?.[key]);
298
- const to = isoInstant(after);
299
- if (from === to) continue;
300
- keep(key, to, `${key}: ${preview(from)} \u2192 ${to === null ? "(cleared)" : preview(to)}`);
301
- }
302
- for (const key of keysIn("scalar")) {
303
- const after = next[key];
304
- if (after === void 0) continue;
305
- const from = stored?.[key] ?? null;
306
- if (from === after) continue;
307
- keep(
308
- key,
309
- after,
310
- `${cardLabel(key)}: ${preview(from)} \u2192 ${after === null ? "(cleared)" : preview(after)}`
311
- );
312
- }
313
- for (const key of keysIn("map")) {
314
- const after = next[key];
315
- if (after === void 0) continue;
316
- const before = stored?.[key] ?? {};
317
- if (sameAppliesTo(before, after)) continue;
318
- keep(key, after, `${key}: ${appliesToPreview(before)} \u2192 ${appliesToPreview(after)}`);
319
- }
320
- return { ...Object.keys(card).length > 0 ? { card } : {}, lines };
321
- }
322
- function isoInstant(value) {
323
- if (value === void 0 || value === null) return null;
324
- const ms = Date.parse(value);
325
- return Number.isFinite(ms) ? new Date(ms).toISOString() : value;
326
- }
327
- function sameAppliesTo(a, b) {
328
- const aKeys = Object.keys(a).sort();
329
- const bKeys = Object.keys(b).sort();
330
- if (!sameList(aKeys, bKeys)) return false;
331
- return aKeys.every((key) => sameList(a[key] ?? [], b[key] ?? []));
332
- }
333
- function editNotes(args, stored, bodyFile, clears) {
334
- if (bodyFile === void 0) return [];
335
- const notes = [];
336
- if (bodyFile.hadFrontmatter) {
337
- notes.push(
338
- "note: frontmatter in the body file was ignored; metadata changes only through flags."
339
- );
340
- }
341
- if (args.excerpt === void 0) {
342
- notes.push(
343
- `note: the excerpt stays as-is (${preview(stored.excerpt)}) and remains lexically indexed; the server does not re-derive it. Pass --excerpt to change it.`
344
- );
345
- }
346
- const asOfMoves = args.asOf !== void 0 || clears.includes("asOf");
347
- if (stored.resource?.temporalMode === "snapshot" && !asOfMoves) {
348
- notes.push(
349
- `note: asOf is unchanged (${preview(stored.resource.asOf)}) on this snapshot card, and search freshness gating uses it. Pass --as-of to move it.`
350
- );
351
- }
352
- return notes;
353
- }
354
- var CLEAR_FIELDS = [
355
- "scope",
356
- "exclusions",
357
- "asOf",
358
- "validUntil",
359
- "provenance",
360
- "methodology",
361
- "supersedesPostId",
362
- "questionsAnswered",
363
- "tasksSupported",
364
- "appliesTo"
365
- ];
366
- var CLEAR_KEY = {
367
- scope: "scope",
368
- exclusions: "exclusions",
369
- asOf: "asOf",
370
- validUntil: "validUntil",
371
- provenance: "provenanceSummary",
372
- methodology: "methodologySummary",
373
- supersedesPostId: "supersedesPostId",
374
- questionsAnswered: "questionsAnswered",
375
- tasksSupported: "tasksSupported",
376
- appliesTo: "appliesTo"
377
- };
378
- var CLEAR_VALUE = {
379
- scope: null,
380
- exclusions: null,
381
- asOf: null,
382
- validUntil: null,
383
- provenance: null,
384
- methodology: null,
385
- supersedesPostId: null,
386
- questionsAnswered: [],
387
- tasksSupported: [],
388
- appliesTo: {}
389
- };
390
- var CLEAR_CONFLICTS = {
391
- scope: ["scope"],
392
- exclusions: ["exclusions"],
393
- asOf: ["asOf"],
394
- validUntil: ["validUntil"],
395
- provenance: ["provenance"],
396
- methodology: ["methodology"],
397
- supersedesPostId: [],
398
- questionsAnswered: ["question", "addQuestion"],
399
- tasksSupported: ["task", "addTask"],
400
- appliesTo: ["appliesTo"]
401
- };
402
- var FLAG_NAME = {
403
- question: "--question",
404
- task: "--task",
405
- addQuestion: "--add-question",
406
- addTask: "--add-task",
407
- scope: "--scope",
408
- exclusions: "--exclusions",
409
- appliesTo: "--applies-to",
410
- asOf: "--as-of",
411
- validUntil: "--valid-until",
412
- artifactType: "--artifact-type",
413
- temporalMode: "--temporal-mode",
414
- provenance: "--provenance",
415
- methodology: "--methodology",
416
- title: "--title",
417
- price: "--price",
418
- body: "--body",
419
- excerpt: "--excerpt"
420
- };
421
- var CHANGE_KEYS = [
422
- "question",
423
- "task",
424
- "addQuestion",
425
- "addTask",
426
- "scope",
427
- "exclusions",
428
- "appliesTo",
429
- "asOf",
430
- "validUntil",
431
- "artifactType",
432
- "temporalMode",
433
- "provenance",
434
- "methodology",
435
- "title",
436
- "price",
437
- "body",
438
- "excerpt",
439
- "clear"
440
- ];
441
- function hasChangeFlags(args) {
442
- return CHANGE_KEYS.some((key) => {
443
- const value = args[key];
444
- return Array.isArray(value) ? value.length > 0 : value !== void 0;
445
- });
446
- }
447
- function rejectEmptyValues(args) {
448
- for (const [key, flag] of Object.entries(FLAG_NAME)) {
449
- const value = args[key];
450
- const empties = typeof value === "string" ? [value] : Array.isArray(value) ? value.filter((v) => typeof v === "string") : [];
451
- for (const v of empties) {
452
- if (v.trim().length === 0) {
453
- const clearable = CLEAR_FIELDS.includes(clearNameFor(key));
454
- throw new CliError("USAGE", `${flag} cannot be empty.`, {
455
- fix: clearable ? `Pass a value, or clear the field with \`--clear ${clearNameFor(key)}\`.` : "Pass a value, or omit the flag to keep the stored one."
456
- });
457
- }
458
- }
459
- }
460
- }
461
- function clearNameFor(key) {
462
- if (key === "question" || key === "addQuestion") return "questionsAnswered";
463
- if (key === "task" || key === "addTask") return "tasksSupported";
464
- return key;
465
- }
466
- function assertAppendExclusivity(args) {
467
- const both = (a, b) => a !== void 0 && a.length > 0 && b !== void 0 && b.length > 0;
468
- if (both(args.question, args.addQuestion)) {
469
- throw new CliError("USAGE", "Pass either --question or --add-question, not both.", {
470
- fix: "--question replaces the stored questions; --add-question appends to them."
471
- });
472
- }
473
- if (both(args.task, args.addTask)) {
474
- throw new CliError("USAGE", "Pass either --task or --add-task, not both.", {
475
- fix: "--task replaces the stored tasks; --add-task appends to them."
476
- });
477
- }
478
- }
479
- function parseClears(args) {
480
- const raw = args.clear ?? [];
481
- const out = [];
482
- for (const name of raw) {
483
- if (!CLEAR_FIELDS.includes(name)) {
484
- throw new CliError("USAGE", `Cannot clear ${JSON.stringify(name)}.`, {
485
- fix: `Clearable fields: ${CLEAR_FIELDS.join(", ")}.`
486
- });
487
- }
488
- const field = name;
489
- for (const key of CLEAR_CONFLICTS[field]) {
490
- const value = args[key];
491
- const given = Array.isArray(value) ? value.length > 0 : value !== void 0;
492
- if (given) {
493
- throw new CliError(
494
- "USAGE",
495
- `--clear ${field} contradicts ${FLAG_NAME[key] ?? String(key)}.`,
496
- { fix: "Set the field or clear it, not both in the same run." }
497
- );
498
- }
499
- }
500
- if (!out.includes(field)) out.push(field);
501
- }
502
- return out;
503
- }
504
- function cardFlagsFrom(args) {
505
- return {
506
- ...args.question !== void 0 && args.question.length > 0 ? { question: args.question } : {},
507
- ...args.task !== void 0 && args.task.length > 0 ? { task: args.task } : {},
508
- ...args.scope !== void 0 ? { scope: args.scope } : {},
509
- ...args.exclusions !== void 0 ? { exclusions: args.exclusions } : {},
510
- ...args.asOf !== void 0 ? { asOf: args.asOf } : {},
511
- ...args.validUntil !== void 0 ? { validUntil: args.validUntil } : {},
512
- ...args.artifactType !== void 0 ? { artifactType: args.artifactType } : {},
513
- ...args.temporalMode !== void 0 ? { temporalMode: args.temporalMode } : {},
514
- ...args.provenance !== void 0 ? { provenance: args.provenance } : {},
515
- ...args.methodology !== void 0 ? { methodology: args.methodology } : {},
516
- ...args.appliesTo !== void 0 && args.appliesTo.length > 0 ? { appliesTo: parseAppliesToFlags(args.appliesTo) } : {}
517
- };
518
- }
519
- function withClears(set, clears, stored) {
520
- const applicable = stored !== void 0 ? clears : [];
521
- if (set === void 0 && applicable.length === 0) return {};
522
- const card = { ...set ?? {} };
523
- for (const name of applicable) {
524
- card[CLEAR_KEY[name]] = CLEAR_VALUE[name];
525
- }
526
- return Object.keys(card).length > 0 ? { resource: card } : {};
527
- }
528
- async function readBodyFile(file) {
529
- let raw;
530
- try {
531
- raw = await readFile(file, "utf8");
532
- } catch (err) {
533
- throw new CliError("USAGE", `Could not read ${JSON.stringify(file)}`, {
534
- fix: "Pass a path to a readable Markdown file, e.g. `tenjin edit <id> --body post.md`.",
535
- cause: err
536
- });
537
- }
538
- const { frontmatter, body } = parseFrontmatter(raw);
539
- return { raw, body, hadFrontmatter: Object.keys(frontmatter).length > 0 };
540
- }
541
- function storedList(post, key) {
542
- return post.resource?.[key] ?? [];
543
- }
544
- function appendUnique(stored, additions) {
545
- const out = [...stored];
546
- for (const item of additions) {
547
- if (!out.includes(item)) out.push(item);
548
- }
549
- return out;
550
- }
551
- function shippedTypedText(args, input) {
552
- const parts = [];
553
- const add = (v) => {
554
- if (v !== void 0) parts.push(v);
555
- };
556
- if (input.title !== void 0) add(args.title);
557
- if (input.excerpt !== void 0) add(args.excerpt);
558
- const card = input.resource;
559
- if (card === void 0) return parts.join("\n");
560
- if (card.scope !== void 0) add(args.scope);
561
- if (card.exclusions !== void 0) add(args.exclusions);
562
- if (card.provenanceSummary !== void 0) add(args.provenance);
563
- if (card.methodologySummary !== void 0) add(args.methodology);
564
- if (card.asOf !== void 0) add(args.asOf);
565
- if (card.validUntil !== void 0) add(args.validUntil);
566
- if (card.questionsAnswered !== void 0) {
567
- for (const item of args.question ?? args.addQuestion ?? []) add(item);
568
- }
569
- if (card.tasksSupported !== void 0) {
570
- for (const item of args.task ?? args.addTask ?? []) add(item);
571
- }
572
- if (card.appliesTo !== void 0 && args.appliesTo !== void 0) {
573
- for (const values of Object.values(parseAppliesToFlags(args.appliesTo))) parts.push(...values);
574
- }
575
- return parts.join("\n");
576
- }
577
- function blockMessage(blocking) {
578
- return `Edit blocked: the new content contains ${describeFindings(blocking)}.`;
579
- }
580
- function confirmMessage(warnCount, changeCount) {
581
- return warnCount > 0 ? `Edit needs confirmation: ${changeCount} change(s), ${warnCount} finding(s).` : `Edit needs confirmation: ${changeCount} change(s).`;
582
- }
583
- var PREVIEW_MAX = 60;
584
- var LINE_MAX = 200;
585
- function clip(value, max = PREVIEW_MAX) {
586
- const clean = sanitizeForTerminal(value).replace(/\s+/g, " ").trim();
587
- return clean.length > max ? `${clean.slice(0, max)}\u2026` : clean;
588
- }
589
- function preview(value) {
590
- if (value === void 0 || value === null || value.length === 0) return "(unset)";
591
- const clean = sanitizeForTerminal(value).replace(/\s+/g, " ").trim();
592
- if (clean.length === 0) return "(unset)";
593
- return clean.length > PREVIEW_MAX ? `${JSON.stringify(clean.slice(0, PREVIEW_MAX))}\u2026` : JSON.stringify(clean);
594
- }
595
- function previewList(values) {
596
- return values.map((v) => preview(v)).join(", ");
597
- }
598
- function appliesToPreview(appliesTo) {
599
- const entries = Object.entries(appliesTo);
600
- if (entries.length === 0) return "(unset)";
601
- const rendered = entries.map(([key, values]) => `${clip(key)}=${values.map((v) => clip(v)).join("|")}`).join(", ");
602
- return clip(rendered, LINE_MAX);
603
- }
604
- function sameList(a, b) {
605
- return a.length === b.length && a.every((v, i) => v === b[i]);
606
- }
607
- function hasText(value) {
608
- return typeof value === "string" && value.trim().length > 0;
609
- }
610
-
611
- export {
612
- runEdit
613
- };
614
- //# sourceMappingURL=chunk-4KG27W2S.js.map