@unbrained/pm-cli 2026.7.19 → 2026.7.20
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/.claude-plugin/marketplace.json +2 -2
- package/AGENTS.md +2 -0
- package/CHANGELOG.md +36 -0
- package/dist/cli/commands/append.js +13 -6
- package/dist/cli/commands/append.js.map +1 -1
- package/dist/cli/commands/calendar.d.ts +1 -1
- package/dist/cli/commands/calendar.js +2 -2
- package/dist/cli/commands/calendar.js.map +1 -1
- package/dist/cli/commands/comments.js +2 -5
- package/dist/cli/commands/comments.js.map +1 -1
- package/dist/cli/commands/completion.js +11 -3
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/context.d.ts +1 -1
- package/dist/cli/commands/context.js +2 -2
- package/dist/cli/commands/context.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/copy.js +5 -3
- package/dist/cli/commands/copy.js.map +1 -1
- package/dist/cli/commands/create.d.ts +3 -1
- package/dist/cli/commands/create.js +5 -3
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/merge.d.ts +8 -0
- package/dist/cli/commands/merge.js +12 -0
- package/dist/cli/commands/merge.js.map +1 -0
- package/dist/cli/commands/plan.d.ts +1 -1
- package/dist/cli/commands/plan.js +2 -2
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/update-many.d.ts +5 -0
- package/dist/cli/commands/update-many.js +81 -6
- package/dist/cli/commands/update-many.js.map +1 -1
- package/dist/cli/commands/update.d.ts +5 -1
- package/dist/cli/commands/update.js +50 -4
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/register-list-query.js +14 -2
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +61 -2
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/register-operations.js +5 -3
- package/dist/cli/register-operations.js.map +1 -1
- package/dist/cli/registration-helpers.js +4 -2
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli-bundle/bundle-manifest.json +365 -333
- package/dist/cli-bundle/chunks/{append-MBXHNWSX.js → append-E6V54WOQ.js} +5 -5
- package/dist/cli-bundle/chunks/append-NNJ3EFIT.js +11 -0
- package/dist/cli-bundle/chunks/{chunk-M4B4RK4J.js → chunk-2BO4CA46.js} +14 -238
- package/dist/cli-bundle/chunks/{chunk-M4B4RK4J.js.map → chunk-2BO4CA46.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-MQOSMBWV.js → chunk-3AO5VSDR.js} +25 -6
- package/dist/cli-bundle/chunks/chunk-3AO5VSDR.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-ODEIDKGW.js → chunk-3LPFHE3P.js} +596 -154
- package/dist/cli-bundle/chunks/chunk-3LPFHE3P.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-YGEA4CLH.js → chunk-3MCTMJXI.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-N7FCFJ76.js → chunk-3P7UJQOX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7B7IHMLH.js → chunk-3VY6MIEO.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-3EZZTFL2.js → chunk-4F6BWJ4J.js} +51 -43
- package/dist/cli-bundle/chunks/chunk-4F6BWJ4J.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-VA3H7VVC.js → chunk-4L23AGQ7.js} +9 -7
- package/dist/cli-bundle/chunks/chunk-4L23AGQ7.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-5S6IZXK7.js → chunk-4U4Z6AHI.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-UOIFZ66L.js → chunk-4XGJLADW.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-SUNZKVAH.js → chunk-5IZJWSDB.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-QQ77W23U.js → chunk-5NTE36LD.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-EVAN5VJA.js → chunk-5OK4UGFV.js} +5 -8
- package/dist/cli-bundle/chunks/{chunk-EVAN5VJA.js.map → chunk-5OK4UGFV.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-H3YKUVDR.js → chunk-5UX66S6U.js} +26 -7
- package/dist/cli-bundle/chunks/chunk-5UX66S6U.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-KGPLSHJD.js → chunk-6C2ZZX5Z.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q5NHJ6RO.js → chunk-6JUTHVQS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-NTS2RKHN.js → chunk-6VIJ7UA5.js} +15 -15
- package/dist/cli-bundle/chunks/{chunk-BBGR4FKQ.js → chunk-6XMUURSS.js} +6 -6
- package/dist/cli-bundle/chunks/chunk-6XMUURSS.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-XVB6BATY.js → chunk-72LQ4TKV.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-WCBB6VI3.js → chunk-7AVEY74G.js} +8 -5
- package/dist/cli-bundle/chunks/chunk-7AVEY74G.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-YG56M3NE.js → chunk-7DOJC3HS.js} +8 -8
- package/dist/cli-bundle/chunks/chunk-7DOJC3HS.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-KZ5AC6B5.js → chunk-7WCE6Y64.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VQOG2ETB.js → chunk-AF2CCM5U.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-P24ZU5QV.js → chunk-AOEOYL3S.js} +49 -12
- package/dist/cli-bundle/chunks/chunk-AOEOYL3S.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-BZKE2O5V.js → chunk-BKIAH72N.js} +8 -6
- package/dist/cli-bundle/chunks/chunk-BKIAH72N.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-RWAIRGBC.js → chunk-C3KD7U3T.js} +12 -243
- package/dist/cli-bundle/chunks/chunk-C3KD7U3T.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-CFHAODHQ.js +334 -0
- package/dist/cli-bundle/chunks/chunk-CFHAODHQ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-TELI67UP.js → chunk-CQTQKUUV.js} +6 -9
- package/dist/cli-bundle/chunks/{chunk-TELI67UP.js.map → chunk-CQTQKUUV.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-ZUCBPXNA.js → chunk-D6NXDNP3.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-D6NXDNP3.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-EAV3P54W.js → chunk-DAQ45GCS.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-6V4T4RD3.js → chunk-DVDBQA3B.js} +79 -22
- package/dist/cli-bundle/chunks/chunk-DVDBQA3B.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-E6LEMURX.js +249 -0
- package/dist/cli-bundle/chunks/chunk-E6LEMURX.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-ZF52NVRT.js → chunk-E7ICD63T.js} +131 -179
- package/dist/cli-bundle/chunks/chunk-E7ICD63T.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-RX53WHFI.js → chunk-EJDGV4GR.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-IXG5CMBR.js → chunk-FDHPAVVB.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-KAE727L2.js → chunk-FSRHYUDA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-FSRHYUDA.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-46Z6FAVP.js → chunk-G3COA6GS.js} +51 -43
- package/dist/cli-bundle/chunks/chunk-G3COA6GS.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-A4FVWFZY.js → chunk-GFQP7HAZ.js} +8 -6
- package/dist/cli-bundle/chunks/chunk-GFQP7HAZ.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-2XPDCXK5.js → chunk-GIQSU6S2.js} +6 -6
- package/dist/cli-bundle/chunks/chunk-GIQSU6S2.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-V4QHAMI5.js → chunk-GROYI4RB.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-77XFQRTD.js → chunk-GSJSM5BJ.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-QYGK2XQ3.js → chunk-GTLCVJOE.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-VSQE43NO.js → chunk-GV2262OF.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-N2TEEOXJ.js → chunk-GVI6FAFG.js} +8 -6
- package/dist/cli-bundle/chunks/chunk-GVI6FAFG.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-A5EQPNV7.js → chunk-GVT754PX.js} +44 -3
- package/dist/cli-bundle/chunks/chunk-GVT754PX.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-Y2VSGFT4.js → chunk-HB3P4M52.js} +22 -7
- package/dist/cli-bundle/chunks/chunk-HB3P4M52.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-STBCBDKF.js → chunk-HCEBZNC3.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-EEECAV5M.js → chunk-HEWM6CEN.js} +80 -25
- package/dist/cli-bundle/chunks/chunk-HEWM6CEN.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-GKCEEXMA.js → chunk-HQ3SB4CN.js} +21 -6
- package/dist/cli-bundle/chunks/{chunk-GKCEEXMA.js.map → chunk-HQ3SB4CN.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-U6RYD446.js → chunk-HRW7GF6T.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-D35WYXWC.js → chunk-HYW67VJ5.js} +6 -3
- package/dist/cli-bundle/chunks/chunk-HYW67VJ5.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-OKWJUL6F.js → chunk-I577UHC7.js} +16 -9
- package/dist/cli-bundle/chunks/{chunk-OKWJUL6F.js.map → chunk-I577UHC7.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XDWXPG2E.js → chunk-IAQE32BI.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-66SRNEBK.js → chunk-IJNK6WW2.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-INSTSQNZ.js +623 -0
- package/dist/cli-bundle/chunks/chunk-INSTSQNZ.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-A3GAQLBH.js → chunk-IX677TRO.js} +75 -12
- package/dist/cli-bundle/chunks/chunk-IX677TRO.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-RLLOZAM2.js → chunk-IY6VZ3IW.js} +29 -8
- package/dist/cli-bundle/chunks/chunk-IY6VZ3IW.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-SVAWG7EE.js → chunk-J4FBIFU6.js} +45 -4
- package/dist/cli-bundle/chunks/chunk-J4FBIFU6.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-AGEBQRBG.js → chunk-JAPE62Y5.js} +9 -9
- package/dist/cli-bundle/chunks/{chunk-UWAQI3B7.js → chunk-JGUKMMRS.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-UU6EP25G.js → chunk-JH2ZSLO3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GRDK25BN.js → chunk-JHJSFOAM.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-FQO5THHM.js → chunk-JM6YAXTR.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-E7KBMWEF.js → chunk-JSLT7WVE.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FIUTBFC6.js → chunk-K4CI6Y45.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-IEMXESIS.js → chunk-KSPWRNVP.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-3QNUDDY2.js → chunk-KZEANWJS.js} +14 -12
- package/dist/cli-bundle/chunks/{chunk-3QNUDDY2.js.map → chunk-KZEANWJS.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BFJP4VYC.js → chunk-L7BH7IWU.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-2UCG5H6B.js → chunk-LPEYZRUR.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-FQF6VVPH.js → chunk-MYSS5H2A.js} +9 -7
- package/dist/cli-bundle/chunks/{chunk-FQF6VVPH.js.map → chunk-MYSS5H2A.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-IR3GOO6E.js → chunk-NHT3F4WZ.js} +15 -15
- package/dist/cli-bundle/chunks/{chunk-6BNV3G6C.js → chunk-NLR32VFS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BDC4TW4B.js → chunk-OV7MSW3I.js} +15 -13
- package/dist/cli-bundle/chunks/chunk-OV7MSW3I.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-EI3UIMZM.js → chunk-OWXOPDHD.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-P7JTWYLH.js +246 -0
- package/dist/cli-bundle/chunks/chunk-P7JTWYLH.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-AQUNTB7G.js → chunk-PEQGTJ5Q.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-QFG4MB7P.js → chunk-POG76WWZ.js} +28 -7
- package/dist/cli-bundle/chunks/chunk-POG76WWZ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-MI3346YW.js → chunk-QANSTTC7.js} +129 -170
- package/dist/cli-bundle/chunks/chunk-QANSTTC7.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-T6MOTLOJ.js → chunk-QJKL5PHS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SBW7EQC4.js → chunk-QLZ643FM.js} +76 -13
- package/dist/cli-bundle/chunks/chunk-QLZ643FM.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-XKVHL3MB.js → chunk-QWRVBJ4D.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-R3EWPG4A.js +106 -0
- package/dist/cli-bundle/chunks/chunk-R3EWPG4A.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-R5U2VZ3K.js +344 -0
- package/dist/cli-bundle/chunks/chunk-R5U2VZ3K.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-VFA5EIEN.js → chunk-R7QV7ICM.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-NPEYH6CE.js → chunk-RDV4ZFYS.js} +12 -10
- package/dist/cli-bundle/chunks/{chunk-NPEYH6CE.js.map → chunk-RDV4ZFYS.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-K2L6FZBX.js → chunk-RJO3YAFM.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-YIC5NGXF.js → chunk-RMF7LMBS.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-YIC5NGXF.js.map → chunk-RMF7LMBS.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MRXAHR4B.js → chunk-RZJLNXFG.js} +50 -13
- package/dist/cli-bundle/chunks/chunk-RZJLNXFG.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-DJAGYYCQ.js → chunk-SC2HMDGB.js} +19 -3
- package/dist/cli-bundle/chunks/chunk-SC2HMDGB.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-SGJB6PXA.js → chunk-SF3DT5HJ.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-SG74J6MV.js +604 -0
- package/dist/cli-bundle/chunks/chunk-SG74J6MV.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-Q3K5XPAQ.js → chunk-SR3JOATZ.js} +18 -2
- package/dist/cli-bundle/chunks/chunk-SR3JOATZ.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-DUDLSQFG.js → chunk-SSKOQNMS.js} +14 -12
- package/dist/cli-bundle/chunks/{chunk-DUDLSQFG.js.map → chunk-SSKOQNMS.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-UNNCT5QY.js → chunk-SZVB53Y3.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-JBW2S2C6.js → chunk-T44FMVRL.js} +613 -157
- package/dist/cli-bundle/chunks/chunk-T44FMVRL.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-GFZB5CLP.js → chunk-T6PPNM7V.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-UE7LK3RE.js → chunk-THAOZG4U.js} +9 -7
- package/dist/cli-bundle/chunks/chunk-THAOZG4U.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-IGBBTPM5.js → chunk-TOBGV45Y.js} +4 -4
- package/dist/cli-bundle/chunks/chunk-TOBGV45Y.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-W6IEJXNC.js → chunk-TVYYO5A7.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-TYHJDFYW.js +109 -0
- package/dist/cli-bundle/chunks/chunk-TYHJDFYW.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-DOASIOQR.js → chunk-UQLXSG72.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-IDUTGRDM.js → chunk-URXVHN3L.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-URXVHN3L.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-7CHWLT2J.js → chunk-UVN66B3M.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-Q6JPYR7I.js → chunk-UX6SSO2I.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-JPWUZOMR.js → chunk-UZDQXNUB.js} +75 -20
- package/dist/cli-bundle/chunks/chunk-UZDQXNUB.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-OK7VSX3N.js → chunk-UZLJOEAC.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-4PSJVGRE.js → chunk-VDO2JMD4.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-IRJ6F23W.js → chunk-VQIHNHMJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FQODDTE7.js → chunk-WUVEBQW6.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-FQODDTE7.js.map → chunk-WUVEBQW6.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-Q4PSG2GV.js → chunk-WVA4DVNV.js} +5 -5
- package/dist/cli-bundle/chunks/{chunk-Q4PSG2GV.js.map → chunk-WVA4DVNV.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-4M6RZJXF.js → chunk-WWNL6WMH.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-WWNL6WMH.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-3KPNOZOH.js → chunk-X6K5XTTN.js} +78 -21
- package/dist/cli-bundle/chunks/chunk-X6K5XTTN.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-G33XIMRT.js → chunk-XJF7CDNH.js} +17 -10
- package/dist/cli-bundle/chunks/{chunk-G33XIMRT.js.map → chunk-XJF7CDNH.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-AR24KW26.js → chunk-YBT7O4KT.js} +17 -112
- package/dist/cli-bundle/chunks/chunk-YBT7O4KT.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-CZA2DXCV.js → chunk-YQQNAKW3.js} +17 -105
- package/dist/cli-bundle/chunks/chunk-YQQNAKW3.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-OKPZDH43.js → chunk-YQWCZ5AC.js} +7 -5
- package/dist/cli-bundle/chunks/{chunk-OKPZDH43.js.map → chunk-YQWCZ5AC.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LT5UWU7H.js → chunk-ZOJ3LR7O.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-3HSRP6T2.js → chunk-ZOY5K4D3.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-XXWDEQ6O.js → chunk-ZV2NTVMJ.js} +4 -4
- package/dist/cli-bundle/chunks/{chunk-UW6HCMP2.js → chunk-ZYPFOO3L.js} +9 -9
- package/dist/cli-bundle/chunks/close-O5QVZ6ET.js +12 -0
- package/dist/cli-bundle/chunks/{close-7NWA3GLA.js → close-QEMOYZN3.js} +5 -5
- package/dist/cli-bundle/chunks/close-many-SDA426VT.js +24 -0
- package/dist/cli-bundle/chunks/{close-many-YALQ7AXS.js → close-many-UTZANOCQ.js} +15 -14
- package/dist/cli-bundle/chunks/{comments-SQIQ5WYR.js → comments-LZN6FXXC.js} +7 -7
- package/dist/cli-bundle/chunks/comments-VBQ345ND.js +13 -0
- package/dist/cli-bundle/chunks/{copy-YDAMENCP.js → copy-DKTSSCK7.js} +4 -4
- package/dist/cli-bundle/chunks/copy-M7DDI6LS.js +9 -0
- package/dist/cli-bundle/chunks/{create-JSL6CXU3.js → create-GG4RBCGC.js} +11 -11
- package/dist/cli-bundle/chunks/create-JBC5KUW6.js +29 -0
- package/dist/cli-bundle/chunks/{delete-IGVOZEU2.js → delete-LCS3VPDH.js} +4 -4
- package/dist/cli-bundle/chunks/delete-MD7YXQLH.js +10 -0
- package/dist/cli-bundle/chunks/{deps-BQAXUQAK.js → deps-DELOO4TL.js} +6 -6
- package/dist/cli-bundle/chunks/{deps-CBPPSS6J.js → deps-FI4O6NQS.js} +6 -6
- package/dist/cli-bundle/chunks/docs-2UYBP5D6.js +14 -0
- package/dist/cli-bundle/chunks/{docs-NS2AZWCN.js → docs-6Z2MP526.js} +6 -6
- package/dist/cli-bundle/chunks/{files-XUUBQ76I.js → files-HEUGSJZL.js} +6 -6
- package/dist/cli-bundle/chunks/{files-PVWEPT5J.js → files-HKEAN5MA.js} +6 -6
- package/dist/cli-bundle/chunks/{focus-DHBHKK3E.js → focus-7SOUT5PZ.js} +5 -5
- package/dist/cli-bundle/chunks/focus-DRQ6FQH6.js +10 -0
- package/dist/cli-bundle/chunks/history-compact-65YVN5DB.js +17 -0
- package/dist/cli-bundle/chunks/{history-compact-3TNPYVFG.js → history-compact-7NDVP3PT.js} +7 -6
- package/dist/cli-bundle/chunks/{history-redact-KKFDICCF.js → history-redact-7YBL4XSG.js} +5 -4
- package/dist/cli-bundle/chunks/{history-redact-ELRL73XN.js → history-redact-IZGNJBU4.js} +5 -4
- package/dist/cli-bundle/chunks/{history-repair-J7WKZFAG.js → history-repair-7M4PYQUH.js} +8 -6
- package/dist/cli-bundle/chunks/history-repair-GNGETJLI.js +18 -0
- package/dist/cli-bundle/chunks/learnings-3YXDRWFT.js +13 -0
- package/dist/cli-bundle/chunks/{learnings-X4D6JCCG.js → learnings-ALC6IMNL.js} +7 -7
- package/dist/cli-bundle/chunks/notes-7JMLQ447.js +13 -0
- package/dist/cli-bundle/chunks/{notes-UQC6VS6N.js → notes-JFCLTC5C.js} +7 -7
- package/dist/cli-bundle/chunks/plan-KOIPWVOZ.js +26 -0
- package/dist/cli-bundle/chunks/{plan-5GKRBJJO.js → plan-T3XB3WTK.js} +12 -12
- package/dist/cli-bundle/chunks/{profile-5PQAPCLF.js → profile-OILJHKUW.js} +12 -11
- package/dist/cli-bundle/chunks/{profile-CW4BD3FO.js → profile-RJXA7PGS.js} +12 -11
- package/dist/cli-bundle/chunks/{register-list-query-PHIPDFP2.js → register-list-query-CFVG75P3.js} +30 -21
- package/dist/cli-bundle/chunks/{register-list-query-PHIPDFP2.js.map → register-list-query-CFVG75P3.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-list-query-HTDQE6VI.js → register-list-query-E7UVY4TN.js} +29 -20
- package/dist/cli-bundle/chunks/{register-list-query-HTDQE6VI.js.map → register-list-query-E7UVY4TN.js.map} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-BLEWM5I6.js → register-mutation-4VJTXBZW.js} +86 -32
- package/dist/cli-bundle/chunks/register-mutation-4VJTXBZW.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-mutation-OTYHR7J6.js → register-mutation-IQ55E25C.js} +78 -33
- package/dist/cli-bundle/chunks/register-mutation-IQ55E25C.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-operations-AMCUFYEW.js → register-operations-AR7RMX4W.js} +42 -38
- package/dist/cli-bundle/chunks/register-operations-AR7RMX4W.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-operations-MRLHOZYR.js → register-operations-NOLZGORC.js} +41 -37
- package/dist/cli-bundle/chunks/register-operations-NOLZGORC.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-setup-ZVKTDL4G.js → register-setup-BB77VUEE.js} +17 -16
- package/dist/cli-bundle/chunks/{register-setup-ZVKTDL4G.js.map → register-setup-BB77VUEE.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-setup-N2FOSWAG.js → register-setup-EYZ7VTPZ.js} +15 -14
- package/dist/cli-bundle/chunks/{register-setup-N2FOSWAG.js.map → register-setup-EYZ7VTPZ.js.map} +1 -1
- package/dist/cli-bundle/chunks/restore-L6IAGOD7.js +15 -0
- package/dist/cli-bundle/chunks/{restore-HEQAG6EK.js → restore-ZH65GZFB.js} +7 -6
- package/dist/cli-bundle/chunks/{schema-Q5DAWJ2S.js → schema-4ERWM5QJ.js} +7 -6
- package/dist/cli-bundle/chunks/{schema-MAXAIHEC.js → schema-55DL3Q52.js} +7 -6
- package/dist/cli-bundle/chunks/{update-DWFXXJKP.js → update-FW6FKDOP.js} +15 -15
- package/dist/cli-bundle/chunks/update-TJHSPRPT.js +23 -0
- package/dist/cli-bundle/chunks/update-many-NNALYQCN.js +35 -0
- package/dist/cli-bundle/chunks/update-many-PWXX5WHO.js +39 -0
- package/dist/cli-bundle/main.js +62 -59
- package/dist/cli-bundle/main.js.map +1 -1
- package/dist/cli-bundle/sdk-runtime.js +62 -59
- package/dist/cli-bundle/sdk-testing.js +8 -8
- package/dist/cli-bundle/sdk.js +327 -57
- package/dist/cli-bundle/sdk.js.map +4 -4
- package/dist/core/config/nested-settings.d.ts +2 -0
- package/dist/core/config/nested-settings.js +18 -2
- package/dist/core/config/nested-settings.js.map +1 -1
- package/dist/core/diagnostics/remediation.js +38 -2
- package/dist/core/diagnostics/remediation.js.map +1 -1
- package/dist/core/extensions/extension-types.d.ts +1 -1
- package/dist/core/extensions/extension-types.js +2 -2
- package/dist/core/extensions/extension-types.js.map +1 -1
- package/dist/core/item/id.d.ts +19 -2
- package/dist/core/item/id.js +27 -6
- package/dist/core/item/id.js.map +1 -1
- package/dist/core/item/parse.d.ts +7 -0
- package/dist/core/item/parse.js +48 -2
- package/dist/core/item/parse.js.map +1 -1
- package/dist/core/schema/item-types-file.d.ts +2 -2
- package/dist/core/schema/item-types-file.js +2 -2
- package/dist/core/schema/item-types-file.js.map +1 -1
- package/dist/core/schema/runtime-schema.d.ts +3 -3
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/schema/runtime-schema.js.map +1 -1
- package/dist/core/schema/type-workflows.d.ts +2 -2
- package/dist/core/schema/type-workflows.js +2 -2
- package/dist/core/schema/type-workflows.js.map +1 -1
- package/dist/core/shared/constants.js +5 -2
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/store/settings-validator.d.ts +4 -0
- package/dist/core/store/settings-validator.js +8 -2
- package/dist/core/store/settings-validator.js.map +1 -1
- package/dist/core/store/settings.js +8 -2
- package/dist/core/store/settings.js.map +1 -1
- package/dist/sdk/annotations.js +24 -2
- package/dist/sdk/annotations.js.map +1 -1
- package/dist/sdk/cli-bootstrap.d.ts +1 -1
- package/dist/sdk/cli-bootstrap.js +3 -3
- package/dist/sdk/cli-bootstrap.js.map +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +22 -2
- package/dist/sdk/cli-contracts/commander-mutation-options.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/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +17 -2
- package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +512 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +21 -11
- package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +13 -3
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -0
- package/dist/sdk/cli-contracts/tool-schema.js +14 -10
- package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +69 -0
- package/dist/sdk/cli-contracts/typed-action-inputs.js +5 -0
- package/dist/sdk/cli-contracts/typed-action-inputs.js.map +1 -0
- package/dist/sdk/cli-contracts.d.ts +4 -3
- package/dist/sdk/cli-contracts.js +5 -5
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/sdk/extension/describe.d.ts +1 -1
- package/dist/sdk/extension/describe.js +2 -2
- package/dist/sdk/extension/describe.js.map +1 -1
- package/dist/sdk/extension/install-runtime.js +5 -3
- package/dist/sdk/extension/install-runtime.js.map +1 -1
- package/dist/sdk/extension.d.ts +2 -2
- package/dist/sdk/extension.js +2 -2
- package/dist/sdk/extension.js.map +1 -1
- package/dist/sdk/governance/gc.d.ts +14 -1
- package/dist/sdk/governance/gc.js +38 -2
- package/dist/sdk/governance/gc.js.map +1 -1
- package/dist/sdk/governance/storage-integrity.d.ts +84 -0
- package/dist/sdk/governance/storage-integrity.js +240 -0
- package/dist/sdk/governance/storage-integrity.js.map +1 -0
- package/dist/sdk/governance/validate.d.ts +3 -1
- package/dist/sdk/governance/validate.js +56 -2
- package/dist/sdk/governance/validate.js.map +1 -1
- package/dist/sdk/history-read.d.ts +1 -1
- package/dist/sdk/history-read.js +2 -2
- package/dist/sdk/history-read.js.map +1 -1
- package/dist/sdk/history-repair.d.ts +36 -0
- package/dist/sdk/history-repair.js +69 -4
- package/dist/sdk/history-repair.js.map +1 -1
- package/dist/sdk/index.d.ts +5 -2
- package/dist/sdk/index.js +5 -2
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/init.js +3 -3
- package/dist/sdk/init.js.map +1 -1
- package/dist/sdk/item-transaction.d.ts +131 -0
- package/dist/sdk/item-transaction.js +280 -0
- package/dist/sdk/item-transaction.js.map +1 -0
- package/dist/sdk/merge/driver.d.ts +75 -0
- package/dist/sdk/merge/driver.js +166 -0
- package/dist/sdk/merge/driver.js.map +1 -0
- package/dist/sdk/merge/index.d.ts +11 -0
- package/dist/sdk/merge/index.js +15 -0
- package/dist/sdk/merge/index.js.map +1 -0
- package/dist/sdk/merge/install.d.ts +90 -0
- package/dist/sdk/merge/install.js +318 -0
- package/dist/sdk/merge/install.js.map +1 -0
- package/dist/sdk/merge/three-way.d.ts +126 -0
- package/dist/sdk/merge/three-way.js +545 -0
- package/dist/sdk/merge/three-way.js.map +1 -0
- package/dist/sdk/query/list.d.ts +19 -2
- package/dist/sdk/query/list.js +5 -2
- package/dist/sdk/query/list.js.map +1 -1
- package/dist/sdk/runtime.d.ts +17 -14
- package/dist/sdk/runtime.js +5 -5
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/schema.d.ts +2 -2
- package/dist/sdk/schema.js +29 -2
- package/dist/sdk/schema.js.map +1 -1
- package/dist/sdk/stats.d.ts +1 -1
- package/dist/sdk/stats.js +2 -2
- package/dist/sdk/stats.js.map +1 -1
- package/dist/sdk/workspace-transaction-gc.d.ts +46 -0
- package/dist/sdk/workspace-transaction-gc.js +155 -0
- package/dist/sdk/workspace-transaction-gc.js.map +1 -0
- package/dist/sdk/workspace.d.ts +28 -4
- package/dist/sdk/workspace.js +61 -15
- package/dist/sdk/workspace.js.map +1 -1
- package/dist/types.d.ts +11 -7
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/docs/AGENT_GUIDE.md +58 -47
- package/docs/COMMANDS.md +7 -0
- package/docs/CONFIGURATION.md +2 -0
- package/docs/MERGE_SAFETY.md +99 -0
- package/docs/README.md +1 -0
- package/docs/SDK.md +56 -0
- package/marketplace.json +2 -2
- package/package.json +3 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/dist/cli-bundle/chunks/append-XUYF7NON.js +0 -11
- package/dist/cli-bundle/chunks/chunk-2XPDCXK5.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-3EZZTFL2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-3KPNOZOH.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-46Z6FAVP.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-4M6RZJXF.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-6V4T4RD3.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-A3GAQLBH.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-A4FVWFZY.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-A5EQPNV7.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-AR24KW26.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-BBGR4FKQ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-BDC4TW4B.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-BZKE2O5V.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-CZA2DXCV.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-D35WYXWC.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-DJAGYYCQ.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-EEECAV5M.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-H3YKUVDR.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-IDUTGRDM.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-IGBBTPM5.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-JBW2S2C6.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-JPWUZOMR.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-KAE727L2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MI3346YW.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-MQOSMBWV.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MRXAHR4B.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-N2TEEOXJ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-ODEIDKGW.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-P24ZU5QV.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-Q3K5XPAQ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-QFG4MB7P.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-RLLOZAM2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-RWAIRGBC.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-SBW7EQC4.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-SVAWG7EE.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-UE7LK3RE.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-VA3H7VVC.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-WCBB6VI3.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-Y2VSGFT4.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-YG56M3NE.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-ZF52NVRT.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-ZUCBPXNA.js.map +0 -7
- package/dist/cli-bundle/chunks/close-ZZCDDWJT.js +0 -12
- package/dist/cli-bundle/chunks/close-many-QCZHFCON.js +0 -23
- package/dist/cli-bundle/chunks/comments-FMQNYPSZ.js +0 -13
- package/dist/cli-bundle/chunks/copy-GI3RCVZP.js +0 -9
- package/dist/cli-bundle/chunks/create-LXMLYJNM.js +0 -29
- package/dist/cli-bundle/chunks/delete-5DFAXJNI.js +0 -10
- package/dist/cli-bundle/chunks/docs-KCWPLQOV.js +0 -14
- package/dist/cli-bundle/chunks/focus-3EJVFI3D.js +0 -10
- package/dist/cli-bundle/chunks/history-compact-JHYVDYLW.js +0 -16
- package/dist/cli-bundle/chunks/history-repair-REMI7DDI.js +0 -16
- package/dist/cli-bundle/chunks/learnings-O6V5WDCV.js +0 -13
- package/dist/cli-bundle/chunks/notes-ZSZREWZA.js +0 -13
- package/dist/cli-bundle/chunks/plan-EZW2YDDY.js +0 -26
- package/dist/cli-bundle/chunks/register-mutation-BLEWM5I6.js.map +0 -7
- package/dist/cli-bundle/chunks/register-mutation-OTYHR7J6.js.map +0 -1
- package/dist/cli-bundle/chunks/register-operations-AMCUFYEW.js.map +0 -1
- package/dist/cli-bundle/chunks/register-operations-MRLHOZYR.js.map +0 -7
- package/dist/cli-bundle/chunks/restore-A55MLFAI.js +0 -14
- package/dist/cli-bundle/chunks/update-5DTSCWVF.js +0 -23
- package/dist/cli-bundle/chunks/update-many-6T4ZLZS7.js +0 -34
- package/dist/cli-bundle/chunks/update-many-MYRK6VBJ.js +0 -38
- /package/dist/cli-bundle/chunks/{append-MBXHNWSX.js.map → append-E6V54WOQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{append-XUYF7NON.js.map → append-NNJ3EFIT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YGEA4CLH.js.map → chunk-3MCTMJXI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-N7FCFJ76.js.map → chunk-3P7UJQOX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7B7IHMLH.js.map → chunk-3VY6MIEO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-5S6IZXK7.js.map → chunk-4U4Z6AHI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UOIFZ66L.js.map → chunk-4XGJLADW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-SUNZKVAH.js.map → chunk-5IZJWSDB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QQ77W23U.js.map → chunk-5NTE36LD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KGPLSHJD.js.map → chunk-6C2ZZX5Z.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-Q5NHJ6RO.js.map → chunk-6JUTHVQS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-NTS2RKHN.js.map → chunk-6VIJ7UA5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XVB6BATY.js.map → chunk-72LQ4TKV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-KZ5AC6B5.js.map → chunk-7WCE6Y64.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VQOG2ETB.js.map → chunk-AF2CCM5U.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-EAV3P54W.js.map → chunk-DAQ45GCS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RX53WHFI.js.map → chunk-EJDGV4GR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-IXG5CMBR.js.map → chunk-FDHPAVVB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-V4QHAMI5.js.map → chunk-GROYI4RB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-77XFQRTD.js.map → chunk-GSJSM5BJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-QYGK2XQ3.js.map → chunk-GTLCVJOE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VSQE43NO.js.map → chunk-GV2262OF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-STBCBDKF.js.map → chunk-HCEBZNC3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-U6RYD446.js.map → chunk-HRW7GF6T.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XDWXPG2E.js.map → chunk-IAQE32BI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-66SRNEBK.js.map → chunk-IJNK6WW2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AGEBQRBG.js.map → chunk-JAPE62Y5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UWAQI3B7.js.map → chunk-JGUKMMRS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UU6EP25G.js.map → chunk-JH2ZSLO3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GRDK25BN.js.map → chunk-JHJSFOAM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FQO5THHM.js.map → chunk-JM6YAXTR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-E7KBMWEF.js.map → chunk-JSLT7WVE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FIUTBFC6.js.map → chunk-K4CI6Y45.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-IEMXESIS.js.map → chunk-KSPWRNVP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-BFJP4VYC.js.map → chunk-L7BH7IWU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-2UCG5H6B.js.map → chunk-LPEYZRUR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-IR3GOO6E.js.map → chunk-NHT3F4WZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-6BNV3G6C.js.map → chunk-NLR32VFS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-EI3UIMZM.js.map → chunk-OWXOPDHD.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AQUNTB7G.js.map → chunk-PEQGTJ5Q.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-T6MOTLOJ.js.map → chunk-QJKL5PHS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XKVHL3MB.js.map → chunk-QWRVBJ4D.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-VFA5EIEN.js.map → chunk-R7QV7ICM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-K2L6FZBX.js.map → chunk-RJO3YAFM.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-SGJB6PXA.js.map → chunk-SF3DT5HJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UNNCT5QY.js.map → chunk-SZVB53Y3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-GFZB5CLP.js.map → chunk-T6PPNM7V.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-W6IEJXNC.js.map → chunk-TVYYO5A7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DOASIOQR.js.map → chunk-UQLXSG72.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7CHWLT2J.js.map → chunk-UVN66B3M.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-Q6JPYR7I.js.map → chunk-UX6SSO2I.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-OK7VSX3N.js.map → chunk-UZLJOEAC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-4PSJVGRE.js.map → chunk-VDO2JMD4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-IRJ6F23W.js.map → chunk-VQIHNHMJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-LT5UWU7H.js.map → chunk-ZOJ3LR7O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3HSRP6T2.js.map → chunk-ZOY5K4D3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-XXWDEQ6O.js.map → chunk-ZV2NTVMJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-UW6HCMP2.js.map → chunk-ZYPFOO3L.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-ZZCDDWJT.js.map → close-O5QVZ6ET.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-7NWA3GLA.js.map → close-QEMOYZN3.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-QCZHFCON.js.map → close-many-SDA426VT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-many-YALQ7AXS.js.map → close-many-UTZANOCQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-SQIQ5WYR.js.map → comments-LZN6FXXC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{comments-FMQNYPSZ.js.map → comments-VBQ345ND.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-YDAMENCP.js.map → copy-DKTSSCK7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{copy-GI3RCVZP.js.map → copy-M7DDI6LS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-JSL6CXU3.js.map → create-GG4RBCGC.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-LXMLYJNM.js.map → create-JBC5KUW6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-IGVOZEU2.js.map → delete-LCS3VPDH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{delete-5DFAXJNI.js.map → delete-MD7YXQLH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-BQAXUQAK.js.map → deps-DELOO4TL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{deps-CBPPSS6J.js.map → deps-FI4O6NQS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-KCWPLQOV.js.map → docs-2UYBP5D6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{docs-NS2AZWCN.js.map → docs-6Z2MP526.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-XUUBQ76I.js.map → files-HEUGSJZL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{files-PVWEPT5J.js.map → files-HKEAN5MA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-DHBHKK3E.js.map → focus-7SOUT5PZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{focus-3EJVFI3D.js.map → focus-DRQ6FQH6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-JHYVDYLW.js.map → history-compact-65YVN5DB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-compact-3TNPYVFG.js.map → history-compact-7NDVP3PT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-KKFDICCF.js.map → history-redact-7YBL4XSG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-ELRL73XN.js.map → history-redact-IZGNJBU4.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-J7WKZFAG.js.map → history-repair-7M4PYQUH.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-repair-REMI7DDI.js.map → history-repair-GNGETJLI.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-O6V5WDCV.js.map → learnings-3YXDRWFT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{learnings-X4D6JCCG.js.map → learnings-ALC6IMNL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-ZSZREWZA.js.map → notes-7JMLQ447.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{notes-UQC6VS6N.js.map → notes-JFCLTC5C.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-EZW2YDDY.js.map → plan-KOIPWVOZ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{plan-5GKRBJJO.js.map → plan-T3XB3WTK.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-5PQAPCLF.js.map → profile-OILJHKUW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{profile-CW4BD3FO.js.map → profile-RJXA7PGS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-A55MLFAI.js.map → restore-L6IAGOD7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-HEQAG6EK.js.map → restore-ZH65GZFB.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-Q5DAWJ2S.js.map → schema-4ERWM5QJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-MAXAIHEC.js.map → schema-55DL3Q52.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-DWFXXJKP.js.map → update-FW6FKDOP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-5DTSCWVF.js.map → update-TJHSPRPT.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-6T4ZLZS7.js.map → update-many-NNALYQCN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-many-MYRK6VBJ.js.map → update-many-PWXX5WHO.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../cli/commands/update-many.ts"],"sourcesContent":["/**\n * @module cli/commands/update-many\n *\n * Implements the pm update many command surface and its agent-facing runtime behavior.\n */\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport {\n createCheckpointId,\n loadMutationCheckpoint,\n restoreCheckpointItems,\n writeMutationCheckpoint,\n type MutationCheckpointItem,\n} from \"../../core/checkpoint/mutation-checkpoint.js\";\nimport { toItemRecord } from \"../../core/item/item-record.js\";\nimport {\n applyAcceptanceCriteriaMutations,\n applyTagRemovals,\n mergeAdditiveTags,\n parseOptionalNonNegativeInteger,\n parseTags,\n splitAcceptanceCriteria,\n} from \"../../core/item/parse.js\";\nimport { resolvePriority } from \"../../core/item/priority.js\";\nimport { normalizeStatusInput } from \"../../core/item/status.js\";\nimport {\n resolveItemTypeRegistry,\n resolveTypeName,\n} from \"../../core/item/type-registry.js\";\nimport { collectRuntimeUpdateFieldValues } from \"../../core/schema/runtime-field-values.js\";\nimport { buildInvalidTypeError } from \"../../core/schema/item-types-file.js\";\nimport {\n resolveItemTypesFilePath,\n resolveRuntimeFieldRegistry,\n resolveRuntimeStatusRegistry,\n type RuntimeFieldRegistry,\n type RuntimeStatusRegistry,\n} from \"../../core/schema/runtime-schema.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 { toErrorMessage } from \"../../core/shared/primitives.js\";\nimport { stableValueEquals } from \"../../core/shared/serialization.js\";\nimport { nowIso, resolveIsoOrRelative } from \"../../core/shared/time.js\";\nimport { getActiveExtensionRegistrations } from \"../../core/extensions/index.js\";\nimport type { ItemStatus, PmSettings } from \"../../types/index.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { resolveAuthor } from \"../../core/shared/author.js\";\nimport { hasListFilters } from \"./list-filter-shared.js\";\nimport {\n runList,\n type ListFullResult,\n type ListOptions,\n type ListedItem,\n} from \"./list.js\";\nimport { runRestore } from \"./restore.js\";\nimport { runUpdate, type UpdateCommandOptions } from \"./update.js\";\n\nconst UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION = 1;\nconst UPDATE_MANY_CHECKPOINT_SUBDIR = \"update-many\";\n\nconst NON_MUTATION_UPDATE_OPTION_KEYS = new Set<PropertyKey>([\n \"author\",\n \"message\",\n \"force\",\n \"ownershipMetadataBypass\",\n \"ownershipDependencyBypass\",\n]);\n\nconst UPDATE_MANY_MUTATION_FLAG_GUIDANCE = [\n \"--status\",\n \"--priority\",\n \"--type\",\n \"--tags\",\n \"--description\",\n \"--body\",\n \"--deadline\",\n \"--estimate\",\n \"--assignee\",\n \"--dep\",\n \"--dep-remove\",\n \"--comment\",\n \"--note\",\n \"--learning\",\n \"--file\",\n \"--test\",\n \"--doc\",\n \"--replace-deps\",\n \"--replace-tests\",\n \"--unset\",\n \"--clear-*\",\n].join(\", \");\n\nconst UPDATE_OPTION_TO_ITEM_KEY: Partial<\n Record<keyof UpdateCommandOptions, string>\n> = {\n title: \"title\",\n description: \"description\",\n body: \"body\",\n status: \"status\",\n closeReason: \"close_reason\",\n priority: \"priority\",\n type: \"type\",\n deadline: \"deadline\",\n estimatedMinutes: \"estimated_minutes\",\n acceptanceCriteria: \"acceptance_criteria\",\n definitionOfReady: \"definition_of_ready\",\n order: \"order\",\n goal: \"goal\",\n objective: \"objective\",\n value: \"value\",\n impact: \"impact\",\n outcome: \"outcome\",\n whyNow: \"why_now\",\n assignee: \"assignee\",\n parent: \"parent\",\n reviewer: \"reviewer\",\n risk: \"risk\",\n confidence: \"confidence\",\n sprint: \"sprint\",\n release: \"release\",\n blockedBy: \"blocked_by\",\n blockedReason: \"blocked_reason\",\n unblockNote: \"unblock_note\",\n reporter: \"reporter\",\n severity: \"severity\",\n environment: \"environment\",\n reproSteps: \"repro_steps\",\n resolution: \"resolution\",\n expectedResult: \"expected_result\",\n actualResult: \"actual_result\",\n affectedVersion: \"affected_version\",\n fixedVersion: \"fixed_version\",\n component: \"component\",\n regression: \"regression\",\n customerImpact: \"customer_impact\",\n};\n\ninterface CollectionMutationPlanDefinition {\n field: string;\n addKey: keyof UpdateCommandOptions;\n removeKey?: keyof UpdateCommandOptions;\n clearKey: keyof UpdateCommandOptions;\n replaceKey?: keyof UpdateCommandOptions;\n}\n\nconst COLLECTION_MUTATION_PLAN_DEFINITIONS: CollectionMutationPlanDefinition[] =\n [\n {\n field: \"dependencies\",\n addKey: \"dep\",\n removeKey: \"depRemove\",\n clearKey: \"clearDeps\",\n replaceKey: \"replaceDeps\",\n },\n {\n field: \"comments\",\n addKey: \"comment\",\n clearKey: \"clearComments\",\n },\n {\n field: \"notes\",\n addKey: \"note\",\n clearKey: \"clearNotes\",\n },\n {\n field: \"learnings\",\n addKey: \"learning\",\n clearKey: \"clearLearnings\",\n },\n {\n field: \"files\",\n addKey: \"file\",\n clearKey: \"clearFiles\",\n },\n {\n field: \"tests\",\n addKey: \"test\",\n clearKey: \"clearTests\",\n replaceKey: \"replaceTests\",\n },\n {\n field: \"docs\",\n addKey: \"doc\",\n clearKey: \"clearDocs\",\n },\n {\n field: \"reminders\",\n addKey: \"reminder\",\n clearKey: \"clearReminders\",\n },\n {\n field: \"events\",\n addKey: \"event\",\n clearKey: \"clearEvents\",\n },\n {\n field: \"type_options\",\n addKey: \"typeOption\",\n clearKey: \"clearTypeOptions\",\n },\n ];\n\nconst UNSET_FIELD_ALIASES: Record<string, string> = {\n close_reason: \"close_reason\",\n \"close-reason\": \"close_reason\",\n deadline: \"deadline\",\n estimate: \"estimated_minutes\",\n estimated_minutes: \"estimated_minutes\",\n \"estimated-minutes\": \"estimated_minutes\",\n acceptance_criteria: \"acceptance_criteria\",\n \"acceptance-criteria\": \"acceptance_criteria\",\n ac: \"acceptance_criteria\",\n definition_of_ready: \"definition_of_ready\",\n \"definition-of-ready\": \"definition_of_ready\",\n order: \"order\",\n rank: \"order\",\n goal: \"goal\",\n objective: \"objective\",\n value: \"value\",\n impact: \"impact\",\n outcome: \"outcome\",\n why_now: \"why_now\",\n \"why-now\": \"why_now\",\n assignee: \"assignee\",\n parent: \"parent\",\n reviewer: \"reviewer\",\n risk: \"risk\",\n confidence: \"confidence\",\n sprint: \"sprint\",\n release: \"release\",\n blocked_by: \"blocked_by\",\n \"blocked-by\": \"blocked_by\",\n blocked_reason: \"blocked_reason\",\n \"blocked-reason\": \"blocked_reason\",\n unblock_note: \"unblock_note\",\n \"unblock-note\": \"unblock_note\",\n reporter: \"reporter\",\n severity: \"severity\",\n environment: \"environment\",\n repro_steps: \"repro_steps\",\n \"repro-steps\": \"repro_steps\",\n resolution: \"resolution\",\n expected_result: \"expected_result\",\n \"expected-result\": \"expected_result\",\n actual_result: \"actual_result\",\n \"actual-result\": \"actual_result\",\n affected_version: \"affected_version\",\n \"affected-version\": \"affected_version\",\n fixed_version: \"fixed_version\",\n \"fixed-version\": \"fixed_version\",\n component: \"component\",\n regression: \"regression\",\n customer_impact: \"customer_impact\",\n \"customer-impact\": \"customer_impact\",\n type_options: \"type_options\",\n \"type-options\": \"type_options\",\n tags: \"tags\",\n};\n\ninterface UpdateManyCheckpoint {\n schema_version: number;\n id: string;\n created_at: string;\n author: string;\n status_filter: string | null;\n list_filters: Record<string, unknown>;\n update_options: Record<string, unknown>;\n items: MutationCheckpointItem[];\n}\n\n/** Documents the update many command options payload exchanged by command, SDK, and package integrations. */\nexport interface UpdateManyCommandOptions {\n /** Lifecycle state reported for status. */\n status?: string;\n /** Value that configures or reports list for this contract. */\n list: ListOptions;\n /** Value that configures or reports update for this contract. */\n update: UpdateCommandOptions;\n /** Value that configures or reports dry run for this contract. */\n dryRun?: boolean;\n /** Value that configures or reports rollback for this contract. */\n rollback?: string;\n /** Value that configures or reports checkpoint for this contract. */\n checkpoint?: boolean;\n}\n\ninterface PlannedChange {\n field: string;\n before: unknown;\n after: unknown;\n}\n\ninterface PlannedItemDiff {\n id: string;\n changes: PlannedChange[];\n warnings?: string[];\n}\n\ninterface UpdateManyApplyResultRow {\n id: string;\n status: \"updated\" | \"failed\" | \"skipped\";\n changed_fields?: string[];\n warnings?: string[];\n error?: string;\n}\n\ninterface UpdateManyRollbackResultRow {\n id: string;\n status: \"restored\" | \"failed\";\n changed_fields?: string[];\n warnings?: string[];\n error?: string;\n}\n\n/** Documents the update many result payload exchanged by command, SDK, and package integrations. */\nexport interface UpdateManyResult {\n /** Value that configures or reports mode for this contract. */\n mode: \"dry_run\" | \"apply\" | \"rollback\";\n /** Number of matched entries represented by this result. */\n matched_count: number;\n /** Value that configures or reports dry run for this contract. */\n dry_run: boolean;\n /** Value that configures or reports filters for this contract. */\n filters?: Record<string, unknown>;\n /** Inputs that customize the planned update operation. */\n planned_update_options?: Record<string, unknown>;\n /** Value that configures or reports item plans for this contract. */\n item_plans?: PlannedItemDiff[];\n /** Value that configures or reports checkpoint for this contract. */\n checkpoint?: {\n id: string;\n created_at: string;\n path: string;\n rollback_command: string;\n };\n /** Number of updated entries represented by this result. */\n updated_count?: number;\n /** Number of skipped entries represented by this result. */\n skipped_count?: number;\n /** Number of failed entries represented by this result. */\n failed_count?: number;\n /** Number of restored entries represented by this result. */\n restored_count?: number;\n /** Value that configures or reports rollback checkpoint id for this contract. */\n rollback_checkpoint_id?: string;\n /** Value that configures or reports rows for this contract. */\n rows?: UpdateManyApplyResultRow[] | UpdateManyRollbackResultRow[];\n /** Value that configures or reports ids for this contract. */\n ids: string[];\n /** Explicitly requested --ids values that matched no tracked item. */\n unmatched_ids?: string[];\n /** Number of explicitly requested --ids values that matched no tracked item. */\n unmatched_count?: number;\n}\n\n/** Removes execution-only options from the mutation summary persisted in checkpoints. */\nconst sanitizeUpdateOptionsForSummary = (\n options: UpdateCommandOptions,\n): Record<string, unknown> => {\n const summary: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(options) as Array<\n [keyof UpdateCommandOptions, unknown]\n >) {\n if (NON_MUTATION_UPDATE_OPTION_KEYS.has(key)) {\n continue;\n }\n if (value === undefined) {\n continue;\n }\n summary[key] = value;\n }\n return summary;\n};\n\n/** Reports whether an update-many request contains at least one mutation input. */\nconst hasAnyUpdateMutationInput = (options: UpdateCommandOptions): boolean => {\n return Object.keys(sanitizeUpdateOptionsForSummary(options)).length > 0;\n};\n\ntype PreviewValueNormalizer = (value: unknown) => unknown;\n\n/** Trims string preview values while preserving non-string inputs. */\nconst trimPreviewValue: PreviewValueNormalizer = (value) =>\n typeof value === \"string\" ? value.trim() : value;\n/** Converts integer-like preview values to their storage representation. */\nconst normalizeIntegerPreviewValue: PreviewValueNormalizer = (value) => {\n const trimmed = String(value).trim();\n const parsed = Number(trimmed);\n return Number.isInteger(parsed) ? parsed : trimmed;\n};\n/** Converts finite numeric preview values to their storage representation. */\nconst normalizeNumericPreviewValue: PreviewValueNormalizer = (value) => {\n const trimmed = String(value).trim();\n const parsed = Number(trimmed);\n return Number.isFinite(parsed) ? parsed : trimmed;\n};\n/** Converts supported regression tokens to their boolean storage representation. */\nconst normalizeRegressionPreviewValue: PreviewValueNormalizer = (value) => {\n const normalized = String(value).trim().toLowerCase();\n const parsed = new Map<string, boolean>([\n [\"true\", true],\n [\"1\", true],\n [\"false\", false],\n [\"0\", false],\n ]).get(normalized);\n return parsed ?? trimPreviewValue(value);\n};\n\nconst PREVIEW_VALUE_NORMALIZERS: Partial<\n Record<keyof UpdateCommandOptions, PreviewValueNormalizer>\n> = {\n priority: normalizeIntegerPreviewValue,\n estimatedMinutes: normalizeNumericPreviewValue,\n order: normalizeNumericPreviewValue,\n rank: normalizeNumericPreviewValue,\n regression: normalizeRegressionPreviewValue,\n};\n\n/** Normalizes a CLI mutation value to the storage-shaped value used by previews. */\nconst toComparablePreviewValue = (\n optionKey: keyof UpdateCommandOptions,\n value: unknown,\n): unknown => {\n if (value === undefined) {\n return undefined;\n }\n return (PREVIEW_VALUE_NORMALIZERS[optionKey] ?? trimPreviewValue)(value);\n};\n\n/** Resolves user-facing unset aliases to stored metadata keys. */\nconst normalizeUnsetField = (rawField: string): string => {\n const normalized = rawField.trim().toLowerCase().replaceAll(\"-\", \"_\");\n return UNSET_FIELD_ALIASES[normalized] ?? normalized;\n};\n\n/** Compares preview values using the canonical stable serialization contract. */\nconst areValuesEqual = (left: unknown, right: unknown): boolean => {\n return stableValueEquals(left, right);\n};\n\n/** Supplies the storage-shaped empty value for an absent collection field. */\nconst normalizeCollectionBeforeValue = (\n field: string,\n value: unknown,\n): unknown => {\n if (value !== undefined) {\n return value;\n }\n if (field === \"type_options\") {\n return {};\n }\n return [];\n};\n\n/** Counts entries in list and type-option collection values. */\nconst collectionValueCount = (field: string, value: unknown): number => {\n if (Array.isArray(value)) {\n return value.length;\n }\n if (field === \"type_options\" && value && typeof value === \"object\") {\n return Object.keys(value as Record<string, unknown>).length;\n }\n return 0;\n};\n\n/** Resolves the dominant collection mutation using apply-path precedence. */\nconst resolveCollectionMutationOperation = (params: {\n replace: boolean;\n clear: boolean;\n removeCount: number;\n}): string => {\n if (params.replace) {\n return \"replace\";\n }\n if (params.clear) {\n return \"clear_or_reset\";\n }\n return params.removeCount > 0 ? \"merge_remove\" : \"append\";\n};\n\n/** Reads an optional definition key without indexing through undefined. */\nconst readOptionalUpdateValue = (\n update: UpdateCommandOptions,\n key: keyof UpdateCommandOptions | undefined,\n): unknown => (key === undefined ? undefined : update[key]);\n\n/** Counts array-shaped mutation inputs while treating other shapes as empty. */\nconst updateArrayValueCount = (value: unknown): number =>\n Array.isArray(value) ? value.length : 0;\n\n/** Builds one collection plan when its definition has an active mutation. */\nconst buildCollectionMutationPlan = (\n definition: CollectionMutationPlanDefinition,\n row: Record<string, unknown>,\n update: UpdateCommandOptions,\n): PlannedChange | undefined => {\n const addValues = update[definition.addKey];\n const removeValues = readOptionalUpdateValue(update, definition.removeKey);\n const addCount = updateArrayValueCount(addValues);\n const removeCount = updateArrayValueCount(removeValues);\n const clear = update[definition.clearKey] === true;\n const replace =\n readOptionalUpdateValue(update, definition.replaceKey) === true;\n if (![clear, replace, addCount > 0, removeCount > 0].includes(true)) {\n return undefined;\n }\n const before = normalizeCollectionBeforeValue(\n definition.field,\n row[definition.field],\n );\n return {\n field: definition.field,\n before,\n after: {\n operation: resolveCollectionMutationOperation({\n replace,\n clear,\n removeCount,\n }),\n clear,\n replace,\n add_count: addCount,\n remove_count: removeCount,\n before_count: collectionValueCount(definition.field, before),\n },\n };\n};\n\n/** Builds collection mutation previews for every active collection option. */\nconst buildCollectionMutationPlans = (\n row: Record<string, unknown>,\n update: UpdateCommandOptions,\n): PlannedChange[] => {\n const changes: PlannedChange[] = [];\n for (const definition of COLLECTION_MUTATION_PLAN_DEFINITIONS) {\n const plan = buildCollectionMutationPlan(definition, row, update);\n if (plan !== undefined) {\n changes.push(plan);\n }\n }\n return changes;\n};\n\n/** Keeps only string tags from an existing storage value. */\nconst normalizeExistingTags = (value: unknown): string[] => {\n if (!Array.isArray(value)) {\n return [];\n }\n return value.filter((tag): tag is string => typeof tag === \"string\");\n};\n\n// Tags support three mutation modes that compose: --tags replaces, --add-tags\n// extends, --remove-tags prunes. Replicate runUpdate's resolution order so the\n// dry-run preview and the apply-mode actionable detection both account for\n// additive/subtractive tag mutations (a --add-tags-only update must NOT be\n// treated as a no-op skip).\nconst buildTagMutationPlan = (\n row: Record<string, unknown>,\n update: UpdateCommandOptions,\n): PlannedChange | undefined => {\n if (\n ![\n update.tags !== undefined,\n updateArrayValueCount(update.addTags) > 0,\n updateArrayValueCount(update.removeTags) > 0,\n ].includes(true)\n ) {\n return undefined;\n }\n const existing = normalizeExistingTags(row.tags);\n const baseTags =\n update.tags === undefined ? existing : parseTags(update.tags);\n const withAdditions = mergeAdditiveTags(baseTags, update.addTags);\n const after = applyTagRemovals(withAdditions, update.removeTags)\n .slice()\n .sort((a, b) => a.localeCompare(b));\n const before = existing.slice().sort((a, b) => a.localeCompare(b));\n if (areValuesEqual(before, after)) {\n return undefined;\n }\n return { field: \"tags\", before: existing, after };\n};\n\n// Acceptance criteria support replace (--ac) plus additive --add-ac/--remove-ac\n// (GH-612). Replicate runUpdate's resolution order so dry-run previews and\n// apply-mode actionable detection account for additive criterion mutations (an\n// --add-ac-only bulk update must NOT be treated as a no-op skip).\nconst buildAcceptanceCriteriaMutationPlan = (\n row: Record<string, unknown>,\n update: UpdateCommandOptions,\n): { change?: PlannedChange; warnings: string[] } => {\n const before = row.acceptance_criteria;\n const base =\n update.acceptanceCriteria === undefined\n ? before\n : String(update.acceptanceCriteria).trim();\n const mutation = applyAcceptanceCriteriaMutations(\n splitAcceptanceCriteria(base),\n update.addAc,\n update.removeAc,\n );\n const warnings = mutation.unmatchedRemovals.map(\n (criterion) => `remove_ac_unmatched:${criterion}`,\n );\n const after = mutation.criteria.join(\"; \");\n if (areValuesEqual(before, after) || (before === undefined && after === \"\")) {\n return { warnings };\n }\n return {\n change: { field: \"acceptance_criteria\", before, after },\n warnings,\n };\n};\n\n/** Adds changed scalar options to a planned item diff. */\nconst appendScalarMutationPlans = (\n changes: PlannedChange[],\n row: Record<string, unknown>,\n update: UpdateCommandOptions,\n): void => {\n for (const [optionKey, itemKey] of Object.entries(\n UPDATE_OPTION_TO_ITEM_KEY,\n ) as Array<[keyof UpdateCommandOptions, string]>) {\n const candidate = update[optionKey];\n if (candidate === undefined) {\n continue;\n }\n const before = row[itemKey];\n const after = toComparablePreviewValue(optionKey, candidate);\n if (!areValuesEqual(before, after)) {\n changes.push({ field: itemKey, before, after });\n }\n }\n};\n\n/** Adds changed runtime-schema fields to a planned item diff. */\nconst appendRuntimeFieldMutationPlans = (\n changes: PlannedChange[],\n row: Record<string, unknown>,\n update: UpdateCommandOptions,\n runtimeFieldRegistry: RuntimeFieldRegistry,\n): void => {\n const runtimeFieldUpdates = collectRuntimeUpdateFieldValues(\n update as Record<string, unknown>,\n runtimeFieldRegistry,\n [\"update_many\"],\n );\n for (const [field, after] of Object.entries(runtimeFieldUpdates)) {\n const before = row[field];\n if (!areValuesEqual(before, after)) {\n changes.push({ field, before, after });\n }\n }\n};\n\n/** Adds present fields requested through unset options to a planned item diff. */\nconst appendUnsetMutationPlans = (\n changes: PlannedChange[],\n row: Record<string, unknown>,\n unset: string[] | undefined,\n): void => {\n for (const rawUnsetField of unset ?? []) {\n const field = normalizeUnsetField(rawUnsetField);\n const before = row[field];\n if (before !== undefined) {\n changes.push({ field, before, after: null });\n }\n }\n};\n\n/** Builds the complete storage-shaped mutation preview for one item. */\nconst buildPlannedItemDiff = (\n item: ListedItem,\n runtimeFieldRegistry: RuntimeFieldRegistry,\n update: UpdateCommandOptions = {},\n): PlannedItemDiff => {\n const row = toItemRecord(item);\n const changes: PlannedChange[] = [];\n const warnings: string[] = [];\n const tagPlan = buildTagMutationPlan(row, update);\n if (tagPlan) {\n changes.push(tagPlan);\n }\n appendScalarMutationPlans(changes, row, update);\n if (\n updateArrayValueCount(update.addAc) > 0 ||\n updateArrayValueCount(update.removeAc) > 0\n ) {\n const composed = buildAcceptanceCriteriaMutationPlan(row, update);\n const withoutAc = changes.filter(\n (change) => change.field !== \"acceptance_criteria\",\n );\n changes.splice(0, changes.length, ...withoutAc);\n if (composed.change !== undefined) {\n changes.push(composed.change);\n }\n warnings.push(...composed.warnings);\n }\n changes.push(...buildCollectionMutationPlans(row, update));\n appendRuntimeFieldMutationPlans(changes, row, update, runtimeFieldRegistry);\n appendUnsetMutationPlans(changes, row, update.unset);\n\n return {\n id: item.id,\n changes,\n ...(warnings.length > 0 ? { warnings } : {}),\n };\n};\n\n/** Normalizes an optional list status against the runtime schema. */\nconst normalizeStatusFilter = (\n value: string | undefined,\n statusRegistry: RuntimeStatusRegistry,\n): ItemStatus | undefined => {\n if (value === undefined) {\n return undefined;\n }\n const normalized = normalizeStatusInput(value, statusRegistry);\n if (!normalized) {\n const allowedStatuses = statusRegistry.definitions.map(\n (definition) => definition.id,\n );\n throw new PmCliError(\n `Invalid --filter-status value \"${value}\". Allowed: ${allowedStatuses.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n return normalized;\n};\n\n/** Rejects an explicitly blank bulk ID filter before loading the corpus. */\nconst rejectBlankIdsFilter = (list: ListOptions | undefined): void => {\n if (list?.ids != null && String(list.ids).trim().length === 0) {\n throw new PmCliError(\n \"--ids requires at least one non-empty item ID\",\n EXIT_CODE.USAGE,\n );\n }\n};\n\n// GH-256: validate planned scalar enum/format fields up front so a `--dry-run`\n// preview rejects globally-invalid values exactly as apply would (true\n// preview==apply parity), and so apply itself fails fast before creating an\n// orphan checkpoint. Only VALUE/ENUM/FORMAT correctness is checked here — these\n// are invalid regardless of the matched item. Per-item governance and\n// workflow-transition rules stay in the apply path (runUpdate). Each field is\n// validated only when the caller actually provided it, reusing the exact same\n// resolvers and error messages runUpdate raises so single/bulk/dry-run stay\n// consistent.\ninterface PlannedUpdateValidationContext {\n update: UpdateCommandOptions;\n settings: PmSettings;\n statusRegistry: RuntimeStatusRegistry;\n pmRoot: string;\n}\n\ntype PlannedUpdateValidator = (context: PlannedUpdateValidationContext) => void;\n\nconst PLANNED_UPDATE_VALIDATORS: PlannedUpdateValidator[] = [\n ({ update }) => {\n if (update.priority !== undefined) {\n resolvePriority(update.priority);\n }\n },\n ({ update, settings, pmRoot }) => {\n if (update.type === undefined) {\n return;\n }\n const typeRegistry = resolveItemTypeRegistry(\n settings,\n getActiveExtensionRegistrations(),\n );\n if (!resolveTypeName(update.type, typeRegistry)) {\n throw new PmCliError(\n buildInvalidTypeError(\n update.type,\n typeRegistry.types,\n resolveItemTypesFilePath(pmRoot, settings.schema),\n ),\n EXIT_CODE.USAGE,\n );\n }\n },\n ({ update, statusRegistry }) => {\n if (\n update.status !== undefined &&\n !normalizeStatusInput(update.status, statusRegistry)\n ) {\n const allowedStatuses = statusRegistry.definitions.map(\n (definition) => definition.id,\n );\n throw new PmCliError(\n `Invalid --status value \"${update.status}\". Allowed: ${allowedStatuses.join(\", \")}`,\n EXIT_CODE.USAGE,\n );\n }\n },\n ({ update }) => {\n if (update.deadline !== undefined) {\n resolveIsoOrRelative(update.deadline, new Date(), \"deadline\");\n }\n },\n ({ update }) => {\n if (update.estimatedMinutes !== undefined) {\n parseOptionalNonNegativeInteger(\n update.estimatedMinutes,\n \"estimated-minutes\",\n );\n }\n },\n];\n\n/** Validates globally invalid mutation values before preview or checkpoint work. */\nconst assertPlannedUpdateValuesValid = (\n update: UpdateCommandOptions,\n settings: PmSettings,\n statusRegistry: RuntimeStatusRegistry,\n pmRoot: string,\n): void => {\n const context = { update, settings, statusRegistry, pmRoot };\n for (const validate of PLANNED_UPDATE_VALIDATORS) {\n validate(context);\n }\n};\n\n/** Restores every item captured by an update-many checkpoint. */\nconst runUpdateManyRollback = async (params: {\n pmRoot: string;\n rollbackId: string;\n options: UpdateManyCommandOptions;\n global: GlobalOptions;\n}): Promise<UpdateManyResult> => {\n const checkpoint = await loadMutationCheckpoint(\n params.pmRoot,\n UPDATE_MANY_CHECKPOINT_SUBDIR,\n params.rollbackId,\n UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION,\n );\n const restoreMessage =\n params.options.update?.message ??\n `Rollback update-many checkpoint ${checkpoint.id}`;\n const rollback = await restoreCheckpointItems(\n checkpoint.items,\n (id, targetUpdatedAt) =>\n runRestore(\n id,\n targetUpdatedAt,\n {\n author: params.options.update?.author,\n message: restoreMessage,\n force: params.options.update?.force ?? true,\n },\n params.global,\n ),\n );\n return {\n mode: \"rollback\",\n matched_count: checkpoint.items.length,\n dry_run: false,\n rollback_checkpoint_id: checkpoint.id,\n checkpoint: {\n id: checkpoint.id,\n created_at: checkpoint.created_at,\n path: checkpoint.path,\n rollback_command: `pm update-many --rollback ${checkpoint.id}`,\n },\n restored_count: rollback.restored_ids.length,\n failed_count: rollback.failed_count,\n rows: rollback.rows,\n ids: rollback.restored_ids,\n };\n};\n\n/** Persists an apply checkpoint and returns its user-facing descriptor. */\nconst writeUpdateManyCheckpoint = async (params: {\n pmRoot: string;\n checkpointId: string;\n nowValue: string;\n options: UpdateManyCommandOptions;\n statusFilter: string | undefined;\n filters: Record<string, unknown>;\n updateSummary: Record<string, unknown>;\n checkpointItems: MutationCheckpointItem[];\n}): Promise<UpdateManyResult[\"checkpoint\"]> => {\n const checkpointPayload: UpdateManyCheckpoint = {\n schema_version: UPDATE_MANY_CHECKPOINT_SCHEMA_VERSION,\n id: params.checkpointId,\n created_at: params.nowValue,\n author: resolveAuthor(params.options.update?.author, \"unknown\"),\n status_filter: params.statusFilter ?? null,\n list_filters: params.filters,\n update_options: params.updateSummary,\n items: params.checkpointItems,\n };\n const checkpointPath = await writeMutationCheckpoint(\n params.pmRoot,\n UPDATE_MANY_CHECKPOINT_SUBDIR,\n params.checkpointId,\n checkpointPayload,\n );\n return {\n id: params.checkpointId,\n created_at: params.nowValue,\n path: checkpointPath,\n rollback_command: `pm update-many --rollback ${params.checkpointId}`,\n };\n};\n\ninterface UpdateManyRuntimeContext {\n pmRoot: string;\n settings: PmSettings;\n statusRegistry: RuntimeStatusRegistry;\n runtimeFieldRegistry: RuntimeFieldRegistry;\n}\n\ninterface UpdateManyPlan {\n listed: ListFullResult;\n planned: PlannedItemDiff[];\n actionable: PlannedItemDiff[];\n updateSummary: Record<string, unknown>;\n statusFilter: ItemStatus | undefined;\n unmatchedIds: string[] | undefined;\n}\n\n// GH-596: an explicit --ids request naming IDs that do not exist must stay\n// machine-detectable without client-side set differencing. The requested list\n// is re-derived here (same CSV split as the list filter) and compared against\n// the unfiltered storage corpus so pagination and additional query filters do\n// not misclassify existing items as nonexistent.\nconst collectUnmatchedRequestedIds = (\n rawIds: unknown,\n existingItems: ReadonlyArray<{ id: string }>,\n): string[] | undefined => {\n if (rawIds == null) {\n return undefined;\n }\n const requested = [\n ...new Set(\n String(rawIds)\n .split(\",\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0),\n ),\n ];\n const existing = new Set(existingItems.map((item) => item.id));\n return requested.filter((id) => !existing.has(id));\n};\n\n/** Builds the shared unmatched-id envelope fields for one prepared plan. */\nconst buildUnmatchedIdFields = (\n plan: UpdateManyPlan,\n): Pick<UpdateManyResult, \"unmatched_ids\" | \"unmatched_count\"> =>\n plan.unmatchedIds === undefined\n ? {}\n : {\n unmatched_ids: plan.unmatchedIds,\n unmatched_count: plan.unmatchedIds.length,\n };\n\n/** Loads tracker settings and runtime registries for update-many execution. */\nconst loadUpdateManyRuntimeContext = async (\n global: GlobalOptions,\n): Promise<UpdateManyRuntimeContext> => {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(\n `Tracker is not initialized at ${pmRoot}. Run pm init first.`,\n EXIT_CODE.NOT_FOUND,\n );\n }\n const settings = await readSettings(pmRoot);\n return {\n pmRoot,\n settings,\n statusRegistry: resolveRuntimeStatusRegistry(settings.schema),\n runtimeFieldRegistry: resolveRuntimeFieldRegistry(settings.schema),\n };\n};\n\n/** Validates rollback exclusivity before restoring a checkpoint. */\nconst runRequestedUpdateManyRollback = (params: {\n runtime: UpdateManyRuntimeContext;\n rollbackId: string;\n options: UpdateManyCommandOptions;\n global: GlobalOptions;\n updateSummary: Record<string, unknown>;\n}): Promise<UpdateManyResult> => {\n if (params.options.dryRun === true) {\n throw new PmCliError(\n \"--dry-run cannot be combined with --rollback\",\n EXIT_CODE.USAGE,\n );\n }\n if (hasListFilters(params.options.list, params.options.status)) {\n throw new PmCliError(\n \"Rollback mode does not accept filter options\",\n EXIT_CODE.USAGE,\n );\n }\n if (Object.keys(params.updateSummary).length > 0) {\n throw new PmCliError(\n \"Rollback mode does not accept update mutation flags\",\n EXIT_CODE.USAGE,\n );\n }\n return runUpdateManyRollback({\n pmRoot: params.runtime.pmRoot,\n rollbackId: params.rollbackId,\n options: params.options,\n global: params.global,\n });\n};\n\n/** Loads complete matching rows and derives their mutation previews. */\nconst buildUpdateManyPlan = async (params: {\n options: UpdateManyCommandOptions;\n global: GlobalOptions;\n runtime: UpdateManyRuntimeContext;\n updateSummary: Record<string, unknown>;\n}): Promise<UpdateManyPlan> => {\n const statusFilter = normalizeStatusFilter(\n params.options.status,\n params.runtime.statusRegistry,\n );\n const listed = await runList(\n statusFilter,\n {\n ...params.options.list,\n compact: undefined,\n brief: undefined,\n fields: undefined,\n includeBody: true,\n full: true,\n },\n params.global,\n );\n const planned = listed.items.map((item) =>\n buildPlannedItemDiff(\n item,\n params.runtime.runtimeFieldRegistry,\n params.options.update,\n ),\n );\n const existenceItems =\n params.options.list?.ids == null\n ? []\n : (\n await runList(\n undefined,\n {\n ids: params.options.list.ids,\n noTruncate: true,\n full: true,\n },\n params.global,\n )\n ).items;\n return {\n listed,\n planned,\n actionable: planned.filter((row) => row.changes.length > 0),\n updateSummary: params.updateSummary,\n statusFilter,\n unmatchedIds: collectUnmatchedRequestedIds(\n params.options.list?.ids,\n existenceItems,\n ),\n };\n};\n\n/** Builds the non-mutating preview response for a prepared update-many plan. */\nconst buildUpdateManyDryRunResult = (\n plan: UpdateManyPlan,\n): UpdateManyResult => ({\n mode: \"dry_run\",\n matched_count: plan.listed.items.length,\n dry_run: true,\n filters: plan.listed.filters,\n planned_update_options: plan.updateSummary,\n item_plans: plan.planned,\n ids: [],\n ...buildUnmatchedIdFields(plan),\n});\n\n/** Builds the apply response for a plan whose rows are all already current. */\nconst buildUpdateManyNoopResult = (plan: UpdateManyPlan): UpdateManyResult => ({\n mode: \"apply\",\n matched_count: plan.listed.items.length,\n dry_run: false,\n filters: plan.listed.filters,\n planned_update_options: plan.updateSummary,\n updated_count: 0,\n skipped_count: plan.listed.items.length,\n failed_count: 0,\n rows: plan.planned.map((row) => ({\n id: row.id,\n status: \"skipped\" as const,\n ...(row.warnings ? { warnings: row.warnings } : {}),\n })),\n ids: [],\n ...buildUnmatchedIdFields(plan),\n});\n\n/** Applies planned item updates independently while preserving per-row failures. */\nconst applyUpdateManyRows = async (params: {\n items: ListedItem[];\n plans: PlannedItemDiff[];\n options: UpdateManyCommandOptions;\n global: GlobalOptions;\n checkpointId: string;\n}): Promise<{ rows: UpdateManyApplyResultRow[]; updatedIds: string[] }> => {\n const rows: UpdateManyApplyResultRow[] = [];\n const updatedIds: string[] = [];\n const updateMessage =\n params.options.update.message ?? `update-many apply ${params.checkpointId}`;\n const plannedById = new Map(params.plans.map((row) => [row.id, row]));\n const actionableById = new Set(\n params.plans.filter((row) => row.changes.length > 0).map((row) => row.id),\n );\n for (const item of params.items) {\n if (!actionableById.has(item.id)) {\n const warnings = plannedById.get(item.id)?.warnings;\n rows.push({\n id: item.id,\n status: \"skipped\",\n ...(warnings ? { warnings } : {}),\n });\n continue;\n }\n try {\n const result = await runUpdate(\n item.id,\n {\n ...params.options.update,\n message: updateMessage,\n runtimeFieldCommands: [\"update_many\"],\n },\n params.global,\n );\n rows.push({\n id: item.id,\n status: \"updated\",\n changed_fields: result.changed_fields,\n warnings: result.warnings,\n });\n updatedIds.push(item.id);\n } catch (error: unknown) {\n rows.push({\n id: item.id,\n status: \"failed\",\n error: toErrorMessage(error),\n });\n }\n }\n return { rows, updatedIds };\n};\n\n/** Applies a prepared plan, checkpointing actionable rows when requested. */\nconst applyUpdateManyPlan = async (params: {\n runtime: UpdateManyRuntimeContext;\n options: UpdateManyCommandOptions;\n global: GlobalOptions;\n plan: UpdateManyPlan;\n}): Promise<UpdateManyResult> => {\n if (params.plan.actionable.length === 0) {\n return buildUpdateManyNoopResult(params.plan);\n }\n const nowValue = nowIso();\n const checkpointId = createCheckpointId(\n UPDATE_MANY_CHECKPOINT_SUBDIR,\n nowValue,\n );\n const actionableById = new Set(params.plan.actionable.map((row) => row.id));\n const checkpointItems = params.plan.listed.items\n .filter((item) => actionableById.has(item.id))\n .map((item) => ({ id: item.id, target_updated_at: item.updated_at }));\n const checkpointInfo =\n params.options.checkpoint === false\n ? undefined\n : await writeUpdateManyCheckpoint({\n pmRoot: params.runtime.pmRoot,\n checkpointId,\n nowValue,\n options: params.options,\n statusFilter: params.plan.statusFilter,\n filters: params.plan.listed.filters,\n updateSummary: params.plan.updateSummary,\n checkpointItems,\n });\n const applied = await applyUpdateManyRows({\n items: params.plan.listed.items,\n plans: params.plan.planned,\n options: params.options,\n global: params.global,\n checkpointId,\n });\n /** Counts apply rows with one terminal status. */\n const countStatus = (status: UpdateManyApplyResultRow[\"status\"]): number =>\n applied.rows.filter((row) => row.status === status).length;\n return {\n mode: \"apply\",\n matched_count: params.plan.listed.items.length,\n dry_run: false,\n filters: params.plan.listed.filters,\n planned_update_options: params.plan.updateSummary,\n ...(checkpointInfo ? { checkpoint: checkpointInfo } : {}),\n updated_count: countStatus(\"updated\"),\n skipped_count: countStatus(\"skipped\"),\n failed_count: countStatus(\"failed\"),\n rows: applied.rows,\n ids: applied.updatedIds,\n ...buildUnmatchedIdFields(params.plan),\n };\n};\n\n/** Implements run update many for the public runtime surface of this module. */\nexport const runUpdateMany = async (\n options: UpdateManyCommandOptions,\n global: GlobalOptions,\n): Promise<UpdateManyResult> => {\n const runtime = await loadUpdateManyRuntimeContext(global);\n const rollbackId =\n typeof options.rollback === \"string\" ? options.rollback : undefined;\n const updateSummary = sanitizeUpdateOptionsForSummary(options.update);\n rejectBlankIdsFilter(options.list);\n if (rollbackId !== undefined) {\n return runRequestedUpdateManyRollback({\n runtime,\n rollbackId,\n options,\n global,\n updateSummary,\n });\n }\n if (!hasAnyUpdateMutationInput(options.update)) {\n throw new PmCliError(\n `No update-many mutation flags provided. Add at least one mutation flag (for example: ${UPDATE_MANY_MUTATION_FLAG_GUIDANCE}).`,\n EXIT_CODE.USAGE,\n );\n }\n assertPlannedUpdateValuesValid(\n options.update,\n runtime.settings,\n runtime.statusRegistry,\n runtime.pmRoot,\n );\n const plan = await buildUpdateManyPlan({\n options,\n global,\n runtime,\n updateSummary,\n });\n return options.dryRun === true\n ? buildUpdateManyDryRunResult(plan)\n : applyUpdateManyPlan({ runtime, options, global, plan });\n};\n\n/** Public contract for test only update many command, shared by SDK and presentation-layer consumers. */\nexport const _testOnlyUpdateManyCommand = {\n assertPlannedUpdateValuesValid,\n buildCollectionMutationPlans,\n buildPlannedItemDiff,\n buildTagMutationPlan,\n collectionValueCount,\n hasAnyUpdateMutationInput,\n hasListFilters,\n normalizeStatusFilter,\n normalizeCollectionBeforeValue,\n normalizeExistingTags,\n normalizeUnsetField,\n rejectBlankIdsFilter,\n sanitizeUpdateOptionsForSummary,\n toComparablePreviewValue,\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,IAAM,wCAAwC;AAC9C,IAAM,gCAAgC;AAEtC,IAAM,kCAAkC,oBAAI,IAAiB;EAC3D;EACA;EACA;EACA;EACA;CACD;AAED,IAAM,qCAAqC;EACzC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,KAAK,IAAI;AAEX,IAAM,4BAEF;EACF,OAAO;EACP,aAAa;EACb,MAAM;EACN,QAAQ;EACR,aAAa;EACb,UAAU;EACV,MAAM;EACN,UAAU;EACV,kBAAkB;EAClB,oBAAoB;EACpB,mBAAmB;EACnB,OAAO;EAC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BAA6B,MAAM;AACzD,QAAM,aACJ,OAAO,QAAQ,aAAa,WAAW,QAAQ,WAAW;AAC5D,QAAM,gBAAgB,gCAAgC,QAAQ,MAAM;AACpE,uBAAqB,QAAQ,IAAI;AACjC,MAAI,eAAe,QAAW;AAC5B,WAAO,+BAA+B;MACpC;MACA;MACA;MACA;MACA;KACD;EACH;AACA,MAAI,CAAC,0BAA0B,QAAQ,MAAM,GAAG;AAC9C,UAAM,IAAI,WACR,wFAAwF,kCAAkC,MAC1H,UAAU,KAAK;EAEnB;AACA,iCACE,QAAQ,QACR,QAAQ,UACR,QAAQ,gBACR,QAAQ,MAAM;AAEhB,QAAM,OAAO,MAAM,oBAAoB;IACrC;IACA;IACA;IACA;GACD;AACD,SAAO,QAAQ,WAAW,OACtB,4BAA4B,IAAI,IAChC,oBAAoB,EAAE,SAAS,SAAS,QAAQ,KAAI,CAAE;AAC5D;AAGO,IAAM,6BAA6B;EACxC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA","debugId":"f8bceeab-61dc-5e2c-a62c-851a6ed5cd49"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalDocument,
|
|
3
|
+
hashDocument,
|
|
4
|
+
orderObject,
|
|
5
|
+
sha256Hex,
|
|
6
|
+
stableStringify,
|
|
7
|
+
toItemRecord
|
|
8
|
+
} from "./chunk-IY6VZ3IW.js";
|
|
9
|
+
import {
|
|
10
|
+
ITEM_METADATA_KEY_ORDER
|
|
11
|
+
} from "./chunk-7AVEY74G.js";
|
|
12
|
+
|
|
13
|
+
// dist/core/history/replay.js
|
|
14
|
+
import jsonPatch from "fast-json-patch";
|
|
15
|
+
!(function() {
|
|
16
|
+
try {
|
|
17
|
+
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
18
|
+
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "870cc300-69e5-5207-a84a-9dc346628044");
|
|
19
|
+
} catch (e2) {
|
|
20
|
+
}
|
|
21
|
+
})();
|
|
22
|
+
var EMPTY_REPLAY_DOCUMENT = {
|
|
23
|
+
metadata: {},
|
|
24
|
+
body: ""
|
|
25
|
+
};
|
|
26
|
+
function cloneEmptyReplayDocument() {
|
|
27
|
+
return structuredClone(EMPTY_REPLAY_DOCUMENT);
|
|
28
|
+
}
|
|
29
|
+
function replayHash(document) {
|
|
30
|
+
try {
|
|
31
|
+
return hashDocument(replayToItemDocument(document));
|
|
32
|
+
} catch {
|
|
33
|
+
return sha256Hex(stableStringify({
|
|
34
|
+
replay_fallback: true,
|
|
35
|
+
metadata: document.metadata,
|
|
36
|
+
body: document.body
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function replayToItemDocument(document) {
|
|
41
|
+
return {
|
|
42
|
+
metadata: document.metadata,
|
|
43
|
+
body: document.body
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function replayToCanonicalItemDocument(document, options = {}) {
|
|
47
|
+
return canonicalDocument(replayToItemDocument(document), options);
|
|
48
|
+
}
|
|
49
|
+
function toReplayDocument(document) {
|
|
50
|
+
if (!document.metadata || Object.keys(document.metadata).length === 0) {
|
|
51
|
+
return {
|
|
52
|
+
metadata: {},
|
|
53
|
+
body: document.body ?? ""
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const canonical = canonicalDocument(document);
|
|
57
|
+
return {
|
|
58
|
+
metadata: orderObject(toItemRecord(canonical.metadata), ITEM_METADATA_KEY_ORDER),
|
|
59
|
+
body: canonical.body
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function normalizeReplayPatchPath(path) {
|
|
63
|
+
if (path === "/front_matter") {
|
|
64
|
+
return "/metadata";
|
|
65
|
+
}
|
|
66
|
+
if (path.startsWith("/front_matter/")) {
|
|
67
|
+
return `/metadata/${path.slice("/front_matter/".length)}`;
|
|
68
|
+
}
|
|
69
|
+
return path;
|
|
70
|
+
}
|
|
71
|
+
function isHistoryPatchOp(value) {
|
|
72
|
+
return typeof value === "object" && value !== null && typeof value.op === "string" && typeof value.path === "string";
|
|
73
|
+
}
|
|
74
|
+
function normalizeReplayPatchOps(patch) {
|
|
75
|
+
if (!Array.isArray(patch)) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
return patch.filter(isHistoryPatchOp).map((operation) => ({
|
|
79
|
+
...operation,
|
|
80
|
+
path: normalizeReplayPatchPath(operation.path),
|
|
81
|
+
from: typeof operation.from === "string" ? normalizeReplayPatchPath(operation.from) : void 0
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
function isReplayDocumentShape(value) {
|
|
85
|
+
return typeof value === "object" && value !== null && "metadata" in value && "body" in value && typeof value.body === "string" && typeof value.metadata === "object" && value.metadata !== null;
|
|
86
|
+
}
|
|
87
|
+
function tryApplyReplayPatch(current, patch) {
|
|
88
|
+
try {
|
|
89
|
+
const normalizedPatch = normalizeReplayPatchOps(patch);
|
|
90
|
+
const applied = jsonPatch.applyPatch(structuredClone(current), normalizedPatch, true, false).newDocument;
|
|
91
|
+
if (!isReplayDocumentShape(applied)) {
|
|
92
|
+
return {
|
|
93
|
+
ok: false,
|
|
94
|
+
error: new Error("history_replay_invalid_document_shape")
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
ok: true,
|
|
99
|
+
document: { metadata: applied.metadata, body: applied.body }
|
|
100
|
+
};
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return { ok: false, error };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function verifyHistoryChain(entries) {
|
|
106
|
+
let replay = cloneEmptyReplayDocument();
|
|
107
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
108
|
+
const entry = entries[index];
|
|
109
|
+
if (replayHash(replay) !== entry.before_hash) {
|
|
110
|
+
return {
|
|
111
|
+
ok: false,
|
|
112
|
+
errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`]
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const applied = tryApplyReplayPatch(replay, entry.patch);
|
|
116
|
+
if (!applied.ok) {
|
|
117
|
+
return {
|
|
118
|
+
ok: false,
|
|
119
|
+
errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
replay = applied.document;
|
|
123
|
+
if (replayHash(replay) !== entry.after_hash) {
|
|
124
|
+
return {
|
|
125
|
+
ok: false,
|
|
126
|
+
errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`]
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { ok: true, errors: [] };
|
|
131
|
+
}
|
|
132
|
+
function tryApplySingleOp(document, op) {
|
|
133
|
+
try {
|
|
134
|
+
const applied = jsonPatch.applyPatch(structuredClone(document), [op], true, false).newDocument;
|
|
135
|
+
return { ok: true, document: applied };
|
|
136
|
+
} catch {
|
|
137
|
+
return { ok: false };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function lenientApplyReplayPatch(current, patch) {
|
|
141
|
+
let working = structuredClone(current);
|
|
142
|
+
let convertedReplaceToAdd = 0;
|
|
143
|
+
let skippedOps = 0;
|
|
144
|
+
for (const op of normalizeReplayPatchOps(patch)) {
|
|
145
|
+
const direct = tryApplySingleOp(working, op);
|
|
146
|
+
if (direct.ok) {
|
|
147
|
+
working = direct.document;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (op.op === "replace") {
|
|
151
|
+
const asAdd = tryApplySingleOp(working, { ...op, op: "add" });
|
|
152
|
+
if (asAdd.ok) {
|
|
153
|
+
working = asAdd.document;
|
|
154
|
+
convertedReplaceToAdd += 1;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
skippedOps += 1;
|
|
159
|
+
}
|
|
160
|
+
const candidate = working;
|
|
161
|
+
const document = {
|
|
162
|
+
metadata: typeof candidate.metadata === "object" && candidate.metadata !== null ? candidate.metadata : {},
|
|
163
|
+
body: typeof candidate.body === "string" ? candidate.body : current.body
|
|
164
|
+
};
|
|
165
|
+
return { document, convertedReplaceToAdd, skippedOps };
|
|
166
|
+
}
|
|
167
|
+
function reanchorHistoryEntries(entries) {
|
|
168
|
+
let replay = cloneEmptyReplayDocument();
|
|
169
|
+
const rewritten = [];
|
|
170
|
+
const details = [];
|
|
171
|
+
let entriesRehashed = 0;
|
|
172
|
+
let entriesPatchRepaired = 0;
|
|
173
|
+
let convertedReplaceToAdd = 0;
|
|
174
|
+
let skippedOps = 0;
|
|
175
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
176
|
+
const entry = entries[index];
|
|
177
|
+
const beforeHash = replayHash(replay);
|
|
178
|
+
const strict = tryApplyReplayPatch(replay, entry.patch);
|
|
179
|
+
let next;
|
|
180
|
+
let outPatch;
|
|
181
|
+
let patchRepaired = false;
|
|
182
|
+
let entryConverted = 0;
|
|
183
|
+
let entrySkipped = 0;
|
|
184
|
+
if (strict.ok) {
|
|
185
|
+
next = strict.document;
|
|
186
|
+
outPatch = entry.patch;
|
|
187
|
+
} else {
|
|
188
|
+
const lenient = lenientApplyReplayPatch(replay, entry.patch);
|
|
189
|
+
next = lenient.document;
|
|
190
|
+
outPatch = jsonPatch.compare(replay, next);
|
|
191
|
+
patchRepaired = true;
|
|
192
|
+
entryConverted = lenient.convertedReplaceToAdd;
|
|
193
|
+
entrySkipped = lenient.skippedOps;
|
|
194
|
+
convertedReplaceToAdd += entryConverted;
|
|
195
|
+
skippedOps += entrySkipped;
|
|
196
|
+
entriesPatchRepaired += 1;
|
|
197
|
+
}
|
|
198
|
+
const afterHash = replayHash(next);
|
|
199
|
+
const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;
|
|
200
|
+
if (rehashed) {
|
|
201
|
+
entriesRehashed += 1;
|
|
202
|
+
}
|
|
203
|
+
rewritten.push({
|
|
204
|
+
...entry,
|
|
205
|
+
patch: outPatch,
|
|
206
|
+
before_hash: beforeHash,
|
|
207
|
+
after_hash: afterHash
|
|
208
|
+
});
|
|
209
|
+
details.push({
|
|
210
|
+
index: index + 1,
|
|
211
|
+
rehashed,
|
|
212
|
+
patch_repaired: patchRepaired,
|
|
213
|
+
converted_replace_to_add: entryConverted,
|
|
214
|
+
skipped_ops: entrySkipped
|
|
215
|
+
});
|
|
216
|
+
replay = next;
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
entries: rewritten,
|
|
220
|
+
finalDocument: replay,
|
|
221
|
+
entriesRehashed,
|
|
222
|
+
entriesPatchRepaired,
|
|
223
|
+
convertedReplaceToAdd,
|
|
224
|
+
skippedOps,
|
|
225
|
+
details
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function historyEntriesToRaw(entries) {
|
|
229
|
+
if (entries.length === 0) {
|
|
230
|
+
return "";
|
|
231
|
+
}
|
|
232
|
+
return `${entries.map((entry) => JSON.stringify(entry)).join("\n")}
|
|
233
|
+
`;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
EMPTY_REPLAY_DOCUMENT,
|
|
238
|
+
cloneEmptyReplayDocument,
|
|
239
|
+
replayHash,
|
|
240
|
+
replayToItemDocument,
|
|
241
|
+
replayToCanonicalItemDocument,
|
|
242
|
+
toReplayDocument,
|
|
243
|
+
normalizeReplayPatchOps,
|
|
244
|
+
tryApplyReplayPatch,
|
|
245
|
+
verifyHistoryChain,
|
|
246
|
+
reanchorHistoryEntries,
|
|
247
|
+
historyEntriesToRaw
|
|
248
|
+
};
|
|
249
|
+
//# sourceMappingURL=chunk-E6LEMURX.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../core/history/replay.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @module core/history/replay\n *\n * Implements append-only history and replay behavior for Replay.\n */\nimport jsonPatch from \"fast-json-patch\";\nimport { ITEM_METADATA_KEY_ORDER } from \"../shared/constants.js\";\nimport { canonicalDocument } from \"../item/item-format.js\";\nimport { toItemRecord } from \"../item/item-record.js\";\nimport {\n orderObject,\n sha256Hex,\n stableStringify,\n} from \"../shared/serialization.js\";\nimport { hashDocument } from \"./history.js\";\nimport type {\n HistoryEntry,\n HistoryPatchOp,\n ItemDocument,\n ItemMetadata,\n} from \"../../types/index.js\";\n\n/**\n * Shared history replay/patch mechanics single-sourced for the history, restore,\n * history-redact, and history-repair commands plus the health/validate drift checks.\n *\n * Each command keeps its own thin error-formatting wrapper so the exact CLI error\n * contracts (restore's rich patch-failure context, redact's op tag, history's\n * generic message) are preserved; only the underlying replay/patch logic is shared.\n */\n\nexport interface ReplayDocument {\n /** Value that configures or reports metadata for this contract. */\n metadata: Record<string, unknown>;\n /** Value that configures or reports body for this contract. */\n body: string;\n}\n\n/** Public contract for empty replay document, shared by SDK and presentation-layer consumers. */\nexport const EMPTY_REPLAY_DOCUMENT: ReplayDocument = {\n metadata: {},\n body: \"\",\n};\n\n/** Implements clone empty replay document for the public runtime surface of this module. */\nexport function cloneEmptyReplayDocument(): ReplayDocument {\n return structuredClone(EMPTY_REPLAY_DOCUMENT);\n}\n\n/** Implements replay hash for the public runtime surface of this module. */\nexport function replayHash(document: ReplayDocument): string {\n try {\n return hashDocument(replayToItemDocument(document));\n } catch {\n // Legacy/malformed replay states (for example a stream whose first entry never\n // established a full `create` document, so the canonicalizer cannot normalize it)\n // cannot be canonically hashed. Fall back to a deterministic structural hash so\n // re-anchor and verification stay internally consistent for these streams. Fully\n // formed documents always take the canonical path above, so valid streams are\n // unaffected.\n return sha256Hex(\n stableStringify({\n replay_fallback: true,\n metadata: document.metadata,\n body: document.body,\n }),\n );\n }\n}\n\n/** Implements replay to item document for the public runtime surface of this module. */\nexport function replayToItemDocument(document: ReplayDocument): ItemDocument {\n return {\n metadata: document.metadata as ItemMetadata,\n body: document.body,\n };\n}\n\n/** Converts a materialized replay document into a canonical item document. Use this when callers have already rejected the empty/deleted replay state and need restored metadata validated through the normal item-metadata rules. */\nexport function replayToCanonicalItemDocument(\n document: ReplayDocument,\n options: Parameters<typeof canonicalDocument>[1] = {},\n): ItemDocument {\n return canonicalDocument(replayToItemDocument(document), options);\n}\n\n/** Canonicalize an item document into the ordered replay form used when comparing a replayed chain against the on-disk item (restore + history-repair reconciliation). */\nexport function toReplayDocument(document: ItemDocument): ReplayDocument {\n if (!document.metadata || Object.keys(document.metadata).length === 0) {\n return {\n metadata: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n return {\n metadata: orderObject(\n toItemRecord(canonical.metadata),\n ITEM_METADATA_KEY_ORDER,\n ),\n body: canonical.body,\n };\n}\n\n/** Implements normalize replay patch path for the public runtime surface of this module. */\nexport function normalizeReplayPatchPath(path: string): string {\n if (path === \"/front_matter\") {\n return \"/metadata\";\n }\n if (path.startsWith(\"/front_matter/\")) {\n return `/metadata/${path.slice(\"/front_matter/\".length)}`;\n }\n return path;\n}\n\nfunction isHistoryPatchOp(value: unknown): value is HistoryPatchOp {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { op?: unknown }).op === \"string\" &&\n typeof (value as { path?: unknown }).path === \"string\"\n );\n}\n\n/** Implements normalize replay patch ops for the public runtime surface of this module. */\nexport function normalizeReplayPatchOps(\n patch: HistoryPatchOp[] | unknown,\n): HistoryPatchOp[] {\n if (!Array.isArray(patch)) {\n return [];\n }\n return patch.filter(isHistoryPatchOp).map((operation) => ({\n ...operation,\n path: normalizeReplayPatchPath(operation.path),\n from:\n typeof operation.from === \"string\"\n ? normalizeReplayPatchPath(operation.from)\n : undefined,\n }));\n}\n\nfunction isReplayDocumentShape(\n value: unknown,\n): value is { metadata: Record<string, unknown>; body: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"metadata\" in value &&\n \"body\" in value &&\n typeof (value as { body: unknown }).body === \"string\" &&\n typeof (value as { metadata: unknown }).metadata === \"object\" &&\n (value as { metadata: unknown }).metadata !== null\n );\n}\n\n/** Restricts replay apply result values accepted by command, SDK, and storage contracts. */\nexport type ReplayApplyResult =\n | { ok: true; document: ReplayDocument }\n | { ok: false; error: unknown };\n\n/** Strictly apply a history patch (front_matter->metadata normalized) to a replay document. Returns a result envelope rather than throwing so each caller can format its own error contract. */\nexport function tryApplyReplayPatch(\n current: ReplayDocument,\n patch: HistoryPatchOp[],\n): ReplayApplyResult {\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 (!isReplayDocumentShape(applied)) {\n return {\n ok: false,\n error: new Error(\"history_replay_invalid_document_shape\"),\n };\n }\n return {\n ok: true,\n document: { metadata: applied.metadata, body: applied.body },\n };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/** Deterministically verify a history chain: each entry's before_hash must equal the prior replayed after_hash, the patch must strictly apply, and the recorded after_hash must equal the replayed result. */\nexport function verifyHistoryChain(entries: HistoryEntry[]): {\n ok: boolean;\n errors: string[];\n} {\n let replay = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n return {\n ok: false,\n errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],\n };\n }\n const applied = tryApplyReplayPatch(replay, entry.patch);\n if (!applied.ok) {\n return {\n ok: false,\n errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],\n };\n }\n replay = applied.document;\n if (replayHash(replay) !== entry.after_hash) {\n return {\n ok: false,\n errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],\n };\n }\n }\n return { ok: true, errors: [] };\n}\n\n/** Documents the lenient apply result payload exchanged by command, SDK, and package integrations. */\nexport interface LenientApplyResult {\n /** Value that configures or reports document for this contract. */\n document: ReplayDocument;\n /** Value that configures or reports converted replace to add for this contract. */\n convertedReplaceToAdd: number;\n /** Value that configures or reports skipped ops for this contract. */\n skippedOps: number;\n}\n\nfunction tryApplySingleOp(\n document: unknown,\n op: HistoryPatchOp,\n): { ok: true; document: unknown } | { ok: false } {\n try {\n const applied = jsonPatch.applyPatch(\n structuredClone(document),\n [op as jsonPatch.Operation],\n true,\n false,\n ).newDocument as unknown;\n return { ok: true, document: applied };\n } catch {\n return { ok: false };\n }\n}\n\n/** Apply a legacy patch op-by-op, recovering from drift that strict replay rejects: a `replace` whose path no longer exists is retried as `add`, and any op that still cannot apply against the current replay state is skipped. The resulting document is what the repaired entry's recomputed patch should target. */\nexport function lenientApplyReplayPatch(\n current: ReplayDocument,\n patch: HistoryPatchOp[],\n): LenientApplyResult {\n let working: unknown = structuredClone(current);\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (const op of normalizeReplayPatchOps(patch)) {\n const direct = tryApplySingleOp(working, op);\n if (direct.ok) {\n working = direct.document;\n continue;\n }\n if (op.op === \"replace\") {\n const asAdd = tryApplySingleOp(working, { ...op, op: \"add\" });\n if (asAdd.ok) {\n working = asAdd.document;\n convertedReplaceToAdd += 1;\n continue;\n }\n }\n skippedOps += 1;\n }\n\n const candidate = working as { metadata?: unknown; body?: unknown };\n const document: ReplayDocument = {\n metadata:\n typeof candidate.metadata === \"object\" && candidate.metadata !== null\n ? (candidate.metadata as Record<string, unknown>)\n : {},\n body: typeof candidate.body === \"string\" ? candidate.body : current.body,\n };\n return { document, convertedReplaceToAdd, skippedOps };\n}\n\n/** Documents the reanchor entry detail payload exchanged by command, SDK, and package integrations. */\nexport interface ReanchorEntryDetail {\n /** Value that configures or reports index for this contract. */\n index: number;\n /** Value that configures or reports rehashed for this contract. */\n rehashed: boolean;\n /** Value that configures or reports patch repaired for this contract. */\n patch_repaired: boolean;\n /** Value that configures or reports converted replace to add for this contract. */\n converted_replace_to_add: number;\n /** Value that configures or reports skipped ops for this contract. */\n skipped_ops: number;\n}\n\n/** Documents the reanchor result payload exchanged by command, SDK, and package integrations. */\nexport interface ReanchorResult {\n /** Value that configures or reports entries for this contract. */\n entries: HistoryEntry[];\n /** Value that configures or reports final document for this contract. */\n finalDocument: ReplayDocument;\n /** Value that configures or reports entries rehashed for this contract. */\n entriesRehashed: number;\n /** Value that configures or reports entries patch repaired for this contract. */\n entriesPatchRepaired: number;\n /** Value that configures or reports converted replace to add for this contract. */\n convertedReplaceToAdd: number;\n /** Value that configures or reports skipped ops for this contract. */\n skippedOps: number;\n /** Value that configures or reports details for this contract. */\n details: ReanchorEntryDetail[];\n}\n\n/** Re-anchor a drifted history chain: replay every entry from empty, recompute the before/after hashes, and only rewrite a patch when the original op set no longer strictly applies (legacy drift). Clean entries keep their patch verbatim so the on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain. */\nexport function reanchorHistoryEntries(\n entries: HistoryEntry[],\n): ReanchorResult {\n let replay = cloneEmptyReplayDocument();\n const rewritten: HistoryEntry[] = [];\n const details: ReanchorEntryDetail[] = [];\n let entriesRehashed = 0;\n let entriesPatchRepaired = 0;\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n const beforeHash = replayHash(replay);\n const strict = tryApplyReplayPatch(replay, entry.patch);\n\n let next: ReplayDocument;\n let outPatch: HistoryPatchOp[];\n let patchRepaired = false;\n let entryConverted = 0;\n let entrySkipped = 0;\n\n if (strict.ok) {\n next = strict.document;\n outPatch = entry.patch;\n } else {\n const lenient = lenientApplyReplayPatch(replay, entry.patch);\n next = lenient.document;\n outPatch = jsonPatch.compare(replay, next) as HistoryPatchOp[];\n patchRepaired = true;\n entryConverted = lenient.convertedReplaceToAdd;\n entrySkipped = lenient.skippedOps;\n convertedReplaceToAdd += entryConverted;\n skippedOps += entrySkipped;\n entriesPatchRepaired += 1;\n }\n\n const afterHash = replayHash(next);\n const rehashed =\n beforeHash !== entry.before_hash || afterHash !== entry.after_hash;\n if (rehashed) {\n entriesRehashed += 1;\n }\n\n rewritten.push({\n ...entry,\n patch: outPatch,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n details.push({\n index: index + 1,\n rehashed,\n patch_repaired: patchRepaired,\n converted_replace_to_add: entryConverted,\n skipped_ops: entrySkipped,\n });\n replay = next;\n }\n\n return {\n entries: rewritten,\n finalDocument: replay,\n entriesRehashed,\n entriesPatchRepaired,\n convertedReplaceToAdd,\n skippedOps,\n details,\n };\n}\n\n/** Implements history entries to raw for the public runtime surface of this module. */\nexport function historyEntriesToRaw(entries: HistoryEntry[]): string {\n if (entries.length === 0) {\n return \"\";\n }\n return `${entries.map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAKA,OAAO,eAAe;;;;;;;;AAkCf,IAAM,wBAAwC;EACnD,UAAU,CAAA;EACV,MAAM;;AAIF,SAAU,2BAAwB;AACtC,SAAO,gBAAgB,qBAAqB;AAC9C;AAGM,SAAU,WAAW,UAAwB;AACjD,MAAI;AACF,WAAO,aAAa,qBAAqB,QAAQ,CAAC;EACpD,QAAQ;AAON,WAAO,UACL,gBAAgB;MACd,iBAAiB;MACjB,UAAU,SAAS;MACnB,MAAM,SAAS;KAChB,CAAC;EAEN;AACF;AAGM,SAAU,qBAAqB,UAAwB;AAC3D,SAAO;IACL,UAAU,SAAS;IACnB,MAAM,SAAS;;AAEnB;AAGM,SAAU,8BACd,UACA,UAAmD,CAAA,GAAE;AAErD,SAAO,kBAAkB,qBAAqB,QAAQ,GAAG,OAAO;AAClE;AAGM,SAAU,iBAAiB,UAAsB;AACrD,MAAI,CAAC,SAAS,YAAY,OAAO,KAAK,SAAS,QAAQ,EAAE,WAAW,GAAG;AACrE,WAAO;MACL,UAAU,CAAA;MACV,MAAM,SAAS,QAAQ;;EAE3B;AACA,QAAM,YAAY,kBAAkB,QAAQ;AAC5C,SAAO;IACL,UAAU,YACR,aAAa,UAAU,QAAQ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