@unbrained/pm-cli 2026.6.19 → 2026.6.21
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/CHANGELOG.md +328 -258
- package/README.md +1 -1
- package/dist/cli/bootstrap-args.d.ts +12 -1
- package/dist/cli/bootstrap-args.js +20 -9
- package/dist/cli/bootstrap-args.js.map +1 -1
- package/dist/cli/commander-usage.js +31 -25
- package/dist/cli/commander-usage.js.map +1 -1
- package/dist/cli/commands/completion.js +3 -3
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/contracts.js +4 -3
- package/dist/cli/commands/contracts.js.map +1 -1
- package/dist/cli/commands/eval.d.ts +62 -0
- package/dist/cli/commands/eval.js +158 -0
- package/dist/cli/commands/eval.js.map +1 -0
- package/dist/cli/commands/extension/install-sources.d.ts +12 -0
- package/dist/cli/commands/extension/install-sources.js +77 -10
- package/dist/cli/commands/extension/install-sources.js.map +1 -1
- package/dist/cli/commands/extension/scaffold.js +49 -3
- package/dist/cli/commands/extension/scaffold.js.map +1 -1
- package/dist/cli/commands/extension.js +9 -2
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/gc.d.ts +12 -1
- package/dist/cli/commands/gc.js +53 -6
- package/dist/cli/commands/gc.js.map +1 -1
- package/dist/cli/commands/health.js +27 -9
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.js +3 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/linked-artifacts.js +13 -3
- package/dist/cli/commands/linked-artifacts.js.map +1 -1
- package/dist/cli/commands/list.js +12 -9
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/plan.js +2 -2
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/restore.js +5 -11
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/search.d.ts +39 -1
- package/dist/cli/commands/search.js +89 -12
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/update.js +96 -58
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +1 -1
- package/dist/cli/commands/validate.js +44 -2
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/extension-command-help.d.ts +9 -0
- package/dist/cli/extension-command-help.js +13 -2
- package/dist/cli/extension-command-help.js.map +1 -1
- package/dist/cli/extension-command-options.d.ts +8 -0
- package/dist/cli/extension-command-options.js +27 -2
- package/dist/cli/extension-command-options.js.map +1 -1
- package/dist/cli/help-content.js +15 -2
- package/dist/cli/help-content.js.map +1 -1
- package/dist/cli/main.d.ts +12 -0
- package/dist/cli/main.js +49 -9
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.js +34 -4
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-operations.js +3 -3
- package/dist/cli/register-operations.js.map +1 -1
- package/dist/cli-bundle/chunks/activity-CIHV64UC.js +18 -0
- package/dist/cli-bundle/chunks/{activity-XJ7WRNWS.js → activity-KW3IRP44.js} +11 -11
- package/dist/cli-bundle/chunks/{aggregate-LBCWF6UJ.js → aggregate-3ZKQG5SW.js} +10 -10
- package/dist/cli-bundle/chunks/{aggregate-OFT4YVB6.js → aggregate-FIGQEIL3.js} +10 -10
- package/dist/cli-bundle/chunks/{append-BP2ARHOK.js → append-EWJYJ7CH.js} +8 -8
- package/dist/cli-bundle/chunks/{append-5U3XR5SD.js → append-QEOLX3XB.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-CSRFOIHG.js → chunk-2EIMPCE4.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-MAKOMXVM.js → chunk-2GCDRRIF.js} +106 -67
- package/dist/cli-bundle/chunks/chunk-2GCDRRIF.js.map +1 -0
- package/dist/cli-bundle/chunks/{search-AZR2JITW.js → chunk-2PKHRP6G.js} +190 -22
- package/dist/cli-bundle/chunks/chunk-2PKHRP6G.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-YWAYOWDQ.js → chunk-32R4PIC6.js} +118 -15
- package/dist/cli-bundle/chunks/chunk-32R4PIC6.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-II3WDRCM.js → chunk-37QXHBIB.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-UCNEPMPY.js → chunk-3EWSGA7N.js} +105 -66
- package/dist/cli-bundle/chunks/chunk-3EWSGA7N.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-UMTPQMEG.js → chunk-3MDHREEV.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-I2VJM36R.js → chunk-434HM6Z5.js} +21 -21
- package/dist/cli-bundle/chunks/chunk-434HM6Z5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-Y4IBSEQ2.js → chunk-52OCIDPG.js} +20 -8
- package/dist/cli-bundle/chunks/chunk-52OCIDPG.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-DJ3YYLHG.js → chunk-5FIEHKEX.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-OURX4WVG.js → chunk-5IDI42VV.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-UA4ANRJY.js → chunk-5PCI3UBT.js} +119 -16
- package/dist/cli-bundle/chunks/chunk-5PCI3UBT.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-RVG3WLY3.js → chunk-5QICDWMV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LIVRA6VG.js → chunk-6CJWZAN7.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-AVMSP2HH.js → chunk-6H4LF7AO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-B2NEFANY.js → chunk-6M4RJS4M.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-4BFNWAMQ.js → chunk-6ZXM2XNF.js} +29 -12
- package/dist/cli-bundle/chunks/chunk-6ZXM2XNF.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-A5JPMD4Q.js → chunk-76Z3YSHV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5NS6TJ2F.js → chunk-7D3SAQXM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-DVUU3AHP.js → chunk-A4Z7ZOL5.js} +17 -6
- package/dist/cli-bundle/chunks/chunk-A4Z7ZOL5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-2E3KSWFG.js → chunk-AIS5PGI3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-47BYN6CA.js → chunk-AZMOLBN3.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-DYZKSIVX.js → chunk-B473GZWW.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-RNWE2HZR.js → chunk-C3AZ5ZML.js} +15 -15
- package/dist/cli-bundle/chunks/{chunk-S673PVHD.js → chunk-C4N5I7ZW.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-TYQBGXH2.js → chunk-CF55WVVS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4EOS35RL.js → chunk-CZPXY7UW.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-MPEWACTG.js → chunk-CZUB4XWO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-22YA6GCA.js → chunk-D7FYS6PG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5SRID7DV.js → chunk-EBH56IXK.js} +29 -12
- package/dist/cli-bundle/chunks/chunk-EBH56IXK.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-UIMLAFOE.js → chunk-F5NZWFSW.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-PSWSQHM7.js → chunk-F7K5GWP3.js} +15 -19
- package/dist/cli-bundle/chunks/chunk-F7K5GWP3.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-H3DP6OUM.js → chunk-FKBDKV7Y.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-SO2IOH37.js → chunk-FRUFKWNK.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7R5YKVKO.js → chunk-FWPDUYEY.js} +7 -7
- package/dist/cli-bundle/chunks/{search-2JX776KX.js → chunk-GMHPNNYG.js} +184 -23
- package/dist/cli-bundle/chunks/chunk-GMHPNNYG.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-USVOBLGB.js → chunk-GOZUHWFD.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZBVYKWT2.js → chunk-H7NJZWG2.js} +15 -15
- package/dist/cli-bundle/chunks/{chunk-FPQA4ZMA.js → chunk-HC4AWIKT.js} +18 -7
- package/dist/cli-bundle/chunks/chunk-HC4AWIKT.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-4L7Q4OVT.js → chunk-HCU6WUSY.js} +9 -9
- package/dist/cli-bundle/chunks/{chunk-2RI3BDFK.js → chunk-HIP7WVTL.js} +10 -9
- package/dist/cli-bundle/chunks/chunk-HIP7WVTL.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-5QLHQK7V.js → chunk-HMOADQVT.js} +26 -26
- package/dist/cli-bundle/chunks/chunk-HMOADQVT.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-K5TD74VU.js → chunk-J4MYYSOL.js} +19 -7
- package/dist/cli-bundle/chunks/chunk-J4MYYSOL.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-GDOTTY2S.js → chunk-JINYH2DB.js} +40 -2
- package/dist/cli-bundle/chunks/chunk-JINYH2DB.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-EMFDZ7N3.js → chunk-LEU5GHRC.js} +55 -5
- package/dist/cli-bundle/chunks/chunk-LEU5GHRC.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-PRUB7RI4.js → chunk-LUWW7L4B.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-N7LDJRB4.js → chunk-M5XALUSL.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NPNNW5TU.js → chunk-N5ZJACJ6.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-NNMBNN6Q.js → chunk-NB3PYLQ6.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-USKTNI7P.js → chunk-NIGXMNNI.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GL3QKIET.js → chunk-NIUEXCFS.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-OUG4CL4H.js → chunk-NJHMAJ6N.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-2K56AWDP.js → chunk-NJN7LL7U.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-5P2LQV2F.js → chunk-NSBZ2CKF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZZEM2PH7.js → chunk-NXS7ZKAK.js} +19 -14
- package/dist/cli-bundle/chunks/chunk-NXS7ZKAK.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-XV6N3QND.js → chunk-O47BPOPC.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X26ODPU4.js → chunk-OFYMIDF2.js} +14 -18
- package/dist/cli-bundle/chunks/chunk-OFYMIDF2.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-QCHNPN24.js → chunk-OTHIWLMB.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-YVYJQR6S.js → chunk-PFSRUHDH.js} +9 -9
- package/dist/cli-bundle/chunks/{chunk-M35R7LFX.js → chunk-PP2U4NMT.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-ZGEWEO7B.js → chunk-PUH4D67U.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LEC57E7K.js → chunk-Q2J2HJUN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-QSH34DSQ.js → chunk-QGG32QHW.js} +61 -4
- package/dist/cli-bundle/chunks/chunk-QGG32QHW.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-QG6M6XQE.js → chunk-QQHISQBJ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-BQVESTOG.js → chunk-QZTWBFXJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-COHNQLB2.js → chunk-R2EMWY7Q.js} +41 -3
- package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-5LZPDRFW.js → chunk-RLK7P77C.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-QTWWHFI3.js → chunk-RVHYI7SL.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-FVZSUIN5.js → chunk-SBGXDO7A.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-VP4Z36GO.js → chunk-SRYYRVPB.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-X7RKOJXL.js → chunk-SX75ADBK.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-MTDEEUGV.js → chunk-TKBHZPKD.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-HMQMRHQJ.js → chunk-UEMNL33O.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-SDUZTZ55.js → chunk-UPE3CDD7.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-VG3B2CYD.js → chunk-UV6IYE5U.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YOGXK3ON.js → chunk-WQ7NIVDK.js} +18 -13
- package/dist/cli-bundle/chunks/chunk-WQ7NIVDK.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-MTGMNUMJ.js → chunk-YCJX76PW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FP7YLQ52.js → chunk-Z6T4PQI2.js} +11 -10
- package/dist/cli-bundle/chunks/chunk-Z6T4PQI2.js.map +1 -0
- package/dist/cli-bundle/chunks/{claim-2BSYPJTJ.js → claim-RC56YUWG.js} +10 -10
- package/dist/cli-bundle/chunks/{claim-EZ6JKY5X.js → claim-THOJ6CMV.js} +10 -10
- package/dist/cli-bundle/chunks/close-DNMHGOCX.js +15 -0
- package/dist/cli-bundle/chunks/{close-3TSX6BYF.js → close-SG5MNCVQ.js} +8 -8
- package/dist/cli-bundle/chunks/{close-many-HB4UFCS3.js → close-many-3L3AQZBU.js} +15 -15
- package/dist/cli-bundle/chunks/{close-many-B7DBVA46.js → close-many-DKQLBGLV.js} +15 -15
- package/dist/cli-bundle/chunks/{comments-M7PAINZT.js → comments-M7ZOZNBX.js} +10 -10
- package/dist/cli-bundle/chunks/{comments-X7M7XM6I.js → comments-SKWMDWCW.js} +10 -10
- package/dist/cli-bundle/chunks/{config-YICACPHA.js → config-7CK62S7T.js} +30 -10
- package/dist/cli-bundle/chunks/config-7CK62S7T.js.map +1 -0
- package/dist/cli-bundle/chunks/{config-UWF3KRP5.js → config-OZCUABPB.js} +29 -9
- package/dist/cli-bundle/chunks/config-OZCUABPB.js.map +7 -0
- package/dist/cli-bundle/chunks/{context-EGUGU4K7.js → context-OEC366TO.js} +13 -13
- package/dist/cli-bundle/chunks/{context-V32ZAPL6.js → context-PUG2A7RC.js} +13 -13
- package/dist/cli-bundle/chunks/{contracts-B2YWYUV5.js → contracts-3THOLA7L.js} +10 -8
- package/dist/cli-bundle/chunks/contracts-3THOLA7L.js.map +7 -0
- package/dist/cli-bundle/chunks/{contracts-7G553BHP.js → contracts-N65FXEOL.js} +10 -8
- package/dist/cli-bundle/chunks/contracts-N65FXEOL.js.map +1 -0
- package/dist/cli-bundle/chunks/{copy-NWFFRYWM.js → copy-6QLHILAC.js} +7 -7
- package/dist/cli-bundle/chunks/{copy-RMLXLZOL.js → copy-JPX7VZCH.js} +7 -7
- package/dist/cli-bundle/chunks/create-NNP6TSFO.js +30 -0
- package/dist/cli-bundle/chunks/{create-GK4MX2LJ.js → create-Y54ZVVZH.js} +14 -14
- package/dist/cli-bundle/chunks/{delete-RMGNIL2S.js → delete-63PCMQAJ.js} +7 -7
- package/dist/cli-bundle/chunks/{delete-EFQLVEAS.js → delete-GDSMGAGJ.js} +7 -7
- package/dist/cli-bundle/chunks/{deps-WKHUPVD3.js → deps-T4ZF5G54.js} +7 -7
- package/dist/cli-bundle/chunks/{deps-K2I7QV4Y.js → deps-XYQ73XRH.js} +7 -7
- package/dist/cli-bundle/chunks/{docs-3FXRDYA7.js → docs-C75YIXHC.js} +10 -9
- package/dist/cli-bundle/chunks/{docs-3FXRDYA7.js.map → docs-C75YIXHC.js.map} +1 -1
- package/dist/cli-bundle/chunks/{docs-2H2UGIT6.js → docs-EHNPDWUL.js} +12 -11
- package/dist/cli-bundle/chunks/{docs-2H2UGIT6.js.map → docs-EHNPDWUL.js.map} +1 -1
- package/dist/cli-bundle/chunks/eval-3WKDTRMH.js +276 -0
- package/dist/cli-bundle/chunks/eval-3WKDTRMH.js.map +1 -0
- package/dist/cli-bundle/chunks/eval-GTENKE24.js +286 -0
- package/dist/cli-bundle/chunks/eval-GTENKE24.js.map +7 -0
- package/dist/cli-bundle/chunks/{extension-4LPTFTV4.js → extension-46NWACO3.js} +5 -5
- package/dist/cli-bundle/chunks/{extension-ASUPTDCC.js → extension-D5FDZ2CO.js} +5 -5
- package/dist/cli-bundle/chunks/{files-TXEQOA7C.js → files-DSZBOSSN.js} +12 -11
- package/dist/cli-bundle/chunks/{files-TXEQOA7C.js.map → files-DSZBOSSN.js.map} +1 -1
- package/dist/cli-bundle/chunks/{files-UAZFB3EA.js → files-X3H7CCBQ.js} +10 -9
- package/dist/cli-bundle/chunks/{files-UAZFB3EA.js.map → files-X3H7CCBQ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{focus-UGROAMAX.js → focus-5STQXDPU.js} +8 -8
- package/dist/cli-bundle/chunks/{focus-ELOPN2SR.js → focus-MDVPOWB5.js} +8 -8
- package/dist/cli-bundle/chunks/gc-ZC7JHBG7.js +395 -0
- package/dist/cli-bundle/chunks/gc-ZC7JHBG7.js.map +7 -0
- package/dist/cli-bundle/chunks/gc-ZMST3WQP.js +385 -0
- package/dist/cli-bundle/chunks/gc-ZMST3WQP.js.map +1 -0
- package/dist/cli-bundle/chunks/{get-OTXPLWYW.js → get-J2IPJRZW.js} +11 -11
- package/dist/cli-bundle/chunks/{get-IWZ7IMPS.js → get-NT7L2HUZ.js} +11 -11
- package/dist/cli-bundle/chunks/{health-PPTJ7XKW.js → health-IVMA3XQC.js} +38 -26
- package/dist/cli-bundle/chunks/health-IVMA3XQC.js.map +1 -0
- package/dist/cli-bundle/chunks/{health-JEBESKID.js → health-WOYBR3KU.js} +37 -25
- package/dist/cli-bundle/chunks/health-WOYBR3KU.js.map +7 -0
- package/dist/cli-bundle/chunks/{history-HNWBUDMI.js → history-RLH2QCRO.js} +10 -10
- package/dist/cli-bundle/chunks/history-WX3MGFS2.js +20 -0
- package/dist/cli-bundle/chunks/{history-compact-MMQC7MCW.js → history-compact-UXDIFC33.js} +12 -12
- package/dist/cli-bundle/chunks/{history-compact-EQXVPK3V.js → history-compact-ZBEBGJM7.js} +12 -12
- package/dist/cli-bundle/chunks/{history-redact-UBDHBEJE.js → history-redact-P7I7AWMB.js} +11 -11
- package/dist/cli-bundle/chunks/history-redact-YQGU3XRA.js +21 -0
- package/dist/cli-bundle/chunks/{history-repair-GMMHFAGH.js → history-repair-52KINVIK.js} +12 -12
- package/dist/cli-bundle/chunks/{history-repair-7DSDRPMX.js → history-repair-RM5ITLU5.js} +12 -12
- package/dist/cli-bundle/chunks/{init-QGK4JFF6.js → init-2BNZOO6F.js} +10 -10
- package/dist/cli-bundle/chunks/init-SC2P6CHP.js +20 -0
- package/dist/cli-bundle/chunks/{learnings-DR53TWRA.js → learnings-W6F3FIPL.js} +10 -10
- package/dist/cli-bundle/chunks/{learnings-A6DGBMG3.js → learnings-YGYVHWJK.js} +10 -10
- package/dist/cli-bundle/chunks/{list-LJ5DBXC3.js → list-K6FPV4J4.js} +10 -10
- package/dist/cli-bundle/chunks/{list-KOJN23UL.js → list-KPAYU5KZ.js} +10 -10
- package/dist/cli-bundle/chunks/{notes-7VLTHKPW.js → notes-PU74EPKV.js} +10 -10
- package/dist/cli-bundle/chunks/{notes-K5I3TAYR.js → notes-YTD6ZILW.js} +10 -10
- package/dist/cli-bundle/chunks/{plan-X3STKLED.js → plan-FNXHXRCI.js} +15 -15
- package/dist/cli-bundle/chunks/plan-FNXHXRCI.js.map +7 -0
- package/dist/cli-bundle/chunks/{plan-BK3OMLGP.js → plan-GEQYUCBW.js} +16 -16
- package/dist/cli-bundle/chunks/plan-GEQYUCBW.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-list-query-XDLFESU7.js → register-list-query-PHWYHENI.js} +43 -22
- package/dist/cli-bundle/chunks/register-list-query-PHWYHENI.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-list-query-FUMXPWZ4.js → register-list-query-QI45RMKN.js} +42 -21
- package/dist/cli-bundle/chunks/register-list-query-QI45RMKN.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-mutation-RXRX4P7D.js → register-mutation-X3BUOQEL.js} +33 -33
- package/dist/cli-bundle/chunks/{register-mutation-ZAGVKMBQ.js → register-mutation-YINRTS7L.js} +33 -33
- package/dist/cli-bundle/chunks/{register-operations-DGSHCS75.js → register-operations-E5JEASRK.js} +35 -35
- package/dist/cli-bundle/chunks/register-operations-E5JEASRK.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-operations-6UURPZN5.js → register-operations-MIDTRW7S.js} +34 -34
- package/dist/cli-bundle/chunks/{register-operations-6UURPZN5.js.map → register-operations-MIDTRW7S.js.map} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-LTJG52WP.js → register-setup-DYBFLEZX.js} +15 -15
- package/dist/cli-bundle/chunks/{register-setup-2FEGSFLM.js → register-setup-EG2U6CEU.js} +15 -15
- package/dist/cli-bundle/chunks/restore-5KHR2YYQ.js +19 -0
- package/dist/cli-bundle/chunks/{restore-SJUWYOCK.js → restore-XQYSWBV7.js} +11 -11
- package/dist/cli-bundle/chunks/{scheduling-shortcuts-VWAMP2S2.js → scheduling-shortcuts-HJMTEXKE.js} +14 -14
- package/dist/cli-bundle/chunks/{scheduling-shortcuts-W4F2LKHW.js → scheduling-shortcuts-NNT5ASZR.js} +14 -14
- package/dist/cli-bundle/chunks/{schema-N5ETYD4P.js → schema-263RI4WW.js} +9 -9
- package/dist/cli-bundle/chunks/{schema-DXQRIEFM.js → schema-TZXW6XWD.js} +9 -9
- package/dist/cli-bundle/chunks/search-LECJYSXE.js +33 -0
- package/dist/cli-bundle/chunks/search-SFRJOVDG.js +37 -0
- package/dist/cli-bundle/chunks/{stats-ZFESFVQC.js → stats-N7ER2PNK.js} +8 -8
- package/dist/cli-bundle/chunks/{stats-J563NJBY.js → stats-VPBGSRQH.js} +8 -8
- package/dist/cli-bundle/chunks/{telemetry-BNGLIFEM.js → telemetry-L6K3BUIQ.js} +4 -4
- package/dist/cli-bundle/chunks/{telemetry-SC7HPRXX.js → telemetry-PP3FUNBU.js} +4 -4
- package/dist/cli-bundle/chunks/{test-47UQGEXE.js → test-3EGNS3T5.js} +15 -15
- package/dist/cli-bundle/chunks/{test-55RJCGRU.js → test-RQCTSWUK.js} +15 -15
- package/dist/cli-bundle/chunks/{test-all-DN6KG4FX.js → test-all-NJ5V2QFS.js} +15 -15
- package/dist/cli-bundle/chunks/{test-all-5SFTTRNL.js → test-all-ZHFAWNC3.js} +15 -15
- package/dist/cli-bundle/chunks/{test-runs-NHRBT7SN.js → test-runs-AJHR6IQF.js} +5 -5
- package/dist/cli-bundle/chunks/{test-runs-DZEDJ4GH.js → test-runs-GN3C6GOI.js} +5 -5
- package/dist/cli-bundle/chunks/update-6YXOGHRT.js +24 -0
- package/dist/cli-bundle/chunks/update-6YXOGHRT.js.map +7 -0
- package/dist/cli-bundle/chunks/update-V33YUBRP.js +28 -0
- package/dist/cli-bundle/chunks/update-V33YUBRP.js.map +1 -0
- package/dist/cli-bundle/chunks/{update-many-IRNV3OTG.js → update-many-N2AN6ZDH.js} +23 -23
- package/dist/cli-bundle/chunks/{update-many-OKYWFCBO.js → update-many-RYQ64CFW.js} +23 -23
- package/dist/cli-bundle/chunks/{upgrade-KP4I45V5.js → upgrade-TJXFLZIX.js} +5 -5
- package/dist/cli-bundle/chunks/{upgrade-3RIAFQIK.js → upgrade-VPCIYAVW.js} +5 -5
- package/dist/cli-bundle/chunks/{validate-GVY4VE43.js → validate-JMNWEUYF.js} +62 -24
- package/dist/cli-bundle/chunks/validate-JMNWEUYF.js.map +1 -0
- package/dist/cli-bundle/chunks/{validate-ADKGN37M.js → validate-PHKIYGSY.js} +61 -23
- package/dist/cli-bundle/chunks/validate-PHKIYGSY.js.map +7 -0
- package/dist/cli-bundle/main.js +133 -55
- package/dist/cli-bundle/main.js.map +2 -2
- package/dist/core/checkpoint/checkpoint-gc.d.ts +69 -0
- package/dist/core/checkpoint/checkpoint-gc.js +175 -0
- package/dist/core/checkpoint/checkpoint-gc.js.map +1 -0
- package/dist/core/config/nested-settings.js +22 -2
- package/dist/core/config/nested-settings.js.map +1 -1
- package/dist/core/diagnostics/remediation.js +40 -2
- package/dist/core/diagnostics/remediation.js.map +1 -1
- package/dist/core/extensions/extension-types.d.ts +0 -9
- package/dist/core/extensions/extension-types.js +2 -27
- package/dist/core/extensions/extension-types.js.map +1 -1
- package/dist/core/fs/fs-utils.d.ts +17 -1
- package/dist/core/fs/fs-utils.js +19 -3
- package/dist/core/fs/fs-utils.js.map +1 -1
- package/dist/core/history/drift-scan.d.ts +17 -5
- package/dist/core/history/drift-scan.js +22 -14
- package/dist/core/history/drift-scan.js.map +1 -1
- package/dist/core/history/replay.d.ts +7 -0
- package/dist/core/history/replay.js +11 -6
- package/dist/core/history/replay.js.map +1 -1
- package/dist/core/item/item-format-version.d.ts +87 -0
- package/dist/core/item/item-format-version.js +85 -0
- package/dist/core/item/item-format-version.js.map +1 -0
- package/dist/core/item/item-format.js +8 -2
- package/dist/core/item/item-format.js.map +1 -1
- package/dist/core/item/status-filter.d.ts +7 -3
- package/dist/core/item/status-filter.js +26 -5
- package/dist/core/item/status-filter.js.map +1 -1
- package/dist/core/search/bm25.d.ts +113 -0
- package/dist/core/search/bm25.js +178 -0
- package/dist/core/search/bm25.js.map +1 -0
- package/dist/core/search/eval.d.ts +114 -0
- package/dist/core/search/eval.js +217 -0
- package/dist/core/search/eval.js.map +1 -0
- package/dist/core/sentry/instrument.d.ts +14 -0
- package/dist/core/sentry/instrument.js +43 -3
- package/dist/core/sentry/instrument.js.map +1 -1
- package/dist/core/shared/constants.js +6 -2
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/store/paths.js +4 -3
- package/dist/core/store/paths.js.map +1 -1
- package/dist/core/store/settings-validator.d.ts +7 -0
- package/dist/core/store/settings-validator.js +10 -2
- package/dist/core/store/settings-validator.js.map +1 -1
- package/dist/core/store/settings.js +6 -2
- package/dist/core/store/settings.js.map +1 -1
- package/dist/mcp/tool-definitions.js +4 -3
- package/dist/mcp/tool-definitions.js.map +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +3 -2
- package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +4 -4
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
- package/dist/sdk/cli-contracts.d.ts +1 -0
- package/dist/sdk/cli-contracts.js +11 -2
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +3 -3
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/runtime.d.ts +1 -0
- package/dist/sdk/runtime.js +3 -2
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/testing.d.ts +48 -1
- package/dist/sdk/testing.js +98 -2
- package/dist/sdk/testing.js.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/docs/AGENT_GUIDE.md +1 -0
- package/docs/ARCHITECTURE.md +126 -11
- package/docs/CLAUDE_CODE_PLUGIN.md +5 -13
- package/docs/COMMANDS.md +57 -5
- package/docs/CONFIGURATION.md +39 -0
- package/docs/EXTENSIONS.md +2 -2
- package/docs/MIGRATION_CLI_SIMPLIFICATION.md +9 -2
- package/docs/QUICKSTART.md +2 -0
- package/docs/README.md +2 -0
- package/docs/RELEASING.md +2 -1
- package/docs/SDK.md +80 -1
- package/docs/TESTING.md +18 -0
- package/package.json +4 -3
- package/packages/pm-command-kit/README.md +4 -0
- package/packages/pm-todos/extensions/todos/index.js +2 -0
- package/packages/pm-todos/extensions/todos/index.ts +2 -0
- package/packages/pm-todos/extensions/todos/runtime.js +192 -9
- package/packages/pm-todos/extensions/todos/runtime.ts +211 -8
- package/dist/cli-bundle/chunks/activity-62I26XZB.js +0 -18
- package/dist/cli-bundle/chunks/chunk-2RI3BDFK.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-4BFNWAMQ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5QLHQK7V.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5SRID7DV.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-COHNQLB2.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-DVUU3AHP.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-EMFDZ7N3.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-FP7YLQ52.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-FPQA4ZMA.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-GDOTTY2S.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-I2VJM36R.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-K5TD74VU.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MAKOMXVM.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-PSWSQHM7.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-QSH34DSQ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-UA4ANRJY.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-UCNEPMPY.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-X26ODPU4.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-Y4IBSEQ2.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-YOGXK3ON.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-YWAYOWDQ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-ZZEM2PH7.js.map +0 -1
- package/dist/cli-bundle/chunks/close-TQZK43Z5.js +0 -15
- package/dist/cli-bundle/chunks/config-UWF3KRP5.js.map +0 -7
- package/dist/cli-bundle/chunks/config-YICACPHA.js.map +0 -1
- package/dist/cli-bundle/chunks/contracts-7G553BHP.js.map +0 -1
- package/dist/cli-bundle/chunks/contracts-B2YWYUV5.js.map +0 -7
- package/dist/cli-bundle/chunks/create-UZLJXHLA.js +0 -30
- package/dist/cli-bundle/chunks/gc-5RTYXLQU.js +0 -211
- package/dist/cli-bundle/chunks/gc-5RTYXLQU.js.map +0 -7
- package/dist/cli-bundle/chunks/gc-FK5732EK.js +0 -208
- package/dist/cli-bundle/chunks/gc-FK5732EK.js.map +0 -1
- package/dist/cli-bundle/chunks/health-JEBESKID.js.map +0 -7
- package/dist/cli-bundle/chunks/health-PPTJ7XKW.js.map +0 -1
- package/dist/cli-bundle/chunks/history-TKTULEVE.js +0 -20
- package/dist/cli-bundle/chunks/history-redact-SPIFIXVY.js +0 -21
- package/dist/cli-bundle/chunks/init-A6FTZ5UC.js +0 -20
- package/dist/cli-bundle/chunks/plan-BK3OMLGP.js.map +0 -1
- package/dist/cli-bundle/chunks/plan-X3STKLED.js.map +0 -7
- package/dist/cli-bundle/chunks/register-list-query-FUMXPWZ4.js.map +0 -7
- package/dist/cli-bundle/chunks/register-list-query-XDLFESU7.js.map +0 -1
- package/dist/cli-bundle/chunks/register-operations-DGSHCS75.js.map +0 -1
- package/dist/cli-bundle/chunks/restore-PI3WM4GK.js +0 -19
- package/dist/cli-bundle/chunks/search-2JX776KX.js.map +0 -1
- package/dist/cli-bundle/chunks/search-AZR2JITW.js.map +0 -7
- package/dist/cli-bundle/chunks/update-2BZEAI7B.js +0 -24
- package/dist/cli-bundle/chunks/update-GCNLER2H.js +0 -28
- package/dist/cli-bundle/chunks/validate-ADKGN37M.js.map +0 -7
- package/dist/cli-bundle/chunks/validate-GVY4VE43.js.map +0 -1
- /package/dist/cli-bundle/chunks/{activity-62I26XZB.js.map → activity-CIHV64UC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{activity-XJ7WRNWS.js.map → activity-KW3IRP44.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{aggregate-LBCWF6UJ.js.map → aggregate-3ZKQG5SW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{aggregate-OFT4YVB6.js.map → aggregate-FIGQEIL3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{append-BP2ARHOK.js.map → append-EWJYJ7CH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{append-5U3XR5SD.js.map → append-QEOLX3XB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-CSRFOIHG.js.map → chunk-2EIMPCE4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-II3WDRCM.js.map → chunk-37QXHBIB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UMTPQMEG.js.map → chunk-3MDHREEV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DJ3YYLHG.js.map → chunk-5FIEHKEX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OURX4WVG.js.map → chunk-5IDI42VV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RVG3WLY3.js.map → chunk-5QICDWMV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-LIVRA6VG.js.map → chunk-6CJWZAN7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AVMSP2HH.js.map → chunk-6H4LF7AO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-B2NEFANY.js.map → chunk-6M4RJS4M.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-A5JPMD4Q.js.map → chunk-76Z3YSHV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-5NS6TJ2F.js.map → chunk-7D3SAQXM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2E3KSWFG.js.map → chunk-AIS5PGI3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-47BYN6CA.js.map → chunk-AZMOLBN3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DYZKSIVX.js.map → chunk-B473GZWW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RNWE2HZR.js.map → chunk-C3AZ5ZML.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-S673PVHD.js.map → chunk-C4N5I7ZW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-TYQBGXH2.js.map → chunk-CF55WVVS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4EOS35RL.js.map → chunk-CZPXY7UW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MPEWACTG.js.map → chunk-CZUB4XWO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-22YA6GCA.js.map → chunk-D7FYS6PG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UIMLAFOE.js.map → chunk-F5NZWFSW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-H3DP6OUM.js.map → chunk-FKBDKV7Y.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-SO2IOH37.js.map → chunk-FRUFKWNK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7R5YKVKO.js.map → chunk-FWPDUYEY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-USVOBLGB.js.map → chunk-GOZUHWFD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZBVYKWT2.js.map → chunk-H7NJZWG2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4L7Q4OVT.js.map → chunk-HCU6WUSY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PRUB7RI4.js.map → chunk-LUWW7L4B.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-N7LDJRB4.js.map → chunk-M5XALUSL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-NPNNW5TU.js.map → chunk-N5ZJACJ6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-NNMBNN6Q.js.map → chunk-NB3PYLQ6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-USKTNI7P.js.map → chunk-NIGXMNNI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GL3QKIET.js.map → chunk-NIUEXCFS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OUG4CL4H.js.map → chunk-NJHMAJ6N.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2K56AWDP.js.map → chunk-NJN7LL7U.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-5P2LQV2F.js.map → chunk-NSBZ2CKF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XV6N3QND.js.map → chunk-O47BPOPC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QCHNPN24.js.map → chunk-OTHIWLMB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YVYJQR6S.js.map → chunk-PFSRUHDH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-M35R7LFX.js.map → chunk-PP2U4NMT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZGEWEO7B.js.map → chunk-PUH4D67U.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-LEC57E7K.js.map → chunk-Q2J2HJUN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QG6M6XQE.js.map → chunk-QQHISQBJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BQVESTOG.js.map → chunk-QZTWBFXJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-5LZPDRFW.js.map → chunk-RLK7P77C.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QTWWHFI3.js.map → chunk-RVHYI7SL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FVZSUIN5.js.map → chunk-SBGXDO7A.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VP4Z36GO.js.map → chunk-SRYYRVPB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-X7RKOJXL.js.map → chunk-SX75ADBK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MTDEEUGV.js.map → chunk-TKBHZPKD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-HMQMRHQJ.js.map → chunk-UEMNL33O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-SDUZTZ55.js.map → chunk-UPE3CDD7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VG3B2CYD.js.map → chunk-UV6IYE5U.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-MTGMNUMJ.js.map → chunk-YCJX76PW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{claim-2BSYPJTJ.js.map → claim-RC56YUWG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{claim-EZ6JKY5X.js.map → claim-THOJ6CMV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-TQZK43Z5.js.map → close-DNMHGOCX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-3TSX6BYF.js.map → close-SG5MNCVQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-HB4UFCS3.js.map → close-many-3L3AQZBU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-B7DBVA46.js.map → close-many-DKQLBGLV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-M7PAINZT.js.map → comments-M7ZOZNBX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-X7M7XM6I.js.map → comments-SKWMDWCW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{context-EGUGU4K7.js.map → context-OEC366TO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{context-V32ZAPL6.js.map → context-PUG2A7RC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-NWFFRYWM.js.map → copy-6QLHILAC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-RMLXLZOL.js.map → copy-JPX7VZCH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-UZLJXHLA.js.map → create-NNP6TSFO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-GK4MX2LJ.js.map → create-Y54ZVVZH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-RMGNIL2S.js.map → delete-63PCMQAJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-EFQLVEAS.js.map → delete-GDSMGAGJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-WKHUPVD3.js.map → deps-T4ZF5G54.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-K2I7QV4Y.js.map → deps-XYQ73XRH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{extension-4LPTFTV4.js.map → extension-46NWACO3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{extension-ASUPTDCC.js.map → extension-D5FDZ2CO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-UGROAMAX.js.map → focus-5STQXDPU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-ELOPN2SR.js.map → focus-MDVPOWB5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{get-OTXPLWYW.js.map → get-J2IPJRZW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{get-IWZ7IMPS.js.map → get-NT7L2HUZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-HNWBUDMI.js.map → history-RLH2QCRO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-TKTULEVE.js.map → history-WX3MGFS2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-MMQC7MCW.js.map → history-compact-UXDIFC33.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-EQXVPK3V.js.map → history-compact-ZBEBGJM7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-UBDHBEJE.js.map → history-redact-P7I7AWMB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-SPIFIXVY.js.map → history-redact-YQGU3XRA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-GMMHFAGH.js.map → history-repair-52KINVIK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-7DSDRPMX.js.map → history-repair-RM5ITLU5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{init-QGK4JFF6.js.map → init-2BNZOO6F.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{init-A6FTZ5UC.js.map → init-SC2P6CHP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-DR53TWRA.js.map → learnings-W6F3FIPL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-A6DGBMG3.js.map → learnings-YGYVHWJK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{list-LJ5DBXC3.js.map → list-K6FPV4J4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{list-KOJN23UL.js.map → list-KPAYU5KZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-7VLTHKPW.js.map → notes-PU74EPKV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-K5I3TAYR.js.map → notes-YTD6ZILW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-mutation-RXRX4P7D.js.map → register-mutation-X3BUOQEL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-mutation-ZAGVKMBQ.js.map → register-mutation-YINRTS7L.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-LTJG52WP.js.map → register-setup-DYBFLEZX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{register-setup-2FEGSFLM.js.map → register-setup-EG2U6CEU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-PI3WM4GK.js.map → restore-5KHR2YYQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-SJUWYOCK.js.map → restore-XQYSWBV7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{scheduling-shortcuts-VWAMP2S2.js.map → scheduling-shortcuts-HJMTEXKE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{scheduling-shortcuts-W4F2LKHW.js.map → scheduling-shortcuts-NNT5ASZR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-N5ETYD4P.js.map → schema-263RI4WW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-DXQRIEFM.js.map → schema-TZXW6XWD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-55RJCGRU.js.map → search-LECJYSXE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-47UQGEXE.js.map → search-SFRJOVDG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{stats-ZFESFVQC.js.map → stats-N7ER2PNK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{stats-J563NJBY.js.map → stats-VPBGSRQH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{telemetry-BNGLIFEM.js.map → telemetry-L6K3BUIQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{telemetry-SC7HPRXX.js.map → telemetry-PP3FUNBU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-GCNLER2H.js.map → test-3EGNS3T5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-2BZEAI7B.js.map → test-RQCTSWUK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-all-DN6KG4FX.js.map → test-all-NJ5V2QFS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-all-5SFTTRNL.js.map → test-all-ZHFAWNC3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-runs-NHRBT7SN.js.map → test-runs-AJHR6IQF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-runs-DZEDJ4GH.js.map → test-runs-GN3C6GOI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-IRNV3OTG.js.map → update-many-N2AN6ZDH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-OKYWFCBO.js.map → update-many-RYQ64CFW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{upgrade-KP4I45V5.js.map → upgrade-TJXFLZIX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{upgrade-3RIAFQIK.js.map → upgrade-VPCIYAVW.js.map} +0 -0
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Implements the pm restore command surface and its agent-facing runtime behavior.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2a9ec353-cabe-59ee-a47c-e69ea28f7ab0")}catch(e){}}();
|
|
8
8
|
import jsonPatch from "fast-json-patch";
|
|
9
9
|
import fs from "node:fs/promises";
|
|
10
10
|
import { pathExists, readFileIfExists, writeFileAtomic } from "../../core/fs/fs-utils.js";
|
|
11
11
|
import { appendHistoryEntry, createHistoryEntry } from "../../core/history/history.js";
|
|
12
|
-
import { EMPTY_REPLAY_DOCUMENT, normalizeReplayPatchOps, replayHash, toReplayDocument, } from "../../core/history/replay.js";
|
|
12
|
+
import { EMPTY_REPLAY_DOCUMENT, normalizeReplayPatchOps, replayHash, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, } from "../../core/history/replay.js";
|
|
13
13
|
import { enforceHistoryStreamPolicyForItem } from "../../core/history/history-stream-policy.js";
|
|
14
14
|
import { normalizeItemId, normalizeRawItemId } from "../../core/item/id.js";
|
|
15
15
|
import { canonicalDocument, serializeItemDocument } from "../../core/item/item-format.js";
|
|
@@ -174,10 +174,7 @@ function replayCurrentDocument(history) {
|
|
|
174
174
|
body: currentReplay.body,
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
return canonicalDocument(
|
|
178
|
-
metadata: currentReplay.metadata,
|
|
179
|
-
body: currentReplay.body,
|
|
180
|
-
});
|
|
177
|
+
return canonicalDocument(replayToItemDocument(currentReplay));
|
|
181
178
|
}
|
|
182
179
|
async function resolveRestoreSubject(pmRoot, id, settings, typeToFolder) {
|
|
183
180
|
const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeToFolder);
|
|
@@ -248,10 +245,7 @@ export async function runRestore(id, target, options, global) {
|
|
|
248
245
|
}
|
|
249
246
|
const resolvedTarget = ensureReplayTarget(target, history);
|
|
250
247
|
const replayDocument = ensureMaterializedRestoreTarget(replayToTarget(history, resolvedTarget.historyIndex), resolvedTarget);
|
|
251
|
-
const restoredDocument =
|
|
252
|
-
metadata: replayDocument.metadata,
|
|
253
|
-
body: replayDocument.body,
|
|
254
|
-
}, { schema: settings.schema });
|
|
248
|
+
const restoredDocument = replayToCanonicalItemDocument(replayDocument, { schema: settings.schema });
|
|
255
249
|
if (restoredDocument.metadata.id !== resolvedId) {
|
|
256
250
|
throw new PmCliError(`Restore target resolved to item ${restoredDocument.metadata.id}, expected ${resolvedId}.`, EXIT_CODE.GENERIC_FAILURE);
|
|
257
251
|
}
|
|
@@ -384,4 +378,4 @@ export const _testOnlyRestoreCommand = {
|
|
|
384
378
|
resolveRestoreSubject,
|
|
385
379
|
};
|
|
386
380
|
//# sourceMappingURL=restore.js.map
|
|
387
|
-
//# debugId=
|
|
381
|
+
//# debugId=2a9ec353-cabe-59ee-a47c-e69ea28f7ab0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restore.js","sources":["cli/commands/restore.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module cli/commands/restore\n *\n * Implements the pm restore command surface and its agent-facing runtime behavior.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport fs from \"node:fs/promises\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { appendHistoryEntry, createHistoryEntry } from \"../../core/history/history.js\";\nimport {\n EMPTY_REPLAY_DOCUMENT,\n normalizeReplayPatchOps,\n replayHash,\n toReplayDocument,\n type ReplayDocument as CanonicalReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { enforceHistoryStreamPolicyForItem } from \"../../core/history/history-stream-policy.js\";\nimport { normalizeItemId, normalizeRawItemId } from \"../../core/item/id.js\";\nimport { canonicalDocument, serializeItemDocument } from \"../../core/item/item-format.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { acquireLock } from \"../../core/lock/lock.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport {\n getActiveExtensionRegistrations,\n projectAfterCommandItemSnapshot,\n recordAfterCommandAffectedItem,\n runActiveOnWriteHooks,\n} from \"../../core/extensions/index.js\";\nimport { locateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\n\ninterface ResolvedRestoreTarget {\n kind: \"version\" | \"timestamp\";\n raw: string;\n historyIndex: number;\n}\n\ninterface ResolvedRestoreSubject {\n id: string;\n historyPath: string;\n located: Awaited<ReturnType<typeof locateItem>>;\n historyPolicyWarnings: string[];\n}\n\n/**\n * Documents the restore command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreCommandOptions {\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/**\n * Documents the restore result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreResult {\n item: ItemMetadata;\n restored_from: {\n kind: \"version\" | \"timestamp\";\n target: string;\n history_index: number;\n entry_ts: string;\n entry_op: string;\n };\n changed_fields: string[];\n warnings: string[];\n}\n\nfunction ensureReplayTarget(target: string, history: HistoryEntry[]): ResolvedRestoreTarget {\n const trimmed = target.trim();\n if (!trimmed) {\n throw new PmCliError(\"Missing restore target. Use a timestamp or version number.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(trimmed)) {\n const version = Number(trimmed);\n if (!Number.isSafeInteger(version) || version < 1 || version > history.length) {\n throw new PmCliError(\n `Restore version must be between 1 and ${history.length} for this item.`,\n EXIT_CODE.USAGE,\n );\n }\n return {\n kind: \"version\",\n raw: trimmed,\n historyIndex: version - 1,\n };\n }\n\n const parsedTarget = Date.parse(trimmed);\n if (!Number.isFinite(parsedTarget)) {\n throw new PmCliError(\n `Invalid restore target \"${target}\". Use a positive version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let index = -1;\n for (let i = 0; i < history.length; i += 1) {\n const entryTimestamp = Date.parse(history[i].ts);\n if (!Number.isFinite(entryTimestamp)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTimestamp <= parsedTarget) {\n index = i;\n }\n }\n\n if (index < 0) {\n throw new PmCliError(`No history entries exist at or before timestamp ${trimmed}.`, EXIT_CODE.USAGE);\n }\n\n return {\n kind: \"timestamp\",\n raw: trimmed,\n historyIndex: index,\n };\n}\n\nfunction extractPatchFailureContext(\n patch: HistoryPatchOp[],\n error: unknown,\n): { patchIndex?: number; op?: string; path?: string; from?: string; reason?: string } {\n const context: { patchIndex?: number; op?: string; path?: string; from?: string; reason?: string } = {};\n if (error instanceof Error && error.message.trim().length > 0) {\n context.reason = error.message.trim();\n }\n if (typeof error !== \"object\" || error === null) {\n return context;\n }\n const candidate = error as {\n index?: unknown;\n operation?: unknown;\n };\n /* c8 ignore start -- parser-generated patch errors may omit index metadata in current fixtures. */\n if (typeof candidate.index === \"number\" && Number.isInteger(candidate.index) && candidate.index >= 0) {\n context.patchIndex = candidate.index;\n }\n /* c8 ignore stop */\n /* c8 ignore start -- operation payload metadata is optional in upstream json-patch failures. */\n const operationRecord =\n typeof candidate.operation === \"object\" && candidate.operation !== null\n ? (candidate.operation as { op?: unknown; path?: unknown; from?: unknown })\n : null;\n /* c8 ignore stop */\n if (operationRecord && typeof operationRecord.op === \"string\") {\n context.op = operationRecord.op;\n }\n if (operationRecord && typeof operationRecord.path === \"string\") {\n context.path = operationRecord.path;\n }\n if (operationRecord && typeof operationRecord.from === \"string\") {\n context.from = operationRecord.from;\n }\n if ((context.op === undefined || context.path === undefined) && context.patchIndex !== undefined) {\n const fallback = patch[context.patchIndex];\n /* c8 ignore start -- fallback enrichment paths are only exercised by malformed patch telemetry payloads. */\n if (fallback) {\n context.op = context.op ?? fallback.op;\n context.path = context.path ?? fallback.path;\n context.from = context.from ?? fallback.from;\n }\n /* c8 ignore stop */\n }\n return context;\n}\n\nfunction applyHistoryPatch(\n current: CanonicalReplayDocument,\n patch: HistoryPatchOp[],\n entryNumber: number,\n entryOp: string,\n): CanonicalReplayDocument {\n try {\n const normalizedPatch = normalizeReplayPatchOps(patch);\n const applied = jsonPatch.applyPatch(\n structuredClone(current),\n normalizedPatch as jsonPatch.Operation[],\n true,\n false,\n ).newDocument as unknown;\n if (\n typeof applied !== \"object\" ||\n applied === null ||\n !(\"metadata\" in applied) ||\n !(\"body\" in applied) ||\n typeof (applied as { body: unknown }).body !== \"string\" ||\n typeof (applied as { metadata: unknown }).metadata !== \"object\" ||\n (applied as { metadata: unknown }).metadata === null\n ) {\n throw new PmCliError(\n `History replay produced an invalid document shape at entry ${entryNumber}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const replay = applied as { metadata: Record<string, unknown>; body: string };\n return {\n metadata: replay.metadata,\n body: replay.body,\n };\n } catch (error: unknown) {\n if (error instanceof PmCliError) {\n throw error;\n }\n const failureContext = extractPatchFailureContext(patch, error);\n const contextTokens = [\n `history_op=${entryOp}`,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.patchIndex !== undefined ? `patch_index=${failureContext.patchIndex}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.op ? `op=${failureContext.op}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.path ? `path=${failureContext.path}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.from ? `from=${failureContext.from}` : null,\n ].filter((token): token is string => token !== null);\n /* c8 ignore start -- jsonPatch/structuredClone/normalizeReplayPatchOps always throw Error instances with non-empty messages here, so extractPatchFailureContext always sets reason; the empty-suffix fallback is unreachable through applyHistoryPatch. */\n const reasonSuffix = failureContext.reason ? ` ${failureContext.reason}` : \"\";\n /* c8 ignore stop */\n throw new PmCliError(\n `Failed to apply history patch at entry ${entryNumber} (${contextTokens.join(\", \")}).${reasonSuffix}`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n}\n\nfunction replayToTarget(history: HistoryEntry[], targetIndex: number): CanonicalReplayDocument {\n let document: CanonicalReplayDocument = structuredClone(EMPTY_REPLAY_DOCUMENT);\n\n for (let i = 0; i <= targetIndex; i += 1) {\n const entry = history[i];\n const beforeHash = replayHash(document);\n if (beforeHash !== entry.before_hash) {\n throw new PmCliError(\n `History hash mismatch before replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n document = applyHistoryPatch(document, entry.patch, i + 1, entry.op);\n\n const afterHash = replayHash(document);\n if (afterHash !== entry.after_hash) {\n throw new PmCliError(\n `History hash mismatch after replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n }\n\n return document;\n}\n\nfunction ensureMaterializedRestoreTarget(\n replayDocument: CanonicalReplayDocument,\n target: ResolvedRestoreTarget,\n): CanonicalReplayDocument {\n if (Object.keys(replayDocument.metadata).length > 0) {\n return replayDocument;\n }\n throw new PmCliError(\n `Restore target ${target.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction replayCurrentDocument(history: HistoryEntry[]): ItemDocument {\n const currentReplay = replayToTarget(history, history.length - 1);\n if (Object.keys(currentReplay.metadata).length === 0) {\n return {\n metadata: {} as ItemMetadata,\n body: currentReplay.body,\n };\n }\n return canonicalDocument({\n metadata: currentReplay.metadata as unknown as ItemMetadata,\n body: currentReplay.body,\n });\n}\n\nasync function resolveRestoreSubject(\n pmRoot: string,\n id: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n typeToFolder: Record<string, string>,\n): Promise<ResolvedRestoreSubject> {\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeToFolder);\n if (located) {\n const historyPath = getHistoryPath(pmRoot, located.id);\n const historyPolicy = await enforceHistoryStreamPolicyForItem({\n pmRoot,\n settings,\n itemId: located.id,\n commandLabel: \"restore\",\n });\n return {\n id: located.id,\n historyPath,\n located,\n historyPolicyWarnings: historyPolicy.warnings,\n };\n }\n\n const normalizedId = normalizeItemId(id, settings.id_prefix);\n const rawNormalizedId = normalizeRawItemId(id);\n /* c8 ignore start -- raw-id fallback is covered by normalize-item-id utility tests. */\n const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];\n /* c8 ignore stop */\n for (const candidateId of candidateIds) {\n const historyPath = getHistoryPath(pmRoot, candidateId);\n if (await pathExists(historyPath)) {\n return {\n id: candidateId,\n historyPath,\n located: null,\n historyPolicyWarnings: [],\n };\n }\n }\n\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n}\n\nfunction changedFields(beforeDocument: ItemDocument, afterDocument: ItemDocument): string[] {\n const beforeReplay = toReplayDocument(beforeDocument);\n const afterReplay = toReplayDocument(afterDocument);\n const patch = jsonPatch.compare(beforeReplay, afterReplay) as HistoryPatchOp[];\n const fields = new Set<string>();\n\n for (const op of patch) {\n if (op.path === \"/body\" || op.path.startsWith(\"/body/\")) {\n fields.add(\"body\");\n continue;\n }\n const segment = op.path.replace(/^\\/(?:metadata|front_matter)\\/?/, \"\").split(\"/\")[0];\n fields.add(segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"));\n }\n\n return Array.from(fields).sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Implements run restore for the public runtime surface of this module.\n */\nexport async function runRestore(\n id: string,\n target: string,\n options: RestoreCommandOptions,\n global: GlobalOptions,\n): Promise<RestoreResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveRestoreSubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n const resolvedId = subject.id;\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const history = await readHistoryEntries(subject.historyPath, resolvedId);\n if (history.length === 0) {\n throw new PmCliError(`No history exists for ${resolvedId}; restore is unavailable.`, EXIT_CODE.NOT_FOUND);\n }\n\n const resolvedTarget = ensureReplayTarget(target, history);\n const replayDocument = ensureMaterializedRestoreTarget(replayToTarget(history, resolvedTarget.historyIndex), resolvedTarget);\n const restoredDocument = canonicalDocument(\n {\n metadata: replayDocument.metadata as unknown as ItemMetadata,\n body: replayDocument.body,\n },\n { schema: settings.schema },\n );\n\n if (restoredDocument.metadata.id !== resolvedId) {\n throw new PmCliError(\n `Restore target resolved to item ${restoredDocument.metadata.id}, expected ${resolvedId}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const loadedItemBeforeLock = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItemBeforeLock?.raw ?? null;\n\n const author = resolveAuthor(options.author, settings.author_default);\n const releaseLock = await acquireLock(\n pmRoot,\n resolvedId,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n settings.governance.force_required_for_stale_lock,\n );\n\n try {\n const historyRawUnderLock = await readFileIfExists(subject.historyPath);\n if (historyRawUnderLock !== historyRawBeforeLock) {\n throw new PmCliError(\n `History for ${resolvedId} changed while waiting for lock; retry restore.`,\n EXIT_CODE.CONFLICT,\n );\n }\n const locatedUnderLock = await locateItem(\n pmRoot,\n resolvedId,\n settings.id_prefix,\n settings.item_format,\n typeRegistry.type_to_folder,\n );\n const loadedItemUnderLock = locatedUnderLock ? await readLocatedItem(locatedUnderLock, { schema: settings.schema }) : null;\n if ((loadedItemUnderLock?.raw ?? null) !== currentItemRawBeforeLock) {\n throw new PmCliError(`Item ${resolvedId} changed while waiting for lock; retry restore.`, EXIT_CODE.CONFLICT);\n }\n\n const existingItemPath = locatedUnderLock?.itemPath ?? null;\n const itemFormat = \"toon\";\n let resolvedCurrentDocument: ItemDocument;\n let resolvedOriginalRaw: string | null = null;\n if (loadedItemUnderLock) {\n resolvedCurrentDocument = loadedItemUnderLock.document;\n resolvedOriginalRaw = loadedItemUnderLock.raw;\n } else {\n resolvedCurrentDocument = replayCurrentDocument(history);\n }\n const assigned = resolvedCurrentDocument.metadata.assignee?.trim();\n const ownershipWarnings: string[] = [];\n const hasOwnershipConflict = assigned && assigned !== author && !options.force;\n if (hasOwnershipConflict) {\n if (settings.governance.ownership_enforcement === \"strict\") {\n throw new PmCliError(\n `Item ${resolvedId} is assigned to ${assigned}. Use --force to override.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (settings.governance.ownership_enforcement === \"warn\") {\n ownershipWarnings.push(`ownership_warning:assignee_conflict:${resolvedId}:${assigned}`);\n }\n }\n\n const serializedRestore = serializeItemDocument(restoredDocument, { format: itemFormat, schema: settings.schema });\n /* c8 ignore next -- restored item path typing is exercised in restore integration workflows. */\n const restoredItemPath = getItemPath(\n pmRoot,\n restoredDocument.metadata.type,\n resolvedId,\n itemFormat,\n typeRegistry.type_to_folder,\n );\n await writeFileAtomic(restoredItemPath, serializedRestore);\n if (existingItemPath && restoredItemPath !== existingItemPath) {\n await fs.rm(existingItemPath);\n }\n\n const historyEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"restore\",\n before: resolvedCurrentDocument,\n after: restoredDocument,\n message: options.message,\n });\n\n try {\n await appendHistoryEntry(subject.historyPath, historyEntry);\n } catch (error: unknown) {\n if (existingItemPath && resolvedOriginalRaw !== null && restoredItemPath !== existingItemPath) {\n await writeFileAtomic(existingItemPath, resolvedOriginalRaw);\n await fs.rm(restoredItemPath, { force: true });\n } else if (existingItemPath && resolvedOriginalRaw !== null) {\n await writeFileAtomic(existingItemPath, resolvedOriginalRaw);\n } else {\n await fs.rm(restoredItemPath, { force: true });\n }\n throw error;\n }\n const restoreChangedFields = changedFields(resolvedCurrentDocument, restoredDocument);\n const hookWarnings = [\n ...(await runActiveOnWriteHooks({\n path: restoredItemPath,\n scope: \"project\",\n op: \"restore\",\n item_id: restoredDocument.metadata.id,\n item_type: restoredDocument.metadata.type,\n before: resolvedCurrentDocument,\n after: restoredDocument,\n changed_fields: [\"restored\"],\n })),\n ...(await runActiveOnWriteHooks({\n path: subject.historyPath,\n scope: \"project\",\n op: \"restore:history\",\n item_id: restoredDocument.metadata.id,\n item_type: restoredDocument.metadata.type,\n before: resolvedCurrentDocument,\n after: restoredDocument,\n changed_fields: [\"restored\"],\n })),\n ];\n recordAfterCommandAffectedItem({\n id: restoredDocument.metadata.id,\n op: \"restore\",\n item_type: restoredDocument.metadata.type,\n previous_status: resolvedCurrentDocument.metadata.status,\n status: restoredDocument.metadata.status,\n previous: projectAfterCommandItemSnapshot(resolvedCurrentDocument.metadata, restoreChangedFields),\n current: projectAfterCommandItemSnapshot(restoredDocument.metadata, restoreChangedFields),\n changed_fields: restoreChangedFields,\n });\n\n const targetEntry = history[resolvedTarget.historyIndex];\n return {\n item: restoredDocument.metadata,\n restored_from: {\n kind: resolvedTarget.kind,\n target: resolvedTarget.raw,\n history_index: resolvedTarget.historyIndex + 1,\n entry_ts: targetEntry.ts,\n entry_op: targetEntry.op,\n },\n changed_fields: restoreChangedFields,\n warnings: [...subject.historyPolicyWarnings, ...ownershipWarnings, ...hookWarnings],\n };\n } finally {\n await releaseLock();\n }\n}\n\nexport const _testOnlyRestoreCommand = {\n applyHistoryPatch,\n changedFields,\n ensureMaterializedRestoreTarget,\n ensureReplayTarget,\n extractPatchFailureContext,\n replayCurrentDocument,\n replayToTarget,\n resolveRestoreSubject,\n};\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iCAAiC,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE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CAAC,MAAM;YACxD,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,MAAM;YACxC,QAAQ,EAAE,+BAA+B,CAAC,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,CAAC;YACjG,OAAO,EAAE,+BAA+B,CAAC,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,CAAC;YACzF,cAAc,EAAE,oBAAoB;SACrC,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACzD,OAAO;YACL,IAAI,EAAE,gBAAgB,CAAC,QAAQ;YAC/B,aAAa,EAAE;gBACb,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,MAAM,EAAE,cAAc,CAAC,GAAG;gBAC1B,aAAa,EAAE,cAAc,CAAC,YAAY,GAAG,CAAC;gBAC9C,QAAQ,EAAE,WAAW,CAAC,EAAE;gBACxB,QAAQ,EAAE,WAAW,CAAC,EAAE;aACzB;YACD,cAAc,EAAE,oBAAoB;YACpC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,qBAAqB,EAAE,GAAG,iBAAiB,EAAE,GAAG,YAAY,CAAC;SACpF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB;IACjB,aAAa;IACb,+BAA+B;IAC/B,kBAAkB;IAClB,0BAA0B;IAC1B,qBAAqB;IACrB,cAAc;IACd,qBAAqB;CACtB,CAAC","debugId":"3553cab0-2c85-52dd-950a-dd48e0b07e11"}
|
|
1
|
+
{"version":3,"file":"restore.js","sources":["cli/commands/restore.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module cli/commands/restore\n *\n * Implements the pm restore command surface and its agent-facing runtime behavior.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport fs from \"node:fs/promises\";\nimport { pathExists, readFileIfExists, writeFileAtomic } from \"../../core/fs/fs-utils.js\";\nimport { appendHistoryEntry, createHistoryEntry } from \"../../core/history/history.js\";\nimport {\n EMPTY_REPLAY_DOCUMENT,\n normalizeReplayPatchOps,\n replayHash,\n replayToCanonicalItemDocument,\n replayToItemDocument,\n toReplayDocument,\n type ReplayDocument as CanonicalReplayDocument,\n} from \"../../core/history/replay.js\";\nimport { enforceHistoryStreamPolicyForItem } from \"../../core/history/history-stream-policy.js\";\nimport { normalizeItemId, normalizeRawItemId } from \"../../core/item/id.js\";\nimport { canonicalDocument, serializeItemDocument } from \"../../core/item/item-format.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { acquireLock } from \"../../core/lock/lock.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { nowIso } from \"../../core/shared/time.js\";\nimport {\n getActiveExtensionRegistrations,\n projectAfterCommandItemSnapshot,\n recordAfterCommandAffectedItem,\n runActiveOnWriteHooks,\n} from \"../../core/extensions/index.js\";\nimport { locateItem, readLocatedItem } from \"../../core/store/item-store.js\";\nimport { getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\nimport { readHistoryEntries } from \"./history.js\";\n\ninterface ResolvedRestoreTarget {\n kind: \"version\" | \"timestamp\";\n raw: string;\n historyIndex: number;\n}\n\ninterface ResolvedRestoreSubject {\n id: string;\n historyPath: string;\n located: Awaited<ReturnType<typeof locateItem>>;\n historyPolicyWarnings: string[];\n}\n\n/**\n * Documents the restore command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreCommandOptions {\n author?: string;\n message?: string;\n force?: boolean;\n}\n\n/**\n * Documents the restore result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RestoreResult {\n item: ItemMetadata;\n restored_from: {\n kind: \"version\" | \"timestamp\";\n target: string;\n history_index: number;\n entry_ts: string;\n entry_op: string;\n };\n changed_fields: string[];\n warnings: string[];\n}\n\nfunction ensureReplayTarget(target: string, history: HistoryEntry[]): ResolvedRestoreTarget {\n const trimmed = target.trim();\n if (!trimmed) {\n throw new PmCliError(\"Missing restore target. Use a timestamp or version number.\", EXIT_CODE.USAGE);\n }\n\n if (/^\\d+$/.test(trimmed)) {\n const version = Number(trimmed);\n if (!Number.isSafeInteger(version) || version < 1 || version > history.length) {\n throw new PmCliError(\n `Restore version must be between 1 and ${history.length} for this item.`,\n EXIT_CODE.USAGE,\n );\n }\n return {\n kind: \"version\",\n raw: trimmed,\n historyIndex: version - 1,\n };\n }\n\n const parsedTarget = Date.parse(trimmed);\n if (!Number.isFinite(parsedTarget)) {\n throw new PmCliError(\n `Invalid restore target \"${target}\". Use a positive version number or ISO timestamp.`,\n EXIT_CODE.USAGE,\n );\n }\n\n let index = -1;\n for (let i = 0; i < history.length; i += 1) {\n const entryTimestamp = Date.parse(history[i].ts);\n if (!Number.isFinite(entryTimestamp)) {\n throw new PmCliError(\n `History for this item contains invalid timestamp at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n if (entryTimestamp <= parsedTarget) {\n index = i;\n }\n }\n\n if (index < 0) {\n throw new PmCliError(`No history entries exist at or before timestamp ${trimmed}.`, EXIT_CODE.USAGE);\n }\n\n return {\n kind: \"timestamp\",\n raw: trimmed,\n historyIndex: index,\n };\n}\n\nfunction extractPatchFailureContext(\n patch: HistoryPatchOp[],\n error: unknown,\n): { patchIndex?: number; op?: string; path?: string; from?: string; reason?: string } {\n const context: { patchIndex?: number; op?: string; path?: string; from?: string; reason?: string } = {};\n if (error instanceof Error && error.message.trim().length > 0) {\n context.reason = error.message.trim();\n }\n if (typeof error !== \"object\" || error === null) {\n return context;\n }\n const candidate = error as {\n index?: unknown;\n operation?: unknown;\n };\n /* c8 ignore start -- parser-generated patch errors may omit index metadata in current fixtures. */\n if (typeof candidate.index === \"number\" && Number.isInteger(candidate.index) && candidate.index >= 0) {\n context.patchIndex = candidate.index;\n }\n /* c8 ignore stop */\n /* c8 ignore start -- operation payload metadata is optional in upstream json-patch failures. */\n const operationRecord =\n typeof candidate.operation === \"object\" && candidate.operation !== null\n ? (candidate.operation as { op?: unknown; path?: unknown; from?: unknown })\n : null;\n /* c8 ignore stop */\n if (operationRecord && typeof operationRecord.op === \"string\") {\n context.op = operationRecord.op;\n }\n if (operationRecord && typeof operationRecord.path === \"string\") {\n context.path = operationRecord.path;\n }\n if (operationRecord && typeof operationRecord.from === \"string\") {\n context.from = operationRecord.from;\n }\n if ((context.op === undefined || context.path === undefined) && context.patchIndex !== undefined) {\n const fallback = patch[context.patchIndex];\n /* c8 ignore start -- fallback enrichment paths are only exercised by malformed patch telemetry payloads. */\n if (fallback) {\n context.op = context.op ?? fallback.op;\n context.path = context.path ?? fallback.path;\n context.from = context.from ?? fallback.from;\n }\n /* c8 ignore stop */\n }\n return context;\n}\n\nfunction applyHistoryPatch(\n current: CanonicalReplayDocument,\n patch: HistoryPatchOp[],\n entryNumber: number,\n entryOp: string,\n): CanonicalReplayDocument {\n try {\n const normalizedPatch = normalizeReplayPatchOps(patch);\n const applied = jsonPatch.applyPatch(\n structuredClone(current),\n normalizedPatch as jsonPatch.Operation[],\n true,\n false,\n ).newDocument as unknown;\n if (\n typeof applied !== \"object\" ||\n applied === null ||\n !(\"metadata\" in applied) ||\n !(\"body\" in applied) ||\n typeof (applied as { body: unknown }).body !== \"string\" ||\n typeof (applied as { metadata: unknown }).metadata !== \"object\" ||\n (applied as { metadata: unknown }).metadata === null\n ) {\n throw new PmCliError(\n `History replay produced an invalid document shape at entry ${entryNumber}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const replay = applied as { metadata: Record<string, unknown>; body: string };\n return {\n metadata: replay.metadata,\n body: replay.body,\n };\n } catch (error: unknown) {\n if (error instanceof PmCliError) {\n throw error;\n }\n const failureContext = extractPatchFailureContext(patch, error);\n const contextTokens = [\n `history_op=${entryOp}`,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.patchIndex !== undefined ? `patch_index=${failureContext.patchIndex}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.op ? `op=${failureContext.op}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.path ? `path=${failureContext.path}` : null,\n /* c8 ignore next -- contextual fields are best-effort and may be absent depending on patch failure shape. */\n failureContext.from ? `from=${failureContext.from}` : null,\n ].filter((token): token is string => token !== null);\n /* c8 ignore start -- jsonPatch/structuredClone/normalizeReplayPatchOps always throw Error instances with non-empty messages here, so extractPatchFailureContext always sets reason; the empty-suffix fallback is unreachable through applyHistoryPatch. */\n const reasonSuffix = failureContext.reason ? ` ${failureContext.reason}` : \"\";\n /* c8 ignore stop */\n throw new PmCliError(\n `Failed to apply history patch at entry ${entryNumber} (${contextTokens.join(\", \")}).${reasonSuffix}`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n}\n\nfunction replayToTarget(history: HistoryEntry[], targetIndex: number): CanonicalReplayDocument {\n let document: CanonicalReplayDocument = structuredClone(EMPTY_REPLAY_DOCUMENT);\n\n for (let i = 0; i <= targetIndex; i += 1) {\n const entry = history[i];\n const beforeHash = replayHash(document);\n if (beforeHash !== entry.before_hash) {\n throw new PmCliError(\n `History hash mismatch before replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n\n document = applyHistoryPatch(document, entry.patch, i + 1, entry.op);\n\n const afterHash = replayHash(document);\n if (afterHash !== entry.after_hash) {\n throw new PmCliError(\n `History hash mismatch after replay at entry ${i + 1}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n }\n\n return document;\n}\n\nfunction ensureMaterializedRestoreTarget(\n replayDocument: CanonicalReplayDocument,\n target: ResolvedRestoreTarget,\n): CanonicalReplayDocument {\n if (Object.keys(replayDocument.metadata).length > 0) {\n return replayDocument;\n }\n throw new PmCliError(\n `Restore target ${target.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,\n EXIT_CODE.USAGE,\n );\n}\n\nfunction replayCurrentDocument(history: HistoryEntry[]): ItemDocument {\n const currentReplay = replayToTarget(history, history.length - 1);\n if (Object.keys(currentReplay.metadata).length === 0) {\n return {\n metadata: {} as ItemMetadata,\n body: currentReplay.body,\n };\n }\n return canonicalDocument(replayToItemDocument(currentReplay));\n}\n\nasync function resolveRestoreSubject(\n pmRoot: string,\n id: string,\n settings: Awaited<ReturnType<typeof readSettings>>,\n typeToFolder: Record<string, string>,\n): Promise<ResolvedRestoreSubject> {\n const located = await locateItem(pmRoot, id, settings.id_prefix, settings.item_format, typeToFolder);\n if (located) {\n const historyPath = getHistoryPath(pmRoot, located.id);\n const historyPolicy = await enforceHistoryStreamPolicyForItem({\n pmRoot,\n settings,\n itemId: located.id,\n commandLabel: \"restore\",\n });\n return {\n id: located.id,\n historyPath,\n located,\n historyPolicyWarnings: historyPolicy.warnings,\n };\n }\n\n const normalizedId = normalizeItemId(id, settings.id_prefix);\n const rawNormalizedId = normalizeRawItemId(id);\n /* c8 ignore start -- raw-id fallback is covered by normalize-item-id utility tests. */\n const candidateIds = normalizedId === rawNormalizedId ? [normalizedId] : [normalizedId, rawNormalizedId];\n /* c8 ignore stop */\n for (const candidateId of candidateIds) {\n const historyPath = getHistoryPath(pmRoot, candidateId);\n if (await pathExists(historyPath)) {\n return {\n id: candidateId,\n historyPath,\n located: null,\n historyPolicyWarnings: [],\n };\n }\n }\n\n throw new PmCliError(`Item ${id} not found`, EXIT_CODE.NOT_FOUND);\n}\n\nfunction changedFields(beforeDocument: ItemDocument, afterDocument: ItemDocument): string[] {\n const beforeReplay = toReplayDocument(beforeDocument);\n const afterReplay = toReplayDocument(afterDocument);\n const patch = jsonPatch.compare(beforeReplay, afterReplay) as HistoryPatchOp[];\n const fields = new Set<string>();\n\n for (const op of patch) {\n if (op.path === \"/body\" || op.path.startsWith(\"/body/\")) {\n fields.add(\"body\");\n continue;\n }\n const segment = op.path.replace(/^\\/(?:metadata|front_matter)\\/?/, \"\").split(\"/\")[0];\n fields.add(segment.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"));\n }\n\n return Array.from(fields).sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Implements run restore for the public runtime surface of this module.\n */\nexport async function runRestore(\n id: string,\n target: string,\n options: RestoreCommandOptions,\n global: GlobalOptions,\n): Promise<RestoreResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const subject = await resolveRestoreSubject(pmRoot, id, settings, typeRegistry.type_to_folder);\n const resolvedId = subject.id;\n const historyRawBeforeLock = await readFileIfExists(subject.historyPath);\n const history = await readHistoryEntries(subject.historyPath, resolvedId);\n if (history.length === 0) {\n throw new PmCliError(`No history exists for ${resolvedId}; restore is unavailable.`, EXIT_CODE.NOT_FOUND);\n }\n\n const resolvedTarget = ensureReplayTarget(target, history);\n const replayDocument = ensureMaterializedRestoreTarget(replayToTarget(history, resolvedTarget.historyIndex), resolvedTarget);\n const restoredDocument = replayToCanonicalItemDocument(replayDocument, { schema: settings.schema });\n\n if (restoredDocument.metadata.id !== resolvedId) {\n throw new PmCliError(\n `Restore target resolved to item ${restoredDocument.metadata.id}, expected ${resolvedId}.`,\n EXIT_CODE.GENERIC_FAILURE,\n );\n }\n const loadedItemBeforeLock = subject.located ? await readLocatedItem(subject.located, { schema: settings.schema }) : null;\n const currentItemRawBeforeLock = loadedItemBeforeLock?.raw ?? null;\n\n const author = resolveAuthor(options.author, settings.author_default);\n const releaseLock = await acquireLock(\n pmRoot,\n resolvedId,\n settings.locks.ttl_seconds,\n author,\n Boolean(options.force),\n settings.governance.force_required_for_stale_lock,\n );\n\n try {\n const historyRawUnderLock = await readFileIfExists(subject.historyPath);\n if (historyRawUnderLock !== historyRawBeforeLock) {\n throw new PmCliError(\n `History for ${resolvedId} changed while waiting for lock; retry restore.`,\n EXIT_CODE.CONFLICT,\n );\n }\n const locatedUnderLock = await locateItem(\n pmRoot,\n resolvedId,\n settings.id_prefix,\n settings.item_format,\n typeRegistry.type_to_folder,\n );\n const loadedItemUnderLock = locatedUnderLock ? await readLocatedItem(locatedUnderLock, { schema: settings.schema }) : null;\n if ((loadedItemUnderLock?.raw ?? null) !== currentItemRawBeforeLock) {\n throw new PmCliError(`Item ${resolvedId} changed while waiting for lock; retry restore.`, EXIT_CODE.CONFLICT);\n }\n\n const existingItemPath = locatedUnderLock?.itemPath ?? null;\n const itemFormat = \"toon\";\n let resolvedCurrentDocument: ItemDocument;\n let resolvedOriginalRaw: string | null = null;\n if (loadedItemUnderLock) {\n resolvedCurrentDocument = loadedItemUnderLock.document;\n resolvedOriginalRaw = loadedItemUnderLock.raw;\n } else {\n resolvedCurrentDocument = replayCurrentDocument(history);\n }\n const assigned = resolvedCurrentDocument.metadata.assignee?.trim();\n const ownershipWarnings: string[] = [];\n const hasOwnershipConflict = assigned && assigned !== author && !options.force;\n if (hasOwnershipConflict) {\n if (settings.governance.ownership_enforcement === \"strict\") {\n throw new PmCliError(\n `Item ${resolvedId} is assigned to ${assigned}. Use --force to override.`,\n EXIT_CODE.CONFLICT,\n );\n }\n if (settings.governance.ownership_enforcement === \"warn\") {\n ownershipWarnings.push(`ownership_warning:assignee_conflict:${resolvedId}:${assigned}`);\n }\n }\n\n const serializedRestore = serializeItemDocument(restoredDocument, { format: itemFormat, schema: settings.schema });\n /* c8 ignore next -- restored item path typing is exercised in restore integration workflows. */\n const restoredItemPath = getItemPath(\n pmRoot,\n restoredDocument.metadata.type,\n resolvedId,\n itemFormat,\n typeRegistry.type_to_folder,\n );\n await writeFileAtomic(restoredItemPath, serializedRestore);\n if (existingItemPath && restoredItemPath !== existingItemPath) {\n await fs.rm(existingItemPath);\n }\n\n const historyEntry = createHistoryEntry({\n nowIso: nowIso(),\n author,\n op: \"restore\",\n before: resolvedCurrentDocument,\n after: restoredDocument,\n message: options.message,\n });\n\n try {\n await appendHistoryEntry(subject.historyPath, historyEntry);\n } catch (error: unknown) {\n if (existingItemPath && resolvedOriginalRaw !== null && restoredItemPath !== existingItemPath) {\n await writeFileAtomic(existingItemPath, resolvedOriginalRaw);\n await fs.rm(restoredItemPath, { force: true });\n } else if (existingItemPath && resolvedOriginalRaw !== null) {\n await writeFileAtomic(existingItemPath, resolvedOriginalRaw);\n } else {\n await fs.rm(restoredItemPath, { force: true });\n }\n throw error;\n }\n const restoreChangedFields = changedFields(resolvedCurrentDocument, restoredDocument);\n const hookWarnings = [\n ...(await runActiveOnWriteHooks({\n path: restoredItemPath,\n scope: \"project\",\n op: \"restore\",\n item_id: restoredDocument.metadata.id,\n item_type: restoredDocument.metadata.type,\n before: resolvedCurrentDocument,\n after: restoredDocument,\n changed_fields: [\"restored\"],\n })),\n ...(await runActiveOnWriteHooks({\n path: subject.historyPath,\n scope: \"project\",\n op: \"restore:history\",\n item_id: restoredDocument.metadata.id,\n item_type: restoredDocument.metadata.type,\n before: resolvedCurrentDocument,\n after: restoredDocument,\n changed_fields: [\"restored\"],\n })),\n ];\n recordAfterCommandAffectedItem({\n id: restoredDocument.metadata.id,\n op: \"restore\",\n item_type: restoredDocument.metadata.type,\n previous_status: resolvedCurrentDocument.metadata.status,\n status: restoredDocument.metadata.status,\n previous: projectAfterCommandItemSnapshot(resolvedCurrentDocument.metadata, restoreChangedFields),\n current: projectAfterCommandItemSnapshot(restoredDocument.metadata, restoreChangedFields),\n changed_fields: restoreChangedFields,\n });\n\n const targetEntry = history[resolvedTarget.historyIndex];\n return {\n item: restoredDocument.metadata,\n restored_from: {\n kind: resolvedTarget.kind,\n target: resolvedTarget.raw,\n history_index: resolvedTarget.historyIndex + 1,\n entry_ts: targetEntry.ts,\n entry_op: targetEntry.op,\n },\n changed_fields: restoreChangedFields,\n warnings: [...subject.historyPolicyWarnings, ...ownershipWarnings, ...hookWarnings],\n };\n } finally {\n await releaseLock();\n }\n}\n\nexport const _testOnlyRestoreCommand = {\n applyHistoryPatch,\n changedFields,\n ensureMaterializedRestoreTarget,\n ensureReplayTarget,\n extractPatchFailureContext,\n replayCurrentDocument,\n replayToTarget,\n resolveRestoreSubject,\n};\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,6BAA6B,EAC7B,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iCAAiC,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,EAC/B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W,GAAG,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACzD,OAAO;YACL,IAAI,EAAE,gBAAgB,CAAC,QAAQ;YAC/B,aAAa,EAAE;gBACb,IAAI,EAAE,cAAc,CAAC,IAAI;gBACzB,MAAM,EAAE,cAAc,CAAC,GAAG;gBAC1B,aAAa,EAAE,cAAc,CAAC,YAAY,GAAG,CAAC;gBAC9C,QAAQ,EAAE,WAAW,CAAC,EAAE;gBACxB,QAAQ,EAAE,WAAW,CAAC,EAAE;aACzB;YACD,cAAc,EAAE,oBAAoB;YACpC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,qBAAqB,EAAE,GAAG,iBAAiB,EAAE,GAAG,YAAY,CAAC;SACpF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB;IACjB,aAAa;IACb,+BAA+B;IAC/B,kBAAkB;IAClB,0BAA0B;IAC1B,qBAAqB;IACrB,cAAc;IACd,qBAAqB;CACtB,CAAC","debugId":"2a9ec353-cabe-59ee-a47c-e69ea28f7ab0"}
|
|
@@ -2,6 +2,7 @@ import { type ItemTypeRegistry } from "../../core/item/type-registry.js";
|
|
|
2
2
|
import { type EmbeddingProviderConfig, type EmbeddingProviderResolution } from "../../core/search/providers.js";
|
|
3
3
|
import { type QueryExpansionConfig, type RerankConfig } from "../../core/search/relevance.js";
|
|
4
4
|
import { type VectorQueryHit, type VectorStoreConfig, type VectorStoreResolution } from "../../core/search/vector-stores.js";
|
|
5
|
+
import { type Bm25Params } from "../../core/search/bm25.js";
|
|
5
6
|
import { type LifecycleClassifier } from "../../core/governance/metadata-coverage.js";
|
|
6
7
|
import { type RuntimeFieldRegistry, type RuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
|
|
7
8
|
import type { GlobalOptions } from "../../core/shared/command-types.js";
|
|
@@ -266,7 +267,9 @@ export declare const _testOnlySearchCommand: {
|
|
|
266
267
|
collectExactPhraseFields: typeof collectExactPhraseFields;
|
|
267
268
|
collectLinkedPaths: typeof collectLinkedPaths;
|
|
268
269
|
combineHybridHits: typeof combineHybridHits;
|
|
270
|
+
computeBuiltInBm25Hits: typeof computeBuiltInBm25Hits;
|
|
269
271
|
computeSemanticOrHybridHits: typeof computeSemanticOrHybridHits;
|
|
272
|
+
resolveBuiltInBm25Mode: typeof resolveBuiltInBm25Mode;
|
|
270
273
|
countOccurrences: typeof countOccurrences;
|
|
271
274
|
dependencyEntries: typeof dependencyEntries;
|
|
272
275
|
documentContainsExactPhrase: typeof documentContainsExactPhrase;
|
|
@@ -440,7 +443,42 @@ declare function buildSemanticHits(vectorHits: VectorQueryHit[], filteredById: M
|
|
|
440
443
|
semanticHits: SearchHit[];
|
|
441
444
|
semanticScores: Map<string, number>;
|
|
442
445
|
};
|
|
443
|
-
declare function combineHybridHits(filteredById: Map<string, ItemDocument>, semanticScores: Map<string, number>, keywordHits: SearchHit[], hybridSemanticWeight: number): SearchHit[];
|
|
446
|
+
declare function combineHybridHits(filteredById: Map<string, ItemDocument>, semanticScores: Map<string, number>, keywordHits: SearchHit[], hybridSemanticWeight: number, semanticFieldLabel?: string): SearchHit[];
|
|
447
|
+
/**
|
|
448
|
+
* Built-in BM25 activation outcome for semantic/hybrid search (pm-75k9):
|
|
449
|
+
* - `"explicit"`: `search.provider` is `bm25` — the user opted into offline
|
|
450
|
+
* lexical ranking, so it is used even if an embedding provider is configured.
|
|
451
|
+
* - `"auto-fallback"`: `search.provider` is `auto` and neither an embedding
|
|
452
|
+
* provider nor an extension search provider is available — BM25 is used in
|
|
453
|
+
* place of degrading to the naive field-weighted keyword scorer.
|
|
454
|
+
* - `null`: BM25 does not apply; the existing embedding/extension path runs.
|
|
455
|
+
*/
|
|
456
|
+
type BuiltInBm25Mode = "explicit" | "auto-fallback";
|
|
457
|
+
declare function resolveBuiltInBm25Mode(params: {
|
|
458
|
+
configuredProvider: string | undefined;
|
|
459
|
+
hasEmbeddingProvider: boolean;
|
|
460
|
+
hasExtensionSearchProvider: boolean;
|
|
461
|
+
}): BuiltInBm25Mode | null;
|
|
462
|
+
/**
|
|
463
|
+
* Rank the filtered corpus with the offline BM25 provider (pm-75k9). Builds a
|
|
464
|
+
* BM25 index over each document's resolved search corpus (honoring
|
|
465
|
+
* `search.corpus_fields`), scores the query, and shapes hits for the requested
|
|
466
|
+
* mode: semantic mode returns pure BM25-ranked hits tagged
|
|
467
|
+
* `matched_fields: ["bm25"]`, while hybrid mode blends the BM25 scores with the
|
|
468
|
+
* locally computed keyword scores via {@link combineHybridHits}. The exact
|
|
469
|
+
* full-ID / short-ID guarantee is preserved in both modes via
|
|
470
|
+
* {@link forceExactIdHitsToTop}. No network, embedding service, or vector store
|
|
471
|
+
* is involved, so this path cannot fail on a backend error.
|
|
472
|
+
*/
|
|
473
|
+
declare function computeBuiltInBm25Hits(params: {
|
|
474
|
+
requestedMode: Exclude<SearchMode, "keyword">;
|
|
475
|
+
query: string;
|
|
476
|
+
filteredDocuments: ItemDocument[];
|
|
477
|
+
keywordHits: SearchHit[];
|
|
478
|
+
corpusFields: string[];
|
|
479
|
+
bm25Params: Bm25Params;
|
|
480
|
+
hybridSemanticWeight: number;
|
|
481
|
+
}): SearchHit[];
|
|
444
482
|
interface SemanticQueryContext {
|
|
445
483
|
requestedMode: Exclude<SearchMode, "keyword">;
|
|
446
484
|
query: string;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Implements the pm search command surface and its agent-facing runtime behavior.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
7
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="717039d4-aae7-5501-9069-971b51a36c49")}catch(e){}}();
|
|
8
8
|
import fs from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { coerceNumberInRange, toNonEmptyStringOrUndefined } from "../../core/shared/primitives.js";
|
|
@@ -19,13 +19,14 @@ import { buildDeterministicQueryExpansions, mergeQueryExpansions, normalizeQuery
|
|
|
19
19
|
import { resolveSettingsWithSemanticRuntimeDefaults } from "../../core/search/semantic-defaults.js";
|
|
20
20
|
import { executeVectorQuery, resolveVectorStores, } from "../../core/search/vector-stores.js";
|
|
21
21
|
import { readVectorizationStatusLedger } from "../../core/search/cache.js";
|
|
22
|
-
import { buildEventCorpus, buildPlanFlatCorpus, buildReminderCorpus } from "../../core/search/corpus.js";
|
|
22
|
+
import { buildEventCorpus, buildPlanFlatCorpus, buildReminderCorpus, buildSearchCorpus, resolveSearchCorpusFields, } from "../../core/search/corpus.js";
|
|
23
|
+
import { buildBm25Index, flattenSearchCorpusText, resolveBm25Params, scoreBm25Query, tokenizeBm25, } from "../../core/search/bm25.js";
|
|
23
24
|
import { collectStaleVectorizationIds } from "../../core/search/staleness.js";
|
|
24
25
|
import { pathExists } from "../../core/fs/fs-utils.js";
|
|
25
26
|
import { parseItemDocument } from "../../core/item/item-format.js";
|
|
26
27
|
import { toItemRecord } from "../../core/item/item-record.js";
|
|
27
28
|
import { isTerminalStatus } from "../../core/item/status.js";
|
|
28
|
-
import { parseStatusFilterCsv } from "../../core/item/status-filter.js";
|
|
29
|
+
import { isStatusAllFilterInput, parseStatusFilterCsv } from "../../core/item/status-filter.js";
|
|
29
30
|
import { collectRuntimeFilterValues, matchesRuntimeFilters } from "../../core/schema/runtime-field-filters.js";
|
|
30
31
|
import { hasMissingMetadataFilter, itemMatchesMissingMetadata, lifecycleClassifierFromStatusRegistry, } from "../../core/governance/metadata-coverage.js";
|
|
31
32
|
import { hasContentFieldFilter, itemMatchesContentFilters, } from "../../core/governance/content-fields.js";
|
|
@@ -139,7 +140,7 @@ function buildCompactSearchFilterSummary(params) {
|
|
|
139
140
|
const { mode, matchMode, options, includeLinked, titleExact, phraseExact, scoreThreshold, hybridSemanticWeight, runtimeFieldFilters, } = params;
|
|
140
141
|
const filters = {};
|
|
141
142
|
if (options.status !== undefined) {
|
|
142
|
-
filters.status = options.status;
|
|
143
|
+
filters.status = isStatusAllFilterInput(options.status) ? "all" : options.status;
|
|
143
144
|
}
|
|
144
145
|
if (options.type !== undefined) {
|
|
145
146
|
filters.type = options.type;
|
|
@@ -215,7 +216,7 @@ function buildVerboseSearchFilters(params) {
|
|
|
215
216
|
return {
|
|
216
217
|
mode: effectiveMode,
|
|
217
218
|
match_mode: matchMode,
|
|
218
|
-
status: options.status ?? null,
|
|
219
|
+
status: isStatusAllFilterInput(options.status) ? "all" : options.status ?? null,
|
|
219
220
|
type: options.type ?? null,
|
|
220
221
|
tag: options.tag ?? null,
|
|
221
222
|
priority: options.priority ?? null,
|
|
@@ -465,7 +466,9 @@ export const _testOnlySearchCommand = {
|
|
|
465
466
|
collectExactPhraseFields,
|
|
466
467
|
collectLinkedPaths,
|
|
467
468
|
combineHybridHits,
|
|
469
|
+
computeBuiltInBm25Hits,
|
|
468
470
|
computeSemanticOrHybridHits,
|
|
471
|
+
resolveBuiltInBm25Mode,
|
|
469
472
|
countOccurrences,
|
|
470
473
|
dependencyEntries,
|
|
471
474
|
documentContainsExactPhrase,
|
|
@@ -920,10 +923,11 @@ function buildHitHighlights(document, matchedFields, tokens) {
|
|
|
920
923
|
}
|
|
921
924
|
function scoreDocument(document, tokens, normalizedQuery, linkedCorpus, tuning, idPrefix, applyCoverageBonus = false) {
|
|
922
925
|
const item = document.metadata;
|
|
923
|
-
const normalizedId = item.id
|
|
926
|
+
const normalizedId = normalizeSearchPhrase(item.id);
|
|
924
927
|
const normalizedIdPrefix = typeof idPrefix === "string" ? idPrefix.trim().toLowerCase() : "";
|
|
925
|
-
const
|
|
926
|
-
|
|
928
|
+
const normalizedIdPrefixPhrase = normalizeSearchPhrase(normalizedIdPrefix);
|
|
929
|
+
const normalizedShortId = normalizedIdPrefixPhrase.length > 0 && normalizedId.startsWith(normalizedIdPrefixPhrase)
|
|
930
|
+
? normalizedId.slice(normalizedIdPrefixPhrase.length).trim()
|
|
927
931
|
: normalizedId;
|
|
928
932
|
if (normalizedQuery === normalizedId || normalizedQuery === normalizedShortId) {
|
|
929
933
|
return {
|
|
@@ -1345,7 +1349,11 @@ function forceExactIdHitsToTop(rankedHits, keywordHits) {
|
|
|
1345
1349
|
}));
|
|
1346
1350
|
return [...promoted, ...remaining];
|
|
1347
1351
|
}
|
|
1348
|
-
function combineHybridHits(filteredById, semanticScores, keywordHits, hybridSemanticWeight
|
|
1352
|
+
function combineHybridHits(filteredById, semanticScores, keywordHits, hybridSemanticWeight,
|
|
1353
|
+
// Matched-field label for the dense-ranking component. Defaults to "semantic"
|
|
1354
|
+
// (vector retrieval); the offline BM25 hybrid path passes "bm25" so hits carry
|
|
1355
|
+
// an honest provenance marker instead of implying a vector match (pm-75k9).
|
|
1356
|
+
semanticFieldLabel = "semantic") {
|
|
1349
1357
|
const keywordScores = new Map(keywordHits.map((entry) => [entry.item.id, entry.score]));
|
|
1350
1358
|
const keywordMatches = new Map(keywordHits.map((entry) => [entry.item.id, entry.matched_fields]));
|
|
1351
1359
|
const normalizedSemantic = normalizeScoreMap(semanticScores);
|
|
@@ -1363,7 +1371,7 @@ function combineHybridHits(filteredById, semanticScores, keywordHits, hybridSema
|
|
|
1363
1371
|
}
|
|
1364
1372
|
const matchedFields = new Set();
|
|
1365
1373
|
if (semanticScores.has(id)) {
|
|
1366
|
-
matchedFields.add(
|
|
1374
|
+
matchedFields.add(semanticFieldLabel);
|
|
1367
1375
|
}
|
|
1368
1376
|
for (const field of keywordMatches.get(id) ?? []) {
|
|
1369
1377
|
matchedFields.add(field);
|
|
@@ -1376,6 +1384,46 @@ function combineHybridHits(filteredById, semanticScores, keywordHits, hybridSema
|
|
|
1376
1384
|
})
|
|
1377
1385
|
.filter((entry) => entry !== null);
|
|
1378
1386
|
}
|
|
1387
|
+
function resolveBuiltInBm25Mode(params) {
|
|
1388
|
+
const normalized = params.configuredProvider?.trim().toLowerCase();
|
|
1389
|
+
if (normalized === "bm25") {
|
|
1390
|
+
return "explicit";
|
|
1391
|
+
}
|
|
1392
|
+
if (normalized === "auto" && !params.hasEmbeddingProvider && !params.hasExtensionSearchProvider) {
|
|
1393
|
+
return "auto-fallback";
|
|
1394
|
+
}
|
|
1395
|
+
return null;
|
|
1396
|
+
}
|
|
1397
|
+
/**
|
|
1398
|
+
* Rank the filtered corpus with the offline BM25 provider (pm-75k9). Builds a
|
|
1399
|
+
* BM25 index over each document's resolved search corpus (honoring
|
|
1400
|
+
* `search.corpus_fields`), scores the query, and shapes hits for the requested
|
|
1401
|
+
* mode: semantic mode returns pure BM25-ranked hits tagged
|
|
1402
|
+
* `matched_fields: ["bm25"]`, while hybrid mode blends the BM25 scores with the
|
|
1403
|
+
* locally computed keyword scores via {@link combineHybridHits}. The exact
|
|
1404
|
+
* full-ID / short-ID guarantee is preserved in both modes via
|
|
1405
|
+
* {@link forceExactIdHitsToTop}. No network, embedding service, or vector store
|
|
1406
|
+
* is involved, so this path cannot fail on a backend error.
|
|
1407
|
+
*/
|
|
1408
|
+
function computeBuiltInBm25Hits(params) {
|
|
1409
|
+
const bm25Documents = params.filteredDocuments.map((document) => ({
|
|
1410
|
+
id: document.metadata.id,
|
|
1411
|
+
text: flattenSearchCorpusText(buildSearchCorpus(document, { fields: params.corpusFields })),
|
|
1412
|
+
}));
|
|
1413
|
+
const index = buildBm25Index(bm25Documents);
|
|
1414
|
+
const bm25Scores = scoreBm25Query(index, tokenizeBm25(params.query), params.bm25Params);
|
|
1415
|
+
const filteredById = new Map(params.filteredDocuments.map((document) => [document.metadata.id, document]));
|
|
1416
|
+
if (params.requestedMode === "semantic") {
|
|
1417
|
+
const semanticHits = [...bm25Scores].map(([id, score]) => ({
|
|
1418
|
+
item: filteredById.get(id).metadata,
|
|
1419
|
+
score,
|
|
1420
|
+
matched_fields: ["bm25"],
|
|
1421
|
+
}));
|
|
1422
|
+
return forceExactIdHitsToTop(semanticHits, params.keywordHits);
|
|
1423
|
+
}
|
|
1424
|
+
const hybridHits = combineHybridHits(filteredById, bm25Scores, params.keywordHits, params.hybridSemanticWeight, "bm25");
|
|
1425
|
+
return forceExactIdHitsToTop(hybridHits, params.keywordHits);
|
|
1426
|
+
}
|
|
1379
1427
|
function mergeVectorHitsById(vectorHitGroups) {
|
|
1380
1428
|
const bestById = new Map();
|
|
1381
1429
|
for (const group of vectorHitGroups) {
|
|
@@ -1741,6 +1789,15 @@ export async function runSearch(rawQuery, rawOptions, global) {
|
|
|
1741
1789
|
const vectorResolution = resolveVectorStores(settings);
|
|
1742
1790
|
const extensionSearchProvider = resolveExtensionSearchProvider(settings);
|
|
1743
1791
|
const extensionVectorAdapter = resolveExtensionVectorAdapter(settings);
|
|
1792
|
+
// pm-75k9: offline BM25 lexical provider. When active, a semantic/hybrid query
|
|
1793
|
+
// ranks the corpus locally with BM25 instead of requiring an embedding service
|
|
1794
|
+
// + vector store — enabling dense-quality offline retrieval in air-gapped, CI,
|
|
1795
|
+
// and zero-setup environments. Resolved here so the semantic block can branch.
|
|
1796
|
+
const bm25Mode = resolveBuiltInBm25Mode({
|
|
1797
|
+
configuredProvider: toOptionalNonEmptyString(settings.search?.provider),
|
|
1798
|
+
hasEmbeddingProvider: providerResolution.active !== null,
|
|
1799
|
+
hasExtensionSearchProvider: extensionSearchProvider !== null,
|
|
1800
|
+
});
|
|
1744
1801
|
const queryExpansion = resolveQueryExpansionConfig(settings, providerResolution.active?.name ?? null);
|
|
1745
1802
|
const rerank = resolveRerankConfig(settings, providerResolution.active?.model ?? toOptionalNonEmptyString(settings.search?.embedding_model) ?? "text-embedding-3-small");
|
|
1746
1803
|
const queryExpansionProvider = resolveExtensionSearchProviderByName(queryExpansion.provider ?? undefined);
|
|
@@ -1800,8 +1857,28 @@ export async function runSearch(rawQuery, rawOptions, global) {
|
|
|
1800
1857
|
// matched some searchable field.
|
|
1801
1858
|
.filter((entry) => matchMode !== "and" || entry.matched_all_terms === true);
|
|
1802
1859
|
let hits = keywordHits;
|
|
1860
|
+
// pm-75k9: offline BM25 path. Runs entirely in-process (no embedding service,
|
|
1861
|
+
// vector store, or HTTP), so it sits OUTSIDE the semantic try/catch fallback
|
|
1862
|
+
// block below — it cannot fail on a backend error. Empty corpus / limit-0 are
|
|
1863
|
+
// handled by the shared threshold+limit path that follows, so no early-return
|
|
1864
|
+
// guard is needed here.
|
|
1865
|
+
const useBuiltInBm25 = bm25Mode !== null && effectiveMode !== "keyword";
|
|
1866
|
+
if (bm25Mode !== null && effectiveMode !== "keyword") {
|
|
1867
|
+
hits = computeBuiltInBm25Hits({
|
|
1868
|
+
requestedMode: effectiveMode,
|
|
1869
|
+
query,
|
|
1870
|
+
filteredDocuments,
|
|
1871
|
+
keywordHits,
|
|
1872
|
+
corpusFields: resolveSearchCorpusFields(settings),
|
|
1873
|
+
bm25Params: resolveBm25Params(settings),
|
|
1874
|
+
hybridSemanticWeight,
|
|
1875
|
+
});
|
|
1876
|
+
if (bm25Mode === "auto-fallback") {
|
|
1877
|
+
warnings.push(`search_${effectiveMode}_offline_bm25:no_embedding_provider:using_lexical_bm25`);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1803
1880
|
/* c8 ignore start -- semantic/provider fallback + compact/count warning-shape permutations are covered by integration command-contract tests */
|
|
1804
|
-
if (effectiveMode !== "keyword") {
|
|
1881
|
+
if (effectiveMode !== "keyword" && !useBuiltInBm25) {
|
|
1805
1882
|
// Surface vector-index staleness once per query so agents notice when a
|
|
1806
1883
|
// refresh is overdue. Only emitted when:
|
|
1807
1884
|
// (1) the user explicitly asked for semantic/hybrid mode (implicit
|
|
@@ -2039,4 +2116,4 @@ export async function runSearch(rawQuery, rawOptions, global) {
|
|
|
2039
2116
|
};
|
|
2040
2117
|
}
|
|
2041
2118
|
//# sourceMappingURL=search.js.map
|
|
2042
|
-
//# debugId=
|
|
2119
|
+
//# debugId=717039d4-aae7-5501-9069-971b51a36c49
|